@extends('layouts.app')
@section('title','Consolidate Statement')
@section('pages')
<style type="text/css">
    .breadcrumb-title {
      border-right: none;
    }
  .thbutton {
    width: 7% !important;
}
</style>
<link rel="stylesheet" type="text/css" href="{{ asset('admin/plugins/datepicker/less/datepicker.less') }}">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/12.1.10/css/intlTelInput.css">
<link href="{{ asset('admin/css/print.css')}}" rel="stylesheet" />

    <!--breadcrumb-->
<div class="page-breadcrumb row align-items-center justify-content-between mb-3 px-3 px-md-0">
    <div class="breadcrumb-title col-md-6">Consolidate Statement</div>
    <div class="col-md-6">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb justify-content-md-end mb-0">
                <li class="breadcrumb-item">
                    <i
                        class="bi bi-info-circle-fill text-info show-help-support"
                        data-id="40"
                        data-bs-toggle="modal"
                        data-bs-target="#commonModal"
                    ></i>
                </li>
                <li class="breadcrumb-item" aria-current="page">Accounts</li>
                <li class="breadcrumb-item active" aria-current="page">
                    <i class="bi bi-dot"></i> Consolidate Statement
                </li>
                <div class="ms-auto">
                    <div class="btn-group">
                        <a href="{{ route('all-transactions.index') }}" class="btn btn-outline-secondary me-2"><i class="bx bx-arrow-back ms-0 me-1"></i>Back</a>
                    </div>
                </div>
            </ol>
        </nav>
    </div>
