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_Member_Import_Form_DataSource
extends CRM_Import_Form_DataSource
{
23 const PATH
= 'civicrm/member/import';
25 const IMPORT_ENTITY
= 'Membership';
28 * Build the form object.
32 public function buildQuickForm() {
33 parent
::buildQuickForm();
35 //Setting Upload File Size
36 $config = CRM_Core_Config
::singleton();
38 $uploadFileSize = CRM_Utils_Number
::formatUnitSize($config->maxFileSize
. 'm', TRUE);
39 $uploadSize = round(($uploadFileSize / (1024 * 1024)), 2);
41 $this->assign('uploadSize', $uploadSize);
43 $this->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE);
44 $this->setMaxFileSize($uploadFileSize);
45 $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array(
48 )), 'maxfilesize', $uploadFileSize);
49 $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile');
50 $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File');
52 $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers'));
54 $this->addRadio('onDuplicate', ts('Import mode'), [
55 CRM_Import_Parser
::DUPLICATE_SKIP
=> ts('Insert new Membership'),
56 CRM_Import_Parser
::DUPLICATE_UPDATE
=> ts('Update existing Membership'),
59 'onDuplicate' => CRM_Import_Parser
::DUPLICATE_SKIP
,
62 $this->addContactTypeSelector();
66 * Process the uploaded file.
70 public function postProcess() {
71 $this->storeFormValues([
78 $this->submitFileForMapping('CRM_Member_Import_Parser_Membership');