<?php
include("common/connection.php");
//login_check();
$_REQUEST['d'];
$_REQUEST['tid'];
$user_type_sql="select User_Type from user_master where User_Name='".$_SESSION['user']."'";
$user_type_query=mysqli_query($con,$user_type_sql);
$user_type=mysqli_fetch_array($user_type_query);

/*$lead_basic_sql="select * from lead_master where Lead_ID='".$Lead_Req_Id."'";
$lead_basic_query=mysqli_query($con,$lead_basic_sql);
$lead_details=mysqli_fetch_array($lead_basic_query);*/
?>

<!doctype html>
<html class="no-js" lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>view Roster Plan | Buurtzorg</title>
    <?php include("headerlink.php"); ?> 
     <link rel="stylesheet" href="css/form/all-type-forms.css">
    <!-- x-editor CSS
		============================================ -->
    <link rel="stylesheet" href="css/editor/select2.css">
    <link rel="stylesheet" href="css/editor/datetimepicker.css">
    <link rel="stylesheet" href="css/editor/bootstrap-editable.css">
    <link rel="stylesheet" href="css/editor/x-editor-style.css">

    
	<style>
	
	.table_head_class{
		background-color:#337ab7;
		height:30px;
		line-height:30px;
		text-align:center;
		color:#FFF;
		font-size:15px;
	}
	
		.table_body_class{
		background-color:#f7f7f6;
		height:auto;
		padding:5px 2%
	}
	
	
	</style>
	
	
	
	
    <script>
	function unlock_form() {
	 
	$('#edit_c_form  input'). prop("disabled", false);
	//$('#not_editable  input'). prop("disabled", true);
	$('#edit_c_form  textarea'). prop("disabled", false);
	$('#edit_c_form  select'). prop("disabled", false);
	$('#update_btn').show();
	$('#edit_btn_1').hide();
	
 
	}
	</script>
    
    <script>
	function call_status(per) {
	 
	// alert(per);
	if(per=='Call Later') {
	$('#call_later').show();
	$('#call_later_time').show();
	
	} 	
	else{
	
	  $('#call_later').hide();
	  $('#call_later_time').hide();
	}
 
	}
	
 
	</script> 
    
    <script>
function isNumberKey(evt) 
{
var charCode = (evt.which) ? evt.which : event.keyCode; 
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) 
{
return false;
} 
else 
{
return true;
} 
} 

</script>
    
<script>
function confirm_edit(par)
{
//alert(par);
$("#update1"+par).hide();
$("#update_status"+par).show();
$("#drop_down1"+par).show();
$("#drop_down2"+par).show();
$("#drop_down3"+par).show();
$("#drop_down4"+par).show();
$("#from_time").hide();
$("#to_time").hide();
$("#tna").hide();
}

</script>    

 <script>
function get_time(par)
{
var from_time=$("#edit_fromtime"+ par).val();
var from_date=$("#update_date").val();
var work_hour=$("#edit_totime"+ par).val();
//alert(update_date);
	$.ajax({
		
		url:'ajax-calculate-time.php',
		type:'POST',
		data:'time1=' + from_time + '&date1=' + from_date + '&work_hour=' + work_hour,
		success:function(f)
		{
		//alert(f);
		$('#worket').show();
		$('#hour1'+ par).show();
		$('#hour_d'+par).val(f);
		}
	});
}

</script>

