[Livello Serbatoi]

- Aggiunto Totale Giacenza
- Modifiche Grafiche
- Modifiche Minori
This commit is contained in:
2023-08-07 10:19:32 +02:00
parent 98887d88bd
commit f41fc928fc
4 changed files with 76 additions and 53 deletions

View File

@@ -3,24 +3,23 @@
class LivelloSerbatoi {
public static function getSerbatoi() {
$query = new Query();
$gestSetup = new GestSetup();
$coloreGiacenzaDB = $gestSetup->gestName("PVM")->section("LIVELLO_SERBATOI")->keySection("COLORE_GIACENZA_DB")->get();
$ret = $query
$query
->importSqlFile("list-serbatoi")
->cacheResult()
->toRet()
->date2ts()
->execute();
->setVar('color', $coloreGiacenzaDB);
$ret = $query->cacheResult()->toRet()->date2ts()->execute();
if ($ret->is_KO()) {
$ret->display();
}
$retData = $ret->get_data();
$setup = new GestSetup();
$color = $setup->keySection("COLORE_GIACENZA_DB")->get();
$serbatoi = $retData;
$finalSerbatoi = array();
$retData = $ret->get_data();
$serbatoi = $retData;
foreach ($serbatoi as $serbatoio) {
if (!array_key_exists($serbatoio["posizione"], $finalSerbatoi)) {
$finalSerbatoi[$serbatoio["posizione"]] = array(
@@ -28,7 +27,7 @@ class LivelloSerbatoi {
"cod_mdep" => $serbatoio["cod_mdep"],
"capacita" => $serbatoio["capacita"],
"qta_esistente" => 0,
"color" => $color,
"color" => $coloreGiacenzaDB,
"articoli" => array(),
"cod_mart" => $serbatoio["cod_mart"],
);

View File

@@ -1,9 +1,9 @@
<div class="row">
<div class="row no-gutters">
<div class="col-md-2">
<div id="sidebar-logManager" class="sidebar col-md-2">
<div class="container-fluid"></div>
<div class="tab-content">
<div class="filtersList pb-40">
<div class="filtersList pb-20">
<div class="form-group">
<label for="codiceDeposito">Codice Deposito</label>
<select id="codiceDeposito" class="form-control">
@@ -23,6 +23,11 @@
</select>
</div>
</div>
<div id="totaleKG" style="text-align: center; display: none">
<h4>
Totale Giacenza: <span class="tot">0</span> KG
</h4>
</div>
</div>
</div>
</div>

View File

@@ -7,10 +7,11 @@ $(function () {
});
LivelloSerbatoi.prototype.init = function () {
let self = this;
let ajax = new Ajax()
const self = this;
const ajax = new Ajax()
.get("getSerbatoi")
.waitModal()
.noticeAsModal()
.onSuccess(function (ret) {
self.buildCharts(ret.returnData);
});
@@ -23,11 +24,10 @@ LivelloSerbatoi.prototype.init = function () {
// {id: 3, title: "Serbatoio CALC", totale: 100, effettivo: 10, calcolato: 30, color: "#563F38"},
// {id: 4, title: "Serbatoio EFF", totale: 100, effettivo: 60, calcolato: 20, color: "#563F38"},
// ];
};
LivelloSerbatoi.prototype.initFilters = function () {
let self = this;
const self = this;
_.forEach(_.uniq(_.map(self.array_serbatoi, "cod_mdep")), (field) => {
let option = new Option(field, field);
@@ -68,30 +68,46 @@ LivelloSerbatoi.prototype.initFilters = function () {
};
LivelloSerbatoi.prototype.checkInputFilter = function (event, value) {
let self = this;
let filters = self.getFilters();
const self = this;
const filters = self.getFilters();
$(".col-chartdiv").hide();
let filteredArray = _.filter(self.array_serbatoi, filters);
const filteredArray = _.filter(self.array_serbatoi, filters);
let qtaEsistente = 0;
_.each(filteredArray, function (serbatoio) {
qtaEsistente += serbatoio.qta_esistente;
$("#col-chartdiv" + serbatoio.posizione).show();
});
const $totaleKG = $("#totaleKG");
if (filters.cod_mart) {
$totaleKG.show();
$totaleKG.find(".tot").text(number_format(qtaEsistente, 0, ".", "'"));
} else {
$totaleKG.hide();
}
};
LivelloSerbatoi.prototype.getFilters = function () {
let filters = {};
let filterCodice = $("#codiceDeposito").val();
if (!_.isNil(filterCodice) && !_.isEmpty(filterCodice))
filters.cod_mdep = filterCodice;
let filterPosizione = $("#posizioneDeposito").val();
if (!_.isNil(filterPosizione) && !_.isEmpty(filterPosizione))
filters.posizione = filterPosizione;
const filters = {};
const filterCodice = $("#codiceDeposito").val();
const filterPosizione = $("#posizioneDeposito").val();
const filterArticolo = $("#articolo").val();
let filterArticolo = $("#articolo").val();
if (!_.isNil(filterArticolo) && !_.isEmpty(filterArticolo))
if (!_.isNil(filterCodice) && !_.isEmpty(filterCodice)) {
filters.cod_mdep = filterCodice;
}
if (!_.isNil(filterPosizione) && !_.isEmpty(filterPosizione)) {
filters.posizione = filterPosizione;
}
if (!_.isNil(filterArticolo) && !_.isEmpty(filterArticolo)) {
filters.cod_mart = filterArticolo;
}
return filters;
};
@@ -114,16 +130,16 @@ LivelloSerbatoi.prototype.buildCharts = function (array_serbatoi) {
am4core.addLicense("ch-custom-attribution");
// Themes end
am4core.options.autoSetClassName = true;
console.log(array_serbatoi);
let iconPath = "M167.7658,262.32278l-47.29772,28.79413v18.93152a3.52059,3.52059,0,0,1-3.5206,3.52063H81.96875a3.52061,3.52061,0,0,1-3.5206-3.52063h0V291.11691l-47.2754-28.75258-.104-231.46653a1.99773,1.99773,0,0,1,1.211-1.83722L98.5697.66139a1.99777,1.99777,0,0,1,1.57321-.00007L166.45056,29.061a1.9977,1.9977,0,0,1,1.21121,1.83547Z";
const iconPath = "M167.7658,262.32278l-47.29772,28.79413v18.93152a3.52059,3.52059,0,0,1-3.5206,3.52063H81.96875a3.52061,3.52061,0,0,1-3.5206-3.52063h0V291.11691l-47.2754-28.75258-.104-231.46653a1.99773,1.99773,0,0,1,1.211-1.83722L98.5697.66139a1.99777,1.99777,0,0,1,1.57321-.00007L166.45056,29.061a1.9977,1.9977,0,0,1,1.21121,1.83547Z";
const self = this;
let self = this;
self.array_serbatoi = array_serbatoi;
self.initFilters();
array_serbatoi.forEach(function (serbatoio) {
let $div = $("#col-chartdiv" + serbatoio.posizione);
if ($div.length <= 0) {
$div = $("<div>", {
id: "col-chartdiv" + serbatoio.posizione,
@@ -135,15 +151,15 @@ LivelloSerbatoi.prototype.buildCharts = function (array_serbatoi) {
}));
$("#listContainer").append($div);
}
let chart = am4core.create("chartdiv" + serbatoio.posizione, am4charts.SlicedChart);
let totale = serbatoio.capacita;
let effettivo = (serbatoio.effettivo) ? serbatoio.effettivo : 0;
let calcolata = serbatoio.qta_esistente;
const chart = am4core.create("chartdiv" + serbatoio.posizione, am4charts.SlicedChart);
const totale = serbatoio.capacita;
const effettivo = (serbatoio.effettivo) ? serbatoio.effettivo : 0;
const calcolata = serbatoio.qta_esistente;
let disponibilita = (totale - calcolata > 0) ? totale - calcolata : 0;
const disponibilita = (totale - calcolata > 0) ? totale - calcolata : 0;
let calcolataColor = (serbatoio.color) ? serbatoio.color : "#7b7b7d";
const calcolataColor = serbatoio.color ? serbatoio.color : "#7b7b7d";
chart.data = [{
"name": "Disponibilità",
@@ -159,7 +175,7 @@ LivelloSerbatoi.prototype.buildCharts = function (array_serbatoi) {
// "color": (serbatoio.color) ? serbatoio.color : "#F1DD27",
}];
let series = chart.series.push(new am4charts.PictorialStackedSeries());
const series = chart.series.push(new am4charts.PictorialStackedSeries());
series.dataFields.value = "value";
series.dataFields.category = "name";
series.slices.template.tooltipText = "{category}: {value} Kg";
@@ -187,7 +203,7 @@ LivelloSerbatoi.prototype.buildCharts = function (array_serbatoi) {
chart.legend = new am4charts.Legend();
chart.legend.position = "bottom";
let marker = chart.legend.markers.template.children.getIndex(0);
chart.legend.name = "{category}";
chart.legend.markers.template.width = 25;
chart.legend.markers.template.height = 25;
@@ -195,37 +211,38 @@ LivelloSerbatoi.prototype.buildCharts = function (array_serbatoi) {
chart.legend.labels.template.text = "{category}:";
chart.legend.valueLabels.template.text = "{value} Kg ({value.percent.formatNumber('#.0')}%)";
const marker = chart.legend.markers.template.children.getIndex(0);
marker.cornerRadius(15, 15, 15, 15);
// Add chart title
let title = chart.titles.create();
const title = chart.titles.create();
title.text = serbatoio.posizione + " - " + number_format(serbatoio.capacita, 0, ".", "'") + " Kg";
title.fontSize = 30;
// Add bottom label
let label = chart.chartContainer.createChild(am4core.Label);
const label = chart.chartContainer.createChild(am4core.Label);
let cod_mart = (serbatoio.cod_mart) ? serbatoio.cod_mart : "SERBATOIO VUOTO";
let partita_mag = (serbatoio.partita_mag) ? serbatoio.partita_mag : "";
let descrizione = (serbatoio.descrizione) ? serbatoio.descrizione : "";
const cod_mart = (serbatoio.cod_mart) ? serbatoio.cod_mart : "SERBATOIO VUOTO";
const partita_mag = (serbatoio.partita_mag) ? serbatoio.partita_mag : "";
const descrizione = (serbatoio.descrizione) ? serbatoio.descrizione : "";
label.html = "<div style='text-align: center'>";
label.html = "";
if (_.isNil(serbatoio.articoli) || _.isEmpty(serbatoio.articoli)) {
label.html += "<span>" + cod_mart + " " + partita_mag + "</span></br>";
} else {
_.forEach(serbatoio.articoli, articolo => {
label.html += "<span class='badge badge-primary'>" + articolo.cod_mart + " (" + articolo.partita_mag + ")</span> &nbsp;<small>" + number_format(articolo.qta, 0, ".", "'") + " KG</small></br>";
label.html += "<small>" + articolo.descrizione + "</small></br>";
label.html += "<small>" + articolo.descrizione + "</small><br>";
});
}
if (calcolata > totale) {
label.html += "<span style='color: red; font-weight: bold'>SUPERATA CAPIENZA DEL SERBATOIO</span></br>";
}
let rilevata = null;
const rilevata = null;
if (rilevata) {
let color;
@@ -242,6 +259,9 @@ LivelloSerbatoi.prototype.buildCharts = function (array_serbatoi) {
label.html += "<span style='font-weight: bold'>Giacenza Rilevata: </span><span style='color: " + color + "' >" + rilevata + " Kg <i class=' " + arrow + "'></i></span></br>";
}
label.html += "</div>";
label.wrap = true;
label.align = "center";
});
};

View File

@@ -1,10 +1,9 @@
SELECT cod_mdep,
posizione,
capacita,
ISNULL(qta_esistente, 0) AS qta_esistente,
ISNULL(qta_esistente, 0) AS qta_esistente,
cod_mart,
descrizione,
partita_mag,
(SELECT dbo.getGestSetup('PVM', 'LIVELLO_SERBATOI', 'COLORE_GIACENZA_DB')) AS color
partita_mag
FROM dbo.MES_getGiacenzaSilos()
ORDER BY cod_mdep, posizione