function deposit(){var t={payment:$("#payment").val(),supplier_id:$("#supplier_id").data("supplier-id")};$.ajax({type:"POST",url:$("#paymentItem").data("payment"),data:t,success:function(t){toastr.options={progressBar:!1,positionClass:"toast-bottom-left",hideMethod:"fadeOut"},1==t.error?($("#msgForm").addClass("has-error"),toastr.error(t.msg)):(toastr.success(t.msg),location.reload())}})}var purchaseOrder={supplierID:$("#supplier_id").data("supplier-id"),addItem:function(t){var e=this,s={product_id:t,amount:$("#qty"+t).val(),price:$("#qty"+t).data("price"),sku:$("#qty"+t).data("sku"),supplier_id:e.supplierID};$.ajax({type:"POST",url:$("#addItem").data("add-item"),data:s,success:function(t){toastr.options={progressBar:!1,positionClass:"toast-bottom-left",hideMethod:"fadeOut"},1==t.error?toastr.error(t.msg):(e.listItem(),toastr.success(t.msg))}})},listItem:function(){var t=this,e="<tr><td colspan='6' class='text-center'>No Order Item</td></tr>";$.ajax({type:"GET",url:$("#getItem").data("get-item"),data:{supplier_id:t.supplierID},success:function(t){if(1==t.error)$("#btn-cancel").prop("disabled",!0),$("#btn-confirm").prop("disabled",!0),$("#data").html(e);else{$("#btn-cancel").prop("disabled",!1),$("#btn-confirm").prop("disabled",!1),$("#data").html(t);var s=$("#total").data("total");$("#usd-total-price").text(" $ "+parseFloat(s).toFixed(2))}}})},editItem:function(t){var e={order_id:t,amount:$("#qtyupdate"+t).val()},s=this;$.ajax({type:"PATCH",url:$("#editItem").data("edit-item"),data:e,success:function(t){toastr.options={progressBar:!1,positionClass:"toast-bottom-left",hideMethod:"fadeOut"},1==t.error?toastr.error(t.msg):(s.listItem(),toastr.success(t.msg))}})},deleteItem:function(t){var e=this;$.ajax({type:"DELETE",url:$("#deleteItem").data("delete-item"),data:{order_id:t},success:function(t){toastr.options={progressBar:!1,positionClass:"toast-bottom-left",hideMethod:"fadeOut"},1==t.error?toastr.error(t.msg):(e.listItem(),toastr.success(t.msg))}})},cancelOrder:function(){var t=this;$("#alert-yes").on("click",function(){$.ajax({type:"DELETE",url:$("#deleteAllItem").data("delete-all-item"),data:{supplier_id:t.supplierID},success:function(e){toastr.options={progressBar:!1,positionClass:"toast-bottom-left",hideMethod:"fadeOut"},1==e.error?toastr.error(e.msg):(t.listItem(),toastr.success(e.msg))}}),$("#modal-2").modal("hide")})}};