Exemplo n.º 1
0
 /**
  * Standard SS variable.
  */
 function getCMSFields()
 {
     //prevent calling updateCMSFields extend function too early
     $siteTreeFieldExtensions = $this->get_static('SiteTree', 'runCMSFieldsExtensions');
     $this->disableCMSFieldsExtensions();
     $fields = parent::getCMSFields();
     if ($siteTreeFieldExtensions) {
         $this->enableCMSFieldsExtensions();
     }
     $fields->replaceField('Root.Content.Main', new HTMLEditorField('Content', _t('Product.DESCRIPTION', 'Product Description'), 3));
     //NOTE: IMAGE FIELD WAS GIVING ERRORS IN ModelAdmin
     //$fields->addFieldToTab('Root.Content.Images', new TreeDropdownField('ImageID', _t('Product.IMAGE', 'Product Image'), "Image"));
     $fields->addFieldToTab('Root.Content.Images', new ImageField('Image', _t('Product.IMAGE', 'Product Image')));
     $fields->addFieldToTab('Root.Content.Details', new ReadonlyField('FullName', _t('Product.FULLNAME', 'Full Name')));
     $fields->addFieldToTab('Root.Content.Details', new CheckboxField('AllowPurchase', _t('Product.ALLOWPURCHASE', 'Allow product to be purchased'), 1));
     $fields->addFieldToTab('Root.Content.Details', new CheckboxField('FeaturedProduct', _t('Product.FEATURED', 'Featured Product')));
     $fields->addFieldToTab('Root.Content.Details', new NumericField('Price', _t('Product.PRICE', 'Price'), '', 12));
     $fields->addFieldToTab('Root.Content.Details', new TextField('InternalItemID', _t('Product.CODE', 'Product Code'), '', 30));
     if ($this->EcomConfig()->ProductsHaveWeight) {
         $fields->addFieldToTab('Root.Content.Details', new NumericField('Weight', _t('Product.WEIGHT', 'Weight')));
     }
     if ($this->EcomConfig()->ProductsHaveModelNames) {
         $fields->addFieldToTab('Root.Content.Details', new TextField('Model', _t('Product.MODEL', 'Model')));
     }
     if ($this->EcomConfig()->ProductsHaveQuantifiers) {
         $fields->addFieldToTab('Root.Content.Details', new TextField('Quantifier', _t('Product.QUANTIFIER', 'Quantifier (e.g. per kilo, per month, per dozen, each)')));
     }
     if ($this->EcomConfig()->ProductsAlsoInOtherGroups) {
         $fields->addFieldsToTab('Root.Content.AlsoShowHere', array(new HeaderField('ProductGroupsHeader', _t('Product.ALSOSHOWSIN', 'Also shows in ...')), $this->getProductGroupsTable()));
     }
     $orderTableField = new ComplexTableField($this, 'OrderItems', 'OrderItem', array('Order.ID' => '#', 'Order.Created' => 'When', 'Quantity' => 'Quantity'), new FieldSet(), "\"BuyableID\" = '" . $this->ID . "' AND \"BuyableClassName\" = '" . $this->ClassName . "'", "\"Created\" DESC");
     $orderTableField->setPermissions(array("show"));
     $orderTableField->setShowPagination(true);
     $orderTableField->setRelationAutoSetting(true);
     /*
     $orderTableField->addSummary(
     	_t("Product.TOTALCOUNT", "Total Count"),
     	array("TotalCount" => array("sum","Quantity->Nice"))
     );
     */
     $fields->addFieldToTab('Root.Content.Orders', $orderTableField);
     if ($siteTreeFieldExtensions) {
         $this->extend('updateCMSFields', $fields);
     }
     return $fields;
 }
 /**
  * Get products table
  * @return ComplexTableField
  */
 public function getCMSProductsTable()
 {
     $table = new ComplexTableField($this, 'OrderItems', 'RepeatOrder_OrderItem', array('Product.Title' => 'Title', 'Quantity' => 'Qty'));
     $table->setShowPagination(false);
     $table->setAddTitle('Product');
     $table->setPermissions(array('add', 'edit', 'delete'));
     return $table;
 }