<?php
include('common/connection.php');
login_check();

$user_sql="select User_Type as type,Location from user_master where User_Name='".$_SESSION['user']."'";
$user_query=mysqli_query($con,$user_sql);
$user=mysqli_fetch_array($user_query);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Buurtzorg</title>
<?php include("headerlink.php"); ?>
 <script src="js/vendor/jquery-1.12.4.min.js"></script>
 
  <link rel="stylesheet" href="css/form/all-type-forms.css">
  
    
    
<style type="text/css">
body{
margin:0px;
padding:0px;
font-family:Arial, Helvetica, sans-serif;
}
.wrapper{
width:100%;
height:auto;
}

.image_div{
float:right;
width:25%;
height:auto;
margin-left:20px;
margin-bottom:20px;
-moz-box-shadow:0px 0px 2px #e2e2e2;
-webkit-box-shadow:0px 0px 2px #e2e2e2;
box-shadow:0px 0px 2px #e2e2e2;
border:5px solid #FFFFFF;
line-height:24px;
font-size:14px;
}

.maindiv{
float:left;
width:100%;
height:auto;
padding:0px 0%;
line-height:28px;
}

.document_details{
float:left;
width:100%;
height:auto;
}

.table_body{
text-align:left;
font-size:13px;
line-height:30px;
height:auto;
padding-left:8px;


}

.heading{
background-color:#2a3f54;
height:35px;
line-height:35px;
color:#FFFFFF;
font-weight:600;
text-align:left;
padding-left:10px;
}

.registant_details_div{
background-color:#f0eded; 
border: 1px solid #eaeaea;
padding:10px;
font-size:14px;
text-align:left;
line-height:24px;
color:#000000;
}


.form_maindiv select{
width: 100%;
height: 40px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
text-indent: 0.01px;
text-overflow: '';
background: transparent url(img/select-icon1.png) no-repeat scroll 97% 17px;
@media (-webkit-min-device-pixel-ratio: 2), 
(min-resolution: 480dpi) {
background: transparent url(img/select-icon1.png) no-repeat scroll 97% 20px;
font-size: 13px;
font-family: 'Lato', sans-serif;
color:#666666;
width: 100%;
}

.txtbox_div {
    float: left;
    width: 96%;
    height: 40px;
    padding: 0px 2%;
    border: 1px solid rgb(204, 204, 204);
    background: none repeat scroll 0% 0% rgb(240, 239, 240);
    color: rgb(0, 0, 0);
    font-size: 13px;
    line-height: normal;
    border-radius: 2px 2px 2px 2px;
    box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.075) inset;
    font-family: "Helvetica Neue",Roboto,Arial,"Droid Sans",sans-serif;
}




</style>

<style type="text/css">

.verify_maindiv{
    width: 150px;
    height: auto;
    margin: 0px auto;
}

.submit_btn_new{
float:right;
width:100%;
height:40px;
background-color:#1f81c0 !Important;
text-align:center;
color:#FFFFFF;
font-size:14px;
border:0px;border-radius: 2px;
transition: 0.5s all;
cursor:pointer;
border-radius:5px;
}

.submit_btn_new:hover{
background-color:#000000;
}

.error-message{
text-align:center;
font-size:18px;
color:#FF0000;
font-weight:600;
}


.success_message{
text-align:center;
font-size:18px;
font-weight:600;
color:#000000;
}

</style>
<?php
$Lead_Id=base64_decode($_REQUEST['Lid']);
$SqlLead="select * from lead_master where Lead_ID='".$Lead_Id."'";
$RsLead=mysqli_query($con,$SqlLead);
$RowLead=mysqli_fetch_array($RsLead);

$FetchLocation=GetLocationName($con,$RowLead['Control_Location']);		
?>

