function getAllowedUsers()
{
    global $HELPDESK_CONFIG;
    //populate user list with all users from permitted companies
    $sql = "SELECT user_id, CONCAT(contact_last_name, ',', contact_first_name)\n\t\t\tFROM users\n\t\t   LEFT JOIN contacts ON user_contact = contact_id\n\t\t\tWHERE " . getCompanyPerms("user_company", PERM_EDIT, $HELPDESK_CONFIG['the_company']) . " OR " . getCompanyPerms("contact_company", PERM_EDIT, $HELPDESK_CONFIG['the_company']) . "ORDER BY contact_last_name, contact_first_name";
    $users = db_loadHashList($sql);
    return $users;
}
Exemple #2
0
    $assigned_to_list = db_loadHashList($sql);
    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
    $sql = "SELECT distinct(item_requestor) as requestor, item_requestor\n\t\t      FROM helpdesk_items\n\t\t      WHERE " . getCompanyPerms("item_company_id", NULL, PERM_READ) . "\n\t\t      ORDER BY item_requestor";
    $requestor_list = db_loadHashList($sql);
    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) . ') ';
}
$sql = "SELECT hi.*,\n        CONCAT(co.contact_first_name,' ',co.contact_last_name) assigned_fullname,\n        co.contact_email as assigned_email,\n        p.project_id,\n        p.project_name,\n        p.project_color_identifier\n        FROM helpdesk_items hi\n        LEFT JOIN users u2 ON u2.user_id = hi.item_assigned_to\n        LEFT JOIN contacts co ON u2.user_contact = co.contact_id\n        LEFT JOIN projects p ON p.project_id = hi.item_project_id\n        WHERE {$where}\n        ORDER BY ";
// Do custom order by if needed, default at the end
if ($orderby == "project_name") {
    $sql .= "p.project_name";
} elseif ($orderby == "item_assigned_to") {
    $sql .= "assigned_fullname";
Exemple #3
0
}
if (!canView) {
    $AppUI->redirect("m=public&a=access_denied");
}
if (!$canEdit) {
    $AppUI->redirect("m=public&a=access_denied");
}
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);
}
$users = getAllowedUsers();
$sql = "SELECT company_id, company_name\n        FROM companies\n        WHERE " . getCompanyPerms("company_id") . "ORDER BY company_name";
$companies = arrayMerge(array(0 => ''), db_loadHashList($sql));
$sql = "\n\tSELECT \n\t\thelpdesk_item_watchers.user_id, \n\t\tCONCAT(contact_last_name, ',', contact_first_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        WHERE \n        \titem_id = " . $item_id . "\n        ORDER BY contact_last_name, contact_first_name";
$watchers = db_loadHashList($sql);
// Setup the title block
$ttl = $item_id ? 'Editing Help Desk Item' : 'Adding Help Desk Item';
$titleBlock = new CTitleBlock($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');