<?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">
          Data Entry Approval
        </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().'user/data_approval' ?>" class="m-nav__link">
              <span class="m-nav__link-text">
                Data Entry Approval
              </a>
            </li>
          </ul>
        </div>
        <div>

        </div>
      </div>
    </div>
    <!-- END: Subheader -->
    <div class="m-content">
      <div class="m-portlet  m-portlet--rounded m-portlet--bordered">
        <div class="m-portlet__body" style="padding: 1rem 2.2rem;">
          <div class="m-form m-form--label-align-right m--margin-bottom-10">
            <div class="row ">
              <div class="col-md-3">
                <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 data-date-format="dd-mm-yyyy" value="<?php echo date('d-m-Y')?>" id="table_filter_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 data-date-format="dd-mm-yyyy" value="<?php echo date('d-m-Y')?>" id="table_filter_end_date" type="text"  class="form-control m-input table_filter  m-input--pill m-input--air" placeholder="End Date" >
                    </div>
                  </div>
                </div>
              </div>
              <div class="col-md-3">
                <div class="form-group m-form__group">
                  <label>
                    Work:
                  </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_work" >
                      <option value="all">All Works</option>
                      <?php
                      foreach($work_contracts as $row): ?>
                      <option data-work-status="<?php echo $row->work_status?>" value="<?php echo $row->work_id?>"><?php echo $row->work_name?></option>
                      <?php
                    endforeach;
                    ?>
                  </select>
                </div>
                <span class="m-form__help">(Labour Payment & Travel Allowance are Not Applicable)</span>
              </div>
            </div>
            <div class="col-md-3">
              <div class="form-group m-form__group">
                <label>
                  Created User :
                </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_user"  name="" data-placeholder="Select Tool">
                    <option selected value="all">All</option>
                    <?php foreach($users as $row) { ?>
                      <option value="<?php echo $row->user_id ?>"><?php echo $row->user_alias ?></option>
                    <?php } ?>
                  </select>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-md-3">
              <div class="form-group m-form__group">
                <label>
                  Approval 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_approval_status"  name="" data-placeholder="Select Approval Type">
                    <option selected value="all">All Data</option>
                    <option value="0">Pending</option>
                    <option value="1">Approved</option>
                    <option value="2">Rejected</option>
                  </select>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <div class="col-md-3">
              <div class="form-group m-form__group">
                <label>
                  Debited/Credited Account :
                </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_account"  name="" data-placeholder="Select Account">
                    <option selected value="all">All Accounts</option>
                    <?php
                    foreach($this->config->item('account_heads') as $row): ?>
                      <option value="<?php echo $row->acc_head_id?>"><?php echo $row->acc_head_name?></option>
                      <?php
                    endforeach;
                    ?>
                  </select>
                </div>
                <span class="m-form__help">Some Tables are Not Applicable</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_account_transfer">
      <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 Account Transfers
            </h3>
          </div>
        </div>
      </div>
      <div class="m-portlet__body">
        <!--begin: Datatable -->
        <?php $this->view("modules/include_tables/table_account_transfer");?>
        <!--end: Datatable -->
      </div>
    </div>
    <?php if($this->config->item('Client_Payment_client_payment_invoice')==1) { ?>
      <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_client_invoice">
        <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 Client Invoices
              </h3>
            </div>
          </div>
        </div>
        <div class="m-portlet__body">
          <!--begin: Datatable -->
          <?php $this->view("modules/include_tables/table_invoices");?>
          <!--end: Datatable -->
        </div>
      </div>
    <?php } ?>
    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_client_payments">
      <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 Client Payments <?php if($this->config->item('Client_Payment_client_payment_invoice')==1) { ?>(Advances & Invoice Payments)<?php } ?>
            </h3>
          </div>
        </div>
      </div>
      <div class="m-portlet__body">
        <!--begin: Datatable -->
        <?php $this->view("modules/include_tables/table_client_payments");?>
        <!--end: Datatable -->
      </div>
    </div>
    <?php if($this->config->item('app_module_purchase_order')==1){ ?>
      <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_purchase_order">
        <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 Purchase Orders
              </h3>
            </div>
          </div>
        </div>
        <div class="m-portlet__body">
          <!--begin: Datatable -->
          <?php $this->view("modules/include_tables/table_purchase_order");?>
          <!--end: Datatable -->
        </div>
      </div>
      <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_purchase_order_payments">
        <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 Purchase Orders Payments
              </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>
    <?php } ?>
    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_purchase_bills">
      <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 Purchase Bills
            </h3>
          </div>
        </div>
      </div>
      <div class="m-portlet__body">
        <!--begin: Datatable -->
        <?php $this->view("modules/include_tables/table_purchase_bills");?>
        <!--end: Datatable -->
      </div>
    </div>
    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_purchase_bill_payments">
      <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 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 class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_supplier_payments">
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
            Supplier Advance / OP Balance Payments
            </h3>
          </div>
        </div>
      </div>
      <div class="m-portlet__body">
        <?php $this->view("modules/include_tables/table_supplier_advance_payments");?>
      </div>
    </div>
    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_expense_bills">
      <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 Expense Bills
            </h3>
          </div>
        </div>
      </div>
      <div class="m-portlet__body">
        <?php $this->view("modules/include_tables/table_expense_bills");?>
      </div>
    </div>
    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_expense_bill_payments">
      <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 Expense Bill Transactions
            </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_expense_bill_payments");?>
        <!--end: Datatable -->
      </div>
    </div>
    <div class="m-portlet m-portlet--mobile m-portlet--focus m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_subcontract_bills">
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
              Subcontract Bills
            </h3>
          </div>
        </div>
      </div>
      <div class="m-portlet__body">
        <?php $this->view("modules/include_tables/table_subcontract_bills");?>
      </div>
    </div>
    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_subcontract_payments">
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
              Subcontract Payments List
            </h3>
          </div>
        </div>
      </div>
      <div class="m-portlet__body">
        <?php $this->view("modules/include_tables/table_subcontract_payments");?>
      </div>
    </div>
    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_stock_transfer">
      <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
            </h3>
          </div>
        </div>
      </div>
      <div class="m-portlet__body">
        <?php $this->view("modules/include_tables/table_stock_transfers");?>
      </div>
    </div>
    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_stock_consumption">
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
              Stock Consumption
            </h3>
          </div>
        </div>
      </div>
      <div class="m-portlet__body">
        <?php $this->view("modules/include_tables/table_stock_consumptions");?>
      </div>
    </div>
    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_labour_wage_slips">
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
              Labour Wage Slips
            </h3>
          </div>
        </div>
      </div>
      <div class="m-portlet__body">
        <?php $this->view("modules/include_tables/table_labour_wage_slips");?>
      </div>
    </div>
    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_labour_wage_payments">
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
              Labour Payments
            </h3>
          </div>
        </div>
      </div>
      <div class="m-portlet__body">
        <?php $this->view("modules/include_tables/table_labour_wage_transaction");?>
      </div>
    </div>
    <?php if($this->config->item('app_module_tools_management')==1){?>
      <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_tool_transfer">
        <div class="m-portlet__head">
          <div class="m-portlet__head-caption">
            <div class="m-portlet__head-title">
              <h3 class="m-portlet__head-text">
                Tool Transfer
              </h3>
            </div>
          </div>
        </div>
        <div class="m-portlet__body">
          <?php $this->view("modules/include_tables/table_tool_transfer");?>
        </div>
      </div>
      <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_tool_rent">
        <div class="m-portlet__head">
          <div class="m-portlet__head-caption">
            <div class="m-portlet__head-title">
              <h3 class="m-portlet__head-text">
                Tool Rent
              </h3>
            </div>
          </div>
        </div>
        <div class="m-portlet__body">
          <?php $this->view("modules/include_tables/table_tool_rent");?>
        </div>
      </div>
      <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_tool_payments">
      <div class="m-portlet__head">
      <div class="m-portlet__head-caption">
      <div class="m-portlet__head-title">
      <h3 class="m-portlet__head-text">
      Tool Payments
    </h3>
  </div>
</div>
</div>
<div class="m-portlet__body">
<?php  $this->view("modules/include_tables/table_tool_payments_transactions");?>
</div>
</div>
<?php } ?>
<?php if($this->config->item('app_module_travel_allowance')==1){ ?>
  <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_travel_allowance">
    <div class="m-portlet__head">
      <div class="m-portlet__head-caption">
        <div class="m-portlet__head-title">
          <h3 class="m-portlet__head-text">
            Travel Allowances
          </h3>
        </div>
      </div>
    </div>
    <div class="m-portlet__body">
      <?php $this->view("modules/include_tables/table_travel_allowance");?>
    </div>
  </div>
<?php } ?>
<?php if($this->config->item('app_module_hr')==1){ ?>
  <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_salary_slips">
    <div class="m-portlet__head">
      <div class="m-portlet__head-caption">
        <div class="m-portlet__head-title">
          <h3 class="m-portlet__head-text">
            Salary Slips
          </h3>
        </div>
      </div>
    </div>
    <div class="m-portlet__body">
      <?php $this->view("modules/include_tables/table_salary_slips");?>
    </div>
  </div>
  <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_employee_payments">
    <div class="m-portlet__head">
      <div class="m-portlet__head-caption">
        <div class="m-portlet__head-title">
          <h3 class="m-portlet__head-text">
            Employee Payments (Salary Slips & Advances)
          </h3>
        </div>
      </div>
    </div>
    <div class="m-portlet__body">
      <?php $this->view("modules/include_tables/table_employee_payments");?>
    </div>
  </div>
<?php } ?>
<?php if($this->config->item('app_module_vehicle')==1){ ?>
<div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_vehicle_work_slips">
  <div class="m-portlet__head">
    <div class="m-portlet__head-caption">
      <div class="m-portlet__head-title">
        <h3 class="m-portlet__head-text">
          Vehicle Work Slip
        </h3>
      </div>
    </div>
  </div>
  <div class="m-portlet__body">
    <?php $this->view("modules/include_tables/table_vehicle_work_slips");?>
  </div>
</div>
<div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_vehicle_work_slip_payments">
  <div class="m-portlet__head">
    <div class="m-portlet__head-caption">
      <div class="m-portlet__head-title">
        <h3 class="m-portlet__head-text">
          Vehicle Work Slip Payments
        </h3>
      </div>
    </div>
  </div>
  <div class="m-portlet__body">
    <?php $this->view("modules/include_tables/table_vehicle_work_slip_transaction");?>
  </div>
</div>
<?php } ?>
<?php if($this->config->item('app_module_user_payments')==1){?>
  <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_user_payment_receipts">
    <div class="m-portlet__head">
      <div class="m-portlet__head-caption">
        <div class="m-portlet__head-title">
          <h3 class="m-portlet__head-text">
            User Payment Receipts
          </h3>
        </div>
      </div>
    </div>
    <div class="m-portlet__body">
      <?php $this->view("modules/include_tables/table_user_payment_receipts");?>
    </div>
  </div>
  <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_user_payment_returns">
    <div class="m-portlet__head">
      <div class="m-portlet__head-caption">
        <div class="m-portlet__head-title">
          <h3 class="m-portlet__head-text">
            User Payment Returns
          </h3>
        </div>
      </div>
    </div>
    <div class="m-portlet__body">
      <?php $this->view("modules/include_tables/table_user_payment_returns");?>
    </div>
  </div>
  <?php } ?>

    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_loans">
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
              Loans
            </h3>
          </div>
        </div>
      </div>
      <div class="m-portlet__body">
        <?php $this->view("modules/include_tables/table_loans");?>
      </div>
    </div>
    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_loan_transactions">
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
              Loan Payments
            </h3>
          </div>
        </div>
      </div>
      <div class="m-portlet__body">
        <?php $this->view("modules/include_tables/table_loan_transaction");?>
      </div>
    </div>
    <div class="m-portlet m-portlet--mobile m-portlet--info m-portlet--head-solid-bg m-portlet--bordered m-portlet--rounded" id="div_income_receipts">
      <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
          <div class="m-portlet__head-title">
            <h3 class="m-portlet__head-text">
              Other Income Receipts
            </h3>
          </div>
        </div>
      </div>
      <div class="m-portlet__body">
        <?php $this->view("modules/include_tables/table_income_receipts");?>
      </div>
    </div>
