/**
  * @category ISO_HOOKS: addProductToCollection
  *
  * @param Product|\Model    $product
  * @param int               $quantity
  * @param ProductCollection $collection
  *
  * @return int
  */
 public function checkBeforeAddToCollection(Product $product, $quantity, ProductCollection $collection)
 {
     /** @var ProductType|\Model $productType */
     $productType = $product->getRelated('type');
     if (!$productType->stockmanagement_active) {
         return $quantity;
     }
     $stock = Stock::getStockForProduct($product->id);
     $quantityInCart = 0;
     foreach ($collection->getItems() as $item) {
         if ($item->product_id === $product->id) {
             $quantityInCart += $item->quantity;
         }
     }
     if (false === $stock) {
         return $quantity;
     } elseif (0 === $stock) {
         Message::addError($GLOBALS['TL_LANG']['MSC']['simpleStockmanagement']['productUnavailable']);
         return 0;
     } elseif ($quantity + $quantityInCart > $stock) {
         Message::addInfo($GLOBALS['TL_LANG']['MSC']['simpleStockmanagement']['maxQuantityAdded']);
         return $stock - $quantityInCart;
     }
     return $quantity;
 }
Example #2
0
 /**
  * Check if a product can be deleted by the current backend user
  * Deleting is prohibited if a product has been ordered
  * @return  bool
  */
 public static function getUndeletableIds()
 {
     static $arrProducts;
     if (null === $arrProducts) {
         $arrProducts = \Database::getInstance()->query("\n                    SELECT p.type AS type FROM " . Product::getTable() . " p\n                    INNER JOIN " . ProductCollectionItem::getTable() . " i ON i.product_id=p.id\n                    INNER JOIN " . ProductCollection::getTable() . " c ON i.pid=c.id\n                    WHERE p.type>0 AND c.type='order'\n                UNION\n                    SELECT p.type AS type FROM " . Product::getTable() . " p\n                    INNER JOIN " . Product::getTable() . " p2 ON p2.pid=p.pid\n                    INNER JOIN " . ProductCollectionItem::getTable() . " i ON i.product_id=p2.id\n                    INNER JOIN " . ProductCollection::getTable() . " c ON i.pid=c.id\n                    WHERE c.type='order'\n            ")->fetchEach('type');
     }
     return $arrProducts;
 }
 public static function increaseStock(\DataContainer $objDc, $intInsertId)
 {
     if (($objOrder = \Isotope\Model\ProductCollection::findByPk($objDc->activeRecord->id)) !== null) {
         $objConfig = $objOrder->getRelated('config_id');
         // if the order had already been set to a stock increasing state, the stock doesn't need to be increased again
         if (in_array($objOrder->order_status, deserialize($objConfig->stockIncreaseOrderStates, true))) {
             return;
         }
         foreach ($objOrder->getItems() as $objItem) {
             if (($objProduct = $objItem->getProduct()) !== null) {
                 $intTotalQuantity = \HeimrichHannot\IsotopePlus\IsotopePlus::getTotalStockQuantity($objItem->quantity, $objProduct, null, $objItem->setQuantity, $objConfig);
                 if ($intTotalQuantity) {
                     $objProduct->stock += $intTotalQuantity;
                     $objProduct->save();
                 }
             }
         }
     }
 }
