<?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">
          <strong>Reports</strong>
        </h3>
      </div>
    </div>
  </div>
  <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">
            <div class="m-card-profile">
              <div class="m-card-profile__title m--hide">
                Activity Reports
              </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/misc/report.png" alt=""/>
                </div>
              </div>
              <div class="m-card-profile__details">
                <span class="m-card-profile__name">
                  Activity Reports
                </span>
              </div>
              <br/>
            </div>
            <ul class="m-nav m-nav--hover-bg m-portlet-fit--sides" id="m_nav" role="tablist">
              <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>
              <?php if($this->session->userdata('user_role')!='supervisor' && $this->session->userdata('user_role')!='purchase_manager'){?>
                <li class="m-nav__item profile_nav" id="nav_client_payments" data-nav="client_payments" data-table-name='client_payments_view_table'>
                  <a href="javascript:;" class="m-nav__link">
                    <i class="m-nav__link-icon fa fa-suitcase"></i>
                    <span class="m-nav__link-title">
                      <span class="m-nav__link-wrap">
                        <span class="m-nav__link-text">
                          Client Payments
                        </span>
                      </span>
                    </span>
                  </a>
                </li>
              <?php } ?>
              <?php if($this->config->item('app_module_user_payments')==1 && $this->session->userdata('user_role')!='purchase_manager'){?>
                <li class="m-nav__item profile_nav" id="nav_user_payments" data-nav="user_payments" data-table-name='user_payment_receipts_view_table,user_payment_returns_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-text">
                      User Payments
                    </span>
                  </a>
                </li>
              <?php } ?>
              <li class="m-nav__item m-nav__item--active">
                <a class="m-nav__link" role="tab" id="m_nav_link_1" data-toggle="collapse" href="#m_nav_sub_1" aria-expanded=" false">
                  <i class="m-nav__link-icon fa fa-shopping-cart"></i>
                  <span class="m-nav__link-title" style="width: 100%">
                    <span class="m-nav__link-wrap">
                      <span class="m-nav__link-text">Purchases</span>
                    </span>
                  </span>
                  <span class="m-nav__link-arrow"></span>
                </a>
                <ul class="m-nav__sub collapse show" id="m_nav_sub_1" role="tabpanel" aria-labelledby="m_nav_link_1" data-parent="#m_nav">
                  <?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">
                              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_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_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>
                </ul>
              </li>
              <?php if($this->session->userdata('user_role')!='purchase_manager'){?>
                <li class="m-nav__item m-nav__item--active">
                  <a class="m-nav__link" role="tab" id="m_nav_link_5" data-toggle="collapse" href="#m_nav_sub_5" aria-expanded=" false">
                    <i class="m-nav__link-icon fa fa-users"></i>
                    <span class="m-nav__link-title" style="width: 100%">
                      <span class="m-nav__link-wrap">
                        <span class="m-nav__link-text">Labour Wages</span>
                      </span>
                    </span>
                    <span class="m-nav__link-arrow"></span>
                  </a>
                  <ul class="m-nav__sub collapse show" id="m_nav_link_5" role="tabpanel" aria-labelledby="m_nav_sub_5" data-parent="#m_nav">
                    <li class="m-nav__item profile_nav" id="nav_labour_wages" data-nav="labour_wages" data-table-name='labour_wage_view_table'>
                      <a href="javascript:;" class="m-nav__link">
                        <i class="m-nav__link-icon fa fa-users"></i>
                        <span class="m-nav__link-title">
                          <span class="m-nav__link-wrap">
                            <span class="m-nav__link-text">
                              Labour Wage Slips
                            </span>
                          </span>
                        </span>
                      </a>
                    </li>
                    <li class="m-nav__item profile_nav" id="nav_labour_payments" data-nav="labour_payments" data-table-name='labour_wage_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">
                              Labour Wage Payments
                            </span>
                          </span>
                        </span>
                      </a>
                    </li>
                  </ul>
                <?php } ?>
                <?php if($this->session->userdata('user_role')!='purchase_manager'){?>
                  <li class="m-nav__item profile_nav" id="nav_expenses" data-nav="expenses" data-table-name='expense_bills_view_table'>
                    <a href="javascript:;" class="m-nav__link">
                      <i class="m-nav__link-icon fa fa-clipboard-list"></i>
                      <span class="m-nav__link-title">
                        <span class="m-nav__link-wrap">
                          <span class="m-nav__link-text">
                            Expense Bills
                          </span>
                        </span>
                      </span>
                    </a>
                  </li>
                <?php } ?>
                <?php if($this->session->userdata('user_role')!='purchase_manager'){?>
                  <li class="m-nav__item m-nav__item--active">
                    <a class="m-nav__link" role="tab" id="m_nav_link_3" data-toggle="collapse" href="#m_nav_sub_3" aria-expanded=" false">
                      <i class="m-nav__link-icon fa fa-sitemap"></i>
                      <span class="m-nav__link-title" style="width: 100%">
                        <span class="m-nav__link-wrap">
                          <span class="m-nav__link-text">Subcontracts</span>
                        </span>
                      </span>
                      <span class="m-nav__link-arrow"></span>
                    </a>
                    <ul class="m-nav__sub collapse show" id="m_nav_sub_3" role="tabpanel" aria-labelledby="m_nav_link_3" data-parent="#m_nav">
                      <li class="m-nav__item profile_nav" id="nav_sub_contracts" data-nav="sub_contracts" data-table-name='subcontracts_view_table'>
                        <a href="javascript:;" class="m-nav__link">
                          <i class="m-nav__link-icon fa fa-sitemap"></i>
                          <span class="m-nav__link-title">
                            <span class="m-nav__link-wrap">
                              <span class="m-nav__link-text">
                                Subcontract Works
                              </span>
                            </span>
                          </span>
                        </a>
                      </li>
                      <li class="m-nav__item profile_nav" id="nav_sub_contract_payments" data-nav="sub_contract_payments" data-table-name='subcontract_payments_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">
                                Subcontract Payments
                              </span>
                            </span>
                          </span>
                        </a>
                      </li>
                    </ul>
                  </li>
                <?php } ?>
              </ul>

              <br/>
            </div>
          </div>
        </div>
        <div class="col-xl-9 col-lg-8" >
          <div class="m-portlet">
            <form autocomplete="off" id="payment_details_form" method="post"  enctype="multipart/form-data" class="m-form m-form--fit m-form--state m-form--label-align-right ">
              <div class="m-portlet__body">
                <div class="row">
                  <div class="col-md-5" >
                    <div class="form-group m-form__group">
                      <label class="col-form-label">
                        Date :
                      </label>
                      <input style="border: none" id="table_filter_date_range"  type="text" class="form-control table_filter  m-input--solid m-input " >
                    </div>
                  </div>
                  <div class="col-md-4">
                    <div class="form-group m-form__group">
                      <label class="col-form-label">
                        Work
                      </label>
                      <select style="width: 100%" class="form-control m-select2 table_filter" id="table_filter_work"  name="table_filter_work" data-placeholder="Select Work">
                        <option selected 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>
                    <span class="m-form__help"></span>
                  </div>
                </div>
                <div class="col-md-3">
                  <a href="javascript:;" style="margin-top: 32px;"  id="print_all"   class="btn btn-primary m-btn m-btn--custom m-btn--icon m-btn--air m-btn--pill">
                    <span>
                      <i class="la la-print"></i>
                      <span>
                        Print All
                      </span>
                    </span>
                  </a>
                </div>
              </div>
            </div>
          </form>
        </div>


        <div id="div_overview" class="m-portlet m-portlet--metal m-portlet--head-solid-bg m-portlet--bordered profile_nav_div">
          <?php if($this->session->userdata('user_role')!='purchase_manager'){?>
            <div class="m-portlet" style="margin: 20px;box-shadow: 0 1px 15px 1px rgba(69, 65, 78, 0.55);background-color: #fff;">
              <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-2 -->
                    <?php if($this->session->userdata('user_role')!='supervisor'){?>
                      <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">
                                Received From Client
                              </h3>
                            </div>
                            <div class="col m--align-right">
                              <span class="m-widget1__number m--font-accent">
                                <label class="total_received_from_client_info"></label>
                              </span>
                            </div>
                          </div>
                        </div>
                      </div>
                    <?php } ?>
                    <!--begin:: Widgets/Stats2-2 -->
                  </div>
                  <div class="col-md-12 col-lg-12 col-xl-6">
                    <!--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 Expense Payments
                            </h3>
                          </div>
                          <div class="col m--align-right">
                            <span class="m-widget1__number m--font-success">
                              <label class="total_expense_payments_info"></label>
                            </span>
                          </div>
                        </div>
                      </div>
                    </div>
                    <!--begin:: Widgets/Stats2-3 -->
                  </div>
                </div>
              </div>
            </div>
          <?php } ?>
          <div  class="m-portlet" style="margin: 20px;box-shadow: 0 1px 15px 1px rgba(69, 65, 78, 0.55);background-color: #fff;">
            <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-3">
                  <!--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 Purchase Payments
                          </h3>
                        </span>
                      </div>
                      <div class="col m--align-right">
                        <span class="m-widget1__number m--font-success">
                          <label class="total_purchase_payment_info"></label>
                        </span><br/>
                      </div>
                    </div>
                  </div>

                </div>
                <!--begin:: Widgets/Stats2-3 -->
              </div>
              <?php if($this->session->userdata('user_role')!='purchase_manager'){?>
                <div class="col-md-12 col-lg-12 col-xl-3">
                  <!--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 Subcontract Payments
                          </h3>
                        </div>
                        <div class="col m--align-right">
                          <span class="m-widget1__number m--font-success">
                            <label class="total_subcontract_payment_info"></label>
                          </span>
                        </div>
                      </div>
                    </div>

                  </div>
                  <!--begin:: Widgets/Stats2-3 -->
                </div>
              <?php } ?>
              <?php if($this->session->userdata('user_role')!='purchase_manager'){?>
                <div class="col-md-12 col-lg-12 col-xl-3">
                  <!--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 Labour Wage Payments
                          </h3>
                        </div>
                        <div class="col m--align-right">
                          <span class="m-widget1__number m--font-success">
                            <label class="total_labour_wage_payments_info"></label>
                          </span>
                        </div>
                      </div>
                    </div>

                  </div>
                  <!--begin:: Widgets/Stats2-3 -->
                </div>
              <?php } ?>
              <div class="col-md-12 col-lg-12 col-xl-3">
                <!--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 Other Expense Payments
                        </h3>
                      </div>
                      <div class="col m--align-right">
                        <span class="m-widget1__number m--font-success">
                          <label class="total_other_expense_payments_info"></label>
                        </span>
                      </div>
                    </div>
                  </div>

                </div>
                <!--begin:: Widgets/Stats2-3 -->
              </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">
              Summary
            </h3>
            <table width="100%" class="table m-table nowrap table-header-fixed table-striped table-bordered table-hover table-header-fixed" id="table_summary">
              <thead>
                <tr class="">
                  <th>Heads</th>
                  <th>Amount</th>
                </tr>
              </thead>
              <tbody>
                <?php if($this->session->userdata('user_role')!='purchase_manager'){?>
                  <tr>
                    <td>Client Payment Received</td>
                    <strong><td class="total_received_from_client_info"></td></strong>
                  </tr>
                <?php }?>
                <tr>
                  <td>Total Purchase Bill Commissions Received</td>
                  <strong><td class="purchase_bill_commission_info"></td></strong>
                </tr>
                <tr>
                  <td></td>
                  <td></td>
                </tr>
                <tr>
                  <td>Total Purchase Bill Amount</td>
                  <strong><td class="total_purchases_bill_info"></td></strong>
                </tr>
                <?php if($this->config->item('app_module_purchase_order')==1){?>
                  <tr>
                    <td>Purchase Order Payments Made (Advances)</td>
                    <strong><td class="total_purchase_order_payments_info"></td></strong>
                  </tr>
                <?php } ?>
                <tr>
                  <td>Purchase Bill Payments Made</td>
                  <strong><td class="total_purchases_bill_payment_info"></td></strong>
                </tr>
                <?php if($this->config->item('app_module_purchase_order')==1){?>
                  <tr>
                    <td>Total Purchase Payments Made (Purchase Bill + Purchase Order)</td>
                    <strong><td class="total_purchase_payment_info"></td></strong>
                  </tr>
                <?php } ?>
                <tr>
                  <td>Pending Purchase Bill Payments</td>
                  <strong><td class="total_purchases_bill_pending_info"></td></strong>
                </tr>
                <tr>
                  <td></td>
                  <td></td>
                </tr>
                <?php if($this->config->item('app_module_stock_management')==1){?>
                  <tr>
                    <td>Total Stock Purchased Amount</td>
                    <strong><td class="total_purchases_bill_info"></td></strong>
                  </tr>
                  <tr>
                    <td>Total Stock Consumed Amount</td>
                    <strong><td class="total_stock_consumed_info"></td></strong>
                  </tr>
                  <tr>
                    <td>Total Stock Balance Amount</td>
                    <strong><td class="total_stock_balance_info"></td></strong>
                  </tr>
                  <tr>
                    <td></td>
                    <td></td>
                  </tr>
                <?php } ?>
                <?php if($this->session->userdata('user_role')!='purchase_manager'){?>
                  <tr>
                    <td>Total Subcontract Payments</td>
                    <strong><td class="total_subcontract_payment_info"></td></strong>
                  </tr>
                <?php } ?>
                <?php if($this->session->userdata('user_role')!='purchase_manager'){?>
                  <tr>
                    <td>Total Labour Wages</td>
                    <strong><td class="total_labour_wage_slips_info"></td></strong>
                  </tr>
                  <tr>
                    <td>Total Labour Wage Payments</td>
                    <strong><td class="total_labour_wage_payments_info"></td></strong>
                  </tr>
                <?php }?>
                <?php if($this->session->userdata('user_role')!='purchase_manager'){?>
                  <tr>
                    <td>Total Tool Purchase Payments</td>
                    <strong><td class="total_tool_purchase_payments_info"></td></strong>
                  </tr>
                  <tr>
                    <td>Total Other Expense Payments</td>
                    <strong><td class="total_other_expense_payments_info"></td></strong>
                  </tr>
                <?php } ?>
                <tr>
                  <td></td>
                  <td></td>
                </tr>
                <?php if($this->session->userdata('user_role')!='purchase_manager'){?>
                  <tr>
                    <td>Total Expense Payments</td>
                    <strong><td class="total_expense_payments_info"></td></strong>
                  </tr>
                <?php } ?>
              </tbody>
            </table>
          </div>
        </div>
      </div>
      <div id="div_client_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">
                  Client Payments Received
                </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_client_payments");?>
          </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 Bills
                </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");?>

          </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_user_payments" class="profile_nav_div">
        <div class="m-portlet m-portlet--metal m-portlet--head-solid-bg m-portlet--bordered ">
          <div class="m-portlet__head">
            <div class="m-portlet__head-caption">
              <div class="m-portlet__head-title">
                <span class="m-portlet__head-icon">
                  <i class="fa fa-briefcase"></i>
                </span>
                <h3 class="m-portlet__head-text">
                  User Payment Receipts
                </h3>
              </div>
            </div>
            <div class="m-portlet__head-tools" style="display: none">

            </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--metal m-portlet--head-solid-bg m-portlet--bordered ">
          <div class="m-portlet__head">
            <div class="m-portlet__head-caption">
              <div class="m-portlet__head-title">
                <span class="m-portlet__head-icon">
                  <i class="fa fa-briefcase"></i>
                </span>
                <h3 class="m-portlet__head-text">
                  User Payment Returns
                </h3>
              </div>
            </div>
            <div class="m-portlet__head-tools" style="display: none">

            </div>
          </div>
          <div class="m-portlet__body">
            <?php $this->view("modules/include_tables/table_user_payment_returns");?>
          </div>
        </div>
      </div>
      <div id="div_labour_wages" 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 Labour Daily Wage Slips
                </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_labour_wage_slips");?>
            <!--end: Datatable -->

          </div>
        </div>

      </div>
      <div id="div_labour_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">
                  List of Labour Wage Payments
                </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_labour_wage_transaction");?>
            <!--end: Datatable -->

          </div>
        </div>

      </div>
      <div id="div_expenses" 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">
                  Other Expense List
                </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_bills");?>

          </div>
        </div>
      </div>
      <div id="div_sub_contracts" 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 Subcontracts
                </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_subcontracts");?>
            <!--end: Datatable -->
          </div>
        </div>
      </div>
      <div id="div_sub_contract_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">
                  Subcontract Payments List
                </h3>
              </div>
            </div>
          </div>
          <div class="m-portlet__body">

            <?php $this->view("modules/include_tables/table_subcontract_payments");?>

          </div>
        </div>

      </div>
    </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>
