var _globals=new Globals,citys=_globals.apiGetDataList("citys"),districts=_globals.apiGetDataList("districts"),staffs=_globals.apiGetDataList("staffs"),branchs=_globals.apiGetDataList("branchs"),listCustomerVisit=!1;function stringtimetotime(a){const t=a.split(" ");if(t.length>1)return t[1]}function stringtimetodate(a){const t=a.split(" ");if(t.length>1)return t[0]}function HistoryVisitTemplate(a){return $("<div>").dxDataGrid({dataSource:a.historyVisit,showBorders:!0,columns:[{caption:_globals.language.fromDateTime,dataField:"dateTime",cellTemplate:function(a,t){$("<a />").append(stringtimetodate(t.value)).appendTo(a)}},{caption:_globals.language.fromTime,dataField:"dateTime",cellTemplate:function(a,t){$("<a />").append(stringtimetotime(t.value)).appendTo(a)}},{caption:_globals.language.purpose_come,dataField:"purpose"},{caption:_globals.language.advisor,dataField:"sa"},{caption:_globals.language.branch,dataField:"Branch.name"}]})}function VisitInfoTemplate(a){return $("<div>").dxForm({formData:a.Customers,colCount:3,items:[{dataField:"code",editorOptions:{readOnly:!0},label:{text:_globals.language.code}},{dataField:"name",editorOptions:{readOnly:!0},label:{text:_globals.language.customer_name}},{dataField:"email",editorOptions:{readOnly:!0},label:{text:_globals.language.email}},{dataField:"phone",editorOptions:{readOnly:!0},label:{text:_globals.language.mobile}},{editorType:"dxSelectBox",valueExpr:"id",dataField:"cityID",editorOptions:{placeholder:"",items:citys,displayExpr:"text",valueExpr:"id",readOnly:!0},label:{text:_globals.language.city}},{editorType:"dxSelectBox",displayExpr:"text",valueExpr:"id",dataField:"districtID",editorOptions:{placeholder:"",items:districts,displayExpr:"text",valueExpr:"id",readOnly:!0},label:{text:"district"}},{dataField:"address",editorOptions:{readOnly:!0},label:{text:_globals.language.address}},{editorType:"dxSelectBox",dataField:"staffID",editorOptions:{placeholder:"",items:staffs,displayExpr:"name",valueExpr:"id",readOnly:!0},label:{text:_globals.language.staff}},{editorType:"dxSelectBox",dataField:"branchID",editorOptions:{placeholder:"",items:branchs,displayExpr:"name",valueExpr:"id",readOnly:!0},label:{text:_globals.language.branch}}]})}function even(a,t){$("<a>").click((function(){_globals.apiPostDataList("visit-customers/updateCusStatus",{cusId:t.data.customerID,status:2})})).attr({class:"dx-link dx-icon-car"}).appendTo(a),$("<i>&nbsp;&nbsp;&nbsp;<i>").appendTo(a),$("<a>").click((function(){_globals.apiPostDataList("visit-customers/updateCusStatus",{cusId:t.data.customerID,status:3})})).attr({class:"dx-link dx-icon-runner"}).appendTo(a)}function test(a,t){_globals.apiPostDataList("visit-customers/updateCusStatus",{cusId:t,status:params})}$((function(){listCustomerVisit=$("#body").dxDataGrid({dataSource:_globals.apiPostDataList("visit-customers/listCustomerVisit"),selection:{mode:"single"},onSelectionChanged:function(a){a.component.collapseAll(-1),a.component.expandRow(a.currentSelectedRowKeys[0])},showBorders:!0,columns:[{dataField:"dateTime",caption:_globals.language.date,width:92,cellTemplate:function(a,t){$("<a />").append(stringtimetodate(t.value)).appendTo(a)}},{dataField:"dateTime",caption:_globals.language.intime,width:70,cellTemplate:function(a,t){$("<a />").append(stringtimetotime(t.value)).appendTo(a)}},{dataField:"customerName",caption:_globals.language.customername,width:170},{dataField:"numberOfVisitors",caption:_globals.language.number_of_visitors,width:120},{caption:"Th\xf4ng tin xe",columns:[{caption:_globals.language.no,dataField:"plate",format:"percent"},{caption:_globals.language.cartype,dataField:"carType",format:"percent"},{caption:_globals.language.carcolor,dataField:"carColor",format:"percent"}]},{caption:_globals.language.purpose_come,dataField:"purpose"},{caption:_globals.language.advisor,dataField:"sa"},{caption:_globals.language.seat,dataField:"Seats.title",cellTemplate:function(a,t){t.data.status&&(1==t.data.status?$("<a />").append(t.value).appendTo(a):0==t.data.status?$("<a />").append(_globals.language.arrived).appendTo(a):2==t.data.status?$("<a />").append(_globals.language.dispatch_car).appendTo(a):3==t.data.status?$("<a />").append(_globals.language.client_left).appendTo(a):4==t.data.status&&$("<a />").append(_globals.language.done).appendTo(a))}}],masterDetail:{enabled:!1,template:function(a,t){$("<div>").dxTabPanel({selectedIndex:0,items:[{title:_globals.language.customer_info,template:function(){return VisitInfoTemplate(t.data)}},{title:_globals.language.visit_history,template:function(){return HistoryVisitTemplate(t.data)}}]}).appendTo(a)}}}).dxDataGrid("instance")}));