<?php
include('../config/config.php');
include('../classes/classDoctor.php');
include('../classes/classAppointment.php');
include('../classes/classPatient.php');

if(isset($_POST['date'])&&$_POST['date']!='')
{
	$_SESSION['temp']['date'] = $_POST['date'];
	
}
elseif(isset($_GET['date'])&&$_GET['date']!='')
{
	$_SESSION['temp']['date'] = $_GET['date'];
	header("Location:mgmtappoint.php");
}
else
{
	$_SESSION['temp']['date'] = date('Y-m-d',time());
}


	$date = $_SESSION['temp']['date'];


try
{
	$retrieveAppOb = new classAppointment;
	$retrieveAppOb->setLocationID($_SESSION['security']['location_id']);
	$retrieveAppOb->setAppDate($date);
	$app_array = $retrieveAppOb->retrieveAllDoctorAppointmentsDetail();
}
catch(MyException $e)
{
	$error_message = $e->getUserMsg();
}

/*echo '<pre>';
print_r($app_array);
echo '</pre>';
*/
?>
<!DOCTYPE html>
<html><!-- InstanceBegin template="/Templates/main.dwt.php" codeOutsideHTMLIsLocked="false" -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<head> 
    <link rel="shortcut icon" href="../images/favicon.png">
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>Med2TEC Hospital Management Information System</title>
    <!-- InstanceEndEditable -->
    <!--Core CSS -->
    <link href="../bs3/css/bootstrap.min.css" rel="stylesheet"> 
    <link href="../css/style.css" rel="stylesheet">
    <link href="../css/style-responsive.css" rel="stylesheet"/> 
    <link href="../popUp/popUp.css" rel="stylesheet">
    <link href="../css/bootstrap-fullcalendar.css" rel="stylesheet"/> 
    
    <link href="../css/clndr.css" rel="stylesheet">
    
    <link href="../css/css/font-awesome.css" rel="stylesheet">
    
    <link href="../assets/jquery-ui/jquery-ui-1.10.1.custom.min.css" rel="stylesheet">
    <link href="../assets/jvector-map/jquery-jvectormap-1.2.2.css" rel="stylesheet">    
    <link href="../assets/jquery-multi-select/css/multi-select.css" rel="stylesheet" type="text/css">
    <!--clock css-->
    <link href="../assets/css3clock/css/style.css" rel="stylesheet"> 
    <!--Morris Chart CSS -->
    <link rel="stylesheet" href="../assets/morris-chart/morris.css">
    <!-- Custom styles for this template -->
   
    <link href="../datepicker/jquery-ui.css" rel="stylesheet" >   
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>
<body>

<section id="container">
    <!--header start-->
    <header class="header fixed-top clearfix">
        <!--logo start-->
        <div class="brand">

            <a href="home.php" class="logo">
                <img src="../images/logo.png" alt="">
            </a>
            <div class="sidebar-toggle-box">
                <div class="fa fa-bars"></div>  
            </div>
        </div> 
        <!--logo end-->

        <div class="nav notify-row" id="top_menu" style="float: right; margin-top: 16px; margin-left: 0px; margin-right: 10px;">
            <!--  notification start -->
             <img alt="" src="../images/org_logos/<?php echo $_SESSION['security']['org_id']?>.png">
            <!--  notification end -->
        </div>
        <div class="top-nav clearfix">
            <!--search & user info start-->
            <ul class="nav pull-right top-menu">
                <li>
                    <div class="toggle-right-box"><!-- InstanceBeginEditable name="print" -->
                    <a href="javascript:Popup('printmgmtappoint.php')"><i class="fa fa-print" style="margin-left: 11px; margin-top: 11px;"></i></a>
					<!-- InstanceEndEditable --></div>
                </li>
                <!-- user login dropdown start-->
                <li class="dropdown">
                    <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                        <img alt="" src="../images/avatar1_small.jpg"> 
                        <span class="username"><?php echo $username;?></span>
                        <b class="caret"></b>
                    </a>
                    <ul class="dropdown-menu extended logout">
                        <li><a href="profile.php"><i class=" fa fa-suitcase"></i>Profile</a></li>
                        <li><a href="#update_password-box" class="update_password-window"><i class="fa fa-cog"></i> Change Password</a></li>
                        <li><a href="../logout.php"><i class="fa fa-key"></i> Log Out</a></li>
                    </ul>
                </li>
                <!-- user login dropdown end -->
                <li>
                    <div class="toggle-right-box">
                        <div class="fa fa-bars"></div>
                    </div>
                </li>
            </ul>
            <!--search & user info end-->
        </div>
    </header>
    <!--header end-->
    <!--sidebar start-->
   <aside>
        <div id="sidebar" class="nav-collapse">
            <!-- sidebar menu start-->
            <ul class="sidebar-menu" id="nav-accordion">
					  	<li>
                    	<a class="active" href="db.php" style="background:#0072BC;">
                        <i class="fa fa-dashboard"></i>
                        <span>Dashboard</span>
                    	</a>
                		</li>
					  <?php
					  
				
					  
