Exemplo n.º 1
0
 /**
  * Generate a product label and return it as HTML string
  * @param array
  * @param string
  * @param object
  * @param array
  * @return string
  */
 public function generate($row, $label, $dc, $args)
 {
     $objProduct = Product::findByPk($row['id']);
     foreach ($GLOBALS['TL_DCA'][$dc->table]['list']['label']['fields'] as $i => $field) {
         switch ($field) {
             // Add an image
             case 'images':
                 $arrImages = deserialize($objProduct->images);
                 $args[$i] = ' ';
                 if (is_array($arrImages) && !empty($arrImages)) {
                     foreach ($arrImages as $image) {
                         $strImage = 'isotope/' . strtolower(substr($image['src'], 0, 1)) . '/' . $image['src'];
                         if (!is_file(TL_ROOT . '/' . $strImage)) {
                             continue;
                         }
                         $size = @getimagesize(TL_ROOT . '/' . $strImage);
                         $args[$i] = sprintf('<a href="%s" onclick="Backend.openModalImage({\'width\':%s,\'title\':\'%s\',\'url\':\'%s\'});return false"><img src="%s" alt="%s" align="left"></a>', $strImage, $size[0], str_replace("'", "\\'", $objProduct->name), $strImage, \Image::get($strImage, 50, 50, 'proportional'), $image['alt']);
                         break;
                     }
                 }
                 break;
             case 'name':
                 $args[$i] = $objProduct->name;
                 /** @var \Isotope\Model\ProductType $objProductType */
                 if ($row['pid'] == 0 && ($objProductType = ProductType::findByPk($row['type'])) !== null && $objProductType->hasVariants()) {
                     // Add a variants link
                     $args[$i] = sprintf('<a href="%s" title="%s">%s</a>', ampersand(\Environment::get('request')) . '&amp;id=' . $row['id'], specialchars($GLOBALS['TL_LANG'][$dc->table]['showVariants']), $args[$i]);
                 }
                 break;
             case 'price':
                 $objPrice = ProductPrice::findPrimaryByProductId($row['id']);
                 if (null !== $objPrice) {
                     /** @var \Isotope\Model\TaxClass $objTax */
                     $objTax = $objPrice->getRelated('tax_class');
                     $strTax = null === $objTax ? '' : ' (' . $objTax->getName() . ')';
                     $args[$i] = $objPrice->getValueForTier(1) . $strTax;
                 }
                 break;
             case 'variantFields':
                 $attributes = array();
                 foreach ($GLOBALS['TL_DCA'][$dc->table]['list']['label']['variantFields'] as $variantField) {
                     $attributes[] = '<strong>' . Format::dcaLabel($dc->table, $variantField) . ':</strong>&nbsp;' . Format::dcaValue($dc->table, $variantField, $objProduct->{$variantField});
                 }
                 $args[$i] = ($args[$i] ? $args[$i] . '<br>' : '') . implode(', ', $attributes);
                 break;
         }
     }
     return $args;
 }
Exemplo n.º 2
0
$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
 */
$GLOBALS['ISO_CHECKOUTSTEP'] = array('address' => array('\\Isotope\\CheckoutStep\\BillingAddress', '\\Isotope\\CheckoutStep\\ShippingAddress'), 'shipping' => array('\\Isotope\\CheckoutStep\\ShippingMethod'), 'payment' => array('\\Isotope\\CheckoutStep\\PaymentMethod'), 'review' => array('\\Isotope\\CheckoutStep\\OrderConditionsOnTop', '\\Isotope\\CheckoutStep\\OrderInfo', '\\Isotope\\CheckoutStep\\OrderConditionsBeforeProducts', '\\Isotope\\CheckoutStep\\OrderProducts', '\\Isotope\\CheckoutStep\\OrderConditionsAfterProducts'));
/**
 * Permissions are access settings for user and groups (fields in tl_user and tl_user_group)
 */
