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 | ||
49 | $userID = $session->get('userID'); | |
50 | ||
51 | //validate access for all cases. | |
52 | if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) { | |
5f1c8c57 | 53 | $allCases = 0; |
6a488035 TO |
54 | CRM_Core_Session::setStatus(ts('You are not authorized to access all cases and activities.'), ts('Sorry'), 'error'); |
55 | } | |
5f1c8c57 | 56 | $this->assign('all', $allCases); |
6a488035 TO |
57 | if (!$allCases) { |
58 | $this->assign('myCases', TRUE); | |
59 | } | |
60 | else { | |
61 | $this->assign('myCases', FALSE); | |
62 | } | |
63 | ||
64 | $this->assign('newClient', FALSE); | |
65 | if (CRM_Core_Permission::check('add contacts') && | |
66 | CRM_Core_Permission::check('access all cases and activities') | |
67 | ) { | |
68 | $this->assign('newClient', TRUE); | |
69 | } | |
5f1c8c57 | 70 | $summary = CRM_Case_BAO_Case::getCasesSummary($allCases); |
be2fb01f CW |
71 | $upcoming = CRM_Case_BAO_Case::getCases($allCases, [], 'dashboard', TRUE); |
72 | $recent = CRM_Case_BAO_Case::getCases($allCases, ['type' => 'recent'], 'dashboard', TRUE); | |
6a488035 TO |
73 | |
74 | $this->assign('casesSummary', $summary); | |
75 | if (!empty($upcoming)) { | |
5f1c8c57 | 76 | $this->assign('upcomingCases', TRUE); |
6a488035 TO |
77 | } |
78 | if (!empty($recent)) { | |
5f1c8c57 | 79 | $this->assign('recentCases', TRUE); |
6a488035 | 80 | } |
5f1c8c57 | 81 | |
82 | $controller = new CRM_Core_Controller_Simple('CRM_Case_Form_Search', | |
83 | ts('Case'), CRM_Core_Action::BROWSE, | |
84 | NULL, | |
85 | FALSE, FALSE, TRUE | |
86 | ); | |
87 | $controller->set('context', 'dashboard'); | |
88 | $controller->setEmbedded(TRUE); | |
89 | $controller->process(); | |
90 | $controller->run(); | |
6a488035 TO |
91 | } |
92 | ||
93 | /** | |
dc195289 | 94 | * the main function that is called when the page loads, |
6a488035 TO |
95 | * it decides the which action has to be taken for the page. |
96 | * | |
76e7a76c | 97 | * @return null |
6a488035 | 98 | */ |
00be9182 | 99 | public function run() { |
6a488035 TO |
100 | $this->preProcess(); |
101 | ||
102 | return parent::run(); | |
103 | } | |
96025800 | 104 | |
6a488035 | 105 | } |