<?php session_start(); ?> <!-- session start -->
<?php include("../include/config.php"); ?> <!-- database connection -->
<?php include("../include/connect_url.php"); ?> <!-- connection url/link folder -->
<?php include("../include/date_time.php"); ?> <!-- date & time format -->
<?php include("../database/account.php"); ?> <!-- query database account -->
<?php include("../include/lang.php"); ?> <!-- language -->
<?php include("../include/session_login.php"); ?> <!-- session login -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title><?php include("../template/title.php"); ?></title>

<link rel="shortcut icon" href="<?php echo $connect_url_data; ?>/favicon.ico" />

<link href="<?php echo $connect_url_data; ?>/css/styles.css" rel="stylesheet" type="text/css" />
<!--[if IE]> <link href="<?php echo $connect_url_data; ?>/css/ie.css" rel="stylesheet" type="text/css"> <![endif]-->
<link rel="stylesheet" href="<?php echo $connect_url_data; ?>/font/font-awesome-4.3.0/css/font-awesome.min.css">

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/download/jquery183.js"></script> 
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/download/jquery192.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/excanvas.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.flot.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.flot.orderBars.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.flot.pie.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.flot.resize.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/charts/jquery.sparkline.min.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/tables/jquery.dataTables.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/tables/jquery.sortable.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/tables/jquery.resizable.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.autosize.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.uniform.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.inputlimiter.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.tagsinput.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.maskedinput.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.autotab.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.select2.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.dualListBox.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.cleditor.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.ibutton.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.validationEngine-en.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.validationEngine.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/globalize/globalize.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/globalize/globalize.culture.de-DE.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/globalize/globalize.culture.ja-JP.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/uploader/plupload.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/uploader/plupload.html4.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/uploader/plupload.html5.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/uploader/jquery.plupload.queue.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/wizards/jquery.form.wizard.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/wizards/jquery.validate.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/wizards/jquery.form.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.collapsible.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.breadcrumbs.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.tipsy.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.progress.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.timeentry.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.colorpicker.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.jgrowl.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.fancybox.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.fileTree.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.sourcerer.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/others/jquery.fullcalendar.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/others/jquery.elfinder.js"></script>

<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/forms/jquery.mousewheel.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/plugins/ui/jquery.easytabs.min.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/files/bootstrap.js"></script>
<script type="text/javascript" src="<?php echo $connect_url_data; ?>/js/files/functions.js"></script>

</head>

<body>

<!-- header-->
<?php include("../template/header.php"); ?>

<!-- sidebar-->
<?php include("../template/sidebar.php"
	      ); ?>
   
<!-- Content begins -->
<div id="content">
    
    <!-- Breadcrumbs line -->
    <div class="breadLine">
        <div class="bc">
            <ul id="breadcrumbs" class="breadcrumbs">
                 <li><a href="<?php echo $connect_url_data; ?>/dashboard"><?php echo $lang['Dashboard']; ?></a></li>
                <li><a href="<?php echo $connect_url_data; ?>/room"><?php echo $lang['Room']; ?></a></li>
                <li class="current"><a href="#"><?php echo $lang['Create Room']; ?></a></li>
            </ul>
        </div>
        
<!-- breaklink -->
<?php include("../menu/breadlink.php"); ?>
	
    </div>
    
    <!-- Main content -->
    <div class="wrapper">

