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

if(isset($_GET['ipdwardid'])&&$_GET['ipdwardid']!='')
{
	$_SESSION['temp']['ipdwardid'] = base64_decode($_GET['ipdwardid']);
}

if(isset($_SESSION['temp']['ipdwardid'])&&$_SESSION['temp']['ipdwardid']!='')
{
	$ipdwardid = $_SESSION['temp']['ipdwardid'];
}
else
{
	header("Location:mgmtwards.php");
}

################# retrieve all beds of ward #######################################
try
{
	$wardBedOb = new classWardMgmt;
	$wardBedOb->setWardID($ipdwardid);
	$wardbeds_array = $wardBedOb->retrieveAllbedOfWard();
}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}


?>
<!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="#"><i class="fa fa-print" style="margin-left: 11px; margin-top: 11px;"></i></a>
					<!-- InstanceEndEditable --></div>
                </li>
                <!-- user login dropdown start-->
                <li class="dropdown">
                    <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                        <img alt="" src="../images/avatar1_small.jpg"> 
                        <span class="username"><?php echo $username;?></span>
                        <b class="caret"></b>
                    </a>
                    <ul class="dropdown-menu extended logout">
                        <li><a href="profile.php"><i class=" fa fa-suitcase"></i>Profile</a></li>
                        <li><a href="#update_password-box" class="update_password-window"><i class="fa fa-cog"></i> Change Password</a></li>
                        <li><a href="../logout.php"><i class="fa fa-key"></i> Log Out</a></li>
                    </ul>
                </li>
                <!-- user login dropdown end -->
                <li>
                    <div class="toggle-right-box">
                        <div class="fa fa-bars"></div>
                    </div>
                </li>
            </ul>
            <!--search & user info end-->
        </div>
    </header>
    <!--header end-->
    <!--sidebar start-->
   <aside>
        <div id="sidebar" class="nav-collapse">
            <!-- sidebar menu start-->
            <ul class="sidebar-menu" id="nav-accordion">
					  	<li>
                    	<a class="active" href="db.php" style="background:#0072BC;">
                        <i class="fa fa-dashboard"></i>
                        <span>Dashboard</span>
                    	</a>
                		</li>
					  <?php
					  
				
					  