Exemplo n.º 3
0
 /**
  * Return all available variant IDs of this product
  *
  * @return int[]|false
  */
 public function getVariantIds()
 {
     if (null === $this->arrVariantIds) {
         $this->arrVariantIds = array();
         // Nothing to do if we have no variants
         if (!$this->hasVariants()) {
             return $this->arrVariantIds;
         }
         $time = time();
         $blnHasProtected = false;
         $blnHasGroups = false;
         $strQuery = "SELECT id, protected, groups FROM tl_iso_product WHERE pid=" . $this->getProductId() . " AND language='' AND published='1' AND (start='' OR start<{$time}) AND (stop='' OR stop>{$time})";
         if (BE_USER_LOGGED_IN !== true) {
             $arrAttributes = $this->getVariantAttributes();
             $blnHasProtected = in_array('protected', $arrAttributes);
             $blnHasGroups = in_array('groups', $arrAttributes);
             // Hide guests-only products when logged in
             if (FE_USER_LOGGED_IN === true && in_array('guests', $arrAttributes)) {
                 $strQuery .= " AND (guests=''" . ($blnHasProtected ? " OR protected='1'" : '') . ")";
             } elseif (FE_USER_LOGGED_IN !== true && $blnHasProtected) {
                 $strQuery .= " AND protected=''";
             }
         }
         /** @type object $objVariants */
         $objVariants = \Database::getInstance()->query($strQuery);
         while ($objVariants->next()) {
             if ($blnHasProtected && $objVariants->protected) {
                 $groups = $blnHasGroups ? deserialize($objVariants->groups) : '';
                 if (empty($groups) || !is_array($groups) || !count(array_intersect($groups, \FrontendUser::getInstance()->groups))) {
                     continue;
                 }
             }
             $this->arrVariantIds[] = $objVariants->id;
         }
         // Only show variants where a price is available
         if (!empty($this->arrVariantIds) && $this->hasVariantPrices()) {
             if ($this->hasAdvancedPrices()) {
                 $objPrices = ProductPrice::findAdvancedByProductIdsAndCollection($this->arrVariantIds, Isotope::getCart());
             } else {
                 $objPrices = ProductPrice::findPrimaryByProductIds($this->arrVariantIds);
             }
             if (null === $objPrices) {
                 $this->arrVariantIds = array();
             } else {
                 $this->arrVariantIds = $objPrices->fetchEach('pid');
             }
         }
     }
     return $this->arrVariantIds;
 }
Exemplo n.º 4
0
<?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
 */
\System::loadLanguageFile(\Isotope\Model\ProductType::getTable());
/**
 * Table tl_iso_product
 */
