diff --git a/public_html/gest-lib/produttivita_a_valore/classes/ProduttivitaAValore.class.php b/public_html/gest-lib/produttivita_a_valore/classes/ProduttivitaAValore.class.php index 704c45dbc..209268f4b 100644 --- a/public_html/gest-lib/produttivita_a_valore/classes/ProduttivitaAValore.class.php +++ b/public_html/gest-lib/produttivita_a_valore/classes/ProduttivitaAValore.class.php @@ -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() { diff --git a/public_html/gest-lib/produttivita_a_valore/include/ajax.php b/public_html/gest-lib/produttivita_a_valore/include/ajax.php index 967a56017..27ab1a53b 100644 --- a/public_html/gest-lib/produttivita_a_valore/include/ajax.php +++ b/public_html/gest-lib/produttivita_a_valore/include/ajax.php @@ -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(); diff --git a/public_html/gest-lib/produttivita_a_valore/include/box-main.php b/public_html/gest-lib/produttivita_a_valore/include/box-main.php index 4174735ec..cd2fe430f 100644 --- a/public_html/gest-lib/produttivita_a_valore/include/box-main.php +++ b/public_html/gest-lib/produttivita_a_valore/include/box-main.php @@ -1,347 +1,364 @@ is_OK()) { - $prodData = $Ret->get_data(); +$ret = ProduttivitaAValore::get_reparti($codMdep, $mondayDate); + +if ($ret->is_OK()) { + $prodData = $ret->get_data(); ?>
| $day) { - $time = ProduttivitaAValore::get_weekDate($i, $mondayDate); - ?> - | = ucfirst($day) ?> = strftime(Format::strftimeDMY, $time) ?> |
- TOTALE SETTIMANALE |
- ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| + $day) { + $time = ProduttivitaAValore::get_weekDate($i, $mondayDate); + ?> + | = ucfirst($day) ?> = strftime(Format::strftimeDMY, $time) ?> |
+
+ TOTALE SETTIMANALE |
+ ||||||||||
| - Valore vendite a budget (= $subrepo["um_prod"] ?>) = $repo["descrizione"] ?> - | - -- = number_format($value, 2, ".", "'") ?> + + | |||||||||||
| + Valore vendite a budget (= $subrepo["um_prod"] ?>) = $repo["descrizione"] ?> | - -= number_format($sumRow, 2, ".", "'") ?> | -|||||||||||
| - Valore vendite consuntivo (= $subrepo["um_prod"] ?>) = $repo["descrizione"] ?> - | - -- = number_format($value, 2, ".", "'") ?> + + | + = number_format($value, 2, ".", "'") ?> + | + += number_format($sumRow, 2, ".", "'") ?> | +|||||||||
| + Valore vendite consuntivo (= $subrepo["um_prod"] ?>) = $repo["descrizione"] ?> | - -- = number_format($sumRow, 2, ".", "'") ?> - | -|||||||||||
| - Differenza valore (= $subrepo["um_prod"] ?>) = $repo["descrizione"] ?> - | - -- = number_format($value, 2, ".", "'") ?> + + | + = number_format($value, 2, ".", "'") ?> + | + ++ = number_format($sumRow, 2, ".", "'") ?> | - -= number_format($sumRow, 2, ".", "'") ?> | -||||||||
| - Standard produttivo (= $subrepo["um_prod"] ?>) = $repo["descrizione"] ?> - | +||||||||||||
| + Differenza valore (= $subrepo["um_prod"] ?>) = $repo["descrizione"] ?> + | + ++ = number_format($value, 2, ".", "'") ?> + | + += number_format($sumRow, 2, ".", "'") ?> | +||||||||||
| + Standard produttivo (= $subrepo["um_prod"] ?>) = $repo["descrizione"] ?> + | + += number_format($value, 2, ".", "'") ?> | + += number_format($sumRow, 2, ".", "'") ?> | +||||||||||
| + Rapporto Consuntivo / Standard (= $subrepo["um_prod"] ?>) = $repo["descrizione"] ?> + | + += number_format($value, 2, ".", "'") ?> | + += number_format($sumRow, 2, ".", "'") ?> | += number_format($value, 2, ".", "'") ?> | -= number_format($sumRow, 2, ".", "'") ?> | - -||||||||
| - Rapporto Consuntivo / Standard (= $subrepo["um_prod"] ?>) = $repo["descrizione"] ?> - | - -= number_format($value, 2, ".", "'") ?> | -= number_format($sumRow, 2, ".", "'") ?> | -||||||||||
| - = $repo["descrizione"] == "CASSIERA" ? "Q.tà prevista" : "Valore vendite a budget" ?> - (= $repo["um"] ?>) = $repo["descrizione"] ?> - | - -= number_format($value, 2, ".", "'") ?> | -= number_format($sumRow, 2, ".", "'") ?> | -||||||||||
| - = $repo["descrizione"] == "CASSIERA" ? "Q.tà prevista" : "Valore vendite consuntivo" ?> - (= $repo["um"] ?>) = $repo["descrizione"] ?> - | - -= number_format($value, 2, ".", "'") ?> | -= number_format($sumRow, 2, ".", "'") ?> | -||||||||||
| - Differenza = $repo["descrizione"] == "CASSIERA" ? "q.tà" : "valore" ?> (= $repo["um"] ?>) = $repo["descrizione"] ?> - | - -= number_format($value, 2, ".", "'") ?> | -= number_format($sumRow, 2, ".", "'") ?> | -||||||||||
| Standard produttivo (= $repo["um_prod"] ?>) = $repo["descrizione"] ?> | - -= number_format($value, 2, ".", "'") ?> | -= number_format($sumRow, 2, ".", "'") ?> | -||||||||||
| - Rapporto Consuntivo / Standard (= $repo["um_prod"] ?>) = $repo["descrizione"] ?> - | - -= number_format($value, 2, ".", "'") ?> | -= number_format($sumRow, 2, ".", "'") ?> | -||||||||||
| Rapporto Consuntivo / Standard (generale) = $repo["descrizione"] ?> | ++ = $repo["descrizione"] == "CASSIERA" ? "Q.tà prevista" : "Valore vendite a budget" ?> + (= $repo["um"] ?>) = $repo["descrizione"] ?> + | + += number_format($value, 2, ".", "'") ?> | + += number_format($sumRow, 2, ".", "'") ?> | +|||||||||
| + = $repo["descrizione"] == "CASSIERA" ? "Q.tà prevista" : "Valore vendite consuntivo" ?> + (= $repo["um"] ?>) = $repo["descrizione"] ?> + | + += number_format($value, 2, ".", "'") ?> | + += number_format($sumRow, 2, ".", "'") ?> | +||||||||||
| + Differenza = $repo["descrizione"] == "CASSIERA" ? "q.tà" : "valore" ?> + (= $repo["um"] ?>) = $repo["descrizione"] ?> + | + += number_format($value, 2, ".", "'") ?> | + += number_format($sumRow, 2, ".", "'") ?> | +||||||||||
| + Standard produttivo (= $repo["um_prod"] ?>) = $repo["descrizione"] ?> + | + += number_format($value, 2, ".", "'") ?> | + += number_format($sumRow, 2, ".", "'") ?> | +||||||||||
| + Rapporto Consuntivo / Standard (= $repo["um_prod"] ?>) = $repo["descrizione"] ?> + | -= number_format($value, 2, ".", "'") ?> | += number_format($value, 2, ".", "'") ?> | += number_format($sumRow, 2, ".", "'") ?> | |||||||||
| + Rapporto Consuntivo / Standard (generale) = $repo["descrizione"] ?> + | + += number_format($value, 2, ".", "'") ?> | + += number_format($sumRow, 2, ".", "'") ?> | +||||||||||
| Ore formazione = $repo["descrizione"] ?> | + ++ " 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, ".", "'") ?>"/> + | + += number_format($sumRow, 2, ".", "'") ?> | +||||||||||
| + | ||||||||||||
| Ore formazione = $repo["descrizione"] ?> | +Minime | -- " - 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, ".", "'") ?>"/> - | -= number_format($sumRow, 2, ".", "'") ?> | + } + + $sumOreMin = $sumRow; + ?> += number_format($sumRow, 2, ".", "'") ?> | ||||||||
| + | Svolto | + += number_format($value, 2, ".", "'") ?> | + += number_format($sumRow, 2, ".", "'") ?> | +|||||||||
| Investimento | + += number_format($value, 2, ".", "'") ?> | + += number_format($sumRow, 2, ".", "'") ?> | +||||||||||
| Formazione | + += number_format($value, 2, ".", "'") ?> | + += number_format($sumRow, 2, ".", "'") ?> | +||||||||||
| + + | = number_format($sumRow - $sumOreMin, 2, ".", "'") ?> | +|||||||||||
| Differenza netta | + += number_format($value, 2, ".", "'") ?> | + += number_format($sumRow, 2, ".", "'") ?> | ++ | |||||||||
| Andamento settimanale consuntivo | + += number_format($value, 2, ".", "'") ?> | + += number_format($prodStdPv, 2, ".", "'") ?> | +||||||||||
| Differenza netta - andamento settimanale | + += number_format($value, 2, ".", "'") ?> | + += number_format($sumRow, 2, ".", "'") ?> | ||||||||||
| Minime | - -= number_format($sumRow, 2, ".", "'") ?> | -|||||||||||
| Svolto | - -= number_format($value, 2, ".", "'") ?> | -= number_format($sumRow, 2, ".", "'") ?> | -||||||||||
| Investimento | - -= number_format($value, 2, ".", "'") ?> | -= number_format($sumRow, 2, ".", "'") ?> | -||||||||||
| Formazione | - -= number_format($value, 2, ".", "'") ?> | -= number_format($sumRow, 2, ".", "'") ?> | -||||||||||
| - - | = number_format($sumRow - $sumOreMin, 2, ".", "'") ?> | -|||||||||||
| Differenza netta | - -= number_format($value, 2, ".", "'") ?> | -= number_format($sumRow, 2, ".", "'") ?> | -- | |||||||||
| Andamento settimanale consuntivo | - -= number_format($value, 2, ".", "'") ?> | - -= number_format($prodStdPv, 2, ".", "'") ?> | - -||||||||||
| Differenza netta - andamento settimanale | - -= number_format($value, 2, ".", "'") ?> | -= number_format($sumRow, 2, ".", "'") ?> | - -||||||||||