</div>
<?php if($this->config->item('Mobile_App_enable_data_entry_approval')==1){?>
  <div class="modal fade"  tabindex="-1" id="data_entry_approve_modal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog " role="document" >
      <form autocomplete="off" method="post" data-modal-id="data_entry_approve_modal" id="form_data_entry_approve" action="<?php echo base_url().'user/data_entry_approval'?>" class="form-horizontal">
        <div class="modal-content">
          <div class="alert alert-info" 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/>
            <div class="alert m-alert--default" role="alert" style="margin-bottom: 10px">
              <div class="form-group m-form__group" >
                <label for="user_name" style="color: black">Approval Status</label>
                <div class="m-radio-inline" style="padding-top: 10px;">
                  <label class="m-radio m-radio--solid m-radio--state-success">
                    <input required type="radio" class="form_fields_radio"  name="data_entry_approval" value="1"> Approved
                    <span></span>
                  </label>
                  <label class="m-radio m-radio--solid m-radio--state-danger">
                    <input type="radio" class="form_fields_radio" name="data_entry_approval"  value="2"> Rejected
                    <span></span>
                  </label>
                </div>
                <span class="m-form__help"></span>
              </div>
            </div>
            <p>
              <button class="btn btn-danger form_submit_btn" type="submit" name="submit">Confirm & Proceed</button>
              <button type="button" class="btn btn-primary modal-dismiss" data-dismiss="modal">Cancel</button>
            </p>
            <input type="hidden" name="data_id" id="data_id_appoval">
            <input type="hidden" name="data_type" id="data_type_appoval">
          </div>
        </div>
      </form>
    </div>
  </div>
<?php } ?>
<?php $this->view("modules/include_modals/modal_bills");?>
<?php $this->view("modules/include_modals/modal_expense_head_add");?>
<?php $this->view("modules/include_modals/modal_transaction_delete");?>
</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>
$("#user_data_entry_menu").addClass('m-menu__item--active m-menu__item--open');
$("#m_aside_left_minimize_toggle").addClass("m-brand__toggler--active");
$("#body").addClass("m-brand--minimize m-aside-left--minimize");