$orgOb = new classUser;
$orgOb->retrieveOrgDataByOrgID($_SESSION['security']['org_id']);
           
		  
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==5||$_SESSION['security']['userrole_id']==9||$_SESSION['security']['userrole_id']==10)
				{
					?>
					    <li class="sub-menu">
                    	<a href="dbpatient.php" style="background:#BC1C4A;">
                        <i class="fa fa-user"></i>
                        <span>Patient Registration</span>
                    	</a>
                    	</li>
					  <?php
				}
		  
		  if($orgOb->getOPD())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==4||$_SESSION['security']['userrole_id']==5||$_SESSION['security']['userrole_id']==9)
				{
					?>
						<li class="sub-menu">
						<a href="dbopd.php" style="background:#003366;">
						<i class="fa fa-th"></i>
						<span>Out-Patient (OPD)</span>
						</a>
						</li>
						<?php
				}
		  }
		  if($orgOb->getIPD())
		  {
			  	?>
						<li class="sub-menu">
						<a href="dbipd.php" style="background:#3AC7F9;">
						<i class="fa fa-th"></i>
						<span>In-Patient (IPD)</span>
						</a>
						</li>
						<?php
					
		  }
		  if($orgOb->getOT())
		  {
			   		?>
						<li class="sub-menu">
						<a href="dbot.php" style="background:#D6502A;">
						<i class="fa fa-th"></i>
						<span>Operation Theater</span>
						</a>
						</li>
                        <?php
		  }			
		  if($orgOb->getPharmacy())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==6||$_SESSION['security']['userrole_id']==7||$_SESSION['security']['userrole_id']==8||$_SESSION['security']['userrole_id']==9)
				{
			  		?>
						<li class="sub-menu">
						<a href="dbpharmacy.php" style="background:#00869C;">
						<i class="fa fa-th"></i>
						<span>Pharmacy</span>
						</a>
						</li>
						<?php
				}
		  }
		  if($orgOb->getDiagnostic())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==3||$_SESSION['security']['userrole_id']==14||$_SESSION['security']['userrole_id']==9)
				{
			  	?>
						<li>
						<a href="dbdiagnostics.php" style="background:#380E4D;">
						<i class="fa fa-th"></i>
						<span>Diagnostics </span>
						</a>
						</li>
						<?php
				}
		  }
		  if($orgOb->getEmergency())
		  {
					  ?>
						<li class="sub-menu">
						<a href="dbemergency.php" style="background:#8EC63F;">
						<i class="fa fa-tasks"></i>
						<span>Emergency </span>
						</a>
						</li>
						<?php
		  }
          if($orgOb->getAdmin())
		  {
				if($_SESSION['security']['userrole_id']==1||$_SESSION['security']['userrole_id']==2||$_SESSION['security']['userrole_id']==9)
				{
					?>
						<li class="sub-menu">
						<a href="dbadmin.php" style="background:#28282E;">
						<i class="fa fa-laptop"></i>
						<span>Admin Panel</span>
						</a>
						</li>
						<?php
				}
		  }
		  ?>
               
            </ul> 
            <div style="position: absolute; bottom: 2%; padding-left:10%;"><a href="http://www.softusion.com/" target="_blank"><img width="30" height="40" src="../images/SoftusionLOGO.png" alt=""><span style="font-size: 11px; float: right; margin-top: 15%;">Designed by Softusion Inc.</span></a></div><br>
            <!-- sidebar menu end-->
        </div>
    </aside>
    <!--sidebar end-->
    <!--main content start-->
	<!-- InstanceBeginEditable name="center" -->
  <section id="main-content">
    <section class="wrapper">
          <table cellspacing="0" cellpadding="0" width="100%" border="0" style="font-size:11px;">
          <tbody>
            <tr>
              <td width="12%" align="center"><a href="dbipd.php"><img src="../images/icondb.png"></a></td>
              <td width="12%" align="center"><a href="mgmtwards.php"><img src="../images/iconwards.png"></a></td>
              <td width="12%" align="center"><a href="mgmtbeds.php"><img src="../images/iconbeds.png"></a></td>
              <td width="12%" align="center"><a href="#add_ipdwardbed-box" class="add_ipdwardbed-window" id="add_ipdwardbed"><img src="../images/iconbeds.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="2%" align="center">&nbsp;</td>
            </tr>
            <tr>
              <td align="center"><a href="dbipd.php">In Patient</a></td>
              <td align="center"><a href="mgmtwards.php">Manage Wards</a></td>
              <td align="center"><a href="mgmtbeds.php">Manage Beds</a></td>
              <td align="center"><a href="#add_ipdwardbed-box" class="add_ipdwardbed-window" id="add_ipdwardbed">Add Beds</a></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>MANAGE BEDS</h2>
            </header>
            
            <?php
            if(isset($error_message)&&$error_message!='')
            {
                ?>
                <tr>
                    <td><span class="message_red"><?php echo $error_message;?></span></td>
                </tr>
                <?php
            }
            ?>
            <br><br>

            <div class="panel-body" style="padding-top:0px;margin-top:-34px;">
              <div class="adv-table">

               
                <?php
				if(isset($wardbeds_array[0]['ipd_ward_id'])&&$wardbeds_array[0]['ipd_ward_id']!='')
				{
					for($wb=0;$wb<count($wardbeds_array);$wb++)
					{
						$ipd_ward_id = $wardbeds_array[$wb]['ipd_ward_id'];
						$ipd_ward_no = $wardbeds_array[$wb]['ipd_ward_no'];
						$ipd_ward_type = $wardbeds_array[$wb]['ipd_ward_type'];
						
						$ipd_bed_id = $wardbeds_array[$wb]['ipd_bed_id'];
						$ipd_bed_id_encode = base64_encode($ipd_bed_id);
						
						$ipd_bed_no = $wardbeds_array[$wb]['ipd_bed_no'];
						$ipd_bed_fee = $wardbeds_array[$wb]['ipd_bed_fee'];
						$status = $wardbeds_array[$wb]['status'];
						
						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="'.$wb.'">Allocate</a>';
						}
						if($status=='occupied')
						{
							$image = 'bed_red';
							$button_type = '<a href="#allocate_ipdwardbed-box" class="allocate_ipdwardbed-window btn btn-success btn-sm allocate_ipdwardbed" id="'.$wb.'">Discharge</a>';
						}
						if($status=='reserved')
						{
							$image = 'bed_yellow';
							$button_type = '<a href="#allocate_ipdwardbed-box" class="allocate_ipdwardbed-window btn btn-success btn-sm allocate_ipdwardbed" id="'.$wb.'">Discharge</a>';
						}
						
						if($wb%2==0)
						{
							$style='float:left;width:48%;margin-top:10px';
						}
						else
						{
							$style='float:left;width:48%;margin-left:10px;margin-top:10px';
						}
						
						?>
						<div style=" <?php echo $style;?>">
                        <table width="100%" border="1" cellspacing="1" cellpadding="1">
                            <tr>
                            
                                <td width="14%">
                               	 	<img src="../images/<?php echo $image;?>.png" alt="" width="128" height="69">
                               		<a href="#update_ipdwardbed-box" class="update_ipdwardbed-window update_ipdwardbed" id="<?php echo $wb;?>">Edit</a>
                                </td>
                                
                                <td width="86%" valign="top"><table width="100%" border="0" cellspacing="1" cellpadding="1">
                                
                                <tr>
                                	<td width="60%" valign="top"><?php echo $ipd_ward_no.' '.ucwords(str_replace('_',' ',$ipd_ward_type));?></td>
                                	<td width="40%" valign="top"><strong>Bed No: <?php echo $ipd_bed_no;?></strong></td>
                                </tr>
                                
                                <tr>
                                	<td valign="top">Date of Admission:<br>Discharge Due at: </td>
                                	<td valign="top">Status: <?php echo ucwords($status);?></td>
                                </tr>
                                
                                <tr>
                                    <td><input type="submit" name="cancel3" value="Details" class="btn btn-success btn-sm"></td>
                                    
                                    <td>
                                    <?php echo $button_type;?>
                                    </td>
                                    
                                </tr>
                                </table></td>
                                
                            </tr>
                        </table>
                        </div>
                        
                        <input type="hidden" name="ipd_bed_id" class="set_to_pop" id="ipd_bed_id_<?php echo $wb;?>" value="<?php echo $ipd_bed_id;?>">
                        <input type="hidden" name="ipd_bed_no" class="set_to_pop" id="ipd_bed_no_<?php echo $wb;?>" value="<?php echo $ipd_bed_no;?>">
                        <input type="hidden" name="ipd_bed_fee" class="set_to_pop" id="ipd_bed_fee_<?php echo $wb;?>" value="<?php echo $ipd_bed_fee;?>">
						<?php 
					}
				}
				else
				{
					?>
                    <table width="100%" border="0" cellspacing="5" cellpadding="5">
                        <tr>
                            <td>No Bed Found!</td>
                        </tr>  
                	</table>
                    <?php
					
				}
				?>
              
 
              </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="select_patient-box" class="select_patient-popup">
    
    <div class="pop_header">
        <span>Select Patient</span>
        <a href="#" class="pop_close" style="float:right;">Close (X)</a>
    </div>
    
    <div class="scrollbar" style="height:300px;">
    
   		<form action="" method="post" id="patient_search_form">
    	<table width="100%" border="0" cellpadding="1" cellspacing="0">
         
          <tr>
          
            <td width="12%" align="right">Search Name: </td>
            <td width="15%">
                <input type="text" name="by_name" id="by_name" value="" class="form-control" aria-controls="dynamic-table">
            </td>
            
            <td width="5%" align="right">ID: </td>
            <td width="15%">
                <input type="text" name="by_id" id="by_id" value="" class="form-control" aria-controls="dynamic-table">
            </td>
            
            <td width="5%" align="right">Phone: </td>
            <td width="15%">
                <input type="text" name="by_phone" id="by_phone" value="" class="form-control" aria-controls="dynamic-table">
            </td>
            
            <td><input name="search" type="submit" id="patient_search" class="btn btn-success btn-sm" value="Search"/></td>
            
            <td width="15%" align="left"><a href="mgmtbeds" id="view_all_patients">View All</a></td>
            
          
          </tr>
        </table>
        <input type="hidden" name="search_patient" value="Search">
        <input type="hidden" name="refferer" value="mgmtbeds">
        
        </form>  
         
    	<table class="display table table-bordered table-striped" id="dynamic-table">
        
          <thead>
            <tr>
              <th width="5%" align="center">&nbsp;</th>
              <th width="5%" align="center">&nbsp;</th>
              <th width="5%" align="center">ID</th>
              <th width="10%" align="center">DOB</th>
              <th width="20%">Patient Name</th>
              <th width="15%">Phone</th>
              <th width="15%">Registration Date</th>
            </tr>
          </thead>
          <tbody id="default_body">
          
          </tbody>
         
        </table>
        
    </div>
    
