PageRenderTime 62ms CodeModel.GetById 14ms app.highlight 43ms RepoModel.GetById 0ms app.codeStats 1ms

/source/gl/realtime/real_time_xyj.php

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