<?php $this->view("includes/Inc_pagehead");?>
<!-- Page Styles Goes Here-->

<?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">
          Tools Payments
        </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().'tools/payments' ?>" class="m-nav__link">
              <span class="m-nav__link-text">
              Tools Payments
              </span>
            </a>
          </li>


        </ul>
      </div>
      <div>

      </div>
    </div>
  </div>
  <!-- END: Subheader -->
  <div class="m-content">
    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded">
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
              List of Tools Payments
            </h3>
          </div>
        </div>
      </div>
      <div class="m-portlet__body">

        <!--begin: Datatable -->
        <table width="100%" class="table m-table nowrap table-header-fixed table-striped table-bordered table-hover table-header-fixed" id="tool_payments_view_table">
          <thead>
            <tr class="">
              <th>Sl No</th>
              <th>Tool Name</th>
              <th>Type</th>
              <th>Price Per Day</th>
              <th>Tool Quantity</th>
              <th>No of Days used</th>
              <th>Amount</th>

            </tr>
          </thead>
          <tbody>
          </tbody>
        </table>
        <!--end: Datatable -->
      </div>
    </div>
  </div>

  <div class="modal fade" tabindex="-1" id="tool_rent_add_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog " role="document" style="max-width: 800px">
      <div class="modal-content">
        <div class="modal-header" style="background-color: #36a3f7;border-radius: 4px">
          <h5 class="modal-title" id="exampleModalLabel" style="color: #ffffff" >
            Add New Rent Details
          </h5>
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">
              &times;
            </span>
          </button>
        </div>
        <!--                                                    ADD EXPENSE DATA start-->
        <form autocomplete="off" id="form_tool_rent_add" data-modal-id="tool_rent_add_modal" method="post" action="<?php echo base_url().'tools/create_rent'?>" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
          <div class="modal-body">
            <div class="m-form__content">
              <div class="m-alert m-alert--icon alert alert-warning m--hide" role="alert" id="form_tool_rent_add_msg">
                <div class="m-alert__icon">
                  <i class="la la-warning"></i>
                </div>
                <div class="m-alert__text">
                  Oh snap! Change a few things up and try submitting again.
                </div>
                <div class="m-alert__close">
                  <button type="button" class="close" data-close="alert" aria-label="Close"></button>
                </div>
              </div>
            </div>
            <div class="row">
              <div class="col-lg-12">
                <div class="form-group m-form__group">
                  <label for="user_name">
                    Tool
                  </label>
                  <div class="m-select2 m-select2--air m-select2--pill">
                    <select required style="width: 100%" class="form-control m-select2 form_tool_rent_add_select" id="tools_add"  name="tool" data-placeholder="Select Tool">
                      <option selected disabled>Select Tool</option>
                      <?php
                      foreach($tools as $row): ?>
                      <option value="<?php echo $row->tool_id?>"><?php echo $row->name." [".$row->cat_name."]"?></option>
                      <?php
                    endforeach;
                    ?>
                  </select>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-6">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Rented From
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <input required type="text" name="rented_from" id=""  class="form-control m-input form_tool_rent_add_fields" placeholder="Rented From" aria-describedby="basic-addon1">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-6">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Rented To
                </label>
                <div class="m-select2 m-select2--air m-select2--pill">
                  <select required style="width: 100%" class="form-control m-select2 form_tool_rent_add_select" id="rented_to_add"  name="rented_to" data-placeholder="Select Rented To">
                    <!-- <option selected disabled>Select Rented To</option> -->
                  </select>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>


            <div class="col-lg-4">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Rented Qty
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <input required type="text" name="rented_qty" id="rented_qty"  class="form-control m-input form_tool_rent_add_fields" placeholder="Rented Qty" aria-describedby="basic-addon1">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Rented Date
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <input required type="text" name="rented_date" id="rented_date"  class="form-control m-input form_tool_rent_add_fields" placeholder="Rented Date" data-date-format="dd-mm-yyyy" value="<?php echo date('d-m-Y')?>" aria-describedby="basic-addon1">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>

            <div class="col-lg-4">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Remarks
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <input type="text" name="remarks"  class="form-control m-input form_tool_rent_add_fields" placeholder="Remarks" aria-describedby="basic-addon1">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <input type="hidden" name="redirect_url" value="<?php echo base_url(uri_string())?>" >
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-secondary" data-dismiss="modal">
            Close
          </button>
          <button type="submit" class="btn btn-primary form_submit_btn">
            Submit
          </button>
        </div>
      </form>
    </div>
  </div>
