public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName("Title");
     $fields->removeByName("Note");
     $fields->addFieldToTab('Root.Main', new CheckboxField("PaymentConfirmed", _t("OrderStatusLog.CONFIRMED", "Payment is confirmed")));
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->removeByName("Title");
     $fields->removeByName("Note");
     $fields->removeByName("InternalUseOnly");
     $fields->removeByName("EmailSent");
     $fields->addFieldToTab('Root.Main', new CheckboxField("AvailabilityChecked", _t("OrderStatusLog.CHECKED", "Availability is confirmed (we can proceed with this order)")));
     return $fields;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab("Root.Main", new LiteralField("FilesInFolder", _t("OrderStep.ACTUALFilesInFolder", "Actual files in folder: ") . implode(", ", $this->getFilesInFolder())));
     return $fields;
 }
 public function getCMSFields()
 {
     $this->beforeExtending('updateCMSFields', function ($fields) {
         $fields->removeByName('Automated');
         $fields->removeByName('AuthorID');
         $fields->removeByName('OrderID');
         $fields->removeByName('Changes');
         $fields->removeByName('FirstRead');
         // Disables the default firing of sent to customer flag
         $fields->removeByName('SentToCustomer');
         // Status Field
         $allSuggestedStatuses = (array) $this->config()->status_list;
         $statusesWithIcons = $otherStatuses = [];
         // Check if readonly
         $editable = $this->canEdit();
         $simplified = !Permission::check('ADMIN') && $this->Automated && !in_array($this->Status, static::$DETAILED_STATUS);
         $dataFields = $fields->dataFields();
         if ($editable) {
             $fields->removeByName('Status');
             foreach ($allSuggestedStatuses as $status => $options) {
                 if (is_array($options) && !empty($options['icon'])) {
                     $statusesWithIcons[$status] = isset($options['title']) ? $options['icon'] . ' ' . $options['title'] : $options['icon'] . ' ' . $status;
                 } else {
                     if (is_array($options) && !empty($options['title'])) {
                         $otherStatuses[$status] = $options['title'];
                     } else {
                         $otherStatuses[$status] = $options;
                     }
                 }
             }
             $otherStatuses = array_merge($otherStatuses, $this->get()->exclude('Status', array_merge(array_keys($allSuggestedStatuses)))->sort('Status', 'ASC')->map('Status', 'Status')->toArray());
             $statuses = ['Common Statuses' => $statusesWithIcons];
             if (!empty($otherStatuses)) {
                 asort($otherStatuses);
                 $statuses['Other Status'] = $otherStatuses;
                 foreach ($statuses['Other Status'] as $status => $title) {
                     $statuses['Other Status'][$status] = FormField::name_to_label($title);
                 }
             }
             $fields->insertBefore($statusField = Select2Field::create('Status', 'Status', '', $statuses)->setMinimumSearchLength(0)->setEmptyString('You can select from suggested statuses, or create a new status')->setAttribute('data-format-searching', _t('OrderLog.SEARCHING-Status', 'Loading statuses...')), 'Title');
             $statusField->requireSelection = false;
             if (!Permission::check('ADMIN')) {
                 $statusField->disabledOptions = $this->config()->disallowed_multiple_statuses;
             }
             if ($this->exists() && !Permission::check('ADMIN') && ($this->Automated || $this->AuthorID != Member::currentUserID())) {
                 $statusField->setAttribute('disabled', 'disabled');
             } elseif ($editable) {
                 $statusField->setDescription(_t('OrderLog.DESC-Status', 'Note: {updated} is a special status. If there are more than {limit} logs for an order, it will automatically delete statuses classed as {updated}, so use with caution.', ['updated' => implode(', ', (array) static::$GENERIC_STATUS), 'limit' => $this->config()->max_records_per_order]));
             }
             $statusField->allowHTML = true;
             $statusField->prefetch = true;
         } elseif (isset($dataFields['Status'])) {
             $fields->removeByName('Status');
             $fields->insertBefore('Title', $dataFields['Status']);
         }
         if (isset($dataFields['Title']) && $editable) {
             $dataFields['Title']->setDescription(_t('OrderLog.DESC-Title', 'If not set, will automatically use the Status above'));
         } elseif (!$editable && $this->Title == $this->Status) {
             $fields->removeByName('Title');
         }
         $lastField = 'Title';
         if (!$editable && !$this->Note) {
             $fields->removeByName('Note');
         } elseif ($editable && isset($dataFields['Note']) && $dataFields['Note'] instanceof TextareaField) {
             $dataFields['Note']->setRows(2);
             $lastField = 'Note';
         } else {
             $lastField = 'Note';
         }
         $fieldSet = [];
         foreach (['Public', 'Unread'] as $field) {
             if (isset($dataFields[$field])) {
                 $fieldSet[$field] = $dataFields[$field];
                 $fields->removeByName($field);
             }
         }
         if (!empty($fieldSet)) {
             if (isset($fieldSet['Public'])) {
                 $fieldSet['Public']->setTitle($fieldSet['Public']->Title() . ' (' . _t('OrderLog.DESC-Public', 'If checked, user can view this log on the front-end when checking the status of their orders') . ')');
             }
             if ($this->FirstRead) {
                 $fieldSet['FirstRead'] = DatetimeField::create('FirstRead');
             }
             $fields->insertAfter(FieldGroup::create($fieldSet)->setTitle('Public Visibility')->setName('PublicFields')->addExtraClass('hero-unit stacked-items'), $lastField);
             $fieldSet = [];
             $lastField = 'PublicFields';
         }
         foreach (['DispatchTicket', 'DispatchedBy', 'DispatchedOn'] as $field) {
             if (($simplified || !$editable) && !$this->{$field}) {
                 $fields->removeByName($field);
                 continue;
             }
             if (isset($dataFields[$field])) {
                 $fieldSet[$field] = $dataFields[$field];
                 $fields->removeByName($field);
                 if ($fieldSet[$field] instanceof DateField) {
                     $fieldSet[$field]->setConfig('showcalendar', true);
                 }
                 if ($field == 'DispatchTicket') {
                     $fieldSet[$field]->setTitle(_t('OrderLog.TRACKING_ID', 'Tracking ID'));
                 } elseif ($field == 'DispatchedBy') {
                     $fieldSet[$field]->setTitle(_t('OrderLog.VIA', 'via'));
                 } elseif ($field == 'DispatchedOn') {
                     $fieldSet[$field]->setTitle(_t('OrderLog.ON', 'on'));
                 }
             }
         }
         if (!empty($fieldSet)) {
             $fields->removeByName('DispatchUri');
             $fields->insertAfter($dispatched = CompositeField::create(FieldGroup::create($fieldSet)->setTitle('Dispatched')->setName('DispatchedDetails'))->setName('Dispatched')->addExtraClass('hero-unit'), $lastField);
             if ($editable || $this->DispatchUri) {
                 $dispatched->push(TextField::create('DispatchUri', _t('OrderLog.DispatchUri', 'Tracking URL'))->setDescription(_t('OrderLog.DESC-DispatchUri', 'If none provided, will attempt to use the URL of the carrier')));
             }
             $fieldSet = [];
             $lastField = 'Dispatched';
         } elseif (($simplified || !$editable) && !$this->DispatchUri) {
             $fields->removeByName('DispatchUri');
         }
         foreach (['PaymentCode', 'PaymentOK'] as $field) {
             if (($simplified || !$editable) && !$this->{$field}) {
                 $fields->removeByName($field);
                 continue;
             }
             if (isset($dataFields[$field])) {
                 $fieldSet[$field] = $dataFields[$field];
                 $fields->removeByName($field);
                 if ($field == 'PaymentCode') {
                     $fieldSet[$field]->setTitle(_t('OrderLog.CODE', 'Code'));
                 }
             }
         }
         if (!empty($fieldSet)) {
             $fields->insertAfter(FieldGroup::create($fieldSet)->setTitle('Payment')->setName('Payment')->addExtraClass('hero-unit'), $lastField);
             $fieldSet = [];
         }
         // Email Fields
         $fields->removeByName('Send_To');
         $fields->removeByName('Send_Subject');
         $fields->removeByName('Send_Body');
         $fields->removeByName('Send_From');
         $fields->removeByName('Send_HideOrder');
         $fields->removeByName('Send');
         $fields->removeByName('Sent');
         if (($simplified || !$editable) && !$this->Sent) {
             return;
         }
         $fields->addFieldsToTab('Root', [Tab::create('Email', _t('OrderLog.EMAIL', 'Email'))]);
         $emailFields = ['Send_To' => TextField::create('Send_To', _t('OrderLog.Send_To', 'Send to')), 'Send_From' => TextField::create('Send_From', _t('OrderLog.Send_From', 'From')), 'Send_Subject' => TextField::create('Send_Subject', _t('OrderLog.Send_Subject', 'Subject'))->setAttribute('placeholder', _t('Order.RECEIPT_SUBJECT', 'Web Order - {reference}', ['reference' => $this->Order()->Reference])), 'Send_HideOrder' => CheckboxField::create('Send_HideOrder', _t('OrderLog.Send_HideOrder', 'Hide order from email')), 'Send_Body' => HTMLEditorField::create('Send_Body', _t('OrderLog.Send_Body', 'Body'))->setRows(2)->addExtraClass('limited limited-with-source limited-with-links')->setDescription(_t('OrderLog.DESC-Send_Body', 'If no body is provided, will use the log notes (as seen below)')), 'EmailPreview' => DataObjectPreviewField::create(get_class($this) . '_EmailPreview', new Preview($this), new DataObjectPreviewer(new Preview($this)))];
         if ($this->Sent || !$editable) {
             $readOnlyEmailFields = [];
             unset($emailFields['Send_HideOrder']);
             foreach ($emailFields as $emailField) {
                 if ($emailField->Name != 'Send_Body' && !$emailField instanceof DataObjectPreviewField) {
                     $readOnlyEmailFields[] = $emailField->performReadonlyTransformation();
                 } elseif ($emailField instanceof DataObjectPreviewField) {
                     $readOnlyEmailFields[] = $emailField;
                 }
             }
             unset($emailFields);
             $fields->addFieldsToTab('Root.Email', array_merge([ReadonlyField::create('READONLY_Sent', _t('OrderLog.Sent', 'Sent'), $this->obj('Sent')->Nice())], $readOnlyEmailFields));
         } else {
             $fields->addFieldsToTab('Root.Email', [$selectionGroup = TabbedSelectionGroup::create('Send', [SelectionGroup_Item::create(0, CompositeField::create(), _t('OrderLog.Send-NO', 'No')), SelectionGroup_Item::create(1, CompositeField::create($emailFields), _t('OrderLog.Send-YES', 'Yes'))])->addExtraClass('selectionGroup--minor')->showAsDropdown(true)->setTitle(_t('OrderLog.Send', 'Send as an email?'))]);
         }
     });
     return parent::getCMSFields();
 }
 /**
  *
  *@return FieldSet
  **/
 function getCMSFields()
 {
     $fields = parent::getCMSFields();
     return $fields;
 }