Member import cleanup - use datasource
[civicrm-core.git] / CRM / Contact / 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
3592a5e4
EM
18use Civi\Api4\UserJob;
19
6a488035 20/**
f12c6f7d 21 * This class summarizes the import results.
6a488035 22 */
52892e8b 23class CRM_Contact_Import_Form_Summary extends CRM_Import_Form_Summary {
6a488035
TO
24
25 /**
fe482240 26 * Set variables up before form is built.
c4f66023
EM
27 *
28 * @throws \API_Exception
29 * @throws \CRM_Core_Exception
6a488035
TO
30 */
31 public function preProcess() {
3592a5e4
EM
32 $userJobID = CRM_Utils_Request::retrieve('user_job_id', 'String', $this, TRUE);
33 $userJob = UserJob::get(TRUE)->addWhere('id', '=', $userJobID)->execute()->first();
34 $onDuplicate = $userJob['metadata']['submitted_values']['onDuplicate'];
6a488035
TO
35 $this->assign('dupeError', FALSE);
36
3592a5e4 37 if ($onDuplicate === CRM_Import_Parser::DUPLICATE_UPDATE) {
c4f66023 38 $this->assign('dupeActionString', ts('These records have been updated with the imported data.'));
6a488035 39 }
3592a5e4 40 elseif ($onDuplicate === CRM_Import_Parser::DUPLICATE_FILL) {
c4f66023 41 $this->assign('dupeActionString', ts('These records have been filled in with the imported data.'));
6a488035
TO
42 }
43 else {
44 /* Skip by default */
c4f66023 45 $this->assign('dupeActionString', ts('These records have not been imported.'));
6a488035
TO
46 $this->assign('dupeError', TRUE);
47 }
6a488035 48
578e4db3
EM
49 $this->assign('groupAdditions', $this->getUserJob()['metadata']['summary_info']['groups']);
50 $this->assign('tagAdditions', $this->getUserJob()['metadata']['summary_info']['tags']);
99e3c5f7 51 $this->assign('totalRowCount', $this->getRowCount());
c4f66023 52 $this->assign('validRowCount', $this->getRowCount(CRM_Import_Parser::VALID) + $this->getRowCount(CRM_Import_Parser::UNPARSED_ADDRESS_WARNING));
99e3c5f7 53 $this->assign('invalidRowCount', $this->getRowCount(CRM_Import_Parser::ERROR));
f5d23fe9 54 $this->assign('duplicateRowCount', $this->getRowCount(CRM_Import_Parser::DUPLICATE));
c4f66023
EM
55 $this->assign('unMatchCount', $this->getRowCount(CRM_Import_Parser::NO_MATCH));
56 $this->assign('unparsedAddressCount', $this->getRowCount(CRM_Import_Parser::UNPARSED_ADDRESS_WARNING));
99e3c5f7 57 $this->assign('downloadDuplicateRecordsUrl', $this->getDownloadURL(CRM_Import_Parser::DUPLICATE));
f5d23fe9 58 $this->assign('downloadErrorRecordsUrl', $this->getDownloadURL(CRM_Import_Parser::ERROR));
c4f66023
EM
59 $this->assign('downloadMismatchRecordsUrl', $this->getDownloadURL(CRM_Import_Parser::NO_MATCH));
60 $this->assign('downloadAddressRecordsUrl', $this->getDownloadURL(CRM_Import_Parser::UNPARSED_ADDRESS_WARNING));
6a488035
TO
61 $session = CRM_Core_Session::singleton();
62 $session->pushUserContext(CRM_Utils_System::url('civicrm/import/contact', 'reset=1'));
63 }
64
6a488035 65 /**
fe482240 66 * Clean up the import table we used.
6a488035
TO
67 */
68 public function postProcess() {
6a488035
TO
69 }
70
6a488035 71}