/** * handle and submit status / comment change via orderdetailpage * @param int $oID * @param object $order * @param string $status * @param string $comments * @param string $notifyCustomer * @param string $notifyWithComments */ function shopSofortComment($oID, $order, $status, $comments, $notifyCustomer, $notifyWithComments) { global $messageStack; $order_updated = false; $check_status_query = shopDbQuery("SELECT customers_name, customers_email_address, orders_status, date_purchased FROM " . TABLE_ORDERS . " WHERE orders_id = '" . shopDbInput($oID) . "'"); $check_status = shopDbFetchArray($check_status_query); if ($check_status['orders_status'] != $status || $comments != '') { shopDbQuery("UPDATE " . TABLE_ORDERS . " SET orders_status = '" . shopDbInput($status) . "', last_modified = now() WHERE orders_id = '" . shopDbInput($oID) . "'"); $customer_notified = '0'; if ($notifyCustomer == 'on') { $notify_comments = ''; if ($notifyWithComments == 'on') { $notify_comments = $comments; } else { $notify_comments = ''; } $smarty = new Smarty(); $smarty->assign('language', $_SESSION['language']); $smarty->caching = false; $smarty->template_dir = DIR_FS_CATALOG . 'templates'; $smarty->compile_dir = DIR_FS_CATALOG . 'templates_c'; $smarty->config_dir = DIR_FS_CATALOG . 'lang'; $smarty->assign('tpl_path', 'templates/' . CURRENT_TEMPLATE . '/'); $smarty->assign('logo_path', HTTP_SERVER . DIR_WS_CATALOG . 'templates/' . CURRENT_TEMPLATE . '/img/'); $smarty->assign('NAME', $check_status['customers_name']); $smarty->assign('ORDER_NR', $oID); $smarty->assign('ORDER_LINK', shopCatalogHrefLink(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $oID, 'SSL')); $smarty->assign('ORDER_DATE', shopDateLong($check_status['date_purchased'])); $smarty->assign('NOTIFY_COMMENTS', $notify_comments); $smarty->assign('ORDER_STATUS', $orders_status_array[$status]); $html_mail = $smarty->fetch('db:change_order_mail.html'); $txt_mail = $smarty->fetch('db:change_order_mail.txt'); shopDbMail(EMAIL_BILLING_ADDRESS, EMAIL_BILLING_NAME, $check_status['customers_email_address'], $check_status['customers_name'], '', EMAIL_BILLING_REPLY_ADDRESS, EMAIL_BILLING_REPLY_ADDRESS_NAME, '', '', EMAIL_BILLING_SUBJECT, $html_mail, $txt_mail); $customer_notified = '1'; } shopDbQuery("INSERT INTO " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) VALUES ('" . shopDbInput($oID) . "', '" . shopDbInput($status) . "', now(), '" . $customer_notified . "', '" . shopDbInput($comments) . "')"); $order_updated = true; } if ($order_updated) { $messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success'); } else { $messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning'); } return; }
case 'cancel': $successCodes .= "<div class='sofort_success'>"; $successCodes .= $PnagInvoice->getStatusReason() == 'confirm_invoice' ? MODULE_PAYMENT_SOFORT_SR_TRANSLATE_INVOICE_CANCELED : MODULE_PAYMENT_SOFORT_SR_TRANSLATE_INVOICE_CANCELED_REFUNDED . "<br/>"; $successCodes .= "</div>"; break; } } } } if ($_POST['sofort_action'] == 'sofort_save') { $articles = array(); reset($_POST['opid_product']); for ($i = 0, $n = count($_POST['opid_product']); $i < $n; ++$i) { $query_product = shopDbQuery('SELECT products_quantity, products_price, products_model, products_tax, products_name FROM ' . TABLE_ORDERS_PRODUCTS . ' WHERE orders_products_id = "' . $_POST['opid_product'][$i] . '"'); $result_product = shopDbFetchArray($query_product); $query_attributes = shopDbQuery("SELECT products_options, products_options_values, options_values_price, price_prefix FROM " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " WHERE orders_id = '" . shopDbInput($_GET['oID']) . "' AND orders_products_id = '" . $_POST['opid_product'][$i] . "'"); $description = ''; while ($attributes = shopDbFetchArray($query_attributes)) { $description .= $attributes['products_options'] . ": " . nl2br($attributes['products_options_values']) . "\n"; if ($attributes['options_values_price'] != '0') { $description .= " (" . $attributes['price_prefix'] . " " . number_format($attributes['options_values_price'], 2) . ")"; } } $description = substr($description, 0, strlen($description) - 1); $query = shopDbQuery('SELECT item_id FROM sofort_products WHERE orders_products_id = "' . $_POST['opid_product'][$i] . '"'); $result = shopDbFetchArray($query); if ($_POST['delete_product'][$i] == 'delete') { $_POST['qty_product'][$i] = 'delete'; } array_push($articles, array('articleId' => $result['item_id'], 'articleNumber' => $result_product['products_model'], 'articleTitle' => $result_product['products_name'], 'articleDescription' => $description, 'articleQuantity' => $_POST['qty_product'][$i], 'articlePrice' => $_POST['price_product'][$i], 'articleTax' => $result_product['products_tax'], 'articleOrdersProductsId' => $_POST['opid_product'][$i], 'articleOrdersId' => $_GET['oID'], 'articleType' => 'product')); }