<?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">Add 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">Add 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">Add 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(old('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(old('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(old('parent_category')) { ?> 
                            <option value="<?php echo e(old('parent_category')); ?>"><?php echo e(Categories::where('id', old('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("parent_category")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('parent_category')); ?></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(old('sub_category')) { ?> 
                        <option value="<?php echo e(old('sub_category')); ?>"><?php echo e(Categories::where('id', old('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(old('suplier')) { ?> 
                        <option value="<?php echo e(old('suplier')); ?>"><?php echo e(Supliers::where('id', old('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(old('brand')) { ?> 
                        <option value="<?php echo e(old('brand')); ?>"><?php echo e(Brands::where('id', old('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">Wholesale Purchase Price</label>
                      <input type="number" class="form-control" name="wholesale_purchase_price" value="<?php echo e(old('wholesale_purchase_price')); ?>">
                      <?php if($errors->has("wholesale_purchase_price")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('wholesale_purchase_price')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Wholesale Selling Price</label>
                      <input type="number" class="form-control" name="wholesale_selling_price" value="<?php echo e(old('wholesale_selling_price')); ?>">
                      <?php if($errors->has("wholesale_selling_price")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('wholesale_selling_price')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Retail Purchase Price</label>
                      <input type="number" class="form-control" name="retail_purchase_price" value="<?php echo e(old('retail_purchase_price')); ?>">
                      <?php if($errors->has("retail_purchase_price")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('retail_purchase_price')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Retail Selling Price</label>
                      <input type="number" class="form-control" name="retail_selling_price" value="<?php echo e(old('retail_selling_price')); ?>">
                      <?php if($errors->has("retail_selling_price")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('retail_selling_price')); ?></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(old('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(old('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(old('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">Minimum Stock Level</label>
                      <input type="text" class="form-control" name="min_stock" value="<?php echo e(old('min_stock')); ?>">
                      <?php if($errors->has("min_stock")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('min_stock')); ?></div><?php endif; ?>
                    </div>
                    <div class="col-md-3 mb-3">
                      <label class="form-label">Max Stock Level</label>
                      <input type="text" class="form-control" name="max_stock" value="<?php echo e(old('max_stock')); ?>">
                      <?php if($errors->has("max_stock")): ?> <div class="alert alert-danger mt-2"><?php echo e($errors->first('max_stock')); ?></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(old('warehouse_location')) { ?> 
                        <option value="<?php echo e(old('warehouse_location')); ?>"><?php echo e(old('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(old('units')) { ?> 
                        <option value="<?php echo e(old('units')); ?>"><?php echo e(old('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(old('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-3 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> -->
                    <div class="col-md-12 mb-3">
                      <label class="form-label">Description</label>
                      <textarea class="js-simplemde" id="description" name="description"><?php echo old('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-success mt-4">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/demo/Modules/Admin/resources/views/product/add_product.blade.php ENDPATH**/ ?>