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


/*echo '<pre>';
print_r($_POST);
echo '</pre>';
*/
if(isset($_POST['org_id'])&&$_POST['org_id']!='')
{
	$_SESSION['security']['org_id'] = $_POST['org_id'];
	//header("Location:db.php");
}

if(isset($_POST['location_id'])&&$_POST['location_id']!='')
{
	$_SESSION['security']['location_id'] = $_POST['location_id'];
	header("Location:home.php");
}

try
{
	$retrieveOrgOB = new classUser;
	$org_array = $retrieveOrgOB->retrieveAllOrganizations();
}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}	

try
{
	$retrieveLocOB = new classUser;
	$retrieveLocOB->setOrganizationID($_SESSION['security']['org_id']);
	$location_array = $retrieveLocOB->retrieveLocationsOfOrganization();
}
catch (MyException $e)
{
	$error_message = $e->getUserMsg();
}			





?>
<!DOCTYPE html>
<html>
<head> 
    <link rel="shortcut icon" href="../images/favicon.png">
<title>Med2TEC Hospital Management Information System</title>
<!--Core CSS -->
<link href="../bs3/css/bootstrap.min.css" rel="stylesheet">
    <link href="../assets/jquery-ui/jquery-ui-1.10.1.custom.min.css" rel="stylesheet">
    <link href="../css/bootstrap-reset.css" rel="stylesheet">
    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet"> 
    <link href="../assets/jvector-map/jquery-jvectormap-1.2.2.css" rel="stylesheet">
    <link href="../css/clndr.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="../assets/jquery-multi-select/css/multi-select.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="../css/style.css" rel="stylesheet">
    <link href="../css/style-responsive.css" rel="stylesheet"/> 
    <link rel="stylesheet" href="../popUp/popUp.css" />
    <link href="../css/custom.css" rel="stylesheet"/>
    <link href="../css/bootstrap-fullcalendar.css" rel="stylesheet"/>  
     <link rel="stylesheet" href="../datepicker/jquery-ui.css">
</head>
<body>
<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> 
<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;">
            <!--  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"> <a href="#"><i class="fa fa-print" style="margin-left: 11px; margin-top: 11px;"></i></a> </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="changepwd.php"><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-->
   
    <!--sidebar end-->
    <!--main content start-->
  <section id="main-content">
    <section class="wrapper">
      <!--mini statistics start-->

      <header class="panel-heading">
            <img src="../images/titlehmis.png">
          </header>
               
                <?php
			if(isset($error_message)&&$error_message!='')
			{
				?>
				<table>
                    <tr>
                        <td><span class="message_red"><?php echo $error_message;?></span></td>
                    </tr>
				</table>
				<?php
			}
			?>
                
            <form action="" method="post" id="form">	
            <table width="100%" border="0" cellpadding="1" cellspacing="0">
            
				<tr>
                <td width="10%"><div class="row-fluid">
                    <div class="span6">
                      <div id="dynamic-table_length" class="dataTables_length">
                        
                           <select name="org_id" id="org_id" class="form-control input-sm m-bot15" style="width:auto; margin-bottom:0px;">
                           		<option value="">Select Organization</option>
								<?php
                                for($d=0;$d<count($org_array);$d++)
                                {
                                    ?>
                                    <option value="<?php echo $org_array[$d]['org_id']?>" <?php if($_SESSION['security']['org_id']==$org_array[$d]['org_id']){echo "selected";}?>><?php echo $org_array[$d]['org_name'];?></option>
                                    <?php
                                }
                                ?>
                            </select> 
                        
                      </div>
                    </div>
                  </div></td>
                  <td width="90%"><a href="#add_organization-box" class="add_organization-window" id="add_organization"><span class="message_red">Create New Organization</span></a></td>
                </tr>
                
                <?php
				if($_SESSION['security']['org_id']!=0)
				{
					?>
					 
					<tr>
					<td colspan="2">
                    
                    	<div class="row-fluid">
						<div class="span6">
						  <div id="dynamic-table_length" class="dataTables_length">
							
                            Location:<br><br>
                            
							<?php
							for($l=0;$l<count($location_array);$l++)
							{
								if($l==0)
								{
									$checked = 'checked';
								}
								else
								{
									$checked = '';
								}
								
								?>
								<input type="radio"  name="location_id" value="<?php echo $location_array[$l]['location_id']?>" <?php echo $checked;?>><span style="margin-left:3px;"><?php echo ucwords($location_array[$l]['location_name']);?></span><br/><br/>
								<?php
							}
							?>
							 <br>  <br> <br> 
							<input type="submit" name="save_org" value="Submit" class="btn btn-success btn-sm">
						  </div>
						</div>
					  </div></td>
					 </tr>
					
					<?php
				}
				?>
             
            </table>
            </form>     

      
