comparison Reservation.class.php @ 91:f6b909678e51

fix: CSとBSを合計するとチューナー数以上の重複予約が出来てしまうバグを修正
author Sushi-k <epgrec@park.mda.or.jp>
date Tue, 02 Mar 2010 17:42:30 +0900
parents 6eabffb0ccac
children e2c37cc736db f268d7d10590
comparison
equal deleted inserted replaced
86:c29d41d0c945 91:f6b909678e51
76 76
77 $crec = new DBRecord( CHANNEL_TBL, "id", $channel_id ); 77 $crec = new DBRecord( CHANNEL_TBL, "id", $channel_id );
78 78
79 // √篋膣 = TUNER 79 // √篋膣 = TUNER
80 $tuners = ($crec->type == "GR") ? $settings->gr_tuners : $settings->bs_tuners; 80 $tuners = ($crec->type == "GR") ? $settings->gr_tuners : $settings->bs_tuners;
81 $type_str = ($crec->type == "GR") ? "type = 'GR' " : "(type = 'BS' OR type = 'CS') ";
82
81 $battings = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' ". 83 $battings = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' ".
82 "AND type = '".$crec->type."' ". 84 "AND ".$type_str.
83 "AND starttime < '".toDatetime($end_time) ."' ". 85 "AND starttime < '".toDatetime($end_time) ."' ".
84 "AND endtime > '".toDatetime($rec_start)."'" 86 "AND endtime > '".toDatetime($rec_start)."'"
85 ); 87 );
86 88
87 if( $battings >= $tuners ) { 89 if( $battings >= $tuners ) {
88 // 茲肴 90 // 茲肴
89 if( $settings->force_cont_rec == 1 ) { 91 if( $settings->force_cont_rec == 1 ) {
90 // 茹f純茲茯帥鴻 92 // 茹f純茲茯帥鴻
91 // 緇篋膣 93 // 緇篋膣
92 $nexts = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' ". 94 $nexts = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' ".
93 "AND type = '".$crec->type."' ". 95 "AND ".$type_str.
94 "AND starttime = '".toDatetime($end_time - $settings->former_time)."'"); 96 "AND starttime = '".toDatetime($end_time - $settings->former_time)."'");
95 97
96 $prevs = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' ". 98 $prevs = DBRecord::countRecords( RESERVE_TBL, "WHERE complete = '0' ".
97 "AND type = '".$crec->type."' ". 99 "AND ".$type_str.
98 "AND endtime = '".$starttime."'" ); 100 "AND endtime = '".$starttime."'" );
99 101
100 // 緇綣ャ若惹違遺札筝茲茹f∞ 102 // 緇綣ャ若惹違遺札筝茲茹f∞
101 if( ($battings - $nexts - $prevs) >= $tuners ) 103 if( ($battings - $nexts - $prevs) >= $tuners )
102 throw new Exception( "茲篋膣茹fс障" ); 104 throw new Exception( "茲篋膣茹fс障" );
109 } 111 }
110 $battings -= $nexts; 112 $battings -= $nexts;
111 113
112 // 翫牙私膣荀篁 114 // 翫牙私膣荀篁
113 $trecs = DBRecord::createRecords(RESERVE_TBL, "WHERE complete = '0' ". 115 $trecs = DBRecord::createRecords(RESERVE_TBL, "WHERE complete = '0' ".
114 "AND type = '".$crec->type."' ". 116 "AND ".$type_str.
115 "AND endtime = '".$starttime."'" ); 117 "AND endtime = '".$starttime."'" );
116 // 翫腟 118 // 翫腟
117 for( $i = 0; $i < count($trecs) ; $i++ ) { 119 for( $i = 0; $i < count($trecs) ; $i++ ) {
118 if( $battings < $tuners ) break; // 茹f腟篋? 120 if( $battings < $tuners ) break; // 茹f腟篋?
119 // 篋膣篆罩c綽荀宴冴 121 // 篋膣篆罩c綽荀宴冴
180 // <ゃ 182 // <ゃ
181 /* 183 /*
182 %TITLE% 腟帥ゃ 184 %TITLE% 腟帥ゃ
183 %ST% 紮ユ鐚ex.200907201830) 185 %ST% 紮ユ鐚ex.200907201830)
184 %ET% 腟篋ユ 186 %ET% 腟篋ユ
185 %TYPE% GR/BS 187 %TYPE% GR/BS/CS
186 %CH% c潟 188 %CH% c潟
187 %DOW% ワSun-Mon鐚 189 %DOW% ワSun-Mon鐚
188 %DOWJ% ワ-鐚 190 %DOWJ% ワ-鐚
189 %YEAR% 紮綛 191 %YEAR% 紮綛
190 %MONTH% 紮 192 %MONTH% 紮