|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione |
| 5 | + * Copyright (C) DevCode s.r.l. |
| 6 | + * |
| 7 | + * This program is free software: you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU General Public License as published by |
| 9 | + * the Free Software Foundation, either version 3 of the License, or |
| 10 | + * (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU General Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Public License |
| 18 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 19 | + */ |
| 20 | + |
| 21 | +include_once __DIR__.'/../../core.php'; |
| 22 | + |
| 23 | +use Models\Module; |
| 24 | +use Util\Zip; |
| 25 | + |
| 26 | +switch (post('op')) { |
| 27 | + case 'export_bulk': |
| 28 | + $dir = base_dir().'/files/export_viaggi/'; |
| 29 | + directory($dir.'tmp/'); |
| 30 | + |
| 31 | + // Rimozione dei contenuti precedenti |
| 32 | + $files = glob($dir.'/*.zip'); |
| 33 | + foreach ($files as $file) { |
| 34 | + delete($file); |
| 35 | + } |
| 36 | + |
| 37 | + // Selezione dei viaggi da stampare |
| 38 | + $viaggi = $dbo->fetchArray('SELECT id FROM an_sedi WHERE id IN('.implode(',', $id_records).')'); |
| 39 | + $_SESSION[$id_module]['data_inizio'] = post('data_inizio'); |
| 40 | + $_SESSION[$id_module]['data_fine'] = post('data_fine'); |
| 41 | + |
| 42 | + if (!empty($viaggi)) { |
| 43 | + foreach ($viaggi as $r) { |
| 44 | + $print = Prints::getModulePredefinedPrint($id_module); |
| 45 | + Prints::render($print['id'], $r['id'], $dir.'tmp/', false, false); |
| 46 | + } |
| 47 | + |
| 48 | + $dir = slashes($dir); |
| 49 | + $file = slashes($dir.'viaggi_'.time().'.zip'); |
| 50 | + |
| 51 | + // Creazione zip |
| 52 | + if (extension_loaded('zip')) { |
| 53 | + Zip::create($dir.'tmp/', $file); |
| 54 | + |
| 55 | + // Invio al browser dello zip |
| 56 | + download($file); |
| 57 | + |
| 58 | + // Rimozione dei contenuti |
| 59 | + delete($dir.'tmp/'); |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + break; |
| 64 | +} |
| 65 | + |
| 66 | +$operations['export_bulk'] = [ |
| 67 | + 'text' => '<span><i class="fa fa-file-archive-o"></i> '.tr('Esporta viaggi'), |
| 68 | + 'data' => [ |
| 69 | + 'title' => tr('Vuoi davvero esportare queste stampe viaggio in un archivio ZIP?'), |
| 70 | + 'msg' => '{[ "type": "date", "label": "'.tr('Data inizio').'", "name": "data_inizio", "required": 1, "value": "-now-" ]} |
| 71 | + {[ "type": "date", "label": "'.tr('Data fine').'", "name": "data_fine", "required": 1, "value": "-now-" ]}', |
| 72 | + 'button' => tr('Procedi'), |
| 73 | + 'class' => 'btn btn-lg btn-warning', |
| 74 | + 'blank' => true, |
| 75 | + ], |
| 76 | +]; |
| 77 | + |
| 78 | +return $operations; |
0 commit comments