/source/gl/show1/f/real_time.php

http://prosporous.googlecode.com/ · PHP · 531 lines · 480 code · 35 blank · 16 comment · 54 complexity · cf9bf9a87705c0ccfc73a537c9bed050 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. $bdtid = $_GET [bdtid];
  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,bdtid,bdid)
  64. VALUES (" . $save_date [$i] . ",'" . $save_num [$i] . "','" . $gid . "','" . $bdtid . "','" . $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,bdtid,bdid)
  94. VALUES (" . $save_date [$i] . ",'" . $save_num [$i] . "','" . $gid . "','" . $bdtid . "','" . $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,bdtid,bdid)
  108. VALUES (1,'" . $save_default_num . "','" . $gid . "','" . $bdtid . "','" . $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,1);
  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,bdtid,bdid)
  141. VALUES (" . $save_date [$i] . ",'" . $save_num [$i] . "'," . $save_room[$i] . ",'" . $gid . "','" . $bdtid . "','" . $bdid . "')");
  142. }
  143. }
  144. $timestamp = mktime(0, 0, 0, $save_month, 1, $save_year);
  145. break;
  146. default :
  147. $timestamp = time ();
  148. }
  149. $today_year = date('Y', time());
  150. $today_month = date('n', time());
  151. $today_day = date('j', time());
  152. $today_week = date('w', time());
  153. $the_year = date('Y', $timestamp);
  154. $the_month = date('n', $timestamp);
  155. $month_days = date('t', $timestamp);
  156. $begin_week = date("w", mktime(0, 0, 0, $the_month, 1, $the_year));
  157. $month_s = mktime(0, 0, 0, $the_month, 1, $the_year);
  158. $month_e = mktime(0, 0, 0, $the_month, $month_days, $the_year);
  159. $read_info = Dz("select * from " . $real_time_table . " where bdid=" . $bdid . " and " . $time_field . ">=" . $month_s . " and " . $time_field . "<=" . $month_e . " and del!=1");
  160. $common_num = Dz("select * from " . $real_time_table . " where bdid=" . $bdid . " and " . $time_field . "=1 and del!=1");
  161. for ($i = 0; $i < count($read_info); $i++) {
  162. $var_read_day = date('j', $read_info [$i] [$time_field]);
  163. $read_day [] = $var_read_day;
  164. $read_num [] = $read_info [$i] [$num_field];
  165. $room_num [] = $read_info [$i] ['room'];
  166. }
  167. // print_r($read_day);
  168. // print_r($read_num);
  169. //Jc($room_num);
  170. ?>
  171. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  172. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
  173. <head>
  174. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  175. <title>Prosperous JIMU</title>
  176. <style>
  177. *{
  178. margin:0;
  179. padding:0;
  180. }
  181. body {
  182. background-color: #666666;
  183. font-size: 14px;
  184. margin: 0 auto;
  185. padding: 0;
  186. }
  187. div {
  188. background-color: #DFEBF7;
  189. padding: 50px;
  190. padding-top: 20px;
  191. width: 600px;
  192. }
  193. .th {
  194. font-size: 12px;
  195. width: 80px;
  196. height: 45px;
  197. border: #999999 1px solid;
  198. background: #5CCAFE;
  199. }
  200. em {
  201. font-size: 12px;
  202. width: 70px;
  203. padding: 0;
  204. height: 20px;
  205. line-height: 20px;
  206. font-style: normal;
  207. }
  208. .input {
  209. border: #CCCCCC 1px solid;
  210. line-height: 12px;
  211. height: 15px;
  212. padding: 0;
  213. }
  214. .can {
  215. border: #999999 1px solid;
  216. width: 450px;
  217. }
  218. .can2 {
  219. width: 450px;
  220. }
  221. .content {
  222. width: 500px;
  223. border: #666666 1px solid;
  224. padding-left: 50px;
  225. padding-right: 50px;
  226. }
  227. .STYLE1 {
  228. color: #FF0000
  229. }
  230. .STYLE2 {
  231. color: #FF3300
  232. }
  233. </style>
  234. <script language="javascript" type="text/javascript" src="../../Plug-in/My97/WdatePicker.js"></script>
  235. </head>
  236. <body>
  237. <div>????
  238. <div class="content">
  239. <table class="can2" cellpadding="0" cellspacing="0" align="center">
  240. <tr style="font-size: 12px; vertical-align: middle;">
  241. <th colspan="4">
  242. <form action="real_time.php" method="GET" name="forward_month">
  243. <table class="can2" cellpadding="0" cellspacing="0">
  244. <tr style="font-size: 12px; vertical-align: middle;">
  245. <th align="center" colspan="3">???<?php echo $today_year . '? ' . $today_month . '? ' . $today_day . '? ' . '??' . $today_week ?></th>
  246. <th colspan="4"><input type="hidden" name="op" value="forward" /> <input
  247. name="year" type="text" size="2" maxlength="6"
  248. value="<?php
  249. echo $today_year;
  250. ?>" /> ? <select name="month"
  251. onchange="document.forward_month.submit();">
  252. <?php
  253. for ($i = 1; $i <= 12; $i++) {
  254. if ($today_month == $i) {
  255. ?>
  256. <option
  257. value="<?php
  258. echo $i;
  259. ?>"
  260. selected="selected"><?php
  261. echo $i;
  262. ?></option>
  263. <?php
  264. } else {
  265. ?>
  266. <option
  267. value="<?php
  268. echo $i;
  269. ?>"><?php
  270. echo $i;
  271. ?></option>
  272. <?php
  273. }
  274. }
  275. ?>
  276. </select> ?<input type="hidden" name="bdid"
  277. value="<?php
  278. echo $_GET [bdid];
  279. ?>" /> <input type="hidden" name="bdtid"
  280. value="<?php
  281. echo $_GET [bdtid];
  282. ?>" /> <input type="submit" value="??" /></th>
  283. </tr>
  284. </table>
  285. </form>
  286. </th>
  287. </tr>
  288. </table>
  289. <br />
  290. ?????
  291. <div style="border: 1px #666666 solid; width: 450px; padding: 10px;">
  292. <form method="GET" action="real_time.php">
  293. <table class="can2" cellpadding="0" cellspacing="0">
  294. <tr style="height: 40px; font-size: 16px; vertical-align: text-top;">
  295. <th colspan="2"><a
  296. href="real_time.php?op=last&ts=<?php
  297. echo $timestamp;
  298. ?>&bdid=<?php
  299. echo $_GET [bdid];
  300. ?>&bdtid=<?php
  301. echo $_GET [bdtid];
  302. ?>"
  303. style="color: #FF3366;">???</a></th>
  304. <th colspan="3"><span><?php echo $the_year . "? " . $the_month . "?" ?></span></th>
  305. <th colspan="2"><a
  306. href="real_time.php?op=next&ts=<?php
  307. echo $timestamp;
  308. ?>&bdid=<?php
  309. echo $_GET [bdid];
  310. ?>&bdtid=<?php
  311. echo $_GET [bdtid];
  312. ?>"
  313. style="color: #FF3366;">???</a></th>
  314. </tr>
  315. </table>
  316. <table class="can">
  317. <tr style="font-size: 12px; height: 30px;">
  318. <th><span class="STYLE1">???</span></th>
  319. <th>???</th>
  320. <th>???</th>
  321. <th>???</th>
  322. <th>???</th>
  323. <th>???</th>
  324. <th><span class="STYLE2">???</span></th>
  325. </tr>
  326. <input type="hidden" name="op" value="save" />
  327. <input type="hidden" name="month" value="<?php
  328. echo $the_month;
  329. ?>" />
  330. <input type="hidden" name="year" value="<?php
  331. echo $the_year;
  332. ?>" />
  333. <?php
  334. $var_day = 1;
  335. for ($week_num = 0; $week_num < 6; $week_num++) {
  336. ?>
  337. <tr class="tr">
  338. <?php for ($week_i = 0; $week_i < 7; $week_i++) {
  339. ?> <th class="th">
  340. <?php
  341. if (($week_num == 0 && $week_i < $begin_week) || intval($var_day) > intval($month_days)) {
  342. ?> <em>&nbsp;</em> <i>&nbsp;</i>
  343. <?php
  344. } else {
  345. for ($i = 0; $i <= count($read_day); $i++) {
  346. if ($read_day [$i] == $var_day) {
  347. $input_value = $read_num [$i];
  348. $room_value = $room_num [$i];
  349. break;
  350. } else {
  351. $input_value = $common_num [0] [$num_field];
  352. $room_value = 0;
  353. }
  354. }
  355. if ($week_i == 0) {
  356. ?>
  357. <em style="color: #FF0000">
  358. <?php
  359. echo $the_month . "-" . $var_day;
  360. ?>
  361. </em> <i><input class="input" type="text"
  362. name="num[<?php
  363. echo $var_day;
  364. ?>]"
  365. value="<?php
  366. echo $input_value;
  367. ?>"
  368. size="2" maxlength="6" /></i>
  369. <!-- ############### ?? ############### -->
  370. <i style="display:none;"><input class="input" type="text"
  371. name="num[<?php
  372. echo $var_day;
  373. ?>_room]"
  374. value="<?php
  375. echo $room_value;
  376. ?>"
  377. size="2" maxlength="6" /></i>
  378. <?php
  379. } else {
  380. ?> <em><?php
  381. echo $the_month . "-" . $var_day;
  382. ?></em> <i><input class="input" type="text"
  383. name="num[<?php
  384. echo $var_day;
  385. ?>]"
  386. value="<?php
  387. echo $input_value;
  388. ?>"
  389. size="2" maxlength="6" /></i>
  390. <!-- ############### ?? ############### -->
  391. <i style="display:none;"><input class="input" type="text"
  392. name="num[<?php
  393. echo $var_day;
  394. ?>_room]"
  395. value="<?php
  396. echo $room_value;
  397. ?>"
  398. size="2" maxlength="6" /></i>
  399. <?php
  400. }
  401. $var_day++;
  402. }
  403. ?>
  404. </th>
  405. <?php
  406. }
  407. ?>
  408. </tr>
  409. <?php
  410. }
  411. ?>
  412. <tr style="height: 50px;">
  413. <th colspan="4"></th>
  414. <th colspan="2"><input type="hidden" name="bdid"
  415. value="<?php echo $_GET [bdid];
  416. ?>" /> <input type="hidden" name="bdtid" value="<?php echo $_GET [bdtid];?>" /><input class="edit" type="submit" value="??" /></th>
  417. <th colspan="3"><input type="reset" value="??" /></th>
  418. </tr>
  419. </table>
  420. </form>
  421. <form action="real_time.php" method="get">
  422. <table class="can2">
  423. <!--<tr style="height: 40px;">
  424. <th colspan="5">???????<input type="text" name="default_num" size="3"
  425. maxlength="6" value="<?php
  426. echo $common_num [0] [$num_field];
  427. ?>" /></th>
  428. <th><input type="hidden" name="bdid"
  429. value="<?php
  430. echo $_GET [bdid];
  431. ?>" /> <input type="hidden" name="bdtid"
  432. value="<?php
  433. echo $_GET [bdtid];
  434. ?>" /><input type="hidden" name="op" value="moren" /><input
  435. type="hidden" name="month" value="<?php
  436. echo $the_month;
  437. ?>" /><input type="hidden" name="year"
  438. value="<?php
  439. echo $the_year;
  440. ?>" /> <input class="edit" type="submit" value="??" /></th>
  441. <th><input type="reset" value="??" /></th>
  442. </tr>-->
  443. </table>
  444. </form>
  445. </div>
  446. <br />
  447. ??????
  448. <div style="border: 1px #666666 solid; width: 450px; padding: 10px;">
  449. <form action="real_time.php" method="get"><input type="hidden" name="op"
  450. value="week" />
  451. <table class="can">
  452. <tr>
  453. <th class="th"><span class="STYLE1">???</span> <input class="input"
  454. type="text" name="week_num[0]" size="2" maxlength="6" /></th>
  455. <th class="th">???<input class="input" type="text" name="week_num[1]"
  456. size="2" maxlength="6" /></th>
  457. <th class="th">???<input class="input" type="text" name="week_num[2]"
  458. size="2" maxlength="6" /></th>
  459. <th class="th">???<input class="input" type="text" name="week_num[3]"
  460. size="2" maxlength="6" /></th>
  461. <th class="th">???<input class="input" type="text" name="week_num[4]"
  462. size="2" maxlength="6" /></th>
  463. <th class="th">???<input class="input" type="text" name="week_num[5]"
  464. size="2" maxlength="6" /></th>
  465. <th class="th"><span class="STYLE2">???</span> <input class="input"
  466. type="text" name="week_num[6]" size="2" maxlength="6" /></th>
  467. </tr>
  468. <tr>
  469. <th colspan="2">????:<input id="startWeekDate" name="startWeekDate"
  470. type="text" size="13" class="Wdate" style="text-align: center;"
  471. value="<?php
  472. echo date("Y-m-d");
  473. ?>"
  474. onfocus="WdatePicker({isShowClear:false,readOnly:true})" /></th>
  475. <th colspan="2">????:<input id="endWeekDate" name="endWeekDate"
  476. type="text" size="13" class="Wdate" style="text-align: center;"
  477. value="<?php
  478. echo date("Y-m-d");
  479. ?>"
  480. onfocus="WdatePicker({isShowClear:false,readOnly:true})" /></th>
  481. <th colspan="2"><input type="hidden" name="bdid"
  482. value="<?php
  483. echo $_GET [bdid];
  484. ?>" /> <input type="hidden" name="bdtid"
  485. value="<?php
  486. echo $_GET [bdtid];
  487. ?>" /> <input class="edit" type="submit" value="??" /></th>
  488. <th><input type="reset" value="??" /></th>
  489. </tr>
  490. </table>
  491. </form>
  492. </div>
  493. </div>
  494. </div>
  495. </body>
  496. </html>