<?php
include_once('./_common.php');
//error_reporting( E_ALL);
//ini_set("display_errors",1);

/*
불당동 : 평일(오전11시 ~ 오후8시), 주말(오전11시 ~ 오후8시)이고 30분 단위로 예약
신부동 : 평일(오전10시 ~ 오후8시), 주말(오전10시 ~ 오후6시)이고 30분 단위로 예약
*/
$ck_rent_wr_id	= get_cookie("ck_rent_wr_id");
$sql	= " select wr_8 from g5_write_cloth_rent where wr_id = '{$ck_rent_wr_id}' ";
$row	= sql_fetch($sql);

$currdate = $_GET["currdate"];
if(!$currdate) { $currdate = date("Ymd"); }

//$nowdate = date("Ymd",strtotime("20150119"));
$nowdate = date("Ymd",time());
$day_type = date("N",strtotime($currdate)); // 1~5 평일, 6 토요일

//20190410의 데이터 가져와서  wr_1(날짜)  wr_2(시간) 이니까 이거 이용시  예약한지안한지 확인 가능. 
$checkdate	= date("Y년 m월 d일", strtotime($currdate));
$sql2	= "select wr_2 from g5_write_cloth_rent3 where wr_1 ='".$checkdate."';";
$result2	= sql_query($sql2);
$result_date = array();
$i = 0;
while($row2 = sql_fetch_array($result2)) {
	array_push($result_date,$row2['wr_2']);
}

if($row['wr_8'] == "스플랜디노(불당동)") {
	$time_array[1] = array("11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00");
	$time_array[2] = array("11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00");
	$time_array[3] = array("11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00");
	$time_array[4] = array("11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00");
	$time_array[5] = array("11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00");
	$time_array[6] = array("11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00");
	$time_array[7] = array("11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00");
} else {
	$time_array[1] = array("10:00","10:30","11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00");
	$time_array[2] = array("10:00","10:30","11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00");
	$time_array[3] = array("10:00","10:30","11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00");
	$time_array[4] = array("10:00","10:30","11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00");
	$time_array[5] = array("10:00","10:30","11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00");
	$time_array[6] = array("11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00");
	$time_array[7] = array("11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00");
}
?>

<div class="schedule">
	<div class="time">
		<div class="time_list" id="time_list">
			<ul class="bu4" id="time_list2">
<?php
	foreach($time_array[$day_type] as $k=>$v)
	{
		$time_type = "오전";
		$reservation_yn = "Y";

		if($v >= "12:00") {
			$time_type = "오후";
		}
		
		// 고객이 선택한 날짜는 예약 불가
		foreach($result_date as $compareDate) {
			if($compareDate == $time_type." ".$v) {
				$reservation_yn="N";
			}
		}
		// 오늘날짜는 예약 불가
		if($currdate == date("Ymd")) { $reservation_yn="N"; }
?>				
				<li class="time_cls {currtime:'<?php echo $time_type." ".$v?>',reservation_yn:'<?php echo $reservation_yn?>'}"><a href="javascript:void(0);"><?php echo $time_type." ".$v?> <?php echo $reservation_yn=="Y"?"(예약가능)":"(예약불가)"?></a></li>
<?php
	}
?>				
				<!-- <li>&nbsp;</li> -->
			</ul>
		</div>
	</div>
</div>
<div class="date_ok timedate">
	<span class="date_choice time_class"></span><span>을 선택하셨습니다.</span>
</div>
