Merge pull request #23704 from eileenmcnaughton/try
[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 $this->set('totalRowCount', $totalRowCount);
32
33 $invalidRowCount = $this->get('invalidRowCount');
34 $invalidSoftCreditRowCount = $this->get('invalidSoftCreditRowCount');
35 if ($invalidSoftCreditRowCount) {
36 $urlParams = 'type=' . CRM_Contribute_Import_Parser_Contribution::SOFT_CREDIT_ERROR . '&parser=CRM_Contribute_Import_Parser_Contribution';
37 $this->set('downloadSoftCreditErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
38 }
39 $validSoftCreditRowCount = $this->get('validSoftCreditRowCount');
40 $invalidPledgePaymentRowCount = $this->get('invalidPledgePaymentRowCount');
41 if ($invalidPledgePaymentRowCount) {
42 $urlParams = 'type=' . CRM_Contribute_Import_Parser_Contribution::PLEDGE_PAYMENT_ERROR . '&parser=CRM_Contribute_Import_Parser_Contribution';
43 $this->set('downloadPledgePaymentErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
44 }
45 $validPledgePaymentRowCount = $this->get('validPledgePaymentRowCount');
46 $duplicateRowCount = $this->get('duplicateRowCount');
47 $onDuplicate = $this->get('onDuplicate');
48 if ($duplicateRowCount > 0) {
49 $urlParams = 'type=' . CRM_Import_Parser::DUPLICATE . '&parser=CRM_Contribute_Import_Parser_Contribution';
50 $this->set('downloadDuplicateRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
51 }
52 else {
53 $duplicateRowCount = 0;
54 $this->set('duplicateRowCount', $duplicateRowCount);
55 }
56
57 $this->assign('dupeError', FALSE);
58
59 if ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
60 $dupeActionString = ts('These records have been updated with the imported data.');
61 }
62 elseif ($onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) {
63 $dupeActionString = ts('These records have been filled in with the imported data.');
64 }
65 else {
66 /* Skip by default */
67
68 $dupeActionString = ts('These records have not been imported.');
69
70 $this->assign('dupeError', TRUE);
71
72 /* only subtract dupes from successful import if we're skipping */
73
74 $this->set('validRowCount', $totalRowCount - $invalidRowCount -
75 $duplicateRowCount - $invalidSoftCreditRowCount - $invalidPledgePaymentRowCount
76 );
77 }
78 $this->assign('dupeActionString', $dupeActionString);
79
80 $properties = [
81 'totalRowCount',
82 'validRowCount',
83 'invalidRowCount',
84 'validSoftCreditRowCount',
85 'invalidSoftCreditRowCount',
86 'downloadErrorRecordsUrl',
87 'duplicateRowCount',
88 'downloadDuplicateRecordsUrl',
89 'groupAdditions',
90 'validPledgePaymentRowCount',
91 'invalidPledgePaymentRowCount',
92 'downloadPledgePaymentErrorRecordsUrl',
93 'downloadSoftCreditErrorRecordsUrl',
94 ];
95 foreach ($properties as $property) {
96 $this->assign($property, $this->get($property));
97 }
98 }
99
100 }