<?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" action="<?php echo e($action); ?>" enctype="multipart/form-data">

            <?php if($seller ?? ''  && $seller->id): ?>
                <?php echo method_field('PUT'); ?>
            <?php endif; ?>
            <?php echo csrf_field(); ?>
            <div class="form-group col-lg-6">
                <label><?php echo e(meta('seller_id', getCurrentLocale()) ?? __('sellers.seller_id')); ?></label>
                <select class="form-control <?php echo e($errors->has('seller_id') ? 'is-invalid' : ''); ?>" name="seller_id">
                    <option value=""><?php echo e(__('dashboard.select')); ?></option>
                    <?php $__currentLoopData = $sellers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                        <option <?php echo e((isset($seller) ? $seller->seller_id : '') == $row->id ? 'selected' : ''); ?> value="<?php echo e($row->id); ?>"><?php echo e($row->name); ?></option>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </select>
            </div>
            <div class="form-group col-lg-6">
                <label><?php echo e(meta('code', getCurrentLocale()) ?? __('sellers.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()) ?? __('sellers.code')); ?>" value='<?php echo e(old("code", $seller->code ?? "")); ?>'/>
            </div>
            <div class="form-group col-lg-6">
                <label><?php echo e(meta('count', getCurrentLocale()) ?? __('sellers.count')); ?></label>
                <input type="number" min="0" class="form-control  <?php echo e($errors->has('count') ? 'is-invalid' : ''); ?>" name="count" placeholder="<?php echo e(meta('count', getCurrentLocale()) ?? __('sellers.count')); ?>" value='<?php echo e(old("count", $seller->count ?? "")); ?>'/>
            </div>

            <div class="form-group col-lg-6">
                <label><?php echo e(meta('status', getCurrentLocale()) ?? __('sellers.status')); ?></label>
                <select onchange="statusSelect(this)" class="form-control <?php echo e($errors->has('status') ? 'is-invalid' : ''); ?>" name="status">
                    <option <?php if($seller ?? ''  && $seller->id): ?> <?php if($seller->status == 'all'): ?> selected <?php endif; ?> <?php endif; ?> value="all"><?php echo e(__('sellers.all')); ?></option>
                    <option <?php if($seller ?? ''  && $seller->id): ?> <?php if($seller->status == 'specific'): ?> selected <?php endif; ?> <?php endif; ?> value="specific"><?php echo e(__('sellers.specific')); ?></option>
                </select>
            </div>
            <div class="form-group col-lg-6">
                <label><?php echo e(meta('discount_type', getCurrentLocale()) ?? __('sellers.discount_type')); ?></label>
                <select onchange="typeSelect(this)" class="form-control <?php echo e($errors->has('discount_type') ? 'is-invalid' : ''); ?>" name="discount_type">
                    <option <?php if($seller ?? ''  && $seller->id): ?> <?php if($seller->discount_type == '1'): ?> selected <?php endif; ?> <?php endif; ?> value="1"><?php echo e(__('sellers.value')); ?></option>
                    <option <?php if($seller ?? ''  && $seller->id): ?> <?php if($seller->discount_type == '2'): ?> selected <?php endif; ?> <?php endif; ?>  value="2"><?php echo e(__('sellers.percentage')); ?></option>
                </select>
            </div>
            <div class="form-group col-lg-6">
                <label><?php echo e(meta('discount_amount', getCurrentLocale()) ?? __('sellers.discount_amount')); ?></label>
                <input type="number"  class="form-control  <?php echo e($errors->has('discount_amount') ? 'is-invalid' : ''); ?>" name="discount_amount" placeholder="<?php echo e(meta('discount_amount', getCurrentLocale()) ?? __('sellers.discount_amount')); ?>" value='<?php echo e(old("discount_amount", $seller->discount_amount ?? "")); ?>'/>
            </div>

            <?php $__currentLoopData = $languages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $language): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <div class="form-group col-lg-6">
                    <label><?php echo e(meta('name', $language->local) ?? __('sellers.name')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?> </label>
                    <input type="text" class="form-control <?php echo e($errors->has('name_'.$language->local) ? 'is-invalid' : ''); ?>" name="name_<?php echo e($language->local); ?>" placeholder="<?php echo e(meta('name', $language->local) ?? __('sellers.name')); ?>" value='<?php echo e(old("name_{$language->local}", $seller[$language->local]->name ?? "")); ?>'/>
                </div>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

            <div class="form-group col-lg-6">
                <label><?php echo e(meta('start_date', getCurrentLocale()) ?? __('sellers.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(meta('start_date', getCurrentLocale()) ?? __('sellers.start_date')); ?>" value='<?php echo e(old("start_date", $seller->start_date ?? "")); ?>'/>
            </div>
            <div class="form-group col-lg-6">
                <label><?php echo e(meta('end_date', getCurrentLocale()) ?? __('sellers.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(meta('end_date', getCurrentLocale()) ?? __('sellers.end_date')); ?>" value='<?php echo e(old("end_date", $seller->end_date ?? "")); ?>'/>
            </div>
                <div class="col-md-12 mb-4" id="users" <?php if($seller ?? '' && $seller->id): ?> <?php if($seller->status == 'all'): ?> style="display: none" <?php endif; ?>  <?php else: ?> style="display: none" <?php endif; ?>>
                    <label for="validationServer"><?php echo e(__('sellers.user')); ?></label>
                    <input type="text" name="search_user" value="" placeholder="<?php echo e(__('sellers.product')); ?>" id="input-product" class="form-control usersBox" />
                    <div id="branche-user" class="well well-sm usersBox form-control" style="height: 150px; overflow: auto;">
                        <?php if($seller ?? '' && $seller->id): ?>
                            <?php $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <div id="branche-user<?php echo e($row->user_id); ?>" class="branches"><i class="fa fa-minus-circle"></i> <?php echo e($row->name); ?><input type="hidden" name="user_ids[]" value="<?php echo e($row->id); ?>"></div>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php endif; ?>
                    </div>
                </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 files -->
    
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <script src="//cdn.tinymce.com/4/tinymce.min.js"></script>

    <script>
        let url_search_user = "<?php echo e(url('')); ?>/admin/cobons/user"
    </script>
    <script>
        function statusSelect(elem)
        {
            let data = $(elem).val()
            if(data == 'all')
            {
                $('#users').css('display','none');
            }
            else
            {
                $('#users').css('display','block');
            }
        }
    </script>
    <script>

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

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

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

        $('#branche-user').delegate('.fa-minus-circle', 'click', function () {
            $(this).parent().remove();
        });
    </script>

    <script>
        let route_prefix = "<?php echo e(url(config('lfm.prefix'))); ?>",
            url = "<?php echo e(url('/')); ?>/",
            url_type = <?php echo json_encode(url(getCurrentLocale().'/admin/type/')); ?>,
            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>
    <script src="<?php echo e(asset('assets/admin/js/sellers.js')); ?>"></script>
<?php $__env->stopSection(); ?>




<?php echo $__env->make('admin.layouts.container', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /Applications/MAMP/htdocs/city/resources/views/admin/sellers/form.blade.php ENDPATH**/ ?>