public function __construct($itemsPerPage = null)
 {
     parent::__construct($itemsPerPage);
     $this->addComponent(new GridFieldViewButton());
     $this->addComponent(new GridFieldDetailForm());
     $this->extend('updateConfig');
 }
 /**
  * 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()
 {
     $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;
 }
 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;
 }
Ejemplo n.º 6
0
 /**
  * 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;
 }
 public function updateFields(FieldList $fields)
 {
     if (!$this->owner->ID) {
         return $fields;
     }
     $effective = $this->workflowService->getDefinitionFor($this->owner);
     $tab = $fields->fieldByName('Root') ? $fields->findOrMakeTab('Root.Workflow') : $fields;
     if (Permission::check('APPLY_WORKFLOW')) {
         $definition = new DropdownField('WorkflowDefinitionID', _t('WorkflowApplicable.DEFINITION', 'Applied Workflow'));
         $definition->setSource($this->workflowService->getDefinitions()->map());
         $definition->setEmptyString(_t('WorkflowApplicable.INHERIT', 'Inherit from parent'));
         $tab->push($definition);
         //			$fields->addFieldToTab($tab, $definition);
     }
     $tab->push(new ReadonlyField('EffectiveWorkflow', _t('WorkflowApplicable.EFFECTIVE_WORKFLOW', 'Effective Workflow'), $effective ? $effective->Title : _t('WorkflowApplicable.NONE', '(none)')));
     if ($this->owner->ID) {
         $config = new GridFieldConfig_Base();
         $config->addComponent(new GridFieldEditButton());
         $config->addComponent(new GridFieldDetailForm());
         $insts = $this->owner->WorkflowInstances();
         $log = new GridField('WorkflowLog', _t('WorkflowApplicable.WORKFLOWLOG', 'Workflow Log'), $insts, $config);
         $tab->push($log);
     }
 }
 public function getEditForm($id = null, $fields = null)
 {
     $form = parent::getEditForm($id, $fields);
     // Show items submitted into a workflow for current user to action
     $fieldName = 'PendingObjects';
     $pending = $this->userObjects(Member::currentUser(), $fieldName);
     if (self::$fieldOverrides) {
         $displayFields = self::$fieldOverrides;
     } else {
         $displayFields = array('Title' => _t('AdvancedWorkflowAdmin.Title', 'Title'), 'LastEdited' => _t('AdvancedWorkflowAdmin.LastEdited', 'Changed'), 'WorkflowTitle' => _t('AdvancedWorkflowAdmin.WorkflowTitle', 'Effective workflow'), 'WorkflowStatus' => _t('AdvancedWorkflowAdmin.WorkflowStatus', 'Current action'));
     }
     // Pending/Submitted items GridField Config
     $config = new GridFieldConfig_Base();
     $config->addComponent(new GridFieldEditButton());
     $config->addComponent(new GridFieldDetailForm());
     $config->getComponentByType('GridFieldPaginator')->setItemsPerPage(5);
     $columns = $config->getComponentByType('GridFieldDataColumns');
     $columns->setFieldFormatting($this->setFieldFormatting($config));
     if ($pending->count()) {
         $formFieldTop = GridField::create($fieldName, $this->isAdminUser(Member::currentUser()) ? _t('AdvancedWorkflowAdmin.GridFieldTitleAssignedAll', 'All pending items') : _t('AdvancedWorkflowAdmin.GridFieldTitleAssignedYour', 'Your pending items'), $pending, $config);
         $dataColumns = $formFieldTop->getConfig()->getComponentByType('GridFieldDataColumns');
         $dataColumns->setDisplayFields($displayFields);
         $formFieldTop->setForm($form);
         $form->Fields()->insertBefore($formFieldTop, 'WorkflowDefinition');
     }
     // Show items submitted into a workflow by current user
     $fieldName = 'SubmittedObjects';
     $submitted = $this->userObjects(Member::currentUser(), $fieldName);
     if ($submitted->count()) {
         $formFieldBottom = GridField::create($fieldName, $this->isAdminUser(Member::currentUser()) ? _t('AdvancedWorkflowAdmin.GridFieldTitleSubmittedAll', 'All submitted items') : _t('AdvancedWorkflowAdmin.GridFieldTitleSubmittedYour', 'Your submitted items'), $submitted, $config);
         $dataColumns = $formFieldBottom->getConfig()->getComponentByType('GridFieldDataColumns');
         $dataColumns->setDisplayFields($displayFields);
         $formFieldBottom->setForm($form);
         $formFieldBottom->getConfig()->removeComponentsByType('GridFieldEditButton');
         $formFieldBottom->getConfig()->addComponent(new GridFieldWorkflowRestrictedEditButton());
         $form->Fields()->insertBefore($formFieldBottom, 'WorkflowDefinition');
     }
     $grid = $form->Fields()->dataFieldByName('WorkflowDefinition');
     if ($grid) {
         $grid->getConfig()->getComponentByType('GridFieldDetailForm')->setItemEditFormCallback(function ($form) {
             $record = $form->getRecord();
             if ($record) {
                 $record->updateAdminActions($form->Actions());
             }
         });
         $grid->getConfig()->getComponentByType('GridFieldDetailForm')->setItemRequestClass('WorkflowDefinitionItemRequestClass');
         $grid->getConfig()->addComponent(new GridFieldExportAction());
         $grid->getConfig()->removeComponentsByType('GridFieldExportButton');
     }
     return $form;
 }
 public function getEditForm($id = null, $fields = null)
 {
     $form = parent::getEditForm($id, $fields);
     /**
      * In the instance that the editing results in the UserAgreement switching between GridField's, we need to
      * load all agreements into both GridFields to permit the Save action to succeed.
      * (ie. the archive boolean is toggled)
      * Use the EditForm action to detect when editing vs viewing
      */
     $action = $this->request->param('Action');
     if ($action && $action == 'EditForm') {
         $archived = UserAgreement::get();
         $liveAgreements = $archived;
     } else {
         $archived = UserAgreement::get()->filter('Archived', true);
         $liveAgreements = UserAgreement::get()->filter('Archived', false);
     }
     // Show Archived agreements separate to current agreements
     $fieldName = 'ArchivedAgreements';
     // Archived Agreements GridField Config
     $config = new GridFieldConfig_Base();
     $config->addComponent(new GridFieldEditButton());
     $config->addComponent(new GridFieldDetailForm());
     $config->addComponent(new GridFieldDeleteAction());
     $config->addComponent(new GridFieldExportButton());
     $config->addComponent(new GridFieldPrintButton());
     $config->getComponentByType('GridFieldPaginator')->setItemsPerPage(5);
     if ($archived->count()) {
         $formFieldArchive = GridField::create($fieldName, _t('UserAgreements.ArchivedAgreements', 'Archived Agreements'), $archived, $config);
         $formFieldArchive->setForm($form);
         $form->Fields()->insertAfter($formFieldArchive, 'UserAgreement');
     }
     // Omit Archived Agreements from main gridfield
     $grid = $form->Fields()->dataFieldByName('UserAgreement');
     if ($grid) {
         $grid->setList($liveAgreements);
         $grid->setTitle(_t('UserAgreements.CurrentAgreements', 'Current Agreements'));
     }
     return $form;
 }
 /**
  * @param {int} $itemsPerPage How many items per page should show up
  */
 public function __construct($itemsPerPage = null)
 {
     parent::__construct($itemsPerPage);
     $this->removeComponentsByType('GridFieldDetailForm')->addComponent(new FrontEndGridFieldDetailForm());
 }
