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



<main class="h-full pb-16 overflow-y-auto">
          <div class="container grid px-6 mx-auto">
            <h2
              class="my-6 text-2xl font-semibold text-gray-700 dark:text-gray-200"
            >
            <span class="text-blue-500">My</span> Product
            </h2>
             <!-- CTA -->
             <a
              class="flex items-center bg-blue-600 justify-between p-4 mb-8 text-sm font-semibold shadow-md focus:outline-none focus:shadow-outline-green"
              href="<?php echo e(url('/')); ?>" style="color: #fff;"
            >
              <div class="flex items-center">
                <svg
                  class="w-5 h-5 mr-2"
                  fill="currentColor"
                  viewBox="0 0 20 20"
                >
                  <path
                    d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"
                  ></path>
                </svg>
                <span>Go to main website</span>
              </div>
              <span>View &RightArrow;</span>
            </a>

            

             <!-- With actions -->
             <div id="" class="flex">
                <h4
                  class="mb-4 text-lg mt-2 mr-6 font-semibold text-gray-600 dark:text-gray-300"
                >
                  Oil Barrels
                </h4> 
            </div>
             
        <hr class="w-12 md:w-12 mb-4">
            <?php if (isset($component)) { $__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4 = $component; } ?>
<?php $component = $__env->getContainer()->make(Illuminate\View\AnonymousComponent::class, ['view' => 'components.alert','data' => []]); ?>
<?php $component->withName('alert'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4)): ?>
<?php $component = $__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4; ?>
<?php unset($__componentOriginalc254754b9d5db91d5165876f9d051922ca0066f4); ?>
<?php endif; ?><br>
            <?php $__errorArgs = ['image'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
              <span class="text-md text-red-600 bg-red-100 dark:text-red-400 p-2">
                  <?php echo e($message); ?>

                </span>
              <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
            <div class="w-full overflow-hidden rounded-lg shadow-xs">
           
           
              <div class="w-full overflow-x-auto"> 
              <table class="w-full whitespace-no-wrap">
                  <thead>
                    <tr
                      class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800"
                    >
                      <th class="px-4 py-3">Product</th>
                      <th class="px-4 py-3">Price/Barrel</th>
                      <th class="px-6 ml-16 py-3">Actions</th>
                    </tr>
                  </thead>
                  <tbody
                    class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800"
                  >
                  <?php $__empty_1 = true; $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $product): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr class="text-gray-700 dark:text-gray-400">
                      <td class="px-4 py-3">
                        <div class="flex items-center text-sm">
                          <div>
                            <p class="font-semibold"><?php echo e($product->name); ?></p>                      
                          </div>
                        </div>
                      </td>
                      <td class="px-4 py-3 text-sm">
                      &#8358;<?php echo e(number_format($product->price)); ?>

                      </td>
                      <td class="px-4 py-3">
                        <div class="flex items-center space-x-6 text-sm">
                        <a
                        class="edit-product flex items-center justify-between px-2 py-2 text-sm font-medium leading-5 text-green-600 rounded-lg dark:text-gray-400 focus:outline-none focus:shadow-outline-gray"
                         aria-label="Edit" href="" id="<?php echo e($product->id); ?>"
                          >
                            <svg
                              class="w-5 h-5"
                              aria-hidden="true"
                              fill="currentColor"
                              viewBox="0 0 20 20"
                            >
                              <path
                                d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z"
                              ></path>
                            </svg>

                            Edit
                          </a>
                        </div>
                      </td>
                    </tr>
                  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                  <div class="mx-auto my-3">
                        <p class="text-center lead text-white">No Products.</p>
                  </div>
                  <br><br><br>
                  <?php endif; ?>
                  
        
                  </tbody>
                </table>
              </div>
              <div
                class="grid px-4 py-3 text-xs font-semibold tracking-wide text-gray-500 uppercase border-t dark:border-gray-700 bg-gray-50 sm:grid-cols-9 dark:text-gray-400 dark:bg-gray-800"
              >

              </div>
            </div>
 
    <hr>



    <!-- Edit Modal -->

  <div class="main-modal fixed w-full inset-0 z-50 overflow-hidden flex justify-center items-center animated fadeIn faster" style="background: rgba(0,0,0,.7);">
		<div class="border border-blue-500 shadow-lg modal-container bg-white w-4/12 md:max-w-11/12 mx-auto ml-2 mr-2 rounded-xl shadow-lg z-50 overflow-y-auto">
			<div class="modal-content py-4 text-left px-6">
				<!--Title-->
				<div class="flex justify-between items-center pb-3">
					<p class="text-2xl mt-6 font-bold text-gray-500">Edit Product</p>
          
					<div class="modal-close cursor-pointer z-50" onclick="modalClose('main-modal')">
						<svg class="fill-current text-gray-500" xmlns="http://www.w3.org/2000/svg" width="18" height="18"
							viewBox="0 0 18 18">
							<path
								d="M14.53 4.53l-1.06-1.06L9 7.94 4.53 3.47 3.47 4.53 7.94 9l-4.47 4.47 1.06 1.06L9 10.06l4.47 4.47 1.06-1.06L10.06 9z">
							</path>
						</svg>
					</div>
				</div>
        <p class="mt-2 mb-4">(<span class="name"></span>)</p>
				<!--Body-->
				<div class="my-5 mr-5 ml-5 flex justify-center">
                    <form action="<?php echo e(route('admin.edit_products', $product->id)); ?>" method="post" id="myForm" class="w-full" enctype="multipart/form-data">
                      <?php echo csrf_field(); ?>

                      <?php echo method_field('patch'); ?>
                        <div class="">
                            <div class="">
                                <label for="name" class="text-sm text-gray-600">Product Name</label>
                            </div>
                            <div class="">
                                <input type="text" id="name" value="<?php echo e($product->name); ?>" autocomplete="off" name="name" class="h-3 p-6 w-full border-2 border-gray-300 mb-5 rounded-md" placeholder="">
                            </div>

                            <div class="">
                                <label for="price" class="text-sm text-gray-600">Product Price(&#8358;)</label>
                            </div>
                            <div class="">
                                <input type="tel" id="price" value="<?php echo e($product->price); ?>" autocomplete="off" name="price" class="h-3 p-6 w-full border-2 border-gray-300 mb-5 rounded-md" placeholder="">
                            </div>

                            <div class="">
                                <label for="price" class="text-sm text-gray-600">Product Min Qty</label>
                            </div>
                            <div class="">
                                <input type="number" id="min" value="<?php echo e($product->min); ?>" autocomplete="off" name="min" class="h-3 p-6 w-full border-2 border-gray-300 mb-5 rounded-md" placeholder="">
                            </div>

                            <div class="">
                                <label for="price" class="text-sm text-gray-600">Product Max Qty</label>
                            </div>
                            <div class="">
                                <input type="number" id="max" value="<?php echo e($product->max); ?>" autocomplete="off" name="max" class="h-3 p-6 w-full border-2 border-gray-300 mb-5 rounded-md" placeholder="">
                            </div>

                            <div class="">
                                <label for="price" class="text-sm text-gray-600">Product Description</label>
                            </div>
                            <div class="">
                                <input type="text" id="description" value="<?php echo e($product->description); ?>" autocomplete="off" name="description" class="h-3 p-6 w-full border-2 border-gray-300 mb-5 rounded-md" placeholder="">
                            </div>
                        </div>
                    </form>
				</div>
				<!--Footer-->
				<div class="flex justify-end space-x-14">
					<button
						class="px-4 mt-4 bg-gray-200 p-3 text-black hover:bg-gray-300 font-semibold" onclick="modalClose('main-modal')">Cancel</button>
					<button
						type="submit" form="myForm" class="px-4 mt-4 p-3 ml-3 bg-blue-600 text-white hover:bg-teal-400" style="color: #fff;">Done</button>
				</div>
			</div>
		</div>
	</div>





<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
 <script>
              $(document).bind("ajaxSend", function() {
                  $("#loader-body").removeClass("invisible");
              }).bind("ajaxComplete", function() {
                  $("#loader-body").addClass("invisible");
              });
              

             // If user clicks on the cart btn, call the withdraw function 
              $(".edit-product").click(function(e) {
                  e.preventDefault();
                   
                  openModal('main-modal');

                  // Get the user curent balance
                  let myid = $(this).attr('id');
                  
                 $.get("<?php echo e(URL::to('product-show')); ?>/"+myid, function (data) {
                     
                     //Calculate the input price
                      let currency = Intl.NumberFormat('en-US');
                      let price = data.price;
                      
                      $(".item-id").val(data.id);

                      $("#myForm").attr("action", "<?php echo e(URL::to('admin/update-products')); ?>/"+data.id);
                      
                      $("#name").val(data.name);

                      $(".name").html(data.name);

                      $("#price").val(data.price);
                      
                       $("#item-qty").on('input', function(){
                              $(".total").html(currency.format($(this).val() * price));
                       });
                       
                 });
              });
              
    
        all_modals = ['main-modal', 'another-modal', 'third-modal']
        all_modals.forEach((modal)=>{
            const modalSelected = document.querySelector('.'+modal);
            modalSelected.classList.remove('fadeIn');
            modalSelected.classList.add('fadeOut');
            modalSelected.style.display = 'none';
        })
        function modalClose (modal){
            const modalToClose = document.querySelector('.'+modal);
            modalToClose.classList.remove('fadeIn');
            modalToClose.classList.add('fadeOut');
            setTimeout(() => {
                modalToClose.style.display = 'none';
            }, 500);
        }

        function openModal (modal) {
            const modalToOpen = document.querySelector('.'+modal);
            modalToOpen.classList.remove('fadeOut');
            modalToOpen.classList.add('fadeIn');
            modalToOpen.style.display = 'flex';
        }
          
</script>



   
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.admin_layout', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\wamp64\www\jango\resources\views/admin/products.blade.php ENDPATH**/ ?>