").text(state.text).html();
+ }
+
+ // console.log(state.text);
+ },
templateResult: function(state) {
if(!state.id) {
return state.text;
}
-
+
if (typeof state.text === "object" ) {
@@ -940,7 +950,8 @@ BMS.FUNCTIONS = {
} else {
- return state.text;
+ // return state.text;
+ return $("
").text(state.text).html();
}
diff --git a/assets/js/bms.min.js b/assets/js/bms.min.js
index 9ef4555..7a14b91 100644
--- a/assets/js/bms.min.js
+++ b/assets/js/bms.min.js
@@ -1 +1 @@
-"use strict";var updateSDPTimeout,BMS=BMS||{};BMS.FUNCTIONS={getDateTime:function(){var t=new Date;return t.getFullYear()+"-"+t.getMonth()+"-"+t.getDay()+"-"+t.getHours()+":"+t.getMinutes()+":"+t.getSeconds()},calculateDiscount:function(t,e=null){return""===e||null===e||"null"===e||0===e?parseFloat(Number(t)):"string"==typeof e&&e.indexOf("%")>0?parseFloat(Number(t)-Number(e.replace("%",""))/100*Number(t)):parseFloat(Number(t)-Number(e))},calculateTarifCharges:function(t,e=null){return""===e||null===e||"null"===e||0===e?0:"string"==typeof e&&e.indexOf("%")>0?(Number(e.replace("%",""))/100*Number(t)).toFixed(2):Number(e).toFixed(2)},datePicker:function({selector:t=".datePicker",format:e="YYYY-MM-DD",timePicker:a=!1}=""){$(t).daterangepicker({autoUpdateInput:!1,singleDatePicker:!0,showDropdowns:!0,timePicker:a,timePicker24Hour:!0,autoApply:!0,parentEl:"div.dynamic-container",drops:"auto",locale:{format:e,cancelLabel:"Clear"}}),$(t).on("apply.daterangepicker",(function(t,a){$(this).val(a.startDate.format(e))})),$(t).on("cancel.daterangepicker",(function(t,e){$(this).val("")}))},dateRangePicker:function({selector:t=".dateRangePicker",format:e="YYYY-MM-DD",timePicker:a=!1}=""){$(t).daterangepicker({autoUpdateInput:!1,showDropdowns:!0,drops:"auto",linkedCalendars:!1,timePicker:a,timePicker24Hour:!0,parentEl:"div.dynamic-container",locale:{format:e,cancelLabel:"Clear"}}),$(t).on("apply.daterangepicker",(function(t,a){$(this).val(a.startDate.format(e)+" - "+a.endDate.format(e))})),$(t).on("cancel.daterangepicker",(function(t,e){$(this).val("")}))},dateRangePickerPreDefined:function({selector:t=".dateRangePickerPreDefined",format:e="YYYY-MM-DD",timePicker:a=!1,ranges:r={}}=""){$(t).daterangepicker({autoUpdateInput:!1,showDropdowns:!0,drops:"auto",alwaysShowCalendars:!0,linkedCalendars:!1,timePicker:a,timePicker24Hour:!0,parentEl:"div.dynamic-container",locale:{format:e,cancelLabel:"Clear"},ranges:Object.keys(r).length>0?r:{Today:[moment(),moment()],"This Month":[moment().startOf("month"),moment().endOf("month")],"Last Month":[moment().subtract(1,"month").startOf("month"),moment().subtract(1,"month").endOf("month")],"This Year":[moment().startOf("year"),moment().endOf("year")],"Last Year":[moment().subtract(1,"year").startOf("year"),moment().subtract(1,"year").endOf("year")],All:[moment(0),moment().subtract("year").endOf("day")]}}),$(t).on("apply.daterangepicker",(function(t,a){$(this).val(a.startDate.format(e)+" - "+a.endDate.format(e))})),$(t).on("cancel.daterangepicker",(function(t,e){$(this).val("")}))},multiDatePicker:function({selector:t=".multiDatePicker",format:e="yyyy-mm-dd"}=""){$(t).datepicker({multidate:!0,multidateSeparator:", ",format:e,todayHighlight:!0})},getCookie:function(t){var e=decodeURIComponent(`; ${document.cookie}`).split(`; ${t}=`);if(e.length>1)return e[1].split("; ")[0]},copy:function(t){var e=$(t);e.select(),navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([e.html()],{type:"text/html"})})])},_n:function(t){let e=BMS.fn.getCookie("lang"),a={bn_BD:"bn-BD"};return void 0!==e?new Intl.NumberFormat(a[e]).format(t):t},createNewSelect2Item:function(t){var e=$(t).attr("select2-create-new-url"),a=$(".select2-search__field").val(),r=encodeURIComponent(a);console.log(t),$("body").trigger("mousedown"),$("#modalDefault").modal("show").find(".modal-content").load(e+"&val="+r),$("#modalDefault").on("hidden.bs.modal",(function(e){BMS.fn.select2(t,"",a)}))},play:function(t,e=!1){var a=`${full_website_address}/assets/sounds/${t}.mp3`,r=new window.Audio(a);$(document).on("pauseAudio",(function(){r.pause()})),r.loop=e,r.play()},pause:function(){$(document).trigger("pauseAudio")},startTimer(t="#timer"){var e=(new Date).getTime();return setInterval((function(){var a=((new Date).getTime()-e)/1e3,r=Math.floor(a%60).toString().padStart(2,0),o=Math.floor(a%3600/60).toString().padStart(2,0),n=Math.floor(a/3600).toString().padStart(2,0);$(t).html(`${n}:${o}:${r}`)}),1e3)},stopTimer:function(t){clearInterval(t)},notify:function(t){Swal.fire({toast:!0,position:"top-right",timer:5e3,timerProgressBar:!0,iconHtml:'
',didOpen:t=>{t.addEventListener("mouseenter",Swal.stopTimer),t.addEventListener("mouseleave",Swal.resumeTimer),this.play("beep")},title:`
${t} `,showConfirmButton:!1,onClose:$("body").css("padding","0px")})},desktopNotify:function(t,e="",a=""){"granted"!==Notification.permission?Notification.requestPermission():new Notification(t,{icon:e,body:a}).onclick=function(){window.focus(),this.close()}},alertError:function(t){Swal.fire({toast:!0,position:"top-right",icon:"error",timer:5e3,timerProgressBar:!0,didOpen:t=>{t.addEventListener("mouseenter",Swal.stopTimer),t.addEventListener("mouseleave",Swal.resumeTimer),this.play("warning")},title:`
${t} `,showConfirmButton:!1,onClose:$("body").css("padding","0px")})},alertSuccess:function(t,e=!0){Swal.fire({toast:!0,position:"top-right",icon:"success",timer:5e3,timerProgressBar:!0,didOpen:t=>{t.addEventListener("mouseenter",Swal.stopTimer),t.addEventListener("mouseleave",Swal.resumeTimer),e&&this.play("warning")},title:`
${t} `,showConfirmButton:!1,onClose:$("body").css("padding","0px")})},dTable:function(t){var e="";e=void 0!==$(t).attr("dt-data-url")?$(t).attr("dt-data-url"):DataTableAjaxPostUrl;var a=!0;void 0!==$(t).attr("dt-disable-on-type-search")&&(a=!1);var r=void 0!==$(".defaultOrder").html()?[[$("th.defaultOrder").index(),"desc"]]:[1,"desc"],o="undefined"!=typeof defaultiDisplayLength?defaultiDisplayLength:15,n=void 0!==$(t).attr("dt-height")?$(t).attr("dt-height"):"60vh",s=$(t).DataTable({processing:!0,serverSide:!0,responsive:!0,scrollX:!0,scrollY:n,scrollCollapse:!0,stateSave:!0,search:{return:!0},initComplete:function(t,e){if(a){var r=new $.fn.dataTable.Api(t);$(".dataTables_filter input").unbind(),$(".dataTables_filter input").bind("keyup",(function(t){13==(t.keyCode||t.which)&&r.search(this.value).draw()}))}},stateSaveParams:function(t,e){var a=this.api();e.search.search="",e.length=15,e.order=r,e.columns.forEach(((t,r)=>{var o=a.column(r).footer(),n=$(o).find("select");n.length>0&&(e.columns[r].search.text=$(n).find(":selected").text())}))},order:r,select:{style:"multi+shift",selector:"td:first-child"},language:Object.keys(language).length>0?language:{processing:"
Processing... "},aLengthMenu:[[15,100,500,1500,5e3,-1],[15,100,500,1500,5e3,"All"]],iDisplayLength:o,ajax:{url:e,type:"post"},columnDefs:[{targets:"countTotal",className:"text-right",render:$.fn.dataTable.render.number(",",".",2)},{targets:"highlightWithCountTotal",className:"text-right highlight",render:$.fn.dataTable.render.number(",",".",2)},{targets:"text-right",className:"text-right"},{targets:"sort",orderable:!0,searchable:!0},{targets:"no-sort",orderable:!1},{targets:0,orderable:!1,checkboxes:{selectRow:!0}},{targets:"px85",className:"px85"},{targets:"px120",className:"px120"},{targets:"px160",className:"px160"},{targets:"px180",className:"px180"},{targets:"px200",className:"px200"},{targets:"px220",className:"px220"},{targets:"px320",className:"px320"},{visible:!1,targets:"hideit"},{targets:"dtDescription",className:"dtDescription"},{targets:"highlight",className:"highlight"}],footerCallback:function(t,e,a,r,o){this.api().columns(".countTotal, .highlightWithCountTotal",{page:"current"}).every((function(){var t=this.data().reduce((function(t,e){return(parseFloat(t)||0)+(parseFloat(e)||0)}),0);$(this.footer()).html(t.toFixed(2).replace(/\d(?=(\d{3})+\.)/g,"$&,"))}))}}),l=s.state.loaded();l=null!==l?l.columns:void 0,s.columns().every((function(t){var e=this,a=$("select, textarea, input:not(.notThisValueFilter)",this.footer());if(void 0!==l&&a.length>0){var r=l[t].search.search,o=void 0!==l[t].search.text?l[t].search.text:"";"SELECT"===a[0].nodeName?($(a).find("option[value='"+r+"']").remove(),$(a).append($(`
${o} `))):$(a).val(r)}$("input, select, textarea",this.footer()).on("enter change clear apply.daterangepicker cancel.daterangepicker",(function(){var t,a=$(this).closest("th").find(".notThisValueFilter");t=a.length>0&&"!="===$(a).val()&&""!==this.value?JSON.stringify({operator:"!=",search:this.value}):this.value,e.search()!==this.value&&e.search(t).draw()}))}));var c=new Date,i=`${c.getDate()}-${c.getMonth()+1}-${c.getFullYear()} ${c.getHours()}:${c.getMinutes()}:${c.getSeconds()}`;$(".printButtonPosition").length>0&&(new $.fn.dataTable.Buttons(s,{buttons:[{extend:"print",text:'
= __("Print"); ?>',titleAttr:"Print",className:"btn btn-default btn-sm",messageTop:"
Printed On: "+i,title:"",footer:!0,autoPrint:!0,exportOptions:{columns:":visible:not(.no-print):not(.dt-checkboxes-cell)",format:{footer:function(t,e,a){return $(a).prop("outerHTML").indexOf("no-print")>0?t.replace(t,""):t}}},messageTop:function(){return void 0!==$("#DtExportTopMessage").html()?$("#DtExportTopMessage").html():"
"+document.title+" Printed On: "+i+"
"}},{extend:"copy",text:'
= __("Copy"); ?>',titleAttr:"Copy",className:"btn btn-default btn-sm",footer:!0,exportOptions:{columns:":visible:not(.no-print):not(.dt-checkboxes-cell)",format:{footer:function(t,e,a){return $(a).prop("outerHTML").indexOf("no-print")>0?t.replace(t,""):t}}}},{extend:"excel",text:'
= __("Export to Excel"); ?>',titleAttr:"Excel",className:"btn btn-default btn-sm",footer:!0,exportOptions:{columns:":visible:not(.no-print):not(.dt-checkboxes-cell)",format:{footer:function(t,e,a){return $(a).prop("outerHTML").indexOf("no-print")>0?t.replace(t,""):t}}},messageTop:function(){if(void 0!==$("#DtExportTopMessage").html())return $("#DtExportTopMessage").html()}},{extend:"pdf",text:'
= __("Export to PDF"); ?>',titleAttr:"PDF",className:"btn btn-default btn-sm",exportOptions:{columns:":visible:not(.no-print):not(.dt-checkboxes-cell)",format:{footer:function(t,e,a){return $(a).prop("outerHTML").indexOf("no-print")>0?t.replace(t,""):t}}},messageTop:function(){if(void 0!==$("#DtExportTopMessage").html())return $("#DtExportTopMessage").html()}},{extend:"colvis",text:'
= __("Hide"); ?>',className:"btn btn-default btn-sm",collectionLayout:"fixed"}]}),s.buttons().container().appendTo(".printButtonPosition")),$("#dataTableWithAjaxExtend tbody").on("click",".has-child-row",(function(){var t=$(this).closest("tr"),e=s.row(t),a=$(this).attr("data-parent-product-id"),r=$("#productReportWarehouseSelection").select2("data")[0].id,o=$(this).text(),n=this;e.child.isShown()?(e.child.hide(),t.removeClass("shown")):($(n).html(`${o}
`),BMS.fn.get(`getChildProductData&pid=${a}&wid=${r}`,(function(a){0==a?BMS.fn.alertError("Sorry! no item found."):(e.child(function(t){var e=s.columns().visible(),a="";return t.forEach((t=>{a+='
',t.forEach(((t,r)=>{var o=s.columns().header()[r].className;a+=e[r]?`${t} `:""})),a+=" "})),$(a).toArray()}(a)).show(),t.addClass("shown"),$("tr.childRow").fadeIn("slow")),$(n).html(`${o}`)})))}))},select2:function(t,e="",a=""){var r=$(t).attr("select2-ajax-url"),o=$(t).attr("select2-minimum-input-length"),n="true"===$(t).attr("select2-tag"),s="false"!==$(t).attr("closeOnSelect"),l="";l=void 0===$(t).attr("select2-create-new-url")?"":`
`,$(document).on("keyup",".select2-search__field",(function(t){"Enter"===t.key&&$(".createNewSelect2Item").click()}));var c=$(t).select2({placeholder:$(t).children("option:first").html()?$(t).children("option:first").html():"Select Options",allowClear:!0,closeOnSelect:s,tags:n,minimumInputLength:o,language:{noResults:function(){return l}},escapeMarkup:function(t){return t},ajax:{url:r,dataType:"json",delay:400,processResults:function(t){return{results:t}},cache:!0},templateResult:function(t){if(!t.id)return t.text;if("object"==typeof t.text){var e=t.text,a="";return a+=`
\n
${e[0]}
\n
Cost
\n
Price
\n
Stock
\n
Brand
\n
\n `,a+=`
\n
${e[1]}
\n
${e[2]}
\n
${e[3]}
\n
${e[4]}
\n
${e[5]}
\n
\n `}return t.text}});if(""!==a&&""===e)$.ajax({type:"get",url:r+"&q="+a}).then((function(t){if(void 0!==(t=JSON.parse(t)[0])){var e=new Option(t.text,t.id,!0,!0);c.append(e).trigger("change")}}));else if(""!==e&&c.find(":selected").val()!==e){var i=new Option(a,e,!0,!0);c.append(i).trigger("change")}},get:function(t,e){$.ajax({url:full_website_address+`/info/?module=data&page=${t}`,contentType:"application/json; charset=utf-8",dataType:"json",success:function(t,a){e(t)},error:function(){e("")}})}},BMS.fn=BMS.FUNCTIONS,BMS.MAIN={printPage:function(t,e,a=function(){}){e.preventDefault(),$(".dynamic-container > iframe").remove();var r=document.createElement("iframe");r.onload=function(){this.contentWindow.focus(),this.contentWindow.print(),a(!0)},r.style.position="fixed",r.style.right="0",r.style.bottom="0",r.style.width="0",r.style.height="0",r.style.border="0",r.src=t,$(".dynamic-container").append(r)},addTariffChargesRow:function(t){$(t).append(`
\n
\n \n Select Tariff/Charges \n \n
\n
\n \n
\n
\n \n
\n
`)}},BMS.PRODUCT={isExists:function(t,e=".productID"){return $(e).filter((function(){return this.value===t})).length>0},validationCheck:function(t,e,a){if(this.isExists(t.pid))return alert(`The product (${t.pn}) is already in the list.`);if(void 0===t.pv)return a(t);var r="",o={},n=[],s={};$.each(t.pv,(function(t,e){Array.isArray(o[e.mk])?o[e.mk].includes(e.mv)||o[e.mk].push(e.mv):o[e.mk]=[e.mv],"DV"===e.t?n.push(e.mv):Array.isArray(s[e.id])?s[e.id].push(e.mv):s[e.id]=[e.mv]})),$.each(o,(function(t,e){r+=`
\n
${t}: \n
\n \n Select ${t}... `,$.each(e,(function(t,e){r+="${e} `})),r+=" \n
\n
"})),Swal.fire({title:"
Select Variation ",html:"for "+t.pn+"
"+r,showCloseButton:!0,showCancelButton:!0,focusConfirm:!1,confirmButtonText:"Ok"}).then((t=>{if(t.isConfirmed){var a=$("#variationSelection select"),r=[];$.each(a,(function(){""!==this.value&&r.push(this.value)}));var o="";$.each(s,(function(t,e){if(r.every((t=>e.includes(t))))return o=t,!1})),""===o||0===r.length?Swal.fire("Sorry! no product found"):e.addProduct(o)}}))},parseProductList:function({category:t="",brand:e="",edition:a="",generic:r="",author:o=""},n){$.ajax({url:full_website_address+`/info/?module=data&page=productList&catId=${t}&brand=${e}&edition=${a}&generic=${r}&author=${o}`,contentType:"application/json; charset=utf-8",dataType:"json",success:function(t,e){n(t)}})},showProduct:function({container:t="#productListContainer",category:e="",brand:a="",edition:r="",generic:o="",author:n=""}=""){this.parseProductList({category:e,brand:a,edition:r,generic:o,author:n},(e=>{if(null!=e){var a="";e.forEach((t=>{var e=full_website_address;t.v&&t.v>0?e+="/images/?for=products&id="+t.id+"&q=YTozOntzOjI6Iml3IjtpOjIwMDtzOjI6ImloIjtpOjIyMDtzOjI6ImlxIjtpOjcwO30=&v="+t.v:e+="/assets/images/noimage.png",a+="
"+t.name+" "})),$(t).html(a)}else $(t).html("
Sorry! No products found in this criteria.
")}))},getDetails:function(t,e){$.ajax({url:full_website_address+`/info/?module=data&page=productDetails&product_id=${t}`,contentType:"application/json; charset=utf-8",dataType:"json",success:function(t,a){e(t)}})},addProduct:function(t="",e=!1){var a=""===t?$("#selectProduct").val():t;""!==a?this.getDetails(a,(t=>{t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{if("1"!==t.hed){var e=t.iq?parseFloat(t.iq).toFixed(0):1,a=`
\n \n ${t.pn} \n \n ${t.pu} \n \n \n \n \n `;$("#productTable > tbody").append(a)}else BMS.fn.alertError("Sorry! The product which have expiry date or batch number, can not be added in sub/bundle product.")})),$("#selectProduct").empty()})),!1===e&&$("#productTable > tbody tr:last").find(".productQnt").select()})):alert("Please select a product")},getListByGeneric:function(t){BMS.fn.select2("#productGenericFilter",t,t)},productUnitCheck:function(t){this.getDetails({product_id:$(t).closest("tr").find(".productID").val(),unit:$(t).val()},(e=>{$(t).closest("tr").find(".productSalePrice").val(e[0].sp)}))}},BMS.POS={clearScreen:function(){$(".dynamic-container").slideUp(350,(function(){var t=new Date;$("#salesDate").val(t.toISOString().split("T")[0]),$("#tariffCharges .row").not("div:first").remove(),$(".tariffChargesName").val("").change();$(".paymentMethodBox").html('
\n
\n Amount \n \n
\n
\n Reference/Info \n \n
\n
\n Bank Account \n \n .... \n \n
\n
\n Payment Method \n \n \n \n \n \n \n \n
\n
'),$("#orderDiscountValue, #shippingCharge, .posSalePaymentAmount, #adjustAmount, #salesNote").val(""),$("#shippingCharge").removeClass("shippingChargeEdited"),$(".posSalePaymentAmount").removeClass("disablePaymentAmountAutoChange"),$("#productTable > tbody").html(""),$("#editSalesId").remove(),$("#payment .modal-footer").html('\n
= __("Close"); ?> \n
\n
= __("Hold"); ?>\n
= __("Confirm"); ?>\n '),$("input:radio, input:checkbox").prop("checked",!1),BMS.fn.select2("#customers",1,"Walk-in Customer"),BMS.POS.grandTotal(),BMS.POS.disableEnableWCSelect()})).slideDown(500)},getProductDetails:function({product_id:t,warehouse_id:e,customer_id:a="",qnt:r="",batch:o="",packet:n=""},s){$.ajax({url:full_website_address+`/info/?module=data&page=productDetailsForPos&product_id=${t}&warehouse_id=${e}&cid=${a}&pqnt=${r}&batch=${o}&packet=${n}`,contentType:"application/json; charset=utf-8",dataType:"json",success:function(t,e){s(t)}})},disableEnableWCSelect:function(){$(".productQnt").length>0?$("#customers, #warehouse").prop("disabled",!0):$("#customers, #warehouse").prop("disabled",!1)},grandTotal:function(t=""){var e=0,a=0;$(".productQnt").each((function(){e+=Number($(this).val()),a+=1})),$(".totalItemAndQnt").html(a+" ("+e+")");var r=0;$(".subtotalCol").each((function(){r+=Number($(this).html())})),$(".totalAmount").html(r.toFixed(2));var o=$("#orderDiscountValue").val(),n=BMS.FUNCTIONS.calculateDiscount(r,o);$(".totalOrderDiscountAmount").html("(-) "+(r-n).toFixed(2));var s=0;if($("#tariffCharges > .row").each((function(){var t=$(this).closest(".row").find(".tariffChargesName").val().split(": ")[1],e=BMS.FUNCTIONS.calculateTarifCharges(n,t);$(this).closest(".row").find(".tariffChargesAmount").val(e),s+=Number(e)})),$(".totalTariffChargesAmount").html("(+) "+s.toFixed(2)),!0===$("#payment").hasClass("in")){if(!1===$("#shippingCharge").is(":focus")&&($("#totalPackets").is(":focus")||$("#packetShippingRate").is(":focus"))){var l=$("#totalPackets").val()*$("#packetShippingRate").val();$("#shippingCharge").val(l)}}else{var c=0;$(".productPacket").each((function(){c+=Number($(this).val())})),$(".displayTotalPackets").html(c.toFixed(2)),$("#totalPackets").val(Math.round(c));l=$("#totalPackets").val()*$("#packetShippingRate").val();$("#shippingCharge").val(l)}var i=(Number(s)+Number(n)).toFixed(2);$(".netTotalAmount").html(i),$("#finalizeSale > tbody > tr:nth-child(1) > td:nth-child(3)").html(i);var d=Number($("#shippingCharge").val()),u=Number(i)+d;"1"===config.posSaleAutoAdjustAmount&&$("#adjustAmount:not(.disableAdjustAmountAutoChange)").val(parseFloat(parseFloat(u).toFixed()-u).toFixed(2));var p=Number($("#adjustAmount").val());u=parseFloat(Number(i)+d+Number(p)).toFixed(2);if("1"===config.posSaleAutoMarkAsPaid){var m=sumInputs(".disablePaymentAmountAutoChange"),h=0;(u>0&&u>m||u<0&&u
f?u-f:0;$("#finalizeSale > tbody > tr:nth-child(4) > td:nth-child(2)").html(u),$("#finalizeSale > tbody > tr:nth-child(6) > td:nth-child(2)").html(v),$("#finalizeSale > tbody > tr:nth-child(7) > td:nth-child(2)").html(g),$("#quickPayableAmount").html(u),!0===$("#payment").hasClass("in")&&(u>0&&uf)&&(Swal.fire({title:"Paid amount can not be more then Grand total.",icon:"error"}),$(".posSalePaymentAmount").last().val(0))},editProductItemDetails:function(t,e){$("#productSaleDetails .modal-title").html(e),$("#productSaleDetails .rowId").val(t);var a=$(`#${t}`);$("#productSaleDetails #productSaleItemPrice").val(a.find(".netSalesPrice").val()),$("#productSaleDetails #productSaleItemDiscount").val(a.find(".productDiscount").val()),$("#productSaleDetails #productSaleItemPacket").val(a.find(".productPacket").val()),$("#productSaleDetails #productSaleItemDetails").val(a.find(".productItemDetails").val())},addProduct:function(t="",e=!1){var a=""===t?$("#selectProduct").val():t;""!==a?($("#selectProduct").val()>0&&$("#selectProduct").html("Search Product.... "),this.getProductDetails({product_id:a,warehouse_id:$("#warehouseId").val(),customer_id:$("#customersId").val()},(t=>{void 0===t.error||!0!==t.error?(t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{var e=0,r=t.iq?parseFloat(t.iq).toFixed(0):1;t.pq>0&&(e=(r/Number(t.pq)).toFixed(2));var o=t.pd?t.pd:"0",n=BMS.FUNCTIONS.calculateDiscount(t.sp,o),s="";s=Number(n)===Number(t.sp)?parseFloat(t.sp).toFixed(2):""+parseFloat(n).toFixed(2)+" "+parseFloat(t.sp).toFixed(2)+" ";var l=Date.now()+t.pid,c=null===t.gn?"":`${t.gn} `,i=` \n \n \n ${t.pn} \n ${c}\n \n ${s} \n \n ${t.pu} \n ${parseFloat(Number(n)*Number(r)).toFixed(2)} \n \n \n \n \n \n \n \n \n \n \n \n \n `;$("#productTable > tbody").append(i)}))})),!1===e&&$("#productTable > tbody tr:last").find(".productQnt").select(),this.grandTotal(),this.disableEnableWCSelect()):Swal.fire({title:"Error!",text:t.msg,icon:"error"})}))):alert("Please select a product")},addReturnProduct:function(t,e,a,r,o,n,s,l,c,i){if(!BMS.PRODUCT.isExists(t)||confirm(`The product (${e}) is already in the list. Do you want to add it again?`)){var d=Date.now()+t,u=` \n \n \n ${e} \n ${null===a?"":`${a} `}\n \n ${l} \n \n ${o} \n -${i} \n \n \n \n \n \n \n \n \n \n \n \n `;$("#productTable > tbody").append(u),this.grandTotal()}},productQntCheck:function(t,e){var a=$(t).closest("tr").find(".netSalesPrice").val(),r=$(t).val(),o=$(t).closest("tr").find(".productDiscount").val(),n=$(t).closest("tr").find("td.subtotalCol"),s=$(t).closest("tr").find(".productPacket"),l=t;0==r&&(Swal.fire({title:"Error!",text:"Product qunatity can not be zero (0)",icon:"error"}),$(t).val(1),r=1),this.getProductDetails({product_id:$(t).closest("tr").find(".productID").val(),warehouse_id:$("#warehouseId").val(),qnt:r,unit:$(t).closest("tr").find(".productItemUnit").val()},(e=>{void 0!==e.error&&!0===e.error&&($(l).val(e.stq),r=e.stq,Swal.fire({title:"Error!",text:e.msg,icon:"error"})),(e=e[0]?e[0]:e).so?$(t).closest("tr").css("background-color","pink"):$(t).closest("tr").css("background-color","white"),$(n).html((BMS.FUNCTIONS.calculateDiscount(a,o)*r).toFixed(2));var c=0;Number(e.pq)>0&&(c=(r/Number(e.pq)).toFixed(2)),s.val(c),this.grandTotal()}))},productPacketCheck:function(){var t=$(selector).closest("tr").find(".netSalesPrice").val(),e=$(selector).val(),a=$(selector).closest("tr").find(".productDiscount").val(),r=$(selector).closest("tr").find("td.subtotalCol"),o=$(selector).closest("tr").find(".productQnt"),n=$(selector).closest("tr").find(".productPacket");this.getProductDetails({product_id:$(selector).closest("tr").find(".productID").val(),warehouse_id:$("#warehouseId").val(),packet:e},(s=>{if(void 0!==s.error&&!0===s.error){$(o).val(s.having_item_quantity),$(r).html((BMS.FUNCTIONS.calculateDiscount(t,a)*s.having_item_quantity).toFixed(2));var l=0;Number(s.product_packet_quantity)>0&&(l=(s.having_item_quantity/Number(s.product_packet_quantity)).toFixed(2)),n.val(l),Swal.fire({title:"Error!",text:s.msg,icon:"error"})}else{var c=Math.round(Number(s.product_packet_quantity)*e);c>0&&($(o).val(c),$(r).html((BMS.FUNCTIONS.calculateDiscount(t,a)*c).toFixed(2)))}this.grandTotal()}))},productDiscountCheck:function(t){var e=$("#productSaleItemPrice").val(),a=$("#productSaleItemDiscount").val();"Enter"===t.key&&a.indexOf("%")>1&&a.replace("%","")>=100?(Swal.fire({title:"Error!",text:"Discount Must be below of 100%",icon:"error"}),$("#productSaleItemDiscount").val(""),$("#productSaleItemDiscount").select(),t.preventDefault()):"Enter"===t.key&&Number(a)>=Number(e)&&a.indexOf("%")<1&&($("#productSaleItemDiscount").val(""),$("#productSaleItemDiscount").select(),"Enter"===t.key&&t.preventDefault(),Swal.fire({title:"Error!",text:"Discount Must be below of product sale price",icon:"error"}),t.preventDefault())},orderDiscountCheck:function(t,e){var a=$(".totalAmount").text(),r=$(t).val();r.indexOf("%")>1&&r.replace("%","")>=100?(Swal.fire({title:"Error!",text:"Discount Must be below of 100%",icon:"error"}),$(t).val(0),e.preventDefault()):Number(a)<0&&Number(r)>0?(Swal.fire({title:"Error!",text:"Discount must be a negative amount in case of negative total amount.",icon:"error"}),$(t).val(-Number(r)),e.preventDefault()):Number(a)<0&&(Number(r)>0||Math.abs(Number(r))>=Math.abs(Number(a)))||Number(a)>0&&Number(r)>=Number(a)&&r.indexOf("%")<1?(Swal.fire({title:"Error!",text:"Discount Must be below of total amount.",icon:"error"}),$(t).val(0),e.preventDefault()):!0!==this.isGivenDiscountPermitted(t)&&(Swal.fire({title:"Error!",text:`You do not have permission to give ${r} discount.`,icon:"error"}),$(t).val(0),e.preventDefault()),this.grandTotal()},isGivenDiscountPermitted:function(t){var e=$(".totalAmount").text(),a=$(t).val();if(""!=get_options("maxDiscount")){var r=e-BMS.FUNCTIONS.calculateDiscount(e,get_options("maxDiscount")),o=e-BMS.FUNCTIONS.calculateDiscount(e,a);return Math.abs(r)>=Math.abs(o)}return!0}},BMS.PURCHASE={getProductDetails:BMS.PRODUCT.getDetails,grandTotal:function(){var t=0;$(".productQnt").each((function(){t+=Number($(this).val())})),$("#totalItems").html($(".productQnt").length+"("+t+")");var e=0;$(".subTotal").each((function(){e+=Number($(this).html())})),$(".totalPurchasePrice").html(e.toFixed(2));var a=BMS.FUNCTIONS.calculateDiscount(e,$("#purchaseDiscountValue").val());$(".totalPurchaseDiscount").html("(-) "+(e-a).toFixed(2));var r=0;$("#tariffCharges > .row").each((function(){var t=$(this).closest(".row").find(".tariffChargesName").val().split(": ")[1],e=BMS.FUNCTIONS.calculateTarifCharges(a,t);$(this).closest(".row").find(".tariffChargesAmount").val(e),r+=Number(e)})),$(".totalTariffCharges").html("(+) "+r.toFixed(2));var o=(Number(r)+Number(a)).toFixed(2);$(".netTotal").html(o),$("#purchaseNetTotal").val(o);var n=Number(o)+Number($("#purchaseShipping").val());$("#purchaseGrandTotal").val(n);var s=Number($("#purchasePaidAmount").val()),l=n<=s?0:n-s,c=n>=s?0:s-n;$("#purchaseChangeAmount").val(c),$("#purchaseDueAmount").val(l)},calculateEachProduct:function(t){var e=$(t).closest("tr").find(".productPurchasePrice").val(),a=$(t).closest("tr").find(".productQnt").val(),r=$(t).closest("tr").find(".productPurchaseDiscount").val(),o=$(t).closest("tr").find(".subTotal");return isNaN(a)?(alert("Product quantity must be a valid number."),void $(t).closest("tr").find(".productQnt").val(1)):a<1&&"Ordered"!==$("#purchaseStatus").val()?(alert("Product quantity must be minimum of 1."),void $(t).closest("tr").find(".productQnt").val(1)):(""!==e&&null!==e&&"null"!==e||(e=0,$(t).closest("tr").find(".productPurchasePrice").val(0)),r.indexOf("%")>1&&r.replace("%","")>=100?($(t).closest("tr").find(".productPurchaseDiscount").val(0),void alert("Discount Must be below of 100%")):Number(r)>Number(e)&&r.indexOf("%")<1?($(t).closest("tr").find(".productPurchaseDiscount").val(0),void alert("Discount Must be below of product purchase price")):void $(o).html((BMS.FUNCTIONS.calculateDiscount(e,r)*a).toFixed(2)))},addProduct:function(t="",e=!1){var a=""===t?$("#selectProduct").val():t;""!==a?this.getProductDetails(a,(t=>{t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{var e=" ";void 0!==t.hed&&"1"===t.hed&&"Ordered"!==$("#purchaseStatus").val()&&(e=`\n = __("Select Batch"); ?>.... \n `);var a=t.iq?parseFloat(t.iq).toFixed(0):1,r=`\n \n ${t.pn} \n ${e} \n ${t.alertq} ${t.soldq} ${t.stockq} \n \n ${t.pu} \n \n \n \n ${t.pp} \n \n \n \n `;$("#productTable > tbody").append(r)}))})),!1===e&&$("#productTable > tbody tr:last").find(".productQnt").select(),this.grandTotal(),$("#selectProduct").empty()})):alert("Please select a product")},productUnitCheck:function(t){var e=$(t).closest("tr").find(".productID").val(),a=this;$.ajax({url:full_website_address+"/info/?module=data&page=productUnitDetails&product_id="+e+"&unit="+$(t).val(),contentType:"application/json; charset=utf-8",dataType:"json",success:function(e,r){"success"==r&&($(t).closest("tr").find(".productPurchasePrice").val(e.pp),$(t).closest("tr").find(".productMainPurchasePrice").val(e.pp),a.calculateEachProduct(t),a.grandTotal())}})}},BMS.ORDER=Object.assign({},BMS.POS),BMS.ORDER.addProduct=function(t=""){var e=""===t?$("#selectProduct").val():t;""!==e?($("#selectProduct").val()>0&&$("#selectProduct").html("Search Product.... "),BMS.PRODUCT.getDetails(e,(t=>{t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{var a=0,r=t.iq?parseFloat(t.iq).toFixed(0):1;t.pq>0&&(a=(r/Number(t.pq)).toFixed(2));var o=t.pd?t.pd:"0",n=BMS.FUNCTIONS.calculateDiscount(t.sp,o),s="";s=Number(n)===Number(t.sp)?parseFloat(t.sp).toFixed(2):""+n+" "+parseFloat(t.sp).toFixed(2)+" ";var l=Date.now()+t.pid,c=` \n \n \n ${t.pn} \n \n ${s} \n \n ${t.pu} \n ${parseFloat(Number(n)*Number(r)).toFixed(2)} \n \n \n \n \n \n \n \n \n \n \n \n \n `;$("#productTable > tbody").append(c)}))})),$("#productTable > tbody tr:last").find(".productQnt").select(),this.grandTotal(),this.disableEnableWCSelect()}))):alert("Please select a product")},BMS.ORDER.productQntCheck=function(t,e){var a=$(t).closest("tr").find(".netSalesPrice").val(),r=$(t).val(),o=$(t).closest("tr").find(".productDiscount").val(),n=$(t).closest("tr").find("td.subtotalCol");0==r&&(Swal.fire({title:"Error!",text:"Product qunatity can not be zero (0)",icon:"error"}),$(t).val(1),r=1),$(n).html((BMS.FUNCTIONS.calculateDiscount(a,o)*r).toFixed(2)),this.grandTotal()},BMS.STOCK_TRANSFER={getProductDetails:BMS.POS.getProductDetails,grandTotal:function(){var t=0;$(".productQnt").each((function(){t+=Number($(this).val())})),$("#totalItems").html($(".productQnt").length+"("+t+")");var e=0;$(".subTotal").each((function(){e+=Number($(this).html())})),$(".totalPurchasePrice").html(e.toFixed(2))},disableEnableWarehouseSelect:function(){$(".productQnt").length>0?$("#stockTransferFromWarehouse, #stockTransferToWarehouse").prop("disabled",!0):$("#stockTransferFromWarehouse, #stockTransferToWarehouse").prop("disabled",!1)},calculateEachProduct:function(t){var e=$(t).closest("tr").find(".productPurchasePrice").val(),a=$(t).closest("tr").find(".productQnt").val(),r=$(t).closest("tr").find(".productPurchaseDiscount").val(),o=$(t).closest("tr").find(".subTotal");return a<1?(alert("Product quantity must be minimum of 1."),void $(t).closest("tr").find(".productQnt").val(1)):(""!==e&&null!==e&&"null"!==e||(e=0,$(t).closest("tr").find(".productPurchasePrice").val(0)),r.indexOf("%")>1&&r.replace("%","")>=100?($(t).closest("tr").find(".productPurchaseDiscount").val(0),void alert("Discount Must be below of 100%")):Number(r)>Number(e)&&r.indexOf("%")<1?($(t).closest("tr").find(".productPurchaseDiscount").val(0),void alert("Discount Must be below of product purchase price")):void $(o).html((BMS.FUNCTIONS.calculateDiscount(e,r)*a).toFixed(2)))},addProduct:function(t="",e=!1){var a=""===t?$("#selectProduct").val():t,r=$("#stockTransferFromWarehouseId").val();""!==r?""!==a?this.getProductDetails({product_id:a,warehouse_id:r,qnt:1},(t=>{void 0===t.error||!0!==t.error?(t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{var e=" ";void 0!==t.hed&&"1"===t.hed&&(e=`\n = __("Select Batch"); ?>.... \n `);var a=t.iq?parseFloat(t.iq).toFixed(0):1,r=`\n \n ${t.pn} \n ${e} \n \n ${t.pu} \n \n \n \n ${parseFloat(t.pp*a).toFixed(2)} \n \n \n \n `;$("#productTable > tbody").append(r)}))})),this.grandTotal(),this.disableEnableWarehouseSelect(),$("#selectProduct").empty()):Swal.fire({title:"Error!",text:t.msg,icon:"error"})})):alert("Please select a product"):alert("Please select an warehouse to add product")},productUnitCheck:function(t){var e=t;this.getProductDetails({product_id:$(t).closest("tr").find(".productID").val(),warehouse_id:$("#stockTransferFromWarehouseId").val(),qnt:$(t).closest("tr").find(".productQnt").val(),unit:$(t).val()},(t=>{void 0!==t.error&&!0===t.error&&(console.log(t.stq),$(e).closest("tr").find(".productQnt").val(t.stq),Swal.fire({title:"Error!",text:t.msg,icon:"error"})),$(e).closest("tr").find(".productPurchasePrice").val(parseFloat(t.pp).toFixed(2)),this.calculateEachProduct(e),this.grandTotal()}))},productQntCheck:function(t){var e=$(t).val(),a=$(t);isNaN(e)&&(alert("Product quantity must be a valid number."),$(t).val(1),e=1),e<1&&(Swal.fire({title:"Error!",text:"Product qunatity must be at least one",icon:"error"}),$(t).val(1),e=1),this.getProductDetails({product_id:$(t).closest("tr").find(".productID").val(),warehouse_id:$("#stockTransferFromWarehouseId").val(),qnt:e,unit:$(t).closest("tr").find(".productItemUnit").val()},(t=>{void 0!==t.error&&!0===t.error&&($(a).val(t.stq),Swal.fire({title:"Error!",text:t.msg,icon:"error"})),this.calculateEachProduct(a),this.grandTotal()}))}},BMS.STOCK_ENTRY={getProductDetails:BMS.PRODUCT.getDetails,grandTotal:function(){var t=0;$(".productQnt").each((function(){t+=Number($(this).val())})),$("#totalItems").html($(".productQnt").length+"("+t+")");var e=0;$(".subTotal").each((function(){e+=Number($(this).html())})),$(".totalPurchasePrice").html(e.toFixed(2))},calculateEachProduct:function(t){var e=$(t).closest("tr").find(".productPurchasePrice").val(),a=$(t).closest("tr").find(".productQnt").val(),r=$(t).closest("tr").find(".productPurchaseDiscount").val(),o=$(t).closest("tr").find(".subTotal");return a<1&&"Production"===$("#stockEntryType").val()?(alert("Negative quantity is not valid for Production of stock."),void $(t).closest("tr").find(".productQnt").val(1)):(""!==e&&null!==e&&"null"!==e||(e=0,$(t).closest("tr").find(".productPurchasePrice").val(0)),r.indexOf("%")>1&&r.replace("%","")>=100?($(t).closest("tr").find(".productPurchaseDiscount").val(0),void alert("Discount Must be below of 100%")):Number(r)>Number(e)&&r.indexOf("%")<1?($(t).closest("tr").find(".productPurchaseDiscount").val(0),void alert("Discount Must be below of product purchase price")):void $(o).html((BMS.FUNCTIONS.calculateDiscount(e,r)*a).toFixed(2)))},addProduct:function(t=""){var e=""===t?$("#selectProduct").val():t;""!==$("#stockTransferFromWarehouseId").val()?""!==e?this.getProductDetails(e,(t=>{void 0===t.error||!0!==t.error?(t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{var e=" ";void 0!==t.hed&&"1"===t.hed&&(e=`\n = __("Select Batch"); ?>.... \n `);var a=t.iq?parseFloat(t.iq).toFixed(0):1,r=`\n \n ${t.pn} \n ${e} \n \n ${t.pu} \n \n \n \n ${parseFloat(t.pp*a).toFixed(2)} \n \n \n \n `;$("#productTable > tbody").append(r)}))})),this.grandTotal(),$("#selectProduct").empty()):Swal.fire({title:"Error!",text:t.msg,icon:"error"})})):alert("Please select a product"):alert("Please select an warehouse to add product")}},BMS.RETURN={getProductReturnDetails:function({product_id:t,customer_id:e},a){$.ajax({url:full_website_address+"/info/?module=data&page=productDetailsForReturn&product_id="+t+"&customer_id="+e,contentType:"application/json; charset=utf-8",dataType:"json",success:function(t,e){a(t)}})},grandTotal:function(){var t=0;$(".productQnt").each((function(){t+=Number($(this).val())})),$("#totalItems").html($(".productQnt").length+"("+t+")");var e=0;$(".subTotal").each((function(){e+=Number($(this).html())})),$(".totalReturnPrice").html(e.toFixed(2));var a=BMS.FUNCTIONS.calculateDiscount(e,$("#returnDiscountValue").val());$(".totalReturnDiscount").html("(-) "+(e-a).toFixed(2));var r=0;$("#tariffCharges > .row").each((function(){var t=$(this).closest(".row").find(".tariffChargesName").val().split(": ")[1],e=BMS.FUNCTIONS.calculateTarifCharges(a,t);$(this).closest(".row").find(".tariffChargesAmount").val(e),r+=Number(e)})),$(".totalTariffCharges").html("(+) "+r.toFixed(2));var o=(Number(r)+Number(a)).toFixed(2);$(".netTotal").html(o),$("#returnNetTotal").val(o);var n=$("#returnShipping").val(),s=Number(o)+Number(n)-Number($("#returnSurcharge").val());$("#returnGrandTotal").val(s);var l=Number($("#returnPaidAmount").val()),c=s<=l?0:s-l,i=s>=l?0:l-s;$("#returnChangeAmount").val(i),$("#returnDueAmount").val(c)},calculateEachProduct:function(t){var e=$(t).closest("tr").find(".productReturnPrice").val(),a=$(t).closest("tr").find(".productQnt").val(),r=$(t).closest("tr").find(".productReturnDiscount").val(),o=$(t).closest("tr").find(".subTotal");if(a<1)return alert("Product quantity must be minimum of 1."),void $(t).closest("tr").find(".productQnt").val(1);""!==e&&null!==e&&"null"!==e||(e=0,$(t).closest("tr").find(".productReturnPrice").val(0)),r.indexOf("%")>1&&r.replace("%","")>=100?alert("Discount Must be below of 100%"):Number(r)>Number(e)&&r.indexOf("%")<1?alert("Discount Must be below of product return price"):$(o).html((BMS.FUNCTIONS.calculateDiscount(e,r)*a).toFixed(2))},addProduct:function(t=""){var e=""===t?$("#selectProduct").val():t,a=$("#returnCustomer").val();""!==a?""!==e?this.getProductReturnDetails({product_id:e,customer_id:a},(t=>{t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{var e=t.pd?t.pd:"0",a=parseFloat(BMS.FUNCTIONS.calculateDiscount(t.sp,e)).toFixed(2),r=" ";void 0!==t.hed&&"1"===t.hed&&(r=`\n = __("Select Batch"); ?>.... \n `);var o=`\n \n ${t.pn} (Purchased: ${t.prq} Returned: ${t.rtq} ) \n ${r} \n \n ${t.pu} \n \n \n \n ${a} \n \n \n \n `;$("#productTable > tbody").append(o)}))})),this.grandTotal(),$("#selectProduct").empty()})):alert("Please select a product"):alert("Please select the customer")},productUnitCheck:function(t){var e=t;this.getProductReturnDetails({product_id:$(t).closest("tr").find(".productID").val(),customer_id:$("#returnCustomer").val(),unit:$(t).val()},(t=>{var a=t[0];$(e).closest("tr").find(".productReturnPrice").val(parseFloat(a.sp).toFixed(2));var r=a.pn+" (Purchased: "+parseFloat(a.prq).toFixed(2)+", Returned: "+parseFloat(a.rtq).toFixed(2)+")";$(e).closest("tr").find(".productDetails").html(r),this.calculateEachProduct(e),this.grandTotal()}))}},BMS.WASTAGE_SALE={grandTotal:function(){var t=0;$(".wastageSaleItemQnt").each((function(){t+=Number($(this).val())})),$("#totalItems").html($(".wastageSaleItemQnt").length+"("+t+")");var e=0;$(".wastageSaleItemSubtotal").each((function(){e+=Number($(this).text())})),$(".totalWastageSalePrice").html(e.toFixed(2));var a=BMS.FUNCTIONS.calculateDiscount(e,$("#wastageSaleDiscountValue").val());$(".totalWastageSaleDiscount").html("(-) "+(e-a).toFixed(2));var r=0;$("#tariffCharges > .row").each((function(){var t=$(this).closest(".row").find(".tariffChargesName").val().split(": ")[1],e=BMS.FUNCTIONS.calculateTarifCharges(a,t);$(this).closest(".row").find(".tariffChargesAmount").val(e),r+=Number(e)})),$(".totalTariffCharges").html("(+) "+r.toFixed(2));var o=(Number(r)+Number(a)).toFixed(2);$(".netTotal").html(o),$("#wastageSaleNetTotal").val(o);var n=$("#wastageSalePaidAmount").val(),s=n tbody").append(' 0.00 '),$(".wastageSaleItem").focus(),this.grandTotal()}},BMS.SPECIMEN_COPY={getProductDetails:BMS.POS.getProductDetails,disableEnableWarehouseSelect:function(){$(".productQnt").length>0?$("#scTransferWarehouse").prop("disabled",!0):$("#scTransferWarehouse").prop("disabled",!1)},addProduct:function(t=""){var e=""===t?$("#selectProduct").val():t,a=$("#scTransferWarehouse").val();""!==a?""!==e?this.getProductDetails({product_id:e,warehouse_id:a},(t=>{void 0===t.error||!0!==t.error?(t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{var e=t.iq?parseFloat(t.iq).toFixed(0):1,a=` \n ${t.pn} \n \n ${t.pu} \n \n \n \n `;$("#productTable > tbody").append(a)}))})),this.disableEnableWarehouseSelect(),$("#selectProduct").empty()):Swal.fire({title:"Error!",text:t.msg,icon:"error"})})):alert("Please select a product"):alert("Please select an warehouse to add product")},productUnitCheck:function(t){this.getProductDetails({product_id:$(t).closest("tr").find(".productID").val(),warehouse_id:$("#scTransferWarehouse").val(),qnt:$(t).closest("tr").find(".productQnt").val(),unit:$(t).val()},(e=>{void 0!==e.error&&!0===e.error&&($(t).closest("tr").find(".productQnt").val(e.stq),Swal.fire({title:"Error!",text:e.msg,icon:"error"}))}))},productQntCheck:function(t){var e=$(t).val();isNaN(e)&&(alert("Product quantity must be a valid number."),$(t).val(1),e=1),e<1&&(Swal.fire({title:"Error!",text:"Product qunatity must be at least one",icon:"error"}),$(t).val(1),e=1),this.getProductDetails({product_id:$(t).closest("tr").find(".productID").val(),warehouse_id:$("#scTransferWarehouse").val(),qnt:e,unit:$(t).closest("tr").find(".productItemUnit").val()},(e=>{void 0!==e.error&&!0===e.error&&($(t).val(e.stq),Swal.fire({title:"Error!",text:e.msg,icon:"error"}))}))}},BMS.SC_DISTRIBUTION={getProductDetails:BMS.PRODUCT.getDetails,addProduct:function(t=""){var e=""===t?$("#selectProduct").val():t;""!==e?this.getProductDetails(e,(t=>{void 0===t.error||!0!==t.error?(t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{var e=t.iq?parseFloat(t.iq).toFixed(0):1,a=`\n \n ${t.pn} \n \n ${t.pu} \n \n \n \n `;$("#productTable > tbody").append(a)}))})),$("#selectProduct").empty()):Swal.fire({title:"Error!",text:t.msg,icon:"error"})})):alert("Please select a product")}},BMS.CHAT={showChatBox:function(t,e){""!==t&&t.preventDefault(),$.ajax({url:full_website_address+"/info/?module=chat&page=getChatUserData",type:"post",data:{userId:e},success:function(t,a){t=JSON.parse(t);console.log(t);var r="";""!==t.latest_msg&&t.latest_msg.forEach((t=>{t.from_user!=e?r+=`\n
\n ${t.from_username} \n ${t.datetime} \n
\n
\n
\n ${t.msg_text}\n
\n
`:r+=`\n
\n ${t.from_username} \n ${t.datetime} \n
\n
\n
\n ${t.msg_text}\n
\n
`}));var o=``;$(".chatBox").prepend(o).ready((function(){var t=$(`.chatBoxForUser${e}`).find(".direct-chat-messages"),a=$(t).get(0).scrollHeight;$(t).animate({scrollTop:a},0),$(t).closest(".chatBox").find(".message-composer").focus()}))}})},send:function(t,e){wss.send(JSON.stringify({type:"message",toUser:e,msg:t}))}};
\ No newline at end of file
+"use strict";var updateSDPTimeout,BMS=BMS||{};BMS.FUNCTIONS={getDateTime:function(){var t=new Date;return t.getFullYear()+"-"+t.getMonth()+"-"+t.getDay()+"-"+t.getHours()+":"+t.getMinutes()+":"+t.getSeconds()},calculateDiscount:function(t,e=null){return""===e||null===e||"null"===e||0===e?parseFloat(Number(t)):"string"==typeof e&&e.indexOf("%")>0?parseFloat(Number(t)-Number(e.replace("%",""))/100*Number(t)):parseFloat(Number(t)-Number(e))},calculateTarifCharges:function(t,e=null){return""===e||null===e||"null"===e||0===e?0:"string"==typeof e&&e.indexOf("%")>0?(Number(e.replace("%",""))/100*Number(t)).toFixed(2):Number(e).toFixed(2)},datePicker:function({selector:t=".datePicker",format:e="YYYY-MM-DD",timePicker:a=!1}=""){$(t).daterangepicker({autoUpdateInput:!1,singleDatePicker:!0,showDropdowns:!0,timePicker:a,timePicker24Hour:!0,autoApply:!0,parentEl:"div.dynamic-container",drops:"auto",locale:{format:e,cancelLabel:"Clear"}}),$(t).on("apply.daterangepicker",(function(t,a){$(this).val(a.startDate.format(e))})),$(t).on("cancel.daterangepicker",(function(t,e){$(this).val("")}))},dateRangePicker:function({selector:t=".dateRangePicker",format:e="YYYY-MM-DD",timePicker:a=!1}=""){$(t).daterangepicker({autoUpdateInput:!1,showDropdowns:!0,drops:"auto",linkedCalendars:!1,timePicker:a,timePicker24Hour:!0,parentEl:"div.dynamic-container",locale:{format:e,cancelLabel:"Clear"}}),$(t).on("apply.daterangepicker",(function(t,a){$(this).val(a.startDate.format(e)+" - "+a.endDate.format(e))})),$(t).on("cancel.daterangepicker",(function(t,e){$(this).val("")}))},dateRangePickerPreDefined:function({selector:t=".dateRangePickerPreDefined",format:e="YYYY-MM-DD",timePicker:a=!1,ranges:r={}}=""){$(t).daterangepicker({autoUpdateInput:!1,showDropdowns:!0,drops:"auto",alwaysShowCalendars:!0,linkedCalendars:!1,timePicker:a,timePicker24Hour:!0,parentEl:"div.dynamic-container",locale:{format:e,cancelLabel:"Clear"},ranges:Object.keys(r).length>0?r:{Today:[moment(),moment()],"This Month":[moment().startOf("month"),moment().endOf("month")],"Last Month":[moment().subtract(1,"month").startOf("month"),moment().subtract(1,"month").endOf("month")],"This Year":[moment().startOf("year"),moment().endOf("year")],"Last Year":[moment().subtract(1,"year").startOf("year"),moment().subtract(1,"year").endOf("year")],All:[moment(0),moment().subtract("year").endOf("day")]}}),$(t).on("apply.daterangepicker",(function(t,a){$(this).val(a.startDate.format(e)+" - "+a.endDate.format(e))})),$(t).on("cancel.daterangepicker",(function(t,e){$(this).val("")}))},multiDatePicker:function({selector:t=".multiDatePicker",format:e="yyyy-mm-dd"}=""){$(t).datepicker({multidate:!0,multidateSeparator:", ",format:e,todayHighlight:!0})},getCookie:function(t){var e=decodeURIComponent(`; ${document.cookie}`).split(`; ${t}=`);if(e.length>1)return e[1].split("; ")[0]},copy:function(t){var e=$(t);e.select(),navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([e.html()],{type:"text/html"})})])},_n:function(t){let e=BMS.fn.getCookie("lang"),a={bn_BD:"bn-BD"};return void 0!==e?new Intl.NumberFormat(a[e]).format(t):t},createNewSelect2Item:function(t){var e=$(t).attr("select2-create-new-url"),a=$(".select2-search__field").val(),r=encodeURIComponent(a);console.log(t),$("body").trigger("mousedown"),$("#modalDefault").modal("show").find(".modal-content").load(e+"&val="+r),$("#modalDefault").on("hidden.bs.modal",(function(e){BMS.fn.select2(t,"",a)}))},play:function(t,e=!1){var a=`${full_website_address}/assets/sounds/${t}.mp3`,r=new window.Audio(a);$(document).on("pauseAudio",(function(){r.pause()})),r.loop=e,r.play()},pause:function(){$(document).trigger("pauseAudio")},startTimer(t="#timer"){var e=(new Date).getTime();return setInterval((function(){var a=((new Date).getTime()-e)/1e3,r=Math.floor(a%60).toString().padStart(2,0),o=Math.floor(a%3600/60).toString().padStart(2,0),n=Math.floor(a/3600).toString().padStart(2,0);$(t).html(`${n}:${o}:${r}`)}),1e3)},stopTimer:function(t){clearInterval(t)},notify:function(t){Swal.fire({toast:!0,position:"top-right",timer:5e3,timerProgressBar:!0,iconHtml:' ',didOpen:t=>{t.addEventListener("mouseenter",Swal.stopTimer),t.addEventListener("mouseleave",Swal.resumeTimer),this.play("beep")},title:` ${t} `,showConfirmButton:!1,onClose:$("body").css("padding","0px")})},desktopNotify:function(t,e="",a=""){"granted"!==Notification.permission?Notification.requestPermission():new Notification(t,{icon:e,body:a}).onclick=function(){window.focus(),this.close()}},alertError:function(t){Swal.fire({toast:!0,position:"top-right",icon:"error",timer:5e3,timerProgressBar:!0,didOpen:t=>{t.addEventListener("mouseenter",Swal.stopTimer),t.addEventListener("mouseleave",Swal.resumeTimer),this.play("warning")},title:` ${t} `,showConfirmButton:!1,onClose:$("body").css("padding","0px")})},alertSuccess:function(t,e=!0){Swal.fire({toast:!0,position:"top-right",icon:"success",timer:5e3,timerProgressBar:!0,didOpen:t=>{t.addEventListener("mouseenter",Swal.stopTimer),t.addEventListener("mouseleave",Swal.resumeTimer),e&&this.play("warning")},title:` ${t} `,showConfirmButton:!1,onClose:$("body").css("padding","0px")})},dTable:function(t){var e="";e=void 0!==$(t).attr("dt-data-url")?$(t).attr("dt-data-url"):DataTableAjaxPostUrl;var a=!0;void 0!==$(t).attr("dt-disable-on-type-search")&&(a=!1);var r=void 0!==$(".defaultOrder").html()?[[$("th.defaultOrder").index(),"desc"]]:[1,"desc"],o="undefined"!=typeof defaultiDisplayLength?defaultiDisplayLength:15,n=void 0!==$(t).attr("dt-height")?$(t).attr("dt-height"):"60vh",s=$(t).DataTable({processing:!0,serverSide:!0,responsive:!0,scrollX:!0,scrollY:n,scrollCollapse:!0,stateSave:!0,search:{return:!0},initComplete:function(t,e){if(a){var r=new $.fn.dataTable.Api(t);$(".dataTables_filter input").unbind(),$(".dataTables_filter input").bind("keyup",(function(t){13==(t.keyCode||t.which)&&r.search(this.value).draw()}))}},stateSaveParams:function(t,e){var a=this.api();e.search.search="",e.length=15,e.order=r,e.columns.forEach(((t,r)=>{var o=a.column(r).footer(),n=$(o).find("select");n.length>0&&(e.columns[r].search.text=$(n).find(":selected").text())}))},order:r,select:{style:"multi+shift",selector:"td:first-child"},language:Object.keys(language).length>0?language:{processing:"Processing... "},aLengthMenu:[[15,100,500,1500,5e3,-1],[15,100,500,1500,5e3,"All"]],iDisplayLength:o,ajax:{url:e,type:"post"},columnDefs:[{targets:"countTotal",className:"text-right",render:$.fn.dataTable.render.number(",",".",2)},{targets:"highlightWithCountTotal",className:"text-right highlight",render:$.fn.dataTable.render.number(",",".",2)},{targets:"text-right",className:"text-right"},{targets:"sort",orderable:!0,searchable:!0},{targets:"no-sort",orderable:!1},{targets:0,orderable:!1,checkboxes:{selectRow:!0}},{targets:"px85",className:"px85"},{targets:"px120",className:"px120"},{targets:"px160",className:"px160"},{targets:"px180",className:"px180"},{targets:"px200",className:"px200"},{targets:"px220",className:"px220"},{targets:"px320",className:"px320"},{visible:!1,targets:"hideit"},{targets:"dtDescription",className:"dtDescription"},{targets:"highlight",className:"highlight"}],footerCallback:function(t,e,a,r,o){this.api().columns(".countTotal, .highlightWithCountTotal",{page:"current"}).every((function(){var t=this.data().reduce((function(t,e){return(parseFloat(t)||0)+(parseFloat(e)||0)}),0);$(this.footer()).html(t.toFixed(2).replace(/\d(?=(\d{3})+\.)/g,"$&,"))}))}}),l=s.state.loaded();l=null!==l?l.columns:void 0,s.columns().every((function(t){var e=this,a=$("select, textarea, input:not(.notThisValueFilter)",this.footer());if(void 0!==l&&a.length>0){var r=l[t].search.search,o=void 0!==l[t].search.text?l[t].search.text:"";"SELECT"===a[0].nodeName?($(a).find("option[value='"+r+"']").remove(),$(a).append($(`${o} `))):$(a).val(r)}$("input, select, textarea",this.footer()).on("enter change clear apply.daterangepicker cancel.daterangepicker",(function(){var t,a=$(this).closest("th").find(".notThisValueFilter");t=a.length>0&&"!="===$(a).val()&&""!==this.value?JSON.stringify({operator:"!=",search:this.value}):this.value,e.search()!==this.value&&e.search(t).draw()}))}));var i=new Date,c=`${i.getDate()}-${i.getMonth()+1}-${i.getFullYear()} ${i.getHours()}:${i.getMinutes()}:${i.getSeconds()}`;$(".printButtonPosition").length>0&&(new $.fn.dataTable.Buttons(s,{buttons:[{extend:"print",text:' = __("Print"); ?>',titleAttr:"Print",className:"btn btn-default btn-sm",messageTop:"Printed On: "+c,title:"",footer:!0,autoPrint:!0,exportOptions:{columns:":visible:not(.no-print):not(.dt-checkboxes-cell)",format:{footer:function(t,e,a){return $(a).prop("outerHTML").indexOf("no-print")>0?t.replace(t,""):t}}},messageTop:function(){return void 0!==$("#DtExportTopMessage").html()?$("#DtExportTopMessage").html():""+document.title+" Printed On: "+c+"
"}},{extend:"copy",text:' = __("Copy"); ?>',titleAttr:"Copy",className:"btn btn-default btn-sm",footer:!0,exportOptions:{columns:":visible:not(.no-print):not(.dt-checkboxes-cell)",format:{footer:function(t,e,a){return $(a).prop("outerHTML").indexOf("no-print")>0?t.replace(t,""):t}}}},{extend:"excel",text:' = __("Export to Excel"); ?>',titleAttr:"Excel",className:"btn btn-default btn-sm",footer:!0,exportOptions:{columns:":visible:not(.no-print):not(.dt-checkboxes-cell)",format:{footer:function(t,e,a){return $(a).prop("outerHTML").indexOf("no-print")>0?t.replace(t,""):t}}},messageTop:function(){if(void 0!==$("#DtExportTopMessage").html())return $("#DtExportTopMessage").html()}},{extend:"pdf",text:' = __("Export to PDF"); ?>',titleAttr:"PDF",className:"btn btn-default btn-sm",exportOptions:{columns:":visible:not(.no-print):not(.dt-checkboxes-cell)",format:{footer:function(t,e,a){return $(a).prop("outerHTML").indexOf("no-print")>0?t.replace(t,""):t}}},messageTop:function(){if(void 0!==$("#DtExportTopMessage").html())return $("#DtExportTopMessage").html()}},{extend:"colvis",text:' = __("Hide"); ?>',className:"btn btn-default btn-sm",collectionLayout:"fixed"}]}),s.buttons().container().appendTo(".printButtonPosition")),$("#dataTableWithAjaxExtend tbody").on("click",".has-child-row",(function(){var t=$(this).closest("tr"),e=s.row(t),a=$(this).attr("data-parent-product-id"),r=$("#productReportWarehouseSelection").select2("data")[0].id,o=$(this).text(),n=this;e.child.isShown()?(e.child.hide(),t.removeClass("shown")):($(n).html(`${o} `),BMS.fn.get(`getChildProductData&pid=${a}&wid=${r}`,(function(a){0==a?BMS.fn.alertError("Sorry! no item found."):(e.child(function(t){var e=s.columns().visible(),a="";return t.forEach((t=>{a+='',t.forEach(((t,r)=>{var o=s.columns().header()[r].className;a+=e[r]?`${t} `:""})),a+=" "})),$(a).toArray()}(a)).show(),t.addClass("shown"),$("tr.childRow").fadeIn("slow")),$(n).html(`${o}`)})))}))},select2:function(t,e="",a=""){var r=$(t).attr("select2-ajax-url"),o=$(t).attr("select2-minimum-input-length"),n="true"===$(t).attr("select2-tag"),s="false"!==$(t).attr("closeOnSelect"),l="";l=void 0===$(t).attr("select2-create-new-url")?"":` `,$(document).on("keyup",".select2-search__field",(function(t){"Enter"===t.key&&$(".createNewSelect2Item").click()}));var i=$(t).select2({placeholder:$(t).children("option:first").html()?$(t).children("option:first").html():"Select Options",allowClear:!0,closeOnSelect:s,tags:n,minimumInputLength:o,language:{noResults:function(){return l}},escapeMarkup:function(t){return t},ajax:{url:r,dataType:"json",delay:400,processResults:function(t){return{results:t}},cache:!0},templateSelection:function(t){return t.id?$("").text(t.text).html():t.text},templateResult:function(t){if(!t.id)return t.text;if("object"==typeof t.text){var e=t.text,a="";return a+=`
\n
${e[0]}
\n
Cost
\n
Price
\n
Stock
\n
Brand
\n
\n `,a+=`
\n
${e[1]}
\n
${e[2]}
\n
${e[3]}
\n
${e[4]}
\n
${e[5]}
\n
\n `}return $("
").text(t.text).html()}});if(""!==a&&""===e)$.ajax({type:"get",url:r+"&q="+a}).then((function(t){if(void 0!==(t=JSON.parse(t)[0])){var e=new Option(t.text,t.id,!0,!0);i.append(e).trigger("change")}}));else if(""!==e&&i.find(":selected").val()!==e){var c=new Option(a,e,!0,!0);i.append(c).trigger("change")}},get:function(t,e){$.ajax({url:full_website_address+`/info/?module=data&page=${t}`,contentType:"application/json; charset=utf-8",dataType:"json",success:function(t,a){e(t)},error:function(){e("")}})}},BMS.fn=BMS.FUNCTIONS,BMS.MAIN={printPage:function(t,e,a=function(){}){e.preventDefault(),$(".dynamic-container > iframe").remove();var r=document.createElement("iframe");r.onload=function(){this.contentWindow.focus(),this.contentWindow.print(),a(!0)},r.style.position="fixed",r.style.right="0",r.style.bottom="0",r.style.width="0",r.style.height="0",r.style.border="0",r.src=t,$(".dynamic-container").append(r)},addTariffChargesRow:function(t){$(t).append(`
\n
\n \n Select Tariff/Charges \n \n
\n
\n \n
\n
\n \n
\n
`)}},BMS.PRODUCT={isExists:function(t,e=".productID"){return $(e).filter((function(){return this.value===t})).length>0},validationCheck:function(t,e,a){if(this.isExists(t.pid))return alert(`The product (${t.pn}) is already in the list.`);if(void 0===t.pv)return a(t);var r="",o={},n=[],s={};$.each(t.pv,(function(t,e){Array.isArray(o[e.mk])?o[e.mk].includes(e.mv)||o[e.mk].push(e.mv):o[e.mk]=[e.mv],"DV"===e.t?n.push(e.mv):Array.isArray(s[e.id])?s[e.id].push(e.mv):s[e.id]=[e.mv]})),$.each(o,(function(t,e){r+=`
\n
${t}: \n
\n \n Select ${t}... `,$.each(e,(function(t,e){r+="${e} `})),r+=" \n
\n
"})),Swal.fire({title:"
Select Variation ",html:"for "+t.pn+"
"+r,showCloseButton:!0,showCancelButton:!0,focusConfirm:!1,confirmButtonText:"Ok"}).then((t=>{if(t.isConfirmed){var a=$("#variationSelection select"),r=[];$.each(a,(function(){""!==this.value&&r.push(this.value)}));var o="";$.each(s,(function(t,e){if(r.every((t=>e.includes(t))))return o=t,!1})),""===o||0===r.length?Swal.fire("Sorry! no product found"):e.addProduct(o)}}))},parseProductList:function({category:t="",brand:e="",edition:a="",generic:r="",author:o=""},n){$.ajax({url:full_website_address+`/info/?module=data&page=productList&catId=${t}&brand=${e}&edition=${a}&generic=${r}&author=${o}`,contentType:"application/json; charset=utf-8",dataType:"json",success:function(t,e){n(t)}})},showProduct:function({container:t="#productListContainer",category:e="",brand:a="",edition:r="",generic:o="",author:n=""}=""){this.parseProductList({category:e,brand:a,edition:r,generic:o,author:n},(e=>{if(null!=e){var a="";e.forEach((t=>{var e=full_website_address;t.v&&t.v>0?e+="/images/?for=products&id="+t.id+"&q=YTozOntzOjI6Iml3IjtpOjIwMDtzOjI6ImloIjtpOjIyMDtzOjI6ImlxIjtpOjcwO30=&v="+t.v:e+="/assets/images/noimage.png",a+="
"+t.name+" "})),$(t).html(a)}else $(t).html("
Sorry! No products found in this criteria.
")}))},getDetails:function(t,e){$.ajax({url:full_website_address+`/info/?module=data&page=productDetails&product_id=${t}`,contentType:"application/json; charset=utf-8",dataType:"json",success:function(t,a){e(t)}})},addProduct:function(t="",e=!1){var a=""===t?$("#selectProduct").val():t;""!==a?this.getDetails(a,(t=>{t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{if("1"!==t.hed){var e=t.iq?parseFloat(t.iq).toFixed(0):1,a=`
\n \n ${t.pn} \n \n ${t.pu} \n \n \n \n \n `;$("#productTable > tbody").append(a)}else BMS.fn.alertError("Sorry! The product which have expiry date or batch number, can not be added in sub/bundle product.")})),$("#selectProduct").empty()})),!1===e&&$("#productTable > tbody tr:last").find(".productQnt").select()})):alert("Please select a product")},getListByGeneric:function(t){BMS.fn.select2("#productGenericFilter",t,t)},productUnitCheck:function(t){this.getDetails({product_id:$(t).closest("tr").find(".productID").val(),unit:$(t).val()},(e=>{$(t).closest("tr").find(".productSalePrice").val(e[0].sp)}))}},BMS.POS={clearScreen:function(){$(".dynamic-container").slideUp(350,(function(){var t=new Date;$("#salesDate").val(t.toISOString().split("T")[0]),$("#tariffCharges .row").not("div:first").remove(),$(".tariffChargesName").val("").change();$(".paymentMethodBox").html('
\n
\n Amount \n \n
\n
\n Reference/Info \n \n
\n
\n Bank Account \n \n .... \n \n
\n
\n Payment Method \n \n \n \n \n \n \n \n
\n
'),$("#orderDiscountValue, #shippingCharge, .posSalePaymentAmount, #adjustAmount, #salesNote").val(""),$("#shippingCharge").removeClass("shippingChargeEdited"),$(".posSalePaymentAmount").removeClass("disablePaymentAmountAutoChange"),$("#productTable > tbody").html(""),$("#editSalesId").remove(),$("#payment .modal-footer").html('\n
= __("Close"); ?> \n
\n
= __("Hold"); ?>\n
= __("Confirm"); ?>\n '),$("input:radio, input:checkbox").prop("checked",!1),BMS.fn.select2("#customers",1,"Walk-in Customer"),BMS.POS.grandTotal(),BMS.POS.disableEnableWCSelect()})).slideDown(500)},getProductDetails:function({product_id:t,warehouse_id:e,customer_id:a="",qnt:r="",batch:o="",packet:n=""},s){$.ajax({url:full_website_address+`/info/?module=data&page=productDetailsForPos&product_id=${t}&warehouse_id=${e}&cid=${a}&pqnt=${r}&batch=${o}&packet=${n}`,contentType:"application/json; charset=utf-8",dataType:"json",success:function(t,e){s(t)}})},disableEnableWCSelect:function(){$(".productQnt").length>0?$("#customers, #warehouse").prop("disabled",!0):$("#customers, #warehouse").prop("disabled",!1)},grandTotal:function(t=""){var e=0,a=0;$(".productQnt").each((function(){e+=Number($(this).val()),a+=1})),$(".totalItemAndQnt").html(a+" ("+e+")");var r=0;$(".subtotalCol").each((function(){r+=Number($(this).html())})),$(".totalAmount").html(r.toFixed(2));var o=$("#orderDiscountValue").val(),n=BMS.FUNCTIONS.calculateDiscount(r,o);$(".totalOrderDiscountAmount").html("(-) "+(r-n).toFixed(2));var s=0;if($("#tariffCharges > .row").each((function(){var t=$(this).closest(".row").find(".tariffChargesName").val().split(": ")[1],e=BMS.FUNCTIONS.calculateTarifCharges(n,t);$(this).closest(".row").find(".tariffChargesAmount").val(e),s+=Number(e)})),$(".totalTariffChargesAmount").html("(+) "+s.toFixed(2)),!0===$("#payment").hasClass("in")){if(!1===$("#shippingCharge").is(":focus")&&($("#totalPackets").is(":focus")||$("#packetShippingRate").is(":focus"))){var l=$("#totalPackets").val()*$("#packetShippingRate").val();$("#shippingCharge").val(l)}}else{var i=0;$(".productPacket").each((function(){i+=Number($(this).val())})),$(".displayTotalPackets").html(i.toFixed(2)),$("#totalPackets").val(Math.round(i));l=$("#totalPackets").val()*$("#packetShippingRate").val();$("#shippingCharge").val(l)}var c=(Number(s)+Number(n)).toFixed(2);$(".netTotalAmount").html(c),$("#finalizeSale > tbody > tr:nth-child(1) > td:nth-child(3)").html(c);var d=Number($("#shippingCharge").val()),u=Number(c)+d;"1"===config.posSaleAutoAdjustAmount&&$("#adjustAmount:not(.disableAdjustAmountAutoChange)").val(parseFloat(parseFloat(u).toFixed()-u).toFixed(2));var p=Number($("#adjustAmount").val());u=parseFloat(Number(c)+d+Number(p)).toFixed(2);if("1"===config.posSaleAutoMarkAsPaid){var m=sumInputs(".disablePaymentAmountAutoChange"),h=0;(u>0&&u>m||u<0&&u
f?u-f:0;$("#finalizeSale > tbody > tr:nth-child(4) > td:nth-child(2)").html(u),$("#finalizeSale > tbody > tr:nth-child(6) > td:nth-child(2)").html(v),$("#finalizeSale > tbody > tr:nth-child(7) > td:nth-child(2)").html(g),$("#quickPayableAmount").html(u),!0===$("#payment").hasClass("in")&&(u>0&&uf)&&(Swal.fire({title:"Paid amount can not be more then Grand total.",icon:"error"}),$(".posSalePaymentAmount").last().val(0))},editProductItemDetails:function(t,e){$("#productSaleDetails .modal-title").html(e),$("#productSaleDetails .rowId").val(t);var a=$(`#${t}`);$("#productSaleDetails #productSaleItemPrice").val(a.find(".netSalesPrice").val()),$("#productSaleDetails #productSaleItemDiscount").val(a.find(".productDiscount").val()),$("#productSaleDetails #productSaleItemPacket").val(a.find(".productPacket").val()),$("#productSaleDetails #productSaleItemDetails").val(a.find(".productItemDetails").val())},addProduct:function(t="",e=!1){var a=""===t?$("#selectProduct").val():t;""!==a?($("#selectProduct").val()>0&&$("#selectProduct").html("Search Product.... "),this.getProductDetails({product_id:a,warehouse_id:$("#warehouseId").val(),customer_id:$("#customersId").val()},(t=>{void 0===t.error||!0!==t.error?(t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{var e=0,r=t.iq?parseFloat(t.iq).toFixed(0):1;t.pq>0&&(e=(r/Number(t.pq)).toFixed(2));var o=t.pd?t.pd:"0",n=BMS.FUNCTIONS.calculateDiscount(t.sp,o),s="";s=Number(n)===Number(t.sp)?parseFloat(t.sp).toFixed(2):""+parseFloat(n).toFixed(2)+" "+parseFloat(t.sp).toFixed(2)+" ";var l=Date.now()+t.pid,i=null===t.gn?"":`${t.gn} `,c=` \n \n \n ${t.pn} \n ${i}\n \n ${s} \n \n ${t.pu} \n ${parseFloat(Number(n)*Number(r)).toFixed(2)} \n \n \n \n \n \n \n \n \n \n \n \n \n `;$("#productTable > tbody").append(c)}))})),!1===e&&$("#productTable > tbody tr:last").find(".productQnt").select(),this.grandTotal(),this.disableEnableWCSelect()):Swal.fire({title:"Error!",text:t.msg,icon:"error"})}))):alert("Please select a product")},addReturnProduct:function(t,e,a,r,o,n,s,l,i,c){if(!BMS.PRODUCT.isExists(t)||confirm(`The product (${e}) is already in the list. Do you want to add it again?`)){var d=Date.now()+t,u=` \n \n \n ${e} \n ${null===a?"":`${a} `}\n \n ${l} \n \n ${o} \n -${c} \n \n \n \n \n \n \n \n \n \n \n \n `;$("#productTable > tbody").append(u),this.grandTotal()}},productQntCheck:function(t,e){var a=$(t).closest("tr").find(".netSalesPrice").val(),r=$(t).val(),o=$(t).closest("tr").find(".productDiscount").val(),n=$(t).closest("tr").find("td.subtotalCol"),s=$(t).closest("tr").find(".productPacket"),l=t;0==r&&(Swal.fire({title:"Error!",text:"Product qunatity can not be zero (0)",icon:"error"}),$(t).val(1),r=1),this.getProductDetails({product_id:$(t).closest("tr").find(".productID").val(),warehouse_id:$("#warehouseId").val(),qnt:r,unit:$(t).closest("tr").find(".productItemUnit").val()},(e=>{void 0!==e.error&&!0===e.error&&($(l).val(e.stq),r=e.stq,Swal.fire({title:"Error!",text:e.msg,icon:"error"})),(e=e[0]?e[0]:e).so?$(t).closest("tr").css("background-color","pink"):$(t).closest("tr").css("background-color","white"),$(n).html((BMS.FUNCTIONS.calculateDiscount(a,o)*r).toFixed(2));var i=0;Number(e.pq)>0&&(i=(r/Number(e.pq)).toFixed(2)),s.val(i),this.grandTotal()}))},productPacketCheck:function(){var t=$(selector).closest("tr").find(".netSalesPrice").val(),e=$(selector).val(),a=$(selector).closest("tr").find(".productDiscount").val(),r=$(selector).closest("tr").find("td.subtotalCol"),o=$(selector).closest("tr").find(".productQnt"),n=$(selector).closest("tr").find(".productPacket");this.getProductDetails({product_id:$(selector).closest("tr").find(".productID").val(),warehouse_id:$("#warehouseId").val(),packet:e},(s=>{if(void 0!==s.error&&!0===s.error){$(o).val(s.having_item_quantity),$(r).html((BMS.FUNCTIONS.calculateDiscount(t,a)*s.having_item_quantity).toFixed(2));var l=0;Number(s.product_packet_quantity)>0&&(l=(s.having_item_quantity/Number(s.product_packet_quantity)).toFixed(2)),n.val(l),Swal.fire({title:"Error!",text:s.msg,icon:"error"})}else{var i=Math.round(Number(s.product_packet_quantity)*e);i>0&&($(o).val(i),$(r).html((BMS.FUNCTIONS.calculateDiscount(t,a)*i).toFixed(2)))}this.grandTotal()}))},productDiscountCheck:function(t){var e=$("#productSaleItemPrice").val(),a=$("#productSaleItemDiscount").val();"Enter"===t.key&&a.indexOf("%")>1&&a.replace("%","")>=100?(Swal.fire({title:"Error!",text:"Discount Must be below of 100%",icon:"error"}),$("#productSaleItemDiscount").val(""),$("#productSaleItemDiscount").select(),t.preventDefault()):"Enter"===t.key&&Number(a)>=Number(e)&&a.indexOf("%")<1&&($("#productSaleItemDiscount").val(""),$("#productSaleItemDiscount").select(),"Enter"===t.key&&t.preventDefault(),Swal.fire({title:"Error!",text:"Discount Must be below of product sale price",icon:"error"}),t.preventDefault())},orderDiscountCheck:function(t,e){var a=$(".totalAmount").text(),r=$(t).val();r.indexOf("%")>1&&r.replace("%","")>=100?(Swal.fire({title:"Error!",text:"Discount Must be below of 100%",icon:"error"}),$(t).val(0),e.preventDefault()):Number(a)<0&&Number(r)>0?(Swal.fire({title:"Error!",text:"Discount must be a negative amount in case of negative total amount.",icon:"error"}),$(t).val(-Number(r)),e.preventDefault()):Number(a)<0&&(Number(r)>0||Math.abs(Number(r))>=Math.abs(Number(a)))||Number(a)>0&&Number(r)>=Number(a)&&r.indexOf("%")<1?(Swal.fire({title:"Error!",text:"Discount Must be below of total amount.",icon:"error"}),$(t).val(0),e.preventDefault()):!0!==this.isGivenDiscountPermitted(t)&&(Swal.fire({title:"Error!",text:`You do not have permission to give ${r} discount.`,icon:"error"}),$(t).val(0),e.preventDefault()),this.grandTotal()},isGivenDiscountPermitted:function(t){var e=$(".totalAmount").text(),a=$(t).val();if(""!=get_options("maxDiscount")){var r=e-BMS.FUNCTIONS.calculateDiscount(e,get_options("maxDiscount")),o=e-BMS.FUNCTIONS.calculateDiscount(e,a);return Math.abs(r)>=Math.abs(o)}return!0}},BMS.PURCHASE={getProductDetails:BMS.PRODUCT.getDetails,grandTotal:function(){var t=0;$(".productQnt").each((function(){t+=Number($(this).val())})),$("#totalItems").html($(".productQnt").length+"("+t+")");var e=0;$(".subTotal").each((function(){e+=Number($(this).html())})),$(".totalPurchasePrice").html(e.toFixed(2));var a=BMS.FUNCTIONS.calculateDiscount(e,$("#purchaseDiscountValue").val());$(".totalPurchaseDiscount").html("(-) "+(e-a).toFixed(2));var r=0;$("#tariffCharges > .row").each((function(){var t=$(this).closest(".row").find(".tariffChargesName").val().split(": ")[1],e=BMS.FUNCTIONS.calculateTarifCharges(a,t);$(this).closest(".row").find(".tariffChargesAmount").val(e),r+=Number(e)})),$(".totalTariffCharges").html("(+) "+r.toFixed(2));var o=(Number(r)+Number(a)).toFixed(2);$(".netTotal").html(o),$("#purchaseNetTotal").val(o);var n=Number(o)+Number($("#purchaseShipping").val());$("#purchaseGrandTotal").val(n);var s=Number($("#purchasePaidAmount").val()),l=n<=s?0:n-s,i=n>=s?0:s-n;$("#purchaseChangeAmount").val(i),$("#purchaseDueAmount").val(l)},calculateEachProduct:function(t){var e=$(t).closest("tr").find(".productPurchasePrice").val(),a=$(t).closest("tr").find(".productQnt").val(),r=$(t).closest("tr").find(".productPurchaseDiscount").val(),o=$(t).closest("tr").find(".subTotal");return isNaN(a)?(alert("Product quantity must be a valid number."),void $(t).closest("tr").find(".productQnt").val(1)):a<1&&"Ordered"!==$("#purchaseStatus").val()?(alert("Product quantity must be minimum of 1."),void $(t).closest("tr").find(".productQnt").val(1)):(""!==e&&null!==e&&"null"!==e||(e=0,$(t).closest("tr").find(".productPurchasePrice").val(0)),r.indexOf("%")>1&&r.replace("%","")>=100?($(t).closest("tr").find(".productPurchaseDiscount").val(0),void alert("Discount Must be below of 100%")):Number(r)>Number(e)&&r.indexOf("%")<1?($(t).closest("tr").find(".productPurchaseDiscount").val(0),void alert("Discount Must be below of product purchase price")):void $(o).html((BMS.FUNCTIONS.calculateDiscount(e,r)*a).toFixed(2)))},addProduct:function(t="",e=!1){var a=""===t?$("#selectProduct").val():t;""!==a?this.getProductDetails(a,(t=>{t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{var e=" ";void 0!==t.hed&&"1"===t.hed&&"Ordered"!==$("#purchaseStatus").val()&&(e=`\n = __("Select Batch"); ?>.... \n `);var a=t.iq?parseFloat(t.iq).toFixed(0):1,r=`\n \n ${t.pn} \n ${e} \n ${t.alertq} ${t.soldq} ${t.stockq} \n \n ${t.pu} \n \n \n \n ${t.pp} \n \n \n \n `;$("#productTable > tbody").append(r)}))})),!1===e&&$("#productTable > tbody tr:last").find(".productQnt").select(),this.grandTotal(),$("#selectProduct").empty()})):alert("Please select a product")},productUnitCheck:function(t){var e=$(t).closest("tr").find(".productID").val(),a=this;$.ajax({url:full_website_address+"/info/?module=data&page=productUnitDetails&product_id="+e+"&unit="+$(t).val(),contentType:"application/json; charset=utf-8",dataType:"json",success:function(e,r){"success"==r&&($(t).closest("tr").find(".productPurchasePrice").val(e.pp),$(t).closest("tr").find(".productMainPurchasePrice").val(e.pp),a.calculateEachProduct(t),a.grandTotal())}})}},BMS.ORDER=Object.assign({},BMS.POS),BMS.ORDER.addProduct=function(t=""){var e=""===t?$("#selectProduct").val():t;""!==e?($("#selectProduct").val()>0&&$("#selectProduct").html("Search Product.... "),BMS.PRODUCT.getDetails(e,(t=>{t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{var a=0,r=t.iq?parseFloat(t.iq).toFixed(0):1;t.pq>0&&(a=(r/Number(t.pq)).toFixed(2));var o=t.pd?t.pd:"0",n=BMS.FUNCTIONS.calculateDiscount(t.sp,o),s="";s=Number(n)===Number(t.sp)?parseFloat(t.sp).toFixed(2):""+n+" "+parseFloat(t.sp).toFixed(2)+" ";var l=Date.now()+t.pid,i=` \n \n \n ${t.pn} \n \n ${s} \n \n ${t.pu} \n ${parseFloat(Number(n)*Number(r)).toFixed(2)} \n \n \n \n \n \n \n \n \n \n \n \n \n `;$("#productTable > tbody").append(i)}))})),$("#productTable > tbody tr:last").find(".productQnt").select(),this.grandTotal(),this.disableEnableWCSelect()}))):alert("Please select a product")},BMS.ORDER.productQntCheck=function(t,e){var a=$(t).closest("tr").find(".netSalesPrice").val(),r=$(t).val(),o=$(t).closest("tr").find(".productDiscount").val(),n=$(t).closest("tr").find("td.subtotalCol");0==r&&(Swal.fire({title:"Error!",text:"Product qunatity can not be zero (0)",icon:"error"}),$(t).val(1),r=1),$(n).html((BMS.FUNCTIONS.calculateDiscount(a,o)*r).toFixed(2)),this.grandTotal()},BMS.STOCK_TRANSFER={getProductDetails:BMS.POS.getProductDetails,grandTotal:function(){var t=0;$(".productQnt").each((function(){t+=Number($(this).val())})),$("#totalItems").html($(".productQnt").length+"("+t+")");var e=0;$(".subTotal").each((function(){e+=Number($(this).html())})),$(".totalPurchasePrice").html(e.toFixed(2))},disableEnableWarehouseSelect:function(){$(".productQnt").length>0?$("#stockTransferFromWarehouse, #stockTransferToWarehouse").prop("disabled",!0):$("#stockTransferFromWarehouse, #stockTransferToWarehouse").prop("disabled",!1)},calculateEachProduct:function(t){var e=$(t).closest("tr").find(".productPurchasePrice").val(),a=$(t).closest("tr").find(".productQnt").val(),r=$(t).closest("tr").find(".productPurchaseDiscount").val(),o=$(t).closest("tr").find(".subTotal");return a<1?(alert("Product quantity must be minimum of 1."),void $(t).closest("tr").find(".productQnt").val(1)):(""!==e&&null!==e&&"null"!==e||(e=0,$(t).closest("tr").find(".productPurchasePrice").val(0)),r.indexOf("%")>1&&r.replace("%","")>=100?($(t).closest("tr").find(".productPurchaseDiscount").val(0),void alert("Discount Must be below of 100%")):Number(r)>Number(e)&&r.indexOf("%")<1?($(t).closest("tr").find(".productPurchaseDiscount").val(0),void alert("Discount Must be below of product purchase price")):void $(o).html((BMS.FUNCTIONS.calculateDiscount(e,r)*a).toFixed(2)))},addProduct:function(t="",e=!1){var a=""===t?$("#selectProduct").val():t,r=$("#stockTransferFromWarehouseId").val();""!==r?""!==a?this.getProductDetails({product_id:a,warehouse_id:r,qnt:1},(t=>{void 0===t.error||!0!==t.error?(t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{var e=" ";void 0!==t.hed&&"1"===t.hed&&(e=`\n = __("Select Batch"); ?>.... \n `);var a=t.iq?parseFloat(t.iq).toFixed(0):1,r=`\n \n ${t.pn} \n ${e} \n \n ${t.pu} \n \n \n \n ${parseFloat(t.pp*a).toFixed(2)} \n \n \n \n `;$("#productTable > tbody").append(r)}))})),this.grandTotal(),this.disableEnableWarehouseSelect(),$("#selectProduct").empty()):Swal.fire({title:"Error!",text:t.msg,icon:"error"})})):alert("Please select a product"):alert("Please select an warehouse to add product")},productUnitCheck:function(t){var e=t;this.getProductDetails({product_id:$(t).closest("tr").find(".productID").val(),warehouse_id:$("#stockTransferFromWarehouseId").val(),qnt:$(t).closest("tr").find(".productQnt").val(),unit:$(t).val()},(t=>{void 0!==t.error&&!0===t.error&&(console.log(t.stq),$(e).closest("tr").find(".productQnt").val(t.stq),Swal.fire({title:"Error!",text:t.msg,icon:"error"})),$(e).closest("tr").find(".productPurchasePrice").val(parseFloat(t.pp).toFixed(2)),this.calculateEachProduct(e),this.grandTotal()}))},productQntCheck:function(t){var e=$(t).val(),a=$(t);isNaN(e)&&(alert("Product quantity must be a valid number."),$(t).val(1),e=1),e<1&&(Swal.fire({title:"Error!",text:"Product qunatity must be at least one",icon:"error"}),$(t).val(1),e=1),this.getProductDetails({product_id:$(t).closest("tr").find(".productID").val(),warehouse_id:$("#stockTransferFromWarehouseId").val(),qnt:e,unit:$(t).closest("tr").find(".productItemUnit").val()},(t=>{void 0!==t.error&&!0===t.error&&($(a).val(t.stq),Swal.fire({title:"Error!",text:t.msg,icon:"error"})),this.calculateEachProduct(a),this.grandTotal()}))}},BMS.STOCK_ENTRY={getProductDetails:BMS.PRODUCT.getDetails,grandTotal:function(){var t=0;$(".productQnt").each((function(){t+=Number($(this).val())})),$("#totalItems").html($(".productQnt").length+"("+t+")");var e=0;$(".subTotal").each((function(){e+=Number($(this).html())})),$(".totalPurchasePrice").html(e.toFixed(2))},calculateEachProduct:function(t){var e=$(t).closest("tr").find(".productPurchasePrice").val(),a=$(t).closest("tr").find(".productQnt").val(),r=$(t).closest("tr").find(".productPurchaseDiscount").val(),o=$(t).closest("tr").find(".subTotal");return a<1&&"Production"===$("#stockEntryType").val()?(alert("Negative quantity is not valid for Production of stock."),void $(t).closest("tr").find(".productQnt").val(1)):(""!==e&&null!==e&&"null"!==e||(e=0,$(t).closest("tr").find(".productPurchasePrice").val(0)),r.indexOf("%")>1&&r.replace("%","")>=100?($(t).closest("tr").find(".productPurchaseDiscount").val(0),void alert("Discount Must be below of 100%")):Number(r)>Number(e)&&r.indexOf("%")<1?($(t).closest("tr").find(".productPurchaseDiscount").val(0),void alert("Discount Must be below of product purchase price")):void $(o).html((BMS.FUNCTIONS.calculateDiscount(e,r)*a).toFixed(2)))},addProduct:function(t=""){var e=""===t?$("#selectProduct").val():t;""!==$("#stockTransferFromWarehouseId").val()?""!==e?this.getProductDetails(e,(t=>{void 0===t.error||!0!==t.error?(t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{var e=" ";void 0!==t.hed&&"1"===t.hed&&(e=`\n = __("Select Batch"); ?>.... \n `);var a=t.iq?parseFloat(t.iq).toFixed(0):1,r=`\n \n ${t.pn} \n ${e} \n \n ${t.pu} \n \n \n \n ${parseFloat(t.pp*a).toFixed(2)} \n \n \n \n `;$("#productTable > tbody").append(r)}))})),this.grandTotal(),$("#selectProduct").empty()):Swal.fire({title:"Error!",text:t.msg,icon:"error"})})):alert("Please select a product"):alert("Please select an warehouse to add product")}},BMS.RETURN={getProductReturnDetails:function({product_id:t,customer_id:e},a){$.ajax({url:full_website_address+"/info/?module=data&page=productDetailsForReturn&product_id="+t+"&customer_id="+e,contentType:"application/json; charset=utf-8",dataType:"json",success:function(t,e){a(t)}})},grandTotal:function(){var t=0;$(".productQnt").each((function(){t+=Number($(this).val())})),$("#totalItems").html($(".productQnt").length+"("+t+")");var e=0;$(".subTotal").each((function(){e+=Number($(this).html())})),$(".totalReturnPrice").html(e.toFixed(2));var a=BMS.FUNCTIONS.calculateDiscount(e,$("#returnDiscountValue").val());$(".totalReturnDiscount").html("(-) "+(e-a).toFixed(2));var r=0;$("#tariffCharges > .row").each((function(){var t=$(this).closest(".row").find(".tariffChargesName").val().split(": ")[1],e=BMS.FUNCTIONS.calculateTarifCharges(a,t);$(this).closest(".row").find(".tariffChargesAmount").val(e),r+=Number(e)})),$(".totalTariffCharges").html("(+) "+r.toFixed(2));var o=(Number(r)+Number(a)).toFixed(2);$(".netTotal").html(o),$("#returnNetTotal").val(o);var n=$("#returnShipping").val(),s=Number(o)+Number(n)-Number($("#returnSurcharge").val());$("#returnGrandTotal").val(s);var l=Number($("#returnPaidAmount").val()),i=s<=l?0:s-l,c=s>=l?0:l-s;$("#returnChangeAmount").val(c),$("#returnDueAmount").val(i)},calculateEachProduct:function(t){var e=$(t).closest("tr").find(".productReturnPrice").val(),a=$(t).closest("tr").find(".productQnt").val(),r=$(t).closest("tr").find(".productReturnDiscount").val(),o=$(t).closest("tr").find(".subTotal");if(a<1)return alert("Product quantity must be minimum of 1."),void $(t).closest("tr").find(".productQnt").val(1);""!==e&&null!==e&&"null"!==e||(e=0,$(t).closest("tr").find(".productReturnPrice").val(0)),r.indexOf("%")>1&&r.replace("%","")>=100?alert("Discount Must be below of 100%"):Number(r)>Number(e)&&r.indexOf("%")<1?alert("Discount Must be below of product return price"):$(o).html((BMS.FUNCTIONS.calculateDiscount(e,r)*a).toFixed(2))},addProduct:function(t=""){var e=""===t?$("#selectProduct").val():t,a=$("#returnCustomer").val();""!==a?""!==e?this.getProductReturnDetails({product_id:e,customer_id:a},(t=>{t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{var e=t.pd?t.pd:"0",a=parseFloat(BMS.FUNCTIONS.calculateDiscount(t.sp,e)).toFixed(2),r=" ";void 0!==t.hed&&"1"===t.hed&&(r=`\n = __("Select Batch"); ?>.... \n `);var o=`\n \n ${t.pn} (Purchased: ${t.prq} Returned: ${t.rtq} ) \n ${r} \n \n ${t.pu} \n \n \n \n ${a} \n \n \n \n `;$("#productTable > tbody").append(o)}))})),this.grandTotal(),$("#selectProduct").empty()})):alert("Please select a product"):alert("Please select the customer")},productUnitCheck:function(t){var e=t;this.getProductReturnDetails({product_id:$(t).closest("tr").find(".productID").val(),customer_id:$("#returnCustomer").val(),unit:$(t).val()},(t=>{var a=t[0];$(e).closest("tr").find(".productReturnPrice").val(parseFloat(a.sp).toFixed(2));var r=a.pn+" (Purchased: "+parseFloat(a.prq).toFixed(2)+", Returned: "+parseFloat(a.rtq).toFixed(2)+")";$(e).closest("tr").find(".productDetails").html(r),this.calculateEachProduct(e),this.grandTotal()}))}},BMS.WASTAGE_SALE={grandTotal:function(){var t=0;$(".wastageSaleItemQnt").each((function(){t+=Number($(this).val())})),$("#totalItems").html($(".wastageSaleItemQnt").length+"("+t+")");var e=0;$(".wastageSaleItemSubtotal").each((function(){e+=Number($(this).text())})),$(".totalWastageSalePrice").html(e.toFixed(2));var a=BMS.FUNCTIONS.calculateDiscount(e,$("#wastageSaleDiscountValue").val());$(".totalWastageSaleDiscount").html("(-) "+(e-a).toFixed(2));var r=0;$("#tariffCharges > .row").each((function(){var t=$(this).closest(".row").find(".tariffChargesName").val().split(": ")[1],e=BMS.FUNCTIONS.calculateTarifCharges(a,t);$(this).closest(".row").find(".tariffChargesAmount").val(e),r+=Number(e)})),$(".totalTariffCharges").html("(+) "+r.toFixed(2));var o=(Number(r)+Number(a)).toFixed(2);$(".netTotal").html(o),$("#wastageSaleNetTotal").val(o);var n=$("#wastageSalePaidAmount").val(),s=n tbody").append(' 0.00 '),$(".wastageSaleItem").focus(),this.grandTotal()}},BMS.SPECIMEN_COPY={getProductDetails:BMS.POS.getProductDetails,disableEnableWarehouseSelect:function(){$(".productQnt").length>0?$("#scTransferWarehouse").prop("disabled",!0):$("#scTransferWarehouse").prop("disabled",!1)},addProduct:function(t=""){var e=""===t?$("#selectProduct").val():t,a=$("#scTransferWarehouse").val();""!==a?""!==e?this.getProductDetails({product_id:e,warehouse_id:a},(t=>{void 0===t.error||!0!==t.error?(t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{var e=t.iq?parseFloat(t.iq).toFixed(0):1,a=` \n ${t.pn} \n \n ${t.pu} \n \n \n \n `;$("#productTable > tbody").append(a)}))})),this.disableEnableWarehouseSelect(),$("#selectProduct").empty()):Swal.fire({title:"Error!",text:t.msg,icon:"error"})})):alert("Please select a product"):alert("Please select an warehouse to add product")},productUnitCheck:function(t){this.getProductDetails({product_id:$(t).closest("tr").find(".productID").val(),warehouse_id:$("#scTransferWarehouse").val(),qnt:$(t).closest("tr").find(".productQnt").val(),unit:$(t).val()},(e=>{void 0!==e.error&&!0===e.error&&($(t).closest("tr").find(".productQnt").val(e.stq),Swal.fire({title:"Error!",text:e.msg,icon:"error"}))}))},productQntCheck:function(t){var e=$(t).val();isNaN(e)&&(alert("Product quantity must be a valid number."),$(t).val(1),e=1),e<1&&(Swal.fire({title:"Error!",text:"Product qunatity must be at least one",icon:"error"}),$(t).val(1),e=1),this.getProductDetails({product_id:$(t).closest("tr").find(".productID").val(),warehouse_id:$("#scTransferWarehouse").val(),qnt:e,unit:$(t).closest("tr").find(".productItemUnit").val()},(e=>{void 0!==e.error&&!0===e.error&&($(t).val(e.stq),Swal.fire({title:"Error!",text:e.msg,icon:"error"}))}))}},BMS.SC_DISTRIBUTION={getProductDetails:BMS.PRODUCT.getDetails,addProduct:function(t=""){var e=""===t?$("#selectProduct").val():t;""!==e?this.getProductDetails(e,(t=>{void 0===t.error||!0!==t.error?(t.forEach((t=>{BMS.PRODUCT.validationCheck(t,this,(t=>{var e=t.iq?parseFloat(t.iq).toFixed(0):1,a=`\n \n ${t.pn} \n \n ${t.pu} \n \n \n \n `;$("#productTable > tbody").append(a)}))})),$("#selectProduct").empty()):Swal.fire({title:"Error!",text:t.msg,icon:"error"})})):alert("Please select a product")}},BMS.CHAT={showChatBox:function(t,e){""!==t&&t.preventDefault(),$.ajax({url:full_website_address+"/info/?module=chat&page=getChatUserData",type:"post",data:{userId:e},success:function(t,a){t=JSON.parse(t);console.log(t);var r="";""!==t.latest_msg&&t.latest_msg.forEach((t=>{t.from_user!=e?r+=`\n
\n ${t.from_username} \n ${t.datetime} \n
\n
\n
\n ${t.msg_text}\n
\n
`:r+=`\n
\n ${t.from_username} \n ${t.datetime} \n
\n
\n
\n ${t.msg_text}\n
\n
`}));var o=``;$(".chatBox").prepend(o).ready((function(){var t=$(`.chatBoxForUser${e}`).find(".direct-chat-messages"),a=$(t).get(0).scrollHeight;$(t).animate({scrollTop:a},0),$(t).closest(".chatBox").find(".message-composer").focus()}))}})},send:function(t,e){wss.send(JSON.stringify({type:"message",toUser:e,msg:t}))}};
\ No newline at end of file
diff --git a/assets/js/events.js b/assets/js/events.js
index fb022dd..c9f85ed 100644
--- a/assets/js/events.js
+++ b/assets/js/events.js
@@ -1844,7 +1844,7 @@ $(document).on('dblclick', 'iledit', function (event) {
// Display changed items
if (type === 'select2' || type === 'select') {
- $thistd.html(`` + $("option:selected", that).text() + ` `);
+ $thistd.html(`` + $("option:selected", that).html() + ` `);
} else {
@@ -1863,7 +1863,9 @@ $(document).on('dblclick', 'iledit', function (event) {
// Display data items if not changed
if (type === 'select2' || type === 'select') {
- $thistd.html(`` + $("option:selected", that).text() + ` `);
+ console.log( $("option:selected", that).html() );
+
+ $thistd.html(`` + $("option:selected", that).html() + ` `);
} else {
diff --git a/assets/js/events.min.js b/assets/js/events.min.js
index 84c4d07..c3ef0c6 100644
--- a/assets/js/events.min.js
+++ b/assets/js/events.min.js
@@ -1 +1 @@
-$(document).on("change","#productCategoryFilter, #productBrandFilter, #productEditionFilter, #productGenericFilter, #productAuthorFilter",(function(){BMS.PRODUCT.showProduct({category:$("#productCategoryFilter").val(),brand:$("#productBrandFilter").val(),edition:$("#productEditionFilter").val(),generic:$("#productGenericFilter").val(),author:$("#productAuthorFilter").val()})})),$(document).on("change","#customers",(function(){var e=$("#customers").val();$("#customersId").val(e),BMS.fn.get(`getCustomerData&cid=${e}`,(function(e){$("#orderDiscountValue").val(e.discount),$("#packetShippingRate").val(e.shipping_rate)}))})),$(document).on("change","#warehouse",(function(){var e=$("#warehouse").val();$("#warehouseId").val(e),$("#selectPosProduct").attr("select2-ajax-url",`${full_website_address}/info/?module=select2&page=productListForPos&wid=${e}`),BMS.fn.select2("#selectPosProduct")})),$(document).on("change","#stockTransferFromWarehouse, #stockTransferToWarehouse",(function(){var e=$("#stockTransferFromWarehouse").val(),t=$("#stockTransferToWarehouse").val();$("#stockTransferFromWarehouseId").val(e),$("#stockTransferToWarehouseId").val(t)})),$(document).on("change","#scTransferWarehouse",(function(){var e=$("#scTransferWarehouse").val();$("#scTransferWarehouseId").val(e)})),$(document).on("click","#addTariffChargesRow",(function(){BMS.MAIN.addTariffChargesRow("#tariffCharges")})),$(document).on("click",".productButton",(function(){isPosPage?BMS.POS.addProduct(this.value):isPurchasePage?BMS.PURCHASE.addProduct(this.value):isTransferStockPage?BMS.STOCK_TRANSFER.addProduct(this.value):isProductReturnPage?BMS.RETURN.addProduct(this.value):isSpecimenCopyPage?BMS.SPECIMEN_COPY.addProduct(this.value):isScDistributionPage?BMS.SC_DISTRIBUTION.addProduct(this.value):isAddProductPage?BMS.PRODUCT.addProduct(this.value):isStockEntryPage?BMS.STOCK_ENTRY.addProduct(this.value):isSaleOrderPage&&BMS.ORDER.addProduct(this.value)})),$(document).on("change","#selectProduct, #selectPosProduct, #selectStockTransferProduct, #selectStockEntryProduct",(function(){isPosPage?BMS.POS.addProduct(this.value):isPurchasePage?BMS.PURCHASE.addProduct(this.value):isTransferStockPage?BMS.STOCK_TRANSFER.addProduct(this.value):isProductReturnPage?BMS.RETURN.addProduct(this.value):isSpecimenCopyPage?BMS.SPECIMEN_COPY.addProduct(this.value):isScDistributionPage?BMS.SC_DISTRIBUTION.addProduct(this.value):isAddProductPage?BMS.PRODUCT.addProduct(this.value):isStockEntryPage?BMS.STOCK_ENTRY.addProduct(this.value):isSaleOrderPage&&BMS.ORDER.addProduct(this.value),$(this).html("Search Product.... ")})),$(document).on("click","#addWastageSaleRow",(function(){BMS.WASTAGE_SALE.addWastageSaleItem()})),$(document).on("click",".removeThisProduct, .removeThisItem",(function(){$(this).closest("tr").css("background-color","red").hide("fast",(function(){$(this).closest("tr").remove(),isPosPage?(BMS.POS.grandTotal(),BMS.POS.disableEnableWCSelect()):isPurchasePage?BMS.PURCHASE.grandTotal():isTransferStockPage?(BMS.STOCK_TRANSFER.grandTotal(),BMS.STOCK_TRANSFER.disableEnableWarehouseSelect()):isProductReturnPage?BMS.RETURN.grandTotal():isWastageSalePage?BMS.WASTAGE_SALE.grandTotal():isSpecimenCopyPage?BMS.SPECIMEN_COPY.disableEnableWarehouseSelect():isStockEntryPage?BMS.STOCK_ENTRY.grandTotal():isSaleOrderPage&&(BMS.ORDER.grandTotal(),BMS.POS.disableEnableWCSelect())}))})),$(document).on("click",".removeThisTariffCharges",(function(){$(this).closest(".row").css("background-color","whitesmoke").hide("fast",(function(){$(this).closest(".row").remove(),isPosPage?BMS.POS.grandTotal():isPurchasePage?BMS.PURCHASE.grandTotal():isProductReturnPage?BMS.RETURN.grandTotal():isWastageSalePage?BMS.WASTAGE_SALE.grandTotal():isSaleOrderPage&&BMS.ORDER.grandTotal()}))})),$(document).on("change",".tariffChargesName",(function(){isPosPage?BMS.POS.grandTotal():isPurchasePage?BMS.PURCHASE.grandTotal():isProductReturnPage?BMS.RETURN.grandTotal():isWastageSalePage?BMS.WASTAGE_SALE.grandTotal():isSaleOrderPage&&BMS.ORDER.grandTotal()})),$(document).on("keyup blur",".productQnt",(function(){isPosPage?BMS.POS.productQntCheck(this):isPurchasePage?(BMS.PURCHASE.calculateEachProduct(this),BMS.PURCHASE.grandTotal()):isTransferStockPage?BMS.STOCK_TRANSFER.productQntCheck(this):isProductReturnPage?(BMS.RETURN.grandTotal(),BMS.RETURN.calculateEachProduct(this)):isSpecimenCopyPage?BMS.SPECIMEN_COPY.productQntCheck(this):isStockEntryPage?(BMS.STOCK_ENTRY.calculateEachProduct(this),BMS.STOCK_ENTRY.grandTotal()):isSaleOrderPage&&BMS.ORDER.productQntCheck(this)})),$(document).on("keydown",".productQnt",(function(e){"Enter"===e.key&&($("#selectProduct, #selectPosProduct, #selectStockTransferProduct, #selectStockEntryProduct").hasClass("select2-hidden-accessible")||BMS.fn.select2("#selectProduct, #selectPosProduct, #selectStockTransferProduct, #selectStockEntryProduct"),$("#selectProduct, #selectPosProduct, #selectStockTransferProduct, #selectStockEntryProduct").select2("open"))})),$(document).on("keydown","#purchaseDiscountValue",(function(e){"Enter"===e.key&&(e.preventDefault(),$("#purchaseDiscount").modal("hide"),$("#finalizePurchase").modal("show"))})),$(document).on("keydown","#shippingCharge",(function(e){"Enter"===e.key&&(e.preventDefault(),$("#adjustAmount").select())})),$(document).on("keydown","#adjustAmount",(function(e){$(this).addClass("disableAdjustAmountAutoChange"),"Enter"===e.key&&(e.preventDefault(),$(".posSalePaymentAmount").first().select(),$(".posSalePaymentAmount").first().addClass("disablePaymentAmountAutoChange"))})),$(document).on("keydown focus",".posSalePaymentAmount",(function(e){var t=$(this).closest(".row").next(".row").find("input.posSalePaymentAmount");$(this).addClass("disablePaymentAmountAutoChange"),1===t.length&&"Enter"===e.key&&(e.preventDefault(),t.addClass("disablePaymentAmountAutoChange"),t.select())})),$(document).on("keydown",".select2-search__field",(function(e){isPosPage&&"select2-selectPosProduct-results"===$(this).attr("aria-controls")&&""===this.value&&$(".productQnt").length>0&&"Enter"===e.key&&($("#selectPosProduct").select2("close"),$("#orderDiscount").modal("show")),isPurchasePage&&"select2-selectProduct-results"===$(this).attr("aria-controls")&&""===this.value&&$(".productQnt").length>0&&"Enter"===e.key&&($("#selectProduct").select2("close"),$("#purchaseDiscount").modal("show"))})),$(document).on("hide.bs.modal","#orderDiscount",(function(e){var t=$("#orderDiscountValue"),a=$(t).val();BMS.POS.isGivenDiscountPermitted(t)?($("#payment").modal("show"),BMS.POS.grandTotal()):(Swal.fire({title:"Error!",text:`You do not have permission to give ${a} discount.`,icon:"error"}),$(t).val(0),e.preventDefault())})),$(document).on("blur keyup",".wastageSaleItemQnt, .wastageSaleItemPrice",(function(){var e=$(this).closest("tr").find(".wastageSaleItemQnt").val(),t=$(this).closest("tr").find(".wastageSaleItemPrice").val();$(this).closest("tr").find(".wastageSaleItemSubtotal").html(parseFloat(e*t).toFixed(2)),BMS.WASTAGE_SALE.grandTotal()})),$(document).on("blur keyup","#wastageSaleDiscount, #wastageSalePaidAmount",(function(){BMS.WASTAGE_SALE.grandTotal()})),$(document).on("blur keyup",".productPurchaseDiscount, .productPurchasePrice",(function(){isPurchasePage?(BMS.PURCHASE.calculateEachProduct(this),BMS.PURCHASE.grandTotal()):isTransferStockPage&&(BMS.STOCK_TRANSFER.calculateEachProduct($(this)),BMS.STOCK_TRANSFER.grandTotal())})),$(document).on("blur keyup",".productReturnDiscount, .productReturnPrice",(function(){BMS.RETURN.calculateEachProduct(this),BMS.RETURN.grandTotal()})),$(document).on("keyup blur","#purchaseDiscount, #purchasePaidAmount, #purchaseShipping",(function(){BMS.PURCHASE.grandTotal()})),$(document).on("keyup blur","#returnDiscount, #returnShipping, #returnSurcharge, #returnPaidAmount",(function(){BMS.RETURN.grandTotal()})),$(document).on("keyup blur","#productSaleItemPacket",(function(){})),$(document).on("blur keydown","#productSaleItemDiscount",(function(e){BMS.POS.productDiscountCheck(e)})),$(document).on("keydown","#orderDiscountValue",(function(e){13===(e.keyCode||e.which)&&BMS.POS.orderDiscountCheck(this,e)})),$(document).on("keyup",".posSalePaymentAmount, #shippingCharge, #totalPackets, #packetShippingRate, #adjustAmount",(function(e){BMS.POS.grandTotal(e)})),$(document).on("submit","#posSale",(function(e){e.preventDefault();var t=0===$(".productQnt").length,a=$(".productSO").filter((function(){return 1==this.value})).length>0;if(""===$("#customersId").val())return BMS.fn.alertError("Please select the customer");var o=e.originalEvent.submitter;if("sale_is_hold"!==o.value||confirm("Are you sure to Hold this?"))if(t||a)Swal.fire({title:"Error!",html:t?"Please add a least one product":"Sorry! there have at least one out of stock product in selected warehouse, which are marked with Pink background . Please remove them first.",icon:"error",onClose:$("body").css("padding","0px")});else{$(o).html("Submit ");var n=new FormData(this);n.append(o.name,o.value),$("#payment").find("button").prop("disabled",!0),$.ajax({url:full_website_address+"/info/?module=pos",type:"post",data:n,cache:!1,contentType:!1,processData:!1,success:function(t,a){if("success"==a){$(o).html("Printing...");var n=JSON.parse(t);"success"===n.saleStatus?BMS.MAIN.printPage(full_website_address+"/invoice-print/?invoiceType=posSale&id="+n.salesId,e,(function(){$("#payment").modal("hide"),BMS.POS.clearScreen(),$("#payment").find("button").prop("disabled",!1)})):($("#posErrorMsg").html(''+n.msg+"
"),$("#payment").find("button").prop("disabled",!1))}}})}})),$(document).on("submit","#productPurchase, #productStockTransfer, #productReturn, #specimenCopyForm, #scDistributionForm",(function(e){if($(".productQnt").length<1)return alert("Please add at least one product."),void e.preventDefault()})),$(document).on("submit","#wastageSaleForm",(function(e){return $(".wastageSaleItemQnt").length<1?(alert("Please add at least one item."),void e.preventDefault()):Number($("#wastageSalePaidAmount").val())>0&&""===$("#wastageSaleAccounts").val()?(alert("Please select the accounts."),void e.preventDefault()):void 0})),$(document).on("keypress","#posSale, #productPurchase, #productReturn, #productStockTransfer, #wastageSaleForm",(function(e){13===(e.keyCode||e.which)&&(!1===$("#payment, #finalizePurchase, #finalizeReturn, #finalizeWastageSale").hasClass("in")&&e.preventDefault(),isPosPage?(BMS.POS.grandTotal(),$("#orderDiscount").hasClass("in")?$("#orderDiscount").modal("hide"):$("#salesTariffCharges").hasClass("in")?$("#salesTariffCharges").modal("hide"):$("#productSaleDetails").hasClass("in")&&$("#productSaleDetails").modal("hide")):isPurchasePage?(BMS.PURCHASE.grandTotal(),$("#purchaseTariffCharges").hasClass("in")?$("#purchaseTariffCharges").modal("hide"):$("#purchaseDiscount").hasClass("in")&&$("#purchaseDiscount").modal("hide")):isProductReturnPage?(BMS.RETURN.grandTotal(),$("#returnTariffCharges").hasClass("in")?$("#returnTariffCharges").modal("hide"):$("#returnDiscount").hasClass("in")&&$("#returnDiscount").modal("hide")):isWastageSalePage&&(BMS.WASTAGE_SALE.grandTotal(),$("#wastageSaleTariffCharges").hasClass("in")?$("#wastageSaleTariffCharges").modal("hide"):$("#wastageSaleDiscount").hasClass("in")&&$("#wastageSaleDiscount").modal("hide")))})),$(document).on("shown.bs.modal","#orderDiscount, #purchaseDiscount, #returnDiscount, #wastageSaleDiscount, #payment",(function(){$("#purchaseDiscountValue, #purchasePaidAmount, #orderDiscountValue, #shippingCharge, #returnDiscountValue, #returnPaidAmount, #wastageSaleDiscountValue, #shippingCharge").select()})),$(document).on("show.bs.modal","#customerPurchaseList",(function(){BMS.fn.get(`customerPurchaseList&cid=${$("#customersId").val()}`,(e=>{if(""!=e){var t="";e.forEach((e=>{"Hold"===e.sales_status?t+=`\n \n ${e.date} (${e.ref})\n ${to_money(e.total)} \n \n Hold \n From: ${e.shop}; Status: ${e.pay_status}\n \n \n `:t+=`\n \n ${e.date} (${e.ref})\n ${to_money(e.total)} \n \n From: ${e.shop}; Status: ${e.pay_status}\n \n \n `})),$("#showPurchaseList ul").html(t)}else $("#showPurchaseList ul").html('Sorry! No data found. ')}))})),$(document).on("keydown",".searchInvoiceInPos",(function(e){if("Enter"===e.key){$("body").toggleClass("wait");var t=encodeURIComponent($(this).val());BMS.fn.get(`customerPurchaseList&cid=${$("#customersId").val()}&s=${t}`,(e=>{if(""==e)return $("body").toggleClass("wait"),void $("#showPurchaseList ul").html('Sorry! No data found. ');var t="";e.forEach((e=>{"Hold"===e.sales_status?t+=`\n \n ${e.date} (${e.ref})\n ${to_money(e.total)} \n \n Hold \n From: ${e.shop}; Status: ${e.pay_status}\n \n \n `:t+=`\n \n ${e.date} (${e.ref})\n ${to_money(e.total)} \n \n From: ${e.shop}; Status: ${e.pay_status}\n \n \n `})),$("#showPurchaseList ul").html(t),$("body").toggleClass("wait")}))}})),$(document).on("click",".quick-cash",(function(){var e=Number($(this).html());$(".posSalePaymentAmount").val(parseFloat(e).toFixed(2)),BMS.POS.grandTotal()})),$(document).on("hide.bs.modal","#productSaleDetails",(function(){var e=$("#productSaleDetails .rowId").val(),t=$("#productSaleDetails #productSaleItemPrice").val(),a=$("#productSaleDetails #productSaleItemDiscount").val(),o=$("#productSaleDetails #productSaleItemPacket").val(),n=$("#productSaleDetails #productSaleItemDetails").val(),s=$("tr#"+e);s.find(".netSalesPrice").val(t);var r=BMS.FUNCTIONS.calculateDiscount(t,a),l="";if(Number(r)===Number(t))l=parseFloat(t).toFixed(2);else l=""+r+" "+parseFloat(t).toFixed(2)+" ";s.find(".displayProductPrice").html(l),s.find(".productDiscount").val(a),s.find(".productItemDetails").val(n),s.find(".productPacket").val(o),s.find(".subtotalCol").html(r*s.find(".productQnt").val()),BMS.POS.grandTotal()})),$(document).on("focus",".productQnt",(function(){$(this)[0].scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})})),$(document).on("change","#ReturnMoney",(function(){$("#ReturnMoney").is(":checked")?$(".returnAmountAccountsDiv").show():$(".returnAmountAccountsDiv").hide()})),$(document).on("submit","#accountsLedgerForm",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=ledgers&page=accountsLedger&account_id="+$("#accountSelection").val()+"&dateRange="+$("#accountsLedgerDateRange").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load(),$.post(full_website_address+"/info/?module=data&page=getAccountsInfo",{accountsId:$("#accountSelection").val()},(function(e,t){var a=JSON.parse(e);$("#accountsName").html(a.name),$("#accountsBalance").html(tsd(a.balance)),$("#accountsLedgerDates").html($("#accountsLedgerDateRange").val())}))})),$(document).on("submit","#employeeLedgerForm",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=ledgers&page=employeeLedger&emp_id="+$("#employeeSelection").val()+"&dateRange="+$("#employeeLedgerDateRange").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load(),$.post(full_website_address+"/info/?module=data&page=getEmpSalaryData",{empId:$("#employeeSelection").val()},(function(e,t){var a=JSON.parse(e),o=Number(a.emp_payable_salary)+Number(a.emp_payable_overtime)+Number(a.emp_payable_bonus);$("#salaryInfo > tbody > tr > td:nth-child(1)").html(tsd(a.emp_payable_salary)),$("#salaryInfo > tbody > tr > td:nth-child(2)").html(tsd(a.emp_payable_overtime)),$("#salaryInfo > tbody > tr > td:nth-child(3)").html(tsd(a.emp_payable_bonus)),$("#salaryInfo > tbody > tr > td:nth-child(4)").html(tsd(o)),$("#employeeName").html(a.emp_firstname+" "+a.emp_lastname),$("#accountsLedgerDates").html($("#employeeLedgerDateRange").val())}))})),$(document).on("submit","#journalLedgerForm",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=ledgers&page=journalLedger&journal_id="+$("#journalSelection").val()+"&dateRange="+$("#journalLedgerDateRange").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load()})),$(document).on("submit","#customerLedgerForm",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=ledgers&page=customerLedger&customer_id="+$("#customerSelection").val()+"&dateRange="+$("#customerLedgerDateRange").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load()})),$(document).on("submit","#companyLedgerForm",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=ledgers&page=companyLedger&company_id="+$("#companySelection").val()+"&dateRange="+$("#companyLedgerDateRange").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load()})),$(document).on("submit","#advancePaymentLedgerForm",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=ledgers&page=advancePaymentLedger&emp_id="+$("#employeeSelection").val()+"&dateRange="+$("#advancePaymentLedgerDateRange").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load()})),$(document).on("submit","#productLedgerForm",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=reports&page=productLedger&pid="+$("#productSelection").val()+"&wid="+$("#warehouseSelection").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load()})),$(document).on("submit","#customerStatementReport",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=reports&page=customerStatement&cid="+$("#customerSelection").val()+"&dateRange="+$("#customerStatementDateRange").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load(),$.post(full_website_address+"/info/?module=data&page=getCustomerStatementInfo",{customerId:$("#customerSelection").val(),dateRange:$("#customerStatementDateRange").val()},(function(e,t){var a=JSON.parse(e),o=Number(a.net_purchased)-(Number(a.total_product_returns)+Number(a.total_purchased_discount)),n=Number(a.advance_payments_amount)+Number(a.received_payments_amount)+Number(a.sales_payments_amount),s=n+Number(a.previous_balance)+Number(a.total_given_bonus)+Number(a.special_discounts_amount)-(o+Number(a.total_shipping)+Number(a.payments_return_amount));$("#paymentInfo > tbody > tr:nth-child(1) > td:nth-child(2)").html(tsd(a.net_purchased)),$("#paymentInfo > tbody > tr:nth-child(2) > td:nth-child(2)").html(tsd(a.total_purchased_discount)),$("#paymentInfo > tbody > tr:nth-child(3) > td:nth-child(2)").html(tsd(a.total_shipping)),$("#paymentInfo > tbody > tr:nth-child(4) > td:nth-child(2)").html(tsd(a.total_product_returns)),$("#paymentInfo > tbody > tr:nth-child(5) > td:nth-child(2)").html(tsd(o)),$("#paymentInfo > tbody > tr:nth-child(1) > td:nth-child(4)").html(tsd(a.sales_payments_amount)),$("#paymentInfo > tbody > tr:nth-child(2) > td:nth-child(4)").html(tsd(a.received_payments_amount)),$("#paymentInfo > tbody > tr:nth-child(3) > td:nth-child(4)").html(tsd(a.advance_payments_amount)),$("#paymentInfo > tbody > tr:nth-child(5) > td:nth-child(4)").html(tsd(n)),$("#paymentInfo > tbody > tr:nth-child(1) > td:nth-child(6)").html(tsd(a.previous_balance)),$("#paymentInfo > tbody > tr:nth-child(2) > td:nth-child(6)").html(tsd(a.total_given_bonus)),$("#paymentInfo > tbody > tr:nth-child(3) > td:nth-child(6)").html(tsd(a.special_discounts_amount)),$("#paymentInfo > tbody > tr:nth-child(4) > td:nth-child(6)").html(tsd(a.payments_return_amount)),$("#paymentInfo > tbody > tr:nth-child(5) > td:nth-child(6)").html(tsd(s)),$("#customerName").html(a.customer_name),$("#customerAddress").html(a.customer_address+", "+a.district_name),$("#customerStatementDates").html($("#customerStatementDateRange").val())}))})),$(document).on("submit","#locationWiseSaleReort",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=reports&page=locationWiseSalesReport&pid="+$("#selectProductForLocationReport").val()+"&location="+$("#selectLocation").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load()})),$(document).on("change","#paymentEmployee, #dontAdujctAdvance, .paymentsType",(function(){var e=$(this);$.post("/info/?module=data&page=getEmpSalaryData",{empId:$("#paymentEmployee").val()},(function(t,a){$("#dontAdjustAdvance").is(":checked");var o=JSON.parse(t),n=Number(o.emp_payable_salary)+Number(o.emp_payable_overtime)+Number(o.emp_payable_bonus),s="Last taken loan: "+tsd(o.loan_amount)+"; Paid: "+tsd(o.loan_installment_paid_amount)+"; Monthly:"+tsd(o.loan_installment_amount);$("#salaryInfo > tbody > tr > td:nth-child(1)").html(tsd(o.emp_payable_salary)),$("#salaryInfo > tbody > tr > td:nth-child(2)").html(tsd(o.emp_payable_overtime)),$("#salaryInfo > tbody > tr > td:nth-child(3)").html(tsd(o.emp_payable_bonus)),$("#salaryInfo > tbody > tr > td:nth-child(4)").html(tsd(n)),$("#salaryInfo > tfoot > tr:nth-child(1) > th").html(s);var r=$(e).val();"Salary"==r?$(e).closest(".row").find(".paymentAmount").val(Number(o.emp_payable_salary).toFixed(0)):"Overtime"==r?$(e).closest(".row").find(".paymentAmount").val(Number(o.emp_payable_overtime).toFixed(0)):"Bonus"==r?$(e).closest(".row").find(".paymentAmount").val(Number(o.emp_payable_bonus).toFixed(0)):"Advance Salary"==r?$(e).closest(".row").find(".paymentAmount").val(0):$(".paymentAmount").val(Number(o.emp_payable_salary).toFixed(0))}))})),$(document).on("change","#paymentMethods",(function(){"Cheque"==$("#paymentMethods").val()?$("#hiddenItem").css("display","block"):$("#hiddenItem").css("display","none")})),$(document).off("click","#addSalaryPaymentRow"),$(document).on("click","#addSalaryPaymentRow",(function(){$("#salaryPaymentRow").append('')})),$(document).on("click",".removeSalaryPaymentRow",(function(){$(this).closest(".row").css("background-color","whitesmoke").hide("slow",(function(){$(this).closest(".row").remove()}))})),$(document).on("focusin",".datePicker",(function(){BMS.FUNCTIONS.datePicker()})),$(document).on("focusin",".dateTimePicker",(function(){BMS.FUNCTIONS.datePicker({selector:this,format:"YYYY-MM-DD HH:mm",timePicker:!0})})),$(document).on("focusin",".dateRangePicker",(function(){BMS.FUNCTIONS.dateRangePicker()})),$(document).on("focusin",".dateTimeRangePicker",(function(){BMS.FUNCTIONS.dateRangePicker({selector:this,format:"YYYY-MM-DD HH:mm",timePicker:!0})})),$(document).on("focusin",".dateRangePickerPreDefined",(function(){BMS.FUNCTIONS.dateRangePickerPreDefined()})),$(document).on("focusin",".dateTimeRangePickerPreDefined",(function(){BMS.FUNCTIONS.dateRangePickerPreDefined({selector:this,format:"YYYY-MM-DD HH:mm",timePicker:!0})})),$(document).on("focusin",".multiDatePicker",(function(){BMS.FUNCTIONS.multiDatePicker()})),$(document).on("change",".imageToUpload",(function(){var e=$(this).closest(".imageContainer").find(".photoErrorMessage");$(e).empty();var t=this.files[0],a=t.type,o=t.size;if(!1===["image/jpeg","image/png","image/jpg"].includes(a))return $(e).length<1?(BMS.fn.alertError(""),this.value=this.defaultValue):$(e).html("
"),!1;if("""),this.value=this.defaultValue):$(e).html("
"),!1;var n=$(this).val().replace(/\\/g,"/").replace(/.*\//,"");$(this).closest(".imageContainer").find(".imageNameShow").val(n);var s=$(this),r=new FileReader;r.onload=function(e){$(s).css("color","green"),$(s).closest(".imageContainer").find(".image_preview").css("display","block"),$(s).closest(".imageContainer").find(".previewing").attr("src",e.target.result)},r.readAsDataURL(this.files[0])})),$(document).on("click","#addPosSalePaymentRow",(function(){$(".paymentMethodBox").append('\n
\n Amount \n \n \n
\n
\n Reference/Info \n \n
\n
\n Bank Account \n \n .... \n \n
\n
\n Payment Method \n \n \n \n \n \n \n \n
\n
')})),$(document).on("click",".removePosPaymentItem",(function(){$(this).closest(".row").remove(),BMS.POS.grandTotal()})),$(document).on("change",".posSalePaymentMethod",(function(){"Cash"===$(this).val()?$(this).closest(".row").find(".posSalePaymentBankAccount").hide():$(this).closest(".row").find(".posSalePaymentBankAccount").show()})),$(document).on("submit","#modalForm, #popUpForm, #jqFormAdd, #jqFormUpdate",(function(e){e.preventDefault(),ajaxFormSubmit(this)})),$(document).on("submit","#inlineForm",(function(e){e.preventDefault(),ajaxFormSubmit(this,!0)})),$(document).on("click",".deleteEntry",(function(e){e.preventDefault();var t=$(this).attr("href"),a=$(this).attr("data-to-be-deleted"),o=$(this).attr("removeParent"),n=this;Swal.fire({title:"Are you sure to delete this entry?",icon:"warning",didOpen:function(){BMS.fn.play("warning")},showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"Yes, delete it!"}).then((e=>{e.value&&$.post(t,{datatoDelete:a},(function(e,t){if(isJson(e)){var a=JSON.parse(e);for(var s in a)sweetAlert[s]=a[s]}Swal.fire({toast:sweetAlert.toast,position:sweetAlert.position,timer:sweetAlert.timer,showConfirmButton:sweetAlert.showConfirmButton,showCloseButton:sweetAlert.showCloseButton,icon:sweetAlert.icon,title:sweetAlert.title,text:sweetAlert.text,onClose:$("body").css("padding","0px")}),void 0!==o&&$(n).closest(o).hide("fast"),$("#dataTableWithAjax").DataTable().ajax.reload(null,!1),$("#dataTableWithAjaxExtend").DataTable().ajax.reload(null,!1)}))}))})),$(document).on("click",".updateEntry",(function(e){e.preventDefault();var t=$(this).attr("href"),a=$(this).attr("data-to-be-updated");$(this).css("color","black"),$(this).find("i.fa").addClass("fa-spin"),$.post(t,{datatoUpdate:a},(function(e,t){if(isJson(e)){var a=JSON.parse(e);for(var o in a)sweetAlert[o]=a[o]}Swal.fire({toast:sweetAlert.toast,position:sweetAlert.position,timer:sweetAlert.timer,showConfirmButton:sweetAlert.showConfirmButton,showCloseButton:sweetAlert.showCloseButton,icon:sweetAlert.icon,title:sweetAlert.title,text:sweetAlert.text,onClose:$("body").css("padding","0px")}),$("#dataTableWithAjax").DataTable().ajax.reload(null,!1),$("#dataTableWithAjaxExtend").DataTable().ajax.reload(null,!1)}))})),$(document).on("dblclick","iledit",(function(e){e.preventDefault();var t=$(this),a=t.closest("td"),o=t.closest("table").find("th").eq(a.index()),n=t.closest("tr").find("pkey").text(),s=o.attr("type"),r=o.attr("data-source"),l=o.attr("data-options"),i=o.attr("where-to-update"),c=t.attr("data-val"),d=t.text(),u=a.width();if("select2"===s){a.html(`\n \n .... \n \n `);var m=a.find(".select2InlineEdit");BMS.fn.select2(m,c,d),m.select2("open")}else if("select"===s){(l=l.split(",")).forEach((function(e){l+=`${e} `})),a.html(`\n \n ${l}\n \n `),(m=a.find("select")).select2(),m.select2("open")}else a.html(`\n \n `),"datePicker"===s&&(a.find("input").addClass("datePicker"),a.find(".datePicker").focus());a.find("input, select, textarea").on("enter blur clear apply.daterangepicker, select2:close",(function(){var e=["select2","select"].includes(s)?c:d,t=$(this).val(),o=$(this);t!==e?$.post(i,{pkey:n,newData:t},(function(e,t){void 0!==(e=JSON.parse(e)).error&&"true"===e.error?BMS.fn.alertError(e.msg):(BMS.fn.alertSuccess("The data has been successfully updated."),"select2"===s||"select"===s?a.html(""+$("option:selected",o).text()+" "):a.html(""+$(o).val()+" "))})):"select2"===s||"select"===s?a.html(""+$("option:selected",o).text()+" "):a.html(""+$(o).val()+" ")}))})),$(document).on("hidden.bs.modal",(function(e){$(e.target).removeData("bs.modal").find(".modal-ajax").html("")})),$(document).ready((function(){$(document).on("mouseenter focus",".select2Ajax",(function(){BMS.fn.select2(this)}))})),$(document).ready((function(){$("body").tooltip({selector:'[data-toggle="tooltip"]'})})),$(document).click((function(e){$(".dropdown-menu[data-parent]").hide()})),$(document).on("click",'.col-sm-12 [data-toggle="dropdown"]',(function(){if($("body").hasClass("modal-open"))throw new Error("This solution is not working inside a responsive table inside a modal, you need to find out a way to calculate the modal Z-index and add it to the element");if($buttonGroup=$(this).parent(),$buttonGroup.attr("data-attachedUl"))$ul=$("[data-parent="+$buttonGroup.attr("data-attachedUl")+"]");else{var e=+new Date;$ul=$(this).siblings("ul"),$ul.attr("data-parent",e),$buttonGroup.attr("data-attachedUl",e),$(window).resize((function(){$ul.css("display","none").data("top")}))}var t,a,o;$buttonGroup.hasClass("open")?(t=$(this).parent(),a=$ul,o=t.offset().top+t.outerHeight(),a.css("top",o+"px"),a.css("left",t.offset().left-100+"px"),a.css("position","absolute"),a.css("width",a.width()),a.css("heigt",a.height()),a.css("display","block"),a.appendTo(".dynamic-container")):$ul.css("display","none")})),$(document).on("click",".restricted",(function(){Swal.fire({title:"Sorry!",text:"You have no permission to perform this action",icon:"error"})})),$(".modal").on("show.bs.modal",(function(e){if(-1!==$.inArray("restricted",e.target.classList))return e.preventDefault()})),$(".modal").on("shown.bs.modal",(function(){$(this).find("[autofocus]").focus()})),$("form").on("focus","input[type=number]",(function(e){$(this).on("wheel.disableScroll",(function(e){e.preventDefault()}))})),$("form").on("blur","input[type=number]",(function(e){$(this).off("wheel.disableScroll")}));var sweetAlert=[];sweetAlert.title="The command has been executed successfully.",sweetAlert.text="",sweetAlert.icon="success",sweetAlert.toast=!0,sweetAlert.position="top",sweetAlert.timer=5e3,sweetAlert.showConfirmButton=!1,sweetAlert.showCloseButton=!1,$('input[type="checkbox"].square, input[type="radio"].square').iCheck({checkboxClass:"icheckbox_square-blue",radioClass:"iradio_square-blue"}),$.ajaxSetup({beforeSend:function(e){e.setRequestHeader("X-CSRF-TOKEN",xCsrfToken)}});var getPageTitle=JSON.parse('');$(window).bind("popstate",(function(e){"undefined"!=typeof session&&(session.terminate(),phone.stop()),e.preventDefault(),$.get(location.href+"?contentOnly=true",(function(e,t){defaultiDisplayLength="",$("li").removeClass("active");var a=location.href,o="Not Found!";void 0!==getPageTitle[a]&&(o=getPageTitle[a]),window.document.title=o,$(".dynamic-container").html(e),jQuery.get(full_website_address+"/assets/js/initiator.min.js")}))})),$(document).on("keydown",(function(e){"F2"===e.key&&($("#selectProduct, #selectPosProduct, #selectStockTransferProduct, #selectStockEntryProduct").hasClass("select2-hidden-accessible")||BMS.fn.select2("#selectProduct, #selectPosProduct, #selectStockTransferProduct, #selectStockEntryProduct"),$("#selectProduct, #selectPosProduct, #selectStockTransferProduct, #selectStockEntryProduct").select2("open")),"F3"===e.key&&(e.preventDefault(),$("#orderDiscount").modal("show"))})),$(document).on("click",".toggleNotButton",(function(){var e=$(this).closest("span").find(".notThisValueFilter");"="===$(e).val()?($(e).val("!="),$(this).text("|")):($(this).text(""),$(e).val("="))})),$(document).on("click",".stopPropagation",(function(e){e.stopPropagation()})),$(document).on("change","#productType",(function(){$("#productVariationSection").hide(),$("#bundleProductsContainer").hide(),$(".bundleProduct").hide(),$(".groupedProduct").hide();"Variable"===this.value?$("#productVariationSection").show():"Bundle"===this.value?($(".bundleProduct").show(),$("#bundleProductsContainer").show()):"Grouped"===this.value&&($(".groupedProduct").show(),$("#bundleProductsContainer").show())})),$(document).on("click",".removeThisVariation",(function(e){if(e.stopPropagation(),confirm("Are sure to remove this variation?")){var t=$(this).closest("li").find(".variation_product_id").val();$(this).closest("li").hide("fast",(function(){$(this).remove()})),void 0!==t&&$.ajax({url:full_website_address+"/xhr/?module=products&page=deleteVariationProduct",type:"post",data:{product_id:t},success:function(e,t){}})}})),$(document).on("click","#setVariationPrice",(function(){setVariationPrice()})),$(window).keydown((function(e){if(13==e.keyCode&&$("#productVariationPrice").hasClass("in"))return e.preventDefault(),setVariationPrice(),$("#productVariationPrice").modal("hide"),!1})),$("#browseProduct").on("show.bs.modal",(function(e){BMS.PRODUCT.showProduct()})),$(document).on("change","#productHasExpiryDate",(function(){"1"===this.value?$(".productIntitalStock").prop("disabled",!0):$(".productIntitalStock").prop("disabled",!1)}));let barCcode="";$(document).on("keypress",(e=>{if("Enter"===e.key){var t="input"!==e.target.tagName.toLowerCase();""!==barCcode&&(isPosPage&&t?BMS.POS.addProduct(barCcode,!0):isPurchasePage&&t?BMS.PURCHASE.addProduct(barCcode,!0):isTransferStockPage&&t?BMS.STOCK_TRANSFER.addProduct(barCcode,!0):isProductReturnPage&&t?BMS.RETURN.addProduct(barCcode,!0):isStockEntryPage&&t?BMS.STOCK_ENTRY.addProduct(barCcode,!0):isAddProductPage&&$("#productCode").val(barCcode)),barCcode=""}else barCcode+=e.key})),$(document).on("click",".copyThis",(function(e){navigator.clipboard.writeText($(this).text())}));
\ No newline at end of file
+$(document).on("change","#productCategoryFilter, #productBrandFilter, #productEditionFilter, #productGenericFilter, #productAuthorFilter",(function(){BMS.PRODUCT.showProduct({category:$("#productCategoryFilter").val(),brand:$("#productBrandFilter").val(),edition:$("#productEditionFilter").val(),generic:$("#productGenericFilter").val(),author:$("#productAuthorFilter").val()})})),$(document).on("change","#customers",(function(){var e=$("#customers").val();$("#customersId").val(e),BMS.fn.get(`getCustomerData&cid=${e}`,(function(e){$("#orderDiscountValue").val(e.discount),$("#packetShippingRate").val(e.shipping_rate)}))})),$(document).on("change","#warehouse",(function(){var e=$("#warehouse").val();$("#warehouseId").val(e),$("#selectPosProduct").attr("select2-ajax-url",`${full_website_address}/info/?module=select2&page=productListForPos&wid=${e}`),BMS.fn.select2("#selectPosProduct")})),$(document).on("change","#stockTransferFromWarehouse, #stockTransferToWarehouse",(function(){var e=$("#stockTransferFromWarehouse").val(),t=$("#stockTransferToWarehouse").val();$("#stockTransferFromWarehouseId").val(e),$("#stockTransferToWarehouseId").val(t)})),$(document).on("change","#scTransferWarehouse",(function(){var e=$("#scTransferWarehouse").val();$("#scTransferWarehouseId").val(e)})),$(document).on("click","#addTariffChargesRow",(function(){BMS.MAIN.addTariffChargesRow("#tariffCharges")})),$(document).on("click",".productButton",(function(){isPosPage?BMS.POS.addProduct(this.value):isPurchasePage?BMS.PURCHASE.addProduct(this.value):isTransferStockPage?BMS.STOCK_TRANSFER.addProduct(this.value):isProductReturnPage?BMS.RETURN.addProduct(this.value):isSpecimenCopyPage?BMS.SPECIMEN_COPY.addProduct(this.value):isScDistributionPage?BMS.SC_DISTRIBUTION.addProduct(this.value):isAddProductPage?BMS.PRODUCT.addProduct(this.value):isStockEntryPage?BMS.STOCK_ENTRY.addProduct(this.value):isSaleOrderPage&&BMS.ORDER.addProduct(this.value)})),$(document).on("change","#selectProduct, #selectPosProduct, #selectStockTransferProduct, #selectStockEntryProduct",(function(){isPosPage?BMS.POS.addProduct(this.value):isPurchasePage?BMS.PURCHASE.addProduct(this.value):isTransferStockPage?BMS.STOCK_TRANSFER.addProduct(this.value):isProductReturnPage?BMS.RETURN.addProduct(this.value):isSpecimenCopyPage?BMS.SPECIMEN_COPY.addProduct(this.value):isScDistributionPage?BMS.SC_DISTRIBUTION.addProduct(this.value):isAddProductPage?BMS.PRODUCT.addProduct(this.value):isStockEntryPage?BMS.STOCK_ENTRY.addProduct(this.value):isSaleOrderPage&&BMS.ORDER.addProduct(this.value),$(this).html("Search Product.... ")})),$(document).on("click","#addWastageSaleRow",(function(){BMS.WASTAGE_SALE.addWastageSaleItem()})),$(document).on("click",".removeThisProduct, .removeThisItem",(function(){$(this).closest("tr").css("background-color","red").hide("fast",(function(){$(this).closest("tr").remove(),isPosPage?(BMS.POS.grandTotal(),BMS.POS.disableEnableWCSelect()):isPurchasePage?BMS.PURCHASE.grandTotal():isTransferStockPage?(BMS.STOCK_TRANSFER.grandTotal(),BMS.STOCK_TRANSFER.disableEnableWarehouseSelect()):isProductReturnPage?BMS.RETURN.grandTotal():isWastageSalePage?BMS.WASTAGE_SALE.grandTotal():isSpecimenCopyPage?BMS.SPECIMEN_COPY.disableEnableWarehouseSelect():isStockEntryPage?BMS.STOCK_ENTRY.grandTotal():isSaleOrderPage&&(BMS.ORDER.grandTotal(),BMS.POS.disableEnableWCSelect())}))})),$(document).on("click",".removeThisTariffCharges",(function(){$(this).closest(".row").css("background-color","whitesmoke").hide("fast",(function(){$(this).closest(".row").remove(),isPosPage?BMS.POS.grandTotal():isPurchasePage?BMS.PURCHASE.grandTotal():isProductReturnPage?BMS.RETURN.grandTotal():isWastageSalePage?BMS.WASTAGE_SALE.grandTotal():isSaleOrderPage&&BMS.ORDER.grandTotal()}))})),$(document).on("change",".tariffChargesName",(function(){isPosPage?BMS.POS.grandTotal():isPurchasePage?BMS.PURCHASE.grandTotal():isProductReturnPage?BMS.RETURN.grandTotal():isWastageSalePage?BMS.WASTAGE_SALE.grandTotal():isSaleOrderPage&&BMS.ORDER.grandTotal()})),$(document).on("keyup blur",".productQnt",(function(){isPosPage?BMS.POS.productQntCheck(this):isPurchasePage?(BMS.PURCHASE.calculateEachProduct(this),BMS.PURCHASE.grandTotal()):isTransferStockPage?BMS.STOCK_TRANSFER.productQntCheck(this):isProductReturnPage?(BMS.RETURN.grandTotal(),BMS.RETURN.calculateEachProduct(this)):isSpecimenCopyPage?BMS.SPECIMEN_COPY.productQntCheck(this):isStockEntryPage?(BMS.STOCK_ENTRY.calculateEachProduct(this),BMS.STOCK_ENTRY.grandTotal()):isSaleOrderPage&&BMS.ORDER.productQntCheck(this)})),$(document).on("keydown",".productQnt",(function(e){"Enter"===e.key&&($("#selectProduct, #selectPosProduct, #selectStockTransferProduct, #selectStockEntryProduct").hasClass("select2-hidden-accessible")||BMS.fn.select2("#selectProduct, #selectPosProduct, #selectStockTransferProduct, #selectStockEntryProduct"),$("#selectProduct, #selectPosProduct, #selectStockTransferProduct, #selectStockEntryProduct").select2("open"))})),$(document).on("keydown","#purchaseDiscountValue",(function(e){"Enter"===e.key&&(e.preventDefault(),$("#purchaseDiscount").modal("hide"),$("#finalizePurchase").modal("show"))})),$(document).on("keydown","#shippingCharge",(function(e){"Enter"===e.key&&(e.preventDefault(),$("#adjustAmount").select())})),$(document).on("keydown","#adjustAmount",(function(e){$(this).addClass("disableAdjustAmountAutoChange"),"Enter"===e.key&&(e.preventDefault(),$(".posSalePaymentAmount").first().select(),$(".posSalePaymentAmount").first().addClass("disablePaymentAmountAutoChange"))})),$(document).on("keydown focus",".posSalePaymentAmount",(function(e){var t=$(this).closest(".row").next(".row").find("input.posSalePaymentAmount");$(this).addClass("disablePaymentAmountAutoChange"),1===t.length&&"Enter"===e.key&&(e.preventDefault(),t.addClass("disablePaymentAmountAutoChange"),t.select())})),$(document).on("keydown",".select2-search__field",(function(e){isPosPage&&"select2-selectPosProduct-results"===$(this).attr("aria-controls")&&""===this.value&&$(".productQnt").length>0&&"Enter"===e.key&&($("#selectPosProduct").select2("close"),$("#orderDiscount").modal("show")),isPurchasePage&&"select2-selectProduct-results"===$(this).attr("aria-controls")&&""===this.value&&$(".productQnt").length>0&&"Enter"===e.key&&($("#selectProduct").select2("close"),$("#purchaseDiscount").modal("show"))})),$(document).on("hide.bs.modal","#orderDiscount",(function(e){var t=$("#orderDiscountValue"),a=$(t).val();BMS.POS.isGivenDiscountPermitted(t)?($("#payment").modal("show"),BMS.POS.grandTotal()):(Swal.fire({title:"Error!",text:`You do not have permission to give ${a} discount.`,icon:"error"}),$(t).val(0),e.preventDefault())})),$(document).on("blur keyup",".wastageSaleItemQnt, .wastageSaleItemPrice",(function(){var e=$(this).closest("tr").find(".wastageSaleItemQnt").val(),t=$(this).closest("tr").find(".wastageSaleItemPrice").val();$(this).closest("tr").find(".wastageSaleItemSubtotal").html(parseFloat(e*t).toFixed(2)),BMS.WASTAGE_SALE.grandTotal()})),$(document).on("blur keyup","#wastageSaleDiscount, #wastageSalePaidAmount",(function(){BMS.WASTAGE_SALE.grandTotal()})),$(document).on("blur keyup",".productPurchaseDiscount, .productPurchasePrice",(function(){isPurchasePage?(BMS.PURCHASE.calculateEachProduct(this),BMS.PURCHASE.grandTotal()):isTransferStockPage&&(BMS.STOCK_TRANSFER.calculateEachProduct($(this)),BMS.STOCK_TRANSFER.grandTotal())})),$(document).on("blur keyup",".productReturnDiscount, .productReturnPrice",(function(){BMS.RETURN.calculateEachProduct(this),BMS.RETURN.grandTotal()})),$(document).on("keyup blur","#purchaseDiscount, #purchasePaidAmount, #purchaseShipping",(function(){BMS.PURCHASE.grandTotal()})),$(document).on("keyup blur","#returnDiscount, #returnShipping, #returnSurcharge, #returnPaidAmount",(function(){BMS.RETURN.grandTotal()})),$(document).on("keyup blur","#productSaleItemPacket",(function(){})),$(document).on("blur keydown","#productSaleItemDiscount",(function(e){BMS.POS.productDiscountCheck(e)})),$(document).on("keydown","#orderDiscountValue",(function(e){13===(e.keyCode||e.which)&&BMS.POS.orderDiscountCheck(this,e)})),$(document).on("keyup",".posSalePaymentAmount, #shippingCharge, #totalPackets, #packetShippingRate, #adjustAmount",(function(e){BMS.POS.grandTotal(e)})),$(document).on("submit","#posSale",(function(e){e.preventDefault();var t=0===$(".productQnt").length,a=$(".productSO").filter((function(){return 1==this.value})).length>0;if(""===$("#customersId").val())return BMS.fn.alertError("Please select the customer");var o=e.originalEvent.submitter;if("sale_is_hold"!==o.value||confirm("Are you sure to Hold this?"))if(t||a)Swal.fire({title:"Error!",html:t?"Please add a least one product":"Sorry! there have at least one out of stock product in selected warehouse, which are marked with Pink background . Please remove them first.",icon:"error",onClose:$("body").css("padding","0px")});else{$(o).html("Submit ");var n=new FormData(this);n.append(o.name,o.value),$("#payment").find("button").prop("disabled",!0),$.ajax({url:full_website_address+"/info/?module=pos",type:"post",data:n,cache:!1,contentType:!1,processData:!1,success:function(t,a){if("success"==a){$(o).html("Printing...");var n=JSON.parse(t);"success"===n.saleStatus?BMS.MAIN.printPage(full_website_address+"/invoice-print/?invoiceType=posSale&id="+n.salesId,e,(function(){$("#payment").modal("hide"),BMS.POS.clearScreen(),$("#payment").find("button").prop("disabled",!1)})):($("#posErrorMsg").html(''+n.msg+"
"),$("#payment").find("button").prop("disabled",!1))}}})}})),$(document).on("submit","#productPurchase, #productStockTransfer, #productReturn, #specimenCopyForm, #scDistributionForm",(function(e){if($(".productQnt").length<1)return alert("Please add at least one product."),void e.preventDefault()})),$(document).on("submit","#wastageSaleForm",(function(e){return $(".wastageSaleItemQnt").length<1?(alert("Please add at least one item."),void e.preventDefault()):Number($("#wastageSalePaidAmount").val())>0&&""===$("#wastageSaleAccounts").val()?(alert("Please select the accounts."),void e.preventDefault()):void 0})),$(document).on("keypress","#posSale, #productPurchase, #productReturn, #productStockTransfer, #wastageSaleForm",(function(e){13===(e.keyCode||e.which)&&(!1===$("#payment, #finalizePurchase, #finalizeReturn, #finalizeWastageSale").hasClass("in")&&e.preventDefault(),isPosPage?(BMS.POS.grandTotal(),$("#orderDiscount").hasClass("in")?$("#orderDiscount").modal("hide"):$("#salesTariffCharges").hasClass("in")?$("#salesTariffCharges").modal("hide"):$("#productSaleDetails").hasClass("in")&&$("#productSaleDetails").modal("hide")):isPurchasePage?(BMS.PURCHASE.grandTotal(),$("#purchaseTariffCharges").hasClass("in")?$("#purchaseTariffCharges").modal("hide"):$("#purchaseDiscount").hasClass("in")&&$("#purchaseDiscount").modal("hide")):isProductReturnPage?(BMS.RETURN.grandTotal(),$("#returnTariffCharges").hasClass("in")?$("#returnTariffCharges").modal("hide"):$("#returnDiscount").hasClass("in")&&$("#returnDiscount").modal("hide")):isWastageSalePage&&(BMS.WASTAGE_SALE.grandTotal(),$("#wastageSaleTariffCharges").hasClass("in")?$("#wastageSaleTariffCharges").modal("hide"):$("#wastageSaleDiscount").hasClass("in")&&$("#wastageSaleDiscount").modal("hide")))})),$(document).on("shown.bs.modal","#orderDiscount, #purchaseDiscount, #returnDiscount, #wastageSaleDiscount, #payment",(function(){$("#purchaseDiscountValue, #purchasePaidAmount, #orderDiscountValue, #shippingCharge, #returnDiscountValue, #returnPaidAmount, #wastageSaleDiscountValue, #shippingCharge").select()})),$(document).on("show.bs.modal","#customerPurchaseList",(function(){BMS.fn.get(`customerPurchaseList&cid=${$("#customersId").val()}`,(e=>{if(""!=e){var t="";e.forEach((e=>{"Hold"===e.sales_status?t+=`\n \n ${e.date} (${e.ref})\n ${to_money(e.total)} \n \n Hold \n From: ${e.shop}; Status: ${e.pay_status}\n \n \n `:t+=`\n \n ${e.date} (${e.ref})\n ${to_money(e.total)} \n \n From: ${e.shop}; Status: ${e.pay_status}\n \n \n `})),$("#showPurchaseList ul").html(t)}else $("#showPurchaseList ul").html('Sorry! No data found. ')}))})),$(document).on("keydown",".searchInvoiceInPos",(function(e){if("Enter"===e.key){$("body").toggleClass("wait");var t=encodeURIComponent($(this).val());BMS.fn.get(`customerPurchaseList&cid=${$("#customersId").val()}&s=${t}`,(e=>{if(""==e)return $("body").toggleClass("wait"),void $("#showPurchaseList ul").html('Sorry! No data found. ');var t="";e.forEach((e=>{"Hold"===e.sales_status?t+=`\n \n ${e.date} (${e.ref})\n ${to_money(e.total)} \n \n Hold \n From: ${e.shop}; Status: ${e.pay_status}\n \n \n `:t+=`\n \n ${e.date} (${e.ref})\n ${to_money(e.total)} \n \n From: ${e.shop}; Status: ${e.pay_status}\n \n \n `})),$("#showPurchaseList ul").html(t),$("body").toggleClass("wait")}))}})),$(document).on("click",".quick-cash",(function(){var e=Number($(this).html());$(".posSalePaymentAmount").val(parseFloat(e).toFixed(2)),BMS.POS.grandTotal()})),$(document).on("hide.bs.modal","#productSaleDetails",(function(){var e=$("#productSaleDetails .rowId").val(),t=$("#productSaleDetails #productSaleItemPrice").val(),a=$("#productSaleDetails #productSaleItemDiscount").val(),o=$("#productSaleDetails #productSaleItemPacket").val(),n=$("#productSaleDetails #productSaleItemDetails").val(),s=$("tr#"+e);s.find(".netSalesPrice").val(t);var r=BMS.FUNCTIONS.calculateDiscount(t,a),l="";if(Number(r)===Number(t))l=parseFloat(t).toFixed(2);else l=""+r+" "+parseFloat(t).toFixed(2)+" ";s.find(".displayProductPrice").html(l),s.find(".productDiscount").val(a),s.find(".productItemDetails").val(n),s.find(".productPacket").val(o),s.find(".subtotalCol").html(r*s.find(".productQnt").val()),BMS.POS.grandTotal()})),$(document).on("focus",".productQnt",(function(){$(this)[0].scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})})),$(document).on("change","#ReturnMoney",(function(){$("#ReturnMoney").is(":checked")?$(".returnAmountAccountsDiv").show():$(".returnAmountAccountsDiv").hide()})),$(document).on("submit","#accountsLedgerForm",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=ledgers&page=accountsLedger&account_id="+$("#accountSelection").val()+"&dateRange="+$("#accountsLedgerDateRange").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load(),$.post(full_website_address+"/info/?module=data&page=getAccountsInfo",{accountsId:$("#accountSelection").val()},(function(e,t){var a=JSON.parse(e);$("#accountsName").html(a.name),$("#accountsBalance").html(tsd(a.balance)),$("#accountsLedgerDates").html($("#accountsLedgerDateRange").val())}))})),$(document).on("submit","#employeeLedgerForm",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=ledgers&page=employeeLedger&emp_id="+$("#employeeSelection").val()+"&dateRange="+$("#employeeLedgerDateRange").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load(),$.post(full_website_address+"/info/?module=data&page=getEmpSalaryData",{empId:$("#employeeSelection").val()},(function(e,t){var a=JSON.parse(e),o=Number(a.emp_payable_salary)+Number(a.emp_payable_overtime)+Number(a.emp_payable_bonus);$("#salaryInfo > tbody > tr > td:nth-child(1)").html(tsd(a.emp_payable_salary)),$("#salaryInfo > tbody > tr > td:nth-child(2)").html(tsd(a.emp_payable_overtime)),$("#salaryInfo > tbody > tr > td:nth-child(3)").html(tsd(a.emp_payable_bonus)),$("#salaryInfo > tbody > tr > td:nth-child(4)").html(tsd(o)),$("#employeeName").html(a.emp_firstname+" "+a.emp_lastname),$("#accountsLedgerDates").html($("#employeeLedgerDateRange").val())}))})),$(document).on("submit","#journalLedgerForm",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=ledgers&page=journalLedger&journal_id="+$("#journalSelection").val()+"&dateRange="+$("#journalLedgerDateRange").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load()})),$(document).on("submit","#customerLedgerForm",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=ledgers&page=customerLedger&customer_id="+$("#customerSelection").val()+"&dateRange="+$("#customerLedgerDateRange").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load()})),$(document).on("submit","#companyLedgerForm",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=ledgers&page=companyLedger&company_id="+$("#companySelection").val()+"&dateRange="+$("#companyLedgerDateRange").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load()})),$(document).on("submit","#advancePaymentLedgerForm",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=ledgers&page=advancePaymentLedger&emp_id="+$("#employeeSelection").val()+"&dateRange="+$("#advancePaymentLedgerDateRange").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load()})),$(document).on("submit","#productLedgerForm",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=reports&page=productLedger&pid="+$("#productSelection").val()+"&wid="+$("#warehouseSelection").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load()})),$(document).on("submit","#customerStatementReport",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=reports&page=customerStatement&cid="+$("#customerSelection").val()+"&dateRange="+$("#customerStatementDateRange").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load(),$.post(full_website_address+"/info/?module=data&page=getCustomerStatementInfo",{customerId:$("#customerSelection").val(),dateRange:$("#customerStatementDateRange").val()},(function(e,t){var a=JSON.parse(e),o=Number(a.net_purchased)-(Number(a.total_product_returns)+Number(a.total_purchased_discount)),n=Number(a.advance_payments_amount)+Number(a.received_payments_amount)+Number(a.sales_payments_amount),s=n+Number(a.previous_balance)+Number(a.total_given_bonus)+Number(a.special_discounts_amount)-(o+Number(a.total_shipping)+Number(a.payments_return_amount));$("#paymentInfo > tbody > tr:nth-child(1) > td:nth-child(2)").html(tsd(a.net_purchased)),$("#paymentInfo > tbody > tr:nth-child(2) > td:nth-child(2)").html(tsd(a.total_purchased_discount)),$("#paymentInfo > tbody > tr:nth-child(3) > td:nth-child(2)").html(tsd(a.total_shipping)),$("#paymentInfo > tbody > tr:nth-child(4) > td:nth-child(2)").html(tsd(a.total_product_returns)),$("#paymentInfo > tbody > tr:nth-child(5) > td:nth-child(2)").html(tsd(o)),$("#paymentInfo > tbody > tr:nth-child(1) > td:nth-child(4)").html(tsd(a.sales_payments_amount)),$("#paymentInfo > tbody > tr:nth-child(2) > td:nth-child(4)").html(tsd(a.received_payments_amount)),$("#paymentInfo > tbody > tr:nth-child(3) > td:nth-child(4)").html(tsd(a.advance_payments_amount)),$("#paymentInfo > tbody > tr:nth-child(5) > td:nth-child(4)").html(tsd(n)),$("#paymentInfo > tbody > tr:nth-child(1) > td:nth-child(6)").html(tsd(a.previous_balance)),$("#paymentInfo > tbody > tr:nth-child(2) > td:nth-child(6)").html(tsd(a.total_given_bonus)),$("#paymentInfo > tbody > tr:nth-child(3) > td:nth-child(6)").html(tsd(a.special_discounts_amount)),$("#paymentInfo > tbody > tr:nth-child(4) > td:nth-child(6)").html(tsd(a.payments_return_amount)),$("#paymentInfo > tbody > tr:nth-child(5) > td:nth-child(6)").html(tsd(s)),$("#customerName").html(a.customer_name),$("#customerAddress").html(a.customer_address+", "+a.district_name),$("#customerStatementDates").html($("#customerStatementDateRange").val())}))})),$(document).on("submit","#locationWiseSaleReort",(function(e){e.preventDefault();var t=full_website_address+"/xhr/?module=reports&page=locationWiseSalesReport&pid="+$("#selectProductForLocationReport").val()+"&location="+$("#selectLocation").val();$("#dataTableWithAjaxExtend").DataTable().ajax.url(t).load()})),$(document).on("change","#paymentEmployee, #dontAdujctAdvance, .paymentsType",(function(){var e=$(this);$.post("/info/?module=data&page=getEmpSalaryData",{empId:$("#paymentEmployee").val()},(function(t,a){$("#dontAdjustAdvance").is(":checked");var o=JSON.parse(t),n=Number(o.emp_payable_salary)+Number(o.emp_payable_overtime)+Number(o.emp_payable_bonus),s="Last taken loan: "+tsd(o.loan_amount)+"; Paid: "+tsd(o.loan_installment_paid_amount)+"; Monthly:"+tsd(o.loan_installment_amount);$("#salaryInfo > tbody > tr > td:nth-child(1)").html(tsd(o.emp_payable_salary)),$("#salaryInfo > tbody > tr > td:nth-child(2)").html(tsd(o.emp_payable_overtime)),$("#salaryInfo > tbody > tr > td:nth-child(3)").html(tsd(o.emp_payable_bonus)),$("#salaryInfo > tbody > tr > td:nth-child(4)").html(tsd(n)),$("#salaryInfo > tfoot > tr:nth-child(1) > th").html(s);var r=$(e).val();"Salary"==r?$(e).closest(".row").find(".paymentAmount").val(Number(o.emp_payable_salary).toFixed(0)):"Overtime"==r?$(e).closest(".row").find(".paymentAmount").val(Number(o.emp_payable_overtime).toFixed(0)):"Bonus"==r?$(e).closest(".row").find(".paymentAmount").val(Number(o.emp_payable_bonus).toFixed(0)):"Advance Salary"==r?$(e).closest(".row").find(".paymentAmount").val(0):$(".paymentAmount").val(Number(o.emp_payable_salary).toFixed(0))}))})),$(document).on("change","#paymentMethods",(function(){"Cheque"==$("#paymentMethods").val()?$("#hiddenItem").css("display","block"):$("#hiddenItem").css("display","none")})),$(document).off("click","#addSalaryPaymentRow"),$(document).on("click","#addSalaryPaymentRow",(function(){$("#salaryPaymentRow").append('')})),$(document).on("click",".removeSalaryPaymentRow",(function(){$(this).closest(".row").css("background-color","whitesmoke").hide("slow",(function(){$(this).closest(".row").remove()}))})),$(document).on("focusin",".datePicker",(function(){BMS.FUNCTIONS.datePicker()})),$(document).on("focusin",".dateTimePicker",(function(){BMS.FUNCTIONS.datePicker({selector:this,format:"YYYY-MM-DD HH:mm",timePicker:!0})})),$(document).on("focusin",".dateRangePicker",(function(){BMS.FUNCTIONS.dateRangePicker()})),$(document).on("focusin",".dateTimeRangePicker",(function(){BMS.FUNCTIONS.dateRangePicker({selector:this,format:"YYYY-MM-DD HH:mm",timePicker:!0})})),$(document).on("focusin",".dateRangePickerPreDefined",(function(){BMS.FUNCTIONS.dateRangePickerPreDefined()})),$(document).on("focusin",".dateTimeRangePickerPreDefined",(function(){BMS.FUNCTIONS.dateRangePickerPreDefined({selector:this,format:"YYYY-MM-DD HH:mm",timePicker:!0})})),$(document).on("focusin",".multiDatePicker",(function(){BMS.FUNCTIONS.multiDatePicker()})),$(document).on("change",".imageToUpload",(function(){var e=$(this).closest(".imageContainer").find(".photoErrorMessage");$(e).empty();var t=this.files[0],a=t.type,o=t.size;if(!1===["image/jpeg","image/png","image/jpg"].includes(a))return $(e).length<1?(BMS.fn.alertError(""),this.value=this.defaultValue):$(e).html("
"),!1;if("""),this.value=this.defaultValue):$(e).html("
"),!1;var n=$(this).val().replace(/\\/g,"/").replace(/.*\//,"");$(this).closest(".imageContainer").find(".imageNameShow").val(n);var s=$(this),r=new FileReader;r.onload=function(e){$(s).css("color","green"),$(s).closest(".imageContainer").find(".image_preview").css("display","block"),$(s).closest(".imageContainer").find(".previewing").attr("src",e.target.result)},r.readAsDataURL(this.files[0])})),$(document).on("click","#addPosSalePaymentRow",(function(){$(".paymentMethodBox").append('\n
\n Amount \n \n \n
\n
\n Reference/Info \n \n
\n
\n Bank Account \n \n .... \n \n
\n
\n Payment Method \n \n \n \n \n \n \n \n
\n
')})),$(document).on("click",".removePosPaymentItem",(function(){$(this).closest(".row").remove(),BMS.POS.grandTotal()})),$(document).on("change",".posSalePaymentMethod",(function(){"Cash"===$(this).val()?$(this).closest(".row").find(".posSalePaymentBankAccount").hide():$(this).closest(".row").find(".posSalePaymentBankAccount").show()})),$(document).on("submit","#modalForm, #popUpForm, #jqFormAdd, #jqFormUpdate",(function(e){e.preventDefault(),ajaxFormSubmit(this)})),$(document).on("submit","#inlineForm",(function(e){e.preventDefault(),ajaxFormSubmit(this,!0)})),$(document).on("click",".deleteEntry",(function(e){e.preventDefault();var t=$(this).attr("href"),a=$(this).attr("data-to-be-deleted"),o=$(this).attr("removeParent"),n=this;Swal.fire({title:"Are you sure to delete this entry?",icon:"warning",didOpen:function(){BMS.fn.play("warning")},showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"Yes, delete it!"}).then((e=>{e.value&&$.post(t,{datatoDelete:a},(function(e,t){if(isJson(e)){var a=JSON.parse(e);for(var s in a)sweetAlert[s]=a[s]}Swal.fire({toast:sweetAlert.toast,position:sweetAlert.position,timer:sweetAlert.timer,showConfirmButton:sweetAlert.showConfirmButton,showCloseButton:sweetAlert.showCloseButton,icon:sweetAlert.icon,title:sweetAlert.title,text:sweetAlert.text,onClose:$("body").css("padding","0px")}),void 0!==o&&$(n).closest(o).hide("fast"),$("#dataTableWithAjax").DataTable().ajax.reload(null,!1),$("#dataTableWithAjaxExtend").DataTable().ajax.reload(null,!1)}))}))})),$(document).on("click",".updateEntry",(function(e){e.preventDefault();var t=$(this).attr("href"),a=$(this).attr("data-to-be-updated");$(this).css("color","black"),$(this).find("i.fa").addClass("fa-spin"),$.post(t,{datatoUpdate:a},(function(e,t){if(isJson(e)){var a=JSON.parse(e);for(var o in a)sweetAlert[o]=a[o]}Swal.fire({toast:sweetAlert.toast,position:sweetAlert.position,timer:sweetAlert.timer,showConfirmButton:sweetAlert.showConfirmButton,showCloseButton:sweetAlert.showCloseButton,icon:sweetAlert.icon,title:sweetAlert.title,text:sweetAlert.text,onClose:$("body").css("padding","0px")}),$("#dataTableWithAjax").DataTable().ajax.reload(null,!1),$("#dataTableWithAjaxExtend").DataTable().ajax.reload(null,!1)}))})),$(document).on("dblclick","iledit",(function(e){e.preventDefault();var t=$(this),a=t.closest("td"),o=t.closest("table").find("th").eq(a.index()),n=t.closest("tr").find("pkey").text(),s=o.attr("type"),r=o.attr("data-source"),l=o.attr("data-options"),i=o.attr("where-to-update"),c=t.attr("data-val"),d=t.text(),u=a.width();if("select2"===s){a.html(`\n \n .... \n \n `);var m=a.find(".select2InlineEdit");BMS.fn.select2(m,c,d),m.select2("open")}else if("select"===s){(l=l.split(",")).forEach((function(e){l+=`${e} `})),a.html(`\n \n ${l}\n \n `),(m=a.find("select")).select2(),m.select2("open")}else a.html(`\n \n `),"datePicker"===s&&(a.find("input").addClass("datePicker"),a.find(".datePicker").focus());a.find("input, select, textarea").on("enter blur clear apply.daterangepicker, select2:close",(function(){var e=["select2","select"].includes(s)?c:d,t=$(this).val(),o=$(this);t!==e?$.post(i,{pkey:n,newData:t},(function(e,t){void 0!==(e=JSON.parse(e)).error&&"true"===e.error?BMS.fn.alertError(e.msg):(BMS.fn.alertSuccess("The data has been successfully updated."),"select2"===s||"select"===s?a.html(""+$("option:selected",o).html()+" "):a.html(""+$(o).val()+" "))})):"select2"===s||"select"===s?(console.log($("option:selected",o).html()),a.html(""+$("option:selected",o).html()+" ")):a.html(""+$(o).val()+" ")}))})),$(document).on("hidden.bs.modal",(function(e){$(e.target).removeData("bs.modal").find(".modal-ajax").html("")})),$(document).ready((function(){$(document).on("mouseenter focus",".select2Ajax",(function(){BMS.fn.select2(this)}))})),$(document).ready((function(){$("body").tooltip({selector:'[data-toggle="tooltip"]'})})),$(document).click((function(e){$(".dropdown-menu[data-parent]").hide()})),$(document).on("click",'.col-sm-12 [data-toggle="dropdown"]',(function(){if($("body").hasClass("modal-open"))throw new Error("This solution is not working inside a responsive table inside a modal, you need to find out a way to calculate the modal Z-index and add it to the element");if($buttonGroup=$(this).parent(),$buttonGroup.attr("data-attachedUl"))$ul=$("[data-parent="+$buttonGroup.attr("data-attachedUl")+"]");else{var e=+new Date;$ul=$(this).siblings("ul"),$ul.attr("data-parent",e),$buttonGroup.attr("data-attachedUl",e),$(window).resize((function(){$ul.css("display","none").data("top")}))}var t,a,o;$buttonGroup.hasClass("open")?(t=$(this).parent(),a=$ul,o=t.offset().top+t.outerHeight(),a.css("top",o+"px"),a.css("left",t.offset().left-100+"px"),a.css("position","absolute"),a.css("width",a.width()),a.css("heigt",a.height()),a.css("display","block"),a.appendTo(".dynamic-container")):$ul.css("display","none")})),$(document).on("click",".restricted",(function(){Swal.fire({title:"Sorry!",text:"You have no permission to perform this action",icon:"error"})})),$(".modal").on("show.bs.modal",(function(e){if(-1!==$.inArray("restricted",e.target.classList))return e.preventDefault()})),$(".modal").on("shown.bs.modal",(function(){$(this).find("[autofocus]").focus()})),$("form").on("focus","input[type=number]",(function(e){$(this).on("wheel.disableScroll",(function(e){e.preventDefault()}))})),$("form").on("blur","input[type=number]",(function(e){$(this).off("wheel.disableScroll")}));var sweetAlert=[];sweetAlert.title="The command has been executed successfully.",sweetAlert.text="",sweetAlert.icon="success",sweetAlert.toast=!0,sweetAlert.position="top",sweetAlert.timer=5e3,sweetAlert.showConfirmButton=!1,sweetAlert.showCloseButton=!1,$('input[type="checkbox"].square, input[type="radio"].square').iCheck({checkboxClass:"icheckbox_square-blue",radioClass:"iradio_square-blue"}),$.ajaxSetup({beforeSend:function(e){e.setRequestHeader("X-CSRF-TOKEN",xCsrfToken)}});var getPageTitle=JSON.parse('');$(window).bind("popstate",(function(e){"undefined"!=typeof session&&(session.terminate(),phone.stop()),e.preventDefault(),$.get(location.href+"?contentOnly=true",(function(e,t){defaultiDisplayLength="",$("li").removeClass("active");var a=location.href,o="Not Found!";void 0!==getPageTitle[a]&&(o=getPageTitle[a]),window.document.title=o,$(".dynamic-container").html(e),jQuery.get(full_website_address+"/assets/js/initiator.min.js")}))})),$(document).on("keydown",(function(e){"F2"===e.key&&($("#selectProduct, #selectPosProduct, #selectStockTransferProduct, #selectStockEntryProduct").hasClass("select2-hidden-accessible")||BMS.fn.select2("#selectProduct, #selectPosProduct, #selectStockTransferProduct, #selectStockEntryProduct"),$("#selectProduct, #selectPosProduct, #selectStockTransferProduct, #selectStockEntryProduct").select2("open")),"F3"===e.key&&(e.preventDefault(),$("#orderDiscount").modal("show"))})),$(document).on("click",".toggleNotButton",(function(){var e=$(this).closest("span").find(".notThisValueFilter");"="===$(e).val()?($(e).val("!="),$(this).text("|")):($(this).text(""),$(e).val("="))})),$(document).on("click",".stopPropagation",(function(e){e.stopPropagation()})),$(document).on("change","#productType",(function(){$("#productVariationSection").hide(),$("#bundleProductsContainer").hide(),$(".bundleProduct").hide(),$(".groupedProduct").hide();"Variable"===this.value?$("#productVariationSection").show():"Bundle"===this.value?($(".bundleProduct").show(),$("#bundleProductsContainer").show()):"Grouped"===this.value&&($(".groupedProduct").show(),$("#bundleProductsContainer").show())})),$(document).on("click",".removeThisVariation",(function(e){if(e.stopPropagation(),confirm("Are sure to remove this variation?")){var t=$(this).closest("li").find(".variation_product_id").val();$(this).closest("li").hide("fast",(function(){$(this).remove()})),void 0!==t&&$.ajax({url:full_website_address+"/xhr/?module=products&page=deleteVariationProduct",type:"post",data:{product_id:t},success:function(e,t){}})}})),$(document).on("click","#setVariationPrice",(function(){setVariationPrice()})),$(window).keydown((function(e){if(13==e.keyCode&&$("#productVariationPrice").hasClass("in"))return e.preventDefault(),setVariationPrice(),$("#productVariationPrice").modal("hide"),!1})),$("#browseProduct").on("show.bs.modal",(function(e){BMS.PRODUCT.showProduct()})),$(document).on("change","#productHasExpiryDate",(function(){"1"===this.value?$(".productIntitalStock").prop("disabled",!0):$(".productIntitalStock").prop("disabled",!1)}));let barCcode="";$(document).on("keypress",(e=>{if("Enter"===e.key){var t="input"!==e.target.tagName.toLowerCase();""!==barCcode&&(isPosPage&&t?BMS.POS.addProduct(barCcode,!0):isPurchasePage&&t?BMS.PURCHASE.addProduct(barCcode,!0):isTransferStockPage&&t?BMS.STOCK_TRANSFER.addProduct(barCcode,!0):isProductReturnPage&&t?BMS.RETURN.addProduct(barCcode,!0):isStockEntryPage&&t?BMS.STOCK_ENTRY.addProduct(barCcode,!0):isAddProductPage&&$("#productCode").val(barCcode)),barCcode=""}else barCcode+=e.key})),$(document).on("click",".copyThis",(function(e){navigator.clipboard.writeText($(this).text())}));
\ No newline at end of file
diff --git a/core/ajax/ajax_data.php b/core/ajax/ajax_data.php
index be0cce4..d13aaa5 100644
--- a/core/ajax/ajax_data.php
+++ b/core/ajax/ajax_data.php
@@ -777,7 +777,7 @@
loan_ids, sum(loan_installment_paying_amount) as loan_installment_paid_amount
from {$table_prefix}loan_installment where is_trash = 0 group by loan_ids
) as loan_installment on loan_id = loan_ids
- where emp_id = {$emp_id}
+ where emp_id = '{$emp_id}'
order by loan_id
desc limit 1"
)["data"][0];
@@ -824,7 +824,7 @@
sum(payments_return_amount) as payments_return_amount
from {$table_prefix}payments_return where is_trash = 0 and payments_return_type = 'Outgoing' group by payments_return_customer_id
) as payment_return on customer_id = payments_return_customer_id
- where customer_id = {$customer_id}"
+ where customer_id = '{$customer_id}'"
)["data"][0];
echo json_encode($customerPaymentsData);
@@ -896,7 +896,7 @@
where is_trash = 0 and payments_return_type = 'Outgoing' and date(payments_return_date) between '{$dateRange[0]}' and '{$dateRange[1]}'
group by payments_return_customer_id
) as payment_return on customer_id = payments_return_customer_id
- where customer_id = {$customer_id}"
+ where customer_id = '{$customer_id}'"
)["data"][0];
$customerPaymentsData["previous_balance"] = easySelectD("
@@ -935,7 +935,7 @@
where is_trash = 0 and payments_return_type = 'Outgoing' and date(payments_return_date) < '{$dateRange[0]}'
group by payments_return_customer_id
) as payment_return on customer_id = payments_return_customer_id
- where customer_id = {$customer_id}
+ where customer_id = '{$customer_id}'
")["data"][0]["previous_balance"];
echo json_encode($customerPaymentsData);
@@ -962,18 +962,18 @@
left join (select
loan_ids,
1 as thisMonthInstallmentPayingStatus
- from {$table_prefix}loan_installment where is_trash = 0 and MONTH(loan_installment_date) = {$month} and year(loan_installment_date) = {$year} group by loan_ids
+ from {$table_prefix}loan_installment where is_trash = 0 and MONTH(loan_installment_date) = '{$month}' and year(loan_installment_date) = '{$year}' group by loan_ids
) as thisMonthStatus on loan_id = thisMonthStatus.loan_ids
- where loan.is_trash = 0 and loan_borrower = {$emp_id} and loan_installment_starting_from <= '{$year}-{$month}-01'
+ where loan.is_trash = 0 and loan_borrower = '{$emp_id}' and loan_installment_starting_from <= '{$year}-{$month}-01'
and ( loan_paid_amount is null or loan_paid_amount < loan_amount)"
// loan_paid_amount can be NULL on left join if there is no recrods, for that the is null check.
- // We can also use HAVING cluese without using is null check. But it will raise a error with full_group_by mode.
+ // We can also use HAVING clause without using is null check. But it will raise a error with full_group_by mode.
);
$selectSalary = easySelectA(array(
"table" => "employees",
"fields" => "round(emp_salary, 2) as emp_salary",
- "where" => array("emp_id = {$emp_id}")
+ "where" => array("emp_id = '{$emp_id}'")
))["data"][0]["emp_salary"];
if(!isset($getLoanDetails["data"])) {
@@ -1042,7 +1042,7 @@
sum(payments_return_amount) as payments_return_amount_sum
from {$table_prefix}payments_return where is_trash = 0 group by payments_return_emp_id
) as get_advance_return on payments_return_emp_id = emp_id
- where emp_id = {$emp_id}"
+ where emp_id = '{$emp_id}'"
)["data"][0];
echo json_encode($getEmpAdvancePaymentData);
@@ -1089,7 +1089,7 @@
sum(CASE WHEN is_return = 1 then purchase_due end) as purchase_return_grand_total
from {$table_prefix}purchases where is_trash = 0 group by purchase_company_id
) as purchaseBill on purchaseBill.purchase_company_id = company_id
- where company_id = {$company_id}"
+ where company_id = '{$company_id}'"
)["data"][0];
echo json_encode($getEmpAdvancePaymentData);
@@ -1369,7 +1369,7 @@
if(isset($_GET['page']) and $_GET['page'] == "customerPurchaseList") {
- $invoiceSearch = ( isset($_GET["s"]) and !empty($_GET["s"]) ) ? "and sales_reference like '%{$_GET["s"]}%'" : "";
+ $invoiceSearch = ( isset($_GET["s"]) and !empty($_GET["s"]) ) ? "and sales_reference like '%". safe_input($_GET["s"]) ."%'" : "";
$selectSales = easySelectA(array(
"table" => "sales",
@@ -1542,10 +1542,10 @@
$productCategoryFilter = ( isset($_GET["catId"]) and !empty($_GET["catId"]) ) ? $_GET["catId"] : "";
$productBrandFilter = ( isset($_GET["brand"]) and !empty($_GET["brand"]) ) ? $_GET["brand"] : "";
- $productEditionFilter = ( isset($_GET["edition"]) and !empty($_GET["edition"]) ) ? " AND product.product_edition = '{$_GET["edition"]}'" : " AND product_type != 'Child' ";
+ $productEditionFilter = ( isset($_GET["edition"]) and !empty($_GET["edition"]) ) ? " AND product.product_edition = '". safe_input($_GET["edition"]) ."'" : " AND product_type != 'Child' ";
$productGenericFilter = ( isset($_GET["generic"]) and !empty($_GET["generic"]) ) ? $_GET["generic"] : "";
$productAuthorFilter = ( isset($_GET["author"]) and !empty($_GET["author"]) ) ? $_GET["author"] : "";
- $productTerms = ( isset($_GET["terms"]) and !empty($_GET["terms"]) ) ? " AND product_name like '%{$_GET["terms"]}%'" : "";
+ $productTerms = ( isset($_GET["terms"]) and !empty($_GET["terms"]) ) ? " AND product_name like '%". safe_input($_GET["terms"]) ."%'" : "";
$productSort = ( isset($_GET["sort"]) and !empty($_GET["sort"]) ) ? $_GET["sort"] : "";
$oderBy = array(
@@ -1692,7 +1692,7 @@
if(isset($_GET['page']) and $_GET['page'] == "getChildProductData") {
- $warehouse_filter = empty($_GET["wid"]) ? "" : " = " . safe_input($_GET["wid"]);
+ $warehouse_filter = empty($_GET["wid"]) ? "" : " = '" . safe_input($_GET["wid"]) . "'";
$getChildProductData = easySelectA(array(
"table" => "products as product",
diff --git a/core/ajax/ajax_select2.php b/core/ajax/ajax_select2.php
index 4cef4c1..2441620 100644
--- a/core/ajax/ajax_select2.php
+++ b/core/ajax/ajax_select2.php
@@ -1014,7 +1014,8 @@
"table" => "product_batches",
"fields" => "batch_id, batch_number",
"where" => array(
- "is_trash = 0 and date(batch_expiry_date) >= curdate() and batch_number LIKE '". $search ."%'",
+ "is_trash = 0 and date(batch_expiry_date) >= curdate()",
+ " and batch_number LIKE " => "{$search}%",
" and product_id" => $product_id
),
"limit" => array (
diff --git a/core/functions.php b/core/functions.php
index cc3644d..3cc3e4d 100644
--- a/core/functions.php
+++ b/core/functions.php
@@ -1565,6 +1565,16 @@ function easyUpload(
);
} else {
+
+ // Remove path traversal characters
+ $location = str_replace(
+ array(
+ "./",
+ "../"
+ ),
+ "",
+ $location
+ );
$uploadDir = DIR_UPLOAD . $location;
diff --git a/core/route.php b/core/route.php
index 698a118..f92afbd 100644
--- a/core/route.php
+++ b/core/route.php
@@ -1,6 +1,6 @@
=5.4.2",
+ "ratchet/rfc6455": "^0.3.1",
+ "react/event-loop": ">=0.4",
+ "react/socket": "^1.0 || ^0.8 || ^0.7 || ^0.6 || ^0.5",
+ "symfony/http-foundation": "^2.6|^3.0|^4.0|^5.0|^6.0",
+ "symfony/routing": "^2.6|^3.0|^4.0|^5.0|^6.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.8"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Ratchet\\": "src/Ratchet"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Chris Boden",
+ "email": "cboden@gmail.com",
+ "role": "Developer"
+ },
+ {
+ "name": "Matt Bonneau",
+ "role": "Developer"
+ }
+ ],
+ "description": "PHP WebSocket library",
+ "homepage": "http://socketo.me",
+ "keywords": [
+ "Ratchet",
+ "WebSockets",
+ "server",
+ "sockets",
+ "websocket"
+ ],
+ "support": {
+ "chat": "https://gitter.im/reactphp/reactphp",
+ "issues": "https://github.com/ratchetphp/Ratchet/issues",
+ "source": "https://github.com/ratchetphp/Ratchet/tree/v0.4.4"
+ },
+ "time": "2021-12-14T00:20:41+00:00"
+ },
+ {
+ "name": "evenement/evenement",
+ "version": "v3.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/igorw/evenement.git",
+ "reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/igorw/evenement/zipball/531bfb9d15f8aa57454f5f0285b18bec903b8fb7",
+ "reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^6.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "Evenement": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Igor Wiedler",
+ "email": "igor@wiedler.ch"
+ }
+ ],
+ "description": "Événement is a very simple event dispatching library for PHP",
+ "keywords": [
+ "event-dispatcher",
+ "event-emitter"
+ ],
+ "support": {
+ "issues": "https://github.com/igorw/evenement/issues",
+ "source": "https://github.com/igorw/evenement/tree/master"
+ },
+ "time": "2017-07-23T21:35:13+00:00"
+ },
+ {
+ "name": "guzzlehttp/psr7",
+ "version": "2.4.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/guzzle/psr7.git",
+ "reference": "67c26b443f348a51926030c83481b85718457d3d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/guzzle/psr7/zipball/67c26b443f348a51926030c83481b85718457d3d",
+ "reference": "67c26b443f348a51926030c83481b85718457d3d",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.2.5 || ^8.0",
+ "psr/http-factory": "^1.0",
+ "psr/http-message": "^1.0",
+ "ralouphie/getallheaders": "^3.0"
+ },
+ "provide": {
+ "psr/http-factory-implementation": "1.0",
+ "psr/http-message-implementation": "1.0"
+ },
+ "require-dev": {
+ "bamarni/composer-bin-plugin": "^1.8.1",
+ "http-interop/http-factory-tests": "^0.9",
+ "phpunit/phpunit": "^8.5.29 || ^9.5.23"
+ },
+ "suggest": {
+ "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
+ },
+ "type": "library",
+ "extra": {
+ "bamarni-bin": {
+ "bin-links": true,
+ "forward-command": false
+ },
+ "branch-alias": {
+ "dev-master": "2.4-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "GuzzleHttp\\Psr7\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Graham Campbell",
+ "email": "hello@gjcampbell.co.uk",
+ "homepage": "https://github.com/GrahamCampbell"
+ },
+ {
+ "name": "Michael Dowling",
+ "email": "mtdowling@gmail.com",
+ "homepage": "https://github.com/mtdowling"
+ },
+ {
+ "name": "George Mponos",
+ "email": "gmponos@gmail.com",
+ "homepage": "https://github.com/gmponos"
+ },
+ {
+ "name": "Tobias Nyholm",
+ "email": "tobias.nyholm@gmail.com",
+ "homepage": "https://github.com/Nyholm"
+ },
+ {
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com",
+ "homepage": "https://github.com/sagikazarmark"
+ },
+ {
+ "name": "Tobias Schultze",
+ "email": "webmaster@tubo-world.de",
+ "homepage": "https://github.com/Tobion"
+ },
+ {
+ "name": "Márk Sági-Kazár",
+ "email": "mark.sagikazar@gmail.com",
+ "homepage": "https://sagikazarmark.hu"
+ }
+ ],
+ "description": "PSR-7 message implementation that also provides common utility methods",
+ "keywords": [
+ "http",
+ "message",
+ "psr-7",
+ "request",
+ "response",
+ "stream",
+ "uri",
+ "url"
+ ],
+ "support": {
+ "issues": "https://github.com/guzzle/psr7/issues",
+ "source": "https://github.com/guzzle/psr7/tree/2.4.3"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/GrahamCampbell",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/Nyholm",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-10-26T14:07:24+00:00"
+ },
+ {
+ "name": "marcelog/pami",
+ "version": "v2.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/marcelog/PAMI.git",
+ "reference": "f586d0fcbf7db7952965ccb91e4ed231bd168fb3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/marcelog/PAMI/zipball/f586d0fcbf7db7952965ccb91e4ed231bd168fb3",
+ "reference": "f586d0fcbf7db7952965ccb91e4ed231bd168fb3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3",
+ "psr/log": ">= 1.0.0"
+ },
+ "require-dev": {
+ "codeclimate/php-test-reporter": "dev-master",
+ "evert/phpdoc-md": "~0.1.1",
+ "marcelog/pagi": "2.*",
+ "monolog/monolog": "1.*",
+ "phing/phing": "2.*",
+ "phpdocumentor/phpdocumentor": "2.*",
+ "phpmd/phpmd": "2.*",
+ "phpunit/phpunit": "4.*",
+ "satooshi/php-coveralls": "1.0.1",
+ "sebastian/phpcpd": "*",
+ "squizlabs/php_codesniffer": "2.*"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "PAMI\\": "src/PAMI"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache2"
+ ],
+ "authors": [
+ {
+ "name": "Marcelo Gornstein",
+ "email": "marcelog@gmail.com",
+ "homepage": "http://marcelog.github.com/",
+ "role": "Developer"
+ }
+ ],
+ "description": "Asterisk Manager Interface (AMI) client for PHP, event driven, object oriented",
+ "homepage": "http://marcelog.github.com/PAMI",
+ "keywords": [
+ "action",
+ "ami",
+ "asterisk",
+ "client",
+ "event",
+ "manager",
+ "monitor",
+ "telephony",
+ "voip"
+ ],
+ "support": {
+ "issues": "https://github.com/marcelog/PAMI/issues",
+ "source": "https://github.com/marcelog/PAMI/tree/v2.0.2"
+ },
+ "time": "2017-10-10T18:59:17+00:00"
+ },
+ {
+ "name": "psr/http-factory",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/http-factory.git",
+ "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
+ "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.0.0",
+ "psr/http-message": "^1.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Http\\Message\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interfaces for PSR-7 HTTP message factories",
+ "keywords": [
+ "factory",
+ "http",
+ "message",
+ "psr",
+ "psr-17",
+ "psr-7",
+ "request",
+ "response"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/http-factory/tree/master"
+ },
+ "time": "2019-04-30T12:38:16+00:00"
+ },
+ {
+ "name": "psr/http-message",
+ "version": "1.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/http-message.git",
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
+ "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Http\\Message\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "http://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for HTTP messages",
+ "homepage": "https://github.com/php-fig/http-message",
+ "keywords": [
+ "http",
+ "http-message",
+ "psr",
+ "psr-7",
+ "request",
+ "response"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/http-message/tree/master"
+ },
+ "time": "2016-08-06T14:39:51+00:00"
+ },
+ {
+ "name": "psr/log",
+ "version": "3.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/php-fig/log.git",
+ "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001",
+ "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.0.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Psr\\Log\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "PHP-FIG",
+ "homepage": "https://www.php-fig.org/"
+ }
+ ],
+ "description": "Common interface for logging libraries",
+ "homepage": "https://github.com/php-fig/log",
+ "keywords": [
+ "log",
+ "psr",
+ "psr-3"
+ ],
+ "support": {
+ "source": "https://github.com/php-fig/log/tree/3.0.0"
+ },
+ "time": "2021-07-14T16:46:02+00:00"
+ },
+ {
+ "name": "ralouphie/getallheaders",
+ "version": "3.0.3",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/ralouphie/getallheaders.git",
+ "reference": "120b605dfeb996808c31b6477290a714d356e822"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
+ "reference": "120b605dfeb996808c31b6477290a714d356e822",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.6"
+ },
+ "require-dev": {
+ "php-coveralls/php-coveralls": "^2.1",
+ "phpunit/phpunit": "^5 || ^6.5"
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "src/getallheaders.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Ralph Khattar",
+ "email": "ralph.khattar@gmail.com"
+ }
+ ],
+ "description": "A polyfill for getallheaders.",
+ "support": {
+ "issues": "https://github.com/ralouphie/getallheaders/issues",
+ "source": "https://github.com/ralouphie/getallheaders/tree/develop"
+ },
+ "time": "2019-03-08T08:55:37+00:00"
+ },
+ {
+ "name": "ratchet/rfc6455",
+ "version": "v0.3.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/ratchetphp/RFC6455.git",
+ "reference": "7c964514e93456a52a99a20fcfa0de242a43ccdb"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/ratchetphp/RFC6455/zipball/7c964514e93456a52a99a20fcfa0de242a43ccdb",
+ "reference": "7c964514e93456a52a99a20fcfa0de242a43ccdb",
+ "shasum": ""
+ },
+ "require": {
+ "guzzlehttp/psr7": "^2 || ^1.7",
+ "php": ">=5.4.2"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^5.7",
+ "react/socket": "^1.3"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Ratchet\\RFC6455\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Chris Boden",
+ "email": "cboden@gmail.com",
+ "role": "Developer"
+ },
+ {
+ "name": "Matt Bonneau",
+ "role": "Developer"
+ }
+ ],
+ "description": "RFC6455 WebSocket protocol handler",
+ "homepage": "http://socketo.me",
+ "keywords": [
+ "WebSockets",
+ "rfc6455",
+ "websocket"
+ ],
+ "support": {
+ "chat": "https://gitter.im/reactphp/reactphp",
+ "issues": "https://github.com/ratchetphp/RFC6455/issues",
+ "source": "https://github.com/ratchetphp/RFC6455/tree/v0.3.1"
+ },
+ "time": "2021-12-09T23:20:49+00:00"
+ },
+ {
+ "name": "react/cache",
+ "version": "v1.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/reactphp/cache.git",
+ "reference": "d47c472b64aa5608225f47965a484b75c7817d5b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/reactphp/cache/zipball/d47c472b64aa5608225f47965a484b75c7817d5b",
+ "reference": "d47c472b64aa5608225f47965a484b75c7817d5b",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0",
+ "react/promise": "^3.0 || ^2.0 || ^1.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.5 || ^5.7 || ^4.8.35"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "React\\Cache\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Christian Lück",
+ "email": "christian@clue.engineering",
+ "homepage": "https://clue.engineering/"
+ },
+ {
+ "name": "Cees-Jan Kiewiet",
+ "email": "reactphp@ceesjankiewiet.nl",
+ "homepage": "https://wyrihaximus.net/"
+ },
+ {
+ "name": "Jan Sorgalla",
+ "email": "jsorgalla@gmail.com",
+ "homepage": "https://sorgalla.com/"
+ },
+ {
+ "name": "Chris Boden",
+ "email": "cboden@gmail.com",
+ "homepage": "https://cboden.dev/"
+ }
+ ],
+ "description": "Async, Promise-based cache interface for ReactPHP",
+ "keywords": [
+ "cache",
+ "caching",
+ "promise",
+ "reactphp"
+ ],
+ "support": {
+ "issues": "https://github.com/reactphp/cache/issues",
+ "source": "https://github.com/reactphp/cache/tree/v1.2.0"
+ },
+ "funding": [
+ {
+ "url": "https://opencollective.com/reactphp",
+ "type": "open_collective"
+ }
+ ],
+ "time": "2022-11-30T15:59:55+00:00"
+ },
+ {
+ "name": "react/dns",
+ "version": "v1.10.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/reactphp/dns.git",
+ "reference": "a5427e7dfa47713e438016905605819d101f238c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/reactphp/dns/zipball/a5427e7dfa47713e438016905605819d101f238c",
+ "reference": "a5427e7dfa47713e438016905605819d101f238c",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0",
+ "react/cache": "^1.0 || ^0.6 || ^0.5",
+ "react/event-loop": "^1.2",
+ "react/promise": "^3.0 || ^2.7 || ^1.2.1",
+ "react/promise-timer": "^1.9"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.3 || ^4.8.35",
+ "react/async": "^4 || ^3 || ^2"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "React\\Dns\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Christian Lück",
+ "email": "christian@clue.engineering",
+ "homepage": "https://clue.engineering/"
+ },
+ {
+ "name": "Cees-Jan Kiewiet",
+ "email": "reactphp@ceesjankiewiet.nl",
+ "homepage": "https://wyrihaximus.net/"
+ },
+ {
+ "name": "Jan Sorgalla",
+ "email": "jsorgalla@gmail.com",
+ "homepage": "https://sorgalla.com/"
+ },
+ {
+ "name": "Chris Boden",
+ "email": "cboden@gmail.com",
+ "homepage": "https://cboden.dev/"
+ }
+ ],
+ "description": "Async DNS resolver for ReactPHP",
+ "keywords": [
+ "async",
+ "dns",
+ "dns-resolver",
+ "reactphp"
+ ],
+ "support": {
+ "issues": "https://github.com/reactphp/dns/issues",
+ "source": "https://github.com/reactphp/dns/tree/v1.10.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/WyriHaximus",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/clue",
+ "type": "github"
+ }
+ ],
+ "time": "2022-09-08T12:22:46+00:00"
+ },
+ {
+ "name": "react/event-loop",
+ "version": "v1.3.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/reactphp/event-loop.git",
+ "reference": "187fb56f46d424afb6ec4ad089269c72eec2e137"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/reactphp/event-loop/zipball/187fb56f46d424afb6ec4ad089269c72eec2e137",
+ "reference": "187fb56f46d424afb6ec4ad089269c72eec2e137",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35"
+ },
+ "suggest": {
+ "ext-event": "~1.0 for ExtEventLoop",
+ "ext-pcntl": "For signal handling support when using the StreamSelectLoop",
+ "ext-uv": "* for ExtUvLoop"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "React\\EventLoop\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Christian Lück",
+ "email": "christian@clue.engineering",
+ "homepage": "https://clue.engineering/"
+ },
+ {
+ "name": "Cees-Jan Kiewiet",
+ "email": "reactphp@ceesjankiewiet.nl",
+ "homepage": "https://wyrihaximus.net/"
+ },
+ {
+ "name": "Jan Sorgalla",
+ "email": "jsorgalla@gmail.com",
+ "homepage": "https://sorgalla.com/"
+ },
+ {
+ "name": "Chris Boden",
+ "email": "cboden@gmail.com",
+ "homepage": "https://cboden.dev/"
+ }
+ ],
+ "description": "ReactPHP's core reactor event loop that libraries can use for evented I/O.",
+ "keywords": [
+ "asynchronous",
+ "event-loop"
+ ],
+ "support": {
+ "issues": "https://github.com/reactphp/event-loop/issues",
+ "source": "https://github.com/reactphp/event-loop/tree/v1.3.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/WyriHaximus",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/clue",
+ "type": "github"
+ }
+ ],
+ "time": "2022-03-17T11:10:22+00:00"
+ },
+ {
+ "name": "react/promise",
+ "version": "v2.9.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/reactphp/promise.git",
+ "reference": "234f8fd1023c9158e2314fa9d7d0e6a83db42910"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/reactphp/promise/zipball/234f8fd1023c9158e2314fa9d7d0e6a83db42910",
+ "reference": "234f8fd1023c9158e2314fa9d7d0e6a83db42910",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.4.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.36"
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "src/functions_include.php"
+ ],
+ "psr-4": {
+ "React\\Promise\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Jan Sorgalla",
+ "email": "jsorgalla@gmail.com",
+ "homepage": "https://sorgalla.com/"
+ },
+ {
+ "name": "Christian Lück",
+ "email": "christian@clue.engineering",
+ "homepage": "https://clue.engineering/"
+ },
+ {
+ "name": "Cees-Jan Kiewiet",
+ "email": "reactphp@ceesjankiewiet.nl",
+ "homepage": "https://wyrihaximus.net/"
+ },
+ {
+ "name": "Chris Boden",
+ "email": "cboden@gmail.com",
+ "homepage": "https://cboden.dev/"
+ }
+ ],
+ "description": "A lightweight implementation of CommonJS Promises/A for PHP",
+ "keywords": [
+ "promise",
+ "promises"
+ ],
+ "support": {
+ "issues": "https://github.com/reactphp/promise/issues",
+ "source": "https://github.com/reactphp/promise/tree/v2.9.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/WyriHaximus",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/clue",
+ "type": "github"
+ }
+ ],
+ "time": "2022-02-11T10:27:51+00:00"
+ },
+ {
+ "name": "react/promise-timer",
+ "version": "v1.9.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/reactphp/promise-timer.git",
+ "reference": "aa7a73c74b8d8c0f622f5982ff7b0351bc29e495"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/reactphp/promise-timer/zipball/aa7a73c74b8d8c0f622f5982ff7b0351bc29e495",
+ "reference": "aa7a73c74b8d8c0f622f5982ff7b0351bc29e495",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3",
+ "react/event-loop": "^1.2",
+ "react/promise": "^3.0 || ^2.7.0 || ^1.2.1"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35"
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "src/functions_include.php"
+ ],
+ "psr-4": {
+ "React\\Promise\\Timer\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Christian Lück",
+ "email": "christian@clue.engineering",
+ "homepage": "https://clue.engineering/"
+ },
+ {
+ "name": "Cees-Jan Kiewiet",
+ "email": "reactphp@ceesjankiewiet.nl",
+ "homepage": "https://wyrihaximus.net/"
+ },
+ {
+ "name": "Jan Sorgalla",
+ "email": "jsorgalla@gmail.com",
+ "homepage": "https://sorgalla.com/"
+ },
+ {
+ "name": "Chris Boden",
+ "email": "cboden@gmail.com",
+ "homepage": "https://cboden.dev/"
+ }
+ ],
+ "description": "A trivial implementation of timeouts for Promises, built on top of ReactPHP.",
+ "homepage": "https://github.com/reactphp/promise-timer",
+ "keywords": [
+ "async",
+ "event-loop",
+ "promise",
+ "reactphp",
+ "timeout",
+ "timer"
+ ],
+ "support": {
+ "issues": "https://github.com/reactphp/promise-timer/issues",
+ "source": "https://github.com/reactphp/promise-timer/tree/v1.9.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/WyriHaximus",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/clue",
+ "type": "github"
+ }
+ ],
+ "time": "2022-06-13T13:41:03+00:00"
+ },
+ {
+ "name": "react/socket",
+ "version": "v1.12.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/reactphp/socket.git",
+ "reference": "81e1b4d7f5450ebd8d2e9a95bb008bb15ca95a7b"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/reactphp/socket/zipball/81e1b4d7f5450ebd8d2e9a95bb008bb15ca95a7b",
+ "reference": "81e1b4d7f5450ebd8d2e9a95bb008bb15ca95a7b",
+ "shasum": ""
+ },
+ "require": {
+ "evenement/evenement": "^3.0 || ^2.0 || ^1.0",
+ "php": ">=5.3.0",
+ "react/dns": "^1.8",
+ "react/event-loop": "^1.2",
+ "react/promise": "^3 || ^2.6 || ^1.2.1",
+ "react/promise-timer": "^1.9",
+ "react/stream": "^1.2"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35",
+ "react/async": "^4 || ^3 || ^2",
+ "react/promise-stream": "^1.4"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "React\\Socket\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Christian Lück",
+ "email": "christian@clue.engineering",
+ "homepage": "https://clue.engineering/"
+ },
+ {
+ "name": "Cees-Jan Kiewiet",
+ "email": "reactphp@ceesjankiewiet.nl",
+ "homepage": "https://wyrihaximus.net/"
+ },
+ {
+ "name": "Jan Sorgalla",
+ "email": "jsorgalla@gmail.com",
+ "homepage": "https://sorgalla.com/"
+ },
+ {
+ "name": "Chris Boden",
+ "email": "cboden@gmail.com",
+ "homepage": "https://cboden.dev/"
+ }
+ ],
+ "description": "Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP",
+ "keywords": [
+ "Connection",
+ "Socket",
+ "async",
+ "reactphp",
+ "stream"
+ ],
+ "support": {
+ "issues": "https://github.com/reactphp/socket/issues",
+ "source": "https://github.com/reactphp/socket/tree/v1.12.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/WyriHaximus",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/clue",
+ "type": "github"
+ }
+ ],
+ "time": "2022-08-25T12:32:25+00:00"
+ },
+ {
+ "name": "react/stream",
+ "version": "v1.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/reactphp/stream.git",
+ "reference": "7a423506ee1903e89f1e08ec5f0ed430ff784ae9"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/reactphp/stream/zipball/7a423506ee1903e89f1e08ec5f0ed430ff784ae9",
+ "reference": "7a423506ee1903e89f1e08ec5f0ed430ff784ae9",
+ "shasum": ""
+ },
+ "require": {
+ "evenement/evenement": "^3.0 || ^2.0 || ^1.0",
+ "php": ">=5.3.8",
+ "react/event-loop": "^1.2"
+ },
+ "require-dev": {
+ "clue/stream-filter": "~1.2",
+ "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "React\\Stream\\": "src"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Christian Lück",
+ "email": "christian@clue.engineering",
+ "homepage": "https://clue.engineering/"
+ },
+ {
+ "name": "Cees-Jan Kiewiet",
+ "email": "reactphp@ceesjankiewiet.nl",
+ "homepage": "https://wyrihaximus.net/"
+ },
+ {
+ "name": "Jan Sorgalla",
+ "email": "jsorgalla@gmail.com",
+ "homepage": "https://sorgalla.com/"
+ },
+ {
+ "name": "Chris Boden",
+ "email": "cboden@gmail.com",
+ "homepage": "https://cboden.dev/"
+ }
+ ],
+ "description": "Event-driven readable and writable streams for non-blocking I/O in ReactPHP",
+ "keywords": [
+ "event-driven",
+ "io",
+ "non-blocking",
+ "pipe",
+ "reactphp",
+ "readable",
+ "stream",
+ "writable"
+ ],
+ "support": {
+ "issues": "https://github.com/reactphp/stream/issues",
+ "source": "https://github.com/reactphp/stream/tree/v1.2.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/WyriHaximus",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/clue",
+ "type": "github"
+ }
+ ],
+ "time": "2021-07-11T12:37:55+00:00"
+ },
+ {
+ "name": "symfony/deprecation-contracts",
+ "version": "v3.0.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/deprecation-contracts.git",
+ "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/26954b3d62a6c5fd0ea8a2a00c0353a14978d05c",
+ "reference": "26954b3d62a6c5fd0ea8a2a00c0353a14978d05c",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.0.2"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "3.0-dev"
+ },
+ "thanks": {
+ "name": "symfony/contracts",
+ "url": "https://github.com/symfony/contracts"
+ }
+ },
+ "autoload": {
+ "files": [
+ "function.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "A generic function and convention to trigger deprecation notices",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/deprecation-contracts/tree/v3.0.2"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-01-02T09:55:41+00:00"
+ },
+ {
+ "name": "symfony/http-foundation",
+ "version": "v6.0.17",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/http-foundation.git",
+ "reference": "22fe17e40b0481d39212e7165e004eb26422085d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/http-foundation/zipball/22fe17e40b0481d39212e7165e004eb26422085d",
+ "reference": "22fe17e40b0481d39212e7165e004eb26422085d",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.0.2",
+ "symfony/deprecation-contracts": "^2.1|^3",
+ "symfony/polyfill-mbstring": "~1.1"
+ },
+ "require-dev": {
+ "predis/predis": "~1.0",
+ "symfony/cache": "^5.4|^6.0",
+ "symfony/dependency-injection": "^5.4|^6.0",
+ "symfony/expression-language": "^5.4|^6.0",
+ "symfony/http-kernel": "^5.4.12|^6.0.12|^6.1.4",
+ "symfony/mime": "^5.4|^6.0",
+ "symfony/rate-limiter": "^5.2|^6.0"
+ },
+ "suggest": {
+ "symfony/mime": "To use the file extension guesser"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\HttpFoundation\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Defines an object-oriented layer for the HTTP specification",
+ "homepage": "https://symfony.com",
+ "support": {
+ "source": "https://github.com/symfony/http-foundation/tree/v6.0.17"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-12-14T15:52:41+00:00"
+ },
+ {
+ "name": "symfony/polyfill-mbstring",
+ "version": "v1.27.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/polyfill-mbstring.git",
+ "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
+ "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.1"
+ },
+ "provide": {
+ "ext-mbstring": "*"
+ },
+ "suggest": {
+ "ext-mbstring": "For best performance"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.27-dev"
+ },
+ "thanks": {
+ "name": "symfony/polyfill",
+ "url": "https://github.com/symfony/polyfill"
+ }
+ },
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ],
+ "psr-4": {
+ "Symfony\\Polyfill\\Mbstring\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony polyfill for the Mbstring extension",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "compatibility",
+ "mbstring",
+ "polyfill",
+ "portable",
+ "shim"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-11-03T14:55:06+00:00"
+ },
+ {
+ "name": "symfony/routing",
+ "version": "v6.0.17",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/routing.git",
+ "reference": "61687a0aa80f6807c52e116ee64072f6ec53780c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/routing/zipball/61687a0aa80f6807c52e116ee64072f6ec53780c",
+ "reference": "61687a0aa80f6807c52e116ee64072f6ec53780c",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=8.0.2"
+ },
+ "conflict": {
+ "doctrine/annotations": "<1.12",
+ "symfony/config": "<5.4",
+ "symfony/dependency-injection": "<5.4",
+ "symfony/yaml": "<5.4"
+ },
+ "require-dev": {
+ "doctrine/annotations": "^1.12|^2",
+ "psr/log": "^1|^2|^3",
+ "symfony/config": "^5.4|^6.0",
+ "symfony/dependency-injection": "^5.4|^6.0",
+ "symfony/expression-language": "^5.4|^6.0",
+ "symfony/http-foundation": "^5.4|^6.0",
+ "symfony/yaml": "^5.4|^6.0"
+ },
+ "suggest": {
+ "symfony/config": "For using the all-in-one router or any loader",
+ "symfony/expression-language": "For using expression matching",
+ "symfony/http-foundation": "For using a Symfony Request object",
+ "symfony/yaml": "For using the YAML loader"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Routing\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Maps an HTTP request to a set of configuration variables",
+ "homepage": "https://symfony.com",
+ "keywords": [
+ "router",
+ "routing",
+ "uri",
+ "url"
+ ],
+ "support": {
+ "source": "https://github.com/symfony/routing/tree/v6.0.17"
+ },
+ "funding": [
+ {
+ "url": "https://symfony.com/sponsor",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/fabpot",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2022-12-20T16:40:04+00:00"
+ }
+ ],
+ "packages-dev": [],
+ "aliases": [],
+ "minimum-stability": "stable",
+ "stability-flags": [],
+ "prefer-stable": false,
+ "prefer-lowest": false,
+ "platform": [],
+ "platform-dev": [],
+ "plugin-api-version": "2.3.0"
+}
diff --git a/include/lib/Composer/composer.phar b/include/lib/Composer/composer.phar
new file mode 100644
index 0000000..6d799eb
Binary files /dev/null and b/include/lib/Composer/composer.phar differ
diff --git a/module/accounts/ajax.php b/module/accounts/ajax.php
index 2fd72a1..a3a4dd0 100644
--- a/module/accounts/ajax.php
+++ b/module/accounts/ajax.php
@@ -1525,6 +1525,11 @@
}
+ $orderby = "ASC";
+ if($requestData['order'][0]['dir'] === "DESC") {
+ $orderby = "DESC";
+ }
+
$getData = easySelectD(
"select
@@ -1558,8 +1563,8 @@
) as payment_adjustment on pa_company = company_id
where company.is_trash = 0 and company_name like '{$search}%'
- group by company_id order by company_name ". safe_input($requestData['order'][0]['dir']) ."
- LIMIT ". safe_input($requestData['start']) .", ". safe_input($requestData['length']) ."
+ group by company_id order by company_name {$orderby}
+ LIMIT ". intval(safe_input($requestData['start'])) .", ". intval(safe_input($requestData['length'])) ."
"
);
diff --git a/module/customer-support/ajax.php b/module/customer-support/ajax.php
new file mode 100644
index 0000000..653685e
--- /dev/null
+++ b/module/customer-support/ajax.php
@@ -0,0 +1,3133 @@
+ "employees",
+ "fields" => "count(*) as totalRow",
+ "where" => array(
+ "is_trash = 0 and emp_department_id = 2"
+ )
+ ))["data"][0]["totalRow"];
+
+ if($requestData['length'] == -1) {
+ $requestData['length'] = $totalRecords;
+ }
+
+ if(!empty($requestData["search"]["value"])) { // get data with search
+
+ $getData = easySelect(
+ "employees as employee",
+ "emp_id, emp_PIN, emp_firstname, emp_lastname, emp_positions, emp_working_area, emp_contact_number, emp_emergency_contact_number, emp_photo",
+ array(),
+ array (
+ "employee.is_trash = 0 and emp_department_id = 2 and (emp_PIN = '". safe_input($requestData['search']['value']) ."' ",
+ " OR emp_firstname LIKE" => $requestData['search']['value'] . "%",
+ " OR emp_lastname LIKE" => $requestData['search']['value'] . "%",
+ " OR emp_positions LIKE" => $requestData['search']['value'] . "%",
+ " OR emp_working_area LIKE" => $requestData['search']['value'] . "%",
+ " OR emp_contact_number LIKE" => $requestData['search']['value'] . "%",
+ ")"
+ ),
+ array (
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ array (
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ );
+
+ $totalFilteredRecords = $getData ? $getData["count"] : 0;
+
+ } else { // Get data withouth search
+
+ $getData = easySelect(
+ "employees as employee",
+ "emp_id, emp_PIN, emp_firstname, emp_lastname, emp_positions, emp_working_area, emp_contact_number, emp_emergency_contact_number, emp_photo",
+ array(),
+ array("employee.is_trash = 0 and emp_department_id = 2"),
+ array (
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ array (
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ );
+
+ }
+
+ $allData = [];
+ // Check if there have more then zero data
+ if(isset($getData['count']) and $getData['count'] > 0) {
+
+ foreach($getData['data'] as $key => $value) {
+ $allNestedData = [];
+ $allNestedData[] = "";
+ $allNestedData[] = $value["emp_PIN"];
+ $allNestedData[] = empty($value['emp_photo']) ? " " : " ";
+ $allNestedData[] = "{$value["emp_firstname"]} {$value["emp_lastname"]}, {$value["emp_positions"]}";
+ $allNestedData[] = $value["emp_working_area"];
+ $allNestedData[] = $value["emp_contact_number"];
+
+ $allData[] = $allNestedData;
+ }
+ }
+
+
+ $jsonData = array (
+ "draw" => intval( $requestData['draw'] ),
+ "recordsTotal" => intval( $totalRecords ),
+ "recordsFiltered" => intval( $totalFilteredRecords ),
+ "data" => $allData
+ );
+
+ // Encode in Json Formate
+ echo json_encode($jsonData);
+
+}
+
+
+/*************************** Product List ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "productList") {
+
+ $requestData = $_REQUEST;
+
+ $getData = [];
+
+ // List of all columns name
+ $columns = array(
+ "",
+ "product_name",
+ "product_edition",
+ "category_name",
+ "product_sale_price",
+ "product_description"
+ );
+
+ // Count Total recrods
+ $totalFilteredRecords = $totalRecords = easySelectA(array(
+ "table" => "products",
+ "fields" => "count(*) as totalRow",
+ "where" => array(
+ "is_trash = 0 and product_type != 'Child'"
+ )
+ ))["data"][0]["totalRow"];
+
+ if($requestData['length'] == -1) {
+ $requestData['length'] = $totalRecords;
+ }
+
+ if(!empty($requestData["search"]["value"]) or !empty($requestData["columns"][2]['search']['value']) or !empty($requestData["columns"][3]['search']['value'])) { // get data with search
+
+ $getData = easySelect(
+ "products as product",
+ "product_name, product_description, round(product_sale_price, 2) as product_sale_price, category_name, product_edition",
+ array (
+ "left join {$table_prefix}product_category on product_category_id = category_id"
+ ),
+ array (
+ "product.is_trash = 0 and (product_name LIKE '". safe_input($requestData['search']['value']) ."%' ",
+ " OR category_name LIKE" => $requestData['search']['value'] . "%",
+ ")",
+ " AND product_category_id" => $requestData["columns"][3]['search']['value'],
+ " AND product_edition" => $requestData["columns"][2]['search']['value']
+ ),
+ array (
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ array (
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ );
+
+ $totalFilteredRecords = $getData ? $getData["count"] : 0;
+
+ } else { // Get data withouth search
+
+ $getData = easySelect(
+ "products as product",
+ "product_name, product_description, round(product_sale_price, 2) as product_sale_price, category_name, product_edition",
+ array (
+ "left join {$table_prefix}product_category on product_category_id = category_id"
+ ),
+ array("product.is_trash = 0 and product_type != 'Child'"),
+ array (
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ array (
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ );
+
+ }
+
+ $allData = [];
+ // Check if there have more then zero data
+ if(isset($getData['count']) and $getData['count'] > 0) {
+
+ foreach($getData['data'] as $key => $value) {
+ $allNestedData = [];
+ $allNestedData[] = "";
+ $allNestedData[] = $value["product_name"] . " Price: " . $value["product_sale_price"];
+ $allNestedData[] = $value["product_edition"];
+ $allNestedData[] = $value["category_name"];
+ $allNestedData[] = $value["product_description"];
+
+ $allData[] = $allNestedData;
+ }
+ }
+
+
+ $jsonData = array (
+ "draw" => intval( $requestData['draw'] ),
+ "recordsTotal" => intval( $totalRecords ),
+ "recordsFiltered" => intval( $totalFilteredRecords ),
+ "data" => $allData
+ );
+
+ // Encode in Json Formate
+ echo json_encode($jsonData);
+
+}
+
+
+/*************************** getCallerDetails ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "getCallerDetails") {
+
+ $caller = str_replace("+88", "", safe_input($_POST["caller"]) );
+
+ $callerData = easySelectD("
+ SELECT
+ person_full_name as name,
+ person_type as type,
+ person_address as address,
+ concat(person_designation, ', ', institute_name) as designation
+ FROM {$table_prefix}persons
+ left join {$table_prefix}institute on institute_id = person_institute
+ WHERE person_phone like '%{$caller}'
+ UNION ALL
+ SELECT
+ customer_name as name,
+ 'Library/ Customer' as type,
+ customer_address as address,
+ customer_type as designation
+ FROM {$table_prefix}customers
+ WHERE customer_phone like '%{$caller}'
+ UNION ALL
+ SELECT
+ concat(emp_firstname, ' ', emp_lastname) as name,
+ 'Internal Employees' as type,
+ emp_present_address as address,
+ emp_positions as designation
+ FROM {$table_prefix}employees
+ WHERE emp_contact_number like '%{$caller}'
+ ");
+
+ // Get the last call datetime
+ $lastCall = easySelectA(array(
+ "table" => "calls",
+ "fields" => "call_datetime as lastCall, concat(emp_firstname, ' ', emp_lastname) as agent_name, call_status, ( select count(call_id) from {$table_prefix}calls where client_identity like '%{$caller}' ) as callCount ",
+ "join" => array(
+ "left join {$table_prefix}users on representative = user_id",
+ "left join {$table_prefix}employees on user_emp_id = emp_id",
+ ),
+ "where" => array(
+ "client_identity like '%{$caller}'"
+ ),
+ "orderby" => array(
+ "call_id" => "DESC"
+ ),
+ "limit" => array(
+ "start" => 0,
+ "length" => 1,
+ )
+ ));
+
+
+ $callerDetails = array(
+ "details" => array(),
+ "lastCallTime" => "",
+ "totalCallCount" => 0,
+ "agentName" => "",
+ "call_status" => ""
+ );
+
+ if($lastCall !== false) {
+ $callerDetails["lastCallTime"] = $lastCall["data"][0]["lastCall"];
+ $callerDetails["call_status"] = $lastCall["data"][0]["call_status"];
+ $callerDetails["agentName"] = $lastCall["data"][0]["agent_name"];
+ $callerDetails["totalCallCount"] = $lastCall["data"][0]["callCount"];
+ }
+
+
+ if($callerData !== false) {
+
+ $callerDetails["details"] = $callerData["data"][0];
+
+ }
+
+ echo json_encode($callerDetails);
+
+}
+
+
+/*************************** getCallerDetails ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "getCallerAllDetails") {
+
+ $caller = str_replace("+88", "", safe_input($_POST["caller"]) );
+
+ $callerData = easySelectD("
+ SELECT
+ person_id as id,
+ 1 as has_sc,
+ '/xhr/?icheck=false&module=marketing&page=editPerson&id=' as editUri,
+ person_full_name as name,
+ person_type as type,
+ CONCAT( COALESCE(person_address, ''), ', ', COALESCE(upazila_name, ''), ', ', COALESCE(district_name, ''), ', ', COALESCE(division_name, '') ) as address,
+ concat( if(person_designation is null, '', person_designation) , ', ', if(institute_name is null, '', institute_name) ) as designation
+ FROM {$table_prefix}persons
+ left join {$table_prefix}institute on institute_id = person_institute
+ left join {$table_prefix}districts on district_id = person_district
+ left join {$table_prefix}divisions on division_id = person_division
+ left join {$table_prefix}upazilas on upazila_id = person_upazila
+ WHERE person_phone like '%{$caller}'
+ UNION ALL
+ SELECT
+ customer_id as id,
+ 0 as has_sc,
+ '/xhr/?icheck=false&module=peoples&page=editCustomer&id=' as editUri,
+ customer_name as name,
+ 'Library/ Customer' as type,
+ customer_address as address,
+ customer_type as designation
+ FROM {$table_prefix}customers
+ WHERE customer_phone like '%{$caller}'
+ UNION ALL
+ SELECT
+ emp_id as id,
+ 0 as has_sc,
+ '/xhr/?icheck=true&module=peoples&page=editEmployee&id=' as editUri,
+ concat(emp_firstname, ' ', emp_lastname) as name,
+ 'Internal Employees' as type,
+ emp_present_address as address,
+ emp_positions as designation
+ FROM {$table_prefix}employees
+ WHERE emp_contact_number like '%{$caller}'
+ ");
+
+ // Get Call History
+ $getCallHistory = easySelectA(array(
+ "table" => "calls",
+ "fields" => "call_datetime, concat(emp_firstname, ' ', emp_lastname) as agent_name, call_status, call_direction,
+ if(call_reason is null, 'Unknown', call_reason) as call_reason, duration, feedback",
+ "join" => array(
+ "left join {$table_prefix}users on user_id = representative",
+ "left join {$table_prefix}employees on emp_id = user_emp_id",
+ ),
+ "where" => array(
+ "client_identity like '%{$caller}'"
+ ),
+ "orderby" => array(
+ "call_id" => "DESC"
+ ),
+ "limit" => array(
+ "start" => 0,
+ "length" => 5,
+ )
+ ));
+
+
+ $callerDetails = array(
+ "details" => array(),
+ "callHistory" => array(),
+ "totalCallCount" => 0,
+ "smsHistory" => array(),
+ "totalSmsCount" => array(),
+ "caseHistory" => array(),
+ "orderHistory" => array()
+ );
+
+ if($getCallHistory !== false) {
+
+ $callerDetails["callHistory"] = $getCallHistory["data"];
+ $callerDetails["totalCallCount"] = easySelectD("select count(*) as totalCallCount from {$table_prefix}calls where client_identity like '%{$caller}'")["data"][0]["totalCallCount"];
+
+ }
+
+
+ if($callerData !== false) {
+
+ $callerDetails["details"] = $callerData["data"][0];
+
+ }
+
+
+ // Get SMS History
+ $getSmsHistory = easySelectA(array(
+ "table" => "sms_sender as sms",
+ "fields" => "send_time, concat(emp_firstname, ' ', emp_lastname) as agent_name, left(sms_text, 50) as sms_text",
+ "join" => array(
+ "left join {$table_prefix}users on user_id = send_by",
+ "left join {$table_prefix}employees on emp_id = user_emp_id",
+ ),
+ "where" => array(
+ "sms.is_trash = 0 and sms.send_to like '%{$caller}'"
+ ),
+ "orderby" => array(
+ "sms_id" => "DESC"
+ ),
+ "limit" => array(
+ "start" => 0,
+ "length" => 5,
+ )
+ ));
+
+ if($getSmsHistory !== false) {
+
+ $callerDetails["smsHistory"] = $getSmsHistory["data"];
+ $callerDetails["totalSmsCount"] = easySelectD("select count(*) as totalSmsCount from {$table_prefix}sms_sender where send_to like '%{$caller}'")["data"][0]["totalSmsCount"];
+
+ }
+
+
+ $caseHistory = easySelectA(array(
+ "table" => "cases as cases",
+ "fields" => "case_id, case_datetime, case_title, case_status,
+ case_added_by_agent, concat(posted_by_employee.emp_firstname, ' ', posted_by_employee.emp_lastname) as posted_by_name",
+ "join" => array(
+ "left join {$table_prefix}users as posted_user on posted_user.user_id = case_added_by_agent",
+ "left join {$table_prefix}employees as posted_by_employee on posted_by_employee.emp_id = posted_user.user_emp_id",
+ "left join {$table_prefix}persons on person_id = case_person",
+ "left join {$table_prefix}customers on customer_id = case_customer",
+ ),
+ "where" => array(
+ "cases.is_trash = 0 AND (",
+ " customer_phone LIKE" => '%' . $caller,
+ " OR person_phone LIKE" => '%' . $caller,
+ ")"
+ ),
+ "limit" => array(
+ "start" => 0,
+ "length" => 5
+ )
+ ));
+
+ if($caseHistory !== false) {
+ $callerDetails["caseHistory"] = $caseHistory["data"];
+ }
+
+
+ // Select Orders
+ $orderHistory = easySelectA(array(
+ "table" => "sales as sale",
+ "fields" => "sales_id as id, sales_delivery_date as date, sales_status as status, sales_reference as reference, round(sales_grand_total, 2) as total, sales_payment_status as payment_status",
+ "join" => array(
+ "left join {$table_prefix}customers on customer_id = sales_customer_id"
+ ),
+ "where" => array(
+ "sale.is_trash = 0 AND customer_phone LIKE" => '%' . $caller,
+ ),
+ "limit" => array(
+ "start" => 0,
+ "length" => 5
+ )
+ ));
+
+ if($orderHistory !== false) {
+ $callerDetails["orderHistory"] = $orderHistory["data"];
+ }
+
+ echo json_encode($callerDetails);
+
+
+}
+
+
+
+/*************************** get Call history ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "getCallHistoryData") {
+
+ $caller = str_replace("+88", "", safe_input($_POST["caller"]) );
+
+
+ $getCallHistory = easySelectA(array(
+ "table" => "calls",
+ "fields" => "call_datetime, concat(emp_firstname, ' ', emp_lastname) as agent_name, call_status, call_direction,
+ if(call_reason is null, 'Unknown', call_reason) as call_reason, duration, feedback",
+ "join" => array(
+ "left join {$table_prefix}users on user_id = representative",
+ "left join {$table_prefix}employees on emp_id = user_emp_id",
+ ),
+ "where" => array(
+ "client_identity like '%{$caller}'"
+ ),
+ "orderby" => array(
+ "call_id" => "DESC"
+ ),
+ "limit" => array(
+ "start" => 5,
+ "length" => 100,
+ )
+ ));
+
+
+ if( $getCallHistory !== false ) {
+
+ echo json_encode($getCallHistory["data"]);
+
+ } else {
+
+ echo json_encode(array());
+
+ }
+
+
+}
+
+
+
+/*************************** getCallerDetails ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "sendSMS") {
+
+ if(send_sms($_POST["number"], $_POST["text"])) {
+
+ echo "1";
+
+ } else {
+ echo "0";
+ }
+
+}
+
+
+/*************************** getCallerDetails ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "addCallLog") {
+
+ $insertCall = easyInsert(
+ "calls",
+ array(
+ "call_datetime" => date("Y-m-d H:i:s"),
+ "call_direction" => $_POST["direction"] === "incoming" ? "Incoming" : "Outgoing",
+ "call_reason" => "Unknown",
+ "client_identity" => $_POST["caller"],
+ "call_status" => $_POST["status"],
+ "duration" => $_POST["duration"],
+ "feedback" => $_POST["feedback"],
+ "reviewer" => empty($_POST["reviewer"]) ? NULL : $_POST["reviewer"],
+ "representative" => $_SESSION["uid"]
+ ),
+ array(),
+ true
+ );
+
+ if($insertCall !== false) {
+
+ // Update last call time in person list
+ easyUpdate(
+ "persons",
+ array(
+ "last_call_time" => date("Y-m-d H:i:s")
+ ),
+ array(
+ "person_phone" => $_POST["caller"]
+ )
+ );
+
+ echo $insertCall["last_insert_id"];
+
+ }
+
+}
+
+
+/*************************** Representative Call List ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "myCallList") {
+
+ $requestData = $_REQUEST;
+ $getData = [];
+
+ // List of all columns name
+ $columns = array(
+ "",
+ "call_id",
+ "call_direction",
+ "call_status",
+ "client_identity",
+ "duration",
+ "feedback",
+ "representative"
+ );
+
+ // Count Total recrods
+
+ $totalFilteredRecords = $totalRecords = easySelectA(array(
+ "table" => "calls",
+ "fields" => "count(*) as totalRow",
+ "where" => array(
+ "is_trash = 0 and (representative = {$_SESSION["uid"]} or reviewer = {$_SESSION["uid"]} )"
+ )
+ ))["data"][0]["totalRow"];
+
+ if($requestData['length'] == -1) {
+ $requestData['length'] = $totalRecords;
+ }
+
+ if(!empty($requestData["search"]["value"]) or
+ !empty($requestData["columns"][1]['search']['value']) or
+ !empty($requestData["columns"][2]['search']['value']) or
+ !empty($requestData["columns"][3]['search']['value']) or
+ !empty($requestData["columns"][4]['search']['value'])
+ ) { // get data with search
+
+ $dateFilter = "";
+ $specimenDateFilter = "";
+ if(!empty($requestData["columns"][1]['search']['value'])) {
+ $dateRange = explode(" - ", safe_input($requestData["columns"][1]['search']['value']));
+ $dateFilter = "and date(call_datetime) BETWEEN '{$dateRange[0]}' and '{$dateRange[1]}'";
+ $specimenDateFilter = "where date(scd_add_on) BETWEEN '{$dateRange[0]}' and '{$dateRange[1]}'";
+ }
+
+ $search = "";
+ if( !empty($requestData['search']['value']) ) {
+ $search = "and ( person_full_name LIKE '". safe_input($requestData['search']['value']) ."%' or client_identity LIKE '". safe_input($requestData['search']['value']) ."%' ) ";
+ }
+
+ $getData = easySelectA(array(
+ "table" => "calls as calls",
+ "fields" => "call_id, call_datetime, call_direction, call_status, specimen_product_details, person_full_name, person_type, person_address, designation,
+ client_identity, duration, feedback, call_reason",
+ "join" => array(
+ "left join ( select
+ person_full_name,
+ person_type,
+ concat(
+ if(person_address = '', '', concat(person_address, ', ') ),
+ if(upazila_name is null, '', concat(upazila_name, ', ') ),
+ if(district_name is null, '', concat(district_name, ', ') ),
+ if(division_name is null, '', concat(division_name) )
+ ) as person_address,
+ product_details as specimen_product_details,
+ person_phone,
+ concat(if(person_designation is null, person_designation, ''), ', ', institute_name) as designation
+ FROM {$table_prefix}persons
+ left join {$table_prefix}districts on district_id = person_district
+ left join {$table_prefix}divisions on division_id = person_division
+ left join {$table_prefix}upazilas on upazila_id = person_upazila
+ left join {$table_prefix}institute on institute_id = person_institute
+ left join ( select
+ group_concat(product_name, '- ', round(scd_product_qnt, 2) SEPARATOR ' ' ) as product_details,
+ scd_person_id
+ from {$table_prefix}sc_distribution
+ left join {$table_prefix}products on product_id = scd_product_id
+ where is_bundle_item = 0
+ group by scd_person_id
+ ) as specimen_details on scd_person_id = person_id
+ ) as person on person.person_phone = calls.client_identity"
+ ),
+ "where" => array(
+ "calls.is_trash = 0",
+ " AND call_direction" => $requestData["columns"][2]['search']['value'],
+ " AND call_reason" => $requestData["columns"][3]['search']['value'],
+ " AND call_status" => $requestData["columns"][4]['search']['value'],
+ " AND (representative = {$_SESSION["uid"]} or reviewer = {$_SESSION["uid"]} ) $search $dateFilter"
+ ),
+ "orderby" => array(
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "limit" => array(
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ ));
+
+
+ $totalFilteredRecords = $getData ? $getData["count"] : 0;
+
+ } else { // Get data withouth search
+
+
+ $getData = easySelectA(array(
+ "table" => "calls as calls",
+ "fields" => "call_id, call_datetime, call_direction, call_status, specimen_product_details, person_full_name, person_type, person_address, designation,
+ client_identity, duration, feedback, call_reason",
+ "join" => array(
+ "left join ( select
+ person_full_name,
+ person_type,
+ concat(
+ if(person_address = '', '', concat(person_address, ', ') ),
+ if(upazila_name is null, '', concat(upazila_name, ', ') ),
+ if(district_name is null, '', concat(district_name, ', ') ),
+ if(division_name is null, '', concat(division_name) )
+ ) as person_address,
+ product_details as specimen_product_details,
+ person_phone,
+ concat(if(person_designation is null, person_designation, ''), ', ', institute_name) as designation
+ FROM {$table_prefix}persons
+ left join {$table_prefix}districts on district_id = person_district
+ left join {$table_prefix}divisions on division_id = person_division
+ left join {$table_prefix}upazilas on upazila_id = person_upazila
+ left join {$table_prefix}institute on institute_id = person_institute
+ left join ( select
+ group_concat(product_name, '- ', round(scd_product_qnt, 2) SEPARATOR ' ' ) as product_details,
+ scd_person_id
+ from {$table_prefix}sc_distribution
+ left join {$table_prefix}products on product_id = scd_product_id
+ where is_bundle_item = 0
+ group by scd_person_id
+ ) as specimen_details on scd_person_id = person_id
+ ) as person on person.person_phone = calls.client_identity"
+ ),
+ "where" => array(
+ "calls.is_trash = 0",
+ " and (representative = {$_SESSION["uid"]} or reviewer = {$_SESSION["uid"]} )"
+ ),
+ "orderby" => array(
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "limit" => array(
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ ));
+
+ }
+
+ $allData = [];
+ // Check if there have more then zero data
+ if($getData) {
+
+ foreach($getData['data'] as $key => $value) {
+ $allNestedData = [];
+
+ $callStatus = "";
+ if($value["call_status"] === "Answered") {
+ $callStatus = "Answered ";
+ } else if($value["call_status"] === "Rejected") {
+ $callStatus = "Rejected ";
+ } else {
+ $callStatus = "{$value["call_status"]} ";
+ }
+
+ $allNestedData[] = "";
+ $allNestedData[] = $value["call_datetime"];
+ $allNestedData[] = $value["call_direction"];
+ $allNestedData[] = $value["call_reason"];
+ $allNestedData[] = $callStatus;
+ $allNestedData[] = "{$value["client_identity"]} {$value["person_full_name"]}, {$value["person_type"]} {$value["designation"]}, {$value["person_address"]}";
+ $allNestedData[] = $value["specimen_product_details"];
+ $allNestedData[] = $value["duration"];
+ $allNestedData[] = $value["feedback"] . ' ';
+
+ $allData[] = $allNestedData;
+ }
+ }
+
+
+ $jsonData = array (
+ "draw" => intval( $requestData['draw'] ),
+ "recordsTotal" => intval( $totalRecords ),
+ "recordsFiltered" => intval( $totalFilteredRecords ),
+ "data" => $allData
+ );
+
+ // Encode in Json Formate
+ echo json_encode($jsonData);
+
+}
+
+
+/*************************** Representative Call List ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "allCallList") {
+
+ $requestData = $_REQUEST;
+ $getData = [];
+
+ // List of all columns name
+ $columns = array(
+ "",
+ "call_id",
+ "call_direction",
+ "call_status",
+ "client_identity",
+ "person_type",
+ "duration",
+ "feedback",
+ "feedback_informative",
+ "sale_our_product",
+ "use_our_product",
+ "mr_feedback",
+ "other_info",
+ "representative"
+ );
+
+ // Count Total recrods
+
+ $totalFilteredRecords = $totalRecords = easySelectA(array(
+ "table" => "calls",
+ "fields" => "count(*) as totalRow",
+ "where" => array(
+ "is_trash = 0"
+ )
+ ))["data"][0]["totalRow"];
+
+ if($requestData['length'] == -1) {
+ $requestData['length'] = $totalRecords;
+ }
+
+ if( !empty($requestData["search"]["value"]) or
+ !empty($requestData["columns"][1]['search']['value']) or
+ !empty($requestData["columns"][2]['search']['value']) or
+ !empty($requestData["columns"][3]['search']['value']) or
+ !empty($requestData["columns"][4]['search']['value']) or
+ !empty($requestData["columns"][6]['search']['value']) or
+ !empty($requestData["columns"][10]['search']['value']) or
+ !empty($requestData["columns"][16]['search']['value'])
+ ) { // get data with search
+
+ $dateFilter = "";
+ $specimenDateFilter = "";
+ if(!empty($requestData["columns"][1]['search']['value'])) {
+ $dateRange = explode(" - ", safe_input($requestData["columns"][1]['search']['value']));
+ $dateFilter = "and date(call_datetime) BETWEEN '{$dateRange[0]}' and '{$dateRange[1]}'";
+ $specimenDateFilter = "where date(scd_add_on) BETWEEN '{$dateRange[0]}' and '{$dateRange[1]}'";
+ }
+
+ $search = "";
+ if( !empty($requestData['search']['value']) ) {
+ $search = "and ( person_full_name LIKE '". safe_input($requestData['search']['value']) ."%' or client_identity LIKE '". safe_input($requestData['search']['value']) ."%' ) ";
+ }
+
+ $getData = easySelectA(array(
+ "table" => "calls as calls",
+ "fields" => "call_id, call_datetime, call_direction, call_status, call_reason, specimen_product_details, person_full_name, person_type,
+ person_address, designation, client_identity, duration, feedback, concat(emp_firstname, ' ', emp_lastname) as representative,
+ feedback_informative, sale_our_product, use_our_product, mr_feedback, other_info, specimen_copy_received",
+ "join" => array(
+ "left join {$table_prefix}users on representative = user_id",
+ "left join {$table_prefix}employees on user_emp_id = emp_id",
+ "left join ( select
+ person_full_name,
+ person_type,
+ concat(
+ if(person_address = '', '', concat(person_address, ', ') ),
+ if(upazila_name is null, '', concat(upazila_name, ', ') ),
+ if(district_name is null, '', concat(district_name, ', ') ),
+ if(division_name is null, '', concat(division_name) )
+ ) as person_address,
+ product_details as specimen_product_details,
+ person_phone,
+ concat(if(person_designation is null, person_designation, ''), ', ', institute_name) as designation
+ FROM {$table_prefix}persons
+ left join {$table_prefix}districts on district_id = person_district
+ left join {$table_prefix}divisions on division_id = person_division
+ left join {$table_prefix}upazilas on upazila_id = person_upazila
+ left join {$table_prefix}institute on institute_id = person_institute
+ left join ( select
+ group_concat(product_name, '- ', round(scd_product_qnt, 2) SEPARATOR ' ' ) as product_details,
+ scd_person_id
+ from {$table_prefix}sc_distribution
+ left join {$table_prefix}products on product_id = scd_product_id
+ where is_bundle_item = 0
+ group by scd_person_id
+ ) as specimen_details on scd_person_id = person_id
+ ) as person on person.person_phone = calls.client_identity"
+ ),
+ "where" => array(
+ "calls.is_trash = 0",
+ " AND call_direction" => $requestData["columns"][2]['search']['value'],
+ " AND call_status" => $requestData["columns"][3]['search']['value'],
+ " AND call_reason" => $requestData["columns"][4]['search']['value'],
+ " AND person_type" => $requestData["columns"][6]['search']['value'],
+ " AND specimen_copy_received" => $requestData["columns"][10]['search']['value'],
+ " AND representative" => $requestData["columns"][16]['search']['value'],
+ " $search $dateFilter"
+ ),
+ "orderby" => array(
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "limit" => array(
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+
+ ));
+
+ $totalFilteredRecords = $getData ? $getData["count"] : 0;
+
+
+ } else { // Get data withouth search
+
+ $getData = easySelectA(array(
+ "table" => "calls as calls",
+ "fields" => "call_id, call_datetime, call_direction, call_status, call_reason, specimen_product_details, person_full_name, person_type,
+ person_address, designation, client_identity, duration, feedback, concat(emp_firstname, ' ', emp_lastname) as representative,
+ feedback_informative, sale_our_product, use_our_product, mr_feedback, other_info, specimen_copy_received
+ ",
+ "join" => array(
+ "left join {$table_prefix}users on representative = user_id",
+ "left join {$table_prefix}employees on user_emp_id = emp_id",
+ "left join ( select
+ person_full_name,
+ person_type,
+ concat(
+ if(person_address = '', '', concat(person_address, ', ') ),
+ if(upazila_name is null, '', concat(upazila_name, ', ') ),
+ if(district_name is null, '', concat(district_name, ', ') ),
+ if(division_name is null, '', concat(division_name) )
+ ) as person_address,
+ product_details as specimen_product_details,
+ person_phone,
+ concat(if(person_designation is null, person_designation, ''), ', ', institute_name) as designation
+ FROM {$table_prefix}persons
+ left join {$table_prefix}districts on district_id = person_district
+ left join {$table_prefix}divisions on division_id = person_division
+ left join {$table_prefix}upazilas on upazila_id = person_upazila
+ left join {$table_prefix}institute on institute_id = person_institute
+ left join ( select
+ group_concat(product_name, '- ', round(scd_product_qnt, 2) SEPARATOR ' ' ) as product_details,
+ scd_person_id
+ from {$table_prefix}sc_distribution
+ left join {$table_prefix}products on product_id = scd_product_id
+ where is_bundle_item = 0
+ group by scd_person_id
+ ) as specimen_details on scd_person_id = person_id
+ ) as person on person.person_phone = calls.client_identity"
+ ),
+ "where" => array(
+ "calls.is_trash = 0"
+ ),
+ "orderby" => array(
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "limit" => array(
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ ));
+
+ }
+
+ $allData = [];
+ // Check if there have more then zero data
+ if($getData) {
+
+ foreach($getData['data'] as $key => $value) {
+ $allNestedData = [];
+
+ $callStatus = "";
+ if($value["call_status"] === "Answered") {
+ $callStatus = "Answered ";
+ } else if($value["call_status"] === "Rejected") {
+ $callStatus = "Rejected ";
+ } else {
+ $callStatus = "{$value["call_status"]} ";
+ }
+
+ $allNestedData[] = "";
+ $allNestedData[] = $value["call_datetime"];
+ $allNestedData[] = $value["call_direction"];
+ $allNestedData[] = $callStatus;
+ $allNestedData[] = $value["call_reason"];
+ $allNestedData[] = "{$value["client_identity"]} {$value["person_full_name"]} {$value["designation"]}, {$value["person_address"]}";
+ $allNestedData[] = $value["person_type"];
+ $allNestedData[] = $value["specimen_product_details"];
+ $allNestedData[] = $value["duration"];
+ $allNestedData[] = $value["feedback"] . ' ';
+ $allNestedData[] = $value["specimen_copy_received"];
+ $allNestedData[] = $value["feedback_informative"];
+ $allNestedData[] = $value["sale_our_product"];
+ $allNestedData[] = $value["use_our_product"];
+ $allNestedData[] = $value["mr_feedback"];
+ $allNestedData[] = $value["other_info"];
+ $allNestedData[] = $value["representative"];
+
+ $allData[] = $allNestedData;
+
+ }
+
+ }
+
+
+ $jsonData = array (
+ "draw" => intval( $requestData['draw'] ),
+ "recordsTotal" => intval( $totalRecords ),
+ "recordsFiltered" => intval( $totalFilteredRecords ),
+ "data" => $allData
+ );
+
+ // Encode in Json Formate
+ echo json_encode($jsonData);
+
+}
+
+
+/************************** Edit Call Feedback **********************/
+if(isset($_GET['page']) and $_GET['page'] == "editCallFeedback") {
+
+ $getCallData = easySelectA(array(
+ "table" => "calls",
+ "fields" => "feedback, client_identity, reviewer, concat(emp_firstname, ' ', emp_lastname) as reviewer_name",
+ "join" => array(
+ "left join {$table_prefix}users on reviewer = user_id",
+ "left join {$table_prefix}employees on user_emp_id = emp_id"
+ ),
+ "where" => array(
+ "call_id" => $_GET["call_id"]
+ )
+ ))["data"][0];
+
+ // Include the modal header
+ modal_header("Edit feedback for {$getCallData["client_identity"]}", full_website_address() . "/xhr/?module=customer-support&page=updateCallFeedback");
+
+ ?>
+
+
+
+ Feedback:
+
+
+
+ Reviewer:
+
+ = __("Select feedback reviewer"); ?>....
+ ">
+
+
+
">
+
+
+
+
+ $_POST["feedback"],
+ "call_reason" => $_POST["reason"],
+ "specimen_copy_received" => empty($_POST["specimenReceived"]) ? NULL : $_POST["specimenReceived"],
+ "feedback_informative" => empty($_POST["informative"]) ? NULL : $_POST["informative"],
+ "sale_our_product" => empty($_POST["saleOurProduct"]) ? NULL : $_POST["saleOurProduct"],
+ "use_our_product" => empty($_POST["userOurProduct"]) ? NULL : $_POST["userOurProduct"],
+ "mr_feedback" => empty($_POST["mrFeedback"]) ? NULL : $_POST["mrFeedback"],
+ "other_info" => $_POST["otherInformation"],
+ "reviewer" => empty($_POST["reviewer"]) ? NULL : $_POST["reviewer"],
+ ),
+ array(
+ "call_id" => $call_id
+ )
+ );
+
+ if($updateCallsFeedback !== false) {
+ _s("Successfully updated");
+ } else {
+ _e($updateCallsFeedback);
+ }
+
+}
+
+/************************** New Case **********************/
+if(isset($_GET['page']) and $_GET['page'] == "newCase") {
+
+ // Include the modal header
+ modal_header("Add New Case", full_website_address() . "/xhr/?module=customer-support&page=addNewCase");
+
+ ?>
+
+
+
+
+
+
+
+
+
+ = __("Case Title:"); ?>
+
+
+
+ Case/ Issue details:
+
+
+
+ Note/ Private Reply:
+
+
+
+ Attachment
+
+ Note: Max Upload Size: MB. Only JPEG and PNG image types are allowed to upload
+
+
+
+
+
+
+
+
+ = __("Prority:"); ?>
+
+ = __("Select Prority"); ?>....
+ {$priority}";
+ }
+ ?>
+
+
+
+
+
+ = __("Type:"); ?>
+
+ = __("Select Type"); ?>....
+ {$type}";
+ }
+ ?>
+
+
+
+
+
+ = __("Status:"); ?>
+
+ = __("Select Status"); ?>....
+ {$status}";
+ }
+ ?>
+
+
+
+
+
+ = __("Customer:"); ?>
+
+ = __("Select Customer"); ?>....
+
+
+
+
+ = __("Person/ Lead:"); ?>
+
+ = __("Select Person/ Lead"); ?>....
+
+
+
+
+ = __("Site:"); ?>
+
+
+
+
+ = __("Assign To:"); ?>
+
+ = __("Select user"); ?>....
+
+
+
+ = __("Belongs To:"); ?>
+
+ = __("Select Employee"); ?>....
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0 ) {
+
+ $maxUploadSize = $_SETTINGS["MAX_UPLOAD_SIZE"] * 1024 * 1024;
+
+ foreach($_FILES["caseAttachment"]["size"] as $index => $size) {
+
+ if ($maxUploadSize < $size) {
+ $hasErrorOnUpload = true;
+ break;
+ }
+
+ $mimeType = strtolower($_FILES["caseAttachment"]["type"][$index]);
+ $extension = explode(".", $_FILES["caseAttachment"]["name"][$index]);
+ $extension = end($extension);
+
+ if(
+ !isset( $_SETTINGS["VALID_IMAGE_TYPE_FOR_UPLOAD"][$extension] ) or
+ (
+ isset($_SETTINGS["VALID_IMAGE_TYPE_FOR_UPLOAD"][$extension]) and
+ !in_array( $mimeType, $_SETTINGS["VALID_IMAGE_TYPE_FOR_UPLOAD"][$extension] )
+ )
+ ) {
+ $hasErrorOnUpload = true;
+ break;
+ }
+
+ if($size > 0) {
+
+ array_push($attachmentList, array(
+ "name" => $_FILES["caseAttachment"]["name"][$index],
+ "type" => $_FILES["caseAttachment"]["type"][$index],
+ "tmp_name" => $_FILES["caseAttachment"]["tmp_name"][$index],
+ "error" => $_FILES["caseAttachment"]["error"][$index],
+ "size" => $_FILES["caseAttachment"]["size"][$index]
+ ));
+
+ }
+
+ }
+
+ }
+
+ if($hasErrorOnUpload) {
+ return _e("There have an error to upload the images. Please check the image type and size.");
+ }
+
+ // Insert case
+ $insertCase = easyInsert(
+ "cases",
+ array(
+ "case_datetime" => date("Y-m-d H:i:s"),
+ "case_title" => $_POST["caseTitle"],
+ "case_priority" => $_POST["casePriority"],
+ "case_type" => $_POST["caseType"],
+ "case_status" => empty($_POST["caseStatus"]) ? 'Open' : $_POST["caseStatus"],
+ "case_site" => $_POST["caseSite"],
+ "case_customer" => empty($_POST["caseCustomer"]) ? NULL : $_POST["caseCustomer"],
+ "case_person" => empty($_POST["casePerson"]) ? NULL : $_POST["casePerson"],
+ "case_assigned_to" => empty($_POST["caseAssignTo"]) ? NULL : $_POST["caseAssignTo"],
+ "case_belongs_to" => empty($_POST["caseBelongsTo"]) ? NULL : $_POST["caseBelongsTo"],
+ "case_added_by_agent" => $_SESSION["uid"]
+ ),
+ array(),
+ true
+ );
+
+ //print_r($insertCase);
+
+ if( isset($insertCase["status"]) and $insertCase["status"] === 'success' ) {
+
+
+ $uploadedAttachment = array();
+
+ if( count($attachmentList) > 0 ) {
+
+ foreach($attachmentList as $attached) {
+
+ $attachmentUploadDir = "attachments/cases/{$_POST["caseType"]}/" . date("Y-m-d");
+ $uploadCaseAttachment = easyUpload($attached, $attachmentUploadDir );
+
+ if(!isset($uploadCaseAttachment["success"])) {
+ $hasErrorOnUpload = true;
+ } else {
+ array_push($uploadedAttachment, $attachmentUploadDir . "/".$uploadCaseAttachment["fileName"]);
+ }
+
+ }
+
+ }
+
+
+ // Insert case public replies
+ easyInsert(
+ "case_replies",
+ array(
+ "reply_type" => 'Public',
+ 'reply_case_id' => $insertCase["last_insert_id"],
+ "reply_datetime" => date("Y-m-d H:i:s"),
+ "reply_details" => purify_html($_POST["caseDetails"]) ,
+ "reply_attachment" => serialize($uploadedAttachment),
+ "reply_by_agent" => $_SESSION["uid"]
+ )
+ );
+
+ // Insert case private replies
+ if( !empty($_POST["caseNote"]) ) {
+ easyInsert(
+ "case_replies",
+ array(
+ "reply_type" => 'Private',
+ 'reply_case_id' => $insertCase["last_insert_id"],
+ "reply_datetime" => date("Y-m-d H:i:s"),
+ "reply_details" => purify_html($_POST["caseNote"]),
+ "reply_attachment" => NULL,
+ "reply_by_agent" => $_SESSION["uid"]
+ )
+ );
+ }
+
+ _s("Case has been added successfully");
+
+ }
+
+}
+
+
+if(isset($_GET['page']) and $_GET['page'] == "addCaseReply") {
+
+
+ if( empty($_POST["caseReply"]) ) {
+ return _e("Please enter case reply");
+ } else if( empty($_POST["replyMode"]) ) {
+ return _e("Please select reply mode");
+ }
+
+ $attachmentList = array();
+ $hasErrorOnUpload = false;
+
+ if( $_FILES["caseReplyAttachment"]["size"][0] > 0 ) {
+
+ $maxUploadSize = $_SETTINGS["MAX_UPLOAD_SIZE"] * 1024 * 1024;
+
+ foreach($_FILES["caseReplyAttachment"]["size"] as $index => $size) {
+
+ if ($maxUploadSize < $size) {
+ $hasErrorOnUpload = true;
+ break;
+ }
+
+ $extensionName = strtolower(explode("/", $_FILES["caseReplyAttachment"]["type"][$index])[1]);
+ if(!in_array($extensionName, $_SETTINGS["VALID_IMAGE_TYPE_FOR_UPLOAD"])) {
+ $hasErrorOnUpload = true;
+ break;
+ }
+
+ if($size > 0) {
+
+ array_push($attachmentList, array(
+ "name" => $_FILES["caseReplyAttachment"]["name"][$index],
+ "type" => $_FILES["caseReplyAttachment"]["type"][$index],
+ "tmp_name" => $_FILES["caseReplyAttachment"]["tmp_name"][$index],
+ "error" => $_FILES["caseReplyAttachment"]["error"][$index],
+ "size" => $_FILES["caseReplyAttachment"]["size"][$index]
+ ));
+
+ }
+
+ }
+
+ }
+
+ if($hasErrorOnUpload) {
+ return _e("There have an error to upload the images. Please check the image type and size.");
+ }
+
+
+ $uploadedAttachment = array();
+
+ if( count($attachmentList) > 0 ) {
+
+ foreach($attachmentList as $attached) {
+
+ $attachmentUploadDir = "attachments/cases/{$_POST["caseType"]}/" . date("Y-m-d");
+ $uploadCaseAttachment = easyUpload($attached, $attachmentUploadDir );
+
+ if(!isset($uploadCaseAttachment["success"])) {
+ $hasErrorOnUpload = true;
+ } else {
+ array_push($uploadedAttachment, $attachmentUploadDir . "/".$uploadCaseAttachment["fileName"]);
+ }
+
+ }
+
+ }
+
+
+ // Insert case public replies
+ $addCaseReyply = easyInsert(
+ "case_replies",
+ array(
+ "reply_type" => $_POST["replyMode"],
+ 'reply_case_id' => $_POST["case_id"],
+ "reply_datetime" => date("Y-m-d H:i:s"),
+ "reply_details" => purify_html($_POST["caseReply"]),
+ "reply_attachment" => serialize($uploadedAttachment),
+ "reply_by_agent" => $_SESSION["uid"]
+ ),
+ array(),
+ true
+ );
+
+
+
+ if( isset($addCaseReyply["status"]) and $addCaseReyply["status"] === 'success' ) {
+
+ $selectReplies = easySelectA(array(
+ "table" => "case_replies as reply",
+ "fields" => "reply_id, reply_type, reply_datetime, reply_details, reply_attachment,
+ if(emp_firstname is null, customer_name, concat(emp_firstname, ' ', emp_lastname)) as reply_by,
+ reply_by_customer
+ ",
+ "join" => array(
+ "left join {$table_prefix}users on user_id = reply_by_agent",
+ "left join {$table_prefix}employees on emp_id = user_emp_id",
+ "left join {$table_prefix}customers on customer_id = reply_by_customer"
+ ),
+ "where" => array(
+ "reply.is_trash = 0 and reply_id" => $addCaseReyply["last_insert_id"]
+ )
+ ));
+
+ if($selectReplies !== false) {
+
+ $reply = $selectReplies["data"][0];
+
+ $time_elaps = time_elapsed_string($reply["reply_datetime"]) . " (" . date("d F, Y h:m A", strtotime($reply["reply_datetime"])) .")";
+
+ $attachment = "";
+ if($reply["reply_attachment"] !== null) {
+
+ $listAttachment = unserialize( html_entity_decode($reply["reply_attachment"]) );
+
+ foreach($listAttachment as $image) {
+ $attachment .= " ";
+ }
+
+ }
+
+
+ // Define user and reply type
+ $userType = " Staff ";
+ $replyType = " Public ";
+ $replyClass = 'reply';
+ $replyTypeMoveTo = 'Private';
+ if( $reply["reply_by_customer"] !== null ) {
+ $userType = " Customer ";
+ }
+
+ if( $reply["reply_type"] === "Private" ) {
+ $replyType = " Private ";
+ $replyClass = 'reply private';
+ $replyTypeMoveTo = 'Public';
+ }
+
+ // If there have any attachment then show them
+ if($attachment !== "") {
+ $attachment = "";
+ }
+
+
+ echo "
+
+
+
{$reply["reply_by"]}
+
+ {$time_elaps}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {$userType}
+ {$replyType}
+
+
+
+ ". str_replace('\n', '', html_entity_decode($reply["reply_details"]) ) ."
+
+ $attachment
+
+
";
+
+ }
+
+ }
+
+}
+
+
+/*************************** case List ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "caseList") {
+
+ $requestData = $_REQUEST;
+ $getData = [];
+
+ // List of all columns name
+ $columns = array(
+ "",
+ "case_datetime",
+ "requester",
+ "case_title",
+ "FIELD(case_is_pin, 1, 0),
+ FIELD(case_status, 'Pending', 'Customer Responded', 'Open', 'Informed', 'On Hold', 'Replied', 'Closed', 'Solved'),
+ FIELD(case_priority, 'Critical', 'High', 'Medium', 'Low'),
+ case_datetime"
+ );
+
+ // Count Total recrods
+
+ $totalFilteredRecords = $totalRecords = easySelectA(array(
+ "table" => "cases",
+ "fields" => "count(*) as totalRow",
+ "where" => array(
+ "is_trash = 0"
+ )
+ ))["data"][0]["totalRow"];
+
+ if($requestData['length'] == -1) {
+ $requestData['length'] = $totalRecords;
+ }
+
+
+ if( !empty($requestData["search"]["value"])) { // get data with only search
+
+ $getData = easySelectA(array(
+ "table" => "cases as cases",
+ "fields" => "case_id, case_datetime, case_title, case_priority, case_type, case_status, last_reply,
+ case_assigned_to, concat(assigned_to_employee.emp_firstname, ' ', assigned_to_employee.emp_lastname) as case_assign_to_name,
+ case_belongs_to, concat(belongs_to.emp_firstname, ' ', belongs_to.emp_lastname) as case_belongs_to_name,
+ case_added_by_agent, concat(posted_by_employee.emp_firstname, ' ', posted_by_employee.emp_lastname) as posted_by_name,
+ if(person_full_name is null,
+ concat(customer_name, ' ', customer_phone),
+ concat(person_full_name, ' ', person_phone, ', ', person_email)
+ ) as requester",
+ "join" => array(
+ "left join {$table_prefix}users as assigned_user on assigned_user.user_id = case_assigned_to",
+ "left join {$table_prefix}employees as assigned_to_employee on assigned_to_employee.emp_id = assigned_user.user_emp_id",
+
+ "left join {$table_prefix}users as posted_user on posted_user.user_id = case_added_by_agent",
+ "left join {$table_prefix}employees as posted_by_employee on posted_by_employee.emp_id = posted_user.user_emp_id",
+
+ "left join {$table_prefix}employees as belongs_to on belongs_to.emp_id = case_belongs_to",
+ "left join {$table_prefix}persons on person_id = case_person",
+ "left join {$table_prefix}customers on customer_id = case_customer",
+ "left join (select
+ max(reply_datetime) as last_reply,
+ reply_case_id
+ from {$table_prefix}case_replies
+ where is_trash = 0
+ group by reply_case_id
+ ) as replies on replies.reply_case_id = case_id"
+ ),
+ "where" => array(
+ "cases.is_trash = 0 AND (",
+ " customer_name LIKE '". safe_input($requestData["search"]["value"]) ."' ",
+ " OR customer_phone LIKE" => $requestData["search"]["value"] . '%',
+ " OR person_full_name LIKE" => '%' . $requestData["search"]["value"] . '%',
+ " OR person_phone LIKE" => $requestData["search"]["value"] . '%',
+ ")",
+ ),
+ "orderby" => array(
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "limit" => array(
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ ));
+
+
+ $totalFilteredRecords = $getData ? $getData["count"] : 0;
+
+ } else if( !empty($requestData["search"]["value"]) or
+ !empty($requestData["columns"][1]['search']['value']) or
+ !empty($requestData["columns"][3]['search']['value']) or
+ !empty($requestData["columns"][4]['search']['value']) or
+ !empty($requestData["columns"][5]['search']['value']) or
+ !empty($requestData["columns"][6]['search']['value']) or
+ !empty($requestData["columns"][7]['search']['value']) or
+ !empty($requestData["columns"][8]['search']['value']) or
+ !empty($requestData["columns"][10]['search']['value'])
+ ) { // get data with search and filters
+
+ $dateFilter = "";
+ if(!empty($requestData["columns"][1]['search']['value'])) {
+ $dateRange = explode(" - ", safe_input($requestData["columns"][1]['search']['value']));
+ $dateFilter = " AND date(case_datetime) BETWEEN '{$dateRange[0]}' and '{$dateRange[1]}'";
+ }
+
+ $getData = easySelectA(array(
+ "table" => "cases as cases",
+ "fields" => "case_id, case_datetime, case_title, case_priority, case_type, case_status, last_reply,
+ case_assigned_to, concat(assigned_to_employee.emp_firstname, ' ', assigned_to_employee.emp_lastname) as case_assign_to_name,
+ case_belongs_to, concat(belongs_to.emp_firstname, ' ', belongs_to.emp_lastname) as case_belongs_to_name,
+ case_added_by_agent, concat(posted_by_employee.emp_firstname, ' ', posted_by_employee.emp_lastname) as posted_by_name,
+ if(person_full_name is null,
+ concat(customer_name, ' ', customer_phone),
+ concat(person_full_name, ' ', person_phone, ', ', person_email)
+ ) as requester",
+ "join" => array(
+ "left join {$table_prefix}users as assigned_user on assigned_user.user_id = case_assigned_to",
+ "left join {$table_prefix}employees as assigned_to_employee on assigned_to_employee.emp_id = assigned_user.user_emp_id",
+
+ "left join {$table_prefix}users as posted_user on posted_user.user_id = case_added_by_agent",
+ "left join {$table_prefix}employees as posted_by_employee on posted_by_employee.emp_id = posted_user.user_emp_id",
+
+ "left join {$table_prefix}employees as belongs_to on belongs_to.emp_id = case_belongs_to",
+ "left join {$table_prefix}persons on person_id = case_person",
+ "left join {$table_prefix}customers on customer_id = case_customer",
+ "left join (select
+ max(reply_datetime) as last_reply,
+ reply_case_id
+ from {$table_prefix}case_replies
+ where is_trash = 0
+ group by reply_case_id
+ ) as replies on replies.reply_case_id = case_id"
+ ),
+ "where" => array(
+ "cases.is_trash = 0 AND (",
+ " COALESCE(customer_name, '') LIKE '%". safe_input($requestData["columns"][2]['search']['value']) ."%' ",
+ " OR customer_phone LIKE" => $requestData["columns"][3]['search']['value'] . '%',
+ " OR COALESCE(person_full_name, '') LIKE" => '%' . $requestData["columns"][2]['search']['value'] . '%',
+ " OR person_phone LIKE" => $requestData["columns"][3]['search']['value'] . '%',
+ ")",
+ " AND case_priority" => $requestData["columns"][4]['search']['value'],
+ " AND case_type" => $requestData["columns"][5]['search']['value'],
+ " AND case_status" => $requestData["columns"][6]['search']['value'],
+ " AND case_assigned_to" => $requestData["columns"][7]['search']['value'],
+ " AND case_belongs_to" => $requestData["columns"][8]['search']['value'],
+ " AND case_added_by_agent" => $requestData["columns"][10]['search']['value'],
+ " {$dateFilter}"
+ ),
+ "orderby" => array(
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "limit" => array(
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ ));
+
+
+ $totalFilteredRecords = $getData ? $getData["count"] : 0;
+
+ } else { // Get data withouth search
+
+
+ $getData = easySelectA(array(
+ "table" => "cases as cases",
+ "fields" => "case_id, case_datetime, case_title, case_priority, case_type, case_status, last_reply,
+ case_assigned_to, concat(assigned_to_employee.emp_firstname, ' ', assigned_to_employee.emp_lastname) as case_assign_to_name,
+ case_belongs_to, concat(belongs_to.emp_firstname, ' ', belongs_to.emp_lastname) as case_belongs_to_name,
+ case_added_by_agent, concat(posted_by_employee.emp_firstname, ' ', posted_by_employee.emp_lastname) as posted_by_name,
+ if(person_full_name is null,
+ concat(customer_name, ' ', customer_phone),
+ concat(person_full_name, ' ', person_phone, ', ', person_email)
+ ) as requester",
+ "join" => array(
+ "left join {$table_prefix}users as assigned_user on assigned_user.user_id = case_assigned_to",
+ "left join {$table_prefix}employees as assigned_to_employee on assigned_to_employee.emp_id = assigned_user.user_emp_id",
+
+ "left join {$table_prefix}users as posted_user on posted_user.user_id = case_added_by_agent",
+ "left join {$table_prefix}employees as posted_by_employee on posted_by_employee.emp_id = posted_user.user_emp_id",
+
+ "left join {$table_prefix}employees as belongs_to on belongs_to.emp_id = case_belongs_to",
+ "left join {$table_prefix}persons on person_id = case_person",
+ "left join {$table_prefix}customers on customer_id = case_customer",
+ "left join (select
+ max(reply_datetime) as last_reply,
+ reply_case_id
+ from {$table_prefix}case_replies
+ where is_trash = 0
+ group by reply_case_id
+ ) as replies on replies.reply_case_id = case_id"
+ ),
+ "where" => array(
+ "cases.is_trash = 0"
+ ),
+ "orderby" => array(
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "limit" => array(
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ ));
+
+ }
+
+ $allData = [];
+ // Check if there have more then zero data
+ if($getData) {
+
+ foreach($getData['data'] as $key => $value) {
+ $allNestedData = [];
+
+ $caseStatus = "";
+ if($value["case_status"] === "Pending") {
+ $caseStatus = "Pending ";
+ } else if($value["case_status"] === "Solved") {
+ $caseStatus = "Solved ";
+ } else {
+ $caseStatus = "{$value["case_status"]} ";
+ }
+
+ $casePriority = "";
+ if($value["case_priority"] === "Critical") {
+ $casePriority = "Critical ";
+ } else if($value["case_priority"] === "High") {
+ $casePriority = "High ";
+ } else if($value["case_priority"] === "Medium") {
+ $casePriority = "Medium ";
+ } else {
+ $casePriority = "Low ";
+ }
+
+ $allNestedData[] = "";
+ $allNestedData[] = $value["case_datetime"];
+ $allNestedData[] = ' '. $value["case_title"] .' ';
+ $allNestedData[] = $value["requester"];
+ $allNestedData[] = $casePriority;
+ $allNestedData[] = $value["case_type"];
+ $allNestedData[] = $caseStatus;
+ $allNestedData[] = $value["case_assign_to_name"];
+ $allNestedData[] = $value["case_belongs_to_name"];
+ $allNestedData[] = $value["last_reply"] === null ? 'No Reply' : time_elapsed_string($value["last_reply"] );
+ $allNestedData[] = $value["posted_by_name"];
+
+ $allNestedData[] = '
+
+ action
+
+ Toggle Dropdown
+
+
+
';
+
+ $allData[] = $allNestedData;
+ }
+ }
+
+
+ $jsonData = array (
+ "draw" => intval( $requestData['draw'] ),
+ "recordsTotal" => intval( $totalRecords ),
+ "recordsFiltered" => intval( $totalFilteredRecords ),
+ "data" => $allData
+ );
+
+ // Encode in Json Formate
+ echo json_encode($jsonData);
+
+}
+
+
+/************************** New Case **********************/
+if(isset($_GET['page']) and $_GET['page'] == "deleteCase") {
+
+ if(current_user_can("customer_support_cases.Delete") !== true) {
+ echo '{
+ "title": "Sorry!",
+ "text": "you do not have permission to delete case.",
+ "showConfirmButton": true,
+ "showCloseButton": true,
+ "toast": false,
+ "icon": "error"
+ }';
+ return;
+ }
+
+ $deleteData = easyDelete(
+ "cases",
+ array(
+ "case_id" => $_POST["datatoDelete"]
+ )
+ );
+
+ if($deleteData === true) {
+ echo '{
+ "title": "The case has been deleted successfully."
+ }';
+ }
+
+}
+
+
+/************************** New Case **********************/
+if(isset($_GET['page']) and $_GET['page'] == "deleteCaseReply") {
+
+ if(current_user_can("customer_support_cases.Delete") !== true) {
+ echo '{
+ "title": "Sorry!",
+ "text": "you do not have permission to delete case reply.",
+ "showConfirmButton": true,
+ "showCloseButton": true,
+ "toast": false,
+ "icon": "error"
+ }';
+ return;
+ }
+
+ $deleteData = easyDelete(
+ "case_replies",
+ array(
+ "reply_id" => $_POST["datatoDelete"]
+ )
+ );
+
+ if($deleteData === true) {
+ echo '{
+ "title": "The reply has been deleted successfully."
+ }';
+ }
+
+}
+
+/***************** update case type/ mode ****************/
+if(isset($_GET['page']) and $_GET['page'] == "updateCaseReplyType") {
+
+
+ $replyMode = easySelectA(array(
+ "table" => "case_replies",
+ "fields" => "reply_type",
+ "where" => array(
+ "reply_id" => $_POST["datatoUpdate"]
+ )
+ ))["data"][0]["reply_type"];
+
+
+ easyUpdate(
+ "case_replies",
+ array(
+ "reply_type" => $replyMode === "Private" ? 'Public' : 'Private'
+ ),
+ array(
+ "reply_id" => $_POST["datatoUpdate"]
+ )
+ );
+
+ echo '{
+ "title": "Updated successfully. Please reload to see the changes."
+ }';
+
+}
+
+
+/*************************** case List ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "updateCase") {
+
+ easyUpdate(
+ "cases",
+ array(
+ "case_title" => $_POST["caseTitle"],
+ "case_priority" => $_POST["casePriority"],
+ "case_type" => $_POST["caseType"],
+ "case_status" => empty($_POST["caseStatus"]) ? 'Open' : $_POST["caseStatus"],
+ "case_site" => $_POST["caseSite"],
+ "case_customer" => empty($_POST["caseCustomer"]) ? NULL : $_POST["caseCustomer"],
+ "case_person" => empty($_POST["casePerson"]) ? NULL : $_POST["casePerson"],
+ "case_assigned_to" => empty($_POST["caseAssignTo"]) ? NULL : $_POST["caseAssignTo"],
+ "case_belongs_to" => empty($_POST["caseBelongsTo"]) ? NULL : $_POST["caseBelongsTo"]
+ ),
+ array(
+ "case_id" => $_POST["case_id"]
+ )
+ );
+
+
+ echo '{
+ "title": "Case properties has been updated successfully."
+ }';
+
+}
+
+/*************************** case List ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "smsList") {
+
+ $requestData = $_REQUEST;
+ $getData = [];
+
+ // List of all columns name
+ $columns = array(
+ "",
+ "sms_id",
+ "send_to",
+ "sms_text",
+ "status",
+ "emp_firstname"
+ );
+
+ // Count Total recrods
+
+ $totalFilteredRecords = $totalRecords = easySelectA(array(
+ "table" => "cases",
+ "fields" => "count(*) as totalRow",
+ "where" => array(
+ "is_trash = 0"
+ )
+ ))["data"][0]["totalRow"];
+
+ if($requestData['length'] == -1) {
+ $requestData['length'] = $totalRecords;
+ }
+
+ if(!empty($requestData["search"]["value"])) { // get data with search
+
+ $getData = easySelectA(array(
+ "table" => "sms_sender as sms_sender",
+ "fields" => "send_to, send_time, sms_text, status, concat(emp_firstname, ' ', emp_lastname) as sms_sent_by",
+ "join" => array(
+ "left join {$table_prefix}users on send_by = user_id",
+ "left join {$table_prefix}employees on user_emp_id = emp_id",
+ ),
+ "where" => array(
+ "sms_sender.is_trash = 0 and send_by" => $_SESSION["uid"],
+ " and ( send_to LIKE" => $requestData['search']['value'] . "%",
+ " or emp_firstname LIKE" => $requestData['search']['value'] . "%",
+ ")"
+ ),
+ "orderby" => array(
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "limit" => array(
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ ));
+
+
+ $totalFilteredRecords = $getData ? $getData["count"] : 0;
+
+ } else { // Get data withouth search
+
+
+ $getData = easySelectA(array(
+ "table" => "sms_sender as sms_sender",
+ "fields" => "send_to, send_time, sms_text, status, concat(emp_firstname, ' ', emp_lastname) as sms_sent_by",
+ "join" => array(
+ "left join {$table_prefix}users on send_by = user_id",
+ "left join {$table_prefix}employees on user_emp_id = emp_id",
+ ),
+ "where" => array(
+ "sms_sender.is_trash = 0 and send_by" => $_SESSION["uid"]
+ ),
+ "orderby" => array(
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "limit" => array(
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ ));
+
+ }
+
+ $allData = [];
+ // Check if there have more then zero data
+ if($getData) {
+
+ foreach($getData['data'] as $key => $value) {
+ $allNestedData = [];
+
+
+ $allNestedData[] = "";
+ $allNestedData[] = $value["send_time"];
+ $allNestedData[] = $value["send_to"];
+ $allNestedData[] = $value["sms_text"];
+ $allNestedData[] = $value["status"];
+ $allNestedData[] = $value["sms_sent_by"];
+
+ $allData[] = $allNestedData;
+ }
+ }
+
+
+ $jsonData = array (
+ "draw" => intval( $requestData['draw'] ),
+ "recordsTotal" => intval( $totalRecords ),
+ "recordsFiltered" => intval( $totalFilteredRecords ),
+ "data" => $allData
+ );
+
+ // Encode in Json Formate
+ echo json_encode($jsonData);
+
+}
+
+
+/*************************** getCallerDetails ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "addNewNote") {
+
+ $insertNote = easyInsert(
+ "notes",
+ array(
+ "note_type" => $_POST["type"],
+ "note_text" => $_POST["note"],
+ "note_created_by" => $_SESSION["uid"]
+ )
+ );
+
+}
+
+
+/************************** New Representative **********************/
+if(isset($_GET['page']) and $_GET['page'] == "newRepresentative") {
+
+ // Include the modal header
+ modal_header("Add New Customer Care Representative", full_website_address() . "/xhr/?module=customer-support&page=addNewRepresentative");
+
+ ?>
+
+
+
+ $_POST["representativeUser"],
+ "sip_username" => $_POST["sipUsername"],
+ "sip_password" => $_POST["sipPassword"],
+ "sip_domain" => $_POST["sipDomain"],
+ "sip_websocket_addr" => $_POST["sipSocketAddress"],
+ "sip_created_by" => $_SESSION["uid"]
+ )
+ );
+
+ if($insertSip !== false) {
+ _s("Successfully addded");
+ } else {
+ _e($insertSip);
+ }
+
+}
+
+
+/*************************** case List ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "callCenterRepresentativeList") {
+
+ $requestData = $_REQUEST;
+ $getData = [];
+
+ // List of all columns name
+ $columns = array(
+ "",
+ "emp_firstname",
+ "sip_username",
+ "sip_domain",
+ "sip_websocket_addr"
+ );
+
+ // Count Total recrods
+
+ $totalFilteredRecords = $totalRecords = easySelectA(array(
+ "table" => "sip_credentials",
+ "fields" => "count(*) as totalRow",
+ "where" => array(
+ "is_trash = 0"
+ )
+ ))["data"][0]["totalRow"];
+
+ if($requestData['length'] == -1) {
+ $requestData['length'] = $totalRecords;
+ }
+
+ if(!empty($requestData["search"]["value"])) { // get data with search
+
+ $getData = easySelectA(array(
+ "table" => "sip_credentials as sip_credentials",
+ "fields" => "sip_id, sip_username, sip_domain, sip_websocket_addr, concat(emp_firstname, ' ', emp_lastname) as callCenterRepresentative",
+ "join" => array(
+ "left join {$table_prefix}users on sip_representative = user_id",
+ "left join {$table_prefix}employees on user_emp_id = emp_id",
+ ),
+ "where" => array(
+ "sip_credentials.is_trash = 0",
+ " or emp_firstname LIKE" => $requestData['search']['value'] . "%",
+ ),
+ "orderby" => array(
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "limit" => array(
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ ));
+
+ $totalFilteredRecords = $getData ? $getData["count"] : 0;
+
+ } else { // Get data withouth search
+
+
+ $getData = easySelectA(array(
+ "table" => "sip_credentials as sip_credentials",
+ "fields" => "sip_id, sip_username, sip_domain, sip_websocket_addr, concat(emp_firstname, ' ', emp_lastname) as callCenterRepresentative",
+ "join" => array(
+ "left join {$table_prefix}users on sip_representative = user_id",
+ "left join {$table_prefix}employees on user_emp_id = emp_id",
+ ),
+ "where" => array(
+ "sip_credentials.is_trash = 0"
+ ),
+ "orderby" => array(
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "limit" => array(
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ ));
+
+ }
+
+ $allData = [];
+ // Check if there have more then zero data
+ if($getData) {
+
+ foreach($getData['data'] as $key => $value) {
+ $allNestedData = [];
+ $allNestedData[] = "";
+ $allNestedData[] = $value["callCenterRepresentative"];
+ $allNestedData[] = $value["sip_username"];
+ $allNestedData[] = $value["sip_domain"];
+ $allNestedData[] = $value["sip_websocket_addr"];
+ $allNestedData[] = '
+
+ action
+
+ Toggle Dropdown
+
+
+
';
+
+ $allData[] = $allNestedData;
+ }
+ }
+
+
+ $jsonData = array (
+ "draw" => intval( $requestData['draw'] ),
+ "recordsTotal" => intval( $totalRecords ),
+ "recordsFiltered" => intval( $totalFilteredRecords ),
+ "data" => $allData
+ );
+
+ // Encode in Json Formate
+ echo json_encode($jsonData);
+
+}
+
+
+
+/***************** Delete CustomerCareRepresentative ****************/
+if(isset($_GET['page']) and $_GET['page'] == "deleteCustomerCareRepresentative") {
+
+ if(current_user_can("customer_support_representative.Delete") !== true) {
+ echo '{
+ "title": "Sorry!",
+ "text": "you do not have permission to delete this accounts.",
+ "showConfirmButton": true,
+ "showCloseButton": true,
+ "toast": false,
+ "icon": "error"
+ }';
+ return;
+ }
+
+ $deleteData = easyDelete(
+ "sip_credentials",
+ array(
+ "sip_id" => $_POST["datatoDelete"]
+ )
+ );
+
+ if($deleteData === true) {
+ echo '{
+ "title": "The accounts has been deleted successfully."
+ }';
+ }
+}
+
+
+/************************** New Representative **********************/
+if(isset($_GET['page']) and $_GET['page'] == "editCCRepresentative") {
+
+ // Include the modal header
+ modal_header("Edit Customer Care Representative", full_website_address() . "/xhr/?module=customer-support&page=updateRepresentative");
+
+ // Select
+ $selectCCR = easySelectA(array(
+ "table" => "sip_credentials as sip_credentials",
+ "fields" => "sip_id, sip_representative, sip_username, sip_password, sip_domain, sip_websocket_addr, concat(emp_firstname, ' ', emp_lastname) as callCenterRepresentative",
+ "join" => array(
+ "left join {$table_prefix}users on sip_representative = user_id",
+ "left join {$table_prefix}employees on user_emp_id = emp_id",
+ ),
+ "where" => array(
+ "sip_credentials.sip_id" => $_GET["id"]
+ )
+ ))["data"][0];
+
+ ?>
+
+
+
+ = __("User:"); ?>
+
+ = __("Select user"); ?>....
+ ">
+
+
+
+ SIP Username
+ " class="form-control" required>
+
+
+ SIP Password
+ " class="form-control" required>
+
+
+ SIP Domain
+ " class="form-control" required>
+
+
+ SIP Socket Address
+ " class="form-control" required>
+
+
">
+
+
+
+
+ $_POST["representativeUser"],
+ "sip_username" => $_POST["sipUsername"],
+ "sip_password" => $_POST["sipPassword"],
+ "sip_domain" => $_POST["sipDomain"],
+ "sip_websocket_addr" => $_POST["sipSocketAddress"],
+ "sip_created_by" => $_SESSION["uid"]
+ ),
+ array(
+ "sip_id" => $_POST["sip_id"]
+ )
+ );
+
+ if($updateSip !== false) {
+ _s("Successfully updated");
+ } else {
+ _e($updateSip);
+ }
+
+}
+
+
+/*************************** Call List ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "noteList") {
+
+ $requestData = $_REQUEST;
+ $getData = [];
+
+ // List of all columns name
+ $columns = array(
+ "",
+ "note_id",
+ "note_type",
+ "note_text"
+ );
+
+ // Count Total recrods
+
+ $totalFilteredRecords = $totalRecords = easySelectA(array(
+ "table" => "notes",
+ "fields" => "count(*) as totalRow",
+ "where" => array(
+ "is_trash = 0"
+ )
+ ))["data"][0]["totalRow"];
+
+ if($requestData['length'] == -1) {
+ $requestData['length'] = $totalRecords;
+ }
+
+ if(!empty($requestData["search"]["value"])) { // get data with search
+
+
+ $getData = easySelectA(array(
+ "table" => "notes as notes",
+ "fields" => "note_id, note_type, note_text",
+ "where" => array(
+ "notes.is_trash = 0 and note_created_by" => $_SESSION["uid"],
+ " and note_text LIKE" => $requestData['search']['value'] . "%",
+ ),
+ "orderby" => array(
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "limit" => array(
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ ));
+
+ $totalFilteredRecords = $getData ? $getData["count"] : 0;
+
+ } else { // Get data withouth search
+
+
+ $getData = easySelectA(array(
+ "table" => "notes as notes",
+ "fields" => "note_id, note_type, note_text",
+ "where" => array(
+ "notes.is_trash = 0 and note_created_by" => $_SESSION["uid"]
+ ),
+ "orderby" => array(
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "limit" => array(
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ ));
+
+ }
+
+ $allData = [];
+ // Check if there have more then zero data
+ if($getData) {
+
+ foreach($getData['data'] as $key => $value) {
+ $allNestedData = [];
+
+ $allNestedData[] = "";
+ $allNestedData[] = $value["note_id"];
+ $allNestedData[] = $value["note_type"];
+ $allNestedData[] = $value["note_text"];
+ $allNestedData[] = '
+
+ action
+
+ Toggle Dropdown
+
+
+
';
+
+ $allData[] = $allNestedData;
+ }
+ }
+
+
+ $jsonData = array (
+ "draw" => intval( $requestData['draw'] ),
+ "recordsTotal" => intval( $totalRecords ),
+ "recordsFiltered" => intval( $totalFilteredRecords ),
+ "data" => $allData
+ );
+
+ // Encode in Json Formate
+ echo json_encode($jsonData);
+
+}
+
+
+/***************** Delete Notes or Feedback ****************/
+if(isset($_GET['page']) and $_GET['page'] == "deleteNote") {
+
+ if(current_user_can("customer_support_note.Delete") !== true) {
+ echo '{
+ "title": "Sorry!",
+ "text": "you do not have permission to delete note or feedback.",
+ "showConfirmButton": true,
+ "showCloseButton": true,
+ "toast": false,
+ "icon": "error"
+ }';
+ return;
+ }
+
+ $deleteData = easyDelete(
+ "notes",
+ array(
+ "note_id" => $_POST["datatoDelete"]
+ )
+ );
+
+ if($deleteData === true) {
+ echo '{
+ "title": "The note or feedback has been deleted successfully."
+ }';
+ }
+}
+
+
+/************************** New Case **********************/
+if(isset($_GET['page']) and $_GET['page'] == "editNote") {
+
+ // select note
+ $note = easySelectA(array(
+ "table" => "notes",
+ "fields" => "note_type, note_text",
+ "where" => array(
+ "note_id" => $_GET["id"]
+ )
+ ))["data"][0];
+
+ // Include the modal header
+ modal_header("Edit {$note['note_type']}", full_website_address() . "/xhr/?module=customer-support&page=updateNote");
+
+ ?>
+
+
+
+ $_POST["noteText"],
+ ),
+ array(
+ "note_id" => $_POST["note_id"]
+ )
+ );
+
+ if($updateNote !== false) {
+ echo _s("Successfully updated");
+ }
+
+}
+
+
+
+/************************** new Voice Message Entry **********************/
+if(isset($_GET['page']) and $_GET['page'] == "newVoiceMessageEntry") {
+
+ // Include the modal header
+ modal_header("Add New Voice Messae", full_website_address() . "/xhr/?module=customer-support&page=addNewVoiceMessageEntry");
+
+ ?>
+
+
+
+ Description:
+
+
+
+ Record:
+
+
+
+ Numbers:
+
+
+
+
+
+
+ 0) {
+
+ $vmRecord = easyUpload(
+ $_FILES["vmRecord"],
+ "media/sounds/voice-message/",
+ $_POST["vmDescription"]."_". time(),
+ "audio"
+ );
+
+ if(!isset($vmRecord["success"])) {
+ return _e($vmRecord);
+ } else {
+ $vmRecord = $vmRecord["fileName"];
+ }
+
+ }
+
+ // Insert case
+ $insertVoiceMessage = easyInsert(
+ "voice_message",
+ array(
+ "vm_description" => $_POST["vmDescription"],
+ "vm_record" => $vmRecord,
+ "vm_added_on" => date("Y-m-d H:i:s"),
+ "vm_added_by" => $_SESSION["uid"]
+ ),
+ array(),
+ true
+ );
+
+ if( isset($insertVoiceMessage["status"]) and $insertVoiceMessage["status"] === "success" ) {
+
+ // insert numbers
+ $numbers = explode(",", $_POST["vmNumbers"] );
+
+ $insertNumbers = "INSERT INTO {$table_prefix}calls(
+ call_type,
+ call_status,
+ client_identity,
+ representative,
+ vm_id
+ ) VALUES ";
+
+ foreach($numbers as $number) {
+
+ $insertNumbers .= "(
+ 'Voice Message',
+ 'Pending',
+ '{$number}',
+ '{$_SESSION["uid"]}',
+ '{$insertVoiceMessage["last_insert_id"]}'
+ ),";
+
+ }
+
+ // Insert numbers in call table
+ $conn->query(substr_replace($insertNumbers, ";", -1, 1));
+
+ echo _s("Case added successfully");
+
+ }
+
+}
+
+
+/*************************** Representative List ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "voiceMessageList") {
+
+ $requestData = $_REQUEST;
+ $getData = [];
+
+ // List of all columns name
+ $columns = array(
+ "",
+ "vm_added_on",
+ "vm_description",
+ "",
+ "vm_status"
+ );
+
+ // Count Total recrods
+ $totalFilteredRecords = $totalRecords = easySelectA(array(
+ "table" => "voice_message",
+ "fields" => "count(*) as totalRow",
+ "where" => array(
+ "is_trash = 0"
+ )
+ ))["data"][0]["totalRow"];
+
+ if($requestData['length'] == -1) {
+ $requestData['length'] = $totalRecords;
+ }
+
+ if(!empty($requestData["search"]["value"])) { // get data with search
+
+ $getData = easySelectA(array(
+ "table" => "voice_message",
+ "fields" => "vm_id, vm_description, vm_record, vm_status, vm_added_on",
+ "where" => array(
+ "is_trash = 0",
+ " and vm_description LIKE" => "%". $requestData['search']['value'] . "%",
+ ),
+ "orderby" => array (
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "limit" => array (
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ ));
+
+
+ $totalFilteredRecords = $getData ? $getData["count"] : 0;
+
+ } else { // Get data withouth search
+
+ $getData = easySelectA(array(
+ "table" => "voice_message",
+ "fields" => "vm_id, vm_description, vm_record, vm_status, vm_added_on",
+ "where" => array(
+ "is_trash = 0"
+ ),
+ "orderby" => array (
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "limit" => array (
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ ));
+
+ }
+
+ $allData = [];
+ // Check if there have more then zero data
+ if(isset($getData['count']) and $getData['count'] > 0) {
+
+ foreach($getData['data'] as $key => $value) {
+ $allNestedData = [];
+ $allNestedData[] = "";
+ $allNestedData[] = $value["vm_added_on"];
+ $allNestedData[] = $value["vm_description"];
+ $allNestedData[] = "";
+ $allNestedData[] = $value["vm_status"];
+ $allNestedData[] = "Start Sending ";
+
+ $allData[] = $allNestedData;
+ }
+ }
+
+
+ $jsonData = array (
+ "draw" => intval( $requestData['draw'] ),
+ "recordsTotal" => intval( $totalRecords ),
+ "recordsFiltered" => intval( $totalFilteredRecords ),
+ "data" => $allData
+ );
+
+ // Encode in Json Formate
+ echo json_encode($jsonData);
+
+}
+
+
+
+/*************************** getVoiceMessageContact List ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "getVoiceMessageContact") {
+
+ // Update Voice Message to mark as sending
+ easyUpdate(
+ "voice_message",
+ array(
+ "vm_status" => "sending"
+ ),
+ array(
+ "vm_id" => $_POST["id"]
+ )
+ );
+
+ // Select recrods etc
+ $record = easySelectA(array(
+ "table" => "voice_message",
+ "fields" => "vm_description, vm_record",
+ "where" => array(
+ "vm_id" => $_POST["id"]
+ )
+ ))["data"][0];
+
+ // Select contacts
+ $contacts = easySelectA(array(
+ "table" => "calls",
+ "fields" => "client_identity",
+ "where" => array(
+ "is_trash = 0 and call_status = 'Pending' and vm_id" => $_POST["id"]
+ )
+ ));
+
+ $data = array(
+ "record" => $record["vm_record"],
+ "description" => $record["vm_description"],
+ "contacts" => array()
+ );
+
+ if($contacts !== false) {
+ foreach($contacts["data"] as $num) {
+ array_push( $data["contacts"], $num["client_identity"] );
+ }
+ }
+
+
+ echo json_encode($data);
+
+}
+
+
+if(isset($_GET['page']) and $_GET['page'] == "updateCallLog") {
+
+ // update the calls log
+ easyUpdate(
+ "calls",
+ array(
+ "call_datetime" => date("Y-m-d h:i:s"),
+ "call_direction" => "Outgoing",
+ "call_status" => $_POST["status"],
+ "duration" => $_POST["duration"]
+ ),
+ array(
+ "vm_id" => $_POST["vm_id"],
+ " and client_identity" => $_POST["number"],
+ )
+ );
+
+}
+
+
+/*************************** agentWiseCallStatistics List ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "agentWiseCallStatistics") {
+
+ $requestData = $_REQUEST;
+ $getData = [];
+
+ // List of all columns name
+ $columns = array(
+ "",
+ "emp_firstname",
+ "talk_time",
+ "total_answered",
+ "total_not_answered",
+ ""
+ );
+
+ // Count Total recrods
+ $totalFilteredRecords = $totalRecords = easySelectA(array(
+ "table" => "sip_credentials",
+ "fields" => "count(*) as totalRow",
+ "where" => array(
+ "is_trash = 0"
+ )
+ ))["data"][0]["totalRow"];
+
+ if($requestData['length'] == -1) {
+ $requestData['length'] = $totalRecords;
+ }
+
+ if(!empty($requestData["search"]["value"]) or !empty($requestData["columns"][1]['search']['value']) ) { // get data with search
+
+ $dateFilter = "";
+ if(!empty($requestData["columns"][1]['search']['value'])) {
+ $dateRange = explode(" - ", safe_input($requestData["columns"][1]['search']['value']));
+ $dateFilter = "and date(call_datetime) BETWEEN '{$dateRange[0]}' and '{$dateRange[1]}'";
+ }
+
+ $getData = easySelectA(array(
+ "table" => "calls as calls",
+ "fields" => "emp_firstname, emp_lastname, emp_positions,
+ sum( case when call_status = 'Answered' then duration end) as talk_time,
+ count(*) as total_call,
+ count( case when call_status = 'Answered' then duration end) as total_answered,
+ count( case when call_status = 'Missed' then duration end) as total_missed,
+ count( case when call_status = 'Not Answered' then duration end) as total_not_answered,
+ count( case when call_status = 'Busy' then duration end) as total_busy,
+ count( case when call_status = 'Unreachable' then duration end) as total_Unreachable
+ ",
+ "join" => array(
+ "left join {$table_prefix}users on representative = user_id",
+ "left join {$table_prefix}employees on user_emp_id = emp_id",
+ ),
+ "where" => array(
+ "calls.is_trash = 0 and emp_firstname like '{$requestData["search"]["value"]}%' $dateFilter"
+ ),
+ "orderby" => array (
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "groupby" => "representative",
+ "limit" => array(
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ ));
+
+ $totalFilteredRecords = $getData ? $getData["count"] : 0;
+
+ } else { // Get data withouth search
+
+ $getData = easySelectA(array(
+ "table" => "calls as calls",
+ "fields" => "emp_firstname, emp_lastname, emp_positions,
+ sum( case when call_status = 'Answered' then duration end) as talk_time,
+ count(*) as total_call,
+ count( case when call_status = 'Answered' then duration end) as total_answered,
+ count( case when call_status = 'Missed' then duration end) as total_missed,
+ count( case when call_status = 'Not Answered' then duration end) as total_not_answered,
+ count( case when call_status = 'Busy' then duration end) as total_busy,
+ count( case when call_status = 'Unreachable' then duration end) as total_Unreachable
+ ",
+ "join" => array(
+ "left join {$table_prefix}users on representative = user_id",
+ "left join {$table_prefix}employees on user_emp_id = emp_id",
+ ),
+ "where" => array(
+ "calls.is_trash = 0"
+ ),
+ "orderby" => array (
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ "groupby" => "representative",
+ "limit" => array(
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ ));
+
+ }
+
+ $allData = [];
+ // Check if there have more then zero data
+ if(isset($getData['count']) and $getData['count'] > 0) {
+
+ foreach($getData['data'] as $key => $value) {
+
+ // ATT = Average Talk Time
+ $att = (empty($value["talk_time"]) ? 1 : $value["talk_time"]) / (empty($value["total_answered"]) ? 1 : $value["total_answered"]);
+ $attSeconds = round($att) % 60;
+ $att = round(( $att - $attSeconds ) / 60);
+
+ $allNestedData = [];
+ $allNestedData[] = "";
+ $allNestedData[] = "{$value["emp_firstname"]} {$value["emp_lastname"]}";
+ $allNestedData[] = round($value["talk_time"] / 60) . " min(s)";
+ $allNestedData[] = $att .".". $attSeconds;
+ $allNestedData[] = $value["total_answered"];
+ $allNestedData[] = $value["total_not_answered"];
+ $allNestedData[] = $value["total_busy"];
+ $allNestedData[] = $value["total_missed"];
+ $allNestedData[] = $value["total_Unreachable"];
+ $allNestedData[] = $value["total_call"];
+
+ $allData[] = $allNestedData;
+ }
+ }
+
+
+ $jsonData = array (
+ "draw" => intval( $requestData['draw'] ),
+ "recordsTotal" => intval( $totalRecords ),
+ "recordsFiltered" => intval( $totalFilteredRecords ),
+ "data" => $allData
+ );
+
+ // Encode in Json Formate
+ echo json_encode($jsonData);
+
+}
+
+
+/*************************** Person List ***********************/
+if(isset($_GET['page']) and $_GET['page'] == "personListForCallCenter") {
+
+ $requestData = $_REQUEST;
+ $getData = [];
+
+ // List of all columns name for sorting
+ $columns = array(
+ "",
+ "person_full_name",
+ "person_designation",
+ "institute_name",
+ "person_phone",
+ "person_address"
+ );
+
+ // Count Total recrods
+ $totalFilteredRecords = $totalRecords = easySelectA(array(
+ "table" => "persons",
+ "fields" => "count(*) as totalRow",
+ "where" => array(
+ "is_trash = 0"
+ )
+ ))["data"][0]["totalRow"];
+
+ if($requestData['length'] == -1) {
+ $requestData['length'] = $totalRecords;
+ }
+
+ if(!empty($requestData["search"]["value"])) { // get data with search
+
+ $getData = easySelect(
+ "persons as person",
+ "person_id, person_full_name, person_type, person_designation, institute_name, person_phone, person_address,
+ upazila_name, district_name, division_name",
+ array (
+ "left join {$table_prefix}districts on person_district = district_id",
+ "left join {$table_prefix}divisions on person_division = division_id",
+ "left join {$table_prefix}upazilas on person_upazila = upazila_id",
+ "left join {$table_prefix}institute on person_institute = institute_id",
+ ),
+ array (
+ "person.is_trash = 0 and ( person_full_name LIKE '". safe_input($requestData['search']['value']) ."%' ",
+ " OR person_phone LIKE" => $requestData['search']['value'] . "%",
+ " OR person_email LIKE" => $requestData['search']['value'] . "%",
+ " OR institute_name LIKE" => $requestData['search']['value'] . "%",
+ " )"
+ ),
+ array (
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ array (
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ );
+
+ $totalFilteredRecords = $getData ? $getData["count"] : 0;
+
+ } else { // Get data withouth search
+
+ $getData = easySelect(
+ "persons as person",
+ "person_id, person_full_name, person_type, person_designation, institute_name, person_phone, person_address, upazila_name, district_name, division_name",
+ array (
+ "left join {$table_prefix}districts on person_district = district_id",
+ "left join {$table_prefix}divisions on person_division = division_id",
+ "left join {$table_prefix}upazilas on person_upazila = upazila_id",
+ "left join {$table_prefix}institute on person_institute = institute_id"
+ ),
+ array("person.is_trash = 0"),
+ array (
+ $columns[$requestData['order'][0]['column']] => $requestData['order'][0]['dir']
+ ),
+ array (
+ "start" => $requestData['start'],
+ "length" => $requestData['length']
+ )
+ );
+
+ }
+
+ $allData = [];
+ // Check if there have more then zero data
+ if(isset($getData['count']) and $getData['count'] > 0) {
+
+ foreach($getData['data'] as $key => $value) {
+ $allNestedData = [];
+ $allNestedData[] = "";
+ $allNestedData[] = "{$value['person_full_name']} , {$value['person_type']} {$value['person_designation']} {$value['institute_name']}";
+ $allNestedData[] = "{$value['person_phone']}";
+ $allNestedData[] = "{$value['person_address']}, {$value['upazila_name']}, {$value['district_name']}, {$value['division_name']}";
+ $allNestedData[] = 'View Specimen ';
+ // The action button
+ $allNestedData[] = '
+
+ action
+
+ Toggle Dropdown
+
+
+
';
+
+ $allData[] = $allNestedData;
+ }
+ }
+
+
+ $jsonData = array (
+ "draw" => intval( $requestData['draw'] ),
+ "recordsTotal" => intval( $totalRecords ),
+ "recordsFiltered" => intval( $totalFilteredRecords ),
+ "data" => $allData
+ );
+
+ // Encode in Json Formate
+ echo json_encode($jsonData);
+
+}
+
+?>
\ No newline at end of file
diff --git a/module/customer-support/all-call-history.php b/module/customer-support/all-call-history.php
new file mode 100644
index 0000000..d148fcd
--- /dev/null
+++ b/module/customer-support/all-call-history.php
@@ -0,0 +1,147 @@
+
+
+
+
diff --git a/module/customer-support/call-center-old.php b/module/customer-support/call-center-old.php
new file mode 100644
index 0000000..d35ada4
--- /dev/null
+++ b/module/customer-support/call-center-old.php
@@ -0,0 +1,559 @@
+
+
+
+ "sip_credentials",
+ "fields" => "sip_username, sip_password, sip_domain, sip_websocket_addr",
+ "where" => array(
+ "sip_representative" => $_SESSION["uid"]
+ )
+ ));
+
+ if ($selectSipCredentials !== false) {
+ $sip = $selectSipCredentials["data"][0];
+ echo "";
+ }
+
+ $getExtentionNumber = easySelectA(array(
+ "table" => "sip_credentials as sip_credential",
+ "fields" => "sip_username as extention, concat(emp_firstname, ' ', emp_lastname) as name",
+ "join" => array(
+ "left join {$table_prefix}users on sip_representative = user_id",
+ "left join {$table_prefix}employees on user_emp_id = emp_id",
+ ),
+ "where" => array(
+ "sip_credential.is_trash = 0"
+ )
+ ));
+
+ if ($getExtentionNumber !== false) {
+
+ echo "";
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = __("Person Details"); ?>
+ = __("Phone"); ?>
+ = __("Address"); ?>
+ = __("Specimen Products"); ?>
+ = __("Action"); ?>
+
+
+
+
+
+
+ = __("Person Details"); ?>
+ = __("Phone"); ?>
+ = __("Address"); ?>
+ = __("Specimen Products"); ?>
+ = __("Action"); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = __("ID"); ?>
+ = __("Photo"); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = __("Name"); ?>
+ = __("District"); ?>
+ = __("Division"); ?>
+ = __("Address"); ?>
+ = __("Contact"); ?>
+ = __("Action"); ?>
+
+
+
+
+
+
+ = __("Customer Name"); ?>
+ = __("District"); ?>
+ = __("Division"); ?>
+ = __("Address"); ?>
+ = __("Contact"); ?>
+ = __("Action"); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "notes",
+ "fields" => "note_text",
+ "where" => array(
+ "is_trash = 0 and note_type = 'feedback' and note_created_by" => $_SESSION["uid"]
+ )
+ ));
+
+ if ($selectFeedback !== false) {
+
+ foreach ($selectFeedback["data"] as $fKey => $fValue) {
+ echo '' . $fValue["note_text"] . ' ';
+ }
+ }
+
+ ?>
+
+ Add New
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "notes",
+ "fields" => "note_text",
+ "where" => array(
+ "is_trash = 0 and note_type = 'note' and note_created_by" => $_SESSION["uid"]
+ )
+ ));
+
+ if ($selectFeedback !== false) {
+
+ foreach ($selectFeedback["data"] as $fKey => $fValue) {
+ echo '' . $fValue["note_text"] . ' ';
+ }
+ }
+
+ ?>
+
+ Add New
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = __("Product Name"); ?>
+ = __("Edition"); ?>
+ = __("Category"); ?>
+ = __("Description"); ?>
+
+
+
+
+
+
+ = __("Product Name"); ?>
+
+
+ = __("All Ed."); ?>
+ "products",
+ "fields" => "product_edition",
+ "groupby" => "product_edition"
+ ));
+
+ if ($selectProductYear) {
+ foreach ($selectProductYear["data"] as $key => $value) {
+ echo "{$value['product_edition']} ";
+ }
+ }
+
+ ?>
+
+
+
+
+ = __("Category"); ?>...
+
+
+ = __("Description"); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/module/customer-support/call-center.php b/module/customer-support/call-center.php
new file mode 100644
index 0000000..87cab80
--- /dev/null
+++ b/module/customer-support/call-center.php
@@ -0,0 +1,850 @@
+
+
+
+
+
+ "sip_credentials",
+ "fields" => "sip_username, sip_password, sip_domain, sip_websocket_addr",
+ "where" => array(
+ "sip_representative" => $_SESSION["uid"]
+ )
+ ));
+
+ if ($selectSipCredentials !== false) {
+ $sip = $selectSipCredentials["data"][0];
+ echo "";
+ }
+
+ $getExtentionNumber = easySelectA(array(
+ "table" => "sip_credentials as sip_credential",
+ "fields" => "sip_username as extention, concat(emp_firstname, ' ', emp_lastname) as name",
+ "join" => array(
+ "left join {$table_prefix}users on sip_representative = user_id",
+ "left join {$table_prefix}employees on user_emp_id = emp_id",
+ ),
+ "where" => array(
+ "sip_credential.is_trash = 0"
+ )
+ ));
+
+ if ($getExtentionNumber !== false) {
+
+ echo "";
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
00:00:00
+
+
+
+
+ Dial
+ End Call
+
+
+
+
+
+ Accept
+ Reject
+
+
+
+
+
+
+
+
+
+
Do not Disturb mode is enabled. No incoming call will work.
+
+
+
+
+
+
+
+
+
+ "sip_credentials as sip",
+ "fields" => "sip_username as ext, emp_id, emp_firstname, emp_lastname",
+ "join" => array(
+ "left join {$table_prefix}users as user on user_id = sip_representative",
+ "left join {$table_prefix}employees on emp_id = user_emp_id"
+ ),
+ "where" => array(
+ "user.is_trash = 0 and user_status = 'Active'"
+ )
+ ));
+
+ if( $selectUserExtension !== false ) {
+
+ foreach($selectUserExtension["data"] as $key => $agent ) {
+
+ echo "
+
+
+
+
+
{$agent['emp_firstname']} {$agent['emp_lastname']}
+
Available
+
+
";
+
+ }
+
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Bangladesh is a land of rivers. Most of her lands are lowings
+
Bangladesh is a land of rivers. Most of her lands are lowings
+
Bangladesh is a land of rivers. Most of her lands are lowings
+
Bangladesh is a land of rivers. Most of her lands are lowings
+
Bangladesh is a land of rivers. Most of her lands are lowings
+
Bangladesh is a land of rivers. Most of her lands are lowings
+
Bangladesh is a land of rivers. Most of her lands are lowings
+
Bangladesh is a land of rivers. Most of her lands are lowings
+
Bangladesh is a land of rivers. Most of her lands are lowings
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
= __("Order/ Service"); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Sorry! No order found.
+
+
+
+
+
+
+
= __("Call History"); ?>
+
+
+
+ = __("Cases"); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
= __("Notes"); ?>
+
+
+
+ "notes",
+ "fields" => "note_text",
+ "where" => array(
+ "is_trash = 0 and note_type = 'note' and note_created_by" => $_SESSION["uid"]
+ )
+ ));
+
+ if ($selectFeedback !== false) {
+
+ foreach ($selectFeedback["data"] as $fKey => $fValue) {
+ echo '' . $fValue["note_text"] . ' ';
+ }
+ }
+
+ ?>
+
+ Add New
+
+
+
+
+
+
+ = __("Message History"); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = __("Call Feedback"); ?>
+
+
+
+
+
+
+
+ = __("Call Reason"); ?>
+
+ = __("Select Reason"); ?>....
+
+
+
+
+ = __("Specimen Copy Received"); ?>
+
+ Select one...
+ No
+ Yes
+ Partial
+ Not Sure
+
+
+
+
+ = __("Informative"); ?>
+
+ Select one...
+ No
+ Yes
+
+
+
+ = __("Sale Our Book"); ?>
+
+ Select one...
+ No
+ Yes
+ Sold Before
+
+
+
+ = __("Use Our Book"); ?>
+
+ Select one...
+ No
+ Yes
+ Used Before
+
+
+
+ = __("MR Feedback"); ?>
+
+ Select one...
+ No Comment
+ Positive
+ Negative
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "notes",
+ "fields" => "note_text",
+ "where" => array(
+ "is_trash = 0 and note_type = 'feedback' and note_created_by" => $_SESSION["uid"]
+ )
+ ));
+
+ if ($selectFeedback !== false) {
+
+ foreach ($selectFeedback["data"] as $fKey => $fValue) {
+ echo '' . $fValue["note_text"] . ' ';
+ }
+ }
+
+ ?>
+
+ Add New
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Agent In Call
+ 0
+
+
+
+
+
+
+
+
+
+
+ Busy Agent
+ 0
+
+
+
+
+
+
+
+
+
+
+ Free Agent
+ 0
+
+
+
+
+
+
+
+
+
+
+ Agent Unavailable
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/module/customer-support/case-list-all.php b/module/customer-support/case-list-all.php
new file mode 100644
index 0000000..0d3b1fc
--- /dev/null
+++ b/module/customer-support/case-list-all.php
@@ -0,0 +1,121 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/module/customer-support/case-list.php b/module/customer-support/case-list.php
new file mode 100644
index 0000000..48df834
--- /dev/null
+++ b/module/customer-support/case-list.php
@@ -0,0 +1,11 @@
+
\ No newline at end of file
diff --git a/module/customer-support/case-reply-view.php b/module/customer-support/case-reply-view.php
new file mode 100644
index 0000000..39f15ef
--- /dev/null
+++ b/module/customer-support/case-reply-view.php
@@ -0,0 +1,762 @@
+
+
+
+
+
+ "cases as cases",
+ "fields" => "case_id, case_datetime, case_title, case_priority, case_type, case_status, last_reply,
+ case_site, case_assigned_to, case_belongs_to,
+ concat(assigned_to.emp_firstname, ' ', assigned_to.emp_lastname) as case_assign_name,
+ concat(belongs_to.emp_firstname, ' ', belongs_to.emp_lastname) as case_belongs_to_name,
+ case_customer, customer_name, customer_phone, customer_email, customer_address,
+ case_person, person_full_name, person_phone, person_email, person_address,
+ person_type, person_designation, institute_name, institute_type, upazila_name, district_name, division_name
+ ",
+ "join" => array(
+ "left join {$table_prefix}users on user_id = case_assigned_to",
+ "left join {$table_prefix}employees as assigned_to on assigned_to.emp_id = user_emp_id",
+ "left join {$table_prefix}employees as belongs_to on belongs_to.emp_id = case_belongs_to",
+ "left join {$table_prefix}persons on person_id = case_person",
+ "left join {$table_prefix}districts on district_id = person_district",
+ "left join {$table_prefix}divisions on division_id = person_division",
+ "left join {$table_prefix}upazilas on upazila_id = person_upazila",
+ "left join {$table_prefix}institute on institute_id = person_institute",
+ "left join {$table_prefix}customers on customer_id = case_customer",
+
+
+ "left join (select
+ max(reply_datetime) as last_reply,
+ reply_case_id
+ from {$table_prefix}case_replies
+ where is_trash = 0
+ group by reply_case_id
+ ) as replies on replies.reply_case_id = case_id"
+ ),
+ "where" => array(
+ "cases.is_trash = 0 and cases.case_id" => $_GET["case_id"]
+ )
+ ));
+
+ if($selectCase === false) {
+
+ echo '
Sorry! No Ticket/ Case found.
';
+
+ } else {
+
+ $case = $selectCase["data"][0];
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ "case_replies as reply",
+ "fields" => "reply_id, reply_type, reply_datetime, reply_details, reply_attachment,
+ if(emp_firstname is null, customer_name, concat(emp_firstname, ' ', emp_lastname)) as reply_by,
+ reply_by_customer
+ ",
+ "join" => array(
+ "left join {$table_prefix}users on user_id = reply_by_agent",
+ "left join {$table_prefix}employees on emp_id = user_emp_id",
+ "left join {$table_prefix}customers on customer_id = reply_by_customer"
+ ),
+ "where" => array(
+ "reply.is_trash = 0 and reply_case_id" => $_GET["case_id"]
+ ),
+ "orderby" => array(
+ "reply_id" => "DESC"
+ )
+ ));
+
+ if($selectReplies !== false) {
+
+ foreach($selectReplies["data"] as $reply) {
+
+ $time_elaps = time_elapsed_string($reply["reply_datetime"]) . " (" . date("d F, Y h:m A", strtotime($reply["reply_datetime"])) .")";
+
+ $attachment = "";
+ if($reply["reply_attachment"] !== null) {
+
+ $listAttachment = unserialize( html_entity_decode($reply["reply_attachment"]) );
+
+ foreach($listAttachment as $image) {
+ $attachment .= "
";
+ }
+
+ }
+
+
+ // Define user and reply type
+ $userType = "
Staff";
+ $replyType = "
Public";
+ $replyClass = 'reply';
+ $replyTypeMoveTo = 'Private';
+ if( $reply["reply_by_customer"] !== null ) {
+ $userType = "
Customer";
+ }
+
+ if( $reply["reply_type"] === "Private" ) {
+ $replyType = "
Private";
+ $replyClass = 'reply private';
+ $replyTypeMoveTo = 'Public';
+ }
+
+ // If there have any attachment then show them
+ if($attachment !== "") {
+ $attachment = "
";
+ }
+
+
+ echo "
+
+
+
{$reply["reply_by"]}
+
+ {$time_elaps}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {$userType}
+ {$replyType}
+
+
+
+ ". str_replace('\n', '', html_entity_decode($reply["reply_details"]) ) ."
+
+ $attachment
+
+
+
";
+
+ }
+
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ,
+
+
+
+
+
+
Contact
+
+
+
+
+
" data-target="#modalDefault"> View Specimen Copies
+
+
+
+
Address
+
+
+
+
+
Recent Case/ Tickets
+
+
+ "cases",
+ "fields" => "case_id, case_title, case_status",
+ "where" => array(
+ "is_trash = 0 and case_id != {$_GET["case_id"]} and case_person" => $case["case_person"]
+ ),
+ "orderby" => array(
+ "case_id" => "DESC"
+ ),
+ "limit" => array(
+ "start" => 0,
+ "length" => 5
+ )
+ ));
+
+ if($selectCaseForThisPerson !== false) {
+ foreach($selectCaseForThisPerson["data"] as $personCase) {
+ echo "
{$personCase['case_title']} ({$personCase['case_status']})
";
+
+ }
+ } else {
+ echo '
Sorry! No Ticket/ Cases found.
';
+ }
+
+ ?>
+
+
+
+
Call Log
+
+ "calls",
+ "fields" => "count(*) as totalCall, max(call_datetime) as lastCallTime",
+ "where" => array(
+ "client_identity LIKE" => explode(",", $case["person_phone"])[0] . "%"
+ ),
+ "groupby" => "client_identity"
+ ));
+
+
+ if($selectCalls !== false) {
+
+ $callStats = $selectCalls["data"][0];
+ echo '
+ Call Count: '. $callStats["totalCall"] .';
+ Last Call: '. time_elapsed_string($callStats["lastCallTime"]) .' ('. $callStats["lastCallTime"] .')
+
';
+ } else {
+ echo '
Sorry! No calls found.
';
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
Contact
+
+
+
+
+
+
+
Address
+
+
+
+
+
Recent Case/ Tickets
+
+
+ "cases",
+ "fields" => "case_id, case_title, case_status",
+ "where" => array(
+ "is_trash = 0 and case_id != {$_GET["case_id"]} and case_customer" => $case["case_customer"]
+ ),
+ "orderby" => array(
+ "case_id" => "DESC"
+ ),
+ "limit" => array(
+ "start" => 0,
+ "length" => 5
+ )
+ ));
+
+ if($selectCaseForThisCustomer !== false) {
+ foreach($selectCaseForThisCustomer["data"] as $customerCase) {
+ echo "
{$personCase['case_title']} ({$personCase['case_status']})
";
+
+ }
+ } else {
+ echo '
Sorry! No Ticket/ Cases found.
';
+ }
+
+ ?>
+
+
+
+
Call Log
+
+ "calls",
+ "fields" => "count(*) as totalCall, max(call_datetime) as lastCallTime",
+ "where" => array(
+ "client_identity LIKE" => explode(",", $case["customer_phone"])[0] . "%"
+ ),
+ "groupby" => "client_identity"
+ ));
+
+
+ if($selectCalls !== false) {
+
+ $callStats = $selectCalls["data"][0];
+ echo '
+ Call Count: '. $callStats["totalCall"] .';
+ Last Call: '. time_elapsed_string($callStats["lastCallTime"]) .' ('. $callStats["lastCallTime"] .')
+
';
+ } else {
+ echo '
Sorry! No calls found.
';
+ }
+
+ ?>
+
+ Sorry! No data found.';
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = __("Title:"); ?>
+ " class="form-control">
+
+
+
+
+
+ = __("Prority:"); ?>
+
+ = __("Select Prority"); ?>....
+ {$priority}";
+ }
+ ?>
+
+
+
+
+
+ = __("Type:"); ?>
+
+ = __("Select Type"); ?>....
+ {$type}";
+ }
+ ?>
+
+
+
+
+
+ = __("Status:"); ?>
+
+ = __("Select Status"); ?>....
+ {$status}";
+ }
+ ?>
+
+
+
+
+
+ = __("Site:"); ?>
+ " class="form-control">
+
+
+
+
+
+
+ = __("Customer:"); ?>
+
+ = __("Select Customer"); ?>....
+ {$case["customer_name"]}";
+ }
+ ?>
+
+
+
+
+ = __("Person/ Lead:"); ?>
+
+ = __("Select Person/ Lead"); ?>....
+ {$case["person_full_name"]}";
+ }
+ ?>
+
+
+
+
+ = __("Assign To:"); ?>
+
+ = __("Select user"); ?>....
+ {$case["case_assign_name"]}";
+ }
+ ?>
+
+
+
+
+ = __("Belongs To:"); ?>
+
+ = __("Select Employee"); ?>....
+ {$case["case_belongs_to_name"]}";
+ }
+ ?>
+
+
+
+
">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/module/customer-support/dashboard.php b/module/customer-support/dashboard.php
new file mode 100644
index 0000000..2e0af63
--- /dev/null
+++ b/module/customer-support/dashboard.php
@@ -0,0 +1,206 @@
+
+
+
+
+ $call){
+
+ if( !in_array($call["db_date"], $dates) ) {
+ array_push($dates, $call["db_date"]);
+ }
+
+ // If call status empty then set zero in all call type
+ if( empty($call["call_status"]) ) {
+ array_push($unreachableCall, 0);
+ array_push($busyCall, 0);
+ array_push($notAnsweredCall, 0);
+ array_push($answeredCall, 0);
+ }
+
+ if( $call["call_status"] === "Unreachable" ) {
+
+ array_push($unreachableCall, $call["totalCall"]);
+
+ } else if( $call["call_status"] === "Busy" ) {
+
+ array_push($busyCall, $call["totalCall"]);
+
+ } else if( $call["call_status"] === "Not Answered" ) {
+
+ array_push($notAnsweredCall, $call["totalCall"]);
+
+ } else if( $call["call_status"] === "Answered" ) {
+
+ array_push($answeredCall, $call["totalCall"]);
+
+ }
+
+ }
+
+ }
+
+ $callDates = __(json_encode($dates));
+ $unreachableCall = json_encode($unreachableCall);
+ $busyCall = json_encode($busyCall);
+ $notAnsweredCall = json_encode($notAnsweredCall);
+ $answeredCall = json_encode($answeredCall);
+
+ ?>
+
+
+
+
diff --git a/module/customer-support/introductory.php b/module/customer-support/introductory.php
new file mode 100644
index 0000000..8d34ed6
--- /dev/null
+++ b/module/customer-support/introductory.php
@@ -0,0 +1,104 @@
+ "#",
+ "title" => "",
+ "t_icon" => "fa fa-assistive-listening-systems"
+);
+$menu["Customer Support"]["Dashboard"] = array (
+ "t_link" => full_website_address() . "/customer-support/dashboard/",
+ "title" => "Customer Support Dashboard",
+ "t_icon" => "fa fa-dashboard",
+ "dload" => true, // This will disable ajax loading
+ "__?" => current_user_can("customer_support_dashboard.View")
+);
+$menu["Customer Support"]["Call Center"] = array (
+ "t_link" => full_website_address() . "/customer-support/call-center/",
+ "title" => "Call Center Dashboard",
+ "t_icon" => "fa fa-headphones",
+ "dload" => true,
+ "__?" => current_user_can("customer_support_call_center.View")
+);
+$menu["Customer Support"]["Call Center Old"] = array (
+ "t_link" => full_website_address() . "/customer-support/call-center-old/",
+ "title" => "Call Center Dashboard",
+ "t_icon" => "fa fa-headphones",
+ "dload" => true,
+ "__?" => current_user_can("customer_support_call_center.View")
+);
+$menu["Customer Support"]["Voice Message"] = array (
+ "t_link" => full_website_address() . "/customer-support/voice-message/",
+ "title" => "Voice Brodcasting System",
+ "t_icon" => "fa fa-volume-up",
+ "dload" => true,
+ "__?" => current_user_can("customer_support_voice_message.View || customer_support_voice_message.Add || customer_support_voice_message.Edit || customer_support_voice_message.Delete")
+);
+$menu["Customer Support"]["Case List"] = array (
+ "t_link" => full_website_address() . "/customer-support/case-list/",
+ "title" => "Case/ Ticket List",
+ "t_icon" => "fa fa-exclamation-circle",
+ "__?" => current_user_can("customer_support_cases.View || customer_support_cases.Add || customer_support_cases.Edit || customer_support_cases.Delete")
+);
+$menu["Customer Support"]["My Call History"] = array (
+ "t_link" => full_website_address() . "/customer-support/my-call-history/",
+ "title" => "My Call History",
+ "t_icon" => "fa fa-headphones",
+ "__?" => current_user_can("customer_support_my_call_history.View || customer_support_my_call_history.Add || customer_support_my_call_history.Edit || customer_support_my_call_history.Delete")
+);
+$menu["Customer Support"]["All Call History"] = array (
+ "t_link" => full_website_address() . "/customer-support/all-call-history/",
+ "title" => "All Call History",
+ "t_icon" => "fa fa-phone",
+ "__?" => current_user_can("customer_support_all_call_history.View || customer_support_all_call_history.Add || customer_support_all_call_history.Edit || customer_support_all_call_history.Delete")
+);
+$menu["Customer Support"]["SMS"] = array (
+ "t_link" => full_website_address() . "/customer-support/sms-list/",
+ "title" => "SMS List",
+ "t_icon" => "fa fa-comment",
+ "__?" => current_user_can("customer_support_sms.View || customer_support_sms.Add || customer_support_sms.Edit || customer_support_sms.Delete")
+);
+$menu["Customer Support"]["Notes/ Feedback"] = array (
+ "t_link" => full_website_address() . "/customer-support/note-list/",
+ "title" => "Notes/ Feedback List",
+ "t_icon" => "fa fa-sticky-note",
+ "__?" => current_user_can("customer_support_note.View || customer_support_note.Add || customer_support_note.Edit || customer_support_note.Delete")
+);
+$menu["Customer Support"]["Representative"] = array (
+ "t_link" => full_website_address() . "/customer-support/representative-list/",
+ "title" => "Representative List",
+ "t_icon" => "fa fa-user",
+ "__?" => current_user_can("customer_support_representative.View || customer_support_representative.Add || customer_support_representative.Edit || customer_support_representative.Delete")
+);
+
+
+// Add menu in specific position
+add_menu($menu, 7);
+
+
+// Permissions
+add_permission(
+ array(
+ "customer_support_dashboard" => array("View"),
+ "customer_support_call_center" => array("View"),
+ "customer_support_cases" => "",
+ "customer_support_my_call_history" => "",
+ "customer_support_all_call_history" => "",
+ "customer_support_sms" => "",
+ "customer_support_representative" => "",
+ "customer_support_note" => ""
+ )
+)
+
+
+
+?>
\ No newline at end of file
diff --git a/module/customer-support/my-call-history.php b/module/customer-support/my-call-history.php
new file mode 100644
index 0000000..236e781
--- /dev/null
+++ b/module/customer-support/my-call-history.php
@@ -0,0 +1,97 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/module/customer-support/note-list.php b/module/customer-support/note-list.php
new file mode 100644
index 0000000..99aec7e
--- /dev/null
+++ b/module/customer-support/note-list.php
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/module/customer-support/representative-list.php b/module/customer-support/representative-list.php
new file mode 100644
index 0000000..2878b5d
--- /dev/null
+++ b/module/customer-support/representative-list.php
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/module/customer-support/screenshot.png b/module/customer-support/screenshot.png
new file mode 100644
index 0000000..48db2b4
Binary files /dev/null and b/module/customer-support/screenshot.png differ
diff --git a/module/customer-support/sms-list.php b/module/customer-support/sms-list.php
new file mode 100644
index 0000000..048a271
--- /dev/null
+++ b/module/customer-support/sms-list.php
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/module/customer-support/voice-message.php b/module/customer-support/voice-message.php
new file mode 100644
index 0000000..df402f9
--- /dev/null
+++ b/module/customer-support/voice-message.php
@@ -0,0 +1,102 @@
+ "sip_credentials",
+ "fields" => "sip_username, sip_password, sip_domain, sip_websocket_addr",
+ "where" => array(
+ "sip_representative" => $_SESSION["uid"]
+ )
+));
+
+if($selectSipCredentials !== false) {
+ $sip = $selectSipCredentials["data"][0];
+ echo "";
+}
+
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Click Start Sending to initiate the terminal
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/module/home2.php b/module/home2.php
new file mode 100644
index 0000000..d23da0e
--- /dev/null
+++ b/module/home2.php
@@ -0,0 +1,322 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
= __("This Year Product Sales"); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
= __("Total Customers"); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
= __("Total Products"); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = __("Product Name"); ?>
+ = __("Sold Qnt"); ?>
+
+
+
+
+ "product_stock as product_stock",
+ "fields" => "product_name, product_unit, sum(stock_item_qty) as totalItemQnt",
+ "join" => array(
+ "left join {$table_prefix}products on stock_product_id = product_id"
+ ),
+ "where" => array(
+ "product_stock.is_trash = 0 and stock_type" => 'sale',
+ ""
+ ),
+ "having" => array(
+ "max(stock_entry_date) >= CONCAT(YEAR(CURRENT_DATE),'-',01,'-',01) AND max(stock_entry_date) <= CONCAT(YEAR(CURRENT_DATE),'-',12,'-',31)"
+ ),
+ "groupby" => "stock_product_id",
+ "orderby" => array(
+ "sum(stock_item_qty)" => "DESC"
+ ),
+ "limit" => array(
+ "start" => 0,
+ "length" => 10
+ )
+ ));
+ $num = 1;
+ if ($topProduct) {
+ foreach ($topProduct["data"] as $key => $product) {
+ echo "";
+ echo "$num. {$product['product_name']} ";
+ echo "" . __(number_format($product['totalItemQnt'], 2)) . " " . __($product['product_unit']) . " ";
+ echo " ";
+ $num++;
+ }
+ } else {
+ echo "
+
+ No Data Found!
+
+ ";
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = __("Product Name"); ?>
+ = __("Left Stock"); ?>
+
+
+
+
+ curdate()
+ GROUP BY pbs.vp_id
+ order by base_stock_in ASC
+ limit 0,10
+ ");
+
+ $num = 1;
+ if ($select_low_product) {
+ foreach ($select_low_product["data"] as $key => $product) {
+ echo "";
+ echo "$num. {$product['product_name']} ";
+ echo "" . __(number_format($product['base_stock_in'] / $product['base_qty'], 2)) . " " . __($product['product_unit']) . " ";
+ echo " ";
+ $num++;
+ }
+ } else {
+ echo "
+
+ No Data Found!
+
+ ";
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = DATE_SUB(NOW(), INTERVAL 30 DAY) group by sales_delivery_date
+ ");
+
+ $dateStart = date('Y-m-d', strtotime('today - 30 days'));
+
+ $i = 0;
+ $newdate = array();
+ $newvalue = array();
+
+ while ($dateStart <= date("Y-m-d")) {
+
+ $dateStart = date("Y-m-d", strtotime("$dateStart + 1 day"));
+
+ if (isset($salesData["data"][$i]) && $salesData["data"][$i]["sales_delivery_date"] == $dateStart) {
+
+ array_push($newdate, $salesData["data"][$i]["sales_delivery_date"]);
+ array_push($newvalue, $salesData["data"][$i]["sales_quantity"]);
+ $i++;
+ } else {
+
+ array_push($newdate, $dateStart);
+ array_push($newvalue, 0);
+ }
+ }
+
+ $salesDate = __(json_encode($newdate));
+ $salesAmount = json_encode($newvalue);
+
+ ?>
+
+
+
+
\ No newline at end of file
diff --git a/module/home_back.php b/module/home_back.php
new file mode 100644
index 0000000..8987ccd
--- /dev/null
+++ b/module/home_back.php
@@ -0,0 +1,473 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
= __("This Year Product Sales"); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
= __("Total Customers"); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
= __("Total Products"); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = __("Customer Name"); ?>
+ = __("Previous Year"); ?>
+ = __("Running Year"); ?>
+ = __("Increase Rate"); ?>
+
+
+
+
+ "customers",
+ "fields" => "customer_id, customer_name, upazila_name, district_name,
+ round(previous_year_total_sales, 2) as previous_year_total_purchase,
+ round(current_year_total_sales, 2) as current_year_total_purchase,
+ round( ( current_year_total_sales - previous_year_total_sales ) / previous_year_total_sales * 100) as increased_rate
+ ",
+ "join" => array(
+ "left join {$table_prefix}upazilas on customer_upazila = upazila_id",
+ "left join {$table_prefix}districts on customer_district = district_id",
+ "left join (
+ select
+ sales_customer_id,
+ sum( CASE WHEN YEAR(sales_delivery_date) = YEAR( CURDATE() - INTERVAL 1 YEAR ) THEN sales_grand_total END ) as previous_year_total_sales,
+ sum( CASE WHEN YEAR(sales_delivery_date) = YEAR( CURDATE() ) THEN sales_grand_total END ) as current_year_total_sales
+ from ro_sales
+ where is_trash = 0
+ group by sales_customer_id
+ ) as customer_sale on sales_customer_id = customer_id"
+ ),
+ "where" => array(
+ "previous_year_total_sales is not null and previous_year_total_sales < current_year_total_sales and current_year_total_sales > 100000"
+ ),
+ "orderby" => array(
+ "increased_rate" => "DESC"
+ ),
+ "limit" => array(
+ "start" => 0,
+ "length" => 10
+ )
+
+ ));
+
+
+ $num = 1;
+ if($getPurchaseIncreasedCustomer !== false) {
+
+ foreach($getPurchaseIncreasedCustomer["data"] as $key => $customer) {
+ echo "";
+ echo "{$num}. {$customer['customer_name']}, {$customer['upazila_name']}, {$customer['district_name']} ";
+
+ echo "". to_money($customer['previous_year_total_purchase']) ." ";
+ echo "". to_money($customer['current_year_total_purchase']) ." ";
+ echo " {$customer['increased_rate']}% ";
+
+ echo " ";
+ $num++;
+ }
+
+ } else {
+
+ echo "
+
+ No Data Found!
+
+ ";
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = __("Customer Name"); ?>
+ = __("Previous Year"); ?>
+ = __("Running Year"); ?>
+ = __("Descrease Rate"); ?>
+
+
+
+
+ "customers",
+ "fields" => "customer_id, customer_name, upazila_name, district_name,
+ round(previous_year_total_sales, 2) as previous_year_total_purchase,
+ round(current_year_total_sales, 2) as current_year_total_purchase,
+ round( ( previous_year_total_sales - current_year_total_sales ) / previous_year_total_sales * 100) as decreased_rate
+ ",
+ "join" => array(
+ "left join {$table_prefix}upazilas on customer_upazila = upazila_id",
+ "left join {$table_prefix}districts on customer_district = district_id",
+ "left join (
+ select
+ sales_customer_id,
+ sum( CASE WHEN YEAR(sales_delivery_date) = YEAR( CURDATE() - INTERVAL 1 YEAR ) THEN sales_grand_total END ) as previous_year_total_sales,
+ sum( CASE WHEN YEAR(sales_delivery_date) = YEAR( CURDATE() ) THEN sales_grand_total END ) as current_year_total_sales
+ from ro_sales
+ where is_trash = 0
+ group by sales_customer_id
+ ) as customer_sale on sales_customer_id = customer_id"
+ ),
+ "where" => array(
+ "previous_year_total_sales is not null and previous_year_total_sales > current_year_total_sales and previous_year_total_sales > 100000"
+ ),
+ "orderby" => array(
+ "decreased_rate" => "DESC"
+ ),
+ "limit" => array(
+ "start" => 0,
+ "length" => 10
+ )
+
+ ));
+
+
+ $num = 1;
+ if($getPurchaseIncreasedCustomer !== false) {
+
+ foreach($getPurchaseIncreasedCustomer["data"] as $key => $customer) {
+ echo "";
+ echo "{$num}. {$customer['customer_name']}, {$customer['upazila_name']}, {$customer['district_name']} ";
+
+ echo "". to_money($customer['previous_year_total_purchase']) ." ";
+ echo "". to_money($customer['current_year_total_purchase']) ." ";
+ echo " {$customer['decreased_rate']}% ";
+
+ echo " ";
+ $num++;
+ }
+
+ } else {
+
+ echo "
+
+ No Data Found!
+
+ ";
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = __("Product Name"); ?>
+ = __("Sold Qnt"); ?>
+
+
+
+
+ "product_stock as product_stock",
+ "fields" => "product_name, product_unit, sum(stock_item_qty) as totalItemQnt",
+ "join" => array(
+ "left join {$table_prefix}products on stock_product_id = product_id"
+ ),
+ "where" => array(
+ "product_stock.is_trash = 0 and stock_type" => 'sale',
+ ""
+ ),
+ "having" => array(
+ "max(stock_entry_date) >= CONCAT(YEAR(CURRENT_DATE),'-',01,'-',01) AND max(stock_entry_date) <= CONCAT(YEAR(CURRENT_DATE),'-',12,'-',31)"
+ ),
+ "groupby" => "stock_product_id",
+ "orderby" => array(
+ "sum(stock_item_qty)" => "DESC"
+ ),
+ "limit" => array(
+ "start" => 0,
+ "length" => 10
+ )
+ ));
+ $num = 1;
+ if($topProduct) {
+ foreach($topProduct["data"] as $key => $product) {
+ echo "";
+ echo "$num. {$product['product_name']} ";
+ echo "". __(number_format($product['totalItemQnt'], 2)) . " " . __($product['product_unit']) ." ";
+ echo " ";
+ $num++;
+ }
+ } else {
+ echo "
+
+ No Data Found!
+
+ ";
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = __("Product Name"); ?>
+ = __("Left Stock"); ?>
+
+
+
+
+ curdate()
+ GROUP BY pbs.vp_id
+ order by base_stock_in ASC
+ limit 0,10
+ ");
+
+ $num = 1;
+ if($select_low_product) {
+ foreach($select_low_product["data"] as $key => $product) {
+ echo "";
+ echo "$num. {$product['product_name']} ";
+ echo "". __(number_format($product['base_stock_in']/$product['base_qty'], 2)) . " " . __($product['product_unit']) ." ";
+ echo " ";
+ $num++;
+ }
+ } else {
+ echo "
+
+ No Data Found!
+
+ ";
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/theme/rui/footer.php b/theme/rui/footer.php
index 491aa85..26c9871 100644
--- a/theme/rui/footer.php
+++ b/theme/rui/footer.php
@@ -244,7 +244,7 @@