질문있습니다... 도와주세요..

질문있습니다... 도와주세요..

QA

질문있습니다... 도와주세요..

본문

우선 소스 php입니다.

 

여기 현재 예약리스트에서 예약자명으로만 검색들어가 있는데 예약일로도 검색할 수있게 넣으려는데 막혀서 잘 모르겠네요.. 혹시라도 도움을 받을 수 있을까 해서 이렇게 글 올려봅니다.

 

<?php
require_once ('./_common.php');

$g5['title'] = $g5['title'].'예약목록';

$page = Request::both('page', 1);
$mth = Request::both('mth', false);
$sts = Request::both('sts', false);
$ph = Request::both('ph', false);
$cname = Request::both('cname', false);

$ReserveController = &Loader::instance()->loadController('reserve_ReserveManager');
$ReserveController->setUrl();

$Page = $ReserveController->doListPage($page, $mth, $sts, $ph, $cname, $start, $end, $rr_start, $rr_end);
$list = $Page->list;
$pay_arr = $ReserveController->pay_method;
$status_arr = $ReserveController->status_cd;

$page_query_string = "mth={$mth}&sts={$sts}&ph={$ph}&cname={$cname}";

Loader::instance()->loadFunction('datepicker');
?>
<?include_once $_SERVER['DOCUMENT_ROOT'].'/include/adm/admin.head.php';?>
<link rel="stylesheet" href="./css/style.css">

<div id="mng-reserve-list">
    <div class="search-area tbl_frm01 tbl_wrap">
        <form method="get" action="<?=$_SERVER['PHP_SELF']?>" >
            <table class="" summary="검색 및 분류">
                <caption>검색 및 분류 폼</caption>            
                <tbody>
                    <tr>
                        <th style="width:80px;">결제방식</th>
                        <td>
                            <select name="mth" title="결제방식 선택">
                                <option value="">전체</option>                            
                                <?foreach($pay_arr as $k => $row):?>
                                <option value="<?=$k?>" <?if($mth && $mth == $k):?>selected="selected"<?endif;?>><?=$row?></option>
                                <?endforeach;?>
                            </select>
                        </td>
                        <th style="width:60px;">
                            상태
                        </th>
                        <td>
                            <select name="sts" title="상태 선택">
                                <option value="">전체</option>
                                <?foreach($status_arr as $k => $row):?>
                                <option value="<?=$k?>" <?if($sts && $sts == $k):?>selected="selected"<?endif;?>><?=$row?></option>
                                <?endforeach;?>
                            </select>
                        </td>
                        <!--<th style="width:80px;">연락처</th>
                        <td>
                            <input type="text" name="ph" title="연락처검색" value="<?=$ph?>" class="frm_input"/>
                            <input type="submit" value="검색" class="btn btn_02"/>
                        </td>-->
                        <th style="width:80px;">예약자명</th>
                        <td>
                            <input type="text" name="cname" title="예약자명검색" value="<?=$cname?>" class="frm_input"/>
                            <input type="submit" value="검색" class="btn btn_02"/>
                        </td>

                        <th style="width:80px;">예약일</th>
                        <td>                        
                            <input type="text" name="rr_start" value="<?=$rr_start?>" class="datepicker frm_input" autocomplete="off" readonly="readonly"/>
                            <!--~ 
                            <input type="text" name="rr_end" value="<?=$rr_end?>" class="datepicker frm_input" autocomplete="off" readonly="readonly"/>-->
                            
                            <input type="submit" value="검색" class="btn btn_02"/>                           
                        </td>
                                         
                    </tr>
                </tbody>
            </table>
        </form>
    </div>

    <div class="tbl_head01 tbl_wrap">
        <table class="room-list-table reserve-list" summary="예약된 정보 목록">
            <caption>예약목록</caption>
            <colgroup>
                <col width="120px" />
                <col width="100px" />
                <col width="100px" />
                <col width="100px" />
                <col width="100px" />
                <col width="100px" />
                <col width="100px" />
                <col width="60px" />
                <col width="100px" />
                <col width="50px" />
                <col width="150px" />
                <col width="50px" />
                <col width="100px" />
            </colgroup>
            <thead>
                <tr>                
                    <th>등록일</th>
                    <th>예약자명</th>
                    <th>연락처</th>
                    <th>총금액</th>                
                    <th>결제금액</th>
                    <th>미결제금액</th>
                    <th>결제방식</th>
                    <th>상태</th>
                    <th>예약일</th>
                    <th>기간</th>
                    <th>객실유형</th>
                    <th>성인/소아</th>
                    <th>총액</th>                
                </tr>
            </thead>
            <tbody>
                <? if(!is_array($list) || count($list) < 1):?>
                <tr>
                    <td colspan="9">※ 검색된 예약정보가 없습니다.</td>
                </tr>
                <? else:?>
                <? foreach($list as $k => $row):?>
                <tr <? if(mktime(0,0,0, date('m'), date('d'), date('Y')) <= $row['r_ctime']):?>class="today"<?endif;?>>
                    <td class="center">
                        <a href="./form.php?seq=<?=$row['r_seq']?>">
                        <?=date('Y.m.d H:i', $row['r_ctime']);?>
                        </a>
                    </td>
                    <td class="center">
                        <?=$row['r_cname']?>
                    </td>
                    <td class="center">
                        <?=$row['r_ph']?>
                    </td>
                    <td class="center">
                        <?=number_format($row['r_total']);?>원
                    </td>
                    <td class="center">
                        <?=number_format($row['r_paied'])?>원
                    </td>
                    <td class="center <?if($row['left'] > 0):?>danger<?endif;?>">                    
                        <?=number_format($row['left'])?>원
                    </td>
                    <td class="center">
                        <?=$row['pay_type_kr']?>
                    </td>
                    <td class="center">
                        <?=$row['status_kr']?>
                    </td>
                    <td colspan="5" style="padding-left:5px; padding-right:5px;">
                        <table class="" summary="예약된 객실 정보">
                            <caption>객실정보 목록</caption>
                            <colgroup>
                                <col width="100px" />
                                <col width="50px" />
                                <col width="150px" />
                                <col width="50px" />
                                <col width="100px" />
                            </colgroup>
                            <tbody class="center">
                                <?if(is_array($row['rooms']) && count($row['rooms']) > 0):?>
                                <?foreach($row['rooms'] as $k => $detail):?>
                                <tr>
                                    <td><?=date('Y.m.d', $detail['rr_start'])?></td>
                                    <td><?=$detail['rr_range']?>박</td>
                                    <td><?=$detail['ri_name']?></td>
                                    <td>
                                        <?=$detail['rr_adult']?> /  <?=$detail['rr_child']?>
                                    </td>
                                    <td>
                                        <?=number_format($detail['rr_total'])?>원
                                    </td>
                                </tr>
                                <?endforeach;?>
                                <?else:?>
                                <tr>
                                    <td colspan="5" class="danger">
                                    ※ 등록된 객실 정보가 없습니다. 
                                    </td>
                                </tr>
                                <?endif;?>
                            </tbody>
                        </table>
                    </td>
                </tr>
                <?endforeach;?>
                <?endif;?>
            </tbody>
        </table>

        <?if(is_array($Page->page_list) && count($Page->page_list) > 0):?>
        <div class="btn-area-center">
            <ul class="page-list">
                <?if($Page->page_prev):?>
                <li>
                    <a href="<?=$_SERVER['PHP_SELF']?>?page=<?=$Page->page_prev?>&<?=$page_query_string?>"><</a>
                </li>
                <?endif;?>
                <?foreach($Page->page_list as $v):?>
                <li <?if($page == $v):?>class="active"<?endif;?>>
                    <a href="<?=$_SERVER['PHP_SELF']?>?page=<?=$v?>&<?=$page_query_string?>"><?=$v?></a>
                </li>
                <?endforeach;?>
                <?if($Page->page_next):?>
                <li>
                    <a href="<?=$_SERVER['PHP_SELF']?>?page=<?=$Page->page_next?>&<?=$page_query_string?>">></a>
                </li>
                <?endif;?>
            </ul>
        </div>
        <?endif;?>        
        
    </div>
