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 | /** | |
df371444 | 19 | * This class generates form components for case report. |
6a488035 TO |
20 | */ |
21 | class CRM_Case_Form_Report extends CRM_Core_Form { | |
22 | ||
23 | /** | |
24 | * Case Id | |
f157740d | 25 | * @var int |
6a488035 TO |
26 | */ |
27 | public $_caseID = NULL; | |
28 | ||
29 | /** | |
30 | * Client Id | |
f157740d | 31 | * @var int |
6a488035 TO |
32 | */ |
33 | public $_clientID = NULL; | |
34 | ||
35 | /** | |
100fef9d | 36 | * Activity set name |
f157740d | 37 | * @var string |
6a488035 TO |
38 | */ |
39 | public $_activitySetName = NULL; | |
40 | ||
41 | public $_report = NULL; | |
42 | ||
43 | /** | |
fe482240 | 44 | * Build the form object. |
95ea96be | 45 | */ |
e7483cbe | 46 | public function preProcess() { |
6a488035 TO |
47 | $this->_caseID = CRM_Utils_Request::retrieve('caseid', 'Integer', $this, TRUE); |
48 | $this->_clientID = CRM_Utils_Request::retrieve('cid', 'Integer', $this, TRUE); | |
49 | $this->_activitySetName = CRM_Utils_Request::retrieve('asn', 'String', $this, TRUE); | |
50 | ||
51 | $this->_report = $this->get('report'); | |
52 | if ($this->_report) { | |
53 | $this->assign_by_ref('report', $this->_report); | |
54 | } | |
55 | ||
56 | // user context | |
57 | $url = CRM_Utils_System::url('civicrm/contact/view/case', | |
58 | "reset=1&action=view&cid={$this->_clientID}&id={$this->_caseID}&show=1" | |
59 | ); | |
60 | $session = CRM_Core_Session::singleton(); | |
61 | $session->pushUserContext($url); | |
62 | } | |
63 | ||
64 | public function buildQuickForm() { | |
65 | if ($this->_report) { | |
66 | return; | |
67 | } | |
68 | ||
be2fb01f | 69 | $includeActivites = [ |
353ffa53 | 70 | 1 => ts('All Activities'), |
f7737fc0 | 71 | 2 => ts('Exclude Completed Activities'), |
be2fb01f | 72 | ]; |
6a488035 TO |
73 | $includeActivitesGroup = $this->addRadio('include_activities', |
74 | NULL, | |
75 | $includeActivites, | |
76 | NULL, | |
77 | ' ', | |
78 | TRUE | |
79 | ); | |
80 | $includeActivitesGroup->setValue(1); | |
81 | ||
82 | $this->add('checkbox', | |
83 | 'is_redact', | |
84 | ts('Redact (hide) Client and Service Provider Data') | |
85 | ); | |
86 | ||
be2fb01f | 87 | $this->addButtons([ |
f157740d SL |
88 | [ |
89 | 'type' => 'refresh', | |
90 | 'name' => ts('Generate Report'), | |
91 | 'isDefault' => TRUE, | |
92 | ], | |
93 | [ | |
94 | 'type' => 'cancel', | |
95 | 'name' => ts('Cancel'), | |
96 | ], | |
97 | ]); | |
2a06342c CW |
98 | // We want this form to redirect to a full page |
99 | $this->preventAjaxSubmit(); | |
6a488035 TO |
100 | } |
101 | ||
102 | /** | |
fe482240 | 103 | * Process the form submission. |
6a488035 TO |
104 | */ |
105 | public function postProcess() { | |
106 | // store the submitted values in an array | |
107 | $params = $this->controller->exportValues($this->_name); | |
108 | ||
a9410a63 | 109 | // this is either a 1 or a 2, but the url expects a 1 or 0 |
110 | $all = ($params['include_activities'] == 1) ? 1 : 0; | |
111 | ||
112 | // similar but comes from a checkbox that's either 1 or not present | |
113 | $is_redact = empty($params['is_redact']) ? 0 : 1; | |
114 | ||
115 | $asn = rawurlencode($this->_activitySetName); | |
116 | ||
117 | CRM_Utils_System::redirect( | |
118 | CRM_Utils_System::url( | |
119 | 'civicrm/case/report/print', | |
120 | "caseID={$this->_caseID}&cid={$this->_clientID}&asn={$asn}&redact={$is_redact}&all={$all}" | |
121 | ) | |
6a488035 | 122 | ); |
6a488035 | 123 | } |
96025800 | 124 | |
6a488035 | 125 | } |