bdb1e521cc9fa50bc0d64f2ccad96a62eecf9415
[civicrm-core.git] / CRM / Contribute / 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_Contribute_Import_Form_DataSource extends CRM_Import_Form_DataSource {
22
23 const PATH = 'civicrm/contribute/import';
24
25 const IMPORT_ENTITY = 'Contribution';
26
27 /**
28 * Build the form object.
29 */
30 public function buildQuickForm() {
31 parent::buildQuickForm();
32
33 $duplicateOptions = [];
34 $duplicateOptions[] = $this->createElement('radio',
35 NULL, NULL, ts('Insert new contributions'), CRM_Import_Parser::DUPLICATE_SKIP
36 );
37 $duplicateOptions[] = $this->createElement('radio',
38 NULL, NULL, ts('Update existing contributions'), CRM_Import_Parser::DUPLICATE_UPDATE
39 );
40 $this->addGroup($duplicateOptions, 'onDuplicate',
41 ts('Import mode')
42 );
43
44 $this->setDefaults(['onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP]);
45
46 $this->addElement('submit', 'loadMapping', ts('Load Mapping'), NULL, ['onclick' => 'checkSelect()']);
47
48 $this->addContactTypeSelector();
49 }
50
51 /**
52 * Process the uploaded file.
53 */
54 public function postProcess() {
55 $this->storeFormValues([
56 'onDuplicate',
57 'contactType',
58 'dateFormats',
59 'savedMapping',
60 ]);
61
62 $this->submitFileForMapping('CRM_Contribute_Import_Parser_Contribution');
63 }
64
65 }