$("#table_filter_work").select2({
  placeholder: "Select Project"
})
$("#table_filter_user").select2({
  placeholder: "Select User"
})
$("#table_filter_account").select2({
  placeholder: "Select Account"
})
$("#table_filter_approval_status").select2({
  placeholder: "Select Approval Status"
})
$("#table_filter_start_date,#table_filter_end_date").datepicker( {
  todayHighlight:!0, orientation:"bottom left", templates: {
    leftArrow: '<i class="la la-angle-left"></i>', rightArrow: '<i class="la la-angle-right"></i>'
  }
})

$('body').on('change', '#table_filter_work', function() {
  var work = $("#table_filter_work").val();
  if(work!='all'){
    $("#div_account_transfer").hide();
    $("#div_supplier_payments").hide();
    $("#div_labour_wage_payments").hide();
    $("#div_travel_allowance").hide();
    $("#div_user_payment_receipts").hide();
    $("#div_user_payment_returns").hide();
  }else{
    $("#div_supplier_payments").show();
    $("#div_account_transfer").show();
    $("#div_labour_wage_payments").show();
    $("#div_travel_allowance").show();
    $("#div_user_payment_receipts").show();
    $("#div_user_payment_returns").show();
  }
})
$('body').on('change', '#table_filter_account', function() {
  var account = $("#table_filter_account").val();
  if(account!='all'){
    $("#div_client_invoice").hide();
    $("#div_purchase_order").hide();
    $("#div_purchase_bills").hide();
    $("#div_expense_bills").hide();
    $("#div_subcontract_bills").hide();
    $("#div_stock_transfer").hide();
    $("#div_stock_consumption").hide();
    $("#div_labour_wage_slips").hide();
    $("#div_tool_transfer").hide();
    $("#div_tool_rent").hide();
    $("#div_vehicle_work_slips").hide();
    $("#div_loans").hide();
  }else{
    $("#div_client_invoice").show();
    $("#div_purchase_order").show();
    $("#div_purchase_bills").show();
    $("#div_expense_bills").show();
    $("#div_subcontract_bills").show();
    $("#div_stock_transfer").show();
    $("#div_stock_consumption").show();
    $("#div_labour_wage_slips").show();
    $("#div_tool_transfer").show();
    $("#div_tool_rent").show();
    $("#div_vehicle_work_slips").show();
    $("#div_loans").show();
  }
})