$orgOb = new classUser;
$orgOb->retrieveOrgDataByOrgID($_SESSION['security']['org_id']);
           
		  
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==5||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==10)
				{
					?>
					    <li class="sub-menu">
                    	<a href="dbpatient.php" style="background:#BC1C4A;">
                        <i class="fa fa-user"></i>
                        <span>Patient Registration</span>
                    	</a>
                    	</li>
					  <?php
				}
		  
		  if($orgOb->getOPD())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==4||$_SESSION['security']['userrole_id']==5||$_SESSION['security']['userrole_id']==9)
				{
					?>
						<li class="sub-menu">
						<a href="dbopd.php" style="background:#003366;">
						<i class="fa fa-th"></i>
						<span>Out-Patient (OPD)</span>
						</a>
						</li>
						<?php
				}
		  }
		  if($orgOb->getIPD())
		  {
			  	?>
						<li class="sub-menu">
						<a href="dbipd.php" style="background:#3AC7F9;">
						<i class="fa fa-th"></i>
						<span>In-Patient (IPD)</span>
						</a>
						</li>
						<?php
					
		  }
		  if($orgOb->getOT())
		  {
			   		?>
						<li class="sub-menu">
						<a href="dbot.php" style="background:#D6502A;">
						<i class="fa fa-th"></i>
						<span>Operation Theater</span>
						</a>
						</li>
                        <?php
		  }			
		  if($orgOb->getPharmacy())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==6||$_SESSION['security']['userrole_id']==7||$_SESSION['security']['userrole_id']==8||$_SESSION['security']['userrole_id']==9)
				{
			  		?>
						<li class="sub-menu">
						<a href="dbpharmacy.php" style="background:#00869C;">
						<i class="fa fa-th"></i>
						<span>Pharmacy</span>
						</a>
						</li>
						<?php
				}
		  }
		  if($orgOb->getDiagnostic())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==14||$_SESSION['security']['userrole_id']==9)
				{
			  	?>
						<li>
						<a href="dbdiagnostics.php" style="background:#380E4D;">
						<i class="fa fa-th"></i>
						<span>Diagnostics </span>
						</a>
						</li>
						<?php
				}
		  }
		  if($orgOb->getEmergency())
		  {
					  ?>
						<li class="sub-menu">
						<a href="dbemergency.php" style="background:#8EC63F;">
						<i class="fa fa-tasks"></i>
						<span>Emergency </span>
						</a>
						</li>
						<?php
		  }
          if($orgOb->getAdmin())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==9)
				{
					?>
						<li class="sub-menu">
						<a href="dbadmin.php" style="background:#28282E;">
						<i class="fa fa-laptop"></i>
						<span>Admin Panel</span>
						</a>
						</li>
						<?php
				}
		  }
		  ?>
               
            </ul> 
            <div style="position: absolute; bottom: 2%; padding-left:10%;"><a href="http://www.softusion.com/" target="_blank"><img width="30" height="40" src="../images/SoftusionLOGO.png" alt=""><span style="font-size: 11px; float: right; margin-top: 15%;">Designed by Softusion Inc.</span></a></div><br>
            <!-- sidebar menu end-->
        </div>
    </aside>
    <!--sidebar end-->
    <!--main content start-->
	<!-- InstanceBeginEditable name="center" -->
  <section id="main-content">
  	<section class="wrapper">
       
        <table cellspacing="0" cellpadding="0" width="100%" border="0" style="font-size:11px;">
  <tbody>
    <tr>
      <td width="12%" align="center"><a href="dbot.php"><img src="../images/icondb.png"></a></td>
      <td width="12%" align="center"><a href="mgmtsurgeries.php"><img src="../images/iconsurgery.png"></a></td>
      <td width="12%" align="center"><a href="mgmtschedules.php"><img src="../images/iconstaff.png"></a></td>
      <td width="12%" align="center"><a href="mgmtstore.php"><img src="../images/iconequip.png"></a></td>
      <td width="12%" align="center"><a href="otpresc.php"><img src="../images/iconpresc.png"></a></td>
      <td width="12%" align="center"><a href="ottransact.php"><img src="../images/iconpayment.png"></a></td>
      <td width="12%" align="center"><a href="repot.php"><img src="../images/iconreport.png"></a></td>
      <td width="12%" align="center"></td>
      <td width="2%" align="center">&nbsp;</td>
    </tr>
    <tr>
      <td align="center"><a href="dbot.php">Operation Theater</a></td>
      <td align="center"><a href="mgmtsurgeries.php">Surgery Bookings</a></td>
      <td align="center"><a href="mgmtschedules.php">Staff Scheduling</a></td>
      <td align="center"><a href="mgmtstore.php">Equipment Store</a></td>
      <td align="center"><a href="otpresc.php">e-Prescriptions</a></td>
      <td align="center"><a href="ottransact.php">Payments & Refunds</a></td>
      <td align="center"><a href="repot.php">Reports</a></td>
      <td align="center"></td>
      <td height="24" align="center">&nbsp;</td>
    </tr>
  </tbody>
