0

oscommerce に注文ページがあり、ユーザーが購入日で結果をフィルターできる検索ボックスがあります。

検索ボックスを表示するための HTML マークアップを次に示します。jquery 日付ピッカーを使用して日付を選択します。

<table border="0" align="right">
<tr><?php echo tep_draw_form('search_date_purchased', FILENAME_ORDERS, '', 'get'); ?>

<td class="smallText" align="right"><?php echo TEXT_ORDER_DATE;?>&nbsp;<input type="text" name="search_date_purchased" placeholder="Choose a Date" class="datepick"/></td>
</form>
</tr>
</table>

tep_draw_formisの html 出力と<form name="search_date_purchased" action="../admin/orders.php" method="get"> 、検索ボックス クエリを実行するための php 側を次に示します。

if (isset($HTTP_GET_VARS['search_date_purchased']) && !empty($HTTP_GET_VARS['search_date_purchased'])){




    if (strstr($HTTP_GET_VARS['search_date_purchased'],'-')){

        $search_date = explode("-", $HTTP_GET_VARS['search_date_purchased']);   

        $start_date = substr($search_date[0],6,4).'-'.substr($search_date[0],3,2).'-'.substr($search_date[0],0,2).' 17:00:00';

        $end_date = substr($search_date[1],6,4).'-'.substr($search_date[1],3,2).'-'.substr($search_date[1],0,2).' 17:00:00';    

        $search_query = "and (o.date_purchased >='".$start_date."' and o.date_purchased <='".$end_date."') ";


    }else{


    $start_date = substr($HTTP_GET_VARS['search_date_purchased'],6,4).'-'.substr($HTTP_GET_VARS['search_date_purchased'],3,2).'-'.substr($HTTP_GET_VARS['search_date_purchased'],0,2).' 17:00:00';

    $end_date = substr($HTTP_GET_VARS['search_date_purchased'],6,4).'-'.substr($HTTP_GET_VARS['search_date_purchased'],3,2).'-'.substr($HTTP_GET_VARS['search_date_purchased'],0,2).' 17:00:00';    

        $search_query = "and (o.date_purchased >='".$start_date."' and o.date_purchased <='".$end_date."') ";
    }

}else{
    $yesterday = date("Y-m-d",strtotime('-1 day')).' 17:00:00';
    $today = date("Y-m-d").' 17:00:00'; 
    $search_query = "and (o.date_purchased >='".$yesterday."' and o.date_purchased <='".$today."') ";

}

if (isset($HTTP_GET_VARS['cID'])) {


  $cID = tep_db_prepare_input($HTTP_GET_VARS['cID']);
  $orders_query_raw = "select o.orders_id, o.customers_id, o.customers_name, o.customers_id, o.payment_method, o.date_purchased, o.franchise_id, o.last_modified, o.date_allocated, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$cID . "' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total'  " . $franchise_search . "order by orders_id DESC ";
} elseif (isset($HTTP_GET_VARS['status']) && is_numeric($HTTP_GET_VARS['status']) && ($HTTP_GET_VARS['status'] > 0)) {
  $status = tep_db_prepare_input($HTTP_GET_VARS['status']);
  $orders_query_raw = "select o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.franchise_id,o.date_purchased, o.last_modified, o.currency, o.currency_value, o.date_allocated, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.orders_status_id = '" . (int)$status . "' and ot.class = 'ot_total'  " . $franchise_search . "order by o.orders_id DESC ";
} else {
  $orders_query_raw = "select o.orders_id, o.customers_id, o.customers_name, o.payment_method, o.date_purchased, o.franchise_id, o.last_modified, o.date_allocated, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total'  " . $search_query . " order by o.orders_id DESC";
}

現時点では、入力ボックスの値と URL で検索された日付を表示しているだけですが、検索は実行されていません。理由、およびそれを修正する方法についてのアイデアはありますか?

4

0 に答える 0