<?php $this->view("includes/Inc_pagehead");?>
<!-- Page Styles Goes Here-->
<style>
.item_table td{
  padding: .75rem !important;
}
.item_table th{
  white-space: nowrap;
  padding: .75rem !important;
}
.table thead th {
  border-top: 2px solid #f4f5f8 !important;
}
.payment-table tbody td{
  border-top: 2px solid #f4f5f8 !important;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__head .m-invoice__container.m-invoice__container--centered {
  width: 90% !important;
}
.m-invoice-2 .m-invoice__wrapper .m-invoice__body.m-invoice__body--centered {
  width: 100% !important;
}
.holder {
  height: 100px;
  width: 100px;
  border: 2px solid black;
}
.holder img {
  max-width: 100px;
  max-height: 100px;
  min-width: 100px;
  min-height: 100px;
}
</style>
<?php $this->view("includes/Inc_navigation");?>
<div class="m-grid__item m-grid__item--fluid m-wrapper">
  <!-- BEGIN: Subheader -->
  <div class="m-subheader ">
    <div class="d-flex align-items-center">
      <div class="mr-auto">
        <h3 class="m-subheader__title m-subheader__title--separator">
          Edit Work Order
        </h3>
        <ul class="m-subheader__breadcrumbs m-nav m-nav--inline">
          <li class="m-nav__item m-nav__item--home">
            <a href="#" class="m-nav__link m-nav__link--icon">
              <i class="m-nav__link-icon la la-home"></i>
            </a>
          </li>
          <li class="m-nav__separator">
            -
          </li>
          <li class="m-nav__item">
            <a href="<?php echo base_url().'dashboard'?>" class="m-nav__link">
              <span class="m-nav__link-text">
                Home
              </span>
            </a>
          </li>
          <li class="m-nav__separator">
            -
          </li>
          <li class="m-nav__item">
            <a href="<?php echo base_url().'work_order' ?>" class="m-nav__link">
              <span class="m-nav__link-text">
                Edit Work Order
              </span>
            </a>
          </li>
        </ul>
      </div>
      <div></div>
    </div>
  </div>
  <!-- END: Subheader -->
  <div class="m-content">
    <div class="m-portlet m-portlet--full-height">
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
              Edit Work Order
            </h3>
          </div>
        </div>
        <div class="m-portlet__head-tools" >

        </div>
      </div>
      <div class="m-portlet__body m-portlet__body--no-padding">
        <form autocomplete="off" id="form_work_order_add" data-form-type="work_order_create" method="post" action="<?php echo base_url()?>work_order/update" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
          <div class="m-invoice-2" style="padding-bottom: 20px">
            <div  class="m-invoice__wrapper">
              <div class="m-invoice__head" >
                <div class="m-invoice__container m-invoice__container--centered">
                  <div class="m-invoice__logo" style="padding-top: 3rem;">
                    <a href="#">
                    </a>
                  </div>
                  <div class="m-invoice__items" style="padding: 2rem 0 3rem 0;border:none">
                    <div class="m-invoice__item">
                      <div class="row">
                        <div class="col-lg-6">
                          <div class="form-group m-form__group" style="padding-top: 0px !important;padding-bottom: 0px !important">
                            <label >Customer Name</label>
                            <input value="<?php echo $order_data->customer_name ?>"  type="text" required  name="customer_name" id="customer_name" class="form-control m-input m-input--air m-input--pill" placeholder="Customer Name" >
                            <span class="m-form__help"></span>
                          </div>
                          <div class="form-group m-form__group" style="padding-top: 0px !important;padding-bottom: 0px !important">
                            <label >Address</label>
                            <input  type="text" value="<?php echo $order_data->customer_address ?>" name="address" class="form-control m-input m-input--air m-input--pill" placeholder="Address" >
                            <span class="m-form__help"></span>
                          </div>
                          <div class="form-group m-form__group" style="padding-top: 0px !important;padding-bottom: 0px !important">
                            <label >Pin</label>
                            <input  type="text" value="<?php echo $order_data->customer_pin ?>" name="pincode" class="form-control m-input m-input--air m-input--pill" placeholder="Pincode" >
                            <span class="m-form__help"></span>
                          </div>
                          <div class="form-group m-form__group" style="padding-top: 0px !important;padding-bottom: 0px !important">
                            <label >GST No</label>
                            <input  type="text" value="<?php echo $order_data->customer_taxno ?>" name="gst_no" class="form-control m-input m-input--air m-input--pill" placeholder="GST No" >
                            <span class="m-form__help"></span>
                          </div>
                        </div>
                        <div class="col-lg-6">
                          <div class="form-group m-form__group" style="padding-top: 0px !important;padding-bottom: 0px !important">
                            <label >Work Order Date</label>
                            <input  data-date-format="dd-mm-yyyy" value="<?php echo date('d-m-Y',strtotime($order_data->order_date)) ?>" id="work_order_date" required type="text" name="order_date" class="form-control m-input m-input--air m-input--pill" placeholder="Work Order Date" >
                            <span class="m-form__help"></span>
                          </div>
                          <div class="form-group m-form__group" style="padding-top: 0px !important;padding-bottom: 0px !important">
                            <label >District</label>
                            <input  type="text"  name="district" value="<?php echo $order_data->customer_district ?>" class="form-control m-input m-input--air m-input--pill" placeholder="District" >
                            <span class="m-form__help"></span>
                          </div>
                          <div class="form-group m-form__group" style="padding-top: 0px !important;padding-bottom: 0px !important">
                            <label >Phone</label>
                            <input  type="text"  name="phone"value="<?php echo $order_data->customer_phone ?>" class="form-control m-input m-input--air m-input--pill" placeholder="Phone" >
                            <span class="m-form__help"></span>
                          </div>
                          <div class="form-group m-form__group" style="padding-top: 0px !important;padding-bottom: 0px !important">
                            <label >Email</label>
                            <input  type="text"  name="email" value="<?php echo $order_data->customer_email ?>" class="form-control m-input m-input--air m-input--pill" placeholder="Email" >
                            <span class="m-form__help"></span>
                          </div>
                          <div class="form-group m-form__group" style="padding-top: 0px !important;padding-bottom: 0px !important">
                            <label >Executive Name</label>
                            <input  type="text"  name="site_coordinator" value="<?php echo $order_data->site_coordinator ?>" class="form-control m-input m-input--air m-input--pill" placeholder="Executive Name" >
                            <span class="m-form__help"></span>
                          </div>
                        </div>
                      </div>
                      <div class="m-invoice__body m-invoice__body--centered" style="min-height: 200px">
                        <div style="background: white;border: 4px solid #f7f7fa;padding: 15px;margin: 5px;padding-bottom: 0px">
                          <div class="m-section" style="margin-bottom: 10px">
                            <h3 class="m-section__heading">Items</h3>
                            <div class="table-responsive">
                              <table class="table m-table table-bordered item_table">
                                <thead>
                                  <tr>
                                    <th width="5%">Sl No</th>
                                    <th width="15%" style="text-align: left">Item Code</th>
                                    <th width="20%" style="text-align: left">Size</th>
                                    <th width="13%" style="text-align: left">Type</th>
                                    <th width="12%" style="text-align: left">Quantity</th>
                                    <th width="16%" style="text-align: left">Rate</th>
                                    <th width="18%" style="text-align: left">Amount</th>
                                    <th width="7%">&nbsp;</th>
                                    <!-- <th>Item Type</th> -->
                                  </tr>
                                </thead>
                                <tbody id="item_body">
                                  <?php foreach ($items_data as $key => $value) { ?>
                                    <tr class="row_<?php echo $key ?>">
                                      <td><?php echo $key+1 ?>
                                        <input value="<?php echo $value->item_id ?>"  type="hidden" required name="item_id[<?php echo $key ?>]" id="item_id_<?php echo $key+1 ?>"  data-sl-no="<?php echo $key+1 ?>"  >
                                      </td>
                                      <td style="text-align: left">
                                        <div class="form-group m-form__group">
                                          <div class="m-input-icon ">
                                            <input value="<?php echo $value->item_code ?>"  type="text" required name="item_code[<?php echo $key ?>]" id="item_code_<?php echo $key+1 ?>" class="form-control m-input m-input--air m-input--pill" data-sl-no="<?php echo $key+1 ?>" placeholder="Item Code" >
                                          </div>
                                        </div>
                                      </td>
                                      <td style="text-align: left">
                                        <div class="form-group m-form__group">
                                          <div class="m-input-icon ">
                                            <input value="<?php echo $value->size ?>" type="text" required name="item_size[<?php echo $key ?>]" id="item_size_<?php echo $key+1 ?>" class="form-control m-input m-input--air m-input--pill" data-sl-no="<?php echo $key+1 ?>" placeholder="Size" >
                                          </div>
                                        </div>
                                      </td>
                                      <td style="text-align: left">
                                        <div class="form-group m-form__group">
                                          <div class="m-input-icon ">
                                            <input value="<?php echo $value->type ?>"  type="text" required name="item_type[<?php echo $key ?>]" class="form-control m-input m-input--air m-input--pill" id="item_type_<?php echo $key+1 ?>" data-sl-no="<?php echo $key+1 ?>" placeholder="Type" >
                                          </div>
                                        </div>
                                      </td>
                                      <td style="text-align: left">
                                        <div class="form-group m-form__group">
                                          <div class="m-input-icon ">
                                            <input value="<?php echo $value->quantity ?>"  type="text" required name="item_qty[<?php echo $key ?>]" class="form-control item_rate_fields m-input m-input--air m-input--pill numeric_fields" id="item_qty_<?php echo $key+1 ?>" data-sl-no="<?php echo $key+1 ?>" placeholder="Qty" >
                                          </div>
                                        </div>
                                      </td>
                                      <td style="text-align: left">
                                        <div class="form-group m-form__group">
                                          <div class="m-input-icon ">
                                            <input value="<?php echo $value->unit_price ?>" type="text" required name="item_price[<?php echo $key ?>]" class="form-control item_rate_fields m-input m-input--air m-input--pill numeric_fields" id="item_price_<?php echo $key+1 ?>" data-sl-no="<?php echo $key+1 ?>" placeholder="Rate" >
                                          </div>
                                        </div>
                                      </td>
                                      <td style="text-align: left">
                                        <div class="form-group m-form__group">
                                          <div class="m-input-icon ">
                                            <input value="<?php echo $value->total_price ?>" type="text" required name="item_total[<?php echo $key ?>]" readonly id="item_total_<?php echo $key+1 ?>" class="form-control item_amount_field m-input m-input--air m-input--pill" data-sl-no="<?php echo $key+1 ?>" placeholder="Total Amount" >
                                          </div>
                                        </div>
                                      </td>
                                      <td>
                                        <a href="javascript:" data-item-id="<?php echo $value->item_id ?>" data-row-sl-no='<?php echo $key ?>' class="ibtnDel btn btn-danger m-btn m-btn--icon m-btn--icon-only m-btn--pill m-btn--air" ><i class="fa fa-trash"></i></a>
                                      </td>
                                    </tr>
                                  <?php } ?>
                                </tbody>
                              </table>
                            </div>
                            <table class="table m-table table-bordered item_table">
                              <thead>
                                <th>
                                  <button type="button" style=" width: 100%; " id="btn_add_row" class="btn m-btn--pill btn-brand"><i class="fa fa-plus-circle"></i> Add New Item</button>
                                </th>
                              </thead>
                            </table>
                            <table class="table m-table table-bordered item_table">
                              <thead>
                                <tr>
                                  <th style="width: 30%;text-align:left">Total Amount</th>
                                  <th style="width: 30%;text-align:left">Discount Amount</th>
                                  <th style="width: 30%;text-align: left">
                                    NET Total Amount
                                  </th>
                                </tr>
                              </thead>
                              <tbody>
                                <tr>
                                  <td>
                                    <input required type="text" required readonly name="grand_total" id="grand_total_amount" class="form-control m-input m-input--air m-input--pill" value="<?php echo $order_data->grand_total_amount ?>" placeholder="" >
                                  </td>
                                  <td>
                                    <input required type="text" required name="discount_amount" id="discount_amount" class="form-control m-input m-input--air m-input--pill" value="<?php echo $order_data->discount_amount ?>" placeholder="" >
                                  </td>
                                  <td>
                                    <input required type="text" required readonly name="total_order_amount" id="total_amount" class="form-control m-input m-input--air m-input--pill" value="<?php echo $order_data->total_order_amount ?>" placeholder="" >
                                  </td>
                                </tr>
                              </tbody>
                            </table>
                          </div>
                          <input type="hidden" name="current_row_count" id="current_row_count" value="<?php echo sizeof($items_data) ?>">
                          <input type="hidden" name="order_id"  value="<?php echo $order_data->order_id ?>">
                          <input type="hidden"  id="deleted_items" name="deleted_items" >
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="row">
              <div class="col-md-12" style="border-right: 1px solid #ebedf2; margin-left: 79%; margin-bottom: 3%;">
                <button type="submit" class="btn btn-primary form_submit_btn_3">
                  Save & Submit
                </button>
              </div>
            </div>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>
