3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class gets the name of the file to upload
21 class CRM_Contribute_Import_Form_DataSource
extends CRM_Import_Form_DataSource
{
23 const PATH
= 'civicrm/contribute/import';
25 const IMPORT_ENTITY
= 'Contribution';
28 * Get the name of the type to be stored in civicrm_user_job.type_id.
32 public function getUserJobType(): string {
33 return 'contribution_import';
37 * Build the form object.
39 public function buildQuickForm() {
40 parent
::buildQuickForm();
42 $this->addRadio('onDuplicate', ts('Import mode'), [
43 CRM_Import_Parser
::DUPLICATE_SKIP
=> ts('Insert new contributions'),
44 CRM_Import_Parser
::DUPLICATE_UPDATE
=> ts('Update existing contributions'),
47 $this->setDefaults(['onDuplicate' => CRM_Import_Parser
::DUPLICATE_SKIP
]);
49 $this->addElement('xbutton', 'loadMapping', ts('Load Mapping'), [
51 'onclick' => 'checkSelect()',
54 $this->addContactTypeSelector();
58 * Process the uploaded file.
60 public function postProcess() {
61 $this->storeFormValues([
68 $this->submitFileForMapping('CRM_Contribute_Import_Parser_Contribution');
72 * @return \CRM_Contribute_Import_Parser_Contribution
74 protected function getParser(): CRM_Contribute_Import_Parser_Contribution
{
76 $this->parser
= new CRM_Contribute_Import_Parser_Contribution();
77 $this->parser
->setUserJobID($this->getUserJobID());
78 $this->parser
->init();