diff --git a/code/app/Http/Controllers/StatisticsController.php b/code/app/Http/Controllers/StatisticsController.php index b323a576..503b2274 100644 --- a/code/app/Http/Controllers/StatisticsController.php +++ b/code/app/Http/Controllers/StatisticsController.php @@ -83,9 +83,14 @@ private function formatCSV($data) return $ret; } - private function createBookingQuery($query, $start, $end, $target, $supplier) + private function createBookingQuery($query, $type, $start, $end, $target, $supplier) { - $query->where('delivery', '!=', '0000-00-00')->where('delivery', '>=', $start)->where('delivery', '<=', $end); + if ($type == 'all') { + $query->where('bookings.updated_at', '>=', $start)->where('bookings.updated_at', '<=', $end); + } + else { + $query->where('bookings.delivery', '!=', '0000-00-00')->where('bookings.delivery', '>=', $start)->where('bookings.delivery', '<=', $end); + } if ($supplier) { $query->whereHas('order', function ($query) use ($supplier) { @@ -100,12 +105,22 @@ private function createBookingQuery($query, $start, $end, $target, $supplier) return $query; } - private function getSummary($start, $end, $target) + private function getSummary($start, $end, $type, $target) { $data = []; - $data_for_suppliers = BookedProduct::selectRaw('supplier_id, SUM(final_price) as price')->whereHas('booking', function($query) use ($start, $end, $target) { - $this->createBookingQuery($query, $start, $end, $target, null); - })->join('bookings', 'booked_products.booking_id', '=', 'bookings.id')->join('orders', 'bookings.order_id', '=', 'orders.id')->groupBy('supplier_id')->get(); + + $data_for_suppliers_query = BookedProduct::whereHas('booking', function($query) use ($type, $start, $end, $target) { + $this->createBookingQuery($query, $type, $start, $end, $target, null); + })->join('bookings', 'booked_products.booking_id', '=', 'bookings.id')->join('orders', 'bookings.order_id', '=', 'orders.id')->groupBy('orders.supplier_id'); + + if ($type == 'all') { + $data_for_suppliers_query->selectRaw('orders.supplier_id, SUM(price) as price')->join('products', 'booked_products.product_id', '=', 'products.id'); + } + else { + $data_for_suppliers_query->selectRaw('orders.supplier_id, SUM(final_price) as price'); + } + + $data_for_suppliers = $data_for_suppliers_query->get(); foreach($data_for_suppliers as $dfs) { $name = $dfs->supplier_id; @@ -120,7 +135,7 @@ private function getSummary($start, $end, $target) $data[$name]->value += $dfs->price; } - $data_for_user = $this->createBookingQuery(Booking::query(), $start, $end, $target, null)->whereHas('user', function($query) { + $data_for_user = $this->createBookingQuery(Booking::query(), $type, $start, $end, $target, null)->whereHas('user', function($query) { $query->whereNull('parent_id'); })->selectRaw('supplier_id, COUNT(DISTINCT(bookings.user_id)) as total')->join('orders', 'bookings.order_id', '=', 'orders.id')->groupBy('supplier_id')->get(); @@ -132,8 +147,16 @@ private function getSummary($start, $end, $target) } $categories = []; - $data_for_categories = BookedProduct::selectRaw('product_id, SUM(final_price) as price, category_id')->whereHas('booking', function($query) use ($start, $end, $target) { - $this->createBookingQuery($query, $start, $end, $target, null); + + if ($type == 'all') { + $price_column = 'price'; + } + else { + $price_column = 'final_price'; + } + + $data_for_categories = BookedProduct::selectRaw('product_id, SUM(' . $price_column . ') as price, category_id')->whereHas('booking', function($query) use ($type, $start, $end, $target) { + $this->createBookingQuery($query, $type, $start, $end, $target, null); })->join('products', 'booked_products.product_id', '=', 'products.id')->groupBy('product_id', 'category_id')->get(); foreach($data_for_categories as $dfc) { @@ -153,17 +176,12 @@ private function getSummary($start, $end, $target) return [$data, $categories]; } - private function getSupplier($start, $end, $target, $supplier) + private function getSupplier($start, $end, $type, $target, $supplier) { $data = []; $categories = []; - /* - TODO: ottimizzare usando gli stessi criteri di getSummary() anziché - iterare tutte le prenotazioni ed i prodotti - */ - - $bookings = $this->createBookingQuery(Booking::query(), $start, $end, $target, $supplier)->with('order', 'products')->get(); + $bookings = $this->createBookingQuery(Booking::query(), $type, $start, $end, $target, $supplier)->with(['order', 'products'])->get(); foreach ($bookings as $booking) { foreach ($booking->products as $product) { @@ -185,8 +203,16 @@ private function getSupplier($start, $end, $target, $supplier) } $data[$name]->users[$booking->user_id] = true; - $data[$name]->value += $product->final_price; - $categories[$product->product->category_id]->value += $product->final_price; + + if ($type == 'all') { + $price = $product->product->price; + } + else { + $price = $product->final_price; + } + + $data[$name]->value += $price; + $categories[$product->product->category_id]->value += $price; } } @@ -202,17 +228,18 @@ public function show(Request $request, $id) $start = decodeDate($request->input('startdate')); $end = decodeDate($request->input('enddate')); $target = fromInlineId($request->input('target')); + $type = $request->input('type') ?: 'shipped'; $csv_headers = []; switch ($id) { case 'summary': - list($data, $categories) = $this->getSummary($start, $end, $target); + list($data, $categories) = $this->getSummary($start, $end, $type, $target); $csv_headers = [_i('Fornitore'), _i('Valore Ordini'), _i('Utenti Coinvolti')]; break; case 'supplier': $supplier = $request->input('supplier'); - list($data, $categories) = $this->getSupplier($start, $end, $target, $supplier); + list($data, $categories) = $this->getSupplier($start, $end, $type, $target, $supplier); $csv_headers = [_i('Prodotto'), _i('Valore Ordini'), _i('Utenti Coinvolti')]; break; } diff --git a/code/public/js/gasdotto.js b/code/public/js/gasdotto.js index 52646deb..b8f0c42f 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:"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}()},72:(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+" 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);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");$(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)})),this.compactFilter(o,s,!1)}}}}],(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){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var n,o,s,r,a=[],l=!0,c=!1;try{if(s=(i=i.call(t)).next,0===e){if(Object(i)!==i)return;l=!1}else for(;!(l=(n=s.call(i)).done)&&(a.push(n.value),a.length!==e);l=!0);}catch(t){c=!0,o=t}finally{try{if(!l&&null!=i.return&&(r=i.return(),Object(r)!==r))return}finally{if(c)throw o}}return a}}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return k(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return k(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(t,e){(null==e||e>t.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)&&R(e.prototype,i),n&&R(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();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 z(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)&&z(e.prototype,i),n&&z(e,n),Object.defineProperty(e,"prototype",{writable:!1}),t}();const Z=V;function Y(t){return Y="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},Y(t)}function X(t,e){for(var i=0;i":">",'"':""","'":"'"};function it(t,e){return"number"==typeof t?t+e:t}function nt(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 ot(t){return String.fromCharCode(97+t%26)}const st=2221e-19;function rt(t,e,i){return e/i.range*t}function at(t,e){const i=Math.pow(10,e||tt);return Math.round(t*i)/i}function lt(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=rt(t,o.step,o)=i)o.step=1;else if(n&&r=i)o.step=r;else{let e=0;for(;;){if(s&&rt(t,o.step,o)<=i)o.step*=2;else{if(s||!(rt(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?st:-st)),t}o.step=Math.max(o.step,st);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=at(t);e!==u[u.length-1]&&u.push(e)}return o.values=u,o}function ct(){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 ht(t,e){return Array.from({length:t},e?(t,i)=>e(i):()=>{})}function dt(t,e){return null!==t&&"object"==typeof t&&Reflect.has(t,e)}function pt(t){return null!==t&&isFinite(t)}function ft(t){return!t&&0!==t}function mt(t){return pt(t)?Number(t):void 0}function gt(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 vt(t,e){const i=Array.isArray(t)?t[e]:dt(t,"data")?t.data[e]:null;return dt(i,"meta")?i.meta:void 0}function yt(t){return null==t||"number"==typeof t&&isNaN(t)}function bt(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)&&dt(t,e)?mt(t[e]):mt(t)}function _t(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(!yt(e))if(Array.isArray(e))for(let i=0;in.high&&(n.high=t),s&&t0||(n.high=1),n.low=0)),n}function wt(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:Ct(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(...ht(Math.max(0,e-t.length)))}))),s.labels.push(...ht(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)dt(e,"data")?e.data.reverse():Array.isArray(e)&&e.reverse()}(s),s}function xt(t,e){if(!yt(t))return e?function(t,e){let i,n;if("object"!=typeof t){const o=mt(t);"x"===e?i=o:n=o}else dt(t,"x")&&(i=mt(t.x)),dt(t,"y")&&(n=mt(t.y));if(void 0!==i||void 0!==n)return{x:i,y:n}}(t,e):mt(t)}function kt(t,e){return Array.isArray(t)?t.map((t=>dt(t,"value")?xt(t.value,e):xt(t,e))):kt(t.data,e)}function Ct(t,e,i){if(function(t){return Array.isArray(t)&&t.every((t=>Array.isArray(t)||dt(t,"data")))}(t))return t.map((t=>kt(t,e)));const n=kt(t,e);return i?n.map((t=>[t])):n}function Tt(t){let e="";return null==t?t:(e="number"==typeof t?""+t:"object"==typeof t?JSON.stringify({data:t}):String(t),Object.keys(et).reduce(((t,e)=>t.replaceAll(e,et[e])),e))}class Dt{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:$t[s]),r.begin=it(r.begin,"ms"),r.dur=it(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=nt(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 At{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(J[i[0]],e,String(t[e]))}else this._node.setAttribute(e,String(t[e]))})),this)}elem(t,e,i){return new At(t,e,i,this,arguments.length>3&&void 0!==arguments[3]&&arguments[3])}parent(){return this._node.parentNode instanceof SVGElement?new At(this._node.parentNode):null}root(){let t=this._node;for(;"svg"!==t.nodeName&&t.parentElement;)t=t.parentElement;return new At(t)}querySelector(t){const e=this._node.querySelector(t);return e?new At(e):null}querySelectorAll(t){const e=this._node.querySelectorAll(t);return new Dt(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",J.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=>Et(this,n,t,!1,i))):Et(this,n,o,e,i)})),this}constructor(t,e,i,n,o=!1){t instanceof Element?this._node=t:(this._node=document.createElementNS(J.svg,t),"svg"===t&&this.attr({"xmlns:ct":J.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 St(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(J.xmlns,"ct"))).forEach((e=>t.removeChild(e)));const o=new At("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 Ot(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()||nt(e.width).value||0,d=t.height()||nt(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 Pt(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 It(t,e,i){let n;const o=[];function s(o){const s=n;n=ct({},t),e&&e.forEach((t=>{window.matchMedia(t[0]).matches&&(n=ct(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}}At.Easing=$t;class Mt{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 jt=new WeakMap;class Lt{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=ct({},i?this.options:this.defaultOptions,e),this.initializeTimeoutId||(null===(n=this.optionsProvider)||void 0===n||n.removeMediaQueryListeners(),this.optionsProvider=It(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 jt.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=It(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 Mt,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=jt.get(s);r&&r.detach(),jt.set(s,this)}}const Nt={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 Ht{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&&ft(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===Nt.x?Nt.y:Nt.x,this.axisLength=e[this.units.rectEnd]-e[this.units.rectStart],this.gridOffset=e[this.units.rectOffset]}}class Ft extends Ht{projectValue(t){const e=Number(bt(t,this.units.pos));return this.axisLength*(e-this.bounds.min)/this.bounds.range}constructor(t,e,i,n){const o=n.highLow||_t(e,n,t.pos),s=lt(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 Rt extends Ht{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 qt(t){return e=t,i=function(){for(var t=arguments.length,e=new Array(t),i=0;i({x:t.x+(dt(e,"x")?e.x:0),y:t.y+(dt(e,"y")?e.y:0)})),{x:0,y:0})},ht(Math.max(...e.map((t=>t.length))),(t=>i(...e.map((e=>e[t])))));var e,i}const Ut={axisX:{offset:30,position:"end",labelOffset:{x:0,y:0},showLabel:!0,showGrid:!0,labelInterpolationFnc:ut,scaleMinSpace:30,onlyInteger:!1},axisY:{offset:40,position:"start",labelOffset:{x:0,y:0},showLabel:!0,showGrid:!0,labelInterpolationFnc:ut,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 Wt extends Lt{createChart(t){const{data:e}=this,i=wt(e,t.reverseData,t.horizontalBars?"x":"y",!0),n=St(this.container,t.width,t.height,t.classNames.chart+(t.horizontalBars?" "+t.classNames.horizontalBars:"")),o=t.stackBars&&!0!==t.stackMode&&i.series.length?_t([qt(i.series)],t,t.horizontalBars?"x":"y"):_t(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=Ot(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 Ft(Nt.x,i.series,l,{...t.axisX,highLow:o,referenceValue:0}):new t.axisX.type(Nt.x,i.series,l,{...t.axisX,highLow:o,referenceValue:0}),h=p=void 0===t.axisY.type?new Rt(Nt.y,i.series,l,{ticks:u}):new t.axisY.type(Nt.y,i.series,l,t.axisY)):(h=d=void 0===t.axisX.type?new Rt(Nt.x,i.series,l,{ticks:u}):new t.axisX.type(Nt.x,i.series,l,t.axisX),c=p=void 0===t.axisY.type?new Ft(Nt.y,i.series,l,{...t.axisY,highLow:o,referenceValue:0}):new t.axisY.type(Nt.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&&Pt(s,l,t.classNames.gridBackground,this.eventEmitter),gt(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"),_=dt(n,"name")&&n.name,w=dt(n,"className")&&n.className,x=dt(n,"meta")?n.meta:void 0;_&&u.attr({"ct:series-name":_}),x&&u.attr({"ct:meta":Tt(x)}),u.addClass([t.classNames.series,w||"".concat(t.classNames.series,"-").concat(ot(o))].join(" ")),i.series[o].forEach(((e,r)=>{const _=dt(e,"x")&&e.x,w=dt(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 Rt&&(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 D=vt(n,r),$=u.elem("line",T,t.classNames.bar).attr({"ct:value":[_,w].filter(pt).join(","),"ct:meta":Tt(D)});this.eventEmitter.emit("draw",{type:"bar",value:e,index:r,meta:D,series:n,seriesIndex:o,axisX:d,axisY:p,chartRect:l,group:u,element:$,...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,Ut,ct({},Ut,i),n),this.data=e}}function zt(t){return zt="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},zt(t)}function Bt(t,e){for(var i=0;i'+e.item.label+'
');var n=i.closest(".completion-rows"),o=K.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=K.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==Xt?r.Z.postAjax({method:"GET",url:"measures/discretes",dataType:"JSON",success:function(t){Xt=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),O.init(t),a.Z.init(t),h.init(t),H.init(t),m.init(t),b.init(t),U.init(t),Z.init(t),Q.init(t),Zt.init(t)}function Kt(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 Jt(t,e){if(1==Yt)return!1;var i;if(Yt=!0,0!=(i=t.find("input[name=test-feedback]")).length&&"error"==e.status)return r.Z.displayServerError(t,e),Yt=!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