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



<div class="border-item">
    <ul class="nav nav-pills bg-nav-pills nav-justified mb-3">
        <li class="nav-item">
            <a href="#main" data-toggle="tab" aria-expanded="false" class="nav-link rounded-0 active">
                <i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i>
                <span class="d-none d-lg-block"><?php echo e(__('products.details')); ?></span>
            </a>
        </li>
        <li class="nav-item">
            <a href="#section_items" data-toggle="tab" aria-expanded="false" class="nav-link rounded-0">
                <i class="mdi mdi-home-variant d-lg-none d-block mr-1"></i>
                <span class="d-none d-lg-block"><?php echo e(__('products.items')); ?></span>
            </a>
        </li>

    </ul>
    <form class="form-row" method="post" onsubmit="saveForm(this)" action="<?php echo e($action); ?>" enctype="multipart/form-data">
        <?php if($product ?? ''  && $product->id): ?>
            <?php echo method_field('PUT'); ?>
        <?php endif; ?>
        <?php echo csrf_field(); ?>
        <div class="tab-content row col-12">
            <div class="tab-pane col-lg-12 active" id="main">
                <div class="form-row">


                    <div class="form-group col-lg-6">
                        <label><?php echo e(meta('status_sold', getCurrentLocale()) ?? __('products.status_sold')); ?> </label>
                        <select id="status_sold" class="form-control <?php echo e($errors->has('status_sold') ? 'is-invalid' : ''); ?>" name="status_sold" >
                            <?php $__currentLoopData = $statuses; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option <?php if((isset($product) ? $product->status_sold : "") == $row ): ?> selected <?php endif; ?> value="<?php echo e($row); ?>"><?php echo e(__('products.statuses.'.$row)); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div class="form-group col-lg-6">
                        <label><?php echo e(__('products.category_id')); ?> </label>
                        <select onchange="categorySelect(this)" id="category_id" class="form-control <?php echo e($errors->has('category_id') ? 'is-invalid' : ''); ?>" name="category_id">
                            <option value=""><?php echo e(__('dashboard.select')); ?></option>
                            <?php $__currentLoopData = $categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option <?php echo e((isset($product) ? $product->category_id : null) == $row->id ? 'selected' : ''); ?> value="<?php echo e($row->id); ?>"><?php echo e($row->title); ?></option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                    <div class="form-group col-lg-6">
                        <label><?php echo e(__('products.sub_category_id')); ?> </label>
                        <select id="sub_category_id" class="form-control <?php echo e($errors->has('sub_category_id') ? 'is-invalid' : ''); ?>" name="sub_category_id">
                            <option value=""><?php echo e(__('dashboard.select')); ?></option>
                            <?php if(isset($sub_categories)): ?>
                                <?php $__currentLoopData = $sub_categories; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <option <?php echo e((isset($product) ? $product->sub_category_id : null) == $row->id ? 'selected' : ''); ?> value="<?php echo e($row->id); ?>"><?php echo e($row->title); ?></option>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php endif; ?>
                        </select>
                    </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('title', $language->local) ?? __('products.title')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?> </label>
                            <input type="text" class="form-control <?php echo e($errors->has('title_'.$language->local) ? 'is-invalid' : ''); ?>" name="title_<?php echo e($language->local); ?>" placeholder="<?php echo e(meta('title', $language->local) ?? __('products.title')); ?>" value='<?php echo e(old("title_{$language->local}", $product[$language->local]->title ?? "")); ?>'/>
                        </div>
                        <div class="form-group col-lg-12">
                            <label><?php echo e(meta('description', $language->local) ?? __('products.description')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?> </label>
                            <textarea  class="form-control my-editor<?php echo e($errors->has('description_'.$language->local) ? 'is-invalid' : ''); ?>" name="description_<?php echo e($language->local); ?>" placeholder="<?php echo e(meta('description', $language->local) ?? __('products.description')); ?>"><?php echo e(old("description_{$language->local}", $product[$language->local]->description ?? "")); ?></textarea>
                        </div>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


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

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

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

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


                    <div class="border-item photos col-md-12 other_image_container">
                        <div class="row">
                            <?php if($product ?? false): ?>
                                <?php $__currentLoopData = $product['photos']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $photo): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <div class="col-md-4">
                                        <div class="items">
                                            <div class="img">
                                                <a href="<?php echo e(asset($photo->image ?? '')); ?>" data-fancybox="gallery"><img src="<?php echo e(asset($photo->image ?? '')); ?>" alt=""></a>
                                            </div>
                                            <input type="hidden" name="images[]" value="<?php echo e($photo->image ?? ""); ?>">
                                            <a href="#" onclick="DeleteImg(this)" class="close"><i class="fas fa-times"></i></a>
                                        </div>
                                    </div>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php endif; ?>
                        </div>
                        <div class="text-center">
                            <input id="other_image_thumbnail" class="other_image_thumbnail" type="hidden"/>
                            <div class="clearfix"></div>
                            <span id="add">
                                <a id="lfm" data-width="" data-cache="article_gallery" data-input=".other_image_thumbnail" data-preview="" data-show="" data-hide="" class="lfm add">
                                    Add New Item
                                </a>
                            </span>
                        </div>
                    </div>

                </div>

            </div>
            <div class="tab-pane col-lg-12" id="section_items">
                <div class="row">
                    <div class="col-lg-12">
                        <h3> <?php echo e(__('products.items')); ?> </h3>
                    </div>
                    <div class="col-lg-12" id="items">
                        <?php if($product ?? ''  && $product->id): ?>
                            <?php $__currentLoopData = $items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <div class="row pricing-list-item  mb-4 "  style="background-color: rgba(21,97,203,0.1);height:auto;padding: 20px">
                                        <?php $__currentLoopData = $languages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $language): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <div class="form-group col-lg-5">
                                                <label><?php echo e(__('products.title')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?> </label>
                                                <input type="text" class="form-control" id="items_<?php echo e($key); ?>_title_<?php echo e($language->local); ?>"  name="items[<?php echo e($key); ?>][title_<?php echo e($language->local); ?>]" placeholder="<?php echo e(__('products.title')); ?> <?php echo e($language->local); ?>" value="<?php echo e($row->descriptions($language->id)->title); ?>"/>
                                            </div>
                                            <div class="form-group col-lg-5">
                                                <label><?php echo e(__('products.description')); ?> <?php echo e(count($languages) > 1 ? "({$language->name})" : ''); ?> </label>
                                                <input type="text" class="form-control" id="items_<?php echo e($key); ?>_description_<?php echo e($language->local); ?>"  name="items[<?php echo e($key); ?>][description_<?php echo e($language->local); ?>]" placeholder="<?php echo e(__('products.description')); ?> <?php echo e($language->local); ?>" value="<?php echo e($row->descriptions($language->id)->description); ?>"/>
                                            </div>

                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        <div class="form-group col-lg-2" style="font-size: 30px;margin-top:35px;">
                                            <i class="fas fa-times-circle" onclick="remove(this)"></i>
                                        </div>
                                </div>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        <?php endif; ?>
                    </div>
                    <div class="col-lg-12">
                        <a style="cursor: pointer;" <?php if($product ?? ''  && $product->id): ?> data-id="<?php echo e(count($items)); ?>" <?php else: ?> data-id="0" <?php endif; ?> onclick="additem(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i><?php echo e(__("products.add_new")); ?></a>
                    </div>
                </div>
            </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 orders -->
    
    <script src="<?php echo e(asset('/assets/admin/js/lib/tinymce.min.js')); ?>"></script>


















    <script>
        function DeleteImg(elem)
        {
            $(elem).closest('.col-md-4').remove();
        }
    </script>
    <script>
        function categorySelect(elem)
        {
            let category_id = $(elem).val()
            $.ajax({
                url : url_model,
                type : 'GET',
                data : 'category_id='+category_id,
                success:function(data)
                {
                    $('#sub_category_id').html(data);
                }
            })
        }
        function additem(elem)
        {
            var num = $(elem).attr('data-id');
            var newrow = parseInt(num)+1;
            $(elem).attr('data-id', newrow);

            $.ajax({
                url : url_item,
                type : 'GET',
                data : 'key='+num,
                success:function(data)
                {
                    $('#items').append(data);
                }
            })
        }
        function remove(elem)
        {
            $(elem).closest('.row').remove();
        }
    </script>
    <script>
        let route_prefix = "<?php echo e(url(config('lfm.prefix'))); ?>",
            url = "<?php echo e(url('/')); ?>/",
            url_item = "<?php echo e(route('admin.item')); ?>",
            url_model = "<?php echo e(route('admin.model')); ?>",
            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>
<?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/modern/resources/views/admin/products/form.blade.php ENDPATH**/ ?>