Merge pull request #23332 from darrick/dupeQuery
[civicrm-core.git] / CRM / Event / Import / Form / Summary.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
18/**
19 * This class summarizes the import results
20 */
52892e8b 21class CRM_Event_Import_Form_Summary extends CRM_Import_Form_Summary {
6a488035
TO
22
23 /**
fe482240 24 * Set variables up before form is built.
6a488035
TO
25 *
26 * @return void
6a488035
TO
27 */
28 public function preProcess() {
29 // set the error message path to display
81c3812a 30 $this->assign('errorFile', $this->get('errorFile'));
6a488035
TO
31
32 $totalRowCount = $this->get('totalRowCount');
33 $relatedCount = $this->get('relatedCount');
34 $totalRowCount += $relatedCount;
35 $this->set('totalRowCount', $totalRowCount);
36
719a6fec 37 $invalidRowCount = $this->get('invalidRowCount');
6a488035 38 $duplicateRowCount = $this->get('duplicateRowCount');
719a6fec 39 $onDuplicate = $this->get('onDuplicate');
6a488035 40 if ($duplicateRowCount > 0) {
d60cd664 41 $urlParams = 'type=' . CRM_Import_Parser::DUPLICATE . '&parser=CRM_Event_Import_Parser_Participant';
6a488035
TO
42 $this->set('downloadDuplicateRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
43 }
6a488035
TO
44 else {
45 $duplicateRowCount = 0;
46 $this->set('duplicateRowCount', $duplicateRowCount);
47 }
48
49 $this->assign('dupeError', FALSE);
50
a05662ef 51 if ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
6a488035
TO
52 $dupeActionString = ts('These records have been updated with the imported data.');
53 }
a05662ef 54 elseif ($onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) {
6a488035
TO
55 $dupeActionString = ts('These records have been filled in with the imported data.');
56 }
57 else {
58 /* Skip by default */
59
60 $dupeActionString = ts('These records have not been imported.');
61
62 $this->assign('dupeError', TRUE);
63
ceb10dc7 64 /* only subtract dupes from successful import if we're skipping */
6a488035
TO
65
66 $this->set('validRowCount', $totalRowCount - $invalidRowCount -
67fa4d56 67 $duplicateRowCount
6a488035
TO
68 );
69 }
70 $this->assign('dupeActionString', $dupeActionString);
71
be2fb01f 72 $properties = [
353ffa53
TO
73 'totalRowCount',
74 'validRowCount',
75 'invalidRowCount',
353ffa53
TO
76 'downloadErrorRecordsUrl',
77 'duplicateRowCount',
78 'downloadDuplicateRecordsUrl',
353ffa53 79 'groupAdditions',
be2fb01f 80 ];
6a488035
TO
81 foreach ($properties as $property) {
82 $this->assign($property, $this->get($property));
83 }
84 }
85
6a488035 86}