<?php

use_class('orders');
$class_o = new orders();
use_class('customers_special_list');
$class_csl = new customers_special_list();
$search_days = 60;
//AJAX ACTION
if (isset($_POST['me_action']) && $_POST['me_action'] != '') {
    if ($_POST['me_action'] == 'SEARCHORDERS') {
        $search_field = tep_db_prepare_input($_POST['search_field']);
        $search_keywords = tep_db_prepare_input(utf8_decode($_POST['search_keywords']));
        $date_filter = date('Y-m-d', strtotime("-{$search_days} day"));
        $orders = $class_o->searchBanktransferOrders($search_field, $search_keywords, "o.date_purchased>DATE('{$date_filter}')");
        $result = '';
        $table = array();
        if (count($orders) > 0) {
            $t = array();
            $t['d'] = 'Date';
            $t['c'] = 'Customer';
            $t['o'] = 'Order No';
            $t['i'] = 'Bank Info';
            $t['p'] = 'Order Value';
            $t['t'] = 'Withdrawal Date';
            $table[] = $t;
            foreach ($orders as $row) {
                $order_date = strtotime($row['date_purchased']);
                $customer_special = $class_csl->getCustomerDetail($row['customers_id']);
                $crown_img = is_null($customer_special) ? '' : $class_csl->getTypeSymbol($customer_special['list_type'], $row['customers_id']);
                $t = array();
                $t['d'] = date('d-M-y', $order_date);