INFRA-132 - CRM/Contribute - phpcbf
[civicrm-core.git] / CRM / Contribute / Import / Form / Preview.php
index e0860480cc3fe19a4725817ab0533a119f369e80..1877a10c18533a84d0d232e429e84229e57f31a2 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.3                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -28,7 +28,7 @@
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
 class CRM_Contribute_Import_Form_Preview extends CRM_Import_Form_Preview {
 
   /**
-   * Function to set variables up before form is built
+   * Set variables up before form is built
    *
    * @return void
-   * @access public
    */
   public function preProcess() {
     $skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader');
 
     //get the data from the session
-    $dataValues       = $this->get('dataValues');
-    $mapper           = $this->get('mapper');
-    $softCreditFields = $this->get('softCreditFields');
-    $invalidRowCount  = $this->get('invalidRowCount');
-    $conflictRowCount = $this->get('conflictRowCount');
-    $mismatchCount    = $this->get('unMatchCount');
+    $dataValues           = $this->get('dataValues');
+    $mapper               = $this->get('mapper');
+    $softCreditFields     = $this->get('softCreditFields');
+    $mapperSoftCreditType = $this->get('mapperSoftCreditType');
+    $invalidRowCount      = $this->get('invalidRowCount');
+    $conflictRowCount     = $this->get('conflictRowCount');
+    $mismatchCount        = $this->get('unMatchCount');
 
     //get the mapping name displayed if the mappingId is set
     $mappingId = $this->get('loadMappingId');
@@ -91,6 +91,7 @@ class CRM_Contribute_Import_Form_Preview extends CRM_Import_Form_Preview {
 
     $properties = array(
       'mapper', 'softCreditFields',
+      'mapperSoftCreditType',
       'dataValues', 'columnCount',
       'totalRowCount', 'validRowCount',
       'invalidRowCount', 'conflictRowCount',
@@ -109,7 +110,6 @@ class CRM_Contribute_Import_Form_Preview extends CRM_Import_Form_Preview {
    * preview the file and extract some summary statistics
    *
    * @return void
-   * @access public
    */
   public function postProcess() {
     $fileName         = $this->controller->exportValue('DataSource', 'uploadFile');
@@ -117,6 +117,7 @@ class CRM_Contribute_Import_Form_Preview extends CRM_Import_Form_Preview {
     $invalidRowCount  = $this->get('invalidRowCount');
     $conflictRowCount = $this->get('conflictRowCount');
     $onDuplicate      = $this->get('onDuplicate');
+    $mapperSoftCreditType = $this->get('mapperSoftCreditType');
 
     $config = CRM_Core_Config::singleton();
     $seperator = $config->fieldSeparator;
@@ -128,15 +129,16 @@ class CRM_Contribute_Import_Form_Preview extends CRM_Import_Form_Preview {
 
     foreach ($mapper as $key => $value) {
       $mapperKeys[$key] = $mapper[$key][0];
-      if (isset($mapper[$key][0]) && $mapper[$key][0] == 'soft_credit') {
-        $mapperSoftCredit[$key] = $mapper[$key][1];
+      if (isset($mapper[$key][0]) && $mapper[$key][0] == 'soft_credit' && isset($mapper[$key])) {
+        $mapperSoftCredit[$key] = isset($mapper[$key][1]) ? $mapper[$key][1] : '';
+        $mapperSoftCreditType[$key] = $mapperSoftCreditType[$key]['value'];
       }
       else {
-        $mapperSoftCredit[$key] = NULL;
+        $mapperSoftCredit[$key] = $mapperSoftCreditType[$key] = NULL;
       }
     }
 
-    $parser = new CRM_Contribute_Import_Parser_Contribution($mapperKeys, $mapperSoftCredit, $mapperPhoneType);
+    $parser = new CRM_Contribute_Import_Parser_Contribution($mapperKeys, $mapperSoftCredit, $mapperPhoneType, $mapperSoftCreditType);
 
     $mapFields = $this->get('fields');
 
@@ -186,4 +188,3 @@ class CRM_Contribute_Import_Form_Preview extends CRM_Import_Form_Preview {
     }
   }
 }
-