$('body').on('click', '#btn_data_entry_approval', function() {
  var no = $(this).closest('tr').children('td');
  $('#data_id_appoval').val($(this).data('id'));
  $('#data_type_appoval').val($(this).data('type'));
  var approval_status = $(this).data('approval-status');
  if(approval_status!=0){
    $('input[type=radio][name=data_entry_approval][value='+approval_status+']').prop('checked',true);
  }else{
    $('.form_fields_radio').prop('checked',false);
  }

})
</script>
<?php $this->view("modules/include_scripts/bill_scripts");?>
<?php $this->view("modules/include_scripts/transaction_scripts");?>
<?php $this->view("modules/include_scripts/expense_bill_scripts");?>
<?php $this->view("modules/include_scripts/account_transfer_scripts");?>
<?php $this->view("modules/include_scripts/client_payments_scripts");?>
<?php if($this->config->item('Client_Payment_client_payment_invoice')==1) { ?>
  <?php $this->view("modules/include_scripts/invoices_scripts");?>
<?php } ?>
<?php $this->view("modules/include_scripts/purchase_bill_view_scripts");?>
<?php $this->view("modules/include_scripts/purchase_bill_payments_view_scripts");?>
<?php $this->view("modules/include_scripts/supplier_advance_payment_view_scripts");?>
<?php if($this->config->item('app_module_purchase_order')==1){ ?>
  <?php $this->view("modules/include_scripts/purchase_order_view_scripts");?>
  <?php $this->view("modules/include_scripts/purchase_order_payments_view_scripts");?>
<?php } ?>
<?php $this->view("modules/include_scripts/subcontract_payments_view_scripts");?>
<?php $this->view("modules/include_scripts/subcontract_bill_scripts");?>
<?php $this->view("modules/include_scripts/stock_transfer_view_scripts");?>
<?php $this->view("modules/include_scripts/stock_consumption_view_scripts");?>
<?php $this->view("modules/include_scripts/labour_wage_scripts");?>
<?php if($this->config->item('app_module_tools_management')==1){?>
  <?php $this->view("modules/include_scripts/tool_transfer_script");?>
  <?php $this->view("modules/include_scripts/tool_rent_script");?>
<?php } ?>
<?php $this->view("modules/include_scripts/tool_consumption_payment_script");?>
<?php if($this->config->item('app_module_travel_allowance')==1){ ?>
  <?php $this->view("modules/include_scripts/travel_allowance_scripts");?>
<?php } ?>
<?php if($this->config->item('app_module_hr')==1){ ?>
  <?php $this->view("modules/include_scripts/salary_slips_scripts");?>
  <?php $this->view("modules/include_scripts/employee_payments_scripts");?>
<?php } ?>
<?php if($this->config->item('app_module_vehicle')==1){ ?>
    <?php $this->view("modules/include_scripts/vehicle_work_scripts");?>
  <?php } ?>
