<div class="row">

    <div class="col-md-12">

        <div class="form-group">

            <?php echo Form::label('invoice_id', trans('application.invoice').' *'); ?>

            <?php if(isset($invoice)): ?>

                <?php echo Form::select('invoice_id',array($invoice->uuid => $invoice->number.'( Bal '.$invoice->totals['amountDue'].') | '. $invoice->client->name), $invoice->uuid, ['class' => 'form-control', 'required']); ?>

            <?php else: ?>

                <?php if(isset($payment->invoice_id)): ?> <strong> <?php echo e($payment->invoice->number); ?> </strong> <?php endif; ?>

                <?php echo Form::select('invoice_id',array(), null, ['class' => 'form-control ajaxChosen input-sm', !isset($payment->invoice_id) ? 'required' : '', 'data-placeholder' => 'Type atleast 2 characters of the invoice number']); ?>

            <?php endif; ?>

        </div>

        <div class="form-group">

            <?php echo Form::label('payment_date', trans('application.received_on')); ?>

            <?php echo Form::text('payment_date', null, ['class' => 'form-control datepicker input-sm', 'required']); ?>

        </div>

        <div class="form-group">

            <?php echo Form::label('method', trans('application.payment_method').'*'); ?>

            <?php echo Form::select('method',$methods, null, ['class' => 'form-control chosen input-sm']); ?>

        </div>

        <div class="form-group">

            <?php echo Form::label('amount', trans('application.amount').'*'); ?>

            <?php echo Form::input('number','amount',null, ['class' => 'form-control input-sm','step'=>'any','min'=>1, 'required']); ?>

        </div>

        <div class="form-group">

            <?php echo Form::label('notes', trans('application.notes')); ?>

            <?php echo Form::textarea('notes',null, ['class' => 'form-control input-sm', 'rows'=> '5']); ?>

        </div>

    </div>

</div>

<script src="<?php echo e(asset('assets/plugins/chosen/chosen.ajaxaddition.jquery.js')); ?>"></script>

<script type="text/javascript">

    $('.ajaxChosen').ajaxChosen({

        dataType: 'json',

        type: 'POST',

        url:'/search',

        data: {'_token':"<?php echo e(csrf_token()); ?>"}, //Or can be [{'name':'keyboard', 'value':'cat'}]. chose your favorite, it handles both.

        success: function(data, textStatus, jqXHR){  }

    },{

        processItems: function(data){return data;},

        generateUrl: function(q){ return '<?php echo e(url("invoices/ajaxSearch")); ?>' },

        loadingImg: '<?php echo e(asset("assets/plugins/chosen/loading.gif")); ?>',

        minLength: 2

    });

</script>

