$result = '<span class="bold red">Error: Status is now ' . statusName($item['status']) . '</span>';
            }
        } else {
            $result = '<span class="bold red">Invalid order barcode!</span>';
        }
        echo utf8_encode($result);
        exit;
    } elseif ($_POST['me_action'] == 'REPRINTPI') {
        $type = tep_db_prepare_input($_POST['type']);
        $mode = tep_db_prepare_input($_POST['mode']);
        if ($mode == 'ready-printed-unscanned') {
            $target_url = 'http://' . $server . '/cron/print-pi.php';
            $post_vars = array('type' => $type, 'mode' => $mode, 'excecuter' => $session_userinfo['username']);
            doCURL($target_url, $post_vars);
        } elseif ($mode == 'ready-printed-unscanned-next-batch') {
            $class_do->reprintNextBatchForPrintedUnscannedOrders();
            echo utf8_encode("ready-printed-unscanned-next-batch-OK");
        }
        exit;
    }
}
if (isset($_GET['me_action'])) {
    if ($_GET['me_action'] == 'LEADTIMEAVGLOAD') {
        $doi_id = tep_db_prepare_input($_GET['depot_orders_id']);
        $q = " SELECT * FROM (";
        $q .= " SELECT do.depot_orders_id, do.leadtime_start_date, dosh.status, dosh.update_time AS status_date";
        $q .= " FROM depot_orders do";
        $q .= " INNER JOIN depot_orders_status_history dosh ON dosh.depot_orders_id = do.depot_orders_id";
        $q .= " WHERE do.status >= 1 AND do.depot_orders_id = {$doi_id}";
        $q .= " UNION ALL";
        $q .= " SELECT psh.orders_items_id AS depot_orders_id, do.leadtime_start_date, CONCAT('4-',SUBSTR(psh.status,1,1)) status, psh.status_date";