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


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

#################### set temp session  ##############################################

if(isset($_GET['patientid'])&&isset($_GET['visitid']))
{
	$_SESSION['temp']['patient_id'] = base64_decode($_GET['patientid']);
	$_SESSION['temp']['visit_id'] = base64_decode($_GET['visitid']);
	//header("Location:mgmtvisits.php");
}
if(isset($_SESSION['temp']['shiftid'])&&$_SESSION['temp']['shiftid']!='')
{
	$shift_id = $_SESSION['temp']['shiftid'];
}
if(isset($_SESSION['temp']['doctorid'])&&$_SESSION['temp']['doctorid']!='')
{
	$doctor_id = $_SESSION['temp']['doctorid'];
}
if(isset($_SESSION['temp']['patient_id'])&&$_SESSION['temp']['patient_id']!='')
{
	$patient_id = $_SESSION['temp']['patient_id'];
}
if(isset($_SESSION['temp']['visit_id'])&&$_SESSION['temp']['visit_id']!='')
{
	$visit_id = $_SESSION['temp']['visit_id'];
}

#################### insert images ##############################################

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

#################### Delete images ##############################################

if(isset($_POST['delete_image'])&&$_POST['delete_image']=='Delete')
{
	if(isset($_POST['image_ids'][0]))
	{
		try
		{
			$delImageOb = new classImages;
			for($d=0;$d<count($_POST['image_ids']);$d++)
			{
				$delImageOb->setImageID($_POST['image_ids'][$d]);
				$delImageOb->deleteImageByImageID();
			}
		}
		catch (MyException $e)
		{
			$error_message = $e->getUserMsg();
		}	
	}
}


#################### Compare images ##############################################

if(isset($_POST['compare_image'])&&$_POST['compare_image']=='Compare')
{
	if(isset($_POST['image_ids'][0]))
	{
		$images = base64_encode(implode(',',$_POST['image_ids']));
		?>
		 	<script type="text/javascript">
			window.open("printimages.php?images=<?php echo $images;?>","","top=10,left=200,width=850,height=700,status=no,menubar=no,toolbar=no,scrollbars=yes"); 
			</script>   
        <?php
	}
}

#################### retrieve data ##############################################

try
{
	$retrieveVisitPrecOb = new classVisits;
	$retrieveVisitPrecOb->setPatientID($patient_id);
	$visit_array = $retrieveVisitPrecOb->retrieveVisitByPatientID();
	
	$count_array = $retrieveVisitPrecOb->countVisitsAndPaymenstByPatientID($patient_id);
	$total_payments = $count_array[0]['sum(payment)'];
	$total_visits = $count_array[0]['count(*)'];
	
	///////////// retrieve patient single data ///////////////////////////////
	
	$retrievePatientOb = new classPatient;
	$retrievePatientOb->setPatientAutoID($patient_id);
	$patient_single_detail = $retrievePatientOb->retrievePatientByPatientID();
	$patient_age = $retrievePatientOb->age_from_dob($patient_single_detail[0]['dob']);
	
	$imageOb = new classImages;
	$imageOb->setPatientAutoID($patient_id);
	$image_id = $imageOb->fetchImageOfPatient();
	$images_array = $imageOb->fetchAllImageOfPatient();
	
}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}


#################### insert visitor images ##############################################

if(isset($_FILES['visitor_image']))
{
	try
	{
		$imageOb = new classImages;
		$imageOb->setImageName($_POST['image_name']);
		$imageOb->setImageSize($_FILES['visitor_image']['size']);
		$imageOb->setImageType($_FILES['visitor_image']['type']);
		$imageOb->setVisitID($_POST['visit_id']);
		$imageOb->executeForVisitor();
		
		$vis_image_id = $imageOb->getImageID();
		
		$path = '../images/visitor_images/'.$vis_image_id.'.jpg';
		move_uploaded_file($_FILES['visitor_image']['tmp_name'],$path);
		
		header("location:opdhistory.php");
	}
	catch (MyException $e)
	{
		$error_message = $e->getUserMsg();
	}
}

#################### Delete images ##############################################

if(isset($_GET['delimage'])&&$_GET['delimage']!='')
{
	try
	{
		$delImageOb = new classImages;
		$delImageOb->setImageID(base64_decode($_GET['delimage']));
		$delImageOb->deleteVisitorImageByImageID();
		
		header("location:opdhistory.php");
	}
	catch (MyException $e)
	{
		$error_message = $e->getUserMsg();
	}	
}


