Merge pull request #23559 from eileenmcnaughton/import_yay
[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 $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 ]);
37
38 $this->setDefaults(['onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP]);
39
40 $this->addElement('xbutton', 'loadMapping', ts('Load Mapping'), [
41 'type' => 'submit',
42 'onclick' => 'checkSelect()',
43 ]);
44
45 $this->addContactTypeSelector();
46 }
47
48 /**
49 * Process the uploaded file.
50 */
51 public function postProcess() {
52 $this->storeFormValues([
53 'onDuplicate',
54 'contactType',
55 'dateFormats',
56 'savedMapping',
57 ]);
58
59 $this->submitFileForMapping('CRM_Contribute_Import_Parser_Contribution');
60 }
61
62 }