<script type="text/javascript">
function AlocateDoctorNurse()
{
   $err=0;
  var patient_name=$('#patient_name').val();
   var contact_person_name=$('#Contact_Person_Name').val();
   var contact_person_ph=$('#Contact_Person_Phone_No').val();
   var patient_state=$('#State_Name').val();
   var patient_city=$('#City_Name').val();
   var patient_address1=$('#Address_1').val();
   var patient_address2=$('#Address_2').val();
   var patient_pincode=$('#Pin_Code').val();
   //var allocation=$('#allocation').val();
  // var date_of_allocation=$('#single-input').val();
   var select_doctor=$('#doctor_name').val();
   var select_nurse=$('#nurse_name').val();
   var visit_date=$('#finish12').val();
   var visit_time=$('#single-input1').val();
   var patient_condition=$('#Patient_Condition').val();
   var price_discussion=$('#price_discussion').val();
   var price_aggred_upon=$('#price_agreed').val();
   //alert(doctor_name);
   var lead_id='<?php echo $Lead_Id; ?>';
   
//alert(patient_name);
  // return false;
   if(patient_name=="")
   {
      $('#patient_name').css('border-color','#FF0000');
	  $err=1;
       //$('.error-message').text("You have to field");
	   //return false;
   }
 
  if(contact_person_name=="")
   {
      $('#Contact_Person_Name').css('border-color','#FF0000');
	  $err=1;
       //$('.error-message').text("You have to select all field");
	   //return false;
  } 
   
   if(contact_person_ph=="")
   {
   		$('#Contact_Person_Phone_No').css('border-color','#FF0000');
		$err=1;
		//return false;
   }
   
   if(patient_city=="")
   {
   		$('#City_Name').css('border-color','#FF0000');
		$err=1;
		//return false;
   }
   
   if(patient_address1=="")
   {
   		$('#Address_1').css('border-color','#FF0000');
		$err=1;
		//return false;
   }
   
   if(patient_address2=="")
   {
   		$('#Address_2').css('border-color','#FF0000');
		$err=1;
		//return false;
   }
   
   if(patient_pincode=="")
   {
   		$('#Pin_Code').css('border-color','#FF0000');
		$err=1;
		//return false;
   }
   
  /* if(date_of_allocation=="")
   {
   		$('#single-input').css('border-color','#FF0000');
		//return false;
   }*/
   //alert(select_doctor)
   if(select_doctor=="")
   {
   		$('#doctor_name').css('border-color','#FF0000');
		//return false;
   }
   
   if(select_nurse=="")
   {
   		$('#nurse_name').css('border-color','#FF0000');
		$err=1;
		//return false;
   }
   
   if(visit_date=="")
   {
   		$('#finish12').css('border-color','#FF0000');
		//return false;
   }
   
   if(visit_time=="")
   {
   		$('#single-input1').css('border-color','#FF0000');
		$err=1;
		//return false;
   }
   
    if(patient_condition=="")
   {
   		$('#Patient_Condition').css('border-color','#FF0000');
		$err=1;
		
   }
   
   if($err==1)
   {
      //$('.error-message').text("You have to input this field");
		return false;
   }
  //alert(lead_id);kb@gmail.com<strong></strong>



 $.ajax({
	
  	url:'ajax-allocate-doctor-nurse.php',
	type:'POST',
	data: 'lead_id=' + lead_id + '&patient_name=' + patient_name + '&contact_person_name=' + contact_person_name + '&contact_person_ph=' + contact_person_ph +  '&patient_state=' + patient_state + '&patient_city=' + patient_city + '&patient_address1=' + patient_address1 + '&patient_address2=' + patient_address2 + '&patient_pincode=' + patient_pincode + '&select_doctor=' + select_doctor + '&select_nurse=' + select_nurse +'&visit_date=' + visit_date + '&visit_time=' + visit_time + '&patient_condition=' + patient_condition + '&price_discussion=' + price_discussion + '&price_aggred_upon=' + price_aggred_upon,
	success:function(f)
	{
	
	  //alert(f);
	   
	   $('#judge_info').hide();
		$('#success_msg').show();
		
			setTimeout( function() {
			
			window.parent.location.href="qualified_leads.php";
			},2000);	
		
	}
   })


}
</script>
</head>

<body>

<div class="wrapper">
<div class="maindiv">
<!--<div class="image_div"><img src="../upload_image/passport-size-2.jpg" style="width:100%; height:auto;" /></div>-->
<div class="document_details">
<form id="manual" method="post">

