var _globals=new Globals,dxlistCustomer=null,dxlistPurpose=null,isme=null,dataItem=null,popup=null,customer={},setIntervalLoad=null,popupOptions={width:"95%",height:"98%",showCloseButton:!0,showTitle:!0,contentTemplate:function(){return $("<div id='popupCustomerContainer' style='height: 100%;' />").append($("<div>").html("<b><i class='fas fa-user' style='width: 20px;text-align: center;'></i> "+customer.customerName+"</b>"),$("<div>").html("<i class='fas fa-car' style='width: 18px;text-align: center;'></i> "+customer.plate+(customer.carType?" ("+customer.carType+")":"")),$("<div>").html("<div id='popupListPurposeCustomer' style='height: 35px;' ></div>"))},onShown:function(t){dxlistPurpose=$("#popupListPurposeCustomer").dxList({height:"100%",noDataText:"",dataSource:dataItem.purposes,itemTemplate:function(t,e){var a=$("<div>").addClass("customer"),s=$("<div>").append($("<div>").dxButton({text:t.title,clickAction:function(t){showHelloWorld()}}));return a.append(s),a},onItemClick:function(t){set_purpose(customer.id,t.itemData.title),popup.hide(),set_dataListCustomer(),setIntervalLoad=setInterval((function(){set_dataListCustomer()}),3e3)}}).dxList("instance")},showTitle:!0,title:customer.customerName,visible:!1,dragEnabled:!1,closeOnOutsideClick:!0};async function get_isme(){await axios({method:"post",url:"/api/staffs/isme",headers:{Authorization:"Bearer "+new URL(location.href).searchParams.get("token"),"content-type":"application/x-www-form-urlencoded"},data:null}).then(t=>{isme=t.data,set_dataListCustomer(),setIntervalLoad=setInterval((function(){set_dataListCustomer()}),3e3)}).catch(t=>{})}async function set_dataListCustomer(){const t=new URLSearchParams;t.append("branchID",isme.branchID),t.append("fromDate",new Date),t.append("toDate",new Date),await axios({method:"post",url:"/api/visit-customers/searchFrm",headers:{Authorization:"Bearer "+new URL(location.href).searchParams.get("token"),"content-type":"application/x-www-form-urlencoded"},data:t}).then(t=>{dxlistCustomer.option("dataSource",t.data)}).catch(t=>{})}async function set_purpose(t,e){const a=new URLSearchParams;a.append("id",t),a.append("purpose",e),a.append("__tcms_model_binding","VisitCustomersModel"),await axios({method:"post",url:"/api/visit-customers/update",headers:{Authorization:"Bearer "+new URL(location.href).searchParams.get("token"),"content-type":"application/x-www-form-urlencoded"},data:a}).then(t=>{}).catch(t=>{})}function get_dataItem(){axios({method:"post",url:"/api/customers/data",headers:{Authorization:"Bearer "+new URL(location.href).searchParams.get("token")},data:{purposes:"purposes",staffs:"staffs"}}).then(t=>{dataItem=t.data}).catch(t=>{})}function checkImage(t){if("undefined"!==typeof t&&t.trim().length>0)return t}$((function(){dxlistCustomer=$("#list").dxList({height:"100%",noDataText:"",itemTemplate:function(t,e){var a=$("<div>").addClass("customer");return $("<img>").attr("src",t.image).css({float:"right"}).click((function(t){})).appendTo(a),$("<div>").html("<b><i class='fas fa-user' style='width: 20px;text-align: center;'></i> "+t.customerName+"</b>").css({"font-size":"large"}).appendTo(a),$("<div>").html("<i class='fas fa-car' style='width: 18px;text-align: center;'></i> "+t.plate+(t.carType?" ("+t.carType+")":"")).appendTo(a),$("<div>").html("<i class='fas fa-thumbtack' style='width: 18px;text-align: center;'></i> "+(t.purpose?t.purpose:"")).appendTo(a),$("<div>").html("<i class='fas fa-users' style='width: 18px;text-align: center;'></i> "+(t.staff?t.staff:"")).appendTo(a),$("<div>").html("<i class='far fa-clock' style='width: 18px;text-align: center;'></i> "+t.created_at).appendTo(a),a},onItemClick:function(t){customer=t.itemData,popup?popup.option("contentTemplate",popupOptions.contentTemplate.bind(this)):popup=$("#popup").dxPopup(popupOptions).dxPopup("instance"),clearInterval(setIntervalLoad),popup.show()}}).dxList("instance"),get_isme(),get_dataItem()}));