</table>

	<br> 
    <!-- page start-->
    <div class="row">
        <div class="col-sm-12">
            <section class="panel">
            
            <header class="panel-heading">
              <h2>STAFF SCHEDULES</h2>
            </header>
            
            <!--<div class="row">
                <aside class="col-lg-9">
                     <section class="panel">
                         <div class="panel-body">
                            <div id="calendar" class="has-toolbar"></div>
                         </div>
                     </section>
                </aside>
            </div>-->
            
            <div id="datepicker">
            <form action="" method="post" id="form">
                <table width="99%" border="0" cellpadding="1" cellspacing="1">
                    <tr>
                        
                        <td align="left"></td>
                        
                        
                    </tr>
                </table>
                
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
              		<tr>
              
                <td width="10%" valign="bottom"></td>
                <td width="90%" align="right">Date: <input type="text" name="date" value="<?php echo $date;?>" class="form-control date start" readonly style="display:inline; width:15%;">
                <div class="col-md-5" style="float: right;">
                <div class="profile-nav alt">
                  <section class="panel">
                    <div class="user-heading alt clock-row terques-bg" style="min-height:0px;">
                      <p class="text-left">Appointments on:</p>
                      <h1><?php echo date('d F Y',strtotime($date));?></h1>
                    </div>
                  </section>
                </div>
              </div>
          		</td>
                
              </tr>
            	</table>
           </form>
           </div>
           
           <br><br>
            
           <div class="panel-body" style="padding-top: 0px; margin-top: -34px;">
                <div class="adv-table">
                    <table  class="display table table-bordered table-striped" id="dynamic-table">
                    
                    <thead>
                        <tr>
                        	<th width="20%">Doctor</th>
                        	<th width="60%">Appointments</th>
                        	<th width="20%" align="center"></th>
                        </tr>
                    </thead>
                    
                    <tbody>
                    <?php
					if(isset($app_array[0]['doctor_id']))
					{
						for($ap=0;$ap<count($app_array);$ap++)
						{
							
							$doc_name = ucwords($app_array[$ap]['title'].'. '.$app_array[$ap]['doc_fname'].' '.$app_array[$ap]['doc_lname']);
							$doc_id = $app_array[$ap]['doctor_id'];
							?>
							<tr>
								<td align="left"><?php echo $doc_name;?><br>
                                <a href="javascript:Popup('calender.php?doc_id=<?php echo base64_encode($doc_id);?>')">Calendar</a></td>
								
								<td align="left" valign="top">
                                <?php
								for($app=0;$app<count($app_array[$ap]['apps']);$app++)
								{
									$app_timein = date('h:i A',$app_array[$ap]['apps'][$app]['app_timein']);
									$app_timeout = date('h:i A',$app_array[$ap]['apps'][$app]['app_timeout']);
									
									$patOb = new classPatient;
									?>
									
                                    <span class="smallgrey"><?php echo $app_timein.' - '.$app_timeout; ?></span> - <?php echo $patOb->retrievePatientNameByPatientID($app_array[$ap]['apps'][$app]['patient_id']); ?><br>
									<?php
								}
								?>
								</td>
								
								<td align="left" valign="top"><a href="#allocate_appointment-box" class="allocate_appointment-window allocate_appointment" id="<?php echo $ap;?>"><p class="btn btn-success btn-sm">Enter Appointment</p></a></td>
                                
							</tr>
                            
                            <input type="hidden" name="doctor_name" id="doctor_name_<?php echo $ap?>" value="<?php echo $doc_name;?>">
                            <input type="hidden" name="doctor_id" id="doctor_id_<?php echo $ap?>" value="<?php echo $doc_id;?>">
							<?php
						}
					}
					else
					{
						?>
                    	<tr>
                            <table>
                                <tr><td>No Entries Found!</td></tr>
                            </table>
                        </tr>
                        <?php
					}
					?>
                    </tbody>
                    
                    </table>
                </div>
            </div>
            
           </section>
        </div>
    </div>
    <!-- page end-->
    
    </section>
  </section>
  
  
  
  <!-- InstanceEndEditable --><!--main content end-->