<table width="100%" border="0" id="success_msg" style="display:none;">
  <tr>
    <td class="success_message" style="padding-top:150px; font-size:24px;">Successfully Allocated</td>
  </tr>
</table>

 
<table width="100%" border="0" cellspacing="0" cellpadding="0" id="judge_info">
  <tr>
    <td class="heading">LEAD DETAILS ( <?php echo $Lead_Id; ?> )</td>
  </tr>
  <tr>
    <td height="10"></td>
  </tr>
  <tr>
    <td class="registant_details_div"><span style="font-size:18px; font-weight:600;"><?php echo $RowLead['Lead_Name']; ?></span><br />
    <strong>Lead Creation Date :</strong> <?php if($RowLead['Lead_Creation_Date']!='0000-00-00') { echo date('d M, Y',strtotime($RowLead['Lead_Creation_Date'])); } ?><br />
    <strong>Phone  :</strong> <?php echo $RowLead['Phone']; ?><br />
    <strong>Email :</strong> <?php echo $RowLead['Email']; ?><br />
    <strong>Source :</strong> <?php echo $RowLead['Form_Source']; ?><br />
    <!--<strong>Priority :</strong> <?php if ($leads_datas['Priority']<=2){echo 'Low';}
												else if ($leads_datas['Priority']<=3){echo 'Moderate';}
												else if($leads_datas['Priority']>3){echo 'High';} ?><br />-->
 
