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.
 
 
 
 
 
 

305 lines
11 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. <script type="text/javascript" src="/monitor/Public/js/json2.js"></script>
  9. <script type="text/javascript" src="/monitor/Public/js/jquery.1.11.js"></script>
  10. <script type="text/javascript">
  11. function saveAll(){
  12. var str = '<?php echo ($json); ?>';
  13. var list = eval(str);
  14. var p='';
  15. for (var i=0; i<list.length; i++){
  16. var id = list[i].id;
  17. var price1 = list[i].room_price;
  18. var price2 = $("#price_"+id).val();
  19. if(Math.abs(price1 - price2) > 1e-6 || Math.abs(price2 - price1) > 1e-6){
  20. if(!p || p == ''){
  21. p += price2 +"P"+id;
  22. }else{
  23. p += "|"+price2 +"P"+id;
  24. }
  25. }
  26. }
  27. if(!p || p == ''){
  28. return;
  29. }
  30. var r=confirm("确认批量保存!")
  31. if (r==true){
  32. var geturl='/monitor/index.php/Monitor/monitorSaveAll';
  33. $.ajax({
  34. type: 'GET',
  35. url: geturl,
  36. data: {
  37. price: p
  38. },
  39. dataType: 'json',
  40. context: $('body'),
  41. success: function (data) {
  42. alert(data.info);
  43. },
  44. error: function (xhr, type) {
  45. var data = $.parseJSON(xhr.responseText);
  46. alert(data.message);
  47. }
  48. });
  49. }else{
  50. }
  51. }
  52. function priceAll(){
  53. var str = '<?php echo ($json); ?>';
  54. var list = eval(str);
  55. var arr = new Array();
  56. var items = document.getElementsByName("Fruit");
  57. for (i = 0; i < items.length; i++) {
  58. if (items[i].checked) {
  59. arr.push(items[i].value);
  60. }
  61. }
  62. if(arr.length <= 0){
  63. alert("请选择星期");
  64. return;
  65. }
  66. var price = $("#priceAll").val();
  67. if(!price || price == ''){
  68. alert("价格不能为空");
  69. return;
  70. }
  71. var p='';
  72. for (var i=0; i<list.length; i++){
  73. var id = list[i].id;
  74. for(var j=0; j<arr.length; j++){
  75. if(parseInt(arr[j]) == parseInt(list[i].dwk)){
  76. if(!p || p == ''){
  77. p += price +"P"+id;
  78. }else{
  79. p += "|"+price +"P"+id;
  80. }
  81. }
  82. }
  83. }
  84. if(!p || p == ''){
  85. alert("价格不能为空");
  86. return;
  87. }
  88. var r=confirm("确认批量保存!")
  89. if (r==true){
  90. var geturl='/monitor/index.php/Monitor/monitorSaveAll';
  91. $.ajax({
  92. type: 'GET',
  93. url: geturl,
  94. data: {
  95. price: p
  96. },
  97. dataType: 'json',
  98. context: $('body'),
  99. success: function (data) {
  100. alert(data.info);
  101. },
  102. error: function (xhr, type) {
  103. var data = $.parseJSON(xhr.responseText);
  104. alert(data.message);
  105. }
  106. });
  107. }else{
  108. }
  109. }
  110. function save(id){
  111. var price = $("#price_"+id).val();
  112. var geturl='/monitor/index.php/Monitor/monitorSave';
  113. $.ajax({
  114. type: 'GET',
  115. url: geturl,
  116. data: {
  117. id: id,
  118. price: price
  119. },
  120. dataType: 'json',
  121. context: $('body'),
  122. success: function (data) {
  123. alert(data.info);
  124. },
  125. error: function (xhr, type) {
  126. var data = $.parseJSON(xhr.responseText);
  127. alert(data.message);
  128. }
  129. });
  130. }
  131. function del(id){
  132. var r=confirm("确认删除!")
  133. if (r==true){
  134. var geturl='/monitor/index.php/Monitor/monitorDelete';
  135. $.ajax({
  136. type: 'GET',
  137. url: geturl,
  138. data: {
  139. id: id
  140. },
  141. dataType: 'json',
  142. context: $('body'),
  143. success: function (data) {
  144. if(data.errorCode == 0){
  145. location.reload(true);
  146. }else{
  147. alert(data.info);
  148. }
  149. },
  150. error: function (xhr, type) {
  151. var data = $.parseJSON(xhr.responseText);
  152. alert(data.message);
  153. }
  154. });
  155. }else{
  156. }
  157. }
  158. function clearNoNum(obj){
  159. //先把非数字的都替换掉,除了数字和.
  160. obj.value = obj.value.replace(/[^\d.]/g,"");
  161. //必须保证第一个为数字而不是.
  162. obj.value = obj.value.replace(/^\./g,"");
  163. //保证只有出现一个.而没有多个.
  164. obj.value = obj.value.replace(/\.{2,}/g,".");
  165. //保证.只出现一次,而不能出现两次以上
  166. obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
  167. }
  168. </script>
  169. </head>
  170. <body>
  171. <div class="panel panel-default" style="width: 1348px;">
  172. <div class="panel-heading">
  173. <div class="row">
  174. <div class="col-sm-10">
  175. <h2 class="panel-title padding_title">极速比价</h2>
  176. </div>
  177. <div class="col-sm-2">
  178. </div>
  179. </div>
  180. </div>
  181. <div class="panel-body">
  182. <form class="form-horizontal" action="/monitor/index.php/monitor/priceList" method="get">
  183. <div class="form-group">
  184. <div class="row">
  185. <label class="col-md-1 control-label">网站:</label>
  186. <div class="col-md-2">
  187. <select class="form-control" id="site" name="site_name">
  188. <?php if(is_array($site)): foreach($site as $key=>$vo): if($site_name == $vo['id']): if(($vo["id"] == 12) OR ($vo["id"] == 19)): ?><option value="<?php echo ($vo["id"]); ?>" selected="selected" ><?php echo ($vo["site_name"]); ?>(开发中)</option>
  189. <?php else: ?>
  190. <option value="<?php echo ($vo["id"]); ?>" selected="selected" ><?php echo ($vo["site_name"]); ?></option><?php endif; ?>
  191. <?php else: ?>
  192. <?php if(($vo["id"] == 12) OR ($vo["id"] == 19)): ?><option value="<?php echo ($vo["id"]); ?>" ><?php echo ($vo["site_name"]); ?>(开发中)</option>
  193. <?php else: ?>
  194. <option value="<?php echo ($vo["id"]); ?>" ><?php echo ($vo["site_name"]); ?></option><?php endif; endif; endforeach; endif; ?>
  195. </select>
  196. </div>
  197. <label class="col-md-1 control-label">酒店名称:</label>
  198. <input type="text" name="hotel_name" class="col-md-2 form-control" style ="display: inline; width: inherit;" placeholder="酒店名称" <?php if(!empty($hotel_name)): ?>value="<?php echo ($hotel_name); ?>"<?php endif; ?>/>
  199. <label class="col-md-1 control-label">房间类型:</label>
  200. <input type="text" name="room_type" class="col-md-2 form-control" style ="display: inline; width: inherit;" placeholder="房间类型" <?php if(!empty($room_type)): ?>value="<?php echo ($room_type); ?>"<?php endif; ?>/>
  201. <label class="col-md-1 control-label">早餐:</label>
  202. <div class="col-md-2">
  203. <select class="form-control" id="breakfast_type" name="breakfast_type">
  204. <option value="-1" selected="selected" >所有</option>
  205. <?php if($breakfast == 0): ?><option value="0" selected="selected" >无早</option>
  206. <?php else: ?>
  207. <option value="0">无早</option><?php endif; ?>
  208. <?php if($breakfast == 1): ?><option value="1" selected="selected" >单早</option>
  209. <?php else: ?>
  210. <option value="1">单早</option><?php endif; ?>
  211. <?php if($breakfast == 2): ?><option value="2" selected="selected" >双早</option>
  212. <?php else: ?>
  213. <option value="2">双早</option><?php endif; ?>
  214. <?php if($breakfast == 3): ?><option value="3" selected="selected" >三早</option>
  215. <?php else: ?>
  216. <option value="3">三早</option><?php endif; ?>
  217. </select>
  218. </div>
  219. </div>
  220. <div class="row" style ="margin-top:30px; margin-left:5px">
  221. <label class="col-md-1 control-label">开始日期:</label>
  222. <input type="date" name="start_time" class="col-md-2 form-control" style ="display: inline; width: inherit;"
  223. <?php if(!empty($start_time)): ?>value="<?php echo ($start_time); ?>"<?php endif; ?>/>
  224. <label class="col-md-1 control-label" style ="margin-left:20px">结束日期:</label>
  225. <input type="date" name="end_time" class="col-md-2 form-control" style ="display: inline; width: inherit;"
  226. <?php if(!empty($end_time)): ?>value="<?php echo ($end_time); ?>"<?php endif; ?>/>
  227. <label class="col-md-1 control-label">数据类型:</label>
  228. <div class="col-md-2">
  229. <select class="form-control" id="date_type" name="date_type">
  230. <?php if($date_type == 0): ?><option value="0" selected="selected" >劣势价格</option>
  231. <option value="1">其他价格</option>
  232. <?php elseif($date_type == 1): ?>
  233. <option value="0">劣势价格</option>
  234. <option value="1" selected="selected">其他价格</option>
  235. <?php else: ?>
  236. <option value="0" selected="selected" >劣势价格</option>
  237. <option value="1">其他价格</option><?php endif; ?>
  238. </select>
  239. </div>
  240. <div class="col-md-1">
  241. <button type="submit" class="btn btn-default">查询</button>
  242. </div>
  243. <div class="col-md-1">
  244. <a class="btn btn-default" onclick="saveAll()">一键保存</a>
  245. </div>
  246. </div>
  247. </div>
  248. </form>
  249. <div class="row">
  250. <label class="col-md-1"><input name="Fruit" type="checkbox" value="0" />星期日 </label>
  251. <label class="col-md-1"><input name="Fruit" type="checkbox" value="1" />星期一 </label>
  252. <label class="col-md-1"><input name="Fruit" type="checkbox" value="2" />星期二</label>
  253. <label class="col-md-1"><input name="Fruit" type="checkbox" value="3" />星期三 </label>
  254. <label class="col-md-1"><input name="Fruit" type="checkbox" value="4" />星期四</label>
  255. <label class="col-md-1"><input name="Fruit" type="checkbox" value="5" />星期五</label>
  256. <label class="col-md-1"><input name="Fruit" type="checkbox" value="6" />星期六 </label>
  257. <input class="col-md-2" id="priceAll" onkeyup="clearNoNum(this)" maxlength="8" value=""></input>
  258. <div class="col-md-1"><a class="btn btn-default" onclick="priceAll()">批量修改</a></div>
  259. </div>
  260. <table class="table table-hover" >
  261. <thead class="navbar-inner">
  262. <tr>
  263. <th>ID</th>
  264. <th>网站名称</th>
  265. <th>酒店名称</th>
  266. <th>房间类型</th>
  267. <th>有/无早餐</th>
  268. <th>查询时间</th>
  269. <th>本地价格</th>
  270. <th>网站价格</th>
  271. <th>保存</th>
  272. <th>删除</th>
  273. </tr>
  274. </thead>
  275. <tbody>
  276. <?php if(is_array($list)): foreach($list as $key=>$vo): ?><tr>
  277. <td><?php echo ($vo["id"]); ?></td>
  278. <td><?php echo ($vo["site_name"]); ?></td>
  279. <td><a href="<?php echo ($vo["url"]); ?>"><?php echo ($vo["hotel_name"]); ?></a></td>
  280. <td><?php echo ($vo["room_type"]); ?></td>
  281. <?php if(($vo["breakfast"] == 0)): ?><td>无早</td>
  282. <?php elseif(($vo["breakfast"] == 1)): ?>
  283. <td>单早</td>
  284. <?php elseif(($vo["breakfast"] == 2)): ?>
  285. <td>双早</td>
  286. <?php elseif(($vo["breakfast"] == 3)): ?>
  287. <td>三早</td>
  288. <?php else: ?>
  289. <td>无早</td><?php endif; ?>
  290. <td><?php echo ($vo["query_date"]); ?></script></td>
  291. <td><input id="price_<?php echo ($vo["id"]); ?>" style="color:red" onkeyup="clearNoNum(this)" maxlength="8" value="<?php echo ($vo["room_price"]); ?>"></input></td>
  292. <td><?php echo ($vo["site_price"]); ?></td>
  293. <td><a onclick="save(<?php echo ($vo["id"]); ?>)">保存</a></td>
  294. <td><a onclick="del(<?php echo ($vo["id"]); ?>)">删除</a></td>
  295. </tr><?php endforeach; endif; ?>
  296. </tbody>
  297. </table>
  298. </div>
  299. </div>
  300. </body>
  301. </html>