<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    @include('layout.header')
    <link href="{{url(env("APP_URL").'storage/assets/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css')}}" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="{{url(env("APP_URL").'storage/assets/libs/lightgallery/lightgallery.css')}}" >
    <link rel="stylesheet" href="{{url(env("APP_URL").'storage/assets/libs/printjs/printjs.css')}}" >
    <script src="{{url(env("APP_URL").'storage/assets/libs/printjs/printjs.min.js')}}"></script>
</head>
<body>


<div class="container-scroller">
@include('layout.navbar')
<!-- partial -->
    @include('layout.breadscrum')
    <div class="container-fluid page-body-wrapper">

    @include('layout.sidebar')

    <!-- partial -->
        <div class="main-panel">
            <div class="content-wrapper">
                <div class="row">
                    <div class="col-md-12 grid-margin stretch-card">
                        <div class="card">
                            <div class="card-body">
                                <h4 class="card-title"><i class="mdi mdi-dots-vertical menu-icon"></i> {{__('report.summary_rpt_tittle')}}</h4>
                                <div class="row">
                                    <div class="col-sm-12">
                                        <div class="col-sm-12 py-2 inv-search">
                                            <form method="get" action="{{url('report/summary-report')}}">
                                                <div class="row">

                                                    <div class="col-sm-12 col-md-10 col-lg-8 pr-0">
                                                        <div class="form-group mb-1">

                                                                <label for="start-invoice-date">{{__('invoice.table_date_filter')}}</label>
                                                                <div class="input-group">
                                                                    <input id="start-invoice-date" value="{{isset($_GET['start_date']) ? $_GET['start_date'] : ''}}" name="start_date" class="form-control rounded-top-left-25 rounded-bottom-left-25 rounded-right-0" onfocus="(this.type='date')" onblur="(this.type='text')" placeholder="{{__('general.type_date_placeholder')}}">
                                                                    <input id="to-invoice-date" value="{{isset($_GET['end_date']) ? $_GET['end_date'] : ''}}" name="end_date" class="form-control rounded-left-0 rounded-right-0" onfocus="(this.type='date')" onblur="(this.type='text')" placeholder="{{__('general.type_date_placeholder')}}">

                                                                    <button class="btn btn-sm btn-inverse-secondary rounded-left-0 rounded-right-0 px-3" title="Search" type="submit"><i class="fa fa-search"></i> {{__('report.btn_view')}}</button>
                                                                    <a href="{{url('report/summary-report')}}" class="btn btn-sm btn-inverse-warning rounded-left-0 rounded-right-0 pt-3" title="Clear Search Filter"><i class="mdi mdi-filter-remove-outline"></i>{{__('general.btn_clear')}}</a>
                                                                    <button type="button" class="btn btn-sm btn-inverse-secondary rounded-left-0 rounded-top-right-25 rounded-bottom-right-25 dropdown-toggle" data-toggle="dropdown" aria-expanded="true">{{__('report.btn_action')}}</button>
                                                                    <div class="dropdown-menu btn-light" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 44px, 0px);" x-placement="bottom-start">
                                                                        <button type="button" data-toggle="modal" data-target="#print_preview_modal" data-backdrop="static" class="dropdown-item font-14">{{__('report.btn_action_print')}}</button>
                                                                        <button type="submit" value="true" name="export" class="dropdown-item font-14">{{__('report.btn_action_export')}}</button>
                                                                    </div>

                                                                </div>


                                                        </div>
                                                    </div>



                                                </div>
                                            </form> <hr class="my-3 d-none">
                                        </div>
                                        <br>

                                        <h6>{{__('report.summary_report_section_by_sample_source')}}</h6>
                                        <div class="col-sm-12 p-0 mb-1 mt-3">
                                            <div class="table-responsive--">
                                                <table class="table table-bordered" id="department_dt">
                                                    <thead>
                                                        <tr class="bg-light">
                                                            <th class="py-2">{{__('report.summary_clinic_name')}}</th>
                                                            <th class="py-2 text-right" width="250px">{{__('report.summary_male_patient')}}</th>
                                                            <th class="py-2 text-right" width="250px">{{__('report.summary_female_patient')}}</th>
                                                            <th class="py-2 text-right" width="250px">{{__('report.summary_total_sample')}}</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                    @foreach($report_data['sample_source_data'] as $j=>$l)
                                                        <tr>
                                                            <td class="py-2 pl-4">{{$l['clinic_name']}}</td>
                                                            <td class="py-2 text-right">{{$l['total_male_patient']}}</td>
                                                            <td class="py-2 text-right">{{$l['total_female_patient']}}</td>
                                                            <td class="py-2 text-right">{{$l['total_patient']}}</td>
                                                        </tr>
                                                    @endforeach
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>

                                        <h6>{{__('report.summary_report_section_by_test')}}</h6>
                                        <div class="col-sm-12 p-0 mb-1 mt-3">
                                            <div class="table-responsive--">
                                                <table class="table table-bordered" id="department_dt">
                                                    <thead>
                                                    <tr class="bg-light">
                                                        <th class="py-2">{{__('report.summary_rpt_test_type')}}</th>
                                                        <th class="py-2 text-right" width="250px">{{__('report.summary_male_patient')}}</th>
                                                        <th class="py-2 text-right" width="250px">{{__('report.summary_female_patient')}}</th>
                                                        <th class="py-2 text-right" width="250px">{{__('report.summary_total_patient')}}</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    @foreach($report_data['report_data'] as $k=>$val)
                                                        @if(!is_array($val))
                                                            <tr class="bg-white">
                                                                <td class="py-2 font-weight-medium pl-3 text-left" colspan="4"><u>{{$val}}</u></td>
                                                            </tr>
                                                        @else
                                                            @foreach($val as $v)
                                                                <tr>
                                                                    <td class="py-2 pl-4">{{$v['group_result']}}</td>
                                                                    <td class="py-2 text-right">{{$v['total_male_patient']}}</td>
                                                                    <td class="py-2 text-right">{{$v['total_female_patient']}}</td>
                                                                    <td class="py-2 text-right">{{$v['total_patient']}}</td>
                                                                </tr>
                                                            @endforeach
                                                        @endif
                                                    @endforeach
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>

                                        <h6>{{__('report.summary_report_section_by_category')}}</h6>
                                        <div class="col-sm-12 p-0 mb-1 mt-3">
                                            <div class="table-responsive--">
                                                <table class="table table-bordered" id="department_dt">
                                                    <thead>
                                                        <tr class="bg-light">
                                                            <th class="py-2">{{__('report.summary_category_name')}}</th>
                                                            <th class="py-2 text-right" width="250px">{{__('report.summary_male_patient')}}</th>
                                                            <th class="py-2 text-right" width="250px">{{__('report.summary_female_patient')}}</th>
                                                            <th class="py-2 text-right" width="250px">{{__('report.summary_total_patient')}}</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                    <?php
                                                    $total_male = 0;
                                                    $total_female = 0;
                                                    $total_patient = 0;
                                                    ?>
                                                    @foreach($report_data['test_category_data'] as $raw=>$v)
                                                    <?php
                                                    $total_male += $v['total_male_patient'];
                                                    $total_female += $v['total_female_patient'];
                                                    $total_patient += $v['total_patient'];
                                                    ?>
                                                        <tr>
                                                            <td class="py-2 pl-4">{{$v['category']}}</td>
                                                            <td class="py-2 text-right">{{$v['total_male_patient']}}</td>
                                                            <td class="py-2 text-right">{{$v['total_female_patient']}}</td>
                                                            <td class="py-2 text-right">{{$v['total_patient']}}</td>
                                                        </tr>
                                                    @endforeach
                                                    <tr class="bg-light">
                                                            <td class="py-2 pl-4">{{__('report.total')}}</td>
                                                            <td class="py-2 text-right">{{$total_male}}</td>
                                                            <td class="py-2 text-right">{{$total_female}}</td>
                                                            <td class="py-2 text-right">{{$total_patient}}</td>
                                                    </tr>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            @include('layout.footer')
        </div>

	@include('modal.summary_report_print')

    </div>
</div>
@include('layout.common_script')

<script src="{{url(env("APP_URL").'storage/assets/libs/bootstrap-datepicker/js/bootstrap-datepicker.min.js')}}"></script>
<script>


    var base_url = "{{url('invoice')}}";
    let invoice_id = 0;

    $(".datepicker").datepicker({
        format:'dd-mm-yyyy',
        autoclose: true
    });

    $(".monthpicker").datepicker({
        format:'mm-yyyy',
        autoclose: true
    });

    $(".yearpicker").datepicker({
        format:'yyyy',
        autoclose: true
    });

</script>
{{--<script src="{{url(env("APP_URL").'storage/assets/js/admin/invoice.js')}}"></script>--}}

</body>

</html>