<script>
function update_tna(par,sln)
{
var edit_fromtime=$('#edit_fromtime'+par).val();
var edit_totime=$('#edit_totime'+par).val();
var edit_tna=$('#edit_tna'+par).val();
var Patients=$('#Patients'+par).val();
var update_date=$('#update_date').val();
var hour_d=$('#hour_d'+par).val();
//var finish12=$('#finish12').val();
//alert(hour_d);
	$.ajax({
	url:'ajax-tna-view-roster-plan.php',
	type:'post',
	data:'id=' + par + '&fromtime=' + edit_fromtime + '&totime=' + edit_totime + '&edittna=' + edit_tna + '&Patients=' + Patients + '&update_date=' + update_date + '&hour_d=' + hour_d + '&sln=' + sln,
	success:function(f)
	{
	//alert(f);
	if(f==1)
	{
	alert('Please select start time before 7:00pm');
	}
	alert('plan updated successfully');
	window.location.href='view-tna-roster-plan.php?d=<?php echo $_REQUEST['d']; ?>&tid=<?php echo $_REQUEST['tid']; ?>';
	//window.parent.location.href='daily-tna-roster.php?d=<?php echo $_REQUEST['d']; ?>&tid=<?php echo $_REQUEST['tid']; ?>';
	}
	
	});
}
</script>
      

<script>
function off(par,par1)
{
//alert(par1);
//alert(par);
var addoff=$('#addoff').val();
//alert(addoff);
 $.ajax({
 url:'ajax-offday-update.php',
 type:'post',
 data:'par=' + par + '&par1=' + par1 + '&addoff=' + addoff,
 success:function(f)
 {
 //alert(f);
 if(f==1)
	{
	alert('Offday updated successfully');
	$("#offday").hide();
	$("#addnew").hide();
	$("#removeoffday").show();
	}
	if(f==2)
	{
	alert('Leave updated successfully');
	$("#offday").hide();
	$("#addnew").hide();
	$("#removeoffday").show();
	}
	if(f==3)
	{
	alert('Night Off updated successfully');
	$("#offday").hide();
	$("#addnew").show();
	$("#removeoffday").show();
	}
	if(f==4)
	{
	alert('On Call updated successfully');
	$("#offday").hide();
	$("#addnew").hide();
	$("#removeoffday").show();
	}
 }
 });

}
</script>
<script>
function deleteoff(par2,par3)
{
//alert(par2);
//alert(par3);
 $.ajax({
 url:'ajax-deloffday-update.php',
 type:'post',
 data:'par2=' + par2 + '&par3=' + par3,
 success:function(f)
 {
 
	alert('Offday deleted successfully');
	}
 });
}   
</script> 
<script>
function delete_plan(per4,per5) 
	{
	  var response = confirm("Are You Sure to Delete!");
	  if (response == true) 
	  {
	  //alert(per5);
		$.ajax({
		url:"ajax_delete_plan.php",
		type:"POST",
		data:{'per4':per4,'per5':per5},
		success:function(f)
		{
		//alert(f);
 			alert('Plan Deleted Successfully');
			window.location.href='view-tna-roster-plan.php';
		}
		});
	  } 
	  else 
	  {
		alert('Lead Not Deleted');
	  }
	}
</script>      
</head>

