<!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" />
    <style>
        .form-group label {
            line-height: 0.4rem !important;
        }
        .select2-container .select2-selection--single, .select2-selection--multiple {
            min-height: 30px !important;
        }
        .select2-selection__arrow {
            height: 30px !important;
        }
        .form-control, .select2-container--default .select2-selection--single, .select2-container--default .select2-selection--single .select2-search__field, .typeahead, .tt-query, .tt-hint {
            padding: 0.4rem 1.375rem;
        }
</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" style="min-height: 80vh">
                            <div class="card-body">
                                <h4 class="card-title"><i class="mdi mdi-dots-vertical menu-icon"></i> {{__('sidebar.payment')}}</h4>
                                <div class="row">
                                    <div class="col-sm-12">
                                        <div class="col-sm-12 inv-search">
                                            <form method="get" action="{{url('invoice')}}">
                                                <div class="row">
                                                    <div class="col-sm-12 col-md-8 col-lg-4 pr-0">
                                                        <div class="form-group mb-1">
                                                            <label for="start-invoice-date">{{__('invoice.repayment_date')}}</label>
                                                            <div class="input-group">
                                                                <input id="start-invoice-date" value="{{isset($_GET['from_date']) ? $_GET['from_date'] : ''}}" name="from_date" class="form-control rounded-right-0 rounded-top-left-25 rounded-bottom-left-25" onfocus="(this.type='date')" onblur="(this.type='text')" placeholder="{{__('general.type_date_placeholder')}}">
                                                                <input id="to-invoice-date" value="{{isset($_GET['to_date']) ? $_GET['to_date'] : ''}}" name="to_date" class="form-control rounded-left-0 rounded-right-0" onfocus="(this.type='date')" onblur="(this.type='text')" placeholder="{{__('general.type_date_placeholder')}}">
                                                            </div>
                                                        </div>
                                                    </div>

                                                    <div class="col-sm-12 col-md-6 col-lg-6">
                                                        <div class="form-group mb-1">
                                                            <label for="lab-name-en">{{__('invoice.table_textable_filter')}}</label>
                                                            <div class="input-group">
                                                                <input type="text" class="form-control rounded-right-0 rounded-left-0" value="{{isset($_GET['kword']) ? $_GET['kword'] : ''}}" name="kword" id="kword" placeholder="{{__('invoice.form_invoice_number')}}">
                                                                <div class="input-group-append">
                                                                    <button class="btn btn-sm btn-inverse-secondary rounded-bottom-right-25 rounded-top-right-25 px-3" title="Search" type="submit"><i class="fa fa-search"></i> {{__('general.btn_search')}}</button>
                                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['create_repayment']))
                                                                        <button type="button" data-toggle="modal" data-action="new" data-target="#modal-repayment" data-backdrop="static" class="btn btn-sm btn-inverse-success rounded-25 rounded-0 waves-effect px-3 ml-5"><i class="typcn typcn-plus"></i>{{__('general.btn_add_new')}}</button>
                                                                    @endif
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                        </form> <hr class="my-3 d-none">
                                        </div>
                                        <div class="col-sm-12 p-0 mb-1 mt-3">
                                            <div class="table-responsive">
                                                <table class="table table-bordered table-hover" id="department_dt">
                                                    <thead>
                                                    <tr class="bg-gradient-light">
                                                        <th class="py-2 text-center" width="50px">{{__('invoice.table_no')}}</th>
                                                        <th class="py-2 text-center" width="100px">{{__('invoice.table_action')}}</th>
                                                        <th class="py-2" width="150px">{{__('invoice.table_patient_name')}}</th>
                                                        <th class="py-2" width="100px">{{__('invoice.table_invoice_code')}}</th>
                                                        <th class="py-2 text-center" width="120px">{{__('invoice.repayment_date')}}</th>
                                                        <th class="py-2 text-center" width="90px">{{__('invoice.cash_paid')}}</th>
                                                        <th class="py-2 text-center" width="90px">{{__('invoice.bank_paid')}}</th>
                                                        <th class="py-2 text-center" width="90px">{{__('invoice.bank_name')}}</th>
                                                        <th class="py-2 text-center" width="90px">{{__('invoice.transaction_no')}}</th>
                                                        <th class="py-2 text-center" width="90px">{{__('invoice.exchange_rate')}}</th>
                                                    </tr>
                                                    </thead>
                                                    <tbody>
                                                    @foreach($repayments as $k=>$repayment)
                                                        <tr>
                                                            <td class="py-1 text-center">{{($k+1) + (($_GET['page'] ?? 1) * 20) - 20}}</td>
                                                            <td class="py-1 text-center">
                                                                <div class="btn-group" role="group" aria-label="Basic example" >

                                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['update_repayment']))
                                                                            <button type="button" data-action="edit" data-uid="{{$repayment->id}}" data-toggle="modal" data-target="#modal-repayment" data-id="" class="btn btn-sm btn-inverse-primary mr-2" title="{{__('general.btn_edit')}}"><i class="typcn typcn-edit"></i></button>
                                                                    @endif
                                                                    @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['delete_repayment']))
                                                                        <button type="button" class="btn btn-sm btn-inverse-danger " title="{{__('general.btn_delete')}}" onclick="deleteRepayment({{$repayment->id}})"><i class="mdi mdi-close-circle"></i></button>
                                                                    @endif
                                                                </div>
                                                            </td>
                                                            <td class="py-1">{{$repayment->invoice->sample->patient->name_en}}</td>
                                                            <td class="py-1">{{$repayment->invoice->invoice_code}}</td>
                                                            <td class="py-1 text-center">{{date('d-m-Y',strtotime($repayment->repayment_date))}}</td>
                                                            <td class="py-1 text-right">{{$repayment->cash_repayment_amount}}</td>
                                                            <td class="py-1 text-right">{{$repayment->bank_repayment_amount}}</td>
                                                            <td class="py-1 text-right">{{$repayment->bank_name}}</td>
                                                            <td class="py-1 text-right">{{$repayment->transaction_ref}}</td>
                                                            <td class="py-1 text-right">{{$repayment->exchange_rate}}</td>
                                                        </tr>
                                                    @endforeach
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>

                                        <div class="float-right mt-3">
                                            {!! $repayments->appends($_GET)->links('pagination.custom') !!}
                                        </div>

                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            @include('modal.repayment')

            @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 repayment_base_url = "{{url('repayment')}}";
    let currency = {{$labSettings->currency}};
    let repayment_modal_title = "{{__('invoice.repayment')}}";

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

</body>

</html>