<?php if($this->config->item('app_module_user_payments')==1){?>
  <?php $this->view("modules/include_scripts/user_payments_scripts");?>
  <?php } ?>
  <?php $this->view("modules/include_scripts/loans_scripts");?>
    <?php $this->view("modules/include_scripts/income_receipts_scripts");?>
<script>
$(".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: {
      received_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,
    beforeSend: function(){
      // Handle the beforeSend event
      // Block UI
      mApp.blockPage({
        overlayColor: "#000000",
        type: "loader",
        state: "success",
        message: "Please wait..."
      });

      mApp.block(".modal-content", {
        overlayColor: "#000000",
        type: "loader",
        state: "success",
        message: "Please wait..."
      });
    },

    success: function (e, t, r, s) {
      // UnBlock UI

      var modal_id = l.attr('data-modal-id');
      var form_type = l.attr('data-form-type');
      $("#" + form_id + "_msg").addClass("m--hide");


      var obj = $.parseJSON(e);
      if (obj.status == 1) {
        a.removeClass("m-loader m-loader--right m-loader--light").attr("disabled", !1);
        $("#"+modal_id).modal('toggle');
        $("."+form_id+"_fields").val('');
        $("."+form_id+"_select").val('').trigger("change");
        $(".custom-file-label").text('');

        client_payments_view_table.ajax.reload();
        acc_transfer_view_table.ajax.reload();
        <?php if($this->config->item('Client_Payment_client_payment_invoice')==1) { ?>
          invoices_view_table.ajax.reload();
          <?php } ?>
          expense_bills_view_table.ajax.reload();
          expense_bill_payments_view_table.ajax.reload();
          purchase_bills_view_table.ajax.reload();
          purchase_bill_transaction_view_table.ajax.reload();
          supplier_advance_view_table.ajax.reload();
          <?php if($this->config->item('app_module_purchase_order')==1){ ?>
            purchase_order_view_table.ajax.reload();
            purchase_order_view_table.ajax.reload();
            <?php } ?>
            subcontract_payments_view_table.ajax.reload();
            subcontract_bills_view_table.ajax.reload();
            stock_transfer_view_table.ajax.reload();
            stock_consumption_view_table.ajax.reload();
            labour_wage_view_table.ajax.reload();
            labour_wage_transaction_view_table.ajax.reload();
            <?php if($this->config->item('app_module_tools_management')==1){?>
              tool_transfer_view_table.ajax.reload();
              tool_rent_view_table.ajax.reload();
              tool_payment_transanctions_view_table.ajax.reload();
              <?php } ?>
              // tool_payment_transanctions_view_table.ajax.reload();
              <?php if($this->config->item('app_module_travel_allowance')==1){ ?>
                ta_view_table.ajax.reload();
                <?php } ?>
                <?php if($this->config->item('app_module_hr')==1){ ?>
                  salary_slip_view_table.ajax.reload();
                  employee_payments_view_table.ajax.reload();
                  <?php } ?>
                  <?php if($this->config->item('app_module_vehicle')==1){ ?>
                  vehicle_work_slip_view_table.ajax.reload();
                  vehicle_work_slip_transaction_view_table.ajax.reload();
                  <?php } ?>
                  <?php if($this->config->item('app_module_user_payments')==1){?>
                    user_payment_receipts_view_table.ajax.reload();
                    user_payment_returns_view_table.ajax.reload();
                    <?php } ?>
                    loan_payments_view_table.ajax.reload();
                    loans_view_table.ajax.reload();
                    income_receipts_view_table.ajax.reload();
                } 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");
              },ajaxComplete : function(){
                mApp.unblockPage();
                mApp.unblock(".modal-content");
              },complete  : function(){
                mApp.unblockPage();
                mApp.unblock(".modal-content");
              },
            })
          )
        });
        </script>
