2023-01-11 18:02:09 +01:00
< ? php
include_once __DIR__ . '/../../../core.php' ;
$id_listino = filter ( 'id_listino' );
2023-12-28 16:18:02 +01:00
$listino = $dbo -> selectOne ( 'mg_listini' , '*' , [ 'id' => $id_listino ]);
2023-01-12 16:27:33 +01:00
$search = filter ( 'search' ) ? filter ( 'search' )[ 'value' ] : null ;
$start = filter ( 'start' );
$length = filter ( 'length' );
2023-01-11 18:02:09 +01:00
2023-09-15 18:06:15 +02:00
$tot_articoli = $dbo -> select ( 'mg_listini_articoli' , '*' , [], [ 'id_listino' => $id_listino ]);
2023-01-12 16:27:33 +01:00
if ( empty ( $search )) {
2024-04-18 17:44:05 +02:00
$articoli = $dbo -> fetchArray ( 'SELECT `mg_listini_articoli`.*, `mg_articoli`.`codice`, `mg_articoli_lang`.`title` AS descrizione, `mg_articoli`.' . ( $prezzi_ivati ? 'minimo_vendita_ivato' : 'minimo_vendita' ) . ' AS minimo_vendita FROM `mg_listini_articoli` LEFT JOIN `mg_articoli` ON `mg_listini_articoli`.`id_articolo`=`mg_articoli`.`id` LEFT JOIN `mg_articoli_lang` ON (`mg_articoli_lang`.`id_record` = `mg_articoli`.`id` AND `mg_articoli_lang`.`id_lang` = ' . prepare ( Models\Locale :: getDefault () -> id ) . ') WHERE `id_listino`=' . prepare ( $id_listino ) . ' LIMIT ' . $start . ', ' . $length );
2023-01-12 16:27:33 +01:00
} else {
$resource = 'articoli_listino' ;
include_once __DIR__ . '/select.php' ;
$articoli = $results ;
}
2023-01-11 18:02:09 +01:00
foreach ( $articoli as $articolo ) {
$riga = [
'<input class="check" type="checkbox" id="' . $articolo [ 'id' ] . '"/>' ,
Modules :: link ( 'Articoli' , $articolo [ 'id_articolo' ], $articolo [ 'codice' ], null , '' ),
$articolo [ 'descrizione' ],
2023-12-28 16:18:02 +01:00
$articolo [ 'data_scadenza' ] ? '<p class="text-center">' . dateFormat ( $articolo [ 'data_scadenza' ]) . '</p>' : '<p class="text-muted text-center">' . dateFormat ( $listino [ 'data_scadenza_predefinita' ]) . '</p>' ,
'<p class="text-right">' . ( $articolo [ 'minimo_vendita' ] != 0 ? moneyFormat ( $articolo [ 'minimo_vendita' ]) : '-' ) . '</p>' ,
'<p class="text-right">' . moneyFormat ( $articolo [ 'prezzo_unitario' ]) . '</p>' ,
'<p class="text-right">' . moneyFormat ( $articolo [ 'prezzo_unitario_ivato' ]) . '</p>' ,
'<p class="text-right">' . ( $articolo [ 'sconto_percentuale' ] != 0 ? numberFormat ( $articolo [ 'sconto_percentuale' ]) . ' %' : '-' ) . '</p>' ,
' < div class = " text-center " >
< a class = " btn btn-xs btn-warning " title = " '.tr('Modifica articolo').' " onclick = " modificaArticolo( $ (this), '. $articolo['id'] .') " >
< i class = " fa fa-edit " ></ i >
</ a >
< a class = " btn btn-xs btn-danger " title = " '.tr('Rimuovi articolo').' " onclick = " rimuoviArticolo('. $articolo['id'] .') " >
< i class = " fa fa-trash " ></ i >
</ a >
</ div > ' ,
2023-01-11 18:02:09 +01:00
];
$righe [] = $riga ;
$class [] = 'text-right' ;
}
// Formattazione dei dati
echo json_encode ([
'data' => $righe ,
'recordsTotal' => sizeof ( $tot_articoli ),
'recordsFiltered' => sizeof ( $tot_articoli ),
'draw' => intval ( filter ( 'draw' )),
2023-08-04 14:54:28 +02:00
]);