use_class('depot_orders');
$class_do = new depot_orders();
$status_otw = '7';
$status_close = '8';
$blank_groupname = 'Blank (No Specific Name)';
$nonrefill_orders_name = 'NON-REFILL ORDER';
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'SUBMITBARCODE') {
        $group_name = tep_db_prepare_input($_POST['group_name']);
        if ($group_name != '') {
            if ($group_name == $nonrefill_orders_name) {
                $dpid = tep_db_prepare_input($_POST['dpid']);
                list($dp, $item_id) = explode('-', $dpid);
                if (is_numeric($item_id)) {
                    $do = $class_do->retrieveDetail($item_id);
                    if ($class_do->isNonRefillOrder($do['trans_type']) && ($do['status'] == '22' || $do['status'] == $status_otw)) {
                        $new_status = $class_do->updateStatus($do['depot_orders_id'], $status_close, $session_userinfo['username']);
                    }
                }
            } else {
                if ($group_name == $blank_groupname) {
                    $group_name = '';
                }
                $ean = tep_db_prepare_input($_POST['ean']);
                use_class('products_ean');
                $class_ean = new products_ean();
                $product_info = $class_ean->getProductArticle($ean);
                $do = $class_do->searchDepotOrder(SEGMENT_ID_HAMBURG, $product_info['products_id'], $product_info['products_articles_id'], $status_otw, $group_name);
                if (count($do) > 0) {
                    $do_first = array_shift($do);
                    $new_status = $class_do->updateStatus($do_first['depot_orders_id'], $status_close, $session_userinfo['username']);