当前位置: 首页>>代码示例>>PHP>>正文


PHP Isotope::formatPriceWithCurrency方法代码示例

本文整理汇总了PHP中Isotope\Isotope::formatPriceWithCurrency方法的典型用法代码示例。如果您正苦于以下问题:PHP Isotope::formatPriceWithCurrency方法的具体用法?PHP Isotope::formatPriceWithCurrency怎么用?PHP Isotope::formatPriceWithCurrency使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Isotope\Isotope的用法示例。


在下文中一共展示了Isotope::formatPriceWithCurrency方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     $objCart = Isotope::getCart();
     $objAddress = $objCart->getShippingAddress();
     $this->Template->showResults = false;
     $this->Template->requiresShipping = false;
     // There is no address
     if (!$objAddress->id) {
         return;
     }
     $this->Template->showResults = true;
     $arrMethods = array();
     // Get the shipping methods
     if ($objAddress->id && $objCart->requiresShipping()) {
         $this->Template->requiresShipping = true;
         $objShippingMethods = Shipping::findMultipleByIds($this->arrShippingMethods);
         /* @var Shipping $objShipping */
         foreach ($objShippingMethods as $objShipping) {
             if ($objShipping->isAvailable()) {
                 $fltPrice = $objShipping->getPrice();
                 $arrMethods[] = array('label' => $objShipping->getLabel(), 'price' => $fltPrice, 'formatted_price' => Isotope::formatPriceWithCurrency($fltPrice), 'shipping' => $objShipping);
             }
         }
         RowClass::withKey('rowClass')->addCount('row_')->addFirstLast('row_')->addEvenOdd('row_')->applyTo($arrMethods);
     }
     $this->Template->shippingMethods = $arrMethods;
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:30,代码来源:ShippingCalculator.php

