1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-03-03 18:58:54 +01:00

Aggiornamento stampe preventivi

Aggiornamento del template di stampa per i preventivi, con bugfix e miglioramenti vari distribuiti.
This commit is contained in:
Thomas Zilio 2017-09-12 16:17:11 +02:00
parent ba18290587
commit fe19b60180
23 changed files with 414 additions and 419 deletions

View File

@ -77,6 +77,7 @@ $(document).ready(function () {
}
);
// Messaggi automatici di eliminazione
$(document).on('click', '.ask', function () {
message(this);
});

View File

@ -1,9 +1,11 @@
$(document).ready(function () {
// Modal di default
$('[data-href]').not('.ask, .bound').click(function () {
$(this).addClass('bound');
launch_modal($(this).data('title'), $(this).data('href'), 1, $(this).data('target'));
});
$('[data-href]').not('.ask, .bound').addClass('bound');
// Tooltip
$('.tip').not('.tooltipstered').tooltipster({
animation: 'grow',
contentAsHTML: true,
@ -15,6 +17,7 @@ $(document).ready(function () {
position: 'top'
});
// Autosize per le textarea
autosize($('.autosize'));
$(".bootstrap-switch").bootstrapSwitch();

View File

@ -7,5 +7,5 @@ if (isset($id_record)) {
}
$id_azienda = $dbo->fetchArray("SELECT idtipoanagrafica FROM an_tipianagrafiche WHERE descrizione='Azienda'")[0]['idtipoanagrafica'];
$id_cliente = $dbo->fetchArray("SELECT descrizione FROM an_tipianagrafiche WHERE descrizione='Cliente'");
$id_fornitore = $dbo->fetchArray("SELECT descrizione FROM an_tipianagrafiche WHERE descrizione='Fornitore'");
$id_cliente = $dbo->fetchArray("SELECT idtipoanagrafica FROM an_tipianagrafiche WHERE descrizione='Cliente'")[0]['idtipoanagrafica'];
$id_fornitore = $dbo->fetchArray("SELECT idtipoanagrafica FROM an_tipianagrafiche WHERE descrizione='Fornitore'")[0]['idtipoanagrafica'];

View File

@ -184,7 +184,7 @@ switch (post('op')) {
$insert = str_replace('|altro|', 'NULL', $insert); // prepare($this_altro)
// Verifico che questa combinazione non esista già
$np = $dbo->fetchNum('SELECT id FROM mg_prodotti WHERE id_articolo='.prepare($id_record).' AND lotto='.prepare($this_lotto).' AND serial='.prepare($this_serial).' AND altro='.prepare($this_altro));
$np = $dbo->fetchNum('SELECT id FROM mg_prodotti WHERE id_articolo='.prepare($id_record).' AND serial='.prepare($this_serial));
if ($np == 0) {
$query .= $insert.', ';
++$c;

View File

@ -28,8 +28,7 @@ $next_serial = get_next_code($max_serial);
echo '
<form action="" method="post" role="form">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="op" value="addprodotto">
<input type="hidden" name="id_record" value="'.$id_record.'">';
<input type="hidden" name="op" value="addprodotto">';
// Campi di inserimento lotti
echo '

View File

@ -36,7 +36,11 @@ switch (filter('op')) {
} elseif ($password != $password_rep) {
$_SESSION['errors'][] = tr('Le password non coincidono');
} else {
$dbo->query('UPDATE zz_users SET password='.prepare(Auth::hashPassword($password)).' WHERE id='.prepare($id_utente));
$idanag = explode('-', filter('idanag'));
$idtipoanagrafica = $idanag[0];
$idanagrafica = $idanag[1];
$dbo->query('UPDATE zz_users SET password='.prepare(Auth::hashPassword($password)).', idanagrafica='.prepare($idanagrafica).', idtipoanagrafica='.prepare($idtipoanagrafica).' WHERE id='.prepare($id_utente));
$_SESSION['infos'][] = tr('Password aggiornata!');
}
@ -69,12 +73,9 @@ switch (filter('op')) {
$password = filter('password1');
$password_rep = filter('password2');
$idtipoanagrafica = '';
$idanag = explode('-', filter('idanag'));
if (count($idanag) == 2) {
$idtipoanagrafica = $idanag[0];
$idanagrafica = $idanag[1];
}
$idtipoanagrafica = $idanag[0];
$idanagrafica = $idanag[1];
// Verifico che questo username non sia già stato usato
$n = $dbo->fetchNum('SELECT * FROM zz_users WHERE username='.prepare($username));

View File

@ -129,10 +129,13 @@ echo '
// Eliminazione gruppo (se non è tra quelli di default)
if ($record['editable'] == 1) {
echo '
<div class="pull-right">
<a class="btn btn-danger ask" data-backto="record-list" data-msg="'.tr('Eliminando questo gruppo verranno eliminati anche i permessi e gli utenti collegati').'" data-op="deletegroup">
<i class="fa fa-trash"></i> '.tr('Elimina').'
</a>
<!-- PULSANTI -->
<div class="row">
<div class="col-md-12 text-right">
<a class="btn btn-danger ask" data-backto="record-list" data-msg="'.tr('Eliminando questo gruppo verranno eliminati anche i permessi e gli utenti collegati').'" data-op="deletegroup">
<i class="fa fa-trash"></i> '.tr('Elimina').'
</a>
</div>
</div>';
}

View File

@ -11,14 +11,17 @@ $id_utente = filter('id_utente');
if (!empty($id_utente)) {
$value = 'change_pwd';
$rs = $dbo->fetchArray('SELECT username FROM zz_users WHERE id='.prepare($id_utente));
$username = $rs[0]['username'];
$message = tr('Modifica');
$rs = $dbo->fetchArray('SELECT idanagrafica, idtipoanagrafica, username FROM zz_users WHERE id='.prepare($id_utente));
$username = $rs[0]['username'];
$id_anagrafica = $rs[0]['idtipoanagrafica'].'-'.$rs[0]['idanagrafica'];
} else {
$value = 'adduser';
$username = '';
$message = tr('Aggiungi');
$username = '';
$id_anagrafica = '';
}
echo '
@ -51,15 +54,13 @@ echo '
</div>
</div>';
if (empty($id_utente)) {
echo '
echo '
<div class="row">
<div class="col-xs-12">
{[ "type": "select", "label": "'.tr('Collega ad una anagrafica').'", "name": "idanag", "values": "query=SELECT CONCAT(`an_tipianagrafiche`.`idtipoanagrafica`, \'-\', `an_anagrafiche`.`idanagrafica`) AS \'id\', `ragione_sociale` AS \'descrizione\', `descrizione` AS \'optgroup\' FROM `an_tipianagrafiche` INNER JOIN `an_tipianagrafiche_anagrafiche` ON `an_tipianagrafiche`.`idtipoanagrafica`=`an_tipianagrafiche_anagrafiche`.`idtipoanagrafica` INNER JOIN `an_anagrafiche` ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica` ORDER BY `descrizione` ASC", "value": "" ]}
{[ "type": "select", "label": "'.tr('Collega ad una anagrafica').'", "name": "idanag", "values": "query=SELECT CONCAT(`an_tipianagrafiche`.`idtipoanagrafica`, \'-\', `an_anagrafiche`.`idanagrafica`) AS \'id\', `ragione_sociale` AS \'descrizione\', `descrizione` AS \'optgroup\' FROM `an_tipianagrafiche` INNER JOIN `an_tipianagrafiche_anagrafiche` ON `an_tipianagrafiche`.`idtipoanagrafica`=`an_tipianagrafiche_anagrafiche`.`idtipoanagrafica` INNER JOIN `an_anagrafiche` ON `an_anagrafiche`.`idanagrafica`=`an_tipianagrafiche_anagrafiche`.`idanagrafica` ORDER BY `descrizione` ASC", "value": "'.$id_anagrafica.'" ]}
</div>
</div>';
}
echo '

View File

@ -97,7 +97,7 @@ table.table-bordered thead tr:nth-child(2) th {
background: #eee;
}
#contents th {
#contents thead th {
font-size: 80%;
}

View File

@ -27,7 +27,7 @@ echo "
<thead>
<tr>
<th class='text-center'>".tr('Descrizione', [], ['upper' => true])."</th>
<th class='text-center' style='width:7%'>".tr('Q.', [], ['upper' => true]).'</th>';
<th class='text-center' style='width:7%'>".tr('Q.', [], ['upper' => true]).'</th>';
if ($mostra_prezzi) {
echo "

View File

@ -10,7 +10,7 @@ if ($mostra_prezzi) {
<tr>
<td rowspan='7'>
<p class='small-bold'>".tr('Note', [], ['upper' => true]).'</p>
<p>'.nl2br($rs[0]['note'])."</p>
<p>'.nl2br($records[0]['note'])."</p>
</td>
<td style='width:33mm;'>
<p class='small-bold'>".tr('Totale imponibile', [], ['upper' => true]).'</p>
@ -58,7 +58,7 @@ if ($mostra_prezzi) {
<tr>
<td style='height:40mm;'>
<p class='small-bold'>".tr('Note', [], ['upper' => true]).'</p>
'.nl2br($rs[0]['note']).'
'.nl2br($records[0]['note']).'
</td>
</tr>';
}
@ -74,11 +74,11 @@ echo '
</th>
<th class="border-bottom border-right" style="width:33%">
'.tr('Causale trasporto', [], ['upper' => true]).'
'.tr('Causale trasporto', [], ['upper' => true]).'
</th>
<th class="border-bottom" style="width:33%">
'.tr('Porto', [], ['upper' => true]).'
'.tr('Porto', [], ['upper' => true]).'
</th>
</tr>

View File

@ -4,24 +4,24 @@ include_once __DIR__.'/../../core.php';
// Lettura info ddt
$q = 'SELECT *, (SELECT dir FROM dt_tipiddt WHERE id=idtipoddt) AS dir, (SELECT descrizione FROM dt_tipiddt WHERE id=idtipoddt) AS tipo_doc, (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 dt_ddt WHERE id='.prepare($idddt);
$rs = $dbo->fetchArray($q);
$records = $dbo->fetchArray($q);
$module_name = ($rs[0]['dir'] == 'entrata') ? 'Ddt di vendita' : 'Ddt di acquisto';
$module_name = ($records[0]['dir'] == 'entrata') ? 'Ddt di vendita' : 'Ddt di acquisto';
$id_cliente = $rs[0]['idanagrafica'];
$id_sede = $rs[0]['idsede'];
$id_cliente = $records[0]['idanagrafica'];
$id_sede = $records[0]['idsede'];
$numero = !empty($rs[0]['numero_esterno']) ? $rs[0]['numero_esterno'] : $rs[0]['numero'];
$numero = !empty($records[0]['numero_esterno']) ? $records[0]['numero_esterno'] : $records[0]['numero'];
if (empty($rs[0]['numero_esterno'])) {
if (empty($records[0]['numero_esterno'])) {
$numero = 'pro-forma '.$numero;
$tipo_doc = 'DDT PRO-FORMA';
}
// Leggo i dati della destinazione (se 0=sede legale, se!=altra sede da leggere da tabella an_sedi)
$destinazione = '';
if (!empty($rs[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($rs[0]['idsede']));
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']));
if (!empty($rsd[0]['indirizzo'])) {
$destinazione .= $rsd[0]['indirizzo'].'<br/>';
@ -44,15 +44,15 @@ if (!empty($rs[0]['idsede'])) {
$custom = [
'tipo_doc' => strtoupper($tipo_doc),
'numero_doc' => $numero,
'data' => Translator::numberToLocale($rs[0]['data']),
'pagamento' => $rs[0]['tipo_pagamento'],
'data' => Translator::numberToLocale($records[0]['data']),
'pagamento' => $records[0]['tipo_pagamento'],
'c_destinazione' => $destinazione,
'aspettobeni' => $rs[0]['aspettobeni'],
'causalet' => $rs[0]['causalet'],
'porto' => $rs[0]['porto'],
'n_colli' => !empty($rs[0]['n_colli']) ? $rs[0]['n_colli'] : '',
'spedizione' => $rs[0]['spedizione'],
'vettore' => $rs[0]['vettore'],
'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

View File

@ -25,7 +25,7 @@ echo "
<thead>
<tr>
<th class='text-center' style='width:50%'>".tr('Descrizione', [], ['upper' => true])."</th>
<th class='text-center' style='width:10%'>".tr('Q.', [], ['upper' => true])."</th>
<th class='text-center' style='width:10%'>".tr('Q.', [], ['upper' => true])."</th>
<th class='text-center' style='width:7%'>".tr('Um', [], ['upper' => true])."</th>
<th class='text-center' style='width:16%'>".tr('Costo unitario', [], ['upper' => true])."</th>
<th class='text-center' style='width:20%'>".tr('Importo', [], ['upper' => true])."</th>
@ -37,8 +37,6 @@ echo "
// RIGHE FATTURA CON ORDINAMENTO UNICO
$righe = $dbo->fetchArray("SELECT *, IFNULL((SELECT codice FROM mg_articoli WHERE id=idarticolo),'') AS codice_articolo, (SELECT percentuale FROM co_iva WHERE id=idiva) AS perc_iva FROM `co_righe_documenti` WHERE iddocumento=".prepare($iddocumento).' ORDER BY `order`');
$tot_righe = sizeof($righe);
foreach ($righe as $r) {
$autofill['count'] += ceil(strlen($r['descrizione']) / $autofill['words']);
$autofill['count'] += substr_count($r['descrizione'], PHP_EOL);
@ -150,11 +148,11 @@ foreach ($v_iva as $key => $value) {
}
}
if (!empty($rs[0]['note'])) {
if (!empty($records[0]['note'])) {
echo '
<br>
<p class="small-bold">'.tr('Note', [], ['upper' => true]).':</p>
<p>'.$rs[0]['note'].'</p>';
<p>'.nl2br($records[0]['note']).'</p>';
}
// Info per il footer

View File

@ -148,7 +148,7 @@ echo "
</tr>';
// Riga 4 (opzionale, solo se c'è la ritenuta d'acconto)
if ($rs[0]['ritenutaacconto'] != 0) {
if ($records[0]['ritenutaacconto'] != 0) {
$rs2 = $dbo->fetchArray('SELECT percentuale FROM co_ritenutaacconto WHERE id=(SELECT idritenutaacconto FROM co_righe_documenti WHERE iddocumento='.prepare($iddocumento).' AND idritenutaacconto!=0 LIMIT 0,1)');
echo "
@ -162,7 +162,7 @@ if ($rs[0]['ritenutaacconto'] != 0) {
<tr>
<td style='text-align:right;' class='border-bottom border-right cell-padded'>
".Translator::numberToLocale($rs[0]['ritenutaacconto'], 2)." &euro;
".Translator::numberToLocale($records[0]['ritenutaacconto'], 2)." &euro;
</td>
</tr>
@ -174,7 +174,7 @@ if ($rs[0]['ritenutaacconto'] != 0) {
<tr>
<td style='text-align:right;' class='border-bottom border-right cell-padded'>
".Translator::numberToLocale($totale_documento - $rs[0]['ritenutaacconto'], 2).' &euro;
".Translator::numberToLocale($totale_documento - $records[0]['ritenutaacconto'], 2).' &euro;
</td>
</tr>';
}

View File

@ -3,30 +3,30 @@
include_once __DIR__.'/../../core.php';
// Lettura info fattura
$rs = $dbo->fetchArray('SELECT *,
$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
FROM co_documenti WHERE id='.prepare($iddocumento));
$module_name = ($rs[0]['dir'] == 'entrata') ? 'Fatture di vendita' : 'Fatture di acquisto';
$module_name = ($records[0]['dir'] == 'entrata') ? 'Fatture di vendita' : 'Fatture di acquisto';
$id_cliente = $rs[0]['idanagrafica'];
$id_sede = $rs[0]['idsede'];
$id_cliente = $records[0]['idanagrafica'];
$id_sede = $records[0]['idsede'];
$tipo_doc = $rs[0]['tipo_doc'];
if ($rs[0]['stato_doc'] != 'Bozza') {
$numero = !empty($rs[0]['numero_esterno']) ? $rs[0]['numero_esterno'] : $rs[0]['numero'];
$tipo_doc = $records[0]['tipo_doc'];
if ($records[0]['stato_doc'] != 'Bozza') {
$numero = !empty($records[0]['numero_esterno']) ? $records[0]['numero_esterno'] : $records[0]['numero'];
} else {
$tipo_doc = 'Fattura pro forma';
$numero = 'PRO-'.$rs[0]['numero'];
$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($rs[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($rs[0]['idsede']));
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']));
if (!empty($rsd[0]['indirizzo'])) {
$destinazione .= $rsd[0]['indirizzo'].'<br/>';
@ -49,8 +49,8 @@ if (!empty($rs[0]['idsede'])) {
$custom = [
'tipo_doc' => strtoupper($tipo_doc),
'numero_doc' => $numero,
'data' => Translator::dateToLocale($rs[0]['data']),
'pagamento' => $rs[0]['tipo_pagamento'],
'data' => Translator::dateToLocale($records[0]['data']),
'pagamento' => $records[0]['tipo_pagamento'],
'c_destinazione' => $destinazione,
];

View File

@ -153,7 +153,7 @@ if (!empty($rs2)) {
$netto = $r['prezzo_vendita'] * $r['qta'] - $r['sconto'];
echo '
<td class="text-center">
'.($visualizza_costi ? Translator::numberToLocale($netto, 2) : '-').'
'.($mostra_prezzi ? Translator::numberToLocale($netto, 2) : '-').'
</td>
</tr>';
}
@ -162,7 +162,7 @@ if (!empty($rs2)) {
</tbody>';
// Totale spesa articoli
if ($visualizza_costi) {
if ($mostra_prezzi) {
echo '
<tr>
<td colspan="2" class="text-right">
@ -231,21 +231,21 @@ if (!empty($rs2)) {
// Prezzo unitario
echo '
<td class="text-center">
'.($visualizza_costi ? Translator::numberToLocale($r['prezzo_vendita'], 2).' &euro;' : '-').'
'.($mostra_prezzi ? Translator::numberToLocale($r['prezzo_vendita'], 2).' &euro;' : '-').'
</td>';
// Prezzo totale
$netto = $r['prezzo_vendita'] * $r['qta'] - $r['sconto'];
echo '
<td class="text-center">
'.($visualizza_costi ? Translator::numberToLocale($netto, 2) : '-').'
'.($mostra_prezzi ? Translator::numberToLocale($netto, 2) : '-').'
</td>
</tr>';
}
echo '
</tbody>';
if ($visualizza_costi) {
if ($mostra_prezzi) {
// Totale spese aggiuntive
echo '
<tr>
@ -349,7 +349,7 @@ echo '
<tr>';
// Ore lavorate
if ($visualizza_costi) {
if ($mostra_prezzi) {
$ore = get_ore_intervento($idintervento);
$costo_orario = $records[0]['tot_ore_consuntivo'] - $records[0]['tot_dirittochiamata'];
@ -396,7 +396,7 @@ echo '
</tr>';
// TOTALE COSTI FINALI
if ($visualizza_costi) {
if ($mostra_prezzi) {
// Totale imponibile
echo '
<tr>

View File

@ -23,4 +23,4 @@ $custom = [
'commessa_numero' => !empty($records[0]['numero_preventivo']) ? $records[0]['codice'] : '&nbsp;',
];
$visualizza_costi = get_var("Visualizza i costi sulle stampe degli interventi");
$mostra_prezzi = get_var("Visualizza i costi sulle stampe degli interventi");

View File

@ -0,0 +1,305 @@
<?php
include_once __DIR__.'/../../core.php';
$report_name = 'preventivo_'.$idpreventivo.'.pdf';
$autofill = [
'count' => 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' => 10, // Numero di righe massimo da aggiungere
'columns' => 5, // Numero di colonne della tabella
];
echo '
<div class="row">
<div class="col-xs-6">
<div class="text-center" style="height:5mm;">
<b>'.tr('Preventivo N<sup>o</sup> _NUM_ del _DATE_', [
'_NUM_' => $records[0]['numero'],
'_DATE_' => Translator::dateToLocale($records[0]['data']),
], ['upper' => true]).'</b>
</div>
</div>
<div class="col-xs-5 col-xs-offset-1">
<table class="table" style="width:100%;margin-top:5mm;">
<tr>
<td colspan=2 class="border-full" style="height:16mm;">
<p class="small-bold">'.tr('Spett.le', [], ['upper' => true]).'</p>
<p>$c_ragionesociale$</p>
<p>$c_indirizzo$ $c_citta$</p>
</td>
</tr>
<tr>
<td class="border-bottom border-left">
<p class="small-bold">'.tr('Partita IVA', [], ['upper' => true]).'</p>
</td>
<td class="border-right border-bottom text-right">
<small>$c_piva$</small>
</td>
</tr>
<tr>
<td class="border-bottom border-left">
<p class="small-bold">'.tr('Codice fiscale', [], ['upper' => true]).'</p>
</td>
<td class="border-right border-bottom text-right">
<small>$c_codicefiscale$</small>
</td>
</tr>
</table>
</div>
</div>';
// Descrizione
if (!empty($records[0]['descrizione'])) {
echo '
<p>'.nl2br($records[0]['descrizione']).'</p>
<br>';
}
$sconto = [];
$imponibile = [];
$iva = [];
// Intestazione tabella per righe
echo "
<table class='table table-striped' id='contents'>
<thead>
<tr>
<th class='text-center' style='width:50%'>".tr('Descrizione', [], ['upper' => true])."</th>
<th class='text-center' style='width:10%'>".tr('Q.tà', [], ['upper' => true])."</th>
<th class='text-center' style='width:15%'>".tr('Costo unitario', [], ['upper' => true])."</th>
<th class='text-center' style='width:15%'>".tr('Imponibile', [], ['upper' => true])."</th>
<th class='text-center' style='width:10%'>".tr('IVA', [], ['upper' => true]).' (%)</th>
</tr>
</thead>
<tbody>';
// RIGHE PREVENTIVO CON ORDINAMENTO UNICO
$righe = $dbo->fetchArray("SELECT *, IFNULL((SELECT codice FROM mg_articoli WHERE id=idarticolo),'') AS codice, (SELECT percentuale FROM co_iva WHERE id=idiva) AS perc_iva FROM `co_righe_preventivi` WHERE idpreventivo=".prepare($idpreventivo).' ORDER BY `order`');
foreach ($righe as $r) {
$count = 0;
$count += ceil(strlen($r['descrizione']) / $autofill['words']);
$count += substr_count($r['descrizione'], PHP_EOL);
echo '
<tr>
<td>
'.nl2br($r['descrizione']);
if (!empty($r['codice_articolo'])) {
echo '
<br><small>'.tr('COD. _COD_', [
'_COD_' => $r['codice_articolo'],
]).'</small>';
if ($count <= 1) {
$count += 0.4;
}
}
echo '
</td>';
echo "
<td class='text-center'>
".(empty($r['qta']) ? '' : Translator::numberToLocale($r['qta'], 2)).' '.$r['um'].'
</td>';
// Costo unitario
echo "
<td class='text-right'>
".(empty($r['qta']) || empty($r['subtotale']) ? '' : Translator::numberToLocale($r['subtotale'] / $r['qta'], 2)).' &euro;
</td>';
// Imponibile
echo "
<td class='text-right'>
".(empty($r['subtotale']) ? '' : Translator::numberToLocale($r['subtotale'], 2)).' &euro;';
if ($r['sconto'] > 0) {
echo "
<br><small class='help-block'>- sconto ".Translator::numberToLocale($r['sconto_unitario']).($r['tipo_sconto'] == 'PRC' ? '%' : ' &euro;').'</small>';
if ($count <= 1) {
$count += 0.4;
}
}
echo '
</td>';
// Iva
echo '
<td class="text-center">
'.Translator::numberToLocale($r['perc_iva'], 2).'
</td>
</tr>';
$autofill['count'] += $count;
$sconto[] = $r['sconto'];
$imponibile[] = $r['subtotale'];
$iva[] = $r['iva'];
}
$sconto = sum($sconto);
$imponibile = sum($imponibile);
$totale = $imponibile - $sconto;
$iva = sum($iva);
echo '
|autofill|
</tbody>';
// TOTALE COSTI FINALI
if ($mostra_prezzi) {
// Totale imponibile
echo '
<tr>
<td colspan="3" class="text-right border-top">
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
</td>
<th colspan="2" class="text-center">
<b>'.Translator::numberToLocale($imponibile, 2).' &euro;</b>
</th>
</tr>';
// Eventuale sconto incondizionato
if (!empty($sconto)) {
echo '
<tr>
<td colspan="3" class="text-right border-top">
<b>'.tr('Sconto', [], ['upper' => true]).':</b>
</td>
<th colspan="2" class="text-center">
<b>-'.Translator::numberToLocale($sconto, 2).' &euro;</b>
</th>
</tr>';
// Imponibile scontato
echo '
<tr>
<td colspan="3" class="text-right border-top">
<b>'.tr('Imponibile scontato', [], ['upper' => true]).':</b>
</td>
<th colspan="2" class="text-center">
<b>'.Translator::numberToLocale($totale, 2).' &euro;</b>
</th>
</tr>';
}
// IVA
echo '
<tr>
<td colspan="3" class="text-right border-top">
<b>'.tr('Totale IVA', [], ['upper' => true]).':</b>
</td>
<th colspan="2" class="text-center">
<b>'.Translator::numberToLocale($iva, 2).' &euro;</b>
</th>
</tr>';
$totale = sum($totale, $iva);
// TOTALE INTERVENTO
echo '
<tr>
<td colspan="3" class="text-right border-top">
<b>'.tr('Quotazione totale', [], ['upper' => true]).':</b>
</td>
<th colspan="2" class="text-center">
<b>'.Translator::numberToLocale($totale, 2).' &euro;</b>
</th>
</tr>';
}
echo'
</table>';
// CONDIZIONI GENERALI DI FORNITURA
// Lettura pagamenti
$query = 'SELECT * FROM co_pagamenti WHERE id = '.$records[0]['idpagamento'];
$rs = $dbo->fetchArray($query);
$pagamento = $rs[0]['descrizione'];
// Lettura resa
$query = 'SELECT * FROM dt_porto WHERE id = '.$records[0]['idporto'];
$rs = $dbo->fetchArray($query);
$resa_materiale = $rs[0]['descrizione'];
echo '
<table class="table table-bordered">
<tr>
<th colspan="2" class="text-center">
'.tr('Condizioni generali di fornitura', [], ['upper' => true]).'
</th>
</tr>
<tr>
<th style="width:25%">
'.tr('Pagamento', [], ['upper' => true]).'
</th>
<td>
'.$pagamento.'
</td>
</tr>
<tr>
<th>
'.tr('Resa materiale', [], ['upper' => true]).'
</th>
<td>
'.$resa_materiale.'
</td>
</tr>
<tr>
<th>
'.tr('Validità offerta', [], ['upper' => true]).'
</th>
<td>
'.tr('_TOT_ giorni', [
'_TOT_' => $records[0]['validita'],
]).' giorni
</td>
</tr>
<tr>
<th>
'.tr('Tempi consegna', [], ['upper' => true]).'
</th>
<td>
'.$records[0]['tempi_consegna'].'
</td>
</tr>
<tr>
<th>
'.tr('Esclusioni', [], ['upper' => true]).'
</th>
<td>
'.nl2br($records[0]['esclusioni']).'
</td>
</tr>
</table>';
// Conclusione
echo '
<p class="text-center">'.tr("In attesa di un Vostro Cortese riscontro, colgo l'occasione per porgere Cordiali Saluti").'</p>';

View File

@ -0,0 +1,16 @@
<?php
echo '
<div class="row">
<div class="col-xs-6">
<img src="'.__DIR__.'/logo_azienda.jpg" alt="Logo" border="0"/>
</div>
<div class="col-xs-6 text-right">
<p><b>$f_ragionesociale$</b></p>
<p>$f_indirizzo$ $f_citta_full$</p>
<p>'.(!empty($f_piva) ? tr('P.Iva').': ' : '').'$f_piva$</p>
<p>'.(!empty($f_codicefiscale) ? tr('C.F.').': ' : '').'$f_codicefiscale$</p>
<p>'.(!empty($f_capsoc) ? tr('Cap.Soc.').': ' : '').'$f_capsoc$</p>
<p>'.(!empty($f_telefono) ? tr('Tel').': ' : '').'$f_telefono$</p>
</div>
</div>';

View File

@ -0,0 +1,13 @@
<?php
include_once __DIR__.'/../../core.php';
$module_name = 'Preventivi';
// Lettura info fattura
$records = $dbo->fetchArray('SELECT *, data_bozza AS data FROM co_preventivi WHERE co_preventivi.id='.prepare($idpreventivo));
$id_cliente = $records[0]['idanagrafica'];
$id_sede = $records[0]['idsede'];
$mostra_prezzi = get_var('Stampa i prezzi sui preventivi');

View File

@ -1,304 +0,0 @@
<?php
include_once __DIR__.'/../../core.php';
// carica intervento
$idpreventivo = save($_GET['idpreventivo']);
$show_costi = get_var('Stampa i prezzi sui preventivi');
// Lettura dati preventivo e interventi
$q = "SELECT *, data_bozza AS data FROM co_preventivi WHERE co_preventivi.id='".$idpreventivo."'";
$rspreventivii = $dbo->fetchArray($q);
$idcliente = $rspreventivii[0]['idanagrafica'];
// carica report html
$report = file_get_contents($docroot.'/templates/preventivi/preventivo.html');
$body = file_get_contents($docroot.'/templates/preventivi/preventivo_body.html');
include_once $docroot.'/templates/pdfgen_variables.php';
$totrows = sizeof($rspreventivii);
$totale_km = 0;
$totale_ore = 0;
$totale = 0;
$preventivi = [];
$ore = [];
$km = [];
$ntecnici = [];
$tecnici = [];
$costi_orari = [];
$costi_km = [];
$idinterventi = ['-1'];
if ($totrows > 0) {
for ($i = 0; $i < $totrows; ++$i) {
// Lettura numero tecnici collegati all'intervento
$query = 'SELECT an_anagrafiche.idanagrafica, ragione_sociale FROM in_interventi_tecnici LEFT OUTER JOIN an_anagrafiche ON in_interventi_tecnici.idtecnico=an_anagrafiche.idanagrafica WHERE idintervento="'.$rspreventivii[$i]['idintervento'].'"';
$rs = $dbo->fetchArray($query);
$n_tecnici = sizeof($rs);
$tecnici_full = '';
for ($j = 0; $j < $n_tecnici; ++$j) {
$tecnici_full .= '- '.$rs[$j]['ragione_sociale']."<br/>\n";
}
// Conteggio ore totali
$t = datediff('n', $rspreventivii[$i]['ora_dal'], $rspreventivii[$i]['ora_al']);
$ore_pausa = Translator::numberToLocale($rspreventivii[$i]['ore_pausa'], 2);
$t = round($t / 60 - $rspreventivii[$i]['ore_pausa'], 1);
if ($rspreventivii[$i]['data'] != '') {
$line = '<span>Intervento del <b>'.Translator::dateToLocale($rspreventivii[$i]['data']).":</b><br/><small style='color:#444;'>".str_replace("\n", '<br/>', $rspreventivii[$i]['descrizione'])."</small></span><br/>\n";
array_push($preventivi, $line);
}
array_push($km, floatval($rspreventivii[$i]['km']));
array_push($ore, $t);
array_push($ntecnici, $n_tecnici);
array_push($tecnici, $tecnici_full);
if ($rspreventivii[$i]['prezzo_ore'] > 0) {
array_push($ore, $rspreventivii[$i]['prezzo_ore_scontato'] / $rspreventivii[$i]['prezzo_ore']);
} else {
array_push($ore, 0);
}
array_push($costi_orari, floatval($rspreventivii[$i]['costo_orario']));
array_push($costi_km, floatval($rspreventivii[$i]['costo_km']));
if ($rspreventivii[$i]['prezzo_ore_unitario'] > 0) {
$totale_ore += $rspreventivii[$i]['prezzo_ore_scontato'] / $rspreventivii[$i]['prezzo_ore_unitario'];
}
$totale_km += floatval($rspreventivii[$i]['km']);
}
}
// Sostituisco i valori tra | | con il valore del campo del db
$body .= preg_replace('/|(.+?)|/', $rspreventivii[0]['${1}'], $body);
// Lettura nome referenti collegati all'anagrafica
$query = 'SELECT * FROM an_referenti WHERE id = '.$rspreventivii[0]['idreferente'];
$rs = $dbo->fetchArray($query);
$nome_referente = $rs[0]['nome'];
// Tabella intestazione
$body .= "<table border='0' cellspacing='10' cellpadding='10'>\n";
$body .= "<tr><td align=\"left\" width='356' valign='top'>\n";
$body .= '<big><b>'.$f_citta.', '.$rspreventivii[0]['data']."</b></big><br/><br/>\n";
$body .= '<big><b>PREVENTIVO N<sup>o</sup> '.$rspreventivii[0]['numero'].' DEL '.$rspreventivii[0]['data']."</b></big>\n";
$body .= "</td>\n";
$body .= "<td align=\"left\" width='356' valign='top'>\n";
if ($c_cap != '') {
$c_cap = $c_cap.' ';
}
if ($c_provincia != '') {
$c_provincia = ' ('.$c_provincia.')';
}
$body .= '<big style="line-height:5mm" >Spettabile<br/><b>'.$c_ragionesociale.'<br>'.$c_indirizzo.'<br>'.$c_cap.$c_citta.$c_provincia.'<br> P.Iva: '.$c_piva."</b></big>\n";
$body .= "</td>\n";
$body .= "</tr>\n";
if ($nome_referente != '') {
$body .= "<tr><td align=\"left\" colspan=\"2\" >\n";
$body .= '<b><u>C.A.</u></b> '.$nome_referente."\n";
$body .= "</td>\n";
$body .= "</tr>\n";
}
$body .= "<tr><td align=\"left\" colspan=\"2\" >\n";
$body .= '<span>'.str_replace("\n", '<br/>', $rspreventivii[0]['cdescrizione'])."</span><br/><br/>\n";
$body .= "</td>\n";
$body .= "</tr>\n";
$body .= "</table>\n";
/*
TABELLA COSTI
*/
$body .= "<table class='table_values' style='table-layout:fixed;' border='0' cellpadding='0'>\n";
$body .= "<col width='340'><col width='50'><col width='90'><col width='75'><col width='90'>\n";
$body .= "<thead>\n";
$body .= "<tr><th width='340'>Descrizione</th>\n";
$body .= "<th width='50' align='center'>Q.tà</th>\n";
$body .= "<th width='90' align='center'>Costo U.</th>\n";
$body .= "<th width='75' align='center'>Iva</th>\n";
$body .= "<th width='90' align='center'>Imponibile</th></tr>\n";
$body .= "</thead>\n";
$body .= "<tbody>\n";
$cifredecimali = get_var('Cifre decimali per importi');
// ARTICOLI
$q_art = "SELECT *, IFNULL((SELECT codice FROM mg_articoli WHERE id=idarticolo),'') AS codice, (SELECT descrizione FROM co_iva WHERE id=idiva) AS desc_iva FROM `co_righe_preventivi` WHERE idpreventivo='$idpreventivo' ORDER BY id ASC";
$rs_art = $dbo->fetchArray($q_art);
$tot_art = sizeof($rs_art);
$imponibile_articoli = 0.0;
$totale_iva = 0.0;
$totale_sconto = 0.0;
for ($i = 0; $i < $tot_art; ++$i) {
// descrizione
$body .= "<tr><td>\n";
if ($rs_art[$i]['codice'] != '') {
$body .= $rs_art[$i]['codice'].' - ';
}
$body .= nl2br($rs_art[$i]['descrizione']);
$body .= "</td>\n";
// q.tà
$body .= "<td class='table_cell' align=\"right\" valign=\"top\">\n";
$qta = $rs_art[$i]['qta'];
$body .= Translator::numberToLocale($rs_art[$i]['qta'], 2)."\n";
if ($rs_art[$i]['um'] != '') {
$body .= "<br/>\n<small style='color:#555;'>".$rs_art[$i]['um']."</small>\n";
}
$body .= "</td>\n";
// Costo unitario
$body .= "<td class='table_cell' align=\"right\" valign=\"top\">\n";
if ($show_costi) {
$body .= Translator::numberToLocale($rs_art[$i]['subtotale'] / $rs_art[$i]['qta'], 2)." &euro;\n";
if ($rs_art[$i]['sconto'] > 0) {
$body .= "<br/>\n<small style='color:#555;'>- sconto ".Translator::numberToLocale($rs_art[$i]['sconto'], 2)." &euro;</small>\n";
}
} else {
$body .= '-';
}
$totale_sconto += ($rs_art[$i]['sconto'] * $qta);
$body .= "</td>\n";
$body .= "<td class='table_cell' align=\"right\" valign=\"top\">\n";
$iva = $rs_art[$i]['iva'];
$body .= Translator::numberToLocale($iva, 2)." &euro;<br/><small style='color:#777;'>".$rs_art[$i]['desc_iva']."</small>\n";
$body .= "</td>\n";
// Imponibile
$body .= "<td class='table_cell' align=\"right\" valign=\"top\">\n";
if ($show_costi) {
$body .= Translator::numberToLocale($rs_art[$i]['subtotale'] - ($qta * $rs_art[$i]['sconto']), 2)." &euro;\n";
} else {
$body .= '-';
}
$body .= "</td></tr>\n";
$imponibile_articoli += $rs_art[$i]['subtotale'];
$totale_iva += $iva;
}
// SCONTO
if (abs($totale_sconto) > 0) {
$body .= "<tr><td align='right' colspan='4'>\n";
$body .= " <b>SCONTO:</b>\n";
$body .= "</td>\n";
$body .= "<td align=\"right\" bgcolor=\"#cccccc\">\n";
$body .= ' <big><b>- '.Translator::numberToLocale($totale_sconto, 2)." &euro;</b></big>\n";
$body .= "</td></tr>\n";
}
// Totale iva
$body .= "<tr><td align=\"right\" colspan=\"4\">\n";
$body .= " <b>TOTALE IMPONIBILE:</b>\n";
$body .= "</td>\n";
$body .= "<td align=\"right\" bgcolor=\"#cccccc\">\n";
$body .= ' <big><b>'.Translator::numberToLocale(($imponibile_articoli - $totale_sconto), 2)." &euro;</b></big>\n";
$body .= "</td></tr>\n";
// Totale iva
$body .= "<tr><td align=\"right\" colspan=\"4\">\n";
$body .= " <b>TOTALE IVA:</b>\n";
$body .= "</td>\n";
$body .= "<td align=\"right\" bgcolor=\"#cccccc\">\n";
$body .= '<big><b>'.Translator::numberToLocale($totale_iva, 2)." &euro;</b></big>\n";
$body .= "</td></tr>\n";
// Totale complessivo intervento
$body .= "<tr><td align=\"right\" colspan=\"4\">\n";
$body .= "<b>QUOTAZIONE TOTALE:</b> \n";
$body .= "</td>\n";
$body .= "<td align=\"right\" bgcolor=\"#cccccc\">\n";
$body .= '<big><b>'.Translator::numberToLocale(($imponibile_articoli - $totale_sconto) + $totale_iva, 2)." &euro;</b></big>\n";
$body .= "</td></tr>\n";
$body .= "</tbody>\n";
$body .= "</table><br/><br/>\n";
// CONDIZIONI GENERALI DI FORNITURA
// Lettura pagamenti
$query = 'SELECT * FROM co_pagamenti WHERE id = '.$rspreventivii[0]['idpagamento'];
$rs = $dbo->fetchArray($query);
$pagamento = $rs[0]['descrizione'];
// Lettura resa
$query = 'SELECT * FROM dt_porto WHERE id = '.$rspreventivii[0]['idporto'];
$rs = $dbo->fetchArray($query);
$resa_materiale = $rs[0]['descrizione'];
$rspreventivii[0]['idpagamento'];
$body .= "<nobreak><table border=\"0\" cellpadding='0' cellspacing='10'>\n";
$body .= "<col width='200'><col width='510'>\n";
$body .= "<tr><td align=\"center\" valign=\"middle\" style=\"height:5mm;font-size:14pt;\" bgcolor=\"#dddddd\" colspan=\"2\">\n";
$body .= "<span><b>CONDIZIONI GENERALI DI FORNITURA</b></span>\n";
$body .= "</td></tr>\n";
// PAGAMENTI
$body .= "<tr><td>\n";
$body .= "<big><b><u>PAGAMENTI:</u></b></big>\n";
$body .= "</td>\n";
$body .= "<td>\n";
$body .= '<span><b>'.$pagamento."</b></span>\n";
$body .= "</td></tr>\n";
// RESA MATERIALI
$body .= "<tr><td>\n";
$body .= "<big><b><u>RESA MATERIALI:</u></b></big>\n";
$body .= "</td>\n";
$body .= "<td>\n";
$body .= '<span><b>'.$resa_materiale."</b></span>\n";
$body .= "</td></tr>\n";
// VALIDITA' OFFERTA
$body .= "<tr><td>\n";
$body .= "<big><b><u>VALIDIT&Agrave; OFFERTA:</u></b></big>\n";
$body .= "</td>\n";
$body .= "<td>\n";
$body .= '<span><b>'.$rspreventivii[0]['validita']." giorni</b></span>\n";
$body .= "</td></tr>\n";
// TEMPI CONSEGNA
$body .= "<tr><td>\n";
$body .= "<big><b><u>TEMPI CONSEGNA:</u></b></big>\n";
$body .= "</td>\n";
$body .= "<td>\n";
$body .= '<span><b>'.$rspreventivii[0]['tempi_consegna']." giorni</b></span>\n";
$body .= "</td></tr>\n";
// ESCLUSIONI
$body .= "<tr><td valign='top'>\n";
$body .= "<big><b><u>ESCLUSIONI:</u></b></big>\n";
$body .= "</td>\n";
$body .= "<td>\n";
$body .= '<span><b>'.nl2br($rspreventivii[0]['esclusioni'])."</b></span>\n";
$body .= "</td></tr>\n";
$body .= "<tr>\n";
$body .= " <td colspan='2'>\n";
$body .= " <br/><span>In attesa di un Vostro Cortese riscontro, colgo l&rsquo;occasione per porgere Cordiali Saluti.</span>\n";
$body .= " </td>\n";
$body .= "</tr>\n";
$body .= "</table></nobreak>\n";
$report_name = 'preventivo_'.$idpreventivo.'.pdf';

View File

@ -1,18 +0,0 @@
<style>
<!--
.table_values td{
border: 1px solid #888;
padding: 4px;
white-space: normal;
}
.table_values th{
background: #abbfcb;
padding: 4px;
}
-->
</style>
<page backcolor="#ffffff" backtop="45mm" backbottom="10mm" backleft="0mm" backright="0mm" footer="" style="font-size: $font_size$">
$body$
</page>

View File

@ -1,23 +0,0 @@
<page_header>
<table $body_table_params$>
<tr>
<td style="width:90mm; font-size:8pt;text-align:left;color:#555;">
<img src="$docroot$/templates/preventivi/logo_azienda.jpg" alt="Logo" border="0" />
</td>
<td style="width:45mm; font-size:8pt; color:#555;" style="font-size:8pt;text-align:left;color:#555;">
$f_ragionesociale$
$f_indirizzo$
$f_citta_full$
$f_piva$
$f_codicefiscale$
$f_capsoc$
$f_telefono$
$f_sitoweb$
$f_email$
</td>
</tr>
</table>
</page_header>