<!--right sidebar start-->
 
<!--right sidebar end-->
</section>
<!-- Placed js at the end of the document so the pages load faster -->
<!--Core js-->
<!--<script src="../js/jquery-1.10.2.min.js"></script>-->
  
 
<script src="../assets/jquery-ui/jquery-ui-1.10.1.custom.min.js"></script>
<script src="../bs3/js/bootstrap.min.js"></script>



<script src="../js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="../popUp/popUp.js"></script>
<script src="../js/ajax.js"></script>

<script src="../js/lib/jquery.js"></script>
<script src="../assets/fullcalendar/fullcalendar/fullcalendar.min.js"></script>
<script src="../js/calendar/external-dragging-calendar.js"></script>
<script src="../js/accordion-menu/jquery.dcjqaccordion.2.7.js"></script>
<script src="../js/scrollTo/jquery.scrollTo.min.js"></script>
<script src="../js/nicescroll/jquery.nicescroll.js" type="text/javascript"></script>
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="js/flot-chart/excanvas.min.js"></script><![endif]-->
<script src="../assets/jQuery-slimScroll-1.3.0/jquery.slimscroll.js"></script>
<script src="../assets/skycons/skycons.js"></script>
<script src="../assets/jquery.scrollTo/jquery.scrollTo.js"></script>
<script src="../js/jquery.easing.min.js"></script>
<script src="../assets/calendar/clndr.js"></script>
<script src="../js/underscore-min.js"></script>
<script src="../assets/calendar/moment-2.2.1.js"></script>
<script src="../js/calendar/evnt.calendar.init.js"></script>
<script src="../assets/jvector-map/jquery-jvectormap-1.2.2.min.js"></script>
<script src="../assets/jvector-map/jquery-jvectormap-us-lcc-en.js"></script>
<script src="../assets/gauge/gauge.js"></script>