</td>
  </tr>
 <tr>
    <td height="10"></td>
  </tr>
  
  <tr>
    <td>
    
  <table width="100%" border="0">
 
  <tr>
    <th scope="col" class="" width="45%">Patient Name</th>
    <th scope="col" width="10%">&nbsp;</th>
    <th scope="col" class="" width="45%">Contact Person Name</th>
  </tr>
  
  <tr>
    <td>
    
    <div class="form_maindiv">
         <input name="patient_name" id="patient_name" type="text" style="border:0px; border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%; height:40px; padding-left:10px;" placeholder="Patient Name" class="form-control txtbox_div" data-rule-required="true" data-msg-required="Please Select Visit date" value="<?php echo $RowLead['Lead_Name']; ?>" />
     </div></td>
    <td >&nbsp;</td>
    <td><div class="form_maindiv">
     <input name="Contact_Person_Name" id="Contact_Person_Name" type="text" style="border:0px; border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%; height:40px; padding-left:10px;" placeholder="Contact Person Name" class="form-control txtbox_div" data-rule-required="true" data-msg-required="Please Select Visit date">
     </div></td>
      
  </tr>
  
  
  <tr>
  <th scope="col" class="" width="45%">Contact Person Phone No</th>
  <th scope="col" width="10%">&nbsp;</th>
  <th scope="col" class="" width="45%">State</th>
    
  </tr>
   
  <tr>
  <td><div class="form_maindiv"> 
     <input name="Contact_Person_Phone_No" id="Contact_Person_Phone_No" type="text" style="border:0px; border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%; height:40px; padding-left:10px;" placeholder="Contact Person Phone No" class="form-control txtbox_div" data-rule-required="true" data-msg-required="Please Select Visit date">
    </div></td>
    <td >&nbsp;</td>
    <td><div class="form_maindiv">
     <select name="State_Name" id="State_Name" type="text" style="border:0px; border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%; height:40px; padding-left:10px;" class="form-control txtbox_div" data-rule-required="true" data-msg-required="Please Select Visit date">
      <option>Select State</option>
      <?php
											  $SqlLoc="select State_Name from state_master";
                                               $RsLoc= mysqli_query($con,$SqlLoc);
                                               while($RowLoc=mysqli_fetch_array($RsLoc))
											   {
											 ?>
                                              <option value="<?php echo $RowLoc['State_Name']; ?>"><?php echo $RowLoc['State_Name']; ?></option>
                                                <?php
												}
												?>
     </select>
     </div></td>
  </tr>
   
  <td colspan="3"></td> 
   <tr>
  <th scope="col" class="" width="45%">City</th>
  <th scope="col" width="10%">&nbsp;</th>
  <th scope="col" class="" width="45%">Pin Code</th>
    
  </tr>
   
  <tr>
  <td><div class="form_maindiv"> 
     <input name="City_Name" id="City_Name" type="text" style="border:0px; border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%; height:40px; padding-left:10px;" placeholder="Enter City Name" class="form-control txtbox_div" data-rule-required="true" data-msg-required="Please Select Visit date">
    </div></td>
    <td >&nbsp;</td>
    <td><div class="form_maindiv">
     <input name="Pin_Code" id="Pin_Code" type="text" style="border:0px; border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%; height:40px; padding-left:10px;" class="form-control txtbox_div" placeholder="Enter Pin Code" data-rule-required="true" data-msg-required="Please Select Visit date">
      
     </div></td>
  </tr>
  
   <td colspan="3"></td> 
   
   <tr>
  <th scope="col" class="" width="45%">Address 1</th>
  <th scope="col" width="10%">&nbsp;</th>
  <th scope="col" class="" width="45%">Address 2</th>
    
  </tr>
   
  <tr>
  <td><div class="form_maindiv"> 
     <textarea name="Address_1" id="Address_1" type="text" style="border:0px; border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%; padding-left:10px;" placeholder="Enter Your Address" class="form-control txtbox_div" data-rule-required="true" data-msg-required="Please Select Visit date"></textarea>
    </div></td>
    <td >&nbsp;</td>
    <td><div class="form_maindiv">
     <textarea name="Address_2" id="Address_2" type="text" style="border:0px; border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%; padding-left:10px;" placeholder="Enter Your Address" class="form-control txtbox_div" data-rule-required="true" data-msg-required="Please Select Visit date"></textarea>
      
     </div></td>
  </tr>
   
  <td colspan="3" style="height:10px; border-bottom:1px dashed #CCCCCC; "></td> 
   
  <!--<tr>
    <th scope="col" class="" width="45%">Allocation</th>
    <th scope="col" width="10%">&nbsp;</th>
    <th scope="col" class="" width="45%">Date of Allocation</th>
  </tr>-->
   <?php
	 $sql="select SLN,First_Name,Last_Name from employee_master where Status='Active' and Designation='Doctor' and Office_Location_City='".$FetchLocation['Location_Name']."'";
	?>
  <!--<tr>
    <td><div class="form_maindiv">
    
   <select name="allocation" class="txtbox_div" id="allocation" style="border:0px;  border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%;  padding-left:10px;">
	<option value="0">Allocation</option>
    <option value="1">Yes</option>
    <option value="2">No</option>
    
		<?php /*?><?php
        
        $rs=mysqli_query($con,$sql);
        while($Row=mysqli_fetch_array($rs))
        {
        $DoctorName=$Row['First_Name']." ".$Row['Last_Name'];
        ?>
        <option value="<?php echo $Row['SLN']; ?>"><?php echo $DoctorName; ?></option>
        <?php
        }
        ?><?php */?>
</select>
</div></td>
    <td >&nbsp;</td>
    <td><div class="form_maindiv"> 
     <input name="Allocation_Date" id="start12" type="text" style="border:0px; border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%; height:40px; padding-left:10px;" placeholder="Allocation Date" class="form-control txtbox_div" data-rule-required="true" data-msg-required="Please Select Visit date">
    </div></td>
  </tr>-->
   
  <td colspan="3" style="height:10px;"></td> 
  
  <tr>
    <th scope="col" class="" width="45%">Select Doctor</th>
    <th scope="col" width="10%">&nbsp;</th>
    <th scope="col" class="" width="45%">Select Nurse</th>
  </tr>
  <tr>
 
    
  </tr>
  <tr>
    <td><div class="form_maindiv">
    <?php
	 $sql="select SLN,First_Name,Last_Name from employee_master where Status='Active' and Designation='Doctor' and Office_Location_City='".$FetchLocation['Location_Name']."'";
	?>
    <select name="doctor_name" class="txtbox_div" id="doctor_name" style="border:0px;  border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%;  padding-left:10px;">

<option value="">Select Doctor</option>
<?php