<div style="position: absolute; padding-left: 256px; bottom: 10%; left: 0px; top: 613px;"><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>
   
    </section>
  </section>
  <!--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>-->


</body>
</html>

<div id="add_organization-box" class="add_organization-popup">
    
    <div class="pop_header">
        <span>Add Organization</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_org_form"></div>
          
          <form action="" method="post" id="insert_org_form" class="cmxform form-horizontal" onsubmit="return false;">
          
          	<div class="form-group">
            <label class="control-label col-lg-3" for="firstname">Hospital :</label>
                <div class="col-lg-6">
                    <input type="text" name="org_name" value="" class="form-control">
                </div>
            </div>
            
            
            
            <div class="form-group" style="margin-bottom:0px;">
            <label class="control-label col-lg-3" for="firstname">OPD :</label>
            	<div class="col-lg-6" style="width:5%;">
                    <input type="checkbox" name="opd" value="" checked class="form-control">
                </div>
            </div>
            
            <div class="form-group" style="margin-bottom:0px;">
            <label class="control-label col-lg-3" for="firstname">IPD :</label>
            	<div class="col-lg-6" style="width:5%;">
                    <input type="checkbox" name="ipd" value="" checked class="form-control">
                </div>
            </div>
            
            <div class="form-group" style="margin-bottom:0px;">
            <label class="control-label col-lg-3" for="firstname">Diagnostics :</label>
            	<div class="col-lg-6" style="width:5%;">
                    <input type="checkbox" name="diagnostic" value="" checked class="form-control">
                </div>
            </div>
            
            <div class="form-group" style="margin-bottom:0px;">
            <label class="control-label col-lg-3" for="firstname">OT :</label>
            	<div class="col-lg-6" style="width:5%;">
                    <input type="checkbox" name="ot" value="" checked class="form-control">
                </div>
            </div>
            
            <div class="form-group" style="margin-bottom:0px;">
            <label class="control-label col-lg-3" for="firstname">Pharmacy :</label>
            	<div class="col-lg-6" style="width:5%;">
                    <input type="checkbox" name="pharmacy" value="" checked class="form-control">
                </div>
            </div>
            
            <div class="form-group" style="margin-bottom:0px;">
            <label class="control-label col-lg-3" for="firstname">Emergency :</label>
            	<div class="col-lg-6" style="width:5%;">
                    <input type="checkbox" name="emergency" value="" checked class="form-control">
                </div>
            </div>
            
            <div class="form-group" style="margin-bottom:0px;">
            <label class="control-label col-lg-3" for="firstname">Admin :</label>
            	<div class="col-lg-6" style="width:5%;">
                    <input type="checkbox" name="admin" value="" checked class="form-control">
                </div>
            </div>
            
            <!--<div class="form-group">
            <label class="control-label col-lg-3" for="firstname">Patient Reg Fee :</label>
            	<div class="col-lg-6">
                     <input type="text" name="patient_reg_fee" value="" class="form-control">
                </div>
            </div>-->
            
            <div class="form-group">
            <label class="control-label col-lg-3" for="firstname">No Of Locations :</label>
            	<div class="col-lg-6">
                     <input type="text" name="no_of_locations" value="" class="form-control">
                </div>
            </div>
            
            <hr style="color:#000000;">
            
            <div class="form-group">
            <label class="control-label col-lg-3" for="firstname">Locations Name :</label>
            	<div class="col-lg-6">
                     <input type="text" name="location_name" value="" class="form-control">
                </div>
            </div>
            
            <p align="right">
            	<input type="hidden" name="redirect_url" value="organization.php">
                <input type="hidden" name="add_org" value="Add_organization">
                <input name="ajax_submit" type="submit" class="ajax_submit btn btn-info" value="Add"/>
            </p>
            
          </form>
          </td>
          
      </tr>
    </table>
</div>

<script>
$(document).ready(function() {
	$('#org_id').change(function() {
		
		$('#form').submit();
	});
});
</script>