Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
7e9e8871 | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
0f03f337 | 6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
0f03f337 | 31 | * @copyright CiviCRM LLC (c) 2004-2017 |
6a488035 TO |
32 | */ |
33 | ||
34 | /** | |
67d19299 | 35 | * This page is for Case Dashboard. |
6a488035 TO |
36 | */ |
37 | class CRM_Case_Page_DashBoard extends CRM_Core_Page { | |
38 | ||
a4400196 CW |
39 | public $useLivePageJS = TRUE; |
40 | ||
6a488035 | 41 | /** |
67d19299 | 42 | * Heart of the viewing process. |
6a488035 | 43 | * |
67d19299 | 44 | * The runner gets all the meta data for the contact and calls the appropriate type of page to view. |
6a488035 | 45 | */ |
00be9182 | 46 | public function preProcess() { |
6a488035 TO |
47 | //check for civicase access. |
48 | if (!CRM_Case_BAO_Case::accessCiviCase()) { | |
49 | CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); | |
50 | } | |
51 | ||
52 | //validate case configuration. | |
53 | $configured = CRM_Case_BAO_Case::isCaseConfigured(); | |
54 | $this->assign('notConfigured', !$configured['configured']); | |
55 | $this->assign('allowToAddNewCase', $configured['allowToAddNewCase']); | |
56 | if (!$configured['configured']) { | |
57 | return; | |
58 | } | |
59 | ||
60 | $session = CRM_Core_Session::singleton(); | |
5f1c8c57 | 61 | $allCases = CRM_Utils_Request::retrieve('all', 'Positive', $this); |
6a488035 TO |
62 | |
63 | CRM_Utils_System::setTitle(ts('CiviCase Dashboard')); | |
64 | ||
65 | $userID = $session->get('userID'); | |
66 | ||
67 | //validate access for all cases. | |
68 | if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) { | |
5f1c8c57 | 69 | $allCases = 0; |
6a488035 TO |
70 | CRM_Core_Session::setStatus(ts('You are not authorized to access all cases and activities.'), ts('Sorry'), 'error'); |
71 | } | |
5f1c8c57 | 72 | $this->assign('all', $allCases); |
6a488035 TO |
73 | if (!$allCases) { |
74 | $this->assign('myCases', TRUE); | |
75 | } | |
76 | else { | |
77 | $this->assign('myCases', FALSE); | |
78 | } | |
79 | ||
80 | $this->assign('newClient', FALSE); | |
81 | if (CRM_Core_Permission::check('add contacts') && | |
82 | CRM_Core_Permission::check('access all cases and activities') | |
83 | ) { | |
84 | $this->assign('newClient', TRUE); | |
85 | } | |
5f1c8c57 | 86 | $summary = CRM_Case_BAO_Case::getCasesSummary($allCases); |
87 | $upcoming = CRM_Case_BAO_Case::getCases($allCases, array(), 'dashboard', TRUE); | |
88 | $recent = CRM_Case_BAO_Case::getCases($allCases, array('type' => 'recent'), 'dashboard', TRUE); | |
6a488035 TO |
89 | |
90 | $this->assign('casesSummary', $summary); | |
91 | if (!empty($upcoming)) { | |
5f1c8c57 | 92 | $this->assign('upcomingCases', TRUE); |
6a488035 TO |
93 | } |
94 | if (!empty($recent)) { | |
5f1c8c57 | 95 | $this->assign('recentCases', TRUE); |
6a488035 | 96 | } |
5f1c8c57 | 97 | |
98 | $controller = new CRM_Core_Controller_Simple('CRM_Case_Form_Search', | |
99 | ts('Case'), CRM_Core_Action::BROWSE, | |
100 | NULL, | |
101 | FALSE, FALSE, TRUE | |
102 | ); | |
103 | $controller->set('context', 'dashboard'); | |
104 | $controller->setEmbedded(TRUE); | |
105 | $controller->process(); | |
106 | $controller->run(); | |
6a488035 TO |
107 | } |
108 | ||
109 | /** | |
dc195289 | 110 | * the main function that is called when the page loads, |
6a488035 TO |
111 | * it decides the which action has to be taken for the page. |
112 | * | |
76e7a76c | 113 | * @return null |
6a488035 | 114 | */ |
00be9182 | 115 | public function run() { |
6a488035 TO |
116 | $this->preProcess(); |
117 | ||
118 | return parent::run(); | |
119 | } | |
96025800 | 120 | |
6a488035 | 121 | } |