2017-09-06 11:59:47 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
|
|
|
switch (post('op')) {
|
|
|
|
case 'export-bulk':
|
|
|
|
$dir = DOCROOT.'/files/export_fatture/';
|
2017-09-13 15:38:47 +02:00
|
|
|
directory($dir.'tmp/');
|
2017-09-06 11:59:47 +02:00
|
|
|
|
2017-09-07 16:51:14 +02:00
|
|
|
// Rimozione dei contenuti precedenti
|
|
|
|
$files = glob($dir.'/*.zip');
|
|
|
|
foreach ($files as $file) {
|
2017-09-11 17:49:03 +02:00
|
|
|
delete($file);
|
2017-09-07 16:51:14 +02:00
|
|
|
}
|
|
|
|
|
2017-09-06 11:59:47 +02:00
|
|
|
// Selezione delle fatture da stampare
|
2018-07-18 15:20:10 +02:00
|
|
|
$fatture = $dbo->fetchArray('SELECT co_documenti.id, numero_esterno, data, ragione_sociale, co_tipidocumento.descrizione FROM co_documenti INNER JOIN an_anagrafiche ON co_documenti.idanagrafica=an_anagrafiche.idanagrafica INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_documenti.id IN('.implode(',', $id_records).')');
|
2017-09-06 11:59:47 +02:00
|
|
|
|
2018-07-18 15:20:10 +02:00
|
|
|
if (!empty($fatture)) {
|
|
|
|
foreach ($fatture as $r) {
|
2017-09-13 18:47:42 +02:00
|
|
|
$numero = !empty($r['numero_esterno']) ? $r['numero_esterno'] : $r['numero'];
|
|
|
|
$numero = str_replace(['/', '\\'], '-', $numero);
|
2017-09-06 11:59:47 +02:00
|
|
|
|
2017-09-13 18:47:42 +02:00
|
|
|
// Gestione della stampa
|
|
|
|
$rapportino_nome = sanitizeFilename($numero.' '.$r['data'].' '.$r['ragione_sociale'].'.pdf');
|
|
|
|
$filename = slashes($dir.'tmp/'.$rapportino_nome);
|
2017-09-06 11:59:47 +02:00
|
|
|
|
2018-06-29 15:57:12 +02:00
|
|
|
$print = Prints::getModuleMainPrint($id_module);
|
2018-06-26 14:30:26 +02:00
|
|
|
|
2018-06-29 15:57:12 +02:00
|
|
|
Prints::render($print['id'], $r['id'], $filename);
|
2017-09-13 18:47:42 +02:00
|
|
|
}
|
2017-09-06 11:59:47 +02:00
|
|
|
|
2017-09-13 18:47:42 +02:00
|
|
|
$dir = slashes($dir);
|
|
|
|
$file = slashes($dir.'fatture_'.time().'.zip');
|
2017-09-06 11:59:47 +02:00
|
|
|
|
2017-09-13 18:47:42 +02:00
|
|
|
// Creazione zip
|
|
|
|
if (extension_loaded('zip')) {
|
|
|
|
create_zip($dir.'tmp/', $file);
|
2017-09-06 11:59:47 +02:00
|
|
|
|
2017-09-13 18:47:42 +02:00
|
|
|
// Invio al browser dello zip
|
|
|
|
download($file);
|
2017-09-06 11:59:47 +02:00
|
|
|
|
2017-09-13 18:47:42 +02:00
|
|
|
// Rimozione dei contenuti
|
|
|
|
delete($dir.'tmp/');
|
|
|
|
}
|
2017-09-06 12:50:44 +02:00
|
|
|
}
|
2017-09-06 11:59:47 +02:00
|
|
|
|
|
|
|
break;
|
2018-03-19 19:07:32 +01:00
|
|
|
|
2018-03-22 15:40:20 +01:00
|
|
|
case 'delete-bulk':
|
2018-06-26 14:30:26 +02:00
|
|
|
|
|
|
|
if ($debug) {
|
|
|
|
foreach ($id_records as $id) {
|
|
|
|
$dbo->query('DELETE FROM co_documenti WHERE id = '.prepare($id).Modules::getAdditionalsQuery($id_module));
|
|
|
|
$dbo->query('DELETE FROM co_righe_documenti WHERE iddocumento='.prepare($id).Modules::getAdditionalsQuery($id_module));
|
|
|
|
$dbo->query('DELETE FROM co_scadenziario WHERE iddocumento='.prepare($id).Modules::getAdditionalsQuery($id_module));
|
|
|
|
$dbo->query('DELETE FROM mg_movimenti WHERE iddocumento='.prepare($id).Modules::getAdditionalsQuery($id_module));
|
|
|
|
}
|
|
|
|
|
2018-07-19 17:29:21 +02:00
|
|
|
flash()->info(tr('Fatture eliminate!'));
|
2018-06-26 14:30:26 +02:00
|
|
|
} else {
|
2018-07-19 17:29:21 +02:00
|
|
|
flash()->warning(tr('Procedura in fase di sviluppo. Nessuna modifica apportata.'));
|
2018-06-26 14:30:26 +02:00
|
|
|
}
|
|
|
|
|
2018-03-22 15:40:20 +01:00
|
|
|
break;
|
2017-09-06 11:59:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return [
|
2018-06-26 14:30:26 +02:00
|
|
|
'delete-bulk' => tr('Elimina selezionati'),
|
2018-03-19 19:07:32 +01:00
|
|
|
|
2017-09-06 11:59:47 +02:00
|
|
|
'export-bulk' => [
|
|
|
|
'text' => tr('Esporta stampe'),
|
|
|
|
'data' => [
|
|
|
|
'msg' => tr('Vuoi davvero esportare tutte le stampe in un archivio?'),
|
|
|
|
'button' => tr('Procedi'),
|
|
|
|
'class' => 'btn btn-lg btn-warning',
|
2017-09-07 16:51:14 +02:00
|
|
|
'blank' => true,
|
2017-09-06 11:59:47 +02:00
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|