[Rilevazioni Anomalie]
- Fix paging - Aggiunto controllo alle relazioni tra le utenti anche per i punti vendita - Ottimizzazione codice (da verificare) [Ordini A Riass] - Pulizia codice
This commit is contained in:
@@ -864,20 +864,24 @@ class OrdiniARiassClie {
|
||||
}
|
||||
|
||||
public static function getListLinee($data) {
|
||||
$Query = new Query;
|
||||
$Query->importSqlFile("list-linee-clie")
|
||||
$query = new Query;
|
||||
$query->importSqlFile("list-linee-clie")
|
||||
->setVar("cod_anag", self::getCodAnagUtente())
|
||||
->setVar("anno_stag", $data["anno_stag"]);
|
||||
$Ret = $Query->toRet()->execute();
|
||||
if ($Ret->is_OK()) {
|
||||
$listLinee = $Ret->get_data();
|
||||
$ret = $query->toRet()->execute();
|
||||
|
||||
if ($ret->is_OK()) {
|
||||
$listLinee = $ret->get_data();
|
||||
|
||||
foreach ($listLinee as $i => $linea) {
|
||||
$listLinee[$i]["flag_reso"] = \boolValue($linea["flag_reso"]);
|
||||
$listLinee[$i]["sconti"] = self::getScontiLinea($linea["cod_line"]);
|
||||
}
|
||||
$Ret->set_data($listLinee);
|
||||
|
||||
$ret->set_data($listLinee);
|
||||
}
|
||||
return $Ret;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getArticoliTema($data) {
|
||||
@@ -919,7 +923,7 @@ class OrdiniARiassClie {
|
||||
$Query->setVar("anno_stag", $data["anno_stag"])
|
||||
->setVar("cod_dgrp_art", $data["cod_dgrp_art"]);
|
||||
|
||||
if (!is_null($data["cod_line"]) && !empty($data["cod_line"])) {
|
||||
if (!empty($data["cod_line"])) {
|
||||
$Query->where("ttb_line.cod_line", $data["cod_line"]);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,10 +105,11 @@ const _ordiniARiassClie_filtroArticoli = {
|
||||
const d = $.Deferred();
|
||||
|
||||
self.resetArticoli()
|
||||
.refreshLinee().always(function () {
|
||||
self.refreshRadioOR(true);
|
||||
d.resolve();
|
||||
});
|
||||
.refreshLinee()
|
||||
.always(function () {
|
||||
self.refreshRadioOR(true);
|
||||
d.resolve();
|
||||
});
|
||||
|
||||
return d;
|
||||
},
|
||||
@@ -210,7 +211,8 @@ const _ordiniARiassClie_filtroArticoli = {
|
||||
},
|
||||
|
||||
getRigaAction: function () {
|
||||
return $("#radio-reso").notExists() ? "O" : (!$("#radio-reso").hasClass("disabled") ? "R" : "O");
|
||||
const $radioReso = $("#radio-reso");
|
||||
return $radioReso.notExists() ? "O" : (!$radioReso.hasClass("disabled") ? "R" : "O");
|
||||
},
|
||||
|
||||
isSelectedReso: function () {
|
||||
@@ -277,9 +279,10 @@ const _ordiniARiassClie_filtroArticoli = {
|
||||
$codLine.append("<option value='" + item.cod_line + "'>" + item.cod_line + " - " + item.descr_linea + "</option>");
|
||||
}
|
||||
|
||||
var flagResoGrpArt = Enumerable.From(arr_linee).Where(function (x) {
|
||||
const flagResoGrpArt = Enumerable.From(arr_linee).Where(function (x) {
|
||||
return x.flag_reso;
|
||||
}).Count() > 0;
|
||||
|
||||
self.refreshRadioOR(flagResoGrpArt);
|
||||
|
||||
if (arr_linee.length === 1) {
|
||||
|
||||
@@ -19,80 +19,57 @@ class RilevazioniSteup {
|
||||
}
|
||||
|
||||
public static function getListIspezioni($filter = array()) {
|
||||
$Query = new Query;
|
||||
$Query->importSqlFile("list-ispezioni");
|
||||
if (User::is_puntoVendita()) {
|
||||
$Query->where("user_name", User::get_current_username());
|
||||
$Query->where("cod_mdep", User::get_current_userCodMdep());
|
||||
$Query->whereNot("activity_result_id", null);
|
||||
$pageNum = array_get($_GET, "pag", 1);
|
||||
$pageSize = 10;
|
||||
|
||||
$query = new Query;
|
||||
$query->importSqlFile("list-ispezioni");
|
||||
$isPuntoVendita = User::is_puntoVendita();
|
||||
|
||||
if ($isPuntoVendita) {
|
||||
$query->whereNot("activity_result_id", null)
|
||||
->where("user_name", User::get_current_username())
|
||||
->where("cod_mdep", User::get_current_userCodMdep())
|
||||
->where("t.user_creator in (select user_name2 from winact.dbo.srl_user where user_name1 = '" . User::get_current_username() . "')");
|
||||
} else {
|
||||
if (array_key_exists("pv", $filter) && !is_null($filter["pv"])) {
|
||||
$Query->where("cod_mdep", $filter["pv"]);
|
||||
}
|
||||
if (User::is_rilevatore() || User::is_tecnico()) {
|
||||
$Query->where("user_creator", User::get_current_username());
|
||||
} else if (User::is_utenteAziendale()) {
|
||||
$Query->where("user_creator in (select user_name2 from srl_user where user_name1 = '" . User::get_current_username() . "')");
|
||||
$query->where("cod_mdep", $filter["pv"]);
|
||||
}
|
||||
|
||||
if (User::is_rilevatore() || User::is_tecnico()) {
|
||||
$query->where("user_creator", User::get_current_username());
|
||||
} else if (User::is_utenteAziendale()) {
|
||||
$query->where("user_creator in (select user_name2 from winact.dbo.srl_user where user_name1 = '" . User::get_current_username() . "')");
|
||||
}
|
||||
}
|
||||
|
||||
$activityId = array_get($filter, "activityId");
|
||||
|
||||
if (array_key_exists("activityId", $filter)) {
|
||||
$Query->where("activity_id", $filter["activityId"]);
|
||||
if ($activityId) {
|
||||
$activityId = is_array($activityId) ? implode(", ", reset($activityId)) : $activityId;
|
||||
$query->where("activity_id", $activityId);
|
||||
}
|
||||
|
||||
if (array_key_exists("data", $filter) && !is_null($filter["data"])) {
|
||||
$Query->whereDate("data_ispezione", $filter["data"]);
|
||||
$query->whereDate("data_ispezione", $filter["data"]);
|
||||
}
|
||||
|
||||
$groupByPvData = User::is_puntoVendita();
|
||||
//$groupByPvData = false;
|
||||
if (array_key_exists("pagination", $filter) && $filter["pagination"]) {
|
||||
$pagination = new Pagination;
|
||||
$pagination
|
||||
->newMode()
|
||||
->query($Query)
|
||||
->passo(10)
|
||||
->orderBy(array("effective_time" => "DESC"));
|
||||
$Ret = $pagination->execute();
|
||||
$ret = $query->orderBy("effective_time DESC")->toRet()->execute();
|
||||
|
||||
if ($Ret->is_OK()) {
|
||||
if ($groupByPvData) {
|
||||
$arr_ispezioni = self::groupBy_pv_data($Ret->get_data());
|
||||
$Query = new Query;
|
||||
$Query->importSqlFile("list-ispezioni")
|
||||
->where("user_name", User::get_current_username());
|
||||
|
||||
$arr_dataIspezione = array_values(from($arr_ispezioni)
|
||||
->distinct(function ($x) {
|
||||
return $x["data_ispezione"];
|
||||
})
|
||||
->select(function ($x) {
|
||||
return $x["data_ispezione"];
|
||||
})
|
||||
->toArray());
|
||||
if (count($arr_dataIspezione) > 0) {
|
||||
$Query->whereDate("data_ispezione", $arr_dataIspezione);
|
||||
}
|
||||
|
||||
$Ret = $Query->orderBy("effective_time DESC")->toRet()->execute();
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret->set("pagination", $pagination);
|
||||
}
|
||||
}
|
||||
if ($ret->is_OK()) {
|
||||
if (array_key_exists("pagination", $filter) && $filter["pagination"] && $isPuntoVendita) {
|
||||
$arr_ispezioni = self::groupBy_pv_data($ret->get_data());
|
||||
} else {
|
||||
$arr_ispezioni = $ret->get_data();
|
||||
}
|
||||
} else {
|
||||
$Ret = $Query->orderBy("effective_time DESC")->toRet()->execute();
|
||||
}
|
||||
|
||||
if ($Ret->is_OK()) {
|
||||
$arr_ispezioni = $Ret->get_data();
|
||||
foreach ($arr_ispezioni as $i => $item) {
|
||||
$Query = new Query;
|
||||
$Query->importSqlFile("list-entriesIspezione")
|
||||
$query = new Query;
|
||||
$query->importSqlFile("list-entriesIspezione")
|
||||
->where("parent_activity_id", $item["activity_id"]);
|
||||
$Ret2 = $Query->toRet()->execute();
|
||||
|
||||
$Ret2 = $query->toRet()->execute();
|
||||
|
||||
if ($Ret2->is_OK()) {
|
||||
$retData = $Ret2->get_data();
|
||||
$arr_entries = from($retData)->groupBy(function ($x) {
|
||||
@@ -102,9 +79,11 @@ class RilevazioniSteup {
|
||||
$arr_ispezioni[$i]["is_completed"] = !is_null($item["activity_result_id"]);
|
||||
|
||||
$hasPunteggi = false;
|
||||
|
||||
if ($arr_ispezioni[$i]["is_completed"]) {
|
||||
$hasPunteggi = true;
|
||||
if (!User::is_puntoVendita()) {
|
||||
|
||||
if (!$isPuntoVendita) {
|
||||
foreach ($retData as $entry) {
|
||||
if (is_null($entry["indice_gradimento"])) {
|
||||
$hasPunteggi = false;
|
||||
@@ -112,25 +91,35 @@ class RilevazioniSteup {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$arr_ispezioni[$i]["has_punteggi"] = $hasPunteggi;
|
||||
} else {
|
||||
$Ret = $Ret2;
|
||||
$ret = $Ret2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($groupByPvData) { // raggruppa x stessa data, stesso pv
|
||||
if ($isPuntoVendita) { // raggruppa x stessa data, stesso pv
|
||||
$arr_ispezioni = self::groupBy_pv_data($arr_ispezioni);
|
||||
} else {
|
||||
foreach ($arr_ispezioni as $i => $item) {
|
||||
$arr_ispezioni[$i]["activity_id"] = array($arr_ispezioni[$i]["activity_id"]);
|
||||
$arr_ispezioni[$i]["activity_id"] = array($item["activity_id"]);
|
||||
}
|
||||
}
|
||||
|
||||
$Ret->set_data($arr_ispezioni);
|
||||
$ret->set_data(array_slice($arr_ispezioni, ($pageNum - 1) * $pageSize, $pageSize));
|
||||
|
||||
$pagination = new Pagination;
|
||||
$pagination
|
||||
->newMode()
|
||||
->setResultsCount(count($arr_ispezioni))
|
||||
->passo($pageSize)
|
||||
->orderBy(array("effective_time" => "DESC"));
|
||||
|
||||
$ret->set("pagination", $pagination);
|
||||
}
|
||||
|
||||
return $Ret;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function groupBy_pv_data($arr_ispezioni) {
|
||||
@@ -153,7 +142,9 @@ class RilevazioniSteup {
|
||||
return $x[0];
|
||||
})
|
||||
->toArrayDeep());
|
||||
|
||||
$arr_appoggio2 = array();
|
||||
|
||||
foreach ($arr_appoggio as $i => $arr_appoggioItem) {
|
||||
foreach ($arr_appoggioItem as $ispezione) {
|
||||
if (!isset($arr_appoggio2[$i])) {
|
||||
@@ -167,6 +158,7 @@ class RilevazioniSteup {
|
||||
"list-entries" => array()
|
||||
));
|
||||
}
|
||||
|
||||
if (is_null($arr_appoggio2[$i]["effective_time"]) || $arr_appoggio2[$i]["effective_time"] > $ispezione["effective_time"]) {
|
||||
$arr_appoggio2[$i]["effective_time"] = $ispezione["effective_time"];
|
||||
}
|
||||
@@ -178,6 +170,7 @@ class RilevazioniSteup {
|
||||
}
|
||||
|
||||
$arr_appoggio2[$i]["activity_id"][] = $ispezione["activity_id"];
|
||||
|
||||
if (!in_array($ispezione["user_creator"], $arr_appoggio2[$i]["user_creator"])) {
|
||||
$arr_appoggio2[$i]["user_creator"][] = $ispezione["user_creator"];
|
||||
}
|
||||
@@ -189,20 +182,23 @@ class RilevazioniSteup {
|
||||
if (isset($ispezione["count-entries"])) {
|
||||
$arr_appoggio2[$i]["count-entries"] += $ispezione["count-entries"];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$arr_appoggio2[$i]["list-entries"] = array_values(from($arr_appoggio2[$i]["list-entries"])->orderBy(function ($x) {
|
||||
return $x["effective_time"];
|
||||
})->toArray());
|
||||
|
||||
asort($arr_appoggio2[$i]["user_creator"]);
|
||||
asort($arr_appoggio2[$i]["activity_id"]);
|
||||
}
|
||||
|
||||
return $arr_appoggio2;
|
||||
}
|
||||
|
||||
public static function get_ispezione($arr_idIspezione) {
|
||||
$filter = array("activityId" => $arr_idIspezione);
|
||||
$Ret = self::getListIspezioni($filter);
|
||||
|
||||
if ($Ret->is_OK()) {
|
||||
$retData = $Ret->get_data();
|
||||
if (count($retData) > 0) {
|
||||
|
||||
@@ -31,18 +31,11 @@ if ($Ret->is_OK()) {
|
||||
// })->toArray());
|
||||
// }
|
||||
|
||||
/* ?>
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-md-10 col-md-offset-1 mt-10 mb-10">
|
||||
<h2 class="text-info">Ispezioni registrate</h2>
|
||||
</div>
|
||||
</div><?*/
|
||||
|
||||
if ($issetFilter || count($arr_ispezioni) > 0) {
|
||||
?>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="row no-gutters">
|
||||
<?php if (!User::is_puntoVendita()) { ?>
|
||||
<div class="col-xs-3 col-md-3 col-md-offset-1">
|
||||
<?php
|
||||
@@ -73,20 +66,16 @@ if ($Ret->is_OK()) {
|
||||
|
||||
if (count($arr_ispezioni) > 0) {
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="row no-gutters">
|
||||
<div class="col-xs-12 col-md-12">
|
||||
<table id="list-ispezioni" class="table table-striped table-hover mt-10">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Data</th>
|
||||
<?php
|
||||
if (!User::is_rilevatore()) {
|
||||
?>
|
||||
<?php if (!User::is_rilevatore()) { ?>
|
||||
<th>Rilevatore</th>
|
||||
<?php
|
||||
}
|
||||
if (!User::is_puntoVendita()) {
|
||||
?>
|
||||
<?php } ?>
|
||||
<?php if (!User::is_puntoVendita()) { ?>
|
||||
<th>Negozio</th>
|
||||
<th>Durata <small class="text-muted">H:M:S</small></th>
|
||||
<?php } ?>
|
||||
@@ -106,13 +95,11 @@ if ($Ret->is_OK()) {
|
||||
<?= strftime(Format::strftimeDMY, $item["effective_time"]) ?><br/>
|
||||
<small class="text-muted"><?= strftime(Format::strftimeHM, $item["effective_time"]) ?></small>
|
||||
</td>
|
||||
<?php
|
||||
if (!User::is_rilevatore()) {
|
||||
?>
|
||||
<td><?= is_array($item["user_creator"]) ? implode(", ", $item["user_creator"]) : $item["user_creator"]; ?></td><?php
|
||||
}
|
||||
if (!User::is_puntoVendita()) {
|
||||
?>
|
||||
<?php if (!User::is_rilevatore()) {
|
||||
$userCreators = reset($item["user_creator"]) ?>
|
||||
<td><?= is_array($userCreators) ? implode(", ", $userCreators) : $userCreators; ?></td>
|
||||
<?php } ?>
|
||||
<?php if (!User::is_puntoVendita()) { ?>
|
||||
<td class="text-left">
|
||||
<?= $item["user_name"] ?><br/>
|
||||
<small class="text-muted"><?= htmlentities($item["descr_deposito"]) ?></small>
|
||||
@@ -174,10 +161,8 @@ if ($Ret->is_OK()) {
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class=" mt-20">
|
||||
<?php
|
||||
$pagination->display();
|
||||
?>
|
||||
<div class="mt-20">
|
||||
<?php $pagination->display(); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user