<?php $__env->startSection('content'); ?>
<input name="_token" type="hidden" id="token_manu" value="<?php echo e(csrf_token()); ?>">
<div class="common-content">
          <div class="page-content">
                <div class="page-heading">
                    <div class="headings">
                        <h6>Product Listing</h6>
                    </div>
                </div>  
                <?php if(count($product_lists) > 0) {?>              
         <div class="tableBox wraper">  
           <table id="example" class="table table-striped table-bordered" style="width:100%">
                <thead>
                    <tr>
                        <th>Id</th>
                        <th>Product Name</th>
                        <th>Product Code</th>
						
                        <th>Created Date</th>
                        <th>Status</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                <?php $__currentLoopData = $product_lists; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$products): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td><?php echo e($key+1); ?></td>
                        <td><?php echo e($products->product_name); ?></td>
                        <td><?php echo e($products->product_code); ?></td>
						
                        <td><?php if(!empty($products->created_at)): ?><?php echo e(date("F j, Y",strtotime($products->created_at))); ?><?php endif; ?></td>
                       <td> <?php if($products->product_status  == '0'){ ?>
                                Inactive 
                            <?php }elseif($products->product_status  == '1'){  ?>
                                Active
                            <?php }elseif($products->product_status  == '2'){  ?>
                                Rejected
                           <?php } ?>
                           </td>
                        <td>
                            <a href="<?php echo e(url('/manufacturers/productdetails/'.$products->product_id)); ?>"><button class="btn common-btn green-btn"><i class="fa fa-eye" aria-hidden="true"></i>Product details </button></a>
                            
                            <?php if(($products->product_status==0)||($products->product_status==2)): ?>
                            
                            <a href="#" ><button class="btn common-btn green-btn" onclick="approve_venprd(<?php echo e($products->product_id); ?>,<?php echo e($products->vendor); ?>)"><i class="fa fa-eye" aria-hidden="true"></i>Approve </button></a>
                            
                            <?php endif; ?>
                            <?php if($products->product_status==1): ?>
                            <a href="#" onclick="reject_venprd(<?php echo e($products->product_id); ?>,<?php echo e($products->vendor); ?>)"><button class="btn common-btn green-btn"><i class="fa fa-eye" aria-hidden="true"></i>Reject </button></a>
                            <?php endif; ?>
                        </td>
                    </tr>

                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>    
                </tbody>
                <!-- <tfoot>
                    <tr>
                        <th>Id</th>
                        <th>Product Name</th>
                        <th>Product Code</th>
                        <th>Action</th>
                    </tr>
                </tfoot> -->
            </table>
 </div><!-- tableBox end -->
        <?php }else{ ?>
                 <div class="wraper">
                                    <div class="product-display">
                                        <ul>
                                            <li>
                                                <div class="details">
                                                    <div>
                                                        <h6>
                                                        No Datas available
                                                        </h6>
                                                    </div>


                                                </div>
                                            </li>


                                        </ul>
                                    </div>
                                </div>
            <?php } ?>
            
        
    </div>
    
<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.23/js/jquery.dataTables.js"></script>

<script>

function approve_venprd(prdid,venid){

    swal({
		  title: "Are you sure you want to approve",
		  text: "",
		  type: "warning",
		  showCancelButton: true,
		  confirmButtonColor: "#DD6B55",
		  confirmButtonText: "Yes, Approve it!",
		  closeOnConfirm: false,
		  html: false
		}, function(){
			
			
			var data = {
					_token	:$('#token_manu').val(),
					
					vendor_id:venid,
					product_id:prdid
				}
				$.ajax({
					url:'https://www.meddbot.com/manufacturers/approve_venprd',
					type: "POST",
					data: data,
					success: function (res) {
		
						swal({
								title: "",
								text: "Successfully approved",
								type: "success",
								showCancelButton: false,
								dangerMode: false,
								confirmButtonText: 'OK'
							},function () {
								window.location = baseurl + 'manufacturers/manage_vendorproducts/';
							})
						
					}
				});
			});
}
function reject_venprd(prdid,venid){

swal({
      title: "Are you sure you want to reject",
      text: "",
      type: "warning",
      showCancelButton: true,
      confirmButtonColor: "#DD6B55",
      confirmButtonText: "Yes, Reject it!",
      closeOnConfirm: false,
      html: false
    }, function(){
        
        
        var data = {
                _token	:$('#token_manu').val(),
                
                vendor_id:venid,
                product_id:prdid
            }
            $.ajax({
                url:'https://www.meddbot.com/manufacturers/reject_venprd',
                type: "POST",
                data: data,
                success: function (res) {
    
                    swal({
                            title: "",
                            text: "Successfully rejected",
                            type: "success",
                            showCancelButton: false,
                            dangerMode: false,
                            confirmButtonText: 'OK'
                        },function () {
                            window.location = baseurl + 'manufacturers/manage_vendorproducts/';
                        })
                    
                }
            });
        });
}

  
    $(document).ready(function() {
        $('#example').DataTable();
    } );
</script>
<?php $__env->stopSection(); ?>




<?php echo $__env->make('layouts.main', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/meddbot/public_html/resources/views/manufacturers/productlist_request.blade.php ENDPATH**/ ?>