<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.23/css/jquery.dataTables.css">
<!-- <link rel="stylesheet" href="https://cdn.datatables.net/1.10.23/css/dataTables.bootstrap4.min.css">  -->
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<?php $__env->startSection('content'); ?>

<div class="common-content">
          <div class="page-content">
                <div class="page-heading">
                    <div class="headings">
                        <h6>Existing Product Listing</h6>
                    </div>
                </div>
				<button class="btn btn-success addproduct" style="margin-top: 10px;margin-bottom: 10px;margin-left: 815px;" >Add Product</button>
              
              <div class="hack1">
                  <div class="hack2 hk3">
                      <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>Department Name</th>
						
						<th>Action</th>
					</tr>
				</thead>
				<tbody>
				<?php $__currentLoopData = $existinglist; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$existinglist): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
					<tr>
						<td><?php echo e($key+1); ?></td>
						<td><?php echo e(ucfirst($existinglist->product_name)); ?></td>
						<td><?php echo e(ucfirst($existinglist->name)); ?></td>
						
						<td><button class="btn edit" data-editid="<?php echo e($existinglist->product_id); ?>" data-departmentid="<?php echo e(ucfirst($existinglist->department_id)); ?>" data-pname="<?php echo e(ucfirst($existinglist->product_name)); ?>">Edit</button></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>
                  </div>
              </div>

          </div>
		  
	<!-- Modal Add department -->
	
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Add Product</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
	   <form name="addepartment_form" id="add_exproduct_admin" method="POST" action="<?php echo e(url('admin/add_exproduct_admin')); ?>">
		  <div class="modal-body">
				<?php echo csrf_field(); ?>
				     <div class="row manufacturerlist manufacturerlist-rs">
						 <div class="col-lg-12 col-md-6 col-sm-12 col-xs-12">
							<div class="form-inputs">
							  <div class="form-group">
								 <label>Product Name</label>
								 <input id="product_name" name="product_name" value="" type="text" class="form-control">
								
							  </div>
							  </div>
							</div>
							 
					</div>
					 <div class="row manufacturerlist manufacturerlist-rs">
						 <div class="col-lg-12 col-md-6 col-sm-12 col-xs-12">
							<div class="form-inputs">
							  <div class="form-group">
								 <label>Department Name</label>
								 <select id="department" class="form-control invoiceselect1" name="department">
								    <option value="">Select</option>
									<?php $__currentLoopData = $departmentlist; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $department): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($department->id); ?>"><?php echo e($department->name); ?></option>
									<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
								 </select>
								
							  </div>
							  </div>
							</div>
							 
					</div>
				
		  </div>
		  <div class="modal-footer">
			<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
			<button type="submit" class="btn btn-primary">Add</button>
		  </div>
	  </form>
	  
    </div>
  </div>
</div>	  	  
	<!-- Modal Edit department -->
	
<div class="modal fade" id="exampleModal1" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Edit Product</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
	   <form name="edit_exproduct_admin" id="edit_exproduct_admin" method="POST" action="<?php echo e(url('admin/edit_exproduct_admin')); ?>">
		  <div class="modal-body">
				<?php echo csrf_field(); ?>
				     <div class="row manufacturerlist manufacturerlist-rs">
						 <div class="col-lg-12 col-md-6 col-sm-12 col-xs-12">
							<div class="form-inputs">
							  <div class="form-group">
								 <label>Product Name</label>
								 <input id="product_name_edit" name="product_name_edit" value="" type="text" class="form-control">
								
							  </div>
							  </div>
							</div>
							  <input id="product_id_edit" name="product_id_edit" value="" type="hidden" class="form-control">
							  
					</div>
					 <div class="row manufacturerlist manufacturerlist-rs">
						 <div class="col-lg-12 col-md-6 col-sm-12 col-xs-12">
							<div class="form-inputs">
							  <div class="form-group">
								 <label>Department Name</label>
								 <select id="department_edit" class="form-control department_edit invoiceselect" name="department_edit">
								    <option value="">Select</option>
									<?php $__currentLoopData = $departmentlist; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $department): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <option value="<?php echo e($department->id); ?>"><?php echo e($department->name); ?></option>
									<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
								 </select>
								
							  </div>
							  </div>
							</div>
							 
					</div>
				
		  </div>
		  <div class="modal-footer">
			<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
			<button type="submit" class="btn btn-primary">Add</button>
		  </div>
	  </form>
	  
    </div>
  </div>
</div>
	  
<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>
<!-- <script src = "https://code.jquery.com/jquery-3.5.1.js"></script>
<script src = "https://cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js"></script>
<script src = "https://cdn.datatables.net/1.10.23/js/dataTables.bootstrap4.min.js"></script> -->
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.23/js/jquery.dataTables.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script>
$(function () {
 //$(".invoiceselect").select2();
  //$(".invoiceselect1").select2();
});

$(document).ready(function() {
 // executes when HTML-Document is loaded and DOM is ready
 $(".pageloader").show();
$(".pageloader").delay(200).fadeOut("slow");
});

$(document).on("click", ".edit", function () {
	
	$('#exampleModal1').modal({backdrop: 'static', keyboard: false});
	var pname = $(this).attr('data-pname');
	var editid = $(this).attr('data-editid');
	var departmentid = $(this).attr('data-departmentid');
	
    $("#product_name_edit").val(pname);
	$("#product_id_edit").val(editid);
	$('.department_edit option[value='+departmentid+']').attr('selected','selected');
	
});

$(document).on("click", ".addproduct", function () {
	
	$('#exampleModal').modal({backdrop: 'static', keyboard: false});
	$("#product_name").val('');
	
	
});
$("#add_exproduct_admin").validate({

        rules: {
            "product_name": {
                required: true
               
            },
			"department": {
                required: true
               
            },
        },
        submitHandler: function(form, e) {
			
			form.submit();
          
        }
    });

$("#edit_exproduct_admin").validate({

        rules: {
            "product_name_edit": {
                required: true
               
            },
			"department_edit": {
                required: true
               
            },
        },
        submitHandler: function(form, e) {
			
			form.submit();
          
        }
    });

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

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