PageRenderTime 85ms CodeModel.GetById 66ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

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