2020-05-29 17:12:23 +02:00
< ? php
include_once __DIR__ . '/../../core.php' ;
switch ( post ( 'op' )) {
case 'delete-bulk' :
foreach ( $id_records as $id ) {
$elementi = $dbo -> fetchArray ( 'SELECT `co_documenti`.`id`, `co_documenti`.`data`, `co_documenti`.`numero`, `co_documenti`.`numero_esterno`, `co_tipidocumento`.`descrizione` AS tipo_documento, `co_tipidocumento`.`dir` FROM `co_documenti` JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` WHERE `co_documenti`.`id` IN (SELECT `iddocumento` FROM `co_righe_documenti` WHERE `idarticolo` = ' . prepare ( $id ) . ' )
UNION SELECT `dt_ddt` . `id` , `dt_ddt` . `data` , `dt_ddt` . `numero` , `dt_ddt` . `numero_esterno` , `dt_tipiddt` . `descrizione` AS tipo_documento , `dt_tipiddt` . `dir` FROM `dt_ddt` JOIN `dt_tipiddt` ON `dt_tipiddt` . `id` = `dt_ddt` . `idtipoddt` WHERE `dt_ddt` . `id` IN ( SELECT `idddt` FROM `dt_righe_ddt` WHERE `idarticolo` = '.prepare($id).' )
UNION SELECT `co_preventivi` . `id` , `co_preventivi` . `data_bozza` , `co_preventivi` . `numero` , 0 AS numero_esterno , " Preventivo " AS tipo_documento , 0 AS dir FROM `co_preventivi` WHERE `co_preventivi` . `id` IN ( SELECT `idpreventivo` FROM `co_righe_preventivi` WHERE `idarticolo` = '.prepare($id).' ) ORDER BY `data` ' );
if ( ! empty ( $elementi )) {
$dbo -> query ( 'UPDATE mg_articoli SET deleted_at = NOW() WHERE id = ' . prepare ( $id ) . Modules :: getAdditionalsQuery ( $id_module ));
2020-06-09 16:59:26 +02:00
} else {
2020-05-29 17:12:23 +02:00
$dbo -> query ( 'DELETE FROM `mg_articoli` WHERE id = ' . prepare ( $id ) . Modules :: getAdditionalsQuery ( $id_module ));
}
}
flash () -> info ( tr ( 'Articoli eliminati!' ));
break ;
}
if ( App :: debug ()) {
$operations [ 'delete-bulk' ] = [
'text' => '<span><i class="fa fa-trash"></i> ' . tr ( 'Elimina selezionati' ) . '</span>' ,
'data' => [
'msg' => tr ( 'Vuoi davvero eliminare gli articoli selezionati?' ),
'button' => tr ( 'Procedi' ),
'class' => 'btn btn-lg btn-danger' ,
],
];
}
return $operations ;