You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

256 lines
10 KiB

  1. <?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>增加酒店信息</title>
  6. <link rel="stylesheet" type="text/css" href="/monitor/Public/css/bootstrap.min.css" />
  7. <link rel="stylesheet" type="text/css" href="/monitor/Public/css/style.css" />
  8. </head>
  9. <body onload="load()">
  10. <div class="panel panel-default" style="width: 1348px;">
  11. <div class="panel-heading">
  12. <div class="row">
  13. <div class="col-sm-10">
  14. <h2 class="panel-title">
  15. 增加酒店信息
  16. </h2>
  17. </div>
  18. </div>
  19. </div>
  20. <div class="panel-body">
  21. <!-- <form action="/monitor/index.php/Monitor/monitorAdd" method="post">-->
  22. <input type="hidden" name="id" id="id" value="<?php if(!empty($edit)): echo ($edit["id"]); else: endif; ?>">
  23. <div class="form-horizontal">
  24. <div class="form-group row">
  25. <label class="col-md-2 control-label">网站名称:</label>
  26. <div class="col-md-8 control-label ">
  27. <select class="form-control" id="site_name" name="site_name">
  28. <?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>
  29. <?php else: ?>
  30. <option value="<?php echo ($vo["id"]); ?>" selected="selected" ><?php echo ($vo["site_name"]); ?></option><?php endif; ?>
  31. <?php else: ?>
  32. <?php if(($vo["id"] == 12) OR ($vo["id"] == 19)): ?><option value="<?php echo ($vo["id"]); ?>" ><?php echo ($vo["site_name"]); ?>(开发中)</option>
  33. <?php else: ?>
  34. <option value="<?php echo ($vo["id"]); ?>" ><?php echo ($vo["site_name"]); ?></option><?php endif; endif; endforeach; endif; ?>
  35. </select>
  36. </div>
  37. </div>
  38. <div class="form-group row">
  39. <label class="col-md-2 control-label">酒店名称:</label>
  40. <div class="col-md-8">
  41. <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"/>
  42. </div>
  43. </div>
  44. <div class="form-group row">
  45. <label class="col-md-2 control-label">房间类型:</label>
  46. <div class="col-md-8 ">
  47. <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"/>
  48. </div>
  49. </div>
  50. <div class="form-group row">
  51. <label class="col-md-2 control-label">URL:</label>
  52. <div class="col-md-8 ">
  53. <input class="form-control" type="text" id="url_addr" name="url_addr" value="<?php if(!empty($edit)): echo ($edit["url"]); else: endif; ?>" required="required"/>
  54. </div>
  55. </div>
  56. <!--
  57. <div class="form-group row">
  58. <label class="col-md-2 control-label">price:</label>
  59. <div class="col-md-8 ">
  60. <input class="form-control" type="text" id="price" name="price" value="<?php if(!empty($edit)): echo ($edit["room_price"]); else: endif; ?>" required="required"
  61. onkeyup="clearNoNum(this)" maxlength="8"/>
  62. </div>
  63. </div>
  64. -->
  65. <div class="form-group row">
  66. <label class="col-md-2 control-label">有无早餐:</label>
  67. <div class="col-md-4 control-label">
  68. <?php if(!empty($edit)): if($edit["breakfast"] == 0): ?><label ><input name="breakfast" type="radio" checked="checked" value="0" onclick="fn(0)"/>无早</label>
  69. <label ><input name="breakfast" type="radio" value="1" onclick="fn(1)"/>单早</label>
  70. <label ><input name="breakfast" type="radio" value="2" onclick="fn(2)"/>双早</label>
  71. <label ><input name="breakfast" type="radio" value="3" onclick="fn(3)"/>三早</label>
  72. <?php elseif($edit["breakfast"] == 1): ?>
  73. <label ><input name="breakfast" type="radio" value="0" onclick="fn(0)"/>无早</label>
  74. <label ><input name="breakfast" type="radio" checked="checked" value="1" onclick="fn(1)"/>单早</label>
  75. <label ><input name="breakfast" type="radio" value="2" onclick="fn(2)"/>双早</label>
  76. <label ><input name="breakfast" type="radio" value="3" onclick="fn(3)"/>三早</label>
  77. <?php elseif($edit["breakfast"] == 2): ?>
  78. <label ><input name="breakfast" type="radio" value="0" onclick="fn(0)"/>无早</label>
  79. <label ><input name="breakfast" type="radio" value="1" onclick="fn(1)"/>单早</label>
  80. <label ><input name="breakfast" type="radio" checked="checked" value="2" onclick="fn(2)"/>双早</label>
  81. <label ><input name="breakfast" type="radio" value="3" onclick="fn(3)"/>三早</label>
  82. <?php elseif($edit["breakfast"] == 3): ?>
  83. <label ><input name="breakfast" type="radio" value="0" onclick="fn(0)"/>无早</label>
  84. <label ><input name="breakfast" type="radio" value="1" onclick="fn(1)"/>单早</label>
  85. <label ><input name="breakfast" type="radio" value="2" onclick="fn(2)"/>双早</label>
  86. <label ><input name="breakfast" type="radio" checked="checked" value="3" onclick="fn(3)"/>三早</label>
  87. <?php else: ?>
  88. <label ><input name="breakfast" type="radio" checked="checked" value="0" onclick="fn(0)"/>无早</label>
  89. <label ><input name="breakfast" type="radio" value="1" onclick="fn(1)"/>单早</label>
  90. <label ><input name="breakfast" type="radio" value="2" onclick="fn(2)"/>双早</label>
  91. <label ><input name="breakfast" type="radio" value="3" onclick="fn(3)"/>三早</label><?php endif; ?>
  92. <?php else: ?>
  93. <label ><input name="breakfast" type="radio" checked="checked" value="0" onclick="fn(0)"/>无早</label>
  94. <label ><input name="breakfast" type="radio" value="1" onclick="fn(1)"/>单早</label>
  95. <label ><input name="breakfast" type="radio" value="2" onclick="fn(2)"/>双早</label>
  96. <label ><input name="breakfast" type="radio" value="3" onclick="fn(3)"/>三早</label><?php endif; ?>
  97. </div>
  98. </div>
  99. <div class="form-group row">
  100. <label class="col-md-2 control-label">price:</label>
  101. <div class="col-md-8 ">
  102. <table class="table table-hover">
  103. <thead class="navbar-inner">
  104. <tr>
  105. <th>时间</th>
  106. <th>价格</th>
  107. <th>时间</th>
  108. <th>价格</th>
  109. </tr>
  110. </thead>
  111. <tbody id="price_table">
  112. </tbody>
  113. </table>
  114. </div>
  115. </div>
  116. <div class="form-group row">
  117. <div class="col-md-5">
  118. </div>
  119. <div class="col-md-2">
  120. <input class="form-control" type="button" value="保存" onclick="save()"></input>
  121. </div>
  122. </div>
  123. </div>
  124. <!-- </form>-->
  125. </div>
  126. </div>
  127. </body>
  128. <script type="text/javascript" src="/monitor/Public/js/json2.js"></script>
  129. <script type="text/javascript" src="/monitor/Public/js/jquery.1.11.js"></script>
  130. <script type="text/javascript">
  131. var breakfast=0;
  132. var arrayTime = new Array();
  133. var myDate = new Date();
  134. function load(){
  135. for(var i=0; i<30; i++){
  136. var year = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
  137. var month = myDate.getMonth()+1; //获取当前月份(0-11,0代表1月)
  138. var dd = myDate.getDate(); //获取当前日(1-31)
  139. var str = year+"-"+month+"-"+dd;
  140. var week = myDate.getDay(); //星期
  141. //判断星期几
  142. var weeks = ["日","一","二","三","四","五","六"];
  143. var getWeek = "(星期" + weeks[week]+")";
  144. arrayTime[i] = new Array();
  145. arrayTime[i][0] = str;
  146. arrayTime[i][1] = '';
  147. arrayTime[i][2] = getWeek;
  148. myDate.setDate(myDate.getDate()-0+1);
  149. }
  150. myDate = new Date(); //时间归位
  151. var s='';
  152. for(var j=0; j<arrayTime.length; j=j-0+2){
  153. s+='<tr>';
  154. s+='<th id="time_'+j+'">'+arrayTime[j][0]+arrayTime[j][2]+'</th>';
  155. s+='<th><input id="price_'+j+'" value="'+arrayTime[j][1]+'" onkeyup="clearNoNum(this)" maxlength="8"></input></th>';
  156. var k = j-0+1;
  157. s+='<th id="time_'+k+'">'+arrayTime[k][0]+arrayTime[k][2]+'</th>';
  158. s+='<th><input id="price_'+k+'" value="'+arrayTime[k][1]+'" onkeyup="clearNoNum(this)" maxlength="8"></input></th>';
  159. s+='</tr>';
  160. }
  161. document.getElementById('price_table').innerHTML = s;
  162. var edit = '<?php echo ($edit); ?>';
  163. if(edit){
  164. breakfast='<?php echo ($edit["breakfast"]); ?>';
  165. }else{
  166. breakfast=0;
  167. }
  168. }
  169. function save(){
  170. var id = $("#id").val();
  171. var site_name = $("#site_name").val();
  172. site_name = site_name.replace(/(^\s*)|(\s*$)/g, "");
  173. var hotel_name = $("#hotel_name").val();
  174. hotel_name = hotel_name.replace(/(^\s*)|(\s*$)/g, "");
  175. var room_type = $("#room_type").val();
  176. room_type = room_type.replace(/(^\s*)|(\s*$)/g, "");
  177. var url_addr = $("#url_addr").val();
  178. url_addr = url_addr.replace(/(^\s*)|(\s*$)/g, "");
  179. var p='';
  180. for(var i=0; i<30; i++){
  181. var price = $("#price_"+i).val();
  182. price = price.replace(/(^\s*)|(\s*$)/g, "");
  183. if(!price || price == ''){
  184. }else{
  185. if(!p || p == ''){
  186. p += arrayTime[i][0] +"P"+price;
  187. }else{
  188. p += "|"+arrayTime[i][0] +"P"+price;
  189. }
  190. }
  191. }
  192. if(!hotel_name || hotel_name == ''){
  193. alert("酒店名称不能为空");
  194. return;
  195. }
  196. if(!room_type || room_type == ''){
  197. alert("房间类型不能为空");
  198. return;
  199. }
  200. if(!url_addr || url_addr == ''){
  201. alert("url地址不能为空");
  202. return;
  203. }
  204. if(!p || p == ''){
  205. alert("价格不能为空");
  206. return;
  207. }
  208. var posturl='/monitor/index.php/Monitor/monitorAdd';
  209. $.ajax({
  210. type: 'POST',
  211. url: posturl,
  212. data: {
  213. id: id,
  214. site_name: site_name,
  215. hotel_name: hotel_name,
  216. room_type: room_type,
  217. url_addr: url_addr,
  218. price: p,
  219. breakfast: breakfast
  220. },
  221. dataType: 'json',
  222. context: $('body'),
  223. success: function (data) {
  224. alert(data.errorInfo);
  225. },
  226. error: function (xhr, type) {
  227. var data = $.parseJSON(xhr.responseText);
  228. alert(data.message);
  229. }
  230. });
  231. }
  232. function clearNoNum(obj){
  233. //先把非数字的都替换掉,除了数字和.
  234. obj.value = obj.value.replace(/[^\d.]/g,"");
  235. //必须保证第一个为数字而不是.
  236. obj.value = obj.value.replace(/^\./g,"");
  237. //保证只有出现一个.而没有多个.
  238. obj.value = obj.value.replace(/\.{2,}/g,".");
  239. //保证.只出现一次,而不能出现两次以上
  240. obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
  241. }
  242. function fn(v){
  243. breakfast=v;
  244. }
  245. </script>
  246. </html>