Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve display of unresolved requests: duplicate referenceids are no…
…w merged into a single column heading for Suggestion #, referenceid, and the "Assign this ReferenceID" button. (CO-2167) (COmanage#40)
arlen committed Oct 27, 2022
1 parent c791de4 commit 520c9be
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions 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 @@
<thead>
<tr>
<td class="empty"></td>
<?php $i = 0; // note that we'll skip the first, "new" record. ?>
<?php foreach($vv_candidates as $c): ?>
<th class="col-names" scope="col">
<?= !empty($c['referenceid']) ? __('match.fd.suggestion.a',[$i]) : __('match.fd.new_record'); ?>
<?php $i = 0; // used to print the suggestion number in the output. ?>
<?php foreach($refIds as $refId => $refIdCount): ?>
<th class="col-names" scope="col" colspan="<?= $refIdCount; ?>">
<?= !empty($refId) ? __('match.fd.suggestion.a',[$i]) : __('match.fd.new_record'); ?>
<?php $i++; ?>
</th>
<?php endforeach; ?>
@@ -90,9 +105,9 @@
<th class="attr-title" scope="row">
<?= __('match.fd.referenceid', [99]); ?>
</th>
<?php foreach($vv_candidates as $c): ?>
<td class="reference-ids">
<?= !empty($c['referenceid']) ? $c['referenceid'] : __('match.op.new'); ?>
<?php foreach($refIds as $refId => $refIdCount): ?>
<td class="reference-ids" colspan="<?= $refIdCount; ?>">
<?= !empty($refId) ? $refId : __('match.op.new'); ?>
</td>
<?php endforeach; ?>
</tr>
@@ -101,16 +116,16 @@
<th class="attr-title" scope="row">
<?= __('match.fd.action'); ?>
</th>
<?php foreach($vv_candidates as $c): ?>
<td class="reconcile-actions">
<?php foreach($refIds as $refId => $refIdCount): ?>
<td class="reconcile-actions" colspan="<?= $refIdCount; ?>">
<?=
$this->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']);

0 comments on commit 520c9be

Please sign in to comment.