Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
f299f7db | 6 | | Copyright CiviCRM LLC (c) 2004-2020 | |
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 | |
f299f7db | 31 | * @copyright CiviCRM LLC (c) 2004-2020 |
6a488035 TO |
32 | */ |
33 | ||
34 | /** | |
f12c6f7d | 35 | * This class summarizes the import results. |
6a488035 | 36 | */ |
52892e8b | 37 | class CRM_Contact_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 | ||
50 | $invalidRowCount = $this->get('invalidRowCount'); | |
51 | $conflictRowCount = $this->get('conflictRowCount'); | |
52 | $duplicateRowCount = $this->get('duplicateRowCount'); | |
53 | $onDuplicate = $this->get('onDuplicate'); | |
54 | $mismatchCount = $this->get('unMatchCount'); | |
55 | $unparsedAddressCount = $this->get('unparsedAddressCount'); | |
56 | if ($duplicateRowCount > 0) { | |
a05662ef | 57 | $urlParams = 'type=' . CRM_Import_Parser::DUPLICATE . '&parser=CRM_Contact_Import_Parser'; |
6a488035 TO |
58 | $this->set('downloadDuplicateRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); |
59 | } | |
60 | elseif ($mismatchCount) { | |
a05662ef | 61 | $urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contact_Import_Parser'; |
6a488035 TO |
62 | $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); |
63 | } | |
64 | else { | |
65 | $duplicateRowCount = 0; | |
66 | $this->set('duplicateRowCount', $duplicateRowCount); | |
67 | } | |
68 | if ($unparsedAddressCount) { | |
a05662ef | 69 | $urlParams = 'type=' . CRM_Import_Parser::UNPARSED_ADDRESS_WARNING . '&parser=CRM_Contact_Import_Parser'; |
6a488035 TO |
70 | $this->assign('downloadAddressRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); |
71 | $unparsedStreetAddressString = ts('Records imported successfully but unable to parse some of the street addresses'); | |
72 | $this->assign('unparsedStreetAddressString', $unparsedStreetAddressString); | |
73 | } | |
74 | $this->assign('dupeError', FALSE); | |
75 | ||
a05662ef | 76 | if ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) { |
6a488035 TO |
77 | $dupeActionString = ts('These records have been updated with the imported data.'); |
78 | } | |
a05662ef | 79 | elseif ($onDuplicate == CRM_Import_Parser::DUPLICATE_REPLACE) { |
6a488035 TO |
80 | $dupeActionString = ts('These records have been replaced with the imported data.'); |
81 | } | |
a05662ef | 82 | elseif ($onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) { |
6a488035 TO |
83 | $dupeActionString = ts('These records have been filled in with the imported data.'); |
84 | } | |
85 | else { | |
86 | /* Skip by default */ | |
87 | ||
88 | $dupeActionString = ts('These records have not been imported.'); | |
89 | ||
90 | $this->assign('dupeError', TRUE); | |
91 | } | |
92 | //now we also create relative contact in update and fill mode | |
93 | $this->set('validRowCount', $totalRowCount - $invalidRowCount - | |
94 | $conflictRowCount - $duplicateRowCount - $mismatchCount | |
95 | ); | |
96 | ||
97 | $this->assign('dupeActionString', $dupeActionString); | |
98 | ||
be2fb01f | 99 | $properties = [ |
353ffa53 TO |
100 | 'totalRowCount', |
101 | 'validRowCount', | |
102 | 'invalidRowCount', | |
103 | 'conflictRowCount', | |
104 | 'downloadConflictRecordsUrl', | |
105 | 'downloadErrorRecordsUrl', | |
106 | 'duplicateRowCount', | |
107 | 'downloadDuplicateRecordsUrl', | |
108 | 'downloadMismatchRecordsUrl', | |
109 | 'groupAdditions', | |
110 | 'tagAdditions', | |
111 | 'unMatchCount', | |
ae5ffbb7 | 112 | 'unparsedAddressCount', |
be2fb01f | 113 | ]; |
6a488035 TO |
114 | foreach ($properties as $property) { |
115 | $this->assign($property, $this->get($property)); | |
116 | } | |
117 | ||
118 | $session = CRM_Core_Session::singleton(); | |
119 | $session->pushUserContext(CRM_Utils_System::url('civicrm/import/contact', 'reset=1')); | |
120 | } | |
121 | ||
6a488035 | 122 | /** |
fe482240 | 123 | * Clean up the import table we used. |
6a488035 TO |
124 | */ |
125 | public function postProcess() { | |
126 | $dao = new CRM_Core_DAO(); | |
127 | $db = $dao->getDatabaseConnection(); | |
128 | ||
129 | $importTableName = $this->get('importTableName'); | |
130 | // do a basic sanity check here | |
131 | if (strpos($importTableName, 'civicrm_import_job_') === 0) { | |
132 | $query = "DROP TABLE IF EXISTS $importTableName"; | |
133 | $db->query($query); | |
134 | } | |
135 | } | |
136 | ||
6a488035 | 137 | } |