

<?php $__env->startSection('content'); ?>
    <?php echo $__env->make('components.notification', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
    <form action="<?php echo e(route('voucher.store')); ?>" method="POST">
        <?php echo csrf_field(); ?>
        <div class="form-group row">
            <div class="col-md-6">
                <label>Member</label>
                <input type="hidden" name="poin" value="<?php echo e(old('poin',0)); ?>" id="poin">
                <select name="id_customer" id="id_customer" class="form-control <?php $__errorArgs = ['id_customer'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>">
                    <option value="">---Pilih Member (Masukkan Nomer HP)---</option>
                    <?php if(request()->member): ?>
                    <option value='<?php echo e(request()->member); ?>' data-poin='<?php echo e($data[0]->poin); ?>' selected><?php echo e($data[0]->nama); ?> <?php echo e($data[0]->phone); ?></option>
                    <?php endif; ?>
                    
                </select>
                <?php $__errorArgs = ['id_customer'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <div class="invalid-feedback">
                        <?php echo e($message); ?>

                    </div>
                <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
            </div>
            <div class="col-md-6">
                <label>Nominal Voucher</label>
                <input type="number" name="price_item" class="form-control <?php $__errorArgs = ['price_item'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                    placeholder="Nominal Voucher" value="<?php echo e(old('price_item')); ?>" id="nominal">
                    <?php $__errorArgs = ['price_item'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <div class="invalid-feedback">
                        <?php echo e($message); ?>

                    </div>
                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>
            </div>
        <div class="form-group row">
            <div class="col-md-6">
                <label>Deskripsi</label>
                <input type="text" name="item_name" class="form-control <?php $__errorArgs = ['item_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> is-invalid <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>"
                    placeholder="Deskripsi" value="<?php echo e(old('item_name')); ?>">
                    <?php $__errorArgs = ['item_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                    <div class="invalid-feedback">
                        <?php echo e($message); ?>

                    </div>
                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                </div>
                <div class="col-md-6">
                    <label>Cabang</label>
                    <select name="id_branch" id="" class="form-control select2">
                        <option value="0">Semua Cabang</option>
                        <?php $__currentLoopData = $branch; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($item->id); ?>"><?php echo e($item->cabang); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                </div>
            </div>
            <div class="form-group row">
            <div class="col-md-6 mt-2">
                <button type="submit" class="btn btn-primary mr-2"><i class="fa fa-save"></i> Simpan</button>
                <button type="reset" class="btn btn-default"><i class="fa fa-times"></i> Reset</button>
            </div>
            </div>
        </div>
    
    </form>
    
<?php $__env->stopSection(); ?>

<?php $__env->startPush('custom-script'); ?>
    <script>
        $(document).ready(function(){
            $("#id_customer").change(function(){
                var poin = $(this).find(':selected').attr('data-poin')
                $("#nominal").val(poin)
                $("#poin").val(poin)
            })
            <?php if(isset($_GET['member'])): ?>
                $("#id_customer").val("<?php echo e($_GET['member']); ?>")
                $("#id_customer").trigger('change')
            <?php endif; ?>
            $("#id_customer").select2({
                minimumInputLength: 10,
                ajax: {
                    url: "<?php echo e(url('voucher/getMember')); ?>",
                    dataType: 'json',
                    type: "GET",
                    data: function (term) {
                        return {
                            term: term.term
                        };
                    },
                    processResults: function (data) {
                        return {
                            results: $.map(data, function (item,i) {
                                return {
                                    text: item.phoneNama,
                                    id: item.id,
                                }
                            })
                        };
                    },
                   cache: true                
                }
            });
            $('#id_customer').on('select2:select', function (e) {
                var thisSelect = $(this)
                $.ajax({
                    url: "<?php echo e(url('voucher/getMember')); ?>",
                    dataType: 'json',
                    type: "GET",
                    async : false,
                    data: {poin:true,id:thisSelect.val()},
                    success:function(res){
                        thisSelect.find(':selected').attr('data-poin',res[0].poin)
                        $("#id_customer").trigger('change')
                    }
                })
            });
        })
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.template', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/coffeeto/public_html/member/resources/views/voucher/create-payment.blade.php ENDPATH**/ ?>