달력에서 해당기간만 예약 접수 받을 수 있게요~

달력에서 해당기간만 예약 접수 받을 수 있게요~

QA

달력에서 해당기간만 예약 접수 받을 수 있게요~

본문

예약 프로그램인데요

특정기간만 예약을 받을건데 여기서 날짜를 설정하는 부분이 있을까요?

 


<?php
//error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING );
include_once($_SERVER["DOCUMENT_ROOT"]."/common.php");
$currdate = $_GET["currdate"];
//$nowdate = date("Ymd",strtotime("20150119"));
$nowdate = date("Ymd", time());
$day_type = date("N", strtotime($currdate)); // 1~5 평일, 6 토요일
//$time_array[1] = array("10:00","10:30","11:00","11:30","13:30","14:00","14:30","15:00","15:30","16:00");
/*
$time_array[2] = array("10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00");
$time_array[3] = array("10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00");
$time_array[4] = array("10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00");
$time_array[5] = array("10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00");
$time_array[6] = array("10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00");
$time_array[7] = array("10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00");
*/
$time_array2[1] = array("10:00","10:30","11:00","11:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00");
$time_array2[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");
$now_hour = date("H:i", time());
//$now_hour = date("H:i",strtotime("13:13"));
?>
<div class="schedule">
    <ul class="new_time">
<?php
if($wr_3 != 3) {
        foreach ($time_array2[1] as $k=>$v) {
        //$time_type = "오전";
        $reservation_yn = "N";
        //if($v >= "12:00") {
        //$time_type = "오후";
        //}
        $sql = " select count(wr_id) as cnt from g5_write_Visit where wr_1 = '".$currdate."' and wr_2='".$time_array2[1][$k]."' ";
        $cnt = sql_fetch($sql);
        $v_strtotime = strtotime($currdate.$v);
        $now_strtotime = strtotime($nowdate.$now_hour);
        if ($v_strtotime > $now_strtotime) {
            //if ($currdate < "20500101") {
            $reservation_yn = "Y";
            //}
        }
        if ($cnt['cnt'] >= 2) {
            $reservation_yn = "N";
        } ?>
        <!--<li class="time_cls {currtime:'<?php echo $v?>',reservation_yn:'<?php echo $reservation_yn?>'}"><a href="javascript:void(0);"><?php echo $v?> <?php echo $reservation_yn=="Y"?"<span style='color:#2da8f6'>(예약가능)</span>":"<span style='color:red'>(예약불가)</span>"?></a></li>-->
        <li class="time_cls {currtime:'<?php echo $time_array2[1][$k]?>',reservation_yn:'<?php echo $reservation_yn?>'}">
            <a href="javascript:void(0);">
                <?php echo $time_array2[1][$k]?> <?php echo $reservation_yn=="Y"?"":""?>
            </a>
        </li>
    <?php
    }
} else {
    foreach ($time_array2[2] as $k=>$v) {
        //$time_type = "오전";
        $reservation_yn = "N";
        //if($v >= "12:00") {
        //$time_type = "오후";
        //}
        $sql = " select count(wr_id) as cnt from g5_write_Visit where wr_1 = '".$currdate."' and wr_2='".$time_array2[2][$k]."' ";
        $cnt = sql_fetch($sql);
        $v_strtotime = strtotime($currdate.$v);
        $now_strtotime = strtotime($nowdate.$now_hour);
        if ($v_strtotime > $now_strtotime) {
            //if ($currdate < "20500101") {
            $reservation_yn = "Y";
            //}
        }
        if ($cnt['cnt'] >= 10) {
            $reservation_yn = "N";
        }
        if($k == 5 || $k == 6) {
            if($cnt['cnt'] >= 5) {
                $reservation_yn = "N";
            }
        }
        ?>
            <!--<li class="time_cls {currtime:'<?php echo $v?>',reservation_yn:'<?php echo $reservation_yn?>'}"><a href="javascript:void(0);"><?php echo $v?> <?php echo $reservation_yn=="Y"?"<span style='color:#2da8f6'>(예약가능)</span>":"<span style='color:red'>(예약불가)</span>"?></a></li>-->
            <li class="time_cls {currtime:'<?php echo $time_array2[2][$k]?>',reservation_yn:'<?php echo $reservation_yn?>'}">
                <a href="javascript:void(0);">
                    <?php echo $time_array2[2][$k]?> <?php echo $reservation_yn=="Y"?"":""?>
                </a>
            </li>
    <?php
    }
}
?>
    </ul>
</div>
 

이 질문에 댓글 쓰기 :

답변 1

$nowdate = date("Ymd", time());

이 부분이 오늘날짜를 가져오는 부분입니다.

이를 활용해서 다른 날짜로 수정하거나 날짜 조건문을 추가할수 있습니다.

예) 

if($nowdate >= '20220720' && $nowdate <= '20220820') {

 

답변을 작성하시기 전에 로그인 해주세요.
전체 139
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT