2023-01-11 18:02:09 +01:00
< ? php
include_once __DIR__ . '/../../../core.php' ;
$id_listino = filter ( '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
$tot_articoli = $dbo -> select ( 'mg_listini_articoli' , '*' , [ 'id_listino' => $id_listino ]);
2023-01-12 16:27:33 +01:00
if ( empty ( $search )) {
$articoli = $dbo -> fetchArray ( 'SELECT mg_listini_articoli.*, mg_articoli.codice, mg_articoli.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 WHERE id_listino=' . prepare ( $id_listino ) . ' LIMIT ' . $start . ', ' . $length );
} 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' ],
'<p class="text-center">' . dateFormat ( $articolo [ 'data_scadenza' ]) . '</div>' ,
2023-08-04 14:54:28 +02:00
'<p class="text-right">' . ( $articolo [ 'minimo_vendita' ] != 0 ? moneyFormat ( $articolo [ 'minimo_vendita' ]) : '-' ) . '</div>' ,
2023-01-11 18:02:09 +01:00
'<p class="text-right">' . moneyFormat ( $articolo [ 'prezzo_unitario' ]) . '</div>' ,
'<p class="text-right">' . moneyFormat ( $articolo [ 'prezzo_unitario_ivato' ]) . '</div>' ,
2023-08-04 14:54:28 +02:00
'<p class="text-right">' . ( $articolo [ 'sconto_percentuale' ] != 0 ? numberFormat ( $articolo [ 'sconto_percentuale' ]) . ' %' : '-' ) . '</div>' ,
2023-01-11 18:02:09 +01:00
'<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 > ' ,
];
$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
]);