<!-- Edit Vendor Modal -->
<div class="modal fade" id="editVendorModal" tabindex="-1" aria-labelledby="editVendorLabel" aria-hidden="true">
  <div class="modal-dialog modal-lg modal-dialog-centered">
    <div class="modal-content">
      <div class="modal-header bg-warning text-white">
        <h5 class="modal-title"><i class="fas fa-edit mr-2"></i>Edit Vendor</h5>
        <button type="button" class="close text-white" data-dismiss="modal">&times;</button>
      </div>
      <form id="editVendorForm">
        <input type="hidden" name="id" id="editVendorId">
        <div class="modal-body">
          <div class="form-row">
            <div class="form-group col-md-6">
              <label>Vendor Name</label>
              <input type="text" name="name" id="editVendorName" class="form-control" required>
            </div>
            <div class="form-group col-md-6">
              <label>Contact Person</label>
              <input type="text" name="contact_person" id="editContactPerson" class="form-control">
            </div>
          </div>
          <div class="form-row">
            <div class="form-group col-md-6">
              <label>Phone</label>
              <input type="text" name="phone" id="editVendorPhone" class="form-control">
            </div>
            <div class="form-group col-md-6">
              <label>Email</label>
              <input type="email" name="email" id="editVendorEmail" class="form-control">
            </div>
          </div>
          <div class="form-group">
            <label>Address</label>
            <textarea name="address" id="editVendorAddress" rows="2" class="form-control"></textarea>
          </div>
          <div class="form-group">
            <label>GST No</label>
            <input type="text" name="gst_no" id="editVendorGst" class="form-control">
          </div>
        </div>
        <div class="modal-footer bg-light">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
          <button type="submit" class="btn btn-warning text-white"><i class="fas fa-save mr-1"></i>Update Vendor</button>
        </div>
      </form>
    </div>
  </div>
</div>

<script>
$('#editVendorForm').on('submit', function(e){
  e.preventDefault();
  $.post('public/ajax/vendor/edit.php', $(this).serialize(), function(r){
    alert(r.message);
    if(r.status==='success') location.reload();
  }, 'json');
});
</script>
