Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | */ |
17 | ||
18 | /** | |
67d19299 | 19 | * This page is for Case Dashboard. |
6a488035 TO |
20 | */ |
21 | class CRM_Case_Page_DashBoard extends CRM_Core_Page { | |
22 | ||
a4400196 CW |
23 | public $useLivePageJS = TRUE; |
24 | ||
6a488035 | 25 | /** |
67d19299 | 26 | * Heart of the viewing process. |
6a488035 | 27 | * |
67d19299 | 28 | * The runner gets all the meta data for the contact and calls the appropriate type of page to view. |
6a488035 | 29 | */ |
00be9182 | 30 | public function preProcess() { |
6a488035 TO |
31 | //check for civicase access. |
32 | if (!CRM_Case_BAO_Case::accessCiviCase()) { | |
beb414cc | 33 | CRM_Core_Error::statusBounce(ts('You are not authorized to access this page.')); |
6a488035 TO |
34 | } |
35 | ||
36 | //validate case configuration. | |
37 | $configured = CRM_Case_BAO_Case::isCaseConfigured(); | |
38 | $this->assign('notConfigured', !$configured['configured']); | |
39 | $this->assign('allowToAddNewCase', $configured['allowToAddNewCase']); | |
40 | if (!$configured['configured']) { | |
41 | return; | |
42 | } | |
43 | ||
44 | $session = CRM_Core_Session::singleton(); | |
5f1c8c57 | 45 | $allCases = CRM_Utils_Request::retrieve('all', 'Positive', $this); |
6a488035 TO |
46 | |
47 | CRM_Utils_System::setTitle(ts('CiviCase Dashboard')); | |
48 | ||
6a488035 TO |
49 | //validate access for all cases. |
50 | if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) { | |
5f1c8c57 | 51 | $allCases = 0; |
6a488035 TO |
52 | CRM_Core_Session::setStatus(ts('You are not authorized to access all cases and activities.'), ts('Sorry'), 'error'); |
53 | } | |
5f1c8c57 | 54 | $this->assign('all', $allCases); |
6a488035 TO |
55 | if (!$allCases) { |
56 | $this->assign('myCases', TRUE); | |
57 | } | |
58 | else { | |
59 | $this->assign('myCases', FALSE); | |
60 | } | |
61 | ||
62 | $this->assign('newClient', FALSE); | |
63 | if (CRM_Core_Permission::check('add contacts') && | |
64 | CRM_Core_Permission::check('access all cases and activities') | |
65 | ) { | |
66 | $this->assign('newClient', TRUE); | |
67 | } | |
5f1c8c57 | 68 | $summary = CRM_Case_BAO_Case::getCasesSummary($allCases); |
be2fb01f CW |
69 | $upcoming = CRM_Case_BAO_Case::getCases($allCases, [], 'dashboard', TRUE); |
70 | $recent = CRM_Case_BAO_Case::getCases($allCases, ['type' => 'recent'], 'dashboard', TRUE); | |
6a488035 TO |
71 | |
72 | $this->assign('casesSummary', $summary); | |
4a54ff16 | 73 | $this->assign('upcomingCases', !empty($upcoming)); |
74 | $this->assign('recentCases', !empty($recent)); | |
5f1c8c57 | 75 | |
76 | $controller = new CRM_Core_Controller_Simple('CRM_Case_Form_Search', | |
77 | ts('Case'), CRM_Core_Action::BROWSE, | |
78 | NULL, | |
79 | FALSE, FALSE, TRUE | |
80 | ); | |
81 | $controller->set('context', 'dashboard'); | |
82 | $controller->setEmbedded(TRUE); | |
83 | $controller->process(); | |
84 | $controller->run(); | |
6a488035 TO |
85 | } |
86 | ||
87 | /** | |
dc195289 | 88 | * the main function that is called when the page loads, |
6a488035 TO |
89 | * it decides the which action has to be taken for the page. |
90 | * | |
76e7a76c | 91 | * @return null |
6a488035 | 92 | */ |
00be9182 | 93 | public function run() { |
6a488035 TO |
94 | $this->preProcess(); |
95 | ||
96 | return parent::run(); | |
97 | } | |
96025800 | 98 | |
6a488035 | 99 | } |