<?php echo $__env->make('admin::layouts.header', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php
use App\Models\Categories;
use App\Models\Supliers;
use App\Models\Brands;
?>
<main id="main-container">
        <!-- Hero -->
        <div class="bg-body-light">
          <div class="content content-full">
            <div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center">
              <h1 class="flex-grow-1 fs-3 fw-semibold my-2 my-sm-3">Edit Product</h1>
              <nav class="flex-shrink-0 my-2 my-sm-0 ms-sm-3" aria-label="breadcrumb">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item">Dashboard</li>
                  <li class="breadcrumb-item">Product</li>
                  <li class="breadcrumb-item active" aria-current="page">Edit Product</li>
                </ol>
              </nav>
            </div>
          </div>
        </div>
        <!-- END Hero -->

        <!-- Page Content -->
        <div class="content">
          <!-- Your Block -->
          <div class="block block-rounded">
            <div class="block-header block-header-default">
              <h3 class="block-title">Edit Product</h3>
            </div>
            <div class="block-content">
            <?php if(Session::has('success')): ?> <div class="alert alert-success mt-2 mb-2"><?php echo e(Session::get('success')); ?></div><?php endif; ?>
            <?php if(Session::has('fail')): ?> <div class="alert alert-danger mt-2 mb-2"><?php echo e(Session::get('fail')); ?></div><?php endif; ?>
            <form class="row" action="" method="POST" enctype="multipart/form-data">
            <?php echo csrf_field(); ?>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Product Name</label>
                      <input type="text" class="form-control" name="product_name" value="<?php echo e($product_details->product_name); ?>">
                      <?php if($errors->has("product_name")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('product_name')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Product Code</label>
                      <input type="text" class="form-control" name="product_code" value="<?php echo e($product_details->product_code); ?>">
                      <?php if($errors->has("product_code")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('product_code')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Parent Category</label>
                      <select class="js-select2 form-select" id="parent_category" name="parent_category" style="width: 100%;" data-placeholder="Select a category..">
                        <?php if($product_details->parent_category) { ?> 
                            <option value="<?php echo e($product_details->parent_category); ?>"><?php echo e(Categories::where('id', $product_details->parent_category)->value('category_name')); ?></option>
                        <?php } ?>
                        <option></option>
                      <?php foreach($parent_categories as $parent_category){ ?> 
                        <option value="<?php echo e($parent_category->id); ?>"><?php echo e($parent_category->category_name); ?></option>
                        <?php } ?>
                      </select>
                      <?php if($errors->has("contact_person")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('contact_person')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                    <label class="form-label">Sub Category</label>
                    <select class="js-select2 form-select" id="sub_category" name="sub_category" style="width: 100%;" data-placeholder="Select a parent category..">
                    <?php if($product_details->sub_category) { ?> 
                        <option value="<?php echo e($product_details->sub_category); ?>"><?php echo e(Categories::where('id', $product_details->sub_category)->value('category_name')); ?></option>
                    <?php } ?>
                    <option></option>
                    </select>
                      <?php if($errors->has("sub_category")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('sub_category')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                    <label class="form-label">Suplier</label>
                    <select class="js-select2 form-select" id="suplier" name="suplier" style="width: 100%;" data-placeholder="Select a suplier..">
                    <?php if($product_details->suplier) { ?> 
                        <option value="<?php echo e($product_details->suplier); ?>"><?php echo e(Supliers::where('id', $product_details->suplier)->value('suplier_name')); ?></option>
                    <?php } ?>
                    <option></option>
                    <?php foreach($supliers as $suplier){ ?> 
                        <option value="<?php echo e($suplier->id); ?>"><?php echo e($suplier->suplier_name); ?></option>
                    <?php } ?>
                    </select>
                      <?php if($errors->has("suplier")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('suplier')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Brand</label>
                      <select class="js-select2 form-select" id="brand" name="brand" style="width: 100%;" data-placeholder="Select a brand..">
                    <?php if($product_details->brand) { ?> 
                        <option value="<?php echo e($product_details->brand); ?>"><?php echo e(Brands::where('id', $product_details->brand)->value('brand_name')); ?></option>
                    <?php } ?>
                      <option></option>
                      <?php foreach($brands as $brand){ ?> 
                      <option value="<?php echo e($brand->id); ?>"><?php echo e($brand->brand_name); ?></option>
                      <?php } ?>
                    </select>
                      <?php if($errors->has("brand")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('brand')); ?></div><?php endif; ?>
                    </div>

                    <!-- <div class="col-md-3 mb-3">
                      <label class="form-label">SKU</label>
                      <input type="text" class="form-control" name="sku" value="<?php echo e($product_details->sku); ?>">
                      <?php if($errors->has("sku")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('sku')); ?></div><?php endif; ?>
                    </div> -->
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Barcode</label>
                      <input type="text" class="form-control" name="barcode" value="<?php echo e($product_details->barcode); ?>">
                      <?php if($errors->has("barcode")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('barcode')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Stock Alert Quantity</label>
                      <input type="number" class="form-control" name="stock_alert_quantity" value="<?php echo e($product_details->stock_alert_quantity); ?>">
                      <?php if($errors->has("stock_alert_quantity")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('stock_alert_quantity')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Warehouse Location</label>
                      <select class="js-select2 form-select" id="warehouse_location" name="warehouse_location" style="width: 100%;" data-placeholder="Select a warehouse..">
                    <?php if($product_details->warehouse_location) { ?> 
                        <option value="<?php echo e($product_details->warehouse_location); ?>"><?php echo e($product_details->warehouse_location); ?></option>
                    <?php } ?>
                      <option value="Default">Default</option>
                    </select>
                      <?php if($errors->has("warehouse_location")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('warehouse_location')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Units</label>
                    <select class="js-select2 form-select" id="units" name="units" style="width: 100%;" data-placeholder="Select a unit..">
                    <?php if($product_details->units) { ?> 
                        <option value="<?php echo e($product_details->units); ?>"><?php echo e($product_details->units); ?></option>
                    <?php } ?>
                      <option value="Piece (pcs)">Piece (pcs)</option>
                      <option value="Kilogram (kg)">Kilogram (kg)</option>
                      <option value="Gram (g)">Gram (g)</option>
                      <option value="Liter (L)">Liter (L)</option>
                      <option value="Milliliter (mL)">Milliliter (mL)</option>
                      <option value="Meter (m)">Meter (m)</option>
                      <option value="Centimeter (cm)">Centimeter (cm)</option>
                      <option value="Square Meter (m²)">Square Meter (m²)</option>
                      <option value="Cubic Meter (m³)">Cubic Meter (m³)</option>
                      <option value="Dozen (doz)">Dozen (doz)</option>
                      <option value="Box (box)">Box (box)</option>
                      <option value="Pack (pack)">Pack (pack)</option>
                      <option value="Case (case)">Case (case)</option>
                      <option value="Pair (pair)">Pair (pair)</option>
                      <option value="Roll (roll)">Roll (roll)</option>
                      <option value="Set (set)">Set (set)</option>
                      <option value="Bottle (btl)">Bottle (btl)</option>
                       <option value="Jar (jar)">Jar (jar)</option>
                    </select>
         
                      <?php if($errors->has("units")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('units')); ?></div><?php endif; ?>
                    </div>
                    <!-- <div class="col-md-3 mb-3">
                      <label class="form-label">Carton Size</label>
                      <input type="text" class="form-control" name="carton_size" value="<?php echo e($product_details->carton_size); ?>">
                      <?php if($errors->has("carton_size")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('carton_size')); ?></div><?php endif; ?>
                    </div> -->
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Featured Image</label>
                      <input type="file" class="form-control" name="featured_image" >
                      <?php if($errors->has("featured_image")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('featured_image')); ?></div><?php endif; ?>
                    </div>
                    <!-- <div class="col-md-12 mb-3">
                      <label class="form-label">Gallery Images</label>
                      <input type="file" class="form-control" name="gallery_images[]" multiple>
                      <?php if($errors->has("gallery_images")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('gallery_images')); ?></div><?php endif; ?>
                      <div class="row items-push js-gallery mt-4">
                        <?php foreach($product_gallery as $product_gal){ ?>
                                <div class="col-md-3 animated fadeIn">
                                    <div class="options-container fx-item-zoom-in fx-overlay-zoom-out">
                                        <img class="img-fluid options-item" src="<?php echo e(asset('db_files/product_images/'.$product_gal->image.'')); ?>" alt="">
                                        <div class="options-overlay bg-black-75">
                                        <div class="options-overlay-content">
                                            <a class="btn btn-sm btn-danger" href="<?php echo e(url('admin/delete-gallery-image/'.$product_gal->id)); ?>">
                                            <i class="fa fa-trash-can opacity-50 me-1"></i> Delete
                                            </a>
                                        </div>
                                        </div>
                                </div>
                                </div>
                        <?php } ?>
                    </div>
                    </div> -->
                    <div class="col-md-12 mb-3">
                      <label class="form-label">Description</label>
                      <textarea class="js-simplemde" id="description" name="description"><?php echo $product_details->description ?></textarea>
                      <?php if($errors->has("description")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('description')); ?></div><?php endif; ?>
                    </div>
                    <div>
                      <button type="submit" class="btn btn-primary">Save</button>
                    </div>
                  </form>
            </div>
          </div>
          <!-- END Your Block -->
        </div>
        <!-- END Page Content -->
</main>
<!-- END Main Container -->
<?php echo $__env->make('admin::layouts.footer', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<script>
    $(document).ready(function() {
        $('#parent_category').change(function() {
            var parentId = $(this).val();
            $('#sub_category').empty();
            if (parentId) {
                $.ajax({
                    url: '<?php echo e(url('admin/get-sub-categories')); ?>/' + parentId,
                    type: 'GET',
                    dataType: 'json',
                    success: function(data) {
                        $.each(data, function(key, value) {
                            $('#sub_category').append('<option value="'+ value.id +'">'+ value.category_name +'</option>');
                        });
                    }
                });
            } else {
                $('#sub_category').append('<option value="">Select a sub category..</option>');
            }
        });
    });
</script>






<?php /**PATH /home/u446954234/domains/orionerp.xyz/public_html/napaskitchen/Modules/Admin/resources/views/product/edit_product.blade.php ENDPATH**/ ?>