3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | This file is a part of CiviCRM. |
8 | CiviCRM is free software; you can copy, modify, and distribute it |
9 | under the terms of the GNU Affero General Public License |
10 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | CiviCRM is distributed in the hope that it will be useful, but |
13 | WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
15 | See the GNU Affero General Public License for more details. |
17 | You should have received a copy of the GNU Affero General Public |
18 | License and the CiviCRM Licensing Exception along |
19 | with this program; if not, contact CiviCRM LLC |
20 | at info[AT]civicrm[DOT]org. If you have questions about the |
21 | GNU Affero General Public License or the licensing of CiviCRM, |
22 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
23 +--------------------------------------------------------------------+
27 * Build the $data array for CiviCampaign related tables
28 * Includes the following tables
31 require_once 'CRM/Campaign/PseudoConstant.php';
32 function _civicrm_campaign_data(&$data, $enabled) {
35 *CiviCRM Campaign Base Table
38 $data['civicrm_campaign']['table']['group'] = t('CiviCRM Campaigns');
40 $data['civicrm_campaign']['table']['base'] = array(
41 // Governs the whole mozilla
43 'title' => t('CiviCRM Campaigns'),
44 'help' => t("View displays CiviCRM Campaigns Data"),
47 $data['civicrm_campaign']['id'] = array(
48 'title' => t('Campaign ID'),
49 'help' => t('The numeric ID of the campaign'),
51 'handler' => 'views_handler_field_numeric',
52 'click sortable' => TRUE,
55 'handler' => 'views_handler_argument_numeric',
59 'handler' => 'views_handler_filter_numeric',
60 'allow empty' => TRUE,
63 'handler' => 'views_handler_sort',
67 $data['civicrm_campaign']['name'] = array(
69 'help' => t('Campaign\'s name'),
71 'handler' => 'views_handler_field',
72 'click sortable' => TRUE,
75 'handler' => 'views_handler_argument_string',
78 'handler' => 'views_handler_filter_string',
81 'handler' => 'views_handler_sort',
86 $data['civicrm_campaign']['title'] = array(
87 'title' => t('Title'),
88 'help' => t('Campaing\'s title'),
90 'handler' => 'views_handler_field',
91 'click sortable' => TRUE,
94 'handler' => 'views_handler_argument_string',
97 'handler' => 'views_handler_filter_string',
98 'allow empty' => TRUE,
101 'handler' => 'views_handler_sort',
104 //Campaign Description
105 $data['civicrm_campaign']['description'] = array(
106 'title' => t('Description'),
107 'help' => t('Campaing\'s description'),
109 'handler' => 'views_handler_field',
110 'click sortable' => TRUE,
113 //Mailing finish date
114 $data['civicrm_campaign']['start_date'] = array(
115 'title' => t('Start Date'),
116 'help' => t('The Campaign\'s Start Date'),
118 'handler' => 'civicrm_handler_field_datetime',
119 'click sortable' => TRUE,
122 'handler' => 'views_handler_argument_date',
125 'handler' => 'civicrm_handler_filter_datetime',
129 'handler' => 'civicrm_handler_sort_date',
133 civicrm_views_add_date_arguments($data['civicrm_campaign'], array(
134 'title' => 'Campaign Start Date',
135 'name' => 'start_date',
138 //Mailing finish date
139 $data['civicrm_campaign']['end_date'] = array(
140 'title' => t('End Date'),
141 'help' => t('The Campaign\'s End Date'),
143 'handler' => 'civicrm_handler_field_datetime',
144 'click sortable' => TRUE,
147 'handler' => 'views_handler_argument_date',
150 'handler' => 'civicrm_handler_filter_datetime',
154 'handler' => 'civicrm_handler_sort_date',
158 civicrm_views_add_date_arguments($data['civicrm_campaign'], array(
159 'title' => 'Campaign End Date',
160 'name' => 'end_date',
164 $data['civicrm_campaign']['campaign_type'] = array(
165 'title' => t('Campaign Type'),
166 'real field' => 'campaign_type_id',
167 'help' => t('The Type of Campaign, ie Direct Mail, Constituent Engagement etc'),
169 'handler' => 'civicrm_handler_field_pseudo_constant',
170 'click sortable' => TRUE,
171 'pseudo class' => 'CRM_Campaign_PseudoConstant',
172 'pseudo method' => 'campaignType',
175 'handler' => 'views_handler_argument',
178 'handler' => 'civicrm_handler_filter_pseudo_constant',
179 'allow empty' => TRUE,
180 'pseudo class' => 'CRM_Campaign_PseudoConstant',
181 'pseudo method' => 'campaignType',
184 'handler' => 'views_handler_sort',
188 $data['civicrm_campaign']['campaign_status'] = array(
189 'title' => t('Campaign Status'),
190 'real field' => 'status_id',
191 'help' => t('The Status of the Campaign, ie Completed, Cancelled etc'),
193 'handler' => 'civicrm_handler_field_pseudo_constant',
194 'click sortable' => TRUE,
195 'pseudo class' => 'CRM_Campaign_PseudoConstant',
196 'pseudo method' => 'campaignStatus',
199 'handler' => 'views_handler_argument',
202 'handler' => 'civicrm_handler_filter_pseudo_constant',
203 'allow empty' => TRUE,
204 'pseudo class' => 'CRM_Campaign_PseudoConstant',
205 'pseudo method' => 'campaignStatus',
208 'handler' => 'views_handler_sort',
211 // Parent Campaign ID
212 $data['civicrm_campaign']['parent_id'] = array(
213 'title' => t('Parent Campaign ID'),
214 'help' => t('The ID of the campaign\'s parent campaign'),
216 'handler' => 'views_handler_field_numeric',
217 'click sortable' => TRUE,
220 'handler' => 'views_handler_argument_numeric',
224 'handler' => 'views_handler_filter_numeric',
225 'allow empty' => TRUE,
228 'handler' => 'views_handler_sort',
231 //BOOLEAN : IS Active
232 $data['civicrm_campaign']['is_active'] = array(
233 'title' => t('Is Active'),
234 'help' => t('Is the campaign active ?'),
236 'handler' => 'views_handler_field_boolean',
237 'click sortable' => TRUE,
240 'handler' => 'views_handler_argument',
243 'handler' => 'views_handler_filter_boolean_operator',
246 'handler' => 'views_handler_sort',
249 // Campaign's General Goal
250 $data['civicrm_campaign']['goal_general'] = array(
251 'title' => t('General Goal'),
252 'help' => t('Campaing\'s general goal'),
254 'handler' => 'views_handler_field',
255 'click sortable' => TRUE,
258 'handler' => 'views_handler_argument_string',
261 'handler' => 'views_handler_filter_string',
262 'allow empty' => TRUE,
265 'handler' => 'views_handler_sort',
269 $data['civicrm_campaign']['goal_revenue'] = array(
270 'title' => t('Campaign Monetary Goal'),
271 'help' => t('The Monetary goal of the campaign'),
273 'handler' => 'civicrm_handler_field_money',
274 'click sortable' => TRUE,
277 'handler' => 'views_handler_argument_numeric',
281 'handler' => 'views_handler_filter_numeric',
282 'allow empty' => TRUE,
285 'handler' => 'views_handler_sort',
289 // Add Support of Survey Fields.
290 $data['civicrm_survey']['table']['group'] = t('CiviCRM Surveys');
293 $data['civicrm_survey']['table']['base'] = array(
294 // Governs the whole mozilla
296 'title' => t('CiviCRM Surveys'),
297 'help' => t("View displays CiviCRM Survey Data"),
299 // Link to activites table for Results
300 $data['civicrm_activity']['table']['join']['civicrm_survey'] = array(
301 // Directly links to tag table
302 'left_field' => 'id',
303 'field' => 'source_record_id',
306 'field' => 'activity_type_id',
307 'value' => CRM_Campaign_PseudoConstant::activityType('value'),
313 $data['civicrm_survey']['id'] = array(
314 'title' => t('Survey ID'),
315 'help' => t('The numeric ID of the survey'),
317 'handler' => 'views_handler_field_numeric',
318 'click sortable' => TRUE,
321 'handler' => 'views_handler_argument_numeric',
325 'handler' => 'views_handler_filter_numeric',
326 'allow empty' => TRUE,
329 'handler' => 'views_handler_sort',
333 $data['civicrm_survey']['campaign_id'] = array(
334 'title' => t('Campaign'),
335 'help' => t('Event -> Campaign'),
336 'relationship' => array(
337 'base' => 'civicrm_campaign',
339 'handler' => 'views_handler_relationship',
340 'label' => t('Survey -> Campaign'),
347 $data['civicrm_survey']['activity_type'] = array(
348 'title' => t('Activity Type'),
349 'real field' => 'activity_type_id',
350 'help' => t('The Type of activity, ie Survey, Canvass, Phone Bank etc'),
352 'handler' => 'civicrm_handler_field_pseudo_constant',
353 'click sortable' => TRUE,
354 'pseudo class' => 'CRM_Campaign_PseudoConstant',
355 'pseudo method' => 'activityType',
358 'handler' => 'views_handler_argument',
361 'handler' => 'civicrm_handler_filter_pseudo_constant',
362 'allow empty' => TRUE,
363 'pseudo class' => 'CRM_Campaign_PseudoConstant',
364 'pseudo method' => 'activityType',
367 'handler' => 'views_handler_sort',
370 //BOOLEAN : IS Active
371 $data['civicrm_survey']['is_active'] = array(
372 'title' => t('Is Active'),
373 'help' => t('Is the survey active?'),
375 'handler' => 'views_handler_field_boolean',
376 'click sortable' => TRUE,
379 'handler' => 'views_handler_argument',
382 'handler' => 'views_handler_filter_boolean_operator',
385 'handler' => 'views_handler_sort',
388 //BOOLEAN : IS Default
389 $data['civicrm_survey']['is_default'] = array(
390 'title' => t('Is Default'),
391 'help' => t('Is the survey the default?'),
393 'handler' => 'views_handler_field_boolean',
394 'click sortable' => TRUE,
397 'handler' => 'views_handler_argument',
400 'handler' => 'views_handler_filter_boolean_operator',
403 'handler' => 'views_handler_sort',
406 require_once 'CRM/Campaign/DAO/Survey.php';
407 $fields = CRM_Campaign_DAO_Survey::fields();
408 //$skipFields = array( );
409 civicrm_views_add_fields($fields, $data['civicrm_survey'], 'civicrm_survey');