0

I have an order page on oscommerce, with a search box that allows the user to filter results through the date of purchase.

here is the html markup for showing the search box, it uses a jquery datepicker to select the date:

<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>

the html output for the tep_draw_form is <form name="search_date_purchased" action="../admin/orders.php" method="get"> and here is the php side for running the search box query:

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";
}

At the moment all it is doing is showing the value of the input box, along with the date searched in the URL but its not running the search. Any ideas on why, and how it can be fixed?

user180857
  • 329
  • 2
  • 3
  • 15

0 Answers0