/** * Make article view * * @param Tx_Commerce_Domain_Model_Article $article Article * @param Tx_Commerce_Domain_Model_Product $product Product * * @return string */ public function makeArticleView(Tx_Commerce_Domain_Model_Article $article, Tx_Commerce_Domain_Model_Product $product) { // Getting the select attributes for view $attCode = ''; if (is_object($product)) { $attributeArray = $product->getAttributeMatrix(array($article->getUid()), $this->selectAttributes); if (is_array($attributeArray)) { $templateAttr = $this->cObj->getSubpart($this->getTemplateCode(), '###BASKET_SELECT_ATTRIBUTES###'); foreach ($attributeArray as $attributeUid => $myAttribute) { /** * Attribute * * @var $attributeObj Tx_Commerce_Domain_Model_Attribute */ $attributeObj = GeneralUtility::makeInstance('Tx_Commerce_Domain_Model_Attribute', $attributeUid, $this->getFrontendController()->tmpl->setup['config.']['sys_language_uid']); $attributeObj->loadData(); $markerArray['###SELECT_ATTRIBUTES_TITLE###'] = $myAttribute['title']; $value = current(array_slice(each($myAttribute['values']), 1, 1)); $markerArray['###SELECT_ATTRIBUTES_VALUE###'] = $value['value']; $markerArray['###SELECT_ATTRIBUTES_UNIT###'] = $myAttribute['unit']; $attCode .= $this->cObj->substituteMarkerArray($templateAttr, $markerArray); } } } /** * Basket item * * @var Tx_Commerce_Domain_Model_BasketItem $basketItem */ $basketItem = $this->basket->getBasketItem($article->getUid()); $tmpArray = $this->generateMarkerArray($article->returnAssocArray(), (array) $this->conf['articleTS.'], 'article_', 'tx_commerce_articles'); $markerArray = array(); foreach ($tmpArray as $key => $value) { if (strpos($key, '#') === FALSE) { $markerArray['###' . $key . '###'] = $value; } } unset($tmpArray); $markerArray['###ARTICLE_SELECT_ATTRIBUTES###'] = $attCode; $markerArray['###ARTICLE_UID###'] = $article->getUid(); $markerArray['###STARTFRM###'] = '<form name="basket_' . $article->getUid() . '" action="' . $this->pi_getPageLink($this->conf['basketPid']) . '" method="post">'; $markerArray['###HIDDENFIELDS###'] = '<input type="hidden" name="' . $this->prefixId . '[catUid]" value="' . (int) $this->piVars['catUid'] . '" />'; $markerArray['###HIDDENFIELDS###'] .= '<input type="hidden" name="' . $this->prefixId . '[artAddUid][' . $article->getUid() . '][price_id]" value="' . $basketItem->getPriceUid() . '" />'; $markerArray['###ARTICLE_HIDDENFIELDS###'] = '<input type="hidden" name="' . $this->prefixId . '[catUid]" value="' . (int) $this->piVars['catUid'] . '" />'; $markerArray['###ARTICLE_HIDDENFIELDS###'] .= '<input type="hidden" name="' . $this->prefixId . '[artAddUid][' . $article->getUid() . '][price_id]" value="' . $basketItem->getPriceUid() . '" />'; $markerArray['###QTY_INPUT_VALUE###'] = $basketItem->getQuantity(); $markerArray['###QTY_INPUT_NAME###'] = $this->prefixId . '[artAddUid][' . $article->getUid() . '][count]'; $markerArray['###BASKET_ITEM_PRICENET###'] = Tx_Commerce_ViewHelpers_Money::format($basketItem->getPriceNet(), $this->currency); $markerArray['###BASKET_ITEM_PRICEGROSS###'] = Tx_Commerce_ViewHelpers_Money::format($basketItem->getPriceGross(), $this->currency); $markerArray['###BASKET_ITEM_PRICENETNOSCALE###'] = Tx_Commerce_ViewHelpers_Money::format($basketItem->getNoScalePriceNet(), $this->currency); $markerArray['###BASKET_ITEM_PRICEGROSSNOSCALE###'] = Tx_Commerce_ViewHelpers_Money::format($basketItem->getNoScalePriceGross(), $this->currency); $markerArray['###BASKET_ITEM_COUNT###'] = $basketItem->getQuantity(); $markerArray['###BASKET_ITEM_PRICESUM_NET###'] = Tx_Commerce_ViewHelpers_Money::format($basketItem->getItemSumNet(), $this->currency); $markerArray['###BASKET_ITEM_PRICESUM_GROSS###'] = Tx_Commerce_ViewHelpers_Money::format($basketItem->getItemSumGross(), $this->currency); // Link to delete this article in basket if (is_array($this->conf['deleteItem.'])) { $typoLinkConf = $this->conf['deleteItem.']; } else { $typoLinkConf = array(); } $typoLinkConf['parameter'] = $this->conf['basketPid']; $typoLinkConf['useCacheHash'] = 1; $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[catUid]=' . (int) $this->piVars['catUid']; $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[artAddUid][' . $article->getUid() . '][price_id]=' . $basketItem->getPriceUid(); $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[artAddUid][' . $article->getUid() . '][count]=0'; // DELIOTMFROMBASKETLINK is deprecated $markerArray['###DELETEFROMBASKETLINK###'] = $this->cObj->typoLink($this->pi_getLL('lang_basket_delete_item'), $typoLinkConf); $markerArray['###DELIOTMFROMBASKETLINK###'] = $markerArray['###DELETEFROMBASKETLINK###']; $templateMarker = '###PRODUCT_BASKET_FORM_SMALL###'; $template = $this->cObj->getSubpart($this->getTemplateCode(), $templateMarker); $markerArray = array_merge($markerArray, $this->languageMarker); if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['makeArticleView'])) { GeneralUtility::deprecationLog(' hook $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/pi2/class.tx_commerce_pi2.php\'][\'makeArticleView\'] is deprecated since commerce 1.0.0, it will be removed in commerce 1.4.0, please use instead $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/Classes/Controller/BasketController.php\'][\'makeArticleView\'] '); foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/pi2/class.tx_commerce_pi2.php']['makeArticleView'] as $classRef) { $hookObj = GeneralUtility::getUserObj($classRef); if (method_exists($hookObj, 'additionalMarker')) { $markerArray = $hookObj->additionalMarker($markerArray, $this, $article, $product, $this->basket->getBasketItem($article->getUid())); } } } if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Controller/BasketController.php']['makeArticleView'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Controller/BasketController.php']['makeArticleView'] as $classRef) { $hookObj = GeneralUtility::getUserObj($classRef); if (method_exists($hookObj, 'additionalMarker')) { $markerArray = $hookObj->additionalMarker($markerArray, $this, $article, $product, $this->basket->getBasketItem($article->getUid())); } } } $content = $this->cObj->substituteMarkerArray($template, $markerArray); return $content; }
/** * This method returns a general overview about the basket content. * It contains * - price of all articles (sum net) * - price for shipping and package * - netto sum * - sum for tax * - end sum (gross) * * @param string $type Marker subtype * * @return string Basket sum */ public function getBasketSum($type = 'WEB') { /** * Basket * * @var $basket Tx_Commerce_Domain_Model_Basket */ $basket = $GLOBALS['TSFE']->fe_user->tx_commerce_basket; $template = $this->cObj->getSubpart($this->templateCode, '###LISTING_BASKET_' . strtoupper($type) . '###'); $sumNet = $basket->getSumNet(); $sumGross = $basket->getSumGross(); $sumTax = $sumGross - $sumNet; $deliveryArticleArray = $basket->getArticlesByArticleTypeUidAsUidlist(DELIVERYARTICLETYPE); $sumShippingNet = 0; $sumShippingGross = 0; foreach ($deliveryArticleArray as $oneDeliveryArticle) { /** * Basket item * * @var Tx_Commerce_Domain_Model_BasketItem $basketItem */ $basketItem = $basket->getBasketItem($oneDeliveryArticle); $sumShippingNet += $basketItem->getPriceNet(); $sumShippingGross += $basketItem->getPriceGross(); } $paymentArticleArray = $basket->getArticlesByArticleTypeUidAsUidlist(PAYMENTARTICLETYPE); $sumPaymentNet = 0; $sumPaymentGross = 0; foreach ($paymentArticleArray as $onePaymentArticle) { /** * Basket item * * @var Tx_Commerce_Domain_Model_BasketItem $basketItem */ $basketItem = $basket->getBasketItem($onePaymentArticle); $sumPaymentNet += $basketItem->getPriceNet(); $sumPaymentGross += $basketItem->getPriceGross(); } $paymentTitle = $basket->getFirstArticleTypeTitle(PAYMENTARTICLETYPE); $markerArray = array(); $markerArray['###LABEL_SUM_ARTICLE_NET###'] = $this->pi_getLL('listing_article_net'); $markerArray['###LABEL_SUM_ARTICLE_GROSS###'] = $this->pi_getLL('listing_article_gross'); $markerArray['###SUM_ARTICLE_NET###'] = Tx_Commerce_ViewHelpers_Money::format($sumNet, $this->currency); $markerArray['###SUM_ARTICLE_GROSS###'] = Tx_Commerce_ViewHelpers_Money::format($sumGross, $this->currency); $markerArray['###LABEL_SUM_SHIPPING_NET###'] = $this->pi_getLL('listing_shipping_net'); $markerArray['###LABEL_SUM_SHIPPING_GROSS##'] = $this->pi_getLL('listing_shipping_gross'); $markerArray['###SUM_SHIPPING_NET###'] = Tx_Commerce_ViewHelpers_Money::format($sumShippingNet, $this->currency); $markerArray['###SUM_SHIPPING_GROSS###'] = Tx_Commerce_ViewHelpers_Money::format($sumShippingGross, $this->currency); $markerArray['###LABEL_SUM_NET###'] = $this->pi_getLL('listing_sum_net'); $markerArray['###SUM_NET###'] = Tx_Commerce_ViewHelpers_Money::format($sumNet, $this->currency); $markerArray['###LABEL_SUM_TAX###'] = $this->pi_getLL('listing_tax'); $markerArray['###SUM_TAX###'] = Tx_Commerce_ViewHelpers_Money::format($sumTax, $this->currency); $markerArray['###LABEL_SUM_GROSS###'] = $this->pi_getLL('listing_sum_gross'); $markerArray['###SUM_GROSS###'] = Tx_Commerce_ViewHelpers_Money::format($sumGross, $this->currency); $markerArray['###SUM_PAYMENT_NET###'] = Tx_Commerce_ViewHelpers_Money::format($sumPaymentNet, $this->currency); $markerArray['###SUM_PAYMENT_GROSS###'] = Tx_Commerce_ViewHelpers_Money::format($sumPaymentGross, $this->currency); $markerArray['###LABEL_SUM_PAYMENT_GROSS###'] = $this->pi_getLL('label_sum_payment_gross'); $markerArray['###LABEL_SUM_PAYMENT_NET###'] = $this->pi_getLL('label_sum_payment_net'); $markerArray['###PAYMENT_TITLE###'] = $paymentTitle; $hookObjectsArr = $this->getHookObjectArray('getBasketSum'); foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'ProcessMarker')) { $markerArray = $hookObj->ProcessMarker($markerArray, $this); } } return $this->cObj->substituteMarkerArray($template, $markerArray); }
/** * This method renders a product to a template * * @param Tx_Commerce_Domain_Model_Product $product Product * @param string $template TYPO3 Template * @param array $typoscript TypoScript * @param array $articleMarker Marker for the article description * @param string $articleSubpart Subpart * * @return string rendered HTML */ public function renderProduct(Tx_Commerce_Domain_Model_Product $product, $template, array $typoscript, array $articleMarker, $articleSubpart = '') { if (!$product instanceof Tx_Commerce_Domain_Model_Product) { return FALSE; } if (empty($articleMarker)) { return $this->error('renderProduct', __LINE__, 'No ArticleMarker defined in renderProduct '); } $hookObjectsArr = array(); if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['product'])) { GeneralUtility::deprecationLog(' hook $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/lib/class.tx_commerce_pibase.php\'][\'product\'] is deprecated since commerce 1.0.0, it will be removed in commerce 1.4.0, please use instead $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/Classes/Controller/BaseController.php\'][\'renderProduct\'] '); foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['product'] as $classRef) { $hookObjectsArr[] =& GeneralUtility::getUserObj($classRef); } } if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Controller/BaseController.php']['renderProduct'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Controller/BaseController.php']['renderProduct'] as $classRef) { $hookObjectsArr[] =& GeneralUtility::getUserObj($classRef); } } $data = $product->returnAssocArray(); // maybe this is a related product so category may be wrong $categoryUid = $this->category->getUid(); $productCategories = $product->getParentCategories(); if (!in_array($categoryUid, $productCategories, FALSE)) { $categoryUid = $productCategories[0]; } /** * Build TS for Linking the Catergory Images */ $localTs = $typoscript; /** * Generate TypoLink Configuration and ad to fields by addTypoLinkToTs */ if ($this->conf['overridePid']) { $typoLinkConf['parameter'] = $this->conf['overridePid']; } else { $typoLinkConf['parameter'] = $this->pid; } $typoLinkConf['useCacheHash'] = 1; $typoLinkConf['additionalParams'] = $this->argSeparator . $this->prefixId . '[showUid]=' . $product->getUid(); $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[catUid]=' . $categoryUid; if ($this->basketHashValue) { $typoLinkConf['additionalParams'] .= $this->argSeparator . $this->prefixId . '[basketHashValue]=' . $this->basketHashValue; } $localTs = $this->addTypoLinkToTypoScript($localTs, $typoLinkConf); $markerArray = $this->generateMarkerArray($data, $localTs, '', 'Tx_Commerce_Domain_Model_Products'); $markerArrayUp = array(); foreach ($markerArray as $k => $v) { $markerArrayUp[strtoupper($k)] = $v; } $markerArray = $this->cObj->fillInMarkerArray(array(), $markerArrayUp, implode(',', array_keys($markerArrayUp)), FALSE, 'PRODUCT_'); $this->can_attributes = $product->getAttributes(array(ATTRIB_CAN)); $this->selectAttributes = $product->getAttributes(array(ATTRIB_SELECTOR)); $this->shall_attributes = $product->getAttributes(array(ATTRIB_SHAL)); $productAttributesSubpartArray = array(); $productAttributesSubpartArray[] = '###' . strtoupper($this->conf['templateMarker.']['productAttributes']) . '###'; $productAttributesSubpartArray[] = '###' . strtoupper($this->conf['templateMarker.']['productAttributes2']) . '###'; $markerArray['###SUBPART_PRODUCT_ATTRIBUTES###'] = $this->cObj->stdWrap($this->renderProductAttributeList($product, $productAttributesSubpartArray, $typoscript['productAttributes.']['fields.']), $typoscript['productAttributes.']); $linkArray = array(); $linkArray['catUid'] = (int) $categoryUid; if ($this->basketHashValue) { $linkArray['basketHashValue'] = $this->basketHashValue; } if (is_numeric($this->piVars['manufacturer'])) { $linkArray['manufacturer'] = $this->piVars['manufacturer']; } if (is_numeric($this->piVars['mDepth'])) { $linkArray['mDepth'] = $this->piVars['mDepth']; } foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'postProcessLinkArray')) { $linkArray = $hookObj->postProcessLinkArray($linkArray, $product, $this); } } $wrapMarkerArray['###PRODUCT_LINK_DETAIL###'] = explode('|', $this->pi_list_linkSingle('|', $product->getUid(), TRUE, $linkArray, FALSE, $this->conf['overridePid'])); $articleTemplate = $this->cObj->getSubpart($template, '###' . strtoupper($articleSubpart) . '###'); if ($this->conf['useStockHandling'] == 1) { $product = Tx_Commerce_Utility_GeneralUtility::removeNoStockArticles($product, $this->conf['articles.']['showWithNoStock']); } // Set RenderMaxArticles to TS value if (!empty($localTs['maxArticles']) && (int) $localTs['maxArticles'] > 0) { $product->setRenderMaxArticles((int) $localTs['maxArticles']); } $subpartArray = array(); if ($this->conf['disableArticleViewForProductlist'] == 1 && !$this->piVars['showUid'] || $this->conf['disableArticleView'] == 1) { $subpartArray['###' . strtoupper($articleSubpart) . '###'] = ''; } else { $subpartArray['###' . strtoupper($articleSubpart) . '###'] = $this->makeArticleView('list', array(), $product, $articleMarker, $articleTemplate); } /** * Get The Checapest Price */ $cheapestArticleUid = $product->getCheapestArticle(); /** * Cheapest Article * * @var Tx_Commerce_Domain_Model_Article $cheapestArticle */ $cheapestArticle = GeneralUtility::makeInstance('Tx_Commerce_Domain_Model_Article', $cheapestArticleUid); $cheapestArticle->loadData(); $cheapestArticle->loadPrices(); $markerArray['###PRODUCT_CHEAPEST_PRICE_GROSS###'] = Tx_Commerce_ViewHelpers_Money::format($cheapestArticle->getPriceGross(), $this->currency); $cheapestArticleUid = $product->getCheapestArticle(1); /** * Cheapest Article * * @var Tx_Commerce_Domain_Model_Article $cheapestArticle */ $cheapestArticle = GeneralUtility::makeInstance('Tx_Commerce_Domain_Model_Article', $cheapestArticleUid); $cheapestArticle->loadData(); $cheapestArticle->loadPrices(); $markerArray['###PRODUCT_CHEAPEST_PRICE_NET###'] = Tx_Commerce_ViewHelpers_Money::format($cheapestArticle->getPriceNet(), $this->currency); foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'additionalMarkerProduct')) { $markerArray = $hookObj->additionalMarkerProduct($markerArray, $product, $this); } } foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'additionalSubpartsProduct')) { $subpartArray = $hookObj->additionalSubpartsProduct($subpartArray, $product, $this); } } $content = $this->substituteMarkerArrayNoCached($template, $markerArray, $subpartArray, $wrapMarkerArray); if ($typoscript['editPanel'] == 1) { $content = $this->cObj->editPanel($content, $typoscript['editPanel.'], 'Tx_Commerce_Domain_Model_Products:' . $product->getUid()); } foreach ($hookObjectsArr as $hookObj) { if (method_exists($hookObj, 'ModifyContentProduct')) { $content = $hookObj->ModifyContentProduct($content, $product, $this); } } return $content; }
/** * Render marker array for System Articles * * @param int $orderUid OrderUID * @param int $articleType Optional, articleTypeID * @param string $prefix Prefix * * @return array System Articles */ protected function getOrderSystemArticles($orderUid, $articleType = 0, $prefix) { $database = $this->getDatabaseConnection(); $queryString = 'order_uid=' . $orderUid . ' '; if ($articleType) { $queryString .= ' AND article_type_uid = ' . $articleType . ' '; } $queryString .= $this->cObj->enableFields('tx_commerce_order_articles'); $res = $database->exec_SELECTquery('*', 'tx_commerce_order_articles', $queryString); $content = ''; while ($row = $database->sql_fetch_assoc($res)) { $subpart = $this->cObj->getSubpart($this->templateCode, '###LISTING_' . $prefix . 'ROW###'); // @todo Use $markerArray = $this->generateMarkerArray($row,'',$prefix); $markerArray['###' . $prefix . 'AMOUNT###'] = $row['amount']; $markerArray['###' . $prefix . 'METHOD###'] = $row['title']; $markerArray['###' . $prefix . 'COST###'] = Tx_Commerce_ViewHelpers_Money::format($row['amount'] * $row['price_gross'], $this->conf['currency'], (bool) $this->conf['showCurrencySign']); $content .= $this->cObj->substituteMarkerArray($subpart, $markerArray); } return $content; }
/** * Oder Articles * Renders the List of aricles * * @param array $parameter Parameter * * @return string HTML-Content */ public function orderArticles(array $parameter) { $database = $this->getDatabaseConnection(); $language = $this->getLanguageService(); $content = ''; $foreignTable = 'tx_commerce_order_articles'; $table = 'tx_commerce_orders'; /** * Document template * * @var \TYPO3\CMS\Backend\Template\DocumentTemplate $doc */ $doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate'); $doc->backPath = $GLOBALS['BACK_PATH']; /** * GET Storage PID and order_id from Data */ $orderStoragePid = $parameter['row']['pid']; $orderId = $parameter['row']['order_id']; /** * Select Order_articles */ // @todo TS config of fields in list $fieldRows = array('amount', 'title', 'article_number', 'price_net', 'price_gross'); /** * Taken from class.db_list_extra.php */ $titleCol = $GLOBALS['TCA'][$foreignTable]['ctrl']['label']; // Check if Orders in this folder are editable $orderEditable = FALSE; $checkResult = $database->exec_SELECTquery('tx_commerce_foldereditorder', 'pages', 'uid = ' . $orderStoragePid); if ($database->sql_num_rows($checkResult) == 1) { if ($checkRow = $database->sql_fetch_assoc($checkResult)) { if ($checkRow['tx_commerce_foldereditorder'] == 1) { $orderEditable = TRUE; } } } // Create the SQL query for selecting the elements in the listing: $result = $database->exec_SELECTquery('*', $foreignTable, 'pid = ' . $orderStoragePid . BackendUtility::deleteClause($foreignTable) . ' AND order_id = \'' . $database->quoteStr($orderId, $foreignTable) . '\''); $dbCount = $database->sql_num_rows($result); $sum = array(); $out = ''; if ($dbCount) { /** * Only if we have a result */ $theData[$titleCol] = '<span class="c-table">' . $language->sL('LLL:EXT:commerce/Resources/Private/Language/locallang_be.xml:order_view.items.article_list', 1) . '</span> (' . $dbCount . ')'; $extConf = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][COMMERCE_EXTKEY]['extConf']; if ($extConf['invoicePageID'] > 0) { $theData[$titleCol] .= '<a href="../index.php?id=' . $extConf['invoicePageID'] . '&tx_commerce_pi6[order_id]=' . $orderId . '&type=' . $extConf['invoicePageType'] . '" target="_blank">' . $language->sL('LLL:EXT:commerce/Resources/Private/Language/locallang_be.xml:order_view.items.print_invoice', 1) . ' *</a>'; } $colCount = count($fieldRows); $out .= ' <tr> <td class="c-headLineTable" style="width: 95%;" colspan="' . ($colCount + 1) . '">' . $theData[$titleCol] . '</td> </tr>'; /** * Header colum */ foreach ($fieldRows as $field) { $out .= '<td class="c-headLineTable"><b>' . $language->sL(BackendUtility::getItemLabel($foreignTable, $field)) . '</b></td>'; } $out .= '<td class="c-headLineTable"></td></tr>'; // @todo Switch to moneylib to use formating $cc = 0; $iOut = ''; while ($row = $database->sql_fetch_assoc($result)) { $cc++; $sum['amount'] += $row['amount']; if ($parameter['row']['pricefromnet'] == 1) { $row['price_net'] = $row['price_net'] * $row['amount']; $row['price_gross'] = $row['price_net'] * (1 + (double) $row['tax'] / 100); } else { $row['price_gross'] = $row['price_gross'] * $row['amount']; $row['price_net'] = $row['price_gross'] / (1 + (double) $row['tax'] / 100); } $sum['price_net_value'] += $row['price_net']; $sum['price_gross_value'] += $row['price_gross']; $row['price_net'] = Tx_Commerce_ViewHelpers_Money::format(intval(round($row['price_net'])), ''); $row['price_gross'] = Tx_Commerce_ViewHelpers_Money::format(intval(round($row['price_gross'])), ''); $rowBgColor = $cc % 2 ? '' : ' bgcolor="' . GeneralUtility::modifyHTMLColor($GLOBALS['SOBE']->doc->bgColor4, +10, +10, +10) . '"'; /** * Not very noice to render html_code directly * @todo change rendering html code here */ $iOut .= '<tr ' . $rowBgColor . '>'; foreach ($fieldRows as $field) { $wrap = array('', ''); switch ($field) { case $titleCol: $iOut .= '<td>'; if ($orderEditable) { $params = '&edit[' . $foreignTable . '][' . $row['uid'] . ']=edit'; $wrap = array('<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])) . '">', '</a>'); } break; case 'amount': $iOut .= '<td>'; if ($orderEditable) { $params = '&edit[' . $foreignTable . '][' . $row['uid'] . ']=edit&columnsOnly=amount'; $onclickAction = 'onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $GLOBALS['BACK_PATH'])) . '"'; $wrap = array('<b><a href="#" ' . $onclickAction . '>' . IconUtility::getSpriteIcon('actions-document-open'), '</a></b>'); } break; case 'price_net': // fall through // fall through case 'price_gross': $iOut .= '<td style="text-align: right">'; break; default: $iOut .= '<td>'; } $iOut .= implode(BackendUtility::getProcessedValue($foreignTable, $field, $row[$field], 100), $wrap); $iOut .= '</td>'; } /** * Trash icon */ $iOut .= '<td></td> </tr>'; } $out .= $iOut; /** * Cerate the sum row */ $out .= '<tr>'; $sum['price_net'] = Tx_Commerce_ViewHelpers_Money::format(intval(round($sum['price_net_value'])), ''); $sum['price_gross'] = Tx_Commerce_ViewHelpers_Money::format(intval(round($sum['price_gross_value'])), ''); foreach ($fieldRows as $field) { switch ($field) { case 'price_net': // fall through // fall through case 'price_gross': $out .= '<td class="c-headLineTable" style="text-align: right"><b>'; break; default: $out .= '<td class="c-headLineTable"><b>'; } if ($sum[$field] != '') { $out .= BackendUtility::getProcessedValueExtra($foreignTable, $field, $sum[$field], 100); } $out .= '</b></td>'; } $out .= '<td class="c-headLineTable"></td></tr>'; } $out = ' <!-- DB listing of elements: "' . htmlspecialchars($table) . '" --> <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist"> ' . $out . ' </table>'; $content .= $out; return $content; }
/** * Rendering a single row for the list * * @param string $table Table name * @param array $row Current record * @param int $cc Counter, counting for each time an element is rendered * (used for alternating colors) * @param string $titleCol Table field (column) where header value is found * @param string $thumbsCol Table field (column) where (possible) thumbnails * can be found * @param int $indent Indent from left. * * @return string Table row for the element * @see getTable() */ public function renderListRow($table, array $row, $cc, $titleCol, $thumbsCol, $indent = 0) { $database = $this->getDatabaseConnection(); $language = $this->getLanguageService(); $iOut = ''; if (substr(TYPO3_version, 0, 3) >= '4.0') { // In offline workspace, look for alternative record: BackendUtility::workspaceOL($table, $row, $GLOBALS['BE_USER']->workspace); } // Background color, if any: $rowBackgroundColor = ''; if ($this->alternateBgColors) { $rowBackgroundColor = $cc % 2 ? '' : ' bgcolor="' . GeneralUtility::modifyHTMLColor($GLOBALS['SOBE']->doc->bgColor4, 10, 10, 10) . '"'; } // Overriding with versions background color if any: $rowBackgroundColor = $row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : $rowBackgroundColor; // Initialization $alttext = BackendUtility::getRecordIconAltText($row, $table); // Incr. counter. $this->counter++; $indentStyle = $indent ? ' style="margin-left: ' . $indent . 'px;"' : ''; $iconAttributes = 'title="' . htmlspecialchars($alttext) . '"' . $indentStyle; // Icon for order comment and delivery address $iconPath = ''; $iconImg = ''; if ($row['comment'] != '' && $row['internalcomment'] != '') { if ($row['tx_commerce_address_type_id'] == 2) { $iconPath = 'orders_add_user_int.gif'; } else { $iconPath = 'orders_user_int.gif'; } } elseif ($row['comment'] != '') { if ($row['tx_commerce_address_type_id'] == 2) { $iconPath = 'orders_add_user.gif'; } else { $iconPath = 'orders_user.gif'; } } elseif ($row['internalcomment'] != '') { if ($row['tx_commerce_address_type_id'] == 2) { $iconPath = 'orders_add_int.gif'; } else { $iconPath = 'orders_int.gif'; } } else { if ($row['tx_commerce_address_type_id'] == 2) { $iconPath = 'orders_add.gif'; } else { $iconImg = '<img' . IconUtility::skinImg($this->backPath, IconUtility::getIcon($table, $row), $iconAttributes) . '/>'; } } if ($iconPath != '') { $iconImg = '<img' . IconUtility::skinImg($this->backPath, PATH_TXCOMMERCE_REL . 'Resources/Public/Icons/Table/' . $iconPath, $iconAttributes) . '/>'; } $theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg; $extConf = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][COMMERCE_EXTKEY]['extConf']; // Preparing and getting the data-array $theData = array(); foreach ($this->fieldArray as $fCol) { if ($fCol == 'pid') { $theData[$fCol] = $row[$fCol]; } elseif ($fCol == 'sum_price_gross') { if ($this->csvOutput) { $row[$fCol] = $row[$fCol] / 100; } else { $theData[$fCol] = Tx_Commerce_ViewHelpers_Money::format($row[$fCol], $row['cu_iso_3'], FALSE); } } elseif ($fCol == 'crdate') { $theData[$fCol] = BackendUtility::date($row[$fCol]); $row[$fCol] = BackendUtility::date($row[$fCol]); } elseif ($fCol == 'tstamp') { $theData[$fCol] = BackendUtility::date($row[$fCol]); $row[$fCol] = BackendUtility::date($row[$fCol]); } elseif ($fCol == 'articles') { $articleNumber = array(); $articleName = array(); $resArticles = $database->exec_SELECTquery('article_number, title, order_uid', 'tx_commerce_order_articles', 'order_uid = ' . (int) $row['uid']); $articles = array(); while ($lokalRow = $database->sql_fetch_assoc($resArticles)) { $articles[] = $lokalRow['article_number'] . ':' . $lokalRow['title']; $articleNumber[] = $lokalRow['article_number']; $articleName[] = $lokalRow['title']; } if ($this->csvOutput) { $theData[$fCol] = implode(',', $articles); $row[$fCol] = implode(',', $articles); } else { $theData[$fCol] = '<input type="checkbox" name="orderUid[]" value="' . $row['uid'] . '">'; } } elseif ($fCol == 'numarticles') { $resArticles = $database->exec_SELECTquery('sum(amount) amount', 'tx_commerce_order_articles', 'order_uid = ' . (int) $row['uid'] . ' and article_type_uid =' . NORMALARTICLETYPE); if ($lokalRow = $database->sql_fetch_assoc($resArticles)) { $theData[$fCol] = $lokalRow['amount']; $row[$fCol] = $lokalRow['amount']; } } elseif ($fCol == 'article_number') { $articleNumber = array(); $resArticles = $database->exec_SELECTquery('article_number', 'tx_commerce_order_articles', 'order_uid = ' . (int) $row['uid'] . ' and article_type_uid =' . NORMALARTICLETYPE); while ($lokalRow = $database->sql_fetch_assoc($resArticles)) { $articleNumber[] = $lokalRow['article_number'] ? $lokalRow['article_number'] : $language->sL('no_article_number'); } $theData[$fCol] = implode(',', $articleNumber); } elseif ($fCol == 'article_name') { $articleName = array(); $resArticles = $database->exec_SELECTquery('title', 'tx_commerce_order_articles', 'order_uid = ' . (int) $row['uid'] . ' and article_type_uid =' . NORMALARTICLETYPE); while ($lokalRow = $database->sql_fetch_assoc($resArticles)) { $articleName[] = $lokalRow['title'] ? $lokalRow['title'] : $language->sL('no_article_title'); } $theData[$fCol] = implode(',', $articleName); } elseif ($fCol == 'order_type_uid_noName') { $typesResult = $database->exec_SELECTquery('*', 'tx_commerce_order_types', 'uid = ' . (int) $row['order_type_uid_noName']); while ($localRow = $database->sql_fetch_assoc($typesResult)) { if ($localRow['icon']) { $filepath = $this->backPath . $GLOBALS['TCA']['tx_commerce_order_types']['columns']['icon']['config']['uploadfolder'] . '/' . $localRow['icon']; $theData[$fCol] = '<img' . IconUtility::skinImg($this->backPath, $filepath, 'title="' . htmlspecialchars($localRow['title']) . '"' . $indentStyle); } else { $theData[$fCol] = $localRow['title']; } } } elseif ($fCol == '_PATH_') { $theData[$fCol] = $this->recPath($row['pid']); } elseif ($fCol == '_CONTROL_') { $theData[$fCol] = $this->makeControl($table, $row); } elseif ($fCol == '_CLIPBOARD_') { $theData[$fCol] = $this->makeClip($table, $row); } elseif ($fCol == '_LOCALIZATION_') { list($lC1, $lC2) = $this->makeLocalizationPanel($table, $row); $theData[$fCol] = $lC1; $theData[$fCol . 'b'] = $lC2; } elseif ($fCol == '_LOCALIZATION_b') { // Do nothing, has been done above. $theData[$fCol] .= ''; } elseif ($fCol == 'order_id') { $theData[$fCol] = $row[$fCol]; } else { $theData[$fCol] = $this->linkUrlMail(htmlspecialchars(BackendUtility::getProcessedValueExtra($table, $fCol, $row[$fCol], 100, $row['uid'])), $row[$fCol]); } } // Add row to CSV list: if ($this->csvOutput) { // Charset Conversion /** * Charset converter * * @var \TYPO3\CMS\Core\Charset\CharsetConverter $csObj */ $csObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Charset\\CharsetConverter'); $csObj->initCharset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']); if (!$extConf['BECSVCharset']) { $extConf['BECSVCharset'] = 'iso-8859-1'; } $csObj->initCharset($extConf['BECSVCharset']); $csObj->convArray($row, $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'], $extConf['BECSVCharset']); $this->addToCSV($row); } // Create element in table cells: $iOut .= $this->addelement(1, $theIcon, $theData, $rowBackgroundColor); // Render thumbsnails if a thumbnail column exists and there is content in it: if ($this->thumbs && trim($row[$thumbsCol])) { $iOut .= $this->addelement(4, '', array($titleCol => $this->thumbCode($row, $table, $thumbsCol)), $rowBackgroundColor); } // Finally, return table row element: return $iOut; }