<?php if($page_name!='data_entry_approval' && $page_name!='work_summary'){ ?>
  <div class="m-form m-form--label-align-right m--margin-bottom-10">
    <div class="row align-items-center">
      <div class="col-xl-12 order-2 order-xl-1">
        <div class="form-group m-form__group row ">
          <div class="col-md-3">
            <?php if(!isset($list_type) || $list_type!="payable"){?>
              <div class="m-form__label">
                <label class="m-label m-label--single">
                  Date:
                </label>
              </div>
              <div class="row">
                <div class="col-md-6">
                  <div class="m-form__control">
                    <input value="<?php if($page_name=='purchase_order_view'){ echo date('d-m-Y');}?>" data-date-format="dd-mm-yyyy" id="table_filter_purchase_order_start_date" type="text"  class="form-control m-input table_filter  m-input--pill m-input--air" placeholder="Start Date" >
                  </div>
                </div>
                <div class="col-md-6">
                  <div class="m-form__control">
                    <input value="<?php if($page_name=='purchase_order_view'){ echo date('d-m-Y');}?>" data-date-format="dd-mm-yyyy" id="table_filter_purchase_order_end_date" type="text"  class="form-control m-input table_filter  m-input--pill m-input--air" placeholder="End Date" >
                  </div>
                </div>
              </div>
            <?php } ?>
          </div>
          <?php if($page_name!='work_profile'){ ?>
            <div class="col-md-3">
              <div class="form-group m-form__group">
                <label>
                  Order to 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_purchase_order_location"   data-placeholder="Select Work">
                    <option value="all">All Location</option>
                    <?php
                    foreach($stock_locations as $row):
                      $location_name = $row->location_name;
                      if($row->location_type=='work_site'){
                        $location_name .= " [Work Site]";
                      }elseif($row->location_type=='ware_house'){
                        $location_name .= " [Warehouse]";
                      }
                      ?>
                      <option data-work-status="<?php echo $row->work_status?>" value="<?php echo $row->location_id?>"><?php echo $location_name?></option>
                      <?php
                    endforeach;
                    ?>
                  </select>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
          <?php } ?>
          <?php if($page_name!='supplier_profile'){ ?>
            <div class="col-md-3">
              <div class="form-group m-form__group">
                <label>
                  Supplier:
                </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_purchase_order_supplier"  name="supplier" data-placeholder="Select Supplier">
                    <option value="all">All Suppliers</option>
                    <?php
                    foreach($suppliers_list as $row): ?>
                    <option value="<?php echo $row->supplier_id?>"><?php echo $row->supplier_name?></option>
                    <?php
                  endforeach;
                  ?>
                </select>
              </div>
              <span class="m-form__help"></span>
            </div>
          </div>
        <?php } ?>
        <div class="col-md-3">
          <div class="form-group m-form__group">
            <label>
              Status:
            </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_purchase_order_status"  name="order_status" data-placeholder="Select Status">
                <option value="all" selected>All Orders</option>
                <?php if($this->config->item('Purchase_purchase_order_approval')==1){ ?>
                  <option value="approval_pending">Pending Approval</option>
                  <option value="approved">Approved</option>
                <?php } ?>
                <option value="balance_to_bill">Bill Not Created/Balance to Bill</option>
                <option value="billed">Billed</option>
            </select>
          </div>
          <span class="m-form__help"></span>
        </div>
      </div>
      </div>
    </div>
  </div>
</div>
<?php } ?>
<table width="100%" class="table m-table nowrap table-header-fixed table-striped table-bordered table-hover table-header-fixed" id="purchase_order_view_table">
  <thead>
    <tr class="">
      <th>Sl No</th>
      <th>Order ID</th>
      <th>Order Date</th>
      <th>Supplier Name</th>
      <th>Order to Location</th>
      <th>Est Amount</th>
      <th>Total Paid</th>
      <th>Bill Creation Status</th>
      <th>Total Billed Amt</th>
      <th>Balance Amt to Bill</th>
      <th>Other Details</th>
      <th>Billing Address</th>
      <th>Approval</th>
      <th>Creation</th>
      <th>Actions</th>
      <th>ID</th>
      <th>Approval Status</th>
    </tr>
  </thead>
  <tbody>
  </tbody>
</table>

<div class="modal fade" tabindex="-1" id="purchase_order_approve_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog " 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" >
          Approve Purchase Order
        </h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">
            &times;
          </span>
        </button>
      </div>
      <form data-form-type="purchase_order_approve_status" data-modal-id="purchase_order_approve_modal" autocomplete="off" id="edit_purchase_order_approve_form" method="post" action="<?php echo base_url().'purchase_order/approve'?>" 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_material_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>
          <input type="hidden" name="order_id" id="purchase_order_id">
          <div class="row">
            <div class="col-lg-12">
              <div class="form-group m-form__group" >
                <div class="m-radio-inline" style="margin-top: 10px;">
                  <label class="m-radio m-radio m-radio--solid m-radio--state-success">
                    <input required type="radio" name="approve_status"  value="1" checked>
                    Approved
                    <span></span>
                  </label>
                  <label class="m-radio m-radio m-radio--solid m-radio--state-danger">
                    <input type="radio" name="approve_status"  value="2">
                    Rejected
                    <span></span>
                  </label>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
          </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>
