<?php
include('../config/config.php');
include("../classes/classPatient.php");
include("../classes/classImages.php");

/*echo '<pre>';
print_r($_SESSION);
echo '</pre>';*/



if(!$_POST)
{
	unset($_SESSION['temp']['image_id']);
}

if(isset($_GET['pid'])&&$_GET['pid']!='')
{
	$patient_auto_id = base64_decode($_GET['pid']); 
	try
	{
		$retrievePatientOb = new classPatient;
		$retrievePatientOb->setPatientAutoID($patient_auto_id);
		$patient_array = $retrievePatientOb->retrievePatientByPatientID();
		
		$imageOb = new classImages;
		$imageOb->setPatientAutoID($patient_auto_id);
		$image_id = $imageOb->fetchImageOfPatient();
		$images_array = $imageOb->fetchAllImageOfPatient();
	}
	catch (MyException $e)
	{
		$error_message = $e->getUserMsg();
	}
}

if(isset($_POST['cancel'])&&$_POST['cancel']=='Cancel')
{
	header("Location:mgmtpatients.php");
	exit;
}

if(isset($_FILES['image']))
{
	try
	{
		
			
		$imageOb = new classImages;
		$imageOb->setImageName($_FILES['image']['name']);
		$imageOb->setImageSize($_FILES['image']['size']);
		$imageOb->setImageType($_FILES['image']['type']);
		$imageOb->execute();
		
		$_SESSION['temp']['image_id'] = $imageOb->getImageID();
		
		$path = '../images/patient_images/'.$_SESSION['temp']['image_id'].'.jpg';
		move_uploaded_file($_FILES['image']['tmp_name'],$path);
		
	}
	catch (MyException $e)
	{
		$error_message = $e->getUserMsg();
	}
}

/*echo '<pre>';
print_r($patient_array);
echo '</pre>';
exit;*/

?>
<!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" -->
                    <?php 
					if(isset($patient_array[0]['patient_auto_id']))
					{
						$url = "?pid=".base64_encode($patient_auto_id);
					}
					else
					{
						$url = "";
					}?>
                    <a href="javascript:Popup('printaddpatient.php<?php echo $url;?>')"><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" -->
<script type="text/javascript">

     function Popup(apri) { 
        window.open(apri,"","top=10,left=200,width=900,height=700,status=no,menubar=no,toolbar=no,scrollbars=yes"); 
     }
