Merge in 5.20
[civicrm-core.git] / CRM / Activity / 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_Activity_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 $relatedCount = $this->get('relatedCount');
32 $totalRowCount += $relatedCount;
33 $this->set('totalRowCount', $totalRowCount);
34
35 $invalidRowCount = $this->get('invalidRowCount');
36 $conflictRowCount = $this->get('conflictRowCount');
37 $duplicateRowCount = $this->get('duplicateRowCount');
38 $onDuplicate = $this->get('onDuplicate');
39 $mismatchCount = $this->get('unMatchCount');
40 if ($duplicateRowCount > 0) {
41 $urlParams = 'type=' . CRM_Import_Parser::DUPLICATE . '&parser=CRM_Activity_Import_Parser';
42 $this->set('downloadDuplicateRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
43 }
44 elseif ($mismatchCount) {
45 $urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Activity_Import_Parser';
46 $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
47 }
48 else {
49 $duplicateRowCount = 0;
50 $this->set('duplicateRowCount', $duplicateRowCount);
51 }
52
53 $this->assign('dupeError', FALSE);
54
55 if ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
56 $dupeActionString = ts('These records have been updated with the imported data.');
57 }
58 elseif ($onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) {
59 $dupeActionString = ts('These records have been filled in with the imported data.');
60 }
61 else {
62 // Skip by default.
63
64 $dupeActionString = ts('These records have not been imported.');
65
66 $this->assign('dupeError', TRUE);
67
68 // Only subtract dupes from successful import if we're skipping.
69
70 $this->set('validRowCount', $totalRowCount - $invalidRowCount -
71 $conflictRowCount - $duplicateRowCount - $mismatchCount
72 );
73 }
74 $this->assign('dupeActionString', $dupeActionString);
75
76 $properties = [
77 'totalRowCount',
78 'validRowCount',
79 'invalidRowCount',
80 'conflictRowCount',
81 'downloadConflictRecordsUrl',
82 'downloadErrorRecordsUrl',
83 'duplicateRowCount',
84 'downloadDuplicateRecordsUrl',
85 'downloadMismatchRecordsUrl',
86 'groupAdditions',
87 'unMatchCount',
88 ];
89 foreach ($properties as $property) {
90 $this->assign($property, $this->get($property));
91 }
92 }
93
94 }