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

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

################## Delete Patient Start ####################################

if(isset($_GET['delAllotID'])&&$_GET['delAllotID']!='')
{
	try
	{
		$delBedAllotOb = new classWardMgmt;
		$delBedAllotOb->setWardBedAllotID(base64_decode($_GET['delAllotID']));
		$delBedAllotOb->deleteBedAllotment();
	}
	catch (MyException $e)
	{
		$error_message = $e->getUserMsg();
	}
}

################# retrieve all wards #######################################

if(isset($_POST['search_bed_no'])&&$_POST['search_bed_no']!='')
{
	$search_ipd_bed_no = $_POST['search_bed_no'];
}
else
{
	$search_ipd_bed_no = NULL;
}

if(isset($_POST['search_patient_name'])&&$_POST['search_patient_name']!='')
{
	$search_patient_name = $_POST['search_patient_name'];
}
else
{
	$search_patient_name = NULL;
}


try
{
	$wardOb = new classWardMgmt;
	$ward_array = $wardOb->retrieveWardAndBeds($_SESSION['security']['location_id'],$search_ipd_bed_no,$search_patient_name,'Occupied');
}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}


/*echo '<pre>';
print_r($bed_ward_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" -->
                    <a href="javascript:Popup('printmgmtinpatients.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">
             <?php
					  
$orgOb = new classUser;
$orgOb->retrieveOrgDataByOrgID($_SESSION['security']['org_id']);

		  if($orgOb->getDB())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==100)
				{
					?>
					  	<li>
                    	<a class="active" href="db.php" style="background:#0072BC;">
                        <i class="fa fa-dashboard"></i> 
                        <span>Dashboard</span>
                    	</a>
                		</li>
					  <?php
				}
		  }
				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||$_SESSION['security']['userrole_id']==100)
				{
					?>
					    <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||$_SESSION['security']['userrole_id']==100)
				{
					?>
						<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())
		  {
			  if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==6||$_SESSION['security']['userrole_id']==15||$_SESSION['security']['userrole_id']==100)
				{
			  	?>
						<li class="sub-menu">
						<a href="dbipd.php" style="background:#8EC63F;">
						<i class="fa fa-th"></i>
						<span>In-Patient (IPD)</span>
						</a>
						</li>
						<?php
				}
					
		  }
		  if($orgOb->getOT())
		  {
			  if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==6||$_SESSION['security']['userrole_id']==15||$_SESSION['security']['userrole_id']==100) 
				{
			   		?>
						<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||$_SESSION['security']['userrole_id']==100)
				{
			  		?>
						<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||$_SESSION['security']['userrole_id']==100)
				{
			  	?>
						<li>
						<a href="dbdiagnostics.php" style="background:#380E4D;">
						<i class="fa fa-th"></i>
						<span>Diagnostics </span>
						</a>
						</li>
						<?php
				}
		  }
		  
					  ?>
						<!--<li class="sub-menu">
						<a href="dbemergency.php" style="background:#3AC7F9;">
						<i class="fa fa-tasks"></i>
						<span>Facility Management </span>
						</a>
						</li>-->
						<?php
          if($orgOb->getAdmin())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==100)
				{
					?>
						<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="dbipd.php"><img src="../images/icondb.png"></a></td>
      <td width="12%" align="center"><a href="mgmtinpatienthistory.php"><img src="../images/iconhistory.png"></a></td>
      <td width="12%" align="center"><a href="mgmtadmissions.php"><img src="../images/iconadm.png"></a></td>
      <td width="12%" align="center"><!--<a href="mgmtmedissues.php"><img src="../images/icon-practices.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="dbipd.php">In Patient</a></td>
      <td align="center"><a href="mgmtinpatienthistory.php">Admission History</a></td>
      <td align="center"><a href="mgmtadmissions.php">Admissions & Discharge</a></td>
      <td align="center"><!--<a href="mgmtmedissues.php">Medical Issues</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>IPD BEDS REGISTER</h2>
            </header>
            
           	<table width="100%" border="0" cellpadding="1" cellspacing="0">
             <form action="" method="post">
              <tr>
              
                <td width="10%" align="right">Search Bed No: </td>
                <td width="10%">
                	<input type="text" name="search_bed_no" value="" class="form-control" aria-controls="dynamic-table">
                </td>
                
                <td width="10%" align="right">Patient Name: </td>
                <td width="15%">
                	<input type="text" name="search_patient_name" value="" class="form-control" aria-controls="dynamic-table">
                </td>
                
                <td width="5%"><input name="search" type="submit" class="btn btn-success btn-sm" value="Search"/></td>
                
                <td width="5%" align="right"><a href="mgmtinpatients.php">View All</a></td>
                
                <!--<td width="5%" align="right">Phone: </td>
                <td width="15%">
                	<input type="text" class="form-control" aria-controls="dynamic-table">
                </td>-->
                
                <td width="15%" align="right"><div class="row-fluid"></div></td>
                <td width="10%"></td>
              </tr>
              </form>
            </table>
            <br>
            <br><br>
            
            <div class="panel-body" style="padding-top: 0px; margin-top: -34px;">
              <div class="adv-table">
              
             	 <table  class="display table table-bordered" id="dynamic-table">
                
                  <thead>
                  
                    <tr>
                      
                      <th width="15%">Ward</th>
                      <th width="85%"> <!--<table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td width="20%">Beds</td>
                      <td width="20%"></td>
                      <td width="20%">Fee</td>
                      <td width="30%">Detail</td>
                      <td width="10%"></td></table>-->
                  
                  </th>                      
                    </tr>
                    
                  </thead>
                  
                  <tbody>
                   <?php
					if(isset($ward_array[0]['ipd_ward_id'])&&$ward_array[0]['ipd_ward_id']!='')
					{
						for($w=0;$w<count($ward_array);$w++)
						{
							
							$ipd_ward_id = $ward_array[$w]['ipd_ward_id'];
							$ipd_ward_id_encode = base64_encode($ipd_ward_id);
							
							$ipd_ward_no = $ward_array[$w]['ipd_ward_no'];
							$ipd_ward_type = ucwords(str_replace('_',' ',$ward_array[$w]['ipd_ward_type']));
							$staff_id = $ward_array[$w]['staff_id'];
							$no_of_beds = $ward_array[$w]['no_of_beds'];
							
							?>
					<tr>
                      
                      <td><?php echo $ipd_ward_no;?> - <?php echo $ipd_ward_type;?><br>
                      <span class="message_grey">No. of Beds: <?php echo $no_of_beds;?></span></td>
                      <td>
                     
                             <?php
							if(isset($ward_array[$w]['bed_details'][0])&&$ward_array[$w]['bed_details'][0]!='')
							{
								for($wb=0;$wb<count($ward_array[$w]['bed_details']);$wb++)
								{
									
									
									$ipd_bed_id = $ward_array[$w]['bed_details'][$wb]['ipd_bed_id'];
									$ipd_bed_id_encode = base64_encode($ipd_bed_id);
									
									$ipd_bed_no = $ward_array[$w]['bed_details'][$wb]['ipd_bed_no'];
									$ipd_bed_fee = $ward_array[$w]['bed_details'][$wb]['ipd_bed_fee'];
									$ipd_bed_type = $ward_array[$w]['bed_details'][$wb]['ipd_bed_type'];
									$status = $ward_array[$w]['bed_details'][$wb]['status'];
									
									$patient_id = $ward_array[$w]['bed_details'][$wb]['patient_id'];
									$patient_name = $ward_array[$w]['bed_details'][$wb]['patient_name'];
									$allot_time = $ward_array[$w]['bed_details'][$wb]['allot_time'];
									$discharge_due_time = $ward_array[$w]['bed_details'][$wb]['discharge_due_time'];
									$ipd_bed_allotment_id = $ward_array[$w]['bed_details'][$wb]['ipd_bed_allotment_id'];
									$ipd_bed_allotment_id_encoded = base64_encode($ward_array[$w]['bed_details'][$wb]['ipd_bed_allotment_id']);
									
									$discharge_slip_created = $ward_array[$w]['bed_details'][$wb]['discharge_slip_created'];
									
									if($patient_id!=0)
									{
										$imageRetrieveOb = new classImages;
										$imageRetrieveOb->setPatientAutoID($patient_id);
										$image_id = $imageRetrieveOb->fetchImageOfPatient();
									}
									
									if($status=='Empty')
									{
										$image = 'bed_green';
										$button_type = '<a href="#allocate_ipdwardbed-box" class="allocate_ipdwardbed-window btn btn-success btn-sm allocate_ipdwardbed" id="'.$w.$wb.'">Allocate</a>';
										
										$transfer_button = '';
										
										$cancel_button = '';
									}
									if($status=='Occupied')
									{
										$image = 'bed_red';
										
										if($discharge_slip_created){$button_class = 'btn-success';}else{$button_class = 'btn-danger';}
										$button_type = "<a href='#discharge_ipdwardbed-box' class='discharge_ipdwardbed-window btn $button_class btn-sm discharge_ipdwardbed' id='$w$wb'>Discharge Slip</a>";
										
										$transfer_button = '<a href="#transfer_ipdwardbed-box" class="transfer_ipdwardbed-window btn btn-success btn-sm transfer_ipdwardbed" id="'.$w.$wb.'">Transfer</a>';
										
										$cancel_button = '';
									}
									if($status=='Reserved')
									{
										$image = 'bed_yellow';
										$button_type = '<a href="#allocate_ipdwardbed-box" class="allocate_ipdwardbed-window btn btn-success btn-sm allocate_reserved_ipdwardbed" id="'.$w.$wb.'">Allocate</a>';
										
										$transfer_button = '';
										
										$cancel_button = " <a href='?cbr=$ipd_bed_id_encode&cbra=$ipd_bed_allotment_id_encoded'>Cancel Reservation</a>";
										
									}
									
									?>
                                    
                                    <table width="100%" class="display table table-bordered table-striped">
                                    <tr>
                                      <td width="10%" align="left"><img src="../images/<?php echo @$image;?>.png" ></td>
                                      <td width="25%" align="left"><strong><?php echo $ipd_bed_no;?></strong><br>
                                      Fee: Rs. <?php echo number_format($ipd_bed_fee,2);?>
                                      <p>
                                      <span class="message_grey">Detail: <?php echo $ipd_bed_type;?></span>
                                      </td>
                                      <td width="5%" ><?php
										if(isset($image_id)&&$image_id!='')
										{
											?>
											<img src="../images/patient_images/<?php echo $image_id;?>.jpg" width="60" height="60">
											<?php
										}
										else
										{
											?>
											<img src="../images/photo.png" width="60" height="60">
											<?php
										}
										?></td>
                                      <td width="40%"><strong>Patient: <?php echo $patient_id;?> - <?php echo $patient_name;?></strong>
                                      <p>
                                      Admission No: <?php echo $ipd_bed_allotment_id;?><br>
                                      Admitted at: <?php echo $allot_time;?><br>
                                      Discharge Due at: <?php echo $discharge_due_time;?></td>
                                      
                                      <td width="10%" align="center"><a href="ipdovw.php?patientid=<?php echo base64_encode($patient_id);?>&allotid=<?php echo $ipd_bed_allotment_id_encoded;?>" class="btn btn-success btn-sm">Clinical Overview</a></td>
                                      
                                      <td width="10%" align="center"><?php echo $button_type;?></td>
                                      
                                    </tr>
                                     </table>

                                    
                            <input type="hidden" name="ipd_ward_id" class="set_to_pop" id="ipd_ward_id_<?php echo $w.$wb;?>" value="<?php echo $ipd_ward_id;?>">
									 <input type="hidden" name="ipd_bed_id" class="set_to_pop" id="ipd_bed_id_<?php echo $w.$wb;?>" value="<?php echo $ipd_bed_id;?>">
									 
									 <input type="hidden" name="ipd_bed_allotment_id" class="set_to_pop" id="ipd_bed_allotment_id_<?php echo $w.$wb;?>" value="<?php echo $ipd_bed_allotment_id;?>">
									 
									 <input type="hidden" name="ipd_patient_id" class="set_to_pop" id="ipd_patient_id_<?php echo $w.$wb;?>" value="<?php echo $patient_id;?>">
									 <input type="hidden" name="ipd_patient_name" class="set_to_pop" id="ipd_patient_name_<?php echo $w.$wb;?>" value="<?php echo $patient_name;?>">
									 
									  <input type="hidden" name="ipd_ward_no" class="set_to_pop" id="ipd_ward_no_<?php echo $w.$wb;?>" value="<?php echo $ipd_ward_no;?>">
									  
									  <input type="hidden" name="ipd_bed_no" class="set_to_pop" id="ipd_bed_no_<?php echo $w.$wb;?>" value="<?php echo $ipd_bed_no;?>">
									<?php 
								}
								
							}
							else
							{
								?>
								There are no beds in this ward.<p>
								<?php
							}
						?>
                      
                      
                      </td>
                      
                    </tr>
                    <input type="hidden" name="ipd_ward_id" class="set_to_pop" id="ipd_ward_id_<?php echo $w;?>" value="<?php echo $ipd_ward_id;?>">
                            <input type="hidden" name="ipd_ward_no" class="set_to_pop" id="ipd_ward_no_<?php echo $w;?>" value="<?php echo $ipd_ward_no;?>">
                            <input type="hidden" name="ipd_ward_type" class="set_to_pop" id="ipd_ward_type_<?php echo $w;?>" value="<?php echo $ward_array[$w]['ipd_ward_type'];?>">
                            
                            <input type="hidden" name="staff_id" class="set_to_pop" id="staff_id_<?php echo $w;?>" value="<?php echo $staff_id;?>">	
                    <?php	
                         }
					}
					else
					{
						?>
                        <tr>
                             <td colspan="6">All Beds are currently empty!</td>
                        </tr>
                        <?php
					}
					?>       
                  </tbody>
                  
               </table>
                
               
                <!--<div class="row-fluid">
                  <div class="span6">
                    <div class="dataTables_info" id="hidden-table-info_info">Showing 1 to 10 of 57 entries</div>
                  </div>
                  <div class="span6">
                    <div class="dataTables_paginate paging_bootstrap pagination">
                    
                      <ul>
                        <li class="prev disabled"><a href="#">? Previous</a></li>
                        <li class="active"><a href="#">1</a></li>
                        <li><a href="#">2</a></li>
                        <li><a href="#">3</a></li>
                        <li><a href="#">4</a></li>
                        <li><a href="#">5</a></li>
                        <li class="next"><a href="#">Next ? </a></li>
                      </ul>
                    </div>
                  </div>
                </div>-->
              </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="discharge_ipdwardbed-box" class="discharge_ipdwardbed-popup">
    
    <div class="pop_header">
        <span>Discharge Slip</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_discharge_ipdwardbed_form"></div>
            
            <form action="" method="post" id="discharge_ipdwardbed_form" class="cmxform form-horizontal" onsubmit="return false;">
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Patient:</label>
                <div class="col-lg-6" id="discharge_patient_name" style="margin-top:7px;"></div>
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Ward No:</label>
                <div class="col-lg-6" id="dis_ward_no" style="margin-top:7px;">
                	
                </div>
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Bed No:</label>
                <div class="col-lg-6" id="dis_bed_no" style="margin-top:7px;">
                	
                </div>
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Provisional Diagnosis:</label>
                <div class="col-lg-6">
                	<textarea name="prov_diagnosis" value="" cols="43" rows="5"></textarea>
                </div>
            </div>
            
             <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Result:</label>
                <div class="col-lg-6">
                	<select name="result" style="width:120px;">
                    <option value="">Select Result</option>
                    <option value="Cured">Cured</option>
                    <option value="Stay Away">Stay Away</option>
                    <option value="Relieved">Relieved</option>
                    </select>
                </div>
            </div>
            
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Referred to:</label>
                <div class="col-lg-6">
                	<input type="text" name="refered_to" value=""  class="form-control">
                </div>
            </div>
            
             <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Final Diagnosis:</label>
                <div class="col-lg-6">
                	<textarea name="final_diagnosis" value="" cols="43" rows="5"></textarea>
                </div>
            </div>
            
            
             <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Follow up Time:</label>
                <div class="col-lg-6">
                	<input type="text" name="discharging_followuptime" value=""  class="form-control">
                </div>
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Discharging Doctor:</label>
                <div class="col-lg-6">
                	<input type="text" name="discharging_doctor" value=""  class="form-control">
                </div>
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Discharging Unit:</label>
                <div class="col-lg-6">
                	<input type="text" name="discharging_unit" value=""  class="form-control">
                </div>
            </div>
           
            <p align="right">
            	<input type="hidden" name="bed_id" id="discharge_bed_id" value="">
                <input type="hidden" name="ipd_bed_allotment_id" id="dis_bed_allotment_id" value="">
                <input type="hidden" name="patient_id" id="discharge_patient_id" value="">
                <input type="hidden" name="discharge_ipdwardbed" value="Discharge_ipdwardbed">
                <input name="ajax_submit" type="submit" class="ajax_submit btn btn-info" value="Create Discharge Slip"/>
            </p>
            
            </form>
            
            </td>
        </tr>
    </table>
    
</div>
<script>
$(".discharge_ipdwardbed").click(function() {
	var id = this.id;
	//alert(id);
	ipd_bed_id = $("#ipd_bed_id_"+id).val();
	$("#discharge_bed_id").val(ipd_bed_id);
	
	ipd_ward_no = $("#ipd_ward_no_"+id).val();
	$("#dis_ward_no").html(ipd_ward_no);
	
	ipd_bed_no = $("#ipd_bed_no_"+id).val();
	$("#dis_bed_no").html(ipd_bed_no);
	
	ipd_bed_allotment_id = $("#ipd_bed_allotment_id_"+id).val();
	$("#dis_bed_allotment_id").val(ipd_bed_allotment_id);
	
	ipd_patient_id = $("#ipd_patient_id_"+id).val();
	$("#discharge_patient_id").val(ipd_patient_id);
	
	ipd_patient_name = $("#ipd_patient_name_"+id).val();
	$("#discharge_patient_name").html(ipd_patient_name);
});

$(function() {
		
		
		
		$("#datepicker2").datepicker({
		showOn: "button",
		buttonImage: "../images/calendar.gif",
		buttonImageOnly: true,
		changeMonth: true,
		changeYear: true,
		dateFormat: "yy-mm-dd",
		minDate: '0'
		});
	
	});
</script>

<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>
-->

<script>


$('#dis_time').timepicker();
	
</script>