<!--clock init-->
<script src="../assets/css3clock/js/script.js"></script>
<!--Easy Pie Chart-->
<script src="../assets/easypiechart/jquery.easypiechart.js"></script>
<!--Sparkline Chart-->
<!--Morris Chart-->
<script src="../assets/morris-chart/morris.js"></script>
<script src="../assets/morris-chart/raphael-min.js"></script>
<!--jQuery Flot Chart-->
<script src="../assets/flot-chart/jquery.flot.animator.min.js"></script>
<script src="../assets/flot-chart/jquery.flot.growraf.js"></script>
<script src="../js/dashboard.js"></script>
<script src="../js/custom-select/jquery.customSelect.min.js" ></script>
<!--common script init for all pages-->
<script src="../js/scripts.js"></script>
<!--dynamic table initialization -->
<script src="../js/dynamic_table/dynamic_table_init.js"></script>



<!--dynamic table initialization -->
<script src="../js/dynamic_table/dynamic_table_init.js"></script>
<!--<start===================>-->
<script src="../js/lib/jquery.js"></script>


<script src="../bs3/js/bootstrap.min.js"></script>



<script class="include" type="text/javascript" src="../js/accordion-menu/jquery.dcjqaccordion.2.7.js"></script>

<script src="../js/scrollTo/jquery.scrollTo.min.js"></script>
<script src="../js/nicescroll/jquery.nicescroll.js" type="text/javascript"></script>
<!--Easy Pie Chart-->
<script src="../assets/easypiechart/jquery.easypiechart.js"></script>
<!--Sparkline Chart-->
<script src="../assets/sparkline/jquery.sparkline.js"></script>
<!--jQuery Flot Chart-->
<script src="../assets/flot-chart/jquery.flot.js"></script>
<script src="../assets/flot-chart/jquery.flot.tooltip.min.js"></script>
<script src="../assets/flot-chart/jquery.flot.resize.js"></script>
<script src="../assets/flot-chart/jquery.flot.pie.resize.js"></script>
<script type="text/javascript" src="../assets/bootstrap-daterangepicker/daterangepicker.js"></script>
<script type="text/javascript" src="../assets/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>

<!--dynamic table-->
<!--common script init for all pages-->
<script src="../js/scripts.js"></script>

<!--dynamic table initialization -->
<script src="../js/dynamic_table/dynamic_table_init.js"></script>

<script type="text/javascript" src="../datepicker/jquery-1.9.1.js"></script>
<script type="text/javascript" src="../datepicker/jquery-ui.js"></script>

<!--<script type="text/javascript" src="../popUp/jquery-1.9.0.js"></script>-->
<script type="text/javascript">

 function Popup(apri) { 
	window.open(apri,"","top=10,left=200,width=800,height=700,status=no,menubar=no,toolbar=no,scrollbars=yes"); 
 }
</script> 

<div id="update_password-box" class="update_password-popup">
    
    <div class="pop_header">
        <span>Change Password</span>
        <a href="#" class="pop_close" style="float:right;">Close (X)</a>
    </div>
    
    <table width="100%" border="0" cellspacing="2" cellpadding="2" class="panel">
      <tr>
        <td>
          <div id="result_update_password_form"></div>
          
          <form action="" method="post" id="update_password_form" class="cmxform form-horizontal" onSubmit="return false;">
          	
            <br>
            
         	<div class="form-group">
            <label class="control-label col-lg-3" for="lastname">New Password:</label>
                <div class="col-lg-6">
                    <input type="password" name="password" class="form-control" value="" id="exampleInputPassword1">
                </div>
            </div>
           
            <p align="right">
            	<input type="hidden" name="user_id" value="<?php if(isset($user_id)&&$user_id!=''){echo $user_id;}else{ echo 
				$_SESSION['security']['user_id'];}?>">
                <input type="hidden" name="updateUserPwd" value="yes">
                <input name="ajax_submit" type="submit" class="ajax_submit btn btn-info" value="Update"/>
            </p>
            
          </form>
          </td>
          
      </tr>
    </table>
