Merge pull request #15338 from totten/master-poc-postcommit
[civicrm-core.git] / CRM / Event / 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 * $Id$
17 *
18 */
19
20 /**
21 * This class summarizes the import results
22 */
23 class CRM_Event_Import_Form_Summary extends CRM_Import_Form_Summary {
24
25 /**
26 * Set variables up before form is built.
27 *
28 * @return void
29 */
30 public function preProcess() {
31 // set the error message path to display
32 $this->assign('errorFile', $this->get('errorFile'));
33
34 $totalRowCount = $this->get('totalRowCount');
35 $relatedCount = $this->get('relatedCount');
36 $totalRowCount += $relatedCount;
37 $this->set('totalRowCount', $totalRowCount);
38
39 $invalidRowCount = $this->get('invalidRowCount');
40 $conflictRowCount = $this->get('conflictRowCount');
41 $duplicateRowCount = $this->get('duplicateRowCount');
42 $onDuplicate = $this->get('onDuplicate');
43 $mismatchCount = $this->get('unMatchCount');
44 if ($duplicateRowCount > 0) {
45 $urlParams = 'type=' . CRM_Import_Parser::DUPLICATE . '&parser=CRM_Event_Import_Parser';
46 $this->set('downloadDuplicateRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
47 }
48 elseif ($mismatchCount) {
49 $urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Event_Import_Parser';
50 $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
51 }
52 else {
53 $duplicateRowCount = 0;
54 $this->set('duplicateRowCount', $duplicateRowCount);
55 }
56
57 $this->assign('dupeError', FALSE);
58
59 if ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
60 $dupeActionString = ts('These records have been updated with the imported data.');
61 }
62 elseif ($onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) {
63 $dupeActionString = ts('These records have been filled in with the imported data.');
64 }
65 else {
66 /* Skip by default */
67
68 $dupeActionString = ts('These records have not been imported.');
69
70 $this->assign('dupeError', TRUE);
71
72 /* only subtract dupes from successful import if we're skipping */
73
74 $this->set('validRowCount', $totalRowCount - $invalidRowCount -
75 $conflictRowCount - $duplicateRowCount - $mismatchCount
76 );
77 }
78 $this->assign('dupeActionString', $dupeActionString);
79
80 $properties = [
81 'totalRowCount',
82 'validRowCount',
83 'invalidRowCount',
84 'conflictRowCount',
85 'downloadConflictRecordsUrl',
86 'downloadErrorRecordsUrl',
87 'duplicateRowCount',
88 'downloadDuplicateRecordsUrl',
89 'downloadMismatchRecordsUrl',
90 'groupAdditions',
91 'unMatchCount',
92 ];
93 foreach ($properties as $property) {
94 $this->assign($property, $this->get($property));
95 }
96 }
97
98 }