'+$("#divSelectLeadTime").html()+"<\/div><\/div><\/div><\/form>",r=$("
").html(u).contents();return r.find("#scheduleDate").datepicker({startDate:new Date(i),autoclose:!0}),r}$(function(){$("#frmSubmitListTO").submit(function(n){$("input:checkbox:checked",$(this)).length==0&&(ShowNotify("error","Vui lòng chọn đơn hàng cần thao tác !"),n.preventDefault())});$(".btnApproveShipmentBooking").click(function(n){n.preventDefault();var t=$(this).data("shid");bootbox.confirm({title:"CHÚ Ý",message:"Bạn có chắc chắn muốn duyệt thời gian hẹn giao của NCC này không?",callback:function(n){n&&$.post(urlApproveShipmentBooking,{shId:t,statusId:170},function(n){n.ID>0?(ShowNotify("success",n.Message),ReloadWithDelay(3e3)):ShowNotify("error",n.Message,1e4)})}})});$(".btnNotApproveShipmentBooking").click(function(n){n.preventDefault();var r=$(this).data("shid"),t=$(this).data("oldscheduleday"),i=$(this).data("oldleadtimeid"),u=$(this).data("purchaseorderdate"),f=$(this).data("desiredeliverydate");bootbox.dialog({message:BootboxNotApprove(t,i,u,f),title:"Vui lòng nhập lý do không duyệt",buttons:{main:{label:"Xác nhận",className:"btn-success",callback:function(){var f=$.trim($("#frmNotApprove #note").val()),u=$("#frmNotApprove #scheduleDate").val(),n=$("#frmNotApprove #ddlLeadTimeHour").val();if(f.length==0)return ShowNotify("error","Vui lòng nhập lý do không duyệt"),!1;if(u.length>0&&n==0)return ShowNotify("error","Vui lòng chọn khung giờ"),!1;if(u.length==0&&n>0&&(n=0),u.length>0&&n>0&&u==t&&n==i)return ShowNotify("error","Ngày mong muốn giao không được trùng với ngày hẹn giao cũ"),!1;$.post(urlApproveShipmentBooking,{shId:r,statusId:210,note:f,date:u,leadTimeId:n},function(n){n.ID>0?(ShowNotify("success",n.Message),ReloadWithMasterDB()):ShowNotify("error",n.Message,1e4)})}}}})});$(".btnExtendOrder").click(function(n){n.preventDefault();var t=$(this).data("toid"),i=$(this).data("enddate");bootbox.dialog({message:BootboxExtendOrder(i),title:"Vui lòng nhập thông tin gia hạn",buttons:{main:{label:"Xác nhận",className:"btn-success",callback:function(){var n=$.trim($("#frmExtendOrder #note").val()),i=$("#frmExtendOrder #extendDate").val();if(n.length==0)return ShowNotify("error","Vui lòng nhập lý do gia hạn"),!1;if(i.length==0)return ShowNotify("error","Vui lòng chọn thời gian"),!1;if(n.length>200)return ShowNotify("error","Lý do gia hạn không vướt quá 200 ký tự"),!1;$.ajax({url:urlExtendOrder,type:"POST",data:{toId:t,extendDesireDeliveryDate:i,note:n},dataType:"json",async:!1,cache:!1,success:function(n){n.ID>0?(ShowNotify("success",n.Message),ReloadWithMasterDB()):(ShowNotify("error",n.Message),HideOverlay())},error:function(n){ShowNotify("error",n.statusText);HideOverlay()}})}}}})});$(".btnUpdateShipmentScheduleDate").click(function(n){n.preventDefault();var t=$(this).data("shid"),i=$(this).data("oldscheduleday"),r=$(this).data("oldleadtimeid"),u=$(this).data("purchaseorderdate"),f=$(this).data("desiredeliverydate");bootbox.dialog({message:BootboxUpdateShipmentScheduleDate(i,r,u,f),title:"Cập nhật lịch giao hàng",buttons:{main:{label:"Xác nhận",className:"btn-success",callback:function(){var r=$.trim($("#frmUpdateShipmentScheduleDate #note").val()),n=$("#frmUpdateShipmentScheduleDate #scheduleDate").val(),i=$("#frmUpdateShipmentScheduleDate #ddlLeadTimeHour").val();if(n.length>0&&i==0)return ShowNotify("error","Vui lòng chọn khung giờ"),!1;if(n.length==0&&i>0)return ShowNotify("error","Vui lòng chọn lịch giao hàng"),!1;$.ajax({type:"POST",url:urlUpdateShipmentScheduleDate,data:{shId:t,note:r,date:n,leadTimeId:i},success:function(n){n.ID>0?(ShowNotify("success",n.Message),ReloadWithMasterDB()):bootbox.alert(n.Message)},error:function(n,t,i){alert(i)}})}}}})})})