Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
f299f7db | 6 | | Copyright CiviCRM LLC (c) 2004-2020 | |
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 | |
f299f7db | 31 | * @copyright CiviCRM LLC (c) 2004-2020 |
6a488035 TO |
32 | */ |
33 | ||
34 | /** | |
df371444 | 35 | * This class generates form components for case report. |
6a488035 TO |
36 | */ |
37 | class CRM_Case_Form_Report extends CRM_Core_Form { | |
38 | ||
39 | /** | |
40 | * Case Id | |
f157740d | 41 | * @var int |
6a488035 TO |
42 | */ |
43 | public $_caseID = NULL; | |
44 | ||
45 | /** | |
46 | * Client Id | |
f157740d | 47 | * @var int |
6a488035 TO |
48 | */ |
49 | public $_clientID = NULL; | |
50 | ||
51 | /** | |
100fef9d | 52 | * Activity set name |
f157740d | 53 | * @var string |
6a488035 TO |
54 | */ |
55 | public $_activitySetName = NULL; | |
56 | ||
57 | public $_report = NULL; | |
58 | ||
59 | /** | |
fe482240 | 60 | * Build the form object. |
95ea96be | 61 | */ |
e7483cbe | 62 | public function preProcess() { |
6a488035 TO |
63 | $this->_caseID = CRM_Utils_Request::retrieve('caseid', 'Integer', $this, TRUE); |
64 | $this->_clientID = CRM_Utils_Request::retrieve('cid', 'Integer', $this, TRUE); | |
65 | $this->_activitySetName = CRM_Utils_Request::retrieve('asn', 'String', $this, TRUE); | |
66 | ||
67 | $this->_report = $this->get('report'); | |
68 | if ($this->_report) { | |
69 | $this->assign_by_ref('report', $this->_report); | |
70 | } | |
71 | ||
72 | // user context | |
73 | $url = CRM_Utils_System::url('civicrm/contact/view/case', | |
74 | "reset=1&action=view&cid={$this->_clientID}&id={$this->_caseID}&show=1" | |
75 | ); | |
76 | $session = CRM_Core_Session::singleton(); | |
77 | $session->pushUserContext($url); | |
78 | } | |
79 | ||
80 | public function buildQuickForm() { | |
81 | if ($this->_report) { | |
82 | return; | |
83 | } | |
84 | ||
be2fb01f | 85 | $includeActivites = [ |
353ffa53 | 86 | 1 => ts('All Activities'), |
f7737fc0 | 87 | 2 => ts('Exclude Completed Activities'), |
be2fb01f | 88 | ]; |
6a488035 TO |
89 | $includeActivitesGroup = $this->addRadio('include_activities', |
90 | NULL, | |
91 | $includeActivites, | |
92 | NULL, | |
93 | ' ', | |
94 | TRUE | |
95 | ); | |
96 | $includeActivitesGroup->setValue(1); | |
97 | ||
98 | $this->add('checkbox', | |
99 | 'is_redact', | |
100 | ts('Redact (hide) Client and Service Provider Data') | |
101 | ); | |
102 | ||
be2fb01f | 103 | $this->addButtons([ |
f157740d SL |
104 | [ |
105 | 'type' => 'refresh', | |
106 | 'name' => ts('Generate Report'), | |
107 | 'isDefault' => TRUE, | |
108 | ], | |
109 | [ | |
110 | 'type' => 'cancel', | |
111 | 'name' => ts('Cancel'), | |
112 | ], | |
113 | ]); | |
2a06342c CW |
114 | // We want this form to redirect to a full page |
115 | $this->preventAjaxSubmit(); | |
6a488035 TO |
116 | } |
117 | ||
118 | /** | |
fe482240 | 119 | * Process the form submission. |
6a488035 TO |
120 | */ |
121 | public function postProcess() { | |
122 | // store the submitted values in an array | |
123 | $params = $this->controller->exportValues($this->_name); | |
124 | ||
125 | $xmlProcessor = new CRM_Case_XMLProcessor_Report(); | |
126 | $contents = $xmlProcessor->run($this->_clientID, | |
127 | $this->_caseID, | |
128 | $this->_activitySetName, | |
129 | $params | |
130 | ); | |
131 | $this->set('report', $contents); | |
132 | } | |
96025800 | 133 | |
6a488035 | 134 | } |