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

################# delete ward #######################################

if(isset($_GET['wid'])&&$_GET['wid']!='')
{
	try
	{
		$wid = base64_decode($_GET['wid']);
		$delWardOb = new classWardMgmt;
		$delWardOb->setWardID($wid);
		$delWardOb->deleteWard();
	}
	catch (MyException $e)
	{
		$error_message = $e->getUserMsg();
	}
}

################# delete bed #######################################

if(isset($_GET['bid'])&&$_GET['bid']!='')
{
	try
	{
		$bid = base64_decode($_GET['bid']);
		$delBedOb = new classWardMgmt;
		$delBedOb->setWardBedID($bid);
		$delBedOb->deleteBed();
	}
	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;
}


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

################# retrieve all staff #######################################

try
{
	$staffOb = new classWardMgmt;
	$staffOb->setLocationID($_SESSION['security']['location_id']);
	$staff_array = $staffOb->retrieveAllStaff();
}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}

/*echo '<pre>';
print_r($ward_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('printmgmtwards.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="mgmtwards.php"><img src="../images/iconwards.png"></a></td>
              <td width="12%" align="center"><a href="#add_ipdward-box" class="add_ipdward-window" id="add_ipdward"><img src="../images/iconward.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="#add_ipdward-box" class="add_ipdward-window" id="add_ipdward">Add Ward</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 WARDS & BEDS</h2>
            </header>
            
            <?php
            if(isset($error_message)&&$error_message!='')
            {
                ?>
                <span class="message_red"><?php echo $error_message;?></span>
                <?php
            }
            ?>
            
            <table width="100%" border="0" cellpadding="1" cellspacing="0">
            <form action="" method="post">
              <tr>
              
                <td width="5%" align="right">Search Bed No: </td>
                <td width="5%"><input type="text" name="search_bed_no" 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="mgmtwards.php">View All</a></td>
               <!-- <td width="5%" align="right">ID: </td>
                <td width="15%">
                	<input type="text" class="form-control" aria-controls="dynamic-table">
                </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="5%" align="center">&nbsp;</th>
                      <th width="15%">Ward</th>
                      <th width="55%"> <!--<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>
                      <th width="10%">No. of Beds</th>
                      <th width="10%">Ward Incharge</th>
                      <th width="5%" align="center" class="hidden-phone">Delete</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 width="5%" align="center"><a href="#update_ipdward-box" class="update_ipdward-window update_ipdward" id="<?php echo $w;?>">Edit</a></td>
                            
                            <td><?php echo $ipd_ward_no;?> - <?php echo $ipd_ward_type;?><br>
                            <?php
                            if(count($ward_array)>0)
                            {
								?>
								<span style="float:left;"><a href="#add_ipdwardbed-box" class="add_ipdwardbed-window add_ipdwardbed" id="<?php echo $w;?>"><span class="message_red">Add Bed</span></a></span>
								<?php
                            }
                            ?></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_ward_id = $ward_array[$w]['bed_details'][$wb]['ipd_ward_id'];
									$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'];
									
									$ipd_bed_allotment_id_encoded = base64_encode($ward_array[$w]['bed_details'][$wb]['ipd_bed_allotment_id']);
									
									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';
										$button_type = '<a href="#discharge_ipdwardbed-box" class="discharge_ipdwardbed-window btn btn-danger btn-sm discharge_ipdwardbed" id="'.$w.$wb.'">Discharge</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">
                                        <a href="#update_ipdwardbed-box" class="update_ipdwardbed-window update_ipdwardbed" id="<?php echo $w.$wb;?>"><img src="../images/<?php echo @$image;?>.png"></a><br>
                                        <span style="float:left;"><?php 
                                        $checkAllotOb = new classWardMgmt;
                                        if($checkAllotOb->checkWardBedAllotmentExist($ipd_bed_id))
                                        {
											?><a href="mgmtwards.php?bid=<?php echo $ipd_bed_id_encode;?>"><span class="message_red">Delete</span></a><?php
                                        }
                                        ?></span>
                                        </td>
                                        
                                        <td width="90%" align="left">Bed No: 
                                        
                                        <strong><a href="#update_ipdwardbed-box" class="update_ipdwardbed-window update_ipdwardbed" id="<?php echo $w.$wb;?>"><?php echo $ipd_bed_no;?></a></strong>
                                        
                                        <span style="float:right;">Fee: Rs. <span style="font-size:18px;"><?php echo number_format($ipd_bed_fee,2);?></span>/hr</span><br>
                                        
                                        <span style="float:left;">Detail: <?php echo $ipd_bed_type;?></span>
                                        
                                        </td>
									</tr>
									</table>
									
									<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_no" class="set_to_pop" id="ipd_bed_no_<?php echo $w.$wb;?>" value="<?php echo $ipd_bed_no;?>">
									<input type="hidden" name="ipd_bed_fee" class="set_to_pop" id="ipd_bed_fee_<?php echo $w.$wb;?>" value="<?php echo $ipd_bed_fee;?>">
									<input type="hidden" name="ipd_bed_type" class="set_to_pop" id="ipd_bed_type_<?php echo $w.$wb;?>" value="<?php echo $ipd_bed_type;?>">
									<input type="hidden" name="ipd_bedward_id" class="set_to_pop" id="ipd_bedward_id_<?php echo $w.$wb;?>" value="<?php echo $ipd_ward_id;?>">
                                    <input type="hidden" name="ipd_bedward_no" class="set_to_pop" id="ipd_bedward_no_<?php echo $w.$wb;?>" value="<?php echo $ipd_ward_no;?>">
                                    <input type="hidden" name="ipd_bedward_type" class="set_to_pop" id="ipd_bedward_type_<?php echo $w.$wb;?>" value="<?php echo $ipd_ward_type;?>">
									<?php 
								}
                            }
                            else
                            {
								?>
								There are no beds in this ward.<p>
								<?php
                            }
                            ?>
                            </td>
                            
                            <td align="right"><?php echo $no_of_beds;?></td>
                            
                            <td><?php echo $staff_id;?></td>
                            
                            <td align="center" class="hidden-phone"><?php 
                            if(count($ward_array[$w]['bed_details'])==0)
                            {
                                ?><a href="mgmtwards.php?wid=<?php echo $ipd_ward_id_encode;?>"><img src="../images/delete.png"></a><?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">No Ward entered yet!</td>
                        </tr>
                        <?php
					}
					?>       
                  </tbody>
                  
               </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_ipdward-box" class="add_ipdward-popup">
    
    <div class="pop_header">
        <span>Add Ward</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_ipdward_form"></div>
            
            <form action="" method="post" id="insert_ipdward_form" class="cmxform form-horizontal" onsubmit="return false;">
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Ward No:</label>
                <div class="col-lg-6">
                	<input type="text" name="ward_no" value="" class="form-control">
                </div>
            </div>
            
            <div class="form-group">
           	 	<label class="control-label col-lg-3" for="firstname">Ward Type:</label>
                <div class="col-lg-6">
                    <select name="ward_type"  class="form-control">
                        <option value="">Select Type</option>
                        <option value="general_ward">General Ward</option>
                        <option value="icu">ICU</option>
                        <option value="private_room">Private Room</option>
                        <option value="outdoor_ward">Out Door Ward</option>
                    </select>
                    
                </div>
            </div>
            
            <div class="form-group">
           	 	<label class="control-label col-lg-3" for="firstname">Ward Incharge:</label>
                <div class="col-lg-6">
                    <select name="ward_incharge"  class="form-control">
                        <option value="">Select Ward Incharge</option>
                        <?php
                        for($l=0;$l<count($staff_array);$l++)
                        {
                            ?>
                            <option value="<?php echo $staff_array[$l]['staff_id']?>"><?php echo $staff_array[$l]['fname'].' '.$staff_array[$l]['lname'];?></option>
                            <?php
                        }
                        ?>
                    </select>
                </div>
            </div>
            
            <p align="right">
            	<input type="hidden" name="add_ipdward" value="Add_ipdward">
                <input name="ajax_submit" type="submit" class="ajax_submit btn btn-info" value="Add"/>
            </p>
            
            </form>
            
            </td>
        </tr>
    </table>
    
</div>

<div id="update_ipdward-box" class="add_ipdward-popup">
    
    <div class="pop_header">
        <span>Update Ward</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_ipdward_form"></div>
            
            <form action="" method="post" id="update_ipdward_form" class="cmxform form-horizontal" onsubmit="return false;">
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Ward No:</label>
                <div class="col-lg-6">
                	<input type="text" name="ward_no" id="ipd_ward_no_value" value="" class="form-control">
                </div>
            </div>
            
            <div class="form-group">
           	 	<label class="control-label col-lg-3" for="firstname">Ward Type:</label>
                <div class="col-lg-6">
                    <select name="ward_type" id="ipd_ward_type_value"  class="form-control">
                        <option value="">Select Type</option>
                        <option value="general_ward">General Ward</option>
                        <option value="ICU">ICU</option>
                        <option value="private_room">Private Room</option>
                        <option value="outdoor_ward">Out Door Ward</option>
                    </select>
                    
                </div>
            </div>
            
            <div class="form-group">
           	 	<label class="control-label col-lg-3" for="firstname">Ward Incharge:</label>
                <div class="col-lg-6">
                    <select name="ward_incharge" id="staff_id_value" class="form-control">
                        <option value="">Select Ward Incharge</option>
                        <?php
                        for($l=0;$l<count($staff_array);$l++)
                        {
                            ?>
                            <option value="<?php echo $staff_array[$l]['staff_id']?>"><?php echo $staff_array[$l]['fname'].' '.$staff_array[$l]['lname'];?></option>
                            <?php
                        }
                        ?>
                    </select>
                </div>
            </div>
            
            <p align="right">
            	<input type="hidden" name="ipd_ward_id" id="ipd_ward_id_value" value="">
            	<input type="hidden" name="update_ipdward" value="Update_ipdward">
                <input name="ajax_submit" type="submit" class="ajax_submit btn btn-info" value="Update"/>
            </p>
            
            </form>
            
            </td>
        </tr>
    </table>
    
</div>

<div id="add_ipdwardbed-box" class="add_ipdwardbed-popup">
    
    <div class="pop_header">
        <span>Add 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><p>
            
            <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">Ward No:</label>
                <div class="col-lg-6" id="ward_type_value">
                	
                </div>
            </div>
            
            <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">Fee per hour:</label>
                <div class="col-lg-6">
                	<input type="text" name="bed_fee" value="" class="form-control"> 
                </div> /hr
            </div>
              
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Details:</label>
                <div class="col-lg-6">
                	<textarea name="bed_type" cols="43" rows="5"></textarea>
                </div>
            </div>
            
           
            <p align="right">
            	<input type="hidden" name="ward_id" id="ward_id_value" value="" class="form-control">
            	<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><p>
            
            <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">Select Ward:</label>
                <div class="col-lg-6" id="ipd_bedward_type">
                </div>
            </div>
            
            <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">Fee per hour:</label>
                <div class="col-lg-6">
                	<input type="text" name="bed_fee" id="ipd_bed_fee_value" value="" class="form-control">
                </div> /hr
            </div>
            
            <div class="form-group">
                <label class="control-label col-lg-3" for="firstname">Details:</label>
                <div class="col-lg-6">
                	<textarea name="bed_type" id="ipd_bed_type" cols="43" rows="5" class="form-control"></textarea>
                </div>
            </div>
           
            <p align="right">
            	
                <input type="hidden" name="ward_id" id="ipd_bedward_id" value="">
                <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_ipdward").click(function() {
	
	var id = this.id;
	//alert(id);
	ipd_ward_id = $("#ipd_ward_id_"+id).val();
	ipd_ward_no = $("#ipd_ward_no_"+id).val();
	ipd_ward_type = $("#ipd_ward_type_"+id).val();
	staff_id = $("#staff_id_"+id).val();
	
	$("#ipd_ward_id_value").val(ipd_ward_id);
	$("#ipd_ward_no_value").val(ipd_ward_no);
	$("#ipd_ward_type_value").val(ipd_ward_type);
	$("#staff_id_value").val(staff_id);
	
});

$(".add_ipdwardbed").click(function() {
	
	var id = this.id;
	
	ipd_ward_id = $("#ipd_ward_id_"+id).val();
	ipd_ward_no = $("#ipd_ward_no_"+id).val();
	ipd_ward_type = $("#ipd_ward_type_"+id).val();
	
	//alert(ipd_ward_id);
	$("#ward_id_value").val(ipd_ward_id);
	$("#ward_type_value").html(ipd_ward_no+'-'+ipd_ward_type);
	
	
});

$(".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_type = $("#ipd_bed_type_"+id).val();
	
	ipd_bedward_id = $("#ipd_bedward_id_"+id).val();
	ipd_bedward_no = $("#ipd_bedward_no_"+id).val();
	ipd_bedward_type = $("#ipd_bedward_type_"+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);
	$("#ipd_bedward_id").val(ipd_bedward_id);
	
	$("#ipd_bedward_type").html(ipd_bedward_no+'-'+ipd_bedward_type);
	$("#ipd_bed_type").val(ipd_bed_type);
	
});
</script>