Skip to content
Snippets Groups Projects
Verified Commit 14592fa4 authored by Damien's avatar Damien
Browse files

FEAT #15401 TIME 1:30 Search Format Registered mail number if necessary

parent 18d8bf8a
No related branches found
No related tags found
No related merge requests found
...@@ -327,17 +327,21 @@ class SearchController ...@@ -327,17 +327,21 @@ class SearchController
if (!empty($body['meta']) && !empty($body['meta']['values']) && is_string($body['meta']['values'])) { if (!empty($body['meta']) && !empty($body['meta']['values']) && is_string($body['meta']['values'])) {
if ($body['meta']['values'][0] == '"' && $body['meta']['values'][strlen($body['meta']['values']) - 1] == '"') { if ($body['meta']['values'][0] == '"' && $body['meta']['values'][strlen($body['meta']['values']) - 1] == '"') {
$quick = trim($body['meta']['values'], '"'); $quick = trim($body['meta']['values'], '"');
$quickWhere = "subject = ? OR alt_identifier = ? OR barcode = ?"; $quickWhere = "subject = ? OR replace(alt_identifier, ' ', '') = ? OR barcode = ?";
$quickWhere .= " OR res_id in (select res_id_master from res_attachments where (title = ? OR identifier = ?) and status in ('TRA', 'A_TRA', 'FRZ'))"; $quickWhere .= " OR res_id in (select res_id_master from res_attachments where (title = ? OR identifier = ?) and status in ('TRA', 'A_TRA', 'FRZ'))";
$whiteStrippedChrono = str_replace(' ', '', $quick);
$args['searchData'] = array_merge($args['searchData'], [$quick, $whiteStrippedChrono, $quick, $quick, $quick]);
if (ctype_digit($quick)) { if (ctype_digit($quick)) {
$quickWhere .= ' OR res_id = ?'; $quickWhere .= ' OR res_id = ?';
$args['searchData'][] = $quick; $args['searchData'][] = $quick;
} }
$args['searchWhere'][] = '(' . $quickWhere . ')'; $args['searchWhere'][] = '(' . $quickWhere . ')';
$args['searchData'] = array_merge($args['searchData'], [$quick, $quick, $quick, $quick, $quick]);
} else { } else {
$fields = ['subject', 'alt_identifier', 'barcode']; $fields = ['subject', 'replace(alt_identifier, \' \', \'\')', 'barcode'];
$fields = AutoCompleteController::getInsensitiveFieldsForRequest(['fields' => $fields]); $fields = AutoCompleteController::getInsensitiveFieldsForRequest(['fields' => $fields]);
$requestDataDocument = AutoCompleteController::getDataForRequest([ $requestDataDocument = AutoCompleteController::getDataForRequest([
'search' => $body['meta']['values'], 'search' => $body['meta']['values'],
...@@ -416,8 +420,9 @@ class SearchController ...@@ -416,8 +420,9 @@ class SearchController
} }
} }
if (!empty($body['chrono']) && !empty($body['chrono']['values']) && is_string($body['chrono']['values'])) { if (!empty($body['chrono']) && !empty($body['chrono']['values']) && is_string($body['chrono']['values'])) {
$args['searchWhere'][] = '(alt_identifier ilike ? OR res_id in (select res_id_master from res_attachments where identifier ilike ? and status in (\'TRA\', \'A_TRA\', \'FRZ\')))'; $args['searchWhere'][] = '(replace(alt_identifier, \' \', \'\') ilike ? OR res_id in (select res_id_master from res_attachments where identifier ilike ? and status in (\'TRA\', \'A_TRA\', \'FRZ\')))';
$args['searchData'][] = "%{$body['chrono']['values']}%"; $whiteStrippedChrono = str_replace(' ', '', $body['chrono']['values']);
$args['searchData'][] = "%{$whiteStrippedChrono}%";
$args['searchData'][] = "%{$body['chrono']['values']}%"; $args['searchData'][] = "%{$body['chrono']['values']}%";
} }
if (!empty($body['barcode']) && !empty($body['barcode']['values']) && is_string($body['barcode']['values'])) { if (!empty($body['barcode']) && !empty($body['barcode']['values']) && is_string($body['barcode']['values'])) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment