2018-02-03 15:03:48 +01:00
< ? php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager : il software gestionale open source per l ' assistenza tecnica e la fatturazione
2021-01-20 15:08:51 +01:00
* Copyright ( C ) DevCode s . r . l .
2020-09-07 15:04:06 +02:00
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < https :// www . gnu . org / licenses />.
*/
2018-02-03 15:03:48 +01:00
2018-02-03 16:29:53 +01:00
include_once __DIR__ . '/../../../core.php' ;
2023-01-18 16:07:48 +01:00
$filter_agente = Auth :: user ()[ 'gruppo' ] == 'Agenti' ;
2018-02-03 15:03:48 +01:00
switch ( $resource ) {
case 'clienti' :
2022-07-07 17:28:18 +02:00
$id_azienda = setting ( 'Azienda predefinita' );
2022-12-31 19:28:46 +01:00
$query = " SELECT
2024-02-05 17:07:33 +01:00
`an_anagrafiche` . `idanagrafica` AS id ,
`an_anagrafiche` . `lat` ,
`an_anagrafiche` . `lng` ,
`is_bloccata` ,
CONCAT ( `ragione_sociale` , IF ( `citta` IS NULL OR `citta` = '' , '' , CONCAT ( ' (' , `citta` , ')' )), IF ( `an_anagrafiche` . `deleted_at` IS NULL , '' , ' (".tr(' eliminata ').")' ), IF ( `is_bloccata` = 1 , CONCAT ( ' (' , `an_relazioni_lang` . `name` , ')' ), '' ), ' - ' , `an_anagrafiche` . `codice` ) AS descrizione ,
`idtipointervento_default` AS idtipointervento ,
2024-02-28 16:28:53 +01:00
`in_tipiintervento_lang` . `name` AS idtipointervento_descrizione ,
2024-02-05 17:07:33 +01:00
`an_anagrafiche` . `idzona` ,
`contratto` . `id` AS id_contratto ,
`contratto` . `descrizione` AS descrizione_contratto ,
`co_pagamenti` . `id` AS id_pagamento ,
2024-02-08 13:10:46 +01:00
`co_pagamenti_lang` . `name` AS desc_pagamento ,
2024-02-05 17:07:33 +01:00
`banca_vendite` . `id` AS id_banca_vendite ,
CONCAT ( `banca_vendite` . `nome` , ' - ' , `banca_vendite` . `iban` ) AS descrizione_banca_vendite
2022-12-31 19:28:46 +01:00
FROM
2024-02-05 17:07:33 +01:00
`an_anagrafiche`
INNER JOIN ( `an_tipianagrafiche_anagrafiche`
INNER JOIN `an_tipianagrafiche` ON `an_tipianagrafiche_anagrafiche` . `idtipoanagrafica` = `an_tipianagrafiche` . `id`
2024-03-13 11:38:29 +01:00
LEFT JOIN `an_tipianagrafiche_lang` ON ( `an_tipianagrafiche` . `id` = `an_tipianagrafiche_lang` . `id_record` AND `an_tipianagrafiche_lang` . `id_lang` = " .prepare( \ App::getLang()). " ))
ON `an_anagrafiche` . `idanagrafica` = `an_tipianagrafiche_anagrafiche` . `idanagrafica` LEFT JOIN `in_tipiintervento` ON `an_anagrafiche` . `idtipointervento_default` = `in_tipiintervento` . `id` LEFT JOIN `in_tipiintervento_lang` ON ( `in_tipiintervento` . `id` = `in_tipiintervento_lang` . `id_record` AND `in_tipiintervento_lang` . `id_lang` = " .prepare( \ App::getLang()). " )
2024-02-05 17:07:33 +01:00
LEFT JOIN `an_relazioni` ON `an_anagrafiche` . `idrelazione` = `an_relazioni` . `id`
2024-03-13 11:38:29 +01:00
LEFT JOIN `an_relazioni_lang` ON ( `an_relazioni` . `id` = `an_relazioni_lang` . `id_record` AND `an_relazioni_lang` . `id_lang` = " .prepare( \ App::getLang()). " )
2022-12-31 19:28:46 +01:00
LEFT JOIN
2024-03-13 11:38:29 +01:00
( SELECT `co_contratti` . `id` , `idanagrafica` , CONCAT ( 'Contratto ' , `numero` , ' del ' , DATE_FORMAT ( `data_bozza` , '%d/%m/%Y' ), ' - ' , `co_contratti` . `nome` , ' [' , `co_staticontratti_lang` . `name` , ']' ) AS descrizione FROM `co_contratti` LEFT JOIN `co_staticontratti` ON `co_contratti` . `idstato` = `co_staticontratti` . `id` LEFT JOIN `co_staticontratti_lang` ON ( `co_staticontratti` . `id` = `co_staticontratti_lang` . `id_record` AND `co_staticontratti_lang` . `id_lang` = " .prepare( \ App::getLang()). " ) WHERE `co_contratti` . `predefined` = 1 AND `is_pianificabile` = 1 ) AS contratto
2024-02-05 17:07:33 +01:00
ON `an_anagrafiche` . `idanagrafica` = `contratto` . `idanagrafica`
2024-02-08 13:10:46 +01:00
LEFT JOIN `co_pagamenti` ON `an_anagrafiche` . `idpagamento_vendite` = `co_pagamenti` . `id`
2024-03-13 11:38:29 +01:00
LEFT JOIN `co_pagamenti_lang` ON ( `co_pagamenti` . `id` = `co_pagamenti_lang` . `id_record` AND `co_pagamenti_lang` . `id_lang` = " .prepare( \ App::getLang()). " )
2022-12-31 19:28:46 +01:00
LEFT JOIN
2024-02-05 17:07:33 +01:00
`co_banche` banca_vendite
2024-03-13 11:38:29 +01:00
ON `co_pagamenti` . `idconto_vendite` = `banca_vendite` . `id_pianodeiconti3` AND `banca_vendite` . `id_anagrafica` = " .prepare( $id_azienda ). " AND `banca_vendite` . `deleted_at` IS NULL AND `banca_vendite` . `predefined` = 1
2022-12-31 19:28:46 +01:00
| where |
ORDER BY
2024-03-13 11:38:29 +01:00
`ragione_sociale` " ;
2018-02-03 15:03:48 +01:00
2019-08-29 15:09:01 +02:00
foreach ( $elements as $element ) {
2024-02-05 17:07:33 +01:00
$filter [] = '`an_anagrafiche`.`idanagrafica`=' . prepare ( $element );
2019-08-29 15:09:01 +02:00
}
2018-02-03 15:03:48 +01:00
2024-02-05 17:07:33 +01:00
$where [] = " `an_tipianagrafiche_lang`.`name`='Cliente' " ;
2019-08-29 15:09:01 +02:00
if ( empty ( $filter )) {
2024-02-05 17:07:33 +01:00
$where [] = '`an_anagrafiche`.`deleted_at` IS NULL' ;
2018-02-03 15:03:48 +01:00
2023-05-25 12:57:40 +02:00
if ( ! empty ( $filter_agente )) {
2024-02-05 17:07:33 +01:00
$where [] = '`idagente` = ' . Auth :: user ()[ 'idanagrafica' ];
2023-05-25 12:57:40 +02:00
}
2023-01-18 16:07:48 +01:00
}
2019-08-29 15:09:01 +02:00
if ( ! empty ( $search )) {
2024-02-05 17:07:33 +01:00
$search_fields [] = '`ragione_sociale` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`citta` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`provincia` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`codice` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`piva` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`codice_fiscale` LIKE ' . prepare ( '%' . $search . '%' );
2019-08-29 15:09:01 +02:00
}
2018-02-03 15:03:48 +01:00
2022-02-06 10:06:48 +01:00
$data = AJAX :: selectResults ( $query , $where , $filter , $search_fields , $limit , $custom );
$rs = $data [ 'results' ];
foreach ( $rs as $k => $r ) {
$rs [ $k ] = array_merge ( $r , [
'text' => $r [ 'descrizione' ],
'disabled' => $r [ 'is_bloccata' ],
]);
}
$results = [
'results' => $rs ,
'recordsFiltered' => $data [ 'recordsFiltered' ],
];
2018-02-03 15:03:48 +01:00
break ;
case 'fornitori' :
2022-07-07 17:28:18 +02:00
$id_azienda = setting ( 'Azienda predefinita' );
2024-02-08 13:10:46 +01:00
$query = " SELECT
`an_anagrafiche` . `idanagrafica` AS id ,
CONCAT ( `ragione_sociale` , IF ( `citta` IS NULL OR `citta` = '' , '' , CONCAT ( ' (' , `citta` , ')' )), IF ( `an_anagrafiche` . `deleted_at` IS NULL , '' , ' (".tr(' eliminata ').")' ), ' - ' , `an_anagrafiche` . `codice` ) AS descrizione ,
`idtipointervento_default` AS `idtipointervento` ,
`co_pagamenti` . `id` AS id_pagamento ,
`co_pagamenti_lang` . `name` AS desc_pagamento ,
`banca_acquisti` . `id` AS id_banca_acquisti ,
CONCAT ( `banca_acquisti` . `nome` , ' - ' , `banca_acquisti` . `iban` ) AS descrizione_banca_acquisti
FROM
`an_anagrafiche`
INNER JOIN (
`an_tipianagrafiche_anagrafiche`
INNER JOIN `an_tipianagrafiche` ON `an_tipianagrafiche_anagrafiche` . `idtipoanagrafica` = `an_tipianagrafiche` . `id`
2024-03-13 11:38:29 +01:00
LEFT JOIN `an_tipianagrafiche_lang` ON ( `an_tipianagrafiche` . `id` = `an_tipianagrafiche_lang` . `id_record` AND `an_tipianagrafiche_lang` . `id_lang` = " .prepare( \ App::getLang()).')) ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica`
2024-02-08 13:10:46 +01:00
LEFT JOIN `co_pagamenti` ON `an_anagrafiche` . `idpagamento_acquisti` = `co_pagamenti` . `id`
2024-03-13 11:38:29 +01:00
LEFT JOIN `co_pagamenti_lang` co_pagamenti_lang ON ( `co_pagamenti` . `id` = `co_pagamenti_lang` . `id_record` AND `co_pagamenti_lang` . `id_lang` = ' . prepare ( \App :: getLang ()) . " )
2024-02-08 13:10:46 +01:00
LEFT JOIN `co_banche` banca_acquisti ON `co_pagamenti` . `idconto_acquisti` = `banca_acquisti` . `id_pianodeiconti3` AND `banca_acquisti` . `id_anagrafica` = '.prepare($id_azienda).' AND `banca_acquisti` . `deleted_at` IS NULL AND `banca_acquisti` . `predefined` = 1
| where |
ORDER BY
`ragione_sociale` " ;
2018-02-03 15:03:48 +01:00
2019-08-29 15:09:01 +02:00
foreach ( $elements as $element ) {
2024-02-05 17:07:33 +01:00
$filter [] = '`an_anagrafiche`.`idanagrafica`=' . prepare ( $element );
2019-08-29 15:09:01 +02:00
}
2018-02-03 15:03:48 +01:00
2019-08-29 15:09:01 +02:00
if ( empty ( $filter )) {
2024-02-08 13:10:46 +01:00
$where [] = " `an_tipianagrafiche_lang`.`name` = 'Fornitore' " ;
2024-02-05 17:07:33 +01:00
$where [] = '`an_anagrafiche`.`deleted_at` IS NULL' ;
2019-08-29 15:09:01 +02:00
}
2018-02-03 15:03:48 +01:00
2019-08-29 15:09:01 +02:00
if ( ! empty ( $search )) {
2024-02-05 17:07:33 +01:00
$search_fields [] = '`ragione_sociale` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`citta` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`provincia` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`codice` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`piva` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`codice_fiscale` LIKE ' . prepare ( '%' . $search . '%' );
2019-08-29 15:09:01 +02:00
}
2018-02-03 15:03:48 +01:00
break ;
2018-11-30 16:10:15 +01:00
case 'vettori' :
2024-03-13 11:38:29 +01:00
$query = " SELECT `an_anagrafiche`.`idanagrafica` AS id, CONCAT(`ragione_sociale`, IF(`citta` IS NULL OR `citta` = '', '', CONCAT(' (', `citta`, ')')), IF(`an_anagrafiche`.`deleted_at` IS NULL, '', ' ( " . tr ( 'eliminata' ) . " )'),' - ', `an_anagrafiche`.`codice`) AS descrizione, `idtipointervento_default` AS idtipointervento FROM `an_anagrafiche` INNER JOIN (`an_tipianagrafiche_anagrafiche` INNER JOIN `an_tipianagrafiche` ON `an_tipianagrafiche_anagrafiche`.`idtipoanagrafica`=`an_tipianagrafiche`.`id` LEFT JOIN `an_tipianagrafiche_lang` ON (`an_tipianagrafiche`.`id` = `an_tipianagrafiche_lang`.`id_record` AND `an_tipianagrafiche_lang`.`id_lang` = " . prepare ( \App :: getLang ()) . ')) ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica` |where| ORDER BY `ragione_sociale`' ;
2018-11-27 11:43:22 +01:00
2019-08-29 15:09:01 +02:00
foreach ( $elements as $element ) {
2024-02-05 17:07:33 +01:00
$filter [] = '`an_anagrafiche`.`idanagrafica`=' . prepare ( $element );
2019-08-29 15:09:01 +02:00
}
2018-11-27 11:43:22 +01:00
2024-02-05 17:07:33 +01:00
$where [] = " `name`='Vettore' " ;
2019-08-29 15:09:01 +02:00
if ( empty ( $filter )) {
2024-02-05 17:07:33 +01:00
$where [] = '`an_anagrafiche`.`deleted_at` IS NULL' ;
2019-08-29 15:09:01 +02:00
}
2018-02-03 15:03:48 +01:00
2019-08-29 15:09:01 +02:00
if ( ! empty ( $search )) {
2024-02-05 17:07:33 +01:00
$search_fields [] = '`ragione_sociale` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`citta` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`provincia` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`codice` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`piva` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`codice_fiscale` LIKE ' . prepare ( '%' . $search . '%' );
2019-08-29 15:09:01 +02:00
}
2018-11-27 11:43:22 +01:00
break ;
2018-11-30 16:10:15 +01:00
2024-01-15 15:30:45 +01:00
/*
* Opzioni utilizzate :
* - idanagrafica
*/
2018-02-03 15:03:48 +01:00
case 'agenti' :
2024-03-13 11:38:29 +01:00
$query = " SELECT `an_anagrafiche`.`idanagrafica` AS id, CONCAT(`ragione_sociale`, IF(`citta` IS NULL OR `citta` = '', '', CONCAT(' (', `citta`, ')')), IF(`an_anagrafiche`.`deleted_at` IS NULL, '', ' ( " . tr ( 'eliminata' ) . " )'),' - ', `an_anagrafiche`.`codice`) AS descrizione, `idtipointervento_default` FROM `an_anagrafiche` INNER JOIN (`an_tipianagrafiche_anagrafiche` INNER JOIN `an_tipianagrafiche` ON `an_tipianagrafiche_anagrafiche`.`idtipoanagrafica`=`an_tipianagrafiche`.`id` LEFT JOIN `an_tipianagrafiche_lang` ON (`an_tipianagrafiche`.`id` = `an_tipianagrafiche_lang`.`id_record` AND `an_tipianagrafiche_lang`.`id_lang` = " . prepare ( \App :: getLang ()) . ')) ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica` |where| ORDER BY `ragione_sociale`' ;
2018-02-03 15:03:48 +01:00
2019-08-29 15:09:01 +02:00
foreach ( $elements as $element ) {
2024-02-05 17:07:33 +01:00
$filter [] = '`an_anagrafiche`.`idanagrafica`=' . prepare ( $element );
2019-08-29 15:09:01 +02:00
}
2018-02-03 15:03:48 +01:00
2024-02-05 17:07:33 +01:00
$where [] = " `name`='Agente' " ;
2019-08-29 15:09:01 +02:00
if ( empty ( $filter )) {
2024-02-05 17:07:33 +01:00
$where [] = '`an_anagrafiche`.`deleted_at` IS NULL' ;
2019-08-29 15:09:01 +02:00
}
2018-02-03 15:03:48 +01:00
2019-08-29 15:09:01 +02:00
if ( ! empty ( $search )) {
2024-02-05 17:07:33 +01:00
$search_fields [] = '`ragione_sociale` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`citta` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`provincia` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`codice` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`piva` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`codice_fiscale` LIKE ' . prepare ( '%' . $search . '%' );
2019-08-29 15:09:01 +02:00
}
2018-02-03 15:03:48 +01:00
2019-08-29 15:09:01 +02:00
$results = AJAX :: selectResults ( $query , $where , $filter , $search , $limit , $custom );
2018-02-03 15:03:48 +01:00
2019-08-29 15:09:01 +02:00
// Evidenzia l'agente di default
if ( $superselect [ 'idanagrafica' ]) {
2024-02-05 17:07:33 +01:00
$rsa = $dbo -> fetchArray ( 'SELECT `idagente` FROM `an_anagrafiche` WHERE `idanagrafica`=' . prepare ( $superselect [ 'idanagrafica' ]));
2019-08-29 15:09:01 +02:00
$idagente_default = $rsa [ 0 ][ 'idagente' ];
} else {
$idagente_default = 0 ;
}
2018-02-03 15:03:48 +01:00
2022-05-18 16:18:04 +02:00
$ids = array_column ( $results [ 'results' ], 'id' );
2019-08-29 15:09:01 +02:00
$pos = array_search ( $idagente_default , $ids );
if ( $pos !== false ) {
2022-05-26 15:39:29 +02:00
$results [ 'results' ][ $pos ][ '_bgcolor_' ] = '#ffff00' ;
2019-08-29 15:09:01 +02:00
}
2018-02-03 15:03:48 +01:00
break ;
case 'tecnici' :
2024-03-13 11:38:29 +01:00
$query = " SELECT `an_anagrafiche`.`idanagrafica` AS id, CONCAT(`ragione_sociale`, IF(`citta` IS NULL OR `citta` = '', '', CONCAT(' (', `citta`, ')')), IF(`an_anagrafiche`.`deleted_at` IS NULL, '', ' ( " . tr ( 'eliminata' ) . " )'),' - ', `an_anagrafiche`.`codice`) AS descrizione, `idtipointervento_default` FROM `an_anagrafiche` INNER JOIN (`an_tipianagrafiche_anagrafiche` INNER JOIN `an_tipianagrafiche` ON `an_tipianagrafiche_anagrafiche`.`idtipoanagrafica`=`an_tipianagrafiche`.`id` LEFT JOIN `an_tipianagrafiche_lang` ON (`an_tipianagrafiche`.`id` = `an_tipianagrafiche_lang`.`id_record` AND `an_tipianagrafiche_lang`.`id_lang` = " . prepare ( \App :: getLang ()) . ')) ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica` |where| ORDER BY `ragione_sociale`' ;
2018-06-26 10:25:50 +02:00
2019-08-29 15:09:01 +02:00
foreach ( $elements as $element ) {
2024-02-05 17:07:33 +01:00
$filter [] = '`an_anagrafiche`.`idanagrafica`=' . prepare ( $element );
2019-08-29 15:09:01 +02:00
}
2018-02-03 15:03:48 +01:00
2024-02-05 17:07:33 +01:00
$where [] = " `name`='Tecnico' " ;
2019-08-29 15:09:01 +02:00
if ( empty ( $filter )) {
2024-02-05 17:07:33 +01:00
$where [] = '`an_anagrafiche`.`deleted_at` IS NULL' ;
2018-06-26 10:25:50 +02:00
2019-12-13 10:08:17 +01:00
if ( setting ( 'Permetti inserimento sessioni degli altri tecnici' )) {
} else {
2024-01-15 15:30:45 +01:00
// come tecnico posso aprire attività solo a mio nome
2019-12-09 17:47:07 +01:00
$user = Auth :: user ();
if ( $user [ 'gruppo' ] == 'Tecnici' && ! empty ( $user [ 'idanagrafica' ])) {
2024-02-05 17:07:33 +01:00
$where [] = '`an_anagrafiche`.`idanagrafica`=' . $user [ 'idanagrafica' ];
2019-12-09 17:47:07 +01:00
}
2018-02-03 15:03:48 +01:00
}
2019-08-29 15:09:01 +02:00
}
2018-02-03 15:03:48 +01:00
2019-08-29 15:09:01 +02:00
if ( ! empty ( $search )) {
2024-02-05 17:07:33 +01:00
$search_fields [] = '`ragione_sociale` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`citta` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`provincia` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`codice` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`piva` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`codice_fiscale` LIKE ' . prepare ( '%' . $search . '%' );
2019-08-29 15:09:01 +02:00
}
2018-02-03 15:03:48 +01:00
break ;
2018-11-22 15:34:44 +01:00
2019-08-29 15:09:01 +02:00
case 'clienti_fornitori' :
2024-03-13 11:38:29 +01:00
$query = " SELECT `an_anagrafiche`.`idanagrafica` AS id, CONCAT_WS('', `ragione_sociale`, IF(`citta` !='' OR `provincia` != '', CONCAT(' (', `citta`, IF(`provincia`!='', CONCAT(' ', `provincia`), ''), ')'), ''), IF(`an_anagrafiche`.`deleted_at` IS NULL, '', ' ( " . tr ( 'eliminata' ) . " )'),' - ', `an_anagrafiche`.`codice`) AS descrizione, `an_tipianagrafiche_lang`.`name` AS optgroup, `idtipointervento_default`, `an_tipianagrafiche`.`id` as id_tipo FROM `an_tipianagrafiche` LEFT JOIN `an_tipianagrafiche_lang` ON (`an_tipianagrafiche`.`id` = `an_tipianagrafiche_lang`.`id_record` AND `an_tipianagrafiche_lang`.`id_lang` = " . prepare ( \App :: getLang ()) . ') INNER JOIN `an_tipianagrafiche_anagrafiche` ON `an_tipianagrafiche`.`id`=`an_tipianagrafiche_anagrafiche`.`idtipoanagrafica` INNER JOIN `an_anagrafiche` ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica` |where| ORDER BY `optgroup` ASC, `ragione_sociale` ASC' ;
2018-11-20 11:53:58 +01:00
2018-11-22 15:34:44 +01:00
foreach ( $elements as $element ) {
2024-02-05 17:07:33 +01:00
$filter [] = '`an_anagrafiche`.`idanagrafica`=' . prepare ( $element );
2018-11-22 15:34:44 +01:00
}
2018-11-22 10:05:45 +01:00
$where = [];
2018-11-22 15:34:44 +01:00
if ( empty ( $filter )) {
2024-02-05 17:07:33 +01:00
$where [] = '`an_anagrafiche`.`deleted_at` IS NULL' ;
2024-03-13 11:38:29 +01:00
$where [] = '`an_tipianagrafiche_anagrafiche`.`idtipoanagrafica` IN (SELECT `an_tipianagrafiche`.`id` FROM `an_tipianagrafiche` LEFT JOIN `an_tipianagrafiche_lang` ON (`an_tipianagrafiche`.`id` = `an_tipianagrafiche_lang`.`id_record` AND `an_tipianagrafiche_lang`.`id_lang` = ' . prepare ( \App :: getLang ()) . " ) WHERE `name` = 'Cliente' OR `name` = 'Fornitore' OR `name` = 'Azienda') " ;
2018-11-22 15:34:44 +01:00
}
if ( ! empty ( $search )) {
2024-02-05 17:07:33 +01:00
$search_fields [] = '`ragione_sociale` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`citta` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`provincia` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`codice` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`piva` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`codice_fiscale` LIKE ' . prepare ( '%' . $search . '%' );
2018-11-22 15:34:44 +01:00
}
// Aggiunta filtri di ricerca
2018-11-22 10:05:45 +01:00
if ( ! empty ( $search_fields )) {
$where [] = '(' . implode ( ' OR ' , $search_fields ) . ')' ;
}
2018-11-22 15:34:44 +01:00
2018-11-22 10:05:45 +01:00
if ( ! empty ( $filter )) {
$where [] = '(' . implode ( ' OR ' , $filter ) . ')' ;
}
2018-11-22 15:34:44 +01:00
2018-11-22 10:05:45 +01:00
$query = str_replace ( '|where|' , ! empty ( $where ) ? 'WHERE ' . implode ( ' AND ' , $where ) : '' , $query );
2018-11-20 11:53:58 +01:00
$rs = $dbo -> fetchArray ( $query );
foreach ( $rs as $r ) {
if ( $prev != $r [ 'optgroup' ]) {
$results [] = [ 'text' => $r [ 'optgroup' ], 'children' => []];
$prev = $r [ 'optgroup' ];
}
$results [ count ( $results ) - 1 ][ 'children' ][] = [
'id' => $r [ 'id' ],
'text' => $r [ 'descrizione' ],
'descrizione' => $r [ 'descrizione' ],
];
}
2018-02-03 15:03:48 +01:00
2018-11-20 11:53:58 +01:00
break ;
2018-11-22 15:34:44 +01:00
2024-01-15 15:30:45 +01:00
// Nota Bene: nel campo id viene specificato idtipoanagrafica-idanagrafica -> modulo Utenti e permessi, creazione nuovo utente
2018-02-03 15:03:48 +01:00
case 'anagrafiche' :
2024-03-13 11:38:29 +01:00
$query = " SELECT `an_anagrafiche`.`idanagrafica` AS id, CONCAT_WS('', `ragione_sociale`, IF(`citta` !='' OR `provincia` != '', CONCAT(' (', `citta`, IF(`provincia`!='', CONCAT(' ', `provincia`), ''), ')'), ''), IF(`an_anagrafiche`.`deleted_at` IS NULL, '', ' ( " . tr ( 'eliminata' ) . " )'),' - ', `an_anagrafiche`.`codice`) AS descrizione, `an_tipianagrafiche_lang`.`name` AS optgroup FROM `an_anagrafiche` INNER JOIN (`an_tipianagrafiche_anagrafiche` INNER JOIN `an_tipianagrafiche` ON `an_tipianagrafiche_anagrafiche`.`idtipoanagrafica`=`an_tipianagrafiche`.`id` LEFT JOIN `an_tipianagrafiche_lang` ON (`an_tipianagrafiche`.`id` = `an_tipianagrafiche_lang`.`id_record` AND `an_tipianagrafiche_lang`.`id_lang` = " . prepare ( \App :: getLang ()) . ')) ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica` |where| ORDER BY `optgroup` ASC, `ragione_sociale` ASC' ;
2018-02-03 15:03:48 +01:00
2019-08-29 15:09:01 +02:00
foreach ( $elements as $element ) {
2024-02-05 17:07:33 +01:00
$filter [] = '`an_anagrafiche`.`idanagrafica`=' . prepare ( $element );
2019-08-29 15:09:01 +02:00
}
2018-02-03 15:03:48 +01:00
2019-08-29 15:09:01 +02:00
if ( empty ( $filter )) {
2024-02-05 17:07:33 +01:00
$where [] = '`an_anagrafiche`.`deleted_at` IS NULL' ;
2019-08-29 15:09:01 +02:00
}
2018-02-03 15:03:48 +01:00
2019-08-29 15:09:01 +02:00
if ( ! empty ( $search )) {
2024-02-05 17:07:33 +01:00
$search_fields [] = '`ragione_sociale` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`citta` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`provincia` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`codice` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`piva` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_anagrafiche`.`codice_fiscale` LIKE ' . prepare ( '%' . $search . '%' );
2019-08-29 15:09:01 +02:00
}
2019-08-27 17:25:52 +02:00
2019-08-29 15:09:01 +02:00
// Aggiunta filtri di ricerca
if ( ! empty ( $search_fields )) {
$where [] = '(' . implode ( ' OR ' , $search_fields ) . ')' ;
}
2019-08-27 17:25:52 +02:00
2019-08-29 15:09:01 +02:00
if ( ! empty ( $filter )) {
$where [] = '(' . implode ( ' OR ' , $filter ) . ')' ;
}
2019-08-27 17:25:52 +02:00
2019-08-29 15:09:01 +02:00
$query = str_replace ( '|where|' , ! empty ( $where ) ? 'WHERE ' . implode ( ' AND ' , $where ) : '' , $query );
2019-08-27 17:25:52 +02:00
2019-08-29 15:09:01 +02:00
$rs = $dbo -> fetchArray ( $query );
foreach ( $rs as $r ) {
if ( $prev != $r [ 'optgroup' ]) {
$results [] = [ 'text' => $r [ 'optgroup' ], 'children' => []];
$prev = $r [ 'optgroup' ];
2019-08-27 17:25:52 +02:00
}
2019-08-29 15:09:01 +02:00
$results [ count ( $results ) - 1 ][ 'children' ][] = [
'id' => $r [ 'id' ],
'text' => $r [ 'descrizione' ],
'descrizione' => $r [ 'descrizione' ],
];
}
2018-02-03 15:03:48 +01:00
break ;
2024-01-15 15:30:45 +01:00
/*
* Opzioni utilizzate :
* - idanagrafica
*/
2018-02-03 15:03:48 +01:00
case 'sedi' :
2018-02-03 16:29:53 +01:00
if ( isset ( $superselect [ 'idanagrafica' ])) {
2022-12-31 19:28:46 +01:00
$query = "
SELECT
*
FROM
2024-02-05 17:07:33 +01:00
( SELECT '0' AS id , ( SELECT `lat` FROM `an_anagrafiche` | where | ) AS lat , ( SELECT `lng` FROM `an_anagrafiche` | where | ) AS lng , ( SELECT `idzona` FROM `an_anagrafiche` | where | ) AS idzona , CONCAT_WS ( ' - ' , \ " " . tr ( 'Sede legale' ) . " \" , (SELECT CONCAT (`citta`, IF(`indirizzo`!='',CONCAT(' (', `indirizzo`, ')'), ''), ' (',`ragione_sociale`,')') FROM `an_anagrafiche` |where|)) AS descrizione
2022-12-31 19:28:46 +01:00
UNION
SELECT
2024-02-05 17:07:33 +01:00
`id` ,
`lat` ,
`lng` ,
`idzona` ,
CONCAT_WS ( ' - ' , `nomesede` , CONCAT ( `citta` , IF ( indirizzo != '' , CONCAT ( ' (' , `indirizzo` , ')' ), '' )) ) FROM `an_sedi` | where | ) AS tab
2022-12-31 19:28:46 +01:00
HAVING
2024-02-05 17:07:33 +01:00
`descrizione` LIKE " .prepare('%'. $search .'%').'
2022-12-31 19:28:46 +01:00
ORDER BY
2024-02-05 17:07:33 +01:00
`descrizione` ' ;
2018-02-03 15:03:48 +01:00
foreach ( $elements as $element ) {
2024-02-05 17:07:33 +01:00
$filter [] = '`id`=' . prepare ( $element );
2018-02-03 15:03:48 +01:00
}
2024-02-05 17:07:33 +01:00
$where [] = '`idanagrafica`=' . prepare ( $superselect [ 'idanagrafica' ]);
2018-02-03 15:03:48 +01:00
2020-11-25 17:35:06 +01:00
/*
2019-05-29 19:17:57 +02:00
if ( ! empty ( $search )) {
$search_fields [] = 'citta LIKE ' . prepare ( '%' . $search . '%' );
}
2020-11-25 17:35:06 +01:00
*/
2019-05-29 19:17:57 +02:00
}
break ;
case 'sedi_azienda' :
2020-07-31 14:25:50 +02:00
$user = Auth :: user ();
$id_azienda = setting ( 'Azienda predefinita' );
2019-05-29 19:17:57 +02:00
2024-02-05 17:07:33 +01:00
$query = " SELECT * FROM (SELECT '0' AS id, 'Sede legale' AS `nomesede`, CONCAT_WS(' - ', \" " . tr ( 'Sede legale' ) . " \" , (SELECT CONCAT (`citta`, IF(`indirizzo`!='',CONCAT(' (', `indirizzo`, ')'), ''),' (', `ragione_sociale`,')') FROM `an_anagrafiche` |where|)) AS descrizione UNION SELECT `id`, `nomesede`, CONCAT_WS(' - ', `nomesede`, CONCAT(`citta`, IF(`indirizzo`!='',CONCAT(' (', `indirizzo`, ')'), '')) ) FROM `an_sedi` |where|) AS tab |filter| ORDER BY descrizione " ;
2019-06-29 11:01:26 +02:00
2020-07-31 14:25:50 +02:00
foreach ( $elements as $element ) {
2024-02-05 17:07:33 +01:00
$filter [] = '`id`=' . prepare ( $element );
2020-07-31 14:25:50 +02:00
}
2019-05-29 19:17:57 +02:00
2024-02-05 17:07:33 +01:00
$where [] = '`idanagrafica`=' . prepare ( $id_azienda );
2024-01-15 15:30:45 +01:00
// admin o utente senza una sede prefissata, avrà accesso a tutte le sedi
2020-07-31 14:25:50 +02:00
if ( ! empty ( $user -> sedi ) and ! $user -> is_admin ) {
2024-02-05 17:07:33 +01:00
$where [] = '`id` IN(' . implode ( ',' , $user -> sedi ) . ')' ;
2020-07-31 14:25:50 +02:00
}
2019-05-29 19:17:57 +02:00
2020-07-31 14:25:50 +02:00
if ( ! empty ( $search )) {
2024-02-05 17:07:33 +01:00
$search_fields [] = '`nomesede` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`citta` LIKE ' . prepare ( '%' . $search . '%' );
2018-02-03 15:03:48 +01:00
}
2019-06-29 11:01:26 +02:00
2018-02-03 15:03:48 +01:00
break ;
2024-01-15 15:30:45 +01:00
/*
* Opzioni utilizzate :
* - idanagrafica
*/
2018-02-03 15:03:48 +01:00
case 'referenti' :
2018-02-03 16:29:53 +01:00
if ( isset ( $superselect [ 'idanagrafica' ])) {
2024-02-05 17:07:33 +01:00
$query = 'SELECT `an_referenti`.`id`, `an_referenti`.`nome` AS descrizione, `an_mansioni`.`nome` AS optgroup FROM `an_referenti` LEFT JOIN `an_mansioni` ON `an_referenti`.`idmansione`=`an_mansioni`.`id` |where| ORDER BY optgroup, `an_referenti`.`nome`' ;
2018-02-03 15:03:48 +01:00
foreach ( $elements as $element ) {
2024-02-05 17:07:33 +01:00
$filter [] = '`an_referenti`.`id`=' . prepare ( $element );
2018-02-03 15:03:48 +01:00
}
2021-07-07 07:57:10 +02:00
if ( isset ( $superselect [ 'idclientefinale' ])) {
2024-02-05 17:07:33 +01:00
$where [] = '(`idanagrafica`=' . prepare ( $superselect [ 'idanagrafica' ]) . ' OR `idanagrafica`=' . prepare ( $superselect [ 'idclientefinale' ]) . ')' ;
2021-07-07 07:57:10 +02:00
} else {
2024-02-05 17:07:33 +01:00
$where [] = '`idanagrafica`=' . prepare ( $superselect [ 'idanagrafica' ]);
2021-06-22 17:31:10 +02:00
}
2018-02-03 15:03:48 +01:00
2023-01-13 09:35:27 +01:00
if ( isset ( $superselect [ 'idsede_destinazione' ])) {
2024-02-05 17:07:33 +01:00
$where [] = '`idsede`=' . prepare ( $superselect [ 'idsede_destinazione' ]);
2023-01-13 09:35:27 +01:00
}
2018-02-03 15:03:48 +01:00
if ( ! empty ( $search )) {
2024-02-05 17:07:33 +01:00
$search_fields [] = '`an_referenti`.`nome` LIKE ' . prepare ( '%' . $search . '%' );
2018-02-03 15:03:48 +01:00
}
}
break ;
2019-05-04 00:32:28 +02:00
case 'nazioni' :
2024-03-13 11:38:29 +01:00
$query = 'SELECT `an_nazioni`.`id` AS id, `iso2`, CONCAT_WS(\' - \', `iso2`, `an_nazioni_lang`.`name`) AS descrizione FROM `an_nazioni` LEFT JOIN `an_nazioni_lang` ON (`an_nazioni`.`id` = `an_nazioni_lang`.`id_record` AND `an_nazioni_lang`.`id_lang` = ' . prepare ( \App :: getLang ()) . ') |where| ORDER BY CASE WHEN `iso2`=\'IT\' THEN -1 ELSE `iso2` END' ;
2019-05-04 00:32:28 +02:00
foreach ( $elements as $element ) {
2024-02-05 17:07:33 +01:00
$filter [] = '`an_nazioni`.`id`=' . prepare ( $element );
2019-05-04 00:32:28 +02:00
}
if ( ! empty ( $search )) {
2024-02-05 17:07:33 +01:00
$search_fields [] = '`an_nazioni_lang`.`name` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`iso2` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = 'CONCAT_WS(\' - \', `iso2`, `name`) LIKE ' . prepare ( '%' . $search . '%' );
2019-05-04 00:32:28 +02:00
}
2019-09-13 12:27:29 +02:00
break ;
2022-04-22 19:08:53 +02:00
case 'regioni' :
if ( isset ( $superselect [ 'id_nazione' ])) {
2024-03-13 11:38:29 +01:00
$query = 'SELECT `an_regioni`.`id` AS id, `an_regioni`.`iso2`, CONCAT(CONCAT_WS(\' - \', `an_regioni`.`iso2`, `an_regioni_lang`.`name`), \' (\', `an_nazioni`.`iso2`, \')\') AS descrizione FROM `an_regioni` LEFT JOIN `an_regioni_lang` ON (`an_regioni`.`id` = `an_regioni_lang`.`id_record` AND `an_regioni_lang`.`id_lang` = ' . prepare ( \App :: getLang ()) . ') INNER JOIN `an_nazioni` ON `an_regioni`.`id_nazione` = `an_nazioni`.`id` |where| ORDER BY `an_regioni_lang`.`name`' ;
2022-04-22 19:08:53 +02:00
foreach ( $elements as $element ) {
2024-02-05 17:07:33 +01:00
$filter [] = '`an_regioni`.`id`=' . prepare ( $element );
2022-04-22 19:08:53 +02:00
}
2024-02-05 17:07:33 +01:00
$where [] = '`an_regioni`.`id_nazione`=' . prepare ( $superselect [ 'id_nazione' ]);
2022-04-22 19:08:53 +02:00
if ( ! empty ( $search )) {
2024-02-05 17:07:33 +01:00
$search_fields [] = '`an_regioni_lang`.`name` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = '`an_regioni`.`iso2` LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = 'CONCAT_WS(\' - \', `an_regioni`.`iso2`, `an_regioni_lang`.`name`) LIKE ' . prepare ( '%' . $search . '%' );
2022-04-22 19:08:53 +02:00
}
}
break ;
2020-01-22 19:39:56 +01:00
case 'relazioni' :
2024-03-13 11:38:29 +01:00
$query = " SELECT `an_relazioni`.`id`, CONCAT(`name`, IF(`an_relazioni`.`deleted_at` IS NULL, '', ' ( " . tr ( 'eliminata' ) . " )')) AS descrizione, `colore` AS _bgcolor_ FROM `an_relazioni` LEFT JOIN `an_relazioni_lang` ON (`an_relazioni`.`id` = `an_relazioni_lang`.`id_record` AND `an_relazioni_lang`.`id_lang` = " . prepare ( \App :: getLang ()) . ') |where| ORDER BY descrizione' ;
2020-01-22 19:39:56 +01:00
foreach ( $elements as $element ) {
2024-02-05 17:07:33 +01:00
$filter [] = '`an_relazioni`.`id`=' . prepare ( $element );
2020-01-22 19:39:56 +01:00
}
2023-04-18 16:55:37 +02:00
if ( empty ( $filter )) {
2024-02-05 17:07:33 +01:00
$where [] = '`an_relazioni`.`deleted_at` IS NULL' ;
2023-04-18 16:55:37 +02:00
}
2020-01-22 19:39:56 +01:00
if ( ! empty ( $search )) {
2024-02-05 17:07:33 +01:00
$search_fields [] = '`an_relazioni_lang`.`name` LIKE ' . prepare ( '%' . $search . '%' );
2020-01-22 19:39:56 +01:00
}
break ;
2023-08-04 14:54:28 +02:00
2022-06-10 17:33:35 +02:00
case 'provenienze' :
2024-03-13 11:38:29 +01:00
$query = 'SELECT `an_provenienze`.`id`, `an_provenienze_lang`.`name` as descrizione, `colore` AS bgcolor FROM `an_provenienze` LEFT JOIN `an_provenienze_lang` ON (`an_provenienze`.`id` = `an_provenienze_lang`.`id_record` AND `an_provenienze_lang`.`id_lang` = ' . prepare ( \App :: getLang ()) . ') |where| ORDER BY `descrizione`' ;
2022-06-10 17:33:35 +02:00
foreach ( $elements as $element ) {
2024-02-05 17:07:33 +01:00
$filter [] = '`an_provenienze`.`id`=' . prepare ( $element );
2022-06-10 17:33:35 +02:00
}
if ( ! empty ( $search )) {
2024-02-05 17:07:33 +01:00
$search_fields [] = '`an_provenienze_lang`.`name` LIKE ' . prepare ( '%' . $search . '%' );
2022-06-10 17:33:35 +02:00
}
break ;
2020-01-22 19:39:56 +01:00
2022-06-10 19:07:12 +02:00
case 'settori' :
2024-03-13 11:38:29 +01:00
$query = 'SELECT `an_settori`.`id`, `an_settori_lang`.`name` as descrizione FROM `an_settori` LEFT JOIN `an_settori_lang` ON (`an_settori`.`id` = `an_settori_lang`.`id_record` AND `an_settori_lang`.`id_lang` = ' . prepare ( \App :: getLang ()) . ') |where| ORDER BY `name`' ;
2022-06-10 19:07:12 +02:00
foreach ( $elements as $element ) {
2024-02-05 17:07:33 +01:00
$filter [] = '`an_settori`.`id`=' . prepare ( $element );
2022-06-10 19:07:12 +02:00
}
if ( ! empty ( $search )) {
2024-02-05 17:07:33 +01:00
$search_fields [] = '`name` LIKE ' . prepare ( '%' . $search . '%' );
2022-06-10 19:07:12 +02:00
}
break ;
2024-01-15 15:30:45 +01:00
/*
* Opzioni utilizzate :
* - idanagrafica
*/
2019-09-13 12:27:29 +02:00
2023-08-04 14:54:28 +02:00
case 'dichiarazioni_intento' :
2022-03-07 15:41:04 +01:00
if ( isset ( $superselect [ 'idanagrafica' ]) && isset ( $superselect [ 'data' ])) {
2024-01-15 15:30:45 +01:00
// $query = "SELECT id, CONCAT('N. prot. ', numero_protocollo, ' (periodo dal ', DATE_FORMAT(data_inizio, '%d/%m/%Y'), ' al ' ,DATE_FORMAT(data_fine, '%d/%m/%Y'),') (utilizzati ',REPLACE(REPLACE(REPLACE(FORMAT(SUM(totale),2), ',', '#'), '.', ','), '#', '.'), ' su ' , REPLACE(REPLACE(REPLACE(FORMAT(SUM(massimale),2), ',', '#'), '.', ','), '#', '.'), ' €)' ) AS descrizione, data_inizio, data_fine FROM co_dichiarazioni_intento |where| ORDER BY `data`, `id`";
2019-09-13 12:27:29 +02:00
2023-08-04 14:54:28 +02:00
$query = 'SELECT id, numero_protocollo, data_inizio, data_fine, massimale, totale FROM co_dichiarazioni_intento |where| ORDER BY data' ;
2019-09-13 12:27:29 +02:00
2022-03-07 15:41:04 +01:00
foreach ( $elements as $element ) {
$filter [] = 'id=' . prepare ( $element );
}
2024-01-15 15:30:45 +01:00
// $where[] = '( '.prepare($superselect['data']).' BETWEEN data_inizio AND data_fine)';
2022-03-07 15:41:04 +01:00
2024-01-15 15:30:45 +01:00
// $where[] = 'data_inizio < NOW()';
// $where[] = 'data_fine > NOW()';
2022-03-07 15:41:04 +01:00
if ( empty ( $filter )) {
2023-04-18 16:55:37 +02:00
$where [] = 'co_dichiarazioni_intento.deleted_at IS NULL' ;
2022-03-07 15:41:04 +01:00
}
$where [] = 'id_anagrafica=' . prepare ( $superselect [ 'idanagrafica' ]);
if ( ! empty ( $search )) {
$search_fields [] = 'numero_protocollo LIKE ' . prepare ( '%' . $search . '%' );
$search_fields [] = 'numero_progressivo LIKE ' . prepare ( '%' . $search . '%' );
}
$data = AJAX :: selectResults ( $query , $where , $filter , $search_fields , $limit , $custom );
$rs = $data [ 'results' ];
2023-08-04 14:54:28 +02:00
foreach ( $rs as $k => $r ) {
$currentDate = date ( 'Y-m-d' , strtotime ( $superselect [ 'data' ]));
2022-03-07 15:41:04 +01:00
$startDate = date ( 'Y-m-d' , strtotime ( $r [ 'data_inizio' ]));
$endDate = date ( 'Y-m-d' , strtotime ( $r [ 'data_fine' ]));
$rs [ $k ] = array_merge ( $r , [
'text' => tr ( 'N. prot.' ) . ' ' . $r [ 'numero_protocollo' ] . ' - ' . Translator :: numberToLocale ( $r [ 'totale' ]) . '/' . Translator :: numberToLocale ( $r [ 'massimale' ]) . ' € [' . Translator :: dateToLocale ( $r [ 'data_fine' ]) . ']' ,
'disabled' => (( $currentDate < $startDate ) || ( $currentDate > $endDate )),
]);
}
$results = [
'results' => $rs ,
'recordsFiltered' => $data [ 'recordsFiltered' ],
];
2019-09-13 12:27:29 +02:00
}
2019-04-30 16:16:25 +02:00
break ;
2018-02-03 15:03:48 +01:00
}