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
|
|
|
|
$records = $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-13 18:47:42 +02:00
|
|
|
if (!empty($records)) {
|
|
|
|
foreach ($records as $r) {
|
|
|
|
$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
|
|
|
|
2017-09-13 18:47:42 +02:00
|
|
|
$_GET['iddocumento'] = $r['id']; // Fix temporaneo per la stampa
|
|
|
|
$iddocumento = $r['id']; // Fix temporaneo per la stampa
|
2017-09-21 16:42:27 +02:00
|
|
|
$ptype = 'fatture';
|
2017-09-06 11:59:47 +02:00
|
|
|
|
2017-09-13 18:47:42 +02:00
|
|
|
require DOCROOT.'/pdfgen.php';
|
|
|
|
}
|
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-03-19 19:07:32 +01:00
|
|
|
foreach ($id_records as $id) {
|
2018-03-22 15:40:20 +01:00
|
|
|
$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-03-19 19:07:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$_SESSION['infos'][] = tr('Fatture eliminate!');
|
|
|
|
|
2018-03-22 15:40:20 +01:00
|
|
|
break;
|
2017-09-06 11:59:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return [
|
2018-03-22 15:40:20 +01: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
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|