$rs=mysqli_query($con,$sql);
$count = mysqli_num_rows($rs);


while($Row=mysqli_fetch_array($rs))
{

$DoctorName=$Row['First_Name']." ".$Row['Last_Name'];
?>
<option value="<?php echo $Row['SLN']; ?>"><?php echo $DoctorName; ?></option>
<?php
}
?>


</select></div></td>
    <td >&nbsp;</td>
    <td><div class="form_maindiv"><select name="nurse_name" class="txtbox_div" id="nurse_name" style="border:0px;  border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%; padding-left:10px;">

<option value="">Select Nurse</option>
<?php
$sqlN="select SLN,First_Name,Last_Name from employee_master where Status='Active' and Designation='Head Nurse' and Office_Location_City='".$FetchLocation['Location_Name']."'";
$rsN=mysqli_query($con,$sqlN);
while($RowN=mysqli_fetch_array($rsN))
{
$NurseName=$RowN['First_Name']." ".$RowN['Last_Name'];
?>
<option value="<?php echo $RowN['SLN']; ?>"><?php echo $NurseName; ?></option>
<?php
}
?>


</select></div></td>
  </tr>
  
  
  <td colspan="3" style="height:10px;"></td> 
  
  
  <tr>
    <td>
    <div class="form_maindiv"> 
     <input name="doc_visit_date" id="finish12" type="text" style="border:0px; border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%; height:40px; padding-left:10px;" placeholder="Visit Date" class="form-control txtbox_div" data-rule-required="true" data-msg-required="Please Select Visit date">
    </div>
    </td>
    
    <td >&nbsp;</td>
    
    <td>
        <div class="form_maindiv">
              <div class="form-group">
                   <input name="doc_visit_time" id="single-input1" type="text" class="form-control" placeholder="Visit Time" style="border:0px; border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%; height:40px;">
              </div>
         </div>
     </td>
    
  </tr>
   
   
  
</table>


    <table width="100%" border="0">
    <tr>
    
    <td colspan="3">
    <div class="form_maindiv"> 
     <textarea name="Patient Condition" id="Patient_Condition" rows="5" style="resize:none; border:0px; border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%;  padding-left:10px;" placeholder="Patient Condition" class="form-control txtbox_div" data-rule-required="true" data-msg-required="Please Select Visit date"></textarea>
    </div>
    </td>
     
  </tr>
   <td colspan="3" style="height:10px;"></td>
   <tr>
    <th scope="col" class="" width="45%">Price Discussion </th>
    <th scope="col" width="10%">&nbsp;</th>
    <th scope="col" class="" width="45%">Price Agreed Upon </th>
  </tr>
  <tr>
    <td>
    <div class="form_maindiv">
    <select name="price_discussion" class="txtbox_div" id="price_discussion" style="border:0px;  border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%; padding-left:10px;">
    <option value="0">Select</option>
    <option value="1">Yes</option>
    <option value="3">No</option>
    </select>
    </div>
    </td>
    
    <td >&nbsp;</td>
    
    <td>
    <div class="form_maindiv">
    <select name="price_agreed" class="txtbox_div" id="price_agreed" style="border:0px;  border: 1px solid rgb(204, 204, 204); background-color:#ebe7e7; width:100%; padding-left:10px;">
    <option value="0">Select</option>
    <option value="1">Yes</option>
    <option value="2">No</option>
    </select>
    </div>
    </td>
 
     
  </tr>
  
  
</table>

    
    
    
    
     </td>
  </tr>
 
  
   <tr>
    <td height="10"></td>
  </tr>
  
  <tr>
    <td class="error-message"></td>
  </tr>
  
  
   <tr>
    <td height="10"></td>
  </tr>
  
   <tr>
    <td><div class="verify_maindiv"><input name="sub" type="button" value="ALLOCATE" class="submit_btn_new" onclick="AlocateDoctorNurse()" /></div></td>
    
  </tr>
  
</table>

</form>
 
</div>











</div>
</div>
 
        
 <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>
     
       <!-- 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 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 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'
});

var input = $('#single-input1').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">
$("#manual").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>
