@extends('template.app')

@section('title','Customer Due Payment Collection')
=

@section('content')
    <div class="row ">
        <div class="col-md-12 col-sm-12">
            <div class="card card-box">
                <div class="card-head text-white " style="background-color:#3FCC7E;">
                    <header>{{ $customer->name }}'s Due Collection</header>
                </div>
                <div class="card-body" id="bar-parent">
                    <div class="card-body">
                <div class="row">
                    {!! Form::open(['route' => ['admin.customer.due.collection','customer' => $customer->id]]) !!}
                        <div class="row">
                            <div class="col-md-6 col-12">
                                <div class="form-group">
                                    <label for="expensehead_id">Select Purpose Head</label>
                                    <select name="purposehead_id" id="purposehead_id" class="form-control select2">
                                        @foreach (\App\Models\PurposeHead::get() as $purposeHead)
                                            <option value="{{ $purposeHead->id }}">{{ $purposeHead->name }}</option>
                                        @endforeach
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="payment_amount">Payment Amount</label>
                                    <input type="number" name="payment_amount" class="form-control" id="payment_amount" @if(request()->from != 'opening_balance' ) max="{{ $amount_to_collect }}" readonly @endif value="{{ $amount_to_collect }}" autocomplete="off" required>
                                </div>
                                <div class="form-group">
                                    <label for="reference">Reference / Bill / Receipt No</label>
                                    <input type="text" name="reference" class="form-control" id="reference" value="{{ old('reference') }}" autocomplete="off">
                                </div>
                                
                            </div>
                            
                            <div class="col-md-6 col-12">
                                <div class="form-group">
                                    <label for="simpleFormEmail">Received By</label>
                                    <input type="text" name="received_by" class="form-control" id="simpleFormEmail" value="{{ auth()->user()->name }}">
                                </div>
                                <div class="form-group">
                                    <label class="">Payment Date</label>
                                    <div class="input-group date form_date" data-date="{{ \Carbon\Carbon::now() }}" data-date-format="dd MM yyyy" data-link-field="dtp_input1">
                                        <input class="form-control" size="16" type="text" name="payment_date" value="{{ \Carbon\Carbon::now()->format('d M Y') }}">
                                        <span class="input-group-addon ml-2">
                                            <span class="fa fa-calendar"></span>
                                        </span>
                                    </div>
                                    <input type="hidden" id="dtp_input1" value="" />
                                </div>
                                <div class="form-group">
                                    <label for="payment_gateway">Select Payment Gateway</label>
                                    <select name="payment_gateway" id="payment_gateway" class="form-control select2">
                                        @foreach( \App\Models\PaymentGateway::get() as $gateway ) 
                                            <option value="{{ $gateway->id }}">{{ $gateway->gateway_name }}({{ $gateway->gateway_account_number }})</option>
                                        @endforeach
                                    </select>
                                </div>
                            </div>
                            @foreach($invoices as $invoiceId) 
                                <input type="hidden" name="invoices[]" class="bulk-select" value="{{ $invoiceId }}"/>
                            @endforeach
                            <input type="hidden" name="from" value="{{ request()->from }}"/>
                        </div>
                        <div class="row">
                            <div class="col-12">
                                {!! Form::submit('Collect',['class' => 'btn btn-success pull-right']) !!}
                            </div>
                        </div>

                    {!! Form::close() !!}
                </div>
            </div>
                </div>
            </div>
        </div>
    </div>
@endsection
