. */ include_once __DIR__.'/../../core.php'; switch (filter('op')) { case 'crea_definitiva': $year = date('Y', strtotime(post('date_start'))); $print = Prints::render(post('id_print'), null, null, true); $pages = count($print['pages']); $first_page = $dbo->fetchOne('SELECT MAX(last_page) AS last_page FROM co_stampecontabili WHERE `id_print`='.prepare(post('id_print')).' AND YEAR(`date_end`)='.prepare($year).' AND `dir`='.prepare(post('dir')))['last_page']+1; $last_page = $first_page + $pages - 1; $result = $dbo->table('co_stampecontabili')->insertGetId([ 'id_print' => post('id_print'), 'date_start' => post('date_start'), 'date_end' => post('date_end'), 'first_page' => $first_page, 'last_page' => $last_page, 'dir' => post('dir'), ]); $print = Prints::render(post('id_print'), null, null, true); $name = 'Registro_iva_'.(post('dir') == 'entrata' ? 'vendite' : 'acquisti').'_del_'.post('date_start'); $upload = Uploads::upload($print['pdf'], [ 'name' => $name, 'original_name' => $name.'.pdf', 'category' => 'Generale', 'id_module' => $id_module, 'id_record' => $result, ]); echo json_encode($result); break; }