<?php $__env->startSection('content'); ?>
<style>
label.error{
	color:red;
}
</style>
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<div class="common-content">
          <div class="page-content">
                <div class="page-heading">
                    <div class="headings">
                        <h6>Request Product</h6>
                    </div>
                </div>
<input name="_token" type="hidden" id="token_buyer" value="<?php echo e(csrf_token()); ?>">
                <div class="dashboard-cnts">
				      <form name="request_product_pop" id="request_product_pop" method="POST" action="<?php echo e(url('buyers/product_request_existing')); ?>">
			   <?php echo csrf_field(); ?>
			 <div class="prrequest">
				<div class="row mb-4 product_mains">
							 <div class="col-lg-4">
								<div class="form-inputs">
								  <div class="form-group">
									 <label>Product Name</label>
									 <input id="request_product_name[]" name="request_product_name[]" value="" type="text" class="form-control">
								  </div>
								  </div>
							</div>
							<div class="col-lg-4">
								<div class="form-inputs">
								  <div class="form-group">
									<label>Select Department</label>
									<select class="form-contro invoiceselect" id="request_department_name[]" name="request_department_name[]">
											<option value="">Select</option>
											 <?php if(!empty($departmentlist)): ?>
												  <?php $__currentLoopData = $departmentlist; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $departmentlist): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
												   <option value="<?php echo e($departmentlist->id); ?>"><?php echo e($departmentlist->name); ?></option>
												  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
											<?php endif; ?>
									</select>
									
								  </div>
								</div>
							</div>
							
						
							
							<div class="col-lg-2 ">
								<div class="Add-buttons">
									<button class="req-product-btn G-add addproduct">ADD<i class="fa fa-plus" aria-hidden="true"></i></button>
								</div>
							</div>
				</div>
				
			</div>
			 <div class="prrequest1">
			 
			 </div>
		  
			  <div class="req-submit-bttn">
				
				<button type="submit" class="btn btn-primary sendmessage" id="requestproduct">
							  <?php echo e(__('Send')); ?>

						   </button>
			  </div>
		  </form>



                </div>
		
	</div>



<!-- Modal Under observation -->
<div class="modal fade" id="exampleModal_adddepartment" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog"> 
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Under Observation</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>

      <div class="modal-body imageArea" id="demo">
	     
		
			   <?php echo csrf_field(); ?>
			 <div class="row manufacturerlist manufacturerlist-rs">
				<div class="col-sm-12 col-xs-12">
					<div class="form-inputs">
					  <div class="form-group">
						 <label>Number of days</label>
						 <input id="no_day" name="no_day" value="7" type="number" class="form-control">
						 
						 
						 
					  </div>
					  </div>
					</div>
				</div>
		  </div>
			  <div class="modal-footer">
				<button type="button" class="btn btn-secondary closemessage" data-dismiss="modal" id="closebar">Close</button>
				<button type="submit" class="btn btn-primary sendmessage" id="sendobservation">
							  <?php echo e(__('Send')); ?>

						   </button>
			  </div>
		  </form>
	  
      </div>
<!--
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal" id="closebar">Close</button>
        
      </div>
-->
    </div>
  </div>




<?php $__env->stopSection(); ?>
<?php $__env->startSection('scripts'); ?>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<script>
function selectRefresh() {
  $('.prrequest1 .select2').select2({
        //-^^^^^^^^--- update here
    
  });
}

$(document).ready(function() {
  selectRefresh();
});

var optrequest = '';

$(document).ready( function () {
	
	
var data = {
					_token	: $('#token_buyer').val(),
					
				}
				$.ajax({
					url:'https://www.meddbot.com/departmentlist_request',
					type: "POST",
					data: data,
					success: function (res) {
						
						var obj = jQuery.parseJSON(res);
						console.log(obj);
						var departmentlistcount = obj.departmentlist.length;
						
						optrequest += '<option value="">Select</option>';
						if (departmentlistcount != 0) {
							
							  for (i = 0; i < departmentlistcount; i++) {
									var depart_id    =obj.departmentlist[i].id;
									var depart_name  =obj.departmentlist[i].name;
									optrequest += '<option value=' + depart_id + '>' + depart_name + '</option>';
									
							  }
							 
							
						}
					}
				});

   
});

$(document).on("click", ".addproduct", function ( event ) {
	
	event.preventDefault();
	$(".invoiceselect").select2();
	var addoptionrequest='';
	addoptionrequest+='<div class="row mb-4 req_pr">';
	addoptionrequest+='<div class="col-lg-4">';
	
	addoptionrequest+='<div class="form-inputs">';
	addoptionrequest+='<div class="form-group">';
	
	addoptionrequest+='<label>Product Name</label>';
	addoptionrequest+='<input  id="request_product_name'+counterval+'" name="request_product_name[]" value="" type="text" class="form-control">';
	addoptionrequest+='</div>';
	addoptionrequest+='</div>';
	addoptionrequest+='</div>';
	
	addoptionrequest+='<div class="col-lg-4">';
	
	addoptionrequest+='<div class="form-inputs">';
	addoptionrequest+='<div class="form-group">';
	
	addoptionrequest+='<label>Department</label>';
	addoptionrequest+='<select class="form-control select2" id="request_department_name'+counterval+'" name="request_department_name[]">';
	addoptionrequest+=optrequest;
	 
	addoptionrequest+='</select>';
	
	$(".invoiceselect").select2();
	
	
	addoptionrequest+='</div>';
	addoptionrequest+='</div>';
	addoptionrequest+='</div>';
	
	addoptionrequest+='<div class="col-lg-4">';
	addoptionrequest+='<div class="Add-buttons add">';
	addoptionrequest+='<button class="G-add removeproduct req-product-btn" >Remove</button>';
	addoptionrequest+='</div>';
	addoptionrequest+='</div>';
	addoptionrequest+='</div>';
	counterval++;
	
	$(".prrequest1").append(addoptionrequest);
	$(".invoiceselect").select2();
    selectRefresh();   
  });

$(function () {
  $(".invoiceselect").select2();
   $(".invoiceselect1").select2();
  
});

$(document).ready( function () {
    $('#table_id').DataTable();
} );

<?php if(Session::has('message')): ?>
      swal({
        title: "",
        text: "<?php echo e(Session::get('message')); ?>",
        type: "success",
        showCancelButton: false,
        dangerMode: false,
        confirmButtonText: 'OK',

    });
<?php endif; ?>
<?php if(Session::has('errormessage')): ?>
      swal({
        title: "",
        text: "<?php echo e(Session::get('errormessage')); ?>",
        type: "error",
        showCancelButton: false,
        dangerMode: true,
        confirmButtonText: 'OK',

    });
<?php endif; ?>

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

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