/** Function to get the list of tickets for the currently loggedin user **/ function getMyTickets($maxval, $calCnt) { global $log; $log->debug("Entering getMyTickets() method ..."); global $current_user; global $theme; global $current_language; global $adb; $current_module_strings = return_module_language($current_language, 'HelpDesk'); $theme_path = "themes/" . $theme . "/"; $image_path = "themes/images/"; $search_query = "SELECT vtiger_troubletickets.*, vtiger_crmentity.*\n\t\tFROM vtiger_troubletickets \n\t\tINNER JOIN vtiger_crmentity on vtiger_crmentity.crmid = vtiger_troubletickets.ticketid \n\t\tINNER JOIN vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid\n\t\twhere vtiger_crmentity.smownerid = ? and vtiger_crmentity.deleted = 0 and " . "vtiger_troubletickets.ticketid > 0 and vtiger_troubletickets.status <> 'Closed' " . "AND vtiger_crmentity.setype='HelpDesk' ORDER BY createdtime DESC"; $search_query .= " LIMIT 0," . $adb->sql_escape_string($maxval); if ($calCnt == 'calculateCnt') { $list_result_rows = $adb->pquery(mkCountQuery($search_query), array($current_user->id)); return $adb->query_result($list_result_rows, 0, 'count'); } $tktresult = $adb->pquery($search_query, array($current_user->id)); if ($adb->num_rows($tktresult)) { $title = array(); $title[] = 'myTickets.gif'; $title[] = $current_module_strings['LBL_MY_TICKETS']; $title[] = 'home_mytkt'; $header = array(); $header[] = $current_module_strings['LBL_SUBJECT']; $header[] = $current_module_strings['Related To']; $noofrows = $adb->num_rows($tktresult); for ($i = 0; $i < $adb->num_rows($tktresult); $i++) { $value = array(); $ticketid = $adb->query_result($tktresult, $i, "ticketid"); $viewstatus = $adb->query_result($tktresult, $i, "viewstatus"); if ($viewstatus == 'Unread') { $value[] = '<a style="color:red;" href="index.php?action=DetailView&module=HelpDesk&record=' . substr($adb->query_result($tktresult, $i, "ticketid"), 0, 20) . '">' . $adb->query_result($tktresult, $i, "title") . '</a>'; } elseif ($viewstatus == 'Marked') { $value[] = '<a style="color:yellow;" href="index.php?action=DetailView&module=HelpDesk&record=' . substr($adb->query_result($tktresult, $i, "ticketid"), 0, 20) . '">' . $adb->query_result($tktresult, $i, "title") . '</a>'; } else { $value[] = '<a href="index.php?action=DetailView&module=HelpDesk&record=' . substr($adb->query_result($tktresult, $i, "ticketid"), 0, 20) . '">' . substr($adb->query_result($tktresult, $i, "title"), 0, 20) . '</a>'; } $parent_id = $adb->query_result($tktresult, $i, "parent_id"); $parent_name = ''; if ($parent_id != '' && $parent_id != NULL) { $parent_name = getParentLink($parent_id); } $value[] = $parent_name; $entries[$ticketid] = $value; } $search_qry = "&query=true&Fields0=ticketstatus&Condition0=n&Srch_value0=closed&Fields1=assigned_user_id&Condition1=e&Srch_value1=" . $current_user->column_fields['user_name'] . "&searchtype=advance&search_cnt=2&matchtype=all"; $values = array('ModuleName' => 'HelpDesk', 'Title' => $title, 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry); if ($display_empty_home_blocks && $noofrows == 0 || $noofrows > 0) { $log->debug("Exiting getMyTickets method ..."); return $values; } } $log->debug("Exiting getMyTickets method ..."); }
/** Function to get the list of tickets for the currently loggedin user **/ function getMyTickets($maxval, $calCnt) { global $log; $log->debug("Entering getMyTickets() method ..."); global $current_user, $current_language, $adb; $current_module_strings = return_module_language($current_language, 'HelpDesk'); $search_query = "SELECT vtiger_troubletickets.*, vtiger_crmentity.*\n\t\tFROM vtiger_troubletickets\n\t\tINNER JOIN vtiger_crmentity on vtiger_crmentity.crmid = vtiger_troubletickets.ticketid\n\t\tINNER JOIN vtiger_users on vtiger_users.id = vtiger_crmentity.smownerid\n\t\twhere vtiger_crmentity.smownerid = ? and vtiger_crmentity.deleted = 0 and " . "vtiger_troubletickets.ticketid > 0 and vtiger_troubletickets.status <> 'Closed' " . "AND vtiger_crmentity.setype='HelpDesk' ORDER BY createdtime DESC"; $search_query .= " LIMIT 0," . $adb->sql_escape_string($maxval); if ($calCnt == 'calculateCnt') { $list_result_rows = $adb->pquery(mkCountQuery($search_query), array($current_user->id)); return $adb->query_result($list_result_rows, 0, 'count'); } $tktresult = $adb->pquery($search_query, array($current_user->id)); if ($adb->num_rows($tktresult)) { $title = array(); $title[] = 'myTickets.gif'; $title[] = $current_module_strings['LBL_MY_TICKETS']; $title[] = 'home_mytkt'; $header = array(); $header[] = $current_module_strings['LBL_SUBJECT']; $header[] = $current_module_strings['Related To']; $noofrows = $adb->num_rows($tktresult); for ($i = 0; $i < $adb->num_rows($tktresult); $i++) { $value = array(); $ticketid = $adb->query_result($tktresult, $i, "ticketid"); $viewstatus = $adb->query_result($tktresult, $i, "viewstatus"); if ($viewstatus == 'Unread') { $value[] = '<a style="color:red;" href="index.php?action=DetailView&module=HelpDesk&record=' . substr($adb->query_result($tktresult, $i, "ticketid"), 0, 20) . '">' . $adb->query_result($tktresult, $i, "title") . '</a>'; } elseif ($viewstatus == 'Marked') { $value[] = '<a style="color:yellow;" href="index.php?action=DetailView&module=HelpDesk&record=' . substr($adb->query_result($tktresult, $i, "ticketid"), 0, 20) . '">' . $adb->query_result($tktresult, $i, "title") . '</a>'; } else { $value[] = '<a href="index.php?action=DetailView&module=HelpDesk&record=' . substr($adb->query_result($tktresult, $i, "ticketid"), 0, 20) . '">' . substr($adb->query_result($tktresult, $i, "title"), 0, 20) . '</a>'; } $parent_id = $adb->query_result($tktresult, $i, "parent_id"); $parent_name = ''; if ($parent_id != '' && $parent_id != NULL) { $parent_name = getParentLink($parent_id); } $value[] = $parent_name; $entries[$ticketid] = $value; } $advft_criteria_groups = array('1' => array('groupcondition' => null)); $advft_criteria = array(array('groupid' => 1, 'columnname' => 'vtiger_troubletickets:status:ticketstatus:HelpDesk_Status:V', 'comparator' => 'n', 'value' => 'Closed', 'columncondition' => 'and'), array('groupid' => 1, 'columnname' => 'vtiger_crmentity:smownerid:assigned_user_id:HelpDesk_Assigned_To:V', 'comparator' => 'e', 'value' => getFullNameFromArray('Users', $current_user->column_fields), 'columncondition' => null)); $search_qry = '&advft_criteria=' . Zend_Json::encode($advft_criteria) . '&advft_criteria_groups=' . Zend_Json::encode($advft_criteria_groups) . '&searchtype=advance&query=true'; $values = array('ModuleName' => 'HelpDesk', 'Title' => $title, 'Header' => $header, 'Entries' => $entries, 'search_qry' => $search_qry); if ($noofrows == 0 || $noofrows > 0) { $log->debug("Exiting getMyTickets method ..."); return $values; } } $log->debug("Exiting getMyTickets method ..."); }