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


try
{
	$retrievePatientOb = new classPatient;
	
	if(isset($_SESSION['print']['search'])&&$_SESSION['print']['search']=='Search')
	{
		$patients_array = $retrievePatientOb->searchPatient($_SESSION['print']['by_id'],$_SESSION['print']['by_name'],$_SESSION['print']['by_phone'],$_SESSION['security']['location_id']);
	}
	else
	{
		
		$retrievePatientOb->setLocationID($_SESSION['security']['location_id']);
		$patients_array = $retrievePatientOb->retrievePatientByLocationID();
	}

}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}


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

?>
<!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"><!-- InstanceBegin template="/Templates/print.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <link rel="shortcut icon" href="../images/favicon.png">
    <title>Med2TEC Hospital Management Information System</title> 
    <link href="../css/print.css" rel="stylesheet">
    <link href="../datepicker/jquery-ui.css" rel="stylesheet" >  
    <script type="text/javascript" src="../datepicker/jquery-1.9.1.js"></script>
	<script type="text/javascript" src="../datepicker/jquery-ui.js"></script> 
</head>

<body> 
<div align="right"> 
 <SCRIPT LANGUAGE="JavaScript">  
if (window.print) {
document.write('<form class="no-print"><input type=button name=print value="Print" onClick="window.print()"></form>');
}
</script></div>

<section class="wrapper">
<div style="background:#FFF; padding:0px 0px 0; height:auto;">
  <table cellspacing="0" cellpadding="0" width="100%" border="0" style="font-size:11px;">
    <tbody>
      <tr>
        <td align="left" style="background:#fff;"><img alt="" src="../images/org_print_logos/<?php echo $_SESSION['security']['org_id']?>.png" style="width:100%;"></td>
      </tr>
    </tbody>
  </table>
  
</br>

</div>

<div class="row">
          <section class="panel">
            <header class="panel-heading">
              <h2><!-- InstanceBeginEditable name="title" -->REGISTERED PATIENTS<!-- InstanceEndEditable --></h2>
            </header>

  <br />
  
<!-- InstanceBeginEditable name="main" -->
  <!-- page start-->
          
                <table  class="bottomBorder" id="dynamic-table" cellpadding="0" cellspacing="0" width="100%">
                  <thead>
                    <tr>

                      <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>
                      <th width="15%">Registration Fee</th>
                    </tr>
                  </thead>
                  <tbody>
                  <?php
					if(isset($patients_array[0]['patient_auto_id'])&&$patients_array[0]['patient_auto_id']!='')
					{
						for($p=0;$p<count($patients_array);$p++)
						{
							if($p%2==0){ $class = 'gradeX';}else{$class = 'gradeC';}
							
							$pid = $patients_array[$p]['patient_auto_id'];
							
							$imageRetrieveOb = new classImages;
							$imageRetrieveOb->setPatientAutoID($pid);
							$image_id = $imageRetrieveOb->fetchImageOfPatient();
							?>
							<tr class="<?php echo $class;?>">
                                <td align="center">
                                <?php
                                if(isset($image_id)&&$image_id!='')
                                {
									?>
                                	<img src="../images/patient_images/<?php echo $image_id;?>.jpg" width="30" height="30">
                                    <?php
                                }
                                else
                                {
									?>
                                	<img src="../images/photo.png" width="30" height="30">
                                    <?php
                                }
								?>
                                </td>
                                <td align="center"><?php echo $patients_array[$p]['patient_id'];?></td>
                                <td align="center"><?php echo  date('d M Y',strtotime($patients_array[$p]['dob']));?></td>
                                <td align="left"><?php echo $patients_array[$p]['patient_fname'].' '.$patients_array[$p]['patient_lname'];?></td>
                                <td align="center"><?php echo $patients_array[$p]['phone'];?></td>
                                <td align="center"><?php echo date('d M Y',$patients_array[$p]['reg_date']);?></td>
                                <td align="center" >Receive Fee</td>
                                
                                
							</tr>
							<?php
						}
					}
					else
					{
						?>
                        
                        
						<tr>
                        <table>
                        <tr>
                        <td>No entries found!</td>
                        </tr>
                        </table>
						</tr>
                        <?php
					}
				  ?>

                  </tbody>
                  <tfoot>
                  </tfoot>
                </table>
  <!-- page end-->
  
<!-- InstanceEndEditable -->
</section>
</div>

<!--<p align="center" style="font-size:12px; font-family:Arial, Helvetica, sans-serif; margin-top:260px;"><strong><!--317 A-1, Nursery Stop, Township, Lahore. 
Ph: 042-35151666</strong><br />
For Appointment call at 042-35151666 (bring your Patient ID Card) </p>-->

   <div class="sidepop" style="float:right;">
    <div class="sidepopbutton stemp"><div style="color: rgb(0, 0, 0); text-align: right; font-size: 10px; margin-top: 4px; position: absolute; right: 180px;">© Software by Softusion Inc. 0322 6155 219</div>   
    </div>
</div>

<!--<div class="sidepop" style="float:right;">
    <div class="sidepopbutton stemp"><div style="color:#000; text-align:right; font-size:9px;">© Software designed by Softusion Inc. Contact us at 0322 6155 219</div>   
    </div>
</div>-->


          
</body>
<!-- InstanceEnd --></html>