Example #4
0
 protected function compile()
 {
     $periodFactory = new PeriodFactory();
     $arrSession = \Session::getInstance()->get('iso_reports');
     $intConfig = (int) $arrSession[$this->name]['iso_config'];
     $strPeriod = (string) $arrSession[$this->name]['period'];
     $intStart = (int) $arrSession[$this->name]['start'];
     $intStop = (int) $arrSession[$this->name]['stop'];
     $intStatus = (int) $arrSession[$this->name]['iso_status'];
     $period = $periodFactory->create($strPeriod);
     $intStart = $period->getPeriodStart($intStart);
     $intStop = $period->getPeriodEnd($intStop);
     $dateFrom = $period->getKey($intStart);
     $dateTo = $period->getKey($intStop);
     $objData = \Database::getInstance()->query("\n            SELECT\n                c.id AS config_id,\n                c.currency,\n                o.locked AS date,\n                COUNT(o.id) AS total_orders,\n                COUNT(i.id) AS total_products,\n                COUNT(DISTINCT o.id) AS total_orders,\n                COUNT(DISTINCT i.id) AS total_products,\n                SUM(i.quantity) AS total_items,\n                SUM(i.tax_free_price * i.quantity) AS total_sales,\n                " . $period->getSqlField('o.' . $this->strDateField) . " AS dateGroup\n            FROM " . ProductCollection::getTable() . " o\n            LEFT JOIN " . ProductCollectionItem::getTable() . " i ON o.id=i.pid\n            LEFT JOIN " . OrderStatus::getTable() . " os ON os.id=o.order_status\n            LEFT OUTER JOIN " . Config::getTable() . " c ON o.config_id=c.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('i', 'product_id') . "\n            " . ($intConfig > 0 ? " AND c.id=" . $intConfig : '') . "\n            " . $this->getConfigProcedure('c') . "\n            GROUP BY config_id, dateGroup\n            HAVING dateGroup>={$dateFrom} AND dateGroup<={$dateTo}\n        ");
     $arrCurrencies = array();
     $arrData = $this->initializeData($period, $intStart, $intStop);
     $arrChart = $this->initializeChart($period, $intStart, $intStop);
     while ($objData->next()) {
         $arrCurrencies[$objData->currency] = $objData->config_id;
         $arrData['rows'][$objData->dateGroup]['columns'][1]['value'] += $objData->total_orders;
         $arrData['rows'][$objData->dateGroup]['columns'][2]['value'] += $objData->total_products;
         $arrData['rows'][$objData->dateGroup]['columns'][3]['value'] += $objData->total_items;
         if (!is_array($arrData['rows'][$objData->dateGroup]['columns'][4]['value'])) {
             $arrData['rows'][$objData->dateGroup]['columns'][4]['value'] = array();
         }
         $arrData['rows'][$objData->dateGroup]['columns'][4]['value'][$objData->currency] = $arrData['rows'][$objData->dateGroup]['columns'][4]['value'][$objData->currency] + $objData->total_sales;
         // Summary in the footer
         $arrData['footer'][1]['value'] += $objData->total_orders;
         $arrData['footer'][2]['value'] += $objData->total_products;
         $arrData['footer'][3]['value'] += $objData->total_items;
         $arrData['footer'][4]['value'][$objData->currency] = (double) $arrData['footer'][4]['value'][$objData->currency] + $objData->total_sales;
         // Generate chart data
         $arrChart[$objData->currency]['data'][$objData->dateGroup]['y'] = (double) $arrChart[$objData->currency]['data'][$objData->dateGroup]['y'] + $objData->total_sales;
     }
     // Apply formatting
     $arrData = $this->formatValues($arrData, $arrCurrencies);
     $this->Template->data = $arrData;
     $this->Template->chart = $arrChart;
     $this->Template->periodFormat = $period->getJavascriptClosure();
 }
Example #5
0
    /**
     * Generate a daily summary for the overview page
     * @return array
     */
    protected function getDailySummary()
    {
        $strBuffer = '
<div class="tl_formbody_edit be_iso_overview">
<fieldset class="tl_tbox">
<legend style="cursor: default;">' . $GLOBALS['TL_LANG']['ISO_REPORT']['24h_summary'] . '</legend>';
        $arrAllowedProducts = \Isotope\Backend\Product\Permission::getAllowedIds();
        $objOrders = \Database::getInstance()->prepare("\n            SELECT\n                c.id AS config_id,\n                c.name AS config_name,\n                c.currency,\n                COUNT(o.id) AS total_orders,\n                SUM(i.tax_free_price * i.quantity) AS total_sales,\n                SUM(i.quantity) AS total_items\n            FROM " . \Isotope\Model\ProductCollection::getTable() . " o\n            LEFT JOIN " . \Isotope\Model\ProductCollectionItem::getTable() . " i ON o.id=i.pid\n            LEFT OUTER JOIN " . \Isotope\Model\Config::getTable() . " c ON o.config_id=c.id\n            WHERE o.type='order' AND o.order_status>0 AND o.locked>=?\n            " . ($arrAllowedProducts === true ? '' : " AND i.product_id IN (" . (empty($arrAllowedProducts) ? '0' : implode(',', $arrAllowedProducts)) . ")") . "\n            GROUP BY config_id\n        ")->execute(strtotime('-24 hours'));
        if (!$objOrders->numRows) {
            $strBuffer .= '
<p class="tl_info" style="margin-top:10px">' . $GLOBALS['TL_LANG']['ISO_REPORT']['24h_empty'] . '</p>';
        } else {
            $i = -1;
            $strBuffer .= '
<br>
<table class="tl_listing">
<tr>
    <th class="tl_folder_tlist">' . $GLOBALS['TL_LANG']['ISO_REPORT']['shop_config'] . '</th>
    <th class="tl_folder_tlist">' . $GLOBALS['TL_LANG']['ISO_REPORT']['currency'] . '</th>
    <th class="tl_folder_tlist">' . $GLOBALS['TL_LANG']['ISO_REPORT']['orders#'] . '</th>
    <th class="tl_folder_tlist">' . $GLOBALS['TL_LANG']['ISO_REPORT']['products#'] . '</th>
    <th class="tl_folder_tlist">' . $GLOBALS['TL_LANG']['ISO_REPORT']['sales#'] . '</th>
</tr>';
            while ($objOrders->next()) {
                $strBuffer .= '
<tr class="row_' . ++$i . ($i % 2 ? 'odd' : 'even') . '">
    <td class="tl_file_list">' . $objOrders->config_name . '</td>
    <td class="tl_file_list">' . $objOrders->currency . '</td>
    <td class="tl_file_list">' . $objOrders->total_orders . '</td>
    <td class="tl_file_list">' . $objOrders->total_items . '</td>
    <td class="tl_file_list">' . Isotope::formatPrice($objOrders->total_sales) . '</td>
</tr>';
            }
            $strBuffer .= '
</table>';
        }
        $strBuffer .= '
</fieldset>
</div>';
        return $strBuffer;
    }
Example #6
0
 protected function compile()
 {
     $arrSession = \Session::getInstance()->get('iso_reports');
     $intConfig = (int) $arrSession[$this->name]['iso_config'];
     $strPeriod = (string) $arrSession[$this->name]['period'];
     $intStart = (int) $arrSession[$this->name]['start'];
     $intStop = (int) $arrSession[$this->name]['stop'];
     $intStatus = (int) $arrSession[$this->name]['iso_status'];
     list($publicDate, $privateDate, $sqlDate) = $this->getPeriodConfiguration($strPeriod);
     $dateFrom = date($privateDate, $intStart);
     $dateTo = date($privateDate, $intStop);
     $objData = \Database::getInstance()->prepare("\n            SELECT\n                c.id AS config_id,\n                c.currency,\n                o.locked AS date,\n                COUNT(o.id) AS total_orders,\n                COUNT(i.id) AS total_products,\n                COUNT(DISTINCT o.id) AS total_orders,\n                COUNT(DISTINCT i.id) AS total_products,\n                SUM(i.quantity) AS total_items,\n                SUM(i.tax_free_price * i.quantity) AS total_sales,\n                DATE_FORMAT(FROM_UNIXTIME(o.{$this->strDateField}), ?) AS dateGroup\n            FROM " . \Isotope\Model\ProductCollection::getTable() . " o\n            LEFT JOIN " . \Isotope\Model\ProductCollectionItem::getTable() . " i ON o.id=i.pid\n            LEFT JOIN " . \Isotope\Model\OrderStatus::getTable() . " os ON os.id=o.order_status\n            LEFT OUTER JOIN " . \Isotope\Model\Config::getTable() . " c ON o.config_id=c.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('i', 'product_id') . "\n            " . ($intConfig > 0 ? " AND c.id=" . $intConfig : '') . "\n            " . $this->getConfigProcedure('c') . "\n            GROUP BY config_id, dateGroup\n            HAVING dateGroup>={$dateFrom} AND dateGroup<={$dateTo}\n        ")->execute($sqlDate);
     $arrCurrencies = array();
     $arrData = $this->initializeData($strPeriod, $intStart, $intStop, $privateDate, $publicDate);
     $arrChart = $this->initializeChart($strPeriod, $intStart, $intStop, $privateDate, $publicDate);
     while ($objData->next()) {
         $arrCurrencies[$objData->currency] = $objData->config_id;
         $arrData['rows'][$objData->dateGroup]['columns'][1]['value'] += $objData->total_orders;
         $arrData['rows'][$objData->dateGroup]['columns'][2]['value'] += $objData->total_products;
         $arrData['rows'][$objData->dateGroup]['columns'][3]['value'] += $objData->total_items;
         if (!is_array($arrData['rows'][$objData->dateGroup]['columns'][4]['value'])) {
             $arrData['rows'][$objData->dateGroup]['columns'][4]['value'] = array();
         }
         $arrData['rows'][$objData->dateGroup]['columns'][4]['value'][$objData->currency] = $arrData['rows'][$objData->dateGroup]['columns'][4]['value'][$objData->currency] + $objData->total_sales;
         // Summary in the footer
         $arrData['footer'][1]['value'] += $objData->total_orders;
         $arrData['footer'][2]['value'] += $objData->total_products;
         $arrData['footer'][3]['value'] += $objData->total_items;
         $arrData['footer'][4]['value'][$objData->currency] = (double) $arrData['footer'][4]['value'][$objData->currency] + $objData->total_sales;
         // Generate chart data
         $arrChart[$objData->currency]['data'][$objData->dateGroup]['y'] = (double) $arrChart['rows'][$objData->dateGroup]['columns'][$objData->currency]['value'] + $objData->total_sales;
     }
     // Apply formatting
     $arrData = $this->formatValues($arrData, $arrCurrencies);
     $this->Template->data = $arrData;
     $this->Template->chart = $arrChart;
 }
Example #7
0
 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']);
     }
     $arrData['footer'] = $arrFooter;
     $this->Template->data = $arrData;
 }
Example #8
0
 * Models
 */
$GLOBALS['TL_MODELS'][\Isotope\Model\Address::getTable()] = 'Isotope\\Model\\Address';
$GLOBALS['TL_MODELS'][\Isotope\Model\Attribute::getTable()] = 'Isotope\\Model\\Attribute';
$GLOBALS['TL_MODELS'][\Isotope\Model\BasePrice::getTable()] = 'Isotope\\Model\\BasePrice';
$GLOBALS['TL_MODELS'][\Isotope\Model\Config::getTable()] = 'Isotope\\Model\\Config';
$GLOBALS['TL_MODELS'][\Isotope\Model\Document::getTable()] = 'Isotope\\Model\\Document';
$GLOBALS['TL_MODELS'][\Isotope\Model\Download::getTable()] = 'Isotope\\Model\\Download';
$GLOBALS['TL_MODELS'][\Isotope\Model\Gallery::getTable()] = 'Isotope\\Model\\Gallery';
$GLOBALS['TL_MODELS'][\Isotope\Model\Group::getTable()] = 'Isotope\\Model\\Group';
$GLOBALS['TL_MODELS'][\Isotope\Model\Label::getTable()] = 'Isotope\\Model\\Label';
$GLOBALS['TL_MODELS'][\Isotope\Model\OrderStatus::getTable()] = 'Isotope\\Model\\OrderStatus';
$GLOBALS['TL_MODELS'][\Isotope\Model\Payment::getTable()] = 'Isotope\\Model\\Payment';
$GLOBALS['TL_MODELS'][\Isotope\Model\Product::getTable()] = 'Isotope\\Model\\Product';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCategory::getTable()] = 'Isotope\\Model\\ProductCategory';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollection::getTable()] = 'Isotope\\Model\\ProductCollection';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollectionDownload::getTable()] = 'Isotope\\Model\\ProductCollectionDownload';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollectionItem::getTable()] = 'Isotope\\Model\\ProductCollectionItem';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCollectionSurcharge::getTable()] = 'Isotope\\Model\\ProductCollectionSurcharge';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductPrice::getTable()] = 'Isotope\\Model\\ProductPrice';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductCache::getTable()] = 'Isotope\\Model\\ProductCache';
$GLOBALS['TL_MODELS'][\Isotope\Model\ProductType::getTable()] = 'Isotope\\Model\\ProductType';
$GLOBALS['TL_MODELS'][\Isotope\Model\RelatedCategory::getTable()] = 'Isotope\\Model\\RelatedCategory';
$GLOBALS['TL_MODELS'][\Isotope\Model\RelatedProduct::getTable()] = 'Isotope\\Model\\RelatedProduct';
$GLOBALS['TL_MODELS'][\Isotope\Model\RequestCache::getTable()] = 'Isotope\\Model\\RequestCache';
$GLOBALS['TL_MODELS'][\Isotope\Model\Shipping::getTable()] = 'Isotope\\Model\\Shipping';
$GLOBALS['TL_MODELS'][\Isotope\Model\TaxClass::getTable()] = 'Isotope\\Model\\TaxClass';
$GLOBALS['TL_MODELS'][\Isotope\Model\TaxRate::getTable()] = 'Isotope\\Model\\TaxRate';
/**
 * Checkout steps
 */