<?php
if($_POST)
{
//room
$query_room1= mysql_query("SELECT * FROM tbl_room");
while($row= mysql_fetch_assoc($query_room1))
{
    $db_room1_id= $row['id'];
}
    $db_room1_id_add = $db_room1_id + 1;
    $db_room1_id_add_comp = "$date_year$db_room1_id_add";
    
    
$room =mysql_real_escape_string(ucwords($_POST['room']));
$room_type =$_POST['room_type'];
$bed = $_POST['bed'];

//number format
include("../include/number_format.php");

if($room==""){
die ("<script> alert('Please fill room.');
window.location.href='javascript:history.back();';		
</script> ");
}

if($room_type==""){
die ("<script> alert('Please choose room type.');
window.location.href='javascript:history.back();';		
</script> ");
}

if($bed==""){
die ("<script> alert('Please choose bed.');
window.location.href='javascript:history.back();';		
</script> ");
}

if($price==""){
die ("<script> alert('Please input price.');
window.location.href='javascript:history.back();';		
</script> ");
}



//create room
$query_insert = mysql_query("
  INSERT INTO tbl_room VALUES ('','$db_room1_id_add_comp','$room','$room_type','$db_user_id','$date','$time','1');
");

$mysql_insert_id = mysql_insert_id();

//price
$query_insert = mysql_query("
  INSERT INTO tbl_room_price VALUES ('','$mysql_insert_id','$price_nf','$db_user_id','$date','$time','1');
");

//bed
for($i=0;$i<sizeof($bed);$i++)
{
if($bed[$i]){
$query_insert = mysql_query("
 INSERT INTO tbl_room_bed VALUES ('','$mysql_insert_id','$bed[$i]','$db_user_id','$date','$time','1');
");
}
}

die ("<script> alert('Saved. ');
window.location.href='$connect_url_data/room';		
</script> ");
}
?>

<form name="form" id="form" action="<?php echo $connect_url_data; ?>/create-room" class="main" method="POST"  enctype="multipart/form-data">
            <fieldset>
                <div class="widget fluid">
                    <div class="whead"><h6><span class="icos-add" style="margin-top:-2px;"></span>&nbsp; <?php echo $lang['Create Room']; ?></h6></div>
               
		    <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Room']; ?>:</label></div>
                        <div class="grid10"><input type="text" name="room" id="room"/></div>
                    </div>
		    
		   <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Room Type']; ?>:</label></div>
                            <div class="grid10">
                               <?php
				$query_room_type1=mysql_query("SELECT * FROM tbl_room_type ORDER BY room_type ASC");
				$option_room_type1="";
				while($row=mysql_fetch_array($query_room_type1)) {
				$option_room_type1 .= "<option value='$row[id]'";
				$option_room_type1 .= ">". $row['room_type'] ."</option>";  }
				?>    
				<select name="room_type" id="room_type"  data-placeholder="Choose" class="select" tabindex="2" style="width:100%;">
                                <option value=""></option> 
				<?php echo $option_room_type1; ?>
				</select>
                            </div>             
                    </div>
		   
		     <div class="formRow">
                            <div class="grid2"><label><?php echo $lang['Bed']; ?>:</label></div>
                            <div class="grid10">
                               <?php
				$query_bed1=mysql_query("SELECT * FROM tbl_bed ORDER BY bed ASC");
				$option_bed1="";
				while($row=mysql_fetch_array($query_bed1)) {
				$option_bed1 .= "<option value='$row[id]'";
				$option_bed1 .= ">". $row['bed'] ."</option>";  }
				?>    
				<select name="bed[]" id="bed[]"  data-placeholder="Choose" class="selectMultiple" multiple="multiple" tabindex="2" style="width:100%;">
                                <option value=""></option> 
				<?php echo $option_bed1; ?>
				</select>
                            </div>             
                    </div>
		   
		    <div class="formRow">
                        <div class="grid2"><label><?php echo $lang['Price']; ?>:</label></div>
                        <div class="grid10"><input type="text" name="price" id="price" placeholder="<?php echo $db_currency_code1; ?><?php echo $db_number_format_number_format; ?>"/></div>
                    </div>
		   
		    <div class="formRow">
                    <div class="grid2"><br /></div>
                    <div class="grid10">
	<a href="#" class="buttonM bBlue" onclick="document.getElementById('form').submit();"><span class="fa fa-save"></span><span><?php echo $lang['Save']; ?></span></a>
		        <a href="#" class="buttonM bBlue" onclick="window.location.href='<?php echo $connect_url_data; ?>/room'"><span class="fa fa-times-circle"></span><span><?php echo $lang['Cancel']; ?></span></a>
		    </div>
		    
		    </div>
                  
                </div>
            </fieldset>

	    
	    
        </div>
	
    </div>
    <!-- Main content ends -->
    
</div>
<!-- Content ends -->  
             
</body>
</html>
