/**
 * Update the order status and the order status history in database
 * @param int $orderId
 * @param array $status
 * @param string $comment
 */
function updateOrderStatus($PnagInvoice, $orderId, $status, $comment, $time, $newTotal, $isReanimatedInvoice = false)
{
    $comments = '';
    if (!$orderId) {
        exit("No order_id given to function updateOrderStatus(). Exit!");
    }
    if ($newTotal) {
        $comments = insertNewTotalCommentToHistory($orderId, $status, $time, $newTotal);
    }
    $SofortOrderSynchronisation = new sofortOrderSynchronisation();
    $SofortOrderSynchronisation->editArticlesShop($PnagInvoice, $orderId);
    $completeInvoiceStatus = $PnagInvoice->getState();
    if (!commentIsValid($orderId, $completeInvoiceStatus) && !$isReanimatedInvoice) {
        echo MODULE_PAYMENT_SOFORT_SR_STATUSUPDATE_UNNECESSARY;
        return $comments;
    }
    xtc_db_query('UPDATE ' . HelperFunctions::escapeSql(TABLE_ORDERS) . ' SET orders_status = "' . HelperFunctions::escapeSql($status) . '", last_modified = now() WHERE orders_id = ' . (int) $orderId . ';');
    $sqlDataArray = array('orders_id' => (int) $orderId, 'orders_status_id' => $status, 'date_added' => 'sqlcommand:now()', 'customer_notified' => 0, 'comments' => $comment . ' ' . MODULE_PAYMENT_SOFORT_SR_TRANSLATE_TIME . ': ' . $time);
    xtc_db_query(HelperFunctions::getEscapedInsertInto(TABLE_ORDERS_STATUS_HISTORY, $sqlDataArray));
    echo MODULE_PAYMENT_SOFORT_SUCCESS_CALLBACK;
    return $comments;
}
     $tax = shopGetTaxRate(MODULE_ORDER_TOTAL_GV_TAX_CLASS);
     array_push($articles, array('articleId' => $itemId, 'articleNumber' => '', 'articleTitle' => $totals['ot_gv']['title'], 'articleDescription' => '', 'articleQuantity' => 1, 'articlePrice' => $_POST['value_ot_gv'], 'articleTax' => $tax, 'articleOrdersProductsId' => '', 'articleOrdersId' => $_GET['oID'], 'articleType' => 'discount'));
 }
 if (isset($_POST['value_ot_coupon'])) {
     $itemId = 'discount|ot_coupon';
     $tax = shopGetTaxRate(MODULE_ORDER_TOTAL_COUPON_TAX_CLASS);
     array_push($articles, array('articleId' => $itemId, 'articleNumber' => '', 'articleTitle' => $totals['ot_coupon']['title'], 'articleDescription' => '', 'articleQuantity' => 1, 'articlePrice' => $_POST['value_ot_coupon'], 'articleTax' => $tax, 'articleOrdersProductsId' => '', 'articleOrdersId' => $_GET['oID'], 'articleType' => 'discount'));
 }
 if (isset($_POST['value_ot_loworderfee'])) {
     $itemId = 'agio|ot_loworderfee';
     $tax = shopGetTaxRate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS);
     array_push($articles, array('articleId' => $itemId, 'articleNumber' => '', 'articleTitle' => $totals['ot_loworderfee']['title'], 'articleDescription' => '', 'articleQuantity' => 1, 'articlePrice' => $_POST['value_ot_loworderfee'], 'articleTax' => $tax, 'articleOrdersProductsId' => '', 'articleOrdersId' => $_GET['oID'], 'articleType' => 'agio'));
 }
 $query = shopDbQuery('SELECT transaction_id FROM sofort_orders WHERE orders_id = "' . $_GET['oID'] . '"');
 $result = shopDbFetchArray($query);
 $sofortOrderSynchronisation = new sofortOrderSynchronisation();
 $errors = $sofortOrderSynchronisation->editArticlesSofort($result['transaction_id'], $articles, $_POST['sofort_update_comment']);
 if ($errors) {
     if ($errors['errors']) {
         $errorCodes .= "<div class='sofort_error'>";
         foreach ($errors['errors'] as $oneError) {
             if (defined('MODULE_PAYMENT_SOFORT_MULTIPAY_XML_FAULT_' . $oneError['code'])) {
                 $errorCodes .= constant('MODULE_PAYMENT_SOFORT_MULTIPAY_XML_FAULT_' . $oneError['code']) . "<br/>";
             } else {
                 $errorCodes .= MODULE_PAYMENT_SOFORT_MULTIPAY_XML_FAULT_0 . "<br/>";
             }
         }
         $errorCodes .= "</div>";
     }
     if ($errors['warnings']) {
         $errorCodes .= "<div class='sofort_error'>";