/**
  * Make article view.
  *
  * @param Article $article Article
  * @param Product $product Product
  *
  * @return string
  */
 public function makeArticleView(Article $article, 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 \CommerceTeam\Commerce\Domain\Model\Attribute $attribute
                  */
                 $attribute = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Attribute', $attributeUid, $this->getFrontendController()->sys_language_uid);
                 $attribute->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 \CommerceTeam\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###'] = Money::format($basketItem->getPriceNet(), $this->currency);
     $markerArray['###BASKET_ITEM_PRICEGROSS###'] = Money::format($basketItem->getPriceGross(), $this->currency);
     $markerArray['###BASKET_ITEM_PRICENETNOSCALE###'] = Money::format($basketItem->getNoScalePriceNet(), $this->currency);
     $markerArray['###BASKET_ITEM_PRICEGROSSNOSCALE###'] = Money::format($basketItem->getNoScalePriceGross(), $this->currency);
     $markerArray['###BASKET_ITEM_COUNT###'] = $basketItem->getQuantity();
     $markerArray['###BASKET_ITEM_PRICESUM_NET###'] = Money::format($basketItem->getItemSumNet(), $this->currency);
     $markerArray['###BASKET_ITEM_PRICESUM_GROSS###'] = 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';
     $markerArray['###DELETEFROMBASKETLINK###'] = $this->cObj->typoLink($this->pi_getLL('lang_basket_delete_item'), $typoLinkConf);
     $templateMarker = '###PRODUCT_BASKET_FORM_SMALL###';
     $template = $this->cObj->getSubpart($this->getTemplateCode(), $templateMarker);
     $markerArray = array_merge($markerArray, $this->languageMarker);
     $hooks = HookFactory::getHooks('Controller/BasketController', 'makeArticleView');
     foreach ($hooks as $hook) {
         if (method_exists($hook, 'additionalMarker')) {
             $markerArray = $hook->additionalMarker($markerArray, $this, $article, $product, $this->basket->getBasketItem($article->getUid()));
         }
     }
     $content = $this->cObj->substituteMarkerArray($template, $markerArray);
     return $content;
 }