</div>
</div>


<!-- end:: Body -->
<!-- begin::Footer -->

<?php $this->view("includes/Inc_footer");?>
<!-- end::Footer -->

<!-- end:: Page -->

<?php $this->view("includes/Inc_sidebar");?>
<?php $this->view("includes/Inc_scripts");?>

<!--begin::Page Snippets -->
<script>

//    Toggle Sidebar
$("#m_aside_left_minimize_toggle").addClass("m-brand__toggler--active");
$("#body").addClass("m-brand--minimize m-aside-left--minimize");

$("#work_order_menu").addClass('m-menu__item--active m-menu__item--open');
$("#work_order_menu_1").addClass('m-menu__item--active');

$("#work_order_date,#project_start_date").datepicker( {
  todayHighlight:!0, orientation:"bottom left", templates: {
    leftArrow: '<i class="la la-angle-left"></i>', rightArrow: '<i class="la la-angle-right"></i>'
  }
})


function calculate_total_amount() {
  var total_amount = 0;
  $(".item_amount_field").each(function(){
    if($(this).val()!='' && $(this).val()!=null){
      total_amount += parseFloat($(this).val());
    }
  });
  var discount_amount = parseFloat($("#discount_amount").val());
  if(isNaN(discount_amount)){
    discount_amount=0;
  }
  $("#grand_total_amount").val((total_amount).toFixed(<?php echo $this->config->item('Currency_amount_decimals_2')?>));
  $("#total_amount").val((total_amount-discount_amount).toFixed(<?php echo $this->config->item('Currency_amount_decimals_2')?>));

}
$('body').on('change keyup', '#discount_amount', function() {
  calculate_total_amount();
})
$('body').on('change keyup', '.item_rate_fields', function() {
  var sl_no = $(this).attr('data-sl-no');
  calculate_item_total(sl_no);
})
function calculate_item_total(sl_no){
  var qty = parseFloat($("#item_qty_"+sl_no).val());
  var price = parseFloat($("#item_price_"+sl_no).val());
  var total_amount = 0;
  if(isNaN(qty)){
    qty=0;
  }
  if(isNaN(price)){
    price=0;
  }
  total_amount = (qty*price).toFixed(<?php echo $this->config->item('Currency_amount_decimals_2')?>);
  $("#item_total_"+sl_no).val(total_amount);
  calculate_total_amount();
}
$('body').on('change keyup', '.schedule_percent', function() {
  var sl_no = $(this).attr('data-sl-no');
  var percent = parseFloat($(this).val());
  var total_amount = parseFloat($("#total_amount").val());
  var percent_amount = total_amount*percent/100;
  $("#schedule_amount_"+sl_no).val(percent_amount.toFixed());
})
</script>
<script>