</div> 
 
</body>  
<!-- InstanceEnd --></html>



<script type="text/javascript" src="../timepicker/jquery.timepicker.js"></script>
<link rel="stylesheet" type="text/css" href="../timepicker/jquery.timepicker.css" />

<script type="text/javascript" src="../timepicker/lib/bootstrap-datepicker.js"></script>
<link rel="stylesheet" type="text/css" href="../timepicker/lib/bootstrap-datepicker.css" />

<script type="text/javascript" src="../timepicker/dist/datepair.js"></script>           
<script type="text/javascript" src="../timepicker/dist/jquery.datepair.js"></script>

<div id="select_patient-box" class="select_patient-popup">
    
    <div class="pop_header">
        <span>Select Patient</span>
        <a href="#" class="pop_close" style="float:right;">Close (X)</a>
    </div>
    
    <div class="scrollbar" style="height:300px;">
    
   		<form action="" method="post" id="patient_search_form">
    	<table width="100%" border="0" cellpadding="1" cellspacing="0">
         
          <tr>
          
            <td width="12%" align="right">Search Name: </td>
            <td width="15%">
                <input type="text" name="by_name" id="by_name" value="" class="form-control" aria-controls="dynamic-table">
            </td>
            
            <td width="5%" align="right">ID: </td>
            <td width="15%">
                <input type="text" name="by_id" id="by_id" value="" class="form-control" aria-controls="dynamic-table">
            </td>
            
            <td width="5%" align="right">Phone: </td>
            <td width="15%">
                <input type="text" name="by_phone" id="by_phone" value="" class="form-control" aria-controls="dynamic-table">
            </td>
            
            <td><input name="search" type="submit" id="patient_search" class="btn btn-success btn-sm" value="Search"/></td>
            
            <td width="15%" align="left"><a href="mgmtbeds" id="view_all_patients">View All</a></td>
            
          
          </tr>
        </table>
        <input type="hidden" name="search_patient" value="Search">
        <input type="hidden" name="refferer" value="mgmtbeds">
        
        </form>  
         
    	<table class="display table table-bordered table-striped" id="dynamic-table">
        
          <thead>
            <tr>
              <th width="5%" align="center">&nbsp;</th>
              <th width="5%" align="center">&nbsp;</th>
              <th width="5%" align="center">ID</th>
              <th width="10%" align="center">DOB</th>
              <th width="20%">Patient Name</th>
              <th width="15%">Phone</th>
              <th width="15%">Registration Date</th>
            </tr>
          </thead>
          <tbody id="default_body">
          
          </tbody>
         
        </table>
        
    </div>
    
</div>

<div id="add_patient-box" class="add_patient-popup">
    
    <div class="pop_header">
        <span>Add Patient</span>
        <a href="#" class="pop_close" style="float:right;">Close (X)</a>
    </div>
    
    <table width="100%" border="0" cellspacing="2" cellpadding="2" class="panel">
      <tr>
        <td>
          <div id="result_insert_patient_form" style="margin:10px;"></div>
          <form action="" method="post" id="insert_patient_form" class="cmxform form-horizontal" onSubmit="return false;">
          
           	<div class="form-group">
              <label class="control-label col-lg-3" for="firstname">First Name:</label>
              <div class="col-lg-6">
              	<input type="text" name="patient_fname" value="" class="form-control">
              </div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="firstname">Last Name:</label>
              <div class= "col-lg-6">
                <input type="text" name="patient_lname" value="" class="form-control">
              </div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="lastname">S/D/W of:</label>
              <div class="col-lg-6">
                <input type="text" name="relationship_name" value="" class="form-control">
              </div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="lastname">Gender:</label>
              <div class="col-lg-6">
                <select name="gender" class="form-control input-sm m-bot15" style="width:50%;">
                    <option value="Male">Male</option>
                    <option value="Female">Female</option>
                </select>
              </div>
            </div>
            
             <div class="form-group">
            <label class="control-label col-lg-3" for="firstname">Age:</label>
                <div class="col-lg-6">
                    <input type="text" name="age" class=" form-control" value="" style="width:50%; display:inline;">
                </div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="firstname">Phone:</label>
              <div class="col-lg-6">
                 <input type="text" name="phone" value="" class="form-control">
              </div>
            </div>
            
            <div class="form-group">
              <label class="control-label col-lg-3" for="lastname">Address:</label>
              <div class="col-lg-6">
               <input type="text" name="address" value="" class="form-control">
            </div>
            </div>
            
             <div class="form-group">
              <label class="control-label col-lg-3" for="lastname">Referred By:</label>
              <div class="col-lg-6">
               <input type="text" name="reffered_by" value="" class="form-control">
            </div>
            </div>
            
            <p align="right">
              <input type="hidden" name="add_patient_basic" value="yes">
              <input type="hidden" name="fee_per_session" value="0">
              <input type="hidden" name="redirect_url" value="mgmtappoint">
              <input name="ajax_submit" type="submit" class="ajax_submit_patient btn btn-info" value="Save" />
            </p>
            
          </form>
          </td>
          
      </tr>
    </table>
