Пример #1
0
 /**
  * The Cart view
  *
  * Mind that the Cart needs to be {@see update()}d before calling this
  * method.
  * @global  array $_ARRAYLANG   Language array
  * @param   \Cx\Core\Html\Sigma $objTemplate  The optional Template
  */
 static function view($objTemplate = null)
 {
     global $_ARRAYLANG;
     if (!$objTemplate) {
         // TODO: Handle missing or empty Template, load one
         die("Cart::view(): ERROR: No template");
         //            return false;
     }
     $objTemplate->setGlobalVariable($_ARRAYLANG);
     $i = 0;
     if (count(self::$products)) {
         foreach (self::$products as $arrProduct) {
             $groupCountId = $arrProduct['group_id'];
             $groupArticleId = $arrProduct['article_id'];
             $groupCustomerId = 0;
             if (Shop::customer()) {
                 $groupCustomerId = Shop::customer()->group_id();
             }
             Shop::showDiscountInfo($groupCustomerId, $groupArticleId, $groupCountId, $arrProduct['quantity']);
             // product image
             $arrProductImg = Products::get_image_array_from_base64($arrProduct['product_images']);
             $shopImagesWebPath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesWebPath() . '/Shop/';
             $thumbnailPath = $shopImagesWebPath . ShopLibrary::noPictureName;
             foreach ($arrProductImg as $productImg) {
                 if (!empty($productImg['img']) && $productImg['img'] != ShopLibrary::noPictureName) {
                     $thumbnailPath = $shopImagesWebPath . \ImageManager::getThumbnailFilename($productImg['img']);
                     break;
                 }
             }
             /* UNUSED (and possibly obsolete, too)
                             if (isset($arrProduct['discount_string'])) {
             //DBG::log("Shop::view_cart(): Product ID ".$arrProduct['id'].": ".$arrProduct['discount_string']);
                                 $objTemplate->setVariable(
                                     'SHOP_DISCOUNT_COUPON_STRING',
                                         $arrProduct['coupon_string']
                                 );
                             }*/
             // The fields that don't apply have been set to ''
             // (empty string) already -- see update().
             $objTemplate->setVariable(array('SHOP_PRODUCT_ROW' => 'row' . (++$i % 2 + 1), 'SHOP_PRODUCT_ID' => $arrProduct['id'], 'SHOP_PRODUCT_CODE' => $arrProduct['product_id'], 'SHOP_PRODUCT_THUMBNAIL' => $thumbnailPath, 'SHOP_PRODUCT_CART_ID' => $arrProduct['cart_id'], 'SHOP_PRODUCT_TITLE' => str_replace('"', '"', contrexx_raw2xhtml($arrProduct['title'])), 'SHOP_PRODUCT_PRICE' => $arrProduct['price'], 'SHOP_PRODUCT_PRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_PRODUCT_QUANTITY' => $arrProduct['quantity'], 'SHOP_PRODUCT_ITEMPRICE' => $arrProduct['itemprice'], 'SHOP_PRODUCT_ITEMPRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_REMOVE_PRODUCT' => $_ARRAYLANG['TXT_SHOP_REMOVE_ITEM']));
             //DBG::log("Attributes String: {$arrProduct['options_long']}");
             if ($arrProduct['options_long']) {
                 $objTemplate->setVariable('SHOP_PRODUCT_OPTIONS', $arrProduct['options_long']);
             }
             if (\Cx\Core\Setting\Controller\Setting::getValue('weight_enable', 'Shop')) {
                 $objTemplate->setVariable(array('SHOP_PRODUCT_WEIGHT' => Weight::getWeightString($arrProduct['weight']), 'TXT_WEIGHT' => $_ARRAYLANG['TXT_TOTAL_WEIGHT']));
             }
             if (Vat::isEnabled()) {
                 $objTemplate->setVariable(array('SHOP_PRODUCT_TAX_RATE' => $arrProduct['vat_rate'] ? Vat::format($arrProduct['vat_rate']) : '', 'SHOP_PRODUCT_TAX_AMOUNT' => $arrProduct['vat_amount'] . ' ' . Currency::getActiveCurrencySymbol()));
             }
             if (intval($arrProduct['minimum_order_quantity']) > 0) {
                 $objTemplate->setVariable(array('SHOP_PRODUCT_MINIMUM_ORDER_QUANTITY' => $arrProduct['minimum_order_quantity']));
             } else {
                 if ($objTemplate->blockExists('orderQuantity')) {
                     $objTemplate->hideBlock('orderQuantity');
                 }
                 if ($objTemplate->blockExists('minimumOrderQuantity')) {
                     $objTemplate->hideBlock('minimumOrderQuantity');
                 }
             }
             $objTemplate->parse('shopCartRow');
         }
     } else {
         $objTemplate->hideBlock('shopCart');
         if ($objTemplate->blockExists('shopCartEmpty')) {
             $objTemplate->touchBlock('shopCartEmpty');
             $objTemplate->parse('shopCartEmpty');
         }
         if ($_SESSION['shop']['previous_product_ids']) {
             $ids = $_SESSION['shop']['previous_product_ids']->toArray();
             Shop::view_product_overview($ids);
         }
     }
     $objTemplate->setGlobalVariable(array('TXT_PRODUCT_ID' => $_ARRAYLANG['TXT_ID'], 'SHOP_PRODUCT_TOTALITEM' => self::get_item_count(), 'SHOP_PRODUCT_TOTALPRICE' => Currency::formatPrice(self::get_price()), 'SHOP_PRODUCT_TOTALPRICE_PLUS_VAT' => Currency::formatPrice(self::get_price() + (Vat::isEnabled() && !Vat::isIncluded() ? self::get_vat_amount() : 0)), 'SHOP_PRODUCT_TOTALPRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_TOTAL_WEIGHT' => Weight::getWeightString(self::get_weight()), 'SHOP_PRICE_UNIT' => Currency::getActiveCurrencySymbol()));
     // Show the Coupon code field only if there is at least one defined
     if (Coupon::count_available()) {
         //DBG::log("Coupons available");
         $objTemplate->setVariable(array('SHOP_DISCOUNT_COUPON_CODE' => isset($_SESSION['shop']['coupon_code']) ? $_SESSION['shop']['coupon_code'] : ''));
         if ($objTemplate->blockExists('shopCoupon')) {
             $objTemplate->parse('shopCoupon');
         }
         if (self::get_discount_amount()) {
             $total_discount_amount = self::get_discount_amount();
             //DBG::log("Shop::view_cart(): Total: Amount $total_discount_amount");
             $objTemplate->setVariable(array('SHOP_DISCOUNT_COUPON_TOTAL' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_TOTAL'], 'SHOP_DISCOUNT_COUPON_TOTAL_AMOUNT' => Currency::formatPrice(-$total_discount_amount)));
         }
     }
     if (Vat::isEnabled()) {
         $objTemplate->setVariable(array('TXT_TAX_PREFIX' => Vat::isIncluded() ? $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_INCL'] : $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_EXCL'], 'SHOP_TOTAL_TAX_AMOUNT' => self::get_vat_amount() . ' ' . Currency::getActiveCurrencySymbol()));
         if (Vat::isIncluded()) {
             $objTemplate->setVariable(array('SHOP_GRAND_TOTAL_EXCL_TAX' => Currency::formatPrice(self::get_price() - self::get_vat_amount()) . ' ' . Currency::getActiveCurrencySymbol()));
         }
     }
     if (self::needs_shipment()) {
         $objTemplate->setVariable(array('TXT_SHIP_COUNTRY' => $_ARRAYLANG['TXT_SHIP_COUNTRY'], 'SHOP_COUNTRIES_MENU' => \Cx\Core\Country\Controller\Country::getMenu('countryId2', $_SESSION['shop']['countryId2'], true, "document.forms['shopForm'].submit()"), 'SHOP_COUNTRIES_MENUOPTIONS' => \Cx\Core\Country\Controller\Country::getMenuoptions($_SESSION['shop']['countryId2'])));
     }
     if (\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_min', 'Shop') > 0 && \Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_min', 'Shop') > self::get_price()) {
         $objTemplate->setVariable('MESSAGE_TEXT', sprintf($_ARRAYLANG['TXT_SHOP_ORDERITEMS_AMOUNT_MIN'], Currency::formatPrice(\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_min', 'Shop')), Currency::getActiveCurrencySymbol()));
     } elseif (\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_max', 'Shop') > 0 && \Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_max', 'Shop') < self::get_price()) {
         $objTemplate->setVariable('MESSAGE_TEXT', sprintf($_ARRAYLANG['TXT_SHOP_ORDERITEMS_AMOUNT_MAX'], Currency::formatPrice(\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_max', 'Shop')), Currency::getActiveCurrencySymbol()));
     } else {
         $objTemplate->setVariable('TXT_NEXT', $_ARRAYLANG['TXT_NEXT']);
     }
 }
Пример #2
0
 static function view_account()
 {
     global $_ARRAYLANG;
     // hide currency navbar
     self::$show_currency_navbar = false;
     self::account_to_session();
     // Only verify the form after it has been posted
     if (isset($_POST['lastname'])) {
         if (self::verify_account()) {
             self::_gotoPaymentPage();
         }
     }
     \JS::activate('jquery');
     self::$objTemplate->setGlobalVariable($_ARRAYLANG);
     // Use the details stored in the database as default.
     // Once the (changed) values are posted back, they are stored
     // in the session
     $company = isset($_SESSION['shop']['company']) ? $_SESSION['shop']['company'] : (self::$objCustomer ? self::$objCustomer->company() : '');
     $gender = isset($_SESSION['shop']['gender']) ? $_SESSION['shop']['gender'] : (self::$objCustomer ? self::$objCustomer->gender() : '');
     $lastname = isset($_SESSION['shop']['lastname']) ? $_SESSION['shop']['lastname'] : (self::$objCustomer ? self::$objCustomer->lastname() : '');
     $firstname = isset($_SESSION['shop']['firstname']) ? $_SESSION['shop']['firstname'] : (self::$objCustomer ? self::$objCustomer->firstname() : '');
     $address = isset($_SESSION['shop']['address']) ? $_SESSION['shop']['address'] : (self::$objCustomer ? self::$objCustomer->address() : '');
     $zip = isset($_SESSION['shop']['zip']) ? $_SESSION['shop']['zip'] : (self::$objCustomer ? self::$objCustomer->zip() : '');
     $city = isset($_SESSION['shop']['city']) ? $_SESSION['shop']['city'] : (self::$objCustomer ? self::$objCustomer->city() : '');
     $country_id = isset($_SESSION['shop']['countryId']) ? $_SESSION['shop']['countryId'] : (self::$objCustomer ? self::$objCustomer->country_id() : 0);
     $email = isset($_SESSION['shop']['email']) ? $_SESSION['shop']['email'] : (self::$objCustomer ? self::$objCustomer->email() : '');
     $phone = isset($_SESSION['shop']['phone']) ? $_SESSION['shop']['phone'] : (self::$objCustomer ? self::$objCustomer->phone() : '');
     $fax = isset($_SESSION['shop']['fax']) ? $_SESSION['shop']['fax'] : (self::$objCustomer ? self::$objCustomer->fax() : '');
     self::$objTemplate->setVariable(array('SHOP_ACCOUNT_COMPANY' => htmlentities($company, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_PREFIX' => Customers::getGenderMenuoptions($gender), 'SHOP_ACCOUNT_LASTNAME' => htmlentities($lastname, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_FIRSTNAME' => htmlentities($firstname, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_ADDRESS' => htmlentities($address, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_ZIP' => htmlentities($zip, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_CITY' => htmlentities($city, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_PHONE' => htmlentities($phone, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_FAX' => htmlentities($fax, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_ACTION' => \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'account'), 'SHOP_ACCOUNT_COUNTRY_MENUOPTIONS' => \Cx\Core\Country\Controller\Country::getMenuoptions($country_id), 'SHOP_ACCOUNT_COUNTRY' => \Cx\Core\Country\Controller\Country::getMenu('countryId', $country_id)));
     $register = \Cx\Core\Setting\Controller\Setting::getValue('register', 'Shop');
     /**
      * @internal  Heavy logic ahead!
      * Some optional parts are visible only in certain cases:
      * - When the setting "register" is set to "optional":
      *   - Checkbox "Don't register"
      * - When no Customer is logged in:
      *   - Input "E-mail"
      *   - When registration is mandatory, or if optional and "Don't register"
      *     is unchecked:
      *     - Input "Password"
      * Here's an overview of all cases:
      * ----------------------------------------------------------------
      *           |     Optional parts visible when registration is
      * Customer  |        off        |     optional      |  mandatory
      * ----------------------------------------------------------------
      * Logged in |         -         |         -         |      -
      *           | (Accounts may     |                   |
      *           | still be created  |                   |
      *           | in the backend)   |                   |
      * ----------------------------------------------------------------
      * Guest     | "E-mail"          | "E-mail",         | "E-mail"
      *           |                   | Checkbox          | Input
      *           | (Noone can        | "Don't register"; | "Password"
      *           | register)         | If not checked:   |
      *           |                   | Input "Password"  |
      * ----------------------------------------------------------------
      * Notes:
      *  - "Don't register" is only parsed into the page when applicable, namely
      *    in the combination "guest/optional".
      *  - "Password" is parsed into the page along with the "E-Mail" field,
      *    but hidden when not applicable.
      */
     $block_password = false;
     $dontRegisterChecked = false;
     // Touches the entire surrounding block
     self::$objTemplate->setVariable('SHOP_ACCOUNT_EMAIL', contrexx_raw2xhtml($email));
     if (!self::$objCustomer) {
         if ($register == ShopLibrary::REGISTER_OPTIONAL) {
             //\DBG::log("Shop::view_account(): Optional -> e-mail, touch 'dont_register'");
             self::$objTemplate->touchBlock('dont_register');
             if (empty($_SESSION['shop']['dont_register'])) {
                 //\DBG::log("Shop::view_account(): Register -> block password");
                 $block_password = true;
             } else {
                 $dontRegisterChecked = true;
             }
         }
         if ($register == ShopLibrary::REGISTER_NONE) {
             $_SESSION['shop']['dont_register'] = true;
         }
         if ($register == ShopLibrary::REGISTER_MANDATORY) {
             //\DBG::log("Shop::view_account(): Mandatory/None -> div password");
             $block_password = true;
         }
     } else {
         //\DBG::log("Shop::view_account(): Got Customer -> no block");
     }
     //\DBG::log("Shop::view_account(): block_password ".var_export($block_password, true));
     self::$objTemplate->setGlobalVariable(array('SHOP_ACCOUNT_PASSWORD_DISPLAY' => $block_password ? \Html::CSS_DISPLAY_BLOCK : \Html::CSS_DISPLAY_NONE, 'SHOP_DONT_REGISTER_CHECKED' => $dontRegisterChecked ? \Html::ATTRIBUTE_CHECKED : '', 'TXT_SHOP_ACCOUNT_PASSWORD_HINT' => \Cx\Core_Modules\Access\Controller\AccessLib::getPasswordInfo()));
     if (!Cart::needs_shipment()) {
         return;
     }
     if (!isset($_SESSION['shop']['equal_address'])) {
         $_SESSION['shop']['equal_address'] = true;
     }
     self::$objTemplate->setVariable(array('SHOP_ACCOUNT_COMPANY2' => empty($_SESSION['shop']['company2']) ? '' : htmlentities($_SESSION['shop']['company2'], ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_PREFIX2' => Customers::getGenderMenuoptions(empty($_SESSION['shop']['gender2']) ? '' : $_SESSION['shop']['gender2']), 'SHOP_ACCOUNT_LASTNAME2' => empty($_SESSION['shop']['lastname2']) ? '' : htmlentities($_SESSION['shop']['lastname2'], ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_FIRSTNAME2' => empty($_SESSION['shop']['firstname2']) ? '' : htmlentities($_SESSION['shop']['firstname2'], ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_ADDRESS2' => empty($_SESSION['shop']['address2']) ? '' : htmlentities($_SESSION['shop']['address2'], ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_ZIP2' => empty($_SESSION['shop']['zip2']) ? '' : htmlentities($_SESSION['shop']['zip2'], ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_CITY2' => empty($_SESSION['shop']['city2']) ? '' : htmlentities($_SESSION['shop']['city2'], ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_COUNTRY2' => \Cx\Core\Country\Controller\Country::getNameById($_SESSION['shop']['countryId2']), 'SHOP_ACCOUNT_COUNTRY2_ID' => $_SESSION['shop']['countryId2'], 'SHOP_ACCOUNT_PHONE2' => empty($_SESSION['shop']['phone2']) ? '' : htmlentities($_SESSION['shop']['phone2'], ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_ACCOUNT_EQUAL_ADDRESS' => empty($_SESSION['shop']['equal_address']) ? '' : \Html::ATTRIBUTE_CHECKED, 'SHOP_EQUAL_ADDRESS_CHECKED' => empty($_SESSION['shop']['equal_address']) ? '' : \Html::ATTRIBUTE_CHECKED, 'SHOP_SHIPPING_ADDRESS_DISPLAY' => empty($_SESSION['shop']['equal_address']) ? \Html::CSS_DISPLAY_BLOCK : \Html::CSS_DISPLAY_NONE));
 }
Пример #3
0
 /**
  * Set up the detail view of the selected order
  * @access  public
  * @param   \Cx\Core\Html\Sigma $objTemplate    The Template, by reference
  * @param   boolean             $edit           Edit if true, view otherwise
  * @global  ADONewConnection    $objDatabase    Database connection object
  * @global  array               $_ARRAYLANG     Language array
  * @return  boolean                             True on success,
  *                                              false otherwise
  * @static
  * @author  Reto Kohli <*****@*****.**> (parts)
  * @version 3.1.0
  */
 static function view_detail(&$objTemplate = null, $edit = false)
 {
     global $objDatabase, $_ARRAYLANG, $objInit;
     $backend = $objInit->mode == 'backend';
     if ($objTemplate->blockExists('order_list')) {
         $objTemplate->hideBlock('order_list');
     }
     $have_option = false;
     // The order total -- in the currency chosen by the customer
     $order_sum = 0;
     // recalculated VAT total
     $total_vat_amount = 0;
     $order_id = intval($_REQUEST['order_id']);
     if (!$order_id) {
         return \Message::error($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_INVALID_ORDER_ID']);
     }
     if (!$objTemplate) {
         $template_name = $edit ? 'module_shop_order_edit.html' : 'module_shop_order_details.html';
         $objTemplate = new \Cx\Core\Html\Sigma(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseModulePath() . '/Shop/View/Template/Backend');
         //DBG::log("Orders::view_list(): new Template: ".$objTemplate->get());
         $objTemplate->loadTemplateFile($template_name);
         //DBG::log("Orders::view_list(): loaded Template: ".$objTemplate->get());
     }
     $objOrder = Order::getById($order_id);
     if (!$objOrder) {
         //DBG::log("Shop::shopShowOrderdetails(): Failed to find Order ID $order_id");
         return \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_ORDER_NOT_FOUND'], $order_id));
     }
     // lsv data
     $query = "\n            SELECT `holder`, `bank`, `blz`\n              FROM " . DBPREFIX . "module_shop" . MODULE_INDEX . "_lsv\n             WHERE order_id={$order_id}";
     $objResult = $objDatabase->Execute($query);
     if (!$objResult) {
         return self::errorHandler();
     }
     if ($objResult->RecordCount() == 1) {
         $objTemplate->setVariable(array('SHOP_ACCOUNT_HOLDER' => contrexx_raw2xhtml($objResult->fields['holder']), 'SHOP_ACCOUNT_BANK' => contrexx_raw2xhtml($objResult->fields['bank']), 'SHOP_ACCOUNT_BLZ' => contrexx_raw2xhtml($objResult->fields['blz'])));
     }
     $customer_id = $objOrder->customer_id();
     if (!$customer_id) {
         //DBG::log("Shop::shopShowOrderdetails(): Invalid Customer ID $customer_id");
         \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_INVALID_CUSTOMER_ID'], $customer_id));
     }
     $objCustomer = Customer::getById($customer_id);
     if (!$objCustomer) {
         //DBG::log("Shop::shopShowOrderdetails(): Failed to find Customer ID $customer_id");
         \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_CUSTOMER_NOT_FOUND'], $customer_id));
         $objCustomer = new Customer();
         // No editing allowed!
         $have_option = true;
     }
     Vat::is_reseller($objCustomer->is_reseller());
     Vat::is_home_country(\Cx\Core\Setting\Controller\Setting::getValue('country_id', 'Shop') == $objOrder->country_id());
     $objTemplate->setGlobalVariable($_ARRAYLANG + array('SHOP_CURRENCY' => Currency::getCurrencySymbolById($objOrder->currency_id())));
     //DBG::log("Order sum: ".Currency::formatPrice($objOrder->sum()));
     $objTemplate->setVariable(array('SHOP_CUSTOMER_ID' => $customer_id, 'SHOP_ORDERID' => $order_id, 'SHOP_DATE' => date(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME, strtotime($objOrder->date_time())), 'SHOP_ORDER_STATUS' => $edit ? Orders::getStatusMenu($objOrder->status(), false, null, 'swapSendToStatus(this.value)') : $_ARRAYLANG['TXT_SHOP_ORDER_STATUS_' . $objOrder->status()], 'SHOP_SEND_MAIL_STYLE' => $objOrder->status() == Order::STATUS_CONFIRMED ? 'display: inline;' : 'display: none;', 'SHOP_SEND_MAIL_STATUS' => $edit ? $objOrder->status() != Order::STATUS_CONFIRMED ? \Html::ATTRIBUTE_CHECKED : '' : '', 'SHOP_ORDER_SUM' => Currency::formatPrice($objOrder->sum()), 'SHOP_DEFAULT_CURRENCY' => Currency::getDefaultCurrencySymbol(), 'SHOP_GENDER' => $edit ? Customer::getGenderMenu($objOrder->billing_gender(), 'billing_gender') : $_ARRAYLANG['TXT_SHOP_' . strtoupper($objOrder->billing_gender())], 'SHOP_COMPANY' => $objOrder->billing_company(), 'SHOP_FIRSTNAME' => $objOrder->billing_firstname(), 'SHOP_LASTNAME' => $objOrder->billing_lastname(), 'SHOP_ADDRESS' => $objOrder->billing_address(), 'SHOP_ZIP' => $objOrder->billing_zip(), 'SHOP_CITY' => $objOrder->billing_city(), 'SHOP_COUNTRY' => $edit ? \Cx\Core\Country\Controller\Country::getMenu('billing_country_id', $objOrder->billing_country_id()) : \Cx\Core\Country\Controller\Country::getNameById($objOrder->billing_country_id()), 'SHOP_PHONE' => $objOrder->billing_phone(), 'SHOP_FAX' => $objOrder->billing_fax(), 'SHOP_EMAIL' => $objOrder->billing_email(), 'SHOP_SHIP_GENDER' => $edit ? Customer::getGenderMenu($objOrder->gender(), 'shipPrefix') : $_ARRAYLANG['TXT_SHOP_' . strtoupper($objOrder->gender())], 'SHOP_SHIP_COMPANY' => $objOrder->company(), 'SHOP_SHIP_FIRSTNAME' => $objOrder->firstname(), 'SHOP_SHIP_LASTNAME' => $objOrder->lastname(), 'SHOP_SHIP_ADDRESS' => $objOrder->address(), 'SHOP_SHIP_ZIP' => $objOrder->zip(), 'SHOP_SHIP_CITY' => $objOrder->city(), 'SHOP_SHIP_COUNTRY' => $edit ? \Cx\Core\Country\Controller\Country::getMenu('shipCountry', $objOrder->country_id()) : \Cx\Core\Country\Controller\Country::getNameById($objOrder->country_id()), 'SHOP_SHIP_PHONE' => $objOrder->phone(), 'SHOP_PAYMENTTYPE' => Payment::getProperty($objOrder->payment_id(), 'name'), 'SHOP_CUSTOMER_NOTE' => $objOrder->note(), 'SHOP_COMPANY_NOTE' => $objCustomer->companynote(), 'SHOP_SHIPPING_TYPE' => $objOrder->shipment_id() ? Shipment::getShipperName($objOrder->shipment_id()) : '&nbsp;'));
     if ($backend) {
         $objTemplate->setVariable(array('SHOP_CUSTOMER_IP' => $objOrder->ip() ? '<a href="index.php?cmd=NetTools&amp;tpl=whois&amp;address=' . $objOrder->ip() . '" title="' . $_ARRAYLANG['TXT_SHOW_DETAILS'] . '">' . $objOrder->ip() . '</a>' : '&nbsp;', 'SHOP_CUSTOMER_HOST' => $objOrder->host() ? '<a href="index.php?cmd=NetTools&amp;tpl=whois&amp;address=' . $objOrder->host() . '" title="' . $_ARRAYLANG['TXT_SHOW_DETAILS'] . '">' . $objOrder->host() . '</a>' : '&nbsp;', 'SHOP_CUSTOMER_LANG' => \FWLanguage::getLanguageParameter($objOrder->lang_id(), 'name'), 'SHOP_CUSTOMER_BROWSER' => $objOrder->browser() ? $objOrder->browser() : '&nbsp;', 'SHOP_LAST_MODIFIED' => $objOrder->modified_on() && $objOrder->modified_on() != '0000-00-00 00:00:00' ? $objOrder->modified_on() . '&nbsp;' . $_ARRAYLANG['TXT_EDITED_BY'] . '&nbsp;' . $objOrder->modified_by() : $_ARRAYLANG['TXT_ORDER_WASNT_YET_EDITED']));
     } else {
         // Frontend: Order history ONLY.  Repeat the Order, go to cart
         $objTemplate->setVariable(array('SHOP_ACTION_URI_ENCODED' => \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'cart')));
     }
     $ppName = '';
     $psp_id = Payment::getPaymentProcessorId($objOrder->payment_id());
     if ($psp_id) {
         $ppName = PaymentProcessing::getPaymentProcessorName($psp_id);
     }
     $objTemplate->setVariable(array('SHOP_SHIPPING_PRICE' => $objOrder->shipment_amount(), 'SHOP_PAYMENT_PRICE' => $objOrder->payment_amount(), 'SHOP_PAYMENT_HANDLER' => $ppName, 'SHOP_LAST_MODIFIED_DATE' => $objOrder->modified_on()));
     if ($edit) {
         // edit order
         $strJsArrShipment = Shipment::getJSArrays();
         $objTemplate->setVariable(array('SHOP_SEND_TEMPLATE_TO_CUSTOMER' => sprintf($_ARRAYLANG['TXT_SEND_TEMPLATE_TO_CUSTOMER'], $_ARRAYLANG['TXT_ORDER_COMPLETE']), 'SHOP_SHIPPING_TYP_MENU' => Shipment::getShipperMenu($objOrder->country_id(), $objOrder->shipment_id(), "calcPrice(0);"), 'SHOP_JS_ARR_SHIPMENT' => $strJsArrShipment, 'SHOP_PRODUCT_IDS_MENU_NEW' => Products::getMenuoptions(null, null, $_ARRAYLANG['TXT_SHOP_PRODUCT_MENU_FORMAT']), 'SHOP_JS_ARR_PRODUCT' => Products::getJavascriptArray($objCustomer->group_id(), $objCustomer->is_reseller())));
     }
     $options = $objOrder->getOptionArray();
     if (!empty($options[$order_id])) {
         $have_option = true;
     }
     // Order items
     $total_weight = $i = 0;
     $total_net_price = $objOrder->view_items($objTemplate, $edit, $total_weight, $i);
     // Show VAT with the individual products:
     // If VAT is enabled, and we're both in the same country
     // ($total_vat_amount has been set above if both conditions are met)
     // show the VAT rate.
     // If there is no VAT, the amount is 0 (zero).
     //if ($total_vat_amount) {
     // distinguish between included VAT, and additional VAT added to sum
     $tax_part_percentaged = Vat::isIncluded() ? $_ARRAYLANG['TXT_TAX_PREFIX_INCL'] : $_ARRAYLANG['TXT_TAX_PREFIX_EXCL'];
     $objTemplate->setVariable(array('SHOP_TAX_PRICE' => Currency::formatPrice($total_vat_amount), 'SHOP_PART_TAX_PROCENTUAL' => $tax_part_percentaged));
     //} else {
     // No VAT otherwise
     // remove it from the details overview if empty
     //$objTemplate->hideBlock('taxprice');
     //$tax_part_percentaged = $_ARRAYLANG['TXT_NO_TAX'];
     //}
     // Parse Coupon if applicable to this product
     // Coupon
     $objCoupon = Coupon::getByOrderId($order_id);
     if ($objCoupon) {
         $discount = $objCoupon->discount_amount() != 0 ? $objCoupon->discount_amount() : $total_net_price / 100 * $objCoupon->discount_rate();
         $objTemplate->setVariable(array('SHOP_COUPON_NAME' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CODE'], 'SHOP_COUPON_CODE' => $objCoupon->code(), 'SHOP_COUPON_AMOUNT' => Currency::formatPrice(-$discount)));
         $total_net_price -= $discount;
         //DBG::log("Order::view_detail(): Coupon: ".var_export($objCoupon, true));
     }
     $objTemplate->setVariable(array('SHOP_ROWCLASS_NEW' => 'row' . (++$i % 2 + 1), 'SHOP_TOTAL_WEIGHT' => Weight::getWeightString($total_weight), 'SHOP_NET_PRICE' => Currency::formatPrice($total_net_price)));
     $objTemplate->setVariable(array('TXT_PRODUCT_ID' => $_ARRAYLANG['TXT_ID'], 'TXT_TAX_RATE' => Vat::isIncluded() ? $_ARRAYLANG['TXT_TAX_PREFIX_INCL'] : $_ARRAYLANG['TXT_TAX_PREFIX_EXCL'], 'TXT_SHOP_ACCOUNT_VALIDITY' => $_ARRAYLANG['TXT_SHOP_VALIDITY']));
     // Disable the "edit" button when there are Attributes
     if ($backend && !$edit) {
         if ($have_option) {
             if ($objTemplate->blockExists('order_no_edit')) {
                 $objTemplate->touchBlock('order_no_edit');
             }
         } else {
             if ($objTemplate->blockExists('order_edit')) {
                 $objTemplate->touchBlock('order_edit');
             }
         }
     }
     return true;
 }