$("#table_filter_work").select2({
  placeholder: "Select  Work",
  templateResult: format_project_dropdown
})
$("#m_aside_left_minimize_toggle").addClass("m-brand__toggler--active");
$("#body").addClass("m-brand--minimize m-aside-left--minimize");

$("#report_menu").addClass('m-menu__item--active m-menu__item--open');
$("#report_menu_1").addClass('m-menu__item--active');
</script>
<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>
function GetSearchDate(){
  return $('#table_filter_date_range').val();
}
function GetSearchWork(){
  return $('#table_filter_work').val();
}
</script>
<!-- Client Payment Scripts -->
<?php $this->view("modules/include_scripts/client_payments_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");?>

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

<!-- Subcontract Payments Scripts -->
<?php $this->view("modules/include_scripts/subcontract_payments_view_scripts");?>

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

<!-- Labour Wage Scripts -->
<?php $this->view("modules/include_scripts/labour_wage_scripts");?>

<!-- User Payment  Scripts -->
<?php $this->view("modules/include_scripts/user_payments_scripts");?>

<script>

// Date Range Picker
var start = moment();
var end = moment();

function cb(start, end) {
  $('#table_filter_date_range').val(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));

  client_payments_view_table.ajax.reload();
  expense_bills_view_table.ajax.reload();
  labour_wage_transaction_view_table.ajax.reload();
  labour_wage_view_table.ajax.reload();
  subcontract_payments_view_table.ajax.reload();
  subcontracts_view_table.ajax.reload();
  user_payment_receipts_view_table.ajax.reload();
  user_payment_returns_view_table.ajax.reload();

  materials_purchased_view_table.ajax.reload();
  purchase_bill_transaction_view_table.ajax.reload();
  purchase_bills_view_table.ajax.reload();
  purchase_order_transaction_view_table.ajax.reload();
  purchase_order_view_table.ajax.reload();


  select_report_summary();
}
$(".table_filter").on("change", function() {

  client_payments_view_table.ajax.reload();
  expense_bills_view_table.ajax.reload();
  labour_wage_transaction_view_table.ajax.reload();
  labour_wage_view_table.ajax.reload();
  subcontract_payments_view_table.ajax.reload();
  subcontracts_view_table.ajax.reload();
  user_payment_receipts_view_table.ajax.reload();

  materials_purchased_view_table.ajax.reload();
  purchase_bill_transaction_view_table.ajax.reload();
  purchase_bills_view_table.ajax.reload();
  purchase_order_transaction_view_table.ajax.reload();
  purchase_order_view_table.ajax.reload();

  select_report_summary();
});
$('.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();
    });
  }
});
$('#table_filter_date_range').daterangepicker({
  buttonClasses: "m-btn btn",
  applyClass: "btn-primary",
  cancelClass: "btn-secondary",
  startDate: start,
  endDate: end,
  locale: {
    format: 'MMMM D, YYYY'
  },
  ranges: {
    'Today': [moment(), moment()],
    'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
    'Last 7 Days': [moment().subtract(6, 'days'), moment()],
    'Last 30 Days': [moment().subtract(29, 'days'), moment()],
    'This Month': [moment().startOf('month'), moment().endOf('month')],
    'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
    'All time': [moment('1970-01-01'), moment().add(9999, 'days')],
  }
}, cb);
cb(start, end);

