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 previews the uploaded file and returns summary
22 class CRM_Event_Import_Form_Preview
extends CRM_Import_Form_Preview
{
25 * Process the mapped fields and map it into the uploaded file
26 * preview the file and extract some summary statistics
30 public function postProcess() {
31 $fileName = $this->controller
->exportValue('DataSource', 'uploadFile');
32 $separator = $this->controller
->exportValue('DataSource', 'fieldSeparator');
33 $invalidRowCount = $this->get('invalidRowCount');
34 $onDuplicate = $this->get('onDuplicate');
36 $mapper = $this->controller
->exportValue('MapField', 'mapper');
39 foreach ($mapper as $key => $value) {
40 $mapperKeys[$key] = $mapper[$key][0];
43 $parser = new CRM_Event_Import_Parser_Participant($mapperKeys);
44 $parser->setUserJobID($this->getUserJobID());
45 $mapFields = $this->get('fields');
47 foreach ($mapper as $key => $value) {
49 if (isset($mapFields[$mapper[$key][0]])) {
50 $header[] = $mapFields[$mapper[$key][0]];
52 $mapperFields[] = implode(' - ', $header);
54 $parser->run($fileName, $separator,
56 $this->getSubmittedValue('skipColumnHeader'),
57 CRM_Import_Parser
::MODE_IMPORT
60 // add all the necessary variables to the form
61 $parser->set($this, CRM_Import_Parser
::MODE_IMPORT
);
65 * @return CRM_Event_Import_Parser_Participant
67 protected function getParser(): CRM_Event_Import_Parser_Participant
{
69 $this->parser
= new CRM_Event_Import_Parser_Participant();
70 $this->parser
->setUserJobID($this->getUserJobID());
71 $this->parser
->init();