$("#form_template_select").validate( {
  rules: {
    template_id: {
      required: !0
    }
  }
  , invalidHandler:function(e, r) {
    var i=$("#form_template_select_msg");
    i.removeClass("m--hide").show(), mUtil.scrollTo(i, -200)
  }
  , submitHandler:function(e) {
    this.submit();
  }
});
$(".form_submit_btn_3").click(function (e) {
  e.preventDefault();
  var a = $(this),
  l = $(this).closest("form"),
  action = l.attr('action');
  var form_id = l.attr('id');
  l.validate({
    rules: {
      "quantity": {
        required: !0,
        number: !0
      },
      "amount": {
        required: !0,
        number: !0
      }
    }, invalidHandler: function (e, r) {
      var i = $("#" + form_id + "_msg");
      i.removeClass("m--hide").show(), mUtil.scrollTo(i, -200)
    }, submitHandler: function (e) {
    }
  }),
  $(".numeric_fields").each(function () {
    $("#"+$(this).attr("id")).rules('add', {
      number: !0
    });
  }),
  l.valid() && (a.addClass("m-loader m-loader--right m-loader--light").attr("disabled", !0),
  l.ajaxSubmit({
    url: action,
    success: function (e, t, r, s) {
      var modal_id = l.attr('data-modal-id');
      var form_type = l.attr('data-form-type');
      $("#" + form_id + "_msg").addClass("m--hide");
      // Block UI
      mApp.blockPage({
        overlayColor: "#000000",
        type: "loader",
        state: "success",
        message: "Please wait..."
      }), setTimeout(function () {
        mApp.unblockPage()
      }, 2e3);
      var obj = $.parseJSON(e);
      if (obj.status == 1) {
        a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
        // toastr[obj.flashdata_type](obj.flashdata_msg, obj.flashdata_title);
        // $("#"+modal_id).modal('toggle');
        // $("."+form_id+"_fields").val("");
        // location.reload();
        swal({
          width: 500,
          title: obj.flashdata_title,
          text: obj.flashdata_msg,
          type: obj.flashdata_type,
          showCancelButton: !0,
          confirmButtonText: "Go to Work Order Details",
          cancelButtonText: "Add New Work Order",
          confirmButtonColor: '#3085d6',
          cancelButtonColor: '#d33',
          reverseButtons: !0,
          closeOnClickOutside: false,
          allowOutsideClick: false,
        }).then(function(e) {
          e.value ? window.location.replace("<?php echo base_url()?>work_order/profile/view/"+obj.order_id) : "cancel" === e.dismiss && window.location.replace("<?php echo base_url()?>work_order/add");
        })
      } else {
        a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
        toastr[obj.flashdata_type](obj.flashdata_msg, obj.flashdata_title);
      }

      if (obj == null) {
        setTimeout(function () {
          a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
          toastr["warning"]("Your Attempt is Timed Out. Please Try Again.", "Timed Out");
        }, 2e4)
      }
    },error: function() {
      a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
      toastr["error"]("Sorry. There Has Been Some Error Occurred. Please Try Again.", "Error");
    }
  })
)
});

