Add function Core_Component::isEnabled
[civicrm-core.git] / CRM / Contribute / Import / Form / Summary.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17
18 /**
19 * This class summarizes the import results.
20 */
21 class CRM_Contribute_Import_Form_Summary extends CRM_Import_Form_Summary {
22
23 /**
24 * Set variables up before form is built.
25 */
26 public function preProcess() {
27 // set the error message path to display
28 $this->assign('errorFile', $this->get('errorFile'));
29
30 $totalRowCount = $this->get('totalRowCount');
31 $relatedCount = $this->get('relatedCount');
32 $totalRowCount += $relatedCount;
33 $this->set('totalRowCount', $totalRowCount);
34
35 $invalidRowCount = $this->get('invalidRowCount');
36 $invalidSoftCreditRowCount = $this->get('invalidSoftCreditRowCount');
37 if ($invalidSoftCreditRowCount) {
38 $urlParams = 'type=' . CRM_Contribute_Import_Parser::SOFT_CREDIT_ERROR . '&parser=CRM_Contribute_Import_Parser';
39 $this->set('downloadSoftCreditErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
40 }
41 $validSoftCreditRowCount = $this->get('validSoftCreditRowCount');
42 $invalidPledgePaymentRowCount = $this->get('invalidPledgePaymentRowCount');
43 if ($invalidPledgePaymentRowCount) {
44 $urlParams = 'type=' . CRM_Contribute_Import_Parser::PLEDGE_PAYMENT_ERROR . '&parser=CRM_Contribute_Import_Parser';
45 $this->set('downloadPledgePaymentErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
46 }
47 $validPledgePaymentRowCount = $this->get('validPledgePaymentRowCount');
48 $conflictRowCount = $this->get('conflictRowCount');
49 $duplicateRowCount = $this->get('duplicateRowCount');
50 $onDuplicate = $this->get('onDuplicate');
51 $mismatchCount = $this->get('unMatchCount');
52 if ($duplicateRowCount > 0) {
53 $urlParams = 'type=' . CRM_Import_Parser::DUPLICATE . '&parser=CRM_Contribute_Import_Parser';
54 $this->set('downloadDuplicateRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
55 }
56 elseif ($mismatchCount) {
57 $urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contribute_Import_Parser';
58 $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
59 }
60 else {
61 $duplicateRowCount = 0;
62 $this->set('duplicateRowCount', $duplicateRowCount);
63 }
64
65 $this->assign('dupeError', FALSE);
66
67 if ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
68 $dupeActionString = ts('These records have been updated with the imported data.');
69 }
70 elseif ($onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) {
71 $dupeActionString = ts('These records have been filled in with the imported data.');
72 }
73 else {
74 /* Skip by default */
75
76 $dupeActionString = ts('These records have not been imported.');
77
78 $this->assign('dupeError', TRUE);
79
80 /* only subtract dupes from successful import if we're skipping */
81
82 $this->set('validRowCount', $totalRowCount - $invalidRowCount -
83 $conflictRowCount - $duplicateRowCount - $mismatchCount - $invalidSoftCreditRowCount - $invalidPledgePaymentRowCount
84 );
85 }
86 $this->assign('dupeActionString', $dupeActionString);
87
88 $properties = [
89 'totalRowCount',
90 'validRowCount',
91 'invalidRowCount',
92 'validSoftCreditRowCount',
93 'invalidSoftCreditRowCount',
94 'conflictRowCount',
95 'downloadConflictRecordsUrl',
96 'downloadErrorRecordsUrl',
97 'duplicateRowCount',
98 'downloadDuplicateRecordsUrl',
99 'downloadMismatchRecordsUrl',
100 'groupAdditions',
101 'unMatchCount',
102 'validPledgePaymentRowCount',
103 'invalidPledgePaymentRowCount',
104 'downloadPledgePaymentErrorRecordsUrl',
105 'downloadSoftCreditErrorRecordsUrl',
106 ];
107 foreach ($properties as $property) {
108 $this->assign($property, $this->get($property));
109 }
110 }
111
112 }