Example #2
0
 /**
  * This method renders a product to a template.
  *
  * @param 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(Product $product, $template, array $typoscript, array $articleMarker, $articleSubpart = '')
 {
     if (!$product instanceof Product) {
         return '';
     }
     if (empty($articleMarker)) {
         return $this->error('renderProduct', __LINE__, 'No ArticleMarker defined in renderProduct ');
     }
     $hooks = HookFactory::getHooks('Controller/BaseController', 'renderProduct');
     $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;
     $typoLinkConf = array('useCacheHash' => 1);
     /*
      * Generate TypoLink Configuration and ad to fields by addTypoLinkToTs
      */
     if ($this->conf['singlePid']) {
         $typoLinkConf['parameter'] = $this->conf['singlePid'];
     } elseif ($this->conf['overridePid']) {
         $typoLinkConf['parameter'] = $this->conf['overridePid'];
     } else {
         $typoLinkConf['parameter'] = $this->pid;
     }
     $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_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 ($hooks 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 = \CommerceTeam\Commerce\Utility\GeneralUtility::removeNoStockArticles($product, $this->conf['articles.']['showWithNoStock']);
     }
     // Set RenderMaxArticles to TS value
     if (isset($localTs['maxArticles']) && (int) $localTs['maxArticles']) {
         $product->setRenderMaxArticles($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 Article $cheapestArticle
      */
     $cheapestArticle = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Article', $cheapestArticleUid);
     $cheapestArticle->loadData();
     $cheapestArticle->loadPrices();
     $markerArray['###PRODUCT_CHEAPEST_PRICE_GROSS###'] = Money::format($cheapestArticle->getPriceGross(), $this->currency);
     $cheapestArticleUid = $product->getCheapestArticle(1);
     /**
      * Cheapest Article.
      *
      * @var Article $cheapestArticle
      */
     $cheapestArticle = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Model\\Article', $cheapestArticleUid);
     $cheapestArticle->loadData();
     $cheapestArticle->loadPrices();
     $markerArray['###PRODUCT_CHEAPEST_PRICE_NET###'] = Money::format($cheapestArticle->getPriceNet(), $this->currency);
     foreach ($hooks as $hookObj) {
         if (method_exists($hookObj, 'additionalMarkerProduct')) {
             $markerArray = $hookObj->additionalMarkerProduct($markerArray, $product, $this);
         }
     }
     foreach ($hooks 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_products:' . $product->getUid());
     }
     foreach ($hooks as $hookObj) {
         if (method_exists($hookObj, 'modifyContentProduct')) {
             $content = $hookObj->modifyContentProduct($content, $product, $this);
         }
     }
     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 = $this->getBasket();
     $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 \CommerceTeam\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 \CommerceTeam\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###'] = Money::format($sumNet, $this->currency);
     $markerArray['###SUM_ARTICLE_GROSS###'] = 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###'] = Money::format($sumShippingNet, $this->currency);
     $markerArray['###SUM_SHIPPING_GROSS###'] = Money::format($sumShippingGross, $this->currency);
     $markerArray['###LABEL_SUM_NET###'] = $this->pi_getLL('listing_sum_net');
     $markerArray['###SUM_NET###'] = Money::format($sumNet, $this->currency);
     $markerArray['###LABEL_SUM_TAX###'] = $this->pi_getLL('listing_tax');
     $markerArray['###SUM_TAX###'] = Money::format($sumTax, $this->currency);
     $markerArray['###LABEL_SUM_GROSS###'] = $this->pi_getLL('listing_sum_gross');
     $markerArray['###SUM_GROSS###'] = Money::format($sumGross, $this->currency);
     $markerArray['###SUM_PAYMENT_NET###'] = Money::format($sumPaymentNet, $this->currency);
     $markerArray['###SUM_PAYMENT_GROSS###'] = 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;
     $hooks = HookFactory::getHooks('Controller/CheckoutController', 'getBasketSum');
     foreach ($hooks as $hook) {
         if (method_exists($hook, 'processMarker')) {
             $markerArray = $hook->processMarker($markerArray, $this);
         }
     }
     return $this->cObj->substituteMarkerArray($template, $markerArray);
 }
 /**
  * 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
  */
 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, $this->getBackendUser()->workspace);
     }
     // Background color, if any:
     $rowBackgroundColor = '';
     if ($this->alternateBgColors) {
         $rowBackgroundColor = $cc % 2 ? '' : ' bgcolor="' . GeneralUtility::modifyHTMLColor($this->getControllerDocumentTemplate()->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 ? $this->getControllerDocumentTemplate()->wrapClickMenuOnIcon($iconImg, $table, $row['uid']) : $iconImg;
     // 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] = \CommerceTeam\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 . SettingsFactory::getInstance()->getTcaValue('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) {
         $beCsvCharset = SettingsFactory::getInstance()->getExtConf('BECSVCharset');
         // 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 (!$beCsvCharset) {
             $beCsvCharset = 'iso-8859-1';
         }
         $csObj->initCharset($beCsvCharset);
         $csObj->convArray($row, $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'], $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;
 }
Example #5
0
    /**
     * Oder Articles
     * Renders the List of aricles.
     *
     * @param array $parameter Parameter
     *
     * @return string HTML-Content
     */
    public function orderArticles(array $parameter)
    {
        $language = $this->getLanguageService();
        $settingsFactory = SettingsFactory::getInstance();
        $content = '';
        $orderArticleTable = 'tx_commerce_order_articles';
        $orderTable = 'tx_commerce_orders';
        /**
         * Document template.
         *
         * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
         */
        $doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
        $doc->backPath = $this->getBackPath();
        /*
         * 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 = $settingsFactory->getTcaValue($orderArticleTable . '.ctrl.label');
        // Check if Orders in this folder are editable
        /**
         * Page repository.
         *
         * @var \CommerceTeam\Commerce\Domain\Repository\PageRepository $pageRepository
         */
        $pageRepository = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Repository\\PageRepository');
        $orderEditable = !empty($pageRepository->findEditFolderByUid($orderStoragePid));
        /**
         * Order article repository.
         *
         * @var OrderArticleRepository
         */
        $orderArticleRepository = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Repository\\OrderArticleRepository');
        $orderArticles = $orderArticleRepository->findByOrderIdInPage($orderId, $orderStoragePid);
        $sum = array();
        $out = '';
        if (!empty($orderArticles)) {
            /*
             * 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> (' . count($orderArticles) . ')';
            if ($settingsFactory->getExtConf('invoicePageID')) {
                $theData[$titleCol] .= '<a href="../index.php?id=' . $settingsFactory->getExtConf('invoicePageID') . '&amp;tx_commerce_pi6[order_id]=' . $orderId . '&amp;type=' . $settingsFactory->getExtConf('invoicePageType') . '" target="_blank">' . $language->sL('LLL:EXT:commerce/Resources/Private/Language/locallang_be.xml:order_view.items.print_invoice', 1) . ' *</a>';
            }
            $out .= '
                <tr>
                    <td class="c-headLineTable" style="width: 95%;" colspan="' . (count($fieldRows) + 1) . '">' . $theData[$titleCol] . '</td>
                </tr>';
            /*
             * Header colum
             */
            foreach ($fieldRows as $field) {
                $out .= '<td class="c-headLineTable"><b>' . $language->sL(BackendUtility::getItemLabel($orderArticleTable, $field)) . '</b></td>';
            }
            $out .= '<td class="c-headLineTable"></td></tr>';
            // @todo Switch to moneylib to use formating
            $cc = 0;
            $iOut = '';
            $currency = 'EUR';
            if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce']['extConf']['defaultCurrency'])) {
                $currency = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce']['extConf']['defaultCurrency'];
            }
            foreach ($orderArticles as $row) {
                ++$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'] = Money::format(strval($row['price_net']), $currency);
                $row['price_gross'] = Money::format(strval($row['price_gross']), $currency);
                $rowBgColor = $cc % 2 ? '' : ' bgcolor="' . GeneralUtility::modifyHTMLColor($this->getControllerDocumentTemplate()->bgColor4, +10, +10, +10) . '"';
                /*
                 * Not very nice 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[' . $orderArticleTable . '][' . $row['uid'] . ']=edit';
                                $wrap = array('<a href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $this->getBackPath())) . '">', '</a>');
                            }
                            break;
                        case 'amount':
                            $iOut .= '<td>';
                            if ($orderEditable) {
                                $params = '&edit[' . $orderArticleTable . '][' . $row['uid'] . ']=edit&columnsOnly=amount';
                                $onclickAction = 'onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, $this->getBackPath())) . '"';
                                $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($orderArticleTable, $field, $row[$field], 100), $wrap);
                    $iOut .= '</td>';
                }
                /*
                 * Trash icon
                 */
                $iOut .= '<td></td>
					</tr>';
            }
            $out .= $iOut;
            /*
             * Cerate the summ row
             */
            $out .= '<tr>';
            $sum['price_net'] = Money::format(strval($sum['price_net_value']), $currency);
            $sum['price_gross'] = Money::format(strval($sum['price_gross_value']), $currency);
            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 (!empty($sum[$field])) {
                    $out .= BackendUtility::getProcessedValueExtra($orderArticleTable, $field, $sum[$field], 100);
                }
                $out .= '</b></td>';
            }
            $out .= '<td class="c-headLineTable"></td></tr>';
            /*
             * Always
             * Update sum_price_net and sum_price_gross
             * To Be shure everything is ok
             */
            $values = array('sum_price_gross' => $sum['price_gross_value'], 'sum_price_net' => $sum['price_net_value']);
            /**
             * Order repository.
             *
             * @var OrderRepository
             */
            $orderRepository = GeneralUtility::makeInstance('CommerceTeam\\Commerce\\Domain\\Repository\\OrderRepository');
            $orderRepository->updateByOrderId($orderId, $values);
        }
        $out = '
            <!--
                DB listing of elements: "' . htmlspecialchars($orderTable) . '"
            -->
            <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist">
                ' . $out . '
            </table>';
        $content .= $out;
        return $content;
    }
Example #6
0
 /**
  * Article order_id
  * Just a hidden field.
  *
  * @param array $parameter Parameter
  *
  * @return string HTML-Content
  */
 public function sumPriceGrossFormat(array $parameter)
 {
     $currency = 'EUR';
     if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce']['extConf']['defaultCurrency'])) {
         $currency = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce']['extConf']['defaultCurrency'];
     }
     $content = '<input type="text" disabled name="' . $parameter['itemFormElName'] . '" value="' . \CommerceTeam\Commerce\ViewHelpers\Money::format(strval($parameter['itemFormElValue']), $currency) . '">';
     return $content;
 }
Example #7
0
 /**
  * Article order_id
  * Just a hidden field.
  *
  * @param array $parameter Parameter
  *
  * @return string HTML-Content
  */
 public function sumPriceGrossFormat(array $parameter)
 {
     $content = '<input type="text" disabled name="' . $parameter['itemFormElName'] . '" value="' . \CommerceTeam\Commerce\ViewHelpers\Money::format($parameter['itemFormElValue'] / 100, '') . '">';
     return $content;
 }