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