/*echo '<pre>';
print_r($count_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('printopdhistory.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" -->
  <script type="text/javascript">

     function Popup(apri) { 
        window.open(apri,"","top=10,left=200,width=850,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="dbopd.php"><img src="../images/icondb.png"></a></td>
      <td width="12%" align="center"><a href="mgmtshifts.php"><img src="../images/iconshifts.png"></a></td>
      <td width="12%" align="center"><a href="mgmtvisits.php"><img src="../images/iconvisits.png" /></a></td>
      <td width="12%" align="center"><a href="addpresc.php"><img src="../images/iconpresc.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="2%" align="center">&nbsp;</td>
    </tr>
    <tr>
      <td align="center"><a href="dbopd.php">Out Patient</a></td>
      <td align="center"><a href="mgmtshifts.php">Manage Shifts</a></td>
      <td align="center"><a href="mgmtvisits.php">Manage Visits</a></td>
      <td align="center"><a href="addpresc.php">Today's Prescription</a></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'S OPD HISTORY</h2>
            </header>
            
            <?php
			if(isset($error_message)&&$error_message!='')
			{
				?>
                <table>
                <tr>
					<td align="left"><span class="message_red"><?php echo $error_message;?></span></td>
                </tr>
                </table>
				<?php
			}
			?>
            
       		<div class="col-md-4" style="width:60%;">
                <section class="panel">
                    <div class="panel-body">
                    
                        	<form action="" method="post" enctype="multipart/form-data">
                        <h4 class="widget-h" style="float:left;">Image History <?php
                            if(isset($images_array[0]['image_id']))
                            {
								?>
                            <input name="delete_image" type="submit" class="btn btn-success btn-sm" style=" background-color:white; border-color:white;color:#ff6600;font-size: 9pt;line-height:1.4em" value="Delete"/>
                            
                            <input name="compare_image" type="submit" class="btn btn-success btn-sm" style=" background-color:white; border-color:white;color:#ff6600;font-size: 9pt;line-height:1.4em" value="Compare"/>
                             
                            <?php
						}
						?></h4>
                       
                        	<?php
                            if(isset($images_array[0]['image_id']))
                            {
								?>
                                <div style="float:left; width:100%;">
									<?php
                                    for($im=0;$im<count($images_array);$im++)
                                    {
                                        ?>
                                        <div style="float:left;width:10%; margin-right:5px;">
                                        <img src="../images/patient_images/<?php echo $images_array[$im]['image_id'];?>.jpg" height="63" width="60" >
                                        <input type="checkbox" name="image_ids[]" value="<?php echo $images_array[$im]['image_id'];?>">
                                        </div>
                                        <?php
                                    }
                                    ?>
                                </div>
                                
                               
								<?php
								
                            }
							else
							{
								?>
                                <span style="float:left; margin-top:10px; width:100%;">
                                	<img src="../images/photo.png" width="63" height="60"><br><br>
                                </span>
                                <?php
							}
							?>
                            </form>
                            
                            <table width="100%" 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" style="float:left;"/></td>
                            </tr>
                            </table></td>	
                        </tr>
                        </form>   
                        </table>
                            
                    </div>
                </section>
          	</div>     
          
           	<div class="col-md-4" style="float: right; width:30%;">
                <div class="profile-nav alt">
                    <section class="panel">
                        <div class="user-heading alt clock-row terques-bg">
                        
                        <h1><?php  if(isset($patient_single_detail[0]['patient_id'])){echo $patient_single_detail[0]['patient_id'];}?> - <?php if(isset($patient_single_detail[0]['patient_fname'])){echo $patient_single_detail[0]['patient_fname'].' '.$patient_single_detail[0]['patient_lname'];}else{echo 'Outdoor';}?></h1>
                        
                        <p class="text-left">Age: <?php echo $patient_age?> <span style="float:right; padding-right:10%;">Blood Group: <?php if(isset($patient_single_detail[0]['blood_group'])){echo $patient_single_detail[0]['blood_group'];}?></span></p><br>
                        
                        <p class="text-left"></p>
                        
                        <span>Phone: <?php if(isset($patient_single_detail[0]['phone'])){echo $patient_single_detail[0]['phone'];}?></span></br>
                        
                        <span>Address: <?php  if(isset($patient_single_detail[0]['address'])){echo $patient_single_detail[0]['address'];}?></span></p><br>
                          <p class="text-left"></p>
                        
                        <span>Total Visits: <div style="float:right;"><?php echo $total_visits;?></div></span><br>
                        
                        <span>Total Payments: <div style="float:right;">Rs. <?php echo number_format($total_payments,2);?></div></span>
                        
                    	</div>
                    </section>
                </div>
           	</div>

			<div class="panel-body" style="padding-top: 0px; margin-top: 200px;">
              <div class="adv-table"><br>
              
                <table width="50%" class="display table table-bordered table-striped" id="dynamic-table2">
                
                        <thead>
                          <tr>
                            <th width="10%" align="left">Visit</th>
                            <th width="10%" align="left">Medical Issue</th>
                            <th width="20%" align="left">Observations</th>
                            <th width="20%" align="left">Medicines</th>
                            <th width="10%" align="left">Tests</th>
                            <th width="10%" align="left">Procedures</th>
                            <th width="10%" align="left">Test Results</th>
                            <th width="10%" align="left">Payment</th>
                          </tr>
                        </thead>
                        
                        <tbody>
                        <?php
						if(isset($visit_array[0]['visit_id']))
						{
							
							for($v=0;$v<count($visit_array);$v++)
							{
								$visit_id = $visit_array[$v]['visit_id'];
								$visit_id_encoded = base64_encode($visit_id);
								
								$patient_id = $visit_array[$v]['patient_id'];
								$patient_id_encoded = base64_encode($patient_id);
							
								$retrieveVisitPrecOb = new classVisits;
								$retrieveVisitPrecOb->setVisitID($visit_array[$v]['visit_id']);
								$prec_array = $retrieveVisitPrecOb->retrievePrescription();
								
								$retrieveVisitPrecOb->setMedicalIssueID($visit_array[$v]['med_issue_id']);
								$medical_issue_array = $retrieveVisitPrecOb->retrieveMedicalIssueByID();
								
								$doctorOb = new classDoctor;
								$doctorOb->setDoctorID($visit_array[$v]['doctor_id']);
								$doctor_detail = $doctorOb->retrieveDoctorByDoctorID();
								
								$doctor_name = $doctor_detail[0]['title'].' '.$doctor_detail[0]['doc_fname'].' '.$doctor_detail[0]['doc_lname'];
								
								
								$imageOb = new classImages;
								$imageOb->setVisitID($visit_id);
								$images_array = $imageOb->fetchAllImageOfVisitor();
								$results = '';
								$imagelink = '';
								if(isset($images_array[0]))
								{
									for($im=0;$im<count($images_array);$im++)
									{
										$image_id = $images_array[$im]['image_id'];
										$image_id_encoded = base64_encode($image_id);
										$image_name = ucwords($images_array[$im]['image_name']);
										
										$imagelink = 'javascript:Popup("printvisitimages.php?visitid='.$visit_id_encoded.'&patientid='.$patient_id_encoded.'&imageid='.base64_encode($image_id).'")';
										
										$results .= "<a href='?delimage=$image_id_encoded'><img src='../images/cross.png'></a> <a href='$imagelink'>$image_name</a><br/>";
										
									}
									
								}
								//else
								//{
									$add_image = "<a href='#add_visitimages-box' class='add_visitimages-window add_visitimages' id='$visit_id'>Upload Results</a><br/>";
									
								//}
								
								
								?>
								<tr class="gradeX">
						
									<td align="left">
									<span class="smallgrey"><?php echo @date('d M Y',$visit_array[$v]['shift_date']);?></span><br>
									
									<?php echo $doctor_name; ?></td>	
                                    
                                    <td><?php echo ucwords($medical_issue_array[0]['med_issue']);?> </td>
									
									<td align="left">
									<?php
			if(isset($visit_array[$v]['temp'])&&$visit_array[$v]['temp']!='')
			{
				?><span class="smallgrey">Temp:</span> <?php echo $visit_array[$v]['temp'];?> 
                                    <?php
			}
			if(isset($visit_array[$v]['bp'])&&$visit_array[$v]['bp']!='')
			{
				?><span class="smallgrey">BP:</span> <?php echo $visit_array[$v]['bp'];?> 
                                    <?php
			}
			if(isset($visit_array[$v]['bsr'])&&$visit_array[$v]['bsr']!='')
			{
				?><span class="smallgrey">BSR:</span> <?php echo $visit_array[$v]['bsr'];?> 
                                    <?php
			}
			if(isset($visit_array[$v]['weight'])&&$visit_array[$v]['weight']!='')
			{
				?><span class="smallgrey">Weight:</span> <?php echo $visit_array[$v]['weight'];?>
                                    <?php
			} ?>
            <br>
            <?php
			if(isset($visit_array[$v]['complaint'])&&$visit_array[$v]['complaint']!='')
			{
				?><span class="smallgrey">Complaint:</span> <?php echo $visit_array[$v]['complaint']; ?><br>
                                    
                                    <?php
			}
			if(isset($visit_array[$v]['diagnosis'])&&$visit_array[$v]['diagnosis']!='')
			{
				?><span class="smallgrey">Diagnosis:</span> <?php echo $visit_array[$v]['diagnosis']; ?><br>
									<?php
			}
			if(isset($visit_array[$v]['notes'])&&$visit_array[$v]['notes']!='')
			{
				?>
            <span class="smallgrey">Notes:</span> <?php echo $visit_array[$v]['notes']; ?>
            <?php
			} ?>
									</td>
									
									<td align="left">
									<?php
									for($prm=0;$prm<count($prec_array);$prm++)
									{
										if($prec_array[$prm]['product_id']!=0)
										{	
											$retreiveMedOb = new classVisits;
											$retreiveMedOb->setMedicineID($prec_array[$prm]['product_id']);
											$med_info = $retreiveMedOb->retrieveMedicineByMedicineID();
											
											echo '<img src="../images/bullet1.png"> '.ucwords($med_info[0]['product_name']);?>
											<span style="float:right"><?php
											echo $prec_array[$prm]['dosage'];?></span><br>
                                      <?php
										}
									}
									?>
									</td>
									
									<td align="left">
									<?php
									for($prm=0;$prm<count($prec_array);$prm++)
									{
										 if($prec_array[$prm]['labtest_id']!=0)
										 {	
											 $retreiveMedOb = new classVisits;
											 $retreiveMedOb->setLabTestID($prec_array[$prm]['labtest_id']);
											 $labtest_info = $retreiveMedOb->retrieveLabTestsByLabTestID();
																
											 echo '<img src="../images/bullet1.png"> '.ucwords($labtest_info[0]['labtest_name']).'<br>';
										}
									}
									?>
									</td>
									
									<td align="left">
									<?php
									for($prm=0;$prm<count($prec_array);$prm++)
									{ 
										if($prec_array[$prm]['procedure_id']!=0)
										{	
											$retreiveMedOb = new classVisits;
											$retreiveMedOb->setProcedureID($prec_array[$prm]['procedure_id']);
											$procedure_info = $retreiveMedOb->retrieveProcedureByProcedureID();
												
											echo '<img src="../images/bullet1.png"> '.ucwords($procedure_info[0]['procedure_name']).'<br>';
										}
									}
									?>
									</td>
                                    
                                    <td align="left"><?php echo $add_image.$results;?></td>
                                    
                                    <td align="right">
									<?php echo "Rs. ".number_format($visit_array[$v]['payment']); ?>
									</td>	
						
								</tr> 
								<?php
							}
						}
						?>
						</tbody>
                        
                        
                        
                        <tfoot>
                        
                         
                        </tfoot>
                        
                 </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>

<div id="add_visitimages-box" class="add_visitimages-popup">
    
    <div class="pop_header">
        <span>Add Images</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_insertvisimages_form" style="margin:10px;"></div>
          
          <form action="" method="post" id="insertvisimages_form" class="cmxform form-horizontal" enctype="multipart/form-data">
          
          	<div class="form-group">
            <label class="control-label col-lg-3" for="firstname">Image Name:</label>
            	<div class="col-lg-6">
                     <input type="text" name="image_name" value="" class="form-control">
                </div>
            </div>
            
            <div class="form-group">
            <label class="control-label col-lg-3" for="firstname">Image:</label>
            	<div class="col-lg-6">
                     <input type="file" name="visitor_image" value="" class="form-control">
                </div>
            </div>
            
            <p align="right">
                <input type="hidden" name="add_vis_image" value="Add_vis_image">
                <input type="hidden" name="visit_id" id="visitor_id" value="">
                <input name="ajax_submit" type="submit" class="btn btn-info" value="Upload"/>
            </p>
            
          </form>
          </td>
          
      </tr>
    </table>
</div>
<script>

$(".add_visitimages").click(function() {
	
	var id = this.id;
	//alert(id);
	$("#visitor_id").val(id);
	
});
</script>