public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
     Requirements::javascript('eventmanagement/javascript/event-ticket-cms.js');
     $fields->removeByName('EventID');
     $fields->removeByName('StartType');
     $fields->removeByName('StartDate');
     $fields->removeByName('StartDays');
     $fields->removeByName('StartHours');
     $fields->removeByName('StartMins');
     $fields->removeByName('EndType');
     $fields->removeByName('EndDate');
     $fields->removeByName('EndDays');
     $fields->removeByName('EndHours');
     $fields->removeByName('EndMins');
     if (class_exists('Payment')) {
         $fields->insertBefore(new OptionSetField('Type', 'Ticket type', array('Free' => 'Free ticket', 'Price' => 'Fixed price ticket')), 'Price');
     } else {
         $fields->removeByName('Type');
         $fields->removeByName('Price');
     }
     foreach (array('Start', 'End') as $type) {
         $fields->addFieldsToTab('Root.Main', array(new OptionSetField("{$type}Type", "{$type} sales at", array('Date' => 'A specific date and time', 'TimeBefore' => 'A time before the event starts')), $dateTime = new DatetimeField("{$type}Date", ''), $before = new FieldGroup("{$type}Offset", new NumericField("{$type}Days", 'Days'), new NumericField("{$type}Hours", 'Hours'), new NumericField("{$type}Mins", 'Minutes'))));
         $before->setName("{$type}Offset");
         $before->setTitle(' ');
         $dateTime->getDateField()->setConfig('showcalendar', true);
         $dateTime->getTimeField()->setConfig('showdropdown', true);
     }
     $fields->addFieldsToTab('Root.Advanced', array(new TextareaField('Description', 'Description'), new NumericField('MinTickets', 'Minimum tickets per order'), new NumericField('MaxTickets', 'Maximum tickets per order')));
     return $fields;
 }
 public function getSettingsFields()
 {
     $dataTypes = $this->getAvailableTypes();
     $reportable = $this->getReportableFields();
     $converted = array();
     foreach ($reportable as $k => $v) {
         $converted[$this->dottedFieldToUnique($k)] = $v;
     }
     $dataTypes = array_merge(array('' => ''), $dataTypes);
     $types = new MultiValueDropdownField('DataTypes', _t('AdvancedReport.DATA_TYPES', 'Data types'), $dataTypes);
     $fieldsGroup = new FieldGroup('Fields', $reportFieldsSelect = new MultiValueDropdownField('ReportFields', _t('AdvancedReport.REPORT_FIELDS', 'Report Fields'), $reportable));
     $fieldsGroup->push(new MultiValueTextField('ReportHeaders', _t('AdvancedReport.HEADERS', 'Header labels')));
     $fieldsGroup->addExtraClass('reportMultiField');
     $reportFieldsSelect->addExtraClass('reportFieldsSelection');
     $fieldsGroup->setName('FieldsGroup');
     $fieldsGroup->addExtraClass('advanced-report-fields dropdown');
     $conditions = new FieldGroup('Conditions', new MultiValueDropdownField('ConditionFields', _t('AdvancedReport.CONDITION_FIELDS', 'Condition Fields'), $reportable), new MultiValueDropdownField('ConditionOps', _t('AdvancedReport.CONDITION_OPERATIONS', 'Op'), $this->config()->allowed_conditions), new MultiValueTextField('ConditionValues', _t('AdvancedReport.CONDITION_VALUES', 'Value')));
     $conditions->setName('ConditionsGroup');
     $conditions->addExtraClass('dropdown');
     // define the group for the sort field
     $sortGroup = new FieldGroup('Sort', new MultiValueDropdownField('SortBy', _t('AdvancedReport.SORTED_BY', 'Sorted By'), $reportable), new MultiValueDropdownField('SortDir', _t('AdvancedReport.SORT_DIRECTION', 'Sort Direction'), array('ASC' => _t('AdvancedReport.ASC', 'Ascending'), 'DESC' => _t('AdvancedReport.DESC', 'Descending'))));
     $sortGroup->setName('SortGroup');
     $sortGroup->addExtraClass('dropdown');
     // build a list of the formatters
     $formatters = ClassInfo::implementorsOf('ReportFieldFormatter');
     $fmtrs = array();
     foreach ($formatters as $formatterClass) {
         $formatter = new $formatterClass();
         $fmtrs[$formatterClass] = $formatter->label();
     }
     // define the group for the custom field formatters
     $fieldFormattingGroup = new FieldGroup(_t('AdvancedReport.FORMAT_FIELDS', 'Custom field formatting'), new MultiValueDropdownField('FieldFormattingField', _t('AdvancedReport.FIELDFORMATTING', 'Field'), $converted), new MultiValueDropdownField('FieldFormattingFormatter', _t('AdvancedReport.FIELDFORMATTINGFORMATTER', 'Formatter'), $fmtrs));
     $fieldFormattingGroup->setName('FieldFormattingGroup');
     $fieldFormattingGroup->addExtraClass('dropdown');
     // assemble the fieldlist
     $fields = new FieldList(new TextField('Title', _t('AdvancedReport.TITLE', 'Title')), new TextareaField('Description', _t('AdvancedReport.DESCRIPTION', 'Description')), $types, $fieldsGroup, $conditions, new KeyValueField('ReportParams', _t('AdvancedReport.REPORT_PARAMETERS', 'Default report parameters')), $sortGroup, new MultiValueDropdownField('NumericSort', _t('AdvancedReport.SORT_NUMERICALLY', 'Sort these fields numerically'), $reportable), DropdownField::create('PaginateBy')->setTitle(_t('AdvancedReport.PAGINATE_BY', 'Paginate By'))->setSource($reportable)->setHasEmptyDefault(true), TextField::create('PageHeader')->setTitle(_t('AdvancedReport.HEADER_TEXT', 'Header text'))->setDescription(_t('AdvancedReport.USE_NAME_FOR_PAGE_NAME', 'use $name for the page name'))->setValue('$name'), new MultiValueDropdownField('AddInRows', _t('AdvancedReport.ADD_IN_ROWS', 'Add these columns for each row'), $converted), new MultiValueDropdownField('AddCols', _t('AdvancedReport.ADD_IN_ROWS', 'Provide totals for these columns'), $converted), $fieldFormattingGroup, new MultiValueDropdownField('ClearColumns', _t('AdvancedReport.CLEARED_COLS', '"Cleared" columns'), $converted));
     if ($this->config()->allow_grouping) {
         // GroupBy
         $groupingGroup = new FieldGroup('Grouping', new MultiValueDropdownField('GroupBy', _t('AdvancedReport.GROUPBY_FIELDS', 'Group by fields'), $reportable), new MultiValueDropdownField('SumFields', _t('AdvancedReport.SUM_FIELDS', 'SUM fields'), $reportable));
         $groupingGroup->addExtraClass('dropdown');
         $fields->insertAfter($groupingGroup, 'ConditionsGroup');
     }
     if ($this->hasMethod('updateReportFields')) {
         Deprecation::notice('3.0', 'The updateReportFields method is deprecated, instead overload getSettingsFields');
         $this->updateReportFields($fields);
     }
     $this->extend('updateSettingsFields', $fields);
     return $fields;
 }
 /**
  * @return FieldList
  */
 protected function getFieldsForFile($relationListCount)
 {
     $extension = $this->getExtension();
     $previewField = new LiteralField("ImageFull", "<img id='thumbnailImage' class='thumbnail-preview' src='{$this->Icon($extension)}?r=" . rand(1, 100000) . "' alt='{$this->Title}' />\n");
     //count the number of pages this document is published on
     $publishedOnCount = $this->Pages()->Count();
     $publishedOnValue = "{$publishedOnCount} pages";
     if ($publishedOnCount == 1) {
         $publishedOnValue = "{$publishedOnCount} page";
     }
     $relationListCountValue = "{$relationListCount} pages";
     if ($relationListCount == 1) {
         $relationListCountValue = "{$relationListCount} page";
     }
     $fields = new FieldGroup($filePreview = CompositeField::create(CompositeField::create($previewField)->setName("FilePreviewImage")->addExtraClass('cms-file-info-preview'), CompositeField::create(CompositeField::create(new ReadonlyField("ID", "ID number" . ':', $this->ID), new ReadonlyField("FileType", _t('AssetTableField.TYPE', 'File type') . ':', self::get_file_type($extension)), new ReadonlyField("Size", _t('AssetTableField.SIZE', 'File size') . ':', $this->getFileSizeFormatted()), $urlField = new ReadonlyField('ClickableURL', _t('AssetTableField.URL', 'URL'), sprintf('<a href="%s" target="_blank" class="file-url">%s</a>', $this->getLink(), $this->getLink())), new ReadonlyField("FilenameWithoutIDField", "Filename" . ':', $this->getFilenameWithoutID()), new DateField_Disabled("Created", _t('AssetTableField.CREATED', 'First uploaded') . ':', $this->Created), new DateField_Disabled("LastEdited", _t('AssetTableField.LASTEDIT', 'Last changed') . ':', $this->LastEdited), new DateField_Disabled("LastChanged", _t('AssetTableField.LASTCHANGED', 'Last replaced') . ':', $this->LastChanged), new ReadonlyField("PublishedOn", "Published on" . ':', $publishedOnValue), new ReadonlyField("ReferencedOn", "Referenced on" . ':', $relationListCountValue)))->setName("FilePreviewData")->addExtraClass('cms-file-info-data'))->setName("FilePreview")->addExtraClass('cms-file-info'));
     $fields->setName('FileP');
     $urlField->dontEscape = true;
     return $fields;
 }
 public function setName($name)
 {
     parent::setName($name);
     foreach ($this->getChildren() as $child) {
         /** @var FormField $child */
         $thisName = $child->getName();
         $thisName = preg_replace('/^.*(\\[\\w+\\])$/', $name . '\\1', $thisName);
         $child->setName($thisName);
     }
 }
 /**
  * Create form fields to represent all of the properties on the {@link Omnipay\Common\CreditCard} object.
  * The form fields are split up into relevent sections to help with adding/removing fields as needed.
  *
  * @return FieldList
  */
 protected function getCreditCardFields()
 {
     $fields = new FieldList();
     $tabindex = 1;
     // Create personal detail fields
     $firstNameTextField = new TextField('FirstName', _t('OmnipayableForm.FIRSTNAME', 'First name'));
     $firstNameTextField->setAttribute('tabindex', $tabindex++);
     $lastNameTextField = new TextField('LastName', _t('OmnipayableForm.LASTNAME', 'Last name'));
     $lastNameTextField->setAttribute('tabindex', $tabindex++);
     $companyTextField = new TextField('Company', _t('OmnipayableForm.COMPANY', 'Company'));
     $companyTextField->setAttribute('tabindex', $tabindex++);
     $emailEmailField = new EmailField('Email', _t('OmnipayableForm.EMAIL', 'Email'));
     $emailEmailField->setAttribute('tabindex', $tabindex++);
     // Create personal details group
     $personalFieldGroup = new FieldGroup();
     $personalFieldGroup->setName('PersonalDetails');
     $personalFieldGroup->setTitle(_t('OmnipayableForm.PERSONALDETAILS', 'Personal Detials'));
     // Add basic fields to personal details group
     $personalFieldGroup->push($firstNameTextField);
     $personalFieldGroup->push($lastNameTextField);
     $personalFieldGroup->push($companyTextField);
     $personalFieldGroup->push($emailEmailField);
     // Add personal details group to fields
     $fields->push($personalFieldGroup);
     // Create credit card detail fields
     $numberCreditCardField = new CreditCardField('Number', _t('OmnipayableForm.NUMBER', 'Card number'));
     $numberCreditCardField->setAttribute('tabindex', $tabindex++);
     $cvvTextField = new TextField('Cvv', _t('OmnipayableForm.CVV', 'Security number'));
     $cvvTextField->setAttribute('tabindex', $tabindex += 3);
     $expiryMonthDropdownField = new DropdownField('ExpiryMonth', _t('OmnipayableForm.EXPIRYMONTH', 'Expiry month'), $this->getMonths());
     $expiryMonthDropdownField->setAttribute('tabindex', $tabindex++);
     $expiryMonthDropdownField->setHasEmptyDefault(true);
     $expiryYearDropdownField = new DropdownField('ExpiryYear', _t('OmnipayableForm.EXPIRYYEAR', 'Expiry year'), $this->getYears(20));
     $expiryYearDropdownField->setAttribute('tabindex', $tabindex++);
     $expiryYearDropdownField->setHasEmptyDefault(true);
     $startMonthDropdownField = new DropdownField('StartMonth', _t('OmnipayableForm.STARTMONTH', 'Start month'), $this->getMonths());
     $startMonthDropdownField->setAttribute('tabindex', $tabindex++);
     $startMonthDropdownField->setHasEmptyDefault(true);
     $startYearDropdownField = new DropdownField('StartYear', _t('OmnipayableForm.STARTYEAR', 'Start year'), $this->getYears(-20));
     $startYearDropdownField->setAttribute('tabindex', $tabindex++);
     $startYearDropdownField->setHasEmptyDefault(true);
     $issueNumberTextField = new TextField('IssueNumber', _t('OmnipayableForm.ISSUENUMBER', 'Issue number'));
     $issueNumberTextField->setAttribute('tabindex', $tabindex++);
     $typeDropdownField = new DropdownField('Type', _t('OmnipayableForm.TYPE', 'Card type'), $this->getCreditCardTypes());
     $typeDropdownField->setAttribute('tabindex', $tabindex++);
     $typeDropdownField->setHasEmptyDefault(true);
     $expiryDateFieldGroup = new FieldGroup();
     $expiryDateFieldGroup->push($expiryMonthDropdownField);
     $expiryDateFieldGroup->push($expiryYearDropdownField);
     $startDateFieldGroup = new FieldGroup();
     $startDateFieldGroup->push($startMonthDropdownField);
     $startDateFieldGroup->push($startYearDropdownField);
     // Create credit card details group
     $creditCardFieldGroup = new FieldGroup();
     $creditCardFieldGroup->setName('CardDetails');
     $creditCardFieldGroup->setTitle(_t('OmnipayableForm.CREDITCARDDETAILS', 'Card Detials'));
     // Add credit card fields to credit card details group
     $creditCardFieldGroup->push($numberCreditCardField);
     $creditCardFieldGroup->push($cvvTextField);
     $creditCardFieldGroup->push($expiryDateFieldGroup);
     $creditCardFieldGroup->push($startDateFieldGroup);
     $creditCardFieldGroup->push($issueNumberTextField);
     $creditCardFieldGroup->push($typeDropdownField);
     // Add credit card details group to fields
     $fields->push($creditCardFieldGroup);
     // Create billing address fields
     $billingAddress1TextField = new TextField('BillingAddress1', _t('OmnipayableForm.BILLINGADDRESS1', 'Address 1'));
     $billingAddress1TextField->setAttribute('tabindex', $tabindex++);
     $billingAddress2TextField = new TextField('BillingAddress2', _t('OmnipayableForm.BILLINGADDRESS2', 'Address 2'));
     $billingAddress2TextField->setAttribute('tabindex', $tabindex++);
     $billingCity = new TextField('BillingCity', _t('OmnipayableForm.BILLINGCITY', 'City'));
     $billingCity->setAttribute('tabindex', $tabindex++);
     $billingPostcode = new TextField('BillingPostcode', _t('OmnipayableForm.BILLINGPOSTCODE', 'Postcode'));
     $billingPostcode->setAttribute('tabindex', $tabindex++);
     $billingState = new TextField('BillingState', _t('OmnipayableForm.BILLINGSTATE', 'State'));
     $billingState->setAttribute('tabindex', $tabindex++);
     $billingCountry = new CountryDropdownField('BillingCountry', _t('OmnipayableForm.BILLINGCOUNTRY', 'Country'));
     $billingCountry->setAttribute('tabindex', $tabindex++);
     $billingPhone = new PhoneNumberField('BillingPhone', _t('OmnipayableForm.BILLINGPHONE', 'Phone'));
     $billingPhone->setAttribute('tabindex', $tabindex++);
     // Create billing details group
     $billingFieldGroup = new FieldGroup();
     $billingFieldGroup->setName('BillingAddress');
     $billingFieldGroup->setTitle(_t('OmnipayableForm.BILLING', 'Billing Address'));
     // Add billiing fields to billing group
     $billingFieldGroup->push($billingAddress1TextField);
     $billingFieldGroup->push($billingAddress2TextField);
     $billingFieldGroup->push($billingCity);
     $billingFieldGroup->push($billingPostcode);
     $billingFieldGroup->push($billingState);
     $billingFieldGroup->push($billingCountry);
     $billingFieldGroup->push($billingPhone);
     // Add billing details group to fields
     $fields->push($billingFieldGroup);
     // Create shipping address fields
     $shippingAddress1TextField = new TextField('ShippingAddress1', _t('OmnipayableForm.SHIPPINGADDRESS1', 'Address 1'));
     $shippingAddress1TextField->setAttribute('tabindex', $tabindex++);
     $shippingAddress2TextField = new TextField('ShippingAddress2', _t('OmnipayableForm.SHIPPINGADDRESS2', 'Address 2'));
     $shippingAddress2TextField->setAttribute('tabindex', $tabindex++);
     $shippingCity = new TextField('ShippingCity', _t('OmnipayableForm.SHIPPINGCITY', 'City'));
     $shippingCity->setAttribute('tabindex', $tabindex++);
     $shippingPostcode = new TextField('ShippingPostcode', _t('OmnipayableForm.SHIPPINGPOSTCODE', 'Postcode'));
     $shippingPostcode->setAttribute('tabindex', $tabindex++);
     $shippingState = new TextField('ShippingState', _t('OmnipayableForm.SHIPPINGSTATE', 'State'));
     $shippingState->setAttribute('tabindex', $tabindex++);
     $shippingCountry = new CountryDropdownField('ShippingCountry', _t('OmnipayableForm.SHIPPINGCOUNTRY', 'Country'));
     $shippingCountry->setAttribute('tabindex', $tabindex++);
     $shippingPhone = new PhoneNumberField('ShippingPhone', _t('OmnipayableForm.SHIPPINGPHONE', 'Phone'));
     $shippingPhone->setAttribute('tabindex', $tabindex++);
     // Create shipping details group
     $shippingFieldGroup = new FieldGroup();
     $shippingFieldGroup->setName('ShippingAddress');
     $shippingFieldGroup->setTitle(_t('OmnipayableForm.SHIPPING', 'Shipping Address'));
     // Add billiing fields to shipping group
     $shippingFieldGroup->push($shippingAddress1TextField);
     $shippingFieldGroup->push($shippingAddress2TextField);
     $shippingFieldGroup->push($shippingCity);
     $shippingFieldGroup->push($shippingPostcode);
     $shippingFieldGroup->push($shippingState);
     $shippingFieldGroup->push($shippingCountry);
     $shippingFieldGroup->push($shippingPhone);
     // Add shipping details group to fields
     $fields->push($shippingFieldGroup);
     return $fields;
 }
 public static function assetsFolderField($obj, $dirExists)
 {
     $field = null;
     $msg = null;
     if ($dirExists) {
         //Message
         $defaultMsg = '<em>Files uploaded via the content area will be uploaded to</em>' . '<br /> <strong>' . Upload::config()->uploads_folder . '</strong>';
         if (method_exists($obj, 'getMessageUploadDirectory')) {
             $msg = $obj->getMessageUploadDirectory();
         }
         if (!$msg) {
             $msg = $defaultMsg;
         }
         //TODO these could also be global settings
         $manageAble = true;
         $editable = true;
         //As this is happening from the subsites administration, when editing a subsite
         //you'd probably be on another site, and hence can't access the site's files anyway
         if ($obj->ClassName == 'Subsite') {
             $manageAble = false;
             $editable = false;
         }
         if ($editable) {
             //Asset folder is editable
             $field1 = new TreeDropdownField('AssetsFolderID', 'Change Directory:', 'Folder');
             $field1->setRightTitle('Directory changes take place after saving.');
             //Dropdown field style adjustments
             //TODO move this to an external stylesheet as these styles don't kick in on AJAX loads
             Requirements::customCSS('
                 #Form_EditForm_UploadDirRulesNotes .ui-accordion-content {
                     overflow: visible;
                 }
                 #TreeDropdownField_Form_EditForm_AssetsFolderID {
                     min-width: 260px;
                 }
                 .UploadDirectoryFields .fieldgroup label {
                     padding: 0 0 4px;
                 }
             ');
             $dir = $obj->AssetsFolder();
             $filescount = File::get()->filter(array('ParentID' => $dir->ID))->count();
             $manageButton = null;
             if ($manageAble) {
                 $manageButton = "<a href='/admin/assets/show/" . $dir->ID . "' class='ss-ui-button ss-ui-button-small ui-button'>\n                        Manage Files (" . $filescount . ')</a>';
             }
             $field2 = new LiteralField('UploadDirRulesNote', "<div style='margin-bottom:10px;margin-right:16px;'>{$msg}</div>" . $manageButton);
             $field = new FieldGroup(array($field2, $field1));
             $field->setTitle('Upload Directory');
             $field->addExtraClass('UploadDirectoryFields');
             $field->setName('UploadDirectoryFields');
         } else {
             //Asset folder is not editable
             $field = new LiteralField('UploadDirRulesNote', '
                 <div class="field text" id="UploadDirRulesNote">
                     <label class="left">Upload Directory</label>
                     <div class="middleColumn">
                         <p style="margin-bottom: 0; padding-top: 0px;">
                             ' . $msg . '
                             <br />
                             <em>If you need to edit or change this folder, please contact your administrator.</em>
                         </p>
                     </div>
                 </div>
                 ');
         }
     } else {
         //Message
         $defaultMsg = 'Please <strong>choose a name and save</strong> for adding content.';
         if (method_exists($obj, 'getMessageSaveFirst')) {
             $msg = $obj->getMessageSaveFirst();
         }
         if (!$msg) {
             $msg = $defaultMsg;
         }
         //preview calculated assets folder
         //$msg = $msg . ' (' . $this->owner->getCalcAssetsFolderDirectory() . ')';
         $field = new LiteralField('UploadDirRulesNote', '
             <p class="message notice" >' . $msg . '</p>
         ');
     }
     return $field;
 }