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 statistics.
21 class CRM_Contribute_Import_Form_Preview
extends CRM_Import_Form_Preview
{
24 * Set variables up before form is built.
26 public function preProcess() {
28 $invalidRowCount = $this->getRowCount(CRM_Import_Parser
::VALID
);
31 if ($invalidRowCount) {
32 $urlParams = 'type=' . CRM_Import_Parser
::ERROR
. '&parser=CRM_Contribute_Import_Parser_Contribution';
33 $downloadURL = CRM_Utils_System
::url('civicrm/export', $urlParams);
36 $this->setStatusUrl();
37 $this->assign('downloadErrorRecordsUrl', $downloadURL);
41 * Get the mapped fields as an array of labels.
44 * ['First Name', 'Employee Of - First Name', 'Home - Street Address']
47 * @throws \API_Exception
48 * @throws \CRM_Core_Exception
50 protected function getMappedFieldLabels(): array {
52 $parser = $this->getParser();
53 foreach ($this->getSubmittedValue('mapper') as $columnNumber => $mappedField) {
54 $mapper[$columnNumber] = $parser->getMappedFieldLabel($parser->getMappingFieldFromMapperInput($mappedField, 0, $columnNumber));
60 * @return \CRM_Contribute_Import_Parser_Contribution
62 protected function getParser(): CRM_Contribute_Import_Parser_Contribution
{
64 $this->parser
= new CRM_Contribute_Import_Parser_Contribution();
65 $this->parser
->setUserJobID($this->getUserJobID());
66 $this->parser
->init();