2020-08-26 15:12:22 +02:00
|
|
|
<?php
|
2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
|
|
|
* Copyright (C) DevCode s.n.c.
|
|
|
|
*
|
|
|
|
* 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-08-26 15:12:22 +02:00
|
|
|
|
|
|
|
use Modules\Anagrafiche\Anagrafica;
|
|
|
|
use Modules\Articoli\Articolo;
|
|
|
|
use Plugins\DettagliArticolo\DettaglioPrezzo;
|
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
|
|
|
$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
|
|
|
|
|
|
|
|
// Informazioni di base
|
|
|
|
$id_articolo = get('id_articolo');
|
|
|
|
$id_anagrafica = get('id_anagrafica');
|
|
|
|
$direzione = get('direzione') == 'uscita' ? 'uscita' : 'entrata';
|
|
|
|
|
|
|
|
// Modelli di interesse
|
|
|
|
$articolo = Articolo::find($id_articolo);
|
|
|
|
$anagrafica = Anagrafica::find($id_anagrafica);
|
|
|
|
|
|
|
|
$prezzo_predefinito = $prezzi_ivati ? $articolo->prezzo_vendita_ivato : $articolo->prezzo_vendita;
|
|
|
|
|
|
|
|
// Individuazione dei prezzi registrati
|
|
|
|
$dettagli = DettaglioPrezzo::dettagli($id_articolo, $id_anagrafica, $direzione)
|
|
|
|
->get();
|
|
|
|
|
|
|
|
$dettaglio_predefinito = DettaglioPrezzo::dettaglioPredefinito($id_articolo, $id_anagrafica, $direzione)
|
|
|
|
->first();
|
|
|
|
$prezzo_dettaglio_predefinito = $prezzo_predefinito;
|
|
|
|
if (!empty($dettaglio_predefinito)) {
|
|
|
|
$prezzo_dettaglio_predefinito = $prezzi_ivati ? $dettaglio_predefinito->prezzo_unitario_ivato : $dettaglio_predefinito->prezzo_unitario;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2020-12-02 11:31:52 +01:00
|
|
|
<p>'.tr('Informazioni relative al _TIPO_', [
|
|
|
|
'_TIPO_' => $direzione=='entrata' ? 'cliente:' : 'fornitore:' ,
|
|
|
|
]).'
|
|
|
|
<br><b><big>'.$anagrafica->ragione_sociale.'</big></b></p>
|
2020-08-26 15:12:22 +02:00
|
|
|
|
|
|
|
<form action="" method="post">
|
|
|
|
<input type="hidden" name="backto" value="record-edit">
|
|
|
|
<input type="hidden" name="op" value="update_prezzi">
|
|
|
|
<input type="hidden" name="id_plugin" value="'.$id_plugin.'">
|
|
|
|
|
|
|
|
<input type="hidden" name="dir" value="'.$direzione.'">
|
|
|
|
<input type="hidden" name="id_anagrafica" value="'.$id_anagrafica.'">
|
|
|
|
<input type="hidden" name="id_articolo" value="'.$id_articolo.'">
|
|
|
|
|
|
|
|
<div class="row">
|
2020-10-30 11:18:15 +01:00
|
|
|
<div class="col-md-4">
|
2020-12-02 11:31:52 +01:00
|
|
|
{[ "type": "checkbox", "label": "'.tr("Imposta prezzo per questa anagrafica").'", "name": "modifica_prezzi", "value": "'.intval(!$dettagli->isEmpty() || !empty($dettaglio_predefinito)).'" ]}
|
2020-08-26 15:12:22 +02:00
|
|
|
</div>
|
2020-12-02 11:31:52 +01:00
|
|
|
<div id="imposta_prezzo_qta" class="col-md-4">
|
|
|
|
{[ "type": "checkbox", "label": "'.tr('Imposta un prezzo in base alla quantità').'", "name": "prezzo_fisso", "value": "'.intval($dettagli->count() != 0).'" ]}
|
2020-08-26 15:12:22 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2020-12-02 11:31:52 +01:00
|
|
|
<div id="info_prezzi" class="row">
|
|
|
|
<div class="col-md-4">
|
|
|
|
{[ "type": "number", "label": "'.tr('Prezzo predefinito').'", "name": "prezzo_predefinito", "value": "'.$prezzo_predefinito.'", "disabled":"1"]}
|
|
|
|
</div>
|
|
|
|
<div class="col-md-4">
|
|
|
|
{[ "type": "number", "label": "'.tr('Prezzo specifico').'", "name": "prezzo_unitario_fisso", "value": "'.($prezzi_ivati ? $dettaglio_predefinito->prezzo_unitario_ivato : $dettaglio_predefinito->prezzo_unitario).'", "icon-after": "'.currency().'", "help": "'.($prezzi_ivati ? tr('Importo IVA inclusa') : '').'" ]}
|
2020-08-26 15:12:22 +02:00
|
|
|
</div>
|
|
|
|
|
2020-12-02 11:31:52 +01:00
|
|
|
<div class="col-md-4">
|
|
|
|
{[ "type": "number", "label": "'.tr('Sconto specifico').'", "name": "sconto_fisso", "value": "'.$dettaglio_predefinito->sconto_percentuale.'", "icon-after": "%"]}
|
2020-08-26 15:12:22 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="box" id="prezzi">
|
|
|
|
<div class="box-header">
|
|
|
|
<h3 class="box-title">
|
|
|
|
'.tr('Prezzi per quantità').'
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
<button type="button" class="btn btn-xs btn-info pull-right" onclick="aggiungiPrezzo(this)">
|
|
|
|
<i class="fa fa-plus"></i> '.tr('Aggiungi range').'
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="box-body">
|
|
|
|
<p>'.tr("Inserire i prezzi da associare all'articolo e all'anagrafica in relazione alla quantità di acquisto").'.</p>
|
|
|
|
<p>'.tr('Per impostare un prezzo generale per quantità non incluse in questi limiti, utilizzare il campo sopra indicato').'.</p>
|
|
|
|
|
|
|
|
<table class="table table-condensed">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th class="text-center">'.tr('Quantità minima').'</th>
|
|
|
|
<th class="text-center">'.tr('Quantità massima').'</th>
|
|
|
|
<th class="text-center tip" title="'.($prezzi_ivati ? tr('Importo IVA inclusa') : '').'">
|
2020-11-13 18:40:09 +01:00
|
|
|
'.tr('Prezzo unitario').($prezzi_ivati ? '<i class="fa fa-question-circle-o"></i>' : '').'
|
2020-08-26 15:12:22 +02:00
|
|
|
</th>
|
2020-10-30 11:18:15 +01:00
|
|
|
<th class="text-center">'.tr('Sconto').'</th>
|
2020-08-26 15:12:22 +02:00
|
|
|
<th>#</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
|
|
|
|
<tbody>';
|
|
|
|
|
|
|
|
foreach ($dettagli as $key => $dettaglio) {
|
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<input type="hidden" name="dettaglio['.$key.']" value="'.$dettaglio->id.'">
|
|
|
|
{[ "type": "number", "name": "minimo['.$key.']", "min-value": 0, "value": "'.$dettaglio->minimo.'" ]}
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
{[ "type": "number", "name": "massimo['.$key.']", "min-value": 0, "value": "'.$dettaglio->massimo.'" ]}
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
{[ "type": "number", "name": "prezzo_unitario['.$key.']", "icon-after": "'.currency().'", "value": "'.($prezzi_ivati ? $dettaglio->prezzo_unitario_ivato : $dettaglio->prezzo_unitario).'" ]}
|
|
|
|
</td>
|
2020-10-30 11:18:15 +01:00
|
|
|
<td>
|
|
|
|
{[ "type": "number", "name": "sconto['.$key.']", "min-value": 0, "value": "'.$dettaglio->sconto.'", "icon-after":"%" ]}
|
2020-08-26 15:12:22 +02:00
|
|
|
<td>
|
|
|
|
<button type="button" class="btn btn-xs btn-danger" onclick="rimuoviPrezzo(this)">
|
|
|
|
<i class="fa fa-trash"></i>
|
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="clearfix"></div>
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
|
|
|
<button class="btn btn-primary pull-right">
|
|
|
|
<i class="fa fa-edit"></i> '.tr('Salva').'
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<table class="hide">
|
|
|
|
<tbody id="prezzi-template">
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
{[ "type": "number", "name": "minimo[-id-]", "min-value": 0 ]}
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
{[ "type": "number", "name": "massimo[-id-]", "min-value": 0 ]}
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
{[ "type": "number", "name": "prezzo_unitario[-id-]", "icon-after": "'.currency().'" ]}
|
|
|
|
</td>
|
|
|
|
|
2020-10-30 11:18:15 +01:00
|
|
|
<td>
|
|
|
|
{[ "type": "number", "name": "sconto[-id-]", "min-value": 0, "icon-after": "%" ]}
|
|
|
|
</td>
|
|
|
|
|
2020-08-26 15:12:22 +02:00
|
|
|
<td>
|
|
|
|
<button type="button" class="btn btn-xs btn-danger" onclick="rimuoviPrezzo(this)">
|
|
|
|
<i class="fa fa-trash"></i>
|
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<script>$(document).ready(init);</script>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
var key = '.$dettagli->count().';
|
|
|
|
function aggiungiPrezzo(button) {
|
|
|
|
cleanup_inputs();
|
|
|
|
|
|
|
|
let text = replaceAll($("#prezzi-template").html(), "-id-", "" + key);
|
|
|
|
key++;
|
|
|
|
|
|
|
|
let body = $(button).closest(".box").find("table > tbody");
|
|
|
|
let lastRow = body.find("tr").last();
|
|
|
|
if (lastRow.length) {
|
|
|
|
lastRow.after(text);
|
|
|
|
} else {
|
|
|
|
body.html(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
restart_inputs();
|
|
|
|
}
|
|
|
|
|
|
|
|
function rimuoviPrezzo(button) {
|
|
|
|
$(button).closest("tr").remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
function cambioImpostazioni() {
|
|
|
|
let modifica_prezzi = input("modifica_prezzi");
|
|
|
|
let prezzo_fisso = input("prezzo_fisso");
|
2020-11-13 18:40:09 +01:00
|
|
|
let prezzo_unitario_fisso = input("prezzo_unitario_fisso");
|
|
|
|
let sconto_fisso = input("sconto_fisso");
|
2020-08-26 15:12:22 +02:00
|
|
|
|
|
|
|
let prezzi_variabili = $("#prezzi");
|
|
|
|
|
|
|
|
if (!modifica_prezzi.get()){
|
2020-12-02 11:31:52 +01:00
|
|
|
$("#imposta_prezzo_qta").hide();
|
|
|
|
$("#info_prezzi").hide();
|
2020-08-26 15:12:22 +02:00
|
|
|
} else {
|
2020-12-02 11:31:52 +01:00
|
|
|
$("#imposta_prezzo_qta").show();
|
|
|
|
$("#info_prezzi").show();
|
2020-08-26 15:12:22 +02:00
|
|
|
}
|
|
|
|
|
2020-12-02 11:31:52 +01:00
|
|
|
if (prezzo_fisso.get() && modifica_prezzi.get()) {
|
2020-08-26 15:12:22 +02:00
|
|
|
prezzi_variabili.removeClass("hidden");
|
|
|
|
} else {
|
|
|
|
prezzi_variabili.addClass("hidden");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-26 17:42:43 +02:00
|
|
|
input("modifica_prezzi").change(function () {
|
2020-08-26 15:12:22 +02:00
|
|
|
cambioImpostazioni();
|
|
|
|
})
|
|
|
|
|
2020-08-26 17:42:43 +02:00
|
|
|
input("prezzo_fisso").change(function () {
|
2020-08-26 15:12:22 +02:00
|
|
|
cambioImpostazioni();
|
|
|
|
})
|
|
|
|
|
|
|
|
$(document).ready(cambioImpostazioni);
|
|
|
|
</script>';
|