Skip to content

Commit

Permalink
Merge pull request #23400 from eileenmcnaughton/import_no_match
Browse files Browse the repository at this point in the history
[Import] Reduce unused copy & paste
  • Loading branch information
colemanw authored May 7, 2022
2 parents cb21080 + 67fa4d5 commit a4bf93f
Show file tree
Hide file tree
Showing 13 changed files with 6 additions and 156 deletions.
9 changes: 0 additions & 9 deletions CRM/Activity/Import/Form/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public function preProcess() {
$dataValues = $this->get('dataValues');
$mapper = $this->get('mapper');
$invalidRowCount = $this->get('invalidRowCount');
$mismatchCount = $this->get('unMatchCount');

// Get the mapping name displayed if the mappingId is set.
$mappingId = $this->get('loadMappingId');
Expand All @@ -45,11 +44,6 @@ public function preProcess() {
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

if ($mismatchCount) {
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Activity_Import_Parser_Activity';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

$properties = [
'mapper',
'dataValues',
Expand All @@ -58,7 +52,6 @@ public function preProcess() {
'validRowCount',
'invalidRowCount',
'downloadErrorRecordsUrl',
'downloadMismatchRecordsUrl',
];
$this->setStatusUrl();

Expand Down Expand Up @@ -130,8 +123,6 @@ public function postProcess() {
$this->set('errorFile', $errorFile);
$urlParams = 'type=' . CRM_Import_Parser::ERROR . '&parser=CRM_Activity_Import_Parser_Activity';
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Activity_Import_Parser_Activity';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
}

Expand Down
10 changes: 2 additions & 8 deletions CRM/Activity/Import/Form/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,11 @@ public function preProcess() {
$invalidRowCount = $this->get('invalidRowCount');
$duplicateRowCount = $this->get('duplicateRowCount');
$onDuplicate = $this->get('onDuplicate');
$mismatchCount = $this->get('unMatchCount');

if ($duplicateRowCount > 0) {
$urlParams = 'type=' . CRM_Import_Parser::DUPLICATE . '&parser=CRM_Activity_Import_Parser_Activity';
$this->set('downloadDuplicateRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
elseif ($mismatchCount) {
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Activity_Import_Parser_Activity';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
else {
$duplicateRowCount = 0;
$this->set('duplicateRowCount', $duplicateRowCount);
Expand All @@ -67,7 +63,7 @@ public function preProcess() {
// Only subtract dupes from successful import if we're skipping.

$this->set('validRowCount', $totalRowCount - $invalidRowCount -
$duplicateRowCount - $mismatchCount
$duplicateRowCount
);
}
$this->assign('dupeActionString', $dupeActionString);
Expand All @@ -79,9 +75,7 @@ public function preProcess() {
'downloadErrorRecordsUrl',
'duplicateRowCount',
'downloadDuplicateRecordsUrl',
'downloadMismatchRecordsUrl',
'groupAdditions',
'unMatchCount',
];
foreach ($properties as $property) {
$this->assign($property, $this->get($property));
Expand Down
9 changes: 0 additions & 9 deletions CRM/Contribute/Import/Form/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function preProcess() {
$softCreditFields = $this->get('softCreditFields');
$mapperSoftCreditType = $this->get('mapperSoftCreditType');
$invalidRowCount = $this->get('invalidRowCount');
$mismatchCount = $this->get('unMatchCount');

//get the mapping name displayed if the mappingId is set
$mappingId = $this->get('loadMappingId');
Expand All @@ -47,11 +46,6 @@ public function preProcess() {
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

if ($mismatchCount) {
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

$properties = [
'mapper',
'softCreditFields',
Expand All @@ -62,7 +56,6 @@ public function preProcess() {
'validRowCount',
'invalidRowCount',
'downloadErrorRecordsUrl',
'downloadMismatchRecordsUrl',
];
$this->setStatusUrl();

Expand Down Expand Up @@ -143,8 +136,6 @@ public function postProcess() {
$this->set('errorFile', $errorFile);
$urlParams = 'type=' . CRM_Import_Parser::ERROR . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
}

Expand Down
9 changes: 1 addition & 8 deletions CRM/Contribute/Import/Form/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,10 @@ public function preProcess() {
$validPledgePaymentRowCount = $this->get('validPledgePaymentRowCount');
$duplicateRowCount = $this->get('duplicateRowCount');
$onDuplicate = $this->get('onDuplicate');
$mismatchCount = $this->get('unMatchCount');
if ($duplicateRowCount > 0) {
$urlParams = 'type=' . CRM_Import_Parser::DUPLICATE . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadDuplicateRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
elseif ($mismatchCount) {
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
else {
$duplicateRowCount = 0;
$this->set('duplicateRowCount', $duplicateRowCount);
Expand All @@ -79,7 +74,7 @@ public function preProcess() {
/* only subtract dupes from successful import if we're skipping */

$this->set('validRowCount', $totalRowCount - $invalidRowCount -
$duplicateRowCount - $mismatchCount - $invalidSoftCreditRowCount - $invalidPledgePaymentRowCount
$duplicateRowCount - $invalidSoftCreditRowCount - $invalidPledgePaymentRowCount
);
}
$this->assign('dupeActionString', $dupeActionString);
Expand All @@ -93,9 +88,7 @@ public function preProcess() {
'downloadErrorRecordsUrl',
'duplicateRowCount',
'downloadDuplicateRecordsUrl',
'downloadMismatchRecordsUrl',
'groupAdditions',
'unMatchCount',
'validPledgePaymentRowCount',
'invalidPledgePaymentRowCount',
'downloadPledgePaymentErrorRecordsUrl',
Expand Down
9 changes: 0 additions & 9 deletions CRM/Custom/Import/Form/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public function preProcess() {
$dataValues = $this->get('dataValues');
$mapper = $this->get('mapper');
$invalidRowCount = $this->get('invalidRowCount');
$mismatchCount = $this->get('unMatchCount');
$entity = $this->get('_entity');

//get the mapping name displayed if the mappingId is set
Expand All @@ -35,11 +34,6 @@ public function preProcess() {
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

if ($mismatchCount) {
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . $this->_importParserUrl;
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

$properties = [
'mapper',
'dataValues',
Expand All @@ -48,7 +42,6 @@ public function preProcess() {
'validRowCount',
'invalidRowCount',
'downloadErrorRecordsUrl',
'downloadMismatchRecordsUrl',
];

foreach ($properties as $property) {
Expand Down Expand Up @@ -119,8 +112,6 @@ public function postProcess() {
$this->set('errorFile', $errorFile);
$urlParams = 'type=' . CRM_Import_Parser::ERROR . $this->_importParserUrl;
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . $this->_importParserUrl;
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
}

Expand Down
9 changes: 0 additions & 9 deletions CRM/Event/Import/Form/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public function preProcess() {
$dataValues = $this->get('dataValues');
$mapper = $this->get('mapper');
$invalidRowCount = $this->get('invalidRowCount');
$mismatchCount = $this->get('unMatchCount');

//get the mapping name displayed if the mappingId is set
$mappingId = $this->get('loadMappingId');
Expand All @@ -49,11 +48,6 @@ public function preProcess() {
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

if ($mismatchCount) {
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Event_Import_Parser_Participant';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

$properties = [
'mapper',
'dataValues',
Expand All @@ -62,7 +56,6 @@ public function preProcess() {
'validRowCount',
'invalidRowCount',
'downloadErrorRecordsUrl',
'downloadMismatchRecordsUrl',
];

foreach ($properties as $property) {
Expand Down Expand Up @@ -132,8 +125,6 @@ public function postProcess() {
$this->set('errorFile', $errorFile);
$urlParams = 'type=' . CRM_Import_Parser::ERROR . '&parser=CRM_Event_Import_Parser_Participant';
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Event_Import_Parser_Participant';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
}

Expand Down
9 changes: 1 addition & 8 deletions CRM/Event/Import/Form/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,10 @@ public function preProcess() {
$invalidRowCount = $this->get('invalidRowCount');
$duplicateRowCount = $this->get('duplicateRowCount');
$onDuplicate = $this->get('onDuplicate');
$mismatchCount = $this->get('unMatchCount');
if ($duplicateRowCount > 0) {
$urlParams = 'type=' . CRM_Import_Parser::DUPLICATE . '&parser=CRM_Event_Import_Parser_Participant';
$this->set('downloadDuplicateRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
elseif ($mismatchCount) {
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Event_Import_Parser_Participant';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
else {
$duplicateRowCount = 0;
$this->set('duplicateRowCount', $duplicateRowCount);
Expand All @@ -69,7 +64,7 @@ public function preProcess() {
/* only subtract dupes from successful import if we're skipping */

$this->set('validRowCount', $totalRowCount - $invalidRowCount -
$duplicateRowCount - $mismatchCount
$duplicateRowCount
);
}
$this->assign('dupeActionString', $dupeActionString);
Expand All @@ -81,9 +76,7 @@ public function preProcess() {
'downloadErrorRecordsUrl',
'duplicateRowCount',
'downloadDuplicateRecordsUrl',
'downloadMismatchRecordsUrl',
'groupAdditions',
'unMatchCount',
];
foreach ($properties as $property) {
$this->assign($property, $this->get($property));
Expand Down
9 changes: 0 additions & 9 deletions CRM/Member/Import/Form/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public function preProcess() {
$dataValues = $this->get('dataValues');
$mapper = $this->get('mapper');
$invalidRowCount = $this->get('invalidRowCount');
$mismatchCount = $this->get('unMatchCount');

//get the mapping name displayed if the mappingId is set
$mappingId = $this->get('loadMappingId');
Expand All @@ -48,11 +47,6 @@ public function preProcess() {
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

if ($mismatchCount) {
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Member_Import_Parser_Membership';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

$properties = [
'mapper',
'dataValues',
Expand All @@ -61,7 +55,6 @@ public function preProcess() {
'validRowCount',
'invalidRowCount',
'downloadErrorRecordsUrl',
'downloadMismatchRecordsUrl',
];
$this->setStatusUrl();

Expand Down Expand Up @@ -151,8 +144,6 @@ public function postProcess() {
$this->set('errorFile', $errorFile);
$urlParams = 'type=' . CRM_Import_Parser::ERROR . '&parser=CRM_Member_Import_Parser_Membership';
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Member_Import_Parser_Membership';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
}

Expand Down
10 changes: 2 additions & 8 deletions CRM/Member/Import/Form/Summary.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,11 @@ public function preProcess() {
$invalidRowCount = $this->get('invalidRowCount');
$duplicateRowCount = $this->get('duplicateRowCount');
$onDuplicate = $this->get('onDuplicate');
$mismatchCount = $this->get('unMatchCount');

if ($duplicateRowCount > 0) {
$urlParams = 'type=' . CRM_Import_Parser::DUPLICATE . '&parser=CRM_Member_Import_Parser_Membership';
$this->set('downloadDuplicateRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
elseif ($mismatchCount) {
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Member_Import_Parser_Membership';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
else {
$duplicateRowCount = 0;
$this->set('duplicateRowCount', $duplicateRowCount);
Expand All @@ -69,7 +65,7 @@ public function preProcess() {
/* only subtract dupes from successful import if we're skipping */

$this->set('validRowCount', $totalRowCount - $invalidRowCount -
$duplicateRowCount - $mismatchCount
$duplicateRowCount
);
}
$this->assign('dupeActionString', $dupeActionString);
Expand All @@ -81,9 +77,7 @@ public function preProcess() {
'downloadErrorRecordsUrl',
'duplicateRowCount',
'downloadDuplicateRecordsUrl',
'downloadMismatchRecordsUrl',
'groupAdditions',
'unMatchCount',
];
foreach ($properties as $property) {
$this->assign($property, $this->get($property));
Expand Down
20 changes: 0 additions & 20 deletions templates/CRM/Activity/Import/Form/Summary.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@
{ts}<strong>Import has completed successfully.</strong> The information below summarizes the results.{/ts}
</p>

{if $unMatchCount }
<p class="error">
{ts count=$unMatchCount plural='CiviCRM has detected mismatched activity IDs. These records have not been Updated.'}CiviCRM has detected mismatched activity ID. This record have not been updated.{/ts}
</p>
<p class="error">
{ts 1=$downloadMismatchRecordsUrl}You can <a href='%1'>Download Mismatched Activity records</a>. You may then correct them, and import the new file with the corrected data.{/ts}
</p>
{/if}

{if $invalidRowCount }
<p class="error">
{ts count=$invalidRowCount plural='CiviCRM has detected invalid data and/or formatting errors in %count records. These records have not been imported.'}CiviCRM has detected invalid data and/or formatting errors in one record. This record have not been imported.{/ts}
Expand Down Expand Up @@ -65,17 +56,6 @@
</tr>
{/if}

{if $unMatchCount }
<tr class="error"><td class="label crm-grid-cell">{ts}Mismatched Rows (skipped){/ts}</td>
<td class="data">{$unMatchCount}</td>
<td class="explanation">{ts}Rows with mismatched activity IDs (NOT updated).{/ts}
{if $unMatchCount}
<p><a href="{$downloadMismatchRecordsUrl}">{ts}Download Mismatched Activity records{/ts}</a></p>
{/if}
</td>
</tr>
{/if}

{if $duplicateRowCount}
<tr class="error"><td class="label crm-grid-cell">{ts}Duplicate Rows{/ts}</td>
<td class="data">{$duplicateRowCount}</td>
Expand Down
19 changes: 0 additions & 19 deletions templates/CRM/Contribute/Import/Form/Summary.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@
<strong>{ts}Import has completed successfully.{/ts}</strong> {ts}The information below summarizes the results.{/ts}
</p>

{if $unMatchCount }
<p class="error">
{ts count=$unMatchCount plural='CiviCRM has detected mismatched contribution IDs. These records have not been Updated.'}CiviCRM has detected mismatched contribution ID. This record has not been updated.{/ts}
</p>
<p class="error">
{ts 1=$downloadMismatchRecordsUrl}You can <a href='%1'>Download Mismatched Contributions</a>. You may then correct them, and import the new file with the corrected data.{/ts}
</p>
{/if}

{if $invalidRowCount }
<p class="error">
{ts count=$invalidRowCount plural='CiviCRM has detected invalid data and/or formatting errors in %count records. These records have not been imported.'}CiviCRM has detected invalid data and/or formatting errors in one record. This record has not been imported.{/ts}
Expand Down Expand Up @@ -99,16 +90,6 @@
</td>
</tr>
{/if}
{if $unMatchCount }
<tr class="error"><td class="label crm-grid-cell">{ts}Mismatched Rows (skipped){/ts}</td>
<td class="data">{$unMatchCount}</td>
<td class="explanation">{ts}Rows with mismatched contribution IDs... (NOT updated).{/ts}
{if $unMatchCount}
<p><a href="{$downloadMismatchRecordsUrl}">{ts}Download Mismatched Contributions{/ts}</a></p>
{/if}
</td>
</tr>
{/if}

{if $duplicateRowCount}
<tr class="error"><td class="label crm-grid-cell">{ts}Duplicate Rows{/ts}</td>
Expand Down
Loading

0 comments on commit a4bf93f

Please sign in to comment.