</div>

<div id="allocate_ipdwardbed-box" class="allocate_ipdwardbed-popup">
    
    <div class="pop_header">
        <span>Allocate Ward Bed</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_allocate_ipdwardbed_form"></div>
            
            <form action="" method="post" id="allocate_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="patient_name" style="margin-top:7px;">
                	
                </div>
                 <a href="#select_patient-box" class="select_patient-window"  id="select_patient_popup">Select Patient</a>
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Allocation Time:</label>
                <div class="col-lg-6">
                	<input type="text" name="allocation_time" value="<?php echo date('Y-m-d',time());?>" id="datepicker" class="form-control" style="width:90%; display:inline;" readonly>
                </div>
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Discharge Time:</label>
                <div class="col-lg-6">
                	<input type="text" name="discharge_time" value="" id="datepicker1" class="form-control" style="width:90%; display:inline;" readonly>
                </div>
            </div>
            
            <div class="form-group">
           	 	<label class="control-label col-lg-3" for="firstname">Bed Status:</label>
                <div class="col-lg-6">
                    <select name="bed_status"  class="form-control">
                        <option value="occupied">Occupied</option>
                        <option value="reserved">Reserved</option>
                    </select>
                    
                </div>
            </div>
            
           
            <p align="right">
            	<input type="hidden" name="bed_id" id="bed_id_allot" value="">
                <input type="hidden" name="patient_id" id="patient_id" value="">
                <input type="hidden" name="ward_id" value="<?php echo $ipdwardid;?>">
            	<input type="hidden" name="allocate_ipdwardbed" value="Allocate_ipdwardbed">
                <input name="ajax_submit" type="submit" class="ajax_submit btn btn-info" value="Allocate"/>
            </p>
            
            </form>
            
            </td>
        </tr>
    </table>
    