</div>
<div class="modal fade" tabindex="-1" id="tool_rent_edit_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog " role="document" style="max-width: 800px">
    <div class="modal-content">
      <div class="modal-header" style="background-color: #00c5dc;border-radius: 4px">
        <h5 class="modal-title" id="exampleModalLabel" style="color: #ffffff" >
          Edit Rent Details
        </h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">
            &times;
          </span>
        </button>
      </div>
      <form autocomplete="off" data-modal-id="tool_rent_edit_modal" id="form_tool_rent_edit" method="post" action="<?php echo base_url().'tools/update_rent'?>" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
        <div class="modal-body">
          <div class="m-form__content">
            <div class="m-alert m-alert--icon alert alert-warning m--hide" role="alert" id="form_tool_rent_edit_msg">
              <div class="m-alert__icon">
                <i class="la la-warning"></i>
              </div>
              <div class="m-alert__text">
                Oh snap! Change a few things up and try submitting again.
              </div>
              <div class="m-alert__close">
                <button type="button" class="close" data-close="alert" aria-label="Close"></button>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-lg-12">
              <div class="form-group m-form__group">
                <label for="user_name">
                  Tool
                </label>
                <div class="m-select2 m-select2--air m-select2--pill">
                  <select required style="width: 100%" class="form-control m-select2 form_tool_rent_edit_select" id="tools_edit"  name="tool" data-placeholder="Select Tool">
                    <option selected disabled>Select Tool</option>
                    <?php
                    foreach($tools as $row): ?>
                    <option value="<?php echo $row->tool_id?>"><?php echo $row->name." [".$row->cat_name."]"?></option>
                    <?php
                  endforeach;
                  ?>
                </select>
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>
          <div class="col-lg-6">
            <div class="form-group m-form__group" >
              <label for="user_name">
                Rented From
              </label>
              <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                <input required type="text" name="rented_from" id="rented_from_edit"  class="form-control m-input form_tool_rent_add_fields" placeholder="Rented From" aria-describedby="basic-addon1">
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>
          <div class="col-lg-6">
            <div class="form-group m-form__group" >
              <label for="user_name">
                Rented To
              </label>
              <div class="m-select2 m-select2--air m-select2--pill">
                <select required style="width: 100%" class="form-control m-select2 form_tool_rent_edit_select" id="rented_to_edit"  name="rented_to" data-placeholder="Select Rented To">
                  <option selected disabled>Select Rented To</option>
                </select>
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>

          <div class="col-lg-6">
            <div class="form-group m-form__group" >
              <label for="user_name">
                Rented Qty
              </label>
              <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                <input required type="text" name="rented_qty" id="rented_qty_edit"  class="form-control m-input form_tool_rent_edit_fields" placeholder="Rented Qty" aria-describedby="basic-addon1">
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>
          <div class="col-lg-6">
            <div class="form-group m-form__group" >
              <label for="user_name">
                Rented Date
              </label>
              <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                <input required type="text" name="rented_date" id="rented_date_edit"  class="form-control m-input form_tool_rent_edit_fields" placeholder="Rented Date" data-date-format="dd-mm-yyyy" value="<?php echo date('d-m-Y')?>" aria-describedby="basic-addon1">
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>

          <div class="col-lg-6">
            <div class="form-group m-form__group" >
              <label for="user_name">
                Remarks
              </label>
              <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                <input type="text" name="remarks" id="remarks_edit"  class="form-control m-input form_tool_rent_edit_fields" placeholder="Remarks" aria-describedby="basic-addon1">
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>

          <input type="hidden" name="redirect_url" value="<?php echo base_url(uri_string())?>" >
          <input type="hidden" name="rent_id" id="rent_id_edit" >
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn  btn-secondary" data-dismiss="modal">
          Close
        </button>
        <button type="submit" class="btn form_submit_btn btn-primary">
          Submit
        </button>
      </div>
    </form>
  </div>
