.
*/
include_once __DIR__.'/../../../core.php';
use Models\Module;
$link_id = (new Module())->GetByName('Preventivi')->id_record;
$fields = [
'Codice preventivo' => 'numero',
'Nome' => 'nome',
'Descrizione' => 'descrizione',
];
$query = 'SELECT *';
foreach ($fields as $name => $value) {
$query .= ', '.$value." AS '".str_replace("'", "\'", $name)."'";
}
$query .= ' FROM co_preventivi WHERE idanagrafica IN('.implode(',', $idanagrafiche).') ';
foreach ($fields as $name => $value) {
$query .= ' OR '.$value.' LIKE "%'.$term.'%"';
}
$query .= Modules::getAdditionalsQuery('Preventivi');
$rs = $dbo->fetchArray($query);
foreach ($rs as $r) {
$result = [];
$result['link'] = base_path().'/editor.php?id_module='.$link_id.'&id_record='.$r['id'];
$result['title'] = 'Preventivo '.$r['numero'];
if ($r['data_accettazione'] == '0000-00-00') {
$result['title'] .= ' del '.Translator::dateToLocale($r['data_accettazione']);
}
$result['category'] = 'Preventivi';
// Campi da evidenziare
$result['labels'] = [];
foreach ($fields as $name => $value) {
if (string_contains($r[$name], $term)) {
$text = str_replace($term, "".$term.'', $r[$name]);
$result['labels'][] = $name.': '.$text.'
';
}
}
// Aggiunta nome anagrafica come ultimo campo
if (sizeof($ragioni_sociali) > 1) {
$result['labels'][] = 'Anagrafica: '.$ragioni_sociali[$r['idanagrafica']].'
';
}
$results[] = $result;
}