$GLOBALS['TL_DCA']['tl_iso_product'] = array('config' => array('label' => &$GLOBALS['TL_LANG']['MOD']['iso_products'][0], 'dataContainer' => 'ProductData', 'enableVersioning' => true, 'switchToEdit' => true, 'ctable' => array(\Isotope\Model\Download::getTable(), \Isotope\Model\ProductCategory::getTable(), \Isotope\Model\ProductPrice::getTable(), \Isotope\Model\AttributeOption::getTable()), 'onload_callback' => array(array('Isotope\\Backend\\Product\\DcaManager', 'load'), array('Isotope\\Backend\\Product\\Permission', 'check'), array('Isotope\\Backend\\Product\\Panel', 'applyAdvancedFilters'), array('Isotope\\Backend\\Product\\XmlSitemap', 'generate')), 'oncreate_callback' => array(array('Isotope\\Backend\\Product\\DcaManager', 'updateNewRecord')), 'oncopy_callback' => array(array('Isotope\\Backend\\Product\\Category', 'updateSorting'), array('Isotope\\Backend\\Product\\DcaManager', 'updateDateAdded')), 'onsubmit_callback' => array(array('Isotope\\Backend', 'truncateProductCache'), array('Isotope\\Backend\\Product\\XmlSitemap', 'scheduleUpdate')), 'onversion_callback' => array(array('Isotope\\Backend\\Product\\Category', 'createVersion')), 'onrestore_callback' => array(array('Isotope\\Backend\\Product\\Category', 'restoreVersion')), 'sql' => array('keys' => array('id' => 'primary', 'gid' => 'index', 'pid,language' => 'index', 'language,published,start,stop,pid' => 'index', 'start' => 'index'))), 'select' => array('buttons_callback' => array(array('Isotope\\Backend\\Product\\Button', 'forSelect'))), 'list' => array('sorting' => array('mode' => 2, 'fields' => array('name'), 'headerFields' => array('name', 'sku', 'price', 'published'), 'flag' => 1, 'panelLayout' => 'iso_buttons,iso_filter;filter;sort,iso_sorting,search,limit', 'icon' => 'system/modules/isotope/assets/images/store-open.png', 'paste_button_callback' => array('Isotope\\Backend\\Product\\PasteButton', 'generate'), 'panel_callback' => array('iso_buttons' => array('Isotope\\Backend\\Product\\Panel', 'generateFilterButtons'), 'iso_filter' => array('Isotope\\Backend\\Product\\Panel', 'generateAdvancedFilters'), 'iso_sorting' => array('Isotope\\Backend\\Product\\Panel', 'generateSortingIcon'))), 'label' => array('fields' => array('images', 'name', 'sku', 'price'), 'showColumns' => true, 'label_callback' => array('Isotope\\Backend\\Product\\Label', 'generate')), 'global_operations' => array('generate' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['generate'], 'href' => 'key=generate', 'icon' => 'new.gif'), 'groups' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['product_groups'], 'href' => 'table=' . \Isotope\Model\Group::getTable(), 'icon' => 'system/modules/isotope/assets/images/folders.png', 'attributes' => 'onclick="Backend.getScrollOffset();"', 'button_callback' => array('Isotope\\Backend\\Product\\Button', 'forGroups')), 'import' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['import'], 'href' => 'key=import', 'icon' => 'system/modules/isotope/assets/images/image--plus.png', 'attributes' => 'onclick="Backend.getScrollOffset();"'), 'all' => array('label' => &$GLOBALS['TL_LANG']['MSC']['all'], 'href' => 'act=select', 'class' => 'header_edit_all', 'attributes' => 'onclick="Backend.getScrollOffset();"')), 'operations' => array('edit' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['edit'], 'href' => 'act=edit', 'icon' => 'edit.gif'), 'copy' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['copy'], 'href' => 'act=copy&amp;childs=1', 'icon' => 'copy.gif', 'button_callback' => array('Isotope\\Backend\\Product\\Button', 'forCopy')), 'cut' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['cut'], 'href' => 'act=cut', 'icon' => 'cut.gif', 'button_callback' => array('Isotope\\Backend\\Product\\Button', 'forCut')), 'delete' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['delete'], 'href' => 'act=delete', 'icon' => 'delete.gif', 'attributes' => 'onclick="if (!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\')) return false; Backend.getScrollOffset();"', 'button_callback' => array('Isotope\\Backend\\Product\\Button', 'forDelete')), 'toggle' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['toggle'], 'icon' => 'visible.gif', 'attributes' => 'onclick="Backend.getScrollOffset(); return AjaxRequest.toggleVisibility(this, %s);"', 'button_callback' => array('Isotope\\Backend\\Product\\Button', 'forVisibilityToggle')), 'show' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['show'], 'href' => 'act=show', 'icon' => 'show.gif'), 'break' => array('button_callback' => function () {
    return '<br>';
}), 'variants' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['variants'], 'href' => '', 'icon' => 'system/modules/isotope/assets/images/table--pencil.png', 'button_callback' => array('Isotope\\Backend\\Product\\Button', 'forVariants')), 'related' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['related'], 'href' => 'table=' . \Isotope\Model\RelatedProduct::getTable(), 'icon' => 'system/modules/isotope/assets/images/sitemap.png', 'button_callback' => array('Isotope\\Backend\\Product\\Button', 'forRelated')), 'downloads' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['downloads'], 'href' => 'table=' . \Isotope\Model\Download::getTable(), 'icon' => 'system/modules/isotope/assets/images/paper-clip.png', 'button_callback' => array('Isotope\\Backend\\Product\\Button', 'forDownloads')), 'group' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['group'], 'href' => 'act=cut', 'icon' => 'system/modules/isotope/assets/images/folder-network.png', 'button_callback' => array('Isotope\\Backend\\Product\\Button', 'forGroup')))), 'palettes' => array('__selector__' => array('type', 'protected'), 'default' => '{general_legend},type'), 'subpalettes' => array('protected' => 'groups'), 'fields' => array('id' => array('attributes' => array('systemColumn' => true), 'sql' => "int(10) unsigned NOT NULL auto_increment"), 'pid' => array('eval' => array('submitOnChange' => true), 'attributes' => array('systemColumn' => true), 'sql' => "int(10) unsigned NOT NULL default '0'"), 'gid' => array('foreignKey' => \Isotope\Model\Group::getTable() . '.name', 'eval' => array('doNotShow' => true), 'attributes' => array('systemColumn' => true, 'inherit' => true), 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy')), 'tstamp' => array('attributes' => array('systemColumn' => true), 'sql' => "int(10) unsigned NOT NULL default '0'"), 'language' => array('eval' => array('doNotShow' => true), 'attributes' => array('systemColumn' => true, 'inherit' => true), 'sql' => "varchar(5) NOT NULL default ''"), 'dateAdded' => array('label' => &$GLOBALS['TL_LANG']['MSC']['dateAdded'], 'eval' => array('rgxp' => 'datim', 'doNotCopy' => true), 'attributes' => array('fe_sorting' => true, 'systemColumn' => true), 'sql' => "int(10) unsigned NOT NULL default '0'"), 'type' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['type'], 'exclude' => true, 'filter' => true, 'inputType' => 'select', 'options_callback' => array('Isotope\\Backend\\ProductType\\Callback', 'getOptions'), 'foreignKey' => \Isotope\Model\ProductType::getTable() . '.name', 'eval' => array('mandatory' => true, 'submitOnChange' => true, 'includeBlankOption' => true, 'tl_class' => 'clr', 'helpwizard' => true), 'attributes' => array('legend' => 'general_legend', 'fixed' => true, 'inherit' => true, 'systemColumn' => true), 'sql' => "int(10) unsigned NOT NULL default '0'", 'relation' => array('type' => 'hasOne', 'load' => 'lazy'), 'explanation' => 'tl_iso_product.type'), 'pages' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['pages'], 'exclude' => true, 'inputType' => 'pageTree', 'foreignKey' => 'tl_page.title', 'eval' => array('doNotSaveEmpty' => true, 'multiple' => true, 'fieldType' => 'checkbox', 'orderField' => 'orderPages', 'tl_class' => 'clr hide_sort_hint'), 'relation' => array('type' => 'hasMany', 'load' => 'lazy'), 'attributes' => array('legend' => 'general_legend', 'fixed' => true, 'inherit' => true, 'systemColumn' => true), 'load_callback' => array(array('Isotope\\Backend\\Product\\Category', 'load')), 'save_callback' => array(array('Isotope\\Backend\\Product\\Category', 'save'))), 'orderPages' => array('eval' => array('doNotShow' => true), 'attributes' => array('systemColumn' => true, 'inherit' => true), 'sql' => "text NULL"), 'inherit' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['inherit'], 'exclude' => true, 'inputType' => 'inheritCheckbox', 'eval' => array('multiple' => true), 'attributes' => array('systemColumn' => true), 'sql' => "blob NULL"), 'alias' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['alias'], 'exclude' => true, 'search' => true, 'sorting' => true, 'inputType' => 'text', 'eval' => array('rgxp' => 'alnum', 'doNotCopy' => true, 'spaceToUnderscore' => true, 'maxlength' => 128, 'tl_class' => 'w50'), 'attributes' => array('legend' => 'general_legend', 'fixed' => true, 'inherit' => true), 'sql' => "varchar(128) NOT NULL default ''", 'save_callback' => array(array('Isotope\\Backend\\Product\\Alias', 'save'))), 'sku' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['sku'], 'exclude' => true, 'search' => true, 'sorting' => true, 'inputType' => 'text', 'eval' => array('mandatory' => true, 'maxlength' => 128, 'unique' => true, 'tl_class' => 'w50'), 'attributes' => array('legend' => 'general_legend', 'fe_sorting' => true, 'fe_search' => true), 'sql' => "varchar(128) NOT NULL default ''"), 'name' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['name'], 'exclude' => true, 'search' => true, 'sorting' => true, 'inputType' => 'text', 'eval' => array('mandatory' => true, 'tl_class' => 'clr long'), 'attributes' => array('legend' => 'general_legend', 'multilingual' => true, 'fixed' => true, 'fe_sorting' => true, 'fe_search' => true), 'sql' => "varchar(255) NOT NULL default ''"), 'teaser' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['teaser'], 'exclude' => true, 'search' => true, 'inputType' => 'textarea', 'eval' => array('style' => 'height:80px', 'tl_class' => 'clr'), 'attributes' => array('legend' => 'general_legend', 'multilingual' => true), 'sql' => "text NULL"), 'description' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['description'], 'exclude' => true, 'search' => true, 'inputType' => 'textarea', 'eval' => array('mandatory' => true, 'rte' => 'tinyMCE', 'tl_class' => 'clr'), 'attributes' => array('legend' => 'general_legend', 'multilingual' => true, 'fe_search' => true), 'sql' => "text NULL"), 'meta_title' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['meta_title'], 'exclude' => true, 'search' => true, 'inputType' => 'text', 'eval' => array('maxlength' => 255, 'tl_class' => 'clr long'), 'attributes' => array('legend' => 'meta_legend', 'multilingual' => true), 'sql' => "varchar(255) NOT NULL default ''"), 'meta_description' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['meta_description'], 'exclude' => true, 'search' => true, 'inputType' => 'textarea', 'eval' => array('style' => 'height:60px', 'tl_class' => 'clr'), 'attributes' => array('legend' => 'meta_legend', 'multilingual' => true), 'sql' => "text NULL"), 'meta_keywords' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['meta_keywords'], 'exclude' => true, 'search' => true, 'inputType' => 'textarea', 'eval' => array('style' => 'height:40px', 'tl_class' => 'clr'), 'attributes' => array('legend' => 'meta_legend', 'multilingual' => true), 'sql' => "text NULL"), 'price' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['price'], 'exclude' => true, 'inputType' => 'timePeriod', 'foreignKey' => \Isotope\Model\TaxClass::getTable() . '.name', 'eval' => array('mandatory' => true, 'maxlength' => 13, 'rgxp' => 'price', 'includeBlankOption' => true, 'blankOptionLabel' => &$GLOBALS['TL_LANG']['MSC']['taxFree'], 'doNotSaveEmpty' => true, 'tl_class' => 'w50'), 'attributes' => array('legend' => 'pricing_legend', 'fe_sorting' => true, 'dynamic' => true, 'systemColumn' => true, 'type' => '\\Isotope\\Model\\Attribute\\Price'), 'load_callback' => array(array('\\Isotope\\Backend\\Product\\Price', 'load')), 'save_callback' => array(array('\\Isotope\\Backend\\Product\\Price', 'save'))), 'prices' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['prices'], 'inputType' => 'dcaWizard', 'foreignTable' => \Isotope\Model\ProductPrice::getTable(), 'attributes' => array('systemColumn' => true), 'eval' => array('listCallback' => array('Isotope\\Backend\\ProductPrice\\Callback', 'generateWizardList'), 'applyButtonLabel' => &$GLOBALS['TL_LANG']['tl_iso_product']['prices']['apply_and_close'], 'tl_class' => 'clr')), 'price_tiers' => array('attributes' => array('type' => '\\Isotope\\Model\\Attribute\\PriceTiers'), 'tableformat' => array('min' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['price_tiers']['min'], 'format' => &$GLOBALS['TL_LANG']['tl_iso_product']['price_tiers']['min_format']), 'price' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['price_tiers']['price'], 'rgxp' => 'price'), 'tax_class' => array('doNotShow' => true))), 'baseprice' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['baseprice'], 'exclude' => true, 'inputType' => 'timePeriod', 'foreignKey' => 'tl_iso_baseprice.name', 'eval' => array('includeBlankOption' => true, 'tl_class' => 'w50'), 'attributes' => array('type' => '\\Isotope\\Model\\Attribute\\BasePrice', 'legend' => 'pricing_legend'), 'sql' => "varchar(255) NOT NULL default ''"), 'shipping_weight' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['shipping_weight'], 'exclude' => true, 'inputType' => 'timePeriod', 'default' => array('', 'kg'), 'options' => array('mg', 'g', 'kg', 't', 'ct', 'oz', 'lb', 'st', 'grain'), 'reference' => &$GLOBALS['TL_LANG']['WGT'], 'eval' => array('rgxp' => 'digit', 'tl_class' => 'w50', 'helpwizard' => true), 'attributes' => array('legend' => 'shipping_legend'), 'sql' => "varchar(255) NOT NULL default ''"), 'shipping_exempt' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['shipping_exempt'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50'), 'attributes' => array('legend' => 'shipping_legend', 'systemColumn' => true), 'sql' => "char(1) NOT NULL default ''"), 'images' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['images'], 'exclude' => true, 'inputType' => 'mediaManager', 'explanation' => 'mediaManager', 'eval' => array('extensions' => 'jpeg,jpg,png,gif', 'helpwizard' => true, 'tl_class' => 'clr'), 'attributes' => array('legend' => 'media_legend', 'fixed' => true, 'multilingual' => true, 'dynamic' => true, 'systemColumn' => true, 'fetch_fallback' => true), 'sql' => "blob NULL"), 'protected' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['protected'], 'exclude' => true, 'filter' => true, 'inputType' => 'checkbox', 'eval' => array('submitOnChange' => true, 'tl_class' => 'clr'), 'attributes' => array('legend' => 'expert_legend', 'systemColumn' => true), 'sql' => "char(1) NOT NULL default ''"), 'groups' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['groups'], 'exclude' => true, 'filter' => true, 'inputType' => 'checkbox', 'foreignKey' => 'tl_member_group.name', 'eval' => array('mandatory' => true, 'multiple' => true, 'systemColumn' => true), 'sql' => "blob NULL", 'relation' => array('type' => 'hasMany', 'load' => 'lazy')), 'guests' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['guests'], 'exclude' => true, 'inputType' => 'checkbox', 'eval' => array('tl_class' => 'w50'), 'attributes' => array('legend' => 'expert_legend', 'systemColumn' => true), 'sql' => "char(1) NOT NULL default ''"), 'cssID' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['cssID'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('multiple' => true, 'size' => 2, 'tl_class' => 'w50'), 'attributes' => array('legend' => 'expert_legend'), 'sql' => "varchar(255) NOT NULL default ''"), 'published' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['published'], 'exclude' => true, 'filter' => true, 'inputType' => 'checkbox', 'eval' => array('doNotCopy' => true, 'tl_class' => 'clr'), 'attributes' => array('legend' => 'publish_legend', 'fixed' => true, 'variant_fixed' => true, 'systemColumn' => true), 'sql' => "char(1) NOT NULL default ''", 'save_callback' => array(array('Isotope\\Backend', 'truncateProductCache'))), 'start' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['start'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('rgxp' => 'date', 'datepicker' => true, 'tl_class' => 'w50 wizard'), 'attributes' => array('legend' => 'publish_legend', 'fixed' => true, 'variant_fixed' => true, 'systemColumn' => true), 'sql' => "varchar(10) NOT NULL default ''"), 'stop' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['stop'], 'exclude' => true, 'inputType' => 'text', 'eval' => array('rgxp' => 'date', 'datepicker' => true, 'tl_class' => 'w50 wizard'), 'attributes' => array('legend' => 'publish_legend', 'fixed' => true, 'variant_fixed' => true, 'systemColumn' => true), 'sql' => "varchar(10) NOT NULL default ''"), 'variantFields' => array('label' => &$GLOBALS['TL_LANG'][\Isotope\Model\ProductType::getTable()]['variant_attributes']), 'source' => array('label' => &$GLOBALS['TL_LANG']['tl_iso_product']['source'], 'eval' => array('mandatory' => true, 'required' => true, 'fieldType' => 'radio'))));
/**
 * Adjust the data configuration array in variants view
 */
