<div class="m-form m-form--label-align-right m--margin-bottom-10">
  <div class="row">
    <div class="col-xl-12 order-2 order-xl-1">
      <div class="form-group m-form__group row ">
        <div class="col-md-5">
          <?php if($page_name!='work_profile'){ ?>
            <div class="form-group m-form__group">
              <label>
                Stock Location:
              </label>
              <div class="m-select2 m-select2--air m-select2--pill">
                <select style="width: 100%" class="form-control m-select2 table_filter" id="table_filter_location"   data-placeholder="Select Work">
                  <option value="all">All Location</option>
                  <?php
                  foreach($stock_locations as $row): ?>
                  <option data-work-status="<?php echo $row->work_status?>" value="<?php echo $row->location_id?>"><?php echo $row->location_name?></option>
                  <?php
                endforeach;
                ?>
              </select>
            </div>
            <span class="m-form__help"></span>
          </div>
        <?php } ?>
      </div>
      <div class="col-md-5">
        <div class="form-group m-form__group">
          <label>
            Material:
          </label>
          <div class="m-select2 m-select2--air m-select2--pill">
            <select style="width: 100%" class="form-control m-select2 table_filter" id="table_filter_material"  name="material_filter" >
              <option value="all">All Materials</option>
              <?php
              foreach($materials as $row): ?>
              <option value="<?php echo $row->material_id?>"><?php echo $row->material_name.' [ in '.$row->unit_name.']';?></option>
              <?php
            endforeach;
            ?>
          </select>
        </div>
        <span class="m-form__help"></span>
      </div>
    </div>
    <?php if($page_name=='stock_register'){ ?>
      <div class="col-md-2">
        <button type="submit" id="btn_get_stock_register" style="margin-top:25px" class="btn btn-brand m-btn--air m-btn--pill">
          <i class="fa fa-search"></i> Get Stock Register
        </button>
      </div>
    <?php } ?>

  </div>
</div>
</div>
</div>
<div id="stock_register_result_div" style="display:none">
  <table width="100%" class="table m-table  table-header-fixed table-striped- table-bordered table-hover table-header-fixed " id="stock_register_view_table">
    <thead>
      <tr class="">
        <th rowspan="2">Sl No</th>
        <th rowspan="2">Stock ID</th>
        <th rowspan="2">Material ID</th>
        <th rowspan="2">Unit ID</th>
        <th rowspan="2">Location ID</th>
        <th rowspan="2">Material Name</th>
        <th rowspan="2">Unit</th>
        <th rowspan="2">Unit Price</th>
        <th rowspan="2">Supplier</th>
        <th colspan="2">Currently Available Stock</th>
        <th rowspan="2">Location</th>
        <th rowspan="2">Location Type</th>
        <th colspan="2">Total Opening Stock</th>
        <th colspan="2">Total Purchased Stock</th>
        <?php if ($this->config->item('app_module_production') == 1 ){?>
          <th colspan="2">Total Production Stock</th>
        <?php } ?>
        <th colspan="2">Total Transferred In Stock</th>
        <th colspan="2">Total Transferred Out Stock</th>
        <th colspan="2">Total Consumed Stock</th>
        <?php if ($this->config->item('app_module_sales_invoice') == 1 ){?>
        <th colspan="2">Total Sold Stock</th>
        <?php } ?>
        <th colspan="2">Total Purchase Returned Stock</th>
        <?php if ($this->config->item('app_module_production') == 1 ){?>
          <th colspan="2">Total Damaged Stock</th>
        <?php } ?>
        <th rowspan="2">Supplier ID</th>
        <th rowspan="2"></th>
      </tr>
      <tr>
        <th><span class="hidden">Currently Available Stock</span> Qty</th>
        <th>Amount</th>
        <th><span class="hidden">Total Opening Stock</span> Qty</th>
        <th>Amount</th>
        <th><span class="hidden">Total Purchased Stock</span> Qty</th>
        <th>Amount</th>
        <?php if ($this->config->item('app_module_production') == 1 ){?>
          <th><span class="hidden">Total Production Stock</span> Qty</th>
          <th>Amount</th>
        <?php } ?>
        <th><span class="hidden">Total Transferred In Stock</span>Qty</th>
        <th>Amount</th>
        <th><span class="hidden">Total Transferred Out Stock</span>Qty</th>
        <th>Amount</th>
        <th><span class="hidden">Total Consumed Stock</span>Qty</th>
        <th>Amount</th>
        <?php if ($this->config->item('app_module_sales_invoice') == 1 ){?>
        <th><span class="hidden">Total Sold Stock</span> Qty</th>
        <th>Amount</th>
        <?php } ?>
        <th><span class="hidden">Total Purchased Returned Stock</span> Qty</th>
        <th>Amount</th>
        <?php if ($this->config->item('app_module_production') == 1 ){?>
          <th><span class="hidden">Total Damaged Stock</span> Qty</th>
          <th>Amount</th>
        <?php } ?>
      </tr>
    </thead>
    <tbody>
    </tbody>
  </table>
</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 ID</th>
                <th>Purchase Date</th>
                <th>Supplier</th>
                <th>Material Name</th>
                <th>Item Code</th>
                <th>Quantity</th>
                <th>Unit</th>
                <th>Unit Price</th>
                <th><?php if($this->config->item('Tax_tax_splitting')==1){ echo "Total ";}?><?php echo $this->config->item('Tax_tax_name')?> %</th>
                <th><?php if($this->config->item('Tax_tax_splitting')==1){ echo "Total ";}?><?php echo $this->config->item('Tax_tax_name')?> Amt</th>
                <th><?php echo $this->config->item('Tax_tax1_name')?> %</th>
                <th><?php echo $this->config->item('Tax_tax1_name')?> Amt</th>
                <th><?php echo $this->config->item('Tax_tax2_name')?> %</th>
                <th><?php echo $this->config->item('Tax_tax2_name')?> Amt</th>
                <th><?php echo $this->config->item('Tax_tax3_name')?> %</th>
                <th><?php echo $this->config->item('Tax_tax3_name')?> Amt</th>
                <th>Total Amount<br/>(Without Tax)</th>
                <th>Total Amount<br/>(With Tax)</th>
                <th>Item Desc</th>
                <th>Bill Remarks</th>
                <th>Created By</th>
                <th>Created Date</th>
                <th>Purchased to Location</th>
                <th>Vehicle</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>
