2017-09-08 17:03:47 +02:00
|
|
|
<?php
|
2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-09-07 15:04:06 +02:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
2017-09-08 17:03:47 +02:00
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
2022-09-06 13:04:32 +02:00
|
|
|
$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
// Creazione righe fantasma
|
2024-11-11 16:49:08 +01:00
|
|
|
$autofill = new Util\Autofill($options['pricing'] ? 6 : 3, 70);
|
|
|
|
$rows_per_page = $options['pricing'] ? 20 : 18;
|
|
|
|
$autofill->setRows($rows_per_page, 0, $options['pricing'] ? 20 : 18);
|
2017-09-08 17:03:47 +02:00
|
|
|
|
|
|
|
// Intestazione tabella per righe
|
|
|
|
echo "
|
2024-05-23 16:05:30 +02:00
|
|
|
<table class='table table-striped border-bottom' id='contents'>
|
2017-09-08 17:03:47 +02:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2020-05-29 16:32:00 +02:00
|
|
|
<th class='text-center' style='width:5%'>".tr('#', [], ['upper' => true])."</th>
|
2017-09-10 14:35:41 +02:00
|
|
|
<th class='text-center'>".tr('Descrizione', [], ['upper' => true])."</th>
|
2020-10-15 18:33:06 +02:00
|
|
|
<th class='text-center'>".tr('Q.tà', [], ['upper' => true]).'</th>';
|
2017-09-08 17:03:47 +02:00
|
|
|
|
2017-09-21 15:51:39 +02:00
|
|
|
if ($options['pricing']) {
|
2017-09-08 17:03:47 +02:00
|
|
|
echo "
|
2020-10-15 18:33:06 +02:00
|
|
|
<th class='text-center'>".tr('Prezzo unitario', [], ['upper' => true])."</th>
|
|
|
|
<th class='text-center'>".tr('Importo', [], ['upper' => true])."</th>
|
|
|
|
<th class='text-center'>".tr('IVA', [], ['upper' => true]).' (%)</th>';
|
2017-09-08 17:03:47 +02:00
|
|
|
}
|
|
|
|
|
2024-01-15 15:30:45 +01:00
|
|
|
echo '
|
2017-09-08 17:03:47 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>';
|
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
// Righe documento
|
|
|
|
$righe = $documento->getRighe();
|
2020-09-11 09:04:06 +02:00
|
|
|
$num = 0;
|
2023-12-13 17:33:24 +01:00
|
|
|
|
|
|
|
if (!setting('Visualizza riferimento su ogni riga in stampa')) {
|
|
|
|
$riferimenti = [];
|
|
|
|
$id_rif = [];
|
|
|
|
|
|
|
|
foreach ($righe as $riga) {
|
|
|
|
$riferimento = ($riga->getOriginalComponent() ? $riga->getOriginalComponent()->getDocument()->getReference() : null);
|
|
|
|
if (!empty($riferimento)) {
|
|
|
|
if (!array_key_exists($riferimento, $riferimenti)) {
|
|
|
|
$riferimenti[$riferimento] = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!in_array($riga->id, $riferimenti[$riferimento])) {
|
|
|
|
$id_rif[] = $riga->id;
|
|
|
|
$riferimenti[$riferimento][] = $riga->id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-11 09:04:06 +02:00
|
|
|
foreach ($righe as $riga) {
|
|
|
|
++$num;
|
2019-07-12 12:40:13 +02:00
|
|
|
$r = $riga->toArray();
|
|
|
|
|
2017-09-13 11:15:31 +02:00
|
|
|
echo '
|
2020-09-11 09:04:06 +02:00
|
|
|
<tr>
|
2023-12-13 17:33:24 +01:00
|
|
|
<td class="text-center" style="vertical-align: middle">';
|
|
|
|
|
|
|
|
$text = '';
|
|
|
|
|
|
|
|
foreach ($riferimenti as $key => $riferimento) {
|
|
|
|
if (in_array($riga->id, $riferimento)) {
|
|
|
|
if ($riga->id === $riferimento[0]) {
|
|
|
|
$riga_ordine = $database->fetchOne('SELECT numero_cliente, data_cliente FROM or_ordini WHERE id = '.prepare($riga->idordine));
|
|
|
|
if (!empty($riga_ordine['numero_cliente']) && !empty($riga_ordine['data_cliente'])) {
|
|
|
|
$text = $text.'<b>Ordine n. '.$riga_ordine['numero_cliente'].' del '.Translator::dateToLocale($riga_ordine['data_cliente']).'</b><br>';
|
|
|
|
}
|
2024-05-23 11:36:25 +02:00
|
|
|
$r['descrizione'] = str_replace('Rif. '.strtolower((string) $key), '', $r['descrizione']);
|
2024-09-25 15:11:01 +02:00
|
|
|
|
2024-09-13 18:10:11 +02:00
|
|
|
if (preg_match("/Rif\.(.*)/s", $r['descrizione'], $rif2)) {
|
|
|
|
$r['descrizione'] = str_replace('Rif.'.strtolower($rif2[1]), '', $r['descrizione']);
|
2023-12-13 17:33:24 +01:00
|
|
|
$text .= '<b>'.$rif2[0].'</b>';
|
|
|
|
}
|
2024-09-13 18:10:11 +02:00
|
|
|
|
2023-12-13 17:33:24 +01:00
|
|
|
$text .= '<b>'.$key.'</b>';
|
|
|
|
|
|
|
|
if ($options['pricing']) {
|
|
|
|
$text .= '</td><td></td><td></td><td>';
|
|
|
|
}
|
|
|
|
$text .= '</td><td></td></tr><tr><td class="text-center" nowrap="nowrap" style="vertical-align: middle">';
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
'.nl2br($text);
|
2024-11-11 16:49:08 +01:00
|
|
|
$autofill->count($text);
|
2023-12-13 17:33:24 +01:00
|
|
|
}
|
|
|
|
}
|
2024-10-16 08:56:08 +02:00
|
|
|
$r['descrizione'] = preg_replace("/Rif\.(.*)/s", '', (string) $r['descrizione']);
|
2023-12-13 17:33:24 +01:00
|
|
|
}
|
2020-10-04 10:32:11 +02:00
|
|
|
|
2024-05-23 11:36:25 +02:00
|
|
|
$source_type = $riga::class;
|
2024-11-11 16:49:08 +01:00
|
|
|
$autofill->count($r['descrizione']);
|
|
|
|
|
|
|
|
echo $num.'
|
|
|
|
</td>
|
|
|
|
<td>'.nl2br((string) $r['descrizione']);
|
|
|
|
|
2020-05-29 16:32:00 +02:00
|
|
|
|
2023-12-13 17:33:24 +01:00
|
|
|
if ($riga->isArticolo()) {
|
|
|
|
echo '<br><small>'.$riga->codice.'</small>';
|
2024-11-11 16:49:08 +01:00
|
|
|
$autofill->count($riga->codice);
|
2023-12-13 17:33:24 +01:00
|
|
|
} else {
|
|
|
|
echo '-';
|
2020-10-15 18:33:06 +02:00
|
|
|
}
|
2017-09-13 11:15:31 +02:00
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
if ($riga->isArticolo()) {
|
|
|
|
// Seriali
|
|
|
|
$seriali = $riga->serials;
|
|
|
|
if (!empty($seriali)) {
|
2019-07-12 13:04:28 +02:00
|
|
|
$text = tr('SN').': '.implode(', ', $seriali);
|
2019-07-12 12:40:13 +02:00
|
|
|
echo '
|
2023-12-13 17:33:24 +01:00
|
|
|
<small>'.$text.'</small>';
|
2018-02-15 14:25:27 +01:00
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
$autofill->count($text, true);
|
2018-02-15 14:25:27 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-13 11:15:31 +02:00
|
|
|
echo '
|
|
|
|
</td>';
|
2017-09-08 17:03:47 +02:00
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
if (!$riga->isDescrizione()) {
|
2018-02-15 17:41:09 +01:00
|
|
|
echo '
|
2020-10-15 18:33:06 +02:00
|
|
|
<td class="text-center" nowrap="nowrap">
|
2023-12-05 17:43:35 +01:00
|
|
|
'.Translator::numberToLocale(abs($riga->qta), $d_qta).' '.$r['um'].'
|
2019-07-12 12:40:13 +02:00
|
|
|
</td>';
|
2017-09-08 17:03:47 +02:00
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
if ($options['pricing']) {
|
|
|
|
// Prezzo unitario
|
2018-02-03 13:55:09 +01:00
|
|
|
echo '
|
2020-10-15 18:33:06 +02:00
|
|
|
<td class="text-right" nowrap="nowrap">
|
2023-12-05 17:43:35 +01:00
|
|
|
'.moneyFormat($prezzi_ivati ? $riga->prezzo_unitario_ivato : $riga->prezzo_unitario, $d_importi);
|
2017-09-08 17:03:47 +02:00
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
if ($riga->sconto > 0) {
|
2020-02-15 14:11:44 +01:00
|
|
|
$text = discountInfo($riga, false);
|
2018-01-18 19:03:06 +01:00
|
|
|
|
|
|
|
echo '
|
2019-07-12 12:40:13 +02:00
|
|
|
<br><small class="text-muted">'.$text.'</small>';
|
|
|
|
|
|
|
|
$autofill->count($text, true);
|
2017-09-13 11:15:31 +02:00
|
|
|
}
|
2019-07-12 12:40:13 +02:00
|
|
|
|
|
|
|
echo '
|
|
|
|
</td>';
|
|
|
|
|
|
|
|
// Imponibile
|
|
|
|
echo '
|
2020-10-15 18:33:06 +02:00
|
|
|
<td class="text-right" nowrap="nowrap">
|
2023-12-05 17:43:35 +01:00
|
|
|
'.moneyFormat($prezzi_ivati ? $riga->totale : $riga->totale_imponibile, $d_importi).'
|
2019-07-12 12:40:13 +02:00
|
|
|
</td>';
|
|
|
|
|
|
|
|
// Iva
|
|
|
|
echo '
|
2020-10-15 18:33:06 +02:00
|
|
|
<td class="text-center" nowrap="nowrap">
|
2023-12-05 17:43:35 +01:00
|
|
|
'.Translator::numberToLocale($riga->aliquota->percentuale, $d_importi).'
|
2019-07-12 12:40:13 +02:00
|
|
|
</td>';
|
2017-09-08 17:03:47 +02:00
|
|
|
}
|
2019-07-12 12:40:13 +02:00
|
|
|
} else {
|
2017-09-08 17:03:47 +02:00
|
|
|
echo '
|
2019-07-12 12:40:13 +02:00
|
|
|
<td></td>';
|
2017-09-08 17:03:47 +02:00
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
if ($options['pricing']) {
|
2018-02-15 17:41:09 +01:00
|
|
|
echo '
|
2019-07-12 12:40:13 +02:00
|
|
|
<td></td>
|
|
|
|
<td></td>
|
|
|
|
<td></td>';
|
2018-01-18 19:03:06 +01:00
|
|
|
}
|
2017-09-08 17:03:47 +02:00
|
|
|
}
|
2017-09-13 11:15:31 +02:00
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
echo '
|
|
|
|
</tr>';
|
2017-09-13 11:15:31 +02:00
|
|
|
|
2019-07-12 12:40:13 +02:00
|
|
|
$autofill->next();
|
2017-09-08 17:03:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
|autofill|
|
|
|
|
</tbody>
|
|
|
|
</table>';
|