Aggiunto pulsante allega fattura in Scadenzario

This commit is contained in:
MatteoPistorello 2022-06-10 15:54:50 +02:00
parent da0ab3d49f
commit 2b5ade13b9
4 changed files with 51 additions and 11 deletions

View File

@ -119,4 +119,22 @@ switch (post('op')) {
$dbo->query("DELETE FROM co_scadenziario WHERE id='".$id_record."'"); $dbo->query("DELETE FROM co_scadenziario WHERE id='".$id_record."'");
flash()->info(tr('Scadenza eliminata!')); flash()->info(tr('Scadenza eliminata!'));
break; 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;
} }

View File

@ -0,0 +1,29 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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 '
<button type="button" class="btn btn-warning ask btn-warning '.(empty($fattura_allegata
) ? '' : 'disabled').'" id="allega-fattura" data-msg="'.tr('Allegare la stampa della fattura?').'" data-op="allega_fattura" data-iddocumento="'.$record['iddocumento'].'" data-button="'.tr('Allega').'" data-class="btn btn-lg btn-warning" data-backto="record-edit" >
<i class="fa fa-paperclip"></i> '.tr('Allega fattura').'
</button>';
}

View File

@ -214,16 +214,7 @@ if ($totale_da_pagare != 0) {
</div> </div>
</form> </form>
<?php {( "name": "filelist_and_upload", "id_module": "$id_module$", "id_record": "<?php echo $id_record; ?>" )}
$id_scadenza = $id_record;
// Forzatura per allegare file sempre al primo record
if (!empty($documento)) {
$id_scadenza = $dbo->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": "<?php echo $id_scadenza; ?>" )}
{( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )} {( "name": "log_email", "id_module": "$id_module$", "id_record": "$id_record$" )}
@ -284,7 +275,8 @@ if (!empty($documento)) {
if ($dir == 'uscita') { if ($dir == 'uscita') {
echo ' echo '
$("#email-button").remove();'; $("#email-button").remove();
$("#allega-fattura").remove();';
} }
echo ' echo '
}); });

View File

@ -27,6 +27,7 @@ if (isset($id_record)) {
// Scelgo la query in base alla scadenza // Scelgo la query in base alla scadenza
if (!empty($documento)) { 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'); $scadenze = $dbo->fetchArray('SELECT * FROM co_scadenziario WHERE iddocumento = '.prepare($documento->id).' ORDER BY scadenza ASC');
$totale_da_pagare = $documento->netto; $totale_da_pagare = $documento->netto;
} else { } else {