$(".hidden").hide();
$($.fn.dataTable.tables(true)).DataTable()
.columns.adjust();


function select_report_summary() {
  $.post("<?php echo base_url().'reports/select_report_summary'?>",{
    date:GetSearchDate(),work:GetSearchWork()
  },function(data){
    var obj= $.parseJSON(data);
    if(obj.status==1) {
      $("#client_total_received").html(obj.total_client_payments_received);
      $("#client_total_received_1").html(obj.total_client_payments_received);
      $("#total_purchases").html(obj.total_purchase_payment);
      $("#total_purchases_1").html(obj.total_purchase_payment);
      $("#subcontract_payments").html(obj.total_subcontract_payment);
      $("#subcontract_payments_1").html(obj.total_subcontract_payment);
      $("#other_payments").html(obj.total_other_expense);
      $("#other_payments_1").html(obj.total_other_expense);
      $("#total_expenses").html(obj.total_expense_amount)
      $("#total_expenses_1").html(obj.total_expense_amount)
      $("#total_income_1").html(obj.total_income)
      $("#total_balance_1").html(obj.total_income)

      $(".total_received_from_client_info").html(obj.total_client_payments_received);
      $(".purchase_bill_commission_info").html(obj.total_purchase_bill_commission);
      $(".total_purchases_bill_info").html(obj.total_purchase_bill_amount);
      $(".total_purchase_order_payments_info").html(obj.total_purchase_order_payment);
      $(".total_purchases_bill_payment_info").html(obj.total_purchase_bill_payment);
      $(".total_purchase_payment_info").html(obj.total_purchase_payment);
      $(".total_purchases_bill_pending_info").html(obj.total_purchase_bill_balance_amount);
      $(".total_subcontract_payment_info").html(obj.total_subcontract_payment);
      $(".total_labour_wage_slips_info").html(obj.total_labour_wages);
      $(".total_labour_wage_payments_info").html(obj.total_labour_wage_payments);
      $(".total_tool_purchase_payments_info").html(obj.total_purchase_payments);
      $(".total_other_expense_payments_info").html(obj.total_other_expense);
      $(".total_expense_payments_info").html(obj.total_expense_amount);

      $(".total_labours_worked_info").html(obj.total_labours_worked);
      $(".total_labours_days_info").html(obj.total_labour_days);
      $(".total_labours_wage_info").html(obj.total_labour_wages);


    }

  })
}
</script>
<script>
  $(function(){
    $('#print_all,#print_all_1').click(function(e){
      var date =  $('#table_filter_date_range').val();
      var work =  $('#table_filter_work').val();
      var date_array = date.split(' - ');
      var start_date = date_array[0].replace(',','');
      start_date = start_date.replace(' ','-');
      start_date = start_date.replace(' ','-');
      var end_date = date_array[1].replace(',','');
      end_date = end_date.replace(' ','-');
      end_date = end_date.replace(' ','-');
      window.open('<?php echo base_url().'reports/report_print/' ?>'+start_date+'/'+end_date+'/'+work,'newwindow','width=800,height=700'); return false

    });
  });
</script>
