Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
232624b1 | 4 | | CiviCRM version 4.4 | |
6a488035 TO |
5 | +--------------------------------------------------------------------+ |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
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 | |
31 | * @copyright CiviCRM LLC (c) 2004-2013 | |
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 | ||
41 | /** | |
42 | * Heart of the viewing process. The runner gets all the meta data for | |
43 | * the contact and calls the appropriate type of page to view. | |
44 | * | |
45 | * @return void | |
46 | * @access public | |
47 | * | |
48 | */ | |
49 | function preProcess() { | |
0ee2ad76 KJ |
50 | // js for changing activity status |
51 | CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Case/Form/ActivityChangeStatus.js'); | |
52 | ||
6a488035 TO |
53 | //check for civicase access. |
54 | if (!CRM_Case_BAO_Case::accessCiviCase()) { | |
55 | CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); | |
56 | } | |
57 | ||
58 | //validate case configuration. | |
59 | $configured = CRM_Case_BAO_Case::isCaseConfigured(); | |
60 | $this->assign('notConfigured', !$configured['configured']); | |
61 | $this->assign('allowToAddNewCase', $configured['allowToAddNewCase']); | |
62 | if (!$configured['configured']) { | |
63 | return; | |
64 | } | |
65 | ||
66 | $session = CRM_Core_Session::singleton(); | |
67 | $allCases = CRM_Utils_Request::retrieve('all', 'Positive', $session); | |
68 | ||
69 | CRM_Utils_System::setTitle(ts('CiviCase Dashboard')); | |
70 | ||
71 | $userID = $session->get('userID'); | |
72 | ||
73 | //validate access for all cases. | |
74 | if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) { | |
75 | $allCases = FALSE; | |
76 | CRM_Core_Session::setStatus(ts('You are not authorized to access all cases and activities.'), ts('Sorry'), 'error'); | |
77 | } | |
78 | if (!$allCases) { | |
79 | $this->assign('myCases', TRUE); | |
80 | } | |
81 | else { | |
82 | $this->assign('myCases', FALSE); | |
83 | } | |
84 | ||
85 | $this->assign('newClient', FALSE); | |
86 | if (CRM_Core_Permission::check('add contacts') && | |
87 | CRM_Core_Permission::check('access all cases and activities') | |
88 | ) { | |
89 | $this->assign('newClient', TRUE); | |
90 | } | |
91 | $summary = CRM_Case_BAO_Case::getCasesSummary($allCases, $userID); | |
92 | $upcoming = CRM_Case_BAO_Case::getCases($allCases, $userID, 'upcoming'); | |
93 | $recent = CRM_Case_BAO_Case::getCases($allCases, $userID, 'recent'); | |
94 | ||
95 | $this->assign('casesSummary', $summary); | |
96 | if (!empty($upcoming)) { | |
97 | $this->assign('upcomingCases', $upcoming); | |
98 | } | |
99 | if (!empty($recent)) { | |
100 | $this->assign('recentCases', $recent); | |
101 | } | |
102 | } | |
103 | ||
104 | /** | |
105 | * This function is the main function that is called when the page loads, | |
106 | * it decides the which action has to be taken for the page. | |
107 | * | |
108 | * return null | |
109 | * @access public | |
110 | */ | |
111 | function run() { | |
112 | $this->preProcess(); | |
113 | ||
114 | return parent::run(); | |
115 | } | |
116 | } | |
117 |