Merge pull request #12001 from jitendrapurohit/core-64
[civicrm-core.git] / CRM / Contribute / Import / Form / Summary.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
fee14197 4 | CiviCRM version 5 |
6a488035 5 +--------------------------------------------------------------------+
8c9251b3 6 | Copyright CiviCRM LLC (c) 2004-2018 |
6a488035
TO
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
d25dd0ee 26 */
6a488035
TO
27
28/**
29 *
30 * @package CRM
8c9251b3 31 * @copyright CiviCRM LLC (c) 2004-2018
6a488035
TO
32 */
33
34/**
347e061b 35 * This class summarizes the import results.
6a488035 36 */
52892e8b 37class CRM_Contribute_Import_Form_Summary extends CRM_Import_Form_Summary {
6a488035
TO
38
39 /**
fe482240 40 * Set variables up before form is built.
6a488035
TO
41 */
42 public function preProcess() {
43 // set the error message path to display
81c3812a 44 $this->assign('errorFile', $this->get('errorFile'));
6a488035
TO
45
46 $totalRowCount = $this->get('totalRowCount');
47 $relatedCount = $this->get('relatedCount');
48 $totalRowCount += $relatedCount;
49 $this->set('totalRowCount', $totalRowCount);
50
51 $invalidRowCount = $this->get('invalidRowCount');
52 $invalidSoftCreditRowCount = $this->get('invalidSoftCreditRowCount');
53 if ($invalidSoftCreditRowCount) {
54 $urlParams = 'type=' . CRM_Contribute_Import_Parser::SOFT_CREDIT_ERROR . '&parser=CRM_Contribute_Import_Parser';
55 $this->set('downloadSoftCreditErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
56 }
57 $validSoftCreditRowCount = $this->get('validSoftCreditRowCount');
58 $invalidPledgePaymentRowCount = $this->get('invalidPledgePaymentRowCount');
59 if ($invalidPledgePaymentRowCount) {
60 $urlParams = 'type=' . CRM_Contribute_Import_Parser::PLEDGE_PAYMENT_ERROR . '&parser=CRM_Contribute_Import_Parser';
61 $this->set('downloadPledgePaymentErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
62 }
63 $validPledgePaymentRowCount = $this->get('validPledgePaymentRowCount');
64 $conflictRowCount = $this->get('conflictRowCount');
65 $duplicateRowCount = $this->get('duplicateRowCount');
66 $onDuplicate = $this->get('onDuplicate');
67 $mismatchCount = $this->get('unMatchCount');
68 if ($duplicateRowCount > 0) {
a05662ef 69 $urlParams = 'type=' . CRM_Import_Parser::DUPLICATE . '&parser=CRM_Contribute_Import_Parser';
6a488035
TO
70 $this->set('downloadDuplicateRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
71 }
72 elseif ($mismatchCount) {
a05662ef 73 $urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contribute_Import_Parser';
6a488035
TO
74 $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
75 }
76 else {
77 $duplicateRowCount = 0;
78 $this->set('duplicateRowCount', $duplicateRowCount);
79 }
80
81 $this->assign('dupeError', FALSE);
82
a05662ef 83 if ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
6a488035
TO
84 $dupeActionString = ts('These records have been updated with the imported data.');
85 }
a05662ef 86 elseif ($onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) {
6a488035
TO
87 $dupeActionString = ts('These records have been filled in with the imported data.');
88 }
89 else {
90 /* Skip by default */
91
92 $dupeActionString = ts('These records have not been imported.');
93
94 $this->assign('dupeError', TRUE);
95
719a6fec 96 /* only subtract dupes from successful import if we're skipping */
6a488035
TO
97
98 $this->set('validRowCount', $totalRowCount - $invalidRowCount -
99 $conflictRowCount - $duplicateRowCount - $mismatchCount - $invalidSoftCreditRowCount - $invalidPledgePaymentRowCount
100 );
101 }
102 $this->assign('dupeActionString', $dupeActionString);
103
353ffa53
TO
104 $properties = array(
105 'totalRowCount',
106 'validRowCount',
107 'invalidRowCount',
108 'validSoftCreditRowCount',
109 'invalidSoftCreditRowCount',
110 'conflictRowCount',
111 'downloadConflictRecordsUrl',
112 'downloadErrorRecordsUrl',
113 'duplicateRowCount',
114 'downloadDuplicateRecordsUrl',
115 'downloadMismatchRecordsUrl',
116 'groupAdditions',
117 'unMatchCount',
118 'validPledgePaymentRowCount',
119 'invalidPledgePaymentRowCount',
120 'downloadPledgePaymentErrorRecordsUrl',
87a890cc 121 'downloadSoftCreditErrorRecordsUrl',
353ffa53 122 );
6a488035
TO
123 foreach ($properties as $property) {
124 $this->assign($property, $this->get($property));
125 }
126 }
127
6a488035 128}