Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | CiviCRM version 4.3 | | |
5 | +--------------------------------------------------------------------+ | |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
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 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * | |
30 | * @package CRM | |
31 | * @copyright CiviCRM LLC (c) 2004-2013 | |
32 | * $Id$ | |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * This class summarizes the import results | |
38 | */ | |
39 | class CRM_Contribute_Import_Form_Summary extends CRM_Core_Form { | |
40 | ||
41 | /** | |
42 | * Function to set variables up before form is built | |
43 | * | |
44 | * @return void | |
45 | * @access public | |
46 | */ | |
47 | public function preProcess() { | |
48 | // set the error message path to display | |
49 | $errorFile = $this->assign('errorFile', $this->get('errorFile')); | |
50 | ||
51 | $totalRowCount = $this->get('totalRowCount'); | |
52 | $relatedCount = $this->get('relatedCount'); | |
53 | $totalRowCount += $relatedCount; | |
54 | $this->set('totalRowCount', $totalRowCount); | |
55 | ||
56 | $invalidRowCount = $this->get('invalidRowCount'); | |
57 | $invalidSoftCreditRowCount = $this->get('invalidSoftCreditRowCount'); | |
58 | if ($invalidSoftCreditRowCount) { | |
59 | $urlParams = 'type=' . CRM_Contribute_Import_Parser::SOFT_CREDIT_ERROR . '&parser=CRM_Contribute_Import_Parser'; | |
60 | $this->set('downloadSoftCreditErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); | |
61 | } | |
62 | $validSoftCreditRowCount = $this->get('validSoftCreditRowCount'); | |
63 | $invalidPledgePaymentRowCount = $this->get('invalidPledgePaymentRowCount'); | |
64 | if ($invalidPledgePaymentRowCount) { | |
65 | $urlParams = 'type=' . CRM_Contribute_Import_Parser::PLEDGE_PAYMENT_ERROR . '&parser=CRM_Contribute_Import_Parser'; | |
66 | $this->set('downloadPledgePaymentErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); | |
67 | } | |
68 | $validPledgePaymentRowCount = $this->get('validPledgePaymentRowCount'); | |
69 | $conflictRowCount = $this->get('conflictRowCount'); | |
70 | $duplicateRowCount = $this->get('duplicateRowCount'); | |
71 | $onDuplicate = $this->get('onDuplicate'); | |
72 | $mismatchCount = $this->get('unMatchCount'); | |
73 | if ($duplicateRowCount > 0) { | |
74 | $urlParams = 'type=' . CRM_Contribute_Import_Parser::DUPLICATE . '&parser=CRM_Contribute_Import_Parser'; | |
75 | $this->set('downloadDuplicateRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); | |
76 | } | |
77 | elseif ($mismatchCount) { | |
78 | $urlParams = 'type=' . CRM_Contribute_Import_Parser::NO_MATCH . '&parser=CRM_Contribute_Import_Parser'; | |
79 | $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); | |
80 | } | |
81 | else { | |
82 | $duplicateRowCount = 0; | |
83 | $this->set('duplicateRowCount', $duplicateRowCount); | |
84 | } | |
85 | ||
86 | $this->assign('dupeError', FALSE); | |
87 | ||
88 | if ($onDuplicate == CRM_Contribute_Import_Parser::DUPLICATE_UPDATE) { | |
89 | $dupeActionString = ts('These records have been updated with the imported data.'); | |
90 | } | |
91 | elseif ($onDuplicate == CRM_Contribute_Import_Parser::DUPLICATE_FILL) { | |
92 | $dupeActionString = ts('These records have been filled in with the imported data.'); | |
93 | } | |
94 | else { | |
95 | /* Skip by default */ | |
96 | ||
97 | $dupeActionString = ts('These records have not been imported.'); | |
98 | ||
99 | $this->assign('dupeError', TRUE); | |
100 | ||
101 | /* only subtract dupes from succesful import if we're skipping */ | |
102 | ||
103 | $this->set('validRowCount', $totalRowCount - $invalidRowCount - | |
104 | $conflictRowCount - $duplicateRowCount - $mismatchCount - $invalidSoftCreditRowCount - $invalidPledgePaymentRowCount | |
105 | ); | |
106 | } | |
107 | $this->assign('dupeActionString', $dupeActionString); | |
108 | ||
109 | $properties = array('totalRowCount', 'validRowCount', 'invalidRowCount', 'validSoftCreditRowCount', 'invalidSoftCreditRowCount', 'conflictRowCount', 'downloadConflictRecordsUrl', 'downloadErrorRecordsUrl', 'duplicateRowCount', 'downloadDuplicateRecordsUrl', 'downloadMismatchRecordsUrl', 'groupAdditions', 'unMatchCount', 'validPledgePaymentRowCount', 'invalidPledgePaymentRowCount', 'downloadPledgePaymentErrorRecordsUrl', 'downloadSoftCreditErrorRecordsUrl'); | |
110 | foreach ($properties as $property) { | |
111 | $this->assign($property, $this->get($property)); | |
112 | } | |
113 | } | |
114 | ||
115 | /** | |
116 | * Function to actually build the form | |
117 | * | |
118 | * @return None | |
119 | * @access public | |
120 | */ | |
121 | public function buildQuickForm() { | |
122 | $this->addButtons(array( | |
123 | array( | |
124 | 'type' => 'next', | |
125 | 'name' => ts('Done'), | |
126 | 'isDefault' => TRUE, | |
127 | ), | |
128 | ) | |
129 | ); | |
130 | } | |
131 | ||
132 | /** | |
133 | * Return a descriptive name for the page, used in wizard header | |
134 | * | |
135 | * @return string | |
136 | * @access public | |
137 | */ | |
138 | public function getTitle() { | |
139 | return ts('Summary'); | |
140 | } | |
141 | } | |
142 |