Пример #1
0
 /**
  * Adds or modifies the fields for the Prices tab
  *
  * @param FieldList $fields FieldList to add fields to
  * 
  * @return void
  */
 public function getFieldsForPrices($fields)
 {
     SilvercartTax::presetDropdownWithDefault($fields->dataFieldByName('SilvercartTaxID'), $this);
     $pricesGroup = new SilvercartFieldGroup('PricesGroup', '', $fields);
     $pricesGroup->push($fields->dataFieldByName('PriceGross'));
     $pricesGroup->push($fields->dataFieldByName('PriceNet'));
     $pricesGroup->push($fields->dataFieldByName('MSRPrice'));
     $pricesGroup->push($fields->dataFieldByName('PurchasePrice'));
     $pricesGroup->push($fields->dataFieldByName('SilvercartTaxID'));
     $fields->insertAfter($pricesGroup, 'ProductNumberGroup');
 }
Пример #2
0
 /**
  * Returns the quick access fields to display in GridField
  * 
  * @return FieldList
  */
 public function getQuickAccessFields()
 {
     $quickAccessFields = new FieldList();
     $threeColField = '<div class="multi-col-field"><strong>%s</strong><span>%s</span><span>%s</span></div>';
     $twoColField = '<div class="multi-col-field"><strong>%s</strong><span></span><span>%s</span></div>';
     $orderNumberField = new TextField('OrderNumber__' . $this->ID, $this->fieldLabel('OrderNumber'), $this->OrderNumber);
     $orderStatusField = new TextField('SilvercartOrderStatus__' . $this->ID, $this->fieldLabel('SilvercartOrderStatus'), $this->SilvercartOrderStatus()->Title);
     $orderPositionTable = new SilvercartTableField('SilvercartOrderPositions__' . $this->ID, $this->fieldLabel('SilvercartOrderPositions'), $this->SilvercartOrderPositions());
     $shippingField = new LiteralField('SilvercartShippingMethod__' . $this->ID, sprintf($threeColField, $this->fieldLabel('SilvercartShippingMethod'), $this->SilvercartShippingMethod()->TitleWithCarrier, $this->HandlingCostShipmentNice));
     $paymentField = new LiteralField('SilvercartPaymentMethod__' . $this->ID, sprintf($threeColField, $this->fieldLabel('SilvercartPaymentMethod'), $this->SilvercartPaymentMethod()->Title, $this->HandlingCostPaymentNice));
     $amountTotalField = new LiteralField('AmountTotal__' . $this->ID, sprintf($twoColField, $this->fieldLabel('AmountTotal'), $this->AmountTotalNice));
     $orderNumberField->setReadonly(true);
     $orderStatusField->setReadonly(true);
     $mainGroup = new SilvercartFieldGroup('MainGroup');
     $mainGroup->push($orderNumberField);
     $mainGroup->push($orderStatusField);
     $quickAccessFields->push($mainGroup);
     $quickAccessFields->push($orderPositionTable);
     $quickAccessFields->push($shippingField);
     $quickAccessFields->push($paymentField);
     $quickAccessFields->push($amountTotalField);
     $this->extend('updateQuickAccessFields', $quickAccessFields);
     return $quickAccessFields;
 }
 /**
  * Return all fields of the backend.
  *
  * @return FieldList Fields of the CMS
  */
 public function getCMSFields()
 {
     $this->getCMSFieldsIsCalled = true;
     $fields = parent::getCMSFields();
     $useOnlydefaultGroupviewSource = array('inherit' => _t('SilvercartProductGroupPage.DEFAULTGROUPVIEW_DEFAULT'), 'yes' => _t('Silvercart.YES'), 'no' => _t('Silvercart.NO'));
     $useContentField = new CheckboxField('useContentFromParent', $this->fieldLabel('useContentFromParent'));
     $doNotShowProductsField = new CheckboxField('DoNotShowProducts', $this->fieldLabel('DoNotShowProducts'));
     $productsPerPageField = new TextField('productsPerPage', $this->fieldLabel('productsPerPage'));
     $defaultGroupViewField = SilvercartGroupViewHandler::getGroupViewDropdownField('DefaultGroupView', $this->fieldLabel('DefaultGroupView'), $this->DefaultGroupView, _t('SilvercartProductGroupPage.DEFAULTGROUPVIEW_DEFAULT'));
     $useOnlyDefaultGroupViewField = new DropdownField('UseOnlyDefaultGroupView', $this->fieldLabel('UseOnlyDefaultGroupView'), $useOnlydefaultGroupviewSource, $this->UseOnlyDefaultGroupView);
     $productGroupsPerPageField = new TextField('productGroupsPerPage', $this->fieldLabel('productGroupsPerPage'));
     $defaultGroupHolderViewField = SilvercartGroupViewHandler::getGroupViewDropdownField('DefaultGroupHolderView', $this->fieldLabel('DefaultGroupHolderView'), $this->DefaultGroupHolderView, _t('SilvercartProductGroupPage.DEFAULTGROUPVIEW_DEFAULT'));
     $useOnlyDefaultGroupHolderViewField = new DropdownField('UseOnlyDefaultGroupHolderView', $this->fieldLabel('UseOnlyDefaultGroupHolderView'), $useOnlydefaultGroupviewSource, $this->UseOnlyDefaultGroupHolderView);
     $fieldGroup = new SilvercartFieldGroup('FieldGroup', '', $fields);
     $productsPerPageField->setRightTitle(_t('SilvercartProductGroupPage.PRODUCTSPERPAGEHINT'));
     $productGroupsPerPageField->setRightTitle(_t('SilvercartProductGroupPage.PRODUCTSPERPAGEHINT'));
     $fieldGroup->push($useContentField);
     $fieldGroup->breakAndPush($doNotShowProductsField);
     $fieldGroup->breakAndPush($productsPerPageField);
     $fieldGroup->breakAndPush($defaultGroupViewField);
     $fieldGroup->push($useOnlyDefaultGroupViewField);
     $fieldGroup->breakAndPush($productGroupsPerPageField);
     $fieldGroup->breakAndPush($defaultGroupHolderViewField);
     $fieldGroup->push($useOnlyDefaultGroupHolderViewField);
     $displaySettingsToggle = ToggleCompositeField::create('DisplaySettingsToggle', $this->fieldLabel('DisplaySettings'), array($fieldGroup))->setHeadingLevel(4)->setStartClosed(true);
     $fields->insertAfter($displaySettingsToggle, 'Content');
     $mirroredProductIdList = '';
     $mirroredProductIDs = $this->getMirroredProductIDs();
     foreach ($mirroredProductIDs as $mirroredProductID) {
         $mirroredProductIdList .= sprintf("'%s',", $mirroredProductID);
     }
     if (!empty($mirroredProductIdList)) {
         $mirroredProductIdList = substr($mirroredProductIdList, 0, -1);
         $filter = sprintf("SilvercartProductGroupID = %d OR\n                 \"SilvercartProduct\".\"ID\" IN (%s)", $this->ID, $mirroredProductIdList);
     } else {
         $filter = sprintf("SilvercartProductGroupID = %d", $this->ID);
     }
     if ($this->drawCMSFields()) {
         $config = GridFieldConfig_RecordViewer::create(100);
         $productsTableField = new GridField('SilvercartProducts', $this->fieldLabel('SilvercartProducts'), SilvercartProduct::get()->filter(array('SilvercartProductGroupID' => $this->ID)), $config);
         $tabPARAM = "Root." . _t('SilvercartProduct.TITLE', 'product');
         $fields->addFieldToTab($tabPARAM, $productsTableField);
         $productAdminLink = Director::baseURL() . 'admin/silvercart-products';
         $manageProductsButton = new LiteralField('ManageProductsButton', sprintf("<a href=\"%s\">%s</a>", $productAdminLink, _t('SilvercartProductGroupPage.MANAGE_PRODUCTS_BUTTON')));
         $fields->addFieldToTab($tabPARAM, $manageProductsButton);
         $fields->addFieldToTab('Root.Main', new UploadField('GroupPicture', _t('SilvercartProductGroupPage.GROUP_PICTURE')), 'Content');
     }
     $widgetSetContent = $fields->fieldByName('Root.Widgets.WidgetSetContent');
     if ($widgetSetContent) {
         $widgetSetAdminLink = Director::baseURL() . 'admin/silvercart-widget-sets';
         $manageWidgetsButton = new LiteralField('ManageWidgetsButton', sprintf("<a href=\"%s\">%s</a>", $widgetSetAdminLink, _t('SilvercartWidgetSet.MANAGE_WIDGETS_BUTTON')));
         $fields->insertAfter($manageWidgetsButton, 'WidgetSetContent');
     }
     $this->extend('extendCMSFields', $fields);
     return $fields;
 }
 /**
  * customizes the backends fields, mainly for ModelAdmin
  * 
  * @param array $params configuration parameters
  *
  * @return FieldList the fields for the backend
  * 
  * @author Roland Lehmann <*****@*****.**>, Sebastian Diel <*****@*****.**>
  * @since 26.10.2012
  */
 public function getCMSFields($params = null)
 {
     $fields = parent::getCMSFields(array_merge(array('fieldClasses' => array('amount' => 'SilvercartMoneyField')), (array) $params));
     SilvercartTax::presetDropdownWithDefault($fields->dataFieldByName('SilvercartTaxID'), $this);
     $fieldGroup = new SilvercartFieldGroup('handlingCostGroup', '', $fields);
     $fieldGroup->push($fields->dataFieldByName('amount'));
     $fieldGroup->pushAndBreak($fields->dataFieldByName('SilvercartTaxID'));
     $fields->addFieldToTab('Root.Main', $fieldGroup);
     return $fields;
 }
 /**
  * Customizes the backends fields, mainly for ModelAdmin
  *
  * @return FieldList the fields for the backend
  * 
  * @author Roland Lehmann <*****@*****.**>, Sebastian Diel <*****@*****.**>
  * @since 13.02.2013
  */
 public function getCMSFields()
 {
     $this->getCMSFieldsIsCalled = true;
     $fields = parent::getCMSFields();
     $postPricingField = $fields->dataFieldByName('PostPricing');
     $postPricingField->setTitle($postPricingField->Title() . ' (' . $this->fieldLabel('PostPricingInfo') . ')');
     SilvercartTax::presetDropdownWithDefault($fields->dataFieldByName('SilvercartTaxID'), $this);
     $fieldGroup = new SilvercartFieldGroup('ShippingFeeGroup', '', $fields);
     $fieldGroup->push($fields->dataFieldByName('MaximumWeight'));
     $fieldGroup->pushAndBreak($fields->dataFieldByName('UnlimitedWeight'));
     $fieldGroup->push($fields->dataFieldByName('Price'));
     $fieldGroup->pushAndBreak($fields->dataFieldByName('SilvercartTaxID'));
     $fieldGroup->pushAndBreak($postPricingField);
     // only the carriers zones must be selectable
     $leftJoinTable = 'SilvercartZone_SilvercartCarriers';
     $leftJoinOn = '"SilvercartZone"."ID" = "SilvercartZone_SilvercartCarriers"."SilvercartZoneID"';
     $where = sprintf("\"SilvercartZone_SilvercartCarriers\".\"SilvercartCarrierID\" = %s", $this->SilvercartShippingMethod()->SilvercartCarrier()->ID);
     $zones = SilvercartZone::get()->leftJoin($leftJoinTable, $leftJoinOn)->where($where);
     if ($zones->exists()) {
         $zonesMap = $zones->map('ID', 'Title');
         $zonesField = new DropdownField('SilvercartZoneID', _t('SilvercartShippingFee.ZONE_WITH_DESCRIPTION', 'zone (only carrier\'s zones available)'), $zonesMap->toArray());
         $fieldGroup->push($zonesField);
     }
     $fieldGroup->breakAndPush($fields->dataFieldByName('freeOfShippingCostsDisabled'));
     $fieldGroup->breakAndPush($fields->dataFieldByName('freeOfShippingCostsFrom'));
     $fields->dataFieldByName('DeliveryTimeMin')->setRightTitle($this->fieldLabel('DeliveryTimeMinDesc'));
     $fields->dataFieldByName('DeliveryTimeMax')->setRightTitle($this->fieldLabel('DeliveryTimeMaxDesc'));
     $fields->dataFieldByName('DeliveryTimeText')->setRightTitle($this->fieldLabel('DeliveryTimeTextDesc'));
     $parentDeliveryTime = '';
     if ($this->SilvercartShippingMethod()->exists()) {
         $parentDeliveryTime = '<br/>(' . SilvercartShippingMethod::get_delivery_time($this->SilvercartShippingMethod(), true) . ')';
     }
     $fieldGroup->pushAndBreak(new LiteralField('DeliveryTimeHint', '<strong>' . $this->fieldLabel('DeliveryTimeHint') . $parentDeliveryTime . '</strong>'));
     $fieldGroup->push($fields->dataFieldByName('DeliveryTimeMin'));
     $fieldGroup->pushAndBreak($fields->dataFieldByName('DeliveryTimeMax'));
     $fieldGroup->pushAndBreak($fields->dataFieldByName('DeliveryTimeText'));
     $fields->addFieldToTab('Root.Main', $fieldGroup);
     return $fields;
 }
 /**
  * Return all fields of the backend.
  *
  * @return FieldList Fields of the CMS
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $useOnlydefaultGroupviewSource = array('inherit' => _t('SilvercartProductGroupPage.DEFAULTGROUPVIEW_DEFAULT'), 'yes' => $this->fieldLabel('Yes'), 'no' => $this->fieldLabel('No'));
     $defaultGroupViewField = SilvercartGroupViewHandler::getGroupViewDropdownField('DefaultGroupView', $this->fieldLabel('DefaultGroupView'), $this->DefaultGroupView, _t('SilvercartProductGroupPage.DEFAULTGROUPVIEW_DEFAULT'));
     $useOnlyDefaultGroupViewField = new DropdownField('UseOnlyDefaultGroupView', $this->fieldLabel('UseOnlyDefaultGroupView'), $useOnlydefaultGroupviewSource, $this->UseOnlyDefaultGroupView);
     $productGroupsPerPageField = new TextField('productGroupsPerPage', $this->fieldLabel('productGroupsPerPage'));
     $defaultGroupHolderViewField = SilvercartGroupViewHandler::getGroupViewDropdownField('DefaultGroupHolderView', $this->fieldLabel('DefaultGroupHolderView'), $this->DefaultGroupHolderView, $this->fieldLabel('DefaultGroupView'));
     $useOnlyDefaultGroupHolderViewField = new DropdownField('UseOnlyDefaultGroupHolderView', $this->fieldLabel('UseOnlyDefaultGroupHolderView'), $useOnlydefaultGroupviewSource, $this->UseOnlyDefaultGroupHolderView);
     $fieldGroup = new SilvercartFieldGroup('FieldGroup', '', $fields);
     $redirectionFieldGroup = new SilvercartFieldGroup('RedirectionFieldGroup', '', $fields);
     $redirectToProductGroupField = new CheckboxField('RedirectToProductGroup', $this->fieldLabel('RedirectToProductGroup'));
     $linkToField = new TreeDropdownField('LinkToID', $this->fieldLabel('LinkTo'), 'SiteTree');
     $productGroupsPerPageField->setRightTitle(_t('SilvercartProductGroupPage.PRODUCTSPERPAGEHINT'));
     $fieldGroup->push($defaultGroupViewField);
     $fieldGroup->push($useOnlyDefaultGroupViewField);
     $fieldGroup->breakAndPush($productGroupsPerPageField);
     $fieldGroup->breakAndPush($defaultGroupHolderViewField);
     $fieldGroup->push($useOnlyDefaultGroupHolderViewField);
     $redirectionFieldGroup->push($redirectToProductGroupField);
     if ($this->exists()) {
         $linkToField->setTreeBaseID($this->ID);
         $redirectionFieldGroup->breakAndPush($linkToField);
     }
     $displaySettingsToggle = ToggleCompositeField::create('DisplaySettingsToggle', $this->fieldLabel('DisplaySettings'), array($fieldGroup))->setHeadingLevel(4)->setStartClosed(true);
     $redirectionSettingsToggle = ToggleCompositeField::create('RedirectionSettingsToggle', $this->fieldLabel('RedirectionSettings'), array($redirectionFieldGroup))->setHeadingLevel(4)->setStartClosed(true);
     $fields->insertAfter($redirectionSettingsToggle, 'Content');
     $fields->insertAfter($displaySettingsToggle, 'Content');
     $this->extend('extendCMSFields', $fields);
     return $fields;
 }