Esempio n. 1
0
 /**
  * Update the shop order totals for the give order id
  *
  * @param int $orderId
  */
 public static function updateShopOrderTotals($orderId)
 {
     $order = new order($orderId);
     $total = Data::getRevertedLocalePrice(Data::getBasketAmount($order, $orderId), $order);
     $sql = "UPDATE orders_total SET value = " . (double) $total . " WHERE class = 'ot_total' AND orders_id = '" . tep_db_input($orderId) . "'";
     tep_db_query($sql);
     $tax = Data::getRevertedLocalePrice(Data::getTotalTaxAmount($orderId), $order);
     $sql = "UPDATE orders_total SET value = " . (double) $tax . " WHERE class = 'ot_tax' AND orders_id = '" . tep_db_input($orderId) . "'";
     tep_db_query($sql);
     $subtotal = Data::getRevertedLocalePrice(Data::getSubtotal($orderId), $order);
     $sql = "UPDATE orders_total SET value = " . (double) $subtotal . " WHERE class = 'ot_subtotal' and orders_id = '" . tep_db_input($orderId) . "'";
     tep_db_query($sql);
     $classes = array('ot_total', 'ot_tax', 'ot_subtotal');
     foreach ($classes as $class) {
         $sql = "SELECT value from orders_total WHERE orders_id = '" . tep_db_input($orderId) . "' and class = '{$class}'";
         $query = tep_db_query($sql);
         $entry = tep_db_fetch_array($query);
         $text = Data::getFormattedPrice($entry['value'], $order->info['language'], $order);
         if ($class == 'ot_total') {
             $text = "<b>" . Data::getFormattedPrice(Data::getLocalePrice($entry['value'], $order), $order->info['language'], $order) . "</b>";
         }
         $sql = "UPDATE orders_total SET text = '{$text}' WHERE orders_id = '" . tep_db_input($orderId) . "' and class = '{$class}'";
         tep_db_query($sql);
     }
 }
 * @license   GPLv2
 */
/**
 * RatePAY order template, displays the deliver/cancel, refund, credit and histroy panel
 */
require_once 'includes/application_top.php';
require_once '../includes/languages/' . $_SESSION['language'] . '/admin/modules/payment/ratepay.php';
require_once '../includes/classes/ratepay/helpers/Data.php';
require_once '../includes/classes/ratepay/helpers/Db.php';
require_once '../includes/classes/ratepay/helpers/Session.php';
require_once '../includes/classes/ratepay/helpers/Globals.php';
require_once 'includes/classes/order.php';
$orderId = Globals::hasParam('oID') ? Globals::getParam('oID') : die('Missing param: "oID"');
$order = new order($orderId);
$lang = $_SESSION['language'];
$basketAmount = Data::getBasketAmount($order, $orderId);
require DIR_WS_INCLUDES . 'template_top.php';
?>
<script language="javascript" src="<?php 
echo DIR_WS_CATALOG . 'templates/javascript/ratepay_order.js';
?>
"></script>
<style>
    .piRpRight
    {
        text-align:right;
    }
</style>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
    <tr>
        <td width="100%" valign="top" class="boxCenter">
 /**
  * Retrieve a basketInfo model, filled with the items and basket data
  * 
  * @param order $order
  * @param int $orderId
  * @param array $post
  * @return BasketInfo
  */
 public static function getBasketInfoModel(order $order, $orderId = null, array $post = array())
 {
     $basketInfo = new BasketInfo();
     $basketInfo->setAmount(Data::getBasketAmount($order, $orderId, $post))->setCurrency($order->info['currency'])->setItems(self::getItems($order, $post, $orderId));
     return $basketInfo;
 }
 /**
  * Is called after checkout_payment.php is confirmed,
  * checks if all needed customer data available or 
  * redirect the customer to the checkout_payment.php
  * with a error message otherwise the user get to the
  * ratepay terms page
  * 
  * @global order $order
  */
 public function pre_confirmation_check()
 {
     global $order;
     if (!$this->isInfoVisited()) {
         if ($this->_isPhoneNeeded()) {
             if (Globals::hasPostEntry($this->code . '_phone') && !Data::betterEmpty(Globals::getPostEntry($this->code . '_phone'))) {
                 $phone = Globals::getPostEntry($this->code . '_phone');
                 if ($this->_isPhoneValid($phone)) {
                     Db::setXtCustomerEntry(Session::getSessionEntry('customer_id'), 'customers_telephone', $phone);
                     $order->customer['telephone'] = $phone;
                 } else {
                     $this->error['PHONE'] = 'INVALID';
                 }
             } else {
                 $this->error['PHONE'] = 'MISSING';
             }
         }
         if ($this->_isDobNeeded()) {
             if (Globals::hasPostEntry($this->code . '_birthdate') && !Data::betterEmpty(Globals::getPostEntry($this->code . '_birthdate'))) {
                 $dob = Globals::getPostEntry($this->code . '_birthdate');
                 if (!$this->_isDobValid($dob)) {
                     $this->error['DOB'] = 'INVALID';
                 } elseif (!$this->_isAdult($dob)) {
                     $this->error['DOB'] = 'YOUNGER';
                 } else {
                     $dobArr = explode('.', $dob);
                     $dateStr = $dobArr[2] . "-" . $dobArr[1] . "-" . $dobArr[0] . " 00:00:00";
                     Db::setXtCustomerEntry(Session::getSessionEntry('customer_id'), 'customers_dob', $dateStr);
                 }
             } else {
                 $this->error['DOB'] = 'MISSING';
             }
         }
         if ($this->_isCompanyNeeded()) {
             if (Globals::hasPostEntry($this->code . '_company') && !Data::betterEmpty(Globals::getPostEntry($this->code . '_company'))) {
                 $company = Globals::getPostEntry($this->code . '_company');
                 $order->customer['company'] = $company;
                 $order->billing['company'] = $company;
                 $dbInput = tep_db_input(Db::getXtCustomerEntry(Session::getSessionEntry('customer_id'), 'customers_default_address_id'));
                 tep_db_query("UPDATE " . TABLE_ADDRESS_BOOK . " " . "SET entry_company = '" . tep_db_prepare_input($company) . "' " . "WHERE address_book_id = '" . $dbInput . "'");
             } else {
                 $this->error['VATID'] = 'MISSING';
             }
         }
         if ($this->_isVatIdNeeded()) {
             if (Globals::hasPostEntry($this->code . '_vatid') && !Data::betterEmpty(Globals::getPostEntry($this->code . '_vatid'))) {
                 Db::setXtCustomerEntry(Session::getSessionEntry('customer_id'), 'customers_vat_id', Globals::getPostEntry($this->code . '_vatid'));
             } else {
                 $this->error['VATID'] = 'MISSING';
             }
         }
         if (empty($this->error)) {
             $this->setInfoVisited(true);
             Session::setRpSessionEntry('basketAmount', Data::getBasketAmount($order));
             //$url = tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL');
             $url = tep_href_link($this->_getNextStepPayment(), '', 'SSL');
         } else {
             $this->error = urlencode($this->_getErrorString($this->error));
             $url = tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . $this->error, 'SSL');
         }
         tep_redirect($url);
     }
 }