示例2: generate

 public function generate(IsotopeProduct $objProduct, array $arrOptions = array())
 {
     $arrData = deserialize($objProduct->{$this->field_name});
     if (is_array($arrData) && $arrData['unit'] > 0 && $arrData['value'] != '') {
         $objBasePrice = \Isotope\Model\BasePrice::findByPk((int) $arrData['unit']);
         if (null !== $objBasePrice && null !== $objProduct->getPrice()) {
             return sprintf($objBasePrice->getLabel(), Isotope::formatPriceWithCurrency($objProduct->getPrice()->getAmount() / $arrData['value'] * $objBasePrice->amount), $arrData['value']);
         }
     }
     return '';
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:11,代码来源:BasePrice.php

示例3: compile

 /**
  * Generate the module
  * @return void
  */
 protected function compile()
 {
     $arrOrders = array();
     $objOrders = Order::findBy(array('order_status>0', 'member=?', 'config_id IN (?)'), array(\FrontendUser::getInstance()->id, implode("','", $this->iso_config_ids)), array('order' => 'locked DESC'));
     // No orders found, just display an "empty" message
     if (null === $objOrders) {
         $this->Template = new \Isotope\Template('mod_message');
         $this->Template->type = 'empty';
         $this->Template->message = $GLOBALS['TL_LANG']['ERR']['emptyOrderHistory'];
         return;
     }
     while ($objOrders->next()) {
         Isotope::setConfig($objOrders->current()->getRelated('config_id'));
         $arrOrders[] = array('collection' => $objOrders->current(), 'raw' => $objOrders->current()->row(), 'date' => Format::date($objOrders->current()->locked), 'time' => Format::time($objOrders->current()->locked), 'datime' => Format::datim($objOrders->current()->locked), 'grandTotal' => Isotope::formatPriceWithCurrency($objOrders->current()->getTotal()), 'status' => $objOrders->current()->getStatusLabel(), 'link' => $this->jumpTo ? \Haste\Util\Url::addQueryString('uid=' . $objOrders->current()->uniqid, $this->jumpTo) : '', 'class' => $objOrders->current()->getStatusAlias());
     }
     RowClass::withKey('class')->addFirstLast()->addEvenOdd()->applyTo($arrOrders);
     $this->Template->orders = $arrOrders;
 }
开发者ID:Aziz-JH,项目名称:core,代码行数:22,代码来源:OrderHistory.php

示例4: getOrderLabel

 /**
  * Generate the order label and return it as string
  * @param   array
  * @param   string
  * @return  string
  */
 public function getOrderLabel($row, $label, \DataContainer $dc, $args)
 {
     /** @var Order $objOrder */
     $objOrder = Order::findByPk($row['id']);
     if (null === $objOrder) {
         return $args;
     }
     // Override system to correctly format currencies etc
     Isotope::setConfig($objOrder->getRelated('config_id'));
     $objAddress = $objOrder->getBillingAddress();
     if (null !== $objAddress) {
         $arrTokens = $objAddress->getTokens(Isotope::getConfig()->getBillingFieldsConfig());
         $args[2] = $arrTokens['hcard_fn'];
     }
     $args[3] = Isotope::formatPriceWithCurrency($row['grandTotal']);
     /** @var \Isotope\Model\OrderStatus $objStatus */
     if (($objStatus = $objOrder->getRelated('order_status')) !== null) {
         $args[4] = '<span style="' . $objStatus->getColorStyles() . '">' . $objOrder->getStatusLabel() . '</span>';
     } else {
         $args[4] = '<span>' . $objOrder->getStatusLabel() . '</span>';
     }
     return $args;
 }
开发者ID:Aziz-JH,项目名称:core,代码行数:29,代码来源:Callback.php

示例5: formatValues

 protected function formatValues($arrData, $arrCurrencies)
 {
     // Format row totals
     foreach ($arrData['rows'] as $dateGroup => $arrRow) {
         if (is_array($arrRow['columns'][4]['value'])) {
             foreach ($arrRow['columns'][4]['value'] as $currency => $varValue) {
                 Isotope::setConfig(Config::findByPk($arrCurrencies[$currency]));
                 $arrData['rows'][$dateGroup]['columns'][4]['value'][$currency] = Isotope::formatPriceWithCurrency($varValue);
             }
         }
     }
     // Format footer totals
     foreach ($arrData['footer'][4]['value'] as $currency => $varValue) {
         Isotope::setConfig(Config::findByPk($arrCurrencies[$currency]));
         $arrData['footer'][4]['value'][$currency] = Isotope::formatPriceWithCurrency($varValue);
     }
     if (empty($arrData['footer'][4]['value'])) {
         $arrData['footer'][4]['value'] = 0;
     }
     return $arrData;
 }
开发者ID:Aziz-JH,项目名称:core,代码行数:21,代码来源:SalesTotal.php

示例6: generateTable

    /**
     * Generate HTML table for associative array values
     * @param   array
     * @param   IsotopeProduct
     * @return  string
     */
    protected function generateTable(array $arrValues, IsotopeProduct $objProduct)
    {
        $arrFormat = $GLOBALS['TL_DCA']['tl_iso_product']['fields'][$this->field_name]['tableformat'];
        $last = count($arrValues[0]) - 1;
        $strBuffer = '
<table class="' . $this->field_name . '">
  <thead>
    <tr>';
        foreach (array_keys($arrValues[0]) as $i => $name) {
            if ($arrFormat[$name]['doNotShow']) {
                continue;
            }
            $label = $arrFormat[$name]['label'] ? $arrFormat[$name]['label'] : $name;
            $strBuffer .= '
      <th class="head_' . $i . ($i == 0 ? ' head_first' : '') . ($i == $last ? ' head_last' : '') . (!is_numeric($name) ? ' ' . standardize($name) : '') . '">' . $label . '</th>';
        }
        $strBuffer .= '
    </tr>
  </thead>
  <tbody>';
        foreach ($arrValues as $r => $row) {
            $strBuffer .= '
    <tr class="row_' . $r . ($r == 0 ? ' row_first' : '') . ($r == $last ? ' row_last' : '') . ' ' . ($r % 2 ? 'odd' : 'even') . '">';
            $c = -1;
            foreach ($row as $name => $value) {
                if ($arrFormat[$name]['doNotShow']) {
                    continue;
                }
                if ($arrFormat[$name]['rgxp'] == 'price') {
                    $intTax = (int) $row['tax_class'];
                    $value = Isotope::formatPriceWithCurrency(Isotope::calculatePrice($value, $objProduct, $this->field_name, $intTax));
                } else {
                    $value = $arrFormat[$name]['format'] ? sprintf($arrFormat[$name]['format'], $value) : $value;
                }
                $strBuffer .= '
      <td class="col_' . ++$c . ($c == 0 ? ' col_first' : '') . ($c == $i ? ' col_last' : '') . ' ' . standardize($name) . '">' . $value . '</td>';
            }
            $strBuffer .= '
    </tr>';
        }
        $strBuffer .= '
  </tbody>
</table>';
        return $strBuffer;
    }
开发者ID:bytehead,项目名称:core,代码行数:51,代码来源:Attribute.php

示例7: generate

 /**
  * Generate price for HTML rendering
  *
  * @param bool  $blnShowTiers
  * @param int   $intQuantity
  * @param array $arrOptions
  *
  * @return string
  */
 public function generate($blnShowTiers = false, $intQuantity = 1, array $arrOptions = array())
 {
     $blnShowFrom = false;
     $fltPrice = $this->getAmount($intQuantity, $arrOptions);
     if ($blnShowTiers) {
         $fltLowest = $this->getLowestAmount($arrOptions);
         if ($fltPrice != $fltLowest) {
             $blnShowFrom = true;
             $fltPrice = $fltLowest;
         }
     }
     $strPrice = Isotope::formatPriceWithCurrency($fltPrice);
     if ($blnShowFrom) {
         return sprintf($GLOBALS['TL_LANG']['MSC']['priceRangeLabel'], $strPrice);
     }
     $fltOriginalPrice = $this->getOriginalAmount($intQuantity, $arrOptions);
     if ($fltPrice < $fltOriginalPrice) {
         $strOriginalPrice = Isotope::formatPriceWithCurrency($fltOriginalPrice);
         // @deprecated remove <strike>, should be a CSS setting
         return '<div class="original_price"><strike>' . $strOriginalPrice . '</strike></div><div class="price">' . $strPrice . '</div>';
     }
     return $strPrice;
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:32,代码来源:ProductPrice.php

示例8: formatSurcharges

 /**
  * Format surcharge prices
  *
  * @param ProductCollectionSurcharge[] $arrSurcharges
  *
  * @return array
  */
 public static function formatSurcharges($arrSurcharges)
 {
     $i = 0;
     $arrReturn = array();
     foreach ($arrSurcharges as $k => $objSurcharge) {
         $arrReturn[$k] = $objSurcharge->row();
         $arrReturn[$k]['price'] = Isotope::formatPriceWithCurrency($objSurcharge->price, true, null, $objSurcharge->applyRoundingIncrement);
         $arrReturn[$k]['total_price'] = Isotope::formatPriceWithCurrency($objSurcharge->total_price, true, null, $objSurcharge->applyRoundingIncrement);
         $arrReturn[$k]['tax_free_total_price'] = Isotope::formatPriceWithCurrency($objSurcharge->tax_free_total_price, true, null, $objSurcharge->applyRoundingIncrement);
         $arrReturn[$k]['rowClass'] = trim('foot_' . ++$i . ' ' . $objSurcharge->rowClass);
         $arrReturn[$k]['tax_id'] = $objSurcharge->getTaxNumbers();
         $arrReturn[$k]['raw'] = $objSurcharge->row();
         $arrReturn[$k]['surcharge'] = $objSurcharge;
     }
     return $arrReturn;
 }
开发者ID:bytehead,项目名称:core,代码行数:23,代码来源:Frontend.php

示例9: generateItem

 /**
  * Generate item array for template
  * @param   ProductCollectionItem
  * @return  array
  */
 protected function generateItem(ProductCollectionItem $objItem)
 {
     $blnHasProduct = $objItem->hasProduct();
     $objProduct = $objItem->getProduct();
     // Set the active product for insert tags replacement
     if ($blnHasProduct) {
         Product::setActive($objProduct);
     }
     $arrCSS = $blnHasProduct ? deserialize($objProduct->cssID, true) : array();
     $arrItem = array('id' => $objItem->id, 'sku' => $objItem->getSku(), 'name' => $objItem->getName(), 'options' => Isotope::formatOptions($objItem->getOptions()), 'quantity' => $objItem->quantity, 'price' => Isotope::formatPriceWithCurrency($objItem->getPrice()), 'tax_free_price' => Isotope::formatPriceWithCurrency($objItem->getTaxFreePrice()), 'total' => Isotope::formatPriceWithCurrency($objItem->getTotalPrice()), 'tax_free_total' => Isotope::formatPriceWithCurrency($objItem->getTaxFreeTotalPrice()), 'tax_id' => $objItem->tax_id, 'href' => false, 'hasProduct' => $blnHasProduct, 'product' => $objProduct, 'item' => $objItem, 'raw' => $objItem->row(), 'rowClass' => trim('product ' . ($blnHasProduct && $objProduct->isNew() ? 'new ' : '') . $arrCSS[1]));
     if (null !== $objItem->getRelated('jumpTo') && $blnHasProduct && $objProduct->isAvailableInFrontend()) {
         $arrItem['href'] = $objProduct->generateUrl($objItem->getRelated('jumpTo'));
     }
     Product::unsetActive();
     return $arrItem;
 }
开发者ID:Aziz-JH,项目名称:core,代码行数:21,代码来源:ProductCollection.php

示例10: getNotificationTokens

 /**
  * Retrieve the array of notification data for parsing simple tokens
  *
  * @param int $intNotification
  *
  * @return array
  */
 public function getNotificationTokens($intNotification)
 {
     /** @type \Isotope\Model\Config $objConfig */
     $objConfig = $this->getRelated('config_id');
     $arrTokens = deserialize($this->email_data, true);
     $arrTokens['uniqid'] = $this->uniqid;
     $arrTokens['order_status_id'] = $this->order_status;
     $arrTokens['order_status'] = $this->getStatusLabel();
     $arrTokens['recipient_email'] = $this->getEmailRecipient();
     $arrTokens['order_id'] = $this->id;
     $arrTokens['order_items'] = $this->sumItemsQuantity();
     $arrTokens['order_products'] = $this->countItems();
     $arrTokens['order_subtotal'] = Isotope::formatPriceWithCurrency($this->getSubtotal(), false);
     $arrTokens['order_total'] = Isotope::formatPriceWithCurrency($this->getTotal(), false);
     $arrTokens['document_number'] = $this->document_number;
     $arrTokens['cart_html'] = '';
     $arrTokens['cart_text'] = '';
     $arrTokens['document'] = '';
     // Add all the collection fields
     foreach ($this->row() as $k => $v) {
         $arrTokens['collection_' . $k] = $v;
     }
     // Add billing/customer address fields
     if (($objAddress = $this->getBillingAddress()) !== null) {
         foreach ($objAddress->row() as $k => $v) {
             $arrTokens['billing_address_' . $k] = Format::dcaValue($objAddress->getTable(), $k, $v);
             // @deprecated (use ##billing_address_*##)
             $arrTokens['billing_' . $k] = $arrTokens['billing_address_' . $k];
         }
         $arrTokens['billing_address'] = $objAddress->generate($objConfig->getBillingFieldsConfig());
         // @deprecated (use ##billing_address##)
         $arrTokens['billing_address_text'] = $arrTokens['billing_address'];
     }
     // Add shipping address fields
     if (($objAddress = $this->getShippingAddress()) !== null) {
         foreach ($objAddress->row() as $k => $v) {
             $arrTokens['shipping_address_' . $k] = Format::dcaValue($objAddress->getTable(), $k, $v);
             // @deprecated (use ##billing_address_*##)
             $arrTokens['shipping_' . $k] = $arrTokens['shipping_address_' . $k];
         }
         $arrTokens['shipping_address'] = $objAddress->generate($objConfig->getShippingFieldsConfig());
         // Shipping address equals billing address
         // @deprecated (use ##shipping_address##)
         if ($objAddress->id == $this->getBillingAddress()->id) {
             $arrTokens['shipping_address_text'] = $this->requiresPayment() ? $GLOBALS['TL_LANG']['MSC']['useBillingAddress'] : $GLOBALS['TL_LANG']['MSC']['useCustomerAddress'];
         } else {
             $arrTokens['shipping_address_text'] = $arrTokens['shipping_address'];
         }
     }
     // Add payment method info
     if ($this->hasPayment() && ($objPayment = $this->getPaymentMethod()) !== null) {
         $arrTokens['payment_id'] = $objPayment->id;
         $arrTokens['payment_label'] = $objPayment->getLabel();
         $arrTokens['payment_note'] = $objPayment->note;
     }
     // Add shipping method info
     if ($this->hasShipping() && ($objShipping = $this->getShippingMethod()) !== null) {
         $arrTokens['shipping_id'] = $objShipping->id;
         $arrTokens['shipping_label'] = $objShipping->getLabel();
         $arrTokens['shipping_note'] = $objShipping->note;
     }
     // Add config fields
     if ($this->getRelated('config_id') !== null) {
         foreach ($this->getRelated('config_id')->row() as $k => $v) {
             $arrTokens['config_' . $k] = Format::dcaValue($this->getRelated('config_id')->getTable(), $k, $v);
         }
     }
     // Add member fields
     if ($this->member > 0 && $this->getRelated('member') !== null) {
         foreach ($this->getRelated('member')->row() as $k => $v) {
             $arrTokens['member_' . $k] = Format::dcaValue($this->getRelated('member')->getTable(), $k, $v);
         }
     }
     if ($intNotification > 0 && ($objNotification = Notification::findByPk($intNotification)) !== null) {
         $objTemplate = new \Isotope\Template($objNotification->iso_collectionTpl);
         $objTemplate->isNotification = true;
         $this->addToTemplate($objTemplate, array('gallery' => $objNotification->iso_gallery, 'sorting' => $this->getItemsSortingCallable($objNotification->iso_orderCollectionBy)));
         $arrTokens['cart_html'] = Haste::getInstance()->call('replaceInsertTags', array($objTemplate->parse(), false));
         $objTemplate->textOnly = true;
         $arrTokens['cart_text'] = strip_tags(Haste::getInstance()->call('replaceInsertTags', array($objTemplate->parse(), true)));
         // Generate and "attach" document
         /** @var \Isotope\Interfaces\IsotopeDocument $objDocument */
         if ($objNotification->iso_document > 0 && ($objDocument = Document::findByPk($objNotification->iso_document)) !== null) {
             $strFilePath = $objDocument->outputToFile($this, TL_ROOT . '/system/tmp');
             $arrTokens['document'] = str_replace(TL_ROOT . '/', '', $strFilePath);
         }
     }
     // !HOOK: add custom email tokens
     if (isset($GLOBALS['ISO_HOOKS']['getOrderNotificationTokens']) && is_array($GLOBALS['ISO_HOOKS']['getOrderNotificationTokens'])) {
         foreach ($GLOBALS['ISO_HOOKS']['getOrderNotificationTokens'] as $callback) {
             $objCallback = \System::importStatic($callback[0]);
             $arrTokens = $objCallback->{$callback}[1]($this, $arrTokens);
         }
//.........这里部分代码省略.........
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:101,代码来源:Order.php

示例11: getErrors

 /**
  * Get error messages for the cart
  * @return  array
  */
 public function getErrors()
 {
     $arrErrors = parent::getErrors();
     if (Isotope::getConfig()->cartMinSubtotal > 0 && Isotope::getConfig()->cartMinSubtotal > $this->getSubtotal()) {
         $arrErrors[] = sprintf($GLOBALS['TL_LANG']['ERR']['cartMinSubtotal'], Isotope::formatPriceWithCurrency(Isotope::getConfig()->cartMinSubtotal));
     }
     return $arrErrors;
 }
开发者ID:Aziz-JH,项目名称:core,代码行数:12,代码来源:Cart.php

示例12: getLabel

 /**
  * Get formatted label for the attribute option
  *
  * @param IsotopeProduct $objProduct
  *
  * @return string
  */
 public function getLabel(IsotopeProduct $objProduct = null)
 {
     $strLabel = $this->label;
     /** @type Attribute $objAttribute */
     $objAttribute = null;
     switch ($this->ptable) {
         case 'tl_iso_product':
             $objAttribute = Attribute::findByFieldName($this->field_name);
             break;
         case 'tl_iso_attribute':
             $objAttribute = Attribute::findByPk($this->pid);
             break;
     }
     if (null !== $objAttribute && !$objAttribute->isVariantOption() && $this->price != '') {
         $strLabel .= ' (';
         if (!$this->isPercentage() || null !== $objProduct) {
             $strPrice = Isotope::formatPriceWithCurrency($this->getPrice($objProduct), false);
         } else {
             $strPrice = $this->price;
         }
         $strLabel .= $this->isFromPrice($objProduct) ? sprintf($GLOBALS['TL_LANG']['MSC']['priceRangeLabel'], $strPrice) : $strPrice;
         $strLabel .= ')';
     }
     return $strLabel;
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:32,代码来源:AttributeOption.php

示例13: getValueForCollectionTag

 /**
  * Replace insert tag for a product collection.
  *
  * @param IsotopeProductCollection $collection
  * @param array                    $tokens
  *
  * @return string
  */
 private function getValueForCollectionTag(IsotopeProductCollection $collection, array $tokens)
 {
     switch ($tokens[1]) {
         case 'items':
             return $collection->countItems();
         case 'quantity':
             return $collection->sumItemsQuantity();
         case 'items_label':
             $intCount = $collection->countItems();
             if (!$intCount) {
                 return '';
             }
             if ($intCount == 1) {
                 return '(' . $GLOBALS['TL_LANG']['MSC']['productSingle'] . ')';
             } else {
                 return sprintf('(' . $GLOBALS['TL_LANG']['MSC']['productMultiple'] . ')', $intCount);
             }
             break;
         case 'quantity_label':
             $intCount = $collection->sumItemsQuantity();
             if (!$intCount) {
                 return '';
             }
             if ($intCount == 1) {
                 return '(' . $GLOBALS['TL_LANG']['MSC']['productSingle'] . ')';
             } else {
                 return sprintf('(' . $GLOBALS['TL_LANG']['MSC']['productMultiple'] . ')', $intCount);
             }
             break;
         case 'subtotal':
             return Isotope::formatPriceWithCurrency($collection->getSubtotal());
         case 'taxfree_subtotal':
             return Isotope::formatPriceWithCurrency($collection->getTaxFreeSubtotal());
         case 'total':
             return Isotope::formatPriceWithCurrency($collection->getTotal());
         case 'taxfree_total':
             return Isotope::formatPriceWithCurrency($collection->getTaxFreeTotal());
         case 'billing_address':
             if (!$collection instanceof IsotopeOrderableCollection || ($address = $collection->getBillingAddress()) === null) {
                 return '';
             }
             return $this->getValueForAddressTag($address, $tokens[2]);
         case 'shipping_address':
             if (!$collection instanceof IsotopeOrderableCollection || !$collection->hasShipping() || ($address = $collection->getShippingAddress()) === null) {
                 return '';
             }
             return $this->getValueForAddressTag($address, $tokens[2]);
         default:
             return $collection->{$tokens[1]};
     }
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:59,代码来源:InsertTag.php

示例14: generate

 /**
  * Generate price for HTML rendering
  * @param   bool
  * @return  string
  */
 public function generate($blnShowTiers = false)
 {
     $blnShowFrom = false;
     $fltPrice = $this->getAmount();
     if ($blnShowTiers) {
         $fltLowest = $this->getLowestAmount();
         if ($fltPrice != $fltLowest) {
             $blnShowFrom = true;
             $fltPrice = $fltLowest;
         }
     }
     $strPrice = Isotope::formatPriceWithCurrency($fltPrice);
     if ($blnShowFrom) {
         return sprintf($GLOBALS['TL_LANG']['MSC']['priceRangeLabel'], $strPrice);
     }
     $fltOriginalPrice = $this->getOriginalAmount();
     if ($fltPrice < $fltOriginalPrice) {
         $strOriginalPrice = Isotope::formatPriceWithCurrency($fltOriginalPrice);
         return '<div class="original_price"><strike>' . $strOriginalPrice . '</strike></div><div class="price">' . $strPrice . '</div>';
     }
     return $strPrice;
 }
开发者ID:Aziz-JH,项目名称:core,代码行数:27,代码来源:ProductPrice.php

示例15: compile

 protected function compile()
 {
     $periodFactory = new PeriodFactory();
     $arrSession = \Session::getInstance()->get('iso_reports');
     $strPeriod = (string) $arrSession[$this->name]['period'];
     $intColumns = (int) $arrSession[$this->name]['columns'];
     $blnVariants = (bool) $arrSession[$this->name]['variants'];
     $intStatus = (int) $arrSession[$this->name]['iso_status'];
     if ($arrSession[$this->name]['from'] == '') {
         $intStart = strtotime('-' . ($intColumns - 1) . ' ' . $strPeriod);
     } else {
         $intStart = (int) $arrSession[$this->name]['from'];
     }
     $period = $periodFactory->create($strPeriod);
     $intStart = $period->getPeriodStart($intStart);
     $dateFrom = $period->getKey($intStart);
     $dateTo = $period->getKey(strtotime('+ ' . ($intColumns - 1) . ' ' . $strPeriod, $intStart));
     $arrData = array('rows' => array());
     $arrData['header'] = $this->getHeader($period, $intStart, $intColumns);
     $groupVariants = $blnVariants ? 'p1.id' : 'IF(p1.pid=0, p1.id, p1.pid)';
     $objProducts = \Database::getInstance()->query("\n            SELECT\n                IFNULL({$groupVariants}, i.product_id) AS product_id,\n                IFNULL(p1.name, i.name) AS variant_name,\n                IFNULL(p2.name, i.name) AS product_name,\n                p1.sku AS product_sku,\n                p2.sku AS variant_sku,\n                IF(p1.pid=0, p1.type, p2.type) AS type,\n                i.configuration AS product_configuration,\n                SUM(i.quantity) AS quantity,\n                SUM(i.tax_free_price * i.quantity) AS total,\n                " . $period->getSqlField($this->strDateField) . " AS dateGroup\n            FROM " . ProductCollectionItem::getTable() . " i\n            LEFT JOIN " . ProductCollection::getTable() . " o ON i.pid=o.id\n            LEFT JOIN " . OrderStatus::getTable() . " os ON os.id=o.order_status\n            LEFT OUTER JOIN " . Product::getTable() . " p1 ON i.product_id=p1.id\n            LEFT OUTER JOIN " . Product::getTable() . " p2 ON p1.pid=p2.id\n            WHERE o.type='order' AND o.order_status>0 AND o.locked!=''\n                " . ($intStatus > 0 ? " AND o.order_status=" . $intStatus : '') . "\n                " . $this->getProductProcedure('p1') . "\n                " . $this->getConfigProcedure('o', 'config_id') . "\n            GROUP BY dateGroup, product_id\n            HAVING dateGroup>={$dateFrom} AND dateGroup<={$dateTo}\n        ");
     // Cache product types so call to findByPk() will trigger the registry
     ProductType::findMultipleByIds($objProducts->fetchEach('type'));
     $arrRaw = array();
     $objProducts->reset();
     // Prepare product data
     while ($objProducts->next()) {
         $arrAttributes = array();
         $arrVariantAttributes = array();
         $blnHasVariants = false;
         // Can't use it without a type
         if ($objProducts->type > 0 && ($objType = ProductType::findByPk($objProducts->type)) !== null) {
             /** @type ProductType $objType */
             $arrAttributes = $objType->getAttributes();
             $arrVariantAttributes = $objType->getVariantAttributes();
             $blnHasVariants = $objType->hasVariants();
             $product_type_name = $objType->name;
         }
         $arrOptions = array('name' => $objProducts->variant_name);
         // Use product title if name is not a variant attribute
         if ($blnHasVariants && !in_array('name', $arrVariantAttributes)) {
             $arrOptions['name'] = $objProducts->product_name;
         }
         $strSku = $blnHasVariants ? $objProducts->variant_sku : $objProducts->product_sku;
         if (in_array('sku', $arrAttributes) && $strSku != '') {
             $arrOptions['name'] = sprintf('%s <span style="color:#b3b3b3; padding-left:3px;">[%s]</span>', $arrOptions['name'], $strSku);
         }
         if ($blnVariants && $blnHasVariants) {
             if (in_array('sku', $arrVariantAttributes) && $objProducts->product_sku != '') {
                 $arrOptions['name'] = sprintf('%s <span style="color:#b3b3b3; padding-left:3px;">[%s]</span>', $arrOptions['name'], $objProducts->product_sku);
             }
             foreach (deserialize($objProducts->product_configuration, true) as $strName => $strValue) {
                 if (isset($GLOBALS['TL_DCA']['tl_iso_product']['fields'][$strName])) {
                     $strValue = $GLOBALS['TL_DCA']['tl_iso_product']['fields'][$strName]['options'][$strValue] ? $GLOBALS['TL_DCA']['tl_iso_product']['fields'][$strName]['options'][$strValue] : $strValue;
                     $strName = $GLOBALS['TL_DCA']['tl_iso_product']['fields'][$strName]['label'][0] ? $GLOBALS['TL_DCA']['tl_iso_product']['fields'][$strName]['label'][0] : $strName;
                 }
                 $arrOptions[] = '<span class="variant">' . $strName . ': ' . $strValue . '</span>';
             }
         }
         $arrOptions['name'] = '<span class="product">' . $arrOptions['name'] . '</span>';
         $arrRaw[$objProducts->product_id]['name'] = implode('<br>', $arrOptions);
         $arrRaw[$objProducts->product_id]['product_type_name'] = $product_type_name;
         $arrRaw[$objProducts->product_id][$objProducts->dateGroup] = (double) $arrRaw[$objProducts->product_id][$objProducts->dateGroup] + (double) $objProducts->total;
         $arrRaw[$objProducts->product_id][$objProducts->dateGroup . '_quantity'] = (int) $arrRaw[$objProducts->product_id][$objProducts->dateGroup . '_quantity'] + (int) $objProducts->quantity;
         $arrRaw[$objProducts->product_id]['total'] = (double) $arrRaw[$objProducts->product_id]['total'] + (double) $objProducts->total;
         $arrRaw[$objProducts->product_id]['quantity'] = (int) $arrRaw[$objProducts->product_id]['quantity'] + (int) $objProducts->quantity;
     }
     // Prepare columns
     $arrColumns = array();
     for ($i = 0; $i < $intColumns; $i++) {
         $arrColumns[] = $period->getKey($intStart);
         $intStart = $period->getNext($intStart);
     }
     $arrFooter = array();
     // Sort the data
     if ($arrSession[$this->name]['tl_sort'] == 'product_name') {
         usort($arrRaw, function ($a, $b) {
             return strcasecmp($a['name'], $b['name']);
         });
     } else {
         usort($arrRaw, function ($a, $b) {
             return $a['total'] == $b['total'] ? 0 : ($a['total'] < $b['total'] ? 1 : -1);
         });
     }
     // Generate data
     foreach ($arrRaw as $arrProduct) {
         $arrRow = array(array('value' => array($arrProduct['name'], sprintf('<span style="color:#b3b3b3;">[%s]</span>', $arrProduct['product_type_name']))));
         $arrFooter[0] = array('value' => $GLOBALS['TL_LANG']['ISO_REPORT']['sums']);
         foreach ($arrColumns as $i => $column) {
             $arrRow[$i + 1] = array('value' => Isotope::formatPriceWithCurrency($arrProduct[$column]) . ($arrProduct[$column . '_quantity'] !== null ? '<br><span class="variant">' . Isotope::formatItemsString($arrProduct[$column . '_quantity']) . '</span>' : ''));
             $arrFooter[$i + 1] = array('total' => $arrFooter[$i + 1]['total'] + $arrProduct[$column], 'quantity' => $arrFooter[$i + 1]['quantity'] + $arrProduct[$column . '_quantity']);
         }
         $arrRow[$i + 2] = array('value' => Isotope::formatPriceWithCurrency($arrProduct['total']) . ($arrProduct['quantity'] !== null ? '<br><span class="variant">' . Isotope::formatItemsString($arrProduct['quantity']) . '</span>' : ''));
         $arrFooter[$i + 2] = array('total' => $arrFooter[$i + 2]['total'] + $arrProduct['total'], 'quantity' => $arrFooter[$i + 2]['quantity'] + $arrProduct['quantity']);
         $arrData['rows'][] = array('columns' => $arrRow);
     }
     for ($i = 1; $i < count($arrFooter); $i++) {
         $arrFooter[$i]['value'] = Isotope::formatPriceWithCurrency($arrFooter[$i]['total']) . '<br><span class="variant">' . Isotope::formatItemsString($arrFooter[$i]['quantity']) . '</span>';
         unset($arrFooter[$i]['total']);
     }
//.........这里部分代码省略.........
开发者ID:error08,项目名称:core,代码行数:101,代码来源:SalesProduct.php


注:本文中的Isotope\Isotope::formatPriceWithCurrency方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。