<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">  -->
<style>
/* Style the tab */
.tab {
  overflow: hidden;
  border: 1px solid #ccc;
  background-color: #f1f1f1;
}

/* Style the buttons that are used to open the tab content */
.tab button {
  background-color: inherit;
  float: left;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 14px 16px;
  transition: 0.3s;
}

/* Change background color of buttons on hover */
.tab button:hover {
  background-color: #ddd;
}

/* Create an active/current tablink class */
.tab button.active {
  background-color: #ccc;
}

/* Style the tab content */
.tabcontent {
  display: none;
  padding: 6px 12px;
  border: 1px solid #ccc;
  border-top: none;
}
.tab button.active {
    background-color: transparent;
    color: #fff;
    color: #02b9b4;
    font-weight: 600;
    border-bottom: 2px solid;
    margin-left: 10px;
}
</style>
<?php $__env->startSection('content'); ?>
<div class="common-content" style="    width: calc(100% - 335px);">
          <div class="page-content">
                <div class="page-heading">
                    <div class="headings">
                        <h6>Department Listing</h6>
                    </div>
                </div>
				
				<!-- Tab links -->
					<div class="tab">
					  <button class="tablinks active" onclick="openCity(event, 'London')">Manage Admin departments</button>
					  <button class="tablinks" onclick="openCity(event, 'Paris')">Manage User departments</button>
					  
					</div>

					<!-- Tab content -->
					<div id="London" class="tabcontent"  style="display: block; height:100%;">
					 
						<button class="btn btn-success adddepartment" style="margin-top: 10px;margin-bottom: 10px;margin-left: 815px;" >Add Department</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>No</th>
										<th>Department Name</th>
										<th>Action</th>
									</tr>
								</thead>
								<tbody>
								<?php $__currentLoopData = $departmentlist; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$departmentlist): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
									<tr>
										<td><?php echo e($key+1); ?></td>
										<td><?php echo e(ucfirst($departmentlist->name)); ?></td>
										<td><button class="btn edit" data-editid="<?php echo e($departmentlist->id); ?>" data-dname="<?php echo e(ucfirst($departmentlist->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>

					<div id="Paris" class="tabcontent">
					 <div class="hack1">
                                    <div class="hack2 hk3">
                                        <div class="tableBox wraper">
					  	<table id="example1" class="table table-striped table-bordered" style="width:100%">
								<thead>
									<tr>
										<th>No</th>
										<th>Department Name</th>
										<th>Action</th>
									</tr>
								</thead>
								<tbody>
								<?php $__currentLoopData = $departmentuser; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key=>$departmentuser): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
									<tr>
										<td><?php echo e($key+1); ?></td>
										<td><?php echo e(ucfirst($departmentuser->department_name	)); ?></td>
										<td>
										<a href="<?php echo e(url('admin/department_approve').'/'.$departmentuser->id); ?>" onclick="return confirm('Are you sure?')"><button class="btn">Approve</button></a>
										<a href="<?php echo e(url('admin/department_reject').'/'.$departmentuser->id); ?>" onclick="return confirm('Are you sure?')"><button class="btn" style="background-color:red">Reject</button></a></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>

				
				

          </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 Department Name</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="addepartment_form" method="POST" action="<?php echo e(url('admin/add_department_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>Department Name</label>
								 <input id="department_name" name="department_name" value="" type="text" class="form-control">
								
							  </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">Add Department Name</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
	   <form name="editdepartment_form" id="editdepartment_form" method="POST" action="<?php echo e(url('admin/edit_department_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>Department Name</label>
								 <input id="department_name_edit" name="department_name_edit" value="" type="text" class="form-control">
								 <input id="department_id_edit" name="department_id_edit" value="" type="hidden" class="form-control">
							  </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">Save changes</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>
function openCity(evt, cityName) {
  // Declare all variables
  var i, tabcontent, tablinks;

  // Get all elements with class="tabcontent" and hide them
  tabcontent = document.getElementsByClassName("tabcontent");
  for (i = 0; i < tabcontent.length; i++) {
    tabcontent[i].style.display = "none";
  }

  // Get all elements with class="tablinks" and remove the class "active"
  tablinks = document.getElementsByClassName("tablinks");
  for (i = 0; i < tablinks.length; i++) {
    tablinks[i].className = tablinks[i].className.replace(" active", "");
  }

  // Show the current tab, and add an "active" class to the button that opened the tab
  document.getElementById(cityName).style.display = "block";
  evt.currentTarget.className += " active";
}


$(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 dname = $(this).attr('data-dname');
	var editid = $(this).attr('data-editid');
    $("#department_name_edit").val(dname);
	$("#department_id_edit").val(editid);
	
});

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

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

$("#editdepartment_form").validate({

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

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