</div>
<!--end breadcrumb-->
  <div class="card style_table shadow-none radius-5 min-height">
    <div class="card-header py-3">
        @include('layouts.partials.nav-menu')
        <div class="row">
            <div class="col-2" style="width: 20%"></div>
            <div class="col-7" style="text-align: center">
                <p style="color: #0b5ed7; font-size: 18px; margin-bottom: -4px !important;"><b></b></p>
                <h5 style="text-decoration: underline" class="mt-3">
                    <b>Consolidate Statement</b>
                </h5>
            </div>
            <div class="col-2" style="text-align: right; width: 20%"></div>
        </div>

        <div>
            <table class="table table-borderless report-container">
                <tbody class="report-content">
                    <tr>
                        <td class="report-content-cell">
                            <div class="row">
                                <div class="col-12">
                                    <!-- 1st Table -->
                                    <table class="table table-bordered-print w-100 table-only-header-full-width mb-3 mt-3" id="quotation_products">
                                        <thead>
                                            <tr class="text-uppercase">
                                                 <tr> 
                                                    <td colspan="20" class="text-center"><h6 class="mt-2 mb-2">
                                                         Billing Statement From Date<span class="text-primary"> 01-10-2024</span>  | To Date  <span class="text-primary">01-10-2024 </span> </h6> 
                                                    </td> 
                                                </tr>
                                                <th style="text-align: left">SN</th>
                                                <th style="text-align: left">Date</th>
                                                <th style="text-align: left">INV NO</th>
                                                <th style="text-align: left">TYPE</th>
                                                <th style="text-align: left">Category</th>
                                                <th style="text-align: left">Patient</th>
                                                <th style="text-align: left">Ref. By</th>
                                                <th style="text-align: left">Particulars</th>
                                                <th style="text-align: left">Bill Amt</th>
                                                <th style="text-align: left">Advance</th>
                                                <th style="text-align: left">Cash</th>
                                                <th style="text-align: left">Bank</th>
                                                <th style="text-align: left">Online</th>
                                                <th style="text-align: left">Discount</th>
                                                <th style="text-align: left">Due</th>
                                                <th style="text-align: left">Billing By</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr class="border-1">
                                                <td style="text-align: left">1</td>
                                                <td style="text-align: left">01-10-2024</td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left">INVOICE</td>
                                                <td style="text-align: left">THE HOPE (CASH)</td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left"> <b> 1) ECG,RBS,BIOMETRY - </b> Rs.850.00</td>
                                                <td style="text-align: left">850.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">850.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">Prytma</td>
                                            </tr>
                                            <tr class="border-1">
                                                <td style="text-align: left">1</td>
                                                <td style="text-align: left">01-10-2024</td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left">INVOICE</td>
                                                <td style="text-align: left">THE HOPE (CASH)</td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left"> <b> 1) ECG,RBS,BIOMETRY - </b> Rs.850.00</td>
                                                <td style="text-align: left">850.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">850.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">Prytma</td>
                                            </tr>
                                            <tr class="border-1">
                                                <td style="text-align: left">1</td>
                                                <td style="text-align: left">01-10-2024</td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left">INVOICE</td>
                                                <td style="text-align: left">THE HOPE (CASH)</td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left"> <b> 1) ECG,RBS,BIOMETRY - </b> Rs.850.00</td>
                                                <td style="text-align: left">850.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">850.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">Prytma</td>
                                            </tr>
                                            <tr class="border-1">
                                                <td style="text-align: left">1</td>
                                                <td style="text-align: left">01-10-2024</td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left">INVOICE</td>
                                                <td style="text-align: left">THE HOPE (CASH)</td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left"> <b> 1) ECG,RBS,BIOMETRY - </b> Rs.850.00</td>
                                                <td style="text-align: left">850.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">850.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">Prytma</td>
                                            </tr>
                                            <tr class="border-1">
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left"> <b>Total</b> </td>
                                                <td style="text-align: left"> <b>2650</b> </td>
                                                <td style="text-align: left"> <b>0</b> </td>
                                                <td style="text-align: left"> <b>850</b> </td>
                                                <td style="text-align: left"> <b>0</b> </td>
                                                <td style="text-align: left"> <b>100</b> </td>
                                                <td style="text-align: left"> <b>1700</b> </td>
                                                <td style="text-align: left"> <b>0</b> </td>
                                                <td style="text-align: left"> <b></b> </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                    <!-- 2nd Table  -->
                                    <table class="table table-bordered-print w-100 table-only-header-full-width mt-2 mb-2" id="quotation_products">
                                        <thead>
                                            <tr class="text-uppercase">
                                                <tr> 
                                                    <td colspan="12" class="text-center"><h6 class="mt-2 mb-2">
                                                        Old Dues Collection  </h6> 
                                                    </td> 
                                                </tr>
                                                <th style="text-align: left">SL No</th>
                                                <th style="text-align: left">Receipt Date</th>
                                                <th style="text-align: left">Bill Date</th>
                                                <th style="text-align: left">Bill/Ref.No</th>
                                                <th style="text-align: left">TYPE</th>
                                                <th style="text-align: left">Received From</th>
                                                <th style="text-align: left">Particulars</th>
                                                <th style="text-align: left">CASH</th>
                                                <th style="text-align: left">BANK</th>
                                                <th style="text-align: left">ONLINE</th>
                                                <th style="text-align: left">User</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr class="border-1">
                                                <td style="text-align: left">1</td>
                                                <td style="text-align: left">01-10-2024</td>
                                                <td style="text-align: left">25-09-2024</td>
                                                <td style="text-align: left">IPD-00002084</td>
                                                <td style="text-align: left">INVOICE</td>
                                                <td style="text-align: left">SANJIBRAO BHATTACHARJEE</td>
                                                <td style="text-align: left">Due Balance Collection</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">10000.00</td>
                                                <td style="text-align: left">RIPA</td>
                                            </tr>
                                            <tr class="border-1">
                                                <td style="text-align: left; border: none;"></td>
                                                        <td style="text-align: left; border: none;"></td>
                                                        <td style="text-align: left; border: none;"></td>
                                                        <td style="text-align: left; border: none;"></td>
                                                        <td style="text-align: left; border: none;"></td>
                                                        <td style="text-align: left; border: none;"></td>
                                                        <td style="text-align: left; border: none; background-color: #E3E4EE"></td>
                                                        <td style="text-align: left; background-color: #E3E4EE"> <b> Cash</b></td>
                                                        <td style="text-align: left; background-color: #E3E4EE"> <b> Bank</b></td>
                                                        <td style="text-align: left; background-color: #E3E4EE"> <b> Online</b></td>
                                                        <td style="text-align: left; background-color: #E3E4EE"> <b> </b></td>
                                            </tr>
                                            <tr class="border-1">
                                                <td style="text-align: left;"></td>
                                                <td style="text-align: left;"></td>
                                                <td style="text-align: left;"></td>
                                                <td style="text-align: left;"></td>
                                                <td style="text-align: left;"></td>
                                                <td style="text-align: left;"></td>
                                                <td style="text-align: left; background-color: #E3E4EE"> <b> GRAND TOTAL</b></td>
                                                <td style="text-align: left; background-color: #E3E4EE"> <b> 460.00</b></td>
                                                <td style="text-align: left; background-color: #E3E4EE"> <b> 40,000.00</b></td>
                                                <td style="text-align: left; background-color: #E3E4EE"> <b> 10,100.00</b></td>
                                                <td style="text-align: left; background-color: #E3E4EE"> <b> </b></td>
                                            </tr>
                                        </tbody>
                                    </table>

                                    <!-- 3rd Table  -->
                                    <table class="table table-bordered-print w-100 table-only-header-full-width mt-2 mb-2" id="quotation_products">
                                        <thead>
                                            <tr class="text-uppercase">
                                                <td colspan="12" class="text-center">
                                                    <h6 class="mt-2 mb-2">
                                                        Payment / Expenditure From Date <span class="text-primary">01-10-2024 </span>  | To Date <span class="text-primary">01-10-2024</span>
                                                    </h6>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th style="text-align: left">SL No</th>
                                                <th style="text-align: left">Date</th>
                                                <th style="text-align: left">Received From</th>
                                                <th style="text-align: left">Narration</th>
                                                <th style="text-align: left">Bill/Reff. No </th>
                                                <th style="text-align: left">CASH</th>
                                                <th style="text-align: left">BANK</th>
                                                <th style="text-align: left">ONLINE</th>
                                                <th style="text-align: left">User</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr class="border-1">
                                                <td style="text-align: left">1</td>
                                                <td style="text-align: left">01-10-2024</td>
                                                <td style="text-align: left">TRAVEL EXP</td>
                                                <td style="text-align: left">DR.SAMIR KUMAR DAS(UBER)</td>
                                                <td style="text-align: left"></td>
                                                <td style="text-align: left">200.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">0.00</td>
                                                <td style="text-align: left">Prytma</td>
                                            </tr>
                                            <tr class="border-1">
                                                <td style="text-align: left; border: none;"></td>
                                                        <td style="text-align: left; border: none;"></td>
                                                        <td style="text-align: left; border: none;"></td>
                                                        <td style="text-align: left; border: none;"></td>
                                                        <td style="text-align: left; border: none; background-color: #E3E4EE"></td>
                                                        <td style="text-align: left; background-color: #E3E4EE"> <b>Cash</b> </td>
                                                        <td style="text-align: left; background-color: #E3E4EE"> <b>Bank</b> </td>
                                                        <td style="text-align: left; background-color: #E3E4EE"> <b>Online</b> </td>
                                                        <td style="text-align: left; background-color: #E3E4EE"></td>
                                            </tr>
                                            <tr class="border-1">
                                                <td style="text-align: left;"></td>
                                                <td style="text-align: left;"></td>
                                                <td style="text-align: left;"></td>
                                                <td style="text-align: left;"></td>
                                                <td style="text-align: left; background-color: #E3E4EE"> <b>FINAL CASH</b>  IN HAND</td>
                                                <td style="text-align: left; background-color: #E3E4EE"> <b>460.00</b> </td>
                                                <td style="text-align: left; background-color: #E3E4EE"> <b> 40,000.00</b></td>
                                                <td style="text-align: left; background-color: #E3E4EE"> <b>10,100.00</b> </td>
                                                <td style="text-align: left; background-color: #E3E4EE"></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
