<!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>

    <style>
        .main-panel{
            width: calc(100% - 306px) !important;
        }
    </style>

</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> {{__('sidebar.doctor_report')}}</h4>
{{--                                <small><code>*</code> is generated based on number of test selected</small>--}}
                                <div class="row">
                                    <div class="col-sm-12">
                                        <div class="col-sm-12 py-2 inv-search">
                                            <form method="get" action="{{url('report/doctor-report')}}">
                                                <div class="row">
                                                    <div class="col-sm-12 col-md-5 col-lg-3">
                                                        <div class="form-group mb-1">
                                                            <label for="start-invoice-date">{{__('report.doctor_date_range_filter')}}</label>
                                                            <div class="input-group">
                                                            <input name="start_date" value="{{isset($_GET['start_date']) ? date('Y-m-d',strtotime($_GET['start_date'])) : ''}}" onfocus="(this.type='date')" onblur="(this.type='text')" placeholder="{{__('general.type_date_placeholder')}}" class="form-control rounded-right-0">
                                                            <input name="end_date" value="{{isset($_GET['end_date']) ? date('Y-m-d',strtotime($_GET['end_date'])) : ''}}" onfocus="(this.type='date')" onblur="(this.type='text')" placeholder="{{__('general.type_date_placeholder')}}" class="form-control rounded-left-0 ">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12 col-md-3 col-lg-2">
                                                        <div class="form-group mb-1">
                                                            <label for="lab-name-en">{{__('report.doctor_sample_source_filter')}}</label>
                                                            <select class="form-control " name="sample_source">
                                                                <option></option>
                                                                @foreach($sampleSources as $sampleSource)
                                                                <option {{$sampleSource->id==@$_GET['sample_source'] ? 'selected':''}} value="{{$sampleSource->id}}">{{$sampleSource->name_en}}</option>
                                                                @endforeach
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12 col-md-3 col-lg-2">
                                                        <div class="form-group mb-1">
                                                            <label for="lab-name-en">{{__('report.doctor_physician_filter')}}</label>
                                                            <select class="form-control select2" name="physician">
                                                                <option></option>
                                                                <option {{'All'==@$_GET['physician'] ? 'selected':''}} value="All">All</option>
                                                                @foreach($physicians as $physician)
                                                                    <option {{$physician->id==@$_GET['physician'] ? 'selected':''}} value="{{$physician->id}}">{{$physician->name_en}}</option>
                                                                @endforeach
                                                            </select>
                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12 col-md-7 col-lg-5">
                                                        <div class="form-group mb-1">
                                                            <label for="lab-name-en">&nbsp;</label>
                                                            <div class="input-group">
                                                                <div class="input-group-append">
                                                                    <button class="btn btn-inverse-secondary rounded-25" title="Search" type="submit"><i class="fa fa-search"></i> {{__('report.btn_view')}}</button>
                                                                    <a href="{{url('report/doctor-report')}}" class="btn rounded-25 btn-inverse-warning ml-1  mx-3 " title="Clear Search Filter"><i class="mdi mdi-filter-remove-outline"></i>{{__('general.btn_clear')}}</a>
                                                                    <button type="button" class="btn btn-light rounded-25 dropdown-toggle ml-1" data-toggle="dropdown" aria-expanded="true">{{__('report.btn_action')}}</button>
                                                                    <div class="dropdown-menu" 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="button" data-toggle="modal" data-target="#print_preview_modal_detail" data-backdrop="static" class="dropdown-item font-14">{{__('report.btn_action_print')}} Detail Report</button>
                                                                        <button type="submit" value="true" name="export" class="dropdown-item font-14">{{__('report.btn_action_export')}}</button>
                                                                    </div>
                                                                </div>
                                                            </div>

                                                        </div>
                                                    </div>


                                                </div>
                                            </form> <hr class="my-3 d-none">
                                        </div>
                                        <br>
                                        <div class="col-sm-12 p-0 mb-1 mt-3">
                                            <div class="table-responsive">
                                                <table class="table table-bordered" id="department_dt">
                                                    <thead>
                                                    @if($report_data['report_id']==3)
                                                        <tr class="bg-light">
                                                            <th class="py-2">Date</th>
                                                            <th class="py-2">Patient Name</th>
                                                            <th class="py-2" >Sample No</th>
                                                            <th class="py-2">Test Name</th>
                                                            <th class="py-2">Physician Name</th>
                                                            <th class="py-2" >Total Amount</th>
                                                            <th class="py-2">Net Amount</th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>
                                                            @foreach($report_data['report_data'] as $v)
                                                                <tr>
                                                                    <td class="py-2 text-center">{{$v['date']}}</td>
                                                                    <td class="py-2">{{$v['patient']}}</td>
                                                                    <td class="py-2 text-center">{{$v['sample_number']}}</td>
                                                                    <td class="py-2" style="word-wrap: break-word; width:250px !important;">{{$v['test_name']}}</td>
                                                                    <td class="py-2">{{$v['physician']}}</td>
                                                                    <td class="py-2 text-right">{{$v['total_amount']}}</td>
                                                                    <td class="py-2 text-right">{{$v['total_net_amount']}}</td>
                                                                </tr>
                                                            @endforeach
                                                        </tbody>
                                                    @elseif($report_data['report_id']==1)
                                                        <tr class="bg-light">
                                                            <th class="py-2">{{__('report.summary_clinic_name')}}</th>
                                                            <th class="py-2 text-right" width="250px">{{__('report.doctor_exam')}}</th>
                                                            <th class="py-2 text-right" width="250px">{{__('report.doctor_net_amount')}}</th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>
                                                            @foreach($report_data['report_data'] as $v)
                                                                <tr>
                                                                    <td class="py-2">{{$v['sample_source_name']}}</td>
                                                                    <td class="py-2 text-right">{{$v['total_exam']}}</td>
                                                                    <td class="py-2 text-right">{{$v['total_net_amount']}}</td>
                                                                </tr>
                                                            @endforeach
                                                        </tbody>
                                                    @else
                                                        <tr class="bg-light">
                                                            <th class="py-2">Physician</th>
                                                            <th class="py-2 text-right" width="250px">Exam</th>
                                                            <th class="py-2 text-right" width="250px">Net Amount</th>
                                                        </tr>
                                                        </thead>
                                                            @foreach($report_data['report_data'] as $v)
                                                                <tr>
                                                                    <td class="py-2">{{$v['physician_name']}}</td>
                                                                    <td class="py-2 text-right">{{$v['total_exam']}}</td>
                                                                    <td class="py-2 text-right">{{$v['total_net_amount']}}</td>
                                                                </tr>
                                                            @endforeach
                                                        <tbody>
                                                        </tbody>
                                                    @endif
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            @include('modal.doctor_report_print')

            @include('modal.doctor_report_detail_print')

            @include('layout.footer')
        </div>
    </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>

