
<?php $__env->startSection('title'); ?>
Product 
<?php $__env->stopSection(); ?>
<?php $__env->startSection('product'); ?>
 menu-item-active
<?php $__env->stopSection(); ?>
<?php $__env->startSection('css'); ?>
<link rel="stylesheet" href="http://cdn.bootcss.com/toastr.js/latest/css/toastr.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css">
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.css" rel="stylesheet">

<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
<div class="content d-flex flex-column flex-column-fluid" id="kt_content">
    <!--begin::Subheader-->
    <div class="subheader py-2 py-lg-4 subheader-solid" id="kt_subheader">
        <div class="container-fluid d-flex align-items-center justify-content-between flex-wrap flex-sm-nowrap">
            <!--begin::Info-->
            <div class="d-flex align-items-center flex-wrap mr-2">
                <!--begin::Page Title-->
                <h5 class="text-dark font-weight-bold mt-2 mb-2 mr-5">Dashboard</h5>
                <!--end::Page Title-->
                <!--begin::Actions-->
                <div class="subheader-separator subheader-separator-ver mt-2 mb-2 mr-4 bg-gray-200"></div>
                <h6 class="text-dark font-weight-bold mt-2 mb-2 mr-5">Product</h6>
                <!--end::Actions-->
            </div>
            <!--end::Info-->
        </div>
    </div>
    <!--end::Subheader-->
    <!--begin::Entry-->
    <div class="d-flex flex-column-fluid">
        <!--begin::Container-->
        <div class="container">
            <!--begin::Dashboard-->
            <!--begin::Row-->
            <div class="row">
                <div class="col-lg-12">
                    <div class="card card-custom">
					 	<div class="card-header">
						    <div class="card-title">
						   		<h3 class="card-label">All Product List</h3>
						    </div>

						    <div class="card-toolbar">
							   	<ul class="nav nav-bold nav-pills ml-auto">
								    <li class="nav-item">
								    	 <!-- Add Logo-->
					                    <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalLong">
					                        <i class="flaticon2-plus-1 icon-lg"></i> Add New Product
					                    </button>

					                    <!-- Modal-->
					                    <div class="modal fade" id="exampleModalLong" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="staticBackdrop" aria-hidden="true">
					                        <div class="modal-dialog modal-lg" role="document">
					                            <div class="modal-content">
					                                <div class="modal-header">
					                                    <h5 class="modal-title" id="exampleModalLabel">Create New Product</h5>
					                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
					                                        <i aria-hidden="true" class="ki ki-close"></i>
					                                    </button>
					                                </div>
					                                <div class="modal-body">
					                                   	<form action="<?php echo e(url('admin/post/product')); ?>" method="POST" enctype="multipart/form-data">
					                                   		<?php echo csrf_field(); ?>
					                           
											  	<div class="form-group row">
													   	<div class="col-lg-4">
														   <label>Category Name:</label><br>
															
															<select id="country" name=category_id  class="form-control">
														        <option value="" selected disabled>Select</option>
														         <?php $__currentLoopData = $all_category; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
															    <option value="<?php echo e($category->id); ?>"><?php echo e($category->category_name); ?></option>
															    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
													         </select>
													   	</div>
													   <div class="col-lg-4" style="display: none;">
														    <label for="title">Sub-Category Name:</label>
													        <select name=subcategory_id id="state" class="form-control">
													        </select>
													   </div>
													   <div class="col-lg-4" style="display: none;">
														    <label for="title">Child-Category Name:</label>
														    <select name=childcategory_id id="city" class="form-control">
        													</select>
													   </div>
												</div>
											  	<div class="form-group row">
													   	<div class="col-lg-8">
														   <label>Product Name</label>
														   <input type="text" name="product_name" class="form-control form-control-solid"/>
														   <span class="form-text text-muted">Please enter your Product Name</span>
													   	</div>
													   <div class="col-lg-4">
														    <label>Price:</label>
														   <input type="text" class="form-control form-control-solid" name="price" />
														   <span class="form-text text-muted">Please enter your Price</span>
													   </div>
												</div>
					                            <div class="form-group">
														<label>Product Photo Browser</label>
														<div></div>
														<div class="custom-file">
															<input type="file" class="custom-file-input" id="customFile" name="image" id="profile-img" onchange="preview_image(event)"/>
															<label class="custom-file-label" for="customFile">Choose file</label>
															<img src="" id="output_image" width="200px" style="padding-top: 5px;" />
														</div>
														<?php $__errorArgs = ['image'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
													   <div class="alert alert-danger">
													   		<strong><?php echo e($mesage); ?></strong>
													   </div>
													   <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
												</div>
												<div class="form-group">
										  			 <label>Description</label>
				                					<textarea id="summernote" name="description"></textarea>
										  		</div>
													
												<div class="form-group" style="text-align:end;">
													<button type="button" class="btn btn-light-primary font-weight-bold" data-dismiss="modal">Close</button>
		                                    		<button type="submit" class="btn btn-primary font-weight-bold">Submit</button>
												</div>
														</form>
					                                </div>
					                            		
					                            </div>
					                        </div>
					                    </div>
								    </li>
							   </ul>
							</div>
						</div>
						<div class="card-body">
						  	<!--begin: Search Form-->
										<!--begin: Datatable-->
										<table id="usertable" class="table table-bordered table-striped">
											<thead>
												<tr>
													<th>SL No.</th>
													<th>Category</th>
													<th>Name</th>
													<th>Price</th>
													<th>Photo</th>
													<th>Status</th>
													<th>Action</th>
												</tr>
											</thead>
											<tbody>
												<?php
													$i = 1;
												?>
											<?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
												<tr>
													<td><?php echo e($i++); ?></td>
													<td><?php echo e($product->connect_category->category_name??'Null'); ?></td>
													<td><?php echo e($product->product_name??'Null'); ?></td>
													<td><?php echo e($product->price??'Null'); ?>&#2547;</td>
													<td><img src="<?php echo e(asset('uploads/product')); ?>/<?php echo e($product->image); ?>" alt="" width="80px;"></td>
													<td>
														<?php if($product->status == 1): ?>
														<a href="#statusModal<?php echo e($product->id); ?>" data-toggle="modal" class="btn btn-danger"  ><i class="fas fa-toggle-off icon-md"></i>Deactive
					                                    </a>
														<?php else: ?>
														<a href="#statusModal<?php echo e($product->id); ?>" data-toggle="modal" class="btn btn-success"  ><i class="fas fa-toggle-on icon-md"></i></i> Active
					                                    </a>
														<?php endif; ?>
													</td>
													<td>
					                                    <div class="dropdown">
														    <button class="btn btn-dark dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
														        Action
														    </button>
														    <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
														    	<a class="dropdown-item text-warning" href="#showModal<?php echo e($product->id); ?>" data-toggle="modal"><i class="flaticon-eye icon-lg"></i>&nbsp;&nbsp;Show
							                                    </a>
														        <a class="dropdown-item text-warning" href="#editModal<?php echo e($product->id); ?>" data-toggle="modal"><i class="flaticon2-edit icon-lg"></i>&nbsp;&nbsp;Edit
							                                    </a>
							                                    <a class="dropdown-item text-danger" href="#deleteModal<?php echo e($product->id); ?>" data-toggle="modal"><i class="flaticon2-rubbish-bin-delete-button icon-lg"></i> &nbsp;&nbsp;Delete
						                                    	</a>
														    </div>
														</div>
													</td>
											</tr>
<!-- Status Update -->
<div class="modal fade" id="statusModal<?php echo e($product->id); ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-primary">

            </div>
            <div class="modal-body m-auto">
                <h5 class="modal-title" id="exampleModalLongTitle">Are You Sure for Change Status?</h5>
            </div>
            <div class="modal-footer">
            	<?php if($product->status==1): ?>
                <a href="<?php echo e(url('admin/product/status')); ?>/<?php echo e($product->id); ?>" class="btn btn-danger">Active</a>
                <?php else: ?>
                <a href="<?php echo e(url('admin/product/status')); ?>/<?php echo e($product->id); ?>" class="btn btn-danger">Deactive</a>
                <?php endif; ?>
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
            </div>
        </div>
    </div>
</div>
<!-- Delete -->
<div class="modal fade" id="deleteModal<?php echo e($product->id); ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-primary">

            </div>
            <div class="modal-body m-auto">
                <h5 class="modal-title" id="exampleModalLongTitle">Are you sure you want to delete ?</h5>
            </div>
            <div class="modal-footer">
                <a href="<?php echo e(url('admin/product/delete')); ?>/<?php echo e($product->id); ?>" class="btn btn-danger">Delete</a>
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
            </div>
        </div>
    </div>
</div>

<!-- Edit -->
<div class="modal fade " id="editModal<?php echo e($product->id); ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-primary">
                <h5 class="modal-title" id="exampleModalLongTitle">Are you sure you want to Edit ?</h5>
                <button type="button" class="btn btn-warning" data-dismiss="modal"><i class="fas fa-times"></i></button>
            </div>
            <div class="modal-body">
              	<form action="<?php echo e(url('admin/update/product')); ?>" method="POST" enctype="multipart/form-data">
			                                   		<?php echo csrf_field(); ?>
			                           
									  	<div class="form-group row">
											   	<div class="col-lg-4">
												   <label>Category Name:</label><br>
													
													<select id="category_id" name=category_id  class="form-control">
												        <option value="" selected disabled>Select</option>
												         <?php $__currentLoopData = $all_category; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $category): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
													    <option value="<?php echo e($category->id); ?>" <?php echo e($product->category_id == $category->id ? 'selected':''); ?>><?php echo e($category->category_name); ?></option>
													    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
											         </select>
													<span class="form-text text-muted">Please select an option.</span>
											   	</div>
											   <div class="col-lg-4" style="display: none;">
												    <label for="title">Sub-Category Name:</label>
												    <select name=subcategory_id id="subcategory_id" class="form-control">
												    	<option value="<?php echo e($product->subcategory_id); ?>"><?php echo e($product->connect_subcategory->title??''); ?></option>
													</select>
									                
											   </div>
											   <div class="col-lg-4" style="display: none;">
												    <label for="title">Child-Category Name:</label>
												    <select name=childcategory_id id="childcategory_id" class="form-control">
												    	<option value="<?php echo e($product->childcategory_id); ?>"><?php echo e($product->connect_childcategory->title??''); ?></option>
        											</select>
									                
											   </div>
										</div>
									  	<div class="form-group row">
											   	<div class="col-lg-8">
												   <label>Product Name</label>
												   <input type="text" name="product_name" class="form-control form-control-solid" value="<?php echo e($product->product_name); ?>" />
												   <input type="hidden" name="id" class="form-control form-control-solid" value="<?php echo e($product->id); ?>" />
												   <span class="form-text text-muted">Please enter your Product Name</span>
											   	</div>
											   <div class="col-lg-4">
												    <label>Price:</label>
												   <input type="text" class="form-control form-control-solid" name="price" value="<?php echo e($product->price); ?>"/>
												   <span class="form-text text-muted">Please enter your Price</span>
											   </div>
										</div>
			                            <div class="form-group">
												<label>Product Photo Browser</label>
												<div></div>
												<div class="custom-file">
													<input type="file" class="custom-file-input" id="customFile" name="image" id="profile-photo" onchange="preview_photo(event)"/>
													<label class="custom-file-label" for="customFile">Choose file</label>
													<img src="<?php echo e(asset('uploads/product')); ?>/<?php echo e($product->image); ?>" id="output_photo" width="200px" style="padding-top: 5px;" />
												</div>
										</div>
										<?php $__errorArgs = ['image'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
										   <div class="alert alert-danger">
										   		<strong><?php echo e($mesage); ?></strong>
										   </div>
										   <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
										   <div class="form-group">
									  			 <label>Description</label>
			                					<textarea id="summernotetwo" name="description"><?php echo $product->description??''; ?></textarea>
									  		</div>

										<div class="form-group" style="text-align:end;">
											<button type="button" class="btn btn-light-primary font-weight-bold" data-dismiss="modal">Close</button>
                                    		<button type="submit" class="btn btn-primary font-weight-bold">Submit</button>
										</div>
												</form>

            </div>
        </div>
    </div>
</div>
<!-- Show -->
<div class="modal fade " id="showModal<?php echo e($product->id); ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header state modal-primary">
                <h5 class="modal-title" id="exampleModalLongTitle">Product Information</h5>
                <button type="button" class="btn btn-warning" data-dismiss="modal"><i class="fas fa-times"></i></button>
            </div>
            <div class="modal-body">
              	<form action="<?php echo e(url('admin/update/product')); ?>" method="POST" enctype="multipart/form-data">
			                                   		<?php echo csrf_field(); ?>
			                           
									  	<div class="form-group row">
											   	<div class="col-lg-4">
												   <label>Category Name:</label><br>
												   <input type="text" name="product_name" class="form-control form-control-solid" value="<?php echo e($product->connect_category->category_name??''); ?>" />
											   	</div>
											   <div class="col-lg-4">
												   <label>Sub-Category Name:</label><br>
												   <input type="text" name="product_name" class="form-control form-control-solid" value="<?php echo e($product->connect_subcategory->title??'Null'); ?>" />
											   	</div>
											   <div class="col-lg-4">
												   <label>Sub-Category Name:</label><br>
												   <input type="text" name="product_name" class="form-control form-control-solid" value="<?php echo e($product->connect_childcategory->title??'Null'); ?>" />
											   	</div>
										</div>
									  	<div class="form-group row">
											   	<div class="col-lg-8">
												   <label>Product Name</label>
												   <input type="text" name="product_name" class="form-control form-control-solid" value="<?php echo e($product->product_name); ?>" />
												   <input type="hidden" name="id" class="form-control form-control-solid" value="<?php echo e($product->id); ?>" />
												   <span class="form-text text-muted">Please enter your Product Name</span>
											   	</div>
											   <div class="col-lg-4">
												    <label>Price:</label>
												   <input type="text" class="form-control form-control-solid" name="price" value="<?php echo e($product->price); ?>"/>
												   <span class="form-text text-muted">Please enter your Price</span>
											   </div>
										</div>
			                            <div class="form-group">
												<label>Product Photo</label>
												<div></div>
												<div class="custom-file">
													<img src="<?php echo e(asset('uploads/product')); ?>/<?php echo e($product->image); ?>" id="output_photo" width="200px" style="padding-top: 5px;" />
												</div>
										</div>
										<?php $__errorArgs = ['image'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
										   <div class="alert alert-danger">
										   		<strong><?php echo e($mesage); ?></strong>
										   </div>
										   <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
										<div class="form-group" style="text-align:end;">
											<button type="button" class="btn btn-light-primary font-weight-bold" data-dismiss="modal">Close</button>
										</div>
												</form>

            </div>
        </div>
    </div>
</div>
												<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
											</tbody>
										</table>
										<!--end: Datatable-->
						</div>
					</div>
                </div>
            </div>
            <!--end::Row-->
            <!--end::Dashboard-->
        </div>
        <!--end::Container-->
    </div>
    <!--end::Entry-->
</div>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>

<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.js"></script>

<script src="http://cdn.bootcss.com/toastr.js/latest/js/toastr.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>

<?php echo Toastr::message(); ?>

<?php if(Session::has('message')): ?>
toastr.options =
{
"closeButton" : true,
"progressBar" : true
}
  toastr.success("<?php echo e(session('message')); ?>");
<?php endif; ?>
<?php if(Session::has('message')): ?>
toastr.options =
{
"closeButton" : true,
"progressBar" : true
}
  toastr.error("<?php echo e(session('message')); ?>");
<?php endif; ?>
<script>
    $(function () {
            $("#usertable").DataTable({
                "responsive": true,
                "autoWidth": false,
            });
    });
</script>
<script type='text/javascript'>
function preview_image(event) 
{
 var reader = new FileReader();
 reader.onload = function()
 {
  var output = document.getElementById('output_image');
  output.src = reader.result;
 }
 reader.readAsDataURL(event.target.files[0]);
}
</script>
<script type='text/javascript'>
function preview_photo(event) 
{
 var reader = new FileReader();
 reader.onload = function()
 {
  var output = document.getElementById('output_photo');
  output.src = reader.result;
 }
 reader.readAsDataURL(event.target.files[0]);
}
</script>

<script type="text/javascript">
        function readURL(input) {
            if (input.files && input.files[0]) {
                var reader = new FileReader();
                
                reader.onload = function (e) {
                    $('#profile-img-tag').attr('src', e.target.result);
                }
                reader.readAsDataURL(input.files[0]);
            }
        }
        $("#profile-img").change(function(){
            readURL(this);
        });
</script>
<script type=text/javascript>
  $('#country').change(function(){
  var countryID = $(this).val();
  if(countryID){
    $.ajax({
      type:"GET",
      url:'/get-state-list/'+countryID,
      data : {"_token":"<?php echo e(csrf_token()); ?>"},
      dataType: "json",
      success:function(res){        
      if(res){
        $("#state").empty();
        $("#state").append('<option value="">Select</option>');
        $.each(res,function(key,value){
          $("#state").append('<option value="'+value.id+'">'+value.title+'</option>');
        });
      
      }else{
        $("#state").empty();
      }
      }
    });
  }else{
    $("#state").empty();
    $("#city").empty();
  }   
  });
  $('#state').on('change',function(){
  var stateID = $(this).val();
  console.log(stateID);
  if(stateID){
    $.ajax({
      type:"GET",
      url:'/get-city-list/'+stateID,
      success:function(res){        
      if(res){
        $("#city").empty();
        $.each(res,function(key,value){
          $("#city").append('<option value="'+value.id+'">'+value.title+'</option>');
        });
      
      }else{
        $("#city").empty();
      }
      }
    });
  }else{
    $("#city").empty();
  }
    
  });
</script>
<script type=text/javascript>
  $('#category_id').change(function(){
  var countryID = $(this).val();
  if(countryID){
    $.ajax({
      type:"GET",
      url:'/get-state-list/'+countryID,
      data : {"_token":"<?php echo e(csrf_token()); ?>"},
      dataType: "json",
      success:function(res){        
      if(res){
        $("#subcategory_id").empty();
        $("#subcategory_id").append('<option>Select</option>');
        $.each(res,function(key,value){
          $("#subcategory_id").append('<option value="'+value.id+'">'+value.title+'</option>');
        });
      
      }else{
        $("#subcategory_id").empty();
      }
      }
    });
  }else{
    $("#subcategory_id").empty();
    $("#childcategory_id").empty();
  }   
  });
  $('#subcategory_id').on('change',function(){
  var stateID = $(this).val();
  console.log(stateID);
  if(stateID){
    $.ajax({
      type:"GET",
      url:'/get-city-list/'+stateID,
      success:function(res){        
      if(res){
        $("#childcategory_id").empty();
        $.each(res,function(key,value){
          $("#childcategory_id").append('<option value="'+value.id+'">'+value.title+'</option>');
        });
      
      }else{
        $("#childcategory_id").empty();
      }
      }
    });
  }else{
    $("#childcategory_id").empty();
  }
    
  });
</script>
<script type="text/javascript">
	
	$(document).ready(function() { 
		$("#category").select2({
			placeholder:"search here",
			allowClear:true,
		}); 
	});
</script>
<script type="text/javascript">
	
	$(document).ready(function() { 
		$("#subcategory").select2({
			placeholder:"search here",
			allowClear:true,
		}); 
	});
</script>
<script type="text/javascript">
	
	$(document).ready(function() { 
		$("#childcategory").select2({
			placeholder:"search here",
			allowClear:true,
		}); 
	});
</script>

<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.18/dist/summernote.min.js"></script>
 <script type="text/javascript">
        $(document).ready(function () {
            $('#summernote').summernote({
                height: 250,
            });
        });

    </script>
     <script type="text/javascript">
        $(document).ready(function () {
            $('#summernotetwo').summernote({
                height: 250,
            });
        });

    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.dashboard', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/tradeasi1021/public_html/demo/resources/views/admin/product/create.blade.php ENDPATH**/ ?>