Example #1
0
 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');
 }
Example #2
0
 function refreshSidebarAction()
 {
     $db = DevblocksPlatform::getDatabaseService();
     $tpl = DevblocksPlatform::getTemplateService();
     $tpl->assign('path', $this->_TPL_PATH);
     $visit = CerberusApplication::getVisit();
     $active_worker = CerberusApplication::getActiveWorker();
     $section = $visit->get(CerberusVisit::KEY_MAIL_MODE, '');
     switch ($section) {
         case 'workflow':
             $groups = DAO_Group::getAll();
             $tpl->assign('groups', $groups);
             $group_buckets = DAO_Bucket::getTeams();
             $tpl->assign('group_buckets', $group_buckets);
             $group_counts = DAO_WorkflowView::getGroupTotals();
             $tpl->assign('group_counts', $group_counts);
             $tpl->display('file:' . $this->_TPL_PATH . 'tickets/workflow/sidebar.tpl');
             break;
         case 'overview':
             $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:' . $this->_TPL_PATH . 'tickets/overview/sidebar.tpl');
             break;
     }
 }