diff --git a/include/top.php b/include/top.php index 880917a1b..4144ef41c 100755 --- a/include/top.php +++ b/include/top.php @@ -400,8 +400,10 @@ if (Auth::check()) { + '; + if ($user->gruppo == 'Amministratori') { + echo ' + '; + } + echo ' diff --git a/modules/scadenzario/actions.php b/modules/scadenzario/actions.php index 51af767aa..159c82984 100755 --- a/modules/scadenzario/actions.php +++ b/modules/scadenzario/actions.php @@ -119,4 +119,22 @@ switch (post('op')) { $dbo->query("DELETE FROM co_scadenziario WHERE id='".$id_record."'"); flash()->info(tr('Scadenza eliminata!')); break; + + case 'allega_fattura': + $id_documento = post('iddocumento'); + $print_predefined = $dbo->selectOne('zz_prints', '*', ['predefined' => 1, 'id_module' => Modules::get('Fatture di vendita')['id']]); + + $print = Prints::render($print_predefined['id'], $id_documento, null, true); + $name = 'Fattura di vendita'; + $upload = Uploads::upload($print['pdf'], [ + 'name' => $name, + 'original_name' => $name.'.pdf', + 'category' => 'Generale', + 'id_module' => $id_module, + 'id_record' => $id_record, + ]); + + flash()->info(tr('Stampa allegata correttamente!')); + + break; } diff --git a/modules/scadenzario/buttons.php b/modules/scadenzario/buttons.php new file mode 100644 index 000000000..ac14fdb0a --- /dev/null +++ b/modules/scadenzario/buttons.php @@ -0,0 +1,29 @@ +. + */ + +include_once __DIR__.'/../../core.php'; + +if (!empty($record['iddocumento'])) { + $fattura_allegata = $dbo->selectOne('zz_files', 'id', ['id_module' => $id_module, 'id_record' => $id_record, 'original' => 'Fattura di vendita.pdf'])['id']; + echo ' + '; +} diff --git a/modules/scadenzario/edit.php b/modules/scadenzario/edit.php index 9afa45e16..c1f0bda90 100755 --- a/modules/scadenzario/edit.php +++ b/modules/scadenzario/edit.php @@ -214,16 +214,7 @@ if ($totale_da_pagare != 0) { -fetchOne('SELECT id FROM co_scadenziario WHERE iddocumento='.prepare($documento->id).' ORDER BY id')['id']; -} -?> - -{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "" )} +{( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "" )} {( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )} @@ -284,7 +275,8 @@ if (!empty($documento)) { if ($dir == 'uscita') { echo ' - $("#email-button").remove();'; + $("#email-button").remove(); + $("#allega-fattura").remove();'; } echo ' }); diff --git a/modules/scadenzario/init.php b/modules/scadenzario/init.php index 304d429de..9b7d6ad1c 100755 --- a/modules/scadenzario/init.php +++ b/modules/scadenzario/init.php @@ -27,6 +27,7 @@ if (isset($id_record)) { // Scelgo la query in base alla scadenza if (!empty($documento)) { + $id_record = $dbo->fetchOne('SELECT id FROM co_scadenziario WHERE iddocumento='.prepare($documento->id).' ORDER BY id')['id']; $scadenze = $dbo->fetchArray('SELECT * FROM co_scadenziario WHERE iddocumento = '.prepare($documento->id).' ORDER BY scadenza ASC'); $totale_da_pagare = $documento->netto; } else {