<!-- Modal Repayment -->
<div class="modal fade modal-primary" id="modal-repayment">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h6 class="modal-title new">{{__('invoice.repayment')}}</h6>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true" class="mdi mdi-close"></span></button>
            </div>

            <div class="modal-body">
                <form method="post" action="#" id="repayment-form" onkeydown="return event.key != 'Enter';">
                    @csrf
                    <input type="hidden" class="form-control" name="uid" id="repayment-data-id" value="0" />
                    <div class="col-sm-12">
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="form-group row">
                                    <label for="total-amount" class="col-sm-5 col-form-label">{{__('invoice.table_invoice_code')}} <span class="text-danger">*</span></label>
                                    <div class="col-sm-7">
                                        <select class="form-control form-control-xxs select2 rounded-0 py-0" name="invoice_id" id="repayment-invoice-id" style=" width: 100% !important;">
                                            <option></option>
                                            @foreach($oweInvoices as $invoice)
                                                <option value="{{$invoice->id}}"> {{$invoice->sample->patient->name_en . ' ' .$invoice->invoice_code}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>
                            </div>

                            <div class="col-sm-12">
                                <div class="form-group row">
                                    <label for="net-amount" class="col-sm-5 col-form-label">{{__('invoice.table_total_cost')}} <span class="text-danger">({{$labSettings->currency==1?'៛':'$'}})</span></label>
                                    <div class="col-sm-7">
                                        <input type="number" min="0.00" max="99999999" step="any" required value="" class="form-control form-control-xxs rounded-0" name="amount_to_pay" id="amount_to_pay" placeholder="0.00">
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-12">
                                <div class="form-group row">
                                    <label for="discount-amount" class="col-sm-5 col-form-label">{{__('invoice.form_discount')}} <span class="text-danger">({{$labSettings->discount_type == 2 ? ($labSettings->currency==1?'៛':'$') : '%'}})</span></label>
                                    <div class="col-sm-7">
                                        <input type="hidden" name="discount_type" value="{{$labSettings->discount_type}}" id="discount_type" />
                                        <input type="number" min="0.00" max="99999999" step="any" required value="" class="form-control form-control-xxs rounded-0" name="discount" id="discount-amount" placeholder="0.00">
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-12">
                                <div class="form-group row">
                                    <label for="discount-amount" class="col-sm-5 col-form-label">{{__('invoice.form_net_amount')}} <span class="text-danger"></span></label>
                                    <div class="col-sm-7">
                                        <input type="number" min="0.00" max="99999999" step="any" required value="" class="form-control form-control-xxs rounded-0" name="amount_after_discount" id="amount_after_discount" placeholder="0.00">
                                    </div>
                                </div>
                            </div>
                            <div class="col-sm-12 bg-light px-0 pt-2">
                                <div class="col-sm-12">
                                    <div class="form-group row">
                                        <label for="paid-amount" class="col-sm-5 col-form-label">{{__('invoice.pay_type')}} <span class="text-danger">*</span></label>
                                        <div class="col-sm-7">
                                            <select class="form-control form-control-xxs select2_ rounded-0 py-0" name="payment_method" id="payment_method" style=" width: 100% !important;">
                                                <option value="1" >{{__('invoice.cash_paid')}}</option>
                                                <option value="2" >{{__('invoice.bank_paid')}}</option>
                                                <option value="3" >{{__('invoice.cash_paid')}} + {{__('invoice.bank_paid')}}</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-12">
                                    <div class="form-group row">
                                        <label for="paid-amount" class="col-sm-5 col-form-label">{{__('invoice.cash_paid')}}</label>
                                        <div class="col-sm-7">
                                            <input type="number" min="0.00" max="99999999" step="any" required value="0.00" class="form-control form-control-xxs rounded-0" name="cash_repayment_amount" id="cash_repayment_amount" placeholder="0.00">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-12">
                                    <div class="form-group row">
                                        <label for="paid-amount" class="col-sm-5 col-form-label">{{__('invoice.bank_paid')}}</label>
                                        <div class="col-sm-7">
                                            <input type="number" min="0.00" max="99999999" step="any" required value="0.00" class="form-control form-control-xxs rounded-0" name="bank_repayment_amount" id="bank_repayment_amount" placeholder="0.00">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-12">
                                    <div class="form-group row">
                                        <label for="paid-amount" class="col-sm-5 col-form-label">{{__('invoice.form_paid_date')}} <span class="text-danger">*</span></label>
                                        <div class="col-sm-7">
                                            <input type="date" value="{{date('Y-m-d')}}" class="form-control form-control-xxs rounded-0" name="repayment_date" id="repayment_date" placeholder="DD-MM-YYYY">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-12">
                                    <div class="form-group row">
                                        <label for="paid-amount" class="col-sm-5 col-form-label">{{__('invoice.bank_name')}}</label>
                                        <div class="col-sm-7">
                                            <input type="text" value="" class="form-control form-control-xxs rounded-0" name="bank_name" id="bank_name">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-12">
                                    <div class="form-group row">
                                        <label for="paid-amount" class="col-sm-5 col-form-label">{{__('invoice.transaction_no')}}</label>
                                        <div class="col-sm-7">
                                            <input type="text" value="" class="form-control form-control-xxs rounded-0" name="transaction_ref" id="transaction_ref">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-12">
                                    <div class="form-group row">
                                        <label for="paid-amount" class="col-sm-5 col-form-label">{{__('invoice.exchange_rate')}}</label>
                                        <div class="col-sm-7">
                                            <input type="number" min="0.00" max="99999999" step="any" required value="{{$labSettings->exchange_rate}}" class="form-control form-control-xxs rounded-0" name="exchange_rate" id="exchange_rate">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                @if(\App\Http\Controllers\Helper\GlobalController::user_can(Auth::user()->role_id, ['create_repayment', 'update_repayment']))
                <button type="button" class="btn btn-info rounded-25" id="btnSaveRepayment"><i class="fa fa-floppy-o"></i>&nbsp;&nbsp;<span class="save">{{__('lang.save')}}</span><span class="update" style="display: none">{{__('lang.update')}}</span></button>
                @endif
                <button type="button" class="btn btn-secondary rounded-25 mx-3" data-dismiss='modal'>{{__('lang.cancel')}}</button>
            </div>
        </div>
    </div>
</div>