</script>
<script>
$("#btn_add_row").on("click", function () {
  var counter = parseInt($("#current_row_count").val());
  var newRow = '<tr class="row_'+(counter)+'"><td>'+(counter+1)+'</td>';

  newRow += '<td style="text-align: left"><div class="form-group m-form__group"><div class="m-input-icon"><input  type="text" name="item_code['+counter+']" required class="form-control m-input m-input--air m-input--pill" id="item_code_'+(counter+1)+'" data-sl-no="'+(counter+1)+'" placeholder="Item Code" ></div></div></td>';
  newRow += '<td style="text-align: left"><div class="form-group m-form__group"><div class="m-input-icon"><input  type="text" name="item_size['+counter+']" required class="form-control m-input m-input--air m-input--pill" id="item_size_'+(counter+1)+'" data-sl-no="'+(counter+1)+'" placeholder="Size" ></div></div></td>';
  newRow += '<td style="text-align: left"><div class="form-group m-form__group"><div class="m-input-icon"><input  type="text" name="item_type['+counter+']" required class="form-control m-input m-input--air m-input--pill" id="item_type_'+(counter+1)+'" data-sl-no="'+(counter+1)+'" placeholder="Item Type" ></div></div></td>';
  newRow += '<td style="text-align: left"><div class="form-group m-form__group"><div class="m-input-icon"><input  type="text" name="item_qty['+counter+']" required class="form-control item_rate_fields m-input m-input--air m-input--pill" id="item_qty_'+(counter+1)+'" data-sl-no="'+(counter+1)+'" placeholder="Qty" ></div></div></td>';
  newRow += '<td style="text-align: left"><div class="form-group m-form__group"><div class="m-input-icon"><input  type="text" name="item_price['+counter+']" required id="item_price_'+(counter+1)+'" class="form-control item_rate_fields m-input m-input--air m-input--pill" data-sl-no="'+(counter+1)+'" placeholder="Rate" ></div></div></td>';
  newRow += '<td style="text-align: left"><div class="form-group m-form__group"><div class="m-input-icon "><input  type="text" name="item_total['+counter+']" required readonly id="item_total_'+(counter+1)+'" class="form-control item_amount_field m-input m-input--air m-input--pill" data-sl-no="'+(counter+1)+'" placeholder="Total Amount" ></div></div></td>';

  newRow += '<td><a href="javascript:" data-row-sl-no='+(counter)+' class="ibtnDel btn btn-danger m-btn m-btn--icon m-btn--icon-only m-btn--pill m-btn--air" ><i class="fa fa-trash"></i></td>';
  newRow += '</tr>';
  $("#item_body").append(newRow);
  counter++;
  $("#current_row_count").val(counter);
  calculate_total_amount();
});
$("#item_body").on("click", ".ibtnDel", function (event) {
  var row_sl_no = $(this).data('row-sl-no');
  var counter = parseInt($("#current_row_count").val());
  $('.row_'+row_sl_no).remove();
  counter -= 1;
  $("#current_row_count").val(counter);
  calculate_total_amount();

  var deleted_sl_no = $(this).attr('data-sl-no');
  var deleted_item_id = $(this).attr('data-item-id');

  // Check Item Id Exist, If Exist, Store it in Deleted  Item Array
  if(deleted_item_id!='' && deleted_item_id != null){
    var value = $("#deleted_items").val();
    value += deleted_item_id+",";
    $("#deleted_items").val(value);
  }
});
</script>
<script>
//  Terms & Conditions
$("#addrow_terms").on("click", function () {
  var i = parseInt($('#current_row_count_terms_and_conditions').val());
  var new_i = i + 1;
  console.log(new_i);

  var new_row = '<tr class="row_'+i+'">';
  new_row += '<td><div class="form-group m-form__group" style="padding: 0px !important;margin: 0px !important;"><div class="input-group m-input-group m-input-group--pill m-input-group--air"><input style="padding: 10px" readonly type="text" class="form-control m-input item_slno" data-sl-no="'+new_i+'" name="terms[sl_no]['+i+']" value="'+new_i+'"/></div></div></td>';
  new_row += '<td><div class="form-group m-form__group" style="padding: 0px !important;margin: 0px !important;"><textarea rows="2" class="form-control m-input m-input--pill m-input--air" name="terms[description]['+i+']" id="description_'+new_i+'"/></textarea></div></td><td>';
  new_row += '<a href="javascript:" data-row-sl-no="'+i+'" class="ibtnDel_terms btn btn-danger btn-icon-only" ><i class="fa fa-trash"></i></td></tr>';

  $('#table_body_terms').append(new_row);
  $('#current_row_count_terms_and_conditions').val(new_i);
});
$("#table_body_terms").on("click", ".ibtnDel_terms", function (event) {
  var sl_no = $(this).attr("data-sl-no");

  var counter = parseInt($("#current_row_count_terms_and_conditions").val());
  $(this).closest("tr").remove();
  counter -= 1;
  $("#current_row_count_terms_and_conditions").val(counter);
});

