3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2019
33 class CRM_Report_Form_Grant_Detail
extends CRM_Report_Form
{
35 protected $_customGroupExtends = [
46 public function __construct() {
47 $contactCols = $this->getColumns('Contact', [
48 'order_bys_defaults' => ['sort_name' => 'ASC '],
49 'fields_defaults' => ['sort_name'],
50 'fields_excluded' => ['id'],
51 'fields_required' => ['id'],
52 'filters_defaults' => ['is_deleted' => 0],
53 'no_field_disambiguation' => TRUE,
57 'dao' => 'CRM_Core_DAO_Email',
60 'title' => ts('Email'),
63 'grouping' => 'contact-fields',
66 'dao' => 'CRM_Core_DAO_Phone',
69 'title' => ts('Phone'),
72 'grouping' => 'contact-fields',
75 'dao' => 'CRM_Grant_DAO_Grant',
78 'name' => 'grant_type_id',
79 'title' => ts('Grant Type'),
82 'name' => 'status_id',
83 'title' => ts('Grant Status'),
86 'name' => 'amount_total',
87 'title' => ts('Amount Requested'),
88 'type' => CRM_Utils_Type
::T_MONEY
,
91 'name' => 'amount_granted',
92 'title' => ts('Amount Granted'),
94 'application_received_date' => [
95 'name' => 'application_received_date',
96 'title' => ts('Application Received'),
98 'type' => CRM_Utils_Type
::T_DATE
,
100 'money_transfer_date' => [
101 'name' => 'money_transfer_date',
102 'title' => ts('Money Transfer Date'),
103 'type' => CRM_Utils_Type
::T_DATE
,
105 'grant_due_date' => [
106 'name' => 'grant_due_date',
107 'title' => ts('Grant Report Due'),
108 'type' => CRM_Utils_Type
::T_DATE
,
111 'name' => 'decision_date',
112 'title' => ts('Grant Decision Date'),
113 'type' => CRM_Utils_Type
::T_DATE
,
116 'name' => 'rationale',
117 'title' => ts('Rationale'),
119 'grant_report_received' => [
120 'name' => 'grant_report_received',
121 'title' => ts('Grant Report Received'),
126 'name' => 'grant_type_id',
127 'title' => ts('Grant Type'),
128 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
129 'options' => CRM_Core_PseudoConstant
::get('CRM_Grant_DAO_Grant', 'grant_type_id'),
132 'name' => 'status_id',
133 'title' => ts('Grant Status'),
134 'type' => CRM_Utils_Type
::T_INT
,
135 'operatorType' => CRM_Report_Form
::OP_MULTISELECT
,
136 'options' => CRM_Core_PseudoConstant
::get('CRM_Grant_DAO_Grant', 'status_id'),
138 'amount_granted' => [
139 'title' => ts('Amount Granted'),
140 'operatorType' => CRM_Report_Form
::OP_INT
,
143 'title' => ts('Amount Requested'),
144 'operatorType' => CRM_Report_Form
::OP_INT
,
146 'application_received_date' => [
147 'title' => ts('Application Received'),
148 'operatorType' => CRM_Report_Form
::OP_DATE
,
149 'type' => CRM_Utils_Type
::T_DATE
,
151 'money_transfer_date' => [
152 'title' => ts('Money Transfer Date'),
153 'operatorType' => CRM_Report_Form
::OP_DATE
,
154 'type' => CRM_Utils_Type
::T_DATE
,
156 'grant_due_date' => [
157 'title' => ts('Grant Report Due'),
158 'operatorType' => CRM_Report_Form
::OP_DATE
,
159 'type' => CRM_Utils_Type
::T_DATE
,
162 'title' => ts('Grant Decision Date'),
163 'operatorType' => CRM_Report_Form
::OP_DATE
,
164 'type' => CRM_Utils_Type
::T_DATE
,
169 'title' => ts('Grant Type'),
172 'title' => ts('Grant Status'),
174 'application_received_date' => [
175 'title' => ts('Application Received Date'),
177 'money_transfer_date' => [
178 'title' => ts('Money Transfer Date'),
181 'title' => ts('Grant Decision Date'),
186 'title' => ts('Grant Type'),
189 'title' => ts('Grant Status'),
192 'title' => ts('Amount Requested'),
194 'amount_granted' => [
195 'title' => ts('Amount Granted'),
197 'application_received_date' => [
198 'title' => ts('Application Received Date'),
200 'money_transfer_date' => [
201 'title' => ts('Money Transfer Date'),
204 'title' => ts('Grant Decision Date'),
210 $this->_columns
= array_merge($contactCols, $specificCols, $this->addAddressFields(FALSE));
212 parent
::__construct();
215 public function from() {
216 $this->setFromBase('civicrm_contact');
217 $this->_from
.= <<<HERESQL
218 INNER JOIN civicrm_grant {$this->_aliases['civicrm_grant']}
219 ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_grant']}.contact_id
222 $this->joinEmailFromContact();
223 $this->joinPhoneFromContact();
224 $this->joinAddressFromContact();
228 * Alter display of rows.
230 * Iterate through the rows retrieved via SQL and make changes for display purposes,
231 * such as rendering contacts as links.
234 * Rows generated by SQL, with an array for each row.
236 public function alterDisplay(&$rows) {
238 foreach ($rows as $rowNum => $row) {
239 // convert display name to links
240 if (array_key_exists('civicrm_contact_sort_name', $row) &&
241 array_key_exists('civicrm_contact_id', $row)
243 $url = CRM_Utils_System
::url('civicrm/contact/view',
244 'reset=1&cid=' . $row['civicrm_contact_id'],
247 $rows[$rowNum]['civicrm_contact_sort_name_link'] = $url;
248 $rows[$rowNum]['civicrm_contact_sort_name_hover'] = ts("View Contact Summary for this Contact.");
252 if (array_key_exists('civicrm_grant_grant_type_id', $row)) {
253 if ($value = $row['civicrm_grant_grant_type_id']) {
254 $rows[$rowNum]['civicrm_grant_grant_type_id'] = CRM_Core_PseudoConstant
::getLabel('CRM_Grant_DAO_Grant', 'grant_type_id', $value);
258 if (array_key_exists('civicrm_grant_status_id', $row)) {
259 if ($value = $row['civicrm_grant_status_id']) {
260 $rows[$rowNum]['civicrm_grant_status_id'] = CRM_Core_PseudoConstant
::getLabel('CRM_Grant_DAO_Grant', 'status_id', $value);