<style>
/* Max width before this PARTICULAR table gets nasty
This query will take effect for any screen smaller than 760px
and also iPads specifically.*/
@media only screen and (max-width: 560px), (min-device-width: 568px) and (max-device-width: 1024px) {
/* Force table to not be like tables anymore */
table, thead, tbody, th, td, tr {display: block;}
/* Hide table headers (but not display: none;, for accessibility) */
thead tr {position: absolute;top: -9999px;left: -9999px;}
tr {border: 0px solid #ccc;}
td {/* Behave  like a "row" */border: none;/*border-bottom: 1px solid #eee; */position: relative;padding-left: 50%;}
td:before {/* Now like a table header */position: unset; /*absolute causing issues*//* Top/left values mimic padding */top: 6px;left: 6px;width: 45%;padding-right: 10px;white-space: nowrap;}
/*Label the data*/
td:nth-of-type(1):before {content: "Name";}
td:nth-of-type(2):before {content: "Email";}
td:nth-of-type(3):before {content: "Phone";}
td:nth-of-type(4):before {content: "Distance";}
td:nth-of-type(5):before {content: "Rating";}
td:nth-of-type(6):before {content: "Assign";}
}
@media only screen and (max-width: 480px), (min-device-width: 300px) and (max-device-width: 480px) {
	.table-checkable tr > td:first-child, .table-checkable tr > th:first-child {max-width: 100%;}	
}
.table-checkable tr > td:first-child, .table-checkable tr > th:first-child {max-width: unset;}
.table td, .table th, .card .table td, .card .table th, .card .dataTable td, .card .dataTable th {padding: 5px 3px;max-width:150px;}
</style>
<style>
/* The switch - the box around the slider */
.switch {display: inline-block;height: 30px;position: relative;width: 55px;}
/* Hide default HTML checkbox */
.switch input {display:none;}
/* The slider */
.slider {position: absolute;cursor: pointer;top: 0;left: 0;right: 0;bottom: 0;background-color: #ccc;-webkit-transition: .4s;transition: .4s;}
.slider {margin: 4px -1px;min-height: 11px;}
.slider::before {background-color: white;bottom: 4px;content: "";height: 15px;left: 4px;position: absolute;transition: all 0.4s ease 0s;width: 21px;}
input:checked + .slider {background-color: #2196F3;}
input:focus + .slider {box-shadow: 0 0 1px #2196F3;}
input:checked + .slider:before {-webkit-transform: translateX(26px);-ms-transform: translateX(26px);transform: translateX(26px);}
/* Rounded sliders */
.slider.round {border-radius: 34px;}
.slider.round:before {border-radius: 50%;}
/*.slot_label {font-size: 14px;margin-top: -30px;width: 107px;}*/
.slot_label {font-size: 14px;margin-top: -16px;width: 107px;}
.slot_main {float: left;margin-right: 10px;margin-bottom:15px;width: 117px;}
.day_row{margin-top:20px;margin-bottom:20px;}
#sunday-div,#monday-div,#tuesday-div,#wednesday-div,#thursday-div,#friday-div,#saturday-div{float:left;}
.slider.round.weekname {/*background-color:#b711cf;*/border-radius: 5px;}
.slider.round.weekname::before {border-radius: 15%;height: 24px;}
</style>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css" rel="stylesheet"></link>
<script src="assets/plugins/jquery/jquery.min.js" ></script>
<script type="text/javascript">
$(document).ready(function() {
	$('.submit-pop').click(function () {
		var btn_id = this.id;	
		var strarray = btn_id.split('-');	
		var tech_id = strarray[1];	
		var commission = $('#commission_percent-'+tech_id).val();	
		var values = $('#regForm'+tech_id).serialize();
		//var valString = values.replace('/&/g', '-|-');
		//alert(valString); 
		//exit;
		if(commission == '' || commission == 'undefined'){
			alert("Enter commission percent");
			return false;
		} else if(commission>100 || commission<=0){
			alert("Enter a valid commission percent");
			return false;
		}
		if(tech_id != '' && tech_id != 'undefined'){			
			var task_id = '<?php echo $taskId; ?>';
			$.ajax({url:"ajax/ajax.php?action=add_extra_tech&tech_id="+tech_id+"&task_id="+task_id+"&commission="+commission+"&values="+values,success:function(result){
				//$(".ajax_result-add").html(result);						
				if(result=='success'){
					$('#addModal').modal('hide');
					window.location = "<?php echo BASE_URL;?>ocontrol/index.php?page=view_task&id=<?php echo $taskId; ?>&success=Assigned the technician";
					//location.reload();
				} else {
					//alert(result);
					$("#ajax_result-"+btn_id).html('<span style="color:red;">'+result+'</span>');
				}													
			}});
		} else {
			alert("something went wrong");
			return false;
		}

		/*if(tech_id != '' && tech_id != 'undefined'){			
			var task_id = '<?php echo $taskId; ?>';
			/*$.ajax({url:"ajax/ajax.php?action=add_extra_tech&tech_id="+tech_id+"&task_id="+task_id+"&commission="+commission,success:function(result){
				//$(".ajax_result-add").html(result);				
				if(result=='success'){
					$('#addModal').modal('hide');
					window.location = "<?php echo BASE_URL;?>ocontrol/index.php?page=view_task&id=<?php echo $taskId; ?>&success=Assigned the technician";
					//location.reload();
				/*} else {
					alert(result);
				}													
			}});
		} else {
			alert("something went wrong");
			return false;
		}*/
	});

	$('.pop-slot').click(function () {		
		var slot_tech = this.id;	
		$(this).addClass('aaa');	
		var task_id = '<?php echo $taskId; ?>';
		var slot_arr = slot_tech.split("-");	
		var tech_id = slot_arr[1];
		var isChecked = $('#'+this.id).prop('checked');
		var slot_count = $('#slot_count-'+tech_id).val();		
		//alert(tech_id); alert(slot_count); exit;
		if(isChecked){	
			//alert(tech_id); 
			//$('.pop-slot').removeAttr('checked');		
			
			$('#slot_count-'+tech_id).val((slot_count*1)+1); 
			$('#task-tech-'+tech_id).val(slot_tech);
			//alert('chked');
		} else {			
			$('#slot_count-'+tech_id).val((slot_count*1)-1); 			
		}
		if((slot_count>0) && isChecked){
			$('input[class="pop-slot aaa"]').each(function() { 
				this.checked = false; 
			});
			$('#slot_count-'+tech_id).val(1*0);
			alert("You cannot select more than one slot. Select a slot");
		}		
	});
});	

function submitSlot(tech_id){
	// alert(tech_id);
	var slot_tech = $('#task-tech-'+tech_id).val();		
	var task_id = '<?php echo $taskId; ?>';
	//alert(slot_tech); exit;
	$.ajax({url:"ajax/ajax.php?action=assign_task_slot&task_id="+task_id+"&slot_tech="+slot_tech,success:function(result){
		//$("#ajax_res"+tech_id).html(result);
		if(result=='success'){
			$("#ajax_res"+tech_id).html('<span style="color:green;">Assigned the technician in to the task</span>');
			$('#addModal').modal('hide');
			window.location = "<?php echo BASE_URL;?>ocontrol/index.php?page=view_task&id=<?php echo $taskId; ?>&success=Assigned the technician";
		} else {
			$("#ajax_res"+tech_id).html(result);
		}
	}});
}
	
function validateCommission(id){
	var newVal = $('#'+id).val();
	var details = id.split("-");
	var sel_tech_id = details[1];
	var tech_id = details[2];
	var task_id = '<?php echo $taskId; ?>';
	var selCommission = $('#commission_percent-'+sel_tech_id).val();
	var sum = 0; var tot_per = 0;
	if(selCommission!='' && selCommission!='undefined'){
		sum+=selCommission*1;
	}
	$(".comm_per-"+sel_tech_id).each(function() {
		if (!isNaN(this.value) && this.value.length != 0) {
			sum += parseFloat(this.value);
		}
	});
	var mainVal = 100-(sum*1);
	$('#main_per-'+sel_tech_id).val(mainVal);
	var maunTechVal = $('#main_per-'+sel_tech_id).val();
	var totCommission = parseFloat(maunTechVal)+(sum*1);
	//alert(totCommission);
	if(mainVal<1){
		alert('The total commission % for all technicians should not exceed 100');
	}

	/*$.ajax({url:"ajax/ajax.php?action=assign_validate_commission&task_id="+task_id+"&tech_id="+tech_id+"&new_val="+newVal,success:function(result){
			//$("#ajax_res"+tech_id).html(result);	
			if(result>0){
				$("#ajax_result-"+sel_tech_id).html('<span style="color:green;">The commission for Main tech will be '+result+'%</span>');
			} else {
				$("#ajax_result-"+sel_tech_id).html('<span style="color:red;">The commission for Main tech will be '+result+'%</span>');
				//$("#ajax_res"+tech_id).html(result);
			}																	
	}});*/
}

function changeMainCommission(id){
	var newVal = $('#'+id).val();
	var details = id.split("-");
	var sel_tech_id = details[1];
	var tech_id = details[2];
	var task_id = '<?php echo $taskId; ?>';
	var selCommission = $('#commission_percent-'+sel_tech_id).val();
	var sum = 0; var tot_per = 0;
	if(selCommission!='' && selCommission!='undefined'){
		sum+=selCommission*1;
	}
	$(".comm_per-"+sel_tech_id).each(function() {
		if (!isNaN(this.value) && this.value.length != 0) {
			sum += parseFloat(this.value);
		}
	});
	var mainVal = 100-(sum*1);
	$('#main_per-'+sel_tech_id).val(mainVal);
	var maunTechVal = $('#main_per-'+sel_tech_id).val();
	var totCommission = parseFloat(maunTechVal)+(sum*1);
	//alert(totCommission);
	if(mainVal<1){
		alert('The total commission % for all technicians should not exceed 100');
	}
}
</script>
<div class="page-content-wrapper">
	<div class="page-content">
		<div class="page-bar">
			<div class="page-title-breadcrumb">
				<div class=" pull-left"><div class="page-title">Assign Technician</div></div>
				<ol class="breadcrumb page-breadcrumb pull-right">
					<li><i class="fa fa-home"></i>&nbsp;<a class="parent-item" href="index.php?page=home">Home</a>&nbsp;<i class="fa fa-angle-right"></i></li>
					<li><a class="parent-item" href="index.php?page=manage_user_tasks">Manage Tasks</a>&nbsp;<i class="fa fa-angle-right"></i></li><li class="active">Assign Technician</li>
				</ol>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<div class="card card-topline-red">
					<div class="card-head">
						<?php
						if(isset($_REQUEST['extra'])){
						?>
						<header>Assign Extra Technician to task #<?php echo $_REQUEST['task_id']; ?></header>
						<?php
							if(isset($_REQUEST['unavailable']) && $_REQUEST['unavailable']=='yes'){
						?>
						<a href="index.php?page=task_assign_technician&task_id=<?php echo $_REQUEST['task_id']; ?>&extra=yes&unavailable=no" class="btn btn-primary btn-sm mt-2">Hide Unavailable</a>
						<?php
							} else {
						?>
						<a href="index.php?page=task_assign_technician&task_id=<?php echo $_REQUEST['task_id']; ?>&extra=yes&unavailable=yes" class="btn btn-primary btn-sm mt-2">Show Unavailable</a>
						<?php
							}
						} else {
						?>
						<header>Assign Technician to task #<?php echo $_REQUEST['task_id']; ?></header>
						<?php
							if(isset($_REQUEST['unavailable']) && $_REQUEST['unavailable']=='yes'){
						?>
						<a href="index.php?page=task_assign_technician&task_id=<?php echo $_REQUEST['task_id']; ?>&unavailable=no" class="btn btn-primary btn-sm mt-2">Hide Unavailable</a>
						<?php
							} else {
						?>
						<a href="index.php?page=task_assign_technician&task_id=<?php echo $_REQUEST['task_id']; ?>&unavailable=yes" class="btn btn-primary btn-sm mt-2">Show Unavailable</a>
						<?php
							}
						}
						?>
						<div class="tools">
							<a class="t-collapse btn-color fa fa-chevron-down" href="javascript:;"></a>
							<a class="t-close btn-color fa fa-times" href="javascript:;"></a>
						</div>
					</div>
					<div class="card-body ">
						<?php
						if(isset($_REQUEST['success'])){
						?>
						<div class="alert alert-success"><?php echo urldecode($_REQUEST['success']); ?></div>
					</div>
					<?php
						} else if(isset($error) && $error!=''){
					?>
					<div class="alert alert-warning"><?php echo $error; ?></div></div>
				<?php
						}
						if(isset($techDistArray) && count($techDistArray)>0 && empty($error)) {
				?>
				<table class="table table-striped table-bordered table-hover table-checkable order-column" style="width: 100%" id="example4">
					<thead>
						<tr>
							<th> Id </th>
							<th> Name </th>
							<th> Distance </th>
							<th> Service Area </th>
							<th> Info </th>
							<th> Rating </th>
							<th> Assign </th>
						</tr>
					</thead>
					<tbody>
						<?php
							if(isset($_GET['p']) && is_numeric($_GET['p']) && ($_GET['p'] > 1)) {
								$slNo = ($_GET['p']*30-29);
							} else {
								$slNo = 1;
							}
							/*while($resDetails = mysqli_fetch_array($execDetails)) {
							$techPhoto = '';
							if($resDetails['dp']!=''){
							$dp = $resDetails['dp'];
							if($dp == 'image1'){
							$techPhoto =  $resDetails['image1'];
							} else if($dp == 'image2'){
							$techPhoto =  $resDetails['image2'];
							} else if($dp == 'image3'){
							$techPhoto =  $resDetails['image3'];
							} else {
							$techPhoto =  $resDetails['image1'];
							}
							}
							$popContent = '';
							if($techPhoto!=''){
							//$popContent .= '<img src="'.TECH_IMG_URL.$techPhoto.'"/>';
							}*/

							foreach ($techDistArray as $techId => $distance) {
								$resDetails = mysqli_fetch_array(mysqli_query($con, "SELECT * FROM tbl_technician WHERE id = '".$techId."'"));
								$techPhoto = '';
								if($resDetails['dp']!=''){
									$dp = $resDetails['dp'];
									if($dp == 'image1'){
										$techPhoto =  $resDetails['image1'];
									} else if($dp == 'image2'){
										$techPhoto =  $resDetails['image2'];
									} else if($dp == 'image3'){
										$techPhoto =  $resDetails['image3'];
									}
								} else {
									if($resDetails['image1']!=''){
										$techPhoto =  $resDetails['image1'];
									} else if($resDetails['image2']!=''){
										$techPhoto =  $resDetails['image2'];
									} else if($resDetails['image3']!=''){
										$techPhoto =  $resDetails['image3'];
									}
								}
								$popContent = '';
								if($techPhoto!=''){
									$popContent .= '<img src="'.TECH_IMG_URL.$techPhoto.'"/>';
								} else {
									//$popContent .= '<br>No Image';
									$techPhoto = 'dummy_user.png';
									$popContent .= '<img src="'.TECH_IMG_URL.$techPhoto.'"/>';
								}
								//get tech service area
								$techAvailLocation = $techAvailRadius = '';
								$techLocationRec = mysqli_fetch_array(mysqli_query($con, "SELECT * FROM `tbl_technician_location` WHERE `technician_id` = '".$resDetails['id']."'"));
								$techAvailLocationArr = explode(',',$techLocationRec['location']);
								$techAvailLocation = $techAvailLocationArr[0];
								$techAvailRadius = $techLocationRec['radius'];
								//get tech info
								$techBalance = getBalanceTech($techId); //the amount in tech hand
								$liiMRPayableToTech = $techPayableToLiiMR = 0;
								if($techBalance>0){
									$liiMRPayableToTech = 0;
									$techPayableToLiiMR = $techBalance;
								} else {
									$liiMRPayableToTech = abs($techBalance);
									$techPayableToLiiMR = 0;
								}
								$techTaskCount = getTotTaskCountTech($techId);
						?>
						<tr class="odd gradeX">
							<td>
								<?php
								if($resDetails['availability']!='on'){
								?>
								<div style="width:100px;"><img src="images/not-available-img.png"></div>
								<?php
								}
								if($techPhoto!=''){
								?>
								<a target="_blank" href="index.php?page=view_technician&id=<?php echo $resDetails['id']; ?>" data-toggle="popover" title="" data-html="true" data-content='<div style="text-align:center;"><img style="width:150px;" src="<?php echo TECH_IMG_URL.$techPhoto; ?>"/></div>'><?php echo TECH_ID.$resDetails['id']; ?></a>
								<?php
								} else {
								?>
								<a href="#" data-toggle="popover" title="<?php echo $resDetails['name']; ?>" data-html="true" data-content="<?php echo $popContent; ?>"><?php echo TECH_ID.$resDetails['id']; ?></a>
								<?php
								}
								?>
							</td>
							<td><?php echo $resDetails['name']; ?><br>
								<?php echo 'Ph:'.$resDetails['phone']; ?>
							</td>
							<td><?php echo $distance.' Km'; ?></td>
							<td><?php echo $techAvailLocation.', '.$techAvailRadius.'Km'; ?></td>
							<td>Due to Tech: <?php echo 'Rs. '.money_format('%!i', $liiMRPayableToTech); ?><br>
								Due to <?php echo($adminLabel); ?>: <?php echo 'Rs. '.money_format('%!i', $techPayableToLiiMR); ?><br>
								Tasks: <?php echo $techTaskCount; ?>
							</td>
							<td><?php echo getTechRating($resDetails['id']); ?></td>
							<td class="valigntop">
								<?php
								if(isset($_REQUEST['extra'])){
									if($taskRec['fixed_rate']>0){
								?>
								<button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#myModal<?php echo $resDetails['id'];?>">Assign</button>
								<!-- The Modal -->
								<div class="modal fade" id="myModal<?php echo $resDetails['id'];?>">
									<div class="modal-dialog">
										<div class="modal-content">
											<!-- Modal Header -->
											<div class="modal-header">
												<h4 class="modal-title">Set Commission</h4>
												<button type="button" class="close" data-dismiss="modal">&times;</button>
											</div>
											<!-- Modal body -->
											<div class="modal-body">
												<div id="ajax_result-<?php echo $resDetails['id'];?>"></div>
												<form name="regForm" id="regForm<?php echo $resDetails['id'];?>" action="" method="post">
													<?php
										$tt = 0; $cc = 0;
										$totalCommissionPer = 100;
										if($showExtraTechs){
											//echo "SELECT technician_id, commission_percent FROM tbl_job_extra_tech WHERE job_id = '".$taskId."' AND commission_percent > 0";
											$chkExtraRs = mysqli_query($con, "SELECT technician_id, commission_percent FROM tbl_job_extra_tech WHERE job_id = '".$taskId."' AND commission_percent > 0");
											while($extraTechAddedRec = mysqli_fetch_array($chkExtraRs)){
													?>
													<div class="form-group row">
														<label for="email" class="col-6 col-form-label"><?php echo getTechnicianName($extraTechAddedRec['technician_id']); ?></label>
														<div class="col-6 pt-2">
															<input class="form-control col-6 comm_per-<?php echo $resDetails['id'];?>" onblur="validateCommission(this.id)" name="extra_per-<?php echo $extraTechAddedRec['technician_id'];?>" id="extra_per-<?php echo $resDetails['id'];?>-<?php echo $extraTechAddedRec['technician_id'];?>" type="text" value="<?php echo $extraTechAddedRec['commission_percent']; ?>">
														</div>
													</div>
													<?php
												$tt+= $extraTechAddedRec['commission_percent']; $cc++;
											}
										}
													?>
													<div class="form-group row">
														<label for="main_per" class="col-6 col-form-label">For Main Tech (%)</label>
														<div class="col-6 pt-2">
															<input class="form-control col-3" readonly="readonly" name="main_per" id="main_per-<?php echo $resDetails['id'];?>" type="text" value="<?php echo $totalCommissionPer-$tt;  ?>">
														</div>
													</div>
													<?php
										//if($tt>0){
													?>
													<!--<div class="form-group row"><div style="color: #806100;" class="col-12">You can submit a commission percent upto <?php echo (100-$tt).'%';?> </div></div>-->
													<?php 
										//}
													?>
													<div class="form-group">
														<label for="email" class="col-12 col-form-label">Commission Percent</label>
														<div class="col-12">
															<input class="form-control col-12" name="commission_percent" onblur="changeMainCommission(this.id)" id="commission_percent-<?php echo $resDetails['id'];?>" type="text" value="<?php if(isset($_POST['commission_percent']) && $_POST['commission_percent']!=''){ echo $_POST['commission_percent']; } ?>">
														</div>
													</div>
													<div class="form-group row justify-content-md-center mt-4 mb-2">
														<div class="col-12">
															<button id="btn-<?php echo $resDetails['id'];?>" type="button" name="submit" data-backdrop="static" class="btn btn-primary submit-pop">Submit</button>
														</div>
													</div>
												</form>
											</div>
											<!-- Modal footer -->
											<div class="modal-footer">
												<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
											</div>
										</div>
									</div>
								</div>
								<script>
									/*$( "form" ).submit(function( event ) {
									event.preventDefault();
									});*/
								</script>
								<!-- The Modal -->
								<?php
									} else {
								?>
								<a class="btn btn-xs deepPink-bgcolor" href="index.php?page=view_task&id=<?php echo $taskId; ?>&action=assign_extra&technician_id=<?php echo $resDetails['id']; ?>">Assign</a>
	                                                	<?php
									}
								} else {
								?>
								<!--<a class="btn btn-xs deepPink-bgcolor" href="index.php?page=view_task&id=<?php echo $taskId; ?>&action=assign&technician_id=<?php echo $resDetails['id']; ?>">Assign</a>-->
								<button type="button" class="btn btn-xs deepPink-bgcolor" data-toggle="modal" data-target="#myModalSlots<?php echo $resDetails['id'];?>">Assign</button><br>
								<!-- The Modal Slots -->
								<div class="modal fade" id="myModalSlots<?php echo $resDetails['id'];?>">
									<div class="modal-dialog">
										<div class="modal-content">
											<!-- Modal Header -->
											<div class="modal-header">
												<h4 class="modal-title">Assign Slot to <?php echo getTechnicianName($resDetails['id']);?> </h4>
												<button type="button" class="close" data-dismiss="modal">&times;</button>
											</div>
											<!-- Modal body -->
											<div class="modal-body">
												<div id="ajax_res<?php echo $resDetails['id'];?>"></div>
												<form name="assignForm" id="assignForm<?php echo $resDetails['id'];?>" action="" method="post">
													<div class="form-group row mt-2 mb-2  pl-4"> Select an inactive slot to assign time to technician </div>
													<div class="form-group row mt-2 mb-2  pl-4"> Task ID : #<?php echo $taskId; ?> </div>
													<div class="form-group row mt-2 mb-2  pl-4"> Task Date : <?php echo getFormattedDate($taskDate); ?> </div>
													<div  class="form-group row mt-2 mb-4  pl-4"> Task Time : <?php echo getFormattedTime($taskTime); ?> </div>
													<div  class="form-group row mt-2 mb-2">
														<div class="col-md-12">
															<div>
																<?php
									$bookedSlots = getTechBusySlots($con, $resDetails['id'], $taskDate);
									$enabledSlots = getTechEnabledSlots($con, $resDetails['id'], $taskDate);
									//print_r($enabledSlots);
									$ampm = 'am';
									for($hr=$startHour;$hr<=22;$hr+=2){
										$hrStart = $hr;
										$hrBetween = $hr+1;
										$hrEnd = $hr+2;
										//check if any task already assigned to the tech.if so show the slot as enabled
										//and check if any slot admin already alloted for the tech. if so disable that too
										//echo $hrStart;
										if(in_array($hrStart, $bookedSlots) || in_array($hrBetween, $bookedSlots)){  //|| in_array($hrEnd, $bookedSlots) - to disable the slot just before selected one
											$enableSlot = true;
										} else {
											$enableSlot = false;
										}
										if(in_array($hrStart, $enabledSlots)){
																?>
																<div class="slot_main">
																	<label class="switch">
																		<div class="slot_label">
																			<?php
											if($hrStart==0){ echo '12';} else { echo $hrStart; } if($hrStart<12){echo 'am';} else {echo 'pm';}?> - <?php echo $hrEnd;if($hrEnd<12){echo 'am';} else {echo 'pm';}?>
																		</div>
																		<?php
											if($hr<10){$hr='0'.$hr;}
											$hr2 = $hr+2; if($hr2<10){$hr2='0'.$hr2;}
											$timeString = $hr.':00:00-'.($hr2).':00:00';
																		?>
																		<input <?php if($enableSlot){ echo 'disabled="disabled" checked'; echo ' class="pop-slot-booked"'; } else { ?> class="pop-slot" <?php } ?> id="<?php echo $hr.'-'.$resDetails['id'];?>" name="slot_time[]" type="checkbox" value="<?php echo $hr;?>:00:00-<?php echo $hr2;?>:00:00" >
																		<span <?php if($enableSlot){ echo 'style="background-color:green;"'; }?> class="slider round"></span>
																	</label>
																</div>
																<?php
										}
									}
																?>
															</div>
														</div>
													</div>
													<input type="hidden" id="slot_count-<?php echo $resDetails['id'];?>" value="0">
													<input type="hidden" id="task-tech-<?php echo $resDetails['id'];?>"  value="">
													<div class="form-group row justify-content-md-center mt-4 mb-2">
														<div class="col-12">
															<button id="<?php echo $resDetails['id'];?>" onclick="submitSlot(this.id)" type="submit" name="submit_slot" data-backdrop="static" class="btn btn-primary submit-pop-slot">Submit</button>
														</div>
													</div>
												</form>
											</div>
											<!-- Modal footer -->
											<div class="modal-footer">
												<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
											</div>
										</div>
									</div>
								</div>
								<script>
									$( "form" ).submit(function( event ) {
										event.preventDefault();
									});
								</script>
								<!-- The Modal Slots-->
								<?php
								}
								?>
								<a target="_blank" class="btn btn-xs deepPink-bgcolor" href="index.php?page=tech_bookings&tech_id=<?php echo $resDetails['id']; ?>">Bookings</a>
								<?php /*if(!isset($_REQUEST['extra'])){ /*Show this option only for main technician*/ ?>
								<?php //} //if not extra ?>
							</td>
						</tr>
						<?php
								++$slNo;
							}
						?>
					</tbody>
				</table>
				<?php
						} else {
				?>
				<div class="alert alert-danger">Sorry! No Results Found.</div>
				<?php
						}
				?>
			</div>
		</div>
	</div>
</div>
</div>
</div>

<script>
$(document).ready(function(){
    //$('[data-toggle="popover"]').popover();
    $('[data-toggle="popover"]').popover({
        placement : 'top',
        trigger : 'hover'
        //trigger: 'focus'
    }); 
});
</script>