// Payment Schedule
$("#addrow_schedule").on("click", function () {
  var i = parseInt($('#current_row_count_schedule').val());
  var new_i = i + 1;
  console.log(new_i);

  var new_row = '<tr class="row_'+i+'">';
  new_row += '<td><div class="form-group m-form__group" style="padding: 0px !important;margin: 0px !important;"><div class="input-group m-input-group m-input-group--pill m-input-group--air"><input style="padding: 10px" readonly type="text" class="form-control m-input item_slno" data-sl-no="'+new_i+'" name="schedule[sl_no]['+i+']" value="'+new_i+'"/></div></div></td>';
  new_row += '<td>  <div class="form-group m-form__group" style="padding: 0px !important;margin: 0px !important;"><input type="text" class="form-control m-input m-input--pill m-input--air" name="schedule[particulars]['+i+']" id="schedule_particulars_'+new_i+'"/></div></td>';
  new_row += '<td><div class="form-group m-form__group" style="padding: 0px !important;margin: 0px !important;"><input type="text" value="0" class="form-control m-input m-input--pill m-input--air numeric_fields schedule_percent" max="100" data-sl-no="'+new_i+'"  name="schedule[percent]['+i+']" id="schedule_percent_'+new_i+'"/></div></td>';
  new_row += '<td><div class="form-group m-form__group" style="padding: 0px !important;margin: 0px !important;"><input type="text" value="0" class="form-control m-input m-input--pill m-input--air numeric_fields" data-sl-no="'+new_i+'"  name="schedule[amount]['+i+']" id="schedule_amount_'+new_i+'"/></div></td>';
  new_row += '<td><div class="form-group m-form__group" style="padding: 0px !important;margin: 0px !important;"><textarea rows="2" class="form-control m-input m-input--pill m-input--air"  name="schedule[remarks]['+i+']" id="remarks_'+new_i+'"/></textarea></div></td>';
  new_row += '<a href="javascript:" data-row-sl-no="'+i+'" class="ibtnDel_schedule btn btn-danger btn-icon-only" ><i class="fa fa-trash"></i></td></tr>';

  $('#table_body_schedule').append(new_row);
  $('#current_row_count_schedule').val(new_i);
});
$("#table_body_schedule").on("click", ".ibtnDel_schedule", function (event) {
  var sl_no = $(this).attr("data-sl-no");

  var counter = parseInt($("#current_row_count_schedule").val());
  $(this).closest("tr").remove();
  counter -= 1;
  $("#current_row_count_schedule").val(counter);
});

</script>
