/** * 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 }
/** * inserts a "new total" comment into shop order status history * @param int $orderId * @param string $status * @param date $time * @param PnagInvoice $PnagInvoice * @param float $lastShopTotal */ protected function _insertNewTotalCommentToHistory($orderId, $status, $time, PnagInvoice $PnagInvoice, $lastShopTotal) { $newTotal = $PnagInvoice->getAmount(); if ($newTotal > $lastShopTotal) { $comment = MODULE_PAYMENT_SOFORT_SR_TRANSLATE_CART_RESET . ' ' . MODULE_PAYMENT_SOFORT_SR_TRANSLATE_CURRENT_TOTAL . ' ' . $newTotal . ' Euro ' . MODULE_PAYMENT_SOFORT_SR_TRANSLATE_TIME . ': ' . $time; } else { $comment = MODULE_PAYMENT_SOFORT_SR_TRANSLATE_CART_EDITED . ' ' . MODULE_PAYMENT_SOFORT_SR_TRANSLATE_CURRENT_TOTAL . ' ' . $newTotal . ' Euro ' . MODULE_PAYMENT_SOFORT_SR_TRANSLATE_TIME . ': ' . $time; } $sqlDataArray = array('orders_id' => (int) $orderId, 'orders_status_id' => $status, 'date_added' => 'now()', 'customer_notified' => 0, 'comments' => $comment); shopDbPerform(TABLE_ORDERS_STATUS_HISTORY, $sqlDataArray); $sofortOrdersId = shopDbFetchArray(shopDbQuery('SELECT id FROM sofort_orders WHERE orders_id = "' . $orderId . '"')); HelperFunctions::insertSofortOrdersNotification($sofortOrdersId['id'], $PnagInvoice, $comment, $comment); }