text: (()=>{"use strict";var e={9432:(e,t,n)=>{var a=n(6165);const s={success(e){alertify.success(e)},error(e){alertify.error(e)}};var o=n(6455),d=n.n(o),i=n(1035);const r={lines:10,length:0,width:12,radius:16,scale:1,corners:1,speed:1,rotate:0,animation:"spinner-line-shrink",direction:1,color:"#e74c3c",fadeColor:"transparent",top:"50%",left:"50%",shadow:"0 0 1px transparent",zIndex:2e9,className:"spinner",position:"absolute"};class c{constructor(e){this.target=e,this.spinner=new i.$(r)}start(){this.spinner.spin(this.target),this.target.classList.add("opaque")}stop(){this.spinner.stop(),this.target.classList.remove("opaque")}}var l=n(7027),u=n(3438),m=n(5709);const f=(e,t)=>{const n=document.querySelectorAll(`${e} a[href]`);n.length&&(0,l.R)(n,"click").pipe((0,u.b)((e=>e.preventDefault())),(0,m.U)((e=>t(e.target.getAttribute("data-ci-pagination-page"))))).subscribe()};let _=1;const h=function(){const e=new c(document.getElementById("currencies"));let t=[],n=0;var a=function(){document.getElementById("search-currency").addEventListener("keyup",(function(e){l()}))},o=function(){document.getElementById("add_currency_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_currency_modal").modal("show")}))},i=function(){document.getElementById("add_currency_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);fetch(`${CONFIG.BASE_URL}api/currency/add_details`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully added!"),document.getElementById("add_currency_form").reset(),$("#add_currency_modal").modal("hide"),l()):s.error(e.message)}))}))},r=function(){document.getElementById("edit_currency_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);0!=n?fetch(`${CONFIG.BASE_URL}api/currency/edit_details/${n}`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully updated!"),document.getElementById("edit_currency_form").reset(),$("#edit_currency_modal").modal("hide"),l(_)):s.error(e.message)})):s.error("Please select an item to edit.")}))},l=function(n=1){_=1,e.start();var a=document.getElementById("search-currency").value;fetch(`${CONFIG.BASE_URL}api/currency/get`,{method:"POST",body:new URLSearchParams({page:n,search:a})}).then((e=>e.json())).then((n=>{t=n.list,function(e){let n='<tr><td class="text-center" colspan="5">No records found.</td></tr>';t.length>0&&(n=t.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td>${e.offset+a+1}</td>\n                            <td>${n.currency}</td>\n                            <td>${n.currency_name}</td>\n                            <td>${n.currency_sign}</td>\n                            <td>${n.CHF_value}</td>\n                            <td align="center">\n                                <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-currency-btn" data-index="${n.currency_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-currency-btn" title="Delete" data-index="${n.currency_id}" data-name="${n.currency}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("currency-table").innerHTML=n,document.getElementById("currency-pagination").innerHTML=e.pagination,f("#currency-pagination .pagination",l),u()}(n),e.stop()}))},u=function(){let e=document.getElementsByClassName("delete-currency-btn"),a=document.getElementsByClassName("edit-currency-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${n}?`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((e=>{e.value&&fetch(`${CONFIG.BASE_URL}api/currency/delete/${t}`).then((e=>e.json())).then((e=>{e.success&&(s.success("Successfully deleted!"),l(_))}))}))}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let a=$(this).data("index"),s=t.find((e=>e.currency_id==a));n=a,document.getElementById("edit_currency_code").value=s.currency,document.getElementById("edit_currency_name").value=s.currency_name,document.getElementById("edit_currency_sign").value=s.currency_sign,document.getElementById("edit_chf_value").value=s.CHF_value,$("#edit_currency_modal").modal("show")}))}))};return{init:function(){a(),o(),i(),r()},get:l}}();let g=1;const p=function(){const e=new c(document.getElementById("vats"));let t=[],n=0;var a=function(){document.getElementById("search-vat").addEventListener("keyup",(function(e){l()}))},o=function(){document.getElementById("add_vat_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_vat_modal").modal("show")}))},i=function(){document.getElementById("add_vat_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);fetch(`${CONFIG.BASE_URL}api/vat/add_details`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully added!"),$("#add_vat_modal").modal("hide"),l()):s.error(e.message)}))}))},r=function(){document.getElementById("edit_vat_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);0!=n?fetch(`${CONFIG.BASE_URL}api/vat/edit_details/${n}`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully updated!"),$("#edit_vat_modal").modal("hide"),l(g)):s.error(e.message)})):s.error("Please select an item to edit.")}))},l=function(n=1){g=n,e.start();var a=document.getElementById("search-vat").value;fetch(`${CONFIG.BASE_URL}api/vat/get`,{method:"POST",body:new URLSearchParams({page:n,search:a})}).then((e=>e.json())).then((n=>{t=n.list,function(e){let n='<tr><td class="text-center" colspan="5">No records found.</td></tr>';t.length>0&&(n=t.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td align="center">${e.offset+a+1}</td>\n                            <td align="center">${n.vat_code}</td>\n                            <td>${n.vat_description}</td>\n                            <td align="center">${n.vat_percentage+" %"}</td>\n                            <td align="center">\n                                <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-vat-btn" data-index="${n.vat_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-vat-btn" title="Delete" data-index="${n.vat_id}" data-name="${n.vat_description}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("vats-table").innerHTML=n,document.getElementById("vats-pagination").innerHTML=e.pagination,f("#vats-pagination .pagination",l),u()}(n),e.stop()}))},u=function(){let e=document.getElementsByClassName("delete-vat-btn"),a=document.getElementsByClassName("edit-vat-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${n}? <br>You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((e=>{e.value&&fetch(`${CONFIG.BASE_URL}api/vat/delete/${t}`).then((e=>e.json())).then((e=>{e.success&&(s.success("Successfully deleted."),l(g))}))}))}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let a=$(this).data("index"),s=t.find((e=>e.vat_id==a));n=a,document.getElementById("edit_vat_code").value=s.vat_code,document.getElementById("edit_vat_description").value=s.vat_description,document.getElementById("edit_vat_percentage").value=s.vat_percentage,$("#edit_vat_modal").modal("show")}))}))};return{init:function(){a(),o(),i(),r()},get:l}}(),y=function(e,t){let n=$(e+" + span > small").prop("style");t?n&&""!==n.backgroundColor||$(e).trigger("click").attr("checked","checked"):n&&""!==n.backgroundColor&&$(e).trigger("click").removeAttr("checked")};let v=1;const b=function(){const e=new c(document.getElementById("payment_terms"));let t=[],n=0;var a=function(){document.getElementById("search-payment-terms").addEventListener("keyup",(function(e){m()}))},o=function(){document.getElementById("add_payment_terms_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_payment_terms_modal").modal("show")}))},i=function(){document.getElementById("add_payment_terms_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);fetch(`${CONFIG.BASE_URL}api/paymentterms/add_details`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully added!"),$("#add_payment_terms_modal").modal("hide"),document.getElementById("add_payment_terms_form").reset(),m()):s.error(e.message)}))}))},r=function(){document.getElementById("edit_payment_terms_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);0!=n?u(n,t):s.error("Please select an item to edit.")}))},l=function(e,t){fetch(`${CONFIG.BASE_URL}api/paymentterms/edit_details/${e}`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully updated!"),$("#edit_payment_terms_modal").modal("hide"),m(v)):s.error(e.message)}))},u=function(e,t){fetch(`${CONFIG.BASE_URL}invoice/checkIfPaymentTermUsed/${e}`).then((e=>e.json())).then((n=>{n.success?d().fire({title:"Are you sure?",html:"This payment term is already used in the invoices. If you continue, you have to manually update invoices to also update its due date.",icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((n=>{n.value&&l(e,t)})):l(e,t)}))},m=function(n=1){v=n,e.start();var a=document.getElementById("search-payment-terms").value;fetch(`${CONFIG.BASE_URL}api/paymentterms/get`,{method:"POST",body:new URLSearchParams({page:n,search:a})}).then((e=>e.json())).then((n=>{t=n.list,function(e){let n='<tr><td class="text-center" colspan="5">No records found.</td></tr>';t.length>0&&(n=t.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td>${e.offset+a+1}</td>\n                            <td>${n.payment_terms_name}</td>\n                            <td align="center">${n.payment_terms_days}</td>\n                            <td align="center">${1==n.payment_terms_is_month_end?"Yes":"No"}</td>\n                            <td align="center">\n                                <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-payment-terms-btn" data-index="${n.payment_terms_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-payment-terms-btn" title="Delete" data-index="${n.payment_terms_id}" data-name="${n.payment_terms_name}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("payment-terms-table").innerHTML=n,document.getElementById("payment-terms-pagination").innerHTML=e.pagination,f("#payment-terms-pagination .pagination",m),_()}(n),e.stop()}))},_=function(){let e=document.getElementsByClassName("delete-payment-terms-btn"),a=document.getElementsByClassName("edit-payment-terms-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${n}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((e=>{e.value&&fetch(`${CONFIG.BASE_URL}api/paymentterms/delete/${t}`).then((e=>e.json())).then((e=>{e.success&&(s.success("Successfully deleted!"),m(v))}))}))}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let a=$(this).data("index"),s=t.find((e=>e.payment_terms_id==a));n=a,document.getElementById("edit_payment_terms_name").value=s.payment_terms_name,document.getElementById("edit_payment_terms_days").value=s.payment_terms_days,s.payment_terms_is_month_end>0?y("#edit_payment_terms_is_month_end",!0):y("#edit_payment_terms_is_month_end",!1),$("#edit_payment_terms_modal").modal("show")}))}))};return{init:function(){a(),o(),i(),r()},get:m}}();let E=1;const B=function(){const e=new c(document.getElementById("shipping_methods"));let t=[],n=0;var a=function(){document.getElementById("search-shipping-method").addEventListener("keyup",(function(e){l()}))},o=function(){document.getElementById("add_shipping_method_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_shipping_method_modal").modal("show")}))},i=function(){document.getElementById("add_shipping_method_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);fetch(`${CONFIG.BASE_URL}api/shippingmethod/add_details`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully added!"),$("#add_shipping_method_modal").modal("hide"),l()):s.error(e.message)}))}))},r=function(){document.getElementById("edit_shipping_method_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);0!=n?fetch(`${CONFIG.BASE_URL}api/shippingmethod/edit_details/${n}`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully updated!"),$("#edit_shipping_method_modal").modal("hide"),l(E)):s.error(e.message)})):s.error("Please select an item to edit.")}))},l=function(n=1){E=n,e.start();var a=document.getElementById("search-shipping-method").value;fetch(`${CONFIG.BASE_URL}api/shippingmethod/get`,{method:"POST",body:new URLSearchParams({page:n,search:a})}).then((e=>e.json())).then((n=>{t=n.list,function(e){let n='<tr><td class="text-center" colspan="5">No records found.</td></tr>';t.length>0&&(n=t.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td>${e.offset+a+1}</td>\n                            <td>${n.shipping_method_name}</td>\n                            <td align="center">\n                                <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-shipping-method-btn" data-index="${n.shipping_method_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-shipping-method-btn" title="Delete" data-index="${n.shipping_method_id}" data-name="${n.shipping_method_name}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("shipping-method-table").innerHTML=n,document.getElementById("shipping-method-pagination").innerHTML=e.pagination,f("#shipping-method-pagination .pagination",l),u()}(n),e.stop()}))},u=function(){let e=document.getElementsByClassName("delete-shipping-method-btn"),a=document.getElementsByClassName("edit-shipping-method-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${n}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((e=>{e.value&&fetch(`${CONFIG.BASE_URL}api/shippingmethod/delete/${t}`).then((e=>e.json())).then((e=>{e.success&&(s.success("Successfully deleted!"),l(E))}))}))}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let a=$(this).data("index"),s=t.find((e=>e.shipping_method_id==a));n=a,document.getElementById("edit_shipping_method_name").value=s.shipping_method_name,$("#edit_shipping_method_modal").modal("show")}))}))};return{init:function(){a(),o(),i(),r()},get:l}}();let w=1;const I=function(){const e=new c(document.getElementById("industries"));let t=[],n=0;var a=function(){document.getElementById("search-industry").addEventListener("keyup",(function(e){l()}))},o=function(){document.getElementById("add_industry_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_industry_modal").modal("show")}))},i=function(){document.getElementById("add_industry_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);fetch(`${CONFIG.BASE_URL}api/industry/add_details`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully added!"),$("#add_industry_modal").modal("hide"),l()):s.error(e.message)}))}))},r=function(){document.getElementById("edit_industry_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);0!=n?fetch(`${CONFIG.BASE_URL}api/industry/edit_details/${n}`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully updated!"),$("#edit_industry_modal").modal("hide"),l(w)):s.error(e.message)})):s.error("Please select an item to edit.")}))},l=function(n=1){w=n,e.start();var a=document.getElementById("search-industry").value;fetch(`${CONFIG.BASE_URL}api/industry/get`,{method:"POST",body:new URLSearchParams({page:n,search:a})}).then((e=>e.json())).then((n=>{t=n.list,function(e){let n='<tr><td class="text-center" colspan="5">No records found.</td></tr>';t.length>0&&(n=t.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td align="center">${e.offset+a+1}</td>\n                            <td>${n.cms_industry_name}</td>\n                            <td align="center">${n.cms_industry_index}</td>\n                            <td align="center">\n                                <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-industry-btn" data-index="${n.cms_industry_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-industry-btn" title="Delete" data-index="${n.cms_industry_id}" data-name="${n.cms_industry_name}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("industry-table").innerHTML=n,document.getElementById("industry-pagination").innerHTML=e.pagination,f("#industry-pagination .pagination",l),u()}(n),e.stop()}))},u=function(){let e=document.getElementsByClassName("delete-industry-btn"),a=document.getElementsByClassName("edit-industry-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${n}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",closeOnConfirm:!0,allowOutsideClick:!0,reverseButtons:!0}).then((e=>{e.value&&fetch(`${CONFIG.BASE_URL}api/industry/delete/${t}`).then((e=>e.json())).then((e=>{e.success&&(s.success("Successfully deleted!"),l(w))}))}))}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let a=$(this).data("index"),s=t.find((e=>e.cms_industry_id==a));n=a,document.getElementById("edit_industry_name").value=s.cms_industry_name,$("#edit_industry_modal").modal("show")}))}))};return{init:function(){a(),o(),i(),r()},get:l}}();let L=1;const k=function(){const e=new c(document.getElementById("departments"));let t=[],n=0;var a=function(){document.getElementById("search-department").addEventListener("keyup",(function(e){l()}))},o=function(){document.getElementById("add_department_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_department_modal").modal("show")}))},i=function(){document.getElementById("add_department_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);fetch(`${CONFIG.BASE_URL}api/department/add_details`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully added!"),$("#add_department_modal").modal("hide"),l()):s.error(e.message)}))}))},r=function(){document.getElementById("edit_department_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);0!=n?fetch(`${CONFIG.BASE_URL}api/department/edit_details/${n}`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully updated!"),$("#edit_department_modal").modal("hide"),l(L)):s.error(e.message)})):s.error("Please select an item to edit.")}))},l=function(n=1){L=n,e.start();var a=document.getElementById("search-department").value;fetch(`${CONFIG.BASE_URL}api/department/get`,{method:"POST",body:new URLSearchParams({page:n,search:a})}).then((e=>e.json())).then((n=>{t=n.list,function(e){let n='<tr><td class="text-center" colspan="5">No records found.</td></tr>';t.length>0&&(n=t.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td>${e.offset+a+1}</td>\n                            <td>${n.cms_department_name}</td>\n                            <td align="center">\n                                <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-department-btn" data-index="${n.cms_department_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-department-btn" title="Delete" data-index="${n.cms_department_id}" data-name="${n.cms_department_name}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("department-table").innerHTML=n,document.getElementById("department-pagination").innerHTML=e.pagination,f("#department-pagination .pagination",l),u()}(n),e.stop()}))},u=function(){let e=document.getElementsByClassName("delete-department-btn"),a=document.getElementsByClassName("edit-department-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${n}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((e=>{e.value&&fetch(`${CONFIG.BASE_URL}api/department/delete/${t}`).then((e=>e.json())).then((e=>{e.success&&(s.success("Successfully deleted!"),l(L))}))}))}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let a=$(this).data("index"),s=t.find((e=>e.cms_department_id==a));n=a,document.getElementById("edit_department_name").value=s.cms_department_name,$("#edit_department_modal").modal("show")}))}))};return{init:function(){a(),o(),i(),r()},get:l}}();let x=1;const D=function(){const e=new c(document.getElementById("positions"));let t=[],n=0;var a=function(){document.getElementById("search-position").addEventListener("keyup",(function(e){l()}))},o=function(){document.getElementById("add_position_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_position_modal").modal("show")}))},i=function(){document.getElementById("add_position_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);fetch(`${CONFIG.BASE_URL}api/position/add_details`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.Toast("Successfully added!"),$("#add_position_modal").modal("hide"),l()):s.error(e.message)}))}))},r=function(){document.getElementById("edit_position_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);0!=n?fetch(`${CONFIG.BASE_URL}api/position/edit_details/${n}`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully updated!"),$("#edit_position_modal").modal("hide"),l(x)):s.error(e.message)})):s.error("Please select an item to edit.")}))},l=function(n=1){x=n,e.start();var a=document.getElementById("search-position").value;fetch(`${CONFIG.BASE_URL}api/position/get`,{method:"POST",body:new URLSearchParams({page:n,search:a})}).then((e=>e.json())).then((n=>{t=n.list,function(e){let n='<tr><td class="text-center" colspan="5">No records found.</td></tr>';t.length>0&&(n=t.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td>${e.offset+a+1}</td>\n                            <td>${n.cms_position_name}</td>\n                            <td align="center">\n                                <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-position-btn" data-index="${n.cms_position_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-position-btn" title="Delete" data-index="${n.cms_position_id}" data-name="${n.cms_position_name}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("position-table").innerHTML=n,document.getElementById("position-pagination").innerHTML=e.pagination,f("#position-pagination .pagination",l),u()}(n),e.stop()}))},u=function(){let e=document.getElementsByClassName("delete-position-btn"),a=document.getElementsByClassName("edit-position-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${n}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((e=>{e.value&&fetch(`${CONFIG.BASE_URL}api/position/delete/${t}`).then((e=>e.json())).then((e=>{e.success&&(s.success("Successfully deleted!"),l(x))}))}))}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let a=$(this).data("index"),s=t.find((e=>e.cms_position_id==a));n=a,document.getElementById("edit_position_name").value=s.cms_position_name,$("#edit_position_modal").modal("show")}))}))};return{init:function(){a(),o(),i(),r()},get:l}}();let S=1;const C=function(){const e=new c(document.getElementById("christmas"));let t=[],n=0;var a=function(){document.getElementById("search-christmas").addEventListener("keyup",(function(e){l()}))},o=function(){document.getElementById("add_christmas_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_christmas_modal").modal("show")}))},i=function(){document.getElementById("add_christmas_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);fetch(`${CONFIG.BASE_URL}api/christmas/add_details`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully added!"),$("#add_christmas_modal").modal("hide"),l()):s.error(e.message)}))}))},r=function(){document.getElementById("edit_christmas_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);0!=n?fetch(`${CONFIG.BASE_URL}api/christmas/edit_details/${n}`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully updated!"),$("#edit_christmas_modal").modal("hide"),l(S)):s.error(e.message)})):s.error("Please select an item to edit.")}))},l=function(n=1){S=n,e.start();var a=document.getElementById("search-christmas").value;fetch(`${CONFIG.BASE_URL}api/christmas/get`,{method:"POST",body:new URLSearchParams({page:n,search:a})}).then((e=>e.json())).then((n=>{t=n.list,function(e){let n='<tr><td class="text-center" colspan="5">No records found.</td></tr>';t.length>0&&(n=t.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td>${e.offset+a+1}</td>\n                            <td>${n.cms_employee_christmas_name}</td>\n                            <td align="center">\n                                <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-christmas-btn" data-index="${n.cms_employee_christmas_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-christmas-btn" title="Delete" data-index="${n.cms_employee_christmas_id}" data-name="${n.cms_employee_christmas_name}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("christmas-table").innerHTML=n,document.getElementById("christmas-pagination").innerHTML=e.pagination,f("#christmas-pagination .pagination",l),u()}(n),e.stop()}))},u=function(){let e=document.getElementsByClassName("delete-christmas-btn"),a=document.getElementsByClassName("edit-christmas-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${n}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((e=>{e.value&&fetch(`${CONFIG.BASE_URL}api/christmas/delete/${t}`).then((e=>e.json())).then((e=>{e.success&&(s.success("Successfully deleted!"),l(S))}))}))}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let a=$(this).data("index"),s=t.find((e=>e.cms_employee_christmas_id==a));n=a,document.getElementById("edit_cms_employee_christmas_name").value=s.cms_employee_christmas_name,$("#edit_christmas_modal").modal("show")}))}))};return{init:function(){a(),o(),i(),r()},get:l}}(),j=document.getElementById("exhibition-table"),A=document.getElementById("exhibition-pagination"),N=document.getElementById("search-exhibition"),O=new c(document.getElementById("exhibitions"));let T=1,F=[],P=0;const U=(e=1)=>{T=e,O.start();let t=new FormData;t.set("page",e),t.set("search",N.value||""),fetch(`${CONFIG.BASE_URL}api/exhibition/get`,{method:"POST",body:t}).then((e=>e.json())).then((e=>{F=e.list,(e=>{let t='<tr><td class="text-center" colspan="5">No records found.</td></tr>';F.length>0&&(t=F.reduce((function(t,n,a){return`${t}\n                    <tr>\n                        <td>${e.offset+a+1}</td>\n                        <td>${n.cms_employee_exhibition_name}</td>\n                        <td align="center">\n                            <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-exhibition-btn" data-index="${n.cms_employee_exhibition_id}"><span class="fa fa-pencil"></span></a>\n                            <a class="btn btn-danger btn-sm waves-effect waves-light delete-exhibition-btn" title="Delete" data-index="${n.cms_employee_exhibition_id}" data-name="${n.cms_employee_exhibition_name}">\n                                <span class="fa fa-trash"></span>\n                            </a>\n                        </td>\n                    </tr>`}),"")),j.innerHTML=t,A.innerHTML=e.pagination,f("#exhibition-pagination .pagination",U),R()})(e),O.stop()}))},R=()=>{let e=j.getElementsByClassName("delete-exhibition-btn"),t=j.getElementsByClassName("edit-exhibition-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=e.currentTarget.dataset.index,n=e.currentTarget.dataset.name;d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${n}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((e=>{e.value&&fetch(`${CONFIG.BASE_URL}api/exhibition/delete/${t}`).then((e=>e.json())).then((e=>{e.success&&(s.success("Successfully deleted!"),U(T))}))}))}))})),Array.from(t).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=e.currentTarget.dataset.index,n=F.find((e=>e.cms_employee_exhibition_id==t));P=t,document.getElementById("edit_cms_employee_exhibition_name").value=n.cms_employee_exhibition_name,$("#edit_exhibition_modal").modal("show")}))}))},G={init:()=>{N.addEventListener("keyup",(()=>U())),document.getElementById("add_exhibition_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_exhibition_modal").modal("show")})),document.getElementById("add_exhibition_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);fetch(`${CONFIG.BASE_URL}api/exhibition/add_details`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully added!"),$("#add_exhibition_modal").modal("hide"),U()):s.error(e.message)}))})),document.getElementById("edit_exhibition_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);0!=P?fetch(`${CONFIG.BASE_URL}api/exhibition/edit_details/${P}`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully updated!"),$("#edit_exhibition_modal").modal("hide"),U(T)):s.error(e.message)})):s.error("Please select an item to edit.")}))},get:U};let H=1;const M=function(){const e=new c(document.getElementById("decisions"));let t=[],n=0;var a=function(){document.getElementById("search-decision").addEventListener("keyup",(function(e){l()}))},o=function(){document.getElementById("add_decision_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_decision_modal").modal("show")}))},i=function(){document.getElementById("add_decision_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);fetch(`${CONFIG.BASE_URL}api/decision/add_details`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully added!"),$("#add_decision_modal").modal("hide"),l()):s.error(e.message)}))}))},r=function(){document.getElementById("edit_decision_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);0!=n?fetch(`${CONFIG.BASE_URL}api/decision/edit_details/${n}`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully updated!"),$("#edit_decision_modal").modal("hide"),l(H)):s.error(e.message)})):s.error("Please select an item to edit.")}))},l=function(n=1){H=n,e.start();var a=document.getElementById("search-decision").value;fetch(`${CONFIG.BASE_URL}api/decision/get`,{method:"POST",body:new URLSearchParams({page:n,search:a})}).then((e=>e.json())).then((n=>{t=n.list,function(e){let n='<tr><td class="text-center" colspan="5">No records found.</td></tr>';t.length>0&&(n=t.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td>${e.offset+a+1}</td>\n                            <td>${n.cms_employee_decision_name}</td>\n                            <td align="center">\n                                <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-decision-btn" data-index="${n.cms_employee_decision_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-decision-btn" title="Delete" data-index="${n.cms_employee_decision_id}" data-name="${n.cms_employee_decision_name}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("decision-table").innerHTML=n,document.getElementById("decision-pagination").innerHTML=e.pagination,f("#decision-pagination .pagination",l),u()}(n),e.stop()}))},u=function(){let e=document.getElementsByClassName("delete-decision-btn"),a=document.getElementsByClassName("edit-decision-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${n}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((e=>{e.value&&fetch(`${CONFIG.BASE_URL}api/decision/delete/${t}`).then((e=>e.json())).then((e=>{e.success&&(s.success("Successfully deleted!"),l(H))}))}))}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let a=$(this).data("index"),s=t.find((e=>e.cms_employee_decision_id==a));n=a,document.getElementById("edit_cms_employee_decision_name").value=s.cms_employee_decision_name,$("#edit_decision_modal").modal("show")}))}))};return{init:function(){a(),o(),i(),r()},get:l}}();let Y=1;const q=function(){const e=new c(document.getElementById("text-blocks"));let t=[],n=0;var a=function(){document.getElementById("search-text-block").addEventListener("keyup",(function(e){l()}))},o=function(){document.getElementById("add_text_block_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_text_block_modal").modal("show")}))},i=function(){document.getElementById("add_text_block_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);fetch(`${CONFIG.BASE_URL}api/textblock/addDetails`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully added!"),$("#add_text_block_modal").modal("hide"),l()):s.error(e.message)}))}))},r=function(){document.getElementById("edit_text_block_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);0!=n?fetch(`${CONFIG.BASE_URL}api/textblock/editDetails/${n}`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully updated!"),$("#edit_text_block_modal").modal("hide"),l(Y)):s.error(e.message)})):s.error("Please select an item to edit.")}))},l=function(n=1){Y=n,e.start();var a=document.getElementById("search-text-block").value;fetch(`${CONFIG.BASE_URL}api/textblock/get`,{method:"POST",body:new URLSearchParams({page:n,search:a})}).then((e=>e.json())).then((n=>{t=n.list,function(e){let n='<tr><td class="text-center" colspan="5">No records found.</td></tr>';t.length>0&&(n=t.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td>${e.offset+a+1}</td>\n                            <td>${n.text_block_title}</td>\n                            <td>${n.text_block_text}</td>\n                            <td>${n.text_block_extra_text}</td>\n                            <td align="center">\n                                <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-text-block-btn" data-index="${n.text_block_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-text-block-btn" title="Delete" data-index="${n.text_block_id}" data-name="${n.text_block_title}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("text-block-table").innerHTML=n,document.getElementById("text-block-pagination").innerHTML=e.pagination,f("#text-block-pagination .pagination",l),u()}(n),e.stop()}))},u=function(){let e=document.getElementsByClassName("delete-text-block-btn"),a=document.getElementsByClassName("edit-text-block-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${n}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((e=>{e.value&&fetch(`${CONFIG.BASE_URL}api/textblock/delete/${t}`).then((e=>e.json())).then((e=>{e.success&&(s.success("Successfully deleted!"),l(Y))}))}))}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(e=>{e.preventDefault();let a=e.currentTarget.dataset.index,s=t.find((e=>e.text_block_id==a));n=a,document.getElementById("edit_text_block_title").value=s.text_block_title,document.getElementById("edit_text_block_text").value=s.text_block_text,document.getElementById("edit_text_block_extra_text").value=s.text_block_extra_text,$("#edit_text_block_modal").modal("show")}))}))};return{init:function(){a(),o(),i(),r()},get:l}}();let Z=1;const Q=function(){const e=new c(document.getElementById("countries"));let t=[],n=0;var a=function(){document.getElementById("add_country_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_country_modal").modal("show")}))},o=function(){document.getElementById("add_country_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);fetch(`${CONFIG.BASE_URL}api/country/add_details`,{method:"POST",body:new URLSearchParams(t)}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully added!"),$("#add_country_modal").modal("hide"),l(Z)):s.error(e.message)}))}))},i=function(){document.getElementById("edit_country_form").addEventListener("submit",(async e=>{e.preventDefault();const t=new FormData(e.target);if(t.append("country_details_sunday_work_allowed",document.getElementById("edit_country_details_sunday_work_allowed").checked?1:0),t.append("country_details_installation_on_sunday",document.getElementById("edit_country_details_installation_on_sunday").checked?1:0),0==n)return void s.error("Please select an item to edit.");const a=await fetch(`${CONFIG.BASE_URL}api/country/edit_details/${n}`,{method:"POST",body:t});(await a.json()).success?(s.success("Successfully updated!"),$("#edit_country_modal").modal("hide"),l(Z)):s.error(result.message)}))},r=function(){document.getElementById("search-country").addEventListener("keyup",(function(e){l(Z)}))},l=function(n=1){Z=n,e.start();var a=document.getElementById("search-country").value;fetch(`${CONFIG.BASE_URL}api/country/get`,{method:"POST",body:new URLSearchParams({page:n,search:a})}).then((e=>e.json())).then((n=>{t=n.list,function(e){let n='<tr><td class="text-center" colspan="7">No records found.</td></tr>';t.length>0&&(n=t.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td>${e.offset+a+1}</td>\n                            <td>${n.country_name}</td>\n                            <td align="center">\n                                ${n.country_details_maximum_working_hrs_per_day?n.country_details_maximum_working_hrs_per_day:"--"}\n                            </td>\n                            <td align="center">\n                                ${n.country_details_maximum_working_hrs_per_week?n.country_details_maximum_working_hrs_per_week:"--"}\n                            </td>\n                            <td align="center">\n                                ${n.country_details_sunday_work_allowed?1===parseInt(n.country_details_sunday_work_allowed)?"Yes":"No":"--"}\n                            </td>\n                            <td align="center">\n                                ${n.country_details_installation_on_sunday?1===parseInt(n.country_details_installation_on_sunday)?"Yes":"No":"--"}\n                            </td>\n                            <td align="center">\n                                <a class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-country-btn" data-index="${n.country_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-country-btn" title="Delete" data-index="${n.country_id}" data-name="${n.country_name}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("country-table").innerHTML=n,document.getElementById("country-pagination").innerHTML=e.pagination,f("#country-pagination .pagination",l),u()}(n),e.stop()}))},u=function(){let e=document.getElementsByClassName("delete-country-btn"),a=document.getElementsByClassName("edit-country-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${n}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((e=>{e.value&&fetch(`${CONFIG.BASE_URL}api/country/delete/${t}`).then((e=>e.json())).then((e=>{e.success&&(s.success("Successfully deleted!"),l(Z))}))}))}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let a=$(this).data("index"),s=t.find((e=>e.country_id==a));n=a,document.querySelector("#edit_country_name").value=s.country_name,document.querySelector("#edit_country_details_maximum_working_hrs_per_day").value=s.country_details_maximum_working_hrs_per_day,document.querySelector("#edit_country_details_maximum_working_hrs_per_week").value=s.country_details_maximum_working_hrs_per_week,document.querySelector("#edit_country_details_maximum_working_hrs_per_week").value=s.country_details_maximum_working_hrs_per_week,y("#edit_country_details_sunday_work_allowed",!1),1===parseInt(s.country_details_sunday_work_allowed)&&y("#edit_country_details_sunday_work_allowed",!0),y("#edit_country_details_installation_on_sunday",!1),1===parseInt(s.country_details_installation_on_sunday)&&y("#edit_country_details_installation_on_sunday",!0),$("#edit_country_modal").modal("show")}))}))};return{init:function(){r(),a(),o(),i()},get:l}}();let J=1;const z=function(){const e=new c(document.getElementById("holidays")),t=`${CONFIG.BASE_URL}api/holiday/`;let n=[],a=0;var o=function(){document.getElementById("search-holiday").addEventListener("keyup",(function(e){m()}))},i=function(){document.getElementById("search-by-country").addEventListener("change",(e=>{m()}))},r=function(){document.getElementById("add_holiday_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_holiday_modal").modal("show")}))},l=function(){document.getElementById("add_holiday_form").addEventListener("submit",(e=>{e.preventDefault();const n=new FormData(e.target);n.delete("country_id"),n.append("countries",$("#add_holiday_form #country_id").val()),fetch(`${t}add_details`,{method:"POST",body:n}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully added!"),$("#add_holiday_modal").modal("hide"),m()):s.error(e.message)}))}))},u=function(){document.getElementById("edit_holiday_form").addEventListener("submit",(e=>{e.preventDefault();const n=new FormData(e.target);n.delete("country_id"),n.append("countries",$("#edit_holiday_form #edit_country_id").val()),0!=a?fetch(`${t}edit_details/${a}`,{method:"POST",body:n}).then((e=>e.json())).then((e=>{e.success?(s.success("Successfully updated!"),$("#edit_holiday_modal").modal("hide"),m(J)):s.error(e.message)})):s.error("Please select a holiday to edit.")}))},m=function(a=1){J=a,e.start();var s=document.getElementById("search-holiday").value,o=document.getElementById("search-by-country").value;fetch(`${t}get`,{method:"POST",body:new URLSearchParams({page:a,search:s,country_id:o})}).then((e=>e.json())).then((t=>{n=t.list,function(e){let t='<tr><td class="text-center" colspan="6">No records found.</td></tr>';n.length>0&&(t=n.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td>${e.offset+a+1}</td>\n                            <td>${n.holiday_name}</td>\n                            <td>${n.holiday_date}</td>\n                            <td>${s=n.countries,s.length?s.length&&0==s[0].country_id?"All":s.map((e=>e.country_name)).join(", "):""}</td>\n                            <td>${1==n.holiday_every_year?"YES":"NO"}</td>\n                            <td align="center">\n                                <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-holiday-btn" data-index="${n.holiday_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-holiday-btn" title="Delete" data-index="${n.holiday_id}" data-name="${n.holiday_name}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`;var s}),"")),document.getElementById("holiday-table").innerHTML=t,document.getElementById("holiday-pagination").innerHTML=e.pagination,f("#holiday-pagination .pagination",m),_()}(t),e.stop()}))},_=function(){let e=document.getElementsByClassName("delete-holiday-btn"),o=document.getElementsByClassName("edit-holiday-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let n=$(this).data("index"),a=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${a}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((e=>{e.value&&fetch(`${t}delete/${n}`).then((e=>e.json())).then((e=>{e.success&&(s.success("Successfully deleted!"),m(J))}))}))}))})),Array.from(o).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),s=n.find((e=>e.holiday_id==t));a=t;let o=s.countries.map((e=>e.country_id));document.getElementById("edit_holiday_name").value=s.holiday_name,document.getElementById("edit_holiday_date").value=s.holiday_date,document.getElementById("edit_country_id").value=s.country_id,document.getElementById("edit_holiday_every_year").value=s.holiday_every_year,o[0]>0?($("#edit_country_id").val(o).trigger("change"),document.getElementById("edit_holiday_all_countries").checked=!1):($("#edit_country_id").val("").trigger("change"),document.getElementById("edit_holiday_all_countries").checked=!0),$("#edit_holiday_modal").modal("show")}))}))};return{init:function(){o(),i(),r(),l(),u(),jQuery(".datepicker").datepicker({autoclose:!0,todayHighlight:!0,format:"yyyy-mm-dd"}),$(".select2").select2()},get:m}}();let K=1;const V=function(){const e=new c(document.getElementById("languages")),t=a.Z.create({prefixUrl:`${CONFIG.BASE_URL}api/language/`});let n=[],o=0;var i=function(){document.getElementById("search-language").addEventListener("keyup",(function(e){m()}))},r=function(){document.getElementById("add_language_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_language_modal").modal("show")}))},l=function(){document.getElementById("add_language_form").addEventListener("submit",(e=>{e.preventDefault();const n=new FormData(e.target);t.post("add_details",{body:n}).json().then((e=>{e.success?(s.success("Successfully added!"),$("#add_language_modal").modal("hide"),m()):s.error(e.message)}))}))},u=function(){document.getElementById("edit_language_form").addEventListener("submit",(e=>{e.preventDefault();const n=new FormData(e.target);0!=o?t.post(`edit_details/${o}`,{body:n}).json().then((e=>{e.success?(s.success("Successfully updated!"),$("#edit_language_modal").modal("hide"),m(K)):s.error(e.message)})):s.error("Please select an item to edit.")}))},m=async function(a=1){K=a,e.start();var s=document.getElementById("search-language").value;let o=new FormData;o.set("search",s),o.set("page",a);const d=await t.post("get",{body:o}).json();n=d.list,function(e){let t='<tr><td class="text-center" colspan="3">No records found.</td></tr>';n.length>0&&(t=n.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td>${e.offset+a+1}</td>\n                            <td>${n.document_language_name}</td>\n                            <td align="center">\n                                <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-language-btn" data-index="${n.document_language_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-language-btn" title="Delete" data-index="${n.document_language_id}" data-name="${n.document_language_name}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("language-table").innerHTML=t,document.getElementById("language-pagination").innerHTML=e.pagination,f("#language-pagination .pagination",m),_()}(d),e.stop()},_=function(){let e=document.getElementsByClassName("delete-language-btn"),a=document.getElementsByClassName("edit-language-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let n=$(this).data("index"),a=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${a}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",closeOnConfirm:!0,allowOutsideClick:!0,reverseButtons:!0}).then((async e=>{e.value&&(await t.get(`delete/${n}`).json()).success&&(s.success("Successfully deleted!"),m(K))}))}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),a=n.find((e=>e.document_language_id==t));o=t,document.getElementById("edit_document_language_name").value=a.document_language_name,$("#edit_language_modal").modal("show")}))}))};return{init:function(){i(),r(),l(),u()},get:m}}();let W=1;const X=function(){const e=new c(document.getElementById("administrative_reminders")),t=a.Z.create({prefixUrl:`${CONFIG.BASE_URL}api/administrativereminder/`});let n=[],o=0;var i=function(){document.getElementById("search-administrative-reminder").addEventListener("keyup",(function(e){h()}))},r=function(e){let t=e.options[e.selectedIndex].text.split(","),n=t[0].toString().trim()[0];return t[1].toString().trim()[0]+n},l=function(){document.getElementById("user_id").addEventListener("change",(function(e){let t=e.target;document.getElementById("administrative_reminder_initial").value=r(t)})),document.getElementById("edit_user_id").addEventListener("change",(function(e){let t=e.target;document.getElementById("edit_administrative_reminder_initial").value=r(t)}))},u=function(){document.getElementById("add_administrative_reminder_btn").addEventListener("click",(function(e){e.preventDefault(),document.getElementById("administrative_reminder_initial").value=r(document.getElementById("user_id")),$("#add_administrative_reminder_modal").modal("show")}))},m=function(){document.getElementById("add_administrative_reminder_form").addEventListener("submit",(e=>{e.preventDefault();const n=new FormData(e.target);t.post("add_details",{body:n}).json().then((e=>{e.success?(s.success("Successfully added!"),$("#add_administrative_reminder_modal").modal("hide"),h()):s.error(e.message)}))}))},_=function(){document.getElementById("edit_administrative_reminder_form").addEventListener("submit",(e=>{e.preventDefault();const n=new FormData(e.target);0!=o?t.post(`edit_details/${o}`,{body:n}).json().then((e=>{e.success?(s.success("Successfully updated!"),$("#edit_administrative_reminder_modal").modal("hide"),h()):s.error(e.message)})):s.error("Please select an item to edit.")}))},h=async function(a=1){W=a,e.start();var s=document.getElementById("search-administrative-reminder").value;let o=new FormData;o.set("search",s),o.set("page",a);const d=await t.post("get",{body:o}).json();n=d.list,function(e){let t='<tr><td class="text-center" colspan="5">No records found.</td></tr>';n.length>0&&(t=n.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td>${e.offset+a+1}</td>\n                            <td>${n.user_firstname+" "+n.user_lastname}</td>\n                            <td>${n.administrative_reminder_initial}</td>\n                            <td>${n.user_email_address}</td>\n                            <td align="center">\n                                <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-language-btn" data-index="${n.administrative_reminder_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-language-btn" title="Delete" data-index="${n.administrative_reminder_id}" data-name="${n.user_firstname+" "+n.user_lastname}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("administrative-reminders-table").innerHTML=t,document.getElementById("administrative-reminders-pagination").innerHTML=e.pagination,f("#administrative-reminders-pagination .pagination",h),g()}(d),e.stop()},g=function(){let e=document.getElementsByClassName("delete-language-btn"),a=document.getElementsByClassName("edit-language-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let n=$(this).data("index"),a=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${a}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((async e=>{e.value&&(await t.get(`delete/${n}`).json()).success&&(s.success("Successfully deleted!"),h(W))}))}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),a=n.find((e=>e.administrative_reminder_id==t));o=t,document.getElementById("edit_user_id").value=a.user_id,document.getElementById("edit_administrative_reminder_initial").value=a.administrative_reminder_initial,$("#edit_administrative_reminder_modal").modal("show")}))}))};return{init:function(){i(),u(),m(),_(),l()},get:h}}();let ee=1;const te=function(){const e=new c(document.getElementById("bank_accounts")),t=a.Z.create({prefixUrl:`${CONFIG.BASE_URL}api/bankaccount/`});let n=[],o=0;var i=function(){document.getElementById("search-bank-account").addEventListener("keyup",(function(e){m()}))},r=function(){document.getElementById("add_bank_account_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_bank_account_modal").modal("show")}))},l=function(){document.getElementById("add_bank_account_form").addEventListener("submit",(e=>{e.preventDefault();const n=new FormData(e.target);t.post("add_details",{body:n}).json().then((e=>{e.success?(s.success("Successfully added!"),$("#add_bank_account_modal").modal("hide"),m()):s.error(e.message)}))}))},u=function(){document.getElementById("edit_bank_account_form").addEventListener("submit",(e=>{e.preventDefault();const n=new FormData(e.target);0!=o?t.post(`edit_details/${o}`,{body:n}).json().then((e=>{e.success?(s.success("Successfully updated!"),$("#edit_bank_account_modal").modal("hide"),m(ee)):s.error(e.message)})):s.error("Please select an item to edit.")}))},m=async function(a=1){ee=a,e.start();var s=document.getElementById("search-bank-account").value;let o=new FormData;o.set("search",s),o.set("page",a);const d=await t.post("get",{body:o}).json();n=d.list,function(e){let t='<tr><td class="text-center" colspan="5">No records found.</td></tr>';n.length>0&&(t=n.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td>${e.offset+a+1}</td>\n                            <td>${n.ba_bank_name}</td>\n                            <td>${n.ba_account_name}</td>\n                            <td>${n.ba_account_number}</td>\n                            <td align="center">\n                                <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-language-btn" data-index="${n.ba_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-language-btn" title="Delete" data-index="${n.ba_id}" data-name="${n.ba_account_name}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("bank-accounts-table").innerHTML=t,document.getElementById("bank-accounts-pagination").innerHTML=e.pagination,f("#bank-accounts-pagination .pagination",m),_()}(d),e.stop()},_=function(){let e=document.getElementsByClassName("delete-language-btn"),a=document.getElementsByClassName("edit-language-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let n=$(this).data("index"),a=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${a}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((async e=>{e.value&&(await t.get(`delete/${n}`).json()).success&&(s.success("Successfully deleted!"),m(ee))}))}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),a=n.find((e=>e.ba_id==t));o=t,document.getElementById("edit_ba_bank_name").value=a.ba_bank_name,document.getElementById("edit_ba_account_name").value=a.ba_account_name,document.getElementById("edit_ba_account_number").value=a.ba_account_number,$("#edit_bank_account_modal").modal("show")}))}))};return{init:function(){i(),r(),l(),u()},get:m}}();let ne=1,ae=1;const se=function(){const e=new c(document.getElementById("po_approvers")),t=new c(document.getElementById("po_notify_users")),n=a.Z.create({prefixUrl:`${CONFIG.BASE_URL}api/settings/`}),o=a.Z.create({prefixUrl:`${CONFIG.BASE_URL}api/purchaseorderapprover/`}),i=a.Z.create({prefixUrl:`${CONFIG.BASE_URL}api/purchaseordernotify/`}),r=document.getElementById("enable_approval_request"),l=document.querySelectorAll(".po-approver-panel");let u=[],m=[];var _=function(){r.addEventListener("change",(async function(e){const t=r.checked?1:0,a=await n.get(`setPurchaseOrderApproval/${t}`).json();a.success?(s.success("Successfully saved!"),h(t)):s.error(a.message)}))},h=function(e){1==e?Array.from(l).forEach((e=>{e.classList.remove("hide")})):Array.from(l).forEach((e=>{e.classList.add("hide")}))},g=function(){document.getElementById("add-po-approver-btn").addEventListener("click",(async function(e){e.preventDefault();let t=new FormData;t.set("user_id",document.getElementById("po_approver").value||0);const n=await o.post("add_details",{body:t}).json();n.success?(s.success("Successfully added!"),p()):s.error(n.message)})),document.getElementById("add-po-notify-btn").addEventListener("click",(async function(e){e.preventDefault();let t=new FormData;t.set("user_id",document.getElementById("po_notify_user").value||0);const n=await i.post("add_details",{body:t}).json();n.success?(s.success("Successfully added!"),y()):s.error(n.message)}))},p=async function(t=1){ne=t,e.start();let n=new FormData;n.set("page",t);const a=await o.post("get",{body:n}).json();u=a.list,function(e){let t='<tr><td class="text-center" colspan="3">No records found.</td></tr>';u.length>0&&(t=u.reduce((function(e,t){return`${e}\n                        <tr>\n                            <td>${t.user_firstname} ${t.user_lastname}</td>\n                            <td>${t.user_email_address}</td>\n                            <td align="center">\n                                ${1==t.is_default?'<span class="label label-success">Default</span>':`<a class="btn btn-info btn-sm waves-effect waves-light set-default-approver-btn" title="Set as Default" data-index="${t.purchase_order_approver_id}" data-name="${t.user_firstname} ${t.user_lastname}">\n                                    Set as Default\n                                </a>`}\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-approver-btn" title="Delete" data-index="${t.purchase_order_approver_id}" data-name="${t.user_firstname} ${t.user_lastname}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("po-approvers-table").innerHTML=t,document.getElementById("po-approvers-pagination").innerHTML=e.pagination,f("#po-approvers-pagination .pagination",p),v()}(a),e.stop()},y=async function(e=1){ae=e,t.start();let n=new FormData;n.set("page",e);const a=await i.post("get",{body:n}).json();m=a.list,function(e){let t='<tr><td class="text-center" colspan="3">No records found.</td></tr>';m.length>0&&(t=m.reduce((function(e,t){return`${e}\n                        <tr>\n                            <td>${t.user_firstname} ${t.user_lastname}</td>\n                            <td>${t.user_email_address}</td>\n                            <td align="center">\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-user-notify-btn" title="Delete" data-index="${t.po_notify_id}" data-name="${t.user_firstname} ${t.user_lastname}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("po-notify-users-table").innerHTML=t,document.getElementById("po-notify-users-pagination").innerHTML=e.pagination,f("#po-notify-users-pagination .pagination",y),b()}(a),t.stop()},v=function(){let e=document.getElementsByClassName("delete-approver-btn"),t=document.getElementsByClassName("set-default-approver-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${n}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((async e=>{e.value&&(await o.get(`delete/${t}`).json()).success&&(s.success("Successfully deleted!"),p(ne))}))}))})),Array.from(t).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to set ${n} as default approver?`,icon:"question",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((async e=>{e.value&&(await o.get(`setDefault/${t}`).json()).success&&(s.success("Successfully saved!"),p(ne))}))}))}))},b=function(){let e=document.getElementsByClassName("delete-user-notify-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${n} for notification?`,icon:"question",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((async e=>{e.value&&(await i.get(`delete/${t}`).json()).success&&(s.success("Successfully deleted!"),y(ne))}))}))}))};return{init:function(){_(),g()},get:async function(e=1){p(e),y(e)}}}();let oe=1;const de=function(){const e=new c(document.getElementById("project_roles")),t=new c(document.getElementById("project_role_documents_form")),n=a.Z.create({prefixUrl:`${CONFIG.BASE_URL}api/projectrole/`});let o=[],i=0;var r=function(){document.getElementById("search-project-role").addEventListener("keyup",(function(e){h()}))},l=function(){document.getElementById("add_project_role_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_project_role_modal").modal("show")}))},u=function(){document.getElementById("add_project_role_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);n.post("add_details",{body:t}).json().then((e=>{e.success?(s.success("Successfully added!"),$("#add_project_role_modal").modal("hide"),h()):s.error(e.message)}))}))},m=function(){document.getElementById("edit_project_role_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);0!=i?n.post(`edit_details/${i}`,{body:t}).json().then((e=>{e.success?(s.success("Successfully updated!"),$("#edit_project_role_modal").modal("hide"),h(oe)):s.error(e.message)})):s.error("Please select an item to edit.")}))},_=function(){document.getElementById("project_role_documents_form").addEventListener("submit",(async e=>{e.preventDefault();const t=new FormData(e.target);if(0==i)return void s.error("Please select a role for this documents.");const a=await n.post(`saveDocuments/${i}`,{body:t}).json();a.success?(s.success("Successfully saved!"),$("#project_role_documents_modal").modal("hide"),h(oe)):s.error(a.message)}))},h=async function(t=1){oe=t,e.start();var a=document.getElementById("search-project-role").value;let s=new FormData;s.set("search",a),s.set("page",t);const d=await n.post("get",{body:s}).json();o=d.list,function(e){let t='<tr><td class="text-center" colspan="3">No records found.</td></tr>';o.length>0&&(t=o.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td>${e.offset+a+1}</td>\n                            <td>${n.project_role_name}</td>\n                            <td align="center">\n                                <a href="" class="btn btn-default btn-sm m-r-5 waves-effect waves-light project-role-documents-btn" data-index="${n.project_role_id}"><span class="fa fa-file-pdf-o"></span></a>\n                                <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-project-role-btn" data-index="${n.project_role_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-project-role-btn" title="Delete" data-index="${n.project_role_id}" data-name="${n.project_role_name}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("project-roles-table").innerHTML=t,document.getElementById("project-roles-pagination").innerHTML=e.pagination,f("#project-roles-pagination .pagination",h),g()}(d),e.stop()},g=function(){let e=document.getElementsByClassName("delete-project-role-btn"),t=document.getElementsByClassName("edit-project-role-btn"),a=document.getElementsByClassName("project-role-documents-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),a=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${a}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((async e=>{if(e.value){const e=await n.get(`delete/${t}`).json();e.success?(s.success("Successfully deleted!"),h(oe)):s.error(e.message)}}))}))})),Array.from(t).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=o.find((e=>e.project_role_id==t));i=t,document.getElementById("edit_project_role_name").value=n.project_role_name,$("#edit_project_role_modal").modal("show")}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=e.currentTarget.dataset.index,n=o.find((e=>e.project_role_id==t));i=t,document.getElementById("project_role_documents_label").innerHTML=n.project_role_name,p(i),$("#project_role_documents_modal").modal("show")}))}))},p=async function(e){t.start();const a=document.querySelectorAll('[name^="role_ptdl_"]'),s=await n.get(`getDocuments/${e}`).json();Array.from(a).forEach((e=>{const t=e.id,n=t.toString().split("_");s.filter((e=>e.ptdl_id==n[2])).length>0?y(`#${t}`,!0):y(`#${t}`,!1)})),t.stop()};return{init:function(){r(),l(),u(),m(),_()},get:h}}();let ie=1;const re=function(){const e=new c(document.getElementById("project_second_roles")),t=new c(document.getElementById("project_second_role_documents_form")),n=a.Z.create({prefixUrl:`${CONFIG.BASE_URL}api/projectsecondrole/`});let o=[],i=0;var r=function(){document.getElementById("search-project-second-role").addEventListener("keyup",(function(e){h()}))},l=function(){document.getElementById("add_project_second_role_btn").addEventListener("click",(function(e){e.preventDefault(),$("#add_project_second_role_modal").modal("show")}))},u=function(){document.getElementById("add_project_second_role_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);n.post("add_details",{body:t}).json().then((e=>{e.success?(s.success("Successfully added!"),$("#add_project_second_role_modal").modal("hide"),h()):s.error(e.message)}))}))},m=function(){document.getElementById("edit_project_second_role_form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target);0!=i?n.post(`edit_details/${i}`,{body:t}).json().then((e=>{e.success?(s.success("Successfully updated!"),$("#edit_project_second_role_modal").modal("hide"),h(ie)):s.error(e.message)})):s.error("Please select an item to edit.")}))},_=function(){document.getElementById("project_second_role_documents_form").addEventListener("submit",(async e=>{e.preventDefault();const t=new FormData(e.target);if(0==i)return void s.error("Please select a second role for this documents.");const a=await n.post(`saveDocuments/${i}`,{body:t}).json();a.success?(s.success("Successfully saved!"),$("#project_second_role_documents_modal").modal("hide"),h(ie)):s.error(a.message)}))},h=async function(t=1){ie=t,e.start();var a=document.getElementById("search-project-second-role").value;let s=new FormData;s.set("search",a),s.set("page",t);const d=await n.post("get",{body:s}).json();o=d.list,function(e){let t='<tr><td class="text-center" colspan="3">No records found.</td></tr>';o.length>0&&(t=o.reduce((function(t,n,a){return`${t}\n                        <tr>\n                            <td>${e.offset+a+1}</td>\n                            <td>${n.project_second_role_name}</td>\n                            <td align="center">\n                                <a href="" class="btn btn-default btn-sm m-r-5 waves-effect waves-light project-second-role-documents-btn" data-index="${n.project_second_role_id}"><span class="fa fa-file-pdf-o"></span></a>\n                                <a href="" class="btn btn-warning btn-sm m-r-5 waves-effect waves-light edit-project-second-role-btn" data-index="${n.project_second_role_id}"><span class="fa fa-pencil"></span></a>\n                                <a class="btn btn-danger btn-sm waves-effect waves-light delete-project-second-role-btn" title="Delete" data-index="${n.project_second_role_id}" data-name="${n.project_second_role_name}">\n                                    <span class="fa fa-trash"></span>\n                                </a>\n                            </td>\n                        </tr>`}),"")),document.getElementById("project-second-roles-table").innerHTML=t,document.getElementById("project-second-roles-pagination").innerHTML=e.pagination,f("#project-second-roles-pagination .pagination",h),g()}(d),e.stop()},g=function(){let e=document.getElementsByClassName("delete-project-second-role-btn"),t=document.getElementsByClassName("edit-project-second-role-btn"),a=document.getElementsByClassName("project-second-role-documents-btn");Array.from(e).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),a=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${a}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((async e=>{if(e.value){const e=await n.get(`delete/${t}`).json();e.success?(s.success("Successfully deleted!"),h(ie)):s.error(e.message)}}))}))})),Array.from(t).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=o.find((e=>e.project_second_role_id==t));i=t,document.getElementById("edit_project_second_role_name").value=n.project_second_role_name,$("#edit_project_second_role_modal").modal("show")}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=e.currentTarget.dataset.index,n=o.find((e=>e.project_second_role_id==t));i=t,document.getElementById("project_second_role_documents_label").innerHTML=n.project_second_role_name,p(i),$("#project_second_role_documents_modal").modal("show")}))}))},p=async function(e){t.start();const a=document.querySelectorAll('[name^="second_role_ptdl_"]'),s=await n.get(`getDocuments/${e}`).json();Array.from(a).forEach((e=>{const t=e.id,n=t.toString().split("_");s.filter((e=>e.ptdl_id==n[3])).length>0?y(`#${t}`,!0):y(`#${t}`,!1)})),t.stop()};return{init:function(){r(),l(),u(),m(),_()},get:h}}();let ce=1;const le=function(){let e=[],t=[],n=0;const o=new Quill("#task_description",{theme:"snow",placeholder:"Enter task description"}),i=new Quill("#edit_task_description",{theme:"snow",placeholder:"Enter task description"}),r=new c(document.getElementById("tasks")),l=a.Z.create({prefixUrl:`${CONFIG.BASE_URL}api/task/`});var u=function(){document.getElementById("search-task").addEventListener("keyup",(function(e){v()}))},m=function(){document.getElementById("add-task-btn").addEventListener("click",(function(e){e.preventDefault(),$("#add-task-modal").modal("show")}))},_=function(){document.getElementById("view-task-archives-btn").addEventListener("click",(function(e){e.preventDefault(),y(),$("#view-task-archives-modal").modal("show")}))};$("#task_category").change((function(){"document_task"==document.getElementById("task_category").value?document.getElementById("project-div").style.display="none":(document.getElementById("project-div").style.display="block",fetch(`${CONFIG.BASE_URL}project/getAllProjects/`).then((e=>e.json())).then((e=>{const t=e.reduce((function(e,t){return`${e}\n                        <option value="${t.project_id}">${t.project_name}</option>`}),"");document.getElementById("task_project_id").innerHTML=t})))})),document.getElementById("clear-description-btn")?.addEventListener("click",(()=>{o.root.innerHTML=""})),document.getElementById("clear-edit-description-btn")?.addEventListener("click",(()=>{i.root.innerHTML=""}));var h=function(){document.getElementById("add-task-form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target),n=o.root.innerHTML;t.append("task_description",n),l.post("add_details",{body:t}).json().then((e=>{e.success?(s.success("Successfully added!"),$("#add-task-modal").modal("hide"),v()):s.error(e.message)}))}))},g=function(){document.getElementById("add-trigger-form").addEventListener("submit",(e=>{if(e.preventDefault(),!$("#technician_id").val())return alertify.logPosition("bottom right"),void alertify.error("Please select a technician!");if(!$("#trigger_id").val())return alertify.logPosition("bottom right"),void alertify.error("Please select a trigger!");const t=new FormData(e.target);let n=document.getElementById("task_id").value;t.set("technicians",JSON.stringify($("#technician_id").val())),t.set("triggers",JSON.stringify($("#trigger_id").val())),l.post(`add_trigger_details/${n}`,{body:t}).json().then((e=>{e.success?(s.success("Successfully added!"),$("#add-trigger-modal").modal("hide"),v()):s.error(e.message)}))}))},p=function(){document.getElementById("edit-task-form").addEventListener("submit",(e=>{e.preventDefault();const t=new FormData(e.target),a=i.root.innerHTML;if(t.append("task_description",a),$("#all_technicians").is(":not(:checked)")&&!$("#technician_id").val())return alertify.logPosition("bottom right"),void alertify.error("Please select a technician!");0!=n?l.post(`edit_details/${n}`,{body:t}).json().then((e=>{e.success?(s.success("Successfully updated!"),$("#edit-task-modal").modal("hide"),v(ce)):s.error(e.message)})):s.error("Please select an item to edit.")}))},y=async function(){const e=await l.get("getArchives").json();t=e.list,function(e){let n='<tr><td class="text-center" colspan="2">No records found.</td></tr>';t.length>0&&(n=t.reduce((function(e,t,n){return`${e}\n                        <tr>\n                            <td align="center">${t.task_name}</td>\n                            <td>${t.task_description}</td>\n                        </tr>`}),"")),document.getElementById("task-archive-table").innerHTML=n,document.getElementById("task-archive-pagination").innerHTML=e.pagination,f("#task-archive-pagination .pagination",y)}(e)},v=async function(t=1){ce=t,r.start();var n=document.getElementById("search-task").value;let a=new FormData;a.set("search",n),a.set("page",t);const s=await l.post("get",{body:a}).json();e=s.list,function(t){let n='<tr><td class="text-center" colspan="6">No records found.</td></tr>';e.length>0&&(n=e.reduce((function(e,t,n){return`${e}\n                        <tr>\n                            <td align="center">${t.task_name}</td>\n                            <td>${t.task_description}</td>\n                            <td align="center">${t.project_name?t.project_name:""}</td>\n                            <td align="center">${t.task_priority_level}</td>\n                            <td align="center">\n                                ${"done"==t.task_status?'<span class="text-success">done</span>':t.task_status} \n                            </td>\n                            <td align="center">\n                                ${"done"==t.task_status?`\n                                    <a class="btn btn-default btn-sm m-t-5 waves-effect waves-light set-archive-btn" title="Archive" data-index="${t.task_id}" data-name="${t.task_name}">\n                                        <span class="fa fa-file-archive-o"></span> Put in Archive.\n                                    </a>\n                                `:` \n                                    <a href="#" class="btn btn-primary btn-sm m-r-2 waves-effect waves-light add-trigger-btn" data-index="${t.task_id}" data-name="${t.task_name}" data-project="${t.project_id}"><span class="fa fa-link"></span></a>\n                                    <a href="#" class="btn btn-warning btn-sm m-r-2 waves-effect waves-light edit-task-btn" data-index="${t.task_id}"><span class="fa fa-pencil"></span></a>\n                                    <a class="btn btn-danger btn-sm m-r-2 waves-effect waves-light delete-task-btn" title="Delete" data-index="${t.task_id}" data-name="${t.task_name}">\n                                        <span class="fa fa-trash"></span>\n                                    </a><br>\n                                    `}\n                            </td>\n                        </tr>`}),"")),document.getElementById("task-table").innerHTML=n,document.getElementById("task-pagination").innerHTML=t.pagination,f("#task-pagination .pagination",v),b()}(s),r.stop()},b=function(){let t=document.getElementsByClassName("set-archive-btn"),a=document.getElementsByClassName("change-task-status-btn"),o=document.getElementsByClassName("add-trigger-btn"),r=document.getElementsByClassName("delete-task-btn"),c=document.getElementsByClassName("edit-task-btn");Array.from(t).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to archive ${n}?`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((async e=>{if(e.value){const e=await l.get(`mark_archive/${t}`).json();e.success?(s.success("Successfully archived!"),v(ce)):s.error(e.message)}}))}))})),Array.from(a).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to mark ${n} as done?`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((async e=>{if(e.value){const e=await l.get(`mark_done/${t}`).json();e.success?(s.success("Successfully marked!"),v(ce)):s.error(e.message)}}))}))})),Array.from(o).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("project"),n=$(this).data("index"),a=$(this).data("name");document.getElementById("task_id").value=n,document.getElementById("trigger_task_name").value=a,function(e,t){let n=[],a=[];e.then((e=>{e.users_list.forEach((e=>{n.push(e.user_id)})),null!=t?(document.getElementById("trigger-div").style.display="none",$("#technician_id").select2("val",n)):(e.triggers_list.forEach((e=>{a.push(e.trigger_id)})),document.getElementById("trigger-div").style.display="block",$("#trigger_id").select2("val",a),$("#technician_id").select2("val",n))}))}(l.get(`getTaskTriggers/${n}`).json(),t),$("#add-trigger-modal").modal("show")}))})),Array.from(r).forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=$(this).data("index"),n=$(this).data("name");d().fire({title:"Are you sure?",html:`Are you sure you want to delete ${n}? <br> You won't be able to revert this.`,icon:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes",allowOutsideClick:!0,reverseButtons:!0}).then((async e=>{if(e.value){const e=await l.get(`delete/${t}`).json();e.success?(s.success("Successfully deleted!"),v(ce)):s.error(e.message)}}))}))})),Array.from(c).forEach((function(t){t.addEventListener("click",(function(t){t.preventDefault();let a=$(this).data("index"),s=e.find((e=>e.task_id==a));n=a,i.root.innerHTML=s.task_description,document.getElementById("edit_task_name").value=s.task_name,document.getElementById("edit_task_priority_level").value=s.task_priority_level,$("#edit_task_priority_level").trigger("change"),$("#edit-task-modal").modal("show")}))}))};return{init:function(){u(),m(),h(),p(),g(),_(),document.getElementById("project-div").style.display="none"},get:v,getArchives:y}}(),ue=document.querySelectorAll("#list-info .list-group-item"),me=document.getElementById("app-settings-form"),fe=document.getElementById("app-settings-btn");(e=>{h.init(),p.init(),b.init(),B.init(),I.init(),k.init(),D.init(),C.init(),G.init(),M.init(),q.init(),Q.init(),z.init(),V.init(),X.init(),te.init(),se.init(),de.init(),re.init(),le.init(),Array.from(e).forEach((t=>{t.addEventListener("click",(n=>{var a,s;n.preventDefault(),a=e,Array.from(a).forEach((e=>{e.classList.remove("active"),e.querySelector(".fa").classList.remove("text-danger")})),t.classList.add("active"),t.querySelector(".fa").classList.add("text-danger"),1==(s=n.currentTarget.dataset.index)||(2==s?h.get():3==s?p.get():4==s?b.get():5==s?B.get():6==s?I.get():7==s?k.get():8==s?D.get():9==s?C.get():10==s?G.get():11==s?M.get():12==s?q.get():13==s?Q.get():14==s?z.get():15==s?V.get():16==s?X.get():17==s?te.get():18==s?se.get():19==s?(de.get(),re.get()):20==s&&le.get())}))}))})(ue),me.addEventListener("submit",(async function(e){e.preventDefault(),fe.disabled=!0;const t=new FormData(me);(await a.Z.post(`${CONFIG.BASE_URL}api/settings/save_app_settings`,{body:t}).json()).success&&(s.success("Successfully saved."),setTimeout((function(){fe.disabled=!1,window.location.reload()}),500))}))}},t={};function n(a){if(t[a])return t[a].exports;var s=t[a]={exports:{}};return e[a].call(s.exports,s,s.exports,n),s.exports}n.m=e,n.x=e=>{},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.j=538,(()=>{var e={538:0},t=[[9432,216]],a=e=>{},s=(s,o)=>{for(var d,i,[r,c,l,u]=o,m=0,f=[];m<r.length;m++)i=r[m],n.o(e,i)&&e[i]&&f.push(e[i][0]),e[i]=0;for(d in c)n.o(c,d)&&(n.m[d]=c[d]);for(l&&l(n),s&&s(o);f.length;)f.shift()();return u&&t.push.apply(t,u),a()},o=self.webpackChunkhotware=self.webpackChunkhotware||[];function d(){for(var a,s=0;s<t.length;s++){for(var o=t[s],d=!0,i=1;i<o.length;i++){var r=o[i];0!==e[r]&&(d=!1)}d&&(t.splice(s--,1),a=n(n.s=o[0]))}return 0===t.length&&(n.x(),n.x=e=>{}),a}o.forEach(s.bind(null,0)),o.push=s.bind(null,o.push.bind(o));var i=n.x;n.x=()=>(n.x=i||(e=>{}),(a=d)())})(),n.x()})();