Corretto salvataggio delle righe in accettazione
This commit is contained in:
@@ -144,13 +144,14 @@ class AccettazioneFloro {
|
||||
->set("numOrd", $key["num_ord"])
|
||||
->set("flagEvasoForzato", $data["flag_evaso_forzato"]);
|
||||
|
||||
$countRigheDaSalvare =
|
||||
$righeDaSalvare =
|
||||
\YaLinqo\Enumerable::from($data["rows"])
|
||||
->count(function ($row) {
|
||||
->where(function ($row) {
|
||||
return $row["basi"] > 0 || $row["pezzi"] > 0;
|
||||
});
|
||||
})
|
||||
->toArray();
|
||||
|
||||
if ($countRigheDaSalvare > 0) {
|
||||
if (count($righeDaSalvare) > 0) {
|
||||
$MtbColt = new EntityItem("mtb_colt");
|
||||
$MtbColt->insert()
|
||||
->setDate("dataCollo", \Utility\Date::getToday())
|
||||
@@ -161,7 +162,22 @@ class AccettazioneFloro {
|
||||
->set("codVdes", $ordine["cod_vdes"])
|
||||
->set("codMdep", $ordine["cod_mdep"]);
|
||||
|
||||
foreach ($ordine["rows"] as $rigaOrdine) {
|
||||
$ordineRowsDaSalvare = array_filter(
|
||||
$ordine["rows"],
|
||||
function ($row) use ($righeDaSalvare) {
|
||||
return in_array(
|
||||
$row["riga_ord"],
|
||||
array_map(
|
||||
function ($rigaDaSalvare) {
|
||||
return $rigaDaSalvare["riga_ord"];
|
||||
},
|
||||
$righeDaSalvare
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
foreach ($ordineRowsDaSalvare as $rigaOrdine) {
|
||||
$rigaOrd = $rigaOrdine["riga_ord"];
|
||||
$hasPartitaMagDefault = !is_null($rigaOrdine["partita_mag_default"]);
|
||||
|
||||
@@ -237,16 +253,19 @@ class AccettazioneFloro {
|
||||
|
||||
if ($Ret->is_OK()) {
|
||||
$result = $EntityList->get_result("mtb_colt", 0);
|
||||
$chiaveCollo = array(
|
||||
"gestione" => $result["gestione"],
|
||||
"data_collo" => \Utility\Date::strtotime($result["dataCollo"], \Format::strtotimeDMYHMS),
|
||||
"num_collo" => $result["numCollo"],
|
||||
"ser_collo" => $result["serCollo"]
|
||||
);
|
||||
|
||||
$Ret = self::getRigheCollo($chiaveCollo);
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret->set_data(array("key" => $chiaveCollo, "righe" => $Ret->get_data()));
|
||||
if (!is_null($result)) {
|
||||
$chiaveCollo = array(
|
||||
"gestione" => $result["gestione"],
|
||||
"data_collo" => \Utility\Date::strtotime($result["dataCollo"], \Format::strtotimeDMYHMS),
|
||||
"num_collo" => $result["numCollo"],
|
||||
"ser_collo" => $result["serCollo"]
|
||||
);
|
||||
|
||||
$Ret = self::getRigheCollo($chiaveCollo);
|
||||
if ($Ret->is_OK()) {
|
||||
$Ret->set_data(array("key" => $chiaveCollo, "righe" => $Ret->get_data()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,10 +98,16 @@ var _accettazioneFloro = {
|
||||
.onSuccess(function (ret) {
|
||||
$listRigheOrd.hide();
|
||||
|
||||
self.colKey = ret.returnData.key;
|
||||
self.showRigheCol(ret.returnData.righe);
|
||||
if (ret.returnData.key && ret.returnData.righe) {
|
||||
self.colKey = ret.returnData.key;
|
||||
self.showRigheCol(ret.returnData.righe);
|
||||
|
||||
new Toast().success("È stato creato il collo num. " + self.colKey.num_collo, "Accettazione completata");
|
||||
new Toast().success("È stato creato il collo num. " + self.colKey.num_collo, "Accettazione completata");
|
||||
} else {
|
||||
$listOrdini.show();
|
||||
|
||||
location.reload();
|
||||
}
|
||||
})
|
||||
.execute();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user