function getTimeSpentWorkerReportAction() { $db = DevblocksPlatform::getDatabaseService(); $subtotal = array(); $total_cm = array(); DevblocksPlatform::getExtensions('timetracking.source', true); @($sel_worker_id = DevblocksPlatform::importGPC($_REQUEST['worker_id'], 'integer', 0)); @($report_type = DevblocksPlatform::importGPC($_REQUEST['report_type'], 'integer', 0)); // Security if (null == ($active_worker = CerberusApplication::getActiveWorker())) { die($translate->_('common.access_denied')); } $tpl = DevblocksPlatform::getTemplateService(); $tpl->cache_lifetime = "0"; $tpl->assign('path', $this->tpl_path); // import dates from form @($start = DevblocksPlatform::importGPC($_REQUEST['start'], 'string', '')); @($end = DevblocksPlatform::importGPC($_REQUEST['end'], 'string', '')); // use date rang@$sel_worker_id = DevblocksPlatform::importGPC($_REQUEST['worker_id'],'integer',0);e if specified, else use duration prior to now $start_time = 0; $end_time = 0; if (empty($start) && empty($end)) { $start = "Last Monday"; $end = "now"; $start_time = strtotime($start); $end_time = strtotime($end); } else { $start_time = strtotime($start); $end_time = strtotime($end); } if ($start_time === false || $end_time === false) { $start = "Last Monday"; $end = "now"; $start_time = strtotime($start); $end_time = strtotime($end); $tpl->assign('invalidDate', true); } // reload variables in template $tpl->assign('start', $start); $tpl->assign('end', $end); $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); $sources = DAO_TimeTrackingEntry::getSources(); $tpl->assign('sources', $sources); $sql = "SELECT tte.log_date, tte.time_actual_mins, tte.worker_id, tte.notes, "; $sql .= "tte.source_extension_id, tte.source_id, "; $sql .= "tta.name activity_name "; $sql .= "FROM timetracking_entry tte "; $sql .= "INNER JOIN timetracking_activity tta ON tte.activity_id = tta.id "; $sql .= "INNER JOIN worker w ON tte.worker_id = w.id "; $sql .= sprintf("WHERE log_date > %d AND log_date <= %d ", $start_time, $end_time); if ($sel_worker_id) { $sql .= sprintf("AND tte.worker_id = %d ", $sel_worker_id); } // Do Not use Group By it breaks things. // $sql .= "GROUP BY activity_name "; $sql .= "ORDER BY w.last_name, w.first_name, activity_name, w.id, tte.log_date "; // echo $sql; $rs = $db->Execute($sql); $time_entries = array(); $filename = "worker-" . $active_worker->id . ".csv"; $full_filename = getcwd() . '/storage/answernet/' . $filename; if (file_exists($full_filename)) { if (!is_writable($full_filename)) { die("The file: {$full_filename} is not writable"); } } elseif (!is_writable(getcwd() . '/storage/answernet/')) { die("you cannot create files in this directory. Check the permissions"); } //open the file for Writing $fh = fopen($full_filename, "w"); //Lock the file for the write operation flock($fh, LOCK_EX); $label = array("Worker Name", "Ticket No", "Client", "Asset", "Site Name", "Billing Group", "Billing Min", "Sub-Total", "Total", "Date Recorded", "Notes"); fputcsv($fh, $label, ",", "\""); if (is_a($rs, 'ADORecordSet')) { while (!$rs->EOF) { $csv = array(); $custom_fields = array(); $mins = intval($rs->fields['time_actual_mins']); $worker_id = intval($rs->fields['worker_id']); $org_id = intval($rs->fields['org_id']); $activity = $rs->fields['activity_name']; $log_date = intval($rs->fields['log_date']); $notes = $rs->fields['notes']; if (!isset($time_entries[$worker_id])) { $time_entries[$worker_id] = array(); $time_entries[$worker_id]['mins'] = array(); } if (!isset($subtotal)) { $subtotal = array(); $subtotal_activity = $activity; $subtotal['name'] = $workers[$worker_id]->getName(false); $subtotal['source_id'] = ""; $subtotal['client'] = ""; $subtotal['asset'] = ""; $subtotal['sitename'] = ""; $subtotal['activity_name'] = $activity; $subtotal['mins'] = ""; } else { if ($subtotal_activity != $activity) { //Dump Sub Total fputcsv($fh, $subtotal, ",", "\""); $subtotal = array(); $subtotal_activity = $activity; $subtotal['name'] = $workers[$worker_id]->getName(false); $subtotal['source_id'] = ""; $subtotal['client'] = ""; $subtotal['asset'] = ""; $subtotal['sitename'] = ""; $subtotal['activity_name'] = $activity; $subtotal['mins'] = ""; } } if (!isset($total_cm)) { $total_cm = array(); $total_worker_id = $worker_id; $total_cm['name'] = $workers[$worker_id]->getName(false); $total_cm['source_id'] = ""; $total_cm['client'] = ""; $total_cm['asset'] = ""; $total_cm['sitename'] = ""; $total_cm['activity_name'] = ""; $total_cm['mins'] = ""; } else { if ($total_worker_id != $worker_id) { //Dump Total fputcsv($fh, $total_cm, ",", "\""); $total_cm = array(); $total_worker_id = $worker_id; $total_cm['name'] = $workers[$worker_id]->getName(false); $total_cm['source_id'] = ""; $total_cm['client'] = ""; $total_cm['asset'] = ""; $total_cm['sitename'] = ""; $total_cm['activity_name'] = ""; $total_cm['mins'] = ""; } } $csv['name'] = $workers[$worker_id]->getName(false); unset($time_entry); $time_entry['activity_name'] = $activity; $time_entry['mins'] = $mins; $time_entry['log_date'] = $log_date; $time_entry['notes'] = $notes; $time_entry['source_extension_id'] = $rs->fields['source_extension_id']; $time_entry['source_id'] = intval($rs->fields['source_id']); $csv['source_id'] = intval($rs->fields['source_id']); $custom_fields = DAO_CustomFieldValue::getValuesBySourceIds(ChCustomFieldSource_Ticket::ID, $csv['source_id']); if (isset($custom_fields[$csv['source_id']][10])) { $csv['client'] = $custom_fields[$csv['source_id']][10]; } else { $csv['client'] = ""; } if (isset($custom_fields[$csv['source_id']][11])) { $csv['asset'] = $custom_fields[$csv['source_id']][11]; } else { $csv['asset'] = ""; } if (isset($custom_fields[$csv['source_id']][1])) { $csv['sitename'] = $custom_fields[$csv['source_id']][1]; } else { $csv['sitename'] = ""; } $csv['activity_name'] = $activity; $csv['mins'] = $mins; $csv['subtotal'] = ""; $csv['total'] = ""; $csv['log_date'] = date("Y-m-d h:i A", $log_date); $csv['notes'] = $notes; $time_entries[$worker_id]['entries'][] = $time_entry; @($time_entries[$worker_id]['mins'][$activity] = intval($time_entries[$worker_id]['mins'][$activity]) + $mins); @($time_entries[$worker_id]['mins']['total'] = intval($time_entries[$worker_id]['mins']['total']) + $mins); $subtotal['subtotal'] = $time_entries[$worker_id]['mins'][$activity]; $total_cm['subtotal'] = ""; $subtotal['total'] = ""; $total_cm['total'] = $time_entries[$worker_id]['mins']['total']; fputcsv($fh, $csv, ",", "\""); $rs->MoveNext(); } } // print_r($time_entries); $tpl->assign('time_entries', $time_entries); $tpl->assign('report_type', $report_type); $tpl->assign('href_filename', $href_filename); fputcsv($fh, $subtotal, ",", "\""); fputcsv($fh, $total_cm, ",", "\""); fclose($fh); $tpl->display('file:' . $this->tpl_path . '/report_worker_time_html.tpl'); }
function run() { $logger = DevblocksPlatform::getConsoleLog(); $logger->info("[Alerts] Starting..."); $alerts = DAO_Alert::getAll(); $check_sensors = DAO_Sensor::getAll(); $workers = DAO_Worker::getAll(); if (is_array($alerts)) { foreach ($alerts as $alert) { /* @var $alert Model_Alert */ if (!isset($workers[$alert->worker_id])) { continue; } $logger->info(sprintf("[Alerts] Checking '%s' for %s...", $alert->name, $workers[$alert->worker_id]->getName())); $hit_sensors = $alert->getMatches($check_sensors); if (is_array($hit_sensors)) { $alert->run($hit_sensors); } } } $logger->info("[Alerts] Finished!"); }
/** * @return Model_WatcherMailFilter[]|false */ static function getMatches(CerberusTicket $ticket, $event, $only_worker_id = null) { $matches = array(); if (!empty($only_worker_id)) { $filters = DAO_WatcherMailFilter::getWhere(sprintf("%s = %d AND %s = %d", DAO_WatcherMailFilter::WORKER_ID, $only_worker_id, DAO_WatcherMailFilter::IS_DISABLED, 0)); } else { $filters = DAO_WatcherMailFilter::getWhere(sprintf("%s = %d", DAO_WatcherMailFilter::IS_DISABLED, 0)); } // [JAS]: Don't send obvious spam to watchers. if ($ticket->spam_score >= 0.9) { return false; } // Build our objects $ticket_from = DAO_Address::get($ticket->last_wrote_address_id); $ticket_group_id = $ticket->team_id; // [TODO] These expensive checks should only populate when needed $messages = DAO_Ticket::getMessagesByTicket($ticket->id); $message_headers = array(); if (empty($messages)) { return false; } if (null != @($message_last = array_pop($messages))) { /* @var $message_last CerberusMessage */ $message_headers = $message_last->getHeaders(); } // Clear the rest of the message manifests unset($messages); $custom_fields = DAO_CustomField::getAll(); // Lazy load when needed on criteria basis $ticket_field_values = null; $address_field_values = null; $org_field_values = null; // Worker memberships (for checking permissions) $workers = DAO_Worker::getAll(); $group_rosters = DAO_Group::getRosters(); // Check filters if (is_array($filters)) { foreach ($filters as $filter) { /* @var $filter Model_WatcherMailFilter */ $passed = 0; // check the worker's group memberships if (!isset($workers[$filter->worker_id]) || $workers[$filter->worker_id]->is_disabled || !$workers[$filter->worker_id]->is_superuser && !isset($group_rosters[$ticket->team_id][$filter->worker_id])) { // no membership continue; } // check criteria foreach ($filter->criteria as $rule_key => $rule) { @($value = $rule['value']); switch ($rule_key) { case 'dayofweek': $current_day = strftime('%w'); //$current_day = 1; // Forced to English abbrevs as indexes $days = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'); // Is the current day enabled? if (isset($rule[$days[$current_day]])) { $passed++; } break; case 'timeofday': $current_hour = strftime('%H'); $current_min = strftime('%M'); //$current_hour = 17; //$current_min = 5; if (null != ($from_time = @$rule['from'])) { list($from_hour, $from_min) = explode(':', $from_time); } if (null != ($to_time = @$rule['to'])) { if (list($to_hour, $to_min) = explode(':', $to_time)) { } } // Do we need to wrap around to the next day's hours? if ($from_hour > $to_hour) { // yes $to_hour += 24; // add 24 hrs to the destination (1am = 25th hour) } // Are we in the right 24 hourly range? if ((int) $current_hour >= $from_hour && (int) $current_hour <= $to_hour) { // If we're in the first hour, are we minutes early? if ($current_hour == $from_hour && (int) $current_min < $from_min) { break; } // If we're in the last hour, are we minutes late? if ($current_hour == $to_hour && (int) $current_min > $to_min) { break; } $passed++; } break; case 'event': if (!empty($event) && is_array($rule) && isset($rule[$event])) { $passed++; } break; case 'groups': if (null !== @($group_buckets = $rule['groups'][$ticket->team_id]) && (empty($group_buckets) || in_array($ticket->category_id, $group_buckets))) { $passed++; } break; case 'next_worker_id': // If it's an assigned event, we only care about the filter's owner if (!empty($event) && 0 == strcasecmp($event, 'ticket_assignment')) { if (intval($value) == intval($filter->worker_id)) { $passed++; break; } } if (intval($value) == intval($ticket->next_worker_id)) { $passed++; } break; case 'mask': $regexp_mask = DevblocksPlatform::strToRegExp($value); if (@preg_match($regexp_mask, $ticket->mask)) { $passed++; } break; case 'from': $regexp_from = DevblocksPlatform::strToRegExp($value); if (@preg_match($regexp_from, $ticket_from->email)) { $passed++; } break; case 'subject': $regexp_subject = DevblocksPlatform::strToRegExp($value); if (@preg_match($regexp_subject, $ticket->subject)) { $passed++; } break; case 'body': if (null == ($message_body = $message_last->getContent())) { break; } // Line-by-line body scanning (sed-like) $lines = preg_split("/[\r\n]/", $message_body); if (is_array($lines)) { foreach ($lines as $line) { if (@preg_match($value, $line)) { $passed++; break; } } } break; case 'header1': case 'header2': case 'header3': case 'header4': case 'header5': @($header = strtolower($rule['header'])); if (empty($header)) { $passed++; break; } if (empty($value)) { // we're checking for null/blanks if (!isset($message_headers[$header]) || empty($message_headers[$header])) { $passed++; } } elseif (isset($message_headers[$header]) && !empty($message_headers[$header])) { $regexp_header = DevblocksPlatform::strToRegExp($value); // Flatten CRLF if (@preg_match($regexp_header, str_replace(array("\r", "\n"), ' ', $message_headers[$header]))) { $passed++; } } break; default: // ignore invalids // Custom Fields if (0 == strcasecmp('cf_', substr($rule_key, 0, 3))) { $field_id = substr($rule_key, 3); // Make sure it exists if (null == @($field = $custom_fields[$field_id])) { continue; } // Lazy values loader $field_values = array(); switch ($field->source_extension) { case ChCustomFieldSource_Address::ID: if (null == $address_field_values) { $address_field_values = array_shift(DAO_CustomFieldValue::getValuesBySourceIds(ChCustomFieldSource_Address::ID, $ticket_from->id)); } $field_values =& $address_field_values; break; case ChCustomFieldSource_Org::ID: if (null == $org_field_values) { $org_field_values = array_shift(DAO_CustomFieldValue::getValuesBySourceIds(ChCustomFieldSource_Org::ID, $ticket_from->contact_org_id)); } $field_values =& $org_field_values; break; case ChCustomFieldSource_Ticket::ID: if (null == $ticket_field_values) { $ticket_field_values = array_shift(DAO_CustomFieldValue::getValuesBySourceIds(ChCustomFieldSource_Ticket::ID, $ticket->id)); } $field_values =& $ticket_field_values; break; } // Type sensitive value comparisons // [TODO] Operators switch ($field->type) { case 'S': // string // string case 'T': // clob // clob case 'U': // URL $field_val = isset($field_values[$field_id]) ? $field_values[$field_id] : ''; $oper = isset($rule['oper']) ? $rule['oper'] : "="; if ($oper == "=" && @preg_match(DevblocksPlatform::strToRegExp($value, true), $field_val)) { $passed++; } elseif ($oper == "!=" && @(!preg_match(DevblocksPlatform::strToRegExp($value, true), $field_val))) { $passed++; } break; case 'N': // number $field_val = isset($field_values[$field_id]) ? $field_values[$field_id] : 0; $oper = isset($rule['oper']) ? $rule['oper'] : "="; if ($oper == "=" && intval($field_val) == intval($value)) { $passed++; } elseif ($oper == "!=" && intval($field_val) != intval($value)) { $passed++; } elseif ($oper == ">" && intval($field_val) > intval($value)) { $passed++; } elseif ($oper == "<" && intval($field_val) < intval($value)) { $passed++; } break; case 'E': // date $field_val = isset($field_values[$field_id]) ? intval($field_values[$field_id]) : 0; $from = isset($rule['from']) ? $rule['from'] : "0"; $to = isset($rule['to']) ? $rule['to'] : "now"; if (intval(@strtotime($from)) <= $field_val && intval(@strtotime($to)) >= $field_val) { $passed++; } break; case 'C': // checkbox $field_val = isset($field_values[$field_id]) ? $field_values[$field_id] : 0; if (intval($value) == intval($field_val)) { $passed++; } break; case 'D': // dropdown // dropdown case 'X': // multi-checkbox // multi-checkbox case 'M': // multi-picklist // multi-picklist case 'W': // worker $field_val = isset($field_values[$field_id]) ? $field_values[$field_id] : array(); if (!is_array($value)) { $value = array($value); } if (is_array($field_val)) { // if multiple things set foreach ($field_val as $v) { // loop through possible if (isset($value[$v])) { // is any possible set? $passed++; break; } } } else { // single if (isset($value[$field_val])) { // is our set field in possibles? $passed++; break; } } break; } } break; } } // If our rule matched every criteria, stop and return the filter if ($passed == count($filter->criteria)) { DAO_WatcherMailFilter::increment($filter->id); // ++ the times we've matched $matches[$filter->id] = $filter; } } } if (!empty($matches)) { return $matches; } // No matches return false; }
function handleRequest(DevblocksHttpRequest $request) { $worker = CerberusApplication::getActiveWorker(); if (empty($worker)) { return; } $stack = $request->path; array_shift($stack); // print @($object = strtolower(array_shift($stack))); // ticket|message|etc $tpl = DevblocksPlatform::getTemplateService(); $tpl->assign('path', $this->_TPL_PATH); $settings = DevblocksPlatform::getPluginSettingsService(); $tpl->assign('settings', $settings); $translate = DevblocksPlatform::getTranslationService(); $tpl->assign('translate', $translate); $teams = DAO_Group::getAll(); $tpl->assign('teams', $teams); $buckets = DAO_Bucket::getAll(); $tpl->assign('buckets', $buckets); $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); // Security $active_worker = CerberusApplication::getActiveWorker(); $active_worker_memberships = $active_worker->getMemberships(); // [TODO] Make this pluggable // Subcontroller switch ($object) { case 'ticket': @($id = array_shift($stack)); @($ticket = is_numeric($id) ? DAO_Ticket::getTicket($id) : DAO_Ticket::getTicketByMask($id)); $convo_timeline = array(); $messages = $ticket->getMessages(); foreach ($messages as $message_id => $message) { /* @var $message CerberusMessage */ $key = $message->created_date . '_m' . $message_id; // build a chrono index of messages $convo_timeline[$key] = array('m', $message_id); } @($mail_inline_comments = DAO_WorkerPref::get($active_worker->id, 'mail_inline_comments', 1)); if ($mail_inline_comments) { // if inline comments are enabled $comments = DAO_TicketComment::getByTicketId($ticket->id); arsort($comments); $tpl->assign('comments', $comments); // build a chrono index of comments foreach ($comments as $comment_id => $comment) { /* @var $comment Model_TicketComment */ $key = $comment->created . '_c' . $comment_id; $convo_timeline[$key] = array('c', $comment_id); } } ksort($convo_timeline); $tpl->assign('convo_timeline', $convo_timeline); // Comment parent addresses $comment_addresses = array(); foreach ($comments as $comment) { /* @var $comment Model_TicketComment */ $address_id = intval($comment->address_id); if (!isset($comment_addresses[$address_id])) { $address = DAO_Address::get($address_id); $comment_addresses[$address_id] = $address; } } $tpl->assign('comment_addresses', $comment_addresses); // Message Notes $notes = DAO_MessageNote::getByTicketId($ticket->id); $message_notes = array(); // Index notes by message id if (is_array($notes)) { foreach ($notes as $note) { if (!isset($message_notes[$note->message_id])) { $message_notes[$note->message_id] = array(); } $message_notes[$note->message_id][$note->id] = $note; } } $tpl->assign('message_notes', $message_notes); // Make sure we're allowed to view this ticket or message if (!isset($active_worker_memberships[$ticket->team_id])) { echo "<H1>" . $translate->_('common.access_denied') . "</H1>"; return; } $tpl->assign('ticket', $ticket); $tpl->display('file:' . $this->_TPL_PATH . 'print/ticket.tpl'); break; case 'message': @($id = array_shift($stack)); @($message = DAO_Ticket::getMessage($id)); @($ticket = DAO_Ticket::getTicket($message->ticket_id)); // Make sure we're allowed to view this ticket or message if (!isset($active_worker_memberships[$ticket->team_id])) { echo "<H1>" . $translate->_('common.access_denied') . "</H1>"; return; } // Message Notes $notes = DAO_MessageNote::getByTicketId($ticket->id); $message_notes = array(); // Index notes by message id if (is_array($notes)) { foreach ($notes as $note) { if (!isset($message_notes[$note->message_id])) { $message_notes[$note->message_id] = array(); } $message_notes[$note->message_id][$note->id] = $note; } } $tpl->assign('message_notes', $message_notes); $tpl->assign('message', $message); $tpl->assign('ticket', $ticket); $tpl->display('file:' . $this->_TPL_PATH . 'print/message.tpl'); break; } }
function saveWorkerPeekAction() { $translate = DevblocksPlatform::getTranslationService(); $active_worker = FegApplication::getActiveWorker(); if (!$active_worker || !$active_worker->is_superuser) { return; } @($id = DevblocksPlatform::importGPC($_POST['id'], 'integer')); @($view_id = DevblocksPlatform::importGPC($_POST['view_id'], 'string')); @($first_name = DevblocksPlatform::importGPC($_POST['first_name'], 'string')); @($last_name = DevblocksPlatform::importGPC($_POST['last_name'], 'string')); @($title = DevblocksPlatform::importGPC($_POST['title'], 'string')); @($email = DevblocksPlatform::importGPC($_POST['email'], 'string')); @($password = DevblocksPlatform::importGPC($_POST['password'], 'string')); @($is_superuser = DevblocksPlatform::importGPC($_POST['is_superuser'], 'integer', 0)); @($disabled = DevblocksPlatform::importGPC($_POST['is_disabled'], 'integer', 0)); // @$group_ids = DevblocksPlatform::importGPC($_POST['group_ids'],'array'); // @$group_roles = DevblocksPlatform::importGPC($_POST['group_roles'],'array'); @($delete = DevblocksPlatform::importGPC($_POST['do_delete'], 'integer', 0)); // [TODO] The superuser set bit here needs to be protected by ACL if (empty($first_name)) { $first_name = "Anonymous"; } if (!empty($id) && !empty($delete)) { // Can't delete or disable self if ($active_worker->id != $id) { DAO_Worker::delete($id); } } else { if (empty($id) && null == DAO_Worker::getWhere(sprintf("%s=%s", DAO_Worker::EMAIL, Feg_ORMHelper::qstr($email)))) { $workers = DAO_Worker::getAll(); $license = FegLicense::getInstance(); if (!empty($license) && !empty($license['serial']) || count($workers) < 3) { // Creating new worker. If password is empty, email it to them if (empty($password)) { $settings = DevblocksPlatform::getPluginSettingsService(); $replyFrom = $settings->get('feg.core', FegSettings::DEFAULT_REPLY_FROM); $replyPersonal = $settings->get('feg.core', FegSettings::DEFAULT_REPLY_PERSONAL, ''); $url = DevblocksPlatform::getUrlService(); $password = FegApplication::generatePassword(8); } $fields = array(DAO_Worker::EMAIL => $email, DAO_Worker::PASS => $password); $id = DAO_Worker::create($fields); } } // end create worker // Update $fields = array(DAO_Worker::FIRST_NAME => $first_name, DAO_Worker::LAST_NAME => $last_name, DAO_Worker::TITLE => $title, DAO_Worker::EMAIL => $email, DAO_Worker::IS_SUPERUSER => $is_superuser, DAO_Worker::IS_DISABLED => $disabled); // if we're resetting the password if (!empty($password)) { $fields[DAO_Worker::PASS] = md5($password); } // Update worker DAO_Worker::update($id, $fields); // Custom field saves @($field_ids = DevblocksPlatform::importGPC($_POST['field_ids'], 'array', array())); DAO_CustomFieldValue::handleFormPost(FegCustomFieldSource_Worker::ID, $id, $field_ids); } if (!empty($view_id)) { $view = Feg_AbstractViewLoader::getView($view_id); $view->render(); } }
function render() { $tpl = DevblocksPlatform::getTemplateService(); $active_worker = CerberusApplication::getActiveWorker(); $memberships = $active_worker->getMemberships(); $response = DevblocksPlatform::getHttpResponse(); @($section = $response->path[1]); //print_r($_REQUEST);exit(); //@$page = DevblocksPlatform::importGPC($_GET['password']); @($page = DevblocksPlatform::importGPC($_REQUEST['page'], 'integer')); if ($page == NULL) { $page = 0; } if (isset($_POST['a2'])) { @($section = $_POST['a2']); } else { @($section = $response->path[2]); } //print_r($section); //echo $section; switch ($section) { case 'search': $title = 'Search'; $query = $_POST['query']; if ($query && false === strpos($query, '*')) { $query = '*' . $query . '*'; } if (!is_null($query)) { $params = array(); $type = $_POST['type']; switch ($type) { case "mask": $params[SearchFields_Ticket::TICKET_MASK] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_MASK, DevblocksSearchCriteria::OPER_LIKE, strtoupper($query)); break; case "sender": $params[SearchFields_Ticket::TICKET_FIRST_WROTE] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_FIRST_WROTE, DevblocksSearchCriteria::OPER_LIKE, strtolower($query)); break; case "subject": $params[SearchFields_Ticket::TICKET_SUBJECT] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_SUBJECT, DevblocksSearchCriteria::OPER_LIKE, $query); break; case "content": $params[SearchFields_Ticket::TICKET_MESSAGE_CONTENT] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_MESSAGE_CONTENT, DevblocksSearchCriteria::OPER_LIKE, $query); break; } } else { //show the search form because no search has been submitted $tpl->display('file:' . dirname(__FILE__) . '/templates/tickets/search.tpl'); return; } break; case 'sidebar': $groups = DAO_Group::getAll(); $tpl->assign('groups', $groups); $group_buckets = DAO_Bucket::getTeams(); $tpl->assign('group_buckets', $group_buckets); $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); $group_counts = DAO_Overview::getGroupTotals(); $tpl->assign('group_counts', $group_counts); $waiting_counts = DAO_Overview::getWaitingTotals(); $tpl->assign('waiting_counts', $waiting_counts); $worker_counts = DAO_Overview::getWorkerTotals(); $tpl->assign('worker_counts', $worker_counts); $tpl->display('file:' . dirname(__FILE__) . '/templates/tickets/sidebar.tpl'); return; break; case 'overview': default: $workers = DAO_Worker::getAll(); $group_buckets = DAO_Bucket::getTeams(); $groups = DAO_Group::getAll(); @($filter = $response->path[3]); switch ($filter) { case 'group': @($filter_group_id = $response->path[4]); $params = array(SearchFields_Ticket::TICKET_CLOSED => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_CLOSED, '=', CerberusTicketStatus::OPEN), SearchFields_Ticket::TICKET_WAITING => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_WAITING, '=', 0), SearchFields_Ticket::TICKET_NEXT_WORKER_ID => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_NEXT_WORKER_ID, '=', 0)); if (!is_null($filter_group_id) && isset($groups[$filter_group_id])) { $tpl->assign('filter_group_id', $filter_group_id); $title = $groups[$filter_group_id]->name; $params[SearchFields_Ticket::TICKET_TEAM_ID] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_TEAM_ID, '=', $filter_group_id); @($filter_bucket_id = $response->path[5]); if (!is_null($filter_bucket_id)) { $tpl->assign('filter_bucket_id', $filter_bucket_id); @($title .= ': ' . ($filter_bucket_id == 0 ? 'Inbox' : $group_buckets[$filter_group_id][$filter_bucket_id]->name)); $params[SearchFields_Ticket::TICKET_CATEGORY_ID] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_CATEGORY_ID, '=', $filter_bucket_id); } else { @($title .= ' (Spam Filtered)'); $params[SearchFields_Ticket::TICKET_SPAM_SCORE] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_SPAM_SCORE, '<=', '0.9000'); } } break; case 'waiting': @($filter_waiting_id = $response->path[4]); $params = array(SearchFields_Ticket::TICKET_CLOSED => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_CLOSED, '=', CerberusTicketStatus::OPEN), SearchFields_Ticket::TICKET_WAITING => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_WAITING, '=', 1)); if (!is_null($filter_waiting_id) && isset($groups[$filter_waiting_id])) { $tpl->assign('filter_waiting_id', $filter_waiting_id); $title = '[Waiting] ' . $groups[$filter_waiting_id]->name; $params[SearchFields_Ticket::TICKET_TEAM_ID] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_TEAM_ID, '=', $filter_waiting_id); @($filter_bucket_id = $response->path[5]); if (!is_null($filter_bucket_id)) { $tpl->assign('filter_bucket_id', $filter_bucket_id); @($title .= ': ' . ($filter_bucket_id == 0 ? 'Inbox' : $group_buckets[$filter_waiting_id][$filter_bucket_id]->name)); $params[SearchFields_Ticket::TICKET_CATEGORY_ID] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_CATEGORY_ID, '=', $filter_bucket_id); } } break; case 'worker': @($filter_worker_id = $response->path[4]); $params = array(SearchFields_Ticket::TICKET_CLOSED => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_CLOSED, '=', CerberusTicketStatus::OPEN), SearchFields_Ticket::TICKET_WAITING => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_WAITING, '=', 0), $params[SearchFields_Ticket::TICKET_TEAM_ID] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_TEAM_ID, 'in', array_keys($memberships))); if (!is_null($filter_worker_id)) { $tpl->assign('filter_bucket_id', $filter_bucket_id); $title = "For " . $workers[$filter_worker_id]->getName(); $params[SearchFields_Ticket::TICKET_NEXT_WORKER_ID] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_NEXT_WORKER_ID, '=', $filter_worker_id); @($filter_group_id = $response->path[5]); if (!is_null($filter_group_id) && isset($groups[$filter_group_id])) { $title .= ' in ' . $groups[$filter_group_id]->name; $params[SearchFields_Ticket::TICKET_TEAM_ID] = new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_TEAM_ID, '=', $filter_group_id); } } break; case 'all': default: $title = 'All (Spam Filtered)'; $params = array(SearchFields_Ticket::TICKET_CLOSED => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_CLOSED, '=', CerberusTicketStatus::OPEN), SearchFields_Ticket::TICKET_WAITING => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_WAITING, '=', 0), SearchFields_Ticket::TICKET_NEXT_WORKER_ID => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_NEXT_WORKER_ID, '=', 0), SearchFields_Ticket::TICKET_SPAM_SCORE => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_SPAM_SCORE, '<=', '0.9000'), SearchFields_Ticket::TICKET_TEAM_ID => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_TEAM_ID, 'in', array_keys($memberships))); break; } // $params = array( // new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_CLOSED,'=',CerberusTicketStatus::OPEN), // new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_NEXT_WORKER_ID,'=',0), // new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_SPAM_SCORE,'<=','0.9000'), // new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_TEAM_ID,'in',array_keys($memberships)) // ); // $title = "Overview"; break; } $mobileView = C4_AbstractViewLoader::getView('', "VIEW_MOBILE"); //print_r($mobileView); if ($mobileView == NULL) { $mobileView = new C4_MobileTicketView(); //C4_TicketView(); } $mobileView->id = "VIEW_MOBILE"; $mobileView->name = $title; $mobileView->view_columns = array(SearchFields_Ticket::TICKET_LAST_ACTION_CODE); $mobileView->params = $params; $mobileView->renderLimit = 10; //$overViewDefaults->renderLimit; $mobileView->renderPage = $page; $mobileView->renderSortBy = SearchFields_Ticket::TICKET_UPDATED_DATE; $mobileView->renderSortAsc = 0; C4_AbstractViewLoader::setView($mobileView->id, $mobileView); $views[] = $mobileView; $tpl->assign('views', $views); if ($filter == null) { $filter = 'all'; } $tpl->assign('filter', $filter); $fid = $response->path[4]; if ($fid == null) { $fid = '0'; } $tpl->assign('fid', $fid); $bucket_id = $response->path[5]; if ($bucket_id == null) { $buket_id = 0; } $tpl->assign('bid', $bucket_id); $tpl->assign('title', $title); $tpl->assign('tickets', $tickets[0]); $tpl->assign('next_page', $page + 1); $tpl->assign('prev_page', $page - 1); //print_r($tickets);exit(); $tpl->display('file:' . dirname(__FILE__) . '/templates/tickets.tpl'); }
function renderCriteriaParam($param) { $field = $param->field; $values = !is_array($param->value) ? array($param->value) : $param->value; switch ($field) { case SearchFields_CrmOpportunity::WORKER_ID: $workers = DAO_Worker::getAll(); $strings = array(); foreach ($values as $val) { if (empty($val)) { $strings[] = "Nobody"; } elseif (!isset($workers[$val])) { continue; } else { $strings[] = $workers[$val]->getName(); } } echo implode(", ", $strings); break; default: parent::renderCriteriaParam($param); break; } }
function render() { $tpl = DevblocksPlatform::getTemplateService(); $tpl->cache_lifetime = "0"; $tpl->assign('path', $this->tpl_path); $tpl->assign('start', '-30 days'); $tpl->assign('end', 'now'); $db = DevblocksPlatform::getDatabaseService(); $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); // Teams $teams = DAO_Group::getAll(); $tpl->assign('teams', $teams); // Categories $team_categories = DAO_Bucket::getTeams(); // [TODO] Cache these $tpl->assign('team_categories', $team_categories); // Security if (null == ($active_worker = CerberusApplication::getActiveWorker())) { die($translate->_('common.access_denied')); } $tpl->assign('active_worker', $active_worker); $filename = "report-plus1-" . $active_worker->id . ".csv"; $href_filename = 'storage/answernet/' . $filename; $tpl->assign('href_filename', $href_filename); $tpl->display('file:' . $this->tpl_path . '/report_plus1_time.tpl'); }
function showComposePeekAction() { @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', '')); @($to = DevblocksPlatform::importGPC($_REQUEST['to'], 'string', '')); $tpl = DevblocksPlatform::getTemplateService(); $tpl_path = $this->_TPL_PATH; $tpl->assign('path', $tpl_path); $tpl->assign('view_id', $view_id); $tpl->assign('to', $to); $teams = DAO_Group::getAll(); $tpl->assign_by_ref('teams', $teams); $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); $tpl->display('file:' . $this->_TPL_PATH . 'tickets/compose/peek.tpl'); }
function showContactHistoryAction() { $visit = CerberusApplication::getVisit(); /* @var $visit CerberusVisit */ $translate = DevblocksPlatform::getTranslationService(); @($ticket_id = DevblocksPlatform::importGPC($_REQUEST['ticket_id'], 'integer')); $tpl = DevblocksPlatform::getTemplateService(); $tpl->assign('path', $this->_TPL_PATH); // Ticket $ticket = DAO_Ticket::getTicket($ticket_id); $tpl->assign('ticket', $ticket); $requesters = $ticket->getRequesters(); // Addy $contact = DAO_Address::get($ticket->first_wrote_address_id); $tpl->assign('contact', $contact); // Scope $scope = $visit->get('display.history.scope', ''); // [TODO] Sanitize scope preference // Defaults $defaults = new C4_AbstractViewModel(); $defaults->class_name = 'C4_TicketView'; $defaults->id = 'contact_history'; $defaults->name = $translate->_('addy_book.history.view.title'); $defaults->view_columns = array(SearchFields_Ticket::TICKET_LAST_ACTION_CODE, SearchFields_Ticket::TICKET_CREATED_DATE, SearchFields_Ticket::TICKET_TEAM_ID, SearchFields_Ticket::TICKET_CATEGORY_ID); $defaults->params = array(); $defaults->renderLimit = 10; $defaults->renderSortBy = SearchFields_Ticket::TICKET_CREATED_DATE; $defaults->renderSortAsc = false; // View $view = C4_AbstractViewLoader::getView('contact_history', $defaults); // Sanitize scope options if ('org' == $scope) { if (empty($contact->contact_org_id)) { $scope = ''; } if (null == ($contact_org = DAO_ContactOrg::get($contact->contact_org_id))) { $scope = ''; } } if ('domain' == $scope) { $email_parts = explode('@', $contact->email); if (!is_array($email_parts) || 2 != count($email_parts)) { $scope = ''; } } switch ($scope) { case 'org': $view->params = array(SearchFields_Ticket::TICKET_FIRST_CONTACT_ORG_ID => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_FIRST_CONTACT_ORG_ID, '=', $contact->contact_org_id), SearchFields_Ticket::TICKET_DELETED => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_DELETED, '=', 0)); $view->name = ucwords($translate->_('contact_org.name')) . ": " . $contact_org->name; break; case 'domain': $view->params = array(SearchFields_Ticket::REQUESTER_ADDRESS => new DevblocksSearchCriteria(SearchFields_Ticket::REQUESTER_ADDRESS, 'like', '*@' . $email_parts[1]), SearchFields_Ticket::TICKET_DELETED => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_DELETED, '=', 0)); $view->name = ucwords($translate->_('common.email')) . ": *@" . $email_parts[1]; break; default: case 'email': $scope = 'email'; $view->params = array(SearchFields_Ticket::REQUESTER_ID => new DevblocksSearchCriteria(SearchFields_Ticket::REQUESTER_ID, 'in', array_keys($requesters)), SearchFields_Ticket::TICKET_DELETED => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_DELETED, '=', 0)); $view->name = ucwords($translate->_('common.email')) . ": " . $contact->email; break; } $tpl->assign('scope', $scope); $view->renderPage = 0; $tpl->assign('view', $view); C4_AbstractViewLoader::setView($view->id, $view); $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); $teams = DAO_Group::getAll(); $tpl->assign('teams', $teams); $buckets = DAO_Bucket::getAll(); $tpl->assign('buckets', $buckets); $team_categories = DAO_Bucket::getTeams(); $tpl->assign('team_categories', $team_categories); $tpl->display('file:' . $this->_TPL_PATH . 'display/modules/history/index.tpl'); }
function render() { $this->_sanitize(); $tpl = DevblocksPlatform::getTemplateService(); $tpl->assign('id', $this->id); $tpl->assign('view', $this); $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); $tpl->cache_lifetime = "0"; $tpl->assign('view_fields', $this->getColumns()); $tpl->display('file:' . DEVBLOCKS_PLUGIN_PATH . 'cerberusweb.core/templates/home/tabs/my_events/view.tpl'); }
function render() { $db = DevblocksPlatform::getDatabaseService(); $tpl = DevblocksPlatform::getTemplateService(); $tpl->assign('path', $this->tpl_path); $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); // Year shortcuts $years = array(); $sql = "SELECT date_format(from_unixtime(created_date),'%Y') as year FROM ticket WHERE created_date > 0 GROUP BY year having year <= date_format(now(),'%Y') ORDER BY year desc limit 0,10"; $rs = $db->query($sql); if (is_a($rs, 'ADORecordSet')) { while (!$rs->EOF) { $years[] = intval($rs->fields['year']); $rs->MoveNext(); } } $tpl->assign('years', $years); // Dates @($age = DevblocksPlatform::importGPC($_REQUEST['age'], 'string', '30d')); @($start = DevblocksPlatform::importGPC($_REQUEST['start'], 'string', '')); @($end = DevblocksPlatform::importGPC($_REQUEST['end'], 'string', '')); @($worker_id = DevblocksPlatform::importGPC($_REQUEST['worker_id'], 'integer', 0)); $tpl->assign('worker_id', $worker_id); // use date range if specified, else use duration prior to now $start_time = 0; $end_time = 0; if (!$worker_id) { $worker = CerberusApplication::getActiveWorker(); $worker_id = $worker->id; } if (empty($start) && empty($end)) { $start = "-30 days"; $end = "now"; $start_time = strtotime($start); $end_time = strtotime($end); } else { $start_time = strtotime($start); $end_time = strtotime($end); } $tpl->assign('start', $start); $tpl->assign('end', $end); // Table $sql = sprintf("SELECT t.id, t.mask, t.subject, a.email as email, " . "date_format(from_unixtime(m.created_date),'%%Y-%%m-%%d') as day " . "FROM ticket t " . "INNER JOIN message m ON t.id = m.ticket_id " . "INNER JOIN worker w ON m.worker_id = w.id " . "INNER JOIN address a on t.first_wrote_address_id = a.id " . "WHERE m.created_date > %d AND m.created_date <= %d " . "AND m.is_outgoing = 1 " . "AND t.is_deleted = 0 " . "AND w.id = %d " . "GROUP BY day, t.id " . "order by m.created_date", $start_time, $end_time, $worker_id); $rs = $db->Execute($sql); $tickets_replied = array(); if (is_a($rs, 'ADORecordSet')) { while (!$rs->EOF) { $created_day = $rs->fields['day']; unset($reply_date_ticket); $reply_date_ticket->mask = $rs->fields['mask']; $reply_date_ticket->email = $rs->fields['email']; $reply_date_ticket->subject = $rs->fields['subject']; $reply_date_ticket->id = intval($rs->fields['id']); $tickets_replied[$created_day][] = $reply_date_ticket; $rs->MoveNext(); } } $tpl->assign('tickets_replied', $tickets_replied); // Chart $sql = sprintf("SELECT count(*) AS hits, m.worker_id " . "FROM message m " . "INNER JOIN ticket t ON (t.id=m.ticket_id) " . "INNER JOIN worker w ON w.id=m.worker_id " . "WHERE m.created_date > %d AND m.created_date <= %d " . "AND m.is_outgoing = 1 " . "AND t.is_deleted = 0 " . "GROUP BY m.worker_id ORDER BY w.last_name DESC ", $start_time, $end_time); $rs_workers = $db->Execute($sql); /* @var $rs_workers ADORecordSet */ $worker_counts = array(); $data = array(); $iter = 0; while (!$rs_workers->EOF) { $hits = intval($rs_workers->fields['hits']); $worker_id = intval($rs_workers->fields['worker_id']); if (!isset($workers[$worker_id])) { continue; } $data[$iter++] = array('value' => $workers[$worker_id]->getName(), 'hits' => $hits); $rs_workers->MoveNext(); } $tpl->assign('data', $data); // Template $tpl->display('file:' . $this->tpl_path . '/reports/worker/worker_history/index.tpl'); }
function saveWorkerAction() { $translate = DevblocksPlatform::getTranslationService(); $active_worker = CerberusApplication::getActiveWorker(); if (!$active_worker || !$active_worker->is_superuser) { echo $translate->_('common.access_denied'); return; } if (DEMO_MODE) { DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('config', 'workers'))); return; } @($id = DevblocksPlatform::importGPC($_POST['id'], 'integer')); @($first_name = DevblocksPlatform::importGPC($_POST['first_name'], 'string')); @($last_name = DevblocksPlatform::importGPC($_POST['last_name'], 'string')); @($title = DevblocksPlatform::importGPC($_POST['title'], 'string')); @($primary_email = DevblocksPlatform::importGPC($_POST['primary_email'], 'string')); @($email = DevblocksPlatform::importGPC($_POST['email'], 'string')); @($password = DevblocksPlatform::importGPC($_POST['password'], 'string')); @($is_superuser = DevblocksPlatform::importGPC($_POST['is_superuser'], 'integer')); @($group_ids = DevblocksPlatform::importGPC($_POST['group_ids'], 'array')); @($group_roles = DevblocksPlatform::importGPC($_POST['group_roles'], 'array')); @($disabled = DevblocksPlatform::importGPC($_POST['do_disable'], 'integer', 0)); @($delete = DevblocksPlatform::importGPC($_POST['do_delete'], 'integer', 0)); // [TODO] The superuser set bit here needs to be protected by ACL if (empty($first_name)) { $first_name = "Anonymous"; } if (!empty($id) && !empty($delete)) { // Can't delete or disable self if ($active_worker->id == $id) { return; } DAO_Worker::deleteAgent($id); } else { if (empty($id) && null == DAO_Worker::lookupAgentEmail($email)) { $workers = DAO_Worker::getAll(); $license = CerberusLicense::getInstance(); if (!empty($license) && !empty($license['serial']) || count($workers) < 3) { // Creating new worker. If password is empty, email it to them if (empty($password)) { $settings = CerberusSettings::getInstance(); $replyFrom = $settings->get(CerberusSettings::DEFAULT_REPLY_FROM); $replyPersonal = $settings->get(CerberusSettings::DEFAULT_REPLY_PERSONAL, ''); $url = DevblocksPlatform::getUrlService(); $password = CerberusApplication::generatePassword(8); try { $mail_service = DevblocksPlatform::getMailService(); $mailer = $mail_service->getMailer(CerberusMail::getMailerDefaults()); $mail = $mail_service->createMessage(); $sendTo = new Swift_Address($email, $first_name . $last_name); $sendFrom = new Swift_Address($replyFrom, $replyPersonal); $mail->setSubject('Your new helpdesk login information!'); $mail->generateId(); $mail->headers->set('X-Mailer', 'Cerberus Helpdesk (Build ' . APP_BUILD . ')'); $body = sprintf("Your new helpdesk login information is below:\r\n" . "\r\n" . "URL: %s\r\n" . "Login: %s\r\n" . "Password: %s\r\n" . "\r\n" . "You should change your password from Preferences after logging in for the first time.\r\n" . "\r\n", $url->write('', true), $email, $password); $mail->attach(new Swift_Message_Part($body, 'text/plain', 'base64', LANG_CHARSET_CODE)); if (!$mailer->send($mail, $sendTo, $sendFrom)) { throw new Exception('Password notification email failed to send.'); } } catch (Exception $e) { // [TODO] need to report to the admin when the password email doesn't send. The try->catch // will keep it from killing php, but the password will be empty and the user will never get an email. } } $id = DAO_Worker::create($email, $password, '', '', ''); } else { //not licensed and worker limit reached DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('config', 'workers'))); return; } } $fields = array(DAO_Worker::FIRST_NAME => $first_name, DAO_Worker::LAST_NAME => $last_name, DAO_Worker::TITLE => $title, DAO_Worker::EMAIL => $email, DAO_Worker::IS_SUPERUSER => $is_superuser, DAO_Worker::IS_DISABLED => $disabled); // if we're resetting the password if (!empty($password)) { $fields[DAO_Worker::PASSWORD] = md5($password); } // Update worker DAO_Worker::updateAgent($id, $fields); // Update group memberships if (is_array($group_ids) && is_array($group_roles)) { foreach ($group_ids as $idx => $group_id) { if (empty($group_roles[$idx])) { DAO_Group::unsetTeamMember($group_id, $id); } else { DAO_Group::setTeamMember($group_id, $id, 2 == $group_roles[$idx]); } } } // Add the worker e-mail to the addresses table if (!empty($email)) { DAO_Address::lookupAddress($email, true); } // Addresses if (null == DAO_AddressToWorker::getByAddress($email)) { DAO_AddressToWorker::assign($email, $id); DAO_AddressToWorker::update($email, array(DAO_AddressToWorker::IS_CONFIRMED => 1)); } } DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('config', 'workers'))); }
function AnswernetMetlifeReportGroupReport1Action() { $db = DevblocksPlatform::getDatabaseService(); $translate = DevblocksPlatform::getTranslationService(); $url = DevblocksPlatform::getUrlService(); $workers = DAO_Worker::getAll(); $radius = 12; // Security if (null == ($active_worker = CerberusApplication::getActiveWorker())) { die($translate->_('common.access_denied')); } // import dates from form @($start_time = DevblocksPlatform::importGPC($_REQUEST['start'], 'string', '')); @($group = DevblocksPlatform::importGPC($_REQUEST['group'], 'string', '')); if (empty($start_time) || !is_numeric($start_time)) { return; } if (empty($group)) { return; } $end_time = $start_time + 604800; print $translate->_('answernet.er.metlife.week.number'); print date("W", $start_time); print '<br>'; print $translate->_('answernet.er.metlife.generate.report'); switch ($group) { case "All": $filename = "report-metlife-week-" . date("W", $start_time) . ".xls"; $group_sql = "and (t.team_id = 756 or t.team_id = 782) "; print " Group: ALL "; $group_text = "All"; break; case "fp": $filename = "report-metlife-first-person-week-" . date("W", $start_time) . ".xls"; $group_sql = "and t.team_id = 756 "; print " Group: First Person "; $group_text = "First Person"; break; case "iDesign": $filename = "report-metlife-iDesign-week-" . date("W", $start_time) . ".xls"; $group_sql = "and team_id = 782 "; print " Group: iDesign "; $group_text = "iDesign"; break; default: print "Error: Group not set: " . $group; return; } print '<br>'; print $translate->_('answernet.er.metlife.generating'); $full_filename = getcwd() . '/storage/answernet/' . $filename; $href_filename = $url->write('storage/answernet/' . $filename, true); $week_range_text = "Week # " . date("W - n/j/y", $start_time) . " - " . date("n/j/y", $start_time + 518400); // Create new Excel Spreadsheet. $workbook = new Spreadsheet_Excel_Writer($full_filename); // Create metrics Tab and set Column Width and Row Hight. $worksheet_metrics =& $workbook->addWorksheet('Weekly Metrics'); $worksheet_metrics->setColumn(0, 0, $radius * 1.71); $worksheet_metrics->setColumn(0, 0, $radius * 0.5); $worksheet_metrics->setRow(0, 56); // Create ACD Calls(Inbound) Tab and set Column Width and Row Hight. $worksheet_acd_in =& $workbook->addWorksheet('ACD calls(Inbound)'); $worksheet_acd_in->setColumn(0, 1, $radius * 0.78); $worksheet_acd_in->setColumn(2, 2, $radius * 1.05); $worksheet_acd_in->setColumn(3, 3, $radius * 1.23); $worksheet_acd_in->setColumn(4, 4, $radius * 1.11); $worksheet_acd_in->setColumn(5, 5, $radius * 1.15); $worksheet_acd_in->setColumn(6, 6, $radius * 2.0); $worksheet_acd_in->setColumn(7, 7, $radius * 0.78); $worksheet_acd_in->setColumn(8, 8, $radius * 2.0); $worksheet_acd_in->setColumn(9, 9, $radius * 0.78); $worksheet_acd_in->setRow(0, 28); $worksheet_acd_in->setRow(2, 32); // Create ACD Calls(Outbound) Tab and set Column Width and Row Hight. $worksheet_acd_out =& $workbook->addWorksheet('ACD calls(Outbound)'); // Create Phone Tickets Tab and set Column Width and Row Hight. $worksheet_phone_tickets =& $workbook->addWorksheet('Phone Tickets'); // Create Email Tickets Tab and set Column Width and Row Hight. $worksheet_email_tickets =& $workbook->addWorksheet('Email Tickets'); // Create Email Tickets Tab and set Column Width and Row Hight. $worksheet_call_count =& $workbook->addWorksheet('Call Count'); // Create Inbound Count Tab and set Column Width and Row Hight. $worksheet_in_count =& $workbook->addWorksheet('Inbound Email Count'); $worksheet_in_count->setColumn(0, 0, $radius * 2.87); $worksheet_in_count->setColumn(1, 1, $radius * 0.66); $worksheet_in_count->setColumn(2, 2, $radius * 2.87); $worksheet_in_count->setColumn(3, 3, $radius * 0.62); $worksheet_in_count->setColumn(4, 4, $radius * 0.66); $worksheet_in_count->setColumn(5, 5, $radius * 2.87); $worksheet_in_count->setColumn(6, 6, $radius * 0.66); $worksheet_in_count->setRow(0, 32); $worksheet_in_count->freezePanes(array(2, 0, 2, 0)); // Create Outbound Count Tab and set Column Width and Row Hight. $worksheet_out_count =& $workbook->addWorksheet('Outbound Email Count'); $worksheet_out_count->setColumn(0, 0, $radius * 2.87); $worksheet_out_count->setColumn(1, 1, $radius * 0.66); $worksheet_out_count->setColumn(2, 2, $radius * 2.87); $worksheet_out_count->setColumn(3, 3, $radius * 0.62); $worksheet_out_count->setColumn(4, 4, $radius * 0.66); $worksheet_out_count->setColumn(5, 5, $radius * 2.87); $worksheet_out_count->setColumn(6, 6, $radius * 0.66); $worksheet_out_count->setRow(0, 32); $worksheet_out_count->freezePanes(array(2, 0, 2, 0)); // Create Inbound Tab and set Column Width and Row Hight. $worksheet_inbound =& $workbook->addWorksheet('Inbound Emails'); $worksheet_inbound->setColumn(0, 0, $radius * 2.78); $worksheet_inbound->setColumn(1, 1, $radius * 1.55); $worksheet_inbound->setColumn(2, 2, $radius * 0.72); $worksheet_inbound->setColumn(3, 4, $radius * 1.51); $worksheet_inbound->setColumn(5, 5, $radius * 2.76); $worksheet_inbound->setColumn(6, 9, $radius * 2.22); $worksheet_inbound->setColumn(10, 10, $radius * 0.83); $worksheet_inbound->setRow(0, 36); $worksheet_inbound->freezePanes(array(2, 0, 2, 0)); // Create Outbound Tab and set Column Width and Row Hight. $worksheet_outbound =& $workbook->addWorksheet('Outbound Emails'); $worksheet_outbound->setColumn(0, 0, $radius * 2.78); $worksheet_outbound->setColumn(1, 1, $radius * 1.55); $worksheet_outbound->setColumn(2, 2, $radius * 0.72); $worksheet_outbound->setColumn(3, 4, $radius * 1.51); $worksheet_outbound->setColumn(5, 5, $radius * 2.76); $worksheet_outbound->setColumn(6, 9, $radius * 2.22); $worksheet_outbound->setColumn(10, 10, $radius * 1.2); $worksheet_outbound->setColumn(11, 11, $radius * 0.83); $worksheet_outbound->setRow(0, 36); $worksheet_outbound->freezePanes(array(2, 0, 2, 0)); // Formats used thoughout the workbook. $format_general =& $workbook->addFormat(); $format_general->setBorder(1); $format_general->setHAlign('center'); $format_general->setTextWrap(); $format_general_nowrap =& $workbook->addFormat(); $format_general_nowrap->setBorder(1); // Setup templating for the formating of certain cells in the Metics Group. $format_metrics_title =& $workbook->addFormat(); $format_metrics_title->setBorder(1); $format_metrics_title->setBold(); $format_metrics_title->setColor(9); $format_metrics_title->setFgColor(32); $format_metrics_title->setHAlign('center'); $format_metrics_title->setVAlign('vjustify'); $format_metrics_title->setVAlign('vcenter'); $format_metrics_title->setTextWrap(); $format_metrics_title2 =& $workbook->addFormat(); $format_metrics_title2->setBorder(1); $format_metrics_title2->setBold(); $format_metrics_title2->setColor(8); $format_metrics_title2->setFgColor(43); $format_metrics_title2->setHAlign('center'); $format_metrics_title2->setVAlign('vjustify'); $format_metrics_title2->setVAlign('vcenter'); $format_metrics_title2->setTextWrap(); $format_metrics_weekly =& $workbook->addFormat(); $format_metrics_weekly->setBorder(1); $format_metrics_weekly->setBold(); $format_metrics_weekly->setColor(8); $format_metrics_weekly->setFgColor(29); $format_metrics_weekly->setHAlign('center'); $format_metrics_weekly->setVAlign('vjustify'); $format_metrics_weekly->setVAlign('vcenter'); $format_metrics_weekly->setTextWrap(); $format_metrics_daily =& $workbook->addFormat(); $format_metrics_daily->setBorder(1); $format_metrics_daily->setBold(); $format_metrics_daily->setColor(8); $format_metrics_daily->setFgColor(29); $format_metrics_daily->setHAlign('center'); $format_metrics_daily->setVAlign('vjustify'); $format_metrics_daily->setVAlign('vcenter'); $format_metrics_daily->setTextWrap(); // Added headers since they never change in the Metics Group. $worksheet_metrics->write(0, 0, 'Week Range', $format_metrics_title); $worksheet_metrics->write(0, 1, 'Inbnd Field Emails', $format_metrics_title); $worksheet_metrics->write(0, 2, 'Inbnd Admin Emails', $format_metrics_title); $worksheet_metrics->write(0, 3, 'Weekly Total Inbnd', $format_metrics_title); $worksheet_metrics->write(0, 4, 'Outbnd Field Emails', $format_metrics_title); $worksheet_metrics->write(0, 5, 'Outbnd Admin Emails', $format_metrics_title); $worksheet_metrics->write(0, 6, 'Weekly Total Outbnd', $format_metrics_title); $worksheet_metrics->write(0, 7, 'Avg time to respond (hrs)', $format_metrics_title); $worksheet_metrics->write(0, 8, ' ', $format_metrics_title2); $worksheet_metrics->write(0, 9, ' ', $format_metrics_title2); $worksheet_metrics->write(0, 10, ' ', $format_metrics_title2); $worksheet_metrics->write(0, 11, ' ', $format_metrics_title2); $worksheet_metrics->write(0, 12, ' ', $format_metrics_title2); $worksheet_metrics->write(0, 13, ' ', $format_metrics_title2); $worksheet_metrics->write(0, 14, ' ', $format_metrics_title2); $week_range_text_metrics = date("n/j/y", $start_time) . " - " . date("n/j/y", $start_time + 518400); $worksheet_metrics->write(1, 0, $week_range_text_metrics, $format_general); $worksheet_metrics->write(5, 0, 'Grand Total', $format_general); $worksheet_metrics->write(6, 0, 'Weekly Averages', $format_metrics_weekly); $worksheet_metrics->write(7, 0, 'Daily Averages', $format_metrics_daily); $worksheet_metrics->write(8, 0, '%', $format_general); // Setup templating for the formating of certain cells in the Inbound Count Group. $format_acd_in_title =& $workbook->addFormat(); $format_acd_in_title->setSize(18); $format_acd_in_title->setColor(8); $format_acd_in_title->setFgColor(34); $format_acd_in_title->setBorder(1); $format_acd_in_title->setBold(); $format_acd_in_title->setHAlign('center'); $format_acd_in_title->setVAlign('vjustify'); $format_acd_in_title->setVAlign('top'); $format_acd_in_title->setTextWrap(); $format_acd_in_title->setAlign('merge'); $format_acd_in_title2 =& $workbook->addFormat(); $format_acd_in_title2->setColor(8); $format_acd_in_title2->setFgColor(43); $format_acd_in_title2->setBorder(1); $format_acd_in_title2->setBold(); $format_acd_in_title2->setHAlign('center'); $format_acd_in_title2->setVAlign('vjustify'); $format_acd_in_title2->setVAlign('top'); $format_acd_in_title2->setTextWrap(); $format_acd_in_title2->setAlign('merge'); $format_acd_in_title3 =& $workbook->addFormat(); $format_acd_in_title3->setColor(8); $format_acd_in_title3->setFgColor(47); $format_acd_in_title2->setBorder(1); $format_acd_in_title3->setBold(); $format_acd_in_title3->setHAlign('center'); $format_acd_in_title3->setVAlign('vjustify'); $format_acd_in_title3->setVAlign('top'); $format_acd_in_title3->setTextWrap(); $format_acd_in_total =& $workbook->addFormat(); $format_acd_in_title->setSize(15); $format_acd_in_total->setBorder(1); $format_acd_in_total->setColor(8); $format_acd_in_total->setFgColor(6); $format_acd_in_total->setBold(); $format_acd_in_total->setHAlign('left'); $format_acd_in_total->setVAlign('vjustify'); $format_acd_in_total->setVAlign('top'); // Added headers since they never change in the acd in Group. $worksheet_acd_in->write(0, 0, 'MetLife / ' . $group_text, $format_acd_in_title); $worksheet_acd_in->write(0, 1, '', $format_acd_in_title); $worksheet_acd_in->write(0, 2, '', $format_acd_in_title); $worksheet_acd_in->write(0, 3, '', $format_acd_in_title); $worksheet_acd_in->write(0, 4, '', $format_acd_in_title); $worksheet_acd_in->write(0, 5, '', $format_acd_in_title); $worksheet_acd_in->write(0, 6, 'WEEKLY TOTALS', $format_acd_in_title); $worksheet_acd_in->write(0, 7, '', $format_acd_in_title); $worksheet_acd_in->write(0, 8, '', $format_acd_in_title); $worksheet_acd_in->write(0, 9, '', $format_acd_in_title); $worksheet_acd_in->write(1, 0, $week_range_text, $format_acd_in_title2); $worksheet_acd_in->write(1, 1, '', $format_acd_in_title2); $worksheet_acd_in->write(1, 2, '', $format_acd_in_title2); $worksheet_acd_in->write(1, 3, '', $format_acd_in_title2); $worksheet_acd_in->write(1, 4, '', $format_acd_in_title2); $worksheet_acd_in->write(1, 5, '', $format_acd_in_title2); $worksheet_acd_in->write(2, 0, 'Date', $format_acd_in_title3); $worksheet_acd_in->write(2, 1, 'Call Times', $format_acd_in_title3); $worksheet_acd_in->write(2, 2, 'Agent Talk', $format_acd_in_title3); $worksheet_acd_in->write(2, 3, '(MIN.SEC) Hold time', $format_acd_in_title3); $worksheet_acd_in->write(2, 4, '(MIN.SEC) Patch Time', $format_acd_in_title3); $worksheet_acd_in->write(2, 5, 'ANI', $format_acd_in_title3); $worksheet_acd_in->write(1, 6, 'Weekly Total Calls', $format_acd_in_total); $worksheet_acd_in->writeFormula(1, 7, "=count(A1:A1000)", $format_acd_in_title2); $worksheet_acd_in->write(1, 8, 'Weekly Average Patch Time', $format_acd_in_total); $worksheet_acd_in->writeFormula(1, 9, "=SUM(B2,E2)", $format_acd_in_title2); $worksheet_acd_in->write(2, 6, 'Weekly Agent Talk Time', $format_acd_in_total); $worksheet_acd_in->writeFormula(2, 7, "=SUM(B2,E2)", $format_acd_in_title2); $worksheet_acd_in->write(2, 8, 'Weekly Average Hold Time', $format_acd_in_total); $worksheet_acd_in->writeFormula(2, 9, "=SUM(B2,E2)", $format_acd_in_title2); // Setup templating for the formating of certain cells in the Inbound Count Group. $format_in_count_title =& $workbook->addFormat(); $format_in_count_title->setSize(15); $format_in_count_title->setColor(8); $format_in_count_title->setBorder(1); $format_in_count_title->setFgColor(35); $format_in_count_title->setBold(); $format_in_count_title->setHAlign('center'); $format_in_count_title->setVAlign('vjustify'); $format_in_count_title->setVAlign('top'); $format_in_count_title->setTextWrap(); $format_in_count_title2 =& $workbook->addFormat(); $format_in_count_title2->setColor(8); $format_in_count_title2->setFgColor(47); $format_in_count_title2->setBold(); $format_in_count_title2->setHAlign('center'); $format_in_count_title2->setVAlign('vjustify'); $format_in_count_title2->setVAlign('top'); $format_in_count_title2->setTextWrap(); $format_in_count_total =& $workbook->addFormat(); $format_in_count_total->setBorder(1); $format_in_count_total->setColor(8); $format_in_count_total->setFgColor(6); $format_in_count_total->setBold(); $format_in_count_total->setSize(18); $format_in_count_total->setHAlign('left'); $format_in_count_total->setVAlign('vjustify'); $format_in_count_total->setVAlign('top'); $format_in_count_grand =& $workbook->addFormat(); $format_in_count_grand->setBorder(1); $format_in_count_grand->setColor(8); $format_in_count_grand->setFgColor(43); $format_in_count_grand->setBold(); $format_in_count_grand->setSize(18); $format_in_count_grand->setHAlign('left'); $format_in_count_grand->setVAlign('vjustify'); $format_in_count_grand->setVAlign('top'); // Added headers since they never change in the Inbound Count Group. $worksheet_in_count->write(0, 0, 'Email Count Admin', $format_in_count_title); $worksheet_in_count->write(0, 1, 'Totals', $format_in_count_title); $worksheet_in_count->write(0, 2, 'Email Count Field', $format_in_count_title); $worksheet_in_count->write(0, 3, 'ID', $format_in_count_title); $worksheet_in_count->write(0, 4, 'Totals', $format_in_count_title); // Setup templating for the formating of certain cells in the Outbound Count Group. $format_out_count_title =& $workbook->addFormat(); $format_out_count_title->setSize(15); $format_out_count_title->setColor(8); $format_out_count_title->setBorder(1); $format_out_count_title->setFgColor(14); $format_out_count_title->setBold(); $format_out_count_title->setHAlign('center'); $format_out_count_title->setVAlign('vjustify'); $format_out_count_title->setVAlign('top'); $format_out_count_title->setTextWrap(); $format_out_count_title2 =& $workbook->addFormat(); $format_out_count_title2->setColor(8); $format_out_count_title2->setFgColor(47); $format_out_count_title2->setBold(); $format_out_count_title2->setHAlign('center'); $format_out_count_title2->setVAlign('vjustify'); $format_out_count_title2->setVAlign('top'); $format_out_count_title2->setTextWrap(); $format_out_count_total =& $workbook->addFormat(); $format_out_count_total->setBorder(1); $format_out_count_total->setColor(8); $format_out_count_total->setFgColor(42); $format_out_count_total->setBold(); $format_out_count_total->setSize(18); $format_out_count_total->setHAlign('left'); $format_out_count_total->setVAlign('vjustify'); $format_out_count_total->setVAlign('top'); $format_out_count_grand =& $workbook->addFormat(); $format_out_count_grand->setBorder(1); $format_out_count_grand->setColor(8); $format_out_count_grand->setFgColor(43); $format_out_count_grand->setBold(); $format_out_count_grand->setSize(18); $format_out_count_grand->setHAlign('left'); $format_out_count_grand->setVAlign('vjustify'); $format_out_count_grand->setVAlign('top'); // Added headers since they never change in the Outbound Count Group. $worksheet_out_count->write(0, 0, 'Email Count Admin', $format_out_count_title); $worksheet_out_count->write(0, 1, 'Totals', $format_out_count_title); $worksheet_out_count->write(0, 2, 'Email Count Field', $format_out_count_title); $worksheet_out_count->write(0, 3, 'ID', $format_out_count_title); $worksheet_out_count->write(0, 4, 'Totals', $format_out_count_title); // Setup templating for the formating of certain cells in the Inbound Group. $format_inbound_title =& $workbook->addFormat(); $format_inbound_title->setSize(15); $format_inbound_title->setColor(8); $format_inbound_title->setBorder(1); $format_inbound_title->setFgColor(35); $format_inbound_title->setBold(); $format_inbound_title->setHAlign('center'); $format_inbound_title->setVAlign('vjustify'); $format_inbound_title->setVAlign('top'); $format_inbound_title->setTextWrap(); $format_inbound_title2 =& $workbook->addFormat(); $format_inbound_title2->setColor(8); $format_inbound_title2->setFgColor(47); $format_inbound_title2->setBold(); $format_inbound_title2->setHAlign('center'); $format_inbound_title2->setVAlign('vjustify'); $format_inbound_title2->setVAlign('top'); $format_inbound_title2->setTextWrap(); // Setup templating for the formating of certain cells in the Inbound Group. $format_inbound_title3 =& $workbook->addFormat(); $format_inbound_title3->setSize(15); $format_inbound_title3->setColor(8); $format_inbound_title3->setBorder(1); $format_inbound_title3->setFgColor(34); $format_inbound_title3->setBold(); $format_inbound_title3->setHAlign('center'); $format_inbound_title3->setVAlign('vjustify'); $format_inbound_title3->setVAlign('top'); $format_inbound_title3->setTextWrap(); // Added headers since they never change in the Inbound Group. $worksheet_inbound->setInputEncoding('utf-8'); $worksheet_inbound->write(0, 0, 'Inbound Email From', $format_inbound_title); $worksheet_inbound->write(0, 1, 'User Name', $format_inbound_title); $worksheet_inbound->write(0, 2, 'ID', $format_inbound_title); $worksheet_inbound->write(0, 3, 'Date Email Received', $format_inbound_title); $worksheet_inbound->write(0, 4, 'Ticket Mask', $format_inbound_title); $worksheet_inbound->write(0, 5, 'Subject Line', $format_inbound_title); $worksheet_inbound->write(0, 6, 'Email Contents', $format_inbound_title); $worksheet_inbound->write(0, 7, 'Category', $format_inbound_title3); $worksheet_inbound->write(0, 8, 'Code', $format_inbound_title3); $worksheet_inbound->write(0, 9, 'Description(or snapshot)', $format_inbound_title3); $worksheet_inbound->write(0, 10, 'Group', $format_inbound_title); $worksheet_inbound->write(1, 0, $week_range_text, $format_inbound_title2); $worksheet_inbound->write(1, 1, "", $format_inbound_title2); $worksheet_inbound->write(1, 2, "", $format_inbound_title2); $worksheet_inbound->write(1, 3, "", $format_inbound_title2); $worksheet_inbound->write(1, 4, "", $format_inbound_title2); $worksheet_inbound->write(1, 5, "", $format_inbound_title2); $worksheet_inbound->write(1, 6, "", $format_inbound_title2); $worksheet_inbound->write(1, 7, "", $format_inbound_title2); $worksheet_inbound->write(1, 8, "", $format_inbound_title2); $worksheet_inbound->write(1, 9, "", $format_inbound_title2); $worksheet_inbound->write(1, 10, "", $format_inbound_title2); // Setup templating for the formating of certain cells in the Outbound Group. $format_outbound_title =& $workbook->addFormat(); $format_outbound_title->setSize(15); $format_outbound_title->setColor(8); $format_outbound_title->setBorder(1); $format_outbound_title->setFgColor(11); $format_outbound_title->setBold(); $format_outbound_title->setHAlign('center'); $format_outbound_title->setVAlign('vjustify'); $format_outbound_title->setVAlign('top'); $format_outbound_title->setTextWrap(); $format_outbound_title2 =& $workbook->addFormat(); $format_outbound_title2->setColor(8); $format_outbound_title2->setFgColor(6); $format_outbound_title2->setBold(); $format_outbound_title2->setHAlign('center'); $format_outbound_title2->setVAlign('vjustify'); $format_outbound_title2->setVAlign('top'); $format_outbound_title2->setTextWrap(); $format_outbound_title3 =& $workbook->addFormat(); $format_outbound_title3->setSize(15); $format_outbound_title3->setColor(8); $format_outbound_title3->setBorder(1); $format_outbound_title3->setFgColor(34); $format_outbound_title3->setBold(); $format_outbound_title3->setHAlign('center'); $format_outbound_title3->setVAlign('vjustify'); $format_outbound_title3->setVAlign('top'); $format_outbound_title3->setTextWrap(); // Added headers since they never change in the Outbound Group. $worksheet_outbound->setInputEncoding('utf-8'); $worksheet_outbound->write(0, 0, 'Outbound Email To', $format_outbound_title); $worksheet_outbound->write(0, 1, 'User Name', $format_outbound_title); $worksheet_outbound->write(0, 2, 'ID', $format_outbound_title); $worksheet_outbound->write(0, 3, 'Date Email Sent', $format_outbound_title); $worksheet_outbound->write(0, 4, 'Ticket Mask', $format_outbound_title); $worksheet_outbound->write(0, 5, 'Subject Line', $format_outbound_title); $worksheet_outbound->write(0, 6, 'Email Contents', $format_outbound_title); $worksheet_outbound->write(0, 7, 'Category', $format_outbound_title3); $worksheet_outbound->write(0, 8, 'Code', $format_outbound_title3); $worksheet_outbound->write(0, 9, 'Description(or snapshot)', $format_outbound_title3); $worksheet_outbound->write(0, 10, 'Responder', $format_outbound_title); $worksheet_outbound->write(0, 11, 'Group', $format_outbound_title); $worksheet_outbound->write(1, 0, $week_range_text, $format_outbound_title2); $worksheet_outbound->write(1, 1, "", $format_outbound_title2); $worksheet_outbound->write(1, 2, "", $format_outbound_title2); $worksheet_outbound->write(1, 3, "", $format_outbound_title2); $worksheet_outbound->write(1, 4, "", $format_outbound_title2); $worksheet_outbound->write(1, 5, "", $format_outbound_title2); $worksheet_outbound->write(1, 6, "", $format_outbound_title2); $worksheet_outbound->write(1, 7, "", $format_outbound_title2); $worksheet_outbound->write(1, 8, "", $format_outbound_title2); $worksheet_outbound->write(1, 9, "", $format_outbound_title2); $worksheet_outbound->write(1, 10, "", $format_outbound_title2); $worksheet_outbound->write(1, 11, "", $format_outbound_title2); print $translate->_('answernet.er.metlife.metlife.done'); print '<br>'; print $translate->_('answernet.er.metlife.generating.email.detail'); $groups = DAO_Group::getAll(); $buckets = DAO_Bucket::getAll(); $sql = "SELECT t.mask, a.email, m.address_id, a.contact_org_id, "; $sql .= "t.created_date ticket_created_date, t.team_id, "; $sql .= "m.created_date message_created_date, mc.content, "; $sql .= "mh.header_value message_subject, m.worker_id, "; $sql .= "m.is_outgoing, mh_to.header_value outbound_email, t.team_id "; $sql .= "FROM message m "; $sql .= "INNER JOIN ticket t ON m.ticket_id = t.id "; $sql .= "INNER JOIN address a ON m.address_id = a.id "; $sql .= "INNER JOIN message_content mc on m.id = mc.message_id "; $sql .= "INNER JOIN message_header mh on m.id = mh.message_id "; $sql .= "and mh.header_name = 'subject' "; $sql .= "INNER JOIN message_header mh_to on m.id = mh_to.message_id "; $sql .= "and mh_to.header_name = 'to' "; $sql .= sprintf("WHERE m.created_date > %d AND m.created_date <= %d ", $start_time, $end_time); // Set abouve based on group selected. $sql .= $group_sql; $sql .= "ORDER BY m.id "; $rs = $db->Execute($sql); $row_inbound = 2; $row_outbound = 2; $in_count_admin = array(); $in_count_other = array(); $out_count_admin = array(); $out_count_other = array(); if (is_a($rs, 'ADORecordSet')) { while (!$rs->EOF) { $mask = $rs->fields['mask']; $ticket_created_date = intval($rs->fields['ticket_created_date']); $team_id = intval($rs->fields['team_id']); // Date Format Month/Day/Year Hour:Min:Sec AM/PM $message_created_date = date("n/j/y g:i:s A", intval($rs->fields['message_created_date'])); $message_content = $rs->fields['content']; $message_subject = $rs->fields['message_subject']; $worker_id = $rs->fields['worker_id']; $is_outgoing = $rs->fields['is_outgoing']; if ($team_id == 756) { $team_text = 'First Person'; } elseif ($team_id == 782) { $team_text = 'iDesign'; } else { $team_text = 'Error'; } if ($worker_id) { $worker_name = $workers[$worker_id]->first_name; } else { $worker_name = ""; } if ($is_outgoing) { $outbound_email = $rs->fields['outbound_email']; $to = array(); $to = CerberusParser::parseRfcAddress($outbound_email); @($toAddress = $to[0]->mailbox . '@' . $to[0]->host); $toAddressInst = CerberusApplication::hashLookupAddress($toAddress, true); $address_id = $toAddressInst->id; $contact_org_id = $toAddressInst->contact_org_id; $email = $toAddressInst->email; } else { $address_id = $rs->fields['address_id']; $contact_org_id = $rs->fields['contact_org_id']; $email = $rs->fields['email']; } if ($is_outgoing) { $worksheet_outbound->setRow($row_outbound, 12); $worksheet_outbound->write($row_outbound, 0, $email, $format_general); $worksheet_outbound->write($row_outbound, 1, "", $format_general); $worksheet_outbound->write($row_outbound, 2, "", $format_general); $worksheet_outbound->write($row_outbound, 3, $message_created_date, $format_general); $worksheet_outbound->write($row_outbound, 4, $mask, $format_general); $worksheet_outbound->write($row_outbound, 5, trim($message_subject), $format_general_nowrap); $worksheet_outbound->write($row_outbound, 6, trim(strip_tags($message_content))); $worksheet_outbound->writeString($row_outbound, 10, $worker_name, $format_general); $worksheet_outbound->write($row_outbound, 11, $team_text, $format_general); $row_outbound++; } else { $worksheet_inbound->setRow($row_inbound, 12); $worksheet_inbound->write($row_inbound, 0, $email, $format_general); $worksheet_inbound->write($row_inbound, 1, "", $format_general); $worksheet_inbound->write($row_inbound, 2, "", $format_general); $worksheet_inbound->write($row_inbound, 3, $message_created_date, $format_general); $worksheet_inbound->write($row_inbound, 4, $mask, $format_general); $worksheet_inbound->write($row_inbound, 5, trim($message_subject), $format_general_nowrap); $worksheet_inbound->writeString($row_inbound, 6, trim(strip_tags($message_content))); $worksheet_inbound->write($row_inbound, 10, $team_text, $format_general); $row_inbound++; } if ($is_outgoing) { if ($contact_org_id == 1) { if (!isset($out_count_admin[$address_id]['count'])) { $out_count_admin[$address_id]['email'] = $email; $out_count_admin[$address_id]['count'] = 1; } else { $out_count_admin[$address_id]['count']++; } } else { if (!isset($out_count_other[$address_id]['count'])) { $out_count_other[$address_id]['email'] = $email; $out_count_other[$address_id]['count'] = 1; } else { $out_count_other[$address_id]['count']++; } } } else { if ($contact_org_id == 1) { if (!isset($in_count_admin[$address_id]['count'])) { $in_count_admin[$address_id]['email'] = $email; $in_count_admin[$address_id]['count'] = 1; } else { $in_count_admin[$address_id]['count']++; } } else { if (!isset($in_count_other[$address_id]['count'])) { $in_count_other[$address_id]['email'] = $email; $in_count_other[$address_id]['count'] = 1; } else { $in_count_other[$address_id]['count']++; } } } $rs->MoveNext(); } } print $translate->_('answernet.er.metlife.metlife.done'); print '<br>'; print $translate->_('answernet.er.metlife.generating.email.count'); $worksheet_in_count->setRow(1, 24); $row_count = 2; foreach ($in_count_admin as $record) { $worksheet_in_count->write($row_count, 0, $record['email'], $format_general); $worksheet_in_count->write($row_count, 1, $record['count'], $format_general); $row_count++; } $worksheet_in_count->write(1, 0, 'Total Admin Email', $format_in_count_total); $worksheet_in_count->writeFormula(1, 1, "=SUM(B3:B" . $row_count . ")", $format_in_count_total); $row_count = 2; foreach ($in_count_other as $record) { $worksheet_in_count->write($row_count, 2, $record['email'], $format_general); $worksheet_in_count->write($row_count, 3, '', $format_general); $worksheet_in_count->write($row_count, 4, $record['count'], $format_general); $row_count++; } $worksheet_in_count->write(1, 2, 'Total Field Email', $format_in_count_total); $worksheet_in_count->write(1, 3, '', $format_in_count_total); $worksheet_in_count->writeFormula(1, 4, "=SUM(E3:E" . $row_count . ")", $format_in_count_total); // Grand Total $worksheet_in_count->write(1, 5, 'Grand Total Email', $format_in_count_grand); $worksheet_in_count->writeFormula(1, 6, "=SUM(B2,E2)", $format_in_count_grand); $worksheet_out_count->setRow(1, 24); $row_count = 2; foreach ($out_count_admin as $record) { $worksheet_out_count->write($row_count, 0, $record['email'], $format_general); $worksheet_out_count->write($row_count, 1, $record['count'], $format_general); $row_count++; } $worksheet_out_count->write(1, 0, 'Total Admin Email', $format_out_count_total); $worksheet_out_count->writeFormula(1, 1, "=SUM(B3:B" . $row_count . ")", $format_out_count_total); $row_count = 2; foreach ($out_count_other as $record) { $worksheet_out_count->write($row_count, 2, $record['email'], $format_general); $worksheet_out_count->write($row_count, 3, '', $format_general); $worksheet_out_count->write($row_count, 4, $record['count'], $format_general); $row_count++; } $worksheet_out_count->write(1, 2, 'Total Field Email', $format_out_count_total); $worksheet_out_count->write(1, 3, '', $format_out_count_total); $worksheet_out_count->writeFormula(1, 4, "=SUM(E3:E" . $row_count . ")", $format_out_count_total); // Grand Total $worksheet_out_count->write(1, 5, 'Grand Total Email', $format_out_count_grand); $worksheet_out_count->writeFormula(1, 6, "=SUM(B2,E2)", $format_out_count_grand); $workbook->close(); print $translate->_('answernet.er.metlife.metlife.done'); print '<br>'; print $translate->_('ranswernet.er.metlife.generating'); print $translate->_('answernet.er.metlife.metlife.done'); print '<br><br>'; print '<b><a href=' . $href_filename . '>' . $translate->_('answernet.er.metlife.download.xls') . '</a></b>'; print '<br><br>'; }
function renderCriteriaParam($param) { $field = $param->field; $vals = $param->value; if (!is_array($vals)) { $vals = array($vals); } // Do we need to do anything special on custom fields? if ('cf_' == substr($field, 0, 3)) { $field_id = intval(substr($field, 3)); $custom_fields = DAO_CustomField::getAll(); switch ($custom_fields[$field_id]->type) { case Model_CustomField::TYPE_WORKER: $workers = DAO_Worker::getAll(); foreach ($vals as $idx => $worker_id) { if (isset($workers[$worker_id])) { $vals[$idx] = $workers[$worker_id]->getName(); } } break; } } echo implode(', ', $vals); }
public function renderConfig(Model_Macro $macro, $source) { // we'll render the config here, _and_ populate the settings properly based on the macro $actions = parent::renderConfig($macro, $source); $tpl = DevblocksPlatform::getTemplateService(); $groups = DAO_Group::getAll(); $tpl->assign('groups', $groups); $buckets = DAO_Bucket::getAll(); $tpl->assign('buckets', $buckets); $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); $tpl->assign('actions', $actions); /* since the sources dont match we don't want the actions to be set to the values stored in the db */ if ($macro->source_extension_id !== $source) { $macro->actions = array(); } $tpl->assign('source', $source); $tpl->assign('macro', $macro); $tpl->display('file:' . dirname(dirname(__FILE__)) . '/templates/actions.tpl'); }
function renderCriteriaParam($param) { $field = $param->field; $values = !is_array($param->value) ? array($param->value) : $param->value; switch ($field) { case SearchFields_FeedbackEntry::WORKER_ID: $workers = DAO_Worker::getAll(); $strings = array(); foreach ($values as $val) { if (0 == $val) { $strings[] = "Nobody"; } else { if (!isset($workers[$val])) { continue; } $strings[] = $workers[$val]->getName(); } } echo implode(", ", $strings); break; case SearchFields_FeedbackEntry::QUOTE_MOOD: $strings = array(); // [TODO] Translations foreach ($values as $val) { switch ($val) { case 0: $strings[] = "Neutral"; break; case 1: $strings[] = "Praise"; break; case 2: $strings[] = "Criticism"; break; } } echo implode(", ", $strings); break; default: parent::renderCriteriaParam($param); break; } }
function render() { $tpl = DevblocksPlatform::getTemplateService(); $tpl->assign('path', $this->_TPL_PATH); $visit = CerberusApplication::getVisit(); $translate = DevblocksPlatform::getTranslationService(); $response = DevblocksPlatform::getHttpResponse(); $stack = $response->path; array_shift($stack); // tasks $module = array_shift($stack); // display switch ($module) { default: case 'display': @($task_id = intval(array_shift($stack))); if (null == ($task = DAO_Task::get($task_id))) { break; // [TODO] Not found } $tpl->assign('task', $task); if (null == @($tab_selected = $stack[0])) { // $tab_selected = $visit->get(self::SESSION_OPP_TAB, ''); } $tpl->assign('tab_selected', $tab_selected); $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); $visit = CerberusApplication::getVisit(); // Does a series exist? if (null != ($series_info = $visit->get('ch_task_series', null))) { @($series = $series_info['series']); // Is this ID part of the series? If not, invalidate if (!isset($series[$task_id])) { $visit->set('ch_task_series', null); } else { $series_stats = array('title' => $series_info['title'], 'total' => $series_info['total'], 'count' => count($series)); reset($series); $cur = 1; while (null !== current($series)) { $pos = key($series); if (intval($pos) == intval($task_id)) { $series_stats['cur'] = $cur; if (false !== prev($series)) { @($series_stats['prev'] = key($series)); next($series); // skip to current } else { reset($series); } next($series); // next @($series_stats['next'] = key($series)); break; } next($series); $cur++; } $tpl->assign('series_stats', $series_stats); } } $tpl->display($this->_TPL_PATH . 'tasks/display/index.tpl'); break; } }
function showInboxFilterPanelAction() { @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0)); @($group_id = DevblocksPlatform::importGPC($_REQUEST['group_id'], 'integer', 0)); @($ticket_id = DevblocksPlatform::importGPC($_REQUEST['ticket_id'], 'integer', 0)); @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', '')); $active_worker = CerberusApplication::getActiveWorker(); $tpl = DevblocksPlatform::getTemplateService(); $tpl_path = $this->_TPL_PATH; $tpl->assign('path', $tpl_path); $tpl->assign('group_id', $group_id); $tpl->assign('view_id', $view_id); if (null != ($filter = DAO_GroupInboxFilter::get($id))) { $tpl->assign('filter', $filter); } // Make sure we're allowed to change this group's setup if (!$active_worker->isTeamManager($group_id) && !$active_worker->is_superuser) { return; } // Load the example ticket + headers if provided if (!empty($ticket_id)) { $ticket = DAO_Ticket::getTicket($ticket_id); $tpl->assign('ticket', $ticket); $messages = $ticket->getMessages(); $message = array_shift($messages); /* @var $message CerberusMessage */ $message_headers = $message->getHeaders(); $tpl->assign('message', $message); $tpl->assign('message_headers', $message_headers); } $category_name_hash = DAO_Bucket::getCategoryNameHash(); $tpl->assign('category_name_hash', $category_name_hash); $groups = DAO_Group::getAll(); $tpl->assign('groups', $groups); $team_categories = DAO_Bucket::getTeams(); $tpl->assign('team_categories', $team_categories); $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); // Custom Fields: Address $address_fields = DAO_CustomField::getBySource(ChCustomFieldSource_Address::ID); $tpl->assign('address_fields', $address_fields); // Custom Fields: Orgs $org_fields = DAO_CustomField::getBySource(ChCustomFieldSource_Org::ID); $tpl->assign('org_fields', $org_fields); // Custom Fields: Tickets $ticket_fields = DAO_CustomField::getBySource(ChCustomFieldSource_Ticket::ID); $tpl->assign('ticket_fields', $ticket_fields); $tpl->display('file:' . $tpl_path . 'groups/manage/filters/peek.tpl'); }
function getWorkerHistoryChartAction() { header("content-type: text/plain"); $db = DevblocksPlatform::getDatabaseService(); // import dates from form @($start = DevblocksPlatform::importGPC($_REQUEST['start'], 'string', '')); @($end = DevblocksPlatform::importGPC($_REQUEST['end'], 'string', '')); @($countonly = DevblocksPlatform::importGPC($_REQUEST['countonly'], 'integer', 0)); // use date range if specified, else use duration prior to now $start_time = 0; $end_time = 0; if (empty($start) && empty($end)) { $start = "-30 days"; $end = "now"; $start_time = strtotime($start); $end_time = strtotime($end); } else { $start_time = strtotime($start); $end_time = strtotime($end); } // Top Workers $workers = DAO_Worker::getAll(); $sql = sprintf("SELECT count(*) AS hits, m.worker_id " . "FROM message m " . "INNER JOIN ticket t ON (t.id=m.ticket_id) " . "INNER JOIN worker w ON w.id=m.worker_id " . "WHERE m.created_date > %d AND m.created_date <= %d " . "AND m.is_outgoing = 1 " . "AND t.is_deleted = 0 " . "GROUP BY m.worker_id ORDER BY w.last_name DESC ", $start_time, $end_time); $rs_workers = $db->Execute($sql); /* @var $rs_workers ADORecordSet */ if ($countonly) { echo intval($rs_workers->RecordCount()); return; } $worker_counts = array(); while (!$rs_workers->EOF) { $hits = intval($rs_workers->fields['hits']); $worker_id = intval($rs_workers->fields['worker_id']); if (!isset($workers[$worker_id])) { continue; } echo $workers[$worker_id]->getName(), "\t", $hits, "\n"; $rs_workers->MoveNext(); } }
function saveWorkerPeekAction() { $translate = DevblocksPlatform::getTranslationService(); $active_worker = PortSensorApplication::getActiveWorker(); if (!$active_worker || !$active_worker->is_superuser) { return; } @($id = DevblocksPlatform::importGPC($_POST['id'], 'integer')); @($view_id = DevblocksPlatform::importGPC($_POST['view_id'], 'string')); @($first_name = DevblocksPlatform::importGPC($_POST['first_name'], 'string')); @($last_name = DevblocksPlatform::importGPC($_POST['last_name'], 'string')); @($title = DevblocksPlatform::importGPC($_POST['title'], 'string')); @($email = DevblocksPlatform::importGPC($_POST['email'], 'string')); @($password = DevblocksPlatform::importGPC($_POST['password'], 'string')); @($is_superuser = DevblocksPlatform::importGPC($_POST['is_superuser'], 'integer', 0)); @($disabled = DevblocksPlatform::importGPC($_POST['is_disabled'], 'integer', 0)); // @$group_ids = DevblocksPlatform::importGPC($_POST['group_ids'],'array'); // @$group_roles = DevblocksPlatform::importGPC($_POST['group_roles'],'array'); @($delete = DevblocksPlatform::importGPC($_POST['do_delete'], 'integer', 0)); // [TODO] The superuser set bit here needs to be protected by ACL if (empty($first_name)) { $first_name = "Anonymous"; } if (!empty($id) && !empty($delete)) { // Can't delete or disable self if ($active_worker->id != $id) { DAO_Worker::delete($id); } } else { if (empty($id) && null == DAO_Worker::getWhere(sprintf("%s=%s", DAO_Worker::EMAIL, Ps_ORMHelper::qstr($email)))) { $workers = DAO_Worker::getAll(); $license = PortSensorLicense::getInstance(); if (!empty($license) && !empty($license['serial']) || count($workers) < 3) { // Creating new worker. If password is empty, email it to them if (empty($password)) { $settings = DevblocksPlatform::getPluginSettingsService(); $replyFrom = $settings->get('portsensor.core', PortSensorSettings::DEFAULT_REPLY_FROM); $replyPersonal = $settings->get('portsensor.core', PortSensorSettings::DEFAULT_REPLY_PERSONAL, ''); $url = DevblocksPlatform::getUrlService(); $password = PortSensorApplication::generatePassword(8); // try { // $mail_service = DevblocksPlatform::getMailService(); // $mailer = $mail_service->getMailer(CerberusMail::getMailerDefaults()); // $mail = $mail_service->createMessage(); // // $mail->setTo(array($email => $first_name . ' ' . $last_name)); // $mail->setFrom(array($replyFrom => $replyPersonal)); // $mail->setSubject('Your new helpdesk login information!'); // $mail->generateId(); // // $headers = $mail->getHeaders(); // // $headers->addTextHeader('X-Mailer','Cerberus Helpdesk (Build '.APP_BUILD.')'); // // $body = sprintf("Your new helpdesk login information is below:\r\n". // "\r\n". // "URL: %s\r\n". // "Login: %s\r\n". // "Password: %s\r\n". // "\r\n". // "You should change your password from Preferences after logging in for the first time.\r\n". // "\r\n", // $url->write('',true), // $email, // $password // ); // // $mail->setBody($body); // // if(!$mailer->send($mail)) { // throw new Exception('Password notification email failed to send.'); // } // } catch (Exception $e) { // // [TODO] need to report to the admin when the password email doesn't send. The try->catch // // will keep it from killing php, but the password will be empty and the user will never get an email. // } } $fields = array(DAO_Worker::EMAIL => $email, DAO_Worker::PASS => $password); $id = DAO_Worker::create($fields); } } // end create worker // Update $fields = array(DAO_Worker::FIRST_NAME => $first_name, DAO_Worker::LAST_NAME => $last_name, DAO_Worker::TITLE => $title, DAO_Worker::EMAIL => $email, DAO_Worker::IS_SUPERUSER => $is_superuser, DAO_Worker::IS_DISABLED => $disabled); // if we're resetting the password if (!empty($password)) { $fields[DAO_Worker::PASS] = md5($password); } // Update worker DAO_Worker::update($id, $fields); // Update group memberships // if(is_array($group_ids) && is_array($group_roles)) // foreach($group_ids as $idx => $group_id) { // if(empty($group_roles[$idx])) { // DAO_Group::unsetTeamMember($group_id, $id); // } else { // DAO_Group::setTeamMember($group_id, $id, (2==$group_roles[$idx])); // } // } // Add the worker e-mail to the addresses table // if(!empty($email)) // DAO_Address::lookupAddress($email, true); // Addresses // if(null == DAO_AddressToWorker::getByAddress($email)) { // DAO_AddressToWorker::assign($email, $id); // DAO_AddressToWorker::update($email, array( // DAO_AddressToWorker::IS_CONFIRMED => 1 // )); // } // Custom field saves @($field_ids = DevblocksPlatform::importGPC($_POST['field_ids'], 'array', array())); DAO_CustomFieldValue::handleFormPost(PsCustomFieldSource_Worker::ID, $id, $field_ids); } if (!empty($view_id)) { $view = Ps_AbstractViewLoader::getView($view_id); $view->render(); } //DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('setup','workers'))); }
function showComposePeekAction() { @($view_id = DevblocksPlatform::importGPC($_REQUEST['view_id'], 'string', '')); @($to = DevblocksPlatform::importGPC($_REQUEST['to'], 'string', '')); $visit = CerberusApplication::getVisit(); $tpl = DevblocksPlatform::getTemplateService(); $tpl_path = $this->_TPL_PATH; $tpl->assign('path', $tpl_path); $tpl->assign('view_id', $view_id); $tpl->assign('to', $to); $teams = DAO_Group::getAll(); $tpl->assign_by_ref('teams', $teams); $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); // Load Defaults $team_id = intval($visit->get('compose.defaults.from', '')); $subject = $visit->get('compose.defaults.subject', ''); $closed = intval($visit->get('compose.defaults.closed', '')); $next_worker_id = intval($visit->get('compose.defaults.next_worker_id', '')); $tpl->assign('default_group_id', $team_id); $tpl->assign('default_subject', $subject); $tpl->assign('default_closed', $closed); $tpl->assign('default_next_worker_id', $next_worker_id); $tpl->display('file:' . $this->_TPL_PATH . 'tickets/compose/peek.tpl'); }
function showContactHistoryAction() { $translate = DevblocksPlatform::getTranslationService(); @($ticket_id = DevblocksPlatform::importGPC($_REQUEST['ticket_id'], 'integer')); $tpl = DevblocksPlatform::getTemplateService(); $tpl->assign('path', $this->_TPL_PATH); $ticket = DAO_Ticket::getTicket($ticket_id); $requesters = $ticket->getRequesters(); $contact = DAO_Address::get($ticket->first_wrote_address_id); $tpl->assign('contact', $contact); $visit = CerberusApplication::getVisit(); /* @var $visit CerberusVisit */ $view = C4_AbstractViewLoader::getView('', 'contact_history'); if (null == $view) { $view = new C4_TicketView(); $view->id = 'contact_history'; $view->name = $translate->_('addy_book.history.view.title'); $view->view_columns = array(SearchFields_Ticket::TICKET_LAST_ACTION_CODE, SearchFields_Ticket::TICKET_CREATED_DATE, SearchFields_Ticket::TICKET_TEAM_ID, SearchFields_Ticket::TICKET_CATEGORY_ID); $view->params = array(); $view->renderLimit = 10; $view->renderSortBy = SearchFields_Ticket::TICKET_CREATED_DATE; $view->renderSortAsc = false; } $view->name = vsprintf($translate->_('addy_book.history.view.requester'), intval(count($requesters))); $view->params = array(SearchFields_Ticket::REQUESTER_ID => new DevblocksSearchCriteria(SearchFields_Ticket::REQUESTER_ID, 'in', array_keys($requesters)), SearchFields_Ticket::TICKET_DELETED => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_DELETED, DevblocksSearchCriteria::OPER_EQ, 0)); $view->renderPage = 0; $tpl->assign('view', $view); C4_AbstractViewLoader::setView($view->id, $view); $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); $teams = DAO_Group::getAll(); $tpl->assign('teams', $teams); $buckets = DAO_Bucket::getAll(); $tpl->assign('buckets', $buckets); $team_categories = DAO_Bucket::getTeams(); $tpl->assign('team_categories', $team_categories); $tpl->display('file:' . $this->_TPL_PATH . 'display/modules/history/index.tpl'); }
function render() { $this->_sanitize(); $tpl = DevblocksPlatform::getTemplateService(); $tpl->assign('id', $this->id); $tpl->assign('view', $this); $tpl->cache_lifetime = "0"; $tpl->assign('view_fields', $this->getColumns()); $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); $groups = DAO_Group::getAll(); $tpl->assign('groups', $groups); $buckets = DAO_Bucket::getAll(); $tpl->assign('buckets', $buckets); $ticket_fields = SearchFields_Ticket::getFields(); $tpl->assign('ticket_fields', $ticket_fields); $tpl->display('file:' . DEVBLOCKS_PLUGIN_PATH . 'cerberusweb.auditlog/templates/display/log/log_view.tpl'); }
private function _getTicketLastAction($ticket) { static $workers = null; $action_code = $ticket[SearchFields_Ticket::TICKET_LAST_ACTION_CODE]; $output = ''; if (is_null($workers)) { $workers = DAO_Worker::getAll(); } // [TODO] Translate switch ($action_code) { case CerberusTicketActionCode::TICKET_OPENED: $output = sprintf("New from %s", $ticket[SearchFields_Ticket::TICKET_LAST_WROTE]); break; case CerberusTicketActionCode::TICKET_CUSTOMER_REPLY: @($worker_id = $ticket[SearchFields_Ticket::TICKET_NEXT_WORKER_ID]); @($worker = $workers[$worker_id]); $output = sprintf("Incoming for %s", !empty($worker) ? $worker->getName() : "Helpdesk"); break; case CerberusTicketActionCode::TICKET_WORKER_REPLY: @($worker_id = $ticket[SearchFields_Ticket::TICKET_LAST_WORKER_ID]); @($worker = $workers[$worker_id]); $output = sprintf("Outgoing from %s", !empty($worker) ? $worker->getName() : "Helpdesk"); break; } return $output; }
function handleRequest(DevblocksHttpRequest $request) { $stack = $request->path; $db = DevblocksPlatform::getDatabaseService(); // **** BEGIN AUTH @($verb = $_SERVER['REQUEST_METHOD']); @($header_date = $_SERVER['HTTP_DATE']); @($header_signature = $_SERVER['HTTP_CERB4_AUTH']); @($this->_payload = $this->_getRawPost()); @(list($auth_access_key, $auth_signature) = explode(":", $header_signature, 2)); $url_parts = parse_url(DevblocksPlatform::getWebPath()); $url_path = $url_parts['path']; $url_query = $this->_sortQueryString($_SERVER['QUERY_STRING']); $string_to_sign_prefix = "{$verb}\n{$header_date}\n{$url_path}\n{$url_query}\n{$this->_payload}"; if (!$this->_validateRfcDate($header_date)) { $this->_error("Access denied! (Invalid timestamp)"); } if (strpos($auth_access_key, '@')) { // WORKER-LEVEL AUTH $workers = DAO_Worker::getAll(); foreach ($workers as $worker) { /* @var $worker CerberusWorker */ if ($worker->email == $auth_access_key) { $this->setActiveWorker($worker); break; } } if (null == $this->getActiveWorker()) { $this->_error("Access denied! (Invalid worker)"); } $pass = $this->getActiveWorker()->pass; $string_to_sign = "{$string_to_sign_prefix}\n{$pass}\n"; $compare_hash = base64_encode(sha1($string_to_sign, true)); if (0 != strcmp($auth_signature, $compare_hash)) { $this->_error("Access denied! (Invalid password)"); } } else { // APP-LEVEL AUTH $stored_keychains = DAO_WebapiKey::getWhere(sprintf("%s = %s", DAO_WebapiKey::ACCESS_KEY, $db->qstr(str_replace(' ', '', $auth_access_key)))); /* @var $stored_keychain Model_WebApiKey */ if (!empty($stored_keychains)) { @($stored_keychain = array_shift($stored_keychains)); @($auth_secret_key = $stored_keychain->secret_key); @($auth_rights = $stored_keychain->rights); $string_to_sign = "{$string_to_sign_prefix}\n{$auth_secret_key}\n"; $compare_hash = base64_encode(sha1($string_to_sign, true)); if (0 != strcmp($auth_signature, $compare_hash)) { $this->_error("Access denied! (Invalid signature)"); } // Check that this IP is allowed to perform the VERB if (!$stored_keychain->isValidIp($_SERVER['REMOTE_ADDR'])) { $this->_error(sprintf("Access denied! (IP %s not authorized)", $_SERVER['REMOTE_ADDR'])); } } else { $this->_error("Access denied! (Unknown access key)"); } } // **** END APP AUTH // Figure out our format by looking at the last path argument @(list($command, $format) = explode('.', array_pop($stack))); array_push($stack, $command); $this->_format = $format; if (null != $this->getActiveWorker()) { $method = strtolower($verb) . 'WorkerAction'; if (method_exists($this, $method)) { call_user_func(array(&$this, $method), $stack); } } else { $method = strtolower($verb) . 'Action'; if (method_exists($this, $method)) { call_user_func(array(&$this, $method), $stack, $stored_keychain); } } }
private function _handleImportTicket($xml) { $settings = CerberusSettings::getInstance(); $logger = DevblocksPlatform::getConsoleLog(); $workers = DAO_Worker::getAll(); static $email_to_worker_id = null; static $group_name_to_id = null; static $bucket_name_to_id = null; // Hash Workers so we can ID their incoming tickets if (null == $email_to_worker_id) { $email_to_worker_id = array(); if (is_array($workers)) { foreach ($workers as $worker) { /* @var $worker CerberusWorker */ $email_to_worker_id[strtolower($worker->email)] = intval($worker->id); } } } // Hash Group names if (null == $group_name_to_id) { $groups = DAO_Group::getAll(); $group_name_to_id = array(); if (is_array($groups)) { foreach ($groups as $group) { $group_name_to_id[strtolower($group->name)] = intval($group->id); } } } // Hash Bucket names if (null == $bucket_name_to_id) { $buckets = DAO_Bucket::getAll(); $bucket_name_to_id = array(); if (is_array($buckets)) { foreach ($buckets as $bucket) { /* @var $bucket CerberusCategory */ // Hash by team ID and bucket name $hash = md5($bucket->team_id . strtolower($bucket->name)); $bucket_to_id[$hash] = intval($bucket->id); } } } $sMask = (string) $xml->mask; $sSubject = substr((string) $xml->subject, 0, 255); $sGroup = (string) $xml->group; $sBucket = (string) $xml->bucket; $iCreatedDate = (int) $xml->created_date; $iUpdatedDate = (int) $xml->updated_date; $isWaiting = (int) $xml->is_waiting; $isClosed = (int) $xml->is_closed; if (empty($sMask)) { $sMask = CerberusApplication::generateTicketMask(); } // Find the destination Group + Bucket (or create them) if (empty($sGroup)) { $iDestGroupId = 0; if (null != ($iDestGroup = DAO_Group::getDefaultGroup())) { $iDestGroupId = $iDestGroup->id; } } elseif (null == ($iDestGroupId = @$group_name_to_id[strtolower($sGroup)])) { $iDestGroupId = DAO_Group::createTeam(array(DAO_Group::TEAM_NAME => $sGroup)); // Give all superusers manager access to this new group if (is_array($workers)) { foreach ($workers as $worker) { if ($worker->is_superuser) { DAO_Group::setTeamMember($iDestGroupId, $worker->id, true); } } } // Rehash DAO_Group::getAll(true); $group_name_to_id[strtolower($sGroup)] = $iDestGroupId; } if (empty($sBucket)) { $iDestBucketId = 0; // Inbox } elseif (null == ($iDestBucketId = @$bucket_name_to_id[md5($iDestGroupId . strtolower($sBucket))])) { $iDestBucketId = DAO_Bucket::create($sBucket, $iDestGroupId); // Rehash DAO_Bucket::getAll(true); $bucket_name_to_id[strtolower($sBucket)] = $iDestBucketId; } // Xpath the first and last "from" out of "/ticket/messages/message/headers/from" $aMessageNodes = $xml->xpath("/ticket/messages/message"); $iNumMessages = count($aMessageNodes); @($eFirstMessage = reset($aMessageNodes)); if (is_null($eFirstMessage)) { $logger->warn('[Importer] Ticket ' . $sMask . " doesn't have any messages. Skipping."); return false; } if (is_null($eFirstMessage->headers) || is_null($eFirstMessage->headers->from)) { $logger->warn('[Importer] Ticket ' . $sMask . " first message doesn't provide a sender address."); return false; } $sFirstWrote = self::_parseRfcAddressList($eFirstMessage->headers->from, true); if (null == ($firstWroteInst = CerberusApplication::hashLookupAddress($sFirstWrote, true))) { $logger->warn('[Importer] Ticket ' . $sMask . " - Invalid sender adddress: " . $sFirstWrote); return false; } $eLastMessage = end($aMessageNodes); if (is_null($eLastMessage)) { $logger->warn('[Importer] Ticket ' . $sMask . " doesn't have any messages. Skipping."); return false; } if (is_null($eLastMessage->headers) || is_null($eLastMessage->headers->from)) { $logger->warn('[Importer] Ticket ' . $sMask . " last message doesn't provide a sender address."); return false; } $sLastWrote = self::_parseRfcAddressList($eLastMessage->headers->from, true); if (null == ($lastWroteInst = CerberusApplication::hashLookupAddress($sLastWrote, true))) { $logger->warn('[Importer] Ticket ' . $sMask . ' last message has an invalid sender address: ' . $sLastWrote); return false; } // Last action code + last worker $sLastActionCode = CerberusTicketActionCode::TICKET_OPENED; $iLastWorkerId = 0; if ($iNumMessages > 1) { if (null != @($iLastWorkerId = $email_to_worker_id[strtolower($lastWroteInst->email)])) { $sLastActionCode = CerberusTicketActionCode::TICKET_WORKER_REPLY; } else { $sLastActionCode = CerberusTicketActionCode::TICKET_CUSTOMER_REPLY; $iLastWorkerId = 0; } } // Dupe check by ticket mask if (null != DAO_Ticket::getTicketByMask($sMask)) { $logger->warn("[Importer] Ticket mask '" . $sMask . "' already exists. Making it unique."); $uniqueness = 1; $origMask = $sMask; // Append new uniqueness to the ticket mask: LLL-NNNNN-NNN-1, LLL-NNNNN-NNN-2, ... do { $sMask = $origMask . '-' . ++$uniqueness; } while (null != DAO_Ticket::getTicketIdByMask($sMask)); $logger->info("[Importer] The unique mask for '" . $origMask . "' is now '" . $sMask . "'"); } // Create ticket $fields = array(DAO_Ticket::MASK => $sMask, DAO_Ticket::SUBJECT => $sSubject, DAO_Ticket::IS_WAITING => $isWaiting, DAO_Ticket::IS_CLOSED => $isClosed, DAO_Ticket::FIRST_WROTE_ID => intval($firstWroteInst->id), DAO_Ticket::LAST_WROTE_ID => intval($lastWroteInst->id), DAO_Ticket::CREATED_DATE => $iCreatedDate, DAO_Ticket::UPDATED_DATE => $iUpdatedDate, DAO_Ticket::TEAM_ID => intval($iDestGroupId), DAO_Ticket::CATEGORY_ID => intval($iDestBucketId), DAO_Ticket::LAST_ACTION_CODE => $sLastActionCode, DAO_Ticket::LAST_WORKER_ID => intval($iLastWorkerId)); $ticket_id = DAO_Ticket::createTicket($fields); // echo "Ticket: ",$ticket_id,"<BR>"; // print_r($fields); // Create requesters if (!is_null($xml->requesters)) { foreach ($xml->requesters->address as $eAddress) { /* @var $eAddress SimpleXMLElement */ $sRequesterAddy = (string) $eAddress; // [TODO] RFC822 // Insert requesters if (null == ($requesterAddyInst = CerberusApplication::hashLookupAddress($sRequesterAddy, true))) { $logger->warn('[Importer] Ticket ' . $sMask . ' - Ignoring malformed requester: ' . $sRequesterAddy); continue; } DAO_Ticket::createRequester($requesterAddyInst->id, $ticket_id); } } // Create messages $is_first = true; if (!is_null($xml->messages)) { foreach ($xml->messages->message as $eMessage) { /* @var $eMessage SimpleXMLElement */ $eHeaders =& $eMessage->headers; /* @var $eHeaders SimpleXMLElement */ $sMsgFrom = (string) $eHeaders->from; $sMsgDate = (string) $eHeaders->date; $sMsgFrom = self::_parseRfcAddressList($sMsgFrom, true); if (NULL == $sMsgFrom) { $logger->warn('[Importer] Ticket ' . $sMask . ' - Invalid message sender: ' . $sMsgFrom . ' (skipping)'); continue; } if (null == ($msgFromInst = CerberusApplication::hashLookupAddress($sMsgFrom, true))) { $logger->warn('[Importer] Ticket ' . $sMask . ' - Invalid message sender: ' . $sMsgFrom . ' (skipping)'); continue; } @($msgWorkerId = intval($email_to_worker_id[strtolower($msgFromInst->email)])); // $logger->info('Checking if '.$msgFromInst->email.' is a worker'); $fields = array(DAO_Message::TICKET_ID => $ticket_id, DAO_Message::CREATED_DATE => strtotime($sMsgDate), DAO_Message::ADDRESS_ID => $msgFromInst->id, DAO_Message::IS_OUTGOING => !empty($msgWorkerId) ? 1 : 0, DAO_Message::WORKER_ID => !empty($msgWorkerId) ? $msgWorkerId : 0); $email_id = DAO_Message::create($fields); // First thread if ($is_first) { DAO_Ticket::updateTicket($ticket_id, array(DAO_Ticket::FIRST_MESSAGE_ID => $email_id)); $is_first = false; } // Create attachments if (!is_null($eMessage->attachments)) { foreach ($eMessage->attachments->attachment as $eAttachment) { /* @var $eAttachment SimpleXMLElement */ $sFileName = (string) $eAttachment->name; $sMimeType = (string) $eAttachment->mimetype; $sFileSize = (int) $eAttachment->size; $sFileContentB64 = (string) $eAttachment->content; // [TODO] This could be a little smarter about detecting extensions if (empty($sMimeType)) { $sMimeType = "application/octet-stream"; } $sFileContent = base64_decode($sFileContentB64); unset($sFileContentB64); $fields = array(DAO_Attachment::MESSAGE_ID => $email_id, DAO_Attachment::DISPLAY_NAME => $sFileName, DAO_Attachment::FILE_SIZE => intval($sFileSize), DAO_Attachment::FILEPATH => '', DAO_Attachment::MIME_TYPE => $sMimeType); $file_id = DAO_Attachment::create($fields); // Write file to disk using ID (Model) $file_path = Model_Attachment::saveToFile($file_id, $sFileContent); unset($sFileContent); // Update attachment table DAO_Attachment::update($file_id, array(DAO_Attachment::FILEPATH => $file_path)); } } // Create message content $sMessageContentB64 = (string) $eMessage->content; $sMessageContent = base64_decode($sMessageContentB64); // Content-type specific handling if (isset($eMessage->content['content-type'])) { // do we have a content-type? if (strtolower($eMessage->content['content-type']) == 'html') { // html? // Force to plaintext part $sMessageContent = CerberusApplication::stripHTML($sMessageContent); } } unset($sMessageContentB64); DAO_MessageContent::create($email_id, $sMessageContent); unset($sMessageContent); // Headers foreach ($eHeaders->children() as $eHeader) { /* @var $eHeader SimpleXMLElement */ DAO_MessageHeader::create($email_id, $eHeader->getName(), (string) $eHeader); } } } // Create comments if (!is_null($xml->comments)) { foreach ($xml->comments->comment as $eComment) { /* @var $eMessage SimpleXMLElement */ $iCommentDate = (int) $eComment->created_date; $sCommentAuthor = (string) $eComment->author; // [TODO] Address Hash Lookup $sCommentTextB64 = (string) $eComment->content; $sCommentText = base64_decode($sCommentTextB64); unset($sCommentTextB64); $commentAuthorInst = CerberusApplication::hashLookupAddress($sCommentAuthor, true); // [TODO] Sanity checking $fields = array(DAO_TicketComment::TICKET_ID => intval($ticket_id), DAO_TicketComment::CREATED => intval($iCommentDate), DAO_TicketComment::ADDRESS_ID => intval($commentAuthorInst->id), DAO_TicketComment::COMMENT => $sCommentText); $comment_id = DAO_TicketComment::create($fields); unset($sCommentText); } } $logger->info('[Importer] Imported ticket #' . $ticket_id); return true; }
function showTabHistoryAction() { $translate = DevblocksPlatform::getTranslationService(); @($org = DevblocksPlatform::importGPC($_REQUEST['org'])); $tpl = DevblocksPlatform::getTemplateService(); $tpl->assign('path', $this->_TPL_PATH); $contact = DAO_ContactOrg::get($org); $tpl->assign('contact', $contact); $visit = CerberusApplication::getVisit(); /* @var $visit CerberusVisit */ $tickets_view = C4_AbstractViewLoader::getView('contact_history'); // All org contacts $people = DAO_Address::getWhere(sprintf("%s = %d", DAO_Address::CONTACT_ORG_ID, $contact->id)); if (null == $tickets_view) { $tickets_view = new C4_TicketView(); $tickets_view->id = 'contact_history'; $tickets_view->name = $translate->_('addy_book.history.view_title'); $tickets_view->view_columns = array(SearchFields_Ticket::TICKET_LAST_ACTION_CODE, SearchFields_Ticket::TICKET_CREATED_DATE, SearchFields_Ticket::TICKET_TEAM_ID, SearchFields_Ticket::TICKET_CATEGORY_ID); $tickets_view->params = array(); $tickets_view->renderLimit = 10; $tickets_view->renderPage = 0; $tickets_view->renderSortBy = SearchFields_Ticket::TICKET_CREATED_DATE; $tickets_view->renderSortAsc = false; } @($tickets_view->name = $translate->_('ticket.requesters') . ": " . htmlspecialchars($contact->name) . ' - ' . intval(count($people)) . ' contact(s)'); $tickets_view->params = array(SearchFields_Ticket::REQUESTER_ID => new DevblocksSearchCriteria(SearchFields_Ticket::REQUESTER_ID, 'in', array_keys($people)), SearchFields_Ticket::TICKET_DELETED => new DevblocksSearchCriteria(SearchFields_Ticket::TICKET_DELETED, DevblocksSearchCriteria::OPER_EQ, 0)); $tpl->assign('contact_history', $tickets_view); C4_AbstractViewLoader::setView($tickets_view->id, $tickets_view); $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); $teams = DAO_Group::getAll(); $tpl->assign('teams', $teams); $buckets = DAO_Bucket::getAll(); $tpl->assign('buckets', $buckets); $team_categories = DAO_Bucket::getTeams(); $tpl->assign('team_categories', $team_categories); $tpl->display('file:' . $this->_TPL_PATH . 'contacts/orgs/tabs/history.tpl'); exit; }
function showMailRoutingRulePanelAction() { @($id = DevblocksPlatform::importGPC($_REQUEST['id'], 'integer', 0)); @($group_id = DevblocksPlatform::importGPC($_REQUEST['group_id'], 'integer', 0)); $active_worker = CerberusApplication::getActiveWorker(); $tpl = DevblocksPlatform::getTemplateService(); $tpl_path = $this->_TPL_PATH; $tpl->assign('path', $tpl_path); $tpl->assign('group_id', $group_id); if (null != ($rule = DAO_MailToGroupRule::get($id))) { $tpl->assign('rule', $rule); } // Make sure we're allowed to change this group's setup if (!$active_worker->isTeamManager($group_id) && !$active_worker->is_superuser) { return; } $groups = DAO_Group::getAll(); $tpl->assign('groups', $groups); $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); // Custom Fields: Address $address_fields = DAO_CustomField::getBySource(ChCustomFieldSource_Address::ID); $tpl->assign('address_fields', $address_fields); // Custom Fields: Orgs $org_fields = DAO_CustomField::getBySource(ChCustomFieldSource_Org::ID); $tpl->assign('org_fields', $org_fields); // Custom Fields: Ticket $ticket_fields = DAO_CustomField::getBySource(ChCustomFieldSource_Ticket::ID); $tpl->assign('ticket_fields', $ticket_fields); $tpl->display('file:' . $tpl_path . 'configuration/tabs/mail/routing/peek.tpl'); }
function getTimeSpentActivityReportAction() { $db = DevblocksPlatform::getDatabaseService(); $tpl = DevblocksPlatform::getTemplateService(); $tpl->cache_lifetime = "0"; $tpl->assign('path', $this->tpl_path); // import dates from form @($start = DevblocksPlatform::importGPC($_REQUEST['start'], 'string', '')); @($end = DevblocksPlatform::importGPC($_REQUEST['end'], 'string', '')); // use date range if specified, else use duration prior to now $start_time = 0; $end_time = 0; if (empty($start) && empty($end)) { $start = "-30 days"; $end = "now"; $start_time = strtotime($start); $end_time = strtotime($end); } else { $start_time = strtotime($start); $end_time = strtotime($end); } if ($start_time === false || $end_time === false) { $start = "-30 days"; $end = "now"; $start_time = strtotime($start); $end_time = strtotime($end); $tpl->assign('invalidDate', true); } $workers = DAO_Worker::getAll(); $tpl->assign('workers', $workers); $sources = DAO_TimeTrackingEntry::getSources(); $tpl->assign('sources', $sources); // reload variables in template $tpl->assign('start', $start); $tpl->assign('end', $end); $sql = sprintf("SELECT tte.log_date, tte.time_actual_mins, tte.notes, tte.source_extension_id, tte.source_id," . "tta.id activity_id, tta.name activity_name, " . "o.name org_name, tte.worker_id " . "FROM timetracking_entry tte " . "LEFT JOIN timetracking_activity tta ON tte.activity_id = tta.id " . "LEFT JOIN contact_org o ON tte.debit_org_id = o.id " . "WHERE log_date > %d AND log_date <= %d " . "ORDER BY activity_name, log_date ", $start_time, $end_time); //echo $sql; $rs = $db->Execute($sql); $time_entries = array(); if (is_a($rs, 'ADORecordSet')) { while (!$rs->EOF) { $mins = intval($rs->fields['time_actual_mins']); $activity = $rs->fields['activity_name']; $log_date = intval($rs->fields['log_date']); $activity_id = intval($rs->fields['activity_id']); $notes = $rs->fields['notes']; $worker_id = intval($rs->fields['worker_id']); $org_name = $rs->fields['org_name']; if (!isset($time_entries[$activity_id])) { $time_entries[$activity_id] = array(); } if (!isset($time_entries[$activity_id]['entries'])) { $time_entries[$activity_id]['entries'] = array(); } unset($time_entry); $time_entry['mins'] = $mins; $time_entry['log_date'] = $log_date; $time_entry['notes'] = $notes; $time_entry['worker_name'] = $workers[$worker_id]->getName(); $time_entry['org_name'] = $org_name; $time_entry['source_extension_id'] = $rs->fields['source_extension_id']; $time_entry['source_id'] = intval($rs->fields['source_id']); $time_entries[$activity_id]['entries'][] = $time_entry; @($time_entries[$activity_id]['total_mins'] = intval($time_entries[$activity_id]['total_mins']) + $mins); @($time_entries[$activity_id]['activity_name'] = $activity); $rs->MoveNext(); } } //print_r($time_entries); $tpl->assign('time_entries', $time_entries); $tpl->display('file:' . $this->tpl_path . '/reports/time_spent_activity/html.tpl'); }