Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * | |
30 | * @package CRM | |
06b69b18 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * This page is for Case Dashboard | |
38 | */ | |
39 | class CRM_Case_Page_DashBoard extends CRM_Core_Page { | |
40 | ||
a4400196 CW |
41 | public $useLivePageJS = TRUE; |
42 | ||
6a488035 TO |
43 | /** |
44 | * Heart of the viewing process. The runner gets all the meta data for | |
45 | * the contact and calls the appropriate type of page to view. | |
46 | * | |
47 | * @return void | |
6a488035 | 48 | */ |
00be9182 | 49 | public function preProcess() { |
6a488035 TO |
50 | //check for civicase access. |
51 | if (!CRM_Case_BAO_Case::accessCiviCase()) { | |
52 | CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); | |
53 | } | |
54 | ||
55 | //validate case configuration. | |
56 | $configured = CRM_Case_BAO_Case::isCaseConfigured(); | |
57 | $this->assign('notConfigured', !$configured['configured']); | |
58 | $this->assign('allowToAddNewCase', $configured['allowToAddNewCase']); | |
59 | if (!$configured['configured']) { | |
60 | return; | |
61 | } | |
62 | ||
63 | $session = CRM_Core_Session::singleton(); | |
64 | $allCases = CRM_Utils_Request::retrieve('all', 'Positive', $session); | |
65 | ||
66 | CRM_Utils_System::setTitle(ts('CiviCase Dashboard')); | |
67 | ||
68 | $userID = $session->get('userID'); | |
69 | ||
70 | //validate access for all cases. | |
71 | if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) { | |
72 | $allCases = FALSE; | |
73 | CRM_Core_Session::setStatus(ts('You are not authorized to access all cases and activities.'), ts('Sorry'), 'error'); | |
74 | } | |
75 | if (!$allCases) { | |
76 | $this->assign('myCases', TRUE); | |
77 | } | |
78 | else { | |
79 | $this->assign('myCases', FALSE); | |
80 | } | |
81 | ||
82 | $this->assign('newClient', FALSE); | |
83 | if (CRM_Core_Permission::check('add contacts') && | |
84 | CRM_Core_Permission::check('access all cases and activities') | |
85 | ) { | |
86 | $this->assign('newClient', TRUE); | |
87 | } | |
353ffa53 | 88 | $summary = CRM_Case_BAO_Case::getCasesSummary($allCases, $userID); |
6a488035 | 89 | $upcoming = CRM_Case_BAO_Case::getCases($allCases, $userID, 'upcoming'); |
353ffa53 | 90 | $recent = CRM_Case_BAO_Case::getCases($allCases, $userID, 'recent'); |
6a488035 | 91 | |
22e263ad TO |
92 | foreach ($upcoming as $key => $value) { |
93 | if (strtotime($value['case_scheduled_activity_date']) < time()) { | |
95661f60 | 94 | $upcoming[$key]['activity_status'] = 'status-overdue'; |
95 | } | |
975890d5 | 96 | } |
6a488035 TO |
97 | $this->assign('casesSummary', $summary); |
98 | if (!empty($upcoming)) { | |
99 | $this->assign('upcomingCases', $upcoming); | |
100 | } | |
101 | if (!empty($recent)) { | |
102 | $this->assign('recentCases', $recent); | |
103 | } | |
104 | } | |
105 | ||
106 | /** | |
dc195289 | 107 | * the main function that is called when the page loads, |
6a488035 TO |
108 | * it decides the which action has to be taken for the page. |
109 | * | |
76e7a76c | 110 | * @return null |
6a488035 | 111 | */ |
00be9182 | 112 | public function run() { |
6a488035 TO |
113 | $this->preProcess(); |
114 | ||
115 | return parent::run(); | |
116 | } | |
117 | } |