1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-26 15:54:17 +01:00

Miglioria filtro = e != nelle tabelle

This commit is contained in:
Pek5892 2023-05-03 10:33:10 +02:00
parent 3955f39852
commit 7de012905d

View File

@ -201,25 +201,28 @@ class Query
$equal = string_starts_with($real_value, '=');
$notequal = string_starts_with($real_value, '!=');
if ($minus || $more || $equal || $notequal) {
if ($minus || $more) {
$sign = string_contains($real_value, '=') ? '=' : '';
if ($more) {
$sign = '>'.$sign;
} elseif ($minus) {
$sign = '<'.$sign;
} elseif ($equal) {
$sign = '=';
} else {
$sign = '!=';
}
$value = trim(str_replace(['&lt;', '=', '&gt;', '!'], '', $value));
$value = trim(str_replace(['&lt;', '&gt;'], '', $value));
if ($more || $minus) {
$search_filters[] = 'CAST('.$search_query.' AS UNSIGNED) '.$sign.' '.prepare($value);
} else {
$search_filters[] = $search_query.' '.$sign.' '.prepare($value);
}
} else if ($equal){
$value = trim(str_replace(['='], '', $value));
$search_filters[] = ($search_query.' = '.prepare($value). ' OR '.$search_query.' LIKE '.prepare('% '.$value) . ' OR '.$search_query.' LIKE '.prepare($value.' %').' OR '.$search_query.' LIKE '.prepare('% '.$value.' %'));
} else if ($notequal) {
$value = trim(str_replace(['!='], '', $value));
$search_filters[] = ($search_query.' != '.prepare($value). ' AND '.$search_query.' NOT LIKE '.prepare('% '.$value) . ' AND '.$search_query.' NOT LIKE '.prepare($value.' %').' AND '.$search_query.' NOT LIKE '.prepare('% '.$value.' %'));
} else {
$search_filters[] = $search_query.' LIKE '.prepare('%'.$value.'%');
}