| 1 | <?php |
| 2 | /* |
| 3 | +--------------------------------------------------------------------+ |
| 4 | | CiviCRM version 4.7 | |
| 5 | +--------------------------------------------------------------------+ |
| 6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
| 7 | +--------------------------------------------------------------------+ |
| 8 | | This file is a part of CiviCRM. | |
| 9 | | | |
| 10 | | CiviCRM is free software; you can copy, modify, and distribute it | |
| 11 | | under the terms of the GNU Affero General Public License | |
| 12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | |
| 13 | | | |
| 14 | | CiviCRM is distributed in the hope that it will be useful, but | |
| 15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 17 | | See the GNU Affero General Public License for more details. | |
| 18 | | | |
| 19 | | You should have received a copy of the GNU Affero General Public | |
| 20 | | License and the CiviCRM Licensing Exception along | |
| 21 | | with this program; if not, contact CiviCRM LLC | |
| 22 | | at info[AT]civicrm[DOT]org. If you have questions about the | |
| 23 | | GNU Affero General Public License or the licensing of CiviCRM, | |
| 24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | |
| 25 | +--------------------------------------------------------------------+ |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * |
| 30 | * @package CRM |
| 31 | * @copyright CiviCRM LLC (c) 2004-2015 |
| 32 | */ |
| 33 | |
| 34 | /** |
| 35 | * This class summarizes the import results. |
| 36 | */ |
| 37 | class CRM_Activity_Import_Form_Summary extends CRM_Import_Form_Summary { |
| 38 | |
| 39 | /** |
| 40 | * Set variables up before form is built. |
| 41 | */ |
| 42 | public function preProcess() { |
| 43 | // set the error message path to display |
| 44 | $this->assign('errorFile', $this->get('errorFile')); |
| 45 | |
| 46 | $totalRowCount = $this->get('totalRowCount'); |
| 47 | $relatedCount = $this->get('relatedCount'); |
| 48 | $totalRowCount += $relatedCount; |
| 49 | $this->set('totalRowCount', $totalRowCount); |
| 50 | |
| 51 | $invalidRowCount = $this->get('invalidRowCount'); |
| 52 | $conflictRowCount = $this->get('conflictRowCount'); |
| 53 | $duplicateRowCount = $this->get('duplicateRowCount'); |
| 54 | $onDuplicate = $this->get('onDuplicate'); |
| 55 | $mismatchCount = $this->get('unMatchCount'); |
| 56 | if ($duplicateRowCount > 0) { |
| 57 | $urlParams = 'type=' . CRM_Import_Parser::DUPLICATE . '&parser=CRM_Activity_Import_Parser'; |
| 58 | $this->set('downloadDuplicateRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); |
| 59 | } |
| 60 | elseif ($mismatchCount) { |
| 61 | $urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Activity_Import_Parser'; |
| 62 | $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); |
| 63 | } |
| 64 | else { |
| 65 | $duplicateRowCount = 0; |
| 66 | $this->set('duplicateRowCount', $duplicateRowCount); |
| 67 | } |
| 68 | |
| 69 | $this->assign('dupeError', FALSE); |
| 70 | |
| 71 | if ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) { |
| 72 | $dupeActionString = ts('These records have been updated with the imported data.'); |
| 73 | } |
| 74 | elseif ($onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) { |
| 75 | $dupeActionString = ts('These records have been filled in with the imported data.'); |
| 76 | } |
| 77 | else { |
| 78 | /* Skip by default */ |
| 79 | |
| 80 | $dupeActionString = ts('These records have not been imported.'); |
| 81 | |
| 82 | $this->assign('dupeError', TRUE); |
| 83 | |
| 84 | /* only subtract dupes from successful import if we're skipping */ |
| 85 | |
| 86 | $this->set('validRowCount', $totalRowCount - $invalidRowCount - |
| 87 | $conflictRowCount - $duplicateRowCount - $mismatchCount |
| 88 | ); |
| 89 | } |
| 90 | $this->assign('dupeActionString', $dupeActionString); |
| 91 | |
| 92 | $properties = array( |
| 93 | 'totalRowCount', |
| 94 | 'validRowCount', |
| 95 | 'invalidRowCount', |
| 96 | 'conflictRowCount', |
| 97 | 'downloadConflictRecordsUrl', |
| 98 | 'downloadErrorRecordsUrl', |
| 99 | 'duplicateRowCount', |
| 100 | 'downloadDuplicateRecordsUrl', |
| 101 | 'downloadMismatchRecordsUrl', |
| 102 | 'groupAdditions', |
| 103 | 'unMatchCount', |
| 104 | ); |
| 105 | foreach ($properties as $property) { |
| 106 | $this->assign($property, $this->get($property)); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | } |