public function getCMSFields() { $fields = parent::getCMSFields(); $fields->insertAfter(new ToggleCompositeField('AfterRegistrationContent', _t('EventRegistration.AFTER_REG_CONTENT', 'After Registration Content'), array(new TextField('AfterRegTitle', _t('EventRegistration.TITLE', 'Title')), new HtmlEditorField('AfterRegContent', _t('EventRegistration.CONTENT', 'Content')))), 'Content'); $fields->insertAfter(new ToggleCompositeField('AfterUnRegistrationContent', _t('EventRegistration.AFTER_UNREG_CONTENT', 'After Un-Registration Content'), array(new TextField('AfterUnregTitle', _t('EventRegistration.TITLE', 'Title')), new HtmlEditorField('AfterUnregContent', _t('EventRegistration.CONTENT', 'Content')))), 'AfterRegistrationContent'); if ($this->RegEmailConfirm) { $fields->addFieldToTab('Root.Main', new ToggleCompositeField('AfterRegistrationConfirmation', _t('EventRegistration.AFTER_REG_CONFIRM_CONTENT', 'After Registration Confirmation Content'), array(new TextField('AfterConfirmTitle', _t('EventRegistration.TITLE', 'Title')), new HtmlEditorField('AfterConfirmContent', _t('EventRegistration.CONTENT', 'Content'))))); } if ($this->UnRegEmailConfirm) { $fields->addFieldToTab('Root.Main', new ToggleCompositeField('AfterUnRegistrationConfirmation', _t('EventRegistration.AFTER_UNREG_CONFIRM_CONTENT', 'After Un-Registration Confirmation Content'), array(new TextField('AfterConfUnregTitle', _t('EventRegistration.TITLE', 'Title')), new HtmlEditorField('AfterConfUnregContent', _t('EventRegistration.CONTENT', 'Content'))))); } $fields->addFieldToTab('Root.Tickets', new GridField('Tickets', 'Ticket Types', $this->Tickets(), GridFieldConfig_RecordEditor::create())); $generators = ClassInfo::implementorsOf('EventRegistrationTicketGenerator'); if ($generators) { foreach ($generators as $generator) { $instance = new $generator(); $generators[$generator] = $instance->getGeneratorTitle(); } $generator = new DropdownField('TicketGenerator', _t('EventRegistration.TICKET_GENERATOR', 'Ticket generator'), $generators); $generator->setEmptyString(_t('EventManagement.NONE', '(None)')); $generator->setDescription(_t('EventManagement.TICKET_GENERATOR_NOTE', 'The ticket generator is used to generate a ticket file for the user to download.')); $fields->addFieldToTab('Root.Tickets', $generator); } $regGridFieldConfig = GridFieldConfig_Base::create()->removeComponentsByType('GridFieldAddNewButton')->removeComponentsByType('GridFieldDeleteAction')->addComponents(new GridFieldButtonRow('after'), new GridFieldPrintButton('buttons-after-left'), new GridFieldExportButton('buttons-after-left')); $fields->addFieldsToTab('Root.Registrations', array(new GridField('Registrations', _t('EventManagement.REGISTRATIONS', 'Registrations'), $this->DateTimes()->relation('Registrations')->filter('Status', 'Valid'), $regGridFieldConfig), new GridField('CanceledRegistrations', _t('EventManagement.CANCELLATIONS', 'Cancellations'), $this->DateTimes()->relation('Registrations')->filter('Status', 'Canceled'), $regGridFieldConfig))); if ($this->RegEmailConfirm) { $fields->addFieldToTab('Root.Registrations', new ToggleCompositeField('UnconfirmedRegistrations', _t('EventManagement.UNCONFIRMED_REGISTRATIONS', 'Unconfirmed Registrations'), array(new GridField('UnconfirmedRegistrations', '', $this->DateTimes()->relation('Registrations')->filter('Status', 'Unconfirmed'))))); } $fields->addFieldToTab('Root.Invitations', new GridField('Invitations', _t('EventManagement.INVITATIONS', 'Invitations'), $this->Invitations(), GridFieldConfig_RecordViewer::create()->addComponent(new GridFieldButtonRow('before'))->addComponent(new EventSendInvitationsButton($this)))); return $fields; }
/** * Gets the form fields for display in the CMS. * * The actual report configuration fields should be generated by * {@link getSettingsFields()}, so they can also be used in the front end. * * @return FieldList */ public function getCMSFields() { Requirements::css('advancedreports/css/cms.css'); $fields = new FieldList(array(new TabSet('Root', new Tab('Main', new GridField('GeneratedReports', _t('AdvancedReport.GENERATED_REPORTS', 'Generated Reports'), $this->Reports()->sort('Created', 'DESC'), $config = GridFieldConfig_Base::create()->addComponent(new GridFieldDeleteAction())))))); $columns = $config->getComponentByType('GridFieldDataColumns'); $columns->setDisplayFields(array('Title' => _t('AdvancedReport.TITLE', 'Title'), 'Created' => _t('AdvancedReport.GENERATED_AT', 'Generated At'), 'Links' => _t('AdvancedReport.LINKS', 'Links'))); $columns->setFieldFormatting(array('Links' => function ($value, $item) { $result = ''; $links = array('html', 'csv'); if ($item->config()->generate_pdf) { $links[] = 'pdf'; } foreach ($links as $type) { $result .= sprintf('<a href="%s" target="_blank" class="advanced-report-download-link">%s</a>', $item->getFileLink($type), strtoupper($type)); } return $result; })); if ($this->isInDB() && $this->canGenerate()) { $options = array('html' => 'HTML', 'csv' => 'CSV', 'pdf' => 'PDF'); if (!class_exists('PDFRenditionService')) { unset($options['pdf']); } $fields->addFieldsToTab('Root.Main', array(DropdownField::create('PreviewFormat')->setTitle(_t('AdvancedReport.PREVIEW_FORMAT', 'Preview format'))->setSource($options), TextField::create('GeneratedReportTitle')->setTitle(_t('AdvancedReport.GENERATED_TITLE', 'Generated report title'))->setValue($this->Title)), 'GeneratedReports'); } if ($this->canEdit()) { $fields->addFieldsToTab('Root.Settings', $this->getSettingsFields()); } $this->extend('updateCMSFields', $fields); return $fields; }
public function getCMSFields() { $existing_customer = $this->config()->existing_customer_class; // Manually inject HTML for totals as Silverstripe refuses to // render Currency.Nice any other way. $subtotal_html = '<div id="SubTotal" class="field readonly">'; $subtotal_html .= '<label class="left" for="Form_ItemEditForm_SubTotal">'; $subtotal_html .= _t("Orders.SubTotal", "Sub Total"); $subtotal_html .= '</label>'; $subtotal_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_SubTotal" class="readonly">'; $subtotal_html .= $this->SubTotal->Nice(); $subtotal_html .= '</span></div></div>'; $discount_html = '<div id="Discount" class="field readonly">'; $discount_html .= '<label class="left" for="Form_ItemEditForm_Discount">'; $discount_html .= _t("Orders.Discount", "Discount"); $discount_html .= '</label>'; $discount_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_Discount" class="readonly">'; $discount_html .= $this->dbObject("DiscountAmount")->Nice(); $discount_html .= '</span></div></div>'; $postage_html = '<div id="Postage" class="field readonly">'; $postage_html .= '<label class="left" for="Form_ItemEditForm_Postage">'; $postage_html .= _t("Orders.Postage", "Postage"); $postage_html .= '</label>'; $postage_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_Postage" class="readonly">'; $postage_html .= $this->Postage->Nice(); $postage_html .= '</span></div></div>'; $tax_html = '<div id="TaxTotal" class="field readonly">'; $tax_html .= '<label class="left" for="Form_ItemEditForm_TaxTotal">'; $tax_html .= _t("Orders.Tax", "Tax"); $tax_html .= '</label>'; $tax_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_TaxTotal" class="readonly">'; $tax_html .= $this->TaxTotal->Nice(); $tax_html .= '</span></div></div>'; $total_html = '<div id="Total" class="field readonly">'; $total_html .= '<label class="left" for="Form_ItemEditForm_Total">'; $total_html .= _t("Orders.Total", "Total"); $total_html .= '</label>'; $total_html .= '<div class="middleColumn"><span id="Form_ItemEditForm_Total" class="readonly">'; $total_html .= $this->Total->Nice(); $total_html .= '</span></div></div>'; $fields = new FieldList($tab_root = new TabSet("Root", $tab_main = new Tab('Main', new OrderItemGridField("Items", "", $this->Items(), $config = GridFieldConfig::create()->addComponents(new GridFieldButtonRow('before'), new GridFieldTitleHeader(), new GridFieldEditableColumns(), new GridFieldDeleteAction(), new GridFieldAddOrderItem())), new HeaderField("PostageDetailsHeader", _t("Orders.PostageDetails", "Postage Details")), TextField::create("PostageType"), TextField::create("PostageCost"), TextField::create("PostageTax"), new HeaderField("DiscountDetailsHeader", _t("Orders.DiscountDetails", "Discount")), TextField::create("Discount"), TextField::create("DiscountAmount"), OrderSidebar::create(ReadonlyField::create("QuoteNumber", "#")->setValue($this->ID), LiteralField::create("SubTotal", $subtotal_html), LiteralField::create("Discount", $discount_html), LiteralField::create("Postage", $postage_html), LiteralField::create("TaxTotal", $tax_html), LiteralField::create("Total", $total_html))->setTitle("Details")), $tab_customer = new Tab('Customer', TextField::create("Company"), TextField::create("FirstName"), TextField::create("Surname"), TextField::create("Address1"), TextField::create("Address2"), TextField::create("City"), TextField::create("PostCode"), TextField::create("Country"), TextField::create("Email"), TextField::create("PhoneNumber")))); if ($this->canEdit()) { // Sidebar $tab_customer->insertBefore(CustomerSidebar::create(new GridField("ExistingCustomers", "", $existing_customer::get(), $config = GridFieldConfig_Base::create()->addComponents($map_extension = new GridFieldMapExistingAction())))->setTitle("Use Existing Customer"), "Company"); if (is_array($this->config()->existing_customer_fields)) { $columns = $config->getComponentByType("GridFieldDataColumns"); if ($columns) { $columns->setDisplayFields($this->config()->existing_customer_fields); } } // Set the record ID $map_extension->setMapFields($this->config()->existing_customer_map); } $tab_main->addExtraClass("order-admin-items"); $tab_customer->addExtraClass("order-admin-customer"); $this->extend("updateCMSFields", $fields); return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->removeByName('Emails'); $config = GridFieldConfig_Base::create(); $config->addComponent(new ViewEmailButton()); $gf = GridField::create('Emails', 'Sent emails', $this->Emails(), $config); $fields->addFieldToTab('Root.Main', $gf); return $fields; }
/** * Creates a new GridField field * * @param string $name * @param string $title * @param SS_List $dataList * @param GridFieldConfig $config */ public function __construct($name, $title = null, SS_List $dataList = null, GridFieldConfig $config = null) { parent::__construct($name, $title, null); $this->name = $name; if ($dataList) { $this->setList($dataList); } $this->setConfig($config ?: GridFieldConfig_Base::create()); $this->config->addComponent(new GridState_Component()); $this->state = new GridState($this); $this->addExtraClass('ss-gridfield'); }
public function getFormFields($buyable) { $fields = \CompositeField::create(\LiteralField::create('Recommended_FindBy-OtherCategory-Message', '<p class="message field desc selectionGroup-desc">' . _t('Product.Recommended_FindBy-OtherProducts-Message', 'Recommended products will be pulled from the selected products') . '</p>'), \CheckboxField::create('Recommended_Random', _t('Product.Recommended_Random', 'Display products in random order?')), \GridField::create('Recommended_Products', _t('Product.Products', 'Products'), $buyable->Recommended_Products()->sort('SortOrder', 'ASC'), $gfc = \GridFieldConfig_Base::create($buyable->config()->recommended_limit)->addComponent(new \GridFieldButtonRow('before'), 'GridFieldToolbarHeader')->addComponent(new \GridFieldAddExistingAutocompleter('buttons-before-left', ['Title:PartialMatch', 'InternalItemID', 'Model:PartialMatch']), 'GridFieldToolbarHeader')->addComponent(new \GridFieldDeleteAction(true)))); if (\ClassInfo::exists('GridFieldExtensions')) { $gfc->removeComponentsByType('GridFieldDataColumns'); $gfc->removeComponentsByType('GridFieldAddExistingAutocompleter'); $gfc->addComponent(new \GridFieldOrderableRows('SortOrder')); $gfc->addComponent(new \GridFieldAddExistingSearchButton('buttons-before-left'), 'GridFieldToolbarHeader'); $gfc->addComponent((new \GridFieldEditableColumns())->setDisplayFields(['AltTitle' => ['title' => _t('Product.TITLE', 'Title'), 'callback' => function ($record, $col, $gf) { return \TextField::create($col, _t('Product.TITLE', 'Title'), $record->{$col})->setAttribute('placeholder', $record->Title); }]]), 'GridFieldDeleteAction'); } return $fields; }
public function getCMSFields() { $fields = parent::getCMSFields(); $grid = $fields->dataFieldByName('ChangesetItems'); $fields = FieldList::create(); $fields->push($grid); $config = GridFieldConfig_Base::create(50); $grid->setConfig($config); $config->addComponent(new GridFieldViewCMSButton()); $invalidItems = $this->ChangesetItems()->filter('OtherID', '0'); // get rid of them $invalidItems->removeAll(); $this->extend('updateCMSFields', $fields); return $fields; }