openstamanager/templates/ddt/body.php

195 lines
5.3 KiB
PHP
Raw Normal View History

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';
$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
2019-07-12 12:40:13 +02:00
// Creazione righe fantasma
2020-10-04 10:32:11 +02:00
$autofill = new \Util\Autofill($options['pricing'] ? 7 : 4);
$rows_per_page = 16;
if (!empty($options['last-page-footer'])) {
$rows_per_page += 10;
}
$autofill->setRows($rows_per_page);
2017-09-08 17:03:47 +02:00
// Intestazione tabella per righe
echo "
2017-09-12 16:45:18 +02:00
<table class='table table-striped table-bordered' id='contents'>
2017-09-08 17:03:47 +02:00
<thead>
<tr>
<th class='text-center' style='width:5%'>".tr('#', [], ['upper' => true])."</th>
2020-10-06 17:55:50 +02:00
<th class='text-center'>".tr('Cod.', [], ['upper' => true])."</th>
<th class='text-center'>".tr('Descrizione', [], ['upper' => true])."</th>
<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 "
<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
}
echo '
</tr>
</thead>
<tbody>';
2019-07-12 12:40:13 +02:00
// Righe documento
$righe = $documento->getRighe();
$num = 0;
foreach ($righe as $riga) {
++$num;
2019-07-12 12:40:13 +02:00
$r = $riga->toArray();
$autofill->count($r['descrizione']);
2017-09-08 17:03:47 +02:00
echo '
<tr>
<td class="text-center" style="vertical-align: middle">
'.$num.'
2020-10-04 10:32:11 +02:00
</td>
2020-10-06 17:55:50 +02:00
<td class="text-center" nowrap="nowrap" style="vertical-align: middle">';
2020-10-04 10:32:11 +02:00
2020-10-16 17:27:21 +02:00
$source_type = get_class($riga);
2020-10-16 08:31:10 +02:00
if ($riga->isArticolo()) {
echo $riga->codice;
} else {
echo '-';
}
2021-02-18 18:48:44 +01:00
echo '
2020-10-04 10:32:11 +02:00
</td>
2020-10-16 17:27:21 +02:00
<td>
'.nl2br($r['descrizione']);
2020-10-16 08:31:10 +02:00
//Riferimenti ordini/ddt righe
2020-10-16 08:31:10 +02:00
if ($riga->referenceTargets()->count()) {
$source = $source_type::find($riga->id);
$riferimenti = $source->referenceTargets;
2020-10-16 08:31:10 +02:00
foreach ($riferimenti as $riferimento) {
2020-10-16 17:27:21 +02:00
$documento_riferimento = $riferimento->target->getDocument();
echo '
2020-10-16 17:27:21 +02:00
<br><small>'.$riferimento->target->descrizione.'<br>'.tr('Rif. _DOCUMENT_', [
'_DOCUMENT_' => strtolower($documento_riferimento->getReference()),
]).'</small>';
}
}
2019-07-12 12:40:13 +02:00
if ($riga->isArticolo()) {
// Codice articolo
$text = tr('COD. _COD_', [
'_COD_' => $riga->codice,
2019-07-12 12:40:13 +02:00
]);
2018-02-15 14:25:27 +01:00
echo '
2019-07-12 12:40:13 +02:00
<br><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
2019-07-12 12:40:13 +02:00
// 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 '
<br><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
}
}
// Aggiunta dei riferimenti ai documenti
/*
if (setting('Riferimento dei documenti nelle stampe') && $riga->hasOriginal()) {
2020-09-24 11:40:11 +02:00
$ref = $riga->getOriginal()->getDocument()->getReference();
2017-09-08 17:03:47 +02:00
if (!empty($ref)) {
echo '
<br><small>'.$ref.'</small>';
2019-07-12 12:40:13 +02:00
$autofill->count($ref, true);
}
}
*/
2017-09-08 17:03:47 +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 '
<td class="text-center" nowrap="nowrap">
2019-07-12 12:40:13 +02:00
'.Translator::numberToLocale(abs($riga->qta), 'qta').' '.$r['um'].'
</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 '
<td class="text-right" nowrap="nowrap">
'.moneyFormat($prezzi_ivati ? $riga->prezzo_unitario_ivato : $riga->prezzo_unitario);
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);
echo '
2019-07-12 12:40:13 +02:00
<br><small class="text-muted">'.$text.'</small>';
$autofill->count($text, true);
}
2019-07-12 12:40:13 +02:00
echo '
</td>';
// Imponibile
echo '
<td class="text-right" nowrap="nowrap">
'.moneyFormat($prezzi_ivati ? $riga->totale : $riga->totale_imponibile).'
2019-07-12 12:40:13 +02:00
</td>';
// Iva
echo '
<td class="text-center" nowrap="nowrap">
2022-05-26 17:25:19 +02:00
'.Translator::numberToLocale($riga->aliquota->percentuale, 2).'
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>';
}
2017-09-08 17:03:47 +02:00
}
2019-07-12 12:40:13 +02:00
echo '
</tr>';
2019-07-12 12:40:13 +02:00
$autofill->next();
2017-09-08 17:03:47 +02:00
}
echo '
|autofill|
</tbody>
</table>';