/** * only SR: Fill table sofort_orders_notification, e.g. in case of status-changes * @see updateTimeline() * @param int $sofortOrdersId - key from table sofort_orders * @param object $invoice with complete transactiondata * @param string $customerComment (optional) * @param string $sellerComment (optional) * @return last insert_id */ function insertSofortOrdersNotification($sofortOrdersId, PnagInvoice $PnagInvoice, $customerComment = '', $sellerComment = '') { if (!$sofortOrdersId || !is_object($PnagInvoice->getTransactionData()) || $PnagInvoice->getTransactionData()->getPaymentMethod() != 'sr') { return false; } $sqlDataArray = array('sofort_orders_id' => $sofortOrdersId, 'items' => serialize($PnagInvoice->getItems()), 'amount' => $PnagInvoice->getAmount(), 'customer_comment' => $customerComment, 'seller_comment' => $sellerComment, 'status_id' => $PnagInvoice->getState(), 'status' => $PnagInvoice->getStatus(), 'status_reason' => $PnagInvoice->getStatusReason(), 'invoice_status' => $PnagInvoice->getStatusOfInvoice(), 'invoice_objection' => $PnagInvoice->getInvoiceObjection()); xtc_db_query(HelperFunctions::getEscapedInsertInto('sofort_orders_notification', $sqlDataArray)); return xtc_db_insert_id(); // fetch and return the last insert id }
} else { $errorCodes .= MODULE_PAYMENT_SOFORT_MULTIPAY_XML_FAULT_0 . "<br/>"; } } $errorCodes .= "</div>"; } else { if (!$errors) { switch ($_POST['sofort_button']) { case 'confirm': $successCodes .= "<div class='sofort_success'>"; $successCodes .= MODULE_PAYMENT_SOFORT_SR_INVOICE_CONFIRMED . "<br/>"; $successCodes .= "</div>"; break; 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)) {
/** * cart was edited at SOFORT-backend, apply changes in shop * @param PnagInvoice $PnagInvoice */ public function editArticlesShop(PnagInvoice $PnagInvoice, $orderNumber) { $lng = $PnagInvoice->getLanguageCode(); $newAmount = $PnagInvoice->getAmount(); $invoiceArticles = $PnagInvoice->getItems(); foreach ($invoiceArticles as $article) { $getTotalItems = explode('|', $article->itemId); if (count($getTotalItems) > '1') { $sofortIdArray[$getTotalItems[0]] = $getTotalItems[0]; $sofortArticleArray[$getTotalItems[0]] = $article; } else { $ordersProductsId = $this->_getOrderProductsId($article->itemId, $orderNumber); $sofortIdArray[$ordersProductsId] = $ordersProductsId; $sofortArticleArray[$ordersProductsId] = $article; } } $shopProductsQuery = shopDbQuery("SELECT orders_products_id FROM " . TABLE_ORDERS_PRODUCTS . " WHERE orders_id = '" . $orderNumber . "'"); while ($shopProductsResult = shopDbFetchArray($shopProductsQuery)) { $shopArticleArray[] = $shopProductsResult['orders_products_id']; } $taxLow = 0; $taxHigh = 0; $subtotal = 0; foreach ($shopArticleArray as $shopArticle) { if (!in_array($shopArticle, $sofortIdArray)) { $this->_sofortRestock($this->_getItemId($shopArticle, $orderNumber), $orderNumber, 0); $this->_deleteShopOrderArticle($shopArticle, $PnagInvoice->getStatusReason()); } else { $qty = $sofortArticleArray[$shopArticle]->quantity; $price = $sofortArticleArray[$shopArticle]->unitPrice; $itemId = $sofortArticleArray[$shopArticle]->itemId; $this->_sofortRestock($itemId, $orderNumber, $qty); $this->_updateShopOrderArticle($shopArticle, $qty, $price, $PnagInvoice->getStatusReason()); if ($sofortArticleArray[$shopArticle]->tax == '7.00') { $taxLow += $sofortArticleArray[$shopArticle]->quantity * $sofortArticleArray[$shopArticle]->unitPrice; } elseif ($sofortArticleArray[$shopArticle]->tax == '19.00') { $taxHigh += $sofortArticleArray[$shopArticle]->quantity * $sofortArticleArray[$shopArticle]->unitPrice; } $subtotal += $sofortArticleArray[$shopArticle]->quantity * $sofortArticleArray[$shopArticle]->unitPrice; } } $shipping = 0; $discount = array(); $agio = array(); foreach ($sofortIdArray as $sofortId) { if (!in_array($sofortId, $shopArticleArray)) { switch ($sofortId) { case 'shipping': $shipping = $sofortArticleArray[$sofortId]->unitPrice; break; case 'discount': $splitItemId = explode('|', $sofortArticleArray[$sofortId]->itemId); $discountClass = $splitItemId[1]; array_push($discount, array('class' => $discountClass, 'value' => $sofortArticleArray[$sofortId]->unitPrice)); break; case 'agio': $splitItemId = explode('|', $sofortArticleArray[$sofortId]->itemId); $agioClass = $splitItemId[1]; array_push($agio, array('class' => $agioClass, 'value' => $sofortArticleArray[$sofortId]->unitPrice)); break; default: $this->_sofortRestock($sofortArticleArray[$sofortId]->itemId, $orderNumber, $sofortArticleArray[$sofortId]->quantity); $this->_insertShopOrderArticle($sofortArticleArray[$sofortId], $orderNumber, $lng); $subtotal += $sofortArticleArray[$sofortId]->quantity * $sofortArticleArray[$sofortId]->unitPrice; break; } if ($sofortArticleArray[$sofortId]->tax == '7.00') { $taxLow += $sofortArticleArray[$sofortId]->unitPrice * $sofortArticleArray[$sofortId]->quantity; } elseif ($sofortArticleArray[$sofortId]->tax == '19.00') { $taxHigh += $sofortArticleArray[$sofortId]->unitPrice * $sofortArticleArray[$sofortId]->quantity; } } } $status = $PnagInvoice->getStatusReason(); $this->_updateShopTotals($taxLow, $taxHigh, $subtotal, $newAmount, $orderNumber, $shipping, $discount, $agio, $status); }