diff --git a/code/app/Http/Controllers/ProductsController.php b/code/app/Http/Controllers/ProductsController.php index 8a4e1b59..5f74a389 100644 --- a/code/app/Http/Controllers/ProductsController.php +++ b/code/app/Http/Controllers/ProductsController.php @@ -86,23 +86,42 @@ public function store(Request $request) public function massiveUpdate(Request $request) { - DB::beginTransaction(); - - $product_ids = $request->input('id', []); - - foreach($product_ids as $index => $id) { - $product = $this->service->show($id); - $data['name'] = $request->input($id . '-name', $product->name); - $data['price'] = $request->input($id . '-price', $product->price); - $data['measure_id'] = $request->input($id . '-measure_id', $product->measure_id); - $data['max_available'] = $request->input($id . '-max_available', $product->max_available); - $data['active'] = $request->has($id . '-active'); - $data['variable'] = $product->variable; - $data['sorting'] = $index; - $this->service->update($id, $data); - } + return $this->easyExecute(function() use ($request) { + DB::beginTransaction(); - return $this->successResponse(); + $product_ids = $request->input('id', []); + $product_ids_remove = $request->input('remove', []); + + foreach($product_ids as $index => $id) { + if (in_array($id, $product_ids_remove)) { + continue; + } + + $product = $this->service->show($id); + $data['name'] = $request->input($id . '-name', $product->name); + $data['price'] = $request->input($id . '-price', $product->price); + $data['category_id'] = $request->input($id . '-category_id', $product->category_id); + $data['measure_id'] = $request->input($id . '-measure_id', $product->measure_id); + $data['max_available'] = $request->input($id . '-max_available', $product->max_available); + $data['active'] = $request->has($id . '-active'); + + /* + Questo sta qui al solo scopo di popolare l'attributo. + Altrimenti, nella funzione update(), "variable" risulterebbe + sempre falso + */ + $data['variable'] = $product->variable; + + $data['sorting'] = $index; + $this->service->update($id, $data); + } + + foreach($product_ids_remove as $remove) { + $this->service->destroy($remove); + } + + return $this->successResponse(); + }); } public function picture($id) diff --git a/code/public/js/gasdotto.js b/code/public/js/gasdotto.js index 5bb71313..02d70c40 100644 --- a/code/public/js/gasdotto.js +++ b/code/public/js/gasdotto.js @@ -1,3 +1,3 @@ /*! For license information please see gasdotto.js.LICENSE.txt */ -(()=>{var t,e={70:()=>{!function(t){t.fn.aggregator=function(){function e(t){var e=t.clone();return e.attr("data-aggregate-id","new").find("ul").empty(),t.before(e),i(e),e}function i(i){i.find("li").length<2&&i.find(".explode-aggregate").hide(),i.find("ul").sortable({connectWith:"#orderAggregator div.card ul",accept:"li",drop:function(i,n){var o=t(this).find("li").length;0==o?e(t(this)):1==o&&t(this).find(".explode-aggregate").show();var s=n.draggable.closest(".card");2==s.find("li").length&&s.find(".explode-aggregate").hide(),n.draggable.css("right","").css("left","").css("top","").css("bottom","").css("width","").css("height",""),t(this).find("ul").append(n.draggable)}})}t(this).each((function(){t(this).find("div.card").each((function(){i(t(this))})),t(this).on("click",".explode-aggregate",(function(){var i=t(this).closest(".card");i.find("li").each((function(){e(i).find("ul").append(t(this).clone())})),i.remove()})),t(this).submit((function(e){e.preventDefault();var i=t(this);i.find("button[type=submit]").prop("disabled",!1);var n=new Array;i.find(".card").each((function(){var e={id:t(this).attr("data-aggregate-id"),orders:new Array};t(this).find("li").each((function(){e.orders.push(t(this).attr("data-order-id"))})),n.push(e)})),t.ajax({method:i.attr("method"),url:i.attr("action"),data:{data:JSON.stringify(n)},dataType:"json",success:function(t){location.reload()}})}))}))}}(jQuery)},323:(t,e,i)=>{"use strict";i.d(e,{Z:()=>a});var n=i(753),o=i(619);function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function r(t,e){for(var i=0;i .accordion-item").sort((function(e,i){e=$(e),i=$(i);var n=t.getBookingRowStatus(e),o=t.getBookingRowStatus(i),s=0;if(n==o)s=e.find(".accordion-button").text().trim().localeCompare(i.find(".accordion-button").text().trim());else{var r=["pending","saved","shipped"];s=r.indexOf(n)-r.indexOf(o)}return s})).each((function(){$(this).appendTo(e)}))}},{key:"submitDeliveryForm",value:function(t){t.find(".fit-add-product").not(".hidden").each((function(){if(0==$(this).find(".inline-variant-selector").length){var e=$(this).find(".booking-product-quantity input:text.number");if(0!=e.length){var i=n.Z.sanitizeId(e.attr("name")),o=n.Z.parseFloatC(e.val()),s=t.find("tr.booking-product").not(".fit-add-product").find("input:text.number[name="+i+"]");0!=s.length&&(s.val(n.Z.parseFloatC(s.val())+o),e.remove())}}}))}},{key:"evaluateEmptyBooking",value:function(t){if("shipped"==t.find("input:hidden[name=action]").val()){var e=!1;if(t.find(".booking-total").each((function(){var t=n.Z.parseFloatC($(this).textVal());e=e||0!=t})),0==e&&0==(e=confirm(_("Tutte le quantità consegnate sono a zero! Vuoi davvero procedere?"))))throw"Empty!"}}},{key:"collectFilteredUsers",value:function(t){t.find('input:hidden[name^="users"]').remove(),$("#credits_status_table tbody tr:visible").each((function(){var e=$(this).find("input[name^=user_id]").val();t.append('')}))}},{key:"formToDownload",value:function(t){var e=t.find("input, select").serializeArray(),i=t.attr("action")+"&"+$.param(e);throw window.open(i,"_blank"),"Done!"}},{key:"passwordProtected",value:function(t){if("1"!=t.attr("data-password-protected-verified")){var e=t.attr("id"),i=$("#password-protection-dialog");throw i.find("input:password").val(""),i.attr("data-form-target","#"+e).modal("show"),"Check password!"}}},{key:"checkVariantsValues",value:function(t){if(t.find("table tbody tr").filter((function(){var t=$(this).find("input[name^=value]").first();if(t){var e=t.val();return void 0!==e&&""!=e}return!1})).length<=0)throw alert("Devi specificare almeno un valore per la variante"),"No values!"}},{key:"triggerPayment",value:function(t){if("shipped"==t.find("input:hidden[name=action]").val()){var e=t.attr("data-reference-modal");$("#"+e).appendTo("body").modal("show")}}},{key:"displayRecalculatedBalances",value:function(t,e){var i=$("#display-recalculated-balance-modal");if(0!=e.diffs.length){var n=i.find(".broken.hidden").removeClass("hidden").find("tbody");for(var o in e.diffs)e.diffs.hasOwnProperty(o)&&n.append(""+o+""+e.diffs[o][0]+""+e.diffs[o][1]+"")}else i.find(".fixed.hidden").removeClass("hidden");i.modal("show")}},{key:"refreshFilter",value:function(t){var e=t.find("input:hidden[name=data-refresh-target]").val();e?$(".form-filler").filter(e).find("button[type=submit]").click():$(".form-filler").find("button[type=submit]").click()}},{key:"afterProductChange",value:function(t,e){n.Z.postAjax({method:"GET",url:"products/"+e.id+"/post_feedback",dataType:"JSON",success:function(t){for(var e=0;e a[data-element-id="+e.id+"]").length&&(e.url=e.url.replace("booking/","delivery/"),o.Z.appendToLoadableList(n,e,!1))}}else o.Z.closeParent(t)}},{key:"handleUserApproval",value:function(t,e){if(o.Z.closeParent(t),"approve"!=e.action){var i=o.Z.closeParent(t),n=i.closest(".loadable-list");i.remove(),o.Z.testListsEmptiness(n)}}},{key:"reloadLoadableHeaders",value:function(t,e){var i;0!=(i=$('.accordion-item[data-element-id="'+t.find("input[name=sender_id]").val()+'"]').filter(":visible")).length&&o.Z.reloadLoadableHead(i),0!=(i=$('.accordion-item[data-element-id="'+t.find("input[name=target_id]").val()+'"]').filter(":visible")).length&&o.Z.reloadLoadableHead(i)}},{key:"closeMainForm",value:function(t,e){o.Z.closeParent(t)}}],(i=null)&&r(e.prototype,i),s&&r(e,s),Object.defineProperty(e,"prototype",{writable:!1}),t}()},762:(t,e,i)=>{"use strict";function n(t){for(var e=1;et?($(this).val(""),r.Z.setInputErrorText($(this),_("Il file è troppo grande!")),!1):(r.Z.setInputErrorText($(this),null),!0)}})),$(".img-preview input:file",t).change((function(t){e.previewImage(t.currentTarget)})),$(".simple-sum",t).change((function(){var t=0,e=$(this).closest(".simple-sum-container");e.find(".simple-sum").each((function(){t+=r.Z.parseFloatC($(this).val())})),e.find(".simple-sum-result").val(t)})),$('.status-selector input:radio[name*="status"]',t).change((function(){var t=$(this).closest(".status-selector"),e=$(this).val(),i="deleted"!=e;t.find("[name=deleted_at]").prop("hidden",i).closest(".input-group").prop("hidden",i);var n="suspended"!=e;t.find("[name=suspended_at]").prop("hidden",n).closest(".input-group").prop("hidden",n)})),0!=$('input[value="put_random_here"]',t).length){var i="new_"+r.Z.randomString(5);$('input[value="put_random_here"]',t).each((function(){0!=$(this).closest(".dynamic-table").length&&0!=$(this).closest("tbody").length&&$(this).val(i)}))}$(".sortable-table tbody",t).sortable({items:"> tr",handler:".sorter"})}},{key:"dateEnforcePeer",value:function(t,e){var i=t.attr(e),n=t.closest(".input-group").find(i);return 0==n.length&&0==(n=t.closest("tr").find(i)).length&&(n=t.closest("form").find(i)),n}},{key:"handlingContactSelection",value:function(t){var e=this;if(0!=t.closest(".contacts-selection").length){var i=t.find('input[name="contact_value[]"]'),n=t.find("select option:selected").val();this.fixContactField(i,n),$("select",t).change((function(t){var i=$(t.currentTarget).closest("tr").find('input[name="contact_value[]"]'),n=$(t.currentTarget).find("option:selected").val();e.fixContactField(i,n)}))}else $(".contacts-selection tr",t).each((function(t,i){var n=$(i).find('input[name="contact_value[]"]'),o=$(i).find("select option:selected").val();e.fixContactField(n,o)}))}},{key:"fixContactField",value:function(t,e){t.attr("class","").addClass("form-control"),"email"==e?t.attr("type","email"):(t.attr("type","text"),t.addClass(e))}},{key:"previewImage",value:function(t){if(t.files&&t.files[0]){var e=new FileReader,i=$(t).closest(".img-preview").find("img");e.onload=function(t){i.attr("src",t.target.result)},e.readAsDataURL(t.files[0])}}}],(i=null)&&c(e.prototype,i),n&&c(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();const h=u;function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function p(t,e){for(var i=0;i .table-sorting-header").addClass("d-none").filter("[data-sorting-"+i+"]").removeClass("d-none"),t.find("> tr[data-sorting-"+i+"], .table-sorting-header:visible").sort((function(t,e){var o=$(t).attr("data-sorting-"+i),s=$(e).attr("data-sorting-"+i);return n?parseFloat(o)-parseFloat(s):o.localeCompare(s)})).each((function(){$(this).appendTo(t)})),t.find("> tr.do-not-sort").each((function(){$(this).appendTo(t)}))}))})),$(".form-filler button[type=submit]",t).click((function(t){t.preventDefault();var e=$(this);e.addClass("disabled");var i=e.closest(".form-filler"),n=$(i.attr("data-fill-target")),o=i.find("input, select").serialize(),s=e.attr("data-action");null==s&&(s=i.attr("data-action")),n.empty().append(r.Z.j().makeSpinner()),$.ajax({method:"GET",url:s,data:o,dataType:"html",success:function(t){e.removeClass("disabled"),t=$(t),n.empty().append(t),r.Z.j().initElements(t)}})}))}},{key:"compactFilter",value:function(t,e,i){i?$(t).each((function(){$(this).closest(".filter-master-block").show()})):setTimeout((function(){$(t).each((function(){var t=$(this).closest(".filter-master-block");if(0!=t.length){var i=$(this).find(e);i.filter(".hidden").length==i.length?t.hide():t.show()}}))}),100)}},{key:"tableFilters",value:function(t){var e=$('[data-table-target="'+t+'"]');$("table"+t).find("tbody tr").each((function(){var t=!0,i=$(this);e.each((function(){if($(this).hasClass("table-number-filters")){var e=$(this).find("input.table-number-filter").val().toLowerCase();if(""==e)t=t&&!0;else{var n=parseFloat(e),o=$(this).find("input[name=filter_mode]:checked").val(),s=i.find(".text-filterable-cell"),r=parseFloat(s.text());t="min"==o&&r<=n||"max"==o&&r>=n?t&&!0:t&&!1}}else if($(this).hasClass("table-filters")){var a=$(this).find("input:radio:checked"),l=a.val();if("all"==l)t=t&&!0;else{var c=a.attr("name"),u=i.attr("data-filtered-"+c);t=t&&u==l}}else if($(this).hasClass("table-text-filter")){var h=$(this).val().toLowerCase();""==h?t=t&&!0:(t=!1,i.find(".text-filterable-cell").each((function(){if(-1!=$(this).text().toLowerCase().indexOf(h))return t=!0,!1})))}if(0==t)return!1})),i.toggleClass("hidden",0==t)})),this.compactFilter("table"+t,"tbody tr",!1)}},{key:"iconsLegendTrigger",value:function(t,e){if(!t.hasClass("dropdown-toggle")){var i=t.closest(e),n=i.attr("data-list-target"),o="",s="";".icons-legend"==e?(o=".loadable-list"+n,s=".accordion-item"):(o=".table"+n,s="tbody tr");var r=o+" "+s;if(t.hasClass("active"))t.removeClass("active"),t.is("a")&&t.closest(".dropdown-menu").siblings(".dropdown-toggle").removeClass("active"),$(r).toggleClass("hidden",!1),this.compactFilter(o,s,!0),$(o).trigger("inactive-filter");else{i.find("button, a").removeClass("active"),t.addClass("active"),t.is("a")&&t.closest(".dropdown-menu").siblings(".dropdown-toggle").addClass("active");var a=t.find("i").attr("class"),l=0;$(r).each((function(){var t=!1;$(this).find("i").each((function(){var e=$(this).attr("class");if(t=e==a)return!1})),$(this).toggleClass("hidden",0==t),0==t&&l++})),this.compactFilter(o,s,!1),0==l?$(o).trigger("inactive-filter"):$(o).trigger("active-filter")}}}}],(i=null)&&v(e.prototype,i),n&&v(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();const b=y;function w(t){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},w(t)}function x(t,e){for(var i=0;it.length)&&(e=t.length);for(var i=0,n=new Array(e);it.length)&&(e=t.length);for(var i=0,n=new Array(e);i'+_("Questa prenotazione esiste già e non può essere ricreata.")+"")),s.empty().append(t),r.Z.j().initElements(t)}})}})})),t.on("change",".variants-selector select",(function(t){var i=$(t.currentTarget).closest(".inline-variant-selector");if(0==r.Z.parseFloatC(i.find(".booking-product-quantity input").val())){var n=[];i.find(".form-select").each((function(){n.push($(this).find(":selected").val())})),r.Z.postAjax({method:"GET",url:"products/price",dataType:"JSON",data:{id:i.closest("tr").find("input:hidden").first().attr("name"),variant:n},success:function(t){var e=i.index(),n=i.closest("tr").find(".prices_block"),o=n.find(".row").first().clone();o.find("small").text(t.price),n.find(".row").length>e?n.find(".row").eq(e).replaceWith(o):n.append(o)}})}else{var o=$(t.currentTarget).closest(".booking-editor");e.bookingTotal(o)}})),$(".add-booking-product",t).click((function(t){t.preventDefault();var e=$(this).closest("table"),i=e.find(".fit-add-product").first().clone().removeClass("hidden");return r.Z.j().initElements(i),i.appendTo(e.find("tbody")),!1})),$(".alt_price_selector input",t).change((function(t){var i=$(t.currentTarget);if(i.prop("checked")){var n=i.closest(".booking-editor");e.bookingTotal(n)}})),$(".fit-add-product-select",t).change((function(t){var i=$(t.currentTarget),n=i.find("option:selected").val(),o=i.closest("tr"),s=o.closest(".booking-editor");-1==n?(o.find(".bookable-target").empty(),e.bookingTotal(s)):r.Z.postAjax({method:"GET",url:"products/"+n,data:{format:"bookable",order_id:s.attr("data-order-id")},dataType:"HTML",success:function(t){t=$(t),r.Z.j().initElements(t),o.find(".bookable-target").empty().append(t),e.bookingTotal(s)}})})),$(".preload-quantities",t).click((function(t){t.preventDefault();var i=$(t.currentTarget).closest("form").find(".booking-editor");return i.each((function(t,i){e.preloadQuantities($(i),!1)})),e.bookingTotal(i.first()),!1})),$("input.manual-total",t).keyup((function(t){var e=$(t.currentTarget);parseFloat(e.val())>0?e.addClass("is-changed"):e.removeClass("is-changed")})),$("input.manual-total",t).change((function(t){var i=$(t.currentTarget).closest(".booking-editor");e.bookingTotal(i)})),$(".load-other-booking",t).click((function(t){t.preventDefault();var e=$(t.currentTarget),i=e.attr("data-booking-url"),n=e.closest(".other-booking");r.Z.j().fetchNode(i,n)})),$(".inline-calculator button[type=submit]",t).click((function(t){t.preventDefault();var e=$(t.currentTarget).closest(".modal"),i=0;e.find("input.number").each((function(){var t=$(this).val();""!=t&&(i+=r.Z.parseFloatC(t)),$(this).val("0")}));var n=e.attr("id");$('[data-bs-target="#'+n+'"]').closest(".booking-product-quantity").find("input.number").first().val(i.toFixed(3)).blur(),e.modal("hide")})),$(".delete-booking",t).click((function(t){t.preventDefault();var i=$(t.currentTarget).closest(".inner-form");return confirm(_("Sei sicuro di voler annullare questa prenotazione?"))&&(i.find("button").prop("disabled",!0),r.Z.postAjax({method:"DELETE",url:i.attr("action"),dataType:"json",success:function(t){i.find("button").prop("disabled",!1),i.find(".booking-product-quantity input").val("0"),i.find(".variants-selector").each((function(){for(;1!=$(this).find(".row:not(.master-variant-selector)").length;)$(this).find(".row:not(.master-variant-selector):last").remove()})),e.bookingTotal(i.find(".booking-editor"))}})),!1})),$(".booking-form .info-button",t).click((function(t){t.preventDefault();var e=$(t.currentTarget).closest("form");e.find("input:hidden[name=action]").val("saved"),e.submit()}))}},{key:"initOnce",value:function(){var t=this;$("body").on("blur",".booking-product-quantity input",(function(e){var i=$(e.currentTarget).closest(".booking-editor");t.bookingTotal(i)})).on("focus",".booking-product-quantity input",(function(t){$(t.currentTarget).removeClass("is-invalid")})).on("click",".booking-product .add-variant",(function(t){t.preventDefault();var e=$(t.currentTarget).closest(".variants-selector").find(".master-variant-selector"),i=e.clone().removeClass("master-variant-selector");return i.find(".skip-on-submit").removeClass("skip-on-submit"),e.before(i),i.find("select").first().change(),!1}))}},{key:"preloadQuantities",value:function(t,e){t.find(".booking-product").each((function(){var t=$(this).find("input:hidden[name=booking-product-real-booked]");0!=t.length&&$(this).find(".booking-product-quantity input").val(t.val())})),e&&this.bookingTotal(t.closest(".booking-editor"))}},{key:"serializeBooking",value:function(t){t.find("textarea").addClass("skip-on-submit restore-after-serialize"),t.find(".booking-product-quantity input").filter((function(){return 0==$(this).closest(".master-variant-selector").length})).filter((function(){return 0==$(this).attr("name").startsWith("variant_quantity_")})).each((function(){$(this).toggleClass("skip-on-submit restore-after-serialize","0"==$(this).val())}));var e=t.find(".manual-total");e.length&&0==e.hasClass("is-changed")&&e.val("");var i=t.find(":not(.skip-on-submit)").serialize();return t.find(".restore-after-serialize").removeClass("skip-on-submit restore-after-serialize"),i}},{key:"checkInvalidFeedback",value:function(t,e,i){e?(t.toggleClass("is-invalid",!0),t.toggleClass("is-annotated",!1),t.val("0")):(t.toggleClass("is-invalid",!1),t.toggleClass("is-annotated",""!=i)),t.siblings(".invalid-feedback").text(i)}},{key:"priceRow",value:function(t){return'
"}},{key:"updateBookingQuantities",value:function(t,e,i){for(var n=0,o=Object.entries(t);nl.variants.length)for(var f=l.variants.length;fi))}},{key:"updatePayment",value:function(t,e,i){var n=t.attr("data-reference-modal"),o=$("#"+n);0!=o.length&&(o.find("input[name=amount]").val(e.toFixed(2)).change(),o.find("input[name=delivering-status]").val(JSON.stringify(i)))}},{key:"verifyManualTotal",value:function(t,e){if(0==e.products.length){var i=$("input.manual-total",t);0!=i.length&&0!=i.val()&&this.preloadQuantities(t,!0)}}},{key:"bookingTotal",value:function(t){var e=this,i=$(t).closest("form"),n=this.serializeBooking(i),o=i.attr("data-dynamic-url");this.dynamicBookingRequest&&this.dynamicBookingRequest.abort(),this.dynamicBookingRequest=$.ajax({url:o,method:"GET",data:n,dataType:"JSON",success:function(t){if(0==Object.entries(t.bookings).length)$(".booking-product-price span",i).text(r.Z.priceRound(0)),$(".booking-modifier, .booking-total",d).textVal(r.Z.priceRound(0));else{var n=$("input:hidden[name=action]",i).val(),o=0,s={};$(".booking-bottom-helper",d).removeClass("bg-success").addClass("bg-danger");for(var a=0,l=Object.entries(t.bookings);a");n.find("[role=tablist]").find(".last-tab").before(l),l.find("button").click(),i.val("")}})}})})),$(".role-editor",t).on("change","input:checkbox[data-role]",(function(t){var e=$(this);e.removeClass("saved-checkbox saved-left-feedback");var i=e.is(":checked")?"roles/attach":"roles/detach";r.Z.postAjax({url:i,data:{role:e.attr("data-role"),action:e.attr("data-action"),user:e.attr("data-user"),target_id:e.attr("data-target-id"),target_class:e.attr("data-target-class")},success:function(){e.addClass("saved-checkbox saved-left-feedback")}})})).on("click",".remove-role",(function(t){if(t.preventDefault(),confirm(_("Sei sicuro di voler revocare questo ruolo?"))){var e=$(this),i=e.attr("data-user");r.Z.postAjax({url:"roles/detach",data:{role:e.attr("data-role"),user:e.attr("data-user")},success:function(){var t=e.closest(".accordion-body"),n=t.find("[data-user="+i+"]");t.find(n.find("button").attr("data-bs-target")).remove(),n.remove()}})}}))}}],(i=null)&&W(e.prototype,i),n&&W(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();function Z(t){return Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(t)}function V(t,e){for(var i=0;ir.Z.parseFloatC(t.find(".current-sender-credit").text())?t.removeClass("alert-success").addClass("alert-danger"):t.removeClass("alert-danger").addClass("alert-success"))}))}},{key:"movementTypeEditor",value:function(t){$("select[name=sender_type], select[name=target_type]",t).change((function(t){var e=$(this).closest(".movement-type-editor"),i=e.find("select[name=sender_type] option:selected").val(),n=e.find("select[name=target_type] option:selected").val(),o=e.find("table");o.find("tbody tr").each((function(){var t=$(this).attr("data-target-class");$(this).toggleClass("hidden","App\\Gas"!=t&&t!=i&&t!=n)})),o.find("thead input[data-active-for]").each((function(){var t=$(this).attr("data-active-for");""!=t&&t!=i&&t!=n?$(this).prop("checked",!1).prop("disabled",!0).change():$(this).prop("disabled",!1)}))})),$("table thead input:checkbox",t).change((function(){var t=$(this).prop("checked"),e=$(this).closest("th").index();0==t?$(this).closest("table").find("tbody tr").each((function(){var t=$(this).find("td:nth-child("+(e+1)+")");t.find("input[value=ignore]").click(),t.find("label, input").prop("disabled",!0)})):$(this).closest("table").find("tbody tr").each((function(){$(this).find("td:nth-child("+(e+1)+")").find("label, input").prop("disabled",!1)}))}))}},{key:"enforcePaymentMethod",value:function(t){var e=t.find("option:selected").val(),i=null,n=null;JSON.parse(t.closest(".modal").find("input[name=matching_methods_for_movement_types]").val()).forEach((function(t){if(t.method==e)return i=t.default_payment,n=t.payments,!1})),null!=n?t.closest("tr").find(".csv_movement_method_select").find("option").each((function(){var t=$(this).val();n.indexOf(t)>=0?($(this).prop("disabled",!1),$(this).prop("selected",i==t)):$(this).prop("disabled",!0)})):t.closest("tr").find(".csv_movement_method_select").find("option").prop("disabled",!1)}}],(i=null)&&V(e.prototype,i),n&&V(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();const G=X;function Q(t){return Q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Q(t)}function K(t,e){for(var i=0;i":">",'"':""","'":"'"};function st(t,e){return"number"==typeof t?t+e:t}function rt(t){if("string"==typeof t){const e=/^(\d+)\s*(.*)$/g.exec(t);return{value:e?+e[1]:0,unit:(null==e?void 0:e[2])||void 0}}return{value:Number(t)}}function at(t){return String.fromCharCode(97+t%26)}const lt=2221e-19;function ct(t,e,i){return e/i.range*t}function ut(t,e){const i=Math.pow(10,e||nt);return Math.round(t*i)/i}function ht(t,e,i){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const o={high:e.high,low:e.low,valueRange:0,oom:0,step:0,min:0,max:0,range:0,numberOfSteps:0,values:[]};o.valueRange=o.high-o.low,o.oom=function(t){return Math.floor(Math.log(Math.abs(t))/Math.LN10)}(o.valueRange),o.step=Math.pow(10,o.oom),o.min=Math.floor(o.low/o.step)*o.step,o.max=Math.ceil(o.high/o.step)*o.step,o.range=o.max-o.min,o.numberOfSteps=Math.round(o.range/o.step);const s=ct(t,o.step,o)=i)o.step=1;else if(n&&r=i)o.step=r;else{let e=0;for(;;){if(s&&ct(t,o.step,o)<=i)o.step*=2;else{if(s||!(ct(t,o.step/2,o)>=i))break;if(o.step/=2,n&&o.step%1!=0){o.step*=2;break}}if(e++>1e3)throw new Error("Exceeded maximum number of iterations while optimizing scale step!")}}function a(t,e){return t===(t+=e)&&(t*=1+(e>0?lt:-lt)),t}o.step=Math.max(o.step,lt);let l=o.min,c=o.max;for(;l+o.step<=o.low;)l=a(l,o.step);for(;c-o.step>=o.high;)c=a(c,-o.step);o.min=l,o.max=c,o.range=o.max-o.min;const u=[];for(let t=o.min;t<=o.max;t=a(t,o.step)){const e=ut(t);e!==u[u.length-1]&&u.push(e)}return o.values=u,o}function dt(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;nt;function ft(t,e){return Array.from({length:t},e?(t,i)=>e(i):()=>{})}function mt(t,e){return null!==t&&"object"==typeof t&&Reflect.has(t,e)}function gt(t){return null!==t&&isFinite(t)}function vt(t){return!t&&0!==t}function yt(t){return gt(t)?Number(t):void 0}function bt(t,e){let i=0;t[arguments.length>2&&void 0!==arguments[2]&&arguments[2]?"reduceRight":"reduce"](((t,n,o)=>e(n,i++,o)),void 0)}function _t(t,e){const i=Array.isArray(t)?t[e]:mt(t,"data")?t.data[e]:null;return mt(i,"meta")?i.meta:void 0}function wt(t){return null==t||"number"==typeof t&&isNaN(t)}function xt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"y";return function(t){return"object"==typeof t&&null!==t&&(Reflect.has(t,"x")||Reflect.has(t,"y"))}(t)&&mt(t,e)?yt(t[e]):yt(t)}function kt(t,e,i){const n={high:void 0===(e={...e,...i?"x"===i?e.axisX:e.axisY:{}}).high?-Number.MAX_VALUE:+e.high,low:void 0===e.low?Number.MAX_VALUE:+e.low},o=void 0===e.high,s=void 0===e.low;return(o||s)&&function t(e){if(!wt(e))if(Array.isArray(e))for(let i=0;in.high&&(n.high=t),s&&t0||(n.high=1),n.low=0)),n}function Ct(t){let e,i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0;const s={labels:(t.labels||[]).slice(),series:Dt(t.series,n,o)},r=s.labels.length;return!function(t){return!!Array.isArray(t)&&t.every(Array.isArray)}(s.series)?e=s.series.length:(e=Math.max(r,...s.series.map((t=>t.length))),s.series.forEach((t=>{t.push(...ft(Math.max(0,e-t.length)))}))),s.labels.push(...ft(Math.max(0,e-r),(()=>""))),i&&function(t){var e;null===(e=t.labels)||void 0===e||e.reverse(),t.series.reverse();for(const e of t.series)mt(e,"data")?e.data.reverse():Array.isArray(e)&&e.reverse()}(s),s}function Tt(t,e){if(!wt(t))return e?function(t,e){let i,n;if("object"!=typeof t){const o=yt(t);"x"===e?i=o:n=o}else mt(t,"x")&&(i=yt(t.x)),mt(t,"y")&&(n=yt(t.y));if(void 0!==i||void 0!==n)return{x:i,y:n}}(t,e):yt(t)}function $t(t,e){return Array.isArray(t)?t.map((t=>mt(t,"value")?Tt(t.value,e):Tt(t,e))):$t(t.data,e)}function Dt(t,e,i){if(function(t){return Array.isArray(t)&&t.every((t=>Array.isArray(t)||mt(t,"data")))}(t))return t.map((t=>$t(t,e)));const n=$t(t,e);return i?n.map((t=>[t])):n}function Et(t){let e="";return null==t?t:(e="number"==typeof t?""+t:"object"==typeof t?JSON.stringify({data:t}):String(t),Object.keys(ot).reduce(((t,e)=>t.replaceAll(e,ot[e])),e))}class St{call(t,e){return this.svgElements.forEach((i=>Reflect.apply(i[t],i,e))),this}attr(){for(var t=arguments.length,e=new Array(t),i=0;i3&&void 0!==arguments[3]&&arguments[3],o=arguments.length>4?arguments[4]:void 0;const{easing:s,...r}=i,a={};let l,c;s&&(l=Array.isArray(s)?s:At[s]),r.begin=st(r.begin,"ms"),r.dur=st(r.dur,"ms"),l&&(r.calcMode="spline",r.keySplines=l.join(" "),r.keyTimes="0;1"),n&&(r.fill="freeze",a[e]=r.from,t.attr(a),c=rt(r.begin||0).value,r.begin="indefinite");const u=t.elem("animate",{attributeName:e,...r});n&&setTimeout((()=>{try{u._node.beginElement()}catch(i){a[e]=r.to,t.attr(a),u.remove()}}),c);const h=u.getNode();o&&h.addEventListener("beginEvent",(()=>o.emit("animationBegin",{element:t,animate:h,params:i}))),h.addEventListener("endEvent",(()=>{o&&o.emit("animationEnd",{element:t,animate:h,params:i}),n&&(a[e]=r.to,t.attr(a),u.remove())}))}class Pt{attr(t,e){return"string"==typeof t?e?this._node.getAttributeNS(e,t):this._node.getAttribute(t):(Object.keys(t).forEach((e=>{if(void 0!==t[e])if(-1!==e.indexOf(":")){const i=e.split(":");this._node.setAttributeNS(it[i[0]],e,String(t[e]))}else this._node.setAttribute(e,String(t[e]))})),this)}elem(t,e,i){return new Pt(t,e,i,this,arguments.length>3&&void 0!==arguments[3]&&arguments[3])}parent(){return this._node.parentNode instanceof SVGElement?new Pt(this._node.parentNode):null}root(){let t=this._node;for(;"svg"!==t.nodeName&&t.parentElement;)t=t.parentElement;return new Pt(t)}querySelector(t){const e=this._node.querySelector(t);return e?new Pt(e):null}querySelectorAll(t){const e=this._node.querySelectorAll(t);return new St(e)}getNode(){return this._node}foreignObject(t,e,i){let n,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("string"==typeof t){const e=document.createElement("div");e.innerHTML=t,n=e.firstChild}else n=t;n instanceof Element&&n.setAttribute("xmlns",it.xmlns);const s=this.elem("foreignObject",e,i,o);return s._node.appendChild(n),s}text(t){return this._node.appendChild(document.createTextNode(t)),this}empty(){for(;this._node.firstChild;)this._node.removeChild(this._node.firstChild);return this}remove(){var t;return null===(t=this._node.parentNode)||void 0===t||t.removeChild(this._node),this.parent()}replace(t){var e;return null===(e=this._node.parentNode)||void 0===e||e.replaceChild(t._node,this._node),t}append(t){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]&&this._node.firstChild?this._node.insertBefore(t._node,this._node.firstChild):this._node.appendChild(t._node),this}classes(){const t=this._node.getAttribute("class");return t?t.trim().split(/\s+/):[]}addClass(t){return this._node.setAttribute("class",this.classes().concat(t.trim().split(/\s+/)).filter((function(t,e,i){return i.indexOf(t)===e})).join(" ")),this}removeClass(t){const e=t.trim().split(/\s+/);return this._node.setAttribute("class",this.classes().filter((t=>-1===e.indexOf(t))).join(" ")),this}removeAllClasses(){return this._node.setAttribute("class",""),this}height(){return this._node.getBoundingClientRect().height}width(){return this._node.getBoundingClientRect().width}animate(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2?arguments[2]:void 0;return Object.keys(t).forEach((n=>{const o=t[n];Array.isArray(o)?o.forEach((t=>Ot(this,n,t,!1,i))):Ot(this,n,o,e,i)})),this}constructor(t,e,i,n,o=!1){t instanceof Element?this._node=t:(this._node=document.createElementNS(it.svg,t),"svg"===t&&this.attr({"xmlns:ct":it.ct})),e&&this.attr(e),i&&this.addClass(i),n&&(o&&n._node.firstChild?n._node.insertBefore(this._node,n._node.firstChild):n._node.appendChild(this._node))}}function It(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"100%",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"100%",n=arguments.length>3?arguments[3]:void 0;Array.from(t.querySelectorAll("svg")).filter((t=>t.getAttributeNS(it.xmlns,"ct"))).forEach((e=>t.removeChild(e)));const o=new Pt("svg").attr({width:e,height:i}).attr({style:"width: ".concat(e,"; height: ").concat(i,";")});return n&&o.addClass(n),t.appendChild(o.getNode()),o}function Mt(t,e){var i,n,o,s;const r=Boolean(e.axisX||e.axisY),a=(null===(i=e.axisY)||void 0===i?void 0:i.offset)||0,l=(null===(n=e.axisX)||void 0===n?void 0:n.offset)||0,c=null===(o=e.axisY)||void 0===o?void 0:o.position,u=null===(s=e.axisX)||void 0===s?void 0:s.position;let h=t.width()||rt(e.width).value||0,d=t.height()||rt(e.height).value||0;const p="number"==typeof(f=e.chartPadding)?{top:f,right:f,bottom:f,left:f}:void 0===f?{top:0,right:0,bottom:0,left:0}:{top:"number"==typeof f.top?f.top:0,right:"number"==typeof f.right?f.right:0,bottom:"number"==typeof f.bottom?f.bottom:0,left:"number"==typeof f.left?f.left:0};var f;h=Math.max(h,a+p.left+p.right),d=Math.max(d,l+p.top+p.bottom);const m={x1:0,x2:0,y1:0,y2:0,padding:p,width(){return this.x2-this.x1},height(){return this.y1-this.y2}};return r?("start"===u?(m.y2=p.top+l,m.y1=Math.max(d-p.bottom,m.y2+1)):(m.y2=p.top,m.y1=Math.max(d-p.bottom-l,m.y2+1)),"start"===c?(m.x1=p.left+a,m.x2=Math.max(h-p.right,m.x1+1)):(m.x1=p.left,m.x2=Math.max(h-p.right-a,m.x1+1))):(m.x1=p.left,m.x2=Math.max(h-p.right,m.x1+1),m.y2=p.top,m.y1=Math.max(d-p.bottom,m.y2+1)),m}function jt(t,e,i,n){const o=t.elem("rect",{x:e.x1,y:e.y2,width:e.width(),height:e.height()},i,!0);n.emit("draw",{type:"gridBackground",group:t,element:o})}function Lt(t,e,i){let n;const o=[];function s(o){const s=n;n=dt({},t),e&&e.forEach((t=>{window.matchMedia(t[0]).matches&&(n=dt(n,t[1]))})),i&&o&&i.emit("optionsChanged",{previousOptions:s,currentOptions:n})}if(!window.matchMedia)throw new Error("window.matchMedia not found! Make sure you're using a polyfill.");return e&&e.forEach((t=>{const e=window.matchMedia(t[0]);e.addEventListener("change",s),o.push(e)})),s(),{removeMediaQueryListeners:function(){o.forEach((t=>t.removeEventListener("change",s)))},getCurrentOptions:()=>n}}Pt.Easing=At;class Nt{on(t,e){const{allListeners:i,listeners:n}=this;"*"===t?i.add(e):(n.has(t)||n.set(t,new Set),n.get(t).add(e))}off(t,e){const{allListeners:i,listeners:n}=this;if("*"===t)e?i.delete(e):i.clear();else if(n.has(t)){const i=n.get(t);e?i.delete(e):i.clear(),i.size||n.delete(t)}}emit(t,e){const{allListeners:i,listeners:n}=this;n.has(t)&&n.get(t).forEach((t=>t(e))),i.forEach((i=>i(t,e)))}constructor(){this.listeners=new Map,this.allListeners=new Set}}const Ht=new WeakMap;class Ft{update(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];var n;(t&&(this.data=t||{},this.data.labels=this.data.labels||[],this.data.series=this.data.series||[],this.eventEmitter.emit("data",{type:"update",data:this.data})),e)&&(this.options=dt({},i?this.options:this.defaultOptions,e),this.initializeTimeoutId||(null===(n=this.optionsProvider)||void 0===n||n.removeMediaQueryListeners(),this.optionsProvider=Lt(this.options,this.responsiveOptions,this.eventEmitter)));return!this.initializeTimeoutId&&this.optionsProvider&&this.createChart(this.optionsProvider.getCurrentOptions()),this}detach(){var t;this.initializeTimeoutId?window.clearTimeout(this.initializeTimeoutId):(window.removeEventListener("resize",this.resizeListener),null===(t=this.optionsProvider)||void 0===t||t.removeMediaQueryListeners());return Ht.delete(this.container),this}on(t,e){return this.eventEmitter.on(t,e),this}off(t,e){return this.eventEmitter.off(t,e),this}initialize(){window.addEventListener("resize",this.resizeListener),this.optionsProvider=Lt(this.options,this.responsiveOptions,this.eventEmitter),this.eventEmitter.on("optionsChanged",(()=>this.update())),this.options.plugins&&this.options.plugins.forEach((t=>{Array.isArray(t)?t[0](this,t[1]):t(this)})),this.eventEmitter.emit("data",{type:"initial",data:this.data}),this.createChart(this.optionsProvider.getCurrentOptions()),this.initializeTimeoutId=null}constructor(t,e,i,n,o){this.data=e,this.defaultOptions=i,this.options=n,this.responsiveOptions=o,this.eventEmitter=new Nt,this.resizeListener=()=>this.update(),this.initializeTimeoutId=setTimeout((()=>this.initialize()),0);const s="string"==typeof t?document.querySelector(t):t;if(!s)throw new Error("Target element is not found");this.container=s;const r=Ht.get(s);r&&r.detach(),Ht.set(s,this)}}const Rt={x:{pos:"x",len:"width",dir:"horizontal",rectStart:"x1",rectEnd:"x2",rectOffset:"y2"},y:{pos:"y",len:"height",dir:"vertical",rectStart:"y2",rectEnd:"y1",rectOffset:"x1"}};class qt{createGridAndLabels(t,e,i,n){const o="x"===this.units.pos?i.axisX:i.axisY,s=this.ticks.map(((t,e)=>this.projectValue(t,e))),r=this.ticks.map(o.labelInterpolationFnc);s.forEach(((a,l)=>{const c=r[l],u={x:0,y:0};let h;h=s[l+1]?s[l+1]-a:Math.max(this.axisLength-a,this.axisLength/this.ticks.length),""!==c&&vt(c)||("x"===this.units.pos?(a=this.chartRect.x1+a,u.x=i.axisX.labelOffset.x,"start"===i.axisX.position?u.y=this.chartRect.padding.top+i.axisX.labelOffset.y+5:u.y=this.chartRect.y1+i.axisX.labelOffset.y+5):(a=this.chartRect.y1-a,u.y=i.axisY.labelOffset.y-h,"start"===i.axisY.position?u.x=this.chartRect.padding.left+i.axisY.labelOffset.x:u.x=this.chartRect.x2+i.axisY.labelOffset.x+10),o.showGrid&&function(t,e,i,n,o,s,r,a){const l={["".concat(i.units.pos,"1")]:t,["".concat(i.units.pos,"2")]:t,["".concat(i.counterUnits.pos,"1")]:n,["".concat(i.counterUnits.pos,"2")]:n+o},c=s.elem("line",l,r.join(" "));a.emit("draw",{type:"grid",axis:i,index:e,group:s,element:c,...l})}(a,l,this,this.gridOffset,this.chartRect[this.counterUnits.len](),t,[i.classNames.grid,i.classNames[this.units.dir]],n),o.showLabel&&function(t,e,i,n,o,s,r,a,l,c){const u={[o.units.pos]:t+r[o.units.pos],[o.counterUnits.pos]:r[o.counterUnits.pos],[o.units.len]:e,[o.counterUnits.len]:Math.max(0,s-10)},h=Math.round(u[o.units.len]),d=Math.round(u[o.counterUnits.len]),p=document.createElement("span");p.className=l.join(" "),p.style[o.units.len]=h+"px",p.style[o.counterUnits.len]=d+"px",p.textContent=String(n);const f=a.foreignObject(p,{style:"overflow: visible;",...u});c.emit("draw",{type:"label",axis:o,index:i,group:a,element:f,text:n,...u})}(a,h,l,c,this,o.offset,u,e,[i.classNames.label,i.classNames[this.units.dir],"start"===o.position?i.classNames[o.position]:i.classNames.end],n))}))}constructor(t,e,i){this.units=t,this.chartRect=e,this.ticks=i,this.counterUnits=t===Rt.x?Rt.y:Rt.x,this.axisLength=e[this.units.rectEnd]-e[this.units.rectStart],this.gridOffset=e[this.units.rectOffset]}}class Ut extends qt{projectValue(t){const e=Number(xt(t,this.units.pos));return this.axisLength*(e-this.bounds.min)/this.bounds.range}constructor(t,e,i,n){const o=n.highLow||kt(e,n,t.pos),s=ht(i[t.rectEnd]-i[t.rectStart],o,n.scaleMinSpace||20,n.onlyInteger),r={min:s.min,max:s.max};super(t,i,s.values),this.bounds=s,this.range=r}}class Wt extends qt{projectValue(t,e){return this.stepLength*e}constructor(t,e,i,n){const o=n.ticks||[];super(t,i,o);const s=Math.max(1,o.length-(n.stretch?1:0));this.stepLength=this.axisLength/s,this.stretch=Boolean(n.stretch)}}function zt(t){return e=t,i=function(){for(var t=arguments.length,e=new Array(t),i=0;i({x:t.x+(mt(e,"x")?e.x:0),y:t.y+(mt(e,"y")?e.y:0)})),{x:0,y:0})},ft(Math.max(...e.map((t=>t.length))),(t=>i(...e.map((e=>e[t])))));var e,i}const Bt={axisX:{offset:30,position:"end",labelOffset:{x:0,y:0},showLabel:!0,showGrid:!0,labelInterpolationFnc:pt,scaleMinSpace:30,onlyInteger:!1},axisY:{offset:40,position:"start",labelOffset:{x:0,y:0},showLabel:!0,showGrid:!0,labelInterpolationFnc:pt,scaleMinSpace:20,onlyInteger:!1},width:void 0,height:void 0,high:void 0,low:void 0,referenceValue:0,chartPadding:{top:15,right:15,bottom:5,left:10},seriesBarDistance:15,stackBars:!1,stackMode:"accumulate",horizontalBars:!1,distributeSeries:!1,reverseData:!1,showGridBackground:!1,classNames:{chart:"ct-chart-bar",horizontalBars:"ct-horizontal-bars",label:"ct-label",labelGroup:"ct-labels",series:"ct-series",bar:"ct-bar",grid:"ct-grid",gridGroup:"ct-grids",gridBackground:"ct-grid-background",vertical:"ct-vertical",horizontal:"ct-horizontal",start:"ct-start",end:"ct-end"}};class Zt extends Ft{createChart(t){const{data:e}=this,i=Ct(e,t.reverseData,t.horizontalBars?"x":"y",!0),n=It(this.container,t.width,t.height,t.classNames.chart+(t.horizontalBars?" "+t.classNames.horizontalBars:"")),o=t.stackBars&&!0!==t.stackMode&&i.series.length?kt([zt(i.series)],t,t.horizontalBars?"x":"y"):kt(i.series,t,t.horizontalBars?"x":"y");this.svg=n;const s=n.elem("g").addClass(t.classNames.gridGroup),r=n.elem("g"),a=n.elem("g").addClass(t.classNames.labelGroup);"number"==typeof t.high&&(o.high=t.high),"number"==typeof t.low&&(o.low=t.low);const l=Mt(n,t);let c;const u=t.distributeSeries&&t.stackBars?i.labels.slice(0,1):i.labels;let h,d,p;t.horizontalBars?(c=d=void 0===t.axisX.type?new Ut(Rt.x,i.series,l,{...t.axisX,highLow:o,referenceValue:0}):new t.axisX.type(Rt.x,i.series,l,{...t.axisX,highLow:o,referenceValue:0}),h=p=void 0===t.axisY.type?new Wt(Rt.y,i.series,l,{ticks:u}):new t.axisY.type(Rt.y,i.series,l,t.axisY)):(h=d=void 0===t.axisX.type?new Wt(Rt.x,i.series,l,{ticks:u}):new t.axisX.type(Rt.x,i.series,l,t.axisX),c=p=void 0===t.axisY.type?new Ut(Rt.y,i.series,l,{...t.axisY,highLow:o,referenceValue:0}):new t.axisY.type(Rt.y,i.series,l,{...t.axisY,highLow:o,referenceValue:0}));const f=t.horizontalBars?l.x1+c.projectValue(0):l.y1-c.projectValue(0),m="accumulate"===t.stackMode,g="accumulate-relative"===t.stackMode,v=[],y=[];let b=v;h.createGridAndLabels(s,a,t,this.eventEmitter),c.createGridAndLabels(s,a,t,this.eventEmitter),t.showGridBackground&&jt(s,l,t.classNames.gridBackground,this.eventEmitter),bt(e.series,((n,o)=>{const s=o-(e.series.length-1)/2;let a;a=t.distributeSeries&&!t.stackBars?h.axisLength/i.series.length/2:t.distributeSeries&&t.stackBars?h.axisLength/2:h.axisLength/i.series[o].length/2;const u=r.elem("g"),_=mt(n,"name")&&n.name,w=mt(n,"className")&&n.className,x=mt(n,"meta")?n.meta:void 0;_&&u.attr({"ct:series-name":_}),x&&u.attr({"ct:meta":Et(x)}),u.addClass([t.classNames.series,w||"".concat(t.classNames.series,"-").concat(at(o))].join(" ")),i.series[o].forEach(((e,r)=>{const _=mt(e,"x")&&e.x,w=mt(e,"y")&&e.y;let x,k;x=t.distributeSeries&&!t.stackBars?o:t.distributeSeries&&t.stackBars?0:r,k=t.horizontalBars?{x:l.x1+c.projectValue(_||0,r,i.series[o]),y:l.y1-h.projectValue(w||0,x,i.series[o])}:{x:l.x1+h.projectValue(_||0,x,i.series[o]),y:l.y1-c.projectValue(w||0,r,i.series[o])},h instanceof Wt&&(h.stretch||(k[h.units.pos]+=a*(t.horizontalBars?-1:1)),k[h.units.pos]+=t.stackBars||t.distributeSeries?0:s*t.seriesBarDistance*(t.horizontalBars?-1:1)),g&&(b=w>=0||_>=0?v:y);const C=b[r]||f;if(b[r]=C-(f-k[h.counterUnits.pos]),void 0===e)return;const T={["".concat(h.units.pos,"1")]:k[h.units.pos],["".concat(h.units.pos,"2")]:k[h.units.pos]};t.stackBars&&(m||g||!t.stackMode)?(T["".concat(h.counterUnits.pos,"1")]=C,T["".concat(h.counterUnits.pos,"2")]=b[r]):(T["".concat(h.counterUnits.pos,"1")]=f,T["".concat(h.counterUnits.pos,"2")]=k[h.counterUnits.pos]),T.x1=Math.min(Math.max(T.x1,l.x1),l.x2),T.x2=Math.min(Math.max(T.x2,l.x1),l.x2),T.y1=Math.min(Math.max(T.y1,l.y2),l.y1),T.y2=Math.min(Math.max(T.y2,l.y2),l.y1);const $=_t(n,r),D=u.elem("line",T,t.classNames.bar).attr({"ct:value":[_,w].filter(gt).join(","),"ct:meta":Et($)});this.eventEmitter.emit("draw",{type:"bar",value:e,index:r,meta:$,series:n,seriesIndex:o,axisX:d,axisY:p,chartRect:l,group:u,element:D,...T})}))}),t.reverseData),this.eventEmitter.emit("created",{chartRect:l,axisX:d,axisY:p,svg:n,options:t})}constructor(t,e,i,n){super(t,e,Bt,dt({},Bt,i),n),this.data=e}}function Vt(t){return Vt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Vt(t)}function Yt(t,e){for(var i=0;i'+e.item.label+'
');var n=i.closest(".completion-rows"),o=et.Z[n.attr("data-callback-add")];"function"==typeof o&&o(n,e.item.id)}})}})),$(t).on("click",".btn-danger",(function(){var t=$(this).closest("li"),e=t.closest(".completion-rows"),i=et.Z[e.attr("data-callback-remove")];"function"==typeof i&&i(e,t.attr("data-object-id")),t.remove()}))})),t.hasClass("modal")?t.draggable({handle:".modal-header"}):$(".modal",t).draggable({handle:".modal-header"});var i=$(".measure-selector",t);0!=i.length&&(null==Kt?r.Z.postAjax({method:"GET",url:"measures/discretes",dataType:"JSON",success:function(t){Kt=t,e(i)}}):e(i)),$(".postponed",t).appendTo("#postponed").removeClass("postponed"),$("ul[role=tablist]",t).each((function(){0==$(this).find("li.active").length&&$(this).find("li a").first().tab("show")})),r.Z.init(t),M.init(t),k.init(t),a.Z.init(t),h.init(t),q.init(t),m.init(t),b.init(t),B.init(t),G.init(t),tt.init(t),Gt.init(t)}function ee(t,e){try{t.closest(".modal").modal("hide");var i=$(e);r.Z.j().initElements(i),i.modal("show")}catch(t){var n=JSON.parse(e),o=$("#service-modal");o.find(".modal-body").empty().append("

"+n.message+"

"),o.modal("show")}}function ie(t,e){if(1==Qt)return!1;var i;if(Qt=!0,0!=(i=t.find("input[name=test-feedback]")).length&&"error"==e.status)return r.Z.displayServerError(t,e),Qt=!1,!1;if(a.Z.innerCallbacks(t,e),0!=(i=t.find("input[name=update-select]")).length){var n=i.val();$("select[name="+n+"]").each((function(){var t=$('");if(e.hasOwnProperty("parent")&&null!=e.parent){for(var i=$(this).find("option[value="+e.parent+"]").first(),n=i.text().replace(/ /g," "),o="  ",s=0;s{"use strict";i.r(e);var n=i(753);i(526),function(t){t.fn.dynamictree=function(){function e(t){for(var i=[],n=1;;){var o=t.find("> li:nth-child("+n+")");if(0==o.length)break;var s={id:o.attr("id"),name:o.find("input:text").val()};s.children=e(o.find("ul")),i.push(s),n++}return i}function i(t){0==t.find("ul").length&&t.append("
    "),t.find("ul").sortable({items:"li",connectWith:".dynamic-tree, .dynamic-tree ul"})}function o(e){t(e.target).closest("li").remove()}function s(e){e.preventDefault();var n=t(e.target).closest(".dynamic-tree-box"),o=n.find("input[name=new_category]"),s=o.val(),r=n.find(".dynamic-tree"),a=t('
  • ');return r.append(a),r.sortable("refresh"),i(a),o.val(""),!1}function r(i){i.preventDefault();var o=t(i.target),s=o.find("button[type=submit]");s.prop("disabled",!0);var r=e(o.find(".dynamic-tree"));return t.ajax({method:o.attr("method"),url:o.attr("action"),data:{_token:o.find("input[name=_token]").val(),_method:o.find("input[name=_method]").val(),serialized:r},success:function(){n.Z.inlineFeedback(s,_("Salvato!")),o.closest(".modal").modal("hide")}}),!1}t(this).each((function(){t(this).find(".dynamic-tree").sortable({items:"li",connectWith:".dynamic-tree ul",start:function(){t(".dynamic-tree ul").css("min-height","50px")},stop:function(){t(".dynamic-tree ul").css("min-height","0")},receive:function(t,e){i(e.item)}}),t(this).find(".dynamic-tree ul").sortable({items:"li",connectWith:".dynamic-tree, .dynamic-tree ul",receive:function(t,e){var i=t.target.closest("ul");e.item.find("ul").find("li").each((function(){i.append(this)})),e.item.find("ul").remove()}}),t(this).on("click",".dynamic-tree-remove",o),t(this).on("click",".dynamic-tree-add",s),t(this).on("submit",r)}))}}(jQuery)},619:(t,e,i)=>{"use strict";i.d(e,{Z:()=>a});var n=i(753),o=i(323);function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function r(t,e){for(var i=0;i .loadable-sorting-header").addClass("hidden").filter("[data-sorting-"+n+"]").removeClass("hidden"),i.find("> .accordion-item:visible, .loadable-sorting-header:visible").sort((function(t,e){var i=$(t).attr("data-sorting-"+n),o=$(e).attr("data-sorting-"+n);return i.localeCompare(o)})).each((function(){$(this).appendTo(i)}))})),e.on("click",".list-filters button",(function(){var t=$(this).closest(".list-filters").attr("data-list-target"),e=$(this).attr("data-filter-attribute");$(".loadable-list"+t+" .accordion-item[data-filtered-"+e+"=true]").each((function(){$(this).toggleClass("d-none")}))})),e.on("keyup",".list-text-filter",(function(){var t=$(this).val().toLowerCase(),e=$(this).attr("data-list-target");""==t?$(".loadable-list"+e+" .accordion-item").css("display","block"):$(".loadable-list"+e+" .accordion-item").each((function(){-1==$(this).find(".accordion-button").text().toLowerCase().indexOf(t)?$(this).css("display","none"):$(this).css("display","block")}))})),e.on("hidden.bs.collapse",".loadable-list > .accordion-item > .accordion-collapse",(function(e){e.stopPropagation();var i=$(this).closest(".accordion-item");t.reloadLoadableHead(i)})),e.on("show.bs.collapse",".loadable-list > .accordion-item > .accordion-collapse",(function(t){t.stopPropagation(),$(this).find(".accordion-body").animate({"min-height":"150px"},600)})),e.on("shown.bs.collapse",".loadable-list > .accordion-item > .accordion-collapse",(function(t){t.stopPropagation();var e=$(this);$("html, body").animate({scrollTop:e.closest(".accordion-item").offset().top-50},300)}))}},{key:"innerCallbacks",value:function(e,i){var n;if(0!=(n=e.find("input[name=update-list]")).length){var o=$("#"+n.val());t.appendToLoadableList(o,i,!0)}0!=(n=e.find("input[name=append-list]")).length&&(o=$("#"+n.val()),t.appendToLoadableList(o,i,!1)),0!=(n=e.find("input[name=reload-loadable]")).length&&t.reloadCurrentLoadable(n.val())}},{key:"listRow",value:function(t,e,i,n){var o=Math.random().toString(36).substring(2);return $('

    ')}},{key:"appendToLoadableList",value:function(e,i,o){var s=t.listRow(e,i.id,i.url,i.header);e.append(s),n.Z.j().handleAsyncAccordion(s),t.afterListChanges(e),o&&s.find(".accordion-button").click()}},{key:"currentLoadableLoaded",value:function(t){return $(t).closest(".async-accordion").attr("data-element-id")}},{key:"reloadCurrentLoadable",value:function(t){$(t).find("> .accordion-item > .accordion-header > .accordion-button:not(.collapsed)").each((function(){var t=$(this);t.click(),setTimeout((function(){t.click()}),600)}))}},{key:"closeAllLoadable",value:function(t){t.find("> accordion-item .accordion-button").filter(":not(.collapsed)").each((function(){$(this).click()}))}},{key:"reloadLoadableHead",value:function(e){n.Z.postAjax({method:"GET",url:e.attr("data-accordion-url")+"/header",dataType:"json",success:function(i){e.find("> .accordion-header > .accordion-button").empty().append(i.header),e.attr("data-accordion-url",i.url),t.afterListChanges(e.closest(".loadable-list"))}})}},{key:"closeParent",value:function(t){var e=t.closest(".accordion-item");return e.find("> .accordion-header > .accordion-button").click(),e}},{key:"afterListChanges",value:function(e){var i=e.attr("data-sorting-function");null!=i&&o.Z[i](e),t.testListsEmptiness(e)}},{key:"testListsEmptiness",value:function(t){var e=t.attr("id"),i=t.find("> .accordion-item").length;$("#empty-"+e).toggleClass("d-none",0!=i)}}],(i=null)&&r(e.prototype,i),s&&r(e,s),Object.defineProperty(e,"prototype",{writable:!1}),t}()},193:(t,e,i)=>{"use strict";i.r(e);var n=i(753);$(document).ready((function(){$("body").on("click",".password-field .bi-eye-slash",(function(){var t=$(this).closest(".password-field").find("input[type!=hidden]");"password"==t.attr("type")?t.attr("type","text"):t.attr("type","password"),$(this).toggleClass("bi-eye").toggleClass("bi-eye-close")})),$("body").on("focus","input.password-changer",(function(){if(0==$(this).closest(".modal").length){var t=$(this);t.popover({content:function(){var e='
    ';return t.hasClass("enforcable_change")&&(e+='

    "),e+='
    ",(e=$(e)).find("button.btn-success").click((function(i){i.preventDefault(),i.stopPropagation();var n=e.find("input[name=password]").val();if(n==e.find("input[name=password_confirm]").val()){if(0!=e.find("input[name=enforce_change]").length){var o=e.find("input[name=enforce_change]").prop("checked")?"true":"false";t.closest(".input-group").find("input[name=enforce_password_change]").val(o)}t.val(n),t.popover("dispose")}else alert("Le password sono diverse!")})),e.find("button.btn-light").click((function(e){e.preventDefault(),e.stopPropagation(),t.popover("dispose")})),setTimeout((function(){e.find("input[name=password]").focus()}),200),e},offset:[0,-50],template:'',placement:"left",html:!0})}})),$("body").on("submit","#password-protection-dialog form",(function(t){t.preventDefault();var e=$(this).closest(".modal");$.ajax({method:"POST",url:$(this).attr("action"),data:{password:$(this).find("input[type=password]").val()},success:function(t){e.modal("hide");var i=e.attr("data-form-target"),o=$(i);if("ok"==t)o.attr("data-password-protected-verified","1"),o.submit();else{var s=o.find("button:submit");n.Z.inlineFeedback(s,_("Password errata!"))}}})}))}))},16:(t,e,i)=>{"use strict";i.r(e);var n=i(753);$(document).ready((function(){function t(t,e,i){var n=t.closest(".modal");0==n.length&&(n=!1),t.popover({container:n,template:'',placement:"left",html:!0,content:i(t)})}$("body").on("focus","input.address",(function(){t($(this),"address",(function(t){var e=$('
    "),i=t.val();if(""!=i){for(var n=i.split(","),o=n.length;o<3;o++)n[o]="";e.find("input[name=street]").val(n[0].trim()),e.find("input[name=city]").val(n[1].trim()),e.find("input[name=cap]").val(n[2].trim())}return e.find("button.btn-success").click((function(i){i.preventDefault(),i.stopPropagation();var n=e.find("input[name=street]").val().trim().replace(",",""),o=e.find("input[name=city]").val().trim().replace(",",""),s=e.find("input[name=cap]").val().trim().replace(",","");""==n&&""==o&&""==s?t.val(""):t.val(n+", "+o+", "+s),t.popover("dispose")})),e.find("button.btn-light").click((function(e){e.preventDefault(),e.stopPropagation(),t.popover("dispose")})),setTimeout((function(){e.find("input[name=street]").focus()}),200),e}))})),$("body").on("focus","input.periodic",(function(){t($(this),"periodic",(function(t){var e=$('
    ");$("input.date",e).datepicker({format:"DD dd MM yyyy",autoclose:!0,language:n.Z.currentLanguage(),clearBtn:!0});var i=t.val();if(""!=i){for(var o=i.split(" - "),s=o.length;s<4;s++)o[s]="";e.find("select[name=day] option").filter((function(){return $(this).html()==o[0]})).prop("selected",!0),e.find("select[name=cycle] option").filter((function(){return $(this).html()==o[1]})).prop("selected",!0),e.find("input[name=from]").val(o[2].trim()),e.find("input[name=to]").val(o[3].trim())}return e.find("button.btn-success").click((function(i){i.preventDefault(),i.stopPropagation();var n=e.find("select[name=day] option:selected").text(),o=e.find("select[name=cycle] option:selected").text(),s=e.find("input[name=from]").val().trim().replace(",",""),r=e.find("input[name=to]").val().trim().replace(",","");t.val(n+" - "+o+" - "+s+" - "+r).change(),t.popover("dispose")})),e.find("button.btn-light").click((function(e){e.preventDefault(),e.stopPropagation(),t.popover("dispose")})),setTimeout((function(){e.find("select[name=day]").focus()}),200),e}))})),$("body").on("change","#dates-in-range input.date, #dates-in-range input.periodic",(function(){if(""!=$(this).val()){var t=$(this).closest("tr");$(this).hasClass("date")?t.find(".periodic").val(""):t.find(".date").val("")}}))}))},981:()=>{!function(){var t=function(t){var e=function(t){if(null==o||null==t)return t;if(t in o==0)return null!=n?n(t):t;var e=o[t];if(null==e)return t;return e}(t);if("function"==typeof e)e=e.apply(this,arguments);else if(arguments.length>1){var s=Array.prototype.slice.call(arguments,1);e=i(e,s)}return e};t.translate=t;var e,i=(e=/\{([^}]+)\}/g,function(t,i){return t.replace(e,(function(t,e){return i[e]}))});t.setFormatter=function(t){i=t},t.format=function(){var t=Array.prototype.slice,e=arguments[0],n=t.call(arguments,1);return i(e,n)};var n=null;t.setDynamicTranslator=function(t){n=t};var o=null;t.setTranslation=function(t){o=t},window._=t}()},753:(t,e,i)=>{"use strict";i.d(e,{Z:()=>l});const n=class{init(t){this.mainOptions=$.extend({},{initFunction:function(){},fixBootstrap:[]},t||{}),this.fixBootstrap(["Modal","Popover"].concat(this.mainOptions.fixBootstrap)),this.onceInit(),this.initElements($("body"))}defineJQueryPlugin(t){const e=t.NAME;if(e in $.fn==0){const i=$.fn[e];$.fn[e]=t.jQueryInterface,$.fn[e].Constructor=t,$.fn[e].noConflict=()=>($.fn[e]=i,t.jQueryInterface)}}fixBootstrap(t){window.bootstrap&&t.forEach((t=>{this.defineJQueryPlugin(window.bootstrap[t])}))}assignIDs(t,e){t.forEach((function(t,i){$(t,e).not("[id]").each((function(){$(this).attr("id",Math.random().toString(36).substring(2))}))}))}makeSpinner(){return'
    '}formValidation(t){return!t.hasClass("needs-validation")||(t.addClass("was-validated"),t.get(0).checkValidity())}initElements(t){$("form.needs-validation",t).each(((t,e)=>{$(e).on("submit",(t=>{let e=$(t.currentTarget);0==this.formValidation(e)&&(t.preventDefault(),t.stopPropagation())}))})),this.assignIDs([".async-modal"],t),$(".async-modal",t).click((t=>{t.preventDefault();let e=$(t.currentTarget).attr("data-modal-url")||$(t.currentTarget).attr("href");this.fetchRemoteModal(e)})),this.assignIDs([".async-accordion"],t),$(".async-accordion > .accordion-collapse",t).each(((t,e)=>{this.handleAsyncAccordion(e)})),this.assignIDs([".async-tab"],t),$(".async-tab",t).on("show.bs.tab",(t=>{t.stopPropagation();let e=$(t.currentTarget).attr("data-bs-target"),i=$(e),n=$(t.target).attr("data-tab-url");this.fetchNode(n,i)})).on("hidden.bs.tab",(t=>{t.stopPropagation();let e=$(t.currentTarget).attr("data-bs-target");$(e).empty()})),$(".async-popover",t).on("show.bs.popover",(t=>{if(void 0===$.data(t.target,"dynamic-inited")){$.data(t.target,"dynamic-inited",{done:!0});let e=$(t.currentTarget),i=e.attr("data-contents-url");$.ajax({url:i,method:"GET",dataType:"HTML",success:function(t){e.attr("data-bs-content",t),e.popover("dispose").popover("show")}})}})),$(".dynamic-table",t).each((function(){$(this).find("> tfoot").find("input, select, textarea").addClass("skip-on-submit")})).on("click",".add-row",(t=>{t.preventDefault();let e=$(t.currentTarget),i=e.closest("table").find("> tfoot tr").first().clone();i.find(".skip-on-submit").removeClass("skip-on-submit"),e.closest("tr").before(i),this.initElements(i)})).on("click",".remove-row",(function(t){t.preventDefault(),$(this).closest("tr").remove()})),$(".modal-form",t).on("submit",(t=>{t.preventDefault();let e=$(t.currentTarget);this.formValidation(e)&&$.ajax({method:e.attr("method"),url:e.attr("action"),data:this.serializeForm(e),success:function(){e.closest(".modal").modal("hide")}})})),$(".infinite-scroll",t).each(((t,e)=>{let i=$(e),n=i.find(".pagination").closest("nav"),o=!1;$(window).on("scroll",(()=>{if(this.onScreen(n,200)&&0==o){o=!0;let t=n.find("li.active").next("li");n.remove(),t.length>0&&$.ajax({url:t.find("a").attr("href"),method:"GET",dataType:"HTML",success:t=>{let e=$(t).find(".infinite-scroll").html();this.initElements(e),i.append(e),n=i.find(".pagination").closest("nav"),o=!1}})}}))})),this.mainOptions.initFunction(t)}handleAsyncAccordion(t){$(t).on("show.bs.collapse",(t=>{t.stopPropagation();let e=$(t.currentTarget).closest(".async-accordion"),i=e.attr("data-accordion-url"),n=e.find(".accordion-body").first();this.fetchNode(i,n)}))}fetchRemoteModal(t){$.ajax({url:t,method:"GET",dataType:"HTML",success:t=>{let e=$(t);this.initElements(e),e.addClass("delete-on-close").modal("show")}})}fetchNode(t,e){e.empty().append(this.makeSpinner()),$.ajax({url:t,method:"GET",dataType:"HTML",success:t=>{let i=$(t);this.initElements(i),e.empty().append(i)}})}reloadNode(t){let e=t.attr("data-reload-url");t.hasClass("modal")?(this.fetchRemoteModal(e),t.modal("hide")):$.ajax({url:e,method:"GET",dataType:"HTML",success:e=>{let i=$(e);this.initElements(i),t.replaceWith(i)}})}submitButton(t){let e=t.find("button[type=submit]");if(0==e.length){let i=t.attr("id");i&&(e=$("button[type=submit][form="+i+"]"))}return e}serializeForm(t){return t.find(":not(.skip-on-submit)").serialize()}serializeFormData(t){let e=new FormData;$.each(t.find('input[type="file"]:not(.skip-on-submit)'),(function(t,i){$.each($(i)[0].files,(function(t,n){e.append(i.name,n)}))}));let i=t.find(":not(.skip-on-submit)").serializeArray();return $.each(i,(function(t,i){e.append(i.name,i.value)})),e}onScreen(t,e){void 0===e&&(e=0);let i=$(window).scrollTop(),n=i+$(window).height(),o=t.offset().top;return o+t.outerHeight()<=n+e&&o>=i-e}onceInit(){$("body").on("hidden.bs.modal",".modal.delete-on-close",(function(){$(this).remove()}))}};var o=i(619);function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function r(t,e){for(var i=0;i