fix: creazione nota di debito

This commit is contained in:
valentina 2024-10-23 12:43:08 +02:00
parent 12856fb9e6
commit 0f50e5b966
2 changed files with 4 additions and 5 deletions

View File

@ -1190,7 +1190,7 @@ switch ($op) {
// Nota di debito
if (get('op') == 'nota_addebito') {
$rs_segment = $dbo->fetchArray('SELECT * FROM `zz_segments` LEFT JOIN `zz_segments_lang` ON (`zz_segments`.`id` = `zz_segments_lang`.`id_record` AND `zz_segments_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).") WHERE `predefined_addebito`='1'");
$rs_segment = $dbo->fetchArray('SELECT `zz_segments`.* FROM `zz_segments` LEFT JOIN `zz_segments_lang` ON (`zz_segments`.`id` = `zz_segments_lang`.`id_record` AND `zz_segments_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).") WHERE `predefined_addebito`='1'");
if (!empty($rs_segment)) {
$id_segment = $rs_segment[0]['id'];
} else {
@ -1198,8 +1198,7 @@ if (get('op') == 'nota_addebito') {
}
$anagrafica = $fattura->anagrafica;
$id_tipo = database()->fetchOne('SELECT `co_tipidocumento`.`id` FROM `co_tipidocumento` LEFT JOIN `co_tipidocumento_lang` ON (`co_tipidocumento_lang`.`id_record` = `co_tipidocumento`.`id` AND `co_tipidocumento_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `title` = "Nota di debito" AND `dir` = "entrata"')['id'];
$tipo = Tipo::find($id_tipo);
$tipo = Tipo::where('name', 'Nota di debito')->where('dir', 'entrata')->first();
$data = $fattura->data;
$nota = Fattura::build($anagrafica, $tipo, $data, $id_segment);

View File

@ -39,10 +39,10 @@ if ($dir == 'entrata' || !empty($abilita_autofattura)) {
if ($dir == 'entrata') {
echo '
<ul class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" data-href="'.base_path().'/editor.php?id_module='.$id_module.'&id_record='.$id_record.'&op=nota_addebito&backto=record-edit">
<a class="dropdown-item" href="'.base_path().'/editor.php?id_module='.$id_module.'&id_record='.$id_record.'&op=nota_addebito&backto=record-edit">
'.tr('Nota di debito').'
</a>
<a class="dropdown-item" data-href="'.base_path().'/modules/fatture/crea_documento.php?id_module='.$id_module.'&id_record='.$id_record.'&iddocumento='.$id_record.'" data-title="Aggiungi nota di credito">
'.tr('Nota di credito').'
</a>