</div>

<div id="allocate_appointment-box" class="allocate_appointment-popup">
    
    <div class="pop_header">
        <span>Enter Appointment</span>
        <a href="#" class="pop2_close" style="float:right;">Close (X)</a>
    </div>
    
    <table width="100%" border="0" cellspacing="2" cellpadding="2" class="panel">
        <tr>
            <td>
            
            <div id="result_insertappointment_form"></div>
            
            <form action="" method="post" id="insertappointment_form" class="cmxform form-horizontal" onsubmit="return false;">
            
            <div class="form-group">
           	 	<label class="control-label col-lg-3" for="firstname">Doctor:</label>
                <div class="col-lg-6" id="doctor_name" style="margin-top:7px;">
                </div>
                <input  type="hidden" name="doctor_id" id="doctor_id" value="">
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Patient:</label>
               
                 <!--<a href="#select_patient-box" class="select_patient-window"  id="select_patient_popup">Select Patient</a>-->
                 <div class="col-lg-6">
                    <select name="patient_type" id="patient_type" class="form-control input-sm m-bot15 patient_type">
                        <option value="">Select Patient Type</option>
                        <option value="in_patient">Registered Patient</option>
                        <option value="out_patient">New Patient</option>
                    </select>
                </div>
                 <label class="control-label col-lg-3" for="firstname"></label>
                 <div class="col-lg-6" id="patient_name"></div>
            </div>
           
          
            <div class="form-group">
           	 	<label class="control-label col-lg-3" for="firstname">Date:</label>
                <div class="col-lg-6">
                	<input type="text" name="app_date"  id="app_date" value="<?php echo $date;?>" class="form-control" readonly style="display:inline; width:50%;">
                </div>
             </div>
          
            
          	<div id="datepairExample">
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Time In:</label>
                <div class="col-lg-6">
                	<input type="text" name="app_timein" value=""  class="form-control time start" style="width:90%; display:inline;">
                </div>
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Time Out:</label>
                <div class="col-lg-6">
                	<input type="text" name="app_timeout" value="" class="form-control time end" style="width:90%; display:inline;">
                </div>
            </div>
            
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Purpose:</label>
                <div class="col-lg-6">
                	<input type="text" name="app_purpose" value=""  class="form-control">
                </div>
            </div>
            
            <p align="right">
            	<input type="hidden" name="patient_id" id="patient_id" value="">
                <input type="hidden" name="app_type" id="app_type" value="opd">
                
               	<input type="hidden" name="insert_appointment" value="Insert_appointment">
                <input name="ajax_submit" type="submit" class="ajax_submit btn btn-info" value="Make Appointment"/>
            </p>
            
            </form>
            
            </td>
        </tr>
    </table>
    
</div>

