<?php $this->view("includes/Inc_pagehead");?>
<!-- Page Styles Goes Here-->
<style>
.m-input{
  border: 1px solid #ebedf2 !important;
  background-color: #f4f5f833 !important;
}
#payment_view_table .dataTables_scrollHeadInner {
  width:100% !important;
  padding: 0 !important;
}

</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">
          Stock Location Profile
        </h3>
      </div>
    </div>
  </div>


  <!-- END: Subheader -->
  <div class="m-content">
    <div class="row">
      <div class="col-xl-3 col-lg-4">
        <div class="m-portlet m-portlet--full-height  ">
          <div class="m-portlet__body" style="padding-top: 0px">
            <div class="m-card-profile">
              <div class="m-card-profile__title m--hide">
                Stock Location Profile
              </div>
              <div class="m-card-profile__pic">
                <div class="m-card-profile__pic-wrapper">
                  <img src="<?php echo $this->config->item('Template_template_file_url'); ?>template/assets/app/media/img/users/user.png" alt=""/>
                </div>
              </div>
              <div class="m-card-profile__details">
                <span class="m-card-profile__name">
                  #<?php echo $location_data->location_id?> - <?php echo $location_data->location_name?>
                </span>

              </div>
              <div class="m-card-profile__details">
                <span class="m-card-profile__name">
                  <?php if($location_data->location_type=='work_site'){?>
                    <span class="m-badge m-badge--success m-badge--wide">Work Site</span><br/>
                    <span style="margin-top: 10px" class="m-badge m-badge--wide">Stock Location Of <br/><a href="<?php echo base_url().'work/profile/'.$location_data->work_id; ?>"><?php echo "#".$location_data->work_id." - ".$location_data->work_name ?></a></span>
                  <?php }else{?>
                    <span class="m-badge m-badge--success m-badge--wide">Ware House</span>
                  <?php } ?>
                </span>
              </div>
              <br/>
            </div>
            <ul class="m-nav m-nav--hover-bg m-portlet-fit--sides">
              <li class="m-nav__separator m-nav__separator--fit" style="margin-top: 0px"></li>
              <li class="m-nav__section m--hide">
                <span class="m-nav__section-text">
                  Section
                </span>
              </li>
              <li class="m-nav__item profile_nav" id="nav_overview" data-nav="overview" data-table-name=''>
                <a href="javascript:;" class="m-nav__link">
                  <i class="m-nav__link-icon fa fa-industry"></i>
                  <span class="m-nav__link-title">
                    <span class="m-nav__link-wrap">
                      <span class="m-nav__link-text">
                        Overview
                      </span>
                    </span>
                  </span>
                </a>
              </li>
              <li class="m-nav__item profile_nav" id="nav_stock_register" data-nav="stock_register" data-table-name='stock_register_view_table'>
                <a href="javascript:;" class="m-nav__link">
                  <i class="m-nav__link-icon fa fa-server"></i>
                  <span class="m-nav__link-title">
                    <span class="m-nav__link-wrap">
                      <span class="m-nav__link-text">
                        Stock Register
                      </span>
                    </span>
                  </span>
                </a>
              </li>
              <?php if($this->config->item('app_module_purchase_order')==1){?>
                <li class="m-nav__item profile_nav" id="nav_purchase_orders" data-nav="purchase_orders" data-table-name='purchase_order_view_table'>
                  <a href="javascript:;" class="m-nav__link">
                    <i class="m-nav__link-icon fa fa-shopping-cart"></i>
                    <span class="m-nav__link-title">
                      <span class="m-nav__link-wrap">
                        <span class="m-nav__link-text">
                          Purchase Orders
                        </span>
                      </span>
                    </span>
                  </a>
                </li>
                <li class="m-nav__item profile_nav" id="nav_purchase_order_payments" data-nav="purchase_order_payments" data-table-name='purchase_order_transaction_view_table'>
                  <a href="javascript:;" class="m-nav__link">
                    <i class="m-nav__link-icon fa fa-money-bill-alt"></i>
                    <span class="m-nav__link-title">
                      <span class="m-nav__link-wrap">
                        <span class="m-nav__link-text">
                          Purchase Order Payments
                        </span>
                      </span>
                    </span>
                  </a>
                </li>
              <?php } ?>
              <li class="m-nav__item profile_nav" id="nav_purchases" data-nav="purchases" data-table-name='purchase_bills_view_table'>
                <a href="javascript:;" class="m-nav__link">
                  <i class="m-nav__link-icon fa fa-shopping-cart"></i>
                  <span class="m-nav__link-title">
                    <span class="m-nav__link-wrap">
                      <span class="m-nav__link-text">
                        Purchase Bills
                      </span>
                    </span>
                  </span>
                </a>
              </li>
              <li class="m-nav__item profile_nav" id="nav_purchase_materials" data-nav="purchase_materials" data-table-name='materials_purchased_view_table'>
                <a href="javascript:;" class="m-nav__link">
                  <i class="m-nav__link-icon fa fa-shopping-cart"></i>
                  <span class="m-nav__link-title">
                    <span class="m-nav__link-wrap">
                      <span class="m-nav__link-text">
                        Purchased Materials
                      </span>
                    </span>
                  </span>
                </a>
              </li>
              <li class="m-nav__item profile_nav" id="nav_purchase_payments" data-nav="purchase_payments" data-table-name='purchase_bill_transaction_view_table'>
                <a href="javascript:;" class="m-nav__link">
                  <i class="m-nav__link-icon fa fa-money-bill-alt"></i>
                  <span class="m-nav__link-title">
                    <span class="m-nav__link-wrap">
                      <span class="m-nav__link-text">
                        Purchase Bill Payments
                      </span>
                    </span>
                  </span>
                </a>
              </li>
              <li class="m-nav__item profile_nav" id="nav_transfer_in" data-nav="transfer_in" data-table-name='stock_transfer_in_view_table'>
                <a href="javascript:;" class="m-nav__link">
                  <i class="m-nav__link-icon fa fa-sign-in-alt"></i>
                  <span class="m-nav__link-title">
                    <span class="m-nav__link-wrap">
                      <span class="m-nav__link-text">
                        Stock Transfer In
                      </span>
                    </span>
                  </span>
                </a>
              </li>
              <li class="m-nav__item profile_nav" id="nav_transfer_out" data-nav="transfer_out" data-table-name='stock_transfer_out_view_table'>
                <a href="javascript:;" class="m-nav__link">
                  <i class="m-nav__link-icon fa fa-sign-out-alt"></i>
                  <span class="m-nav__link-title">
                    <span class="m-nav__link-wrap">
                      <span class="m-nav__link-text">
                        Stock Transfer Out
                      </span>
                    </span>
                  </span>
                </a>
              </li>
              <li class="m-nav__item profile_nav" id="nav_consumption" data-nav="consumption" data-table-name='stock_consumption_view_table'>
                <a href="javascript:;" class="m-nav__link">
                  <i class="m-nav__link-icon fa fa-shopping-basket"></i>
                  <span class="m-nav__link-title">
                    <span class="m-nav__link-wrap">
                      <span class="m-nav__link-text">
                        Material Consumption
                      </span>
                    </span>
                  </span>
                </a>
              </li>
            </ul>

          </div>
        </div>
      </div>
      <div class="col-xl-9 col-lg-8">
        <div id="div_overview" class="profile_nav_div">
          <div class="m-portlet">
            <div class="m-portlet__body m-portlet__body--no-padding">
              <div class="row m-row--no-padding m-row--col-separator-xl">
                <div class="col-md-12 col-lg-12 col-xl-4">
                  <!--begin:: Widgets/Stats2-1 -->
                  <div class="m-widget1">
                    <div class="m-widget1__item">
                      <div class="row m-row--no-padding align-items-center">
                        <div class="col">
                          <h3 class="m-widget1__title">
                            Total Purchased Stock Amt
                          </h3>
                        </div>
                        <div class="col m--align-right">
                          <span class="m-widget1__number m--font-brand">
                            <label class="total_purchase_amt_info"></label>
                          </span>
                        </div>
                      </div>
                    </div>
                  </div>
                  <!--end:: Widgets/Stats2-1 -->
                </div>
                <div class="col-md-12 col-lg-12 col-xl-4">
                  <!--begin:: Widgets/Stats2-2 -->
                  <div class="m-widget1">
                    <div class="m-widget1__item">
                      <div class="row m-row--no-padding align-items-center">
                        <div class="col">
                          <h3 class="m-widget1__title">
                            Total Transferred In Stock Amt
                          </h3>
                        </div>
                        <div class="col m--align-right">
                          <span class="m-widget1__number m--font-accent">
                            <label class="total_transferred_in_amt_info"></label>
                          </span>
                        </div>
                      </div>
                    </div>
                  </div>
                  <!--begin:: Widgets/Stats2-2 -->
                </div>
                <div class="col-md-12 col-lg-12 col-xl-4">
                  <!--begin:: Widgets/Stats2-3 -->
                  <div class="m-widget1">
                    <div class="m-widget1__item">
                      <div class="row m-row--no-padding align-items-center">
                        <div class="col">
                          <h3 class="m-widget1__title">
                            Total Transferred Out Stock Amt
                          </h3>
                        </div>
                        <div class="col m--align-right">
                          <span class="m-widget1__number m--font-success">
                            <label class="total_transferred_out_amt_info"></label>
                          </span>
                        </div>
                      </div>
                    </div>
                  </div>
                  <!--begin:: Widgets/Stats2-3 -->
                </div>
              </div>
            </div>
          </div>
          <div class="m-portlet">
            <div class="m-portlet__body m-portlet__body--no-padding">
              <div class="row m-row--no-padding m-row--col-separator-xl">
                <div class="col-md-12 col-lg-12 col-xl-6">
                  <!--begin:: Widgets/Stats2-1 -->
                  <div class="m-widget1">
                    <div class="m-widget1__item">
                      <div class="row m-row--no-padding align-items-center">
                        <div class="col">
                          <h3 class="m-widget1__title">
                            Total Stock Consumed Amt
                          </h3>
                        </div>
                        <div class="col m--align-right">
                          <span class="m-widget1__number m--font-brand">
                            <label class="total_consumed_amt_info"></label>
                          </span>
                        </div>
                      </div>
                    </div>
                  </div>
                  <!--end:: Widgets/Stats2-1 -->
                </div>
                <div class="col-md-12 col-lg-12 col-xl-6">
                  <!--begin:: Widgets/Stats2-2 -->
                  <div class="m-widget1">
                    <div class="m-widget1__item">
                      <div class="row m-row--no-padding align-items-center">
                        <div class="col">
                          <h3 class="m-widget1__title">
                            Total Balance Stock Amt
                          </h3>
                        </div>
                        <div class="col m--align-right">
                          <span class="m-widget1__number m--font-accent">
                            <label class="total_balance_amt_info"></label>
                          </span>
                        </div>
                      </div>
                    </div>
                  </div>
                  <!--begin:: Widgets/Stats2-2 -->
                </div>

              </div>
            </div>
          </div>
          <div class="m-portlet  m-portlet--rounded m-portlet--bordered">
            <div class="m-portlet__body">
              <h3 class="m-portlet__head-text" style="text-align: center">
                Payment Summary
              </h3>
              <table width="100%" class="table m-table nowrap table-header-fixed table-striped table-bordered table-hover table-header-fixed" id="all_payments">
                <thead>
                  <tr class="">
                    <th>Types Of Payments</th>
                    <th>Amount</th>
                  </tr>
                </thead>
                <tbody>
                  <tr>
                    <td>Total Purchase Bill Amount</td>
                    <strong><td class="total_purchase_amt_info"></td></strong>
                  </tr>
                  <tr>
                    <td></td>
                    <td></td>
                  </tr>
                  <tr>
                    <td>Purchase Order Payments (Advances)</td>
                    <strong><td class="total_purchase_order_payment_info"></td></strong>
                  </tr>
                  <tr>
                    <td>Purchase Bill Payments</td>
                    <strong><td class="total_purchase_bill_payment_info"></td></strong>
                  </tr>
                  <tr>
                    <td>Total Purchase Payments (Purchase Order + Purchase Bill)</td>
                    <strong><td class="total_purchase_payment_info"></td></strong>
                  </tr>
                  <tr>
                    <td>Total Pending Purchase Bill Payment </td>
                    <strong><td class="total_purchase_bill_pending_info"></td></strong>
                  </tr>
                  <tr>
                    <td></td>
                    <td></td>
                  </tr>
                  <tr>
                    <td>Total Purchased Stock Value</td>
                    <strong><td class="total_purchase_amt_info"></td></strong>
                  </tr>
                  <tr>
                    <td>Total Transferred In Stock Value</td>
                    <strong><td class="total_transferred_in_amt_info"></td></strong>
                  </tr>
                  <tr>
                    <td>Total Transferred Out Stock Value</td>
                    <strong><td class="total_transferred_out_amt_info"></td></strong>
                  </tr>
                  <tr>
                    <td>Total Consumed Stock Value</td>
                    <strong><td class="total_consumed_amt_info"></td></strong>
                  </tr>
                  <tr>
                    <td>Remaining Stock Value</td>
                    <strong><td class="total_balance_amt_info"></td></strong>
                  </tr>

                </tbody>
              </table>
            </div>
          </div>
        </div>
        <div id="div_stock_register" class="profile_nav_div">
          <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">
                    Stock Register
                  </h3>
                </div>
              </div>
              <div class="m-portlet__head-tools">

              </div>
            </div>
            <div class="m-portlet__body">
              <!--begin: Datatable -->
              <?php $this->view("modules/include_tables/table_stock_register");?>
              <!--end: Datatable -->
            </div>
          </div>
        </div>
        <div id="div_purchase_orders" class="profile_nav_div">
          <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">
                    Purchase Orders
                  </h3>
                </div>
              </div>
              <div class="m-portlet__head-tools">

              </div>
            </div>
            <div class="m-portlet__body">
              <!--begin: Datatable -->
              <?php $this->view("modules/include_tables/table_purchase_order");?>
              <!--end: Datatable -->
            </div>
          </div>
        </div>
        <div id="div_purchase_order_payments" class="profile_nav_div">
          <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">
                    Purchase Order Payments (Orders Those Haven't Purchase Bill Created)
                  </h3>
                </div>
              </div>
            </div>
            <div class="m-portlet__body">
              <!--begin: Datatable -->
              <?php $this->view("modules/include_tables/table_purchase_order_payments");?>
              <!--end: Datatable -->
            </div>
          </div>
        </div>
        <div id="div_purchases" class="profile_nav_div">
          <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">
                    Purchase Blls
                  </h3>
                </div>
              </div>
              <div class="m-portlet__head-tools">

              </div>
            </div>
            <div class="m-portlet__body">
              <?php $this->view("modules/include_tables/table_purchase_bills");?>
              <!--end: Datatable -->
            </div>
          </div>
        </div>
        <div id="div_purchase_materials" class="profile_nav_div">
          <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 Material Purchased
                  </h3>
                </div>
              </div>
            </div>
            <div class="m-portlet__body">
              <!--begin: Datatable -->
              <?php $this->view("modules/include_tables/table_materials_purchased");?>
              <!--end: Datatable -->
            </div>
          </div>
        </div>
        <div id="div_purchase_payments" class="profile_nav_div">
          <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">
                    Purchase Bill Payments
                  </h3>
                </div>
              </div>
            </div>
            <div class="m-portlet__body">
              <!--begin: Datatable -->
              <?php $this->view("modules/include_tables/table_purchase_bill_payments");?>
              <!--end: Datatable -->
            </div>
          </div>
        </div>
        <div id="div_transfer_in" class="profile_nav_div">
          <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">
                    Stock Transfer In List
                  </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="stock_transfer_in_view_table">
                <thead>
                  <tr class="">
                    <th>Sl No</th>
                    <th>Transfer ID</th>
                    <th>Bill ID</th>
                    <th>Date</th>
                    <th>Material Name</th>
                    <th>Unit</th>
                    <th>Transferred Stock Qty</th>
                    <th>Transferred Stock Amt</th>
                    <th>Transferred From</th>
                    <th>Transferred To</th>
                    <th>Transferred By</th>
                    <th>Transferred On</th>
                    <th></th>
                  </tr>
                </thead>
                <tbody>
                </tbody>
              </table>
              <!--end: Datatable -->
            </div>
          </div>
        </div>
        <div id="div_transfer_out" class="profile_nav_div">
          <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">
                    Stock Transfer Out List
                  </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="stock_transfer_out_view_table">
                <thead>
                  <tr class="">
                    <th>Sl No</th>
                    <th>Transfer ID</th>
                    <th>Bill ID</th>
                    <th>Date</th>
                    <th>Material Name</th>
                    <th>Unit</th>
                    <th>Transferred Stock Qty</th>
                    <th>Transferred Stock Amt</th>
                    <th>Transferred From</th>
                    <th>Transferred To</th>
                    <th>Transferred By</th>
                    <th>Transferred On</th>
                    <th></th>
                  </tr>
                </thead>
                <tbody>
                </tbody>
              </table>
              <!--end: Datatable -->
            </div>
          </div>
        </div>
        <div id="div_consumption" class="profile_nav_div">
          <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">
                    Material Consumptions
                  </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="stock_consumption_view_table">
                <thead>
                  <tr class="">
                    <th>Sl No</th>
                    <th>Cons ID</th>
                    <th>Date</th>
                    <th>Material Name</th>
                    <th>Unit</th>
                    <th>Consumed Stock Qty</th>
                    <th>Consumed Stock Price</th>
                    <th>Work</th>
                    <th>Created By</th>
                    <th></th>
                  </tr>
                </thead>
                <tbody>
                </tbody>
              </table>
              <!--end: Datatable -->
            </div>
          </div>
        </div>

      </div>
    </div>
  </div>

  <div class="modal fade" tabindex="-1" id="purchase_history_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-lg" role="document" >
      <div class="modal-content" >
        <div class="modal-header" style="background-color: #36a3f7;border-radius: 4px">
          <h5 class="modal-title" id="exampleModalLabel" style="color: #ffffff" >
            View Purchase History
          </h5>
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">
              &times;
            </span>
          </button>
        </div>
        <form autocomplete="off"  method="post" action="" enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right " >
          <div class="modal-body">
            <table width="100%" class="table m-table nowrap table-header-fixed table-striped table-bordered table-hover table-header-fixed" id="purchase_history_view_table">
              <thead>
                <tr class="">
                  <th>Sl No</th>
                  <th>Purchase Bill ID</th>
                  <th>Purchase Date</th>
                  <th>Material Name</th>
                  <th>Quantity</th>
                  <th>Unit</th>
                  <th>Total Amount</th>
                  <th>Unit Price</th>
                  <th>Item Type</th>
                  <th>Created By</th>
                  <th>Created Date</th>
                  <th>Purchased to Location</th>
                  <th>View Bill</th>
                </tr>
              </thead>
              <tbody>
              </tbody>
            </table>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-dismiss="modal">
              Close
            </button>
          </div>
        </form>
      </div>
    </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 src="<?php echo $this->config->item('Template_template_file_url'); ?>template/assets/app/js/dashboard.js" type="text/javascript"></script>
<!--end::Page Snippets -->

<script>
function hide_all(){
  $(".profile_nav").removeClass('m-nav__item--active');
  $(".profile_nav_div").hide();
}
function active(menu_name){
  hide_all();
  $("#nav_"+menu_name).addClass('m-nav__item--active');
  $("#div_"+menu_name).show();
  $("#div_"+menu_name).fadeIn("slow");
  $('html, body').animate({
    scrollTop: eval($("#div_"+menu_name).offset().top - 150)
  }, 500);
}
//  Hide All Div and In Active All Menu
hide_all();
//  Active First Menu and Its div
active('overview');
$('body').on('click', '.profile_nav', function() {
  var nav = $(this).attr('data-nav');
  active(nav);
})
</script>
<script>

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

$("#stock_menu").addClass('m-menu__item--active m-menu__item--open');
$("#stock_menu_3").addClass('m-menu__item--active');

select_summary();
function select_summary(){
  var location_id = "<?php echo $location_data->location_id?>";
  $.post("<?php echo base_url().'stock/select_location_summary/count' ?>",{
    location_id:location_id
  },function(data){
    var obj= $.parseJSON(data);
    $(".total_purchase_order_payment_info").text(obj.total_purchase_order_payment);
    $(".total_purchase_bill_payment_info").text(obj.total_purchase_bill_payment);
    $(".total_purchase_payment_info").text(obj.total_purchase_payment);
    $(".total_purchase_bill_pending_info").text(obj.total_purchase_bill_pending_amount);
    $(".total_purchase_amt_info").text(obj.total_purchase_bill_amount);
    $(".total_transferred_in_amt_info").text(obj.total_transferred_in_stock_amt);
    $(".total_transferred_out_amt_info").text(obj.total_transferred_out_stock_amt);
    $(".total_consumed_amt_info").text(obj.total_consumption_stock_amt);
    $(".total_balance_amt_info").text(obj.total_balance_stock_amt);

  })
}
</script>
<!-- Bill Scripts -->
<?php $this->view("modules/include_scripts/bill_scripts");?>

<!-- Transaction Scripts -->
<?php $this->view("modules/include_scripts/transaction_scripts");?>

<!-- Purchase Order Scripts -->
<?php $this->view("modules/include_scripts/purchase_order_view_scripts");?>

<!-- Purchase Order Payments Scripts -->
<?php $this->view("modules/include_scripts/purchase_order_payments_view_scripts");?>

<!-- Purchase Bill Scripts -->
<?php $this->view("modules/include_scripts/purchase_bill_view_scripts");?>

<!-- Purchase Bill Payments Scripts -->
<?php $this->view("modules/include_scripts/purchase_bill_payments_view_scripts");?>

<!-- Purchased Material Scripts -->
<?php $this->view("modules/include_scripts/materials_purchased_view_scripts");?>

<!-- Stock Register Scripts -->
<?php $this->view("modules/include_scripts/stock_register_view_scripts");?>
<script>
  var location_id = "<?php echo $location_data->location_id?>";


  var stock_consumption_view_table = $('#stock_consumption_view_table').DataTable({
    "ajax":{
      url :"<?php echo base_url().'stock/select_stock_consumption' ?>", // json datasource
      type: "post", // type of method  , by default would be get
      data: function(d){
        d.location_id = location_id;
      }
    },
    "bProcessing": true,
    "deferRender": true,
    "bDeferRender": true,
    "scrollX" : true,
    scrollX:!0, scrollCollapse:!0,
    buttons: [
    { extend: 'print', className: 'btn dark btn-outline',exportOptions: {columns: ':visible'},title: 'Stock Consumptions' },
    { 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": [ 1,9],
      className: "hidden"
    }
    ],
    'order': false
  });

  jQuery(document).ready(function() {
    $('.profile_nav').on('click', function(e){
      var table_name = $(this).attr('data-table-name');
      if(table_name!=''){
        var tables = table_name.split(',');
        $.each(tables, function( index, value ){
          var table_name = value;
          eval(table_name).ajax.reload();
        });
      }
    });
    $(".form_submit_btn").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: {
          paid_amount: {
            number: !0,
            required: !0
          }
        }, invalidHandler: function (e, r) {
          var i = $("#" + form_id + "_msg");
          i.removeClass("m--hide").show(), mUtil.scrollTo(i, -200)
        }, submitHandler: function (e) {
        }
      }), 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('');
            $("."+form_id+"_select").val('').trigger("change");
            select_summary();

          } 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");
        }
      })
      )
    });
    $($.fn.dataTable.tables(true)).DataTable()
    .columns.adjust()
    .responsive.recalc();

  });
</script>
