<?php $__env->startSection('content'); ?>
    <div class="side-title">
        <h3><?php echo e($head ?? ''); ?></h3>
    </div>

    <div class="border-item">
        <form class="form-row" method="post" onsubmit="saveForm(this)" action="<?php echo e($action); ?>" enctype="multipart/form-data">
            <?php if($coupon ?? ''  && $coupon->id): ?>
                <?php echo method_field('PUT'); ?>
            <?php endif; ?>
            <?php echo csrf_field(); ?>

            <div class="form-group col-lg-6">
                <label><?php echo e(meta('code', getCurrentLocale()) ?? __('coupons.code')); ?></label>
                <input type="text"  class="form-control  <?php echo e($errors->has('code') ? 'is-invalid' : ''); ?>" name="code" placeholder="<?php echo e(meta('code', getCurrentLocale()) ?? __('coupons.code')); ?>" value='<?php echo e(old("code", $coupon->code ?? "")); ?>'/>
            </div>

            <div class="form-group col-lg-6">
                <label><?php echo e(__('coupons.discount_status')); ?> </label>
                <select id="discount_status" class="form-control <?php echo e($errors->has('discount_status') ? 'is-invalid' : ''); ?>" name="discount_status">
                    <?php $__currentLoopData = $discount_statuses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option <?php echo e(isset($coupon) ? ($coupon->discount_status == $row ? 'selected' : '') : ''); ?> value="<?php echo e($row); ?>"><?php echo e(__('coupons.discount_statuses.'.$row)); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>

            <div class="form-group col-lg-6" >
                <label><?php echo e(__('coupons.discount')); ?> </label>
                <input type="number" class="form-control <?php echo e($errors->has('discount') ? 'is-invalid' : ''); ?>" name="discount" placeholder="<?php echo e(__('coupons.discount')); ?>" value='<?php echo e(old("discount", $coupon->discount ?? "")); ?>'/>
            </div>


            <div class="form-group col-lg-6" >
                <label><?php echo e(__('coupons.user_count')); ?> </label>
                <input type="number" class="form-control <?php echo e($errors->has('user_count') ? 'is-invalid' : ''); ?>" name="user_count" placeholder="<?php echo e(__('coupons.user_count')); ?>" value='<?php echo e(old("user_count", $coupon->user_count ?? "")); ?>'/>
            </div>

            <div class="form-group col-lg-6" >
                <label><?php echo e(__('coupons.count')); ?> </label>
                <input type="number" class="form-control <?php echo e($errors->has('count') ? 'is-invalid' : ''); ?>" name="count" placeholder="<?php echo e(__('coupons.count')); ?>" value='<?php echo e(old("count", $coupon->count ?? "")); ?>'/>
            </div>

            <div class="form-group col-lg-6" >
                <label><?php echo e(__('coupons.start_date')); ?> </label>
                <input type="date" class="form-control <?php echo e($errors->has('start_date') ? 'is-invalid' : ''); ?>" name="start_date" placeholder="<?php echo e(__('coupons.start_date')); ?>" value='<?php echo e(old("start_date", $coupon->start_date ?? "")); ?>' />
            </div>

            <div class="form-group col-lg-6" >
                <label><?php echo e(__('coupons.end_date')); ?> </label>
                <input type="date" class="form-control <?php echo e($errors->has('end_date') ? 'is-invalid' : ''); ?>" name="end_date" placeholder="<?php echo e(__('coupons.end_date')); ?>" value='<?php echo e(old("end_date", $coupon->end_date ?? "")); ?>' />
            </div>


            <div class="text-center mt-5 col-12">
                <button class="butn"><span><?php echo e(__('dashboard.save')); ?></span></button>
            </div>
        </form>
    </div>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('inner_js'); ?>
    <!-- Editor JS orders -->
    <script src="<?php echo e(asset('/assets/admin/js/lib/tinymce.min.js')); ?>"></script>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script>

        $('input[name=\'search_product\']').autocomplete({

            'source': function (request, response) {
                let target = request['term'];
                $.ajax({
                    url: url_search_product,
                    data: 'title='+target,
                    dataType: 'json',
                    type: 'get',

                    success: function (json) {
                        response($.map(json, function (item) {
                            return {
                                label:`${item['title']}` ,
                                value: item['title'],
                                id: item['id']
                            };
                        }));
                    }
                });
            }, 'select': function (e, selected) {
                var item = selected['item'];
                $('#branche-product' + item['id']).remove();
                $('#input-product').removeAttr('value');
                $('#branche-product').append('<div id="branche-product' + item['id'] + '" class="branches"><i class="fa fa-minus-circle"></i> ' + item['label'] + '<input type="hidden" name="product_ids[]" value="' + item['id'] + '" /></div>');
            }
        });
        $('#branche-product').delegate('.fa-minus-circle', 'click', function () {
            $(this).parent().remove();
        });

        function statusSelect()
        {
            let data = $('#status').val()
            if(data == '0')
            {
                $('#product_status').show();
            }
            else
            {
                $('#product_status').hide();
            }
        }
        $('#status').trigger('change');
    </script>
    <script>
        let route_prefix = "<?php echo e(url(config('lfm.prefix'))); ?>",
            url = "<?php echo e(url('/')); ?>/",
            url_search_product = "<?php echo e(route('admin.search_products')); ?>",
            currentLanguage = "<?php echo e(getCurrentLocale()); ?>",
            imagePath = "<?php echo e(asset('')); ?>";
    </script>
    <script src="<?php echo e(asset('assets/admin/js/editor.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/admin/js/lfm.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/admin/js/articles.js')); ?>"></script>
<?php $__env->stopSection(); ?>




<?php echo $__env->make('admin.layouts.container', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/omaralyomhost/public_html/made/resources/views/admin/coupons/form.blade.php ENDPATH**/ ?>