<?php /*?><div id="allocate_appointment-box" class="allocate_appointment-popup">
    
    <div class="pop_header">
        <span>Allocate Appointment</span>
        <a href="#" class="pop2_close" style="float:right;">Close (X)</a>
    </div>
    
    <table width="100%" border="0" cellspacing="2" cellpadding="2" class="panel">
        <tr>
            <td>
            
            <div id="result_insertappointment_form"></div>
            
            <form action="" method="post" id="insertappointment_form" class="cmxform form-horizontal" onsubmit="return false;">
            
            <div class="form-group">
           	 	<label class="control-label col-lg-3" for="firstname">Select Doctor:</label>
                <div class="col-lg-6">
                    <select name="doctor_id"  class="form-control">
                        <option value="">Select Doctor</option>
                        <?php
                        if(isset($doc_array[0]['doctor_id'])&&$doc_array[0]['doctor_id']!='')
                        {
                            for($d=0;$d<count($doc_array);$d++)
                            {
                                ?>
                                <option value="<?php echo $doc_array[$d]['doctor_id'];?>"><?php echo $doc_array[$d]['title'].'. '.$doc_array[$d]['doc_fname'].' '.$doc_array[$d]['doc_lname'];?></option>
                                <?php
                                
                            }
                        }
                        ?>
                      </select>
                    
                </div>
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Patient:</label>
               
                 <!--<a href="#select_patient-box" class="select_patient-window"  id="select_patient_popup">Select Patient</a>-->
                 <div class="col-lg-6">
                    <select name="patient_type" id="patient_type" class="form-control input-sm m-bot15 patient_type">
                        <option value="">Select Patient Type</option>
                        <option value="in_patient">Registered Patient</option>
                        <option value="out_patient">New Patient</option>
                    </select>
                </div>
                 <label class="control-label col-lg-3" for="firstname"></label>
                 <div class="col-lg-6" id="patient_name"></div>
            </div>
            
          	<div id="datepairExample">
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">App Time In:</label>
                <div class="col-lg-6">
                	<input type="text" name="app_timein" value=""  class="form-control time start" style="width:90%; display:inline;">
                </div>
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">App Time Out:</label>
                <div class="col-lg-6">
                	<input type="text" name="app_timeout" value="" class="form-control time end" style="width:90%; display:inline;">
                </div>
            </div>
            
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">App Purpose:</label>
                <div class="col-lg-6">
                	<input type="text" name="app_purpose" value=""  class="form-control">
                </div>
            </div>
            
            <p align="right">
            	<input type="hidden" name="patient_id" id="patient_id" value="">
                <input type="hidden" name="app_type" id="app_type" value="opd">
                <input type="hidden" name="app_date" value="<?php echo date('Y-m-d',time());?>">
                <input type="hidden" name="insert_appointment" value="Insert_appointment">
                <input name="ajax_submit" type="submit" class="ajax_submit btn btn-info" value="Allocate"/>
            </p>
            
            </form>
            
            </td>
        </tr>
    </table>
    
</div><?php */?>

<script>

$(document).ready(function(e) {
    $('#datepairExample .time').timepicker({
        'showDuration': true,
        'timeFormat': 'g:ia'
    });

    $('#datepairExample .date').datepicker({
        'format': 'yyyy-mm-dd',
        'autoclose': true
    });

    // initialize datepair
    $('#datepairExample').datepair();
	
	});

$(document).ready(function(e) {
    
    $('#datepicker .date').datepicker({
		'format': 'yyyy-mm-dd',
        'autoclose': false
	});
	
	$("#datepicker").on("changeDate",function (e) {
		$("#form").submit();
	});
	
	 // initialize datepair
    $('#datepicker').datepair();
	
	});

$(".allocate_appointment").click(function() {
	
	var id = this.id;
	
	doctor_name = $("#doctor_name_"+id).val();
	doctor_id = $("#doctor_id_"+id).val();
	
	$("#doctor_id").val(doctor_id);
	$("#doctor_name").html(doctor_name);});
	
$('#app_date').datepicker({
	'format': 'yyyy-mm-dd',
	'autoclose': true});


</script>

	