</div>
</div>
<div class="modal fade" tabindex="-1" id="status_change_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog " role="document" style="max-width: 800px">
    <div class="modal-content">
      <div class="modal-header" style="background-color: #00c5dc;border-radius: 4px">
        <h5 class="modal-title" id="exampleModalLabel" style="color: #ffffff" >
          Return Rented Tools
        </h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">
            &times;
          </span>
        </button>
      </div>
      <form autocomplete="off" data-modal-id="status_change_modal" id="form_status_change" method="post" action="<?php echo base_url().'tools/update_rent_return'?>" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
        <div class="modal-body">
          <div class="m-form__content">
            <div class="m-alert m-alert--icon alert alert-warning m--hide" role="alert" id="form_tool_rent_edit_msg">
              <div class="m-alert__icon">
                <i class="la la-warning"></i>
              </div>
              <div class="m-alert__text">
                Oh snap! Change a few things up and try submitting again.
              </div>
              <div class="m-alert__close">
                <button type="button" class="close" data-close="alert" aria-label="Close"></button>
              </div>
            </div>
          </div>
          <div class="row">
            <div class="col-lg-4" >
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Balance to Return
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <input readonly required type="text" name="returnable_qty_status_change" id="returnable_qty_edit_status_change"  class="form-control m-input form_tool_rent_edit_fields" placeholder="Qty to be returned" aria-describedby="basic-addon1">
                  <input required type="hidden" name="current_returned_qty_status_change" id="current_returned_qty_status_change">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-4" >
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Returned Quantity
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <input required type="text" name="quantity" id="returned_qty_edit_status_change"  class="form-control m-input form_tool_rent_edit_fields" placeholder="Returned Qty" aria-describedby="basic-addon1">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-lg-4">
              <div class="form-group m-form__group" >
                <label for="user_name">
                  Returned Date
                </label>
                <div class="input-group m-input-group m-input-group--pill m-input-group--air">
                  <input required type="text" name="date" id="returned_date_edit_status_change"  class="form-control m-input form_tool_rent_edit_fields" placeholder="Returned Date" data-date-format="dd-mm-yyyy" value="<?php echo date('d-m-Y')?>" aria-describedby="basic-addon1">
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <input type="hidden" name="redirect_url" value="<?php echo base_url(uri_string())?>" >
            <input type="hidden" name="rent_id" id="rent_id_edit_status_change" >
          </div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn  btn-secondary" data-dismiss="modal">
            Close
          </button>
          <button type="submit" class="btn form_submit_btn btn-primary">
            Submit
          </button>
        </div>
      </form>
    </div>
  </div>
</div>
<div class="modal fade" tabindex="-1" id="tool_rent_delete_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog " role="document" >
    <form autocomplete="off" data-modal-id="tool_rent_delete_modal" id="form_tool_transfer_delete" method="post" action="<?php echo base_url().'tools/delete_rent'?>" class="form-horizontal">
      <div class="modal-content">
        <div class="alert alert-danger" role="alert" style="margin-bottom: 0px">
          <button type="button" class="close" data-dismiss="modal"></button>
          <br/>
          <h4 class="alert-heading">Warning! Please Confirm Your Action</h4>
          <br/>
          <p> Are You Sure to Delete this Data ?. All the Associated Data will Lost. </p>
          <p>
            <button class="btn btn-danger form_submit_btn" type="submit" name="submit">Confirm & Delete</button>
            <button type="button" class="btn btn-primary modal-dismiss" data-dismiss="modal">Cancel</button>
          </p>
          <input type="hidden"  name="rent_id" id="rent_id_delete">
          <input type="hidden" name="redirect_url" value="<?php echo base_url(uri_string())?>" >
        </div>
      </div>
    </form>
  </div>
</div>


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

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

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

<!--begin::Page Snippets -->
<script>
$("#tools_menu").addClass('m-menu__item--active m-menu__item--open');
$("#tools_menu_4").addClass('m-menu__item--active');


//  client List Data Table
var Datatable=function() {
  var t=function() {


    var table = $('#tool_payments_view_table').DataTable({
      "ajax":{
        url :"<?php echo base_url().'tools/select_tools_payments/' ?>", // json datasource
        type: "post", // type of method  , by default would be get
        data: function(d){
          d.work_id = <?php echo $work_id; ?>;
        }
      },
      "bProcessing": true,
      "deferRender": true,
      "bDeferRender": true,
      "scrollX" : true,
      buttons: [
        { extend: 'print', className: 'btn dark btn-outline',exportOptions: {columns: ':visible'},title: 'Tool Payments' },
        { extend: 'csv', className: 'btn purple btn-outline ' },
        { extend: 'colvis', className: 'btn dark btn-outline', text: 'Columns'}
      ],
      dom:"<'row'<'col-sm-6 text-left'B><'col-sm-6 text-right'f>>\n\t\t\t<'row'<'col-sm-12'tr>>\n\t\t\t<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7 dataTables_pager'lp>>", // horizobtal scrollable datatable
      "lengthMenu": [
        [25, 50, 100, -1],
        [25, 50, 100, "All"] // change per page values here
      ],
      "columnDefs": [
        {
          "targets": [],
          className: "hidden"
        }
      ],
      'order': [[0, 'asc']]
    });


};
return {
  init:function() {
    t()
  }
}
}

();
jQuery(document).ready(function() {
  Datatable.init();
  $(".hidden").hide();
  //            $('#service_view_table').wrap("");
}

);
</script>
<style>
.hidden{
  display: none;
}
</style>
