function renderEntry($node, $level, $type) { if (in_array($this->_menuType, array('tree', 'sitemap', 'rows')) && $this->_tpl->blockExists($this->_prefix . ($level + 1) . '_' . $this->_typeNames[$type])) { $blockName = $this->_prefix . ($level + 1) . '_' . $this->_typeNames[$type]; } else { $blockName = $this->_prefix . $this->_typeNames[$type]; } if (('tree' == $this->_menuType || 'sitemap' == $this->_menuType) && $this->_tpl->blockExists($blockName . '_indent')) { for ($i = 0; $i < $level; $i++) { $this->_tpl->touchBlock($blockName . '_indent'); $this->_tpl->parse($blockName . '_indent'); } } foreach ($node as $k => $v) { if ('sub' != $k && $this->_tpl->placeholderExists($this->_prefix . $k, $blockName)) { $this->_tpl->setVariable($this->_prefix . $k, $v); } } $this->_tpl->parse($blockName); if ('rows' == $this->_menuType && $this->_tpl->blockExists($this->_prefix . ($level + 1) . '_entry_loop')) { $this->_tpl->parse($this->_prefix . ($level + 1) . '_entry_loop'); } else { $this->_tpl->parse($this->_prefix . 'entry_loop'); } }
function renderEntry($node, $level, $type) { // Close the entry if previous was on same or higher level if ($this->_level >= $level) { if ($this->_tpl->blockExists($this->_prefix . ($level + 1) . '_entry_close')) { $this->_tpl->touchBlock($this->_prefix . ($level + 1) . '_entry_close'); } else { $this->_tpl->touchBlock($this->_prefix . 'entry_close'); } $this->_tpl->parse($this->_prefix . 'tree_loop'); // If the new level is higher then open the level } else { if ($this->_tpl->blockExists($this->_prefix . ($level + 1) . '_level_open')) { $this->_tpl->touchBlock($this->_prefix . ($level + 1) . '_level_open'); } else { $this->_tpl->touchBlock($this->_prefix . 'level_open'); } $this->_tpl->parse($this->_prefix . 'tree_loop'); } // Open the entry if ($this->_tpl->blockExists($this->_prefix . ($level + 1) . '_entry_open')) { $this->_tpl->touchBlock($this->_prefix . ($level + 1) . '_entry_open'); } else { $this->_tpl->touchBlock($this->_prefix . 'entry_open'); } $this->_tpl->parse($this->_prefix . 'tree_loop'); if ($this->_tpl->blockExists($this->_prefix . ($level + 1) . '_' . $this->_typeNames[$type])) { $blockName = $this->_prefix . ($level + 1) . '_' . $this->_typeNames[$type]; } else { $blockName = $this->_prefix . $this->_typeNames[$type]; } foreach ($node as $k => $v) { if ('sub' != $k && $this->_tpl->placeholderExists($this->_prefix . $k, $blockName)) { $this->_tpl->setVariable($this->_prefix . $k, $v); } } $this->_tpl->parse($blockName); $this->_tpl->parse($this->_prefix . 'tree_loop'); $this->_level = $level; }
/** * Returns the name of a block to use for element rendering * * If a name was not explicitly set via setElementBlock(), it tries * the names '{prefix}_{element type}' and '{prefix}_{element}', where * prefix is either 'qf' or the name of the current group's block * * @param HTML_QuickForm_element form element being rendered * @access private * @return string block name */ function _matchBlock(&$element) { $name = $element->getName(); $type = $element->getType(); if (isset($this->_elementBlocks[$name]) && $this->_tpl->blockExists($this->_elementBlocks[$name])) { if (('group' == $type) || ($this->_elementBlocks[$name] . '_loop' != $this->_tpl->currentBlock)) { return $this->_elementBlocks[$name]; } } if ('group' != $type && 'qf_main_loop' != $this->_tpl->currentBlock) { $prefix = substr($this->_tpl->currentBlock, 0, -5); // omit '_loop' postfix } else { $prefix = 'qf'; } if ($this->_tpl->blockExists($prefix . '_' . $type)) { return $prefix . '_' . $type; } elseif ($this->_tpl->blockExists($prefix . '_' . $name)) { return $prefix . '_' . $name; } else { return $prefix . '_element'; } }
/** * View of this Orders' items * @global ADONewConnection $objDatabase * @global array $_ARRAYLANG * @param HTML_Template_Sigma $objTemplate The template * @param type $edit If true, items are editable * @param type $total_weight Initial value for the * total item weight, by * reference. * Usually empty or zero * @param type $i Initial value for the row * count, by reference. * Usually empty or zero. * @return float The net item sum on success, * false otherwise */ function view_items($objTemplate, $edit, &$total_weight = 0, $i = 0) { global $objDatabase, $_ARRAYLANG; // Order items // c_sp // Mind the custom price calculation $objCustomer = Customer::getById($this->customer_id); if (!$objCustomer) { \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_MISSING_CUSTOMER'], $this->customer_id)); $objCustomer = new Customer(); } $query = "\n SELECT `id`, `product_id`, `product_name`,\n `price`, `quantity`, `vat_rate`, `weight`\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_order_items`\n WHERE `order_id`=?"; $objResult = $objDatabase->Execute($query, array($this->id)); if (!$objResult) { return self::errorHandler(); } $arrProductOptions = $this->getOptionArray(); $total_vat_amount = 0; $total_net_price = 0; // Orders with Attributes cannot currently be edited // (this would spoil all the options!) // $have_option = false; while (!$objResult->EOF) { $item_id = $objResult->fields['id']; $name = $objResult->fields['product_name']; $price = $objResult->fields['price']; $quantity = $objResult->fields['quantity']; $vat_rate = $objResult->fields['vat_rate']; $product_id = $objResult->fields['product_id']; // Get missing product details $objProduct = Product::getById($product_id); if (!$objProduct) { \Message::warning(sprintf($_ARRAYLANG['TXT_SHOP_PRODUCT_NOT_FOUND'], $product_id)); $objProduct = new Product('', 0, $name, '', $price, 0, 0, 0, $product_id); } $code = $objProduct->code(); $distribution = $objProduct->distribution(); if (isset($arrProductOptions[$item_id])) { if ($edit) { // Edit options } else { //DBG::log("Order::view_items(): Item ID $item_id, Attributes: ".var_export($arrProductOptions[$item_id], true)); // Verify that options are properly shown foreach ($arrProductOptions[$item_id] as $attribute_id => $attribute) { //DBG::log("Order::view_items(): Added option, price: $options_price"); foreach ($attribute as $a) { $name .= '<i><br />- ' . $attribute_id . ': ' . $a['name'] . ' (' . $a['price'] . ')</i>'; $price += $a['price']; } } } } // c_sp $row_net_price = $price * $quantity; $row_price = $row_net_price; // VAT added later, if applicable $total_net_price += $row_net_price; // Here, the VAT has to be recalculated before setting up the // fields. If the VAT is excluded, it must be added here. // Note: the old Order.vat_amount field is no longer valid, // individual shop_order_items *MUST* have been UPDATEd by the // time PHP parses this line. // Also note that this implies that the vat_id and // country_id can be ignored, as they are considered when the // order is placed and the VAT is applied to the order // accordingly. // Calculate the VAT amount per row, included or excluded $row_vat_amount = Vat::amount($vat_rate, $row_net_price); //\DBG::log("$row_vat_amount = Vat::amount($vat_rate, $row_net_price)"); // and add it to the total VAT amount $total_vat_amount += $row_vat_amount; if (!Vat::isIncluded()) { // Add tax to price $row_price += $row_vat_amount; } //else { // VAT is disabled. // There shouldn't be any non-zero percentages in the order_items! // but if there are, there probably has been a change and we *SHOULD* // still treat them as if VAT had been enabled at the time the order // was placed! // That's why the else {} block is commented out. //} $weight = '-'; if ($distribution != 'download') { $weight = $objResult->fields['weight']; if (intval($weight) > 0) { $total_weight += $weight * $quantity; } } $itemHasOptions = !empty($arrProductOptions[$item_id]); $objTemplate->setVariable(array('SHOP_PRODUCT_ID' => $product_id, 'SHOP_ROWCLASS' => 'row' . (++$i % 2 + 1), 'SHOP_QUANTITY' => $quantity, 'SHOP_PRODUCT_NAME' => $name, 'SHOP_PRODUCT_PRICE' => Currency::formatPrice($price), 'SHOP_PRODUCT_SUM' => Currency::formatPrice($row_net_price), 'SHOP_P_ID' => $edit ? $item_id : $objResult->fields['product_id'], 'SHOP_PRODUCT_CODE' => $code, 'SHOP_PRODUCT_TAX_RATE' => $edit ? $vat_rate : Vat::format($vat_rate), 'SHOP_PRODUCT_TAX_AMOUNT' => Currency::formatPrice($row_vat_amount), 'SHOP_PRODUCT_WEIGHT' => Weight::getWeightString($weight), 'SHOP_ACCOUNT_VALIDITY' => \FWUser::getValidityString($weight))); // Get a product menu for each Product if $edit-ing. // Preselect the current Product ID. if ($edit) { if ($itemHasOptions && $objTemplate->blockExists('order_item_product_options_tooltip')) { $objTemplate->touchBlock('order_item_product_options_tooltip'); } $objTemplate->setVariable('SHOP_PRODUCT_IDS_MENU', Products::getMenuoptions($product_id, null, +$_ARRAYLANG['TXT_SHOP_PRODUCT_MENU_FORMAT'], false)); } $objTemplate->parse('order_item'); $objResult->MoveNext(); } return $total_net_price; }