Member import cleanup - use datasource
[civicrm-core.git] / CRM / Member / 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_Member_Import_Form_Summary extends CRM_Import_Form_Summary {
22
23 /**
24 * Set variables up before form is built.
25 *
26 * @return void
27 */
28 public function preProcess() {
29 // set the error message path to display
30 $this->assign('errorFile', $this->get('errorFile'));
31
32 $totalRowCount = $this->get('totalRowCount');
33 $this->set('totalRowCount', $totalRowCount);
34
35 $invalidRowCount = $this->get('invalidRowCount');
36 $duplicateRowCount = $this->get('duplicateRowCount');
37 $onDuplicate = $this->get('onDuplicate');
38
39 if ($duplicateRowCount > 0) {
40 $urlParams = 'type=' . CRM_Import_Parser::DUPLICATE . '&parser=CRM_Member_Import_Parser_Membership';
41 $this->set('downloadDuplicateRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
42 }
43 else {
44 $duplicateRowCount = 0;
45 $this->set('duplicateRowCount', $duplicateRowCount);
46 }
47
48 $this->assign('dupeError', FALSE);
49
50 if ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
51 $dupeActionString = ts('These records have been updated with the imported data.');
52 }
53 elseif ($onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) {
54 $dupeActionString = ts('These records have been filled in with the imported data.');
55 }
56 else {
57 /* Skip by default */
58
59 $dupeActionString = ts('These records have not been imported.');
60
61 $this->assign('dupeError', TRUE);
62
63 /* only subtract dupes from successful import if we're skipping */
64
65 $this->set('validRowCount', $totalRowCount - $invalidRowCount -
66 $duplicateRowCount
67 );
68 }
69 $this->assign('dupeActionString', $dupeActionString);
70
71 $properties = [
72 'totalRowCount',
73 'validRowCount',
74 'invalidRowCount',
75 'downloadErrorRecordsUrl',
76 'duplicateRowCount',
77 'downloadDuplicateRecordsUrl',
78 'groupAdditions',
79 ];
80 foreach ($properties as $property) {
81 $this->assign($property, $this->get($property));
82 }
83 }
84
85 }