From d62f5fef5e95a18fe81788f82e77e7a3c151bd44 Mon Sep 17 00:00:00 2001 From: Thomas Zilio Date: Thu, 21 Sep 2017 16:42:27 +0200 Subject: [PATCH] Unificazione delle stampe di fatture e fatture accompagnatorie --- modules/fatture/bulk.php | 2 +- modules/fatture/edit.php | 6 - templates/fatture/body.php | 4 +- templates/fatture/footer.php | 102 +++- templates/fatture/header.php | 18 +- templates/fatture/init.php | 53 +- .../fatture_accompagnatorie/fattura.html | 22 - .../fatture_accompagnatorie/fattura_body.html | 55 -- .../fatture_accompagnatorie/logo_azienda.jpg | Bin 4348 -> 0 bytes .../pdfgen.fatture_accompagnatorie.php | 540 ------------------ 10 files changed, 136 insertions(+), 666 deletions(-) delete mode 100644 templates/fatture_accompagnatorie/fattura.html delete mode 100644 templates/fatture_accompagnatorie/fattura_body.html delete mode 100644 templates/fatture_accompagnatorie/logo_azienda.jpg delete mode 100644 templates/fatture_accompagnatorie/pdfgen.fatture_accompagnatorie.php diff --git a/modules/fatture/bulk.php b/modules/fatture/bulk.php index bd52f3390..77116ac33 100644 --- a/modules/fatture/bulk.php +++ b/modules/fatture/bulk.php @@ -27,7 +27,7 @@ switch (post('op')) { $_GET['iddocumento'] = $r['id']; // Fix temporaneo per la stampa $iddocumento = $r['id']; // Fix temporaneo per la stampa - $ptype = ($r['descrizione'] == 'Fattura accompagnatoria di vendita') ? 'fatture_accompagnatorie' : 'fatture'; + $ptype = 'fatture'; require DOCROOT.'/pdfgen.php'; } diff --git a/modules/fatture/edit.php b/modules/fatture/edit.php index f3a1f908d..d4a01fc63 100644 --- a/modules/fatture/edit.php +++ b/modules/fatture/edit.php @@ -328,15 +328,9 @@ if ($dir == 'entrata') { echo "
Prima di procedere alla stampa completa i seguenti campi dell'anagrafica:
".implode(', ', $campi_mancanti).'
'.Modules::link('Anagrafiche', $records[0]['idanagrafica'], tr('Vai alla scheda anagrafica'), null).'
'; } else { - if ($records[0]['descrizione_tipodoc'] == 'Fattura accompagnatoria di vendita') { - ?> - Stampa fattura - Stampa fattura 0, // Conteggio delle righe 'words' => 70, // Numero di parolo dopo cui contare una riga nuova - 'rows' => 20, // Numero di righe massimo presente nella pagina - 'additional' => 15, // Numero di righe massimo da aggiungere + 'rows' => $fattura_accompagnatoria ? 15 : 20, // Numero di righe massimo presente nella pagina + 'additional' => $fattura_accompagnatoria ? 10 : 15, // Numero di righe massimo da aggiungere 'columns' => 5, // Numero di colonne della tabella ]; diff --git a/templates/fatture/footer.php b/templates/fatture/footer.php index b634fdacc..32fc0d556 100644 --- a/templates/fatture/footer.php +++ b/templates/fatture/footer.php @@ -102,22 +102,22 @@ echo ' '; // TOTALI -$width = round(100/(!empty($sconto) ? 5 : 3), 2); +$width = round(100 / (!empty($sconto) ? 5 : 3), 2); echo " - ".tr('Imponibile', [], ['upper' => true])." - "; + ".tr('Imponibile', [], ['upper' => true]).' + '; if (!empty($sconto)) { - echo " + echo " ".tr('Sconto', [], ['upper' => true])." - ".tr('Imponibile scontato', [], ['upper' => true])." - "; + ".tr('Imponibile scontato', [], ['upper' => true]).' + '; } echo " @@ -132,8 +132,8 @@ echo " - ".Translator::numberToLocale($imponibile)." € - "; + ".Translator::numberToLocale($imponibile).' € + '; if (!empty($sconto)) { echo " @@ -143,8 +143,8 @@ if (!empty($sconto)) { - ".Translator::numberToLocale($imponibile - $sconto)." € - "; + ".Translator::numberToLocale($imponibile - $sconto).' € + '; } echo " @@ -163,24 +163,24 @@ if ($records[0]['ritenutaacconto'] != 0) { echo " - - ".tr("Ritenuta d'acconto _PRC_%", [ + Translator::numberToLocale($rs2[0]['percentuale'], 0), ], ['upper' => true])." - - ".tr('Netto a pagare', [], ['upper' => true])." + - - ".Translator::numberToLocale($records[0]['ritenutaacconto'])." € + - - ".Translator::numberToLocale($totale - $records[0]['ritenutaacconto']).' € + + + + '.tr('Aspetto beni', [], ['upper' => true]).' + + + + '.tr('Num. colli', [], ['upper' => true]).' + + + + '.tr('Causale trasporto', [], ['upper' => true]).' + + + + '.tr('Porto', [], ['upper' => true]).' + + + + + + $aspettobeni$   + + + + $n_colli$   + + + + $causalet$   + + + + $porto$   + + +'; + + // Firme + echo ' + + + + + + + + + + + + + + +
+ '.tr('Tipo di spedizione', [], ['upper' => true]).' + + '.tr('Firma conducente', [], ['upper' => true]).' + + '.tr('Firma destinatario', [], ['upper' => true]).' +
$spedizione$ $vettore$
'; +} + echo ' diff --git a/templates/fatture/header.php b/templates/fatture/header.php index 854fc9ec6..a7e11d845 100644 --- a/templates/fatture/header.php +++ b/templates/fatture/header.php @@ -62,7 +62,7 @@ $default_header$
- - + '; + +if ($fattura_accompagnatoria) { + echo ' + + + '; + + $settings['header-height'] += 13; +} + +echo '
+

'.tr('Spett.le', [], ['upper' => true]).'

$c_ragionesociale$

$c_indirizzo$ $c_citta_full$

@@ -85,7 +85,21 @@ $default_header$
$c_codicefiscale$
+

'.tr('Destinazione diversa', [], ['upper' => true]).'

+

$c_destinazione$

+
'; diff --git a/templates/fatture/init.php b/templates/fatture/init.php index e7ba805dc..8da56ba8b 100644 --- a/templates/fatture/init.php +++ b/templates/fatture/init.php @@ -7,7 +7,12 @@ $records = $dbo->fetchArray('SELECT *, (SELECT descrizione FROM co_statidocumento WHERE id=idstatodocumento) AS stato_doc, (SELECT descrizione FROM co_tipidocumento WHERE id=idtipodocumento) AS tipo_doc, (SELECT descrizione FROM co_pagamenti WHERE id=idpagamento) AS tipo_pagamento, - (SELECT dir FROM co_tipidocumento WHERE id=idtipodocumento) AS dir + (SELECT dir FROM co_tipidocumento WHERE id=idtipodocumento) AS dir, + (SELECT descrizione FROM dt_causalet WHERE id=idcausalet) AS causalet, + (SELECT descrizione FROM dt_porto WHERE id=idporto) AS porto, + (SELECT descrizione FROM dt_aspettobeni WHERE id=idaspettobeni) AS aspettobeni, + (SELECT descrizione FROM dt_spedizione WHERE id=idspedizione) AS spedizione, + (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=idvettore) AS vettore FROM co_documenti WHERE id='.prepare($id_record)); $module_name = ($records[0]['dir'] == 'entrata') ? 'Fatture di vendita' : 'Fatture di acquisto'; @@ -23,26 +28,28 @@ if ($records[0]['stato_doc'] != 'Bozza') { $numero = 'PRO-'.$records[0]['numero']; } -// Leggo i dati della destinazione (se 0=sede legale, se!=altra sede da leggere da tabella an_sedi) -$destinazione = ''; -if (!empty($records[0]['idsede'])) { - $rsd = $dbo->fetchArray('SELECT (SELECT codice FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS codice, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS ragione_sociale, indirizzo, indirizzo2, cap, citta, provincia, piva, codice_fiscale FROM an_sedi WHERE idanagrafica='.prepare($id_cliente).' AND id='.prepare($records[0]['idsede'])); +// Fix per le fattura accompagnatorie +$fattura_accompagnatoria = ($records[0]['tipo_doc'] == 'Fattura accompagnatoria di vendita'); +$tipo_doc = ($fattura_accompagnatoria) ? 'Fattura accompagnatoria di vendita' : $tipo_doc; - if (!empty($rsd[0]['indirizzo'])) { - $destinazione .= $rsd[0]['indirizzo'].'
'; - } - if (!empty($rsd[0]['indirizzo2'])) { - $destinazione .= $rsd[0]['indirizzo2'].'
'; - } - if (!empty($rsd[0]['cap'])) { - $destinazione .= $rsd[0]['cap'].' '; - } - if (!empty($rsd[0]['citta'])) { - $destinazione .= $rsd[0]['citta']; - } - if (!empty($rsd[0]['provincia'])) { - $destinazione .= ' ('.$rsd[0]['provincia'].')'; - } +// Leggo i dati della destinazione (se 0=sede legale, se!=altra sede da leggere da tabella an_sedi) +$rsd = $dbo->fetchArray('SELECT (SELECT codice FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS codice, (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS ragione_sociale, indirizzo, indirizzo2, cap, citta, provincia, piva, codice_fiscale FROM an_sedi WHERE idanagrafica='.prepare($id_cliente).(!empty($records[0]['idsede']) ? ' AND id='.prepare($records[0]['idsede']) : '')); + +$destinazione = ''; +if (!empty($rsd[0]['indirizzo'])) { + $destinazione .= $rsd[0]['indirizzo'].'
'; +} +if (!empty($rsd[0]['indirizzo2'])) { + $destinazione .= $rsd[0]['indirizzo2'].'
'; +} +if (!empty($rsd[0]['cap'])) { + $destinazione .= $rsd[0]['cap'].' '; +} +if (!empty($rsd[0]['citta'])) { + $destinazione .= $rsd[0]['citta']; +} +if (!empty($rsd[0]['provincia'])) { + $destinazione .= ' ('.$rsd[0]['provincia'].')'; } // Sostituzioni specifiche @@ -52,6 +59,12 @@ $custom = [ 'data' => Translator::dateToLocale($records[0]['data']), 'pagamento' => $records[0]['tipo_pagamento'], 'c_destinazione' => $destinazione, + 'aspettobeni' => $records[0]['aspettobeni'], + 'causalet' => $records[0]['causalet'], + 'porto' => $records[0]['porto'], + 'n_colli' => !empty($records[0]['n_colli']) ? $records[0]['n_colli'] : '', + 'spedizione' => $records[0]['spedizione'], + 'vettore' => $records[0]['vettore'], ]; // Controllo sui permessi diff --git a/templates/fatture_accompagnatorie/fattura.html b/templates/fatture_accompagnatorie/fattura.html deleted file mode 100644 index c32665b65..000000000 --- a/templates/fatture_accompagnatorie/fattura.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - $body$ - diff --git a/templates/fatture_accompagnatorie/fattura_body.html b/templates/fatture_accompagnatorie/fattura_body.html deleted file mode 100644 index 8eea7b2fb..000000000 --- a/templates/fatture_accompagnatorie/fattura_body.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - -
- Logo
- $f_ragionesociale$ - $f_indirizzo$ - $f_citta_full$ - $f_piva$ - $f_codicefiscale$ - $f_capsoc$ - $f_telefono$ - $f_sitoweb$ - $f_email$ -

- - - - - - - -
- CLIENTE
-
- $c_ragionesociale$ - $c_indirizzo$ - $c_citta$ - $c_piva$ - $c_codicefiscale$ -
-
- DESTINAZIONE
-
- $c_destinazione$ -
-
-
-
- - - - - |footer| - - -
- $dicitura_fissa_fattura$ -
- -
- - $default_footer$ -
diff --git a/templates/fatture_accompagnatorie/logo_azienda.jpg b/templates/fatture_accompagnatorie/logo_azienda.jpg deleted file mode 100644 index 3fd3914522510a5f6af55ca002d656131577943f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4348 zcmcIG2UJtpwl@VrCxoJO0wL0+iU>%N7AX=0X-XSViqaGWl->m-1e5`!S7|~75d=X3 zN^z7RHAo$0C`u6!6#_qDW_+&y)_d>IU-Qnn>)hSXzWeNb_t_uYp8?>f4KM}(2m}J0 zs1w+q08Rn)P&#@#C_OzLJq$+AzyxPvVq|3EVq<54AL2TE_z)Kl51*j8Fdx5|01uCd zjEETeh@_MxuduAVtc1L{gro$`2nYs)F)=W4GBI&V@bU0T{N=IV32-m~J|H;=hyws~ zfFK;8{VsqX009uHw;YHsSymH+?*e`4T3wM!=3P%0DwPvc>F z*G;^Z@LK|Fdd3NSqUGAu@eQMK`F=e#>6TaaO#e|%2%O*{5IK4;5-IuU>Lmw%n1eGe z%kaEY&OC3FH(wd=;LrMJAE+TtEo3Y_yX%0aw~cepyOT7pqflUlRQW{=UZKZKpJiTc z;PdnRc!njkTUU3nfrYRx4*+b+PuY?WyrV7Dt-ixF;CGoHNdF}8aM0-oHUP>Fr-oV* z4uBv~5SWhc&y#=vP&yEplS>J%OwWN3HRl$QSJ6gN-A&QgtFDHC-HhfI>5_Z0A&2cUPd#RbIXo){l zn=;x&Y~0`+X;Q07sDd6Yemk3q5rX?}W>YTvIA!fzGH;tgW;Ss~QFJ=U;FO$aJ7z_p zgQu~Rzg%uiuUZ%jDnFk+GMmKOEp~efQkUuzoN6;TlFYY6&z$zcXLj#7^RCp|D))+j zdQhNV16(lvz;-(KybE6+)HD%!w%yGSvz$>QmgPBUwsdFS!%Aq|P2JT_t%VTV7;S7v zcUq}=IOC~B!{x3*{9QGhN)SEPcAicual?{m(CVHDYc%GXfMx>C{E;_et z_NbMda#3kWxu6>Co3Bx#%`jO`+jfsxu0`#m8_|jfJinJkCG4V78IFe`3}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s[0]['dir'] == 'entrata') { - $module_name = 'Fatture di vendita'; -} else { - $module_name = 'Fatture di acquisto'; -} - -$additional_where[$module_name] = str_replace('|idanagrafica|', "'".$user['idanagrafica']."'", $additional_where[$module_name]); - -// Lettura info fattura -$q = 'SELECT *, (SELECT descrizione FROM co_tipidocumento WHERE id=idtipodocumento) AS tipo_doc, (SELECT descrizione FROM co_pagamenti WHERE id=idpagamento) AS tipo_pagamento, (SELECT dir FROM co_tipidocumento WHERE id=idtipodocumento) AS dir FROM co_documenti WHERE id="'.$iddocumento.'" '.$additional_where[$module_name]; -$rs = $dbo->fetchArray($q); -$numero_doc = $rs[0]['numero']; -$idcliente = $rs[0]['idanagrafica']; -(!empty($rs[0]['numero_esterno'])) ? $numero = $rs[0]['numero_esterno'] : $numero = $rs[0]['numero']; - -// carica report html -$report = file_get_contents($docroot.'/templates/fatture_accompagnatorie/fattura.html'); -$body = file_get_contents($docroot.'/templates/fatture_accompagnatorie/fattura_body.html'); - -if (!($idcliente == $user['idanagrafica'] || Auth::admin())) { - die('Non hai i permessi per questa stampa!'); -} - -include_once $docroot.'/templates/pdfgen_variables.php'; - -// Leggo i dati della destinazione (se 0=sede legale, se!=altra sede da leggere da tabella an_sedi) -$destinazione = ''; -if ($rs[0]['idsede'] == 0) { - $queryd = "SELECT ragione_sociale, indirizzo, indirizzo2, cap, citta, provincia, piva, codice_fiscale FROM an_anagrafiche WHERE idanagrafica='".$idcliente."'"; - $rsd = $dbo->fetchArray($queryd); - - if ($rsd[0]['ragione_sociale'] != '') { - $destinazione .= $rsd[0]['ragione_sociale']."
\n"; - } - if ($rsd[0]['indirizzo'] != '') { - $destinazione .= $rsd[0]['indirizzo']."
\n"; - } - if ($rsd[0]['indirizzo2'] != '') { - $destinazione .= $rsd[0]['indirizzo2']."
\n"; - } - if ($rsd[0]['cap'] != '') { - $destinazione .= $rsd[0]['cap'].' '; - } - if ($rsd[0]['citta'] != '') { - $destinazione .= $rsd[0]['citta']; - } - if ($rsd[0]['provincia'] != '') { - $destinazione .= ' ('.$rsd[0]['provincia'].")
\n"; - } - if ($rsd[0]['piva'] != '') { - $destinazione .= 'P.IVA: '.$rsd[0]['piva']."
\n"; - } - if ($rsd[0]['piva'] == '') { - $destinazione .= 'C.F.: '.$rsd[0]['codice_fiscale']."
\n"; - } -} else { - $queryd = "SELECT (SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=an_sedi.idanagrafica) AS ragione_sociale, indirizzo, indirizzo2, cap, citta, provincia, piva, codice_fiscale FROM an_sedi WHERE idanagrafica='".$idcliente."' AND id='".$rs[0]['idsede']."'"; - $rsd = $dbo->fetchArray($queryd); - - if ($rsd[0]['ragione_sociale'] != '') { - $destinazione .= $rsd[0]['ragione_sociale']."
\n"; - } - if ($rsd[0]['indirizzo'] != '') { - $destinazione .= $rsd[0]['indirizzo']."
\n"; - } - if ($rsd[0]['indirizzo2'] != '') { - $destinazione .= $rsd[0]['indirizzo2']."
\n"; - } - if ($rsd[0]['cap'] != '') { - $destinazione .= $rsd[0]['cap'].' '; - } - if ($rsd[0]['citta'] != '') { - $destinazione .= $rsd[0]['citta']; - } - if ($rsd[0]['provincia'] != '') { - $destinazione .= ' ('.$rsd[0]['provincia'].")
\n"; - } - if ($rsd[0]['piva'] != '') { - $destinazione .= 'P.IVA: '.$rsd[0]['piva']."
\n"; - } - if ($rsd[0]['codice_fiscale'] != '') { - $destinazione .= 'C.F.: '.$rsd[0]['codice_fiscale']."
\n"; - } -} -$body = str_replace('$c_destinazione$', $destinazione, $body); - -// Dati generici fattura -if ($rs[0]['buono_ordine'] != '') { - $width = '165'; -} else { - $width = '228'; -} - -$body .= "\n"; -$body .= "\n"; -$body .= "\n"; -$body .= "\n"; -$body .= "\n"; - -if ($rs[0]['buono_ordine']) { - $body .= "\n"; -} - -$body .= "\n"; -$body .= "
".$rs[0]['tipo_doc']."
num. $numero
Data:
".Translator::dateToLocale($rs[0]['data'])."
Pagamento:
".$rs[0]['tipo_pagamento']."
Buono d'ordine:
".$rs[0]['buono_ordine']."


\n"; - -// Intestazione tabella per righe -$body .= "\n"; -$body .= "\n"; -$body .= "\n"; -$body .= "\n"; -$body .= "\n"; -$body .= "\n"; -$body .= "\n"; -$body .= "\n"; -$body .= "\n"; -$body .= "\n"; - -$body .= "\n"; - -// Mostro le righe del documento -$totale_documento = 0.00; -$totale_imponibile = 0.00; -$totale_iva = 0.00; -$sconto = 0.00; - -/* - Righe fattura -*/ -$qr = "SELECT * FROM `co_righe_documenti` WHERE iddocumento='$iddocumento'"; -$rsr = $dbo->fetchArray($qr); -$tot = sizeof($rsr); -$imponibile_int = 0.00; -$iva_int = 0.00; - -if ($tot > 0) { - for ($i = 0; $i < $tot; ++$i) { - // Intervento - if (!empty($rsr[$i]['idintervento']) && empty($rsr[$i]['idarticolo'])) { - $body .= "\n"; - - $qta = $rsr[$i]['qta']; - ($qta == 0) ? $qta = '-' : $qta = Translator::numberToLocale($qta); - $body .= "\n"; - - ($qta == 0) ? $um = '-' : $um = $rsr[$i]['um']; - $body .= "\n"; - - // costo unitario - $subtotale = $rsr[$i]['subtotale'] / $rsr[$i]['qta']; - ($subtotale == 0) ? $subtotale = '-' : $subtotale = Translator::numberToLocale($subtotale).' €'; - $body .= "\n"; - - $body .= "\n"; - - $body .= "\n"; - - $imponibile_int += $rsr[$i]['subtotale']; - $iva_int += $iva; - $sconto += $rsr[$i]['sconto']; - } - - // Preventivi - elseif ($rsr[$i]['idpreventivo'] != 0) { - $body .= "\n"; - - $body .= "\n"; - - $body .= "\n"; - - $body .= "\n"; - - // Iva - $body .= "\n"; - - // Imponibile - $body .= "\n"; - - $imponibile_pre += $rsr[$i]['subtotale']; - $iva_pre += $iva; - $sconto += $rsr[$i]['sconto']; - } - - // Contratti - elseif ($rsr[$i]['idcontratto'] != 0) { - $body .= "\n"; - - $body .= "\n"; - - $body .= "\n"; - - $body .= "\n"; - - // Iva - $body .= "\n"; - - // Imponibile - $body .= "\n"; - - $imponibile_con += $rsr[$i]['subtotale']; - $iva_con += $iva; - $sconto += $rsr[$i]['sconto']; - } - - // Articoli - elseif ($rsr[$i]['idarticolo'] != 0) { - $body .= "\n"; - - $body .= "\n"; - - $body .= "\n"; - - // costo unitario - $body .= "\n"; - - $body .= "\n"; - - $body .= "\n"; - - $imponibile_art += $rsr[$i]['subtotale']; - $iva_art += $iva; - $sconto += $rsr[$i]['sconto']; - } - - // Righe generiche - else { - $body .= "\n"; - - $body .= "\n"; - - $body .= "\n"; - - $body .= "\n"; - - // Iva - $body .= "\n"; - - // Imponibile - $body .= "\n"; - - $imponibile_gen += $rsr[$i]['subtotale']; - $iva_gen += $iva; - $sconto += $rsr[$i]['sconto']; - } - } - - $imponibile_documento += $imponibile_int; - $totale_iva += $iva_int; - $totale_documento += $imponibile_int; - - $imponibile_documento += $imponibile_pre; - $totale_iva += $iva_pre; - $totale_documento += $imponibile_pre; - - $imponibile_documento += $imponibile_con; - $totale_iva += $iva_con; - $totale_documento += $imponibile_con; - - $imponibile_documento += $imponibile_art; - $totale_iva += $iva_art; - $totale_documento += $imponibile_art; - - $imponibile_documento += $imponibile_gen; - $totale_iva += $iva_gen; - $totale_documento += $imponibile_gen; -} - -// Totale documento -$body .= "\n"; - -// Imponibile -$body .= "\n"; - -// Mostra sconto se c'è -if (abs($sconto) > 0) { - $body .= "\n"; - - // Sconto - $body .= "'; - - // Totale scontato - $body .= "\n"; - - // Sconto - $body .= "\n"; -} - -// Mostra INPS se c'è -if (abs($rs[0]['rivalsainps']) > 0) { - $body .= "\n"; - - // Rivalsa INPS - $body .= "\n"; - $totale_documento += $rs[0]['rivalsainps']; -} - -// Mostra iva se c'è -$totale_iva += $rs[0]['iva_rivalsainps']; -if (abs($totale_iva) > 0) { - $body .= "\n"; - - // Iva - $body .= "\n"; - $totale_documento += $totale_iva; -} - -/* - Totale documento -*/ -$body .= "\n"; - -$body .= "\n"; -$netto_a_pagare = $totale_documento; - -// Mostra marca da bollo se c'è -if (abs($rs[0]['bollo']) > 0) { - $body .= "\n"; - - // Marca da bollo - $body .= "\n"; - $netto_a_pagare += $marca_da_bollo; -} - -// Mostra ritenuta d'acconto se c'è -if (abs($rs[0]['ritenutaacconto']) > 0) { - $body .= "\n"; - - // Ritenuta d'acconto - $body .= "\n"; - $netto_a_pagare -= $rs[0]['ritenutaacconto']; -} - -/* - Netto a pagare (se diverso dal totale) -*/ -if ($totale_documento != $netto_a_pagare) { - $body .= "\n"; - - $body .= "\n"; -} -$body .= "\n"; -$body .= "
DescrizioneQ.tàu.m.Costo unitarioIvaImponibile
\n"; - $body .= nl2br($rsr[$i]['descrizione'])."\n"; - $body .= "\n"; - $body .= $qta; - $body .= "\n"; - $body .= $um; - $body .= "\n"; - $body .= $subtotale."\n"; - $body .= "\n"; - $iva = $rsr[$i]['iva']; - $body .= '
'.Translator::numberToLocale($iva)." €
".$rsr[$i]['desc_iva']."\n"; - $body .= "
\n"; - $subtot = $rsr[$i]['subtotale']; - $body .= Translator::numberToLocale($subtot)." €\n"; - if ($rsr[$i]['sconto'] > 0) { - $body .= "
\n- sconto ".Translator::numberToLocale($rsr[$i]['sconto'])." €\n"; - } - $body .= "
\n"; - $body .= nl2br($rsr[$i]['descrizione'])."\n"; - $body .= "\n"; - $body .= "1\n"; - $body .= "\n"; - $body .= '-'; - $body .= "\n"; - $body .= "-\n"; - $body .= "\n"; - $iva = $rsr[$i]['iva']; - $body .= '
'.Translator::numberToLocale($iva)." €
".$rsr[$i]['desc_iva']."\n"; - $body .= "
\n"; - $subtot = $rsr[$i]['subtotale']; - $body .= Translator::numberToLocale($subtot)." €\n"; - if ($rsr[$i]['sconto'] > 0) { - $body .= "
\n- sconto ".Translator::numberToLocale($rsr[$i]['sconto'])." €\n"; - } - $body .= "
\n"; - $body .= nl2br($rsr[$i]['descrizione'])."\n"; - $body .= "\n"; - $body .= "1\n"; - $body .= "\n"; - $body .= '-'; - $body .= "\n"; - $body .= "-\n"; - $body .= "\n"; - $iva = $rsr[$i]['iva']; - $body .= '
'.Translator::numberToLocale($iva)." €
".$rsr[$i]['desc_iva']."\n"; - $body .= "
\n"; - $subtot = $rsr[$i]['subtotale']; - $body .= Translator::numberToLocale($subtot)." €\n"; - if ($rsr[$i]['sconto'] > 0) { - $body .= "
\n- sconto ".Translator::numberToLocale($rsr[$i]['sconto'])." €\n"; - } - $body .= "
\n"; - - // Immagine articolo - $f = pathinfo($rsr[$i]['immagine01']); - $img = $docroot.'/modules/magazzino/articoli/images/'.$f['filename'].'_thumb100.'.$f['extension']; - if (file_exists($img)) { - $body .= '\"\"\n"; - } - - $body .= nl2br($rsr[$i]['descrizione']); - - // Aggiunta riferimento a ordine - if (!empty($rsr[$i]['idordine'])) { - $rso = $dbo->fetchArray('SELECT numero, numero_esterno, data FROM or_ordini WHERE id="'.$rsr[$i]['idordine'].'"'); - ($rso[0]['numero_esterno'] != '') ? $numero = $rso[0]['numero_esterno'] : $numero = $rso[0]['numero']; - $body .= '
Rif. ordine '.$numero.' del '.Translator::dateToLocale($rso[0]['data']).''; - } - - // Aggiunta riferimento a ddt - elseif (!empty($rsr[$i]['idddt'])) { - $rso = $dbo->fetchArray('SELECT numero, numero_esterno, data FROM dt_ddt WHERE id="'.$rsr[$i]['idddt'].'"'); - ($rso[0]['numero_esterno'] != '') ? $numero = $rso[0]['numero_esterno'] : $numero = $rso[0]['numero']; - $body .= '
Rif. ddt '.$numero.' del '.Translator::dateToLocale($rso[0]['data']).''; - } - $body .= "
\n"; - $body .= Translator::numberToLocale($rsr[$i]['qta']); - $body .= "\n"; - $body .= $rsr[$i]['um']; - $body .= "\n"; - $body .= Translator::numberToLocale($rsr[$i]['subtotale'] / $rsr[$i]['sumqta'])." €\n"; - $body .= "\n"; - $iva = $rsr[$i]['iva']; - $body .= '
'.Translator::numberToLocale($iva)." €
".$rsr[$i]['desc_iva']."\n"; - $body .= "
\n"; - $subtot = $rsr[$i]['subtotale']; - $body .= Translator::numberToLocale($subtot)." €\n"; - if ($rsr[$i]['sconto'] > 0) { - $body .= "
\n- sconto ".Translator::numberToLocale($rsr[$i]['sconto'])." €\n"; - } - $body .= "
\n"; - $body .= nl2br($rsr[$i]['descrizione']); - - // Aggiunta riferimento a ordine - if (!empty($rsr[$i]['idordine'])) { - $rso = $dbo->fetchArray('SELECT numero, numero_esterno, data FROM or_ordini WHERE id="'.$rsr[$i]['idordine'].'"'); - ($rso[0]['numero_esterno'] != '') ? $numero = $rso[0]['numero_esterno'] : $numero = $rso[0]['numero']; - $body .= '
Rif. ordine num.'.$numero.' del '.Translator::dateToLocale($rso[0]['data']).''; - } - - // Aggiunta riferimento a ddt - elseif (!empty($rsr[$i]['idddt'])) { - $rso = $dbo->fetchArray('SELECT numero, numero_esterno, data FROM dt_ddt WHERE id="'.$rsr[$i]['idddt'].'"'); - ($rso[0]['numero_esterno'] != '') ? $numero = $rso[0]['numero_esterno'] : $numero = $rso[0]['numero']; - $body .= '
Rif. ddt num.'.$numero.' del '.Translator::dateToLocale($rso[0]['data']).''; - } - $body .= "
\n"; - $body .= Translator::numberToLocale($rsr[$i]['qta'])."\n"; - $body .= "\n"; - $body .= $rsr[$i]['um']."\n"; - $body .= "\n"; - $body .= Translator::numberToLocale($rsr[$i]['subtotale'] / $rsr[$i]['qta'])." €\n"; - $body .= "\n"; - $iva = $rsr[$i]['iva']; - $body .= '
'.Translator::numberToLocale($iva)." €
".$rsr[$i]['desc_iva']."\n"; - $body .= "
\n"; - $subtot = $rsr[$i]['subtotale']; - $body .= Translator::numberToLocale($subtot)." €\n"; - if ($rsr[$i]['sconto'] > 0) { - $body .= "
\n- sconto ".Translator::numberToLocale($rsr[$i]['sconto'])." €\n"; - } - $body .= "
\n"; -$body .= 'Subtot.:'; -$body .= "\n"; -$totale_documento = $imponibile_documento; -$body .= Translator::numberToLocale($totale_documento)." €\n"; -$body .= "
\n"; - $body .= 'Sconto:'; - $body .= "\n"; - $body .= Translator::numberToLocale($sconto)." €\n"; - $body .= '
\n"; - $body .= 'Totale scontato:'; - $body .= "\n"; - $totale_documento -= $sconto; - $body .= Translator::numberToLocale($totale_documento)." €\n"; - $body .= "
\n"; - $body .= 'Rivalsa INPS:'; - $body .= "\n"; - $body .= Translator::numberToLocale($rs[0]['rivalsainps'])." €\n"; - $body .= "
\n"; - $body .= 'Iva:'; - $body .= "\n"; - $body .= Translator::numberToLocale($totale_iva)." €\n"; - $body .= "
\n"; -$body .= 'Totale documento:'; -$body .= "\n"; -$body .= ''.Translator::numberToLocale($totale_documento)." €\n"; -$body .= "
\n"; - $body .= 'Marca da bollo:'; - $body .= "\n"; - $marca_da_bollo = str_replace(',', '.', $rs[0]['bollo']); - $body .= Translator::numberToLocale($marca_da_bollo).' €'; - $body .= "
\n"; - $body .= "Ritenuta d'acconto:"; - $body .= "\n"; - $body .= Translator::numberToLocale($rs[0]['ritenutaacconto']).' €'; - $body .= "
\n"; - $body .= 'Netto a pagare:'; - $body .= "\n"; - $body .= ''.Translator::numberToLocale($netto_a_pagare)." €\n"; - $body .= "
\n"; - -$body .= '

'.nl2br($rs[0]['note'])."

\n"; - -if ($rs[0]['vettore'] != '') { - $vettore = ' ('.$rs[0]['vettore'].')'; -} else { - $vettore = ''; -} - -// Dati footer ddt -$footer = "

\n"; -$footer .= "\n"; -$footer .= "\n"; -$footer .= "\n"; -$footer .= "\n"; -$footer .= "\n"; -$footer .= "
Colli:
".$rs[0]['n_colli']." 
Aspetto beni:
".$rs[0]['aspettobeni']." 
Causale trasporto:
".$rs[0]['causalet']." 
Porto:
".$rs[0]['porto']." 
\n"; - -$footer .= "\n"; -$footer .= "\n"; -$footer .= "\n"; -$footer .= "\n"; -$footer .= "\n"; -$footer .= "
Tipo di spedizione:
".$rs[0]['spedizione'].$vettore." 
Conducente:
______________________
Destinatario:
______________________
\n"; - -$body = str_replace('|footer|', $footer, $body); - -$report_name = 'fattura_'.$numero_doc.'.pdf';