Merge pull request #23456 from eileenmcnaughton/import_more
[civicrm-core.git] / CRM / Event / Import / Form / DataSource.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 gets the name of the file to upload
20 */
21 class CRM_Event_Import_Form_DataSource extends CRM_Import_Form_DataSource {
22
23 const PATH = 'civicrm/event/import';
24
25 const IMPORT_ENTITY = 'Participant';
26
27 /**
28 * Build the form object.
29 *
30 * @return void
31 */
32 public function buildQuickForm() {
33 parent::buildQuickForm();
34
35 $duplicateOptions = [];
36 $this->addRadio('onDuplicate', ts('On Duplicate Entries'), [
37 CRM_Import_Parser::DUPLICATE_SKIP => ts('Skip'),
38 CRM_Import_Parser::DUPLICATE_UPDATE => ts('Update'),
39 CRM_Import_Parser::DUPLICATE_NOCHECK => ts('No Duplicate Checking'),
40 ]);
41 $this->setDefaults(['onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP]);
42
43 $this->addContactTypeSelector();
44 }
45
46 /**
47 * Process the uploaded file.
48 *
49 * @return void
50 */
51 public function postProcess() {
52 $this->storeFormValues([
53 'onDuplicate',
54 'contactType',
55 'dateFormats',
56 'savedMapping',
57 ]);
58
59 $this->submitFileForMapping('CRM_Event_Import_Parser_Participant');
60 }
61
62 /**
63 * @return CRM_Event_Import_Parser_Participant
64 */
65 protected function getParser(): CRM_Event_Import_Parser_Participant {
66 if (!$this->parser) {
67 $this->parser = new CRM_Event_Import_Parser_Participant();
68 $this->parser->setUserJobID($this->getUserJobID());
69 $this->parser->init();
70 }
71 return $this->parser;
72 }
73
74 }