</div>

<div id="add_ipdwardbed-box" class="add_ipdwardbed-popup">
    
    <div class="pop_header">
        <span>Add Ward Bed</span>
        <a href="#" class="pop_close" style="float:right;">Close (X)</a>
    </div>
    
    <table width="100%" border="0" cellspacing="2" cellpadding="2" class="panel">
        <tr>
            <td>
            
            <div id="result_insert_ipdwardbed_form"></div>
            
            <form action="" method="post" id="insert_ipdwardbed_form" class="cmxform form-horizontal" onsubmit="return false;">
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Bed No:</label>
                <div class="col-lg-6">
                	<input type="text" name="bed_no" value="" class="form-control">
                </div>
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Bed Fee:</label>
                <div class="col-lg-6">
                	<input type="text" name="bed_fee" value="" class="form-control"> 
                </div> /hr
            </div>
            
           
            <p align="right">
            	<input type="hidden" name="ward_id" value="<?php echo $ipdwardid;?>">
            	<input type="hidden" name="add_ipdwardbed" value="Add_ipdwardbed">
                <input name="ajax_submit" type="submit" class="ajax_submit btn btn-info" value="Add"/>
            </p>
            
            </form>
            
            </td>
        </tr>
    </table>
    
</div>

<div id="update_ipdwardbed-box" class="update_ipdwardbed-popup">
    
    <div class="pop_header">
        <span>Update Ward Bed</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_ipdwardbed_form"></div>
            
            <form action="" method="post" id="update_ipdwardbed_form" class="cmxform form-horizontal" onsubmit="return false;">
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Bed No:</label>
                <div class="col-lg-6">
                	<input type="text" name="bed_no" id="ipd_bed_no_value" value="" class="form-control">
                </div>
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Bed Fee:</label>
                <div class="col-lg-6">
                	<input type="text" name="bed_fee" id="ipd_bed_fee_value" value="" class="form-control">
                </div> /hr
            </div>
            
           
            <p align="right">
            	<input type="hidden" name="ward_id" value="<?php echo $ipdwardid;?>">
                <input type="hidden" name="bed_id" id="ipd_bed_id_value" value="">
            	<input type="hidden" name="update_ipdwardbed" value="Update_ipdwardbed">
                <input name="ajax_submit" type="submit" class="ajax_submit btn btn-info" value="Update"/>
            </p>
            
            </form>
            
            </td>
        </tr>
    </table>
    
</div>



<script>

$(".update_ipdwardbed").click(function() {
	
	var id = this.id;
	//alert(id);
	ipd_bed_id = $("#ipd_bed_id_"+id).val();
	ipd_bed_no = $("#ipd_bed_no_"+id).val();
	ipd_bed_fee = $("#ipd_bed_fee_"+id).val();
	
	$("#ipd_bed_id_value").val(ipd_bed_id);
	$("#ipd_bed_no_value").val(ipd_bed_no);
	$("#ipd_bed_fee_value").val(ipd_bed_fee);
	
});

$(".allocate_ipdwardbed").click(function() {
	var id = this.id;
	//alert(id);
	ipd_bed_id = $("#ipd_bed_id_"+id).val();
	$("#bed_id_allot").val(ipd_bed_id);
});


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