From 4b2817264c4308b7968427223c85901a7df3f80e Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Wed, 10 Aug 2022 18:42:23 -0400 Subject: [PATCH] Improve display of unresolved requests: duplicate referenceids are now merged into a single column heading for Suggestion #, referenceid, and the "Assign this ReferenceID" button. (CO-2167) --- app/templates/Matchgrids/reconcile.php | 47 +++++++++++++++++--------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/app/templates/Matchgrids/reconcile.php b/app/templates/Matchgrids/reconcile.php index c701c5305..d4dcbb1c5 100644 --- a/app/templates/Matchgrids/reconcile.php +++ b/app/templates/Matchgrids/reconcile.php @@ -29,25 +29,40 @@ use \App\Lib\Util\ArrayUtil; - // extract the attribute field names into a simple array + // Ensure that the candidates array is sorted by referenceid so we can easily match up identical adjacent referenceids. + // Note that this will retain the "New" record in first position (because the referenceid is empty). + array_multisort(array_column($vv_candidates, 'referenceid'), SORT_ASC, $vv_candidates); + + // Generate the referenceid label output by creating a simple array that contains the unique referenceid values + // along with the count of how many occurrences each has in the $vv_candidates structure (for colspan). + // Note that we must assign an empty string when encountering a NULL referenceid because array_count_values + // can only work on integers or strings. + $refIds = array(); + foreach ($vv_candidates as $candidate) { + $refIds[] = !empty($candidate['referenceid']) ? $candidate['referenceid'] : ''; + } + $refIds = array_count_values($refIds); + + // Extract the attribute field names into a simple array. $fieldNames = array(); foreach ($vv_candidates as $candidate) { $fieldNames = array_keys($candidate); break; } - // remove "referenceid" - it is given special treatment and should not be included in our structure + // Remove "referenceid" from the field names - it is given special treatment and should not be included in our + // attributes structure. array_splice($fieldNames, array_search('referenceid',$fieldNames), 1); - // build the data for the candidates into a structure for generating the view: + // Build the data for the candidates into a structure for generating the view: // attribute field name | attribute values | do the values match? $canAttr = array(); for($i = 0; $i < count($fieldNames); $i++) { - // put the field name in the first column + // Put the field name in the first column. $canAttr[$i][0] = $fieldNames[$i]; - // put all the values for the current attribute into the second column + // Put all the values for the current attribute into the second column. $canAttr[$i][1] = array(); foreach($vv_candidates as $c) { foreach($c as $key => $val) { @@ -75,10 +90,10 @@ - - - - + + $refIdCount): ?> + + @@ -90,9 +105,9 @@ - - - + $refIdCount): ?> + + @@ -101,16 +116,16 @@ - - + $refIdCount): ?> + Form->postLink(__('match.op.reconcile.' . (!empty($c['referenceid']) ? 'assign' : 'generate')), + $this->Form->postLink(__('match.op.reconcile.' . (!empty($refId) ? 'assign' : 'generate')), ['action' => 'reconcile', $vv_cur_mg->id], ['data' => [ 'rowid' => $vv_request['id'], // Default value needs to be the literal string "new" and not a localized text string - 'referenceid' => (!empty($c['referenceid']) ? $c['referenceid'] : 'new') + 'referenceid' => (!empty($refId) ? $refId : 'new') ], 'confirm' => __('match.op.assign.confirm'), 'class' => 'btn btn-primary nospin']);