Ejemplo n.º 13
0
 public function updateFields(FieldList $fields)
 {
     if (!$this->owner->ID) {
         return $fields;
     }
     $tab = $fields->fieldByName('Root') ? $fields->findOrMakeTab('Root.Workflow') : $fields;
     if (Permission::check('APPLY_WORKFLOW')) {
         $definition = new DropdownField('WorkflowDefinitionID', _t('WorkflowApplicable.DEFINITION', 'Applied Workflow'));
         $definitions = $this->workflowService->getDefinitions()->map()->toArray();
         $definition->setSource($definitions);
         $definition->setEmptyString(_t('WorkflowApplicable.INHERIT', 'Inherit from parent'));
         $tab->push($definition);
         // Allow an optional selection of additional workflow definitions.
         if ($this->owner->WorkflowDefinitionID) {
             $fields->removeByName('AdditionalWorkflowDefinitions');
             unset($definitions[$this->owner->WorkflowDefinitionID]);
             $tab->push($additional = ListboxField::create('AdditionalWorkflowDefinitions', _t('WorkflowApplicable.ADDITIONAL_WORKFLOW_DEFINITIONS', 'Additional Workflows')));
             $additional->setSource($definitions);
             $additional->setMultiple(true);
         }
     }
     // Display the effective workflow definition.
     if ($effective = $this->getWorkflowInstance()) {
         $title = $effective->Definition()->Title;
         $tab->push(ReadonlyField::create('EffectiveWorkflow', _t('WorkflowApplicable.EFFECTIVE_WORKFLOW', 'Effective Workflow'), $title));
     }
     if ($this->owner->ID) {
         $config = new GridFieldConfig_Base();
         $config->addComponent(new GridFieldEditButton());
         $config->addComponent(new GridFieldDetailForm());
         $insts = $this->owner->WorkflowInstances();
         $log = new GridField('WorkflowLog', _t('WorkflowApplicable.WORKFLOWLOG', 'Workflow Log'), $insts, $config);
         $tab->push($log);
     }
 }
