Finish Carelli_OrdiniAcquisto_PopupSelezionaOrdini
This commit is contained in:
@@ -360,7 +360,50 @@ class OrdiniA {
|
||||
->setDateVar("data_ord", $key["data_ord"])
|
||||
->setVar("listino", $key["listino"])
|
||||
->setVar("num_ord", $key["num_ord"])
|
||||
->setVar("cod_mdep", User::get_current_userCodMdep());
|
||||
->setVar("cod_mdep", User::get_current_userCodMdep())
|
||||
->setVar("note", $key["note"])
|
||||
->setVar("serie", $key["serie"]);
|
||||
|
||||
$ret = $query->toRet()->execute();
|
||||
|
||||
if ($ret->is_OK()) {
|
||||
$righe = $ret->get_data();
|
||||
|
||||
$hasDuplicati = count($righe) > 1;
|
||||
|
||||
if ($hasDuplicati) {
|
||||
$data = [
|
||||
"hasDuplicati" => true,
|
||||
"righe" => $righe,
|
||||
];
|
||||
|
||||
$ret->set_data($data);
|
||||
} else {
|
||||
$data = [
|
||||
"righe" => $righe,
|
||||
"key" => $key,
|
||||
];
|
||||
|
||||
self::accorpaOrdini($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getArticoliDaAccorpare($data) {
|
||||
$key = $data["key"];
|
||||
$righe = $data["righe"];
|
||||
$numOrds = array_column($righe, "num_ord");
|
||||
|
||||
$query = new Query();
|
||||
$query
|
||||
->importSqlFile("getArticoliDaAccorpare")
|
||||
->setDateVar("data_ord", $key["data_ord"])
|
||||
->setVar("listino", $key["listino"])
|
||||
->setVar("num_ord", $key["num_ord"])
|
||||
->setVar("cod_mdep", User::get_current_userCodMdep())
|
||||
->setVar("num_ords", implode(', ', $numOrds));
|
||||
|
||||
$ret = $query->toRet()->execute();
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
<table id="tableArticoliDuplicati" class="table table-condensed table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="">Articolo</th>
|
||||
<th>Num. Ord.</th>
|
||||
<th>Articolo</th>
|
||||
<th>Qta ordinata</th>
|
||||
<th>UM</th>
|
||||
<th>CT</th>
|
||||
@@ -12,7 +13,11 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
<% _.each(articoli, function(articolo){ %>
|
||||
<tr class="<%= articolo.id_riga_art === 1 ? 'daNonAnnullare' : '' %>">
|
||||
<tr class="<%= articolo.id_riga_art === 1 ? 'daNonAnnullare' : '' %>"
|
||||
data-num_ord="<%= articolo.num_ord %>">
|
||||
<td class="text-center numOrd">
|
||||
<%= articolo.num_ord %>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<small class="text-muted codMart"><%= articolo.cod_mart %></small>
|
||||
<%= articolo.descrizione %>
|
||||
@@ -56,7 +61,7 @@
|
||||
|
||||
$tr.find('td.qtaOrd > input').each(function () {
|
||||
const content = $(this).val();
|
||||
|
||||
|
||||
$(this).html(content);
|
||||
$(this).contents().unwrap();
|
||||
});
|
||||
|
||||
47
public_html/gest-lib/ordini_a/html/ordiniDuplicati.ejs
Normal file
47
public_html/gest-lib/ordini_a/html/ordiniDuplicati.ejs
Normal file
@@ -0,0 +1,47 @@
|
||||
<div class="row-fluid">
|
||||
<div>
|
||||
Sono presenti più ordini del fornitore <%= key.listino %> in data
|
||||
<%= key.data_ord.unixtime_format("DD/MM/YYYY") %>,
|
||||
selezionare eventualmente gli ordini da accorpare e proseguire
|
||||
</div>
|
||||
<br>
|
||||
<div class="span">
|
||||
<table id="tableOrdiniDuplicati" class="table table-condensed table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Data Ord.</th>
|
||||
<th>Num. Ord.</th>
|
||||
<th>Note</th>
|
||||
<th>Listino</th>
|
||||
<th>Descr. Gruppi Merc.</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% _.each(ordini, function(ordine){ %>
|
||||
<% const mainOrder = ordine.num_ord === key.num_ord; %>
|
||||
<tr style="<%= mainOrder && 'background-color: #cbfacb' %>">
|
||||
<td class="text-center">
|
||||
<input type="checkbox" checked <%= mainOrder && "disabled" %>>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<%= ordine.data_ord.unixtime_format("DD/MM/YYYY") %>
|
||||
</td>
|
||||
<td class="text-center numOrd">
|
||||
<%= ordine.num_ord %>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<%= ordine.note %>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<%= ordine.listino %>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<%= ordine.gruppi_merc %>
|
||||
</td>
|
||||
</tr>
|
||||
<% }) %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -44,6 +44,9 @@ if (isset($_POST["upload_ordine"])) {
|
||||
} else if (isset($_POST["getOrdiniDaAccorpare"])) {
|
||||
$data = Utility::sanitizeB64JSON_parse($_POST["getOrdiniDaAccorpare"]);
|
||||
OrdiniA::getOrdiniDaAccorpare($data)->display();
|
||||
} else if (isset($_POST["getArticoliDaAccorpare"])) {
|
||||
$data = Utility::sanitizeB64JSON_parse($_POST["getArticoliDaAccorpare"]);
|
||||
OrdiniA::getArticoliDaAccorpare($data)->display();
|
||||
} else if (isset($_POST["accorpaOrdini"])) {
|
||||
$data = Utility::sanitizeB64JSON_parse($_POST["accorpaOrdini"]);
|
||||
OrdiniA::accorpaOrdini($data)->display();
|
||||
|
||||
@@ -50,7 +50,7 @@ if ($Ret->is_OK()) {
|
||||
if (count($arr_ordini) > 0) {
|
||||
include "panel-filter.php";
|
||||
?>
|
||||
<div class="col-md-12 mt-20 max-height-60vh">
|
||||
<div class="col-md-12 mt-20 max-height-70vh">
|
||||
<table id="list_ord" class="table table-striped table-hover table-condensed table-text-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -143,7 +143,7 @@ if ($Ret->is_OK()) {
|
||||
}
|
||||
}
|
||||
|
||||
$orderKey = array("data_ord" => $dataOrd, "gestione" => $gestione, "num_ord" => $numOrd, "rag_soc" => $ragSoc, "cod_anag" => $ordine["cod_anag"], "cod_vdes" => $ordine["cod_vdes"], "listino" => $listino, "flagCountOrdiniNonEsportati" => $flagCountOrdiniNonEsportati, "flagAccorpaOrdini" => $flagAccorpaOrdini);
|
||||
$orderKey = array("data_ord" => $dataOrd, "gestione" => $gestione, "num_ord" => $numOrd, "rag_soc" => $ragSoc, "cod_anag" => $ordine["cod_anag"], "cod_vdes" => $ordine["cod_vdes"], "listino" => $listino, "note" => $ordine["note"], "serie" => $ordine["serie"], "flagCountOrdiniNonEsportati" => $flagCountOrdiniNonEsportati, "flagAccorpaOrdini" => $flagAccorpaOrdini);
|
||||
?>
|
||||
<tr class="<?= (($rowFocused == B64JSON_stringify($orderKey)) ? " warning" : "") . ($flagPlus ? " plus" : "") ?>"
|
||||
data-data_cons="<?= $dataCons ?>" data-check_cartoni="<?= $check_cartoni ?>"
|
||||
@@ -165,12 +165,14 @@ if ($Ret->is_OK()) {
|
||||
</span>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="text-center"><?= $numOrd . ($flagTipoOrdine == "R" ? " <span title='Prenotazione'>*</span>" : "") ?>
|
||||
<br/>
|
||||
<td class="text-center">
|
||||
<?= $numOrd . ($flagTipoOrdine == "R" ? " <span title='Prenotazione'>*</span>" : "") ?>
|
||||
</td>
|
||||
<td class="text-center"><?= Utility\Date::format($dataOrd, Format::strftimeDMY) ?><br/>
|
||||
<td class="text-center">
|
||||
<?= Utility\Date::format($dataOrd, Format::strftimeDMY) ?>
|
||||
</td>
|
||||
<td class="text-center"><?= Utility\Date::format($dataCons, Format::strftimeDMY) ?><br/>
|
||||
<td class="text-center">
|
||||
<?= Utility\Date::format($dataCons, Format::strftimeDMY) ?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span class="<?= !$flagEsportato ? "dataExport_datePart" : "" ?>"><?= Utility\Date::format($dataEsportazione, Format::strftimeDMy) ?></span><br/>
|
||||
@@ -210,16 +212,16 @@ if ($Ret->is_OK()) {
|
||||
</div>
|
||||
<div class="emailbox input-group col-xs-12" style="display: none;">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default btn-sm emailcancel" type="button">
|
||||
<i class="fa fa-times-circle"></i>
|
||||
<button class="btn btn-danger btn-sm icbtn emailcancel" type="button">
|
||||
<i class="fa fa-fw fa-times"></i>
|
||||
</button>
|
||||
</span>
|
||||
<input type="email" value="<?= $eMail ?>"
|
||||
class="form-control input-sm" <?= !is_null(nullIfBlank($eMail)) ? "readonly" : "" ?>
|
||||
style="font-size: 11px;"/>
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-success btn-sm emailok" type="button">
|
||||
<i class="fa fa-arrow-right"></i>
|
||||
<button class="btn btn-success btn-sm icbtn emailok" type="button">
|
||||
<i class="fa fa-fw fa-arrow-right"></i>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -2,69 +2,73 @@ $(function () {
|
||||
const module = new Module();
|
||||
|
||||
module.onLoad(function () {
|
||||
$(".bt_viewOrd").on("click", function () {
|
||||
const $tr = $(this).closest("tr[data-order_key]");
|
||||
const key = $tr.getDataAttr("order_key");
|
||||
$(".bt_viewOrd").on("click", function () {
|
||||
const $tr = $(this).closest("tr[data-order_key]");
|
||||
const key = $tr.getDataAttr("order_key");
|
||||
|
||||
_ordiniA.popup.open(key);
|
||||
});
|
||||
_ordiniA.popup.open(key);
|
||||
});
|
||||
|
||||
$(document).on("click", ".bt_pdfOrd", function (e) {
|
||||
const $bt = $(this);
|
||||
const $tr = $bt.closest("tr[data-order_key]");
|
||||
const ajax = new Ajax();
|
||||
$(document).on("click", ".bt_pdfOrd", function (e) {
|
||||
const $bt = $(this);
|
||||
const $tr = $bt.closest("tr[data-order_key]");
|
||||
const ajax = new Ajax();
|
||||
|
||||
ajax.get("getPdfOrdine")
|
||||
.data({key: $tr.getDataAttr("order_key")})
|
||||
.$toDisable($("#cod_alis"))
|
||||
.$button($bt)
|
||||
.noticeAsModal()
|
||||
.onSuccess({downloadFile: true})
|
||||
.execute();
|
||||
ajax.get("getPdfOrdine")
|
||||
.data({key: $tr.getDataAttr("order_key")})
|
||||
.$toDisable($("#cod_alis"))
|
||||
.$button($bt)
|
||||
.noticeAsModal()
|
||||
.onSuccess({downloadFile: true})
|
||||
.execute();
|
||||
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
e.preventDefault();
|
||||
return false;
|
||||
});
|
||||
|
||||
$(".bt_annulla").on("click", function () {
|
||||
const $bt = $(this);
|
||||
const $tr = $bt.closest("tr[data-order_key]");
|
||||
const key = $tr.getDataAttr("order_key");
|
||||
const ajax = new Ajax();
|
||||
$(".bt_annulla").on("click", function () {
|
||||
const $bt = $(this);
|
||||
const $tr = $bt.closest("tr[data-order_key]");
|
||||
const key = $tr.getDataAttr("order_key");
|
||||
const ajax = new Ajax();
|
||||
|
||||
ajax.post("cancel")
|
||||
.data({key: key})
|
||||
.confirmModal({message: "Confermi l'annullamento dell'ordine n. " + key.num_ord + "?"})
|
||||
.$button($bt)
|
||||
.noticeAsModal()
|
||||
.$toDisable($tr)
|
||||
.onSuccess({
|
||||
toast: {message: "L'ordine n. " + key.num_ord + " è stato annullato"},
|
||||
callback: function () {
|
||||
$tr.slideUp(500, function () {
|
||||
$tr.remove();
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
})
|
||||
.execute();
|
||||
});
|
||||
ajax.post("cancel")
|
||||
.data({key: key})
|
||||
.confirmModal({message: "Confermi l'annullamento dell'ordine n. " + key.num_ord + "?"})
|
||||
.$button($bt)
|
||||
.noticeAsModal()
|
||||
.$toDisable($tr)
|
||||
.onSuccess({
|
||||
toast: {message: "L'ordine n. " + key.num_ord + " è stato annullato"},
|
||||
callback: function () {
|
||||
$tr.slideUp(500, function () {
|
||||
$tr.remove();
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
})
|
||||
.execute();
|
||||
});
|
||||
|
||||
$(".emailbox > input[type='email']").on("enterKey", function () {
|
||||
$(this).closest("td").find(".emailbox .emailok").trigger("click");
|
||||
});
|
||||
$(".emailbox > input[type='email']").on("enterKey", function () {
|
||||
$(this).closest("td").find(".emailbox .emailok").trigger("click");
|
||||
});
|
||||
|
||||
$(".bt_sendMail").on("click", function () {
|
||||
const $btn = $(this);
|
||||
const $tr = $btn.closest("tr[data-order_key]");
|
||||
const key = $tr.getDataAttr("order_key");
|
||||
$(".bt_sendMail").on("click", function () {
|
||||
const $btn = $(this);
|
||||
const $tr = $btn.closest("tr[data-order_key]");
|
||||
const key = $tr.getDataAttr("order_key");
|
||||
const action = _.bind(activeEmailInput, this, $btn);
|
||||
|
||||
if (key.flagAccorpaOrdini && key.flagCountOrdiniNonEsportati) {
|
||||
const message = "Sono presenti più ordini del fornitore " + key.listino + " in data " + key.data_ord.unixtime_format("DD/MM/YYYY") + ", per inviare l'ordine via mail è necessario prima accorpare gli ordini, vuoi procedere?";
|
||||
if (key.flagAccorpaOrdini && key.flagCountOrdiniNonEsportati) {
|
||||
accorpaOrdini($(this), action);
|
||||
} else {
|
||||
action()
|
||||
}
|
||||
});
|
||||
|
||||
accorpaOrdini($(this), message);
|
||||
} else {
|
||||
const $btnGroup = $(this).closest(".btn-group");
|
||||
function activeEmailInput($btn) {
|
||||
const $btnGroup = $btn.closest(".btn-group");
|
||||
const $td = $btnGroup.closest("td");
|
||||
const $emailbox = $td.find(".emailbox");
|
||||
|
||||
@@ -77,56 +81,68 @@ $(function () {
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(".emailcancel").on("click", function () {
|
||||
const $emailbox = $(this).closest(".emailbox");
|
||||
const $td = $emailbox.closest("td");
|
||||
$(".emailcancel").on("click", function () {
|
||||
const $emailbox = $(this).closest(".emailbox");
|
||||
const $td = $emailbox.closest("td");
|
||||
|
||||
$(".btn-group", $td).show();
|
||||
$emailbox.hide();
|
||||
});
|
||||
$(".btn-group", $td).show();
|
||||
$emailbox.hide();
|
||||
});
|
||||
|
||||
$(".emailok").on("click", function () {
|
||||
const $bt = $(this);
|
||||
const $tr = $bt.closest("tr[data-order_key]");
|
||||
const key = $tr.getDataAttr("order_key");
|
||||
const eMail = $tr.find(".emailbox input[type='email']").getValue();
|
||||
$(".emailok").on("click", function () {
|
||||
const $bt = $(this);
|
||||
const $tr = $bt.closest("tr[data-order_key]");
|
||||
const key = $tr.getDataAttr("order_key");
|
||||
const eMail = $tr.find(".emailbox input[type='email']").getValue();
|
||||
|
||||
if (!is_null(eMail)) {
|
||||
const ajax = new Ajax();
|
||||
ajax.get("sendEmailOrdine")
|
||||
.data({key: key, e_mail: eMail})
|
||||
.noticeAsModal()
|
||||
.$button($bt)
|
||||
.$toDisable($tr)
|
||||
.onSuccess({
|
||||
toast: {message: "E-mail inviata al fornitore"},
|
||||
callback: function () {
|
||||
$tr.find(".dataExport_datePart").text(getToday("DD/MM/YY"));
|
||||
$tr.find(".dataExport_timePart").text(getNow("HH:mm"));
|
||||
$tr.find(".emailcancel").trigger("click");
|
||||
}
|
||||
})
|
||||
.execute();
|
||||
} else {
|
||||
const toast = new Toast();
|
||||
if (!is_null(eMail)) {
|
||||
const ajax = new Ajax();
|
||||
ajax.get("sendEmailOrdine")
|
||||
.data({key: key, e_mail: eMail})
|
||||
.noticeAsModal()
|
||||
.$button($bt)
|
||||
.$toDisable($tr)
|
||||
.onSuccess({
|
||||
toast: {message: "E-mail inviata al fornitore"},
|
||||
callback: function () {
|
||||
$tr.find(".dataExport_datePart").text(getToday("DD/MM/YY"));
|
||||
$tr.find(".dataExport_timePart").text(getNow("HH:mm"));
|
||||
$tr.find(".emailcancel").trigger("click");
|
||||
}
|
||||
})
|
||||
.execute();
|
||||
} else {
|
||||
const toast = new Toast();
|
||||
|
||||
toast.warning("Indirizzo e-mail non specificato");
|
||||
}
|
||||
});
|
||||
toast.warning("Indirizzo e-mail non specificato");
|
||||
}
|
||||
});
|
||||
|
||||
$(".bt_export").on("click", function () {
|
||||
const $btn = $(this);
|
||||
const $tr = $btn.closest("tr[data-order_key]");
|
||||
const $btAnnulla = $tr.find(".annulla");
|
||||
const key = $tr.getDataAttr("order_key");
|
||||
$(".bt_export").on("click", async function () {
|
||||
const $btn = $(this);
|
||||
const $tr = $btn.closest("tr[data-order_key]");
|
||||
const key = $tr.getDataAttr("order_key");
|
||||
const action = _.bind(esportaOrdine, this, $btn);
|
||||
|
||||
if (key.flagAccorpaOrdini && key.flagCountOrdiniNonEsportati) {
|
||||
const message = "Sono presenti più ordini del fornitore " + key.listino + " in data " + key.data_ord.unixtime_format("DD/MM/YYYY") + ", per esportare l'ordine è necessario prima accorpare gli ordini, vuoi procedere?";
|
||||
if (key.flagAccorpaOrdini && key.flagCountOrdiniNonEsportati) {
|
||||
accorpaOrdini($btn, action);
|
||||
} else {
|
||||
action();
|
||||
}
|
||||
});
|
||||
|
||||
$(".bt_accorpa").on("click", function () {
|
||||
const $btn = $(this);
|
||||
|
||||
accorpaOrdini($btn);
|
||||
});
|
||||
|
||||
function esportaOrdine($btn) {
|
||||
const $tr = $btn.closest("tr[data-order_key]");
|
||||
const key = $tr.getDataAttr("order_key");
|
||||
const $btAnnulla = $tr.find(".annulla");
|
||||
|
||||
accorpaOrdini($(this), message);
|
||||
} else {
|
||||
const callback = function () {
|
||||
const dataCons = $tr.getIntDataAttr("data_cons");
|
||||
const flagTipoOrdine = $tr.getDataAttr("flag_tipo_ordine");
|
||||
@@ -214,6 +230,7 @@ $(function () {
|
||||
} else if (checkValue.check_promo <= 0) {
|
||||
modalBox.yesNo()
|
||||
.content("Nell'ordine non sono presenti articoli in promozione. Vuoi continuare?")
|
||||
.style("warning")
|
||||
.show()
|
||||
.then(function (ret) {
|
||||
if (ret) {
|
||||
@@ -227,118 +244,187 @@ $(function () {
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(".bt_accorpa").on("click", function () {
|
||||
const $btn = $(this);
|
||||
const $tr = $btn.closest("tr[data-order_key]");
|
||||
const key = $tr.getDataAttr("order_key");
|
||||
const message = "Accorpare gli ordini del fornitore " + key.listino + " in data " + key.data_ord.unixtime_format("DD/MM/YYYY") + "?";
|
||||
async function accorpaOrdini($btn, action) {
|
||||
const $tr = $btn.closest("tr[data-order_key]");
|
||||
const key = $tr.getDataAttr("order_key");
|
||||
const ajax = new Ajax();
|
||||
|
||||
accorpaOrdini($(this), message);
|
||||
});
|
||||
ajax.post("getOrdiniDaAccorpare")
|
||||
.data({key: key})
|
||||
.waitModal("Esportazione ordine")
|
||||
.noticeAsModal()
|
||||
.onSuccess(function (ret) {
|
||||
const retData = ret?.returnData;
|
||||
|
||||
function accorpaOrdini($btn, message) {
|
||||
const $tr = $btn.closest("tr[data-order_key]");
|
||||
const key = $tr.getDataAttr("order_key");
|
||||
const ajax = new Ajax();
|
||||
if (retData?.hasDuplicati) {
|
||||
const modalBox = new ModalBox();
|
||||
const template = _.template(module.get_template("ordiniDuplicati"));
|
||||
|
||||
ajax.post("getOrdiniDaAccorpare")
|
||||
.data({key: key})
|
||||
.confirmModal({message: message})
|
||||
.waitModal("Esportazione ordine")
|
||||
.noticeAsModal()
|
||||
.onSuccess(function (ret) {
|
||||
const retData = ret?.returnData;
|
||||
console.log(retData);
|
||||
modalBox
|
||||
.title("Attenzione Ordini Duplicati");
|
||||
|
||||
if (retData?.hasDuplicati) {
|
||||
const modalBox = new ModalBox();
|
||||
const template = _.template(module.get_template("articoliDuplicati"));
|
||||
|
||||
modalBox
|
||||
.title("Attenzione Articoli Duplicati")
|
||||
.okCancel()
|
||||
.btCancel({size: {sm: 10}})
|
||||
.btOK({
|
||||
text: "Salva",
|
||||
onClick: function (e, $btOk, $div) {
|
||||
const $table = $("#tableArticoliDuplicati");
|
||||
|
||||
$table.find(".save:visible").trigger("click");
|
||||
|
||||
const $trDaNonAnnullare = $table.find("tr.daNonAnnullare");
|
||||
|
||||
_.each($trDaNonAnnullare, function (tr) {
|
||||
const codMart = $(tr).find(".codMart").text();
|
||||
const qtaOrd = $(tr).find(".qtaOrd").text();
|
||||
const righe = retData.righe;
|
||||
const obj = righe.find(riga => riga.cod_mart === codMart && riga.id_riga_art === 1);
|
||||
|
||||
obj.qta_ord = parseInt(qtaOrd);
|
||||
if (action) {
|
||||
modalBox
|
||||
.yesNoCancel()
|
||||
.btNo({
|
||||
text: "Prosegui senza accorpare",
|
||||
onClick: function (e, $btOk, $div) {
|
||||
modalBox.close();
|
||||
action();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
modalBox.yesNo()
|
||||
.btNo({
|
||||
text: "Annulla",
|
||||
});
|
||||
}
|
||||
|
||||
modalBox.btYes({
|
||||
text: "Accorpa selezionati",
|
||||
onClick: function (e, $btOk, $div) {
|
||||
const $table = $("#tableOrdiniDuplicati");
|
||||
const $trUnchecked = $table.find("tr td input:not(:checked)").parents("tr");
|
||||
const righe = retData.righe;
|
||||
|
||||
_.each($trUnchecked, function (tr) {
|
||||
const numOrd = $(tr).find(".numOrd").text();
|
||||
|
||||
console.log(numOrd);
|
||||
|
||||
for (let i = 0; i < righe.length; i++) {
|
||||
if (righe[i].num_ord == numOrd) {
|
||||
righe.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
modalBox.close();
|
||||
|
||||
const data = {
|
||||
"key": key,
|
||||
"righe": retData.righe,
|
||||
"righe": righe,
|
||||
}
|
||||
|
||||
ajax
|
||||
.post("accorpaOrdini")
|
||||
.waitModal()
|
||||
.data(data)
|
||||
.noticeAsToast()
|
||||
.onSuccess(function (ret) {
|
||||
const toast = new Toast();
|
||||
toast.success("L'ordine n. " + key.num_ord + " è stato accorpato");
|
||||
|
||||
location.reload();
|
||||
})
|
||||
.execute();
|
||||
getArticoliDaAccorpare(data);
|
||||
}
|
||||
})
|
||||
.content(template({articoli: retData.righeDuplicate}))
|
||||
.style("warning")
|
||||
.backdropStatic().backhash().xl().okCancel().show();
|
||||
} else {
|
||||
const toast = new Toast();
|
||||
toast.success("L'ordine n. " + key.num_ord + " è stato accorpato");
|
||||
.content(template({ordini: retData.righe, key: key}))
|
||||
.style("warning")
|
||||
.backdropStatic().backhash().xl().show();
|
||||
} else {
|
||||
const toast = new Toast();
|
||||
toast.success("L'ordine n. " + key.num_ord + " è stato accorpato");
|
||||
|
||||
location.reload();
|
||||
}
|
||||
|
||||
})
|
||||
.execute();
|
||||
}
|
||||
|
||||
$("#upload_ordine").on("click", function () {
|
||||
$("input[name='file_orda']").trigger("click");
|
||||
});
|
||||
|
||||
$("input[name='file_orda']").on("change", function () {
|
||||
_ordiniA.uploadFile();
|
||||
});
|
||||
|
||||
$("#btGetXmlGriglia").on("click", function () {
|
||||
const $bt = $(this);
|
||||
const codAlis = $("#cod_alis").getValue();
|
||||
|
||||
if (!is_null(codAlis)) {
|
||||
const ajax = new Ajax();
|
||||
ajax.get("get_xmlGriglia")
|
||||
.data({cod_alis: codAlis})
|
||||
.$button($bt)
|
||||
.noticeAsModal()
|
||||
.onSuccess({downloadString: "OR_4" + codAlis + ".xml"})
|
||||
location.reload();
|
||||
}
|
||||
})
|
||||
.execute();
|
||||
}
|
||||
});
|
||||
|
||||
$("#cod_alis").on("change", function () {
|
||||
$("#btGetXmlGriglia").disabled(is_null($(this).getValue()));
|
||||
});
|
||||
_ordiniA.init(module);
|
||||
}).load();
|
||||
function getArticoliDaAccorpare(data) {
|
||||
const ajax = new Ajax();
|
||||
const key = data.key;
|
||||
|
||||
ajax.post("getArticoliDaAccorpare")
|
||||
.data(data)
|
||||
.waitModal("Esportazione ordine")
|
||||
.noticeAsModal()
|
||||
.onSuccess(function (ret) {
|
||||
const retData = ret?.returnData;
|
||||
console.log(retData);
|
||||
|
||||
if (retData?.hasDuplicati) {
|
||||
const modalBox = new ModalBox();
|
||||
const template = _.template(module.get_template("articoliDuplicati"));
|
||||
|
||||
modalBox
|
||||
.title("Attenzione Articoli Duplicati")
|
||||
.okCancel()
|
||||
.btCancel({size: {sm: 10}})
|
||||
.btOK({
|
||||
text: "Salva",
|
||||
onClick: function (e, $btOk, $div) {
|
||||
const $table = $("#tableArticoliDuplicati");
|
||||
|
||||
$table.find(".save:visible").trigger("click");
|
||||
|
||||
const $trDaNonAnnullare = $table.find("tr.daNonAnnullare");
|
||||
|
||||
_.each($trDaNonAnnullare, function (tr) {
|
||||
const codMart = $(tr).find(".codMart").text();
|
||||
const qtaOrd = $(tr).find(".qtaOrd").text();
|
||||
const righe = retData.righe;
|
||||
const obj = righe.find(riga => riga.cod_mart === codMart && riga.id_riga_art === 1);
|
||||
|
||||
obj.qta_ord = parseInt(qtaOrd);
|
||||
});
|
||||
|
||||
const data = {
|
||||
"key": key,
|
||||
"righe": retData.righe,
|
||||
}
|
||||
|
||||
ajax
|
||||
.post("accorpaOrdini")
|
||||
.waitModal()
|
||||
.data(data)
|
||||
.noticeAsToast()
|
||||
.onSuccess(function (ret) {
|
||||
const toast = new Toast();
|
||||
toast.success("L'ordine n. " + key.num_ord + " è stato accorpato");
|
||||
|
||||
modalBox.close();
|
||||
|
||||
location.reload();
|
||||
})
|
||||
.execute();
|
||||
}
|
||||
})
|
||||
.content(template({articoli: retData.righeDuplicate}))
|
||||
.style("warning")
|
||||
.backdropStatic().backhash().xl().okCancel().show();
|
||||
} else {
|
||||
const toast = new Toast();
|
||||
toast.success("L'ordine n. " + key.num_ord + " è stato accorpato");
|
||||
|
||||
location.reload();
|
||||
}
|
||||
})
|
||||
.execute();
|
||||
}
|
||||
|
||||
$("#upload_ordine").on("click", function () {
|
||||
$("input[name='file_orda']").trigger("click");
|
||||
});
|
||||
|
||||
$("input[name='file_orda']").on("change", function () {
|
||||
_ordiniA.uploadFile();
|
||||
});
|
||||
|
||||
$("#btGetXmlGriglia").on("click", function () {
|
||||
const $bt = $(this);
|
||||
const codAlis = $("#cod_alis").getValue();
|
||||
|
||||
if (!is_null(codAlis)) {
|
||||
const ajax = new Ajax();
|
||||
ajax.get("get_xmlGriglia")
|
||||
.data({cod_alis: codAlis})
|
||||
.$button($bt)
|
||||
.noticeAsModal()
|
||||
.onSuccess({downloadString: "OR_4" + codAlis + ".xml"})
|
||||
.execute();
|
||||
}
|
||||
});
|
||||
|
||||
$("#cod_alis").on("change", function () {
|
||||
$("#btGetXmlGriglia").disabled(is_null($(this).getValue()));
|
||||
});
|
||||
_ordiniA.init(module);
|
||||
}
|
||||
).load();
|
||||
});
|
||||
|
||||
const _ordiniA = {
|
||||
|
||||
28
public_html/gest-lib/ordini_a/sql/getArticoliDaAccorpare.sql
Normal file
28
public_html/gest-lib/ordini_a/sql/getArticoliDaAccorpare.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
SELECT dtb_ordt.num_ord,
|
||||
riga_ord,
|
||||
cod_mart,
|
||||
cod_art_for,
|
||||
descrizione,
|
||||
unt_ord,
|
||||
rap_conv,
|
||||
qta_ord,
|
||||
qta_cnf,
|
||||
CASE WHEN (dtb_ordt.num_ord <> '[num_ord]') THEN 1 ELSE 0 END AS flag_da_annullare,
|
||||
DENSE_RANK() OVER (PARTITION BY dtb_ordr.cod_mart, cod_art_for ORDER BY CASE WHEN dtb_ordt.num_ord = '[num_ord]' THEN 0 ELSE dtb_ordt.num_ord END ) AS id_riga_art,
|
||||
CASE
|
||||
WHEN (COUNT(*) OVER (PARTITION BY dtb_ordr.cod_mart, cod_art_for) > 1) THEN 1
|
||||
ELSE 0 END AS flag_articolo_duplicato
|
||||
FROM dtb_ordt
|
||||
INNER JOIN dtb_ordr ON dtb_ordt.gestione = dtb_ordr.gestione AND
|
||||
dtb_ordt.data_ord = dtb_ordr.data_ord AND
|
||||
dtb_ordt.num_ord = dtb_ordr.num_ord
|
||||
WHERE dtb_ordt.data_esportazione IS NULL
|
||||
AND dtb_ordt.listino = '[listino]'
|
||||
AND dtb_ordt.data_ord = '[data_ord]'
|
||||
AND dtb_ordt.num_ord IN ([num_ords])
|
||||
AND dtb_ordt.gestione = 'A'
|
||||
AND dtb_ordt.flag_annulla = 'N'
|
||||
AND dtb_ordt.flag_sospeso = 'N'
|
||||
AND (dtb_ordt.cod_mdep = '[cod_mdep]' OR ISNULL('[cod_mdep]', '') = '')
|
||||
AND dtb_ordr.qta_ord <> dtb_ordr.qta_evasa
|
||||
ORDER BY cod_mart, flag_da_annullare DESC
|
||||
@@ -1,21 +1,16 @@
|
||||
SELECT dtb_ordt.num_ord,
|
||||
riga_ord,
|
||||
cod_mart,
|
||||
cod_art_for,
|
||||
descrizione,
|
||||
unt_ord,
|
||||
rap_conv,
|
||||
qta_ord,
|
||||
qta_cnf,
|
||||
CASE WHEN (dtb_ordt.num_ord <> '[num_ord]') THEN 1 ELSE 0 END AS flag_da_annullare,
|
||||
DENSE_RANK() OVER (Partition BY dtb_ordr.cod_mart, cod_art_for order by case when dtb_ordt.num_ord = '[num_ord]' THEN 0 ELSE dtb_ordt.num_ord end ) as id_riga_art,
|
||||
CASE
|
||||
WHEN (COUNT(*) OVER (PARTITION BY dtb_ordr.cod_mart, cod_art_for) > 1) THEN 1
|
||||
ELSE 0 END AS flag_articolo_duplicato
|
||||
SELECT dtb_ordt.data_ord,
|
||||
dtb_ordt.num_ord,
|
||||
dtb_ordt.note,
|
||||
dtb_ordt.listino,
|
||||
STUFF((SELECT DISTINCT ', ' + mtb_grup.descrizione AS [text()]
|
||||
FROM dtb_ordr
|
||||
INNER JOIN mtb_aart ON dtb_ordr.cod_mart = mtb_aart.cod_mart
|
||||
INNER JOIN mtb_grup ON mtb_aart.cod_mgrp = mtb_grup.cod_mgrp
|
||||
WHERE dtb_ordt.gestione = dtb_ordr.gestione
|
||||
AND dtb_ordt.data_ord = dtb_ordr.data_ord
|
||||
AND dtb_ordt.num_ord = dtb_ordr.num_ord
|
||||
FOR XML PATH('')), 1, 1, '') AS gruppi_merc
|
||||
FROM dtb_ordt
|
||||
INNER JOIN dtb_ordr ON dtb_ordt.gestione = dtb_ordr.gestione AND
|
||||
dtb_ordt.data_ord = dtb_ordr.data_ord AND
|
||||
dtb_ordt.num_ord = dtb_ordr.num_ord
|
||||
WHERE dtb_ordt.data_esportazione IS NULL
|
||||
AND dtb_ordt.listino = '[listino]'
|
||||
AND dtb_ordt.data_ord = '[data_ord]'
|
||||
@@ -23,5 +18,6 @@ WHERE dtb_ordt.data_esportazione IS NULL
|
||||
AND dtb_ordt.flag_annulla = 'N'
|
||||
AND dtb_ordt.flag_sospeso = 'N'
|
||||
AND (dtb_ordt.cod_mdep = '[cod_mdep]' OR ISNULL('[cod_mdep]', '') = '')
|
||||
AND dtb_ordr.qta_ord <> dtb_ordr.qta_evasa
|
||||
ORDER BY cod_mart, flag_da_annullare DESC
|
||||
AND (ISNULL(dtb_ordt.note, '') = ISNULL('[note]', ''))
|
||||
AND (ISNULL(dtb_ordt.serie, '') = ISNULL('[serie]', ''))
|
||||
ORDER BY num_ord DESC
|
||||
@@ -1,7 +1,7 @@
|
||||
SELECT *,
|
||||
SUM(tot_ct_ord) OVER (PARTITION BY data_ord, listino) AS tot_ct,
|
||||
CASE
|
||||
WHEN (COUNT(*) OVER (PARTITION BY t.listino, t.data_ord, t.data_esportazione) > 1) THEN 1
|
||||
WHEN (COUNT(*) OVER (PARTITION BY t.listino, t.data_ord, t.data_esportazione, t.note, t.serie) > 1) THEN 1
|
||||
ELSE 0 END AS flag_count_ordini_non_esportati
|
||||
FROM (SELECT dtb_ordt.gestione,
|
||||
dtb_ordt.data_ord,
|
||||
@@ -18,7 +18,9 @@ FROM (SELECT dtb_ordt.gestione,
|
||||
UPPER(dtb_ordt.listino) AS listino,
|
||||
SUM(CASE WHEN dtb_ordr.cod_mart IS NULL THEN 1 ELSE 0 END) AS not_cod_interno,
|
||||
SUM(dtb_ordr.num_cnf) AS tot_ct_ord,
|
||||
MAX(ISNULL(mtb_depo_intercode.email_ordine, pers_rif.e_mail)) AS e_mail
|
||||
MAX(ISNULL(mtb_depo_intercode.email_ordine, pers_rif.e_mail)) AS e_mail,
|
||||
dtb_ordt.note,
|
||||
dtb_ordt.serie
|
||||
FROM dtb_ordt
|
||||
INNER JOIN avw_tipo_ordine ON dtb_ordt.gestione = avw_tipo_ordine.gestione
|
||||
AND dtb_ordt.data_ord = avw_tipo_ordine.data_ord
|
||||
@@ -50,5 +52,6 @@ FROM (SELECT dtb_ordt.gestione,
|
||||
AND dtb_ordt.flag_evaso_forzato = 'N'
|
||||
GROUP BY dtb_ordt.listino, dtb_ordt.gestione, dtb_ordt.data_ord, dtb_ordt.num_ord, dtb_ordt.cod_anag,
|
||||
dtb_ordt.cod_vdes, atb_list.descrizione, dtb_ordt.data_esportazione, dtb_ordt.data_ricezione,
|
||||
avw_tipo_ordine.flag_tipo_ordine, avw_tipo_ordine.num_prenotazione, dtb_ordt.term_cons) t
|
||||
avw_tipo_ordine.flag_tipo_ordine, avw_tipo_ordine.num_prenotazione, dtb_ordt.term_cons, dtb_ordt.note,
|
||||
dtb_ordt.serie) t
|
||||
ORDER BY data_ord DESC, num_ord DESC
|
||||
Reference in New Issue
Block a user