2 lines
54 KiB
JavaScript
2 lines
54 KiB
JavaScript
(()=>{function _typeof(t){return _typeof="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},_typeof(t)}function _defineProperties(t,a){for(var r=0;r<a.length;r++){var o=a[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,_toPropertyKey(o.key),o)}}function _defineProperty(t,a,r){return(a=_toPropertyKey(a))in t?Object.defineProperty(t,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[a]=r,t}function _toPropertyKey(t){var a=function _toPrimitive(t,a){if("object"!=_typeof(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,a||"default");if("object"!=_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===a?String:Number)(t)}(t,"string");return"symbol"==_typeof(a)?a:a+""}var t=function(){return function _createClass(t,a,r){return a&&_defineProperties(t.prototype,a),r&&_defineProperties(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(function ModuleBase(t,a){!function _classCallCheck(t,a){if(!(t instanceof a))throw new TypeError("Cannot call a class as a function")}(this,ModuleBase),_defineProperty(this,"Opts",{testMode:!1,CSSSelectorContainer:"",CSSSelectorForm:"",token:null,URL:{getDataTableContent:null,checkReadyToSend:null,index:null,show:null,edit:null,create:null,store:null,update:null,destroy:null},dataTable:{orderDirective:[1,"asc"],CSSSelector:null,advanceSearchParameter:{}}}),_defineProperty(this,"data",null),_defineProperty(this,"root",this),this.Opts.CSSSelectorContainer=".container"+this.constructor.name,this.Opts.CSSSelectorForm="."+this.constructor.name+"Form",this.Opts.dataTable.CSSSelector=this.Opts.CSSSelectorContainer+" .dataTable",this.root=this,"undefined"===a&&null==a||(this.data=a),null!=t&&$.extend(this.Opts,t)},[{key:"init",value:function init(t,a){"undefined"===a&&null==a||(this.data=a),null!=t&&$.extend(this.Opts,t)}},{key:"datatableRowActionButtonClick",value:function datatableRowActionButtonClick(t,a,r){debug("call ModuleBase.datatableRowActionButtonClick"),debug(a);var o=$(t[0].currentTarget),i=$(a.Opts.dataTable.CSSSelector).DataTable().row(o.parents("tr")).data(),l="datatableRowAction"+o.data("buttontype").capitalize();if("function"==typeof a[l])return a[l](i,o)}},{key:"datatableRowActionAttachment",value:function datatableRowActionAttachment(t,a,r){debug("call ModuleBase.datatableRowActionAttachment ");var o="downloadedFile";void 0!==r.defaultFileName&&(o=r.defaultFileName),t.fileUrl?(t.fileName&&(o=t.fileName),$.ajax({url:t.fileUrl,method:"GET",xhrFields:{responseType:"blob"},success:function success(t){var a=document.createElement("a"),r=window.URL.createObjectURL(t);a.href=r,a.download=o,document.body.append(a),a.click(),a.remove(),window.URL.revokeObjectURL(r)}})):Toast.create({title:"Hiba!",message:"Nincs csatolt fájl!",status:TOAST_STATUS.DANGER,timeout:1e4})}},{key:"datatableRowActionView",value:function datatableRowActionView(t,a,r,o){debug("call ModuleBase.datatableRowActionView");var i=r.Opts.URL.show.replace("%id%",t.id);console.log(i),APP.loadMainContent(i,r.initViewShow),console.log("ModuleBase.datatableRowActionEdit End")}}])}();window.ModuleBase=t})(),(()=>{function _typeof(t){return _typeof="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},_typeof(t)}function _createForOfIteratorHelper(t,a){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function _unsupportedIterableToArray(t,a){if(t){if("string"==typeof t)return _arrayLikeToArray(t,a);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,a):void 0}}(t))||a&&t&&"number"==typeof t.length){r&&(t=r);var o=0,i=function F(){};return{s:i,n:function n(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function e(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,c=!0,d=!1;return{s:function s(){r=r.call(t)},n:function n(){var t=r.next();return c=t.done,t},e:function e(t){d=!0,l=t},f:function f(){try{c||null==r.return||r.return()}finally{if(d)throw l}}}}function _arrayLikeToArray(t,a){(null==a||a>t.length)&&(a=t.length);for(var r=0,o=Array(a);r<a;r++)o[r]=t[r];return o}function _defineProperties(t,a){for(var r=0;r<a.length;r++){var o=a[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,_toPropertyKey(o.key),o)}}function _toPropertyKey(t){var a=function _toPrimitive(t,a){if("object"!=_typeof(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,a||"default");if("object"!=_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===a?String:Number)(t)}(t,"string");return"symbol"==_typeof(a)?a:a+""}function _callSuper(t,a,r){return a=_getPrototypeOf(a),function _possibleConstructorReturn(t,a){if(a&&("object"==_typeof(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,_isNativeReflectConstruct()?Reflect.construct(a,r||[],_getPrototypeOf(t).constructor):a.apply(t,r))}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _setPrototypeOf(t,a){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,a){return t.__proto__=a,t},_setPrototypeOf(t,a)}window.OrderModulDefault={actionFunction:function actionFunction(){}};var t=function(){function DataModelOrder(t,a){var r;return function _classCallCheck(t,a){if(!(t instanceof a))throw new TypeError("Cannot call a class as a function")}(this,DataModelOrder),void 0===(r=_callSuper(this,DataModelOrder,[t,a])).productSelected&&(r.productSelected={}),void 0===r.productComment&&(r.productComment={}),console.log(r.constructor.name+" constructor called"),r}return function _inherits(t,a){if("function"!=typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(a&&a.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),a&&_setPrototypeOf(t,a)}(DataModelOrder,DataModel),function _createClass(t,a,r){return a&&_defineProperties(t.prototype,a),r&&_defineProperties(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(DataModelOrder)}();window.DataModelOrder=t,window.Stepper=function(){var t={complete:["supplier"],available:["supplier","parameter","productSelect","invoice","send"],enable:["supplier","invoice"],load:[],excludeLoaded:["invoice","send"],loaded:[],active:!1,URL:{create:""},UrlData:!1,onAfterLoad:function onAfterLoad(){},onAfterActivate:function onAfterActivate(){},autoCallback:{invoice:{onAfterActivate:function onAfterActivate(){}},send:{onAfterActivate:function onAfterActivate(){}}},nowLoaded:!1},a=this;this.construct=function(a){$.extend(t,a)},this.getOpts=function(){return t},this.setOpts=function(a){$.extend(t,a)},this.init=function(r){$.extend(t,r),debug(t),$(".step").each(function(){var r=$(this).data("stepname");t.complete.includes(r)&&a.setCompleted(r),t.enable.includes(r)&&a.setEnabled(r),t.load.includes(r)&&a.loadStepContent(r),t.active===r&&a.setActive(r)}),a.bindClickAction()},this.bindClickAction=function(){var t=$(".stepClick");t.off("click"),t.on("click",a.stepClick)},this.setCompleted=function(t){console.log(t+" completed"),$('.step[data-stepName="'+t+'"]').addClass("completed")},this.unsetCompleted=function(a){console.log(a+" Uncompleted"),$('.step[data-stepName="'+a+'"]').removeClass("completed"),t.complete=arrayRemove(t.complete,a)},this.unsetEnabled=function(a){console.log(a+" Un enabled"),$(".click"+a).contents().unwrap(),t.enable=arrayRemove(t.enable,a)},this.setEnabled=function(t){console.log(t+" enabled");var r=$('.step[data-stepName="'+t+'"]');r.html('<a class="stepClick click'+t+'" data-stepName="'+t+'" href="#">'+r.html()+"</a>"),a.bindClickAction()},this.addEnabled=function(r){t.enable.includes(r)||t.enable.push(r),a.setEnabled(r)},this.addCompleted=function(r){t.complete.includes(r)||t.complete.push(r),a.setCompleted(r),a.bindClickAction()},this.loadStepContent=function(a){var r={type:a};$.extend(r,t.UrlData),$.ajax({async:!0,type:"GET",url:t.URL.create,data:r,cache:!1,success:function success(r){var o=$(".SC"+a.capitalize());-1==$.inArray(a,t.excludeLoaded)?t.loaded.push(a):console.log("excluded View"),o.html(r),t.nowLoaded&&t.nowLoaded(a),t.onAfterLoad()}})},this.clearLoaded=function(){t.loaded=["supplier"],$(".stepContainer").each(function(){this.classList.contains("SCSupplier")||$(this).html("")})},this.setActiveFinish=function(r){var o=$(".SC"+r.capitalize());"productSelect"===r?$(".containerStepper").addClass("activeSideBar"):$(".containerStepper").removeClass("activeSideBar"),debug("setActiveFinish show:"+r),o.show(),t.nowLoaded=!1,a.active=r,t.onAfterActivate(),void 0!==t.autoCallback[r]&&t.autoCallback[r].onAfterActivate()},this.setActive=function(r){$(".stepContainer").hide(),t.loaded.includes(r)?this.setActiveFinish(r):(a.loadStepContent(r),t.nowLoaded=this.setActiveFinish)},this.stepClick=function(t){t.preventDefault();var r=$(t.currentTarget).data("stepname");console.log("setActive:"+r),a.setActive(r)}},window.OrderModule=function(){var a={testMode:!1,needStepper:!0,CSSSelectorForm:".orderParameterForm",defaultDeliveryDate:"",dataSyncPauseTime:500,token:null,URL:{root:null,getDataTableContentProductList:null,checkReadyToSend:null,index:null,show:null,edit:null,create:null,store:null,update:null,destroy:null,toggleFavorites:null}},r=null,o=this,i=[];this.setOpts=function(t){$.extend(a,t)},this.getOpts=function(){return a},this.clickOrderEdit=function(t){debug("clickEdit"),debug(t);var r=a.URL.edit.replace("%id%",t.id);APP.loadMainContent(r)},this.afterOrderDeleted=function(t){1==t.success?(debug("Order delete success"),APP.loadMainContent(a.URL.index)):Toast.create({title:"Error deleted !",message:"",status:TOAST_STATUS.DANGER,timeout:5e3})},this.clickOrderDeleteConfirmed=function(t){debug("clickOrderDeleteConfirmed"),debug(t),debug(t.data),$("#dialogModal").modal("hide");var r={};r._token=a.token;var i=a.URL.destroy.replace("%id%",t.data.id);$.ajax({url:i,data:r,method:"DELETE",success:o.afterOrderDeleted})},this.initViewOrderSelect=function(){debug("called initViewOrderSelect "),$(".ordersSelectTable button").off("click"),$(".ordersSelectTable button").on("click",function(){var t=$(this).data("action"),a=$($(this).closest("tr")[0]).data("orderid");debug(t),debug(a),"delete"==t?($("#dialogModal").on("show.bs.modal",function(t){var r=$(this);r.find(".modal-title").text("Megerősítés "),r.find(".modal-body").text("Biztosan törli a megrendelést?"),r.find(".buttonYes").off("click"),r.find(".buttonYes").on("click",{id:a},o.clickOrderDeleteConfirmed)}),$("#dialogModal").modal("show")):o.clickOrderEdit({id:a})}),$(".buttonNew").off("click"),$(".buttonNew").on("click",function(){APP.loadMainContent(a.URL.index,"force=true")})},this.initStepper=function(){debug(r.getData()),i=[],$(".statusNamePlace").text("Nincs elküldve"),$(".statusNamePlace").addClass("statusBlink"),o.setDeliveryDate("-"),o.setSupplier("-"),$.each(["parameter","productSelect","invoice","send"],function(t,a){o.Stepper.unsetEnabled(a),o.Stepper.unsetCompleted(a)}),debug(o.Stepper.getOpts().available),debug(r.getData().orderStatus);var t,l="supplier",c=["supplier"],d=[],u=function stepOnAfterActivate(){},p=o.Stepper.getOpts().available,b=!1,v=[],h=_createForOfIteratorHelper(p);try{for(h.s();!(t=h.n()).done;){var y=t.value;u=this["initView"+y.capitalize()];var m={};m.onAfterActivate=u,v[y]=m}}catch(t){h.e(t)}finally{h.f()}if(debug(v),debug(r.getData().id),r.getData().id>0){debug("hajra"),debug(r.getData()),r.getData().deliveryDate&&o.setDeliveryDate(r.getData().deliveryDate),r.getData().supplierName&&o.setSupplier(r.getData().supplierName),b={supplierId:r.supplierId,id:r.id};var g,S=_createForOfIteratorHelper(p);try{for(S.s();!(g=S.n()).done;){var w=g.value;if(console.log(w),c.push(w),d.push(w),r.getData().orderStatus==w){l=w;break}}}catch(t){S.e(t)}finally{S.f()}}o.Stepper.init({complete:c,enable:d,loaded:[],active:l,URL:{create:a.URL.create},UrlData:b,onAfterActivate:u,autoCallback:v})},this.initOrder=function(a){r=new t(a)},this.init=function(i){if(debug("OrderModul init called"),$.extend(a,window.OrderModulDefault,i),r=new t,a.needStepper&&void 0===this.Stepper&&(this.Stepper=new Stepper),a.testMode)return o.testMode()},this.setSupplier=function(t,a){t&&$(".supplierNamePlace").text(t),a&&(r.setData({supplierId:a}),o.Stepper.setOpts({UrlData:{supplierId:a}}))},this.setDeliveryDate=function(t,r){var o=t.replaceAll("-",".")+".";o.length<5?$(".deliveryDatePlace").text(t):(r&&(o+=" - "+r.replaceAll("-",".")+"."),$(a.CSSSelectorForm+" .selectedDateText").text(o),$(".deliveryDatePlace").text(o),$(a.CSSSelectorForm+' input[name="deliveryDate"]').val(t))},this.getData=function(){return r},this.setSupplierCompleted=function(){console.log("bingo"),o.initViewParameter()},this.afterOrderSetSupplierOk=function(t){Toast.create({title:"Supplier selected !",message:t.supplier.name,status:TOAST_STATUS.INFO,timeout:5e3}),o.setSupplier(t.supplier.name,t.supplier.id),r.setData({id:t.id}),o.Stepper.setOpts({UrlData:{supplierId:r.supplierId,id:r.id}}),o.Stepper.setEnabled("parameter"),o.Stepper.addCompleted("parameter"),o.Stepper.setCompleted("parameter"),o.Stepper.setActive("parameter")},this.initViewSupplier=function(){debug("call initViewSupplier"),o.Stepper.setOpts({onAfterLoad:function onAfterLoad(){}}),$(".supplierItem").off("click"),$(".supplierItem").on("click",function(i){console.log(r.getData()),i.preventDefault();var l=$(i.currentTarget).data("id"),c=$(i.currentTarget).find("h5.card-title").text();if(void 0===r.supplierId){var d={};d._token=a.token,d.supplierId=l,d.storeType="supplierSelect",$.extend(d,r),$.ajax({url:a.URL.store,method:"POST",data:d,success:function success(t){t.success&&o.afterOrderSetSupplierOk(t.data)}})}else r.supplierId!=l&&(Toast.create({title:"Supplier change to!",message:c,status:TOAST_STATUS.WARNING,timeout:5e3}),o.Stepper.clearLoaded(),r=new t)})},this.checkContactNameField=function(){var t=$(".orderParameterForm input[name=contactName]");return t.val().length<2?(t.removeClass("is-valid"),t.addClass("is-invalid"),!1):(t.addClass("is-valid"),t.removeClass("is-invalid"),!0)},this.sendOrderDataToServer=function(t,o,i){var l={},c=a.URL.store;r.id&&(c=a.URL.update.replace("%id%",r.id),l._method="PUT"),l._token=a.token,l.updateType=t,$.extend(l,r),debug(r),debug(l),debug("ajaxUrl:"+c),l=jsonToFormData(l),$.ajax({url:c,data:l,type:"POST",contentType:!1,processData:!1,success:function success(t){debug("ajax returned data"),debug(t),t.success&&o(t)},error:function error(t,a,r){ajaxErrorHandler(t,a,r),void 0!==i&&i(t.responseJSON)}})},this.afterOrderSetParameterOk=function(t){debug("called afterOrderSetParameterOk"),o.Stepper.setOpts({UrlData:{supplierId:r.supplierId,id:r.id}}),o.Stepper.setEnabled("productSelect"),o.Stepper.addCompleted("productSelect"),o.Stepper.setCompleted("productSelect"),o.Stepper.setActive("productSelect")},this.selectCurrentWeek=function(){console.error("selectCurrentWeek"),console.error($(".ui-datepicker").find(".ui-datepicker-current-day a")),$(".ui-datepicker").find(".ui-datepicker-current-selected-weekday a").addClass("ui-state-active")},this.weekHover=function(){console.error("hover Active"),$(".ui-datepicker-calendar tr").off("mousemove"),$(".ui-datepicker-calendar tr").off("mouseleave"),$(".ui-datepicker-calendar tr").on("mousemove",function(){$(this).find("td a").addClass("ui-state-hover")}),$(".ui-datepicker-calendar tr").on("mouseleave",function(){$(this).find("td a").removeClass("ui-state-hover")})},this.weekHoverSlow=function(){console.error("weekHoverSlow"),$(".ui-datepicker-calendar tr").length<1?setTimeout(o.weekHoverSlow,1):o.weekHover()},this.initDatePicker=function(t){console.error("asdasdadad"),console.log("tipus"+t);var a=".orderParameterForm",r=new Date("1900-01-01"),i=new Date("1900-01-02");$(a+" .datePicker").datepicker("destroy"),"weekly"==t?$(a+" .datePicker").datepicker({showOtherMonths:!0,selectOtherMonths:!0,showWeek:!0,dateFormat:"yy-mm-dd",firstDay:1,minDate:new Date,afterShow:function afterShow(t,a){o.weekHover(),o.selectCurrentWeek()},onSelect:function onSelect(t,a){var l=$(this).datepicker("getDate");r=new getMonday(l),i=new Date(l.getFullYear(),l.getMonth(),l.getDate()-l.getDay()+7),o.setDeliveryDate($.datepicker.formatDate("yy-mm-dd",r),$.datepicker.formatDate("yy-mm-dd",i))},beforeShow:function beforeShow(){console.group("beforeShow"),console.log(r),console.log(i),console.groupEnd()},beforeShowDay:function beforeShowDay(t){console.group("beforeShowDay"),console.log(t.toLocaleDateString("hu-Hu"));var a="";return t>=r&&t<=i&&(console.error(t.toLocaleDateString("hu-Hu")),a="ui-datepicker-current-selected-weekday"),console.log(a),console.groupEnd(),[!0,a]},onChangeMonthYear:function onChangeMonthYear(t,a,r){}}):$(a+" .datePicker").datepicker({dateFormat:"yy-mm-dd",minDate:new Date,onSelect:function onSelect(t){$(a+" .selectedDateText").text(t),$(".deliveryDatePlace").text(t.replaceAll("-",".")+"."),$(a+' input[name="deliveryDate"]').val(t)}})},this.callChangeOrderType=function(){console.log(this),console.log(this.value),o.initDatePicker(this.value)},this.initViewParameter=function(){debug("call initViewParameter"),o.Stepper.setOpts({onAfterLoad:function onAfterLoad(){}});var t=".orderParameterForm";if($(t+" .datePickerClick").click(function(){$(t+" .datePicker").datepicker("show")}),$(t+" .orderParameterDeliveryAddress").select2({}).show(),$(t+" input[name=contactName]").off("blur"),$(t+" input[name=contactName]").off("keyup"),$(t+" input[name=contactName]").on("blur",o.checkContactNameField),$(t+" input[name=contactName]").on("keyup",o.checkContactNameField),$(t+" input[name=orderType]").off("change"),$(t+" input[name=orderType]").on("change",o.callChangeOrderType),$(t+" .orderParameterNextButton").off("click"),r.getData().id>0){if("weekly"==r.getData().orderType){o.initDatePicker(r.getData().orderType),$(t+" input[name=orderType][value="+r.getData().orderType+"]").prop("checked",!0);var a=new Date(r.getData().deliveryDate);a.setDate(a.getDate()+6),o.setDeliveryDate(r.getData().deliveryDate,$.datepicker.formatDate("yy-mm-dd",a)),o.initDatePicker("weekly")}else r.getData().deliveryDate&&o.setDeliveryDate(r.getData().deliveryDate),o.initDatePicker("daily");r.getData().contactName&&$(t+" input[name=contactName]").val(r.getData().contactName),r.getData().note&&$(t+" textarea[name=note]").val(r.getData().note),r.getData().deliveryAddressId&&(console.log($(t+" select[name=deliveryAddressId]")),$(t+" select[name=deliveryAddressId]").val(r.getData().deliveryAddressId)),r.getData().customNotificationEmail&&(console.log($(t+" select[name=customNotificationEmail]")),$(t+" select[name=customNotificationEmail]").val(r.getData().customNotificationEmail))}else o.initDatePicker("daily");$(t+" .orderParameterDeliveryAddress").select2({}).show(),$(t+" .orderParameterCustomNotificationEmail").select2({}).show(),$(t).submit(function(a){if(a.preventDefault(),!1===$(t)[0].checkValidity())return debug("validaton false"),void a.stopPropagation();debug("validaton ok"),$(".deliveryDatePlace").text($(t+" input[name=deliveryDate]").val().replaceAll("-",".")+"."),r.setData({contactName:$(t+" input[name=contactName]").val(),note:$(t+" textarea[name=note]").val(),orderType:$(t+" input:checked[name=orderType]").val(),deliveryDate:$(t+" input[name=deliveryDate]").val(),deliveryAddressId:$(t+" select[name=deliveryAddressId]").val(),deliveryAddress:$(t+" select[name=deliveryAddress]").val(),customNotificationEmail:$(t+" select[name=customNotificationEmail]").val()}),console.group("parameter form submit"),console.error($(t+" input:checked[name=orderType]").val()),console.error($(t+" input[name=deliveryDate]").val()),debug(r.getData()),console.groupEnd(),o.sendOrderDataToServer("parameter",o.afterOrderSetParameterOk)})},this.blank=function(){},this.setParameterCompleted=function(){console.log("setParameterCompleted called"),o.Stepper.setOpts({onAfterLoad:function onAfterLoad(){}})},this.bindRowFavoritesAction=function(){$(".buttonItemFavorites").off("click"),$(".buttonItemFavorites").on("click",function(){var t=$(this).data("id");console.log(t);var r=a.URL.toggleFavorites.replace("%id%",t),o={};o._token=a.token;var i=this;console.log(r),$.ajax({url:r,method:"POST",data:o,success:function success(t){t.success&&(t.status?(console.log("true"),$(i).addClass("btn-warning"),$(i).removeClass("btn-light")):($(i).removeClass("btn-warning"),$(i).addClass("btn-light"),console.log("false")))}})})},this.bindRowDescriptionAction=function(){$("textarea.orderItemComment").on("change",function(){var t=$(this).val(),a=$(this).data("id"),i=r.getData("productComment");if(null!==i){if(void 0===i[a]&&0===t.length)return;if(i[a]===t)return}i[a]=t,0===t.length&&delete r.productComment[a],r.productComment=i,u.push(Date.now()),o.syncOrderDataToServer()})},this.productSelectDatatablesRowFormatter=function(t){console.group("productSelectDatatablesRowFormatter"),console.log(t);var a=t;a.comment="",r.productComment&&null!==r.productComment&&(debug(_typeof(r.productComment[t.id])),void 0!==r.productComment[t.id]&&r.productComment[t.id].length>0&&(a.comment=r.productComment[t.id])),!0===t.favorites?a.btnFavoritesClass="btn-warning":a.btnFavoritesClass="btn-light";var o=$('template[data-name="orderProductSelectDetails"]').html();a.weekly=!1,"weekly"===r.getData().orderType&&(a.weekly=!0);var i=r.getData("productSelected");void 0!==i[t.id]&&(a.itemQuantity=i[t.id]),console.log(["templateData",a]);var l=Mustache.tags;Mustache.tags=["~!","!~"],"false"!=a.specification&&0!=a.specification||(a.specificationClass="d-none"),a.pictureImg="","false"==a.picture||0==a.picture?a.pictureClass="d-none":a.pictureImg='<img src= "'+a.picture+'" class="productPicture" ></img>',console.log("templateData",a);var c=Mustache.render(o,a);return Mustache.tags=l,console.groupEnd(),c},this.setDatatableHeaderText=function(t){$(".tableHeaderText").text(t)},this.getTreePathName=function(t){var a="",r=$(t).parents("li").toArray();for(var o in r.shift(),r.reverse(),r)console.log($(r[o]).children("a.categoryItem")),$(r[o]).children("a.categoryItem").length>0&&(a+=$(r[o]).children("a.categoryItem").text()+"/");return a+=$(t).text(),console.log(a),a};var l=null,c=null,d=!1;this.searchProductByString=function(t){o.setDatatableHeaderText("Termékek szűrve:"+t),c=t,$(".dataTableOrderProductSelect").DataTable().ajax.reload()},this.clickSearchProduct=function(){debug(this);var t=$(".sidebar-search input[name=searchValue]").val();debug(t),o.searchProductByString(t)},this.clickFavoritesProduct=function(){debug("clickFavoritesProduct"),o.setDatatableHeaderText("Termékek szűrve: kedvencek"),c="**favorites**",$(".dataTableOrderProductSelect").DataTable().ajax.reload()},this.clickOftenProduct=function(){debug("clickOftenProduct"),o.setDatatableHeaderText("Termékek szűrve: gyakran vásárolt"),c="**often**",$(".dataTableOrderProductSelect").DataTable().ajax.reload()},this.clickSpecialOffer=function(){debug("clickSpecialOffer"),o.setDatatableHeaderText("Termékek szűrve: Akciós termékek"),c="**specialOffer**",$(".dataTableOrderProductSelect").DataTable().ajax.reload()},this.clickLastProduct=function(){debug("clickLastProduct"),o.setDatatableHeaderText("Termékek szűrve: utoljára vásárolt"),c="**last**",$(".dataTableOrderProductSelect").DataTable().ajax.reload()},this.clickWeeklyProduct=function(){debug("clickWeeklyProduct"),o.setDatatableHeaderText("Termékek szűrve: Heti termékek"),c="**weekly**",$(".dataTableOrderProductSelect").DataTable().ajax.reload()},this.clickKrelProduct=function(){debug("clickKrelProduct"),$(this).parent().toggleClass("krelActive"),d=!d,$(".dataTableOrderProductSelect").DataTable().ajax.reload()},this.productSelectDataTableColumnDefs=function(){return[{width:"10px",targets:0},{className:"dt-left",targets:1},{width:"28px",targets:2},{width:"41px",targets:3},{width:"76px",targets:4},{width:"55px",targets:5},{width:"70px",targets:6},{width:"54px",targets:7},{width:"57px",targets:8},{width:"42px",targets:9},{width:"100px",targets:10},{className:"dt-center",targets:"_all"}]},this.productSelectDataTableColumn=function(){var t=[{className:"details-control",orderable:!1,data:null,defaultContent:""},{data:"name"},{data:"krel"},{data:"packing"},{data:"unitValue"},{data:"productUnit"},{data:"sellerUnit"},{data:"unitMultiplier"},{data:"amountUnit"},{data:"price"}],a={className:"details-control2",orderable:!1,data:null,width:"100px",defaultContent:""};return"daily"==r.getData("orderType")&&(a.defaultContent='<input type="number" value="0" min="0" max="9999" step="1" data-decimals="1" class="form-control-sm inputNumberSpinner" style="width: 1em;" "/>'),t.push(a),t},this.getDatatables=function(t){return console.error(t),$(".dataTableOrderProductSelect").DataTable({language:{url:"//cdn.datatables.net/plug-ins/1.10.24/i18n/Hungarian.json"},ajax:{url:a.URL.getDataTableContentProductList,data:function data(t){t.searchStr=c,t.krel=d,t.groupId=l,t.supplierId=r.supplierId,t.deliveryDate=r.deliveryDate}},buttons:{buttons:[]},columnDefs:o.productSelectDataTableColumnDefs(),columns:o.productSelectDataTableColumn(),order:[[1,"asc"]]})},this.productSelectDataTableDrawDT=function(t){$("td").filter(function(){return"*"===$(this).text()}).html('<i class="bi bi-check-circle-fill"></i>'),"daily"==r.getData().orderType&&$("input[type='number'].inputNumberSpinner").inputSpinner({template:'<div class="input-group ${groupClass}"><button style="min-width: ${buttonsWidth}" class="btn btn-sm btn-decrement ${buttonsClass}" type="button">${decrementButton}</button><input type="text" step="0.1" data-decimals="2" style="text-align: ${textAlign}" class="productQuantity form-control"/><button style="min-width: ${buttonsWidth}" class="btn btn-sm btn-increment ${buttonsClass}" type="button">${incrementButton}</button></div>',buttonsWidth:"0.5rem",groupClass:"",buttonsClass:"btn-outline-secondary"}),o.bindWeakUserHelper(),$(".dataTableOrderProductSelect .details-control2 input[type=text]").off("change"),$(".dataTableOrderProductSelect .details-control2 input[type=text]").on("change",function(t){var a=$(this).val();a=a.replace(",","."),a=parseFloat(a);var r=$(".dataTableOrderProductSelect").DataTable().row($(this).closest("tr")).data();o.orderItemsChange(r,a)}),$(".dataTableOrderProductSelect .details-control2 input[type=text]").each(function(){$(this).val();var t=$(".dataTableOrderProductSelect").DataTable().row($(this).closest("tr")).data();if(r.productSelected[t.id]){debug(t),debug($($(this).closest("tr").find("input[type=number]")[0])),debug(r.productSelected[t.id]);var a=r.productSelected[t.id];"string"!=typeof a&&(a+=""),$($(this).closest("tr").find("input[type=number]")[0]).val(a.replace(",","."))}}),$(".dataTableOrderProductSelect .details-control2 button").off("click"),$(".dataTableOrderProductSelect .details-control2 button").on("click",function(){$(this).parent().find("input[type=text]").trigger("change")})},this.initViewProductSelect=function(){var t="initViewProductSelect";if(console.log(t+" called"),!i.includes(t)){o.setDatatableHeaderText(""),o.Stepper.setOpts({onAfterActivate:function onAfterActivate(){}}),o.Stepper.addCompleted("invoice"),o.Stepper.addEnabled("invoice"),debug(".orderParameterForm .fa-search"),$(".sidebar-search .fa-search").off("click"),$(".sidebar-search .fa-search").on("click",o.clickSearchProduct),$("a.sidebar.favorites").off("click"),$("a.sidebar.favorites").on("click",o.clickFavoritesProduct),$("a.sidebar.often").off("click"),$("a.sidebar.often").on("click",o.clickOftenProduct),$("a.sidebar.last").off("click"),$("a.sidebar.last").on("click",o.clickLastProduct),$("a.sidebar.weekly").off("click"),$("a.sidebar.weekly").on("click",o.clickWeeklyProduct),$("a.sidebar.krel").off("click"),$("a.sidebar.krel").on("click",o.clickKrelProduct),$("a.sidebar.specialOffer").off("click"),$("a.sidebar.specialOffer").on("click",o.clickSpecialOffer),$(".sidebar-search input[name=searchValue]").off("keypress"),$(".sidebar-search input[name=searchValue]").on("keypress",function(t){13==t.which&&t.preventDefault(),$(this).val().length>=2&&o.searchProductByString($(this).val()+t.key)}),$(".sidebar-wrapper .sidebar-menu .sidebar-dropdown .sidebar-submenu li a.categoryItem.clickable").off("click"),$(".sidebar-wrapper .sidebar-menu .sidebar-dropdown .sidebar-submenu li a.categoryItem.clickable").on("click",function(){var t=$(this).data("id");l=t,c=null,console.log(t),console.log(o.getTreePathName(this)),o.setDatatableHeaderText(o.getTreePathName(this)),$(".dataTableOrderProductSelect").DataTable().ajax.reload()});var a=o.getDatatables(r.getData("orderType"));$(".dataTableOrderProductSelect").on("init.dt",function(){console.log("Table initialisation complete: "+(new Date).getTime())}).dataTable(),$(".dataTableOrderProductSelect").on("draw.dt",o.productSelectDataTableDrawDT).dataTable(),$(".dataTableOrderProductSelect").on("xhr.dt",function(){debug("Table xhr complete: "+(new Date).getTime())}).dataTable(),$(".dataTableOrderProductSelect tbody").on("click","td.details-control",function(){var t=$(this).closest("tr"),r=a.row(t);r.child.isShown()?(r.child.hide(),t.removeClass("shown")):(r.child(o.productSelectDatatablesRowFormatter(r.data())).show(),t.addClass("shown"),o.bindProductDetailsAction())}),i.push(t)}},this.bindProductDetailsAction=function(){o.bindRowDescriptionAction(),o.bindRowFavoritesAction(),"weekly"==r.getData().orderType&&o.bindOrderItemWeekQuantity()},this.bindWeakUserHelper=function(){$("input.inputNumberSpinner").off("focus"),$("input.inputNumberSpinner").on("focus",function(){var t=$(this).val();t=t.replace(",","."),0===(t=parseFloat(t))&&$(this).val("")}),$("input[type=text].inputNumberSpinner").off("keypress"),$("input[type=text].inputNumberSpinner").on("keypress",function(t){if(13==t.which){var a=this,r=$("input[type=text].inputNumberSpinner");r.each(function(t){if(this==a)return t+1<=r.length&&$(r[t+1]).focus(),!1})}})},this.bindOrderItemWeekQuantity=function(){$("input.productSelectDayQuantity").off("change"),$("input.productSelectDayQuantity").on("change",function(){console.log(this.name),console.log(this.value),console.log($(this).data("dayindex"));var t,a=$($(this).closest("table.orderProductSelectRowDetailsTable").closest("tr")).prev();t=$(".dataTableOrderProductSelect").DataTable().row(a).data(),console.log(t);var r=$(this).val();r=r.replace(",","."),r=parseFloat(r),console.log(t.id),o.orderItemsChange(t,r,$(this).data("dayindex"))})},this.afterSyncOrderDataToServer=function(t){for(var r=0;r<u.length;r++)console.log("shiftel"),u.shift();setTimeout(function(){p=!1,o.syncOrderDataToServer()},a.dataSyncPauseTime)};var u=[],p=!1;this.syncOrderDataToServer=function(){if(p)return!1;u.length<1||(p=!0,o.sendOrderDataToServer("productSelect",o.afterSyncOrderDataToServer))},this.orderItemsChange=function(t,a,i){isNaN(a)&&(a=0);var l=r.getData("productSelected");console.group("orderItemsChange"),console.log(["productSelected",l]),console.log(["ItemData",t]),console.log(["ItemData.id",t.id]),console.log(["quantity",a]),console.log(["dayIndex",i]),console.log(l[t.id]);var c=l[t.id];if(0==a){if(console.error("quantity==0"),void 0===c)return console.error("itt lep1"),void console.groupEnd();if(i&&(console.log("van dayIndex"),void 0===l[t.id][i]))return console.log(["productSelectedItem",c]),console.error("itt lep2"),void console.groupEnd()}if(i){if(void 0!==l[t.id]&&void 0!==l[t.id][i]&&l[t.id][i]==a)return console.error("azonos napi"),void console.groupEnd()}else if(l[t.id]==a)return console.error("azonos"),void console.groupEnd();0==a?i?(delete r.productSelected[t.id][i],delete l[t.id][i]):(delete r.productSelected[t.id],delete l[t.id]):i?(void 0===l[t.id]&&(l[t.id]=[]),console.log("set quantity productSelected[ItemData.id][dayIndex]",a),l[t.id][i]=a):(l[t.id]=a,console.log("set quantity productSelected[ItemData.id]",a)),console.log(["productSelected",l]),r.productSelected=l,console.groupEnd(),u.push(Date.now()),o.syncOrderDataToServer()},this.initViewInvoice=function(){o.Stepper.setOpts({onAfterLoad:function onAfterLoad(){}}),Object.keys(r.productSelected).length>0&&(o.Stepper.addCompleted("send"),o.Stepper.addEnabled("send")),a.URL.root,$("table.invoice button.printButton").off("click"),$("table.invoice button.printButton").on("click",function(){window.print()})},this.resetOrder=function(){o.init(),o.setDeliveryDate("-"),o.setSupplier("-")},this.afterOrderSendOk=function(t){Toast.create({title:"Sent!",message:"Order Sent",status:TOAST_STATUS.INFO,timeout:5e3}),$(".buttonOrderSend").off("click"),$(".buttonOrderSend").prop("disabled",!0),$(".statusNamePlace").removeClass("statusBlink"),$(".statusNamePlace").text("elküldve"),$(".buttonOrderSending").toggleClass("d-none"),$(".buttonOrderSendOk").toggleClass("d-none"),$("div.invoiceContainer").html(t.retHTML)},this.afterOrderSendError=function(t){$(".buttonOrderSend").toggleClass("d-none"),$(".buttonOrderSending").toggleClass("d-none"),$.each(APP.OrderModule.Stepper.getOpts().available,function(t,a){APP.OrderModule.Stepper.setEnabled(a),APP.OrderModule.Stepper.setCompleted(a)})},this.initViewSend=function(){console.log("initViewSend called 2"),o.Stepper.setOpts({onAfterLoad:function onAfterLoad(){}}),$(".buttonOrderSend").off("click"),$(".buttonOrderSend").on("click",function(){console.log("Send buton clicked"),$(".buttonOrderSend").toggleClass("d-none"),$(".buttonOrderSending").toggleClass("d-none"),$.each(APP.OrderModule.Stepper.getOpts().available,function(t,a){o.Stepper.unsetEnabled(a),o.Stepper.unsetCompleted(a)}),o.sendOrderDataToServer("send",o.afterOrderSendOk,o.afterOrderSendError)})},this.testModeSend=function(){},this.testMode=function(){console.log("testMode called "),r.setData({id:234,supplierId:7,productSelected:{116:3,293:2},contactName:"Contact Name",note:"Note",type:"daily",deliveryDate:a.defaultDeliveryDate,deliveryAddress:12}),console.log(r.getData()),console.log("*******************"),o.Stepper.setOpts({UrlData:{supplierId:r.supplierId,id:r.id}}),this.Stepper.init({URL:{create:a.URL.create},complete:["supplier","parameter","productSelect"],enable:["supplier","parameter","productSelect"],active:"productSelect",onAfterActivate:this.initViewProductSelect,autoCallback:{invoice:{onAfterActivate:o.initViewInvoice},send:{onAfterActivate:o.initViewSend}}}),console.log("*******************")},this.toggleEnableSend=function(){console.log("toggleEnableSend called");var t=a.URL.checkReadyToSend.replace("%id%",r.id);$.ajax({url:t,success:function success(t){t.success&&(t.readyToSend?(o.Stepper.addCompleted("send"),o.Stepper.addEnabled("send")):(o.Stepper.unsetCompleted("send"),o.Stepper.unsetEnabled("send"))),console.log(t)}})}}})(),(()=>{function _typeof(t){return _typeof="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},_typeof(t)}function _superPropGet(t,a,r,o){var i=_get(_getPrototypeOf(1&o?t.prototype:t),a,r);return 2&o&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,a,r){var o=function _superPropBase(t,a){for(;!{}.hasOwnProperty.call(t,a)&&null!==(t=_getPrototypeOf(t)););return t}(t,a);if(o){var i=Object.getOwnPropertyDescriptor(o,a);return i.get?i.get.call(arguments.length<3?t:r):i.value}},_get.apply(null,arguments)}function _defineProperties(t,a){for(var r=0;r<a.length;r++){var o=a[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,_toPropertyKey(o.key),o)}}function _createClass(t,a,r){return a&&_defineProperties(t.prototype,a),r&&_defineProperties(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function _toPropertyKey(t){var a=function _toPrimitive(t,a){if("object"!=_typeof(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,a||"default");if("object"!=_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===a?String:Number)(t)}(t,"string");return"symbol"==_typeof(a)?a:a+""}function _classCallCheck(t,a){if(!(t instanceof a))throw new TypeError("Cannot call a class as a function")}function _callSuper(t,a,r){return a=_getPrototypeOf(a),function _possibleConstructorReturn(t,a){if(a&&("object"==_typeof(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,_isNativeReflectConstruct()?Reflect.construct(a,r||[],_getPrototypeOf(t).constructor):a.apply(t,r))}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,a){if("function"!=typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(a&&a.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),a&&_setPrototypeOf(t,a)}function _setPrototypeOf(t,a){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,a){return t.__proto__=a,t},_setPrototypeOf(t,a)}if(void 0===window.DataModelOrderArchive){window.OrderArchiveModulDefault={actionFunction:function actionFunction(){}};var t=function(){function _DataModelOrderArchive(t,a){var r;return _classCallCheck(this,_DataModelOrderArchive),void 0===(r=_callSuper(this,_DataModelOrderArchive,[t,a])).items&&(r.items={}),console.log(r.constructor.name+" constructor called"),r}return _inherits(_DataModelOrderArchive,DataModel),_createClass(_DataModelOrderArchive)}();window.DataModelOrderArchive=t}if(void 0===window.OrderArchiveModule){var a=function(){function OrderArchiveModule(t,a){var r;return _classCallCheck(this,OrderArchiveModule),r=_callSuper(this,OrderArchiveModule,[t,a]),"undefined"!==a||null!=a||(r.data=new DataModelOrderArchive),r.dataTable=null,r.Opts.dataTable.advanceSearchParameter={deliveryDateFrom:null,deliveryDateTo:null,profitCenterId:null,supplierId:null},r}return _inherits(OrderArchiveModule,ModuleBase),_createClass(OrderArchiveModule,[{key:"datatableRowActionAttachment",value:function datatableRowActionAttachment(t,a){debug("call datatableRowActionAttachment"),_superPropGet(OrderArchiveModule,"datatableRowActionAttachment",this,3)([t,a,{defaultFileName:"order"}])}},{key:"datatableRowActionView",value:function datatableRowActionView(t,a){debug("call datatableRowActionView"),_superPropGet(OrderArchiveModule,"datatableRowActionView",this,3)([t,a,APP.OrderArchiveModule]),console.log("datatableRowActionEdit End")}},{key:"datatableRowActionButtonClick",value:function datatableRowActionButtonClick(t){debug("datatableRowActionButtonClick"),_superPropGet(OrderArchiveModule,"datatableRowActionButtonClick",this,3)([t,APP.OrderArchiveModule])}},{key:"datatableRowActionEdit",value:function datatableRowActionEdit(t,a){console.log("datatableRowActionEdit Called");var r=this.Opts.URL.edit.replace("%id%",t.id);console.log(this.Opts.URL),console.log(r),APP.loadMainContent(r),console.log("datatableRowActionEdit End")}},{key:"initViewShow",value:function initViewShow(){debug("call initViewShow"),APP.OrderArchiveModule.Opts.URL.root,$("table.invoice button.printButton").off("click"),$("table.invoice button.printButton").on("click",function(){window.print()})}},{key:"datatableCustomHeadButtonClickCallBack",value:function datatableCustomHeadButtonClickCallBack(){console.info("hello itt vagyok"),$(".advanceSearchModal").modal("show")}},{key:"initAdvancedSearch",value:function initAdvancedSearch(){console.log("initAdvancedSearch"),window.datePickerTarget="",$(".deliveryDateFrom,.deliveryDateTo").datepicker({dateFormat:"yy-mm-dd",onSelect:function onSelect(t){debug("target:"+window.datePickerTarget),$("."+window.datePickerTarget+"SelectedDateText").text(t),debug($(' input[name="'+window.datePickerTarget+'"]')),$(' input[name="'+window.datePickerTarget+'"]').val(t)}}),$(".datePickerClick").click(function(){debug($(this).data("target")),datePickerTarget=$(this).data("target"),$("."+datePickerTarget).datepicker("show")}),$(".selectProfitCenter,.selectSupplier").select2({maximumSelectionLength:1});var t=!1;$.each(this.Opts.dataTable.advanceSearchParameter,function(a,r){null!=r&&(t=!0,console.log(a+" > "+r),$(".advanceSearchModal input[name="+a+"],.advanceSearchModal select[name="+a+"]").val(r).trigger("change"),$("."+a+"SelectedDateText").text(r))}),t&&$(".dt-button.btn-advanceSearchParameter").addClass("btn-success"),$(".advanceSearchModal .buttonClear").off("click"),$(".advanceSearchModal .buttonClear").on("click",function(){$(".advanceSearchModal input,.advanceSearchModal select").val("").trigger("change"),$(".SelectedDateText").text(" ");var t=APP.OrderArchiveModule;$.each(t.Opts.dataTable.advanceSearchParameter,function(a,r){t.Opts.dataTable.advanceSearchParameter[a]=null}),$(".dt-button.btn-advanceSearchParameter").removeClass("btn-success");var a=t.Opts.CSSSelectorContainer+" .dataTable";$(a).DataTable().ajax.reload(),$(".advanceSearchModal").modal("hide")}),$(".advanceSearchModal .buttonSave").off("click"),$(".advanceSearchModal .buttonSave").on("click",function(){console.log("clicked advanced search ");var t=APP.OrderArchiveModule,a=$(".advanceSearchModalForm").find("input,select").serializeArray();console.log(a),console.log(t.Opts),console.log(t.Opts.dataTable.advanceSearchParameter),$.each(t.Opts.dataTable.advanceSearchParameter,function(a,r){t.Opts.dataTable.advanceSearchParameter[a]=null}),$.each(a,function(a,r){console.log(r.name),console.log(r.value),void 0!==t.Opts.dataTable.advanceSearchParameter[r.name]&&r.value.length>0&&(t.Opts.dataTable.advanceSearchParameter[r.name]=r.value)}),console.log(t.Opts.dataTable.advanceSearchParameter);var r=t.Opts.CSSSelectorContainer+" .dataTable";$(r).DataTable().ajax.reload(),$(".dt-button.btn-advanceSearchParameter").addClass("btn-success"),$(".advanceSearchModal").modal("hide")})}},{key:"initViewList",value:function initViewList(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};debug("listview inicialization"),APP.IsUserAdmin?this.DtColumns=[{data:"supplier_name"},{data:"deliveryDate"},{data:"profit_center.name"},{data:"deliveryAddressName"},{data:"sentTime"},{data:"humanId"},{data:"confirmed"},null]:this.DtColumns=[{data:"supplier_name"},{data:"deliveryDate"},{data:"deliveryAddressName"},{data:"sentTime"},{data:"humanId"},{data:"confirmed"},null];var a=this.Opts.CSSSelectorContainer+" .dataTable",r=$(a+" thead th").length;APP.setOpts({datatableRowActionButtonClickCallBack:this.datatableRowActionButtonClick,datatableCustomHeadButtonClickCallBack:this.datatableCustomHeadButtonClickCallBack});var o=this.Opts.dataTable.orderDirective,i=this.Opts.dataTable.advanceSearchParameter;void 0!==t.orderDirective&&(o=t.orderDirective),this.dataTable=$(a).DataTable({language:{url:"//cdn.datatables.net/plug-ins/1.10.24/i18n/Hungarian.json"},ajax:{url:this.Opts.URL.getDataTableContent,data:function data(t){t.advanceSearchParameter=i}},columnDefs:[{targets:r-1,render:function render(t,a,r){var o=APP.datatableAddRowViewButton(0,arguments);return o+=APP.datatableAddRowAttachmentButton(0,arguments),r.canEditable&&(o+=APP.datatableAddRowEditButton(0,{title:"módosítás"})),o}},{targets:r-2,render:function render(t,a,r){return null==r.confirmed?'<span class="badge badge-pill badge-danger"><i class="fas fa-handshake-slash"></i></span>':r.confirmed}},{targets:1,render:function render(t,a,r){return"sort"===a?t.latinise():t}}],buttons:{buttons:["excel","pdf",{extend:"print",title:"title custom text",messageTop:"Message On Top",autoPrint:!0},{text:"Szürők",action:function action(t,a,r,o){APP.datatableCustomHeadButtonClickCallBack()},className:"btn-advanceSearchParameter"}]},columns:this.DtColumns,order:o,stateSave:!1,drawCallback:function drawCallback(t){APP.datatableAddRowAction(a)}}),this.initAdvancedSearch(),debug("listview end")}}])}();window.OrderArchiveModule=a}})(),(()=>{function _typeof(t){return _typeof="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},_typeof(t)}function _defineProperties(t,a){for(var r=0;r<a.length;r++){var o=a[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,_toPropertyKey(o.key),o)}}function _toPropertyKey(t){var a=function _toPrimitive(t,a){if("object"!=_typeof(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,a||"default");if("object"!=_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===a?String:Number)(t)}(t,"string");return"symbol"==_typeof(a)?a:a+""}function _callSuper(t,a,r){return a=_getPrototypeOf(a),function _possibleConstructorReturn(t,a){if(a&&("object"==_typeof(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,_isNativeReflectConstruct()?Reflect.construct(a,r||[],_getPrototypeOf(t).constructor):a.apply(t,r))}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,a,r){var o=function _superPropBase(t,a){for(;!{}.hasOwnProperty.call(t,a)&&null!==(t=_getPrototypeOf(t)););return t}(t,a);if(o){var i=Object.getOwnPropertyDescriptor(o,a);return i.get?i.get.call(arguments.length<3?t:r):i.value}},_get.apply(null,arguments)}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _setPrototypeOf(t,a){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,a){return t.__proto__=a,t},_setPrototypeOf(t,a)}if(void 0===window.PriceListModule){var t=function(){function PriceListModule(){return function _classCallCheck(t,a){if(!(t instanceof a))throw new TypeError("Cannot call a class as a function")}(this,PriceListModule),_callSuper(this,PriceListModule,arguments)}return function _inherits(t,a){if("function"!=typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(a&&a.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),a&&_setPrototypeOf(t,a)}(PriceListModule,ModuleBase),function _createClass(t,a,r){return a&&_defineProperties(t.prototype,a),r&&_defineProperties(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(PriceListModule,[{key:"datatableRowActionAttachment",value:function datatableRowActionAttachment(t,a){debug("call datatableRowActionAttachment"),function _superPropGet(t,a,r,o){var i=_get(_getPrototypeOf(1&o?t.prototype:t),a,r);return 2&o&&"function"==typeof i?function(t){return i.apply(r,t)}:i}(PriceListModule,"datatableRowActionAttachment",this,3)([t,a,{defaultFileName:"arlista.xls"}])}},{key:"datatableRowActionView",value:function datatableRowActionView(t,a){debug("call datatableRowActionView")}},{key:"datatableRowActionButtonClick",value:function datatableRowActionButtonClick(t){debug("datatableRowActionButtonClick");var a=APP.PriceListModule,r=$(t[0].currentTarget),o=$(a.Opts.dataTable.CSSSelector).DataTable().row(r.parents("tr")).data(),i="datatableRowAction"+r.data("buttontype").capitalize();if("function"==typeof a[i])return a[i](o,r)}},{key:"initViewList",value:function initViewList(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};debug("listview inicialization");var a=this.Opts.CSSSelectorContainer+" .dataTable",r=$(a+" thead th").length;APP.setOpts({datatableRowActionButtonClickCallBack:this.datatableRowActionButtonClick});var o=this.Opts.dataTable.orderDirective;void 0!==t.orderDirective&&(o=t.orderDirective),$(a).DataTable({language:{url:"//cdn.datatables.net/plug-ins/1.10.24/i18n/Hungarian.json"},ajax:{url:this.Opts.URL.getDataTableContent,data:function data(t){}},columnDefs:[{targets:r-1,render:function render(t,a,r){return r.fileUrl?APP.datatableAddRowAttachmentButton(0,arguments):""}}],buttons:{buttons:[]},columns:[{data:"id"},{data:"supplierName"},{data:"available"},{data:"created_at"},{data:"note"},null],order:o,drawCallback:function drawCallback(t){APP.datatableAddRowAction(a)}}),debug("listview end")}}])}();window.PriceListModule=t}})(),(()=>{function _typeof(t){return _typeof="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},_typeof(t)}function _defineProperties(t,a){for(var r=0;r<a.length;r++){var o=a[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,_toPropertyKey(o.key),o)}}function _toPropertyKey(t){var a=function _toPrimitive(t,a){if("object"!=_typeof(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,a||"default");if("object"!=_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===a?String:Number)(t)}(t,"string");return"symbol"==_typeof(a)?a:a+""}function _callSuper(t,a,r){return a=_getPrototypeOf(a),function _possibleConstructorReturn(t,a){if(a&&("object"==_typeof(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,_isNativeReflectConstruct()?Reflect.construct(a,r||[],_getPrototypeOf(t).constructor):a.apply(t,r))}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _superPropGet(t,a,r,o){var i=_get(_getPrototypeOf(1&o?t.prototype:t),a,r);return 2&o&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function _get(){return _get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,a,r){var o=function _superPropBase(t,a){for(;!{}.hasOwnProperty.call(t,a)&&null!==(t=_getPrototypeOf(t)););return t}(t,a);if(o){var i=Object.getOwnPropertyDescriptor(o,a);return i.get?i.get.call(arguments.length<3?t:r):i.value}},_get.apply(null,arguments)}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _setPrototypeOf(t,a){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,a){return t.__proto__=a,t},_setPrototypeOf(t,a)}if(void 0===window.SupplierModule){var t=function(){function SupplierModule(){return function _classCallCheck(t,a){if(!(t instanceof a))throw new TypeError("Cannot call a class as a function")}(this,SupplierModule),_callSuper(this,SupplierModule,arguments)}return function _inherits(t,a){if("function"!=typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(a&&a.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),a&&_setPrototypeOf(t,a)}(SupplierModule,ModuleBase),function _createClass(t,a,r){return a&&_defineProperties(t.prototype,a),r&&_defineProperties(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(SupplierModule,[{key:"datatableRowActionAttachment",value:function datatableRowActionAttachment(t,a){debug("call datatableRowActionAttachment"),_superPropGet(SupplierModule,"datatableRowActionAttachment",this,3)([t,a,{defaultFileName:"arlista.xls"}])}},{key:"datatableRowActionView",value:function datatableRowActionView(t,a){debug("call datatableRowActionView"),_superPropGet(SupplierModule,"datatableRowActionView",this,3)([t,a,APP.SupplierModule])}},{key:"datatableRowActionButtonClick",value:function datatableRowActionButtonClick(t){debug("datatableRowActionButtonClick");var a=APP.SupplierModule,r=$(t[0].currentTarget),o=$(a.Opts.dataTable.CSSSelector).DataTable().row(r.parents("tr")).data(),i="datatableRowAction"+r.data("buttontype").capitalize();if("function"==typeof a[i])return a[i](o,r)}},{key:"initViewShow",value:function initViewShow(){$(".productCategorySelect").select2({disabled:!0}),$(".serviceSelect").select2({disabled:!0}),APP.SupplierModule.renderContact()}},{key:"initViewList",value:function initViewList(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};debug("listview inicialization");var a=this.Opts.CSSSelectorContainer+" .dataTable",r=$(a+" thead th").length;APP.setOpts({datatableRowActionButtonClickCallBack:this.datatableRowActionButtonClick});var o=this.Opts.dataTable.orderDirective;void 0!==t.orderDirective&&(o=t.orderDirective),$(a).DataTable({language:{url:"//cdn.datatables.net/plug-ins/1.10.24/i18n/Hungarian.json"},ajax:{url:this.Opts.URL.getDataTableContent,data:function data(t){}},columnDefs:[{targets:r-1,render:function render(t,a,r){return APP.datatableAddRowViewButton(0,arguments)}}],buttons:{buttons:[]},columns:[{data:"name"},{data:"product_group"},{data:"service"},null],order:o,drawCallback:function drawCallback(t){APP.datatableAddRowAction(a)}}),debug("listview end")}},{key:"renderContact",value:function renderContact(){var t=1;console.log("renderingContacts"),$.each(APP.Supplier.getData("contact"),function(){this.rowNum=t;var a=$('template[data-name="supplierContactTableRow"]').html(),r=Mustache.render(a,this);$(".contactTable tbody").append(r),t++})}}])}();window.SupplierModule=t}})();
|
||
//# sourceMappingURL=module.js.map
|