|
- <?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <title>增加酒店信息</title>
- <link rel="stylesheet" type="text/css" href="/monitor/Public/css/bootstrap.min.css" />
- <link rel="stylesheet" type="text/css" href="/monitor/Public/css/style.css" />
- </head>
- <body onload="load()">
- <div class="panel panel-default" style="width: 1348px;">
- <div class="panel-heading">
- <div class="row">
- <div class="col-sm-10">
- <h2 class="panel-title">
- 增加酒店信息
- </h2>
- </div>
- </div>
- </div>
- <div class="panel-body">
- <!-- <form action="/monitor/index.php/Monitor/monitorAdd" method="post">-->
-
- <input type="hidden" name="id" id="id" value="<?php if(!empty($edit)): echo ($edit["id"]); else: endif; ?>">
- <div class="form-horizontal">
- <div class="form-group row">
- <label class="col-md-2 control-label">网站名称:</label>
- <div class="col-md-8 control-label ">
- <select class="form-control" id="site_name" name="site_name">
- <?php if(is_array($site)): foreach($site as $key=>$vo): if((!empty($edit)) AND ($vo["site_name"] == $edit['site_name'])): if(($vo["id"] == 12) OR ($vo["id"] == 19)): ?><option value="<?php echo ($vo["id"]); ?>" selected="selected" ><?php echo ($vo["site_name"]); ?>(开发中)</option>
- <?php else: ?>
- <option value="<?php echo ($vo["id"]); ?>" selected="selected" ><?php echo ($vo["site_name"]); ?></option><?php endif; ?>
- <?php else: ?>
- <?php if(($vo["id"] == 12) OR ($vo["id"] == 19)): ?><option value="<?php echo ($vo["id"]); ?>" ><?php echo ($vo["site_name"]); ?>(开发中)</option>
- <?php else: ?>
- <option value="<?php echo ($vo["id"]); ?>" ><?php echo ($vo["site_name"]); ?></option><?php endif; endif; endforeach; endif; ?>
-
-
- </select>
- </div>
- </div>
- <div class="form-group row">
- <label class="col-md-2 control-label">酒店名称:</label>
- <div class="col-md-8">
- <input class="form-control" type="text" id="hotel_name" name="hotel_name" value="<?php if(!empty($edit)): echo ($edit["hotel_name"]); else: endif; ?>" required="required"/>
- </div>
- </div>
- <div class="form-group row">
- <label class="col-md-2 control-label">房间类型:</label>
- <div class="col-md-8 ">
- <input class="form-control" type="text" id="room_type" name="room_type" value="<?php if(!empty($edit)): echo ($edit["room_type"]); else: endif; ?>" required="required"/>
- </div>
- </div>
- <div class="form-group row">
- <label class="col-md-2 control-label">URL:</label>
- <div class="col-md-8 ">
- <input class="form-control" type="text" id="url_addr" name="url_addr" value="<?php if(!empty($edit)): echo ($edit["url"]); else: endif; ?>" required="required"/>
- </div>
- </div>
- <!--
- <div class="form-group row">
- <label class="col-md-2 control-label">price:</label>
- <div class="col-md-8 ">
- <input class="form-control" type="text" id="price" name="price" value="<?php if(!empty($edit)): echo ($edit["room_price"]); else: endif; ?>" required="required"
- onkeyup="clearNoNum(this)" maxlength="8"/>
- </div>
- </div>
- -->
- <div class="form-group row">
- <label class="col-md-2 control-label">有无早餐:</label>
- <div class="col-md-4 control-label">
- <?php if(!empty($edit)): if($edit["breakfast"] == 0): ?><label ><input name="breakfast" type="radio" checked="checked" value="0" onclick="fn(0)"/>无早</label>
- <label ><input name="breakfast" type="radio" value="1" onclick="fn(1)"/>单早</label>
- <label ><input name="breakfast" type="radio" value="2" onclick="fn(2)"/>双早</label>
- <label ><input name="breakfast" type="radio" value="3" onclick="fn(3)"/>三早</label>
- <?php elseif($edit["breakfast"] == 1): ?>
- <label ><input name="breakfast" type="radio" value="0" onclick="fn(0)"/>无早</label>
- <label ><input name="breakfast" type="radio" checked="checked" value="1" onclick="fn(1)"/>单早</label>
- <label ><input name="breakfast" type="radio" value="2" onclick="fn(2)"/>双早</label>
- <label ><input name="breakfast" type="radio" value="3" onclick="fn(3)"/>三早</label>
- <?php elseif($edit["breakfast"] == 2): ?>
- <label ><input name="breakfast" type="radio" value="0" onclick="fn(0)"/>无早</label>
- <label ><input name="breakfast" type="radio" value="1" onclick="fn(1)"/>单早</label>
- <label ><input name="breakfast" type="radio" checked="checked" value="2" onclick="fn(2)"/>双早</label>
- <label ><input name="breakfast" type="radio" value="3" onclick="fn(3)"/>三早</label>
- <?php elseif($edit["breakfast"] == 3): ?>
- <label ><input name="breakfast" type="radio" value="0" onclick="fn(0)"/>无早</label>
- <label ><input name="breakfast" type="radio" value="1" onclick="fn(1)"/>单早</label>
- <label ><input name="breakfast" type="radio" value="2" onclick="fn(2)"/>双早</label>
- <label ><input name="breakfast" type="radio" checked="checked" value="3" onclick="fn(3)"/>三早</label>
- <?php else: ?>
- <label ><input name="breakfast" type="radio" checked="checked" value="0" onclick="fn(0)"/>无早</label>
- <label ><input name="breakfast" type="radio" value="1" onclick="fn(1)"/>单早</label>
- <label ><input name="breakfast" type="radio" value="2" onclick="fn(2)"/>双早</label>
- <label ><input name="breakfast" type="radio" value="3" onclick="fn(3)"/>三早</label><?php endif; ?>
- <?php else: ?>
- <label ><input name="breakfast" type="radio" checked="checked" value="0" onclick="fn(0)"/>无早</label>
- <label ><input name="breakfast" type="radio" value="1" onclick="fn(1)"/>单早</label>
- <label ><input name="breakfast" type="radio" value="2" onclick="fn(2)"/>双早</label>
- <label ><input name="breakfast" type="radio" value="3" onclick="fn(3)"/>三早</label><?php endif; ?>
- </div>
- </div>
- <div class="form-group row">
- <label class="col-md-2 control-label">price:</label>
- <div class="col-md-8 ">
- <table class="table table-hover">
- <thead class="navbar-inner">
- <tr>
- <th>时间</th>
- <th>价格</th>
- <th>时间</th>
- <th>价格</th>
- </tr>
- </thead>
- <tbody id="price_table">
- </tbody>
- </table>
- </div>
- </div>
- <div class="form-group row">
- <div class="col-md-5">
- </div>
- <div class="col-md-2">
- <input class="form-control" type="button" value="保存" onclick="save()"></input>
- </div>
- </div>
- </div>
- <!-- </form>-->
-
-
-
-
- </div>
- </div>
- </body>
- <script type="text/javascript" src="/monitor/Public/js/json2.js"></script>
- <script type="text/javascript" src="/monitor/Public/js/jquery.1.11.js"></script>
- <script type="text/javascript">
- var breakfast=0;
- var arrayTime = new Array();
- var myDate = new Date();
- function load(){
- for(var i=0; i<30; i++){
- var year = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
- var month = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
- var dd = myDate.getDate(); //获取当前日(1-31)
- var str = year+"-"+month+"-"+dd;
- var week = myDate.getDay(); //星期
- //判断星期几
- var weeks = ["日","一","二","三","四","五","六"];
- var getWeek = "(星期" + weeks[week]+")";
- arrayTime[i] = new Array();
- arrayTime[i][0] = str;
- arrayTime[i][1] = '';
- arrayTime[i][2] = getWeek;
- myDate.setDate(myDate.getDate()-0+1);
- }
- myDate = new Date(); //时间归位
- var s='';
- for(var j=0; j<arrayTime.length; j=j-0+2){
- s+='<tr>';
- s+='<th id="time_'+j+'">'+arrayTime[j][0]+arrayTime[j][2]+'</th>';
- s+='<th><input id="price_'+j+'" value="'+arrayTime[j][1]+'" onkeyup="clearNoNum(this)" maxlength="8"></input></th>';
- var k = j-0+1;
- s+='<th id="time_'+k+'">'+arrayTime[k][0]+arrayTime[k][2]+'</th>';
- s+='<th><input id="price_'+k+'" value="'+arrayTime[k][1]+'" onkeyup="clearNoNum(this)" maxlength="8"></input></th>';
- s+='</tr>';
- }
- document.getElementById('price_table').innerHTML = s;
-
-
- var edit = '<?php echo ($edit); ?>';
- if(edit){
- breakfast='<?php echo ($edit["breakfast"]); ?>';
- }else{
- breakfast=0;
- }
- }
- function save(){
- var id = $("#id").val();
- var site_name = $("#site_name").val();
- site_name = site_name.replace(/(^\s*)|(\s*$)/g, "");
- var hotel_name = $("#hotel_name").val();
- hotel_name = hotel_name.replace(/(^\s*)|(\s*$)/g, "");
- var room_type = $("#room_type").val();
- room_type = room_type.replace(/(^\s*)|(\s*$)/g, "");
- var url_addr = $("#url_addr").val();
- url_addr = url_addr.replace(/(^\s*)|(\s*$)/g, "");
- var p='';
- for(var i=0; i<30; i++){
- var price = $("#price_"+i).val();
- price = price.replace(/(^\s*)|(\s*$)/g, "");
- if(!price || price == ''){
- }else{
- if(!p || p == ''){
- p += arrayTime[i][0] +"P"+price;
- }else{
- p += "|"+arrayTime[i][0] +"P"+price;
- }
- }
- }
- if(!hotel_name || hotel_name == ''){
- alert("酒店名称不能为空");
- return;
- }
- if(!room_type || room_type == ''){
- alert("房间类型不能为空");
- return;
- }
- if(!url_addr || url_addr == ''){
- alert("url地址不能为空");
- return;
- }
- if(!p || p == ''){
- alert("价格不能为空");
- return;
- }
- var posturl='/monitor/index.php/Monitor/monitorAdd';
- $.ajax({
- type: 'POST',
- url: posturl,
- data: {
- id: id,
- site_name: site_name,
- hotel_name: hotel_name,
- room_type: room_type,
- url_addr: url_addr,
- price: p,
- breakfast: breakfast
- },
- dataType: 'json',
- context: $('body'),
- success: function (data) {
- alert(data.errorInfo);
- },
- error: function (xhr, type) {
- var data = $.parseJSON(xhr.responseText);
- alert(data.message);
- }
- });
-
- }
- function clearNoNum(obj){
- //先把非数字的都替换掉,除了数字和.
- obj.value = obj.value.replace(/[^\d.]/g,"");
- //必须保证第一个为数字而不是.
- obj.value = obj.value.replace(/^\./g,"");
- //保证只有出现一个.而没有多个.
- obj.value = obj.value.replace(/\.{2,}/g,".");
- //保证.只出现一次,而不能出现两次以上
- obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
- }
- function fn(v){
- breakfast=v;
- }
- </script>
- </html>
|