</div>

<iframe name="formReceiver" id="formReceiver" style="border:1px solid red; width:100%; height:400px; display:none;"></iframe>

<style>
    tr.hover > td{background-color:#9DCEF8;}
    table table tr td{background-color:#fff;}
</style>
<script>
$(document).ready(function(){
    var tr_list = $('.room-list-table > tbody > tr');
    $.each(tr_list, function(i, e){
        $(e).css('cursor', 'pointer');
        var $a = $(e).find('a');
        var href = $a.attr('href');

        $(e).on('mouseenter', function(){
            $(this).addClass('hover');
        }).on('mouseleave', function(){
            $(this).removeClass('hover');
        }).on('click', function(){
            document.location.href=href;
        });

    });
});
</script>
<?=datepicker_default('.datepicker')?>
<?include_once $_SERVER['DOCUMENT_ROOT'].'/include/adm/admin.tail.php';;?>

이 질문에 댓글 쓰기 :

답변 2

예를 들어 다음과 같이 해볼수 있을것 같습니다.

폼필드 추가 (예약일이 범위일 경우, rr_start와 rr_end 필드를 추가)


<th style="width:80px;">예약일</th>
<td>                        
    <input type="text" name="rr_start" value="<?=$rr_start?>" class="datepicker frm_input" autocomplete="off" readonly="readonly"/>
    <!--~
    <input type="text" name="rr_end" value="<?=$rr_end?>" class="datepicker frm_input" autocomplete="off" readonly="readonly"/>
    -->
    <input type="submit" value="검색" class="btn btn_02"/>                           
</td>

 

php 스크립트 수정


$rr_start = Request::both('rr_start', false);
$rr_end = Request::both('rr_end', false);
 
// 예약 일자 검색 조건 추가
if ($rr_start && $rr_end) {
    $Page->addCondition('r.r_ctime >= ' . strtotime($rr_start) . ' AND r.r_ctime <= ' . strtotime($rr_end));
} elseif ($rr_start) {
    $Page->addCondition('r.r_ctime >= ' . strtotime($rr_start));
} elseif ($rr_end) {
    $Page->addCondition('r.r_ctime <= ' . strtotime($rr_end));
}

이렇게 하면 rr_start와 rr_end가 모두 있을 때 두 날짜 사이의 예약일을 검색하고, 하나만 있을 때 해당 날짜 이후(이전)의 예약을 검색하도록 추가하면 되지 않을까 합니다.

 

답변을 작성하시기 전에 로그인 해주세요.
전체 14,981
QA 내용 검색
filter #php ×

회원로그인

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