Example #9
0
 /**
  * Show messages for new order status
  *
  * @return string
  */
 public function getOrderMessages()
 {
     /** @type \BackendUser $objUser */
     $objUser = \BackendUser::getInstance();
     if (!\Database::getInstance()->tableExists(\Isotope\Model\OrderStatus::getTable()) || !$objUser->hasAccess('iso_orders', 'modules')) {
         return '';
     }
     // Can't see any orders if user does not have access to any shop config
     $strConfig = '';
     if (!\BackendUser::getInstance()->isAdmin) {
         $arrConfigs = \BackendUser::getInstance()->iso_configs;
         if (empty($arrConfigs) || !is_array($arrConfigs)) {
             return '';
         }
         $strConfig = "AND c.config_id IN (" . implode(',', $arrConfigs) . ")";
     }
     $arrMessages = array();
     $objOrders = \Database::getInstance()->query("\n            SELECT COUNT(*) AS total, s.name\n            FROM " . \Isotope\Model\ProductCollection::getTable() . " c\n            LEFT JOIN " . \Isotope\Model\OrderStatus::getTable() . " s ON c.order_status=s.id\n            WHERE c.type='order' AND s.welcomescreen='1' {$strConfig}\n            GROUP BY s.id");
     while ($objOrders->next()) {
         $arrMessages[] = '<p class="tl_new">' . sprintf($GLOBALS['TL_LANG']['MSC']['newOrders'], $objOrders->total, $objOrders->name) . '</p>';
     }
     return implode("\n", $arrMessages);
 }
