2020-02-24 18:30:05 +01: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-02-24 18:30:05 +01:00
|
|
|
|
|
|
|
use Modules\DDT\DDT;
|
|
|
|
use Modules\Ordini\Ordine;
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
include_once __DIR__.'/init.php';
|
|
|
|
|
|
|
|
$direzione = 'uscita';
|
|
|
|
$id_riga = get('id_riga');
|
|
|
|
$qta = get('qta');
|
2024-06-28 09:24:45 +02:00
|
|
|
$descrizione = get('descrizione');
|
|
|
|
$prezzo_unitario = get('prezzo_unitario');
|
2020-02-24 18:30:05 +01:00
|
|
|
|
|
|
|
$id_documento = get('id_documento');
|
|
|
|
$tipo_documento = get('tipo_documento');
|
2021-02-18 17:46:38 +01:00
|
|
|
$dir = get('dir');
|
2020-09-03 11:55:15 +02:00
|
|
|
if ($tipo_documento == 'ordine') {
|
|
|
|
$documento = Ordine::find($id_documento);
|
|
|
|
$righe_utilizzate = get('righe_ordini');
|
|
|
|
} else {
|
|
|
|
$documento = DDT::find($id_documento);
|
|
|
|
$righe_utilizzate = get('righe_ddt');
|
|
|
|
}
|
2020-02-24 18:30:05 +01:00
|
|
|
|
2020-09-03 11:55:15 +02:00
|
|
|
echo '
|
2024-06-28 09:24:45 +02:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-8">
|
|
|
|
Riga: <strong>'.$descrizione.'</strong>
|
|
|
|
</div>
|
|
|
|
<div class="col-md-4 text-right">
|
|
|
|
Quantità: <strong>'.$qta.'</strong> - Prezzo unitario: <strong>'.number_format($prezzo_unitario, 2, ',', '.').'</strong>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<br>
|
2020-02-24 18:30:05 +01:00
|
|
|
<table class="table table-striped table-hover table-condensed table-bordered">
|
|
|
|
<tr>
|
|
|
|
<th>'.tr('Descrizione').'</th>
|
2020-09-16 09:14:00 +02:00
|
|
|
<th class="text-center" width="120">
|
|
|
|
'.tr('Q.tà').' <i title="'.tr('da evadere').' / '.tr('totale').'" class="tip fa fa-question-circle-o"></i>
|
|
|
|
</th>
|
|
|
|
<th class="text-center" width="120">'.tr('Prezzo unitario').'</th>
|
2020-02-24 18:30:05 +01:00
|
|
|
<th class="text-center" width="60">#</th>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tbody>';
|
|
|
|
|
2020-09-03 11:55:15 +02:00
|
|
|
$id_riferimento = get('id_riferimento');
|
|
|
|
$righe = $documento->getRighe();
|
|
|
|
foreach ($righe as $riga) {
|
2024-07-02 12:39:01 +02:00
|
|
|
$qta_rimanente = $riga->qta_rimanente - (float) $righe_utilizzate[$riga->id];
|
2020-09-22 20:28:37 +02:00
|
|
|
$riga_origine = $riga->getOriginalComponent();
|
2020-02-24 18:30:05 +01:00
|
|
|
|
2023-03-07 14:38:17 +01:00
|
|
|
if (!empty($riga->idarticolo)) {
|
|
|
|
$desc_conto = $dbo->fetchOne('SELECT CONCAT( co_pianodeiconti2.numero, ".", co_pianodeiconti3.numero, " ", co_pianodeiconti3.descrizione ) AS descrizione FROM co_pianodeiconti3 INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE co_pianodeiconti3.id = '.prepare($riga->articolo->idconto_acquisto))['descrizione'];
|
|
|
|
}
|
|
|
|
|
2020-09-03 14:29:17 +02:00
|
|
|
$dettagli = [
|
2024-05-23 11:36:25 +02:00
|
|
|
'tipo' => $riga::class,
|
2020-09-03 14:29:17 +02:00
|
|
|
'id' => $riga->id,
|
2021-02-18 17:46:38 +01:00
|
|
|
'descrizione' => str_replace(' ', '_', $riga->descrizione),
|
2020-09-03 14:29:17 +02:00
|
|
|
'qta' => $riga->qta,
|
2020-09-11 08:55:39 +02:00
|
|
|
'um' => $riga->um,
|
|
|
|
'prezzo_unitario' => $riga->prezzo_unitario ?: $riga_origine->prezzo_unitario,
|
2020-09-03 14:29:17 +02:00
|
|
|
'id_iva' => $riga->id_iva,
|
|
|
|
'iva_percentuale' => $riga->aliquota->percentuale,
|
2023-03-07 14:38:17 +01:00
|
|
|
'id_articolo' => $riga->idarticolo,
|
2024-04-18 17:44:05 +02:00
|
|
|
'desc_articolo' => str_replace(' ', '_', $riga->articolo->codice.' - '.$riga->articolo->getTranslation('title')),
|
2023-03-07 14:38:17 +01:00
|
|
|
'id_conto' => $riga->articolo->idconto_acquisto,
|
2024-06-28 09:24:45 +02:00
|
|
|
'desc_conto' => $desc_conto ? str_replace(' ', '_', $desc_conto) : null,
|
2020-09-03 14:29:17 +02:00
|
|
|
];
|
|
|
|
|
2020-09-03 11:55:15 +02:00
|
|
|
echo '
|
2020-09-03 14:29:17 +02:00
|
|
|
<tr '.($id_riferimento == $riga->id ? 'class="success"' : '').' data-dettagli='.json_encode($dettagli).'>
|
2020-09-14 10:49:23 +02:00
|
|
|
<td>'.(!empty($riga->codice) ? $riga->codice.' - ' : '').$riga->descrizione.'</td>
|
2020-09-16 09:14:00 +02:00
|
|
|
<td>'.numberFormat($qta_rimanente, 'qta').' / '.numberFormat($riga->qta, 'qta').' '.$riga->um.'</td>
|
|
|
|
<td class="text-right">'.moneyFormat($riga->prezzo_unitario_corrente).'</td>
|
2020-02-24 18:30:05 +01:00
|
|
|
<td class="text-center">';
|
|
|
|
|
2021-10-06 15:07:01 +02:00
|
|
|
if ($qta_rimanente >= $qta || !empty(setting('Permetti il superamento della soglia quantità dei documenti di origine'))) {
|
2020-09-03 11:55:15 +02:00
|
|
|
echo '
|
|
|
|
<button type="button" class="btn btn-info btn-xs" onclick="selezionaRiga(this)">
|
2020-02-24 18:30:05 +01:00
|
|
|
<i class="fa fa-check"></i>
|
|
|
|
</button>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2020-09-03 11:55:15 +02:00
|
|
|
</td>
|
|
|
|
</tr>';
|
2020-02-24 18:30:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2020-09-03 11:55:15 +02:00
|
|
|
</tbody>
|
|
|
|
</table>
|
2020-02-24 18:30:05 +01:00
|
|
|
|
2020-09-16 09:14:00 +02:00
|
|
|
<script>$(document).ready(init)</script>
|
|
|
|
|
2020-02-24 18:30:05 +01:00
|
|
|
<script>
|
2020-09-03 11:55:15 +02:00
|
|
|
var documento_importazione = {
|
|
|
|
tipo: "'.$tipo_documento.'",
|
|
|
|
id: "'.$id_documento.'",
|
2020-09-16 09:14:00 +02:00
|
|
|
descrizione: '.json_encode(reference($documento, tr('Origine'))).',
|
2023-03-07 14:38:17 +01:00
|
|
|
opzione: "'.($tipo_documento == 'ordine' ? 'Ordine' : 'DDT').' num. '.($documento->numero_esterno ?: $documento->numero).' del '.Translator::dateToLocale($documento->data).'",
|
2020-09-03 11:55:15 +02:00
|
|
|
};
|
2020-02-24 18:30:05 +01:00
|
|
|
|
2020-09-03 11:55:15 +02:00
|
|
|
function selezionaRiga(button) {
|
|
|
|
let riga = $(button).closest("tr");
|
2020-02-24 18:30:05 +01:00
|
|
|
|
2023-03-07 14:38:17 +01:00
|
|
|
let dettagli_riga = riga.data("dettagli");
|
2021-02-18 17:46:38 +01:00
|
|
|
|
|
|
|
if("'.$dir.'"=="entrata"){
|
|
|
|
impostaRiferimentoVendita("'.$id_riga.'", documento_importazione, dettagli_riga);
|
|
|
|
}else{
|
|
|
|
impostaRiferimento("'.$id_riga.'", documento_importazione, dettagli_riga);
|
|
|
|
}
|
|
|
|
|
2020-02-24 18:30:05 +01:00
|
|
|
|
2020-09-03 11:55:15 +02:00
|
|
|
$(button).closest(".modal").modal("hide");
|
2020-02-24 18:30:05 +01:00
|
|
|
}
|
2020-09-16 09:14:00 +02:00
|
|
|
|
|
|
|
// Deselezione del riferimento in caso di selezione riga non effettuata
|
|
|
|
$("#modals > div").on("hidden.bs.modal", function () {
|
|
|
|
if(!$("#id_riferimento_'.$id_riga.'").val()) {
|
|
|
|
input("selezione_riferimento['.$id_riga.']").enable()
|
|
|
|
.getElement().selectReset();
|
|
|
|
}
|
|
|
|
});
|
2020-02-24 18:30:05 +01:00
|
|
|
</script>';
|