<?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>
        <li class="nav-item">
            <a href="#section_attributes" 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.sizes')); ?></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 <?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="form-group col-lg-12 image_container" >
                        <label><?php echo e(meta('image', getCurrentLocale()) ?? __('products.image')); ?> </label>
                        <input id="image_thumbnail" class="image_thumbnail" type="hidden" name="image" value="<?php echo e(old("image", $product->image ?? "")); ?>"/>

                        <div class="photos main_photo <?php echo e(old('image', $product->image ?? '') ? ' wow fadeInUp' : 'hide'); ?>">
                            <div class="col-md-4">
                                <div class="items">
                                    <div class="img">
                                        <a href="#" id="lfm" data-input=".image_thumbnail" data-preview=".image_holder" class="lfm" data-hide=".pick_button">
                                            <img src="<?php echo e(asset(old('image', $product->image ?? ''))); ?> "  id="image_holder" class="image_holder"/>
                                        </a>
                                    </div>
                                    <a href="#" class="showHide resetImage close" data-empty=".image_thumbnail" data-hide=".main_photo" data-show=".pick_button"><i class="fas fa-times"></i></a>
                                </div>
                            </div>
                        </div>

                        <div class="clearfix"></div>
                        <span class="input-group-btn pick_button <?php echo e(old('image', $product->image ?? '') ? 'hide' : ''); ?> ">
                <a id="lfm"  data-input=".image_thumbnail" data-preview=".image_holder" data-show=".main_photo" data-hide=".pick_button" class="lfm btn btn-primary text-light">
                    <i class="fas fa-camera-retro"></i> <?php echo e(__('dashboard.choose')); ?>

                </a>
             </span>
                    </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>
                                        <?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 class="pricing-list-item col-lg-12 mb-4 " id="item<?php echo e($key); ?>"  style="background-color: white;height:auto;padding: 20px">
                                            <?php $__currentLoopData = $row->items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $keyItem=>$rowItem): $__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); ?>_item_<?php echo e($keyItem); ?>_title_<?php echo e($language->local); ?>"  name="items[<?php echo e($key); ?>][item][<?php echo e($keyItem); ?>][title_<?php echo e($language->local); ?>]" placeholder="<?php echo e(__('products.title')); ?> <?php echo e($language->local); ?>" value="<?php echo e($rowItem->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); ?>_item_<?php echo e($keyItem); ?>_description_<?php echo e($language->local); ?>"  name="items[<?php echo e($key); ?>][item][<?php echo e($keyItem); ?>][description_<?php echo e($language->local); ?>]" placeholder="<?php echo e(__('products.description')); ?> <?php echo e($language->local); ?>" value="<?php echo e($rowItem->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(); ?>
                                        </div>
                                        <a style="cursor: pointer;"  data-id="<?php echo e(count($row->items)); ?>" key-id="<?php echo e($key); ?>" onclick="additemKey(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i><?php echo e(__("products.add_new")); ?></a>
                                </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 class="tab-pane col-lg-12" id="section_attributes">
                <div class="row">
                    <div class="col-lg-12">
                        <h3> <?php echo e(__('products.sizes')); ?> </h3>
                    </div>
                    <div class="col-lg-12" id="sizes">
                        <?php if($product ?? ''  && $product->id): ?>

                            <?php $__currentLoopData = $sizeItems; $__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">
                                    <div class="form-group col-lg-8">
                                        <label><?php echo e(__('products.size')); ?>  </label>
                                        <select class="form-control" id="sizes_<?php echo e($key); ?>_size"  name="sizes[<?php echo e($key); ?>][size_id]" placeholder="<?php echo e(__('products.size')); ?>">
                                            <option value=""><?php echo e(__('web.select')); ?></option>
                                            <?php $__currentLoopData = $sizes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $size): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <option <?php echo e($size->id == $row->attribute_id ? 'selected' : ''); ?> value="<?php echo e($size->id); ?>"><?php echo e($size->title); ?></option>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </select>
                                    </div>
                                    <div class="form-group col-lg-4" style="font-size: 30px;margin-top:35px;">
                                        <i class="fas fa-times-circle" onclick="remove(this)"></i>
                                    </div>
                                    <div class="pricing-list-item col-lg-12 mb-4 " id="size<?php echo e($key); ?>"  style="background-color: white;height:auto;padding: 20px">
                                        <?php $__currentLoopData = $row->sub; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $keyItem=>$sub): $__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">
                                                <div class="form-group col-lg-5">
                                                    <label><?php echo e(__('products.color')); ?>  </label>
                                                    <select class="form-control" id="sizes_<?php echo e($key); ?>_colors_<?php echo e($keyItem); ?>_color_id"  name="sizes[<?php echo e($key); ?>][colors][<?php echo e($keyItem); ?>][color_id]" placeholder="<?php echo e(__('products.color')); ?>">
                                                        <option value=""><?php echo e(__('web.select')); ?></option>
                                                        <?php $__currentLoopData = $colors; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $color): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                            <option <?php echo e($color->id == $sub->attribute_id ? 'selected' : ''); ?> value="<?php echo e($color->id); ?>"><?php echo e($color->title); ?></option>
                                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                    </select>
                                                </div>
                                                <div class="form-group col-lg-5">
                                                    <label><?php echo e(__('products.count')); ?>  </label>
                                                    <input type="number" class="form-control" id="sizes_<?php echo e($key); ?>_colors_<?php echo e($keyItem); ?>_count" name="sizes[<?php echo e($key); ?>][colors][<?php echo e($keyItem); ?>][count]" placeholder="<?php echo e(__('products.count')); ?>" value="<?php echo e($sub->count); ?>">
                                                </div>
                                                <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(); ?>
                                    </div>
                                    <a style="cursor: pointer;" data-id="<?php echo e(count($row->sub)); ?>" key-id="<?php echo e($key); ?>" onclick="addcolor(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i><?php echo e(__("products.add_new")); ?></a>
                                </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($sizes)); ?>" <?php else: ?> data-id="0" <?php endif; ?> onclick="addsize(this)" class="btn_1 gray "><i class="fa fa-fw fa-plus-circle"></i><?php echo e(__("products.add_size")); ?></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 addsize(elem)
        {
            var num = $(elem).attr('data-id');
            var newrow = parseInt(num)+1;
            $(elem).attr('data-id', newrow);

            $.ajax({
                url : url_size,
                type : 'GET',
                data : 'key='+num,
                success:function(data)
                {
                    $('#sizes').append(data);
                }
            })
        }

        function addcolor(elem)
        {
            var num = $(elem).attr('data-id');
            var key = $(elem).attr('key-id');
            var newrow = parseInt(num)+1;
            $(elem).attr('data-id', newrow);

            $.ajax({
                url : url_color,
                type : 'GET',
                data : 'keyItem='+num+"&key="+key,
                success:function(data)
                {
                    $('#size'+key).append(data);
                }
            })
        }
        function additemKey(elem)
        {
            var num = $(elem).attr('data-id');
            var key = $(elem).attr('key-id');
            var newrow = parseInt(num)+1;
            $(elem).attr('data-id', newrow);

            $.ajax({
                url : url_item_key,
                type : 'GET',
                data : 'keyItem='+num+"&key="+key,
                success:function(data)
                {
                    $('#item'+key).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_size = "<?php echo e(route('admin.size')); ?>",
            url_color = "<?php echo e(route('admin.color')); ?>",
            url_item = "<?php echo e(route('admin.item')); ?>",
            url_item_key = "<?php echo e(route('admin.item.key')); ?>",
            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 /home/omaralyomhost/public_html/rose/resources/views/admin/products/form.blade.php ENDPATH**/ ?>