<?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>Create department</h6>
                    </div>
                </div>

                <div class="dashboard-cnts">
				    <form method="POST" action="<?php echo e(url('buyers/add_department')); ?>" id="create_department">
					  <?php echo csrf_field(); ?>
						<input type="hidden" name="type" id="type" value="existing">
                    <div class="row createSpace">
                        <div class="col-lg-6 col-md-6 col-sm-12" style="margin-bottom: 20px;">
                            <div class="form-group">
								<label>Department</label>
								<select class="form-control selectmanufacturer invoiceselect" id="department" name="department">
								  <option value="">Select</option>
								  <?php $__currentLoopData = $departmentlist_existing; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $departmentlists): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
								  <option value="<?php echo e($departmentlists->id); ?>"><?php echo e($departmentlists->name); ?></option>
								  <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
								</select>
                  </div>
                          </div>
													<div class="col-lg-6 col-md-6 col-sm-12">
														<button  style="width: fit-content;" type="submit" class="btn btn-primary">
																<?php echo e(__('Select New Department')); ?>

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

                        <!-- <div class="form-group row mb-0">

                        </div> -->
                   </form>
				   
				   <button class="barcodeBtn" style="width: fit-content;" type="button" id="create_new_department" style="display:block;height: 38px;margin-top: 25px;">
            			Create New
            	   </button>


                
		
		<?php if(count($departmentlist) !=0): ?>
              
           <div class="tableBox wraper mt-4">
                	<table id="example" class="display table mb-3 mt-3 dataTable" cellspacing="0" width="100%">
                    <thead>
                        <tr>
                            <th>No:</th>
                            <th>Department Name</th>
                            <th>No of Equipments</th>
                            <th>Action</th>
                          
							<th>Login details</th>
                        </tr>
                    </thead>
                <tbody>
                <?php $i=1;?>
                <?php $__currentLoopData = $departmentlist; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $departmentlist): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                    <?php
                        $res  			= App\Helpers\CustomHelper::departmentproduct($departmentlist->department_id);
                    ?>
					<?php
                        $res1  			= App\Helpers\CustomHelper::departmentadmin($departmentlist->department_id);
                    ?>
					
					<?php
                        $res2  			= App\Helpers\CustomHelper::departmentname($departmentlist->department_id,$departmentlist->type);
                    ?>

                    <tr>
                        <td><?php echo e($i); ?></td>
                        <td><?php echo e(ucfirst($res2['departmentdetails']['name'])); ?></td>
                        <td><?php echo e($res); ?></td>
						<td>
							<?php if($res !=0): ?>
								<a class="prdctBtns" href="<?php echo e(url('/buyers/department_product/'.$departmentlist->department_id)); ?>">Product list</a>
							<?php endif; ?>
							
						</td>
						<td>
                            <a class="prdctBtns" href="<?php echo e(url('/buyers/department_admin/'.$departmentlist->department_id)); ?>">Create New</a>
                            <a class="prdctBtns" href="<?php echo e(url('/buyers/departmentadminlist/'.$departmentlist->department_id)); ?>">Userslist</a>
                            
				
						</td>
                        
                    </tr>
                    <?php $i++;?>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                </tbody>
            </table>
               </div>
       
	<?php endif; ?>
	</div>

<!-- Modal -->

    <div class="modal fade" id="myModalaction" role="dialog"  >
		<div class="modal-dialog modal-dialog-centered">
        <!-- Modal content-->
			<div class="modal-content">
			    <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Create New</h5>
                    <button type="button" class="close close_message" data-dismiss="modal" aria-label="Close">
                      <span aria-hidden="true">&times;</span>
                    </button>
                </div>
				<div class="modal-body">
   	                <div class="col-sm-12 col-xs-12">
					<div class="dashboard-cnts">
				    <form method="POST" action="<?php echo e(url('buyers/add_department')); ?>" id="create_departmentnew">
					  <?php echo csrf_field(); ?>
						<input type="hidden" name="type" id="type" value="new">
                    <div class="row createSpace">
                        <div class="col-lg-6 col-md-6 col-sm-12" style="margin-bottom: 20px;">
                            <div class="form-group">
								<label>Department</label>
								<input type="text" name="name" id="type" class="form-control">
							 </div>
                          </div>
						<div class="col-lg-6 col-md-6 col-sm-12">
							<button type="submit" class="btn btn-primary">
								<?php echo e(__('Create')); ?>

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

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

			</div>

		</div>
	</div></div>
<!-- Modal -->

<?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 () {
  $(".invoiceselect").select2();
  
});
$(document).ready(function() {

    $("#department").on('change', function () {
        if($(this).val()!=''){
	        $('label[for=department]').hide();
	    }
        else{
        $('label[for=department]').show();
        }
	});

});





    $('#example').DataTable();
	$('#example1').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/create_department.blade.php ENDPATH**/ ?>