<body>
    <!--[if lt IE 8]>
		<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
	<![endif]-->
    <!-- Start Left menu area -->
    
    
    
    <?php //include("left-menu.php"); ?>
    
    
    
    <!-- End Left menu area -->
    <!-- Start Welcome area -->
    <div class="all-content-wrapper" style="margin-left:0px;">
        
        
       <?php //include("header-menu.php"); ?> 
        
       
                                        	
        <!-- Static Table Start -->
        <div class="static-table-area">
        
       
        
        
        
            <div class="container-fluid">
                <div class="row">
                    <?php 
						$tna="select * from employee_master where SLN='".$_REQUEST['tid']."'"; 
						$tna_query=mysqli_query($con,$tna);
						$tna_fetch=mysqli_fetch_array($tna_query);
						$name=$tna_fetch['First_Name']." ".$tna_fetch['Last_Name'];

					 ?>
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" >
                        <div class="sparkline9-list analysis-progrebar-ctn" style="background-color:#FFFFFF">
                            <div class="sparkline9-hd">
                                <div class="main-sparkline9-hd">
                                    <h1 style="margin-bottom:15px">Roster Plan for <?php echo $name;?> on <?php echo date('d-M-y',strtotime($_REQUEST['d']));?> </h1>
                                   
                                    
                                    
                                       <div class="row" style="padding:0; background-color:#FFFFFF">
      
                                
                                
										
                                        <?php
										$sql="select * from roster_master where TNA_Name='".$_REQUEST['tid']."' and Treatment_Service_Date='".$_REQUEST['d']."'";
										$query=mysqli_query($con,$sql);
										$fetch=mysqli_fetch_array($query);
										if($fetch['Offday']==0)
										{
										?>
										 <div class="col-sm-2" id="addnew" style="float:right; margin-bottom:10px;">
                                            <a href="add-tna-roster-plan.php?d=<?php echo $_REQUEST['d'] ?>&tid=<?php echo $_REQUEST['tid'];
?>"><input type="button" class="btn btn-custon-rounded-three btn-primary" name="update" id="update" value="ADD NEW" style="float:right; margin-bottom:10px;"></a>
                                    	  </div>
                                          
										<div class="col-sm-4" id="offday" style="float:right; margin-bottom:10px;">
                                        <select class="form-control" id="addoff" name="addoff" onChange="off('<?php echo $_REQUEST['d'] ?>','<?php echo $_REQUEST['tid'] ?>')">
                                       <option value="">Select Day</option>
                                       <option value="1">Off Day</option>
                                       <option value="2">Leave</option>
                                       <option value="3">Night Off</option>
									   <option value="4">On Call</option>
                                       </select>
                                            <!--<a href="#"><input type="button" class="btn btn-custon-rounded-three btn-warning" name="addoff" id="addoff" value="ADD OFF DAY" style="float:right; margin-bottom:10px;" onClick="off('<?php echo $_REQUEST['d'] ?>','<?php echo $_REQUEST['tid'] ?>')"></a>-->
                                    	  </div>
										<?php
										}
										
										else if($fetch['Offday']==1)
										{
										?>  
										  <div class="col-sm-10" id="removeoffday">
                                            <a href="#"><input type="button" class="btn btn-custon-rounded-three btn-warning" name="addoff" id="addoff" value="REMOVE OFF DAY" style="float:right; margin-bottom:10px;" onClick="deleteoff('<?php echo $_REQUEST['d'] ?>','<?php echo $_REQUEST['tid'] ?>')"></a>
                                    	  </div>
                                          <?php
										}
										else if($fetch['Offday']==2)
										{
										?>  
										  <div class="col-sm-10" id="removeoffday">
                                            <a href="#"><input type="button" class="btn btn-custon-rounded-three btn-warning" name="addoff" id="addoff" value="REMOVE LEAVE" style="float:right; margin-bottom:10px;" onClick="deleteoff('<?php echo $_REQUEST['d'] ?>','<?php echo $_REQUEST['tid'] ?>')"></a>
                                    	  </div>
                                          <?php
										}
										else if($fetch['Offday']==3)
										{
										?>  
                                        <!--<div class="col-sm-2" id="addnew" style="float:right; margin-bottom:10px;">
                                            <a href="add-tna-roster-plan.php?d=<?php echo $_REQUEST['d'] ?>&tid=<?php echo $_REQUEST['tid'];
?>"><input type="button" class="btn btn-custon-rounded-three btn-primary" name="update" id="update" value="ADD NEW" style="float:right; margin-bottom:10px;"></a>
                                    	  </div>-->
										  <div class="col-sm-10" id="removeoffday">
                                            <a href="#"><input type="button" class="btn btn-custon-rounded-three btn-warning" name="addoff" id="addoff" value="REMOVE NIGHT OFF" style="float:right; margin-bottom:10px;" onClick="deleteoff('<?php echo $_REQUEST['d'] ?>','<?php echo $_REQUEST['tid'] ?>')"></a>
                                    	  </div>
                                          <?php
										}
										else if($fetch['Offday']==4)
										{
										?>
										  <div class="col-sm-10" id="removeoffday">
                                            <a href="#"><input type="button" class="btn btn-custon-rounded-three btn-warning" name="addoff" id="addoff" value="REMOVE ON CALL" style="float:right; margin-bottom:10px;" onClick="deleteoff('<?php echo $_REQUEST['d'] ?>','<?php echo $_REQUEST['tid'] ?>')"></a>
                                    	  </div>
                                          <?php
										}
										?>										
                                        <form method="post" action="" id="edit_lead">
                                        <input type="hidden" name="update_date" id="update_date" value="<?php echo  $_REQUEST['d'];?>">
                                        
                                        
                                  <div class="col-sm-12">
								   <table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#5e5e5e" style="border-collapse:collapse;">
								   
								   <tr>
                                   <td width="%" class="table_head_class">From Duty Time Start</td>
								   <td width="%" class="table_head_class">Number Of Working Hours</td>
                                   <td width="%" class="table_head_class" id="worket" style="display:;">Work End Time</td>
								   <td width="%" class="table_head_class">Patient</td>
								   <td width="%" class="table_head_class">Action</td>
								   			   
								   	</tr>
									 <?php 
								  $edit_sql="select * from roster_master where TNA_Name='".$_REQUEST['tid']."' and Treatment_Service_Date='".$_REQUEST['d']."' and Active='0'";
								 $edit_sql_query=mysqli_query($con,$edit_sql);
									if (mysqli_num_rows($edit_sql_query)>0)
									{
									$i=1;
										while($edit_sql_fetch=mysqli_fetch_array($edit_sql_query))
										{
										$patient="select * from patient_master where Patient_Id='".$edit_sql_fetch['Patient_Id']."'";
										$patient_query=mysqli_query($con,$patient);
										$patient_fetch=mysqli_fetch_array($patient_query);
										//employee-master
										$tna="select * from employee_master where SLN='".$_REQUEST['tid']."'"; 
										$tna_query=mysqli_query($con,$tna);
										$tna_fetch=mysqli_fetch_array($tna_query);
										$name=$tna_fetch['First_Name']." ".$tna_fetch['Last_Name'];
										$fetchoff=mysqli_fetch_array(mysqli_query($con,"select * from roster_master where Treatment_Service_Date='".$_REQUEST['d']."' and TNA_Name='".$_REQUEST['tid']."'"));
										if($fetchoff['Offday']==0)
										{
								   ?>
									  <tr>
                                     
								   <td class="table_body_class">
								   <input name="from_time" id="from_time" type="text" class="form-control" placeholder="From Time" value="<?php  echo date('h.i a',strtotime($edit_sql_fetch['Duty_Hour_Start_Time'])) ?>" readOnly>
								   <div class="form-group" id="drop_down1<?php echo $i; ?>" style="display:none;">
								   <select name="edit_fromtime" class="form-control" id="edit_fromtime<?php echo $i; ?>">
                                   			<option value="">SELECT FROM TIME</option>
                                            <?php
											$SqlAssLoc="select * from  roster_time_master";
											$RsAssLoc=mysqli_query($con,$SqlAssLoc);
											if(mysqli_num_rows($RsAssLoc)>0)
											{
											while($RowLoc=mysqli_fetch_array($RsAssLoc))
												{
											?>
                                               <option value="<?php echo $RowLoc['Start']; ?>"<?php if($RowLoc['Start']==date('H:i:s',strtotime($edit_sql_fetch['Duty_Hour_Start_Time']))){echo "selected";} ?>><?php echo date('h.i a',strtotime($RowLoc['Start'])); ?></option>
                                             <?php
												}
											}
											?>
                                             </select>
								   		</div>
								   </td>
								  <td class="table_body_class">
								  <input name="to_time" id="to_time" type="text" class="form-control" placeholder="To Time" value="<?php echo $edit_sql_fetch['Number_Of_Working_Hour'] ?>" readOnly>
                                  
								   <div class="form-group" id="drop_down2<?php echo $i; ?>" style="display:none;">
								   <select name="edit_totime" class="form-control" id="edit_totime<?php echo $i; ?>" onChange="get_time(<?php echo $i; ?>)">
                                   			<option>SELECT DUTY HOUR</option>
                                            <?php
											$SqlAssLoc="select * from  roster_hours";
											$RsAssLoc=mysqli_query($con,$SqlAssLoc);
											if(mysqli_num_rows($RsAssLoc)>0)
											{
											while($RowLoc=mysqli_fetch_array($RsAssLoc))
												{
											?>
                                               <option value="<?php echo $RowLoc['Hours']; ?>"<?php if($RowLoc['Hours']==$edit_sql_fetch['Number_Of_Working_Hour']){echo "selected";} ?>><?php echo $RowLoc['Hours']; ?></option>
                                               <?php
													}
												}
												?>
                                             </select>
                                       </div>
                                       
                                       <div>
                                       <?php
									  /*	$date = new DateTime("date('y-m-d',strtotime($edit_sql_fetch['Duty_Hour_Start_Time']))");
										$date->modify("+8 hours");
										echo $date->format("Y-m-d H:i:s");*/
                                       ?>
                                       </div>
								   </td>
                 					
                                    <td class="table_body_class" style="display:;" id="hour1<?php echo $i; ?>">
                                    <div class="form-group col-xs-3"><label></label> 
                                    <input type="text"class="form-group"  id="hour_d<?php echo $i; ?>" name="hour_d"  readonly value="<?php echo $edit_sql_fetch['To_Time_Date']." ".$edit_sql_fetch['To_Time'] ?>">
									</div>
                                    </td>
                                   
								   <td class="table_body_class">
                              <input name="tna" id="tna" type="text" class="form-control" placeholder="Patient" value="<?php echo $patient_fetch['Patient_Name']; ?>" readonly />
								    <div class="form-group" id="drop_down3<?php echo $i; ?>" style="display:none;">
								   <select name="edit_tna" class="form-control" id="edit_tna<?php echo $i; ?>">
								   <option value="">SELECT PATIENT</option>
								   <?php
											   
											   $Sql_tna="select * from patient_master";
                                               $Sql_tna_query= mysqli_query($con,$Sql_tna);
                                               while($RowLoc=mysqli_fetch_array($Sql_tna_query))
											   		{
											 ?>
                                            
                                               <option value="<?php echo $RowLoc['Patient_Id']; ?>"<?php if($RowLoc['Patient_Id']==$edit_sql_fetch['Patient_Id']){echo "selected";} ?>><?php echo $RowLoc['Patient_Name']; ?></option>
											   <?php 
													}	
											   ?>
											     </select>
                                             </div>
                                             </td>
                                             
                                             <!--<td class="table_body_class">
                                   <input name="Patient" id="Patient<?php echo $i; ?>" type="text" class="form-control" placeholder="Patient" value="<?php echo $edit_sql_fetch['Patient_Id'] ?>" readOnly> 
                                             </td>-->
                                               <input name="Patients" id="Patients<?php echo $i; ?>" type="hidden" class="form-control" placeholder="Patient" value="<?php echo $edit_sql_fetch['TNA_Name']; ?>" readOnly>
											
								   <td class="table_body_class">
                                   
                                   <input type="button" class="btn btn-custon-rounded-three btn-primary" name="update1"  id="update1<?php echo $i; ?>" value="EDIT" style="margin-bottom:10px; width: 78px;" onClick="confirm_edit(<?php echo $i; ?>)">
								   
								   <input type="button" class="btn btn-custon-rounded-three btn-success" name="update_status" id="update_status<?php echo $i; ?>" value="UPDATE" style="margin-bottom:10px; width: 78px; display:none;" onClick="update_tna('<?php echo $i; ?>','<?php echo $edit_sql_fetch['SLN'] ?>')">
								    
                                    <input type="button" class="btn btn-custon-rounded-three btn-danger" name="deleteplan" id="deleteplan<?php echo $i; ?>" value="Delete" style="width: 78px;" onClick="delete_plan('<?php echo $i; ?>','<?php echo $edit_sql_fetch['SLN'] ?>')">
                                    
								   </td>
								   	</tr>
								    <?php
									$i++;
											}
											else if($fetchoff['Offday']==1)
											{
											?>
													<tr><td colspan="5" style="text-align:center; color:#FF0000;">This is Off Day</td></tr>
													<?php
											}
											else if($fetchoff['Offday']==2)
											{
											?>
													<tr><td colspan="5" style="text-align:center; color:#FF0000;">This is Leave</td></tr>
													<?php
											}
											else if($fetchoff['Offday']==3)
											{
											?>
													<tr><td colspan="5" style="text-align:center; color:#FF0000;">This is Night Off</td></tr>
													<?php
											}
											}
										}else	
										{
													?>
													<tr><td colspan="5" style="text-align:center;">No Plan Found</td></tr>
													<?php
												}
												?>
								   
								  
								   </table>
								   </div>
                                        </form> 
                                        <!--<div class="col-sm-12">
                                            <a href="add-roster-plan.php"><input type="button" class="btn btn-custon-rounded-three btn-primary" name="update" value="ADD NEW" style="float:right;margin-top:10px;"></a>
                                    	  </div>-->
                                         
                                       </div>
                                       
                                       
                                        
                                         
                                         
                                         
                                           
                                </div>
                            </div>
                             
                         </div>
                         
                    </div> 
                     
                    	
                                         
                        </div>
                    </div>
                </div>
                
                
            </div>
        </div>
        <!-- Static Table End -->
        <!-- <div class="footer-copyright-area">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="footer-copy-right">
                           <p>Copyright © 2019. All rights reserved. </p>
                           
                        </div>
                    </div>
                </div>
            </div>
        </div>-->
    </div>

     <!-- jquery
		============================================ -->
     
       <script src="js/vendor/jquery-1.12.4.min.js"></script>
    <!-- bootstrap JS
		============================================ -->
    <script src="js/bootstrap.min.js"></script>
    <!-- wow JS
		============================================ -->
    <script src="js/wow.min.js"></script>
    <!-- price-slider JS
		============================================ -->
    <script src="js/jquery-price-slider.js"></script>
    <!-- meanmenu JS
		============================================ -->
    <script src="js/jquery.meanmenu.js"></script>
    <!-- owl.carousel JS
		============================================ -->
    <script src="js/owl.carousel.min.js"></script>
    <!-- sticky JS
		============================================ -->
    <script src="js/jquery.sticky.js"></script>
    <!-- scrollUp JS
		============================================ -->
    <script src="js/jquery.scrollUp.min.js"></script>
    
    <script src="js/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
    <script src="js/scrollbar/mCustomScrollbar-active.js"></script>

     
    
     <!--  editable JS
		============================================ -->
    <script src="js/editable/jquery.mockjax.js"></script>
    <script src="js/editable/mock-active.js"></script>
    <script src="js/editable/select2.js"></script>
    <script src="js/editable/moment.min.js"></script>
    <script src="js/editable/bootstrap-datetimepicker.js"></script>
    <script src="js/editable/bootstrap-editable.js"></script>
    <script src="js/editable/xediable-active.js"></script>
 <!-- datepicker JS
		============================================ -->
    <script src="js/datepicker/jquery-ui.min.js"></script>
    <script src="js/datepicker/datepicker-active.js"></script>
    
    <!-- mCustomScrollbar JS
		============================================ -->
    <script src="js/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
    <script src="js/scrollbar/mCustomScrollbar-active.js"></script>
    <!-- metisMenu JS
		============================================ -->
    <script src="js/metisMenu/metisMenu.min.js"></script>
    <script src="js/metisMenu/metisMenu-active.js"></script>
    <!-- peity JS
		============================================ -->
    <script src="js/peity/jquery.peity.min.js"></script>
    <script src="js/peity/peity-active.js"></script>
    <!-- sparkline JS
		============================================ -->
    <script src="js/sparkline/jquery.sparkline.min.js"></script>
    <script src="js/sparkline/sparkline-active.js"></script>
    <!-- tab JS
		============================================ -->
    <script src="js/tab.js"></script>
    <!-- plugins JS
		============================================ -->
    <script src="js/plugins.js"></script>
    <!-- main JS
		============================================ -->
    <script src="js/main.js"></script>
    <!-- tawk chat JS
		============================================ -->
    <script src="js/tawk-chat.js"></script>
   <!-- form validate JS
		============================================ -->
    <script src="js/form-validation/jquery.form.min.js"></script>
    <script src="js/form-validation/jquery.validate.min.js"></script>
    <script src="js/form-validation/form-active.js"></script>
    
    <script>
