Commit | Line | Data |
---|---|---|
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 gets the name of the file to upload | |
20 | */ | |
81c3812a | 21 | class CRM_Contribute_Import_Form_DataSource extends CRM_Import_Form_DataSource { |
6a488035 | 22 | |
81c3812a CW |
23 | const PATH = 'civicrm/contribute/import'; |
24 | ||
25 | const IMPORT_ENTITY = 'Contribution'; | |
6a488035 TO |
26 | |
27 | /** | |
fe482240 | 28 | * Build the form object. |
6a488035 TO |
29 | */ |
30 | public function buildQuickForm() { | |
81c3812a | 31 | parent::buildQuickForm(); |
6a488035 | 32 | |
39405208 SL |
33 | $this->addRadio('onDuplicate', ts('Import mode'), [ |
34 | CRM_Import_Parser::DUPLICATE_SKIP => ts('Insert new contributions'), | |
35 | CRM_Import_Parser::DUPLICATE_UPDATE => ts('Update existing contributions'), | |
36 | ]); | |
6a488035 | 37 | |
be2fb01f | 38 | $this->setDefaults(['onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP]); |
6a488035 | 39 | |
cbd83dde AH |
40 | $this->addElement('xbutton', 'loadMapping', ts('Load Mapping'), [ |
41 | 'type' => 'submit', | |
42 | 'onclick' => 'checkSelect()', | |
43 | ]); | |
6a488035 | 44 | |
81c3812a | 45 | $this->addContactTypeSelector(); |
6a488035 TO |
46 | } |
47 | ||
48 | /** | |
fe482240 | 49 | * Process the uploaded file. |
6a488035 TO |
50 | */ |
51 | public function postProcess() { | |
be2fb01f | 52 | $this->storeFormValues([ |
81c3812a CW |
53 | 'onDuplicate', |
54 | 'contactType', | |
55 | 'dateFormats', | |
56 | 'savedMapping', | |
be2fb01f | 57 | ]); |
6a488035 | 58 | |
81c3812a | 59 | $this->submitFileForMapping('CRM_Contribute_Import_Parser_Contribution'); |
6a488035 | 60 | } |
96025800 | 61 | |
83a1c234 EM |
62 | /** |
63 | * @return \CRM_Contribute_Import_Parser_Contribution | |
64 | */ | |
65 | protected function getParser(): CRM_Contribute_Import_Parser_Contribution { | |
66 | if (!$this->parser) { | |
67 | $this->parser = new CRM_Contribute_Import_Parser_Contribution(); | |
68 | $this->parser->setUserJobID($this->getUserJobID()); | |
69 | $this->parser->init(); | |
70 | } | |
71 | return $this->parser; | |
72 | } | |
73 | ||
6a488035 | 74 | } |