</script>     
  <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="mgmtpatients.php"><img src="../images/iconpatients.png"></a></td>
      <td width="12%" align="center"><a href="addpatient.php"><img src="../images/iconregister.png"></a></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="12%" align="center"></td>
      <td width="2%" align="center">&nbsp;</td>
    </tr>
    <tr>
     
      <td align="center"><a href="mgmtpatients.php">Manage Patients</a></td>
      <td align="center"><a href="addpatient.php">Register Patient</a></td>
       <td align="center"></td>
      <td align="center"></td>
      <td align="center"></td>
      <td align="center"></td>
      <td align="center"></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>PATIENT REGISTRATION FORM</h2>
            </header>
            
            <?php
			if(isset($error_message)&&$error_message!='')
			{
				?>
				<span class="message_red"><?php echo $error_message;?></span>
				<?php
			}
			?>
            
            
            
            <div id="result_insert_patient_form"></div>
            
            <form method="post" id="insert_patient_form" class="cmxform form-horizontal" enctype="multipart/form-data">
            
            <table width="100%" border="0" cellspacing="15" cellpadding="15">
            	<tr>
             		<td width="10%" align="left">
                    <div style="float: left; margin-left: 15px;">
                    <?php
					if(isset($_SESSION['temp']['image_id']))
                    {
                    	?>
                    	<img style="height:148px; width:140px;" src="../images/patient_images/<?php echo $_SESSION['temp']['image_id'];?>.jpg">
                        <?php
                    }
					elseif(isset($image_id))
					{
						
						?>
                    	<img style="height:148px; width:140px;" src="../images/patient_images/<?php echo $image_id;?>.jpg">
                        <?php
					}
                    else
                    {
                    	?>
                    	<img src="../images/photo.png">
                        <?php
                    }
					?>
                    
                    
                    </div>
                	</td>
                	<td width="50%" align="left" valign="bottom"><table width="80%" border="0" cellspacing="1" cellpadding="1">
                        <form action="" method="post" enctype="multipart/form-data">
                        <tr>
                            <td width="100%" align="left" valign="top">Select Image:<table width="100%" border="0" cellspacing="1" cellpadding="1">
                            <tr>
                                <td width="30%" style="border: solid 1px #ccc;"><input type="file" name="image" value="" id="image"></td>
                                <td width="70%"  valign="middle">
                                <input name="upload_image" type="submit" class="btn btn-success btn-sm" value="Upload"/></td>
                            </tr>
                            </table></td>	
                        </tr>
                        </form>   
                        </table></td>
                        <td width="40%" align="right" valign="bottom"><?php 
                        if(isset($patient_array[0]['patient_auto_id']))
                        {
                            ?>
                            <input name="ajax_submit" type="submit" class="ajax_submit btn btn-success btn-sm" value="Update"/>
                            <?php
                        }
                        else
                        {
                            ?>
                            <input name="ajax_submit" type="submit" class="ajax_submit btn btn-success btn-sm" value="Save"/>
                            <?php
                        }
                        ?>
                        <input type="submit" name="cancel" value="Cancel" class="btn btn-success btn-sm"></td>
               	</tr>
            </table>

            <div class="panel-body">
                <div class="adv-table">
                  <table class="display table table-bordered table-striped" id="dynamic-table">
                      <thead>
                        <tr>
                        
                          <th>
                          <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            
                            
                            <tr>
                                <td><h4>PATIENT'S INFORMATION</h4></td>
                                <td><label class="control-label col-lg-3" for="firstname">Registration Date:</label>
                                        <div class="col-lg-6">
                                         <?php 
										if(isset($patient_array[0]['patient_auto_id']))
										{
											echo date('d M Y',$patient_array[0]['reg_date']);
											?>
                                        	<input type="hidden" name="reg_date" value=" <?php if(isset($patient_array[0]['reg_date'])){echo date('d M Y',$patient_array[0]['reg_date']);}else{echo date('d M Y',time());}?>" style="width:60%; display:inline;">
                                        	<?php
										}
										else
										{
											?>
                                        	<input type="text" name="reg_date" id="datepicker1" class=" form-control" value=" <?php if(isset($patient_array[0]['reg_date'])){echo date('d M Y',$patient_array[0]['reg_date']);}else{echo date('d M Y',time());}?>" style="width:60%; display:inline;">
                                        	<?php
										}
										?>
                                          
                                        </div>
                                    </div></td>
                            </tr>  
                            
                            <tr>
                            
                                <td>
                                    <label class="control-label col-lg-3" for="firstname">Patient ID *</label>
                                        <div class="col-lg-6">
                                            <input type="text" name="patient_id" id="lastname" class="form-control" style="width:40%;" value="<?php 
											if(isset($patient_array[0]['patient_id']))
											{
												echo $patient_array[0]['patient_id'];
											}
											else
											{
												 $patOb = new classPatient;
												 echo $patOb->nextPatientID($_SESSION['security']['location_id']);
											}?>">
                                            
                                        </div>
                                        
                                    </div>
                                </td>
                                
                                <td>
                                     
                                <label class="control-label col-lg-3" for="firstname">Fee Per Session:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="fee_per_session" id="lastname" class=" form-control" value="<?php if(isset($patient_array[0]['fee_per_session'])){echo $patient_array[0]['fee_per_session'];}?>"  style="width:40%;">
                                    </div>
                                </div>
                                
                                </td>
                                
                            </tr>  
                            
                            <tr>
                                <td>
                                <label class="control-label col-lg-3" for="firstname">First Name *:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="patient_fname" id="lastname" class=" form-control" value="<?php if(isset($patient_array[0]['patient_fname'])){echo $patient_array[0]['patient_fname'];}?>" style="width:60%;">
                                    </div>
                                </div>
                                </td>
                            
                                <td>
                                <label class="control-label col-lg-3" for="firstname">Last Name:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="patient_lname" id="lastname" class=" form-control" value="<?php if(isset($patient_array[0]['patient_lname'])){echo $patient_array[0]['patient_lname'];}?>" style="width:60%;">
                                    </div>
                                </div>
                                </td>
                            </tr>      
                            
                            <tr>
                                <td>
                                <label class="control-label col-lg-3" for="firstname">Birth Date *:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="dob" id="datepicker" class=" form-control" value="<?php if(isset($patient_array[0]['dob'])){echo $patient_array[0]['dob'];}?>" style="width:60%; display:inline;">
                                    </div>
                                </div>
                                </td>
                            
                                <td>
                            <label class="control-label col-lg-3" for="firstname">Gender:</label>
                            <div class="col-lg-6">
                                        <select name="gender" class="form-control input-sm m-bot15" style="width:60%;">
                                            <option value="Male" <?php if(isset($patient_array[0]['gender'])&&$patient_array[0]['gender']=='Male'){echo'selected';}?>>Male</option>
                                            <option value="Female" <?php if(isset($patient_array[0]['gender'])&&$patient_array[0]['gender']=='Female'){echo'selected';}?>>Female</option>
                                        </select>
                                    </div>
                            </div>
                                </td>
                            </tr>   
                            
                            <tr>
                             <td>
                                <label class="control-label col-lg-3" for="firstname">Phone No *:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="phone" id="lastname" class=" form-control" value="<?php if(isset($patient_array[0]['phone'])){echo $patient_array[0]['phone'];}?>"  style="width:60%;">
                                    </div>
                                </div>
                                </td>
                            
                                <td>
                                <label class="control-label col-lg-3" for="firstname">Address:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="address" id="lastname" class=" form-control" value="<?php if(isset($patient_array[0]['address'])){echo $patient_array[0]['address'];}?>">
                                    </div>
                                </div>
                                </td>
                            </tr>      
                            
                            <tr>
                                <td>
                                <label class="control-label col-lg-3" for="firstname">City:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="city" id="lastname" class=" form-control" value="<?php if(isset($patient_array[0]['city'])){echo $patient_array[0]['city'];}?>"  style="width:60%;">
                                    </div>
                                </div>
                                </td>
                            
                               
                                <td>
                                <label class="control-label col-lg-3" for="firstname">CNIC No:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="nic" id="lastname" class=" form-control" value="<?php if(isset($patient_array[0]['nic'])){echo $patient_array[0]['nic'];}?>">
                                    </div>
                                </div>
                                </td>
                            </tr>
                            
                            <?php /*?><tr>
                            
                                <td>
                                  <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="<?php if(isset($patient_array[0]['relationship_name'])){echo $patient_array[0]['relationship_name'];}?>" class="form-control"  style="width:60%;">
                                  </div>
                                </div>
                                </td>
                                <td>
                                <label class="control-label col-lg-3" for="firstname">Email Address:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="email" id="lastname" class=" form-control" value="<?php if(isset($patient_array[0]['email'])){echo $patient_array[0]['email'];}?>">
                                    </div>
                                </div>
                                </td>
                                
                            </tr><?php */?>
                            
                                                              
                            <tr>
                                <td><h4>PARENT/ATTENDANT INFORMATION</h4></td>
                            </tr>
                            
                            <tr>
                            <td>
                                <label class="control-label col-lg-3" for="firstname">Son/Daughter/Wife of:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="parent_name" id="lastname" class=" form-control" value="<?php if(isset($patient_array[0]['parent_name'])){echo $patient_array[0]['parent_name'];}?>">
                                    </div>
                                </div>
                            </td>
                            <td>
                                <label class="control-label col-lg-3" for="firstname">Father/Spouse Phone:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="parent_phone" id="lastname" class=" form-control" value="<?php if(isset($patient_array[0]['parent_phone'])){echo $patient_array[0]['parent_phone'];}?>">
                                    </div>
                                </div>
                                </td>
                                
                            </tr>
                            
                           <!-- <tr>
                            
                            <td>
                                <label class="control-label col-lg-3" for="firstname">NIC No:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="parent_nic" id="lastname" class=" form-control" value="<?php /*?><?php if(isset($patient_array[0]['parent_nic'])){echo $patient_array[0]['parent_nic'];}?><?php */?>">
                                    </div>
                                </div>
                                </td>
                                
                            
                                
                            </tr>-->
                            
                            <tr>
                                <td><h4>MEDICAL HISTORY</h4></td>
                            </tr>
                            
                            <tr>
                            <td>
                                <label class="control-label col-lg-3" for="firstname">Referring Doctor:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="ref_doctor" id="lastname" class=" form-control" value="<?php if(isset($patient_array[0]['ref_doctor'])){echo $patient_array[0]['ref_doctor'];}?>">
                                    </div>
                                </div>
                            </td>
                            <td>
                                <label class="control-label col-lg-3" for="firstname">Blood Group:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="blood_group" id="lastname" class=" form-control" style="width:40%;" value="<?php if(isset($patient_array[0]['blood_group'])){echo $patient_array[0]['blood_group'];}?>">
                                    </div>
                                </div>
                                </td>
                            </tr>
                            
                            <tr>
                            <td>
                                <label class="control-label col-lg-3" for="firstname">Medical Issues:</label>
                                    <div class="col-lg-6">
                                        <textarea name="med_history" cols="55" rows="5" class="form-control"><?php if(isset($patient_array[0]['med_history'])){echo $patient_array[0]['med_history'];}?></textarea>
                                    </div>
                                </div>
                            </td>
                            <td>
                                <label class="control-label col-lg-3" for="firstname">Allergies:</label>
                                    <div class="col-lg-6">
                                      <textarea name="allergies" cols="55" rows="5" class="form-control"><?php if(isset($patient_array[0]['allergies'])){echo $patient_array[0]['allergies'];}?></textarea>
                                    </div>
                                </div>
                                </td>
                            </tr>
                            
                            <?php /*?><tr>
                            <td>
                                <label class="control-label col-lg-3" for="firstname">Family History:</label>
                                    <div class="col-lg-6">
                                        <textarea name="fam_history" cols="55" rows="5" class="form-control"><?php if(isset($patient_array[0]['fam_history'])){echo $patient_array[0]['fam_history'];}?></textarea>
                                    </div>
                                </div>
                            </td>
                            <td>
                                <label class="control-label col-lg-3" for="firstname">Social History:</label>
                                    <div class="col-lg-6">
                                     <textarea name="soc_history" cols="55" rows="5" class="form-control"><?php if(isset($patient_array[0]['soc_history'])){echo $patient_array[0]['soc_history'];}?></textarea>
                                    </div>
                                </div>
                                </td>
                            </tr> <?php */?>
                        
                            
                            <tr>
                                <td><h4>EMERGENCY INFORMATION</h4></td>
                            </tr>
                            
                            <tr>
                            <td>
                                <label class="control-label col-lg-3" for="firstname">Brought in by:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="emer_name" id="lastname" class=" form-control" value="<?php if(isset($patient_array[0]['emer_name'])){echo $patient_array[0]['emer_name'];}?>">
                                    </div>
                                </div>
                            </td>
                            <td>
                                <label class="control-label col-lg-3" for="firstname">Phone:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="emer_phone" id="lastname" class=" form-control" value="<?php if(isset($patient_array[0]['emer_phone'])){echo $patient_array[0]['emer_phone'];}?>">
                                    </div>
                                </div>
                                </td>
                            </tr>
                            
                            <tr>
                                <td>
                                <label class="control-label col-lg-3" for="firstname">NIC No:</label>
                                    <div class="col-lg-6">
                                        <input type="text" name="emer_nic" id="lastname" class=" form-control" value="<?php if(isset($patient_array[0]['emer_nic'])){echo $patient_array[0]['emer_nic'];}?>">
                                    </div>
                                </div>
                                </td>
                            
                                
                            </tr>
                            
                           
                           
                          </table>
                          </th>
                         
                        </tr>
                      </thead>
                    </table>
                </div>
            </div>
             <?php 
			if(isset($patient_array[0]['patient_auto_id']))
            {
            	?>
                <input type="hidden" name="image_id" value="<?php if(isset($_SESSION['temp']['image_id'])){echo $_SESSION['temp']['image_id'];}?>">
                <input type="hidden" name="patient_auto_id" value="<?php echo $patient_array[0]['patient_auto_id'];?>">
                <input type="hidden" name="update_patient" value="update_patient">
            	<?php
            }
            else
			{
				?>
               <input type="hidden" name="image_id" value="<?php if(isset($_SESSION['temp']['image_id'])){echo $_SESSION['temp']['image_id'];}?>">
               <input type="hidden" name="save_patient" value="save_patient">
            	<?php
			}
			?>
            </form>
            
          </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>
	
	$(function() {
		$( "#datepicker" ).datepicker({
		showOn: "button",
		changeMonth: true,
		changeYear: true,
		buttonImage: "../images/calendar.gif",
		buttonImageOnly: true,
		dateFormat: "yy-mm-dd",
		yearRange: '1910:<?php echo date('Y',time());?>',
		
		});
		
		$( "#datepicker1" ).datepicker({
		showOn: "button",
		changeMonth: true,
		changeYear: true,
		buttonImage: "../images/calendar.gif",
		buttonImageOnly: true,
		dateFormat: "yy-mm-dd",
		});
	});

</script>