/source/gl/realtime/real_time_xsj.php

http://prosporous.googlecode.com/ · PHP · 598 lines · 532 code · 46 blank · 20 comment · 54 complexity · 653404b8d73fd2df1427360fa1918df5 MD5 · raw file

  1. <?php
  2. header ( "Content-type: text/html; charset= UTF-8" );
  3. require_once '../../includes/global.php';
  4. //error_reporting(E_ALL);
  5. $real_time_table = 'se_price';
  6. $time_field = 'date';
  7. $num_field = 'price';
  8. $bdid = $_GET ['bdid'];
  9. $bdb = $_GET ['tid'];
  10. switch ($_GET ['op']) {
  11. case 'next' :
  12. $temp_ts = $_GET ['ts'];
  13. $temp_month = date ( "n", $temp_ts ) + 1;
  14. $temp_year = date ( 'Y', $temp_ts );
  15. $timestamp = mktime ( 0, 0, 0, $temp_month, 1, $temp_year );
  16. break;
  17. case 'last' :
  18. $temp_ts = $_GET ['ts'];
  19. $temp_month = date ( "n", $temp_ts ) - 1;
  20. $temp_year = date ( 'Y', $temp_ts );
  21. $timestamp = mktime ( 0, 0, 0, $temp_month, 1, $temp_year );
  22. break;
  23. case 'forward' :
  24. $timestamp = mktime ( 0, 0, 0, $_GET ['month'], 1, $_GET ['year'] );
  25. break;
  26. case 'week' :
  27. $arr = explode ( '-', $_GET ['startWeekDate'] );
  28. $s_year = $arr [0];
  29. $s_month = $arr [1];
  30. $s_day = $arr [2];
  31. $arr = explode ( '-', $_GET ['endWeekDate'] );
  32. $e_year = $arr [0];
  33. $e_month = $arr [1];
  34. $e_day = $arr [2];
  35. $s_ts = mktime ( 0, 0, 0, $s_month, $s_day, $s_year );
  36. $e_ts = mktime ( 0, 0, 0, $e_month, $e_day, $e_year );
  37. $var_week_num = $_GET ['week_num'];
  38. // echo count($var_week_num);
  39. for($i = 0; $i < count ( $var_week_num ); $i ++) {
  40. if (isset ( $var_week_num [$i] ) && (! empty ( $var_week_num [$i] ) || $var_week_num [$i] == 0) && $var_week_num [$i] != '') {
  41. $save_week [] = $i;
  42. $save_num1 [] = $var_week_num [$i];
  43. }
  44. }
  45. // print_r($save_week);
  46. // print_r($save_num1);
  47. for($var_ts = $s_ts; $var_ts <= $e_ts; $var_ts += 86400) {
  48. for($i = 0; $i < count ( $save_week ); $i ++) {
  49. if (date ( 'w', $var_ts ) == $save_week [$i]) {
  50. $save_date [] = $var_ts;
  51. $save_num [] = $save_num1 [$i];
  52. }
  53. }
  54. }
  55. // print_r($save_date);
  56. // print_r($save_num);
  57. $gid = bic ();
  58. for($i = 0; $i < count ( $save_date ); $i ++) {
  59. $read_info = Dz ( "select * from " . $real_time_table . " where bdid=" . $bdid . " and " . $time_field . "=" . $save_date [$i] . " and del!=1" );
  60. if (count ( $read_info ) != 0) {
  61. $read_info = Dz ( "UPDATE " . $real_time_table . " SET " . $num_field . "='" . $save_num [$i] . "' WHERE bdid=" . $bdid . " and " . $time_field . "=" . $save_date [$i] . " AND del!=1" );
  62. } else {
  63. $read_info = Dz ( "INSERT INTO " . $real_time_table . " (" . $time_field . "," . $num_field . ",gid,bdb,bdid)
  64. VALUES (" . $save_date [$i] . ",'" . $save_num [$i] . "','" . $gid . "','" . $bdb . "','" . $bdid . "')" );
  65. }
  66. }
  67. $timestamp = time ();
  68. break;
  69. case 'span' :
  70. $arr = explode ( '-', $_GET ['startWeekDate'] );
  71. $s_year = $arr [0];
  72. $s_month = $arr [1];
  73. $s_day = $arr [2];
  74. $arr = explode ( '-', $_GET ['endWeekDate'] );
  75. $e_year = $arr [0];
  76. $e_month = $arr [1];
  77. $e_day = $arr [2];
  78. $s_ts = mktime ( 0, 0, 0, $s_month, $s_day, $s_year );
  79. $e_ts = mktime ( 0, 0, 0, $e_month, $e_day, $e_year );
  80. //$save_default_num = $_GET [default_num];
  81. for($var_ts = $s_ts; $var_ts <= $e_ts; $var_ts += 86400) {
  82. $save_date [] = $var_ts;
  83. $save_num [] = $save_default_num;
  84. }
  85. // print_r($save_date);
  86. // print_r($save_num);
  87. $gid = bic ();
  88. for($i = 0; $i < count ( $save_date ); $i ++) {
  89. $read_info = Dz ( "select * from " . $real_time_table . " where bdid=" . $bdid . " and " . $time_field . "=" . $save_date [$i] . " and del!=1" );
  90. if (count ( $read_info ) != 0) {
  91. $read_info = Dz ( "UPDATE " . $real_time_table . " SET " . $num_field . "='" . $save_num [$i] . "' WHERE bdid=" . $bdid . " and " . $time_field . "=" . $save_date [$i] . " AND del!=1" );
  92. } else {
  93. $read_info = Dz ( "INSERT INTO " . $real_time_table . " (" . $time_field . "," . $num_field . ",gid,bdb,bdid)
  94. VALUES (" . $save_date [$i] . ",'" . $save_num [$i] . "','" . $gid . "','" . $bdb . "','" . $bdid . "')" );
  95. }
  96. }
  97. $timestamp = time ();
  98. break;
  99. case 'moren' :
  100. //$save_default_num = $_GET [default_num];
  101. $save_year = $_GET ['year'];
  102. $save_month = $_GET ['month'];
  103. $read_info = Dz ( "select * from " . $real_time_table . " where bdid=" . $bdid . " and " . $time_field . "=1 and del!=1" );
  104. if (count ( $read_info ) != 0) {
  105. $read_info = Dz ( "UPDATE " . $real_time_table . " SET price='" . $save_default_num . "' WHERE bdid=" . $bdid . " and " . $time_field . "=1 AND del!=1" );
  106. } else {
  107. $read_info = Dz ( "INSERT INTO " . $real_time_table . " (" . $time_field . "," . $num_field . ",gid,bdb,bdid)
  108. VALUES (1,'" . $save_default_num . "','" . $gid . "','" . $bdb . "','" . $bdid . "')" );
  109. }
  110. $timestamp = mktime ( 0, 0, 0, $save_month, 1, $save_year );
  111. break;
  112. case 'save' :
  113. $var_num = $_GET ['num'];
  114. $save_year = $_GET ['year'];
  115. $save_month = $_GET ['month'];
  116. $read_info = Dz ( "select * from " . $real_time_table . " where bdid=" . $bdid . " and date=1 and del!=1" );
  117. $save_default_num = $read_info [0] ['price'];
  118. $save_date='';
  119. for($i = 1; $i < 32; $i ++) {
  120. if (isset ( $var_num [$i] ) && $var_num [$i] != '') {
  121. if ($var_num [$i] != $save_default_num) {
  122. $save_date [] = mktime ( 0, 0, 0, $save_month, $i, $save_year );
  123. $save_num [] = $var_num [$i];
  124. $save_room [] = $var_num [$i.'_room'];
  125. } else {
  126. $del_date = mktime ( 0, 0, 0, $save_month, $i, $save_year );
  127. $exe = Dz ( "UPDATE " . $real_time_table . " SET del=1 WHERE date=" . $del_date . " and bdid=" . $bdid );
  128. }
  129. }
  130. }
  131. //Jc($save_date);
  132. //Jc($save_num);
  133. //Jc($save_room);
  134. for($i = 0; $i < count ( $save_date ); $i ++) {
  135. $read_info = Dz ( "select * from " . $real_time_table . " where bdid=" . $bdid . " and " . $time_field . "=" . $save_date [$i] . " and del!=1" );
  136. if ( $read_info != '') {
  137. $read_info = Dz ( "UPDATE " . $real_time_table . " SET " . $num_field . "='" . $save_num [$i] . "',room=".$save_room[$i]." WHERE bdid=" . $bdid . " and " . $time_field . "=" . $save_date [$i] . " AND del!=1" );
  138. } else {
  139. $gid = bic ();
  140. $read_info = Dz ( "INSERT INTO " . $real_time_table . " (" . $time_field . "," . $num_field . ",room,gid,bdb,bdid)
  141. VALUES (" . $save_date [$i] . ",'" . $save_num [$i] . "',".$save_room[$i].",'" . $gid . "','" . $bdb . "','" . $bdid . "')" );
  142. }
  143. }
  144. /**
  145. * ???????
  146. */
  147. $min=Dga('price',"del!=1 and bdid='{$bdid}' and price!=0 order by price");
  148. $hotel_room=Dga('hotel_room',"gid='{$bdid}'");
  149. $hotel=Dga('hotel',"gid='{$hotel_room['bdid']}'");
  150. $room=Dz("select gid from lm_hotel_room where 1 and del!=1 {$city} and bdid like '{$hotel['gid']}'");
  151. $gid=array();
  152. foreach($room as $room_val){
  153. $gid[]='"'.$room_val['gid'].'"';
  154. //$gid=$gid==''?$room_val['gid']:','.$room_val['gid'];
  155. }
  156. $gid=implode(',',$gid);
  157. $date=strtotime(date("Y-m-d"));
  158. $price=Dga('price',"del!=1 and bdid in ({$gid})");
  159. $lowerPrice['lowerPrice']=$price['price'];
  160. Du('hotel_room',$lowerPrice,'id',$hotel_room['id']);
  161. Du('hotel',$lowerPrice,'gid',$hotel_room['bdid']);
  162. $timestamp = mktime ( 0, 0, 0, $save_month, 1, $save_year );
  163. break;
  164. default :
  165. $timestamp = time ();
  166. }
  167. $today_year = date ( 'Y', time () );
  168. $today_month = date ( 'n', time () );
  169. $today_day = date ( 'j', time () );
  170. $today_week = date ( 'w', time () );
  171. $the_year = date ( 'Y', $timestamp );
  172. $the_month = date ( 'n', $timestamp );
  173. $month_days = date ( 't', $timestamp );
  174. $begin_week = date ( "w", mktime ( 0, 0, 0, $the_month, 1, $the_year ) );
  175. $month_s = mktime ( 0, 0, 0, $the_month, 1, $the_year );
  176. $month_e = mktime ( 0, 0, 0, $the_month, $month_days, $the_year );
  177. $read_info = Dz ( "select * from " . $real_time_table . " where bdid=" . $bdid . " and " . $time_field . ">=" . $month_s . " and " . $time_field . "<=" . $month_e . " and del!=1" );
  178. $common_num = Dz ( "select * from " . $real_time_table . " where bdid=" . $bdid . " and " . $time_field . "=1 and del!=1" );
  179. for($i = 0; $i < count ( $read_info ); $i ++) {
  180. $var_read_day = date ( 'j', $read_info [$i] [$time_field] );
  181. $read_day [] = $var_read_day;
  182. $read_num [] = $read_info [$i] [$num_field];
  183. $room_num [] = $read_info [$i] ['room'];
  184. }
  185. // print_r($read_day);
  186. // print_r($read_num);
  187. //Jc($room_num);
  188. ?>
  189. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  190. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
  191. <head>
  192. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  193. <title>Prosperous JIMU</title>
  194. <style>
  195. body {
  196. background-color: #666666;
  197. font-size: 14px;
  198. }
  199. div {
  200. background-color: #DFEBF7;
  201. padding: 50px;
  202. padding-top: 20px;
  203. width: 600px;
  204. }
  205. .th {
  206. font-size: 12px;
  207. width: 80px;
  208. height: 45px;
  209. border: #999999 1px solid;
  210. background: #5CCAFE;
  211. }
  212. em {
  213. font-size: 12px;
  214. width: 70px;
  215. padding: 0;
  216. height: 20px;
  217. line-height: 20px;
  218. font-style: normal;
  219. }
  220. .input {
  221. border: #CCCCCC 1px solid;
  222. line-height: 12px;
  223. height: 15px;
  224. padding: 0;
  225. }
  226. .can {
  227. border: #999999 1px solid;
  228. width: 450px;
  229. }
  230. .can2 {
  231. width: 450px;
  232. }
  233. .content {
  234. width: 500px;
  235. border: #666666 1px solid;
  236. padding: 5px;
  237. padding-left: 50px;
  238. padding-right: 50px;
  239. }
  240. .STYLE1 {
  241. color: #FF0000
  242. }
  243. .STYLE2 {
  244. color: #FF3300
  245. }
  246. </style>
  247. <script language="javascript" type="text/javascript"
  248. src="../../jimu/My97/WdatePicker.js"></script>
  249. </head>
  250. <body>
  251. <div>????
  252. <div class="content">
  253. <table class="can2" cellpadding="0" cellspacing="0">
  254. <tr style="font-size: 12px; vertical-align: middle;">
  255. <th colspan="4">
  256. <form action="real_time.php" method="GET" name="forward_month">
  257. <table class="can2" cellpadding="0" cellspacing="0">
  258. <tr style="font-size: 12px; vertical-align: middle;">
  259. <th align="center" colspan="3">???<?php
  260. echo $today_year . '? ' . $today_month . '? ' . $today_day . '? ' . '??' . $today_week?></th>
  261. <th colspan="4"><input type="hidden" name="op" value="forward" /> <input
  262. name="year" type="text" size="2" maxlength="6"
  263. value="<?php
  264. echo $today_year;
  265. ?>" /> ? <select name="month"
  266. onchange="document.forward_month.submit();">
  267. <?php
  268. for($i = 1; $i <= 12; $i ++) {
  269. if ($today_month == $i) {
  270. ?>
  271. <option
  272. value="<?php
  273. echo $i;
  274. ?>"
  275. selected="selected"><?php
  276. echo $i;
  277. ?></option>
  278. <?php
  279. } else {
  280. ?>
  281. <option
  282. value="<?php
  283. echo $i;
  284. ?>"><?php
  285. echo $i;
  286. ?></option>
  287. <?php
  288. }
  289. }
  290. ?>
  291. </select> ?<input type="hidden" name="bdid"
  292. value="<?php
  293. echo $_GET [bdid];
  294. ?>" /> <input type="hidden" name="bdb"
  295. value="<?php
  296. echo $_GET [bdb];
  297. ?>" /> <input type="submit" value="??" /></th>
  298. </tr>
  299. </table>
  300. </form>
  301. </th>
  302. </tr>
  303. </table>
  304. <br />
  305. ?????
  306. <div style="border: 1px #666666 solid; width: 450px; padding: 10px;">
  307. <form method="GET" action="real_time.php">
  308. <table class="can2" cellpadding="0" cellspacing="0">
  309. <tr style="height: 40px; font-size: 16px; vertical-align: text-top;">
  310. <th colspan="2"><a
  311. href="real_time.php?op=last&ts=<?php
  312. echo $timestamp;
  313. ?>&bdid=<?php
  314. echo $_GET [bdid];
  315. ?>&bdb=<?php
  316. echo $_GET [bdb];
  317. ?>"
  318. style="color: #FF3366;">???</a></th>
  319. <th colspan="3"><span><?php
  320. echo $the_year . "? " . $the_month . "?"?></span></th>
  321. <th colspan="2"><a
  322. href="real_time.php?op=next&ts=<?php
  323. echo $timestamp;
  324. ?>&bdid=<?php
  325. echo $_GET [bdid];
  326. ?>&bdb=<?php
  327. echo $_GET [bdb];
  328. ?>"
  329. style="color: #FF3366;">???</a></th>
  330. </tr>
  331. </table>
  332. <table class="can">
  333. <tr style="font-size: 12px; height: 30px;">
  334. <th><span class="STYLE1">???</span></th>
  335. <th>???</th>
  336. <th>???</th>
  337. <th>???</th>
  338. <th>???</th>
  339. <th>???</th>
  340. <th><span class="STYLE2">???</span></th>
  341. </tr>
  342. <input type="hidden" name="op" value="save" />
  343. <input type="hidden" name="month" value="<?php
  344. echo $the_month;
  345. ?>" />
  346. <input type="hidden" name="year" value="<?php
  347. echo $the_year;
  348. ?>" />
  349. <?php
  350. $var_day = 1;
  351. for($week_num = 0; $week_num < 6; $week_num ++) {
  352. ?>
  353. <tr class="tr">
  354. <?php
  355. for($week_i = 0; $week_i < 7; $week_i ++) {
  356. ?> <th class="th">
  357. <?php
  358. if (($week_num == 0 && $week_i < $begin_week) || intval ( $var_day ) > intval ( $month_days )) {
  359. ?> <em>&nbsp;</em> <i>&nbsp;</i>
  360. <?php
  361. } else {
  362. for($i = 0; $i <= count ( $read_day ); $i ++) {
  363. if ($read_day [$i] == $var_day) {
  364. $input_value = $read_num [$i];
  365. $room_value = $room_num [$i];
  366. break;
  367. } else {
  368. $input_value = $common_num [0] [$num_field];
  369. $room_value = 0;
  370. }
  371. }
  372. if ($week_i == 0) {
  373. ?>
  374. <em style="color: #FF0000">
  375. <?php
  376. echo $the_month . "-" . $var_day;
  377. ?>
  378. </em> <i><input class="input" type="text"
  379. name="num[<?php
  380. echo $var_day;
  381. ?>]"
  382. value="<?php
  383. echo $input_value;
  384. ?>"
  385. size="2" maxlength="6" /></i>
  386. <!-- ############### ?? ############### -->
  387. <i style="display:none;"><input class="input" type="text"
  388. name="num[<?php
  389. echo $var_day;
  390. ?>_room]"
  391. value="<?php
  392. echo $room_value;
  393. ?>"
  394. size="2" maxlength="6" /></i>
  395. <?php
  396. } else {
  397. ?> <em><?php
  398. echo $the_month . "-" . $var_day;
  399. ?></em> <i><input class="input" type="text"
  400. name="num[<?php
  401. echo $var_day;
  402. ?>]"
  403. value="<?php
  404. echo $input_value;
  405. ?>"
  406. size="2" maxlength="6" /></i>
  407. <!-- ############### ?? ############### -->
  408. <i style="display:none;"><input class="input" type="text"
  409. name="num[<?php
  410. echo $var_day;
  411. ?>_room]"
  412. value="<?php
  413. echo $room_value;
  414. ?>"
  415. size="2" maxlength="6" /></i>
  416. <?php
  417. }
  418. $var_day ++;
  419. }
  420. ?>
  421. </th>
  422. <?php
  423. }
  424. ?>
  425. </tr>
  426. <?php
  427. }
  428. ?>
  429. <tr style="height: 50px;">
  430. <th colspan="4"></th>
  431. <th colspan="2"><input type="hidden" name="bdid"
  432. value="<?php
  433. echo $_GET ['bdid'];
  434. ?>" /> <input type="hidden" name="bdb"
  435. value="<?php
  436. echo $_GET ['bdb'];
  437. ?>" /><input class="edit" type="submit" value="??" /></th>
  438. <th colspan="3"><input type="reset" value="??" /></th>
  439. </tr>
  440. </table>
  441. </form>
  442. <form action="real_time.php" method="get">
  443. <table class="can2">
  444. <!--<tr style="height: 40px;">
  445. <th colspan="5">???????<input type="text" name="default_num" size="3"
  446. maxlength="6" value="<?php
  447. echo $common_num [0] [$num_field];
  448. ?>" /></th>
  449. <th><input type="hidden" name="bdid"
  450. value="<?php
  451. echo $_GET ['bdid'];
  452. ?>" /> <input type="hidden" name="bdb"
  453. value="<?php
  454. echo $_GET ['bdb'];
  455. ?>" /><input type="hidden" name="op" value="moren" /><input
  456. type="hidden" name="month" value="<?php
  457. echo $the_month;
  458. ?>" /><input type="hidden" name="year"
  459. value="<?php
  460. echo $the_year;
  461. ?>" /> <input class="edit" type="submit" value="??" /></th>
  462. <th><input type="reset" value="??" /></th>
  463. </tr>-->
  464. </table>
  465. </form>
  466. </div>
  467. <br />
  468. ??????
  469. <div style="border: 1px #666666 solid; width: 450px; padding: 10px;">
  470. <form action="real_time.php" method="get"><input type="hidden" name="op"
  471. value="week" />
  472. <table class="can">
  473. <tr>
  474. <th class="th"><span class="STYLE1">???</span> <input class="input"
  475. type="text" name="week_num[0]" size="2" maxlength="6" /></th>
  476. <th class="th">???<input class="input" type="text" name="week_num[1]"
  477. size="2" maxlength="6" /></th>
  478. <th class="th">???<input class="input" type="text" name="week_num[2]"
  479. size="2" maxlength="6" /></th>
  480. <th class="th">???<input class="input" type="text" name="week_num[3]"
  481. size="2" maxlength="6" /></th>
  482. <th class="th">???<input class="input" type="text" name="week_num[4]"
  483. size="2" maxlength="6" /></th>
  484. <th class="th">???<input class="input" type="text" name="week_num[5]"
  485. size="2" maxlength="6" /></th>
  486. <th class="th"><span class="STYLE2">???</span> <input class="input"
  487. type="text" name="week_num[6]" size="2" maxlength="6" /></th>
  488. </tr>
  489. <tr>
  490. <th colspan="2">????:<input id="startWeekDate" name="startWeekDate"
  491. type="text" size="13" class="Wdate" style="text-align: center;"
  492. value="<?php
  493. echo date ( "Y-m-d" );
  494. ?>"
  495. onfocus="WdatePicker({isShowClear:false,readOnly:true})" /></th>
  496. <th colspan="2">????:<input id="endWeekDate" name="endWeekDate"
  497. type="text" size="13" class="Wdate" style="text-align: center;"
  498. value="<?php
  499. echo date ( "Y-m-d" );
  500. ?>"
  501. onfocus="WdatePicker({isShowClear:false,readOnly:true})" /></th>
  502. <th colspan="2"><input type="hidden" name="bdid"
  503. value="<?php
  504. echo $_GET ['bdid'];
  505. ?>" /> <input type="hidden" name="bdb"
  506. value="<?php
  507. echo $_GET ['bdb'];
  508. ?>" /> <input class="edit" type="submit" value="??" /></th>
  509. <th><input type="reset" value="??" /></th>
  510. </tr>
  511. </table>
  512. </form>
  513. </div>
  514. <br />
  515. ????????
  516. <div style="border: 1px #666666 solid; width: 450px; padding: 10px;">
  517. <form action="real_time.php" method="get"><input type="hidden" name="op"
  518. value="span" />
  519. <table>
  520. <tr>
  521. <th colspan="3">????:<input id="startWeekDate" name="startWeekDate"
  522. type="text" size="13" class="Wdate" style="text-align: center;"
  523. value="<?php
  524. echo date ( "Y-m-d" );
  525. ?>"
  526. onfocus="WdatePicker({isShowClear:false,readOnly:true})" /></th>
  527. <th colspan="3">????:<input id="endWeekDate" name="endWeekDate"
  528. type="text" size="13" class="Wdate" style="text-align: center;"
  529. value="<?php
  530. echo date ( "Y-m-d" );
  531. ?>"
  532. onfocus="WdatePicker({isShowClear:false,readOnly:true})" /></th>
  533. </tr>
  534. <tr>
  535. <th colspan="4">????<input type="text" name="default_num" size="4"
  536. maxlength="4" /></th>
  537. <th colspan="2"><input type="hidden" name="bdid"
  538. value="<?php
  539. echo $_GET ['bdid'];
  540. ?>" /> <input type="hidden" name="bdb"
  541. value="<?php
  542. echo $_GET ['bdb'];
  543. ?>" /> <input class="edit" type="submit" value="??" /></th>
  544. <th><input type="reset" value="??" /></th>
  545. </tr>
  546. </table>
  547. </form>
  548. </div>
  549. </div>
  550. </div>
  551. </body>
  552. </html>