Ejemplo n.º 14
0
 /**
  */
 public function getCMSFields()
 {
     $cmsUsers = Member::mapInCMSGroups();
     $fields = new FieldList(new TabSet('Root'));
     $fields->addFieldToTab('Root.Main', new TextField('Title', _t('WorkflowDefinition.TITLE', 'Title')));
     $fields->addFieldToTab('Root.Main', new TextareaField('Description', _t('WorkflowDefinition.DESCRIPTION', 'Description')));
     if ($this->ID) {
         $fields->addFieldToTab('Root.Main', new CheckboxSetField('Users', _t('WorkflowDefinition.USERS', 'Users'), $cmsUsers));
         $fields->addFieldToTab('Root.Main', new TreeMultiselectField('Groups', _t('WorkflowDefinition.GROUPS', 'Groups'), 'Group'));
     }
     if (class_exists('AbstractQueuedJob')) {
         $before = _t('WorkflowDefinition.SENDREMINDERDAYSBEFORE', 'Send reminder email after ');
         $after = _t('WorkflowDefinition.SENDREMINDERDAYSAFTER', ' days without action.');
         $fields->addFieldToTab('Root.Main', new FieldGroup(_t('WorkflowDefinition.REMINDEREMAIL', 'Reminder Email'), new LabelField('ReminderEmailBefore', $before), new NumericField('RemindDays', ''), new LabelField('ReminderEmailAfter', $after)));
     }
     if ($this->ID) {
         if ($this->Template) {
             $template = $this->workflowService->getNamedTemplate($this->Template);
             $fields->addFieldToTab('Root.Main', new ReadonlyField('Template', _t('WorkflowDefinition.TEMPLATE_NAME', 'Source Template'), $this->Template));
             $fields->addFieldToTab('Root.Main', new ReadonlyField('TemplateDesc', _t('WorkflowDefinition.TEMPLATE_INFO', 'Template Info'), $template ? $template->getDescription() : ''));
             $fields->addFieldToTab('Root.Main', $tv = new ReadonlyField('TemplateVersion', _t('WorkflowDefinition:TEMPLATE_VERSION', 'Template Version')));
             $tv->setRightTitle(sprintf(_t('WorkflowDefinition.LATEST_VERSION', 'Latest version is %s'), $template->getVersion()));
         }
         $fields->addFieldToTab('Root.Main', new WorkflowField('Workflow', _t('WorkflowDefinition.WORKFLOW', 'Workflow'), $this));
     } else {
         // add in the 'template' info
         $templates = $this->workflowService->getTemplates();
         if (is_array($templates)) {
             $items = array('' => '');
             foreach ($templates as $template) {
                 $items[$template->getName()] = $template->getName();
             }
             $templates = array_combine(array_keys($templates), array_keys($templates));
             $fields->addFieldToTab('Root.Main', $dd = new DropdownField('Template', _t('WorkflowDefinition.CHOOSE_TEMPLATE', 'Choose template (optional)'), $items));
             $dd->setRightTitle('If set, this workflow definition will be automatically updated if the template is changed');
         }
         $message = _t('WorkflowDefinition.ADDAFTERSAVING', 'You can add workflow steps after you save for the first time.');
         $fields->addFieldToTab('Root.Main', new LiteralField('AddAfterSaving', "<p class='message notice'>{$message}</p>"));
     }
     if ($this->ID && Permission::check('VIEW_ACTIVE_WORKFLOWS')) {
         $active = $this->Instances()->filter(array('WorkflowStatus' => array('Active', 'Paused')));
         $active = new GridField('Active', 'Active Workflow Instances', $active, new GridFieldConfig_RecordEditor());
         $active->getConfig()->removeComponentsByType('GridFieldAddNewButton');
         $active->getConfig()->removeComponentsByType('GridFieldDeleteAction');
         if (!Permission::check('REASSIGN_ACTIVE_WORKFLOWS')) {
             $active->getConfig()->removeComponentsByType('GridFieldEditButton');
             $active->getConfig()->addComponent(new GridFieldViewButton());
             $active->getConfig()->addComponent(new GridFieldDetailForm());
         }
         $completed = $this->Instances()->filter(array('WorkflowStatus' => array('Complete', 'Cancelled')));
         $config = new GridFieldConfig_Base();
         $config->addComponent(new GridFieldEditButton());
         $config->addComponent(new GridFieldDetailForm());
         $completed = new GridField('Completed', 'Completed Workflow Instances', $completed, $config);
         $fields->addFieldToTab('Root.Active', $active);
         $fields->addFieldToTab('Root.Completed', $completed);
     }
     return $fields;
 }