2021-07-27 18:11:54 +02:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
|
|
|
* Copyright (C) DevCode s.r.l.
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
2024-03-05 16:01:45 +01:00
|
|
|
use Models\Module;
|
2024-03-22 15:52:24 +01:00
|
|
|
use Plugins\ListinoClienti\DettaglioPrezzo;
|
2021-07-27 18:11:54 +02:00
|
|
|
|
|
|
|
include_once __DIR__.'/../../core.php';
|
|
|
|
|
|
|
|
$id_articolo = $id_record;
|
2021-10-26 10:18:32 +02:00
|
|
|
|
2021-07-27 18:11:54 +02:00
|
|
|
echo '
|
2024-05-16 18:02:50 +02:00
|
|
|
<div class="card">
|
|
|
|
<div class="card-header">
|
|
|
|
<h3 class="card-title">'.tr('Informazioni specifiche per cliente').'</h3>
|
2021-07-27 18:11:54 +02:00
|
|
|
</div>
|
|
|
|
|
2024-05-16 18:02:50 +02:00
|
|
|
<div class="card-body">
|
2021-07-27 18:11:54 +02:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-9">
|
2024-06-11 16:58:27 +02:00
|
|
|
{[ "type": "select", "label": "'.tr('Cliente').'", "name": "id_cliente_informazioni", "required":"1", "ajax-source": "clienti", "icon-after": "add|'.Module::where('name', 'Anagrafiche')->first()->id.'|tipoanagrafica=Cliente&readonly_tipo=1" ]}
|
2021-07-27 18:11:54 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-md-3">
|
2021-07-30 16:27:19 +02:00
|
|
|
<button type="button" class="btn btn-info btn-block" style="margin-top:25px;" onclick="aggiungiPrezzi(this, false)">
|
2021-07-27 18:11:54 +02:00
|
|
|
<i class="fa fa-money"></i> '.tr('Prezzi').'
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<h4>'.tr('Elenco clienti').'</h4>';
|
|
|
|
|
|
|
|
$clienti = DettaglioPrezzo::where('id_articolo', $id_articolo)
|
|
|
|
->where('dir', 'entrata')
|
|
|
|
->get()
|
|
|
|
->groupBy('id_anagrafica');
|
|
|
|
if (!$clienti->isEmpty()) {
|
|
|
|
echo '
|
2022-02-16 16:29:13 +01:00
|
|
|
<table class="table table-striped table-condensed table-bordered">
|
|
|
|
<tbody>
|
2021-07-27 18:11:54 +02:00
|
|
|
<tr>
|
|
|
|
<th>'.tr('Cliente').'</th>
|
|
|
|
<th class="text-center" width="210">'.tr('Q.tà minima').'</th>
|
|
|
|
<th class="text-center" width="210">'.tr('Q.tà massima').'</th>
|
|
|
|
<th class="text-center" width="150">'.tr('Prezzo unitario').'</th>
|
|
|
|
<th class="text-center" width="150">'.tr('Sconto').'</th>
|
|
|
|
<th class="text-center" width="150">#</th>
|
2022-02-16 16:29:13 +01:00
|
|
|
</tr>';
|
2021-07-27 18:11:54 +02:00
|
|
|
|
|
|
|
foreach ($clienti as $id_cliente => $prezzi) {
|
|
|
|
$anagrafica = $prezzi->first()->anagrafica;
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<tr data-id_anagrafica="'.$id_cliente.'" data-direzione="entrata">
|
|
|
|
<td colspan="5">
|
|
|
|
'.Modules::link('Anagrafiche', $anagrafica->id, $anagrafica->ragione_sociale).'
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td class="text-center">
|
|
|
|
<button type="button" class="btn btn-xs btn-warning" onclick="modificaPrezzi(this)">
|
|
|
|
<i class="fa fa-money"></i>
|
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
</tr>';
|
|
|
|
|
|
|
|
foreach ($prezzi as $key => $dettaglio) {
|
|
|
|
echo '
|
|
|
|
<tr>
|
|
|
|
<td></td>
|
|
|
|
|
|
|
|
<td class="text-right">
|
|
|
|
'.($dettaglio->minimo ? numberFormat($dettaglio->minimo) : '-').'
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td class="text-right">
|
|
|
|
'.($dettaglio->massimo ? numberFormat($dettaglio->massimo) : '-').'
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td class="text-right">
|
|
|
|
'.moneyFormat($dettaglio->prezzo_unitario).'
|
2024-05-16 18:02:50 +02:00
|
|
|
<p><span class="right badge badge-default tip" title="'.Translator::timestampToLocale($dettaglio['updated_at']).'"><i class="fa fa-clock-o"></i> '.Carbon::parse($dettaglio['updated_at'])->diffForHumans().'</small></p>
|
2021-07-27 18:11:54 +02:00
|
|
|
</td>
|
|
|
|
|
|
|
|
<td class="text-right">
|
|
|
|
'.numberFormat($dettaglio->sconto_percentuale).'%
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>';
|
|
|
|
|
|
|
|
if (!isset($dettaglio->minimo) && !isset($dettaglio->massimo)) {
|
|
|
|
echo '
|
|
|
|
<span class="badge badge-primary">'.tr('Prezzo predefinito').'</span>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</td>
|
|
|
|
</tr>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
</tbody>
|
|
|
|
</table>';
|
|
|
|
} else {
|
|
|
|
echo '
|
|
|
|
<div class="alert alert-info">
|
|
|
|
<i class="fa fa-info-circle"></i> '.tr('Nessuna informazione disponibile').'...
|
|
|
|
</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<script>
|
|
|
|
function modificaPrezzi(button) {
|
|
|
|
let tr = $(button).closest("tr");
|
|
|
|
let id_anagrafica = tr.data("id_anagrafica");
|
|
|
|
let direzione = tr.data("direzione");
|
|
|
|
|
|
|
|
gestionePrezzi(id_anagrafica, direzione);
|
|
|
|
}
|
|
|
|
|
|
|
|
function gestionePrezzi(id_anagrafica, direzione) {
|
|
|
|
openModal("'.tr('Gestisci prezzi specifici').'", "'.$structure->fileurl('dettaglio_prezzi.php').'?id_plugin='.$id_plugin.'&id_module='.$id_module.'&id_parent='.$id_record.'&id_articolo='.$id_record.'&id_anagrafica=" + id_anagrafica + "&direzione=" + direzione);
|
|
|
|
}
|
|
|
|
|
2021-07-30 16:27:19 +02:00
|
|
|
function aggiungiPrezzi(button, is_uscita) {
|
2024-07-08 15:55:05 +02:00
|
|
|
let card = $(button).closest(".card");
|
2021-07-27 18:11:54 +02:00
|
|
|
|
2021-07-30 16:27:19 +02:00
|
|
|
let direzione = is_uscita ? "uscita" : "entrata";
|
2024-05-16 18:02:50 +02:00
|
|
|
let id_anagrafica = card.find("select").val();
|
2021-07-27 18:11:54 +02:00
|
|
|
|
|
|
|
if (id_anagrafica) {
|
|
|
|
gestionePrezzi(id_anagrafica, direzione);
|
|
|
|
} else {
|
|
|
|
swal("'.tr('Attenzione').'", "'.tr('Inserire un\'anagrafica').'", "warning");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>';
|