<style>
.control-label {  
  padding-top: 0 !important;
}
.div-left {  
  width: 100%;
}
</style>
<style>
@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%;  
	}
	td:nth-of-type(1)::before {
	  content: "";
	}
}
</style>
<script>
function showDiv() {	
	$('#add_div').show();
}
function showAdjust() {	
	$('#adjust_div').show();
}
function showExtra() {	
	$('#extra_div').show();
}
function showSms() {	
	$('#sms_div').show();
}
</script>
<link rel="stylesheet" href="css/colorbox.css" />
<script src="assets/plugins/jquery/jquery.min.js" ></script>
<script src="js/jquery.colorbox.js"></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">View Task</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">View Task</li>
                            </ol>
                        </div>
                    </div>
<div class="row">
                        <div class="col-md-12 col-sm-12">
                            <div class="card card-box">
                                <div class="card-head">
                                    <header>Task #<?php echo $resEdit['id'];?></header>  
                                    <div style="margin-left:20px;">
	                                	<a class="btn btn-info" href="index.php?page=manage_user_tasks&p=<?php echo $p;?>">Back</a>&nbsp;	
	                                	<?php if($resEdit['technician_id']==0 && ($resEdit['status']!='paid')){ ?>                                	
	                                	<a target="_blank" class="btn btn-info" href="index.php?page=task_assign_technician&task_id=<?php echo $resEdit['id']; ?>">Find Technician</a>
	                                	<?php } ?>
	                                	<?php if($resEdit['tech_request']=='yes'){ ?>
	                                		<a target="_blank" class="btn btn-info" href="index.php?page=task_assign_technician&task_id=<?php echo $resEdit['id']; ?>&extra=yes">Find Extra Technician</a>
	                                	<?php } ?>
	                                </div>   
	                                <div style="float: right;margin-left: 10px;margin-right: 5px;">Status: <?php if($resEdit['status']=='assigned'){ echo 'Assigned to Technician';} else { echo $resEdit['status'];}?></div>                               
                                </div>
                                <div class="card-body" id="bar-parent1">
                                	
                                	<?php if(isset($_REQUEST['success'])){ ?>                                		
                                		<div class="alert alert-success"><?php echo urldecode($_REQUEST['success']); ?></div>
                                	<?php } ?>                               	
                                	                              		
                                		                                      	                          	                                	
                                    <form action="" id="form_staff_add" class="form-horizontal" method="post">                                    	
                                        <div class="form-body div-left">                                        	                                        	 
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">User</label>                                                
                                                <div class="col-md-4">                                                    
                                                    <a target="_blank" href="index.php?page=view_user&id=<?php echo $resEdit['user_id']; ?>"><?php echo getUserName($resEdit['user_id']);?></a>
                                                    
												    &nbsp;&nbsp;<a target="_blank" class="btn btn-xs deepPink-bgcolor" href="index.php?page=admin_login&action=admin_login&user_id=<?php echo $resEdit['user_id']; ?>">Login</a>
												    
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Technician</label>
                                                <div class="col-md-4">                                                  	                                                                                                                                                                
                                                    <?php if($resEdit['technician_id']==0){ ?>
                                                    	<!--<a target="_blank" class="btn btn-xs deepPink-bgcolor" href="index.php?page=task_assign_technician&task_id=<?php echo $resEdit['id']; ?>">Find Technician near this User</a>-->
                                                    <?php } else { ?>                                                    	
														 <a target="_blank" href="index.php?page=view_technician&id=<?php echo $resEdit['technician_id']; ?>"><?php echo getTechnicianName($resEdit['technician_id']); ?></a>
														 <?php if(($resEdit['status']=='waiting') || ($resEdit['status']=='assigned') || ($resEdit['status']=='accepted') || ($resEdit['status']=='start_off') || ($resEdit['status']=='arrived') || ($resEdit['status']=='start_job')){ ?>
														 &nbsp;&nbsp;<a class="btn btn-xs deepPink-bgcolor" href="index.php?page=view_task&id=<?php echo $resEdit['id']; ?>&action=cancel_tech">Cancel</a>
														 <?php } ?>
												    <?php } ?>
												    <?php if($resEdit['technician_id']>0){ ?>
												    &nbsp;&nbsp;<a target="_blank" class="btn btn-xs deepPink-bgcolor" href="index.php?page=admin_login&action=tech_login&tech_id=<?php echo $resEdit['technician_id']; ?>">Login</a>
												    <?php } ?>												    
                                                </div>
                                            </div>
                                            <?php if(mysqli_num_rows($extraTechRs)>0){
                                            	$cc = 1; 
                                            	while($extraTechRec = mysqli_fetch_array($extraTechRs)){
                                            		if($extraTechRec['technician_id']>0){ ?>
                                            		<div class="form-group row">
		                                                <label class="control-label col-md-3">Extra Technician <?php echo $cc; ?></label>
		                                                <div class="col-md-4">                                                    
		                                                    <a target="_blank" href="index.php?page=view_technician&id=<?php echo $extraTechRec['technician_id']; ?>"><?php echo getTechnicianName($extraTechRec['technician_id']);?></a>
		                                                    <?php if($resEdit['fixed_rate']>0){ ?>
		                                                    &nbsp;&nbsp;(<?php echo $extraTechRec['commission_percent'].'%';?>)
		                                                    <?php } ?>
		                                                    
		                                                    <?php if($extraTechRec['status']=='assigned' || $extraTechRec['status']=='accepted' || $extraTechRec['status']=='start_off' || $extraTechRec['status']=='arrived'){ ?>
															 &nbsp;&nbsp;<a class="btn btn-xs deepPink-bgcolor" href="index.php?page=view_task&id=<?php echo $resEdit['id']; ?>&action=cancel_extra_tech&extra_id=<?php echo $extraTechRec['technician_id']; ?>">Cancel</a>
															<?php } ?>
															<?php if($extraTechRec['technician_id']>0){ ?>
														    &nbsp;&nbsp;<a target="_blank" class="btn btn-xs deepPink-bgcolor" href="index.php?page=admin_login&action=tech_login&tech_id=<?php echo $extraTechRec['technician_id']; ?>">Login</a>
														    <?php } ?>
		                                                </div>
		                                            </div>                                            
                                            <?php $cc++; } } ?>
											<?php } ?>
											<?php if($resEdit['fixed_rate']>0 && $buttonHours<24 && ($resEdit['status']=='completed' || $resEdit['status']=='start_job' || $resEdit['status']=='user_paid' || $resEdit['status']=='paid')){ ?>																				
													<a target="_blank" style="margin-left:250px" class="btn btn-primary btn-sm" href="index.php?page=change_commission&task_id=<?php echo $resEdit['id']; ?>">Change Rates and Commission</a>
											<?php } ?>
											
											<?php if($resEdit['fixed_rate']==0 && $buttonHours<24){ ?>
												<a target="_blank" style="margin-left:250px" class="btn btn-primary btn-sm" href="index.php?page=change_commission&task_id=<?php echo $resEdit['id']; ?>">Change Rates and Commission</a>
											<?php } ?>
											
                                            <?php /*if($resEdit['technician_id']>0){ ?>
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Technician</label>
                                                <div class="col-md-4">  
                                                    <a target="_blank" href="index.php?page=view_technician&id=<?php echo $resEdit['technician_id']; ?>"><?php echo getTechnicianName($resEdit['technician_id']); ?></a>
                                                </div>
                                            </div>
                                            <?php }*/ ?>
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Category</label>
                                                <div class="col-md-4">  
                                                	<?php $parentCategory = getParentCategory($resEdit['category_id']); 
                                                	if($parentCategory!='NA'){
														echo $parentCategory.' -->';
													}?>                                                  
                                                    <?php echo getCategory($resEdit['category_id']);?>
                                                </div>
                                            </div>  
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Order Date</label>
                                                <div class="col-md-4">        
                                                	<?php echo getFormattedDate($resEdit['date']);?>                                            
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Task Date</label>
                                                <div class="col-md-4">        
                                                	<?php echo getFormattedDate($resEdit['task_date']);?>                                            
                                                </div>
                                            </div>
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Task Time</label>
                                                <div class="col-md-4">        
                                                	<?php if($resEdit['task_time']!='00:00:00'){ echo $resEdit['task_time']; } ?>                                            
                                                </div>
                                            </div>
                                            <?php if($resEdit['admin_slot']!='00:00:00'){ ?>
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Assigned Slot</label>
                                                <div class="col-md-4">        
                                                	<?php echo getAdminSlot($resEdit['id']); ?>                                            
                                                </div>
                                            </div>
                                            <?php } ?>
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Details</label>
                                                <div class="col-md-4">        
                                                	<?php echo $resEdit['details'];?>                                            
                                                </div>
                                            </div>
                                            <?php if($resEdit['image']!=''){ ?>
                                            <div class="form-group row">
                                                <img style="max-width:500px;" src="<?php echo TASK_IMG_URL.$resEdit['image'];?>">
                                            </div>
                                            <?php } ?>
                                            
                                            <div class="form-group row">
                                                <label class="control-label col-md-3">Task Location</label>
                                                <div class="col-md-4">        
                                                	<?php 
													 //get location details from tbl_job (new flow)
													 if($resEdit['house_name']!=''){
													 	echo $resEdit['house_name']; ?><br>
													 	<?php if($resEdit['street']!=''){ ?>
													 		<?php echo $resEdit['street']; ?><br>
													 	<?php } ?> 
													 	<?php echo $resEdit['place']; ?><br>
													 	<?php echo 'PIN: '.$resEdit['pin']; ?><br>
													 	<?php echo getCityName($resEdit['city']); ?>								
													<?php } else if($resEdit['address_id']>0){ 
													 	$addressRs = mysqli_query($con, "SELECT * FROM tbl_user_address WHERE id = '".$resEdit['address_id']."'");
													 	if(mysqli_num_rows($addressRs)>0){ 
													 		$addressRec = mysqli_fetch_array($addressRs);?> 
													 		<?php echo $addressRec['house_name']; ?><br>
													 		<?php if($addressRec['street']!=''){ ?>
													 			<?php echo $addressRec['street']; ?><br>
													 		<?php } ?> 
													 		<?php echo $addressRec['place']; ?><br>
													 		<?php echo 'PIN: '.$addressRec['pin']; ?><br>
													 		<?php echo getCityName($addressRec['city']); ?>								 	
													 <?php } } else { 
													 	$addressRec = mysqli_fetch_array(mysqli_query($con, "SELECT house_name, street, place, pin, city FROM tbl_user WHERE id = '".$resEdit['user_id']."'"));?>
													 		<?php echo $addressRec['house_name']; ?><br>
													 		<?php if($addressRec['street']!=''){ ?>
													 			<?php echo $addressRec['street']; ?><br>
													 		<?php } ?> 
													 		<?php echo $addressRec['place']; ?><br>
													 		<?php echo 'PIN: '.$addressRec['pin']; ?><br>
													 		<?php echo getCityName($addressRec['city']); ?>
													 <?php } ?>                                           
                                                </div>
                                            </div>
                                            
                                            
                                            <?php $taskStatRs = mysqli_query($con, "SELECT * FROM tbl_job_status WHERE task_id = '".$resEdit['id']."'");
													if(mysqli_num_rows($taskStatRs)>0){ ?>
														<div class="col-10 text-center">
			                                                <b>Job status of <?php echo getTechnicianName($resEdit['technician_id']); ?></b>
			                                            </div>
														
														<?php while($taskStatRec = mysqli_fetch_array($taskStatRs)){ ?>
															<?php if($taskStatRec['status'] == 'start_off'){
																$statShow = 'On the way'; ?>
																<div class="form-group row">
																	<label for="test" class="control-label col-md-3"><?php echo $statShow; ?></label>
																	<div class="col-6">
																		 <?php if($taskStatRec['date']!='0000-00-00 00:00:00'){ echo getFormattedDateTime($taskStatRec['date']);}  ?>   
																	</div> 		
																</div>
															<?php } else if($taskStatRec['status'] == 'arrived'){
																$statShow = 'Arrived'; ?>
																<div class="form-group row">
																	<label for="test" class="control-label col-md-3"><?php echo $statShow; ?></label>
																	<div class="col-6">
																		 <?php if($taskStatRec['date']!='0000-00-00 00:00:00'){ echo getFormattedDateTime($taskStatRec['date']);}  ?>   
																	</div> 		
																</div>
															<?php } else if($taskStatRec['status'] == 'start_job'){
																$statShow = 'Started Job'; ?>
																<div class="form-group row">
																	<label for="test" class="control-label col-md-3"><?php echo $statShow; ?></label>
																	<div class="col-6">
																		 <?php if($taskStatRec['date']!='0000-00-00 00:00:00'){ echo getFormattedDateTime($taskStatRec['date']);}  ?>   
																	</div> 		
																</div>
															<?php } else if($taskStatRec['status'] == 'pause'){
																$statShow = 'Paused Job'; ?>
																<div class="form-group row">
																	<label for="test" class="control-label col-md-3"><?php echo $statShow; ?></label>
																	<div class="col-6">
																		 <?php if($taskStatRec['date']!='0000-00-00 00:00:00'){ echo getFormattedDateTime($taskStatRec['date']);}  ?>   
																	</div> 		
																</div>
															<?php } else if($taskStatRec['status'] == 'resume'){
																$statShow = 'Resumed Job'; ?>
																<div class="form-group row">
																	<label for="test" class="control-label col-md-3"><?php echo $statShow; ?></label>
																	<div class="col-6">
																		 <?php if($taskStatRec['date']!='0000-00-00 00:00:00'){ echo getFormattedDateTime($taskStatRec['date']);}  ?>   
																	</div> 		
																</div>
															<?php } else if($taskStatRec['status'] == 'completed'){
																$statShow = 'Completed Job'; ?>
																<div class="form-group row">
																	<label for="test" class="control-label col-md-3"><?php echo $statShow; ?></label>
																	<div class="col-6">
																		 <?php if($taskStatRec['date']!='0000-00-00 00:00:00'){ echo getFormattedDateTime($taskStatRec['date']);}  ?>   
																	</div> 		
																</div>
															<?php } ?>
															
															
													<?php } ?>
															<?php if($taskStatRec['status']=='completed' || $taskStatRec['status']=='user_paid' || $taskStatRec['status']=='paid'){ ?>
																<div class="form-group row">
		                                                            <label for="test" class="control-label col-md-3">Time spent</label>
		                                                            <div class="col-6">
		                                                                 <?php echo $mainTechTaskTime;   ?>   
		                                                            </div> 		
		                                                        </div>
		                                                        <div class="form-group row">
		                                                            <label for="test" class="control-label col-md-3">Tech Income</label>
		                                                            <div class="col-6">
		                                                                 <b><?php echo 'Rs.'.$mainTechTaskIncome;   ?></b>   
		                                                            </div> 		
		                                                        </div>
		                                                        <div class="form-group row">
		                                                            <label for="test" class="control-label col-md-3">Admin Commission.</label>
		                                                            <div class="col-6">
		                                                                 <?php echo 'Rs.'.$mainTechAdminCommission;   ?>   
		                                                            </div> 		
		                                                        </div>
	                                                        <?php } ?>
													
													<?php } ?>
                                            		<?php if($resEdit['fixed_rate']>0){ ?>
															<div class="form-group row">										
																<div class="col-12 pt-2">
																	 <b>Changed the task amount to fixed rate Rs: <?php echo $resEdit['fixed_rate']; ?></b>   
																</div> 		
															</div>
													<?php } ?>
													
													
													<!--Extra Technician Status-->
													<?php $extraTechRs = mysqli_query($con, "SELECT * FROM tbl_job_extra_tech WHERE job_id = '".$editId."'"); 
													if(mysqli_num_rows($extraTechRs)>0){ ?>
													<?php while($extraTechRec = mysqli_fetch_array($extraTechRs)){ ?>
													<div class="col-10 text-center">
														<b>Extra Technician - <?php echo getTechnicianName($extraTechRec['technician_id']);?></b>					
													</div>
													<?php 
													$taskExtraStatRs = mysqli_query($con, "SELECT * FROM tbl_job_extra_tech_status WHERE task_id = '".$editId."' AND tech_id = '".$extraTechRec['technician_id']."' ORDER BY id");
													if(mysqli_num_rows($taskExtraStatRs)>0){ 
														while($taskExtraStatRec = mysqli_fetch_array($taskExtraStatRs)){ ?>
															<?php if($taskExtraStatRec['status'] == 'start_off'){
																$statShow = 'On the way'; ?>
																<div class="form-group row mb-1">
																	<label for="test" class="control-label col-md-3"><?php echo $statShow; ?></label>
																	<div class="col-6">
																		 <?php if($taskExtraStatRec['date']!='0000-00-00 00:00:00'){ echo getFormattedDateTime($taskExtraStatRec['date']);}  ?>   
																	</div> 		
																</div>
															<?php } else if($taskExtraStatRec['status'] == 'arrived'){
																$statShow = 'Arrived'; ?>
																<div class="form-group row mb-1">
																	<label for="test" class="control-label col-md-3"><?php echo $statShow; ?></label>
																	<div class="col-6">
																		 <?php if($taskExtraStatRec['date']!='0000-00-00 00:00:00'){ echo getFormattedDateTime($taskExtraStatRec['date']);}  ?>   
																	</div> 		
																</div>
															<?php } else if($taskExtraStatRec['status'] == 'start_job'){
																$statShow = 'Started Job'; ?>
																<div class="form-group row mb-1">
																	<label for="test" class="control-label col-md-3"><?php echo $statShow; ?></label>
																	<div class="col-6">
																		 <?php if($taskExtraStatRec['date']!='0000-00-00 00:00:00'){ echo getFormattedDateTime($taskExtraStatRec['date']);}  ?>   
																	</div> 		
																</div>
															<?php } else if($taskExtraStatRec['status'] == 'pause'){
																$statShow = 'Paused Job'; ?>
																<div class="form-group row mb-1">
																	<label for="test" class="control-label col-md-3"><?php echo $statShow; ?></label>
																	<div class="col-6">
																		 <?php if($taskExtraStatRec['date']!='0000-00-00 00:00:00'){ echo getFormattedDateTime($taskExtraStatRec['date']);}  ?>   
																	</div> 		
																</div>
															<?php } else if($taskExtraStatRec['status'] == 'resume'){
																$statShow = 'Resumed Job'; ?>
																<div class="form-group row mb-1">
																	<label for="test" class="control-label col-md-3"><?php echo $statShow; ?></label>
																	<div class="col-6">
																		 <?php if($taskExtraStatRec['date']!='0000-00-00 00:00:00'){ echo getFormattedDateTime($taskExtraStatRec['date']);}  ?>   
																	</div> 		
																</div>
															<?php } else if($taskExtraStatRec['status'] == 'completed'){
																$statShow = 'Completed Job'; ?>
																<div class="form-group row mb-1">
																	<label for="test" class="control-label col-md-3"><?php echo $statShow; ?></label>
																	<div class="col-6">
																		 <?php if($taskExtraStatRec['date']!='0000-00-00 00:00:00'){ echo getFormattedDateTime($taskExtraStatRec['date']);}  ?>   
																	</div> 		
																</div>
															<?php } ?>
															<?php if($taskExtraStatRec['status']=='completed'){ 
																$extraTechComplteRec = mysqli_fetch_array(mysqli_query($con, "SELECT * FROM tbl_task_completed WHERE tech_id = '".$extraTechRec['technician_id']."' AND task_id = '".$taskId."'"));
																$extraTechTaskAmount = $extraTechComplteRec['task_amount'];
																$extraTechAdminCommission = $extraTechComplteRec['admin_commission'];
																$extraTechTaskIncome = $extraTechComplteRec['tech_income'];
																$extraTechTaskTime = $extraTechComplteRec['total_hours'];																
																?>
																<div class="form-group row mb-1">
		                                                            <label for="test" class="control-label col-md-3">Time spent</label>
		                                                            <div class="col-6">
		                                                                 <?php echo $extraTechTaskTime;   ?>   
		                                                            </div> 		
		                                                        </div>
		                                                        <div class="form-group row mb-1">
		                                                            <label for="test" class="control-label col-md-3">Tech Income</label>
		                                                            <div class="col-6">
		                                                                 <b><?php echo 'Rs.'.$extraTechTaskIncome;   ?></b>   
		                                                            </div> 		
		                                                        </div>
		                                                        <div class="form-group row mb-1">
		                                                            <label for="test" class="control-label col-md-3">Admin Commission:</label>
		                                                            <div class="col-6">
		                                                                 <?php echo 'Rs.'.$extraTechAdminCommission;   ?>   
		                                                            </div> 		
		                                                        </div>
	                                                        <?php } ?>
													<?php } } ?>
													<?php } } ?>
													<!--Extra Technician Status--> 
													
													<?php if(mysqli_num_rows($disputeRs)>0){ 
														$dispStatRec = mysqli_fetch_array(mysqli_query($con, "SELECT DISTINCT status FROM tbl_job_disputes WHERE task_id = '".$taskId."'"));
														if($dispStatRec['status']=='settled'){
															$dispStat = '<span style="color: green;margin-left: 5px;">Settled</span>'; 
														} else if($dispStatRec['status']=='In Progress'){
															$dispStat = '<span style="color: #eb831b;margin-left: 5px;">In Progress</span>'; 
														} else {
															$dispStat = '<span style="color: #de403a;margin-left: 5px;">Pending</span>'; 
														} ?>
													<div class="col-10 text-center"><b>Dispute Details (<?php echo $dispStat; ?>)</b></div>
														<?php while($disputeRec = mysqli_fetch_array($disputeRs)){ ?>
															<div class="form-group row">
																<label for="test" class="control-label col-md-3">
																	<?php if($disputeRec['from']=='user'){ echo 'Me: '; } else { echo getTechnicianName($disputeRec['technician_id']).': ';} ?>
																</label>
																<div class="col-6">
																	<?php echo $disputeRec['details'];  ?> 
																</div> 		
															</div>
														<?php } ?>	
													<?php } ?>
                                                    
                                                    
                                                    <?php if($resEdit['status']=='completed' || $resEdit['status']=='paid' || $resEdit['status']=='user_paid'){ ?>
                                                    <div class="col-10 text-center">
			                                                <b>Task Amount</b>
			                                        </div>
                                                    
                                                    <?php if($fixedRate>0){ ?>	
                                                        <div class="form-group row">
                                                            <label for="test" class="control-label col-md-3">Fixed Rate</label>
                                                            <div class="col-6">
                                                                 <b><?php echo 'Rs. '.$totCharge;   ?> </b>  
                                                            </div> 		
                                                        </div>											
                                                     <?php } else {  ?>
                                                        <?php if($totalExtraTechAmount>0){ ?>
                                                        <div class="form-group row">
                                                            <label for="test" class="control-label col-md-3">Extra tech. Charges</label>
                                                            <div class="col-6">
                                                                 <?php echo 'Rs. '.$totalExtraTechAmount;   ?>   
                                                            </div> 		
                                                        </div>
                                                        <?php } ?>
                                                        <div class="form-group row">
                                                            <label for="test" class="control-label col-md-3"><b>Total Charge</b></label>
                                                            <div class="col-6">
                                                                 <b><?php echo 'Rs. '.money_format('%!i', $totCharge);   ?></b>                                                                  
                                                            </div> 		
                                                        </div>
                                                        <?php if($adminDiscount>0){ ?>
                                                        <div class="form-group row">
                                                            <label for="test" class="control-label col-md-3"><b>Admin Discounted Charge</b></label>
                                                            <div class="col-6">
                                                                 <b><?php $totCharge = $totCharge-$adminDiscount; echo 'Rs. '.number_format((float)($totCharge), 2, '.', '');   ?></b>                                                                 
                                                            </div> 		
                                                        </div>
                                                        <?php } else if($techDiscount>0){ ?>
                                                        <div class="form-group row">
                                                            <label for="test" class="control-label col-md-3"><b>Technician Discounted Charge</b></label>
                                                            <div class="col-6">
                                                                 <b><?php $totCharge = $totCharge-$techDiscount; echo 'Rs. '.number_format((float)($totCharge), 2, '.', '');   ?></b>                                                                 
                                                            </div> 		
                                                        </div>
                                                        <?php } ?>
                                                        <?php if($adminExtra>0){ ?>
                                                        <div class="form-group row">
                                                            <label for="test" class="control-label col-md-3"><b>Total with Extra Charge</b></label>
                                                            <div class="col-6">
                                                                 <b><?php $totCharge = $totCharge+$adminExtra; echo 'Rs. '.number_format((float)($totCharge), 2, '.', '');   ?></b>                                                                 
                                                            </div> 		
                                                        </div>
                                                        <?php } ?>                                            
	                                                    <?php } ?>
	                                                    <div class="form-group row">
                                                            <label for="test" class="control-label col-md-3">Total Admin Commission</label>
                                                            <div class="col-6">
                                                                 <?php $totalTaskAdminCommission = getTotTaskAdminCommission($taskId); echo 'Rs. '.$totalTaskAdminCommission;   ?>                                                               
                                                            </div> 		
                                                        </div>
                                                   <?php } ?>
                                                   
                                                   <?php if($resEdit['status']=='completed' || $resEdit['status']=='start_job'){ ?>
	                                                   <div class="form-group row">
	                                                       <label for="test" class="control-label col-md-3"></label>
	                                                       <div class="col-8">
	                                                            <span id="adjust" onclick="showAdjust();" style="margin-left:10px;padding:4px 14px;cursor:pointer;" class="badge badge-info">Make Adjustments</span>
	                                                            <span id="extra" onclick="showExtra();" style="margin-left:10px;padding:4px 14px;cursor:pointer;background-color: #e06d65;" class="badge badge-info">Add Extra Charge</span>
	                                                            <span id="sms" onclick="showSms();" style="margin-left:10px;padding:4px 14px;cursor:pointer;background-color: #e06d65;" class="badge badge-info">Send SMS</span>                                                                  
	                                                       </div> 		
	                                                   </div>    
                                                   
                                                   		<?php if(isset($adjustError) && $adjustError!='') { ?> 
					                                		<div class="alert alert-danger"><?php echo $adjustError; ?></div>
					                                	<?php } else if(isset($adjustSuccess) && $adjustSuccess!=''){ ?>                                		
					                                		<div class="alert alert-success"><?php echo $adjustSuccess; ?></div>
					                                	<?php } ?>
					                                	
                                                        <div id="adjust_div" <?php if(isset($_POST['submit_discount'])){ echo 'style="display:block;"'; } else { echo 'style="display:none;"'; }?> >
	                                                        <div class="form-group row">
	                                                            <label for="test" class="control-label col-md-3">Enter Discount Amount</label>
	                                                            <div class="col-6">
	                                                                 <input type="text" name="discount" id="discount" value="<?php if(isset($_POST['discount']) && $_POST['discount']!=''){ echo $_POST['discount']; }?>"><br>
	                                                                 <span style="font-size: 11px;color: red;">Note: If any extra charge added will be cancelled</span>   
	                                                            </div> 		
	                                                        </div>
	                                                        <div class="form-group row">
	                                                            <label for="test" class="control-label col-md-3">Discount From</label>
	                                                            <div class="col-2">
	                                                                <input type="radio" name="discount_from" id="discount_from_admin" value="admin" <?php if(isset($_POST['discount_from']) && $_POST['discount_from']=='admin'){ echo 'checked'; }?> > Admin    
	                                                            </div>
	                                                            <div class="col-2">
	                                                                <input type="radio" name="discount_from" id="discount_from_technician" value="technician" <?php if(isset($_POST['discount_from']) && $_POST['discount_from']=='technician'){ echo 'checked'; }?> >  Technician
	                                                            </div> 		
	                                                        </div>
	                                                        <div class="form-group row">  
	                                                        	<label for="test" class="control-label col-md-3"></label>                                                          
	                                                            <div class="col-6">
	                                                                    <button type="submit" name="submit_discount" class="btn btn-info">Submit</button>
	                                                            </div> 		
	                                                        </div>
	                                                    </div>                                                        
                                                     	
                                                     
                                                     
                                                     	<?php if(isset($extraError) && $extraError!='') { ?> 
					                                		<div class="alert alert-danger"><?php echo $extraError; ?></div>
					                                	<?php } else if(isset($extraSuccess) && $extraSuccess!=''){ ?>                                		
					                                		<div class="alert alert-success"><?php echo $extraSuccess; ?></div>
					                                	<?php } ?>
					                                	
                                                        <div id="extra_div" <?php if(isset($_POST['submit_extra'])){ echo 'style="display:block;"'; } else { echo 'style="display:none;"'; }?> >
	                                                        <div class="form-group row">
	                                                            <label for="test" class="control-label col-md-3">Enter Extra Amount</label>
	                                                            <div class="col-6">
	                                                                 <input type="text" name="admin_extra" id="admin_extra" value="<?php if(isset($_POST['admin_extra']) && $_POST['admin_extra']!=''){ echo $_POST['admin_extra']; }?>"><br>
	                                                                 <span style="font-size: 11px;color: red;">Note: If any admin/tech discount added will be cancelled</span>   
	                                                            </div> 		
	                                                        </div>
	                                                        <div class="form-group row">  
	                                                        	<label for="test" class="control-label col-md-3"></label>                                                          
	                                                            <div class="col-6">
	                                                                    <button type="submit" name="submit_extra" class="btn btn-info">Submit</button>
	                                                            </div> 		
	                                                        </div>
	                                                    </div>
	                                                    
	                                                    <div id="sms_div" <?php if(isset($_POST['submit_sms'])){ echo 'style="display:block;"'; } else { echo 'style="display:none;"'; }?> >
	                                                        <div class="form-group row">
	                                                            <label for="test" class="control-label col-md-3">Message</label>
	                                                            <div class="col-6">	                                                                 
	                                                                 <textarea cols="30" rows="5" name="sms_msg" id="sms_msg"><?php if(isset($_POST['sms_msg']) && $_POST['sms_msg']!=''){ echo $_POST['sms_msg']; } else if(isset($smsMessage)){ echo urldecode($smsMessage); }?></textarea>  
	                                                            </div> 		
	                                                        </div>
	                                                        <div class="form-group row">  
	                                                        	<label for="test" class="control-label col-md-3"></label>                                                          
	                                                            <div class="col-6">
	                                                            	<input type="hidden" name="user_id" value="<?php echo $resEdit['user_id'];?>">
	                                                                    <button type="submit" name="submit_sms" class="btn btn-info">Submit</button>
	                                                            </div> 		
	                                                        </div>
	                                                    </div>
                                                                                                  
                                                   <?php } ?>
													
													<div id="add_note" class="form-group row">		                                                
		                                                <div class="col-10 text-center">                                                    
		                                                    <b>Add Note</b>
		                                                </div>
		                                            </div>
													
													<div class="form-group row">		                                                
		                                                <div class="col-10 text-center">                                                    
		                                                    <textarea name="note" id="note" cols="30" rows="4" class="form-control"><?php if(isset($_POST['note'])){ echo $_POST['note']; }?></textarea>
		                                                </div>
		                                            </div>   
		                                            <div class="form-group row">		                                                
		                                                <div class="col-10 text-center">                                                    
		                                                    <button type="submit" name="submit_note" class="btn btn-info">Submit</button>
		                                                </div>
		                                            </div> 
		                                            
		                                            <?php if(mysqli_num_rows($taskNotesRs)>0){ ?>
													<div class="col-10 text-center"><b>Task Notes</b></div>
														<?php while($notesRec = mysqli_fetch_array($taskNotesRs)){ ?>
															<div class="form-group row">																
																<div class="col-10 pt-2 border" style="background-color: #efefef;">																	
																	<div class="col-12 row">
																		<div style="width: 30%;float: left;color: #937820;">
																			<?php echo getFormattedDateTime($notesRec['date']);  ?> 
																		</div>
																		<div style="width: 70%;float: left;color: #937820;text-align: right;">
																			Added By: <?php echo getAdminUserName($notesRec['added_by']);  ?> 
																		</div>
																	</div>
																	<div class="col-12 row">
																		<div style="width: 100%;float: left;padding: 4px;">
																			<?php echo $notesRec['note'];  ?> 
																		</div>																		
																	</div>
																</div> 		
															</div>
														<?php } ?>	
													<?php } ?>                                                                                   
                                        </div>  
                                                                              
                                      	
                                    </form>
                                </div>
                            </div>
                        </div>
                        
                        
                        
                        
                        
                    </div>
	</div>
</div>
<script>
			(function ($) {						
		        $(".commission").colorbox({  
				   iframe:true, 
				   fastIframe:false,
				   width: '600px', 
				   height:"400px",        
		           maxWidth:'70%'
		        });
			})(jQuery);
		</script>
