jQuery(document).ready(function(d){(d=jQuery.noConflict())(".coupon-service-data").select2();var e=d("#coupon-expire").attr("data-date-format").replace("Y","yyyy");d("#coupon-expire, #coupon-expire-update").datepicker({format:e}),d("#bookingor-update-coupon-data").on("submit",function(e){e.preventDefault();var e=Object.fromEntries(new FormData(e.target).entries()),t=d("#coupon-expire-update").data("datepicker").getFormattedDate("yyyy-mm-dd");e.action="bp_update_coupon",e.expire_date_update=t,e.nonce=TCN_BIND.nonce,d.post(TCN_BIND.GET_URL,e,function(e){})}),d("#bookingor-add-coupon-data").on("submit",function(e){e.preventDefault();var o,t=d("#coupon-expire").data("datepicker").getFormattedDate("yyyy-mm-dd"),e=Object.fromEntries(new FormData(e.target).entries());e.action="bp_add_coupon",d("#staff-get-service").val(),o=[],d("#coupon-get-service option:selected").each(function(e){d(this).val();var t=d(this).attr("data-service-id");o.push({coupon_service_get_id:t})}),e.coupon_get_services=o,e.nonce=TCN_BIND.nonce,e.expire_date=t,d.post(TCN_BIND.GET_URL,e,function(e){})}),d("#example").on("click",".bp-coupon-update-b-id",function(e){e.preventDefault();e=d(this).attr("data-id");d.post(TCN_BIND.GET_URL+"?action=bp_get_coupon",{coupon_id:e,nonce:TCN_BIND.nonce},function(e){e=JSON.parse(e);d("#coupon-name-update").val(e[0].coupon_code),d("#coupon-discount-update").val(e[0].coupon_discount),d("#coupon-deduction-update").val(e[0].coupon_deduction),d("#coupon-limit-update").val(e[0].coupon_limit),d("#customer-coupon-limit-update").val(e[0].customer_coupon_limit),d("#coupon-id-update").val(e[0].coupon_id),d("#coupon-expire-update").val(e[0].coupon_end_date);var o,t,n,a,c=d("#coupon-get-service-update");if(null!==e[0].coupon_assign){d("#coupon-get-service-update").empty();for(var p=e[0].coupon_assign.split(","),i=0;i<p.length;i++)var u=p;o=c,t=u,n=e[0].service_id.split(","),a=e[0].coupon_get_id.split(","),t.forEach(function(e,t){e=new Option(e,e,!1,!1);e.setAttribute("data-id",n[t]),e.setAttribute("data-coupon-id",a[t]),o.append(e)}),o.val(t),o.trigger("change")}else c.empty()})})});