Commit c76d12b6 authored by Jean-Paul Saman's avatar Jean-Paul Saman

import of helpdesk module version 0.8

parents
<?php /* HELPDESK $Id$ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
include_once 'helpdesk.functions.php';
global $HELPDESK_CONFIG;
$AppUI->loadCalendarJS();
$item_id = (int) w2PgetParam($_GET, 'item_id', 0);
$projects = getAllowedProjectsForJavascript(1);
$allowedProjects=getAllowedProjects(0,1);
$proj_ids=array();
foreach ($allowedProjects as $proj) {
$proj_ids[]=$proj['project_id'];
}
$tasks = getAllowedTasksForJavascript($proj_ids,1);
$ict = w2PgetSysVal( 'HelpDeskCallType' );
$ics = w2PgetSysVal( 'HelpDeskSource' );
$ios = w2PgetSysVal( 'HelpDeskService' );
$iap = w2PgetSysVal( 'HelpDeskApplic' );
$ipr = w2PgetSysVal( 'HelpDeskPriority' );
$isv = w2PgetSysVal( 'HelpDeskSeverity' );
$ist = w2PgetSysVal( 'HelpDeskStatus' );
$isa = w2PgetSysVal( 'HelpDeskAuditTrail' );
$helpdesk = new CHelpDesk();
$helpdesk->load($item_id);
$q = new w2p_Database_Query;
$q->addQuery('*');
$q->addTable('helpdesk_items');
$q->addWhere('item_id = ' .$item_id);
$hditem = $q->loadHash();
// Check permissions for this record
if ($item_id) {
// Already existing item
$canEdit = $perms->checkModule($m, 'edit') && hditemEditable($hditem);
} else {
$canEdit = $perms->checkModule($m, 'add');
}
if (!$canEdit) {
$AppUI->redirect(ACCESS_DENIED);
}
// Use new default 'assigned to' ---KZHAO
if (!@$hditem["item_assigned_to"]) {
if ($HELPDESK_CONFIG['default_assigned_to_current_user']=='-1') {
@$hditem["item_assigned_to"] = 0;
if (!@$hditem["item_status"]) {
@$hditem["item_status"]=0;
}
} elseif ($HELPDESK_CONFIG['default_assigned_to_current_user']=='0') {
@$hditem["item_assigned_to"] = $AppUI->user_id;
if (!@$hditem["item_status"]) {
@$hditem["item_status"]=1;
}
} else {
@$hditem["item_assigned_to"] = $HELPDESK_CONFIG['default_assigned_to_current_user'];
if (!@$hditem["item_status"]) {
@$hditem["item_status"]=1;
}
}
}
if (!@$hditem["item_company_id"] && $HELPDESK_CONFIG['default_company_current_company']) {
@$hditem["item_company_id"] = $AppUI->user_company;
}
$itemtitleprefix = $HELPDESK_CONFIG['new_hd_item_title_prefix'];
// KZHAO : 8-8-2006
// get current user's company id and use it to filter users
$q = new w2p_Database_Query;
$q->addQuery('DISTINCT cn.contact_company,cp.company_name');
$q->addTable('contacts','cn');
$q->addTable('users','u');
$q->addJoin('companies','cp','cn.contact_company=cp.company_id');
$q->addWhere('u.user_id=' . $AppUI->user_id . ' AND u.user_contact=cn.contact_id ');
$allowedComp = $q->loadHashList();
if (!count($allowedComp)) {
echo "ERROR: No company found for current user!!<br>";
$compId=0;
} elseif (count($allowedComp)==1) {
$tmp=array_keys($allowedComp);
$compId=$tmp[0];
if ($HELPDESK_CONFIG['default_company_current_company']) {
$allowedCompanies = arrayMerge( $allowedComp, array( 0 => '' ));
} else {
$allowedCompanies = arrayMerge( array( 0 => '' ), $allowedComp );
}
$allowedCompanies = arrayMerge( $allowedCompanies, getAllowedCompanies() );
} else {
echo "ERROR: Multiple companies found for current user!!!<br>";
$compId=0;
}
// Determine whether current user is a client
if ($compId!=$HELPDESK_CONFIG['the_company']) {
$client_disable=' disabled ';
} else {
$client_disable=' ';
}
// setup contact list for javascript
$q = new w2p_Database_Query;
$q->addQuery('c.contact_id,u.user_id, contact_email, contact_phone,
CONCAT_WS(\' \',c.contact_first_name, c.contact_last_name) as full_name');
$q->addTable('contacts','c');
$q->addJoin('users','u','c.contact_id=u.user_contact');
$list = $q->loadList();
foreach ($list as $row) {
$contacts[] = "[{$row['contact_id']},{$row['user_id']},'" . addslashes($row['full_name']) . "', '" . addslashes($row['contact_email']) . "','" . addslashes($row['contact_phone']) . "']";
}
$users = getAllowedUsers($compId,1);
//Use new watcher list --KZHAO
if ($item_id) {
// if editing an existing helpdesk item, get its watchers from database
$q = new w2p_Database_Query;
$q->addQuery('helpdesk_item_watchers.user_id, contact_email,
CONCAT(contact_first_name, \' \',contact_last_name) as name');
$q->addTable('helpdesk_item_watchers');
$q->addJoin('users','','helpdesk_item_watchers.user_id = users.user_id');
$q->addJoin('contacts','c','user_contact = contact_id');
$q->addWhere('item_id = ' . $item_id );
$q->addOrder('contact_last_name, contact_first_name');
$watchers = $q->loadHashList();
} else { // for a new item, check default
$q = new w2p_Database_Query;
$q->addQuery('max(item_id)');
$q->addTable('helpdesk_items');
$new_item_id = $q->loadResult()+1;
if ($HELPDESK_CONFIG['default_watcher'] && $HELPDESK_CONFIG['default_watcher_list']) {
$watchers = explode(',',$HELPDESK_CONFIG['default_watcher_list']);
}
}
// Setup the title block
$ttl = $item_id ? 'Editing Help Desk Item' : 'Adding Help Desk Item';
$titleBlock = new w2p_Theme_TitleBlock( $ttl, 'helpdesk.png', $m, "$m.$a" );
$titleBlock->addCrumb( "?m=helpdesk", 'home' );
$titleBlock->addCrumb( "?m=helpdesk&a=list", 'list');
if ($item_id) {
$titleBlock->addCrumb( "?m=helpdesk&a=view&item_id=$item_id", 'view this item' );
}
$titleBlock->show();
if ($item_id) {
$df = $AppUI->getPref('SHDATEFORMAT');
$tf = $AppUI->getPref('TIMEFORMAT');
$item_date = new w2p_Utilities_Date( $hditem["item_created"] );
$deadline_date = intval($hditem["item_deadline"]) ?
new w2p_Utilities_Date($hditem["item_deadline"]) : new w2p_Utilities_Date();
$tc = $item_date->format( "$df $tf" );
} else {
$item_date = new w2p_Utilities_Date();
$deadline_date = new w2p_Utilities_Date();
$item_date = $item_date->format( FMT_DATETIME_MYSQL );
$hditem["item_created"] = $item_date;
}
?>
<script src="./lib/jquery/jquery.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
function submitIt()
{
var f = document.frmHelpDeskItem;
var msg = '';
if (f.item_title.value.length < 1) {
msg += "\n<?php echo $AppUI->_('Title'); ?>";
f.item_title.focus();
}
if (f.item_requestor.value.length < 1) {
msg += "\n<?php echo $AppUI->_('Requestor'); ?>";
f.item_requestor.focus();
}
if (f.item_summary.value.length < 1) {
msg += "\n<?php echo $AppUI->_('Summary'); ?>";
f.item_summary.focus();
}
//concat all the multiselect values together for easier retrieval on the back end.
var watchers = "";
var list = f.watchers_select;
for (var i=0, n = list.options.length; i < n; i++) {
var user = list.options[i];
if(user.selected)
watchers += user.value + ",";
}
if (watchers.length>0) {
f.watchers.value = watchers.substring(0,watchers.length-1);
}
if (msg.length > 0) {
alert('<?php echo $AppUI->_('helpdeskSubmitError', UI_OUTPUT_JS); ?>:' + msg);
} else {
f.submit();
}
}
function popContactDialog()
{
<?php
print "\nvar company_id = ";
print $compId . ";";
?>
var selected_contacts_id = $('item_requestor_id').value;
// J: fix error populating ticket
if (selected_contacts_id == undefined) {selected_contacts_id=""};
//
window.open('./index.php?m=public&a=contact_selector&dialog=1&call_back=setRequestor&selected_contacts_id='+selected_contacts_id+'&company_id='+company_id, 'contacts','height=600,width=400,resizable,scrollbars=yes');
}
var oldRequestor = '';
<?php
print "\nvar contacts = new Array(";
if ($contacts) {
print implode(",",$contacts );
}
print ");";
?>
// Callback function for the generic selector
function setRequestor(key, uid)
{
var f = document.frmHelpDeskItem;
var keyrray = key.split(',');
f.item_requestor.value = '';
f.item_requestor_email.value = '';
f.item_requestor_phone.value = '';
if (key=='') {
keyrray[0] = <?php echo $AppUI->user_id; ?>;
}
f.item_requestor_id.value = keyrray[0];
//do lookup
$.ajax({
type: 'POST',
url: 'index.php?m=helpdesk',
data: { dosql: 'do_contact_lookup',
suppressHeaders: '1', contact_id: keyrray[0]},
success: function (response) {
var values = response.split('||');
f.item_requestor.value = values[0];
f.item_requestor_phone.value = values[1];
f.item_requestor_email.value = values[2];
}
});
}
function updateStatus(obj)
{
var f = document.frmHelpDeskItem;
if (obj.options[obj.selectedIndex].value>0) {
if (f.item_status.selectedIndex==0) {
f.item_status.selectedIndex=1;
}
}
}
<?php
$ua = $_SERVER['HTTP_USER_AGENT'];
$isMoz = strpos( $ua, 'Gecko' ) !== false;
print "\nvar projects = new Array(";
if ($projects) {
print implode(",",$projects );
}
print ");";
print "\nvar tasks = new Array(";
if ($tasks) {
print implode(",",$tasks );
}
print ");";
?>
// Dynamic project list handling functions
function emptyList(list)
{
<?php
if ($isMoz) {
?>
list.options.length = 0;
<?php
} else {
?>
while( list.options.length > 0 )
list.options.remove(0);
<?php } ?>
}
function addToList(list, text, value)
{
<?php if ($isMoz) { ?>
list.options[list.options.length] = new Option(text, value);
<?php } else { ?>
var newOption = document.createElement("OPTION");
newOption.text = text;
newOption.value = value;
list.add( newOption, 0 );
<?php } ?>
}
function changeList(listName, source, target)
{
var f = document.frmHelpDeskItem;
var list = eval( "f."+listName );
// Clear the options
emptyList( list );
// Refill the list based on the target
// Add a blank first to force a change
addToList( list, '', '0' );
for (var i=0, n = source.length; i < n; i++) {
if (source[i][0] == target) {
addToList( list, source[i][2], source[i][1] );
}
}
}
// Select an item in the list by target value
function selectList(listName, target)
{
var f = document.frmHelpDeskItem;
var list = eval( 'f.'+listName );
for (var i=0, n = list.options.length; i < n; i++) {
if (list.options[i].value == target) {
list.options.selectedIndex = i;
return;
}
}
}
<!-- TIMER RELATED SCRIPTS -->
function setDate(frm_name, f_date)
{
fld_date = eval( 'document.' + frm_name + '.' + f_date );
fld_real_date = eval( 'document.' + frm_name + '.' + 'item_' + f_date );
if (fld_date.value.length>0) {
if ((parseDate(fld_date.value))==null) {
alert('The Date/Time you typed does not match your prefered format, please retype.');
fld_real_date.value = '';
fld_date.style.backgroundColor = 'red';
} else {
fld_real_date.value = formatDate(parseDate(fld_date.value), 'yyyyMMdd');
fld_date.value = formatDate(parseDate(fld_date.value), '<?php echo $cal_sdf ?>');
fld_date.style.backgroundColor = '';
}
} else {
fld_real_date.value = '';
}
}
</script>
<!-- END OF TIMER RELATED SCRIPTS -->
<form name="frmHelpDeskItem" action="?m=helpdesk" method="post" enctype="multipart/form-data">
<input type="hidden" name="dosql" value="do_item_aed" />
<input name="del" type="hidden" value="0" />
<input type="hidden" name="item_id" value="<?php echo $item_id; ?>" />
<input type="hidden" name="item_requestor_type" value="<?php echo @$hditem["item_requestor_type"]; ?>" />
<input type="hidden" name="item_requestor_id" id="item_requestor_id" value="<?php echo @$hditem["item_requestor_id"]; ?>" />
<input type="hidden" name="item_created" value="<?php echo @$hditem["item_created"]; ?>" />
<?php if (!$item_id): ?>
<input type="hidden" name="item_created_by" value="<?php echo $AppUI->user_id; ?>" />
<?php endif; ?>
<table cellspacing="1" cellpadding="1" border="0" width="100%" class="std">
<tr>
<td valign="top" width="50%">
<table cellspacing="0" cellpadding="2" border="0">
<?php if ($item_id): ?>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Date Created'); ?>:</td>
<td width="100%"><strong><?php echo $tc; ?></strong></td>
</tr>
<?php endif; ?>
<tr>
<td align="right"><font color="red"><label for="it">* <?php echo $AppUI->_('Title'); ?>:</label></font></td>
<td valign="top"><input type="text" class="text" id="it" name="item_title"
<?php if ($item_id): ?>
value="<?php echo @$hditem["item_title"]; ?>" maxlength="64"
<?php else: ?>
value="<?php printf($itemtitleprefix ,$new_item_id); ?>" maxlength="64"
<?php endif; ?> /></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><font color="red"><label for="ir">* <?php echo $AppUI->_('Requestor'); ?>:</label></font></td>
<td valign="top" nowrap="nowrap">
<input type="text" class="text" id="ir" name="item_requestor"
value="<?php echo @$hditem["item_requestor"]; ?>" maxlength="64"
onChange="if (this.value!=oldRequestor) {
document.frmHelpDeskItem.item_requestor_id.value = 0;
oldRequestor = this.value;
}" />
<input type="button" class="button"
value="<?php echo $AppUI->_('Contacts'); ?>" onclick="popContactDialog();" />
</td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><label for="ire">&dagger; <?php echo $AppUI->_('Requestor E-mail'); ?>:</label></td>
<td valign="top"><input type="text" class="text" id="ire"
name="item_requestor_email"
value="<?php echo @$hditem["item_requestor_email"]; ?>"
maxlength="64" /></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><label for="irp">&dagger; <?php echo $AppUI->_('Requestor Phone'); ?>:</label></td>
<td valign="top"><input type="text" class="text" id="irp"
name="item_requestor_phone"
value="<?php echo @$hditem["item_requestor_phone"]; ?>"
maxlength="30" /></td>
</tr>
<tr>
<td align="right"><label for="c"><?php echo $AppUI->_('Company'); ?>:</label></td>
<td><?php echo arraySelect( $allowedCompanies, 'item_company_id', 'size="1" class="text" id="c" onchange="changeList(\'item_project_id\',projects, this.options[this.selectedIndex].value)"',
@$hditem["item_company_id"] ); ?></td>
</tr>
<tr>
<td align="right"><label for="p"><?php echo $AppUI->_('Project'); ?>:</label></td>
<td><select name="item_project_id" size="1" class="text" id="p" onchange="changeList('item_task_id', tasks, this.options[this.selectedIndex].value)" value="<?php echo @$hditem["item_project_id"]; ?>">
</select></td>
</tr>
<tr>
<td align="right"><label for="p"><?php echo $AppUI->_('Task'); ?>:</label></td>
<td><select name="item_task_id" size="1" class="text" id="t" value="<?php echo @$hditem["item_task_id"]; ?>"></select></td>
</tr>
<tr>
<td align="right" valign="top"><label for="iat"><?php echo $AppUI->_('Assigned To'); ?>:</label></td>
<td><?php
echo arraySelect( arrayMerge( array( 0 => '' ), $users), 'item_assigned_to', 'size="1" class="text" id="iat" ' . $client_disable . ' onchange="updateStatus(this)"', @$hditem["item_assigned_to"] );
?></td>
</tr>
<?php if ($item_id) {
//existing item
if($hditem['item_notify']) $emailNotify=1;
else $emailNotify=0;
} else {
$emailNotify=$HELPDESK_CONFIG['default_notify_by_email'];
}
?>
<tr>
<td align="right" valign="top"><label for="iat"><?php echo $AppUI->_('Email Notification'); ?>:</label>
</td>
<td>
<input type="radio" name="item_notify" value="1" id="ina"
<?php if($emailNotify) echo "checked";
echo $client_disable; ?> />
<label for="ina"><?php echo $AppUI->_( 'Yes' ); ?></label>
<input type="radio" name="item_notify" value="0" id="inn"
<?php if(!$emailNotify) echo "checked";
echo $client_disable; ?> />
<label for="inn"><?php echo $AppUI->_( 'No' ); ?></label>
</td>
</tr>
</table>
</td>
<td valign="top" width="50%">
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td align="right" nowrap="nowrap"><label for="ict"><?php echo $AppUI->_('Call Type'); ?>:</label></td>
<td><?php echo arraySelect( $ict, 'item_calltype', 'size="1" class="text" id="ict"',
@$hditem["item_calltype"], true ); ?></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><label for="ics"><?php echo $AppUI->_('Call Source'); ?>:</label></td>
<td><?php echo arraySelect( $ics, 'item_source', 'size="1" class="text" id="ics"',
@$hditem["item_source"], true); ?></td>
</tr>
<tr>
<td align="right"><label for="ist"><?php echo $AppUI->_('Status'); ?>:</label></td>
<td><?php echo arraySelect( $ist, 'item_status', 'size="1" class="text" id="ist"' . $client_disable ,
@$hditem["item_status"], true ); ?></td>
</tr>
<tr>
<td align="right"><label for="ipr"><?php echo $AppUI->_('Priority'); ?>:</label></td>
<td><?php echo arraySelect( $ipr, 'item_priority', 'size="1" class="text" id="ipr"',
@$hditem["item_priority"], true ); ?></td>
</tr>
<tr>
<td align="right"><label for="isv"><?php echo $AppUI->_('Severity'); ?>:</label></td>
<td><?php echo arraySelect( $isv, 'item_severity', 'size="1" class="text" id="isv"',
@$hditem["item_severity"], true ); ?></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><label for="ios"><?php echo $AppUI->_('Service'); ?>:</label></td>
<td><?php echo arraySelect( $ios, 'item_service', 'size="1" class="text" id="ios"',
@$hditem["item_service"], true); ?></td>
</tr>
<tr>
<td align="right"><label for="iap"><?php echo $AppUI->_('Application'); ?>:</label></td>
<td><?php echo arraySelect( $iap, 'item_application', 'size="1" class="text" id="iap"',
@$hditem["item_application"], true); ?></td>
</tr>
<tr>
<!--
<td align="right" nowrap="nowrap"><label for="idl"><?php echo $AppUI->_('Deadline'); ?>:</label></td>
<td valign="top"><input type="text" class="text" id="idl"
name="item_deadline"
value="<?php echo "NA"/*@$hditem["item_deadline"]*/; ?>"
size="4"
maxlength="4" /><?php echo $AppUI->_('day(s) from today'); ?>
</td>
-->
<td align="right" nowrap="nowrap"><label for="idl"><?php echo $AppUI->_('Deadline'); ?>:</label> </td>
<td>
<input type="hidden" name="item_deadline" value="
<?php
if($item_id && $hditem["item_deadline"]!=NULL)
echo $deadline_date->format( FMT_DATETIME_MYSQL );
else echo "N/A";
?>">
<input type="text" name="deadline" id="deadline" onchange="setDate('frmHelpDeskItem', 'log_date');"
value=
"<?php if($item_id && $hditem['item_deadline']!=NULL) echo $deadline_date->format( $df ); else echo "Not Specified";?>"
class="text" disabled="disabled">
<a href="javascript: void(0);" onclick="return showCalendar('deadline', '<?php echo $df ?>', 'frmHelpDeskItem', null, true)">
<img src="<?php echo w2PfindImage('calendar.gif'); ?>" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?>" border="0" />
</a>
</td>
</tr>
<tr>
<td align="right"><label for="iap"><?php echo $AppUI->_('Hours Worked'); ?>:</label></td>
<td>
<input type="text" style="text-align:right" class="text" name="task_log_hours" id="task_log_hours" value="<?php echo $log->task_log_hours; ?>" maxlength="8" size="4" />
</td>
</tr>
</table>
</td>
</tr>
<tr><td colspan="2">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="left"><font color="red"><label for="summary">* <?php echo $AppUI->_('Summary'); ?>:</label></font>
</td>
<td>&nbsp;&nbsp;</td>
<td><label for="watchers"><?php echo $AppUI->_('Watchers'); ?>:</label></td>
</tr>
<tr>
<td valign="top">
<textarea id="summary" cols="75" rows="12" class="textarea"
name="item_summary"><?php echo @$hditem["item_summary"]; ?></textarea>
</td>
<td>&nbsp;&nbsp;</td>
<td>
<select name="watchers_select" size="14" id="watchers_select" multiple="multiple"
<?php if($is_client) echo "disabled class=disabledText";
else echo "class=text";
?>
>
<?php
foreach ($users as $id => $name) {
echo "<option value=\"{$id}\"";
// Two situations -- KZHAO
if($item_id && array_key_exists($id,$watchers))
echo " selected";
elseif(!$item_id && $watchers && in_array($id, $watchers))
echo " selected";
echo ">{$name}</option>";
}
?></select>
<input type="hidden" name="watchers" value="" /></td>
</tr>
<!--Kang: file attachment-->
<tr>
<td align="left"><?php echo $AppUI->_("Attach a file"); ?>
<input type="File" name="hdfile" />
</td>
</tr>
</table>
</td></tr>
<!--commented by KZHAO 7-20-2006
code dealing with hours worked and cost code
-->
<tr>
<td colspan="2">
<br />
<small>
<font color="red">* <?php echo $AppUI->_('Required field'); ?></font><br />
&dagger; <?php echo $AppUI->_('helpdeskFieldMessage'); ?>
</small>
<br /><br />
</td>
</tr>
<tr>
<td><input type="button" value="<?php echo $AppUI->_('back'); ?>" class="button" onClick="javascript:history.back(-1);" />
</td>
<td align="right"><input type="button" value="<?php echo $AppUI->_('submit'); ?>" class="button" onClick='submitIt()' >
</td>
</tr>
</table>
</form>
<?php
/* If we have a company stored, pre-select it.
Else, select nothing */
if (@$hditem['item_company_id']) {
$target = $hditem['item_company_id'];
} elseif (@$hditem['item_project_id']) {
$target = $reverse[$hditem['item_project_id']];
} else {
$target = 0;
}
/* Select the project from the list */
$select = @$hditem['item_project_id'] ? $hditem['item_project_id'] : 0;
$select_task = @$hditem['item_task_id'] ? $hditem['item_task_id'] : 0;
?>
<script language="javascript">
<?php if (($compId!=$HELPDESK_CONFIG['the_company']) && (!$item_id) ) { ?>
setRequestor ('',<?php echo $AppUI->user_id ?> );
<?php } ?>
selectList('item_company_id',<?php echo $target?>);
changeList('item_project_id', projects, <?php echo $target?>);
selectList('item_project_id',<?php echo $select?>);
<?php if (@$hditem['item_project_id']) { ?>
changeList('item_task_id', tasks, <?php echo @$hditem['item_project_id']?>);
selectList('item_task_id',<?php echo $select_task?>);
<?php } ?>
</script>
2009-07-16 - Field "Hours worked" added to helpdesk item edit form. Can be used to log spent time when creating new item
2009-07-20 - permissions related updates
2009-07-22 - notification system redesigned to be more flexible and to minimize emails sent:
- only one email is sent when tasklog modified status/calltype/etc.
- unified email format for tasklogs and ticket modifications emails
- if ticket is created and remain Unassigned email is sent
to an address defined in helpdesk configuration in case of email notification required
- added configuration radioboxes to choose whether watchers / requestor
are notified about all logs or only about status changes (incl. requestor change & calltype change)
- emails are not sent to current user
- if ticket is created by an user from non-helpdesk company, the user is filled-in as requestor
- localization applied on notification texts ( I hope everywhere )
2009-07-24 - when adding watchers notifications were not send always correctly. Unified with another notification emails.
\ No newline at end of file
<?php /* HELPDESK $Id$ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
include_once 'helpdesk.functions.php';
/* This file will write a php config file to be included during execution of
* all helpdesk files which require the configuration options. */
// Deny all but system admins
if (!canView('system')) {
$AppUI->redirect(ACCESS_DENIED);
}
@include_once( "./functions/admin_func.php" );
$CONFIG_FILE = "./modules/helpdesk/config.php";
// get a list of permitted companies
$company = new CCompany();
$companies = $company->getAllowedRecords($AppUI->user_id, 'company_id,company_name', 'company_name');
$companies = arrayMerge(array('0' => ''), $companies);
// Get all active users -- KZHAO
$activeUsers=getAllowedUsers(0,1);
$assignUsers=arrayMerge( array(-1=>'', 0 => 'Current User' ), $activeUsers);
$utypes = w2PgetSysVal('UserType');
//define user type list
$user_types = arrayMerge( $utypes, array( '-1' => $AppUI->_('None') ) );
/* All config options, their descriptions and their default values are defined
* here. Add new config options here. Type can be "checkbox", "text", "radio" or
* "select". If the type is "radio," it must include a set of buttons. If it's
* "select" then be sure to include a 'list' entry with the options. if the key
* starts with headingXXX then it will just display the contents on the value.
* This is used for grouping.
*/
$config_options = array(
"heading1" => $AppUI->_('Paging Options'),
"items_per_page" => array(
"description" => $AppUI->_('Helpdesk Items Per Page'),
"value" => 30,
'type' => 'text'
),
"status_log_items_per_page" => array(
"description" => $AppUI->_('Helpdesk Logs Per Page'),
"value" => 15,
'type' => 'text'
),
"pages_per_side" => array(
"description" => $AppUI->_('Helpdesk Pages Per Side'),
"value" => 5,
'type' => 'text'
),
"heading2" => $AppUI->_('Permission Options'),
"the_company" => array(
"description" => $AppUI->_('Helpdesk Host Company'),
"value" => '',
'type' => 'select',
'list' => $companies
),
"no_company_editable" => array(
"description" => $AppUI->_('Allow Helpdesk Items without Company'),
"value" => '0',
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Yes'),
0 => $AppUI->_('No'))
),
'minimum_edit_level' => array(
'description' => $AppUI->_('Helpdesk Min Level'),
'value' => 9,
'type' => 'select',
'list' => @$user_types
),
"use_project_perms" => array(
"description" => $AppUI->_('Helpdesk Use Project Perms'),
"value" => '0',
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Yes'),
0 => $AppUI->_('No'))
),
'minimum_report_level' => array(
'description' => $AppUI->_('Helpdesk Min Rep Level'),
'value' => 9,
'type' => 'select',
'list' => @$user_types
),
// KZHAO: 2-6-2007
// Change/add default settings
"heading3" => $AppUI->_('New Item Default Selections'),
// MiraKlim 18.05.2009 -added format for new HD item name
"new_hd_item_title_prefix" => array(
"description" => $AppUI->_('Default item title prefix'),
"value" => 'HD-%05d',
'type' => 'text'
),
"default_assigned_to_current_user" => array(
"description" => $AppUI->_('Default Assigned To'),
"value" => '',
'type' => 'select',
'list' => $assignUsers
),
"default_company_current_company" => array(
"description" => $AppUI->_('Default Company'),
"value" => 1,
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Current User\'s Company'),
0 => $AppUI->_('None'))
),
"default_watcher" => array(
"description" => $AppUI->_('Use Default Watcher(s)'),
"value" => 0,
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Yes'),
0 => $AppUI->_('No'))
),
"default_watcher_list" => array(
"description" => $AppUI->_('Default Watchers'),
"value" => 0,
'type' => 'multiselect',
'list' => $activeUsers
),
"heading4" => $AppUI->_('Search Fields On Item List'),
"search_criteria_search" => array(
"description" => $AppUI->_('Title/Summary Search'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_call_type" => array(
"description" => $AppUI->_('Call Type'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_company" => array(
"description" => $AppUI->_('Company'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_status" => array(
"description" => $AppUI->_('Status'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_call_source" => array(
"description" => $AppUI->_('Call Source'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_project" => array(
"description" => $AppUI->_('Project'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_assigned_to" => array(
"description" => $AppUI->_('Assigned To'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_priority" => array(
"description" => $AppUI->_('Priority'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_application" => array(
"description" => $AppUI->_('Application'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_requestor" => array(
"description" => $AppUI->_('Requestor'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_severity" => array(
"description" => $AppUI->_('Severity'),
"value" => 1,
'type' => 'checkbox'
),
"search_criteria_service" => array(
"description" => $AppUI->_('Service'),
"value" => 1,
'type' => 'checkbox'
),
//KZHAO 9-12-2006
// Configurable fields for email notification
"heading5" => $AppUI->_('Notification Email Options'),
"default_notify_by_email" => array(
"description" => $AppUI->_('Email notification as default for new item'),
"value" => 1,
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Yes'),
0 => $AppUI->_('No'))
),
"task_watchers_notification" => array(
"description" => $AppUI->_('Watchers notification'),
"value" => 1,
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Always'),
0 => $AppUI->_('Status change'))
),
"task_requestor_notification" => array(
"description" => $AppUI->_('Requestor notification'),
"value" => 1,
'type' => 'radio',
'buttons' => array (1 => $AppUI->_('Always'),
0 => $AppUI->_('Status change'))
),
"notity_email_address" => array(
"description" => $AppUI->_('New unassigned items notification address'),
"value" => 'support@yourcompany.com',
'type' => 'text'
),
"email_subject" => array(
"description" => $AppUI->_('Email subject (trailed by ticket number)'),
"value" => 'The Company registered your recent request',
'type' => 'text'
),
"email_header" => array(
"description" => $AppUI->_('Email header'),
"value" => 'The Company Ticket Management Registry',
'type' => 'text'
)
);
//if this is a submitted page, overwrite the config file.
if(w2PgetParam( $_POST, "Save", '' )!=''){
if (is_writable($CONFIG_FILE)) {
if (!$handle = fopen($CONFIG_FILE, 'w')) {
$AppUI->setMsg( $CONFIG_FILE." ".$AppUI->_('cannot be opened'), UI_MSG_ERROR );
exit;
}
if (fwrite($handle, "<?php //Do not edit this file by hand, it will be overwritten by the configuration utility. \n") === FALSE) {
$AppUI->setMsg( $CONFIG_FILE." ".$AppUI->_('cannot be written to'), UI_MSG_ERROR );
exit;
} else {
foreach ($config_options as $key=>$value){
if(substr($key,0,7)=='heading') continue;
$val="";
switch($value['type']){
case 'checkbox':
$val = isset($_POST[$key])?"1":"0";
break;
case 'text':
$val = isset($_POST[$key])?$_POST[$key]:"";
break;
case 'select':
$val = isset($_POST[$key])?$_POST[$key]:"0";
break;
case 'multiselect':
if(isset($_POST[$key])){
foreach ($_POST[$key] as $idx=>$watcher){
$val .= $watcher.",";
}
$val=trim($val,',');
}
else $val=0;
break;
case 'radio':
$val = $_POST[$key];
break;
default:
break;
}
fwrite($handle, "\$HELPDESK_CONFIG['".$key."'] = '".$val."';\n");
}
fwrite($handle, "?>\n");
$AppUI->setMsg( $CONFIG_FILE." ".$AppUI->_('has been successfully updated'), UI_MSG_OK );
fclose($handle);
require( $CONFIG_FILE );
}
} else {
$AppUI->setMsg( $CONFIG_FILE." ".$AppUI->_('is not writable'), UI_MSG_ERROR );
}
} else if(w2PgetParam( $_POST, $AppUI->_('cancel'), '' )!=''){
$AppUI->redirect("m=system&a=viewmods");
}
//$HELPDESK_CONFIG = array();
require_once( $CONFIG_FILE );
//Read the current config values from the config file and update the array.
foreach ($config_options as $key=>$value){
if(isset($HELPDESK_CONFIG[$key])){
$config_options[$key]['value']=$HELPDESK_CONFIG[$key];
}
}
// setup the title block
$titleBlock = new w2p_Theme_TitleBlock( 'Configure Help Desk Module', 'helpdesk.png', $m, "$m.$a" );
$titleBlock->addCrumb( "?m=system", "System Admin" );
$titleBlock->addCrumb( "?m=system&a=viewmods", "Modules" );
$titleBlock->show();
?>
<script language = 'javascript' type='text/javascript'>
function enableWatcherList(show){
var useDefWatcher=document.getElementById('default_watcher');
var WatcherList=document.getElementById('default_watcher_list[]');
if(show){
document.getElementById('default_watcher_list[]').disabled=false;
document.getElementById('default_watcher_list[]').className='text';
}
else{
document.getElementById('default_watcher_list[]').disabled=true;
document.getElementById('default_watcher_list[]').className='disabledText';
}
}
</script>
<form method="post">
<table class="std">
<?php
$useDefWatcher=0;
foreach ($config_options as $key=>$value){
?>
<tr>
<?php
// the key starts with hr, then just display the value
if(substr($key,0,7)=='heading'){ ?>
<th align="center" colspan="2"><?php echo $value?></th>
<?php } else { ?>
<td align="right"><?php echo $value['description']?></td>
<td><?php
switch($value['type']){
case 'checkbox': ?>
<input type="checkbox" name="<?php echo $key?>" <?php echo $value['value']?"checked=\"checked\"":""?>>
<?php
break;
case 'text': ?>
<input type="text" name="<?php echo $key?>" value="<?php echo $value['value']?>" size=32>
<?php
break;
case 'select':
print arraySelect( $value["list"], $key, 'class="text" size="1" id="' . $key . '" ' . $value["events"], $value["value"] );
break;
case 'multiselect':
?>
<select name=<?php echo $key.'[]';
if($useDefWatcher)
echo " class='text'";
else
echo " class='disabledText' Disabled ";
?>
multiple="multiple" size="5" bgcolor=#ddd id=<?php echo $key.'[]'; ?>>
<?php
// organize string '118,72,2,68' into array
$selected=explode(',',$value["value"]);
foreach ( $value["list"] as $k => $v ) {
echo "\n\t<option value=\"".$k."\"".(in_array($k, $selected) ? " selected=\"selected\"" : '').">" . $v . "</option>";
}
?>
</select>
<?php
break;
case 'radio':
if($value['value']) $useDefWatcher=1;
else $useDefWatcher=0;
foreach ($value['buttons'] as $v => $n) {
if($key=='default_watcher'){ ?>
<label><input type="radio" name="<?php echo $key; ?>" id="<?php echo $key; ?>"
value=<?php echo $v; ?>
<?php echo (($value['value'] == $v)?"checked":""); ?> <?php echo $value['events']; ?> onClick=enableWatcherList(<?php echo $v; ?>)> <?php echo $n;?></label>
<?php }
else {?>
<label><input type="radio" name="<?php echo $key; ?>" id="<?php echo $key; ?>" value=<?php echo $v; ?> <?php echo (($value['value'] == $v)?"checked":""); ?> <?php echo $value['events']; ?>> <?php echo $n;?></label>
<?php }
}
break;
default:
break;
}
?></td>
<?php
}
?>
</tr>
<?php
}
?>
<tr>
<td colspan="2" align="right"><input type="Submit" name="Cancel" value="<?php echo $AppUI->_('back')?>">
<input type="Submit" name="Save" value="<?php echo $AppUI->_('save')?>"></td>
</tr>
</table>
</form>
<?php
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
global $AppUI;
/*
* This is a horrible ugly hack.. we need to rethink how we do contact lookups, etc.
*
*/
$contact_id = (int) w2PgetParam( $_POST, 'contact_id', 0 );
$helpdesk = new CHelpDesk();
echo $helpdesk->lookup_contact($contact_id);
die();
<?php /* HELPDESK $Id$ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
$del = w2PgetParam($_POST, 'del', 0);
$isNotNew = $_POST['task_log_id'];
$perms = &$AppUI->acl();
if ($del) {
if (!$perms->checkModule('task_log', 'delete')) {
$AppUI->redirect(ACCESS_DENIED);
}
} elseif ($isNotNew) {
if (!$perms->checkModule('task_log', 'edit')) {
$AppUI->redirect(ACCESS_DENIED);
}
} else {
if (!$perms->checkModule('task_log', 'add')) {
$AppUI->redirect(ACCESS_DENIED);
}
}
$obj = new CTask_Log();
if (!$obj->bind($_POST)) {
$AppUI->setMsg($obj->getError(), UI_MSG_ERROR);
$AppUI->redirect();
}
$redir='m=helpdesk&a=view&tab=0&item_id=' . $obj->task_log_help_desk_id;
$AppUI->setMsg('Task Log');
if ($del) {
if (($msg = $obj->delete())) {
$AppUI->setMsg($msg, UI_MSG_ERROR);
} else {
$AppUI->setMsg('deleted', UI_MSG_ALERT);
}
}
$AppUI->redirect($redir);
<?php /* HELPDESK $Id$ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
global $HELPDESK_CONFIG, $w2Pconfig;
global $field_event_map,$ist,$ict;
$del = (int) w2PgetParam( $_POST, 'del', 0 );// the last parameter is the default value
$item_id = (int) w2PgetParam( $_POST, 'item_id', 0 );
$do_task_log = w2PgetParam( $_POST, 'task_log', 0 );
$deadline=w2PgetParam( $_POST, 'item_deadline', 0 );
$new_item = !($item_id>0);
$updated_date = new w2p_Utilities_Date();
$update = $updated_date->format( FMT_DATETIME_MYSQL );
$notify_all = isset($_POST['item_notify']) ? w2PgetParam( $_POST,'item_notify',0) : $HELPDESK_CONFIG['default_notify_by_email'];
if ($do_task_log) { // called from HD task log
//first update the status on to current helpdesk item.
$hditem = new CHelpDesk();
$hditem->load( $item_id );
$hditem->item_updated = $update;
$new_status = w2PgetParam( $_POST, 'item_status', 0 );
$new_calltype = w2PgetParam( $_POST, 'item_calltype', 0 );
$new_assignee = w2PgetParam( $_POST, 'item_assigned_to', 0 );
$users = getAllowedUsers();
$log_status_msg='';
$update_item = false;
if ($new_status!=$hditem->item_status) {
$status_msg = $hditem->log_status(11,$AppUI->_($ist[$hditem->item_status]),$AppUI->_($ist[$new_status]));
$log_status_msg .= $status_msg . "\n";
$hditem->item_status = $new_status;
$update_item = true;
}
if ($new_calltype!=$hditem->item_calltype) {
$status_msg = $hditem->log_status(9,$AppUI->_($ict[$hditem->item_calltype]),$AppUI->_($ict[$new_calltype]));
$log_status_msg .= $status_msg . "\n";
$hditem->item_calltype = $new_calltype;
$update_item = true;
}
if ($new_assignee!=$hditem->item_assigned_to) {
$status_msg = $hditem->log_status(5,$AppUI->_($users[$hditem->item_assigned_to]),$AppUI->_($users[$new_assignee]));
$log_status_msg .= $status_msg . "\n";
$hditem->item_assigned_to = $new_assignee;
$update_item = true;
}
if ($update_item) {
if (!$hditem->store()) {
$AppUI->setMsg( $hditem->getError(), UI_MSG_ERROR );
$AppUI->redirect('m=helpdesk&a=view&item_id=' . $hditem->item_id);
}
}
//then create/update the task log
$obj = new CTask_Log();
if (!$obj->bind( $_POST )) {
$AppUI->setMsg( $obj->getError(), UI_MSG_ERROR );
$AppUI->redirect('m=helpdesk&a=view&item_id=' . $hditem->item_id);
}
if ($obj->task_log_date) {
$date = new w2p_Utilities_Date($obj->task_log_date . date('Hi'));
$obj->task_log_date = $date->format( FMT_DATETIME_MYSQL );
}
$AppUI->setMsg('Task Log');
$obj->task_log_costcode = $obj->task_log_costcode;
if (!$obj->store()) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
$AppUI->redirect('m=helpdesk&a=view&item_id=' . $hditem->item_id);
} else {
$body = $AppUI->_('Summary') . " : " . $obj->task_log_name . "\n";
$body .= $AppUI->_('Description') . " : \n" . $obj->task_log_description . "\n";
if ($log_status_msg) {
$body .= "\n" . $AppUI->_('Updates') . " : \n" . $log_status_msg;
$hditem->notifymsg(STATUSTASK_LOG, $body);
} else {
$hditem->notifymsg(TASK_LOG, $body);
}
if ($AppUI->msgNo != UI_MSG_ERROR) {
$AppUI->setMsg( @$_POST['task_log_id'] ? 'updated' : 'added', UI_MSG_OK, true );
}
}
$AppUI->redirect("m=helpdesk&a=view&item_id=$item_id&tab=0");
} else { // for creating or editting Helpdesk items
$hditem = new CHelpDesk();
if ( !$hditem->bind( $_POST )) {
$AppUI->setMsg( $hditem->error, UI_MSG_ERROR );
$AppUI->redirect('m=helpdesk&a=view&item_id=' . $hditem->item_id);
}
$AppUI->setMsg( 'Help Desk Item', UI_MSG_OK );
if ($del) {// to delete an item
$hditem->load( $item_id );
$hditem->item_updated = $udate;
if (!$hditem->store()) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
$AppUI->redirect();
}
if ($hditem->delete()) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
} else {
$AppUI->setMsg( 'deleted', UI_MSG_OK, true );
$hditem->log_status(18,'Item '.$AppUI->_('Deleted'),1);
$AppUI->redirect('m=helpdesk&a=list');
}
} else { // edit or new
if ($new_item) {
$item_date = new w2p_Utilities_Date();
$idate = $item_date->format( FMT_DATETIME_MYSQL );
$hditem->item_created = $idate;
$hditem->item_updated = $udate;
$hditem->item_notify = $notify_all;
} else {
$hditem->item_notify = $notify_all;
$hditem->item_updated = $udate;
$status_log_msg = $hditem->log_status_changes();
}
//KZHAO 8-10-2006
// get the deadline for the HD item
$dl = ((int) $deadline) ? new w2p_Utilities_Date($deadline) : new w2p_Utilities_Date();
$dl->setTime(23,59,59);
$hditem->item_deadline = $dl->format( FMT_DATETIME_MYSQL );
// Kang: 3-15-2007
// file uploading
if (isset( $_FILES['hdfile']) && isset($_FILES['hdfile']['name']) && $_FILES['hdfile']['name']!='') {
$file_obj = new CFile();
$file_info=array();
$acl =& $AppUI->acl();
if ( ! $acl->checkModule('files', 'add')) {
$AppUI->setMsg($AppUI->_( "noDeletePermission" ));
$AppUI->redirect(ACCESS_DENIED);
}
$file_obj->_message = 'added';
$file_info['file_version'] = 1.0;
$file_info['file_category'] = 0;
$file_info['file_parent'] = 0;
$file_info['file_project'] = $hditem->item_project_id;
if (!$new_item) {
$file_info['file_description'] = $AppUI->_('This file is associated with helpdesk item') . ' ' .$hditem->item_id . ' ('. $hditem->item_title . ')';
$file_info['file_helpdesk_item'] = $hditem->item_id;
}
$file_info['file_owner']=$AppUI->user_id;
if (!$file_obj->bind( $file_info )) {
$AppUI->setMsg( $file_obj->getError(), UI_MSG_ERROR );
$AppUI->redirect();
}
$upload=null;
$upload = $_FILES['hdfile'];
if ($upload['size'] < 1) {
if (!$file_id) {
$AppUI->setMsg( 'Upload file size is zero. Process aborted.', UI_MSG_ERROR );
$AppUI->redirect('m=helpdesk&a=view&item_id='.$hditem->item_id);
}
} else {
// store file with a unique name
$file_obj->file_name = $upload['name'];
$file_obj->file_type = $upload['type'];
$file_obj->file_size = $upload['size'];
$file_obj->file_date = str_replace("'", '', $db->DBTimeStamp(time()));
$file_obj->file_real_filename = uniqid( rand() );
$res = $file_obj->moveTemp( $upload );
if (!$res) {
$AppUI->setMsg( 'File could not be written', UI_MSG_ERROR );
$AppUI->redirect();
}
}
if (! $file_obj->file_version_id) {
$q = new w2p_Database_Query;
$q->addTable('files');
$q->addQuery('file_version_id');
$q->addOrder('file_version_id DESC');
$q->setLimit(1);
$sql = $q->prepare();
$latest_file_version = $q->loadResult($sql);
$file_obj->file_version_id = $latest_file_version + 1;
}
if (($msg = $file_obj->store()) !== true) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
}
// add the link of the file to the description of the helpdesk item
$hd_file_info="\n------------------\n" . $AppUI->_('Associated File Name:'). ' '.$file_obj->file_name;
$hd_file_info.=" Link: ".$w2Pconfig['base_url']."/fileviewer.php?file_id=".$file_obj->file_id;
$hd_file_info.="\n------------------\n";
$hditem->item_summary=$hditem->item_summary . $hd_file_info;
}// end of file uploading
if (!$hditem->store()) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
} else {
if ($new_item) {
// new item creation
$status_log_msg = $hditem->log_status(0,$AppUI->_('Ticket').' '.$AppUI->_('Created'),'',1);
//Lets create a log for the item creation:
$obj = new CHelpDesk();
$new_item_log = array('task_log_id' => 0,'task_log_help_desk_id' => $hditem->item_id, 'task_log_creator' => $AppUI->user_id, 'task_log_name' => 'Item Created: '.$_POST['item_title'], 'task_log_date' => $hditem->item_created, 'task_log_description' => $_POST['item_title'], 'task_log_hours' => $_POST['task_log_hours'], 'task_log_costcode' => $_POST['task_log_costcode']);
if (!$obj->bind( $new_item_log )) {
$AppUI->setMsg( $obj->getError(), UI_MSG_ERROR );
$AppUI->redirect();
}
if (($msg = $obj->store()) !== true) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
$AppUI->redirect();
}
// Generate the description for attached file
if ($file_obj) {
$file_obj->file_description = $AppUI->_('This file is associated with helpdesk item') . ' ' .$hditem->item_id . ' ('. $hditem->item_title . ')';
$file_obj->file_helpdesk_item=$hditem->item_id;
if (($msg = $file_obj->store()) !== true) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
}
}
}
// KZHAO 8-7-2006
doWatchers(w2PgetParam( $_POST, 'watchers', 0 ), $hditem, $notify_all);
// KZHAO 8-7-2006
if ($AppUI->msgNo != UI_MSG_ERROR) {
$AppUI->setMsg( $new_item ? ($AppUI->_('Help Desk Item') .' '. $AppUI->_('added')) : ($AppUI->_('Help Desk Item') . ' ' . $AppUI->_('updated')) , UI_MSG_OK, false );
}
$AppUI->redirect('m=helpdesk&a=view&item_id='.$hditem->item_id);
}
}
}
\ No newline at end of file
<?php /* HELPDESK $Id: export.php v 0.1*/
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
include_once 'helpdesk.functions.php';
//KZHAO 10-24-2006
global $HELPDESK_CONFIG, $w2Pconfig;
$item_id = (int) w2PgetParam($_GET, 'item_id', 0);
// Pull data
$q = new w2p_Database_Query;
$q->addQuery('*');
$q->addTable('helpdesk_items');
$q->addWhere('item_id = ' . $item_id);
$hditem = $q->loadHash();
// Check permissions for this record
if ($item_id) {
// Already existing item
$canEdit = $perms->checkModule($m, 'edit') && hditemEditable($hditem);
} else {
echo "Cannot find the item id!";
return;
}
if (!$canEdit) {
$AppUI->redirect(ACCESS_DENIED);
}
//KZHAO 10-24-2006
//Load helpdesk item
$org_hditem = new CHelpDesk();
$org_hditem->load( $item_id );
//Check required information before export
if (!@$hditem["item_project_id"]) {
$AppUI->setMsg( "Project must be specified for this item before exporting to task!" , UI_MSG_ERROR );
$AppUI->redirect("m=helpdesk&a=view&item_id=$item_id");
}
//KZHAO 7-10-2007
// Item with associated task cannot be exported
if (@$hditem["item_task_id"]) {
$AppUI->setMsg( "Item with associated task cannot be exported to another task!" , UI_MSG_ERROR );
$AppUI->redirect("m=helpdesk&a=view&item_id=$item_id");
}
//KZHAO 10-24-2006
// Check status
if ($ist[@$hditem["item_status"]]=="Closed") {
$AppUI->setMsg( "Closed helpdesk items cannot be exported to tasks!" , UI_MSG_ERROR );
$AppUI->redirect("m=helpdesk&a=view&item_id=$item_id");
}
if (!@$hditem["item_assigned_to"] && $HELPDESK_CONFIG['default_assigned_to_current_user']) {
@$hditem["item_assigned_to"] = $AppUI->user_id;
@$hditem["item_status"] = 1;
}
if (!@$hditem["item_company_id"] && $HELPDESK_CONFIG['default_company_current_company']) {
@$hditem["item_company_id"] = $AppUI->user_company;
}
// Setup the title block
$df = $AppUI->getPref('SHDATEFORMAT');
$tf = $AppUI->getPref('TIMEFORMAT');
$item_date = new w2p_Utilities_Date( $hditem["item_created"] );
$deadline_date = new w2p_Utilities_Date( $hditem["item_deadline"] );
$tc = $item_date->format( "$df $tf" );
$dateNow = new w2p_Utilities_Date();
$dateNowSQL = $dateNow->format( FMT_DATETIME_MYSQL );
$newTask = new CTask();
$ref_task ="This task was created from Helpdesk item #".$item_id.".\n";
$ref_task.= "-----------------------\n";
if (@$hditem["item_priority"]==0 || @$hditem["item_priority"]==2) {
$taskPrio=0;
} elseif (@$hditem["item_priority"]==1) {
$taskPrio=-1;
} else {
$taskPrio=1;
}
$hditem["item_deadline"] = (isset($hditem["item_deadline"])) ? $hditem["item_deadline"] : $dateNowSQL;
$taskInfo= array( "task_id"=>0,
"task_name"=> @$hditem["item_title"],
"task_project"=> @$hditem["item_project_id"],
"task_start_date"=> $dateNowSQL,
"task_end_date"=>@$hditem["item_deadline"],
"task_priority"=>$taskPrio,
"task_owner"=> $AppUI->user_id,
"task_creator"=>$AppUI->user_id,
"task_description"=> $ref_task.@$hditem["item_summary"],
"task_contacts" => @$hditem["item_requestor_id"],
"task_related_url"=> $w2Pconfig['base_url']."/index.php?m=helpdesk&a=view&item_id=".$item_id
);
echo "<br><br>";
$result= $newTask->bind( $taskInfo);
if (!$result) {
$AppUI->setMsg( $newTask->getError(), UI_MSG_ERROR );
$AppUI->redirect();
}
$result = $newTask->store();
if (is_array($result)) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
$AppUI->redirect(); // Store failed don't continue?
} else {
$ref_hd ="This helpdesk item has been exported to task #".$newTask->task_id.".\n";
$ref_hd.="Link: ".$w2Pconfig['base_url']."/index.php?m=tasks&a=view&task_id=".$newTask->task_id."\n";
$ref_hd.="---------------------------\n";
$org_hditem->item_status=2;
$org_hditem->item_updated=$dateNowSQL;
$org_hditem->item_summary=$ref_hd.$org_hditem->item_summary;
$result = $org_hditem->store();
if (is_array($result)) {
$AppUI->setMsg( $msg, UI_MSG_ERROR );
$AppUI->redirect();
}
$newTask->updateAssigned($hditem["item_assigned_to"], array($hditem["item_assigned_to"] => 100));
$AppUI->setMsg( 'Task added!', UI_MSG_OK);
$AppUI->redirect("m=helpdesk&a=view&item_id=$item_id&tab=0");
}
-- Upgrade script for helpdesk module
-- Use this script only if you have already installed helpdesk module into dotproject.
-- Kang 12/19/2006
-- The LinuxBox Corp. www.linuxbox.com
-- Ann Arbor, MI
ALTER TABLE helpdesk_items ADD item_updated datetime DEFAULT NULL;
ALTER TABLE helpdesk_items ADD item_deadline datetime DEFAULT NULL;
<?php /* HELPDESK $Id$ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
//KZHAO 10-24-2006
// Use mutlipart header and send emails in two formats
include_once 'helpdesk.functions.php';
// Define log types
define("NEW_ITEM_LOG", 1);
define("STATUS_LOG", 2);
define("STATUSTASK_LOG", 3);
define("TASK_LOG", 4);
define("NEW_WATCHER_LOG", 5);
$field_event_map = array(
//0=>Created
1=>"item_title", //Title
2=>"item_requestor", //Requestor Name
3=>"item_requestor_email", //Requestor E-mail
4=>"item_requestor_phone", //Requestor Phone
5=>"item_assigned_to", //Assigned To
6=>"item_notify", //Notify by e-mail
7=>"item_company_id", //Company
8=>"item_project_id", //Project
9=>"item_calltype", //Call Type
10=>"item_source", //Call Source
11=>"item_status", //Status
12=>"item_priority", //Priority
13=>"item_severity", //Severity
14=>"item_service", //Service - operating System, ...
15=>"item_application", //Application
16=>"item_summary", //Summary
17=>"item_deadline" //Deadline
// 18=>Deleted
);
// Help Desk class
class CHelpDesk extends w2p_Core_BaseObject
{
public $item_id = NULL;
public $item_title = NULL;
public $item_summary = NULL;
public $item_calltype = NULL;
public $item_source = NULL;
public $item_service = NULL;
public $item_application = NULL;
public $item_priority = NULL;
public $item_severity = NULL;
public $item_status = NULL;
public $item_project_id = NULL;
public $item_company_id = NULL;
public $item_assigned_to = NULL;
public $item_notify = 0;
public $item_requestor = NULL;
public $item_requestor_id = NULL;
public $item_requestor_email = NULL;
public $item_requestor_phone = NULL;
public $item_requestor_type = NULL;
public $item_created_by = NULL;
public $item_created = NULL;
public $item_modified = NULL;
//public $item_updated = NULL;
public $item_deadline =NULL;
public function __construct()
{
parent::__construct('helpdesk_items', 'item_id','helpdesk');
}
public function check()
{
$errorArray = array();
$baseErrorMsg = get_class($this) . '::store-check failed - ';
return $errorArray;
}
public function store()
{
$stored = false;
$errorMsgArray = $this->check();
if (count($errorMsgArray) > 0) {
return $errorMsgArray;
}
$this->item_summary = strip_tags($this->item_summary);
//if type indicates a contact or a user, then look up that phone and email
//for those entries
switch ($this->item_requestor_type) {
case '0'://it's not a user or a contact
break;
case '1'://it's a system user
$q = $this->_getQuery();
$q->addTable('users','u');
$q->addQuery('u.user_id as id');
$q->addQuery("CONCAT(c.contact_first_name,' ', c.contact_last_name) as name");
$q->addQuery("contact_email as email, contact_phone as phone");
$q->addJoin('contacts','c','u.user_contact = c.contact_id');
$q->addWhere('u.user_id='.$this->item_requestor_id);
break;
case '2': //it's only a contact
$q = $this->_getQuery();
$q->addTable('contacts','c');
$q->addQuery("CONCAT(c.contact_first_name,' ', c.contact_last_name) as name");
$q->addQuery("contact_email as email, contact_phone as phone");
$q->addWhere('contact_id='.$this->item_requestor_id);
break;
default:
break;
}
// get requestor's information
if (isset($q)) {
$result = $q->loadHash();
$q->clear();
$this->item_requestor_email = $result['email'];
$this->item_requestor_phone = $result['phone'];
$this->item_requestor = $result['name'];
}
/*
* TODO: I don't like the duplication on each of these two branches, but I
* don't have a good idea on how to fix it at the moment...
*
* TODO: Each of these branches should have a permissions check
* included. Review one fo the core core classes - like CLink - for
* the standard structure.
*/
$stored = false;
$q = $this->_getQuery();
$this->item_modified = $q->dbfnNowWithTZ();
if ($this->item_id) {
if (($msg = parent::store())) {
return $msg;
}
$stored = true;
}
if (0 == $this->item_id) {
$this->item_created = $q->dbfnNowWithTZ();
if (($msg = parent::store())) {
return $msg;
}
$stored = true;
}
return $stored;
}
public function lookup_contact($contact_id)
{
$contact = new CContact();
$contact->load($contact_id);
return $contact->contact_first_name.' '.$contact->contact_last_name.'||'.$contact->contact_phone.'||'.$contact->contact_email.'||';
}
public function delete()
{
// This section will grant every request to delete an HDitem
$k = $this->_tbl_key;
if ($oid) {
$this->$k = intval( $oid );
}
//load the item first so we can get the item_title for history
$this->load($this->item_id);
addHistory($this->_tbl, $this->$k, 'delete', $this->item_title, $this->item_project_id);
$result = null;
$q = $this->_getQuery();
$q->setDelete($this->_tbl);
$q->addWhere("$this->_tbl_key = '".$this->$k."'");
if (!$q->exec()) {
$result = db_error();
}
$q->clear();
$q->setDelete('helpdesk_item_status');
$q->addWhere("status_item_id = '".$this->item_id."'");
if (!$q->exec()) {
$result .= db_error();
}
$q->clear();
$q->setDelete('helpdesk_item_watchers');
$q->addWhere("item_id = '".$this->item_id."'");
if (!$q->exec()) {
$result .= db_error();
}
$q->clear();
$q->setDelete('task_log');
$q->addWhere("task_log_help_desk_id = '".$this->item_id."'");
if (!$q->exec()) {
$result .= db_error();
}
$q->clear();
return $result;
}
////////////////////////////////////////////////////////////////////////////////
// MiraKlim - for compatibility with unmodified files.class.php
public function notify($type, $log_id, $newhdi=0)
{
$this->notifymsg($type, 'Notify called');
}
public function notifymsg($type, $log_msg, $email_list=null)
{
global $w2Pconfig, $HELPDESK_CONFIG;
if (!isset($email_list)) {
$email_list = array();
if (($type!=TASK_LOG) || $HELPDESK_CONFIG['task_watchers_notification'] ) {
// Pull up the email address of everyone on the watch list
// this list does not include the assignee
$q = $this->_getQuery();
$q->addTable('helpdesk_item_watchers','hdw');
$q->addQuery('contact_email');
$q->addJoin('users','u','hdw.user_id = u.user_id');
$q->addJoin('contacts','c','u.user_contact = c.contact_id');
$q->addWhere("hdw.item_id='".$this->item_id."'");
$log_user_email = $q->loadHashList();
$log_user_email = array_keys($log_user_email);
foreach ($log_user_email as $user_email) {
if (trim($user_email)) {
$email_list[] = $user_email;
}
}
$q->clear();
}
if (($type!=TASK_LOG) || $HELPDESK_CONFIG['task_requestor_notification']) {
//add the requestor email to the list of mailing people
$email_list[] = $this->item_requestor_email;
//add the assigned user email to the list of mailing people
if (isset($this->item_assigned_to)) {
$assigned_user_email = array();
$q = $this->_getQuery();
$q->addTable('users','u');
$q->addQuery('contact_email');
$q->addJoin('contacts','c','u.user_contact = c.contact_id');
$q->addWhere('u.user_id='.$this->item_assigned_to);
$log_user_email = $q->loadHashList();
$log_user_email = array_keys($log_user_email);
foreach ($log_user_email as $user_email) {
if (trim($user_email) ) {
$email_list[] = $user_email;
}
}
$q->clear();
}
}
}
// Use subject and header from config.php
$subject = $HELPDESK_CONFIG['email_subject']."---".$this->_AppUI->_('Item')."#{$this->item_id} ";
$body .= $HELPDESK_CONFIG{'email_header'} . "\n";
$body .= $this->_AppUI->_('Item') . " : " . $this->item_id . "\n";
$body .= $this->_AppUI->_('Subject') . " : " . $this->item_title."\n";
$body .= $this->_AppUI->_('Requestor') . " : " . $this->item_requestor . "\n";
$body .= $this->_AppUI->_('Link') . " : " . $w2Pconfig['base_url']."/index.php?m=helpdesk&a=view&item_id=" . $this->item_id. "\n";
switch ($type) {
case STATUS_LOG:
case NEW_ITEM_LOG:
if ($type==NEW_ITEM_LOG) {
$subject .= $this->_AppUI->_('Created');
if (!isset($this->item_status) || ($ist[$this->item_status]=='Unassigned') ) {
$email_list[] = $HELPDESK_CONFIG['notity_email_address'];
}
} else {
$subject .= $this->_AppUI->_('Updated');
}
$body .= $this->_AppUI->_('Call Type') . " : " . $ict[$this->item_calltype]."\n";
$body .= $this->_AppUI->_('Status') . " : " . $ist[$this->item_status]."\n";
$body .= $this->_AppUI->_('Summary') . " : \n" . $this->item_summary."\n";
$body .= $this->_AppUI->_('Updates') . " : \n" . $log_msg . "\n";
break;
case TASK_LOG:
$subject .= $this->_AppUI->_('Task Log');
$body .= "\n" . $this->_AppUI->_('Task Log') . "\n" . $log_msg . "\n";
break;
case STATUSTASK_LOG:
$subject .= $this->_AppUI->_('Task+Status Log');
$body .= "\n" . $this->_AppUI->_('Task+Status Log') . "\n" . $log_msg . "\n";
break;
case NEW_WATCHER_LOG:
$subject .= $this->_AppUI->_('Watchers Notification');
$body = $this->_AppUI->_('You have been added to the watchers list for Help Desk item') . "\n" . $body . "\n" . $log_msg . "\n";
break;
}
//if there's no one in the list, skip the rest.
if (count($email_list)>0) {
$email_list=array_unique($email_list);
foreach ($email_list as $assigned_to_email) {
$mail = new w2p_Utilities_Mail();
if ($mail->ValidEmail($assigned_to_email) && ($this->_AppUI->user_email!=$assigned_to_email)) {
// KZHAO 9-12-2006
$to=$assigned_to_email;
if ($mail->ValidEmail($this->_AppUI->user_email)) {
$email = $this->_AppUI->user_email;
} else {
$email = $HELPDESK_CONFIG['notity_email_address'];
}
// Mail it
$mail->Subject($subject, $locale_char_set);
$mail->From($email);
$mail->To($assigned_to_email);
$mail->Body($body, isset( $GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : "");
$mail->Send();
}
}
}
}
public function hook_search()
{
$search['table'] = 'helpdesk_items';
$search['table_alias'] = 'h';
$search['table_module'] = 'helpdesk';
$search['table_key'] = 'h.item_id';
$search['table_link'] = 'index.php?m=helpdesk&a=view&item_id=';
$search['table_title'] = 'Helpdesk';
$search['table_orderby'] = 'item_title';
$search['table_orderby'] = 'item_title';
$search['search_fields'] = array('item_title', 'item_summary',
'item_application', 'item_requestor', 'item_requestor_email',
'task_log_name', 'task_log_description');
$search['display_fields'] = $search['search_fields'];
$search['table_joins'] = array(array('table' => 'task_log',
'alias' => 'tl', 'join' => 'h.item_id = tl.task_log_help_desk_id'));
return $search;
}
public function log_status_changes()
{
global $ist, $ict, $ics, $ios, $iap, $ipr, $isv, $ist, $field_event_map;
if (w2PgetParam( $_POST, "item_id")) {
$item_id = (int) w2PgetParam( $_POST, "item_id");
$hditem = new CHelpDesk();
$hditem->load($item_id);
$count=0;
$status_changes_summary="";
foreach ($field_event_map as $key => $value) {
if (eval("return (isset(\$this->$value) && (\$hditem->$value != \$this->$value));")) {
$old = $new = "";
$count++;
switch ($value) {
// Create the comments here
case 'item_assigned_to':
$q = $this->_getQuery();
$q->addQuery('user_id, concat(contact_first_name,\' \',contact_last_name) as user_name');
$q->addTable('users');
$q->addJoin('contacts','','user_contact = contact_id');
$q->addWhere('user_id in ('.($hditem->$value?$hditem->$value:'0').
($this->$value&&$hditem->$value?', ':'').
($this->$value?$this->$value:'').')');
$ids = $q->loadList();
foreach ($ids as $row) {
if ($row["user_id"]==$this->$value) {
$new = $row["user_name"];
} elseif ($row["user_id"]==$hditem->$value) {
$old = $row["user_name"];
}
}
break;
case 'item_company_id':
// $q = new w2p_Database_Query();
$q = $this->_getQuery();
$q->addQuery('company_id, company_name');
$q->addTable('companies');
$q->addWhere('company_id in ('.($hditem->$value?$hditem->$value:'').
($this->$value&&$hditem->$value?', ':'').
($this->$value?$this->$value:'').')');
$ids = $q->loadList();
foreach ($ids as $row) {
if ($row["company_id"]==$this->$value) {
$new = $row["company_name"];
} elseif ($row["company_id"]==$hditem->$value) {
$old = $row["company_name"];
}
}
break;
case 'item_project_id':
// $q = new w2p_Database_Query();
$q = $this->_getQuery();
$q->addQuery('project_id, project_name');
$q->addTable('projects');
$q->addWhere('project_id in ('.($hditem->$value?$hditem->$value:'').
($this->$value&&$hditem->$value?', ':'').
($this->$value?$this->$value:'').')');
$ids = $q->loadList();
foreach ($ids as $row) {
if ($row["project_id"]==$this->$value) {
$new = $row["project_name"];
} elseif ($row["project_id"]==$hditem->$value) {
$old = $row["project_name"];
}
}
break;
case 'item_calltype':
$old = $this->_AppUI->_($ict[$hditem->$value]);
$new = $this->_AppUI->_($ict[$this->$value]);
break;
case 'item_source':
$old = $this->_AppUI->_($ics[$hditem->$value]);
$new = $this->_AppUI->_($ics[$this->$value]);
break;
case 'item_status':
$old = $this->_AppUI->_($ist[$hditem->$value]);
$new = $this->_AppUI->_($ist[$this->$value]);
break;
case 'item_priority':
$old = $this->_AppUI->_($ipr[$hditem->$value]);
$new = $this->_AppUI->_($ipr[$this->$value]);
break;
case 'item_severity':
$old = $this->_AppUI->_($isv[$hditem->$value]);
$new = $this->_AppUI->_($isv[$this->$value]);
break;
case 'item_service':
$old = $this->_AppUI->_($ios[$hditem->$value]);
$new = $this->_AppUI->_($ios[$this->$value]);
break;
case 'item_application':
$old = $this->_AppUI->_($iap[$hditem->$value]);
$new = $this->_AppUI->_($iap[$this->$value]);
break;
case 'item_notify':
$old = $hditem->$value ? $this->_AppUI->_('On') : $this->_AppUI->_('Off');
$new = $this->$value ? $this->_AppUI->_('On') : $this->_AppUI->_('Off');
break;
case 'item_deadline':
$old = $hditem->$value;
$new = $this->$value;
if (strcmp($new,'N/A')) {
unset($new);
}
break;
default:
$old = trim($hditem->$value);
$new = trim($this->$value);
break;
}// end of switch
if (!eval("return \$new == \$old;")) {
if ($new=='') {$new = ' ';}
$last_status_comment = $this->log_status($key, $old, $new);
$status_changes_summary .= $last_status_comment . "\n";
}
}//end of if
}//end of loop
if ($this->item_notify && $count) {
$this->notifymsg(STATUS_LOG, $status_changes_summary);
}
return $status_changes_summary;
}
}
public function log_status($audit_code, $commentfrom="", $commentto="", $notify=0)
{
global $isa ;
if ($commentto) {
$sep = ' ';
$sepend = ' ';
if ($audit_code==16) {
$sep = "------ ";
$sepend = " \n";
}
$comment = $sep . $this->_AppUI->_('changed from'). $sepend . " \"" . addslashes($commentfrom) . "\" ";
$comment .= $sep . $this->_AppUI->_('to') . $sepend . " \"" . addslashes($commentto) . "\"";
} else {
$comment=$commentfrom;
}
$sql = "
INSERT INTO helpdesk_item_status
(status_item_id,status_code,status_date,status_modified_by,status_comment)
VALUES('{$this->item_id}','{$audit_code}',NOW(),'{$this->_AppUI->user_id}','$comment')";
db_exec($sql);
if (db_error()) {
return false;
}
$log_id = mysql_insert_id();
if (($this->item_notify) && $notify==1) {
$this->notifymsg(($audit_code==0) ? NEW_ITEM_LOG : STATUS_LOG , $comment);
}
return $isa[$audit_code] . " " . $comment;
}
}
\ No newline at end of file
<?php /* HELPDESK $Id$ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
include_once 'config.php';
function getAllowedUsers($companyid=0,$activeOnly=0)
{
global $HELPDESK_CONFIG, $AppUI, $m;
//populate user list with all users from permitted companies
$q = new w2p_Database_Query;
$q->addQuery('user_id, CONCAT(contact_first_name, \' \',contact_last_name) as fullname');
$q->addTable('users');
$q->addJoin('contacts','','user_contact = contact_id');
$q->addWhere(getCompanyPerms('user_company', PERM_EDIT, $HELPDESK_CONFIG['the_company']) .' OR ' .getCompanyPerms('contact_company', PERM_EDIT, $HELPDESK_CONFIG['the_company'] ));
$q->addOrder('contact_last_name, contact_first_name');
$users = $q->loadHashList();
//Filter inactive users
if ($activeOnly) {
$perms =& $AppUI->acl();
$cnt=0;
$userids=array_keys($users);
foreach ($userids as $row) {
if ($perms->isUserPermitted($row) == false) {
// echo "Inactive!!!!".$row."<br>";
unset($users[$row]);
}
//$cnt++;
}
}
return $users;
}
//KZHAO 8-8-2006
// eliminate non-user's companies if needed
function getAllowedCompanies($companyId=0)
{
global $AppUI;
$company = new CCompany();
$allowedCompanies = $company->getAllowedRecords( $AppUI->user_id, 'company_id,company_name', 'company_name' );
if ($companyId!=0 && $companyId!=$HELPDESK_CONFIG['the_company']) {
$compIds=array_keys($allowedCompanies);
foreach ($compIds as $row) {
if($row!=$companyId)
unset($allowedCompanies[$row]);
}
}
return $allowedCompanies;
}
function getAllowedProjects($list = 0, $activeOnly = 0)
{
global $AppUI, $HELPDESK_CONFIG;
$project = new CProject();
return $project->getAllowedProjects($AppUI->user_id, $activeOnly);
}
// Add a parameter for active projects-- Kang
function getAllowedProjectsForJavascript($activeonly = 0)
{
global $HELPDESK_CONFIG, $AppUI;
$allowedProjects = getAllowedProjects();
$projects = array();
foreach ($allowedProjects as $project) {
$projects[] = "[{$project['project_company']},{$project['project_id']},'"
. addslashes($project['project_name']) . "']";
}
return $projects;
}
//----------------------------------------------
//Kang--retrieve a list of tasks for helpdesk items
// Note: may need more access control here
function getAllowedTasksForJavascript($project_ids,$activeOnly=1)
{
global $HELPDESK_CONFIG, $AppUI;
$tasks = array();
if (!isset($project_ids) || !is_array($project_ids) || !count($project_ids)) {
return;
}
$q = new w2p_Database_Query;
$q->addQuery('task_id, task_name, task_project');
$q->addTable('tasks');
$q->addWhere('task_project IN (' . implode(',',$project_ids) .') ');
if ($activeOnly) {
$q->addWhere('task_status=0 AND task_percent_complete!=100.00');
}
$q->addOrder('task_name');
$allowedTask = $q->loadList();
foreach ($allowedTask as $row) {
$tasks[]="[{$row['task_project']},{$row['task_id']},'"
. addslashes($row['task_name'])."']";
}
return $tasks;
}
/* Function to build a where clasuse that will restrict the list of Help Desk
* items to only those viewable by a user. The viewable items include
* 1. Items the user created
* 2. Items that are assigned to the user
* 3. Items where the user is the requestor
* 4. Items of a company you have permissions for
*/
function getItemPerms()
{
global $HELPDESK_CONFIG, $AppUI;
$permarr = array();
//pull in permitted companies
$allowedCompanies = getAllowedCompanies();
$allowedProjects = getAllowedProjects();
//if there are none listed, make sure that sql returns nothing
if (!$allowedCompanies) {
return "0=1";
}
foreach ($allowedCompanies as $k=>$v) {
$companyIds[] = $k;
}
$companyIds = implode(",", $companyIds);
$permarr[] = "(item_company_id in ("
.$companyIds
.") OR item_created_by="
.$AppUI->user_id
.") ";
//it's assigned to the current user
$permarr[] = "item_assigned_to=".$AppUI->user_id;
//it's requested by a user and that user is you
$permarr[] = " (item_requestor_type=1 AND item_requestor_id=".$AppUI->user_id.') ' ;
if ($HELPDESK_CONFIG['use_project_perms']) {
$projectIds = array_keys($allowedProjects);
} else {
foreach ($allowedProjects as $p) {
$projectIds[] = $p['project_id'];
}
}
if (count($projectIds)) {
$projarr[] = " AND item_project_id in (0,".implode(", ", $projectIds).")";
} else {
$projarr[] = " AND item_project_id in (0)";
}
$sql = '('.implode("\n OR ", $permarr).')'.implode('',$projarr);
return $sql;
}
// Function to build a where clause to be appended to any sql that will narrow
// down the returned data to only permitted company data
function getCompanyPerms($mod_id_field,$perm_type=NULL,$the_company=NULL)
{
GLOBAL $AppUI, $perms, $m;
//pull in permitted companies
$allowedCompanies = getAllowedCompanies();
//if there are none listed, make sure that sql returns nothing
if (!$allowedCompanies) {
return "0=1";
}
$allowedCompanies = array_keys($allowedCompanies);
if (is_numeric($the_company)) {
$allowedCompanies[] = $the_company;
}
return "($mod_id_field in (".implode(",", $allowedCompanies)."))";
}
function hditemReadable($hditem)
{
return hditemPerm($hditem, PERM_READ);
}
function hditemEditable($hditem)
{
return hditemPerm($hditem, PERM_EDIT);
}
function hditemPerm($hditem, $perm_type)
{
global $HELPDESK_CONFIG, $AppUI, $m;
$perms = & $AppUI->acl();
$created_by = $hditem['item_created_by'];
$company_id = isset($hditem['item_company_id'])?$hditem['item_company_id']:'';
$assigned_to = isset($hditem['item_assigned_to'])?$hditem['item_assigned_to']:'';
$requested_by = isset($hditem['item_requestor_id'])?$hditem['item_requestor_id']:'';
switch ($perm_type) {
case PERM_READ:
$company_perm = $perms->checkModuleItem('companies', 'view', $company_id);
break;
case PERM_EDIT:
// If the item is not assigned to a company, figure out if we can edit it
if ($company_id == 0) {
if ($HELPDESK_CONFIG['no_company_editable']) {
$company_perm = 1;
} else {
$company_perm = 0;
}
} else {
$company_perm = $perms->checkModuleItem('companies', 'view', $company_id);
}
break;
default:
die ("Wrong permission type was passed");
}
/* User is allowed if
1. He has the company permission
2. He is the creator
3. He is the assignee
4. He is the requestor
*/
if($company_perm ||
($created_by == $AppUI->user_id) ||
($assigned_to == $AppUI->user_id) ||
($requested_by == $AppUI->user_id)) {
return true;
} else {
return false;
}
}
function hditemCreate()
{
global $m, $AppUI;
$perms = & $AppUI->acl();
if ($perms->checkModule($m, 'add'))
return true;
return false;
}
function dump($var)
{
print "<pre>";
print_r($var);
print "</pre>";
}
// Added by KZHAO: 8-4-2006
// convert mysql date format into PHP date format
function get_mysql_to_epoch($sqldate)
{
list( $year, $month, $day, $hour, $minute, $second )= split( '([^0-9])', $sqldate );
//echo $year.",".$month.",".$day;
return date( 'U', mktime( $hour, $minute, $second, $month, $day, $year) );
}
// KZHAO: get how long ago
function get_time_ago($mysqltime)
{
global $AppUI;
$wrong=0;
$timestamp=get_mysql_to_epoch($mysqltime);
$elapsed_seconds = time() - $timestamp;
// KZHAO 8-10-2006
// dealing with time in the future
if ($elapsed_seconds<0) {
return ("N/A");
} elseif ($elapsed_seconds < 60) { // seconds ago
if ($elapsed_seconds) {
$interval = $elapsed_seconds;
} else {
$interval = 1;
}
$output = "sec.";
} elseif ($elapsed_seconds < 3600) { // minutes ago
$interval = round($elapsed_seconds / 60);
$output = "min.";
} elseif ($elapsed_seconds < 86400) { // hours ago
$interval = round($elapsed_seconds / 3600);
$output = "hr.";
} elseif ($elapsed_seconds < 604800) { // days ago
$interval = round($elapsed_seconds / 86400);
$output = "day";
} elseif ($elapsed_seconds < 2419200) { // weeks ago
$interval = round($elapsed_seconds / 604800);
$output = "week";
} elseif ($elapsed_seconds < 29030400) { // months ago
$interval = round($elapsed_seconds / 2419200);
$output = " month";
} else { // years ago
$interval = round($elapsed_seconds / 29030400);
$output = "year";
}
if ($interval > 1) {
$output .= "s";
}
$output = " ".$AppUI->_($output);
$output .= " ".$AppUI->_('ago');
$output = $interval.$output;
return($output);
}
//KZHAO 8-10-2006
// handle the deadline
function get_due_time($mysqltime, $listView=0)
{
global $AppUI;
$ago=1;
$color="000000";
$color_soon="ff0000";// red
$color_days="990066";//pink
$color_weeks="cc6600";// brown
$color_months="339900";//green
$color_long="66ff00";//
$timestamp=get_mysql_to_epoch($mysqltime);
$elapsed_seconds = time() - $timestamp;
// KZHAO 8-10-2006
// dealing with time in the future
if ($elapsed_seconds<0) {
$elapsed_seconds=$timestamp-time();
$ago=0;
}
if ($elapsed_seconds < 60) { // seconds ago
$interval = $elapsed_seconds;
$output = "sec.";
$color=$color_soon;
} elseif ($elapsed_seconds < 3600) { // minutes ago
$interval = round($elapsed_seconds / 60);
$output = "min.";
$color=$color_soon;
} elseif ($elapsed_seconds < 86400) { // hours ago
$interval = round($elapsed_seconds / 3600);
$output = "hr.";
$color=$color_soon;
} elseif ($elapsed_seconds < 604800) { // days ago
$interval = round($elapsed_seconds / 86400);
$output = "day";
if($interval<=3)
$color=$color_soon; //red
else
$color=$color_days;//orange
} elseif ($elapsed_seconds < 2419200) { // weeks ago
$interval = round($elapsed_seconds / 604800);
$output = "week";
$color=$color_weeks;
} elseif ($elapsed_seconds < 29030400) { // months ago
$interval = round($elapsed_seconds / 2419200);
$output = " month";
$color=$color_months;
} else { // years ago
$interval = round($elapsed_seconds / 29030400);
$output = "year";
$color=$color_long;
}
if ($interval > 1) {
$output .= "s";
}
$output = " ".$AppUI->_($output);
//Only display time for list view
if ($listView) {
if($ago)
$output =$interval." ".$output." ".$AppUI->_('ago');
else
$output = "<font color=#".$color.">".$interval.$output."</font>";
} else {
if ($ago) {
$output .= " ".$AppUI->_('ago');
$output = "Deadline is ".$interval.$output;
} else {
$output = "<font color=#".$color.">Due in <strong>".$interval.$output."</strong></font>";
//$output ="Due in "
}
}
return($output);
}
function linkLinks($data)
{
$data = strip_tags($data);
$search_email = '/([\w-]+([.][\w_-]+){0,4}[@][\w_-]+([.][\w-]+){1,3})/';
$search_http = '/(http(s)?:\/\/[^\s]+)/i';
$data = preg_replace($search_email,"<a href=\"mailto:$1\">$1</a>",$data);
$data = preg_replace($search_http,"<a href=\"$1\" target=\"_blank\">$1</a>",$data);
return $data;
}
// dealing with the helpdesk_item_watchers table in DB and send emails
// send emails to acknowledge that they are added to the watcher list
function doWatchers($list, $hditem, $notify_all) {//KZHAO 8-7-2006
global $AppUI;
# Create the watcher list
$watcherlist = split(',', $list);
$q = new w2p_Database_Query;
$q->addQuery('user_id');
$q->addTable('helpdesk_item_watchers');
$q->addWhere('item_id=' . $hditem->item_id);
$current_users = $q->loadHashList();
$current_users = array_keys($current_users);
# Delete the existing watchers as the list might have changed
$sql = "DELETE FROM helpdesk_item_watchers WHERE item_id=" . $hditem->item_id;
db_exec($sql);
if (!$del) {
if ($list) {
foreach ($watcherlist as $watcher) {
$q = new w2p_Database_Query;
$q->addQuery('user_id, c.contact_email');
$q->addTable('users');
$q->addJoin('contacts','c','user_contact = contact_id');
$q->addWhere('user_id=' . $watcher);
if ($notify_all) {
$rows = $q->loadlist($sql);
$email_list = array();
foreach ($rows as $row) {
# Send the notification that they've been added to a watch list.
//KZHAO 8-3-2006: only when users choose to send emails
if (!in_array($row['user_id'],$current_users)) {
$email_list[] = $row['contact_email'];
}
}
$hditem->notifymsg(NEW_WATCHER_LOG, '', $email_list);
}
$sql = "INSERT INTO helpdesk_item_watchers VALUES(". $hditem->item_id . "," . $watcher . ",'Y')";
db_exec($sql);
}
}
}
}
/*
* opened = 0
* closed = 1
* mine = 2
*/
function vw_idx_handler($type)
{
global $m, $ipr, $ist, $AppUI, $HELPDESK_CONFIG;
global $project_id;
$ipr = w2PgetSysVal( 'HelpDeskPriority' );
$ist = w2PgetSysVal( 'HelpDeskStatus' );
$where = $date_field_name = $date_field_title = "";
switch ($type) {
case 0:// newly created open ticket today
$date_field_title = $AppUI->_('Opened On');
$date_field_name = "item_created";
$where .= "(TO_DAYS(NOW()) - TO_DAYS(his.status_date) = 0) AND item_status = 1 AND (his.status_code = 0)";
break;
case 1:// Closed today
$date_field_title = $AppUI->_('Closed On');
$date_field_name = "status_date";
$where .= "item_status=2 AND (TO_DAYS(NOW()) - TO_DAYS(status_date) = 0) AND status_code=11";
break;
case 2: // Mine open
$date_field_title = $AppUI->_('Opened On');
$date_field_name = "item_created";
$where .= "item_assigned_to={$AppUI->user_id} AND item_status !=2 ";
break;
case 3: // Any state by project
$date_field_title = $AppUI->_('Opened On');
$date_field_name = "item_created";
$where .= "item_project_id = $project_id";
break;
default:
print "Shouldn't be here (for now)";
exit(1);
}
$df = $AppUI->getPref( 'SHDATEFORMAT' );
$tf = $AppUI->getPref( 'TIMEFORMAT' );
$format = $df." ".$tf;
/*
* Unassigned = 0
* Open = 1
* Closed = 2
* On hold = 3
* Delete = 4
* Testing = 5
*/
$item_perms = getItemPerms();
$q = new w2p_Database_Query;
$q->addQuery('hi.*, CONCAT(co.contact_first_name,\' \',co.contact_last_name) assigned_fullname');
$q->addQuery('contact_email AS assigned_email');
$q->addQuery('p.project_id,p.project_name,p.project_color_identifier,his.status_date sd');
$q->addTable('helpdesk_items','hi');
$q->addJoin('helpdesk_item_status','his','his.status_item_id = hi.item_id');
$q->addJoin('users','u','u.user_id = hi.item_assigned_to');
$q->addJoin('contacts','co','co.contact_id = u.user_contact');
$q->addJoin('projects','p','p.project_id = hi.item_project_id');
$q->addWhere($where . ' AND ' . $item_perms);
$q->addGroup('item_id');
$q->addOrder('item_id');
$items = $q->loadList();
?>
<table cellspacing="1" cellpadding="2" border="0" width="100%" class="tbl">
<tr>
<th><?php echo $AppUI->_('Number'); ?></th>
<th><?php echo $AppUI->_('Requestor'); ?></th>
<th><?php echo $AppUI->_('Title'); ?></th>
<th ><?php echo $AppUI->_('Summary'); ?></th>
<th nowrap="nowrap"><?php echo $AppUI->_('Assigned To'); ?></th>
<th><?php echo $AppUI->_('Status'); ?></th>
<th><?php echo $AppUI->_('Priority'); ?></th>
<th><?php echo $AppUI->_('Updated'); ?></th>
<th><?php echo $AppUI->_('Project'); ?></th>
<th nowrap="nowrap"><?php echo $date_field_title?></th>
</tr>
<?php
$tmp=0;
foreach ($items as $row) {
/* We need to check if the user who requested the item is still in the
system. Just because we have a requestor id does not mean we'll be
able to retrieve a full name */
if ($row[$date_field_name]) {
$date = new w2p_Utilities_Date( $row[$date_field_name] );
$tc = $date->format( $format );
} else {
$tc = ' ';
}
if ($row['status_date']) {
$datesd = new w2p_Utilities_Date( $row['status_date'] );
$sd = $datesd->format( $format );
} else {
$sd = ' ';
}
?>
<tr>
<td nowrap="nowrap"><b><a href="?m=helpdesk&a=view&item_id=<?php echo $row['item_id']?>"><?php echo $row['item_id']?></a></b>
<?php echo w2PshowImage ('ct'.$row['item_calltype'].'.png', 15, 17, '', '', 'helpdesk'); ?></td>
<td nowrap=\"nowrap\">
<?php
if ($row['item_requestor_email']) {
print "<a href=\"mailto:".$row['item_requestor_email']."\">".$row['item_requestor']."</a>";
} else {
print $row['item_requestor'];
}
?>
</td>
<td width="20%"><a href="?m=helpdesk&a=view&item_id=<?php echo $row['item_id']?>"><?php echo $HELPDESK_CONFIG['new_hd_item_title_prefix'] . ' ' .$row['item_title']?></a></td>
<td width="80%"><?php echo substr($row['item_summary'],0,max(strpos($row['item_summary']."\n","\n"),80)) . '</td>'; ?></td>
<td align="center" nowrap="nowrap">
<?php
if ($row['item_assigned_to']) {
$user = new CUser();
$user->load($row['item_assigned_to']);
$contact = new CContact();
$contact->contact_id = $user->user_contact;
$contactMethods = $contact->getContactMethods(array('email_primary'));
$assigned_email = $contactMethods['email_primary'];
print "<a href='mailto:{$assigned_email}'>{$row['assigned_fullname']}</a>";
} else {
print $row['assigned_fullname'] ? $row['assigned_fullname'] : "-";
}
?>
</td>
<td align="center" nowrap><?php echo $AppUI->_($ist[@$row['item_status']]); ?></td>
<td align="center" nowrap><?php echo $AppUI->_($ipr[@$row['item_priority']]); ?></td>
<td align="center" nowrap><?php echo @$sd?></td>
<td align="center" style="background-color: #<?php echo $row['project_color_identifier']?>;" nowrap>
<?php if ($row['project_id']) { ?>
<a href="./index.php?m=projects&a=view&project_id=<?php echo $row['project_id']?>" style="color: <?php echo bestColor( $row['project_color_identifier'] ) ?>;"><?php echo $row['project_name']?></a>
<?php } else { ?>
-
<?php } ?>
</td>
<td nowrap="nowrap"><?php print ($tc); ?></td>
</tr>
<?php } ?>
</table>
<?php
}
// Returns a header link used to sort results
// TODO Probably need a better up/down arrow
function sort_header($field, $name)
{
global $orderby, $orderdesc;
$arrow = "";
$link = "<a class=\"hdr\" href=\"?m=helpdesk&a=list&orderby=$field&orderdesc=";
if ($orderby == $field) {
$link .= $orderdesc ? "0" : "1";
$arrow .= $orderdesc ? " &uarr;" : " &darr;";
} else {
$link .= "0";
}
$link .= "\">$name</a>$arrow";
return $link;
}
\ No newline at end of file
<?php /* TASKS $Id: helpdesk_tab.view.files.php 5771 2008-07-15 14:41:58Z merlinyoda $ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
GLOBAL $AppUI, $project_id, $task_id, $helpdesk_id, $deny, $canRead, $canEdit, $w2Pconfig, $cfObj, $m, $obj;
global $allowed_folders_ary, $denied_folders_ary, $limited;
$cfObj = new CFileFolder();
$allowed_folders_ary = $cfObj->getAllowedRecords($AppUI->user_id);
$denied_folders_ary = $cfObj->getDeniedRecords($AppUI->user_id);
$limited = ((count( $allowed_folders_ary ) < $cfObj->countFolders()) ? true : false);
if (!$limited) {
$canEdit = true;
} elseif ($limited && array_key_exists($folder, $allowed_folders_ary)) {
$canEdit = true;
} else {
$canEdit = false;
}
$showProject = false;
if (getPermission('files', 'edit')) {
echo ('<a href="./index.php?m=files&a=addedit&project_id=' . $project_id . '&file_helpdesk_item=' . $helpdesk_id
. '&file_task=' . $task_id . '">' . $AppUI->_('Attach a file') . '</a>');
echo w2PshowImage('stock_attach-16.png', 16, 16, '', '', $m);
}
$canAccess_folders = getPermission('file_folders', 'access');
if ($canAccess_folders) {
$folder = w2PgetParam($_GET, 'folder', 0);
require( W2P_BASE_DIR . '/modules/files/folders_table.php' );
} elseif (getPermission('files', 'view')) {
require( W2P_BASE_DIR . '/modules/files/index_table.php' );
}
images/ct0.png

257 Bytes

images/ct1.png

892 Bytes

images/ct2.png

611 Bytes

images/ct3.png

257 Bytes

images/ct4.png

574 Bytes

images/ct5.png

268 Bytes

images/ct6.png

273 Bytes

images/ct7.png

858 Bytes

<html><body bgcolor="#FFFFFF"></body></html>
\ No newline at end of file
<html><body bgcolor="#FFFFFF"></body></html>
\ No newline at end of file
<?php /* HELPDESK $Id$ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
include_once 'helpdesk.functions.php';
// check permissions for this module
$canReadModule = canView( $m );
if (!$canReadModule) {
$AppUI->redirect(ACCESS_DENIED);
}
if (isset( $_GET['tab'] )) {
$AppUI->setState( 'HelpDeskIdxTab', $_GET['tab'] );
}
$tab = $AppUI->getState( 'HelpDeskIdxTab' ) !== NULL ? $AppUI->getState( 'HelpDeskIdxTab' ) : 0;
// Setup the title block
$titleBlock = new w2p_Theme_TitleBlock( 'Help Desk', 'helpdesk.png', $m, 'ID_HELP_HELPDESK_IDX' );
if (hditemCreate()) {
$titleBlock->addCell(
'<input type="submit" class="button" value="'.$AppUI->_('new item').'" />', '',
'<form action="?m=helpdesk&a=addedit" method="post">', '</form>'
);
}
$titleBlock->addCrumb( "?m=helpdesk", 'home' );
$titleBlock->addCrumb( "?m=helpdesk&a=list", 'list' );
$titleBlock->addCrumb( "?m=helpdesk&a=reports", 'reports' );
$titleBlock->show();
$item_perms = getItemPerms();
$q = new w2p_Database_Query;
$q->addQuery('COUNT(item_id)');
$q->addTable('helpdesk_items');
$q->addWhere($item_perms);
$numtotal = $q->loadResult ();
/*
* Unassigned = 0
* Open = 1
* Closed = 2
* On hold = 3
* ....
*/
$item_perms = getItemPerms();
$q = new w2p_Database_Query;
$q->addQuery('COUNT(DISTINCT(item_id))');
$q->addTable('helpdesk_items');
$q->addWhere('item_assigned_to=' . $AppUI->user_id . ' AND (item_status != 2)');
$nummine = $q->loadResult ();
$q = new w2p_Database_Query;
$q->addQuery('COUNT(DISTINCT(item_id))');
$q->addTable('helpdesk_items');
$q->addJoin('helpdesk_item_status','his','helpdesk_items.item_id = his.status_item_id');
$q->addWhere('item_status = 1 AND status_code = 0 ');
$q->addWhere($item_perms . ' AND (TO_DAYS(NOW()) - TO_DAYS(status_date) = 0)');
$numopened = $q->loadResult ();
$q = new w2p_Database_Query;
$q->addQuery('COUNT(DISTINCT(item_id))');
$q->addTable('helpdesk_items');
$q->addJoin('helpdesk_item_status','his','helpdesk_items.item_id = his.status_item_id');
$q->addWhere('item_status = 2 AND status_code = 11 ');
$q->addWhere($item_perms . ' AND (TO_DAYS(NOW()) - TO_DAYS(status_date) = 0)');
$numclosed = $q->loadResult();
?>
<table cellspacing="0" cellpadding="2" border="0" width="100%">
<tr>
<td width="80%" valign="top">
<?php
// Tabbed information boxes
$tabBox = new CTabBox( '?m=helpdesk', W2P_BASE_DIR . '/modules/helpdesk/', $tab );
$tabBox->add( 'vw_idx_stats', $AppUI->_('Help Desk Items')." ($numtotal)" );
$tabBox->add( 'vw_idx_my', $AppUI->_('My Open')." ($nummine)" );
$tabBox->add( 'vw_idx_new', $AppUI->_('Opened Today')." ($numopened)" );
$tabBox->add( 'vw_idx_closed', $AppUI->_('Closed Today')." ($numclosed)" );
$tabBox->add( 'vw_idx_watched', "Watched Tickets" );
$tabBox->show();
?>
</td>
</tr>
</table>
<?php /* HELPDESK $Id$ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
include_once 'helpdesk.functions.php';
$allowedCompanies = getAllowedCompanies();
$allowedProjects = getAllowedProjects();
$ipr = w2PgetSysVal( 'HelpDeskPriority' );
$ist = w2PgetSysVal( 'HelpDeskStatus' );
$df = $AppUI->getPref( 'SHDATEFORMAT' );
$tf = $AppUI->getPref( 'TIMEFORMAT' );
$format = $df." ".$tf;
// check sort order
if (isset( $_GET['orderby'] )) {
$AppUI->setState( 'HelpDeskIdxOrderBy', $_GET['orderby'] );
}
$orderby = $AppUI->getState( 'HelpDeskIdxOrderBy' ) ? $AppUI->getState( 'HelpDeskIdxOrderBy' ) : 'item_id';
// check sort order way (asc/desc)
if (isset($_GET['orderdesc'])) {
$AppUI->setState('HelpDeskIdxOrderDesc', $_GET['orderdesc']);
}
$orderdesc = $AppUI->getState('HelpDeskIdxOrderDesc') ? $AppUI->getState('HelpDeskIdxOrderDesc') : 0;
if (isset($_GET['page'])) {
$AppUI->setState('HelpDeskListPage', $_GET['page']);
} else {
// If page isn't mentioned, we need to reset
$AppUI->setState('HelpDeskListPage', 0);
}
$page = $AppUI->getState('HelpDeskListPage') ? $AppUI->getState('HelpDeskListPage') : 0;
$tarr = array();
$selectors = array();
// check for search text
if ($HELPDESK_CONFIG['search_criteria_search']) {
if (isset($_GET['search'])) {
// Set the search text as system state--Kang
$AppUI->setState( 'HelpDeskSearch', $_GET['search'] );
}
$search =$AppUI->getState( 'HelpDeskSearch' ) !== null ? $AppUI->getState( 'HelpDeskSearch' ) : '';
//echo "<br>".$search."<br>";
if (strlen(trim($search))>0) {
$tarr[] = "(lower(hi.item_title) LIKE lower('%$search%')
OR lower(hi.item_summary) LIKE lower('%$search%'))";
}
if (!$_REQUEST['project_id'] && !$_REQUEST['company_id']) {
$selectors[] = "<td align=\"right\"><label for=\"search\">"
. $AppUI->_('Search')
. ":</label></td><td nowrap=\"nowrap\">"
. "<input type=\"text\" name=\"search\" id=\"search\" class=\"text\" value=\"".$search."\" size=\"12\">"
. " <input type=\"submit\" value=\""
. $AppUI->_('Search')
. "\" class=\"button\" /></td>";
}
}
// check for calltype filter
if ($HELPDESK_CONFIG['search_criteria_call_type']) {
if (isset( $_GET['item_calltype'] )) {
$AppUI->setState( 'HelpDeskCallType', $_GET['item_calltype'] );
}
$calltype = $AppUI->getState( 'HelpDeskCallType' ) !== null ? $AppUI->getState( 'HelpDeskCallType' ) : -1;
if ($calltype >= 0) {
$tarr[] = "hi.item_calltype=$calltype";
}
if (!$_REQUEST['project_id'] && !$_REQUEST['company_id']) {
$selectors[] = "<td align=\"right\" nowrap><label for=\"call_type\">"
. $AppUI->_('Call Type')
. ":</label></td><td>"
. arraySelect( arrayMerge( array( '-1'=>'All' ), $ict ),
'item_calltype',
'size="1" id="call_type" class="text" onchange="changeList()"',
$calltype, true )
. "</td>";
}
}
// check for status filter
if ($HELPDESK_CONFIG['search_criteria_status']) {
if (isset( $_GET['item_status'] )) {
$AppUI->setState( 'HelpDeskStatus', $_GET['item_status'] );
}
$status = $AppUI->getState( 'HelpDeskStatus' ) !== null ? $AppUI->getState( 'HelpDeskStatus' ) : -1;
if ($status >= 0) {
$tarr[] = "hi.item_status=$status";
} elseif ($status == -2) {
$tarr[] = "hi.item_status<>2";
}
if (!$_REQUEST['project_id'] && !$_REQUEST['company_id']) {
$selectors[] = "<td align=\"right\"><label for=\"status\">"
. $AppUI->_('Status')
. ":</label></td><td>"
. arraySelect( arrayMerge( array( '-1'=>'All', '-2'=>'All (not closed)'), $ist ),
'item_status',
'size="1" id="status" class="text" onchange="changeList()"',
$status, true )
. "</td>";
}
}
// check for priority filter
if ($HELPDESK_CONFIG['search_criteria_priority']) {
if (isset( $_GET['item_priority'] )) {
$AppUI->setState( 'HelpDeskPriority', $_GET['item_priority'] );
}
$priority = $AppUI->getState( 'HelpDeskPriority' ) !== null ? $AppUI->getState( 'HelpDeskPriority' ) : -1;
if ($priority >= 0) {
$tarr[] = "hi.item_priority=$priority";
}
if (!$_REQUEST['project_id'] && !$_REQUEST['company_id']) {
$selectors[] = "<td align=\"right\"><label for=\"priority\">"
. $AppUI->_('Priority')
. ":</label></td><td>"
. arraySelect( arrayMerge( array( '-1'=>'All' ), $ipr ),
'item_priority',
'size="1" id="priority" class="text" onchange="changeList()"',
$priority, true )
. "</td>";
}
}
// check for severity filter
if ($HELPDESK_CONFIG['search_criteria_severity']) {
if (isset( $_GET['item_severity'] )) {
$AppUI->setState( 'HelpDeskSeverity', $_GET['item_severity'] );
}
$item_severity = $AppUI->getState( 'HelpDeskSeverity' ) !== null ? $AppUI->getState( 'HelpDeskSeverity' ) : -1;
if ($item_severity >= 0) {
$tarr[] = "hi.item_severity=$item_severity";
}
if (!$_REQUEST['project_id'] && !$_REQUEST['company_id']) {
$selectors[] = "<td align=\"right\"><label for=\"severity\">"
. $AppUI->_('Severity')
. ":</label></td><td>"
. arraySelect( arrayMerge( array( '-1'=>'All' ), $isv ),
'item_severity',
'size="1" id="severity" class="text" onchange="changeList()"',
$item_severity, true )
. "</td>";
}
}
// check for source filter
if ($HELPDESK_CONFIG['search_criteria_call_source']) {
if (isset( $_GET['item_source'] )) {
$AppUI->setState( 'HelpDeskSource', $_GET['item_source'] );
}
$item_source = $AppUI->getState( 'HelpDeskSource' ) !== null ? $AppUI->getState( 'HelpDeskSource' ) : -1;
if ($item_source >= 0) {
$tarr[] = "hi.item_source=$item_source";
}
if (!$_REQUEST['project_id'] && !$_REQUEST['company_id']) {
$selectors[] = "<td align=\"right\" nowrap><label for=\"call_source\">"
. $AppUI->_('Call Source')
. ":</label></td><td>"
. arraySelect( arrayMerge( array( '-1'=>$AppUI->_('All') ), $ics ),
'item_source',
'size="1" id="call_source" class="text" onchange="changeList()"',
$item_source, true)
. "</td>";
}
}
// check for os filter
if ($HELPDESK_CONFIG['search_criteria_service']) {
if (isset( $_GET['item_service'] )) {
$AppUI->setState( 'HelpDeskService', $_GET['item_service'] );
}
$item_service = $AppUI->getState( 'HelpDeskService' ) !== null ? $AppUI->getState( 'HelpDeskService' ) : -1;
if (isset($item_service) && strlen($item_service)>0 && $item_service!='-1') {
$tarr[] = "hi.item_service='$item_service'";
}
if (!$_REQUEST['project_id'] && !$_REQUEST['company_id']) {
$selectors[] = "<td align=\"right\"><label for=\"service\">"
. $AppUI->_('Service')
. ":</label></td><td>"
. arraySelect( arrayMerge( array( '-1'=>$AppUI->_('All') ), $ios ),
'item_service',
'size="1" id="service" class="text" onchange="changeList()"',
$item_service, true )
. "</td>";
}
}
// check for application filter
if ($HELPDESK_CONFIG['search_criteria_application']) {
if (isset( $_GET['item_application'] )) {
$AppUI->setState( 'HelpDeskApplication', $_GET['item_application'] );
}
$item_application = $AppUI->getState( 'HelpDeskApplication' ) !== null ? $AppUI->getState( 'HelpDeskApplication' ) : -1;
if (isset($item_application) && strlen($item_application)>0 && $item_application!='-1') {
$tarr[] = "hi.item_application='$item_application'";
}
if (!$_REQUEST['project_id'] && !$_REQUEST['company_id']) {
$selectors[] = "<td align=\"right\"><label for=\"application\">"
. $AppUI->_('Application')
. "</label>:</td><td>"
. arraySelect( arrayMerge( array( '-1'=>$AppUI->_('All') ), $iap ),
'item_application',
'size="1" id="application" class="text" onchange="changeList()"',
$item_application, true)
. "</td>";
}
}
// check for company filter
if ($HELPDESK_CONFIG['search_criteria_company']) {
if (isset( $_GET['company'] )) {
$AppUI->setState( 'HelpDeskCompany', $_GET['company'] );
}
if (empty($_REQUEST['company_id'])) {
$company = $AppUI->getState( 'HelpDeskCompany' ) !== null ? $AppUI->getState( 'HelpDeskCompany' ) : -1;
} else {
$company = $_REQUEST['company_id'];
}
if ($company >= 0) {
$tarr[] = "hi.item_company_id=$company";
}
if (!$_REQUEST['project_id'] && !$_REQUEST['company_id']) {
$selectors[] = "<td align=\"right\"><label for=\"company\">"
. $AppUI->_('Company')
. ":</label></td><td>"
. arraySelect( arrayMerge( array( '-1'=>$AppUI->_('All') ), $allowedCompanies ),
'company',
'size="1" id="company" class="text" onchange="changeList()"',
$company )
. "</td>";
}
}
// check for project filter
if ($HELPDESK_CONFIG['search_criteria_project']) {
if (isset( $_GET['project'] )) {
$AppUI->setState( 'HelpDeskProject', $_GET['project'] );
}
if (empty($_REQUEST['project_id'])) {
$project_id = $AppUI->getState( 'HelpDeskProject' ) !== null ? $AppUI->getState( 'HelpDeskProject' ) : -1;
} else {
$project_id = $_REQUEST['project_id'];
}
if ($project_id >= 0) {
$tarr[] = "hi.item_project_id=$project_id";
}
// retrieve project list
$project = new CProject();
$projects = $project->getAllowedProjects($AppUI->user_id);
$arrayProjects = array();
foreach ($projects as $prj_id => $prj_name) {
$arrayProjects[$prj_id] = $prj_name['project_name'];
}
if (!$_REQUEST['project_id']) {
$selectors[] = "<td align=\"right\"><label for=\"project\">"
. $AppUI->_('Project')
. ":</label></td><td>"
. arraySelect( arrayMerge( array( '-1'=>'('.$AppUI->_('All').')', '0'=>'('.$AppUI->_('Without Project').')' ), $arrayProjects ),
'project',
'size="1" id="project" class="text" onchange="changeList()"',
$project_id )
. "</td>";
}
}
// check for assigned_to filter
if ($HELPDESK_CONFIG['search_criteria_assigned_to']) {
if (isset( $_GET['assigned_to'] )) {
$AppUI->setState( 'HelpDeskAssignedTo', $_GET['assigned_to'] );
}
$assigned_to = $AppUI->getState( 'HelpDeskAssignedTo' ) !== null ? $AppUI->getState( 'HelpDeskAssignedTo' ) : -1;
if ($assigned_to >= 0) {
$tarr[] = "hi.item_assigned_to=$assigned_to";
}
// retrieve assigned to user list
$q = new w2p_Database_Query;
$q->addQuery('user_id, CONCAT(contact_first_name, \' \', contact_last_name)');
$q->addTable('users');
$q->addJoin('contacts','','contact_id = user_contact','INNER');
$q->addJoin('helpdesk_items','','item_assigned_to = user_id','INNER');
$q->addWhere(getCompanyPerms('contact_company', NULL, PERM_READ, $HELPDESK_CONFIG['the_company']));
$q->addOrder('contact_first_name');
$assigned_to_list = $q->loadHashList();
if (!$_REQUEST['project_id']) {
$selectors[] = "<td align=\"right\" nowrap><label for=\"assigned_to\">"
. $AppUI->_('Assigned To')
. ":</label></td><td>"
. arraySelect( arrayMerge( array( '-1'=>$AppUI->_('All') ), $assigned_to_list ),
'assigned_to',
'size="1" id="assigned_to" class="text" onchange="changeList()"',
$assigned_to )
. "</td>";
}
}
// check for requestor filter
if ($HELPDESK_CONFIG['search_criteria_requestor']) {
if (isset( $_GET['requestor'] )) {
$AppUI->setState( 'HelpDeskRequestor', $_GET['requestor'] );
}
$requestor = $AppUI->getState( 'HelpDeskRequestor' ) !== null ? $AppUI->getState( 'HelpDeskRequestor' ) : -1;
if (isset($requestor) && strlen($requestor)>0 && $requestor!='-1') {
$tarr[] = "hi.item_requestor='$requestor'";
}
// retrieve requestor list
$q = new w2p_Database_Query;
$q->addQuery('distinct(item_requestor) as requestor, item_requestor');
$q->addTable('helpdesk_items');
$q->addWhere(getCompanyPerms('item_company_id', NULL, PERM_READ));
$q->addOrder('item_requestor');
$requestor_list = $q->loadHashList();
if (!$_REQUEST['project_id']) {
$selectors[] = "<td align=\"right\"><label for=\"requestor\">"
. $AppUI->_('Requestor')
. ":</label></td><td>"
. arraySelect( arrayMerge( array( '-1'=>$AppUI->_('All') ), $requestor_list ),
'requestor',
'size="1" id="requestor" class="text" onchange="changeList()"',
$requestor )
. "</td>";
}
}
$where = getItemPerms();
if (count( $tarr )) {
$where .= ' AND ('.implode("\n AND ", $tarr).') ';
}
$q = new w2p_Database_Query;
$q->addQuery('hi.*,CONCAT(co.contact_first_name,\' \',co.contact_last_name) assigned_fullname,
p.project_id,p.project_name,p.project_color_identifier');
$q->addTable('helpdesk_items','hi');
$q->addJoin('users','u2','u2.user_id = hi.item_assigned_to');
$q->addJoin('contacts','co','u2.user_contact = co.contact_id');
$q->addJoin('projects','p','p.project_id = hi.item_project_id');
$q->addWhere($where);
// Do custom order by if needed, default at the end
if ($orderby == 'project_name') {
$order = 'p.project_name';
} elseif ($orderby == 'item_assigned_to') {
$order = 'assigned_fullname';
} elseif ($orderby == 'item_updated') {
$order = 'hi.item_updated';
} else {
$order = 'hi.' . $orderby;
}
if ($orderdesc) {
$order .= ' DESC';
}
// Pagination
$items_per_page = $HELPDESK_CONFIG['items_per_page'];
// Figure out number of total results, but do not retrieve
$total_results = db_num_rows($q->exec());
// Figure out the offset
$offset = $page * $items_per_page;
$q->addOrder($order);
$q->setLimit($items_per_page,$offset);
// Get the actual, paginated results
$rows = $q->loadList();
// Setup the title block
if (!$_REQUEST['project_id'] && !$_REQUEST['company_id']) {
#$titleBlock = new CTitleBlock( 'Help Desk', 'helpdesk.png', $m, 'ID_HELP_HELPDESK_IDX' );
$titleBlock = new w2p_Theme_TitleBlock( 'Help Desk', 'helpdesk.png', $m, 'ID_HELP_HELPDESK_IDX' );
if (hditemCreate()) {
$titleBlock->addCell(
'<input type="submit" class="button" value="'.$AppUI->_('new item').'" />', '',
'<form action="?m=helpdesk&a=addedit" method="post">', '</form>'
);
}
$titleBlock->addCrumb( "?m=helpdesk", "home" );
$titleBlock->addCrumb( "?m=helpdesk&a=list", "list" );
$titleBlock->addCrumb( "?m=helpdesk&a=reports", "reports" );
$titleBlock->show();
}
?>
<script language="javascript">
function changeList()
{
document.filterFrm.submit();
}
</script>
<?php
if (!$_REQUEST['project_id'] && !$_REQUEST['company_id']) {
?>
<table border="0" cellpadding="2" cellspacing="1" class="std" width="100%">
<form name="filterFrm" action="?index.php" method="get">
<input type="hidden" name="m" value="<?php echo $m?>" />
<input type="hidden" name="a" value="<?php echo $a?>" />
<tr>
<?php
$count = 1;
foreach ($selectors as $selector) {
print $selector;
if ($count%3==0) {
print "</tr>\n<tr>";
}
$count++;
}
implode("</tr>\n<tr>",$selectors)
?>
</tr>
</form>
</table>
<?php
}
?>
<table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">
<tr>
<th align="right" nowrap="nowrap">&nbsp;</th>
<th nowrap="nowrap"><?php echo sort_header("item_id", $AppUI->_('Number')); ?></th>
<th nowrap="nowrap"><?php echo sort_header("item_created", $AppUI->_('Opened On')); ?></th>
<th nowrap="nowrap"><?php echo sort_header("item_requestor", $AppUI->_('Requestor')); ?></th>
<th nowrap="nowrap"><?php echo sort_header("item_title", $AppUI->_('Title')); ?></th>
<th nowrap="nowrap"><?php echo sort_header("item_summary", $AppUI->_('Summary')); ?></th>
<th nowrap="nowrap"><?php echo sort_header("item_assigned_to", $AppUI->_('Assigned To')); ?></th>
<th nowrap="nowrap"><?php echo sort_header("item_status", $AppUI->_('Status')); ?></th>
<th nowrap="nowrap"><?php echo sort_header("item_priority", $AppUI->_('Priority')); ?></th>
<th nowrap="nowrap"><?php echo sort_header("item_updated", $AppUI->_('Updated')); ?></th>
<th nowrap="nowrap"><?php echo sort_header("item_deadline", $AppUI->_('Deadline')); ?></th>
<th nowrap="nowrap"><?php echo sort_header("project_name", $AppUI->_('Project')); ?></th>
</tr>
<?php
$s = '';
foreach ($rows as $row) {
$canEdit = hditemEditable($row);
/* We need to check if the user who requested the item is still in the
system. Just because we have a requestor id does not mean we'll be
able to retrieve a full name */
$s .= $CR . '<form method="post">';
$s .= $CR . '<tr>';
$s .= $CR . '<td align="right" nowrap>';
if ($canEdit) {
$s .= $CR . '<a href="?m=helpdesk&a=addedit&item_id='
. $row['item_id']
. '">'
. w2PshowImage('pencil.gif', 12, 12, 'edit')
. '</a>&nbsp;';
}
$s .= $CR . '</td>';
$s .= $CR . '<td nowrap="nowrap"><a href="./index.php?m=helpdesk&a=view&item_id='
. $row['item_id']
. '">'
. '<strong>'
. $row['item_id']
. '</strong></a> '
. w2PshowImage ('ct'.$row['item_calltype'].'.png', 15, 17, '','', $m )
. '</td>';
// KZHAO: Display the creation date
$date = new w2p_Utilities_Date( $row['item_created'] );
//Check whether the creation date is available
if ($row['item_created']==NULL) {
$s .= $CR . "<td nowrap><a title='Unknown'>N/A</a></td>";
} else {
$s .= $CR . "<td nowrap><a title='".$date->format( $format )."'>".get_time_ago($row['item_created'])."</a></td>";
}
$s .= $CR . "<td nowrap align=\"center\">";
if ($row['item_requestor_email']) {
$s .= $CR . "<a href=\"mailto:".$row['item_requestor_email']."\">"
. $row['item_requestor']
. "</a>";
} else {
$s .= $CR . $row['item_requestor'];
}
$s .= $CR . "</td>";
$s .= $CR . '<td width="20%"><a href="?m=helpdesk&a=view&item_id=' . $row['item_id'] . '">'
. $HELPDESK_CONFIG['new_hd_item_title_prefix'] . ' ' . $row['item_title']
. '</a></td>';
$s .= $CR . '<td width="80%">'
. substr($row['item_summary'],0,max(strpos($row['item_summary']."\n","\n"),70))
. ' </td>';
$s .= $CR . "<td nowrap align=\"center\">";
if ($row['item_assigned_to']) {
$user = new CUser();
$user->load($row['item_assigned_to']);
$contact = new CContact();
$contact->contact_id = $user->user_contact;
$contactMethods = $contact->getContactMethods(array('email_primary'));
$assigned_email = $contactMethods['email_primary'];
$s .= $CR . "<a href=\"mailto:".$assigned_email."\">"
. $row['assigned_fullname']
. "</a>";
} else {
$s .= $CR . $row['assigned_fullname'];
}
$s .= $CR . "</td>";
$s .= $CR . '<td align="center" nowrap>' . $AppUI->_($ist[@$row['item_status']]) . '</td>';
$s .= $CR . '<td align="center" nowrap>' . $AppUI->_($ipr[@$row['item_priority']]) . '</td>';
// Display the date of updating
$dateu = new w2p_Utilities_Date( $row['item_updated'] );
//Check which date is available
if ($row['item_updated']!=NULL) {
$s .= $CR . "<td align='center' nowrap><a title='".@$dateu->format($format)."'>".get_time_ago($row['item_updated'])."</a></td>";
} elseif ($row['item_modified']!=NULL) {
$dateu = new w2p_Utilities_Date( $row['item_modified'] );
$s .= $CR . "<td align='center' nowrap><a title='".@$dateu->format($format)."'>".get_time_ago($row['item_modified'])."</a></td>";
} else {
$s .= $CR . "<td align='center' nowrap><a title='Unknown'>N/A</a></td>";
}
// KZHAO 8-10-2006
// Display deadline
if ($ist[@$row['item_status']]=='Close') {
} elseif ($row['item_deadline']!=NULL) {
$dl=new w2p_Utilities_Date ($row['item_deadline']);
$s .= $CR . "<td align='center' nowrap><a title='".@$dl->format($format)."'>".get_due_time($row['item_deadline'],1)."</a></td>";
} else {
$s .= $CR . "<td align='center' nowrap><a title='Unknown'>N/A</a></td>";
}
if ($row['project_id']) {
$s .= $CR . '<td align="center" style="background-color: #'
. $row['project_color_identifier']
. ';" nowrap><a href="./index.php?m=projects&a=view&project_id='
. $row['project_id'].'" style="color: '
. bestColor( @$row['project_color_identifier'] )
. ';">'
. $row['project_name']
.'</a></td>';
} else {
$s .= $CR . '<td align="center">-</td>';
}
$s .= $CR . '</tr></form>';
}
print "$s\n";
// Pagination
$pages = 0;
if ($total_results > $items_per_page) {
$pages_per_side = $HELPDESK_CONFIG['pages_per_side'];
$pages = ceil($total_results / $items_per_page) - 1;
if ($page < $pages_per_side) {
$start = 0;
} else {
$start = $page - $pages_per_side;
}
if ($page > ($pages - $pages_per_side)) {
$end = $pages;
} else {
$end = $page + $pages_per_side;
}
print "<tr><td colspan=\"12\" align=\"center\">";
$link = "?m=helpdesk&a=list&page=";
if ($page > 0) {
print "<a href=\"{$link}0\">&larr; "
. $AppUI->_('First')
. "</a>&nbsp;&nbsp;";
print "<a href=\"$link"
. ($page - 1)
. "\">&larr; "
. $AppUI->_('Previous')
. "</a>&nbsp;&nbsp;";
}
for ($i = $start; $i <= $end; $i++) {
if ($i == $page) {
print " <b>".($i + 1)."</b> ";
} else {
print " <a href=\"$link$i\">"
. ($i + 1)
. "</a> ";
}
}
if ($page < $pages) {
print "&nbsp;&nbsp;<a href=\"$link"
. ($page + 1)
. "\">"
. $AppUI->_('Next')
. "&rarr;</a>";
print "&nbsp;&nbsp;<a href=\"$link$pages\">"
. $AppUI->_('Last')
. " &rarr;</a>";
}
print "</td></tr>";
}
echo '<tr><td colspan="12" align="center">';
echo $total_results.' ';
echo ($total_results == 1) ? $AppUI->_('Item') : $AppUI->_('Items');
echo ' '.$AppUI->_('found');
echo '</td></tr>';
?>
</table>
<?php
print "<center><small>";
if ($pages > 0) {
print ", "
. ($pages + 1)
. " "
. $AppUI->_('Pages');
}
print "</small></center>";
// Returns a header link used to sort results
// TODO Probably need a better up/down arrow
function sort_header($field, $name)
{
global $orderby, $orderdesc;
$arrow = "";
if (!$_REQUEST['project_id'] && !$_REQUEST['company_id']) {
$link = "<a class=\"hdr\" href=\"?m=helpdesk&a=list&orderby=$field&orderdesc=";
} else {
if (!$_REQUEST['project_id']) {
$link = "<a class=\"hdr\" href=\"?m=companies&a=view&company_id={$_REQUEST['company_id']}&orderby=$field&orderdesc=";
} else {
$link = "<a class=\"hdr\" href=\"?m=projects&a=view&project_id={$_REQUEST['project_id']}&orderby=$field&orderdesc=";
}
}
if ($orderby == $field) {
$link .= $orderdesc ? "0" : "1";
$arrow .= $orderdesc ? " &uarr;" : " &darr;";
} else {
$link .= "0";
}
$link .= "\">$name</a>$arrow";
return $link;
}
##
## DO NOT MODIFY THIS FILE BY HAND!
##
'new log',
'Add Log',
'Adding Help Desk Item',
'Ago',
'All (not closed)',
'All Companies and All Projects',
'All Helpdesk task log entries',
'All users',
'Amount',
'Application',
'Assigned To',
'Attach a file',
'Bug',
'Call Source',
'Call Type',
'Closed',
'Closed On',
'Closed Today',
'Comments',
'Company',
'Complaint',
'Configure Help Desk Module',
'Cost',
'Cost Code',
'Created',
'Created by',
'Critical',
'Date Created',
'Deadline',
'Default Actions',
'Delete this item',
'Deleted',
'E-Lodged',
'E-Mail',
'Edit log',
'Edit this item',
'Editing Help Desk Item',
'Email Notification',
'Feature Request',
'First',
'For period',
'Help Desk',
'Help Desk Item',
'Help Desk Item ID is NULL',
'Help Desk Items',
'Helpdesk Reports',
'Helpdesk Task Log Report',
'Helpdesk Task Logs',
'Helpdesk task log entries from',
'High',
'Home',
'Hours',
'Hours Worked',
'Ignore 0 hours',
'In Person',
'Invalid item id',
'IsNowWatched'=>'has been added to your watch list.',
'Item',
'Item Created',
'Item Details',
'Item History',
'Items',
'Last',
'Link',
'List',
'Log All',
'Low',
'Make PDF',
'Medium',
'My Open',
'New Helpdesk Log',
'New Item',
'New Item Default Selections',
'New Log',
'Next',
'Next Day',
'Next Month',
'Next Week',
'No Impact',
'Not Specified',
'Notify by e-mail',
'Number',
'OS',
'Off',
'On',
'On Hold',
'Open',
'Opened On',
'Opened Today',
'Operating System',
'Pages',
'Paging Options',
'Permission Options',
'Previous',
'Previous Day',
'Previous Month',
'Previous Week',
'Priority',
'Project',
'Report Totals',
'Requestor',
'Requestor E-mail',
'Requestor Phone',
'Required field',
'Reset',
'Search Fields On Item List',
'Severity',
'Start',
'Status',
'Subject',
'Suggestion',
'Summary',
'Task Log',
'Task Logs',
'Testing',
'This helpdesk item has been exported to task',
'This task is exported from Helpdesk item',
'Ticket',
'Ticket Detail',
'Ticket ID',
'Title',
'Title/Summary Search',
'Type',
'URL',
'Unassigned',
'Update',
'Updated',
'Updated Today',
'View this item',
'Viewing Help Desk Item',
'WWW',
'Watched'=>'now being watched',
'Watched Tickets',
'Watchers',
'Watchers Notification',
'Without Project',
'added',
'ago',
'cancel',
'cannot be opened',
'cannot be written to',
'changed from',
'create task log',
'day',
'days',
'delete this item',
'edit this item',
'export this item to task',
'found',
'has been successfully updated',
'helpdeskDefCompany'=>'Default \"company\" field to be that of the current user',
'helpdeskDefCurUser'=>'Default \"assigned to\" field to be the current user',
'helpdeskDefNotify'=>'Default the \"notify by email\" field to on',
'helpdeskDefThisUser'=>'Default \"assigned to\" field to be this user',
'helpdeskFieldMessage'=>'If you select your name from the popup window, your e-mail address and phone number will be populated from your account details (if available).',
'helpdeskHDCompany'=>'The company which handles Help Desk items',
'helpdeskHDDepartment'=>'The department which handles Help Desk items',
'helpdeskItemsNoCompany'=>'Items with no company should be editable by anyone',
'helpdeskItemsPerPage'=>'Number of items displayed per page on the list view',
'helpdeskLogsPerPage'=>'Number of status log items displayed per page in item view',
'helpdeskMinLevel'=>'Minimum user level to edit other users\' logs',
'helpdeskMinRepLevel'=>'Minimum user level to view reports',
'helpdeskPagesPerSide'=>'Number of pages to display on each side of current page',
'helpdeskSignature'=>'The IT Department',
'helpdeskSubmitError'=>'You must enter the following value(s)',
'helpdeskUseProjectPerms'=>'Project list based on Project, as opposed to Company, permissions.',
'home',
'hours',
'is not writable',
'list',
'month',
'months',
'new item',
'save',
'to',
'update task log',
'value for the previous buttons',
'view this item',
'week',
'weeks',
'year',
'years',
##
## DO NOT MODIFY THIS FILE BY HAND!
##
'Add Log'=>'Ajouter une action',
'Adding Help Desk Item'=>'Ajout d\'une demande d\'assistance',
'Ago'=>'passé(e)',
'All (not closed)'=>'Tous (non fermés)',
'All Companies and All Projects'=>'Toutes les sociétés et tous les projets',
'All Helpdesk task log entries'=>'Tout le temps passé pour assistance',
'All users'=>'Tous',
'Amount'=>'Montant',
'Application'=>'Application',
'Assigned To'=>'Assignée à ',
'Attach a file'=>'Joindre un fichier',
'Bug'=>'Bogue',
'Call Source'=>'Source de l\'appel',
'Call Type'=>'Type d\'appel',
'Closed'=>'Fermée',
'Closed On'=>'Fermée le',
'Closed Today'=>'Fermées aujourd\'hui',
'Comments'=>'Commentaires',
'Company'=>'Société',
'Complaint'=>'Plainte',
'Configure Help Desk Module'=>'Configurer le module d\'assistance',
'Cost'=>'Coût',
'Cost Code'=>'C.Coût',
'Created'=>'Créée',
'Created by'=>'Créée par',
'Critical'=>'Critique',
'Date Created'=>'Date de création',
'Deadline'=>'Échéance',
'Default Actions'=>'Actions',
'Delete this item'=>'Supprimer cette demande d\'assistance',
'Deleted'=>'Supprimée',
'E-Lodged'=>'Automatique',
'E-Mail'=>'Courriel',
'Edit log'=>'Editer l\'action',
'Edit this item'=>'Editer cette demande d\'assistance',
'Editing Help Desk Item'=>'Edition de la demande d\'assistance',
'Email Notification'=>'Informer par courriel',
'Feature Request'=>'Demande de fonctionalité',
'First'=>'Première',
'For period'=>'Pour la période',
'Help Desk'=>'Centre d\'assistance',
'Help Desk Item'=>'Demande d\'assistance',
'Help Desk Item ID is NULL'=>'L\'ID de la demande est nulle',
'Help Desk Items'=>'Demandes d\'assistance',
'Helpdesk Reports'=>'Rapports de demandes d\'assistance',
'Helpdesk Task Log Report'=>'Rapport de temps passé pour assistance',
'Helpdesk Task Logs'=>'Temps passé pour assistance',
'Helpdesk task log entries from'=>'Temps passé pour assistance du',
'High'=>'Elevé',
'Home'=>'Accueil',
'Hours'=>'Heures',
'Hours Worked'=>'Heures travaillées',
'Ignore 0 hours'=>'Ignorer les heures à 0',
'In Person'=>'En personne',
'Invalid item id'=>'ID de demande invalide',
'IsNowWatched'=>'A été ajoutée à votre liste de surveillance.',
'Item'=>'Demande',
'Item Created'=>'Demande créée',
'Item Details'=>'Détails de la demande',
'Item History'=>'Historique de la demande',
'Items'=>'Demandes',
'Last'=>'Dernière',
'Link'=>'Lien',
'List'=>'Liste',
'Log All'=>'Montrer tout',
'Low'=>'Bas',
'Make PDF'=>'Générer en PDF',
'Medium'=>'Moyen',
'My Open'=>'Mes demandes ouvertes',
'New Helpdesk Log'=>'Nouvelle action',
'New Item'=>'Nouvelle demande',
'New Item Default Selections'=>'Sélection par défaut pour nouvelle demande',
'New Log'=>'Nouveau temps',
'Next'=>'Prochaine',
'Next Day'=>'Jour suivant',
'Next Month'=>'Mois suivant',
'Next Week'=>'Semaine suivante',
'No Impact'=>'Aucun Impact',
'Not Specified'=>'Non spécifié',
'Notify by e-mail'=>'Informer par courriel',
'Number'=>'Numéro',
'OS'=>'SE',
'Off'=>'Eteinte',
'On'=>'Allumée',
'On Hold'=>'En Attente',
'Open'=>'Ouverte',
'Opened On'=>'Ouverte le',
'Opened Today'=>'Ouvertes aujourd\'hui',
'Operating System'=>'Système d\'exploitation',
'Pages'=>'Pages',
'Paging Options'=>'Options de pagination',
'Permission Options'=>'Options d\'authorisation',
'Previous'=>'Précédente',
'Previous Day'=>'Jour précédent',
'Previous Month'=>'Mois précédent',
'Previous Week'=>'Semaine précédente',
'Priority'=>'Priorité',
'Project'=>'Projet',
'Report Totals'=>'Totaux',
'Requestor'=>'Demandeur',
'Requestor E-mail'=>'Courriel du demandeur',
'Requestor Phone'=>'Téléphone du demandeur',
'Required field'=>'Champ obligatoire',
'Reset'=>'Réintialiser',
'Search Fields On Item List'=>'Rechercher les champs dans la liste de demandes',
'Severity'=>'Sévérité',
'Start'=>'Début',
'Status'=>'Statut',
'Subject'=>'Titre',
'Suggestion'=>'Suggestion',
'Summary'=>'Résumé',
'Task Log'=>'Temps passé',
'Task Logs'=>'Temps passé',
'Testing'=>'En cours de test',
'This helpdesk item has been exported to task'=>'Cette demande a été transformée dans la tâche',
'This task is exported from Helpdesk item'=>'Cette demande a été transformée de la demande',
'Ticket'=>'Demande',
'Ticket Detail'=>'Détails de la demande',
'Ticket ID'=>'Demande #',
'Title'=>'Titre',
'Title/Summary Search'=>'Recherche Titre/Résumé',
'Type'=>'Type',
'URL'=>'URL',
'Unassigned'=>'Non-assignée',
'Update'=>'Mise à jour',
'Updated'=>'mise à jour',
'Updated Today'=>'Mise à jour aujourd\'hui\'',
'View this item'=>'Voir cette demande',
'Viewing Help Desk Item'=>'Visualisation de la demande d\'assistance',
'WWW'=>'Internet',
'Watched'=>'maintenant surveillée',
'Watched Tickets'=>'Demandes surveillées',
'Watchers'=>'Surveillants',
'Watchers Notification'=>'Avis de surveillance',
'Without Project'=>'Sans projet',
'added'=>'ajoutée',
'ago'=>'passé(e)',
'cancel'=>'Annuler',
'cannot be opened'=>'impossible d\'ouvrir',
'cannot be written to'=>'impossible d\'écrire',
'changed from'=>'changé depuis',
'create task log'=>'créer une action',
'day'=>'jour',
'days'=>'jours',
'delete this item'=>'Supprimer cette demande',
'edit this item'=>'Éditer cette demande',
'export this item to task'=>'Transformer cette demande en tâche',
'found'=>'trouvée(s)',
'has been successfully updated'=>'mise à jour réussie',
'helpdeskDefCompany'=>'Champ \'société\' par défaut pour l\'utilisateur courant',
'helpdeskDefCurUser'=>'Champ \'assigné à\' par défaut pour l\'utilisateur courant',
'helpdeskDefNotify'=>'Champ \'informer par courriel\' coché par défaut',
'helpdeskDefThisUser'=>'Champ \'assigné à\' par défaut pour cet utilisateur',
'helpdeskFieldMessage'=>'Si vous choisissez le nom dans le fenêtre, votre adresse email et votre numéro de téléphone seront pré-remplis avec les valeurs de votre compte utilisateur (si disponibles) ',
'helpdeskHDCompany'=>'La société qui prend les demandes en charge',
'helpdeskHDDepartment'=>'Le département qui prend les demandes en charge',
'helpdeskItemsNoCompany'=>'Les demandes sans sociétés devraient être éditables par tout le monde',
'helpdeskItemsPerPage'=>'Nombre de demandes affichées par page dans la vue principale',
'helpdeskLogsPerPage'=>'Nombre d\'actions affichées par page dans la vue \'item\'',
'helpdeskMinLevel'=>'Niveau minimal d\'utilisateur pour pouvoir éditer les actions d\'autres utilisateurs',
'helpdeskMinRepLevel'=>'Niveau minimal d\'utilisateur pour pouvoir visualiser les rapports',
'helpdeskPagesPerSide'=>'Nombre de pages à afficher sur chaque coté de la page courante',
'helpdeskSignature'=>'L\'équipe du département d\'informatique',
'helpdeskSubmitError'=>'Vous devez entrer les valeurs suivantes',
'helpdeskUseProjectPerms'=>'Les permissions sont basées sur les projets plutôt que sur la société.',
'home'=>'Résumé',
'hours'=>'heures',
'is not writable'=>'impossible d\'écrire',
'list'=>'Liste',
'month'=>'mois',
'months'=>'mois',
'new item'=>'Nouvelle demande',
'new log'=>'Nouveau temps',
'save'=>'Enregistrer',
'to'=>'à',
'update task log'=>'mettre à jour le temps passé',
'value for the previous buttons'=>'valeur pour les boutons d\'action',
'view this item'=>'visualiser cette demande',
'week'=>'semaine',
'weeks'=>'semaines',
'year'=>'année',
'years'=>'années',
##
## DO NOT MODIFY THIS FILE BY HAND!
##
'Add Log'=>'Novo Registo',
'Adding Help Desk Item'=>'A Adicionar Item',
'Ago'=>'Atrs',
'All (not closed)'=>'Tudo (por fechar)',
'All Companies and All Projects'=>'Todas as Empresas e Todos os Projectos',
'All Helpdesk task log entries'=>'Todos os Registos do Helpdesk',
'All users'=>'Todos',
'Amount'=>'Montante',
'Application'=>'Aplicao',
'Assigned To'=>'Atribuido a',
'Attach a file'=>'Anexar ficheiro',
'Bug'=>'Bug',
'Call Source'=>'Origem do Item',
'Call Type'=>'Tipo de Pedido',
'Closed'=>'Fechado',
'Closed On'=>'Fechado em',
'Closed Today'=>'Fechado hoje',
'Comments'=>'Observaes',
'Company'=>'Empresa',
'Complaint'=>'Reclamao',
'Configure Help Desk Module'=>'Configurar Helpdesk',
'Cost'=>'Custo',
'Cost Code'=>'C.Custo',
'Created'=>'Criado',
'Created by'=>'Criado por',
'Critical'=>'Urgente',
'Date Created'=>'Data de Criao',
'Deadline'=>'Data Limite',
'Default Actions'=>'Aces por Defeito',
'Delete this item'=>'Eliminar este item',
'Deleted'=>'Eliminado',
'E-Lodged'=>'Web',
'E-Mail'=>'E-Mail',
'Edit log'=>'Editar registo',
'Edit this item'=>'Editar este Item',
'Editing Help Desk Item'=>'A Editar Item de Helpdesk',
'Email Notification'=>'Notificar por Email',
'Feature Request'=>'Pedido de Funcionalidade',
'First'=>'Primeiro',
'For period'=>'Para o periodo',
'Help Desk'=>'Help Desk',
'Help Desk Item'=>'Item de Help Desk',
'Help Desk Item ID is NULL'=>'O ID do Item NULO',
'Help Desk Items'=>'Itens de Help Desk',
'Helpdesk Reports'=>'Relatrios do Help Desk',
'Helpdesk Task Log Report'=>'Relatrio de Registos do Help Hesk',
'Helpdesk Task Logs'=>'Registos do Help Desk',
'Helpdesk task log entries from'=>'Registos do Help Desk desde',
'High'=>'Alta',
'Home'=>'Princpio',
'Hours'=>'Horas',
'Hours Worked'=>'Horas de trabalho',
'Ignore 0 hours'=>'Ignorar horas a 0',
'In Person'=>'Em pessoa',
'Invalid item id'=>'ID do item invlido',
'IsNowWatched'=>'Adicionou o Item sua lista de superviso',
'Item'=>'Item',
'Item Created'=>'Item Criado',
'Item Details'=>'Detalhes do Item',
'Item History'=>'Histrico do Item',
'Items'=>'Itens',
'Last'=>'Ultimo',
'Link'=>'Link',
'List'=>'Lista',
'Log All'=>'Mostrar Tudo',
'Low'=>'Baixa',
'Make PDF'=>'Criar PDF',
'Medium'=>'Mdia',
'My Open'=>'Meus em Aberto',
'New Helpdesk Log'=>'Novo Registo de Help Desk',
'New Item'=>'Novo Item',
'New Item Default Selections'=>'Seleces por Defeito para Novos Itens',
'New Log'=>'Novo Registo',
'Next'=>'Prximo',
'Next Day'=>'Prximo Dia',
'Next Month'=>'Prcimo Ms',
'Next Week'=>'Prxima Semana',
'No Impact'=>'Sem Impacto',
'Not Specified'=>'No Especificado',
'Notify by e-mail'=>'Notificar por Email',
'Number'=>'Nmero',
'OS'=>'SO',
'Off'=>'Desligar',
'On'=>'Ligar',
'On Hold'=>'Em Espera',
'Open'=>'Aberto',
'Opened On'=>'Aberto Em',
'Opened Today'=>'Aberto Hoje',
'Operating System'=>'Sistema Operativo',
'Pages'=>'Pginas',
'Paging Options'=>'Opes de Paginao',
'Permission Options'=>'Permisses',
'Previous'=>'Anterior',
'Previous Day'=>'Dia Anterior',
'Previous Month'=>'Ms Anterior',
'Previous Week'=>'Semana Anterior',
'Priority'=>'Prioridade',
'Project'=>'Projecto',
'Report Totals'=>'Total',
'Requestor'=>'Pedido por',
'Requestor E-mail'=>'Email',
'Requestor Phone'=>'Telefone',
'Required field'=>'Campo obrigatrio',
'Reset'=>'Reiniciar',
'Search Fields On Item List'=>'Campos de Procura',
'Severity'=>'Gravidade',
'Start'=>'Comeo',
'Status'=>'Estado',
'Subject'=>'Assunto',
'Suggestion'=>'Sugesto',
'Summary'=>'Sumrio',
'Task Log'=>'Registo',
'Task Logs'=>'Registos',
'Testing'=>'Em testes',
'This helpdesk item has been exported to task'=>'Este Item foi exportado para um a Tarefa',
'This task is exported from Helpdesk item'=>'Esta tarefa foi exportada de um Item do Help Desk',
'Ticket'=>'Pedido',
'Ticket Detail'=>'Detalhes do Pedido',
'Ticket ID'=>'Pedido #',
'Title'=>'Assunto',
'Title/Summary Search'=>'Procura por Assunto/Sumrio',
'Type'=>'Tipo',
'URL'=>'URL',
'Unassigned'=>'Por Atribuir',
'Update'=>'Actualizar',
'Updated'=>'Actualizado',
'Updated Today'=>'Actualizado Hoje',
'View this item'=>'Ver este Item',
'Viewing Help Desk Item'=>'A ver Item de Help Desk',
'WWW'=>'Internet',
'Watched'=>'Supervisionado',
'Watched Tickets'=>'Pedidos Supervisionados',
'Watchers'=>'Supervisores',
'Watchers Notification'=>'Notificao aos Supervisores',
'Without Project'=>'Sem Projecto',
'added'=>'adicionado',
'ago'=>'atrs',
'cancel'=>'cancelar',
'cannot be opened'=>'no possvel abrir',
'cannot be written to'=>'no possvel gravar',
'changed from'=>'mudado desde',
'create task log'=>'criar registo de tarefa',
'day'=>'dia',
'days'=>'dias',
'delete this item'=>'eliminar este item',
'edit this item'=>'editar este item',
'export this item to task'=>'converter este item numa tarefa',
'found'=>'encontrado',
'has been successfully updated'=>'foi actualizado com sucesso',
'helpdeskDefCompany'=>'Definir Campo da Empresa igual ao do utilizador por defeito',
'helpdeskDefCurUser'=>'Definir atribuio ao utilizador por defeito',
'helpdeskDefNotify'=>'Notificao por Email ligada por defeito',
'helpdeskDefThisUser'=>'Definir atribuio ao prprio utlizador por defeito',
'helpdeskFieldMessage'=>'Se escolher o seu nome da janela de pop-up, o seu endereo de email e telfone sero adicionados ao item (se disponveis)',
'helpdeskHDCompany'=>'a Empresa que gere os Itens',
'helpdeskHDDepartment'=>'O Departamento que gere os Itens',
'helpdeskItemsNoCompany'=>'Itens sem Empresa podem ser editados por todos',
'helpdeskItemsPerPage'=>'Nmero de registos por pgina na lista de itens',
'helpdeskLogsPerPage'=>'Nmero de registos por pgina na vista de item',
'helpdeskMinLevel'=>'Nvel mnimo do utilizador para poder alterar registos de outros utilizadores',
'helpdeskMinRepLevel'=>'Nvel mnimo do utilizador para poder ver relatrios',
'helpdeskPagesPerSide'=>'Nmero de pginas a mostrar em cada lado da pgina actual',
'helpdeskSignature'=>'Departamento do Help Desk',
'helpdeskSubmitError'=>'Tem de preencher os seguintes campos',
'helpdeskUseProjectPerms'=>'Lista de Projectos baseada nas Permisses dos Projectos invs das Empresas',
'home'=>'resumo',
'hours'=>'horas',
'is not writable'=>'sem permisso de escrita',
'list'=>'lista',
'month'=>'ms',
'months'=>'meses',
'new item'=>'novo item',
'new log'=>'novo registo',
'save'=>'gravar',
'to'=>'para',
'update task log'=>'actualizar registo de tarefa',
'value for the previous buttons'=>'valor para os botes anteriores',
'view this item'=>'ver este item',
'week'=>'semana',
'weeks'=>'semanas',
'year'=>'ano',
'years'=>'anos',
<?php /* HELPDESK $Id: vw_idx_my.php,v 1.3 2004/08/03 03:27:05 cyberhorse Exp $*/
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
include_once 'helpdesk.functions.php';
global $AppUI, $project_id, $deny, $canRead, $canEdit, $w2Pconfig, $showCompany, $company_id;
$showCompany = false;
if (canView('helpdesk')) {
if (canEdit('helpdesk')) {
echo '<a href="./index.php?m=helpdesk&a=addedit&project_id=' . $project_id . '&company_id=' . $company_id . '">' . $AppUI->_('Add Issue') . '</a>';
echo w2PshowImage('stock_attach-16.png', 16, 16, '', '', $m);
}
vw_idx_handler(3);
}
<?php /* PROJECTS $Id: reports.php,v 1.1 2005/11/10 21:59:02 pedroix Exp $ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
$project_id = (int) w2PgetParam( $_REQUEST, "project_id", 0 );
$report_type = w2PgetParam( $_REQUEST, "report_type", '' );
// check permissions for this record
$perms =& $AppUI->acl();
$canRead = $perms->checkModule( $m, 'view' );
if (!$canRead) {
$AppUI->redirect(ACCESS_DENIED);
}
//$can_view_reports = $HELPDESK_CONFIG['minimum_report_level']>=$AppUI->user_type;
//if (!$can_view_reports) {
// $AppUI->redirect(ACCESS_DENIED);
//}
$obj = new CProject();
$q = new w2p_Database_Query;
$q->addQuery('pr.project_id, pr.project_status, pr.project_name, pr.project_description, pr.project_short_name');
$q->addTable('projects','pr');
$q->addGroup('pr.project_id');
$q->addOrder('pr.project_short_name');
$obj->setAllowedSQL($AppUI->user_id, $q);
$project_list=array("0"=> $AppUI->_("All", UI_OUTPUT_RAW) );
$ptrc = $q->exec();
$nums=db_num_rows($ptrc);
echo db_error();
for ($x=0; $x < $nums; $x++) {
$row = db_fetch_assoc( $ptrc );
if ($row["project_id"] == $project_id)
$display_project_name='('.$row["project_short_name"].') '.$row["project_name"];
$project_list[$row["project_id"]] = '('.$row["project_short_name"].') '.$row["project_name"];
}
$q->clear();
if (! $suppressHeaders) {
?>
<script language="javascript">
function changeIt(obj)
{
var f=document.changeMe;
f.submit();
}
</script>
<?php
}
// get the prefered date format
$df = $AppUI->getPref('SHDATEFORMAT');
$reports = $AppUI->readFiles( w2PgetConfig( 'root_dir' )."/modules/$m/reports", "\.php$" );
// setup the title block
if (! $suppressHeaders) {
$titleBlock = new w2p_Theme_TitleBlock( 'Helpdesk Reports', 'helpdesk.png', $m, "$m.$a" );
$titleBlock->addCrumb( "?m=helpdesk", "home" );
$titleBlock->addCrumb( "?m=helpdesk&a=list", "list" );
if ($report_type) {
$titleBlock->addCrumb( "?m=helpdesk&a=reports&project_id=$project_id", "reports" );
}
$titleBlock->show();
}
$report_type_var = w2PgetParam($_GET, 'report_type', '');
if (!empty($report_type_var))
$report_type_var = '&report_type=' . $report_type;
if (! $suppressHeaders) {
if (!isset($display_company_name)) {
if (!isset($display_project_name)) {
$display_project_name = "None";
} else {
echo $AppUI->_('Selected Project') . ": <b>".$display_project_name."</b>";
$display_company_name = "None";
}
} else {
echo $AppUI->_('Selected Company') . ": <b>".$display_company_name."</b>";
}
?>
<form name="changeMe" action="./index.php?m=helpdesk&a=reports<?php echo $report_type_var; ?>" method="post">
<table width="100%" cellspacing="0" cellpadding="4" border="0" class="std">
<tr>
<td><?php echo $AppUI->_('Projects') . ':';?></td>
<td><?php echo arraySelect( $project_list, 'project_id', 'size="1" class="text" onchange="changeIt(this);"', $project_id, false );?></td>
</tr>
<tr>
<td colspan="2">
<?php
}
if ($report_type) {
$report_type = $AppUI->checkFileName( $report_type );
$report_type = str_replace( ' ', '_', $report_type );
require "$baseDir/modules/$m/reports/$report_type.php";
} else {
echo "<table>";
echo "<tr><td><h2>" . $AppUI->_( 'Reports Available' ) . "</h2></td></tr>";
foreach ($reports as $v) {
$type = str_replace( ".php", "", $v );
$desc_file = str_replace( ".php", ".{$AppUI->user_locale}.txt", $v );
$desc = @file( "$baseDir/modules/$m/reports/$desc_file");
echo "\n<tr>";
echo "\n <td><a href=\"index.php?m=$m&a=reports&project_id=$project_id&report_type=$type";
if (isset($desc[2]))
echo "&" . $desc[2];
echo "\">";
echo @$desc[0] ? $desc[0] : $v;
echo "</a>";
echo "\n</td>";
echo "\n<td>" . (@$desc[1] ? "- $desc[1]" : '') . "</td>";
echo "\n</tr>";
}
echo "</table>";
}
?>
</td>
</tr>
</table>
</form>
Helpdesk List
View the Projects Helpdesk List
<?php /* $Id: tasklist.php 156 2008-04-11 15:47:40Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/reports/reports/tasklist.php $ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
/**
*
* Generates a report of the helpdesk logs for given dates including task logs
* Based on the original report tasklist.php by jcgonz
*/
global $AppUI, $cal_sdf;
$AppUI->loadCalendarJS();
$do_report = w2PgetParam($_POST, 'do_report', 0);
$log_all = w2PgetParam($_POST, 'log_all', 0);
$log_pdf = w2PgetParam($_POST, 'log_pdf', 0);
$log_ignore = w2PgetParam($_POST, 'log_ignore', 0);
$days = w2PgetParam($_POST, 'days', 30);
$list_start_date = w2PgetParam($_POST, 'list_start_date', 0);
$list_end_date = w2PgetParam($_POST, 'list_end_date', 0);
$period = w2PgetParam($_POST, 'period', 0);
$period_value = w2PgetParam($_POST, 'pvalue', 1);
if ($period) {
$today = new w2p_Utilities_Date();
$ts = $today->format(FMT_TIMESTAMP_DATE);
if (strtok($period, ' ') == $AppUI->_('Next')) {
$sign = + 1;
} else {
$sign = -1;
}
$day_word = strtok(' ');
if ($day_word == $AppUI->_('Day')) {
$days = $period_value;
} elseif ($day_word == $AppUI->_('Week')) {
$days = 7 * $period_value;
} elseif ($day_word == $AppUI->_('Month')) {
$days = 30 * $period_value;
}
$start_date = new w2p_Utilities_Date($ts);
$end_date = new w2p_Utilities_Date($ts);
if ($sign > 0) {
$end_date->addSpan(new Date_Span("$days,0,0,0"));
} else {
$start_date->subtractSpan(new Date_Span("$days,0,0,0"));
}
$do_report = 1;
} else {
// create Date objects from the datetime fields
$start_date = intval($list_start_date) ? new w2p_Utilities_Date($list_start_date) : new w2p_Utilities_Date();
$end_date = intval($list_end_date) ? new w2p_Utilities_Date($list_end_date) : new w2p_Utilities_Date();
}
if (!$list_start_date) {
$start_date->subtractSpan(new Date_Span('14,0,0,0'));
}
$end_date->setTime(23, 59, 59);
?>
<script language="javascript">
function setDate( frm_name, f_date ) {
fld_date = eval( 'document.' + frm_name + '.' + f_date );
fld_real_date = eval( 'document.' + frm_name + '.' + 'list_' + f_date );
if (fld_date.value.length>0) {
if ((parseDate(fld_date.value))==null) {
alert('The Date/Time you typed does not match your prefered format, please retype.');
fld_real_date.value = '';
fld_date.style.backgroundColor = 'red';
} else {
fld_real_date.value = formatDate(parseDate(fld_date.value), 'yyyyMMdd');
fld_date.value = formatDate(parseDate(fld_date.value), '<?php echo $cal_sdf ?>');
fld_date.style.backgroundColor = '';
}
} else {
fld_real_date.value = '';
}
}
</script>
<form name="editFrm" action="index.php?m=helpdesk&a=reports" method="post">
<input type="hidden" name="project_id" value="<?php echo $project_id;?>" />
<input type="hidden" name="report_type" value="<?php echo $report_type;?>" />
<?php
if (function_exists('styleRenderBoxTop')) {
echo styleRenderBoxTop();
}
?>
<table cellspacing="0" cellpadding="4" border="0" width="100%" class="std">
<tr>
<td align="right"><?php echo $AppUI->_('Default Actions'); ?>:</td>
<td nowrap="nowrap" colspan="2">
<input class="button" type="submit" name="period" value="<?php echo $AppUI->_('Previous Month'); ?>" />
<input class="button" type="submit" name="period" value="<?php echo $AppUI->_('Previous Week'); ?>" />
<input class="button" type="submit" name="period" value="<?php echo $AppUI->_('Previous Day'); ?>" />
</td>
<td nowrap="nowrap">
<input class="button" type="submit" name="period" value="<?php echo $AppUI->_('Next Day'); ?>" />
<input class="button" type="submit" name="period" value="<?php echo $AppUI->_('Next Week'); ?>" />
<input class="button" type="submit" name="period" value="<?php echo $AppUI->_('Next Month'); ?>" />
</td>
<td colspan="3"><input class="text" type="field" size="2" name="pvalue" value="1" /> - value for the previous buttons</td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('For period'); ?>:</td>
<td nowrap="nowrap">
<input type="hidden" name="list_start_date" id="list_start_date" value="<?php echo $start_date ? $start_date->format(FMT_TIMESTAMP_DATE) : ''; ?>" />
<input type="text" name="start_date" id="start_date" onchange="setDate('editFrm', 'start_date');" value="<?php echo $start_date ? $start_date->format($df) : ''; ?>" class="text" />
<a href="javascript: void(0);" onclick="return showCalendar('start_date', '<?php echo $df ?>', 'editFrm', null, true)">
<img src="<?php echo w2PfindImage('calendar.gif'); ?>" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?>" border="0" />
</a>
</td>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('to'); ?></td>
<td nowrap="nowrap">
<input type="hidden" name="list_end_date" id="list_end_date" value="<?php echo $end_date ? $end_date->format(FMT_TIMESTAMP_DATE) : ''; ?>" />
<input type="text" name="end_date" id="end_date" onchange="setDate('editFrm', 'end_date');" value="<?php echo $end_date ? $end_date->format($df) : ''; ?>" class="text" />
<a href="javascript: void(0);" onclick="return showCalendar('end_date', '<?php echo $df ?>', 'editFrm', null, true)">
<img src="<?php echo w2PfindImage('calendar.gif'); ?>" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?>" border="0" />
</a>
</td>
<td nowrap="nowrap">
<input type="checkbox" name="log_all" id="log_all" <?php if ($log_all)
echo 'checked="checked"' ?> />
<label for="log_all"><?php echo $AppUI->_('Log All'); ?></label>
</td>
<td nowrap="nowrap">
<input type="checkbox" name="log_pdf" id="log_pdf" <?php if ($log_pdf)
echo 'checked="checked"' ?> />
<label for="log_pdf"><?php echo $AppUI->_('Make PDF'); ?></label>
</td>
<td align="right" width="50%" nowrap="nowrap">
<input class="button" type="submit" name="do_report" value="<?php echo $AppUI->_('submit'); ?>" />
</td>
</tr>
</table>
</form>
<?php
if ($do_report) {
$q = new w2p_Database_Query;
$q->addTable('helpdesk_items','hi');
$q->addTable('users', 'ru');
$q->addTable('contacts','rc');
$q->addTable('users','au');
$q->addTable('contacts','ac');
$q->addQuery('hi.*, concat(rc.contact_first_name, " ", rc.contact_last_name) requested_by,
concat(ac.contact_first_name, " " , ac.contact_last_name) assigned_to');
if ($project_id) {
$q->addWhere('(hi.item_project_id = ' . $project_id . ' OR hi.item_project_id = 0)');
$q->addWhere('ru.user_id = hi.item_requestor_id');
} else {
$q->addWhere('ru.user_id = hi.item_requestor_id');
}
$q->addWhere('rc.contact_id = ru.user_contact');
$q->addWhere('au.user_id = hi.item_assigned_to');
$q->addWhere('ac.contact_id = au.user_contact');
if (!$log_all) {
$q->addWhere('hi.item_created >= "' . $start_date->format(FMT_DATETIME_MYSQL) . '"');
$q->addWhere('hi.item_created <= "' . $end_date->format(FMT_DATETIME_MYSQL) . '"');
}
$obj =&new CTask;
$allowedTasks = $obj->getAllowedSQL($AppUI->user_id);
if (count($allowedTasks)) {
$q->addWhere(implode(" AND ", $allowedTasks));
}
$q->addOrder('hi.item_id');
$Task_List = $q->exec();
if (function_exists('styleRenderBoxBottom')) {
echo styleRenderBoxBottom();
}
echo '<br />';
if (function_exists('styleRenderBoxTop')) {
echo styleRenderBoxTop();
}
echo "Call Log entries for ticket created from " . $start_date->format( $df ) . ' to ' . $end_date->format( $df ), 9 ;
echo "<table cellspacing=\"1\" cellpadding=\"4\" border=\"0\" class=\"tbl\">";
echo "<tr>";
echo "<th>Number</th>";
echo "<th>Created On</th>";
echo "<th>Created By</th>";
echo "<th>Title</th>";
echo "<th width=200>Summary</th>";
echo "<th>Assigned To</th>";
echo "<th>Status</th>";
echo "<th>Priority</th>";
echo "</tr>";
$pdfdata = array();
$columns = array(
"<b>".$AppUI->_('Number')."</b>",
"<b>".$AppUI->_('Created On')."</b>",
"<b>".$AppUI->_('Created By')."</b>",
"<b>".$AppUI->_('Title')."</b>",
"<b>".$AppUI->_('Summary')."</b>",
"<b>".$AppUI->_('Assigned To')."</b>",
"<b>".$AppUI->_('Status')."</b>",
"<b>".$AppUI->_('Priority')."</b>",
);
while ($Tasks = db_fetch_assoc($Task_List)){
$log_date = new w2p_Utilities_Date( $Tasks['item_created'] );
$q = new w2p_Database_Query;
$q->addQuery('TRIM(SUBSTRING_INDEX(SUBSTRING(sysval_value, LOCATE(\''.
$Tasks['item_status'] . '|\', sysval_value) + 1), \'\\n\', 1)) item_status_desc');
$q->addTable('sysvals');
$q->addWhere('sysval_title =\'HelpDeskStatus\'');
$Log_Status = $q->loadHash();
if (substr($Log_Status['item_status_desc'], 0, 6) != 'Closed') {
$q = new w2p_Database_Query;
$q->addQuery('TRIM(SUBSTRING_INDEX(SUBSTRING(sysval_value, LOCATE(\''.
$Tasks['item_status'] . '|\', sysval_value) + 1), \'\\n\', 1)) item_priority_desc');
$q->addTable('sysvals');
$q->addWhere('sysval_title =\'HelpDeskPriority\'');
$Log_Priority = $q->loadHash();
$str = "<tr valign=\"top\">";
$str .= "<td align=\"right\">".$Tasks['item_id']."</td>";
$str .= "<td>".$log_date->format( $df )."</td>";
$str .= "<td>".$Tasks['requested_by']."</td>";
$str .= "<td>".$Tasks['item_title']."</td>";
$str .= "<td>".$Tasks['item_summary']."</td>";
$str .= "<td>".$Tasks['assigned_to']."</td>";
$str .= "<td>".$Log_Status['item_status_desc']."</td>";
$str .= "<td>".$Log_Priority['item_priority_desc']."</td>";
$str .= "</tr>";
echo $str;
$pdfdata[] = array(
$Tasks['item_id'],
$log_date->format( $df ),
$Tasks['requested_by'],
$Tasks['item_title'],
$Tasks['item_summary'],
$Tasks['assigned_to'],
$Log_Status['item_status_desc'],
$Log_Priority['item_priority_desc'],
);
$q = new w2p_Database_Query;
$q->addQuery('tl.task_log_date, tl.task_log_description, concat(rc.contact_first_name, " ", rc.contact_last_name) created_by');
$q->addTable('task_log','tl');
$q->addTable('users','ru');
$q->addTable('contacts','rc');
$q->addWhere('tl.task_log_help_desk_id = "' . $Tasks['item_id'] . '"');
$q->addWhere('ru.user_id = tl.task_log_creator');
$q->addWhere('rc.contact_id = ru.user_contact');
$q->addOrder('tl.task_log_id');
$Task_Log_Query = $q->exec();
$Row_Count = 1;
while ($Task_Log = db_fetch_assoc($Task_Log_Query)){
$log_date = new w2p_Utilities_Date( $Task_Log['task_log_date'] );
$str = "<tr valign=\"top\">";
$str .= "<td align=\"right\">".$Tasks['item_id']."/".$Row_Count."</td>";
$str .= "<td>".$log_date->format( $df )."</td>";
$str .= "<td>".$Task_Log['created_by']."</td>";
$str .= "<td>"."</td>";
$str .= "<td>".$Task_Log['task_log_description']."</td>";
$str .= "<td>"."</td>";
$str .= "<td>"."</td>";
$str .= "<td>"."</td>";
$str .= "</tr>";
echo $str;
$pdfdata[] = array(
$Tasks['item_id']."/".$Row_Count,
$log_date->format( $df ),
$Task_Log['created_by'],
"",
$Task_Log['task_log_description'],
"",
"",
"",
);
$Row_Count++;
} // while LOG
} // if !Closed
} //while Task
echo "</table>";
if ($log_pdf) {
// make the PDF file
$q = new w2p_Database_Query;
$q->addTable('projects');
$q->addQuery('project_name');
$q->addWhere('project_id=' . (int)$project_id);
$pname = $q->loadResult();
$font_dir = W2P_BASE_DIR . '/lib/ezpdf/fonts';
$temp_dir = W2P_BASE_DIR . '/files/temp';
$base_url = w2PgetConfig( 'base_url' );
require ($AppUI->getLibraryClass('ezpdf/class.ezpdf'));
$pdf = &new Cezpdf($paper = 'A4', $orientation = 'landscape');
$pdf->ezSetCmMargins(1, 2, 1.5, 1.5);
$pdf->selectFont($font_dir . '/Helvetica.afm');
$pdf->ezText(w2PgetConfig('company_name'), 12);
$date = new w2p_Utilities_Date();
$pdf->ezText("\n" . $date->format($df), 8);
$pdf->selectFont( "$font_dir/Helvetica-Bold.afm" );
$pdf->ezText( "\n" . $AppUI->_('Helpdesk Report'), 12 );
if ($project_id != 0) {
$pdf->ezText($pname, 15);
}
if ($log_all) {
$pdf->ezText( "All open entries", 9 );
} else {
$pdf->ezText( "Call Log entries for ticket created from ".$start_date->format( $df ).' to '.$end_date->format( $df ), 9 );
}
$pdf->ezText( "\n" );
$pdf->selectFont( "$font_dir/Helvetica.afm" );
$title = null;
$options = array(
'showLines' => 2,
'showHeadings' => 1,
'fontSize' => 9,
'rowGap' => 4,
'colGap' => 5,
'xPos' => 50,
'xOrientation' => 'right',
'width'=>'750',
'shaded'=> 0,
'cols'=>array(0=>array('justification'=>'right','width'=>150),
2=>array('justification'=>'left','width'=>95),
3=>array('justification'=>'center','width'=>75),
4=>array('justification'=>'center','width'=>75),
5=>array('justification'=>'center','width'=>200))
);
$pdf->ezTable( $pdfdata, $columns, $title, $options );
if ($fp = fopen( "$temp_dir/temp$AppUI->user_id.pdf", 'wb' )) {
fwrite( $fp, $pdf->ezOutput() );
fclose( $fp );
echo "<a href=\"$base_url/files/temp/temp$AppUI->user_id.pdf\" target=\"pdf\">";
echo $AppUI->_( "View PDF File" );
echo "</a>";
} else {
echo "Could not open file to save PDF. ";
if (!is_writable( $temp_dir )) {
"The files/temp directory is not writable. Check your file system permissions.";
}
}
}
}
?>
</table>
\ No newline at end of file
Helpdesk Task Log
View the user task logs for helpdesk items
<?php /* $Id: tasklogs.php 156 2008-04-11 15:47:40Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/reports/reports/tasklogs.php $ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
/**
* Generates a report of the task logs for given dates
*/
//error_reporting( E_ALL );
global $AppUI, $cal_sdf;
$AppUI->loadCalendarJS();
$perms = &$AppUI->acl();
if (!$perms->checkModule('task_log', 'view')) {
$AppUI->redirect(ACCESS_DENIED);
}
$do_report = w2PgetParam($_GET, 'do_report', 0);
$log_all = w2PgetParam($_GET, 'log_all', 0);
$log_pdf = w2PgetParam($_GET, 'log_pdf', 0);
$log_ignore = w2PgetParam($_GET, 'log_ignore', 0);
$log_userfilter = w2PgetParam($_GET, 'log_userfilter', '0');
$log_start_date = w2PgetParam($_GET, 'log_start_date', 0);
$log_end_date = w2PgetParam($_GET, 'log_end_date', 0);
// create Date objects from the datetime fields
$start_date = intval($log_start_date) ? new w2p_Utilities_Date($log_start_date) : new w2p_Utilities_Date();
$end_date = intval($log_end_date) ? new w2p_Utilities_Date($log_end_date) : new w2p_Utilities_Date();
if (!$log_start_date) {
$start_date->subtractSpan(new Date_Span('14,0,0,0'));
}
$end_date->setTime(23, 59, 59);
// Lets check cost codes
$q = new w2p_Database_Query;
$q->addTable('billingcode');
$q->addQuery('billingcode_id, billingcode_name');
$task_log_costcodes[0] = $AppUI->_('None');
$rows = $q->loadList();
echo db_error();
$nums = 0;
if ($rows) {
$nums = count($rows);
}
foreach ($rows as $row) {
$task_log_costcodes[$row['billingcode_id']] = $row['billingcode_name'];
}
?>
<script language="javascript">
function setDate( frm_name, f_date ) {
fld_date = eval( 'document.' + frm_name + '.' + f_date );
fld_real_date = eval( 'document.' + frm_name + '.' + 'log_' + f_date );
if (fld_date.value.length>0) {
if ((parseDate(fld_date.value))==null) {
alert('The Date/Time you typed does not match your prefered format, please retype.');
fld_real_date.value = '';
fld_date.style.backgroundColor = 'red';
} else {
fld_real_date.value = formatDate(parseDate(fld_date.value), 'yyyyMMdd');
fld_date.value = formatDate(parseDate(fld_date.value), '<?php echo $cal_sdf ?>');
fld_date.style.backgroundColor = '';
}
} else {
fld_real_date.value = '';
}
}
</script>
<form name="editFrm" action="" method="GET">
<input type="hidden" name="m" value="helpdesk" />
<input type="hidden" name="a" value="reports" />
<input type="hidden" name="company_id" value="<?php echo $company_id; ?>" />
<input type="hidden" name="project_id" value="<?php echo $project_id; ?>" />
<input type="hidden" name="report_type" value="<?php echo $report_type; ?>" />
<?php
if (function_exists('styleRenderBoxTop')) {
echo styleRenderBoxTop();
}
?>
<table cellspacing="0" cellpadding="4" border="0" width="100%" class="std">
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('For period'); ?>:</td>
<td nowrap="nowrap">
<input type="hidden" name="log_start_date" id="log_start_date" value="<?php echo $start_date ? $start_date->format(FMT_TIMESTAMP_DATE) : ''; ?>" />
<input type="text" name="start_date" id="start_date" onchange="setDate('editFrm', 'start_date');" value="<?php echo $start_date ? $start_date->format($df) : ''; ?>" class="text" />
<a href="javascript: void(0);" onclick="return showCalendar('start_date', '<?php echo $df ?>', 'editFrm', null, true)">
<img src="<?php echo w2PfindImage('calendar.gif'); ?>" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?>" border="0" />
</a>
</td>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('to'); ?></td>
<td nowrap="nowrap">
<input type="hidden" name="log_end_date" id="log_end_date" value="<?php echo $end_date ? $end_date->format(FMT_TIMESTAMP_DATE) : ''; ?>" />
<input type="text" name="end_date" id="end_date" onchange="setDate('editFrm', 'end_date');" value="<?php echo $end_date ? $end_date->format($df) : ''; ?>" class="text" />
<a href="javascript: void(0);" onclick="return showCalendar('end_date', '<?php echo $df ?>', 'editFrm', null, true)">
<img src="<?php echo w2PfindImage('calendar.gif'); ?>" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?>" border="0" />
</a>
</td>
<td nowrap="nowrap">
<?php echo $AppUI->_('User'); ?>:
<select name="log_userfilter" class="text" style="width: 200px">
<?php
if ($log_userfilter == 0)
echo '<option value="0" selected="selected">' . $AppUI->_('All users');
else
echo '<option value="0">All users';
if (($log_userfilter_users = w2PgetUsersList())) {
foreach ($log_userfilter_users as $row) {
$selected = '';
if ($log_userfilter == $row['user_id']) {
$selected = ' selected="selected"';
}
echo '<option value="' . $row['user_id'] . '"' . $selected . '>' . $row['contact_first_name'] . ' ' . $row['contact_last_name'];
}
}
?>
</select>
</td>
<td nowrap="nowrap">
<input type="checkbox" name="log_all" <?php if ($log_all)
echo "checked" ?> />
<?php echo $AppUI->_('Log All'); ?>
</td>
<td nowrap="nowrap">
<input type="checkbox" name="log_pdf" <?php if ($log_pdf)
echo "checked" ?> />
<?php echo $AppUI->_('Make PDF'); ?>
</td>
<td nowrap="nowrap">
<input type="checkbox" name="log_ignore" />
<?php echo $AppUI->_('Ignore 0 hours'); ?>
</td>
<td align="right" width="50%" nowrap="nowrap">
<input class="button" type="submit" name="do_report" value="<?php echo $AppUI->_('submit'); ?>" />
</td>
</tr>
</table>
</form>
<?php
if ($do_report) {
if (function_exists('styleRenderBoxBottom')) {
echo styleRenderBoxBottom();
}
echo '<br />';
if (function_exists('styleRenderBoxTop')) {
echo styleRenderBoxTop();
}
$q = new w2p_Database_Query;
$q->addTable('task_log','t');
$q->addQuery('t.*, item_id, CONCAT_WS(\' \',contact_first_name,contact_last_name) AS creator, billingcode_value, ROUND((billingcode_value * t.task_log_hours), 2) AS amount');
$q->addJoin('helpdesk_items','ts','ts.item_id = task_log_help_desk_id');
$q->addJoin('users','u','user_id = task_log_creator');
$q->addJoin('contacts','','user_contact = contact_id');
$q->addJoin('projects','','project_id = item_project_id');
$q->addJoin('companies','c','c.company_id = item_company_id');
$q->addJoin('billingcode','','billingcode_id = task_log_costcode');
$q->addWhere('task_log_task = 0 AND task_log_help_desk_id > 0');
if ($project_id)
$q->addWhere('project_id = ' . (int)$project_id);
if ($company_id)
$q->addWhere('c.company_id = ' . (int)$company_id);
if (!$log_all) {
$q->addWhere('task_log_date >= \''.$start_date->format( FMT_DATETIME_MYSQL ).'\'');
$q->addWhere('task_log_date <= \''.$end_date->format( FMT_DATETIME_MYSQL ).'\'');
}
if ($log_ignore) {
$q->addWhere('task_log_hours > 0');
}
if ($log_userfilter) {
$q->addWhere('task_log_creator = ' . (int)$log_userfilter);
}
$proj = &new CProject;
$allowedProjects = $proj->getAllowedSQL($AppUI->user_id, 'task_project');
if (count($allowedProjects)) {
$q->addWhere(implode(' AND ', $allowedProjects));
}
$q->addOrder('task_log_date');
$logs = $q->loadList();
echo db_error();
?>
<table cellspacing="1" cellpadding="4" border="0" class="tbl">
<tr>
<th><?php echo $AppUI->_('Date');?></th>
<th><?php echo $AppUI->_('Created by');?></th>
<th><?php echo $AppUI->_('Item');?></th>
<th><?php echo $AppUI->_('Summary');?></th>
<th><?php echo $AppUI->_('Description');?></th>
<th><?php echo $AppUI->_('Cost Code');?></th>
<th><?php echo $AppUI->_('Hours');?></th>
<th><?php echo $AppUI->_('Cost');?></th>
<th><?php echo $AppUI->_('Amount');?></th>
</tr>
<?php
$hours = 0.00;
$tamount = 0.00;
$pdfdata = array();
foreach ($logs as $log) {
$date = new w2p_Utilities_Date( $log['task_log_date'] );
$hours += $log['task_log_hours'];
$tamount += $log['amount'];
$pdfdata[] = array(
$date->format( $df ),
$log['creator'],
$log['item_id'],
$log['task_log_name'],
$log['task_log_description'],
$task_log_costcodes[$log['task_log_costcode']],
sprintf( "%.2f", $log['task_log_hours'] ),
sprintf( "%.2f", $log['billingcode_value'] ),
sprintf( "%.2f", $log['amount'] ),
);
?>
<tr>
<td><?php echo $date->format( $df );?></td>
<td><?php echo $log['creator'];?></td>
<td align="center"><a href="index.php?m=helpdesk&a=view&item_id=<?php echo $log['item_id'];?>"><?php echo $log['item_id'];?></a></td>
<td>
<a href="index.php?m=helpdesk&a=view&tab=1&item_id=<?php echo $log['task_log_help_desk_id'];?>&task_log_id=<?php echo $log['task_log_id'];?>"><?php echo $log['task_log_name'];?></a>
</td>
<td><?php
// dylan_cuthbert: auto-transation system in-progress, leave these lines for time-being
$transbrk = "\n[translation]\n";
$descrip = str_replace( "\n", "<br />", $log['task_log_description'] );
$tranpos = strpos( $descrip, str_replace( "\n", "<br />", $transbrk ) );
if ( $tranpos === false) echo $descrip;
else
{
$descrip = substr( $descrip, 0, $tranpos );
$tranpos = strpos( $log['task_log_description'], $transbrk );
$transla = substr( $log['task_log_description'], $tranpos + strlen( $transbrk ) );
$transla = trim( str_replace( "'", '"', $transla ) );
echo $descrip."<div style='font-weight: bold; text-align: right'><a title='$transla' class='hilite'>[".$AppUI->_("translation")."]</a></div>";
}
// dylan_cuthbert; auto-translation end
?></td>
<td><?php echo $task_log_costcodes[$log['task_log_costcode']];?></td>
<td align="right"><?php printf( "%.2f", $log['task_log_hours'] );?></td>
<td align="right"><?php printf( "%.2f", $log['billingcode_value'] );?></td>
<td align="right"><?php printf( "%.2f", $log['amount'] );?></td>
</tr>
<?php
}
$pdfdata[] = array(
'',
'',
'',
'',
'',
$AppUI->_('Report Totals').':',
sprintf( "%.2f", $hours ),
'',
sprintf( "%.2f", $tamount ),
);
?>
<tr>
<td align="right" colspan="6"><?php echo $AppUI->_('Report Totals');?>:</td>
<td align="right"><?php printf( "%.2f", $hours );?></td>
<td>&nbsp;</td>
<td align="right"><?php printf( "%.2f", $tamount );?></td>
</tr>
</table>
<?php
if ($log_pdf) {
// make the PDF file
if ($project_id) {
$q = new w2p_Database_Query;
$q->addTable('projects');
$q->addQuery('project_name');
$q->addWhere('project_id=' . (int)$project_id);
$pname = 'Project: ' . $q->loadResult();
} else {
$pname = 'All Companies and All Projects';
}
echo db_error();
if ($company_id) {
$q = new w2p_Database_Query;
$q->addTable('companies');
$q->addQuery('company_name');
$q->addWhere('company_id=' . (int)$company_id);
$cname = 'Company: ' . $q->loadResult();
} else {
$cname = 'All Companies and All Projects';
}
echo db_error();
if ($log_userfilter) {
$q = new w2p_Database_Query;
$q->addTable('contacts');
$q->addQuery('CONCAT(contact_first_name, \' \', contact_last_name)');
$q->addJoin('users', '', 'user_contact = contact_id', 'inner');
$q->addWhere('user_id =' . (int)$log_userfilter);
$uname = 'User: ' . $q->loadResult();
} else {
$uname = 'All Users';
}
echo db_error();
$font_dir = w2PgetConfig('root_dir') . '/lib/ezpdf/fonts';
$temp_dir = w2PgetConfig('root_dir') . '/files/temp';
$base_url = w2PgetConfig('base_url');
require ($AppUI->getLibraryClass('ezpdf/class.ezpdf'));
$pdf = &new Cezpdf();
$pdf->ezSetCmMargins(1, 2, 1.5, 1.5);
$pdf->selectFont($font_dir . '/Helvetica.afm');
$pdf->ezText(w2PgetConfig('company_name'), 12);
$date = new w2p_Utilities_Date();
$pdf->ezText("\n" . $date->format($df), 8);
$pdf->selectFont($font_dir . '/Helvetica-Bold.afm');
$pdf->ezText("\n" . $AppUI->_('Task Log Report'), 12);
if ($company_id) {
$pdf->ezText($cname, 10);
} else {
$pdf->ezText($pname, 10);
}
$pdf->ezText($uname, 10);
if ($log_all) {
$pdf->ezText( "All Helpdesk task log entries", 9 );
} else {
$pdf->ezText( "Helpdesk task log entries from ".$start_date->format( $df ).' to '.$end_date->format( $df ), 9 );
}
$pdf->ezText( "\n\n" );
$title = 'Helpdesk Task Logs';
$pdfheaders = array(
$AppUI->_('Date',UI_OUTPUT_JS),
$AppUI->_('Creator',UI_OUTPUT_JS),
$AppUI->_('Item',UI_OUTPUT_JS),
$AppUI->_('Summary',UI_OUTPUT_JS),
$AppUI->_('Description',UI_OUTPUT_JS),
$AppUI->_('Cost Code',UI_OUTPUT_JS),
$AppUI->_('Hours',UI_OUTPUT_JS),
$AppUI->_('Cost',UI_OUTPUT_JS),
$AppUI->_('Amount',UI_OUTPUT_JS)
);
$options = array(
'showLines' => 1,
'fontSize' => 7,
'rowGap' => 1,
'colGap' => 1,
'xPos' => 50,
'xOrientation' => 'right',
'width'=>'500',
'cols'=>array(
0=>array('justification'=>'center','width'=>45),
1=>array('justification'=>'left','width'=>65),
2=>array('justification'=>'center','width'=>25),
3=>array('justification'=>'left','width'=>95),
4=>array('justification'=>'left','width'=>95),
5=>array('justification'=>'center','width'=>50),
6=>array('justification'=>'right','width'=>35),
7=>array('justification'=>'right','width'=>35),
8=>array('justification'=>'right','width'=>50)
)
);
$pdf->ezTable( $pdfdata, $pdfheaders, $title, $options );
if ($fp = fopen( "$temp_dir/temp$AppUI->user_id.pdf", 'wb' )) {
fwrite( $fp, $pdf->ezOutput() );
fclose( $fp );
echo "<a href=\"$base_url/files/temp/temp$AppUI->user_id.pdf\" target=\"pdf\">";
echo $AppUI->_( "View PDF File" );
echo "</a>";
} else {
echo "Could not open file to save PDF. ";
if (!is_writable( $temp_dir )) {
"The files/temp directory is not writable. Check your file system permissions.";
}
}
}
}
\ No newline at end of file
<?php /* HELPDESK $Id: selector.php,v 1.14 2006-12-14 12:55 Kang Exp $ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
function selPermWhere($table, $idfld)
{
global $AppUI;
// get any companies denied from viewing
$sql = "SELECT $idfld"
."\nFROM $table, permissions"
."\nWHERE permission_user = $AppUI->user_id"
."\n AND permission_grant_on = '$table'"
."\n AND permission_item = $idfld"
."\n AND permission_value = 0";
$deny = db_loadColumn( $sql );
echo db_error();
return "permission_user = $AppUI->user_id"
."\nAND permission_value <> 0"
."\nAND ("
."\n (permission_grant_on = 'all')"
."\n OR (permission_grant_on = '$table' and permission_item = -1)"
."\n OR (permission_grant_on = '$table' and permission_item = $idfld)"
."\n )"
. (count($deny) > 0 ? "\nAND $idfld NOT IN (" . implode( ',', $deny ) . ')' : '');
}
$debug = false;
$callback = w2PgetParam( $_GET, 'callback', 0 );
$table = w2PgetParam( $_GET, 'table', 0 );
$comp=w2PgetParam($_GET, 'comp', 0);
$ok = $callback & $table;
$title = "Generic Selector";
$select = '';
$from = $table;
$where = '';
$order = '';
switch ($table) {
case 'companies':
$title = 'Company';
$select = 'company_id,company_name';
$order = 'company_name';
$table .= ", permissions";
$where = selPermWhere( 'companies', 'company_id' );
break;
case 'departments':
// known issue: does not filter out denied companies
$title = 'Department';
$company_id = w2PgetParam( $_GET, 'company_id', 0 );
$where = "dept_company = company_id ";
$where .= "\nAND ".selPermWhere( 'departments', 'dept_id' );
$table .= ", companies, permissions";
$hide_company = w2PgetParam( $_GET, 'hide_company', 0 );
if ($hide_company == 1) {
$select = "dept_id, dept_name";
} else {
$select = "dept_id,CONCAT_WS(': ',company_name,dept_name) AS dept_name";
}
if ($company_id) {
$where .= "\nAND dept_company = $company_id";
$order = 'dept_name';
} else {
$order = 'company_name,dept_name';
}
break;
case 'forums':
$title = 'Forum';
$select = 'forum_id,forum_name';
$order = 'forum_name';
break;
case 'projects':
$project_company = w2PgetParam( $_GET, 'project_company', 0 );
$title = 'Project';
$select = 'project_id,project_name';
$order = 'project_name';
$where = selPermWhere( 'projects', 'project_id' );
$where .= $project_company ? "\nAND project_company = $project_company" : '';
$table .= ", permissions";
break;
case 'tasks':
$task_project = w2PgetParam( $_GET, 'task_project', 0 );
$title = 'Task';
$select = 'task_id,task_name';
$order = 'task_name';
$where = $task_project ? "task_project = $task_project" : '';
break;
case 'users':
$title = 'User';
//by KZHAO
$templist = getAllowedUsers($comp, 1);
foreach ($templist as $key=>$value) {
$list[$key]=$value;
}
break;
case 'contacts':
$title = 'Contacts';
$select = "contact_id,CONCAT_WS(' ',contact_first_name,contact_last_name)";
$order = "CONCAT_WS(' ',contact_first_name,contact_last_name)";
break;
default:
$ok = false;
break;
}
if (!$ok) {
echo "Incorrect parameters passed\n";
if ($debug) {
echo "<br />callback = $callback \n";
echo "<br />table = $table \n";
echo "<br />ok = $ok \n";
}
} else {
if (!isset($list)) {
$q = new w2p_Database_Query;
$q->addQuery($select);
$q->addTable($table);
if ($where) {
$q->addWhere($where);
}
$q->addOrder($order);
$list = arrayMerge( array( 0=>''), $q->loadHashList());
}
echo db_error();
?>
<script language="javascript">
public function setClose(key, val)
{
window.opener.<?php echo $callback;?>(key,val);
window.close();
}
public function setHeight()
{
window.opener.<?php echo $callback;?>(key,val);
window.close();
}
</script>
<table cellspacing="0" cellpadding="3" border="0">
<tr>
<td>
<?php
if (count( $list ) > 1) {
echo $AppUI->_( 'Select' ).' '.$AppUI->_( $title ).':<br />';
foreach ($list as $key => $val) {
echo "<a href=\"javascript:setClose('$key','".addslashes($val)."');\">$val</a><br>\n";
}
?>
</td>
</tr>
<tr>
<td align="right">
<input type="button" class="button" value="<?php echo $AppUI->_( 'cancel' );?>" onclick="window.close()" />
<?php
} else {
echo $AppUI->_( "no$table" );
}
?>
</td>
</tr>
</table>
<?php
}
<?php /* HELPDESK $Id: setup.php,v 1.47 2005/10/07 16:09:10 pedroix Exp $ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
/* Help Desk module definitions */
$config = array();
$config['mod_name'] = 'HelpDesk';
$config['mod_version'] = '0.8';
$config['mod_directory'] = 'helpdesk';
$config['mod_setup_class'] = 'CSetupHelpDesk';
$config['mod_type'] = 'user';
$config['mod_ui_name'] = 'Help Desk';
$config['mod_ui_icon'] = 'helpdesk.png';
$config['mod_description'] = 'Help Desk is a bug, feature request, complaint and suggestion tracking centre';
$config['mod_config'] = true;
$config['mod_main_class'] = 'CHelpDesk'; // the name of the PHP class used by the module
//This will allow permissions to be applied to this module based on the following database criteria
$config['permissions_item_table'] = 'helpdesk_items';
$config['permissions_item_label'] = 'item_title';
$config['permissions_item_field'] = 'item_id';
if (@$a == 'setup') {
print w2PshowModuleConfig( $config );
}
class CSetupHelpDesk extends w2p_System_Setup
{
public function install()
{
$success = true;
$bulk_sql[] = "
CREATE TABLE helpdesk_items (
`item_id` int(11) unsigned NOT NULL auto_increment,
`item_title` varchar(64) NOT NULL default '',
`item_summary` text,
`item_calltype` int(3) unsigned NOT NULL default '0',
`item_source` int(3) unsigned NOT NULL default '0',
`item_service` varchar(48) NOT NULL default '',
`item_application` varchar(48) NOT NULL default '',
`item_priority` int(3) unsigned NOT NULL default '0',
`item_severity` int(3) unsigned NOT NULL default '0',
`item_status` int(3) unsigned NOT NULL default '0',
`item_assigned_to` int(11) NOT NULL default '0',
`item_created_by` int(11) NOT NULL default '0',
`item_notify` int(1) DEFAULT '1' NOT NULL ,
`item_requestor` varchar(48) NOT NULL default '',
`item_requestor_id` int(11) NOT NULL default '0',
`item_requestor_email` varchar(128) NOT NULL default '',
`item_requestor_phone` varchar(30) NOT NULL default '',
`item_requestor_type` tinyint NOT NULL default '0',
`item_created` datetime default NULL,
`item_modified` datetime default NULL,
`item_parent` int(10) unsigned NOT NULL default '0',
`item_project_id` int(11) NOT NULL default '0',
`item_company_id` int(11) NOT NULL default '0',
`item_task_id` int(11) default '0',
`item_updated` datetime default NULL,
`item_deadline` datetime default NULL,
PRIMARY KEY (item_id)
) ENGINE=MyISAM";
$bulk_sql[] = "
CREATE TABLE `helpdesk_item_status` (
`status_id` int NOT NULL AUTO_INCREMENT,
`status_item_id` int NOT NULL,
`status_code` tinyint NOT NULL,
`status_date` timestamp NOT NULL,
`status_modified_by` int NOT NULL,
`status_comment` text,
PRIMARY KEY (`status_id`)
) ENGINE=MyISAM";
$bulk_sql[] = "
CREATE TABLE helpdesk_item_watchers (
`item_id` int(11) NOT NULL default '0',
`user_id` int(11) NOT NULL default '0',
`notify` char(1) NOT NULL default ''
) ENGINE=MyISAM ";
$bulk_sql[] = "
ALTER TABLE `files` ADD COLUMN `file_helpdesk_item` int(11) DEFAULT 0";
$bulk_sql[] = "
ALTER TABLE `task_log` ADD `task_log_help_desk_id` int(11) NOT NULL default '0' AFTER `task_log_task`";
foreach ($bulk_sql as $s) {
try {
db_exec($s);
} catch (Exception $exc) {
//do nothing
}
}
$q = $this->_getQuery();
$i = 0;
$priorities = array('Not Specified', 'Low', 'Normal', 'High');
foreach ($priorities as $priority) {
$q->clear();
$q->addTable('sysvals');
$q->addInsert('sysval_key_id', 1);
$q->addInsert('sysval_title', 'HelpDeskPriority');
$q->addInsert('sysval_value', $priority);
$q->addInsert('sysval_value_id', $i);
$q->exec();
$i++;
}
$i = 0;
$severities = array('Not Specified', 'No Impact', 'Low', 'Medium', 'High', 'Critical');
foreach ($severities as $severity) {
$q->clear();
$q->addTable('sysvals');
$q->addInsert('sysval_key_id', 1);
$q->addInsert('sysval_title', 'HelpDeskSeverity');
$q->addInsert('sysval_value', $severity);
$q->addInsert('sysval_value_id', $i);
$q->exec();
$i++;
}
$i = 0;
$types = array('Not Specified', 'Incident', 'Feature Request', 'Account Request', 'Complaint', 'Bug', 'User Support');
foreach ($types as $type) {
$q->clear();
$q->addTable('sysvals');
$q->addInsert('sysval_key_id', 1);
$q->addInsert('sysval_title', 'HelpDeskCallType');
$q->addInsert('sysval_value', $type);
$q->addInsert('sysval_value_id', $i);
$q->exec();
$i++;
}
$i = 0;
$sources = array('Not Specified', 'E-Mail', 'Phone', 'Fax', 'In Person', 'E-Lodged', 'WWW');
foreach ($sources as $source) {
$q->clear();
$q->addTable('sysvals');
$q->addInsert('sysval_key_id', 1);
$q->addInsert('sysval_title', 'HelpDeskSource');
$q->addInsert('sysval_value', $source);
$q->addInsert('sysval_value_id', $i);
$q->exec();
$i++;
}
$i = 0;
$services = array('Not Specified', 'Linux', 'Unix', 'Solaris', 'Windows 2000', 'Windows XP', 'Other');
foreach ($services as $service) {
$q->clear();
$q->addTable('sysvals');
$q->addInsert('sysval_key_id', 1);
$q->addInsert('sysval_title', 'HelpDeskService');
$q->addInsert('sysval_value', $service);
$q->addInsert('sysval_value_id', $i);
$q->exec();
$i++;
}
$i = 0;
$statuses = array('Unassigned', 'Open', 'Closed', 'On Hold', 'Testing');
foreach ($statuses as $status) {
$q->clear();
$q->addTable('sysvals');
$q->addInsert('sysval_key_id', 1);
$q->addInsert('sysval_title', 'HelpDeskStatus');
$q->addInsert('sysval_value', $status);
$q->addInsert('sysval_value_id', $i);
$q->exec();
$i++;
}
$i = 0;
$audittrails = array('Created', 'Title', 'Requestor Name', 'Requestor E-mail', 'Requestor Phone', 'Assigned To',
'Notify by e-mail', 'Company', 'Project', 'Call Type', 'Call Source', 'Status', 'Priority',
'Severity', 'Service', 'Application', 'Summary', 'Deadline', 'Deleted');
foreach ($audittrails as $audittrail) {
$q->clear();
$q->addTable('sysvals');
$q->addInsert('sysval_key_id', 1);
$q->addInsert('sysval_title', 'HelpDeskAuditTrail');
$q->addInsert('sysval_value', $audittrail);
$q->addInsert('sysval_value_id', $i);
$q->exec();
$i++;
}
global $AppUI;
$perms = $AppUI->acl();
return $perms->registerModule('Help Desk', 'helpdesk');
}
public function remove()
{
$success = true;
$bulk_sql[] = "DROP TABLE helpdesk_items";
$bulk_sql[] = "DROP TABLE helpdesk_item_status";
$bulk_sql[] = "DROP TABLE helpdesk_item_watchers";
$bulk_sql[] = "ALTER TABLE `task_log` DROP COLUMN `task_log_help_desk_id`";
$bulk_sql[] = "ALTER TABLE `files` DROP COLUMN `file_helpdesk_item`";
foreach ($bulk_sql as $s) {
try {
db_exec($s);
} catch (Exception $exc) {
//do nothing
}
}
$q = new w2p_Database_Query;
$q->addQuery('syskey_id');
$q->addTable('syskeys');
$q->addWhere('syskey_name = \'HelpDeskList\'');
$id = (int) $q->loadResult();
unset($bulk_sql);
$bulk_sql[] = "DELETE FROM syskeys WHERE syskey_id = $id";
$bulk_sql[] = "DELETE FROM sysvals WHERE sysval_key_id = $id";
foreach ($bulk_sql as $s) {
try {
db_exec($s);
} catch (Exception $exc) {
//do nothing
}
}
$q = new w2p_Database_Query;
$q->setDelete('modules');
$q->addWhere("mod_directory = 'helpdesk'");
$q->exec();
return $success;
}
public function upgrade($old_version)
{
$success = true;
switch ($old_version) {
case 0.2:
// Version 0.3 features new permissions
break;
case 0.3:
// Version 0.31 includes new watchers functionality
$sql = "
CREATE TABLE helpdesk_item_watchers (
`item_id` int(11) NOT NULL default '0',
`user_id` int(11) NOT NULL default '0',
`notify` char(1) NOT NULL default ''
) TYPE=MyISAM";
db_exec($sql);
if (db_error()) {
return false;
}
case 0.31:
$sql = "ALTER TABLE files ADD COLUMN file_helpdesk_item int(11) DEFAULT 0;";
db_exec($sql);
$sql = "
ALTER TABLE `helpdesk_items`
CHANGE `item_os` `item_service` varchar(48) NOT NULL default '',
ADD `item_updated` datetime default NULL,
ADD `item_deadline` datetime default NULL,
ADD `item_task_id` int(11) default '0'";
db_exec($sql);
if (db_error()) {
return false;
}
$sql = "SELECT `item_id` FROM helpdesk_items";
$rows = db_loadList( $sql );
$sql = '';
foreach ($rows as $row) {
$sql = "SELECT MAX(status_date) status_date FROM helpdesk_item_status WHERE status_item_id =".$row['item_id'];
$sdrow = db_loadList( $sql );
$sql = '';
$sql = "UPDATE `helpdesk_items`
SET `item_updated`='".$sdrow[0]['status_date']."'
WHERE `item_id`=".$row['item_id'];
db_exec($sql);
if (db_error()) {
return false;
}
}
break;
case 0.4:
$sql = "ALTER TABLE `helpdesk_items`
CHANGE `item_os` `item_service` varchar(48) NOT NULL default '',
ADD `item_deadline` datetime default NULL,
ADD `item_task_id` int(11) default '0'";
//???: Should this query actually get applied? - caseydk
break;
case 0.6:
$sql = "ALTER TABLE `helpdesk_items`
CHANGE `item_os` `item_service` varchar(48) NOT NULL default '',
ADD `item_task_id` int(11) default '0'";
db_exec($sql);
if (db_error()) {
return false;
}
break;
case 0.8:
$sql = "UPDATE `modules` SET `mod_main_class` = 'CHelpDesk'
WHERE `mod_main_class` = 'CHelpDeskItem";
db_exec($sql);
if (db_error()) {
return false;
}
break;
default:
$success = 0;
}
global $AppUI;
$perms = $AppUI->acl();
return $perms->registerModule('Help Desk', 'helpdesk');
}
public function configure()
{
global $AppUI;
$AppUI->redirect("m=helpdesk&a=configure");
return true;
}
}
<?php /* HELPDESK $Id: vw_idx_my.php,v 1.3 2004/08/03 03:27:05 cyberhorse Exp $*/
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
include_once 'helpdesk.functions.php';
// Show my items
vw_idx_handler(2);
<?php /* HELPDESK $Id$ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
include_once 'helpdesk.functions.php';
global $HELPDESK_CONFIG, $AppUI, $m;
$df = $AppUI->getPref( 'SHDATEFORMAT' );
$tf = $AppUI->getPref( 'TIMEFORMAT' );
$format = $df." ".$tf;
$item_id = (int) w2PgetParam( $_GET, 'item_id', 0 );
$helpdesk_id = $item_id;
$task_log_id = (int) w2PgetParam($_GET, 'task_log_id', 0);
// Get pagination page
if (isset($_GET['page'])) {
$AppUI->setState('HelpDeskLogPage', $_GET['page']);
} else {
$AppUI->setState('HelpDeskLogPage', 0);
}
$page = $AppUI->getState('HelpDeskLogPage') ? $AppUI->getState('HelpDeskLogPage') : 0;
// Get tab state
$tab = $AppUI->processIntState('HelpLogVwTab', $_GET, 'tab', 0);
$ict = w2PgetSysVal( 'HelpDeskCallType' );
$ics = w2PgetSysVal( 'HelpDeskSource' );
$ios = w2PgetSysVal( 'HelpDeskService' );
$iap = w2PgetSysVal( 'HelpDeskApplic' );
$ipr = w2PgetSysVal( 'HelpDeskPriority' );
$isv = w2PgetSysVal( 'HelpDeskSeverity' );
$ist = w2PgetSysVal( 'HelpDeskStatus' );
$isa = w2PgetSysVal( 'HelpDeskAuditTrail' );
$q = new w2p_Database_Query;
$q->addQuery('hi.*,CONCAT(co.contact_first_name,\' \',co.contact_last_name) assigned_fullname,
p.project_id,p.project_name,p.project_color_identifier, c.company_name');
$q->addTable('helpdesk_items','hi');
$q->addJoin('users','u','u.user_id = hi.item_assigned_to');
$q->addJoin('contacts','co','u.user_contact = co.contact_id');
$q->addJoin('projects','p','p.project_id = hi.item_project_id');
$q->addJoin('companies','c','c.company_id = hi.item_company_id');
$q->addWhere('item_id = ' . $item_id);
$hditem = $q->loadHash();
if (!$hditem) {
$titleBlock = new w2p_Theme_TitleBlock( $AppUI->_('Invalid item id'), 'helpdesk.png', $m, 'ID_HELP_HELPDESK_VIEW' );
$titleBlock->addCrumb( "?m=helpdesk", 'home' );
$titleBlock->addCrumb( "?m=helpdesk&a=list", 'list' );
$titleBlock->show();
} else {
// Check permissions on this record
$canRead = hditemReadable($hditem);
$canEdit = $perms->checkModule($m, 'edit') && hditemEditable($hditem);
if (!$canRead && !$canEdit) {
$AppUI->redirect(ACCESS_DENIED);
}
$name = $hditem['item_requestor'];
$assigned_to_name = $hditem['item_assigned_to'] ? $hditem['assigned_fullname'] : '';
$user = new CUser();
$user->load($hditem['item_assigned_to']);
$contact = new CContact();
$contact->contact_id = $user->user_contact;
$contactMethods = $contact->getContactMethods(array('email_primary'));
$assigned_email = $contactMethods['email_primary'];
$q = new w2p_Database_Query;
$q->addQuery('helpdesk_item_watchers.user_id,
CONCAT(contact_first_name, \' \', contact_last_name) as name');
$q->addTable('helpdesk_item_watchers');
$q->addJoin('users','','helpdesk_item_watchers.user_id = users.user_id');
$q->addJoin('contacts','co','user_contact = contact_id');
$q->addWhere('item_id = ' . $item_id);
$q->addOrder('contact_last_name, contact_first_name');
$watchers = $q->loadList();
$titleBlock = new w2p_Theme_TitleBlock( 'Viewing Help Desk Item', 'helpdesk.png', $m, 'ID_HELP_HELPDESK_IDX' );
if (hditemCreate()) {
$titleBlock->addCell(
'<input type="submit" class="button" value="'.$AppUI->_('new item').'" />', '',
'<form action="?m=helpdesk&a=addedit" method="post">', '</form>'
);
}
$titleBlock->addCrumb( "?m=helpdesk", 'home');
$titleBlock->addCrumb( "?m=helpdesk&a=list", 'list');
if ($canEdit) {
$titleBlock->addCrumbDelete('delete this item', 1);
$titleBlock->addCrumb( "?m=helpdesk&a=addedit&item_id=$item_id", 'edit this item' );
$titleBlock->addCrumb( "?m=helpdesk&a=export&item_id=$item_id", 'export this item to task' );
}
$titleBlock->show();
?>
<script language="JavaScript">
public function delIt()
{
if (confirm( "<?php print $AppUI->_('doDelete').' '.$AppUI->_('Item').'?';?>" )) {
document.frmDelete.submit();
}
}
public function toggle_comment(id)
{
var element = document.getElementById(id)
element.style.display = (element.style.display == '' || element.style.display == "none") ? "inline" : "none"
}
</script>
<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td valign="top">
<table border="0" cellpadding="4" cellspacing="0" width="100%" class="std">
<tr>
<td valign="top" width="50%" colspan="2">
<strong><?php echo $AppUI->_('Item Details')?> </strong>
<?php if ($hditem["item_deadline"]!=NULL) {
$date3 = new w2p_Utilities_Date( $hditem['item_deadline'] );
echo "<a title='Deadline: ".$date3->format($format)."'>(";
echo get_due_time($hditem["item_deadline"]);
echo ")</a>";
}
?>
</td>
</tr>
<tr>
<td valign="top">
<table cellspacing="1" cellpadding="2" width="100%">
<tr>
<!--KZHAO 8-3-2006-->
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Item Created')?>:</td>
<td class="hilite" width="100%"><?php
if ($hditem["item_created"]!=NULL) {
$date1 = new w2p_Utilities_Date( $hditem['item_created'] );
echo $date1->format($format);
} else echo "N/A";
?>
(<font color="#ff0000"><?php
if ($hditem["item_created"]!=NULL) {
echo get_time_ago($hditem["item_created"]);
} else echo "N/A";
?>
</font>)
</td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Number')?>:</td>
<td class="hilite" width="100%"><?php echo $hditem["item_id"]?></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Title')?>:</td>
<td class="hilite" width="100%"><?php echo $HELPDESK_CONFIG['new_hd_item_title_prefix'] . ' ' . $hditem["item_title"]?></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Requestor')?>:</td>
<td class="hilite" width="100%"><?php
print $hditem["item_requestor_email"] ?
"<a href=\"mailto:".$hditem["item_requestor_email"]."\">".$hditem['item_requestor']."</a>" :
$hditem['item_requestor'];?></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Requestor Phone')?>:</td>
<td class="hilite" width="100%"><?php echo $hditem["item_requestor_phone"]?></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Assigned To')?>:</td>
<td class="hilite" width="100%"><?php
print $assigned_email ?
"<a href=\"mailto:$assigned_email\">$assigned_to_name</a>" :
$assigned_to_name;?></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Company')?>:</td>
<td class="hilite" width="100%"><?php echo $hditem["company_name"]?></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Project')?>:</td>
<td class="hilite" width="100%" style="background-color: #<?php echo $hditem['project_color_identifier']?>;"><a href="./index.php?m=projects&a=view&project_id=<?php echo $hditem["project_id"]?>"; style="color: <?php echo bestColor( $hditem['project_color_identifier'] ) ?>;"><?php echo $hditem["project_name"]?></a></td>
</tr>
</table>
</td><td valign="top">
<table cellspacing="1" cellpadding="2" width="100%">
<tr>
<!--KZHAO 8-7-2006-->
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Item Updated')?>:</td>
<td class="hilite" width="100%">
<?php if ($hditem["item_updated"]!=NULL) {
$date2 = new w2p_Utilities_Date( $hditem['item_updated'] );
echo $date2->format($format);
} elseif ($hditem["item_modified"]!=NULL) {
$date2 = new w2p_Utilities_Date( $hditem['item_modified'] );
echo $date2->format($format);
} else echo "Unknown";
?>
(<font color="#ff0000"><?php
if ($hditem["item_updated"]!=NULL) {
echo get_time_ago($hditem["item_updated"]);
} elseif ($hditem["item_modified"]!=NULL) {
echo get_time_ago($hditem["item_modified"]);
} else echo "N/A";
?></font>)
</td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Call Type')?>:</td>
<td class="hilite" width="100%"><?php
print $AppUI->_($ict[$hditem["item_calltype"]])." ";
print w2PshowImage ('ct'.$hditem['item_calltype'].'.png', 15, 17, 'align=center','', $m );
?></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Call Source')?>:</td>
<td class="hilite" width="100%"><?php echo $AppUI->_(@$ics[$hditem["item_source"]])?></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Status')?>:</td>
<td class="hilite" width="100%"><?php echo $AppUI->_(@$ist[$hditem["item_status"]])?></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Priority')?>:</td>
<td class="hilite" width="100%"><?php echo $AppUI->_(@$ipr[$hditem["item_priority"]])?></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Severity')?>:</td>
<td class="hilite" width="100%"><?php echo $AppUI->_(@$isv[$hditem["item_severity"]])?></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Service')?>:</td>
<td class="hilite" width="100%"><?php echo $AppUI->_(@$ios[$hditem["item_service"]])?></td>
</tr>
<tr>
<td align="right" nowrap="nowrap"><?php echo $AppUI->_('Application')?>:</td>
<td class="hilite" width="100%"><?php echo $AppUI->_(@$iap[$hditem["item_application"]])?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" colspan="2">
<table cellspacing="0" cellpadding="2" border="0" width="100%">
<tr>
<td><strong><?php echo $AppUI->_('Summary')?></strong></td>
<td><strong><?php echo $AppUI->_('Watchers')?></strong></td>
<tr>
<td class="hilite" width="50%"><?php echo str_replace( chr(10), "<br />", linkLinks($hditem["item_summary"]))?>&nbsp;</td>
<td class="hilite" width="50%"><?php
$delimiter = "";
foreach ($watchers as $watcher) {
echo "$delimiter <a href=\"mailto: {$watcher['contact_email']}\">".$watcher['name']."</a>";
$delimiter = ",";
}
?>&nbsp;</td>
</tr>
</table>
</td>
</tr>
</table>
</td></tr>
<tr><td valign="top">
<?php
$tabBox = new CTabBox( "?m=helpdesk&a=view&item_id=$item_id", "", $tab );
$tabBox->add( w2PgetConfig('root_dir') . '/modules/helpdesk/vw_logs', 'Task Logs' );
if ($perms->checkModule($m, 'edit')) {
if ($task_log_id == 0) {
$tabBox->add( w2PgetConfig('root_dir') . '/modules/helpdesk/vw_log_update', 'New Log' );
} else {
$tabBox->add( w2PgetConfig('root_dir') . '/modules/helpdesk/vw_log_update', 'Edit Log' );
}
}
$tabBox->add( w2PgetConfig('root_dir') . '/modules/helpdesk/vw_history', 'Item History' );
$tabBox->show();
}
?>
</td></tr></table>
<form name="frmDelete" action="./index.php?m=helpdesk&a=list" method="post">
<input type="hidden" name="dosql" value="do_item_aed">
<input type="hidden" name="del" value="1" />
<input type="hidden" name="item_id" value="<?php echo $item_id?>" />
</form>
<?php
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
global $AppUI, $HELPDESK_CONFIG, $hditem, $isa, $m, $item_id;
// User's specified format for date and time
$df = $AppUI->getPref('SHDATEFORMAT');
$tf = $AppUI->getPref('TIMEFORMAT');
$isa = w2PgetSysVal( 'HelpDeskAuditTrail' );
// Get pagination page
if (isset($_GET['page'])) {
$AppUI->setState('HelpDeskLogPage', $_GET['page']);
} else {
$AppUI->setState('HelpDeskLogPage', 0);
}
$page = $AppUI->getState('HelpDeskLogPage') ? $AppUI->getState('HelpDeskLogPage') : 0;
$q = new w2p_Database_Query;
$q->addQuery('*, TRIM(CONCAT(co.contact_first_name,\' \',co.contact_last_name)) modified_by');
$q->addQuery('contact_email AS email');
$q->addTable('helpdesk_item_status','h');
$q->addJoin('users','u','u.user_id = h.status_modified_by');
$q->addJoin('contacts','co','u.user_contact = co.contact_id');
$q->addWhere('h.status_item_id='.$hditem['item_id']);
$q->addOrder('h.status_date');
// Pagination
$status_log_items_per_page = $HELPDESK_CONFIG['status_log_items_per_page'];
// Figure out number of total results, but do not retrieve
$total_logs = db_num_rows($q->exec());
// Now lets do the offset
$offset = $page * $status_log_items_per_page;
$q->setLimit($status_log_items_per_page,$offset);
// Get the actual, paginated results
$status_log = $q->loadList();
?>
<table border="0" cellpadding="4" cellspacing="0" width="100%" >
<tr>
<td><b><?php echo $AppUI->_('Item History')?></b></td>
<td align="right">
<?php
if ($total_logs > $status_log_items_per_page) {
$pages_per_side = $HELPDESK_CONFIG['pages_per_side'];
$pages = ceil($total_logs / $status_log_items_per_page) - 1;
$link = "?m=helpdesk&a=view&item_id=$item_id&page=";
if ($page < $pages_per_side) {
$start = 0;
} else {
$start = $page - $pages_per_side;
}
if ($page > ($pages - $pages_per_side)) {
$end = $pages;
} else {
$end = $page + $pages_per_side;
}
if ($page > 0) {
print "<a href=\"$link".($page - 1)."\">&larr; Previous</a>&nbsp;&nbsp;";
}
for ($i = $start; $i <= $end; $i++) {
if ($i == $page) {
print " <b>".($i + 1)."</b>";
} else {
print " <a href=\"$link$i\">".($i + 1)."</a>";
}
}
if ($page < $pages) {
print "&nbsp;&nbsp;<a href=\"$link".($page + 1)."\">Next &rarr;</a>";
}
}
?></td>
</tr>
</table>
<table cellspacing="1" cellpadding="2" border="0" width="100%" class="std">
<?php
$last_date = "";
if (is_array($status_log)) {
foreach ($status_log as $log) {
$log_date = new w2p_Utilities_Date($log['status_date']);
$date = $log_date->format( $df );
if ($date!=$last_date) {
$last_date = $date;
?>
<tr>
<th nowrap="nowrap" colspan="3"><?php echo $date?>:</th>
</tr>
<?php
}
$time = $log_date->format( $tf );
?>
<tr>
<td class="hilite" nowrap="nowrap" width="1%"><?php echo $time?></td>
<td class="hilite" nowrap="nowrap" width="1%"><?php echo ($log['email']?"<a href=\"mailto: {$log['email']}\">{$log['modified_by']}</a>":$log['modified_by'])?></td>
<td class="hilite" width="98%"><?php
if ($log['status_code']==0 || $log['status_code']==18) {
// Created or Deleted
print $AppUI->_($isa[$log['status_code']]);
} elseif ($log['status_code'] == 16) {
// Comment
print "<a href=\"javascript:void(0);\"
onClick=\"toggle_comment('{$log['status_id']}_short');
toggle_comment('{$log['status_id']}_long');\">"
. w2PshowImage ('toggle.png', 16, 16, '','', $m )
. "</a>";
print "<span style='display: inline' id='{$log['status_id']}_short'> "
. $AppUI->_($isa[$log['status_code']]) . " "
. htmlspecialchars(substr($log['status_comment'],0,8))
. "</span><span style='display: none' id='{$log['status_id']}_long'> "
. $AppUI->_($isa[$log['status_code']]) . " "
. htmlspecialchars($log['status_comment'])
. "</span>";
} else {
// Everything else
print $AppUI->_($isa[$log['status_code']])." ".$log['status_comment'];
}
?></td>
</tr>
<?php
}
}
?>
</table>
<?php /* HELPDESK $Id: vw_idx_closed.php 161 2006-10-26 14:10:50Z kang $*/
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
// Show closed items
print vw_idx_handler(1);
<?php /* HELPDESK $Id: vw_idx_my.php,v 1.3 2004/08/03 03:27:05 cyberhorse Exp $*/
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
include_once 'helpdesk.functions.php';
// Show my items
vw_idx_handler(2);
<?php /* HELPDESK $Id: vw_idx_new.php 161 2006-10-26 14:10:50Z kang $*/
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
// Show opened items
vw_idx_handler(0);
<?php /* HELPDESK $Id: vw_idx_stats.php 340 2007-02-19 15:57:59Z kang $*/
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
global $m, $ict, $ist, $AppUI;
$stats = array();
$item_perms = getItemPerms();
$ict = w2PgetSysVal( 'HelpDeskCallType' );
$ist = w2PgetSysVal('HelpDeskStatus');
foreach ($ict as $k => $v) {
$q = new w2p_Database_Query;
$q->addQuery('item_status, count(item_id)');
$q->addTable('helpdesk_items');
$q->addWhere('item_calltype=' . '\'' . $k . '\' ');
$q->addGroup('item_status');
$stats[$k] = $q->loadHashList();
}
?>
<table cellspacing="1" cellpadding="2" border="0" width="100%" class="tbl">
<tr>
<th colspan="2"><?php echo $AppUI->_('Type')?></th>
<?php
$s = '';
foreach ($ist as $k => $v) {
$s .= "<th width=\"12%\"><a href=\"?m=helpdesk&a=list&item_calltype=-1&item_status=$k\" class=\"hdr\">"
. $AppUI->_($v)
. "</a></th>";
}
echo $s;
$s = '';
foreach ($ict as $kct => $vct) {
$s .= '<tr>';
$s .= '<td width="15">'
. w2PshowImage ('ct'.$kct.'.png', 15, 17, $vct,'',$m)
. '</td>';
$s .= "<td nowrap><a href=\"?m=helpdesk&a=list&item_calltype=$kct&item_status=-1\">"
. $AppUI->_($vct)
. "</a></td>";
foreach ($ist as $kst => $vst) {
$s .= "<td align=\"center\"><a href=\"?m=helpdesk&a=list&item_calltype={$kct}&item_status=$kst\">"
. @$stats[$kct][$kst]
. "</a></td>";
}
$s .= '</tr>';
}
echo $s;
?>
</table>
<?php /* HELPDESK $Id: vw_idx_watched.php,v 1.2 2006-12-14 Kang Exp $ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
include_once 'helpdesk.functions.php';
global $AppUI, $HELPDESK_CONFIG;
$q = new w2p_Database_Query;
$q->addQuery('helpdesk_items.*, CONCAT(co.contact_first_name,\' \',co.contact_last_name) assigned_fullname,
p.project_id, p.project_name, p.project_color_identifier');
$q->addQuery('contact_email AS assigned_email');
$q->addTable('helpdesk_items');
$q->addTable('helpdesk_item_watchers');
$q->addJoin('users','u','u.user_id = helpdesk_item_watchers.user_id');
$q->addJoin('contacts','co','u.user_contact = co.contact_id');
$q->addJoin('projects','p','p.project_id = helpdesk_items.item_project_id');
$q->addWhere('helpdesk_item_watchers.item_id = helpdesk_items.item_id');
$q->addWhere('helpdesk_item_watchers.user_id = '.$AppUI->user_id);
$rows = $q->loadList();
?>
<script language="javascript">
function changeList()
{
document.filterFrm.submit();
}
</script>
<?php
$ipr = w2PgetSysVal('HelpDeskPriority');
$ist = w2PgetSysVal('HelpDeskStatus');
?>
<table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl">
<tr>
<!--<td align="right" nowrap>&nbsp;</td>-->
<th nowrap="nowrap"><?php echo $AppUI->_('Number')?></th>
<th nowrap="nowrap"><?php echo $AppUI->_('Requestor')?></th>
<th nowrap="nowrap"><?php echo $AppUI->_('Title')?></th>
<th ><?php echo $AppUI->_('Summary'); ?></th>
<th nowrap="nowrap"><?php echo sort_header("item_assigned_to", $AppUI->_('Assigned To'))?></th>
<th nowrap="nowrap"><?php echo $AppUI->_('Status')?></th>
<th nowrap="nowrap"><?php echo $AppUI->_('Priority')?></th>
<th nowrap="nowrap"><?php echo $AppUI->_('Project')?></th>
</tr>
<?php
$s = '';
foreach ($rows as $row) {
/* We need to check if the user who requested the item is still in the
system. Just because we have a requestor id does not mean we'll be
able to retrieve a full name */
$s .= $CR . '<form method="post">';
$s .= $CR . '<tr>';
$s .= $CR . '<td><a href="./index.php?m=helpdesk&a=view&item_id='
. $row['item_id']
. '">'
. '<strong>'
. $row['item_id']
. '</strong></a> '
. '-'
. '</td>';
$s .= $CR . "<td nowrap align=\"center\">";
if ($row['item_requestor_email']) {
$s .= $CR . "<a href=\"mailto:".$row['item_requestor_email']."\">"
. $row['item_requestor']
. "</a>";
} else {
$s .= $CR . $row['item_requestor'];
}
$s .= $CR . "</td>";
$s .= $CR . '<td width="20%"><a href="?m=helpdesk&a=view&item_id='
. $row['item_id']
. '">'
. $HELPDESK_CONFIG['new_hd_item_title_prefix'] . ' ' .$row['item_title']
. '</a></td>';
$s .= $CR . '<td width="80%">'
. substr($row['item_summary'],0,max(strpos($row['item_summary']."\n","\n"),100))
. ' </td>';
$s .= $CR . "<td nowrap align=\"center\">";
if ($row['assigned_email']) {
$s .= $CR . "<a href=\"mailto:".$row['assigned_email']."\">"
. $row['assigned_fullname']
. "</a>";
} else {
$s .= $CR . $row['assigned_fullname'];
}
$s .= $CR . "</td>";
$s .= $CR . '<td align="center" nowrap>' . $ist[@$row['item_status']] . '</td>';
$s .= $CR . '<td align="center" nowrap>' . $ipr[@$row['item_priority']] . '</td>';
if ($row['project_id']) {
$s .= $CR . '<td align="center" style="background-color: #'
. $row['project_color_identifier']
. ';" nowrap><a href="./index.php?m=projects&a=view&project_id='
. $row['project_id'].'">'.$row['project_name'].'</a></td>';
} else {
$s .= $CR . '<td align="center">-</td>';
}
$s .= $CR . '</tr></form>';
}
print "$s\n";
?>
</table>
<?php /* $Id$ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
GLOBAL $AppUI, $hditem, $ist, $ict, $HELPDESK_CONFIG,$cal_sdf;
$item_id = w2PgetParam( $_GET, 'item_id', 0 );
$AppUI->loadCalendarJS();
$users = getAllowedUsers();
$task_log_id = intval( w2PgetParam( $_GET, 'task_log_id', 0 ) );
$log = new CTask_Log();
if ($task_log_id) {
$log->load( $task_log_id );
//Prevent users from editing other ppls timecards.
// KZHAO 11-30-2006
// Problem: the $HELPDESK_CONFIG['minimum_edit_level'] is based on pre-defined user types in dP/functions/admin_func.php
// the user types are not consistent with the user type defined for actual users...
// Solution: use hard-coded admin user type 7 here
if($HELPDESK_CONFIG['minimum_edit_level']>=$AppUI->user_type || $AppUI->user_type==7)
$can_edit_task_logs=true;
if (!$can_edit_task_logs) {
if ($log->task_log_creator!= $AppUI->user_id) {
$AppUI->redirect(ACCESS_DENIED);
}
}
} else {
$log->task_log_help_desk_id = $item_id;
$log->task_log_name = $hditem['item_title'];
}
//if ($canEdit) {
// Task Update Form
$df = $AppUI->getPref( 'SHDATEFORMAT' );
$log_date = new w2p_Utilities_Date( $log->task_log_date );
?>
<script language="JavaScript">
function updateStatus(obj)
{
var f = document.editFrm;
if (obj.options[obj.selectedIndex].value>0) {
if (f.item_status.selectedIndex==0) {
f.item_status.selectedIndex=1;
}
}
}
<!-- TIMER RELATED SCRIPTS -->
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com
// adapted by: Juan Carlos Gonzalez jcgonz@users.sourceforge.net
var timerID = 0;
var tStart = null;
var total_minutes = -1;
public function UpdateTimer()
{
if (timerID) {
clearTimeout(timerID);
clockID = 0;
}
// One minute has passed
total_minutes = total_minutes+1;
document.getElementById('timerStatus').innerHTML = '( '+total_minutes+' <?php echo $AppUI->_('minutes elapsed'); ?> )';
// Lets round hours to two decimals
var total_hours = Math.round( (total_minutes / 60) * 100) / 100;
document.editFrm.task_log_hours.value = total_hours;
timerID = setTimeout('UpdateTimer()', 60000);
}
public function timerStart()
{
if (!timerID) { // this means that it needs to be started
timerSet();
button = document.getElementById('timerStartStopButton');
button.innerHTML = '<?php echo $AppUI->_('Stop'); ?>';
UpdateTimer();
} else { // timer must be stoped
button = document.getElementById('timerStartStopButton');
button.innerHTML = '<?php echo $AppUI->_('Start'); ?>';
document.getElementById('timerStatus').innerHTML = '';
timerStop();
}
}
public function timerStop()
{
if (timerID) {
clearTimeout(timerID);
timerID = 0;
total_minutes = total_minutes-1;
}
}
public function timerReset()
{
document.editFrm.task_log_hours.value = '0.00';
total_minutes = -1;
}
public function timerSet()
{
total_minutes = Math.round(document.editFrm.task_log_hours.value * 60) -1;
}
function setDate(frm_name, f_date)
{
fld_date = eval( 'document.' + frm_name + '.' + f_date );
fld_real_date = eval( 'document.' + frm_name + '.' + 'task_' + f_date );
if (fld_date.value.length>0) {
if ((parseDate(fld_date.value))==null) {
alert('The Date/Time you typed does not match your prefered format, please retype.');
fld_real_date.value = '';
fld_date.style.backgroundColor = 'red';
} else {
fld_real_date.value = formatDate(parseDate(fld_date.value), 'yyyyMMdd');
fld_date.value = formatDate(parseDate(fld_date.value), '<?php echo $cal_sdf ?>');
fld_date.style.backgroundColor = '';
}
} else {
fld_real_date.value = '';
}
}
</script>
<!-- END OF TIMER RELATED SCRIPTS -->
<table cellspacing="1" cellpadding="2" border="0" width="100%">
<form name="editFrm" action="?m=helpdesk&a=view&item_id=<?php echo $item_id; ?>" method="post">
<input type="hidden" name="uniqueid" value="<?php echo uniqid(""); ?>" />
<input type="hidden" name="dosql" value="do_item_aed" />
<input type="hidden" name="item_id" value="<?php echo $item_id; ?>" />
<input type="hidden" name="task_log" value="1" />
<input type="hidden" name="task_log_id" value="<?php echo $log->task_log_id; ?>" />
<input type="hidden" name="task_log_help_desk_id" value="<?php echo $item_id; ?>" />
<input type="hidden" name="task_log_creator" value="<?php echo $AppUI->user_id; ?>" />
<input type="hidden" name="task_log_name" value="Update :<?php echo $log->task_log_name; ?>" />
<tr>
<td nowrap="nowrap">
<?php echo $AppUI->_('Date'); ?><br />
<input type="hidden" name="task_log_date" id="task_log_date" value="<?php echo $log_date ? $log_date->format(FMT_TIMESTAMP_DATE) : ''; ?>" />
<input type="text" name="log_date" id="log_date" onchange="setDate('editFrm', 'log_date');" value="<?php echo $log_date ? $log_date->format($df) : ''; ?>" class="text" />
<a href="javascript: void(0);" onclick="return showCalendar('log_date', '<?php echo $df ?>', 'editFrm', null, true)">
<img src="<?php echo w2PfindImage('calendar.gif'); ?>" width="24" height="12" alt="<?php echo $AppUI->_('Calendar'); ?>" border="0" />
</a>
</td>
<td><?php echo $AppUI->_('Summary'); ?>:<br />
<input type="text" class="text" name="task_log_name" value="<?php echo $log->task_log_name; ?>" maxlength="255" size="60" />
</td>
</tr>
<tr>
<td><?php echo $AppUI->_('Status')?>:<br />
<?php echo arraySelect( $ist, 'item_status', 'size="1" class="text" id="medium"',@$hditem["item_status"], true )?>
</td>
<td rowspan="4">
<?php echo $AppUI->_('Description'); ?>:<br />
<textarea name="task_log_description" class="textarea" cols="50" rows="7"><?php echo $log->task_log_description; ?></textarea>
</td>
</tr>
<tr>
<td><?php echo $AppUI->_('Assigned to'); ?>:<br />
<?php echo arraySelect( arrayMerge( array( 0 => '' ), $users), 'item_assigned_to', 'size="1" class="text" id="iat" onchange="updateStatus(this)"',
@$hditem["item_assigned_to"] ); ?>
</td>
</tr>
<tr>
<td><?php echo $AppUI->_('Call Type'); ?>:<br />
<?php echo arraySelect( $ict, 'item_calltype', 'size="1" class="text" id="ict"',@$hditem["item_calltype"], true ); ?>
</td>
</tr>
<tr>
<td nowrap="nowrap">
<br />
<?php echo "&nbsp;&nbsp;" . $AppUI->_('Hours Worked'); ?>
<input type="text" style="text-align:right;" class="text" name="task_log_hours" value="<?php echo $log->task_log_hours; ?>" maxlength="8" size="4" />
<a class="button" href="javascript:;" onclick="javascript:timerStart()"><span id="timerStartStopButton"><?php echo $AppUI->_('Start'); ?></span></a>
<a class="button" href="javascript:;" onclick="javascript:timerReset()"><span id="timerResetButton"><?php echo $AppUI->_('Reset'); ?></span></a>
<span id='timerStatus'></span>
</td>
</tr>
<tr>
<td colspan="2" valign="bottom" align="right">
<input type="submit" class="button" value="<?php echo $AppUI->_($task_log_id?'update task log':'create log'); ?>" onclick="" />
</td>
</tr>
</form>
</table>
<?php /* HELPDESK $Id$ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly');
}
global $AppUI, $format, $perms, $m;
$item_id = (int) w2PgetParam( $_GET, 'item_id', 0 );
// Lets check cost codes
$q = new w2p_Database_Query;
$q->addTable('billingcode');
$q->addWhere('billingcode_status=0');
$q->addWhere("company_id='$proj->project_company'"." OR company_id='0'");
$q->addOrder('billingcode_name');
$task_log_costcodes[0]=$AppUI->_('None');
$ptrc = $q->exec();
echo db_error();
$nums = 0;
if ($ptrc)
$nums=db_num_rows($ptrc);
for ($x=0; $x < $nums; $x++) {
$row = db_fetch_assoc( $ptrc );
$task_log_costcodes[$row["billingcode_id"]] = $row["billingcode_name"];
}
?>
<script language="JavaScript">
function delIt2(id)
{
if (confirm( "<?php echo $AppUI->_('doDelete', UI_OUTPUT_JS).' '.$AppUI->_('Task Log', UI_OUTPUT_JS).'?';?>" )) {
document.frmDelete2.task_log_id.value = id;
document.frmDelete2.submit();
}
}
</script>
<table border="0" cellpadding="2" cellspacing="1" width="100%" class="tbl">
<form name="frmDelete2" action=<?php echo '"./index.php?m=helpdesk&a=view&tab=0&item_id=' . $item_id . '"'; ?> method="post">
<input type="hidden" name="dosql" value="do_dellog" />
<input type="hidden" name="del" value="1" />
<input type="hidden" name="task_log_id" value="0" />
<input type="hidden" name="task_log_help_desk_id" value=<?php echo '"' . $item_id . '"'; ?> />
</form>
<tr>
<th></th>
<th><?php echo $AppUI->_('Date');?></th>
<th width="100"><?php echo $AppUI->_('Summary');?></th>
<th width="100"><?php echo $AppUI->_('User');?></th>
<th width="100"><?php echo $AppUI->_('Hours');?></th>
<th width="100"><?php echo $AppUI->_('Cost Code');?></th>
<th width="100%"><?php echo $AppUI->_('Comments');?></th>
<th></th>
</tr>
<?php
$q = new w2p_Database_Query;
$q->addQuery('task_log.*, user_username');
$q->addTable('task_log');
$q->addJoin('users','','user_id = task_log_creator');
$q->addWhere('task_log_help_desk_id = '. $item_id);
$q->addOrder('task_log_date');
$logs = $q->loadList();
$s = '';
$hrs = 0;
$q = new w2p_Database_Query;
$q->addQuery('item_company_id,item_created_by');
$q->addTable('helpdesk_items');
$q->addWhere('item_id = '.$item_id);
$hditem = $q->loadHash();
$canEdit = hditemEditable($hditem);
$canEdit = $perms->checkModule($m, 'edit') && hditemEditable($hditem);
foreach ($logs as $row) {
$task_log_date = intval( $row['task_log_date'] ) ? new w2p_Utilities_Date( $row['task_log_date'] ) : null;
$s .= '<tr bgcolor="white" valign="top">';
$s .= "\n\t<td>";
if ($canEdit) {
$s .= "\n\t\t<a href=\"?m=helpdesk&a=view&item_id=$item_id&tab=1&task_log_id=".@$row['task_log_id']."\">"
. "\n\t\t\t". w2PshowImage( 'stock_edit-16.png', 16, 16, '' )
. "\n\t\t</a>";
}
$s .= "\n\t</td>";
$s .= '<td nowrap="nowrap">'.($task_log_date ? $task_log_date->format( $format ) : '-').'</td>';
$s .= '<td width="30%">'.@$row["task_log_name"].'</td>';
$s .= '<td width="100">'.$row["user_username"].'</td>';
$s .= '<td width="100" align="right">'.sprintf( "%.2f", $row["task_log_hours"] ) . '</td>';
$s .= '<td width="100">'.$task_log_costcodes[$row["task_log_costcode"]].'</td>';
$s .= '<td>';
// dylan_cuthbert: auto-transation system in-progress, leave these lines
$transbrk = "\n[translation]\n";
$descrip = str_replace( "\n", "<br />", $row['task_log_description'] );
$tranpos = strpos( $descrip, str_replace( "\n", "<br />", $transbrk ) );
if ( $tranpos === false) $s .= $descrip;
else {
$descrip = substr( $descrip, 0, $tranpos );
$tranpos = strpos( $row['task_log_description'], $transbrk );
$transla = substr( $row['task_log_description'], $tranpos + strlen( $transbrk ) );
$transla = trim( str_replace( "'", '"', $transla ) );
$s .= $descrip."<div style='font-weight: bold; text-align: right'><a title='$transla' class='hilite'>[".$AppUI->_("translation")."]</a></div>";
}
// end auto-translation code
$s .= '</td><td>';
if ($canEdit) {
$s .= '<a href="javascript:delIt2(' . $row['task_log_id'] . ');" title="' . $AppUI->_('delete log') . '">' . w2PshowImage('icons/stock_delete-16.png', 16, 16, '') . '</a>';
}
$s .= '</td></tr>';
$hrs += (float) $row["task_log_hours"];
}
$s .= '<tr bgcolor="white" valign="top">';
$s .= '<td colspan="4" align="right">' . $AppUI->_('Total Hours') . ' =</td>';
$s .= '<td align="right">' . sprintf( "%.2f", $hrs ) . '</td>';
$s .= '<td align="right" colspan="3"><form action="?m=helpdesk&a=view&tab=1&item_id=' . $item_id . '" method="post">';
if ($canEdit) {
$s .= '<input type="submit" class="button" value="' . $AppUI->_('new log') . '">';
}
$s .= '</form></td></tr>';
echo $s;
?>
</table>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment