2020-07-08 09:15:14 +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/>.
|
|
|
|
*/
|
2020-07-08 09:15:14 +02:00
|
|
|
|
|
|
|
use Modules\Ordini\Ordine;
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
|
|
|
$ordine = Ordine::find($id_record);
|
|
|
|
$articoli = $ordine->articoli->groupBy('idarticolo');
|
|
|
|
|
|
|
|
if ($articoli->isEmpty()) {
|
|
|
|
echo '
|
|
|
|
<p>'.tr('Il documento non contiene articoli').'.</p>';
|
2020-07-16 16:49:36 +02:00
|
|
|
|
|
|
|
return;
|
2020-07-08 09:15:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<table class="table table-striped table-hover table-condensed table-bordered">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>'.tr('Articolo').'</th>
|
|
|
|
<th class="text-center tip" width="150" title="'.tr('Quantità presente nel documento').'">'.tr('Q.tà').'</th>
|
|
|
|
<th class="text-center tip" width="150" title="'.tr('Quantità presente nel magazzino del gestionale').'">'.tr('Q.tà magazzino').'</th>
|
|
|
|
<th class="text-center tip" width="150" title="'.tr('Quantità impegnata in altri Ordini del gestionale').'">'.tr('Q.tà impegnata').'</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>';
|
|
|
|
|
|
|
|
foreach ($articoli as $elenco) {
|
|
|
|
$qta = $elenco->sum('qta');
|
|
|
|
$articolo = $elenco->first()->articolo;
|
|
|
|
|
|
|
|
$codice = $articolo ? $articolo->codice : tr('Articolo eliminato');
|
|
|
|
$descrizione = $articolo ? $articolo->descrizione : $elenco->first()->descrizione;
|
|
|
|
|
|
|
|
$qta_impegnata = $database->fetchOne("SELECT SUM(qta) as qta
|
|
|
|
FROM or_righe_ordini
|
|
|
|
JOIN or_ordini ON or_ordini.id = or_righe_ordini.idordine
|
2020-10-06 12:25:22 +02:00
|
|
|
WHERE idstatoordine = (SELECT id FROM or_statiordine WHERE descrizione = 'Bozza')
|
2020-07-08 09:15:14 +02:00
|
|
|
AND idtipoordine IN (SELECT id FROM or_tipiordine WHERE dir = 'entrata')
|
2020-10-06 12:25:22 +02:00
|
|
|
AND confermato = 1
|
2020-09-07 10:34:42 +02:00
|
|
|
AND idarticolo=".prepare($articolo->id).'
|
|
|
|
GROUP BY idarticolo')['qta'];
|
2020-07-08 09:15:14 +02:00
|
|
|
$qta_impegnata = floatval($qta_impegnata);
|
|
|
|
|
|
|
|
$class = $qta_impegnata + $qta > $articolo->qta ? 'danger' : 'success';
|
|
|
|
$descrizione_riga = $codice.' - '.$descrizione;
|
|
|
|
$text = $articolo ? Modules::link('Articoli', $articolo->id, $descrizione_riga) : $descrizione_riga;
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<tr class="'.$class.'">
|
|
|
|
<td>'.$text.'</td>
|
|
|
|
<td class="text-center">'.numberFormat($qta, 'qta').'</td>
|
|
|
|
<td class="text-center">'.numberFormat($articolo->qta, 'qta').'</td>
|
|
|
|
<td class="text-center">'.numberFormat($qta_impegnata, 'qta').'</td>
|
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
echo '
|
|
|
|
</tbody>
|
|
|
|
</table>';
|