if (\Input::get('id')) {
    $GLOBALS['TL_LANG']['tl_iso_product']['new'] = $GLOBALS['TL_LANG']['tl_iso_product']['new_variant'];
    $GLOBALS['TL_DCA']['tl_iso_product']['config']['switchToEdit'] = false;
    unset($GLOBALS['TL_DCA']['tl_iso_product']['list']['global_operations']['import']);
    unset($GLOBALS['TL_DCA']['tl_iso_product']['list']['global_operations']['groups']);
} else {
    unset($GLOBALS['TL_DCA']['tl_iso_product']['list']['global_operations']['generate']);
}
Exemplo n.º 5
0
 /**
  * Save price to the prices subtable
  * @param   mixed
  * @param   DataContainer
  * @return  mixed
  */
 public function save($varValue, \DataContainer $dc)
 {
     $time = time();
     // Parse the timePeriod widget
     $arrValue = deserialize($varValue, true);
     $strPrice = (string) $arrValue['value'];
     $intTax = (int) $arrValue['unit'];
     $objPrice = \Database::getInstance()->query("SELECT t.id, p.id AS pid, p.tax_class, t.price FROM " . ProductPrice::getTable() . " p LEFT JOIN tl_iso_product_pricetier t ON p.id=t.pid AND t.min=1 WHERE p.pid={$dc->id} AND p.config_id=0 AND p.member_group=0 AND p.start='' AND p.stop=''");
     // Price tier record already exists, update it
     if ($objPrice->numRows && $objPrice->id > 0) {
         if ($objPrice->price != $strPrice) {
             \Database::getInstance()->prepare("UPDATE tl_iso_product_pricetier SET tstamp={$time}, price=? WHERE id=?")->execute($strPrice, $objPrice->id);
             $dc->createNewVersion = true;
         }
         if ($objPrice->tax_class != $intTax) {
             \Database::getInstance()->prepare("UPDATE " . ProductPrice::getTable() . " SET tstamp={$time}, tax_class=? WHERE id=?\n                ")->execute($intTax, $objPrice->pid);
             $dc->createNewVersion = true;
         }
     } else {
         $intPrice = $objPrice->pid;
         // Neither price tier nor price record exist, must add both
         if (!$objPrice->numRows) {
             $intPrice = \Database::getInstance()->prepare("\n                    INSERT INTO " . ProductPrice::getTable() . " (pid,tstamp,tax_class) VALUES (?,?,?)\n                ")->execute($dc->id, $time, $intTax)->insertId;
         } elseif ($objPrice->tax_class != $intTax) {
             \Database::getInstance()->prepare("\n                    UPDATE " . ProductPrice::getTable() . " SET tstamp=?, tax_class=? WHERE id=?\n                ")->execute($time, $intTax, $intPrice);
         }
         \Database::getInstance()->prepare("\n                INSERT INTO tl_iso_product_pricetier (pid,tstamp,min,price) VALUES (?,?,1,?)\n            ")->execute($intPrice, $time, $strPrice);
         $dc->createNewVersion = true;
     }
     return '';
 }