-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathcustom.php
848 lines (841 loc) · 43.6 KB
/
custom.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
<?php
/**
* @file custom.php
*
* This file defines the summary fields that will be made available
* on your site. If you want to add your own summary fields, see the
* README.md file for information on how you can use a hook to add your
* own definitions in your own extension.
*
* Defining a summary field requires a specially crafted sql query that
* can be used both in the definition of a SQL trigger and also can be
* used to create a query that initializes the summary fields for your
* existing records.
*
* In addition, the name and trigger table have to be defined, as well as
* details on how the field should be displayed.
*
* Since all summary fields are totaled for a given contact, this extension
* expects the table that triggers a summary field to be calculated to have
* contact_id as one of the fields.
*
* However, if that is not the case (for example, civicrm_line_item does
* not have contact_id, but it does have contribution_id which then
* leads to civicrm_contribution which does have contact_id), you can
* tell sumfields how to calculate the contact_id using the 'tables'
* array of data.
*
**/
/**
* Define a few trigger sql queries first - because they need to be
* referenced first for a total number and a second time for the
* percent.
**/
$event_attended_trigger_sql =
'(SELECT COUNT(e.id) AS summary_value FROM civicrm_participant t1 JOIN civicrm_event e ON
t1.event_id = e.id WHERE t1.contact_id = NEW.contact_id AND t1.status_id IN (%participant_status_ids)
AND e.event_type_id IN (%event_type_ids) AND t1.is_test = 0)';
$event_total_trigger_sql =
'(SELECT COUNT(t1.id) AS summary_value FROM civicrm_participant t1 JOIN civicrm_event e ON
t1.event_id = e.id WHERE contact_id = NEW.contact_id AND e.event_type_id IN (%event_type_ids) AND
t1.is_test = 0)';
$event_total_trigger_sql_null =
'(SELECT COUNT(t1.id) AS summary_value FROM civicrm_participant t1 JOIN civicrm_event e ON
t1.event_id = e.id WHERE e.event_type_id IN (%event_type_ids) AND t1.is_test = 0 GROUP BY contact_id
HAVING contact_id = NEW.contact_id)';
$event_noshow_trigger_sql =
'(SELECT COUNT(e.id) AS summary_value FROM civicrm_participant t1 JOIN civicrm_event e ON
t1.event_id = e.id WHERE t1.contact_id = NEW.contact_id AND t1.status_id IN (%participant_noshow_status_ids)
AND e.event_type_id IN (%event_type_ids) AND t1.is_test = 0)';
$custom = array(
'groups' => array(
'summary_fields' => array(
'name' => 'Summary_Fields',
'title' => ts('Summary Fields', array('domain' => 'net.ourpowerbase.sumfields')),
'extends' => 'Contact',
'style' => 'Tab',
'collapse_display' => '0',
'help_pre' => '',
'help_post' => '',
'weight' => '30',
'is_active' => '1',
'is_multiple' => '0',
'collapse_adv_display' => '0',
'optgroup' => 'fundraising',
),
),
// Any trigger table that does not have contact_id should be listed here, along with
// a sql statement that can be used to calculate the contact_id from a field that is
// in the table. You should also specify the trigger_field - the field in the table
// that will help you determine the contact_id, and also a JOIN statement to use
// when initializing the data.
'tables' => array(
'civicrm_line_item' => array(
'calculated_contact_id' => '(SELECT contact_id FROM civicrm_contribution WHERE id = NEW.contribution_id)',
'trigger_field' => 'contribution_id',
'initialize_join' => 'JOIN civicrm_contribution AS c ON trigger_table.contribution_id = c.id',
),
),
'fields' => array(
'contribution_total_lifetime' => array(
'label' => ts('Total Lifetime Contributions', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '10',
'text_length' => '32',
'trigger_sql' => '(SELECT IF(SUM(line_total) IS NULL, 0, SUM(line_total))
FROM civicrm_contribution t1 JOIN
civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND
t1.contribution_status_id = 1 AND t1.is_test = 0 AND
t2.financial_type_id IN (%financial_type_ids))',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_total_lifetime_simplified' => array(
'label' => ts('Total Lifetime Contributions (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '10',
'text_length' => '32',
'trigger_sql' => '(SELECT IF(SUM(total_amount) IS NULL, 0, SUM(total_amount))
FROM civicrm_contribution t1 WHERE t1.contact_id = NEW.contact_id AND t1.is_test = 0
AND t1.contribution_status_id = 1 AND t1.financial_type_id IN (%financial_type_ids))',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_total_this_year' => array(
'label' => ts('Total Contributions this Fiscal Year', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '15',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(line_total),0)
FROM civicrm_contribution t1
JOIN civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE CAST(receive_date AS DATE) BETWEEN "%current_fiscal_year_begin"
AND "%current_fiscal_year_end" AND t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND
t1.contribution_status_id = 1 AND t2.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_total_this_year_simplified' => array(
'label' => ts('Total Contributions this Fiscal Year (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '15',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(total_amount),0)
FROM civicrm_contribution t1 WHERE CAST(receive_date AS DATE) BETWEEN "%current_fiscal_year_begin"
AND "%current_fiscal_year_end" AND t1.contact_id = NEW.contact_id AND
t1.contribution_status_id = 1 AND t1.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_total_twelve_months' => array(
'label' => ts('Total Contributions in the Last 12 Months', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '20',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(line_total),0)
FROM civicrm_contribution t1
JOIN civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE CAST(receive_date AS DATE) BETWEEN DATE_SUB(NOW(), INTERVAL 12 MONTH) AND NOW()
AND t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND
t1.contribution_status_id = 1 AND t2.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_total_twelve_months_simplified' => array(
'label' => ts('Total Contributions in the Last 12 Months (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '20',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(total_amount),0)
FROM civicrm_contribution t1 WHERE CAST(receive_date AS DATE) BETWEEN DATE_SUB(NOW(), INTERVAL 12 MONTH) AND NOW()
AND t1.contact_id = NEW.contact_id AND
t1.contribution_status_id = 1 AND t1.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_total_deductible_this_year' => array(
'label' => ts('Total Deductible Contributions this Fiscal Year', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '25',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(line_total),0) - COALESCE(SUM(qty * COALESCE(t3.non_deductible_amount, 0)), 0)
FROM civicrm_contribution t1 JOIN civicrm_financial_type t2 ON
t1.financial_type_id = t2.id AND is_deductible = 1
JOIN civicrm_line_item t3 ON t1.id = t3.contribution_id
WHERE CAST(receive_date AS DATE) BETWEEN "%current_fiscal_year_begin" AND
"%current_fiscal_year_end" AND t1.contact_id IN (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND
t1.contribution_status_id = 1 AND t3.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_total_deductible_this_year_simplified' => array(
'label' => ts('Total Deductible Contributions this Fiscal Year (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '25',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(total_amount),0)
FROM civicrm_contribution t1 JOIN civicrm_financial_type t2 ON
t1.financial_type_id = t2.id AND is_deductible = 1
WHERE CAST(receive_date AS DATE) BETWEEN "%current_fiscal_year_begin" AND
"%current_fiscal_year_end" AND t1.contact_id = NEW.contact_id AND
t1.contribution_status_id = 1 AND t1.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_total_last_year' => array(
'label' => ts('Total Contributions last Fiscal Year', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '30',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(line_total),0)
FROM civicrm_contribution t1
JOIN civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE CAST(receive_date AS DATE) BETWEEN "%last_fiscal_year_begin"
AND "%last_fiscal_year_end" AND t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND
t1.contribution_status_id = 1 AND t2.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_total_last_year_simplified' => array(
'label' => ts('Total Contributions last Fiscal Year (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '30',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(total_amount),0)
FROM civicrm_contribution t1 WHERE CAST(receive_date AS DATE) BETWEEN "%last_fiscal_year_begin"
AND "%last_fiscal_year_end" AND t1.contact_id = NEW.contact_id AND
t1.contribution_status_id = 1 AND t1.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_total_deductible_last_year' => array(
'label' => ts('Total Deductible Contributions last Fiscal Year', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '35',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(line_total),0) - COALESCE(SUM(qty * COALESCE(t3.non_deductible_amount, 0)), 0)
FROM civicrm_contribution t1 JOIN civicrm_financial_type t2 ON
t1.financial_type_id = t2.id AND is_deductible = 1
JOIN civicrm_line_item t3 ON t1.id = t3.contribution_id
WHERE CAST(receive_date AS DATE) BETWEEN "%last_fiscal_year_begin" AND
"%last_fiscal_year_end" AND t1.contact_id IN (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND
t1.contribution_status_id = 1 AND t3.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_total_deductible_last_year_simplified' => array(
'label' => ts('Total Deductible Contributions last Fiscal Year (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '35',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(total_amount),0)
FROM civicrm_contribution t1 JOIN civicrm_financial_type t2 ON
t1.financial_type_id = t2.id AND is_deductible = 1
WHERE CAST(receive_date AS DATE) BETWEEN "%last_fiscal_year_begin" AND
"%last_fiscal_year_end" AND t1.contact_id = NEW.contact_id AND
t1.contribution_status_id = 1 AND t1.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_total_year_before_last' => array(
'label' => ts('Total Contributions Fiscal Year Before Last', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '40',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(line_total),0)
FROM civicrm_contribution t1
JOIN civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE CAST(receive_date AS DATE) BETWEEN "%year_before_last_fiscal_year_begin"
AND "%year_before_last_fiscal_year_end" AND t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND
t1.contribution_status_id = 1 AND t2.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_total_year_before_last_simplified' => array(
'label' => ts('Total Contributions Fiscal Year Before Last (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '40',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(total_amount),0)
FROM civicrm_contribution t1 WHERE CAST(receive_date AS DATE) BETWEEN "%year_before_last_fiscal_year_begin"
AND "%year_before_last_fiscal_year_end" AND t1.contact_id = NEW.contact_id AND
t1.contribution_status_id = 1 AND t1.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_total_deductible_year_before_last_year' => array(
'label' => ts('Total Deductible Contributions Fiscal Year Before Last', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '45',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(line_total),0) - COALESCE(SUM(qty * COALESCE(t3.non_deductible_amount, 0)), 0)
FROM civicrm_contribution t1 JOIN civicrm_financial_type t2 ON
t1.financial_type_id = t2.id AND is_deductible = 1
JOIN civicrm_line_item t3 ON t1.id = t3.contribution_id
WHERE CAST(receive_date AS DATE) BETWEEN "%year_before_last_fiscal_year_begin" AND
"%year_before_last_fiscal_year_end" AND t1.contact_id IN (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND
t1.contribution_status_id = 1 AND t3.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_total_deductible_year_before_last_year_simplified' => array(
'label' => ts('Total Deductible Contributions Fiscal Year Before Last (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '45',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(total_amount),0)
FROM civicrm_contribution t1 JOIN civicrm_financial_type t2 ON
t1.financial_type_id = t2.id AND is_deductible = 1
WHERE CAST(receive_date AS DATE) BETWEEN "%year_before_last_fiscal_year_begin" AND
"%year_before_last_fiscal_year_end" AND t1.contact_id = NEW.contact_id AND
t1.contribution_status_id = 1 AND t1.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_count_this_year' => array(
'label' => ts('Count of Contributions this Fiscal Year', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Int',
'html_type' => 'Text',
'weight' => '50',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(COUNT(t1.id),0)
FROM civicrm_contribution t1
JOIN civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE CAST(receive_date AS DATE) BETWEEN "%current_fiscal_year_begin"
AND "%current_fiscal_year_end" AND t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND
t1.contribution_status_id = 1 AND t2.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_count_this_year_simplified' => array(
'label' => ts('Count of Contributions this Fiscal Year (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Int',
'html_type' => 'Text',
'weight' => '50',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(COUNT(t1.id),0)
FROM civicrm_contribution t1 WHERE CAST(receive_date AS DATE) BETWEEN "%current_fiscal_year_begin"
AND "%current_fiscal_year_end" AND t1.contact_id = NEW.contact_id AND
t1.contribution_status_id = 1 AND t1.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_count_last_year' => array(
'label' => ts('Count of Contributions last Fiscal Year', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Int',
'html_type' => 'Text',
'weight' => '55',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(COUNT(t1.id),0)
FROM civicrm_contribution t1
JOIN civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE CAST(receive_date AS DATE) BETWEEN "%last_fiscal_year_begin"
AND "%last_fiscal_year_end" AND t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND
t1.contribution_status_id = 1 AND t2.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_count_last_year_simplified' => array(
'label' => ts('Count of Contributions last Fiscal Year (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Int',
'html_type' => 'Text',
'weight' => '55',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(COUNT(t1.id),0)
FROM civicrm_contribution t1 WHERE CAST(receive_date AS DATE) BETWEEN "%last_fiscal_year_begin"
AND "%last_fiscal_year_end" AND t1.contact_id = NEW.contact_id AND
t1.contribution_status_id = 1 AND t1.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_count_year_before_last' => array(
'label' => ts('Count of Contributions Fiscal Year Before Last', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Int',
'html_type' => 'Text',
'weight' => '60',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(COUNT(t1.id),0)
FROM civicrm_contribution t1
JOIN civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE CAST(receive_date AS DATE) BETWEEN "%year_before_last_fiscal_year_begin"
AND "%year_before_last_fiscal_year_end" AND t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND
t1.contribution_status_id = 1 AND t2.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_count_year_before_last_simplified' => array(
'label' => ts('Count of Contributions Fiscal Year Before Last (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Int',
'html_type' => 'Text',
'weight' => '60',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(COUNT(t1.id),0)
FROM civicrm_contribution t1 WHERE CAST(receive_date AS DATE) BETWEEN "%year_before_last_fiscal_year_begin"
AND "%year_before_last_fiscal_year_end" AND t1.contact_id = NEW.contact_id AND
t1.contribution_status_id = 1 AND t1.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_amount_last' => array(
'label' => ts('Amount of last contribution', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '65',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(total_amount,0)
FROM civicrm_contribution t1
JOIN civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id)
AND t1.contribution_status_id = 1 AND t2.financial_type_id IN
(%financial_type_ids) AND t1.is_test = 0 ORDER BY t1.receive_date DESC LIMIT 1)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_amount_last_simplified' => array(
'label' => ts('Amount of last contribution (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '65',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(total_amount,0)
FROM civicrm_contribution t1 WHERE t1.contact_id = NEW.contact_id
AND t1.contribution_status_id = 1 AND t1.financial_type_id IN
(%financial_type_ids) AND t1.is_test = 0 ORDER BY t1.receive_date DESC LIMIT 1)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_date_last' => array(
'label' => ts('Date of Last Contribution', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Date',
'html_type' => 'Select Date',
'weight' => '70',
'text_length' => '32',
'trigger_sql' => '(SELECT MAX(receive_date) FROM civicrm_contribution t1
JOIN civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND t1.contribution_status_id = 1 AND
t2.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_date_last_simplified' => array(
'label' => ts('Date of Last Contribution (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Date',
'html_type' => 'Select Date',
'weight' => '70',
'text_length' => '32',
'trigger_sql' => '(SELECT MAX(receive_date) FROM civicrm_contribution t1
WHERE t1.contact_id = NEW.contact_id AND t1.contribution_status_id = 1 AND
t1.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_amount_first' => array(
'label' => ts('Amount of first contribution', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '75',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(total_amount,0)
FROM civicrm_contribution t1
JOIN civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id)
AND t1.contribution_status_id = 1 AND t2.financial_type_id IN
(%financial_type_ids) AND t1.is_test = 0 ORDER BY t1.receive_date ASC LIMIT 1)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_amount_first_simplified' => array(
'label' => ts('Amount of first contribution (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '75',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(total_amount,0)
FROM civicrm_contribution t1 WHERE t1.contact_id = NEW.contact_id
AND t1.contribution_status_id = 1 AND t1.financial_type_id IN
(%financial_type_ids) AND t1.is_test = 0 ORDER BY t1.receive_date ASC LIMIT 1)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_date_first' => array(
'label' => ts('Date of First Contribution', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Date',
'html_type' => 'Select Date',
'weight' => '80',
'text_length' => '32',
'trigger_sql' => '(SELECT MIN(receive_date) FROM civicrm_contribution t1
JOIN civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND t1.contribution_status_id = 1 AND
t2.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_date_first_simplified' => array(
'label' => ts('Date of First Contribution (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Date',
'html_type' => 'Select Date',
'weight' => '80',
'text_length' => '32',
'trigger_sql' => '(SELECT MIN(receive_date) FROM civicrm_contribution t1
WHERE t1.contact_id = NEW.contact_id AND t1.contribution_status_id = 1 AND
t1.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_date_largest' => array(
'label' => ts('Date of Largest Contribution', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Date',
'html_type' => 'Select Date',
'weight' => '85',
'text_length' => '32',
'trigger_sql' => '(SELECT receive_date
FROM civicrm_contribution t1
JOIN civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND
t1.contribution_status_id = 1 AND t2.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0
ORDER BY t1.total_amount DESC, t1.receive_date DESC LIMIT 1)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_date_largest_simplified' => array(
'label' => ts('Date of Largest Contribution (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Date',
'html_type' => 'Select Date',
'weight' => '85',
'text_length' => '32',
'trigger_sql' => '(SELECT receive_date
FROM civicrm_contribution t1 WHERE t1.contact_id = NEW.contact_id AND
t1.contribution_status_id = 1 AND t1.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0
ORDER BY total_amount, receive_date DESC LIMIT 1)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_largest' => array(
'label' => ts('Largest Contribution', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '90',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(MAX(total_amount), 0)
FROM civicrm_contribution t1
JOIN civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND
t1.contribution_status_id = 1 AND t2.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_largest_simplified' => array(
'label' => ts('Largest Contribution (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '90',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(MAX(total_amount), 0)
FROM civicrm_contribution t1 WHERE t1.contact_id = NEW.contact_id AND
t1.contribution_status_id = 1 AND t1.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_total_number' => array(
'label' => ts('Count of Contributions', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Int',
'html_type' => 'Text',
'weight' => '95',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(COUNT(DISTINCT t1.id), 0) FROM civicrm_contribution t1
JOIN civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND t1.contribution_status_id = 1 AND
t2.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_total_number_simplified' => array(
'label' => ts('Count of Contributions (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Int',
'html_type' => 'Text',
'weight' => '95',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(COUNT(id), 0) FROM civicrm_contribution t1
WHERE t1.contact_id = NEW.contact_id AND t1.contribution_status_id = 1 AND
t1.financial_type_id IN (%financial_type_ids) AND t1.is_test = 0)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'contribution_average_annual_amount' => array(
'label' => ts('Average Annual (Calendar Year) Contribution', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '100',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(line_total),0) / (SELECT NULLIF(COUNT(DISTINCT SUBSTR(receive_date, 1, 4)), 0)
FROM civicrm_contribution t0
JOIN civicrm_line_item t1 ON t0.id = t1.contribution_id
WHERE t0.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND t1.financial_type_id
IN (%financial_type_ids) AND t0.contribution_status_id = 1 AND is_test = 0) FROM civicrm_contribution t2
JOIN civicrm_line_item t3 ON t2.id = t3.contribution_id
WHERE t2.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND t3.financial_type_id IN (%financial_type_ids)
AND t2.contribution_status_id = 1 AND t2.is_test = 0)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'fundraising',
),
'contribution_average_annual_amount_simplified' => array(
'label' => ts('Average Annual (Calendar Year) Contribution (Simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '100',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(total_amount),0) / (SELECT NULLIF(COUNT(DISTINCT SUBSTR(receive_date, 1, 4)), 0)
FROM civicrm_contribution t0 WHERE t0.contact_id = NEW.contact_id AND t0.financial_type_id
IN (%financial_type_ids) AND t0.contribution_status_id = 1 and t0.is_test = 0) FROM civicrm_contribution t1
WHERE t1.contact_id = NEW.contact_id AND t1.financial_type_id IN (%financial_type_ids)
AND t1.contribution_status_id = 1 AND t1.is_test = 0)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'fundraising',
),
'soft_total_lifetime' => array(
'label' => ts('Total Lifetime Soft Credits', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '200',
'text_length' => '32',
'trigger_sql' => '(SELECT IF(SUM(amount) IS NULL, 0, SUM(amount))
FROM civicrm_contribution_soft t1 WHERE t1.contact_id = NEW.contact_id
AND t1.contribution_id IN (SELECT id FROM civicrm_contribution WHERE contribution_status_id = 1 AND financial_type_id IN (%financial_type_ids) AND is_test = 0))',
'trigger_table' => 'civicrm_contribution_soft',
'optgroup' => 'soft',
),
'soft_total_this_year' => array(
'label' => ts('Total Soft Credits this Fiscal Year', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '210',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(amount),0)
FROM civicrm_contribution_soft t1 WHERE t1.contact_id = NEW.contact_id
AND t1.contribution_id IN (
SELECT id FROM civicrm_contribution WHERE contribution_status_id = 1 AND financial_type_id IN (%financial_type_ids)
AND CAST(receive_date AS DATE) BETWEEN "%current_fiscal_year_begin" AND "%current_fiscal_year_end" AND is_test = 0
))',
'trigger_table' => 'civicrm_contribution_soft',
'optgroup' => 'soft',
),
'soft_total_twelve_months' => array(
'label' => ts('Total Soft Credits in the Last 12 Months', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '215',
'text_length' => '32',
'trigger_sql' => '(SELECT COALESCE(SUM(amount),0)
FROM civicrm_contribution_soft t1 WHERE t1.contact_id = NEW.contact_id
AND t1.contribution_id IN (
SELECT id FROM civicrm_contribution WHERE contribution_status_id = 1 AND financial_type_id IN (%financial_type_ids)
AND CAST(receive_date AS DATE) BETWEEN DATE_SUB(NOW(), INTERVAL 12 MONTH) AND NOW() AND is_test = 0
))',
'trigger_table' => 'civicrm_contribution_soft',
'optgroup' => 'soft',
),
'contribution_date_last_membership_payment' => array(
'label' => ts('Date of Last Membership Payment', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Date',
'html_type' => 'Select Date',
'weight' => '150',
'text_length' => '32',
'trigger_sql' => '(SELECT MAX(receive_date) FROM civicrm_contribution t1
JOIN civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND t1.contribution_status_id = 1 AND
t2.financial_type_id IN (%membership_financial_type_ids) AND is_test = 0 ORDER BY
receive_date DESC LIMIT 1)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'membership',
),
'contribution_date_last_membership_payment_simplified' => array(
'label' => ts('Date of Last Membership Payment (simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Date',
'html_type' => 'Select Date',
'weight' => '155',
'text_length' => '32',
'trigger_sql' => '(SELECT MAX(receive_date) FROM civicrm_contribution t1 WHERE
t1.contact_id = NEW.contact_id AND t1.contribution_status_id = 1 AND
t1.financial_type_id IN (%membership_financial_type_ids) AND t1.is_test = 0 ORDER BY
receive_date DESC LIMIT 1)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'membership',
),
'contribution_amount_last_membership_payment' => array(
'label' => ts('Amount of Last Membership Payment', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '160',
'text_length' => '32',
'trigger_sql' => '(SELECT total_amount FROM civicrm_contribution t1
JOIN civicrm_line_item t2 ON t1.id = t2.contribution_id
WHERE t1.contact_id = (SELECT contact_id FROM civicrm_contribution cc WHERE cc.id = NEW.contribution_id) AND t1.contribution_status_id = 1 AND
t2.financial_type_id IN (%membership_financial_type_ids) AND t1.is_test = 0 ORDER BY
receive_date DESC LIMIT 1)',
'trigger_table' => 'civicrm_line_item',
'optgroup' => 'membership',
),
'contribution_amount_last_membership_payment_simplified' => array(
'label' => ts('Amount of Last Membership Payment (simplified)', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Money',
'html_type' => 'Text',
'weight' => '160',
'text_length' => '32',
'trigger_sql' =>'(SELECT total_amount FROM civicrm_contribution t1 WHERE
t1.contact_id = NEW.contact_id AND t1.contribution_status_id = 1 AND
t1.financial_type_id IN (%membership_financial_type_ids) AND t1.is_test = 0 ORDER BY
receive_date DESC LIMIT 1)',
'trigger_table' => 'civicrm_contribution',
'optgroup' => 'membership',
),
'membership_join_date' => array(
'label' => ts('First membership join date', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Date',
'html_type' => 'Select Date',
'weight' => '170',
'text_length' => '32',
'trigger_sql' =>'(SELECT join_date FROM civicrm_membership t1 WHERE
t1.contact_id = NEW.contact_id AND t1.is_test = 0 ORDER BY
join_date ASC LIMIT 1)',
'trigger_table' => 'civicrm_membership',
'optgroup' => 'membership',
),
'membership_end_date' => array(
'label' => ts('Latest membership end date', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Date',
'html_type' => 'Select Date',
'weight' => '175',
'text_length' => '32',
'trigger_sql' =>'(SELECT end_date FROM civicrm_membership t1 WHERE
t1.contact_id = NEW.contact_id AND t1.is_test = 0 ORDER BY
join_date DESC LIMIT 1)',
'trigger_table' => 'civicrm_membership',
'optgroup' => 'membership',
),
'event_last_attended_name' => array(
'label' => ts('Name of the last attended event', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'String',
'html_type' => 'Text',
'weight' => '200',
'text_length' => '128',
'is_search_range' => '0',
'trigger_sql' => sumfields_multilingual_rewrite('(SELECT civicrm_event.title AS summary_value
FROM civicrm_participant t1 JOIN civicrm_event ON t1.event_id = civicrm_event.id
WHERE t1.contact_id = NEW.contact_id AND t1.status_id IN (%participant_status_ids)
AND civicrm_event.event_type_id IN (%event_type_ids) AND t1.is_test = 0
ORDER BY start_date DESC LIMIT 1)'),
'trigger_table' => 'civicrm_participant',
'optgroup' => 'event_standard',
),
'event_last_attended_date' => array(
'label' => ts('Date of the last attended event', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Date',
'html_type' => 'Select Date',
'weight' => '205',
'text_length' => '32',
'trigger_sql' => '(SELECT e.start_date AS summary_value FROM civicrm_participant t1 JOIN civicrm_event e ON
t1.event_id = e.id WHERE t1.contact_id = NEW.contact_id AND t1.status_id IN (%participant_status_ids)
AND e.event_type_id IN (%event_type_ids) AND t1.is_test = 0 ORDER BY start_date DESC LIMIT 1)',
'trigger_table' => 'civicrm_participant',
'optgroup' => 'event_standard',
),
'event_total' => array(
'label' => ts('Total Number of events', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Int',
'html_type' => 'Text',
'weight' => '210',
'text_length' => '8',
'trigger_sql' => $event_total_trigger_sql,
'trigger_table' => 'civicrm_participant',
'optgroup' => 'event_standard',
),
'event_attended' => array(
'label' => ts('Number of events attended', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Int',
'html_type' => 'Text',
'weight' => '215',
'text_length' => '8',
'trigger_sql' => $event_attended_trigger_sql,
'trigger_table' => 'civicrm_participant',
'optgroup' => 'event_standard',
),
'event_attended_percent_total' => array(
'label' => ts('Events attended as percent of total', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Int',
'html_type' => 'Text',
'weight' => '220',
'text_length' => '8',
// Divide event_attended_total_lifetime / event_total, substituting 0 if either field is NULL. Then, only
// take two decimal places and multiply by 100, so .8000 becomes 80.
'trigger_sql' => '(SELECT FORMAT(IFNULL(' . $event_attended_trigger_sql .
', 0)' . ' / ' . 'IFNULL(' . $event_total_trigger_sql_null . ', 1), 2) * 100 AS summary_value)',
'trigger_table' => 'civicrm_participant',
'optgroup' => 'event_standard',
),
'event_noshow' => array(
'label' => ts('Number of no-show events', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Int',
'html_type' => 'Text',
'weight' => '225',
'text_length' => '8',
'trigger_sql' => $event_noshow_trigger_sql,
'trigger_table' => 'civicrm_participant',
'optgroup' => 'event_standard',
),
'event_noshow_percent_total' => array(
'label' => ts('No-shows as percent of total events', array('domain' => 'net.ourpowerbase.sumfields')),
'data_type' => 'Int',
'html_type' => 'Text',
'weight' => '230',
'text_length' => '8',
'trigger_sql' => '(SELECT FORMAT(IFNULL(' . $event_noshow_trigger_sql .
', 0)' . ' / ' . 'IFNULL(' . $event_total_trigger_sql_null . ', 1), 2) * 100 AS summary_value)',
'trigger_table' => 'civicrm_participant',
'optgroup' => 'event_standard',
),
),
'optgroups' => array(
'fundraising' => array(
'title' => ts('Contribution Fields', array('domain' => 'net.ourpowerbase.sumfields')),
'component' => 'CiviContribute',
'fieldset' => ts('Fundraising', array('domain' => 'net.ourpowerbase.sumfields')),
),
'soft' => array(
'title' => ts('Soft Credit Fields', array('domain' => 'net.ourpowerbase.sumfields')),
'component' => 'CiviContribute',
'fieldset' => ts('Fundraising', array('domain' => 'net.ourpowerbase.sumfields')),
),
'membership' => array(
'title' => ts('Membership Fields', array('domain' => 'net.ourpowerbase.sumfields')),
'component' => 'CiviMember',
'fieldset' => ts('Membership', array('domain' => 'net.ourpowerbase.sumfields')),
),
'event_standard' => array(
'title' => ts('Standard Event Fields', array('domain' => 'net.ourpowerbase.sumfields')),
'component' => 'CiviEvent',
'fieldset' => ts('Events', array('domain' => 'net.ourpowerbase.sumfields')),
),
'event_turnout' => array(
'title' => ts('Event Turnout Fields', array('domain' => 'net.ourpowerbase.sumfields')),
'component' => 'CiviEvent',
'fieldset' => ts('Events', array('domain' => 'net.ourpowerbase.sumfields')),
),
)
);