<?php

/**
 * Isotope eCommerce for Contao Open Source CMS
 *
 * Copyright (C) 2009-2014 terminal42 gmbh & Isotope eCommerce Workgroup
 *
 * @package    Isotope
 * @link       http://isotopeecommerce.org
 * @license    http://opensource.org/licenses/lgpl-3.0.html
 */
/**
 * Table tl_iso_rule_usage
 */
$GLOBALS['TL_DCA']['tl_iso_rule_usage'] = array('config' => array('sql' => array('keys' => array('id' => 'primary', 'pid' => 'index'))), 'fields' => array('id' => array('sql' => "int(10) unsigned NOT NULL auto_increment"), 'pid' => array('foreignKey' => \Isotope\Model\Rule::getTable() . '.name', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'belongsTo', 'load' => 'lazy')), 'tstamp' => array('sql' => "int(10) unsigned NOT NULL default '0'"), 'order_id' => array('foreignKey' => \Isotope\Model\ProductCollection::getTable() . '.document_number', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'config_id' => array('foreignKey' => \Isotope\Model\Config::getTable() . '.name', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'member_id' => array('foreignKey' => \MemberModel::getTable() . '.username', 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy'))));
Example #11
0
 /**
  * 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;
 }
 public function validateStockCollectionAdd($objProduct, $intQuantity, ProductCollection $objProductCollection)
 {
     if (!$this->validateQuantity($objProduct, $intQuantity, $objProductCollection->getItemForProduct($objProduct))) {
         return 0;
     } else {
         unset($_SESSION['ISO_ERROR']);
     }
     return $intQuantity;
 }
Example #13
0
 /**
  * Clear all cache properties
  */
 protected function clearCache()
 {
     parent::clearCache();
     $this->objDraftOrder = null;
 }
Example #14
0
 /**
  * Delete downloads when deleting this order
  * @return integer
  */
 public function delete()
 {
     $this->ensureNotLocked();
     $intPid = $this->id;
     if (parent::delete() && $intPid > 0) {
         \Database::getInstance()->query("DELETE FROM tl_iso_product_collection_download WHERE pid IN (SELECT id FROM tl_iso_product_collection_item WHERE pid={$intPid})");
         return true;
     }
     return false;
 }