<?php /* HELPDESK $Id: vw_idx_watched.php,v 1.3 2007/06/30 15:40:09 caseydk Exp $ */ global $m; $sql = "SELECT hi.*,\n CONCAT(contact_first_name,' ',contact_last_name) assigned_fullname,\n contact_email as assigned_email,\n p.project_id,\n p.project_name,\n p.project_color_identifier\n FROM helpdesk_items hi\n INNER JOIN helpdesk_item_watchers hiw ON hiw.item_id = hi.item_id\n LEFT JOIN users u2 ON u2.user_id = hiw.user_id\n LEFT JOIN contacts ON u2.user_contact = contacts.contact_id\n LEFT JOIN projects p ON p.project_id = hi.item_project_id\n\tWHERE hiw.user_id = {$AppUI->user_id} and hi.item_status <> 3 and hi.item_status <> 2\n\t"; #print $sql; $rows = db_loadlist($sql); ?> <script language="javascript"> function changeList() { document.filterFrm.submit(); } </script> <?php $ipr = dPgetSysVal('HelpDeskPriority'); $ist = dPgetSysVal('HelpDeskStatus'); ?> <table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl"> <tr> <!--<td align="right" nowrap> </td>--> <th nowrap="nowrap"><?php echo $AppUI->_('Number'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Requestor'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Title'); ?>
$titleBlock = new CTitleBlock($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 = hditemEditable($hditem); if (!$canRead && !$canEdit) { $AppUI->redirect("m=public&a=access_denied"); } $name = $hditem['item_requestor']; $assigned_to_name = $hditem["item_assigned_to"] ? $hditem["assigned_to_fullname"] : ""; $assigned_email = $hditem["assigned_email"]; $sql = "\n\tSELECT \n\t\thelpdesk_item_watchers.user_id, \n\t\tCONCAT(contact_first_name, ' ', contact_last_name) as name,\n\t\tcontact_email\n\tFROM \n\t\thelpdesk_item_watchers\n\t\tLEFT JOIN users ON helpdesk_item_watchers.user_id = users.user_id\n\t\tLEFT JOIN contacts ON user_contact = contact_id\n\tWHERE \n\t\titem_id = " . $item_id . "\n\tORDER BY contact_last_name, contact_first_name"; $watchers = db_loadlist($sql); $titleBlock = new CTitleBlock('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->show(); ?> <script language="JavaScript"> function delIt() { if (confirm( "<?php
function doWatchers($list, $hditem) { global $AppUI; # Create the watcher list $watcherlist = split(',', $list); $sql = "SELECT user_id FROM helpdesk_item_watchers WHERE item_id=" . $hditem->item_id; $current_users = db_loadHashList($sql); $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) { $sql = "SELECT user_id, contact_email FROM users LEFT JOIN contacts ON user_contact = contact_id WHERE user_id=" . $watcher; $rows = db_loadlist($sql); foreach ($rows as $row) { # Send the notification that they've been added to a watch list. if (!in_array($row['user_id'], $current_users)) { notify($row['contact_email'], $hditem); } } $sql = "INSERT INTO helpdesk_item_watchers VALUES(" . $hditem->item_id . "," . $watcher . ",'Y')"; db_exec($sql); } } } }
function getUsers() { $sql = "SELECT user_username,user_id FROM users"; $result = db_loadlist($sql); return $result; }