@endsection
@section('js')
<script type="text/javascript" src="{{ asset('admin/plugins/datepicker/js/bootstrap-datepicker.js') }}"></script>
  <script>

     /***************** Global Delay Fucntion ***************/
     function delay(callback, ms) {
        var timer = 0;
        return function() {
            var context = this,
                args = arguments;
            clearTimeout(timer);
            timer = setTimeout(function() {
                callback.apply(context, args);
            }, ms || 0);
        };
    }


    $(document).ready(function(){
      $( function() {
          $('.datepicker').datepicker({
            format: "{!! $companyDateFormate??'dd-mm-yyyy' !!}",
            autoclose: true,
        })
        .on('changeDate', function (ev) {
            $(this).datepicker('hide');

            var page  = $('[name="hidden_page"]').val();
            var query = $('#search').val()?$('#search').val():'';
            var sort_type = $('#hidden_sort_type').val();
            var column_name = $('.sorting').val()?$('.sorting').val():'';
            fetch_data(page,sort_type,column_name, query)
        })

      });

      function fetch_data(page, sort_type, sort_by, query){
        var start_date   = $('#start_date').val();
        var end_date     = $('#end_date').val();
        var voucher_type = $('#voucher_type').val();

        $.ajax({
          url:"?page="+page+"&query="+query+"&start_date="+start_date+"&end_date="+end_date+"&voucher_type="+voucher_type+"&sort_by="+sort_by,
          success:function(data){
            $('#tables').html('');
            $('#tables').html(data);
            $(document).ready(function(){$.switcher();});
          }
        })
      }

       /******** searching ********/
    $(document).on('keyup', '#search', delay(function() {
        var query = $('#search').val();

        if (query.length < 2 && query.length != 0) {
            return;
        }

        var column_name = $('.sorting').val();
        var sort_type   = $('#hidden_sort_type').val();
        var page        = 1 ? 1 : (this).attr('href').split('page=')[1];
        fetch_data(page, sort_type, column_name, query);
    }, 700));


      $('body').on('change', '#voucher_type', function(){
        var query = $('#search').val();
        var page = 1;

        if (query.length < 2 && query.length != 0) {
          return;
        }
        var column_name = $('.sorting').val();
        var sort_type   = $('#hidden_sort_type').val();
        fetch_data(page, sort_type, column_name, query);
      });
      $('body').on('change', '.sorting', function(){

        var column_name = $(this).val();
        console.log('perpage',column_name);
        var order_type = $(this).data('sorting_type');
        var reverse_order = '';
        var page = 1?1:(this).attr('href').split('page=')[1];
        var query = $('#search').val()?$('#search').val():'';
        fetch_data(page, reverse_order, column_name, query);
        });

      $('body').on('click', '.pager a', function(event){
        event.preventDefault();
        $('#hidden_page').val(page);
        var page  = $(this).attr('href').split('page=')[1];
        var column_name = $('.sorting').val()?$('.sorting').val():'';
        var sort_type = $('#hidden_sort_type').val();
        var query = $('#search').val()?$('#search').val():'';
        $('li').removeClass('active');
        $(this).parent().addClass('active');

        fetch_data(page, sort_type, column_name, query);
      });
    });
  </script>
@endsection
