[Produttivita a Valore]

- Pulizia codice
This commit is contained in:
2024-05-20 13:14:10 +02:00
parent 75c0b9f3f2
commit c20e86b167
5 changed files with 456 additions and 404 deletions

View File

@@ -30,54 +30,62 @@ class ProduttivitaAValore {
}
public static function get_reparti($codMdep, $mondayDate) {
$Query = new Query();
$Ret = $Query
$query = new Query();
$ret = $query
->importSqlFile("getReparti")
->setVar("cod_mdep", $codMdep)
->setVar("username", User::get_current_username())
->toRet()->execute();
if ($Ret->is_OK()) {
$arr_repo = $Ret->get_data();
if ($ret->is_OK()) {
$arr_repo = $ret->get_data();
foreach ($arr_repo as $i => $repo) {
$codJfas = $repo["cod_jfas"];
$um = explode("/", $repo["um_prod"]);
$repo["um"] = $um[0];
// QTA_PREV_UM
$Ret = self::get_qtaBdgPrev($codMdep, $codJfas, $mondayDate);
if ($Ret->is_OK()) {
$qtaBdgPrev = self::fill_dataWeekRow($Ret->get_data());
$ret = self::get_qtaBdgPrev($codMdep, $codJfas, $mondayDate);
if ($ret->is_OK()) {
$qtaBdgPrev = self::fill_dataWeekRow($ret->get_data());
} else {
break;
}
$repo["qtaBdgPrev"] = $qtaBdgPrev;
// QTA_CONSUNTIVA_UM
$Ret = self::get_qtaVendCons($codMdep, $codJfas, $mondayDate);
if ($Ret->is_OK()) {
$repo["qtaVendCons"] = self::fill_dataWeekRow($Ret->get_data());
$ret = self::get_qtaVendCons($codMdep, $codJfas, $mondayDate);
if ($ret->is_OK()) {
$repo["qtaVendCons"] = self::fill_dataWeekRow($ret->get_data());
} else {
break;
}
// PERC_SCOSTAMENTO
$Ret = self::get_formazione($codMdep, $codJfas, $mondayDate);
if ($Ret->is_OK()) {
$repo["oreFormazione"] = self::fill_dataWeekRow($Ret->get_data());
$ret = self::get_formazione($codMdep, $codJfas, $mondayDate);
if ($ret->is_OK()) {
$repo["oreFormazione"] = self::fill_dataWeekRow($ret->get_data());
} else {
break;
}
$Ret = self::get_prodStd($codMdep, $codJfas, $mondayDate);
if ($Ret->is_OK()) {
$repo["prodStd"] = self::fill_dataWeekRow($Ret->get_data());
$ret = self::get_prodStd($codMdep, $codJfas, $mondayDate);
if ($ret->is_OK()) {
$repo["prodStd"] = self::fill_dataWeekRow($ret->get_data());
} else {
break;
}
$Ret = self::get_qtaBdgAdeg($codMdep, $codJfas, $mondayDate);
if ($Ret->is_OK()) {
$qtaBdgAdeg = self::fill_dataWeekRow($Ret->get_data());
$ret = self::get_qtaBdgAdeg($codMdep, $codJfas, $mondayDate);
if ($ret->is_OK()) {
$qtaBdgAdeg = self::fill_dataWeekRow($ret->get_data());
} else {
break;
}
@@ -97,29 +105,33 @@ class ProduttivitaAValore {
$retData = array();
if ($Ret->is_OK()) {
$Ret = self::get_oreMin($codMdep, $mondayDate);
if ($Ret->is_OK()) {
$retData["oreMin"] = self::fill_dataWeekRow($Ret->get_data());
if ($ret->is_OK()) {
$ret = self::get_oreMin($codMdep, $mondayDate);
if ($ret->is_OK()) {
$retData["oreMin"] = self::fill_dataWeekRow($ret->get_data());
}
}
if ($Ret->is_OK()) {
$Ret = self::get_oreSvolto($codMdep, $mondayDate);
if ($Ret->is_OK()) {
$retData["oreSvolto"] = self::fill_dataWeekRow($Ret->get_data());
if ($ret->is_OK()) {
$ret = self::get_oreSvolto($codMdep, $mondayDate);
if ($ret->is_OK()) {
$retData["oreSvolto"] = self::fill_dataWeekRow($ret->get_data());
}
}
if ($Ret->is_OK()) {
$Ret = self::get_oreInvestimento($codMdep, $mondayDate);
if ($Ret->is_OK()) {
$retData["oreInvestimento"] = self::fill_dataWeekRow($Ret->get_data());
if ($ret->is_OK()) {
$ret = self::get_oreInvestimento($codMdep, $mondayDate);
if ($ret->is_OK()) {
$retData["oreInvestimento"] = self::fill_dataWeekRow($ret->get_data());
}
}
if ($Ret->is_OK()) {
if ($ret->is_OK()) {
$retData["oreFormazioneNegozio"] = self::fill_dataWeekRow();
foreach ($arr_repo as $repo) {
foreach ($repo["oreFormazione"] as $dayId => $oreFormazioneDay) {
$retData["oreFormazioneNegozio"][$dayId] += $oreFormazioneDay;
@@ -127,6 +139,7 @@ class ProduttivitaAValore {
}
$retData["differenzaNettoCN"] = self::fill_dataWeekRow();
foreach ($retData["differenzaNettoCN"] as $dayId => $differenzaNettoCNDay) {
$oreSvoltoDay = $retData["oreSvolto"][$dayId];
$oreInvestimentoDay = $retData["oreInvestimento"][$dayId];
@@ -135,10 +148,13 @@ class ProduttivitaAValore {
$retData["differenzaNettoCN"][$dayId] = $differenzaNettoCNDay;
}
}
$rapProdStdPv = array();
foreach ($arr_repo as $repo) {
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
if (array_key_exists($dayId, $rapProdStdPv) && is_numeric($rapProdStdPv[$dayId])) {
$rapProdStdPv[$dayId] += $repo["rapProd"][$dayId];
} else {
@@ -146,6 +162,7 @@ class ProduttivitaAValore {
}
}
}
$retData["RapProdStdPv"] = $rapProdStdPv;
foreach ($arr_repo as $i => $repo) {
@@ -153,18 +170,20 @@ class ProduttivitaAValore {
foreach ($arr_repo as $k => $item) {
if ($item["cod_jfas"] === $repo["cod_jfas_view"]) {
$arr_repo[$k]["child"][] = $repo;
}
}
unset($arr_repo[$i]);
}
}
if ($Ret->is_OK()) {
if ($ret->is_OK()) {
$retData["repo"] = $arr_repo;
$Ret->set_data($retData);
$ret->set_data($retData);
}
}
return $Ret;
return $ret;
}
public static function get_prodStd($codMdep, $codJfas, $mondayDate) {
@@ -220,8 +239,8 @@ class ProduttivitaAValore {
}
public static function save($data) {
$Ret = new Ret;
$EntityList = new EntityList;
$ret = new Ret;
$entityList = new EntityList;
$codMdep = User::get_current_userCodMdep();
$arr_dataBdg = array_values(from($data["values"])->distinct(function ($x) {
@@ -238,10 +257,10 @@ class ProduttivitaAValore {
})->select(function ($x) {
return $x["cod_jfas"];
})->toArray());
foreach ($arr_codJfas as $codJfas) {
$JtbBdgHr = new EntityItem("jtb_bdg_hr");
$JtbBdgHr->insert_or_update()
foreach ($arr_codJfas as $codJfas) {
$jtbBdgHr = new EntityItem("jtb_bdg_hr");
$jtbBdgHr->insert_or_update()
->set("codMdep", $codMdep)
->setDate("dataBdg", $dataBdg)
->set("codJfas", $codJfas);
@@ -249,39 +268,36 @@ class ProduttivitaAValore {
$arr_itemValues = array_values(from($data["values"])->where(function ($x) use ($dataBdg, $codJfas) {
return $x["data_bdg"] == $dataBdg && $x["cod_jfas"] == $codJfas;
})->toArray());
foreach ($arr_itemValues as $resValue) {
foreach ($arr_itemValues as $resValue) {
if ($resValue["row"] == "oreFormazione") {
$activityTypeId = "FORMAZIONE";
} else {
$Ret->set_error("Tipo dato '{$resValue["row"]}' non ammesso");
$ret->set_error("Tipo dato '{$resValue["row"]}' non ammesso");
break;
}
$JtbBdgHrDet = new EntityItem("jtb_bdg_hr_det");
$JtbBdgHrDet->insert_or_update()
$jtbBdgHrDet = new EntityItem("jtb_bdg_hr_det");
$jtbBdgHrDet->insert_or_update()
->set("activityTypeId", $activityTypeId)
->set("flagTipologia", "A")
->set("ore", $resValue["value"], 0);
$JtbBdgHr->set("jtbBdgHrDet")->append($JtbBdgHrDet);
$jtbBdgHr->set("jtbBdgHrDet")->append($jtbBdgHrDet);
}
$EntityList->push($JtbBdgHr);
$entityList->push($jtbBdgHr);
}
}
//echo$EntityList;exit;
if ($Ret->is_OK()) {
if ($EntityList->count() > 0) {
$Ret = $EntityList->profileDB(self::get_defaultProfileDb())->send();
if ($ret->is_OK()) {
if ($entityList->count() > 0) {
$ret = $entityList->profileDB(self::get_defaultProfileDb())->send();
} else {
$Ret->set_error("Non è stato registrato alcun aggiornamento");
$ret->set_error("Non è stato registrato alcun aggiornamento");
}
}
return $Ret;
return $ret;
}
private static function get_defaultProfileDb() {

View File

@@ -13,11 +13,9 @@ if (isset($_GET["load_weekPvTable"])) {
$html = Utility\Str::remove_multiple_spaces(@ob_get_clean());
$Ret = new Ret;//sleep(30);
$Ret->set_string($html)->display();
} else if (isset($_POST["update"])) {
$data = Utility::sanitizeB64JSON_parse($_POST["update"]);
} else if (isset($_POST["save"])) {
$data = Utility::sanitizeB64JSON_parse($_POST["save"]);
ProduttivitaAValore::save($data)->display();
} else if (Controller::is_ajaxRequest()) {
$Ret = new Ret;
$Ret->set_errorCode(ErrorHandler::UNEXPECTED_AJAX_METHOD)->display();

View File

@@ -1,347 +1,364 @@
<?php
$codMdep = $codMdep ?: User::get_current_userCodMdep();
$Ret = ProduttivitaAValore::get_reparti($codMdep, $mondayDate);
if ($Ret->is_OK()) {
$prodData = $Ret->get_data();
$ret = ProduttivitaAValore::get_reparti($codMdep, $mondayDate);
if ($ret->is_OK()) {
$prodData = $ret->get_data();
?>
<table class="table table-striped table-hover table-condensed table-bordered" style="font-size:11px;">
<thead>
<tr>
<th class="col-sm-5">&nbsp;</th><?php
foreach (ProduttivitaAValore::get_weekDays() as $i => $day) {
$time = ProduttivitaAValore::get_weekDate($i, $mondayDate);
?>
<th><?= ucfirst($day) ?><br/><?= strftime(Format::strftimeDMY, $time) ?></th><?php
} ?>
<th>TOTALE<br/>SETTIMANALE</th>
</tr>
</thead>
<thead>
<tr>
<th class="col-sm-5">&nbsp;</th>
<?php
foreach (ProduttivitaAValore::get_weekDays() as $i => $day) {
$time = ProduttivitaAValore::get_weekDate($i, $mondayDate);
?>
<th><?= ucfirst($day) ?><br/><?= strftime(Format::strftimeDMY, $time) ?></th>
<?php } ?>
<th>TOTALE<br/>SETTIMANALE</th>
</tr>
</thead>
<?php
foreach ($prodData["repo"] as $repo) {
?>
<tbody>
<?php if (array_key_exists("child", $repo) && !empty($repo["child"])) {
foreach ($repo["child"] as $subrepo) { ?>
<tr>
<td class="font-weight-bold">
Valore vendite a budget (<?= $subrepo["um_prod"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $subrepo["qtaBdgPrev"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace dayname">
<?= number_format($value, 2, ".", "'") ?>
<?php
foreach ($prodData["repo"] as $repo) {
?>
<tbody>
<?php if (array_key_exists("child", $repo) && !empty($repo["child"])) {
foreach ($repo["child"] as $subrepo) { ?>
<tr>
<td class="font-weight-bold">
Valore vendite a budget (<?= $subrepo["um_prod"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">
Valore vendite consuntivo (<?= $subrepo["um_prod"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $subrepo["qtaVendCons"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace">
<?= number_format($value, 2, ".", "'") ?>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $subrepo["qtaBdgPrev"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace dayname">
<?= number_format($value, 2, ".", "'") ?>
</td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">
Valore vendite consuntivo (<?= $subrepo["um_prod"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold">
<?= number_format($sumRow, 2, ".", "'") ?>
</td>
</tr>
<tr>
<td class="font-weight-bold">
Differenza valore (<?= $subrepo["um_prod"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $subrepo["qtaDiff"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace">
<?= number_format($value, 2, ".", "'") ?>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $subrepo["qtaVendCons"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace">
<?= number_format($value, 2, ".", "'") ?>
</td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold">
<?= number_format($sumRow, 2, ".", "'") ?>
</td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">
Standard produttivo (<?= $subrepo["um_prod"] ?>) <?= $repo["descrizione"] ?>
</td>
</tr>
<tr>
<td class="font-weight-bold">
Differenza valore (<?= $subrepo["um_prod"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $subrepo["qtaDiff"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace">
<?= number_format($value, 2, ".", "'") ?>
</td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">
Standard produttivo (<?= $subrepo["um_prod"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $subrepo["prodStd"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">
Rapporto Consuntivo / Standard (<?= $subrepo["um_prod"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $subrepo["rapProd"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $subrepo["prodStd"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td><?php
} ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">
Rapporto Consuntivo / Standard (<?= $subrepo["um_prod"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $subrepo["rapProd"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td><?php
} ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<?php
}
}
} ?>
<tr>
<td class="font-weight-bold">
<?= $repo["descrizione"] == "CASSIERA" ? "Q.t&agrave; prevista" : "Valore vendite a budget" ?>
(<?= $repo["um"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $repo["qtaBdgPrev"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace dayname"><?= number_format($value, 2, ".", "'") ?></td><?php
} ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">
<?= $repo["descrizione"] == "CASSIERA" ? "Q.t&agrave; prevista" : "Valore vendite consuntivo" ?>
(<?= $repo["um"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $repo["qtaVendCons"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td><?php
} ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">
Differenza <?= $repo["descrizione"] == "CASSIERA" ? "q.t&agrave;" : "valore" ?> (<?= $repo["um"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $repo["qtaDiff"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td><?php
} ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">Standard produttivo (<?= $repo["um_prod"] ?>) <?= $repo["descrizione"] ?></td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $repo["prodStd"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td><?php
} ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">
Rapporto Consuntivo / Standard (<?= $repo["um_prod"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $repo["rapProd"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td><?php
} ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<?php if (array_key_exists("child", $repo) && !empty($repo["child"])) { ?>
?>
<tr>
<td class="font-weight-bold">Rapporto Consuntivo / Standard (generale) <?= $repo["descrizione"] ?></td>
<td class="font-weight-bold">
<?= $repo["descrizione"] == "CASSIERA" ? "Q.t&agrave; prevista" : "Valore vendite a budget" ?>
(<?= $repo["um"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $repo["qtaBdgPrev"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace dayname"><?= number_format($value, 2, ".", "'") ?></td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">
<?= $repo["descrizione"] == "CASSIERA" ? "Q.t&agrave; prevista" : "Valore vendite consuntivo" ?>
(<?= $repo["um"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $repo["qtaVendCons"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">
Differenza <?= $repo["descrizione"] == "CASSIERA" ? "q.t&agrave;" : "valore" ?>
(<?= $repo["um"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $repo["qtaDiff"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">
Standard produttivo (<?= $repo["um_prod"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $repo["prodStd"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">
Rapporto Consuntivo / Standard (<?= $repo["um_prod"] ?>) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $repo["rapProd"][$dayId];
foreach ($repo["child"] as $child) {
$dayId = "d{$j}";
$value += $child["rapProd"][$dayId];
}
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td><?php
} ?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<?php
} ?>
<?php if (array_key_exists("child", $repo) && !empty($repo["child"])) { ?>
<tr>
<td class="font-weight-bold">
Rapporto Consuntivo / Standard (generale) <?= $repo["descrizione"] ?>
</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $repo["rapProd"][$dayId];
foreach ($repo["child"] as $child) {
$dayId = "d{$j}";
$value += $child["rapProd"][$dayId];
}
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<?php } ?>
<tr>
<td class="font-weight-bold vertical-middle">Ore formazione <?= $repo["descrizione"] ?></td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $repo["oreFormazione"][$dayId];
$sumRow += $value;
$time = ProduttivitaAValore::get_weekDate($j, $mondayDate);
?>
<td>
<input data-row="oreFormazione" data-data_bdg="<?= $time ?>"
data-cod_jfas="<?= $repo["cod_jfas"] ?>" placeholder="0"
type="number" class="form-control no-spin-buttons text-monospace input-xs" min="0"
step="0.1"
value="<?= zeroIfNull($value) == 0 ? "" : number_format($value, 1, ".", "'") ?>"/>
</td>
<?php } ?>
<td class="sumRow text-right text-monospace font-weight-bold vertical-middle"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<th colspan="10">&nbsp;</th>
</tr>
</tbody>
<?php } ?>
<tbody>
<tr>
<td class="font-weight-bold vertical-middle">Ore formazione <?= $repo["descrizione"] ?></td>
<td colspan="8" class="font-weight-bold">Minime</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $repo["oreFormazione"][$dayId];
$value = $prodData["oreMin"][$dayId];
$sumRow += $value;
$time = ProduttivitaAValore::get_weekDate($j, $mondayDate);
?>
<td>
<input data-row="oreFormazione" data-data_bdg="<?= $time ?>" data-cod_jfas="<?= $repo["cod_jfas"] ?>"
type="number" class="form-control no-spin-buttons text-monospace input-xs" min="0" step="0.1"
placeholder="0"
value="<?= zeroIfNull($value) == 0 ? "" : number_format($value, 1, ".", "'") ?>"/>
</td><?php
} ?>
<td class="sumRow text-right text-monospace font-weight-bold vertical-middle"><?= number_format($sumRow, 2, ".", "'") ?></td>
}
$sumOreMin = $sumRow;
?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<th colspan="10">&nbsp;</th>
<td class="font-weight-bold">Svolto</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $prodData["oreSvolto"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">Investimento</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $prodData["oreInvestimento"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">Formazione</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $prodData["oreFormazioneNegozio"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td colspan="8">&nbsp;</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $prodData["differenzaNettoCN"][$dayId];
$sumRow += $value;
}
?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow - $sumOreMin, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">Differenza netta</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $prodData["differenzaNettoCN"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
<td>&nbsp;</td>
</tr>
<tr>
<td class="font-weight-bold">Andamento settimanale consuntivo</td>
<?php
$prodStdPv = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $prodData["RapProdStdPv"][$dayId];
$prodStdPv += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($prodStdPv, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">Differenza netta - andamento settimanale</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $prodData["differenzaNettoCN"][$dayId] - $prodData["RapProdStdPv"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
</tbody>
<?php } ?>
<tbody>
<tr>
<td colspan="8" class="font-weight-bold">Minime</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $prodData["oreMin"][$dayId];
$sumRow += $value;
}
$sumOreMin = $sumRow;
?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">Svolto</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $prodData["oreSvolto"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td><?php
} ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">Investimento</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $prodData["oreInvestimento"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td><?php
} ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">Formazione</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $prodData["oreFormazioneNegozio"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td><?php
} ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
<tr>
<td colspan="8">&nbsp;</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $prodData["differenzaNettoCN"][$dayId];
$sumRow += $value;
}
?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow - $sumOreMin, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">Differenza netta</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $prodData["differenzaNettoCN"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td><?php
}
?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
<td>&nbsp;</td>
</tr>
<tr>
<td class="font-weight-bold">Andamento settimanale consuntivo</td>
<?php
$prodStdPv = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $prodData["RapProdStdPv"][$dayId];
$prodStdPv += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td>
<?php } ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($prodStdPv, 2, ".", "'") ?></td>
</tr>
<tr>
<td class="font-weight-bold">Differenza netta - andamento settimanale</td>
<?php
$sumRow = 0;
for ($j = 1; $j <= 7; $j++) {
$dayId = "d{$j}";
$value = $prodData["differenzaNettoCN"][$dayId] - $prodData["RapProdStdPv"][$dayId];
$sumRow += $value;
?>
<td class="text-right text-monospace"><?= number_format($value, 2, ".", "'") ?></td><?php
} ?>
<td class="text-right text-monospace font-weight-bold"><?= number_format($sumRow, 2, ".", "'") ?></td>
</tr>
</tbody>
</table><?php
</table>
<?php
} else {
$Ret->showErrorAlert();
$ret->showErrorAlert();
}

View File

@@ -1,8 +1,10 @@
<div class="panel panel-default panel-strip panel-strip-top">
<?php
$Ret = ProduttivitaAValore::get_pv();
if ($Ret->is_OK()) {
$arr_pv = $Ret->get_data();
$arr_pv = array();
$ret = ProduttivitaAValore::get_pv();
if ($ret->is_OK()) {
$arr_pv = $ret->get_data();
}
?>
<div class="panel-body">

View File

@@ -1,5 +1,4 @@
$(function () {
$("#bt_save").on("click", function () {
_produttivitaAValore.save();
});
@@ -7,14 +6,15 @@ $(function () {
_produttivitaAValore.init();
});
var _produttivitaAValore = {
const _produttivitaAValore = {
module: null,
_week: null,
_year: null,
_toastRefresh: null,
init: function () {
var self = this;
const self = this;
self.module = new Module();
self.module.onLoad(function () {
const $weekPicker = $("#weekPicker");
@@ -27,19 +27,20 @@ var _produttivitaAValore = {
}
});
$weekPicker.weekPicker("change");
}).load();
$("#cod_mdep").on("change", function () {
$("#weekPicker").weekPicker("change");
})
},
init_tableEvents: function () {
var self = this;
var $btSave = $("#bt_save");
const self = this;
const $btSave = $("#bt_save");
const $boxMain = $("#box-main");
$btSave.disabled();
var $boxMain = $("#box-main");
$boxMain.find("input[data-row][data-data_bdg][data-cod_jfas]").on("keyup change", function () {
$(this).attr("edited", "");
$btSave.enabled();
@@ -51,54 +52,68 @@ var _produttivitaAValore = {
},
view_toastRefresh: function () {
var self = this;
const self = this;
if (is_null(self._toastRefresh)) {
self._toastRefresh = new Toast();
self._toastRefresh.noAutoclose().bottomRight().closeButton().classes("small") /*.icon("exclamation-circle")*/.warning("Alcuni dati visualizzati potrebbero differire da quelli effettivi.<br/>Salvare le modifiche attuali per aggiornarli."/*, "Aggiornamento necessario"*/);
}
return self;
},
refresh_rowSum: function ($tr) {
var sum = 0;
let sum = 0;
$tr.find("input[data-row][data-data_bdg][data-cod_jfas]").each(function () {
sum += $(this).getNumericValue();
});
$tr.find(".sumRow").text(number_format(sum, 2, ".", "'"));
return this;
},
refresh_table: function () {
var self = this;
var $boxMain = $("#box-main");
var data = {week: self._week, year: self._year, codMdep: self.get_codMdep()};
var ajax = new Ajax();
const self = this;
const $boxMain = $("#box-main");
const data = {week: self._week, year: self._year, codMdep: self.get_codMdep()};
const ajax = new Ajax();
ajax.get("load_weekPvTable").data(data).$toDisable($("#content")).waitToast("Caricamento dati della settimana").noticeAsModal().execute(function (ret) {
if (ret.returnId == 1) {
if (ret.returnId === 1) {
$boxMain.html(ret.returnString);
self.init_tableEvents();
}
});
if (!is_null(self._toastRefresh)) {
self._toastRefresh.close();
self._toastRefresh = null;
}
return self;
},
get_codMdep: function () {
const $codMdep = $("#cod_mdep");
if ($codMdep.length > 0) {
return $codMdep.val();
}
return null;
},
save: function () {
var self = this;
var $boxMain = $("#box-main");
var data = [];
const self = this;
const $boxMain = $("#box-main");
const data = [];
$boxMain.find("input[data-row][data-data_bdg][data-cod_jfas][edited]").each(function () {
var $this = $(this);
const $this = $(this);
console.log($this);
data.push({
row: $this.getDataAttr("row"),
data_bdg: $this.getIntDataAttr("data_bdg"),
@@ -108,17 +123,21 @@ var _produttivitaAValore = {
});
if (data.length > 0) {
var ajax = new Ajax();
ajax.post("update").data({values: data}).waitModal("Aggiornamento dati").noticeAsModal().execute(function (ret) {
if (ret.returnId == 1) {
self.refresh_table();
//$boxMain.find("input[data-row][data-data_bdg][data-cod_jfas]").removeAttr("edited");
// $("#bt_save").disabled();
}
});
const ajax = new Ajax();
ajax
.post("save")
.data({values: data})
.waitModal("Aggiornamento dati")
.noticeAsModal()
.execute(function (ret) {
if (ret.returnId === 1) {
self.refresh_table();
}
});
} else {
var toast = new Toast();
const toast = new Toast();
toast.warning("Nessun dato da salvare");
}
}