Import from SVN (r45945, r596)
[civicrm-core.git] / CRM / Case / Form / Report.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2013
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 /**
53 * activity set name
54 */
55 public $_activitySetName = NULL;
56
57 public $_report = NULL;
58
59 /**
60 * Function to build the form
61 *
62 * @return None
63 * @access public
64 */ function preProcess() {
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
87 $includeActivites = array(1 => ts('Include All Activities'),
88 2 => ts('Include Missing Activities Only'),
89 );
90 $includeActivitesGroup = $this->addRadio('include_activities',
91 NULL,
92 $includeActivites,
93 NULL,
94 '&nbsp;',
95 TRUE
96 );
97 $includeActivitesGroup->setValue(1);
98
99 $this->add('checkbox',
100 'is_redact',
101 ts('Redact (hide) Client and Service Provider Data')
102 );
103
104 $this->addButtons(array(
105 array(
106 'type' => 'refresh',
107 'name' => ts('Generate Report'),
108 'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
109 'isDefault' => TRUE,
110 ),
111 array(
112 'type' => 'cancel',
113 'name' => ts('Cancel'),
114 ),
115 )
116 );
117 }
118
119 /**
120 * Function to process the form
121 *
122 * @access public
123 *
124 * @return None
125 */
126 public function postProcess() {
127 // store the submitted values in an array
128 $params = $this->controller->exportValues($this->_name);
129
130 $xmlProcessor = new CRM_Case_XMLProcessor_Report();
131 $contents = $xmlProcessor->run($this->_clientID,
132 $this->_caseID,
133 $this->_activitySetName,
134 $params
135 );
136 $this->set('report', $contents);
137 }
138 }
139