$(document).ready(function() {
   $("body").tooltip({ 
   	selector: '[data-toggle=tooltip]' 
	 });
});
 
</script> 
  
               
                                               <script>
 
$('button.call_btn_1').click(function() {
    //var text = $(this).text();
	var text = $(this).data('value_santanu');
	//alert(text)
	$('#hidden_call_box').val(text);
	$('#response').val(text);
    // do something with the text
});
												</script> 
                                                
                                                
                                                
                                                
       <!-- bootstrap-clockpicker -->
      <link rel="stylesheet" type="text/css" href="css/bootstrap-clockpicker.min.css">
    <script type="text/javascript" src="js/bootstrap-clockpicker.min.js"></script>


 <script type="text/javascript">
$('.clockpicker').clockpicker()
	.find('input').change(function(){
		console.log(this.value);
	});
var input = $('#single-input').clockpicker({
	placement: 'bottom',
	align: 'left',
	autoclose: true,
	'default': 'now'
});

$('.clockpicker-with-callbacks').clockpicker({
		donetext: 'Done',
		init: function() { 
			console.log("colorpicker initiated");

		},
		beforeShow: function() {
			console.log("before show");
		},
		afterShow: function() {
			console.log("after show");
		},
		beforeHide: function() {
			console.log("before hide");
		},
		afterHide: function() {
			console.log("after hide");
		},
		beforeHourSelect: function() {
			console.log("before hour selected");
		},
		afterHourSelect: function() {
			console.log("after hour selected");
		},
		beforeDone: function() {
			console.log("before done");
		},
		afterDone: function() {
			console.log("after done");
		}
	})
	.find('input').change(function(){
		console.log(this.value);
	});

// Manually toggle to the minutes view
$('#check-minutes').click(function(e){
	// Have to stop propagation here
	e.stopPropagation();
	input.clockpicker('show')
			.clockpicker('toggleView', 'minutes');
});
if (/mobile/i.test(navigator.userAgent)) {
	$('input').prop('readOnly', true);
}
</script>                                          
                                                
                                                
 <script type="text/javascript">
$("#edit_lead").validate({
          
      showErrors: function(errorMap, errorList) {
          // Clean up any tooltips for valid elements
          $.each(this.validElements(), function (index, element) {
              var $element = $(element);
              $element.data("title", "") // Clear the title - there is no error associated anymore
                  .removeClass("error")
                  .tooltip("destroy");
          });
          // Create new tooltips for invalid elements
          $.each(errorList, function (index, error) {
              var $element = $(error.element);

              $element.tooltip("destroy") // Destroy any pre-existing tooltip so we can repopulate with new tooltip content
                  .data("title", error.message)
                  .addClass("error")
                  .tooltip(); // Create a new tooltip based on the error messsage we just set in the title
          });
      },

     
	  
});
</script>                                               
                                                
    
</body>

</html>