/**
  * Returns the form fields.
  * 
  * @param bool $withUpdate Call extensions to update fields?
  * 
  * @return array
  */
 public function getFormFields($withUpdate = true)
 {
     if (!array_key_exists('Salutation', $this->formFields)) {
         $birthdayFields = array();
         $businessFields = array();
         if ($this->demandBirthdayDate()) {
             $birthdayDays = array('' => _t('SilvercartEditAddressForm.EMPTYSTRING_PLEASECHOOSE'));
             $birthdayMonths = array('' => _t('SilvercartEditAddressForm.EMPTYSTRING_PLEASECHOOSE'), '1' => _t('SilvercartPage.JANUARY'), '2' => _t('SilvercartPage.FEBRUARY'), '3' => _t('SilvercartPage.MARCH'), '4' => _t('SilvercartPage.APRIL'), '5' => _t('SilvercartPage.MAY'), '6' => _t('SilvercartPage.JUNE'), '7' => _t('SilvercartPage.JULY'), '8' => _t('SilvercartPage.AUGUST'), '9' => _t('SilvercartPage.SEPTEMBER'), '10' => _t('SilvercartPage.OCTOBER'), '11' => _t('SilvercartPage.NOVEMBER'), '12' => _t('SilvercartPage.DECEMBER'));
             for ($idx = 1; $idx < 32; $idx++) {
                 $birthdayDays[$idx] = $idx;
             }
             $birthdayFields = array('BirthdayDay' => array('type' => 'DropdownField', 'title' => _t('SilvercartPage.DAY'), 'value' => $birthdayDays, 'checkRequirements' => array('isFilledIn' => true)), 'BirthdayMonth' => array('type' => 'DropdownField', 'title' => _t('SilvercartPage.MONTH'), 'value' => $birthdayMonths, 'checkRequirements' => array('isFilledIn' => true)), 'BirthdayYear' => array('type' => 'TextField', 'title' => _t('SilvercartPage.YEAR'), 'maxLength' => 4, 'checkRequirements' => array('isFilledIn' => true, 'isNumbersOnly' => true, 'hasLength' => 4)));
         }
         if ($this->EnableBusinessCustomers()) {
             $businessFields = array('IsBusinessAccount' => array('type' => 'CheckboxField', 'title' => _t('SilvercartCustomer.ISBUSINESSACCOUNT')), 'TaxIdNumber' => array('type' => 'TextField', 'title' => _t('SilvercartAddress.TAXIDNUMBER'), 'maxLength' => 30, 'checkRequirements' => array('isFilledInDependantOn' => array('field' => 'IsBusinessAccount', 'hasValue' => '1'))), 'Company' => array('type' => 'TextField', 'title' => _t('SilvercartAddress.COMPANY'), 'maxLength' => 50, 'checkRequirements' => array('isFilledInDependantOn' => array('field' => 'IsBusinessAccount', 'hasValue' => '1'))));
         }
         $backlink = '';
         if (isset($_GET['backlink'])) {
             $backlink = Convert::raw2sql($_GET['backlink']);
         }
         $formFields = array('Salutation' => array('type' => 'DropdownField', 'title' => _t('SilvercartAddress.SALUTATION'), 'value' => array('' => _t('SilvercartEditAddressForm.EMPTYSTRING_PLEASECHOOSE'), 'Frau' => _t('SilvercartAddress.MISSES'), 'Herr' => _t('SilvercartAddress.MISTER')), 'checkRequirements' => array('isFilledIn' => true)), 'AcademicTitle' => array('type' => 'TextField', 'title' => _t('SilvercartAddress.AcademicTitle', 'Academic title')), 'FirstName' => array('type' => 'TextField', 'title' => _t('SilvercartAddress.FIRSTNAME', 'firstname'), 'checkRequirements' => array('isFilledIn' => true, 'hasMinLength' => 3)), 'Surname' => array('type' => 'TextField', 'title' => _t('SilvercartAddress.SURNAME', 'surname'), 'checkRequirements' => array('isFilledIn' => true, 'hasMinLength' => 3)), 'Addition' => array('type' => 'TextField', 'title' => _t('SilvercartAddress.ADDITION', 'Addition')), 'Street' => array('type' => 'TextField', 'title' => _t('SilvercartAddress.STREET', 'street'), 'checkRequirements' => array('isFilledIn' => true)), 'StreetNumber' => array('type' => 'TextField', 'title' => _t('SilvercartAddress.STREETNUMBER', 'streetnumber'), 'maxLength' => 10, 'checkRequirements' => array('isFilledIn' => true)), 'Postcode' => array('type' => 'TextField', 'title' => _t('SilvercartAddress.POSTCODE', 'postcode'), 'maxLength' => 10, 'checkRequirements' => array('isFilledIn' => true)), 'City' => array('type' => 'TextField', 'title' => _t('SilvercartAddress.CITY', 'city'), 'checkRequirements' => array('isFilledIn' => true)), 'Country' => array('type' => 'DropdownField', 'title' => _t('SilvercartCountry.SINGULARNAME'), 'value' => SilvercartCountry::getPrioritiveDropdownMap(true, _t('SilvercartCheckoutFormStep2.EMPTYSTRING_COUNTRY')), 'checkRequirements' => array('isFilledIn' => true)), 'Email' => array('type' => 'TextField', 'title' => _t('SilvercartAddress.EMAIL', 'email address'), 'checkRequirements' => array('isEmailAddress' => true, 'isFilledIn' => true, 'callBack' => 'doesEmailExistAlready')), 'EmailCheck' => array('type' => 'TextField', 'title' => _t('SilvercartAddress.EMAIL_CHECK', 'email address check'), 'checkRequirements' => array('isFilledIn' => true, 'mustEqual' => 'Email')), 'PhoneAreaCode' => array('type' => 'TextField', 'title' => _t('SilvercartAddress.PHONEAREACODE', 'phone area code'), 'checkRequirements' => array('isFilledIn' => true, 'isNumbersOnly' => true)), 'Phone' => array('type' => 'TextField', 'title' => _t('SilvercartAddress.PHONE', 'phone'), 'checkRequirements' => array('isFilledIn' => true, 'isNumbersOnly' => true)), 'Fax' => array('type' => 'TextField', 'title' => _t('SilvercartAddress.FAX')), 'Password' => array('type' => 'PasswordField', 'title' => _t('SilvercartPage.PASSWORD'), 'checkRequirements' => array('isFilledIn' => true, 'hasMinLength' => 6, 'mustNotEqual' => 'Email')), 'PasswordCheck' => array('type' => 'PasswordField', 'title' => _t('SilvercartPage.PASSWORD_CHECK'), 'checkRequirements' => array('isFilledIn' => true, 'mustEqual' => 'Password')), 'SubscribedToNewsletter' => array('type' => 'CheckboxField', 'title' => _t('SilvercartCheckoutFormStep.I_SUBSCRIBE_NEWSLETTER')), 'backlink' => array('type' => 'HiddenField', 'value' => $backlink));
         $this->formFields = array_merge($this->formFields, $formFields, $businessFields, $birthdayFields);
     }
     return parent::getFormFields($withUpdate);
 }
 /**
  * Returns the form fields
  * 
  * @param bool $withUpdate Execute update method of decorators?
  * 
  * @return array
  * 
  * @author Sebastian Diel <*****@*****.**>
  * @since 09.10.2012
  */
 public function getFormFields($withUpdate = true)
 {
     if (empty($this->formFields)) {
         $address = singleton('SilvercartAddress');
         $this->formFields = array('Salutation' => array('type' => 'DropdownField', 'title' => $address->fieldLabel('Salutation'), 'value' => array('' => _t('SilvercartEditAddressForm.EMPTYSTRING_PLEASECHOOSE'), "Frau" => _t('SilvercartAddress.MISSES'), "Herr" => _t('SilvercartAddress.MISTER')), 'checkRequirements' => array('isFilledIn' => true)), 'AcademicTitle' => array('type' => 'TextField', 'title' => $address->fieldLabel('AcademicTitle')), 'FirstName' => array('type' => 'TextField', 'title' => $address->fieldLabel('FirstName'), 'checkRequirements' => array('isFilledIn' => true)), 'Surname' => array('type' => 'TextField', 'title' => $address->fieldLabel('Surname'), 'checkRequirements' => array('isFilledIn' => true)), 'Addition' => array('type' => 'TextField', 'title' => $address->fieldLabel('Addition')), 'Street' => array('type' => 'TextField', 'title' => $address->fieldLabel('Street'), 'checkRequirements' => array('isFilledIn' => true)), 'StreetNumber' => array('type' => 'TextField', 'title' => $address->fieldLabel('StreetNumber'), 'checkRequirements' => array('isFilledIn' => true)), 'Postcode' => array('type' => 'TextField', 'title' => $address->fieldLabel('Postcode'), 'checkRequirements' => array('isFilledIn' => true)), 'City' => array('type' => 'TextField', 'title' => $address->fieldLabel('City'), 'checkRequirements' => array('isFilledIn' => true)), 'PhoneAreaCode' => array('type' => 'TextField', 'title' => $address->fieldLabel('PhoneAreaCode'), 'checkRequirements' => array('isFilledIn' => true)), 'Phone' => array('type' => 'TextField', 'title' => $address->fieldLabel('Phone'), 'checkRequirements' => array('isFilledIn' => true)), 'Fax' => array('type' => 'TextField', 'title' => $address->fieldLabel('Fax')), 'Country' => array('type' => 'DropdownField', 'title' => $address->fieldLabel('SilvercartCountry'), 'value' => SilvercartCountry::getPrioritiveDropdownMap(true, _t('SilvercartEditAddressForm.EMPTYSTRING_PLEASECHOOSE')), 'checkRequirements' => array('isFilledIn' => true)));
         if ($this->EnableBusinessCustomers()) {
             $this->formFields = array_merge($this->formFields, array('IsBusinessAccount' => array('type' => 'CheckboxField', 'title' => $address->fieldLabel('IsBusinessAccount')), 'TaxIdNumber' => array('type' => 'TextField', 'title' => $address->fieldLabel('TaxIdNumber'), 'maxLength' => 30, 'checkRequirements' => array('isFilledInDependantOn' => array('field' => 'IsBusinessAccount', 'hasValue' => '1'))), 'Company' => array('type' => 'TextField', 'title' => $address->fieldLabel('Company'), 'maxLength' => 50, 'checkRequirements' => array('isFilledInDependantOn' => array('field' => 'IsBusinessAccount', 'hasValue' => '1')))));
         }
         if ($this->EnablePackstation()) {
             $this->formFields = array_merge($this->formFields, array('IsPackstation' => array('type' => 'OptionsetField', 'title' => $address->fieldLabel('AddressType'), 'selectedValue' => '0', 'value' => array('0' => $address->fieldLabel('UseAbsoluteAddress'), '1' => $address->fieldLabel('UsePackstation')), 'checkRequirements' => array('isFilledIn' => true)), 'PostNumber' => array('type' => 'TextField', 'title' => $address->fieldLabel('PostNumber'), 'checkRequirements' => array('isFilledIn' => true)), 'Packstation' => array('type' => 'TextField', 'title' => $address->fieldLabel('Packstation'), 'checkRequirements' => array('isFilledIn' => true))));
         } else {
             $this->formFields = array_merge($this->formFields, array('IsPackstation' => array('type' => 'HiddenField', 'title' => $address->fieldLabel('AddressType'), 'value' => '0')));
         }
     }
     return parent::getFormFields($withUpdate);
 }
 /**
  * CMS fields for this object
  * 
  * @param array $params Scaffolding parameters
  * 
  * @return FieldList
  */
 public function getCMSFields($params = null)
 {
     $fields = SilvercartDataObject::getCMSFields($this);
     if ($fields->dataFieldByName('SilvercartCountryID')) {
         $countryDropdown = new DropdownField('SilvercartCountryID', $this->fieldLabel('Country'), SilvercartCountry::getPrioritiveDropdownMap());
         $fields->replaceField('SilvercartCountryID', $countryDropdown);
     }
     return $fields;
 }
 /**
  * Set initial form values
  *
  * @return void
  *
  * @author Roland Lehmann <*****@*****.**>, Sebastian Diel <*****@*****.**>
  * @since 07.12.2012
  */
 protected function fillInFieldValues()
 {
     // --------------------------------------------------------------------
     // Set i18n labels
     // --------------------------------------------------------------------
     $this->formFields['InvoiceAddressAsShippingAddress']['title'] = _t('SilvercartAddress.InvoiceAddressAsShippingAddress');
     $this->formFields['Invoice_Salutation']['title'] = _t('SilvercartAddress.SALUTATION', 'salutation');
     $this->formFields['Invoice_Salutation']['value'] = array('' => _t('SilvercartEditAddressForm.EMPTYSTRING_PLEASECHOOSE'), "Frau" => _t('SilvercartAddress.MISSES', 'misses'), "Herr" => _t('SilvercartAddress.MISTER', 'mister'));
     $this->formFields['Invoice_AcademicTitle']['title'] = _t('SilvercartAddress.AcademicTitle', 'Academic title');
     $this->formFields['Invoice_FirstName']['title'] = _t('SilvercartAddress.FIRSTNAME', 'firstname');
     $this->formFields['Invoice_Surname']['title'] = _t('SilvercartAddress.SURNAME', 'surname');
     $this->formFields['Invoice_Addition']['title'] = _t('SilvercartAddress.ADDITION', 'addition');
     $this->formFields['Invoice_Street']['title'] = _t('SilvercartAddress.STREET', 'street');
     $this->formFields['Invoice_StreetNumber']['title'] = _t('SilvercartAddress.STREETNUMBER', 'streetnumber');
     $this->formFields['Invoice_Postcode']['title'] = _t('SilvercartAddress.POSTCODE', 'postcode');
     $this->formFields['Invoice_City']['title'] = _t('SilvercartAddress.CITY', 'city');
     $this->formFields['Invoice_Phone']['title'] = _t('SilvercartAddress.PHONE', 'phone');
     $this->formFields['Invoice_PhoneAreaCode']['title'] = _t('SilvercartAddress.PHONEAREACODE', 'phone area code');
     $this->formFields['Invoice_Country']['title'] = _t('SilvercartCountry.SINGULARNAME');
     $this->formFields['Shipping_Salutation']['title'] = _t('SilvercartAddress.SALUTATION');
     $this->formFields['Shipping_Salutation']['value'] = array('' => _t('SilvercartEditAddressForm.EMPTYSTRING_PLEASECHOOSE'), "Frau" => _t('SilvercartAddress.MISSES'), "Herr" => _t('SilvercartAddress.MISTER'));
     $this->formFields['Shipping_AcademicTitle']['title'] = _t('SilvercartAddress.AcademicTitle');
     $this->formFields['Shipping_FirstName']['title'] = _t('SilvercartAddress.FIRSTNAME');
     $this->formFields['Shipping_Surname']['title'] = _t('SilvercartAddress.SURNAME');
     $this->formFields['Shipping_Addition']['title'] = _t('SilvercartAddress.ADDITION');
     $this->formFields['Shipping_Street']['title'] = _t('SilvercartAddress.STREET');
     $this->formFields['Shipping_StreetNumber']['title'] = _t('SilvercartAddress.STREETNUMBER');
     $this->formFields['Shipping_Postcode']['title'] = _t('SilvercartAddress.POSTCODE');
     $this->formFields['Shipping_City']['title'] = _t('SilvercartAddress.CITY');
     $this->formFields['Shipping_Phone']['title'] = _t('SilvercartAddress.PHONE');
     $this->formFields['Shipping_PhoneAreaCode']['title'] = _t('SilvercartAddress.PHONEAREACODE');
     $this->formFields['Shipping_Country']['title'] = _t('SilvercartCountry.SINGULARNAME');
     $countries = SilvercartCountry::get()->filter('Active', 1);
     if ($countries->exists()) {
         $this->formFields['Shipping_Country']['value'] = SilvercartCountry::getPrioritiveDropdownMap(true, _t('SilvercartCheckoutFormStep2.EMPTYSTRING_COUNTRY'));
         $this->formFields['Invoice_Country']['value'] = SilvercartCountry::getPrioritiveDropdownMap(true, _t('SilvercartCheckoutFormStep2.EMPTYSTRING_COUNTRY'));
     }
     // --------------------------------------------------------------------
     // Insert values from previous entries the customer has made
     // --------------------------------------------------------------------
     $this->controller->fillFormFields($this->formFields);
     if ($this->formFields['InvoiceAddressAsShippingAddress']['value'] == '1') {
         $this->controller->addJavascriptOnloadSnippet(array('deactivateShippingAddressValidation();
                 $(\'#ShippingAddressFields\').css(\'display\', \'none\');', 'loadInTheEnd'));
     }
 }
 /**
  * Returns the form fields
  * 
  * @param bool $withUpdate Execute update method of decorators?
  * 
  * @return array
  * 
  * @author Sebastian Diel <*****@*****.**>
  * @since 05.06.2014
  */
 public function getFormFields($withUpdate = true)
 {
     if (empty($this->formFields)) {
         $email = '';
         $orderDate = '';
         $orderNumber = '';
         $orderPositions = '';
         $orderID = '';
         $customer = SilvercartCustomer::currentRegisteredCustomer();
         if ($customer instanceof Member) {
             $email = $customer->Email;
             $address = $customer->SilvercartInvoiceAddress();
             $existingOrder = array('type' => 'DropdownField', 'title' => _t('SilvercartRevocationForm.OrderHistory'), 'value' => $customer->SilvercartOrder()->map('ID', 'Title', ' '));
             if (array_key_exists('ExistingOrder', $_POST)) {
                 $orderID = $_POST['ExistingOrder'];
             } elseif (array_key_exists('o', $_GET)) {
                 $orderID = $_GET['o'];
                 if (!is_numeric($orderID)) {
                     $orderID = '';
                 }
             }
             if (!empty($orderID)) {
                 $order = $customer->SilvercartOrder()->find('ID', $orderID);
                 if ($order instanceof SilvercartOrder && $order->exists()) {
                     $existingOrder['selectedValue'] = $orderID;
                     $address = $order->SilvercartInvoiceAddress();
                     $orderDate = date(_t('Silvercart.DATEFORMAT'), strtotime($order->Created));
                     $orderNumber = $order->OrderNumber;
                     $orderPositions = $order->getPositionsAsString(false, true);
                 }
             }
         } else {
             $address = singleton('SilvercartAddress');
             $existingOrder = array();
         }
         $this->formFields = array('RevocationOrderData' => array('type' => 'TextareaField', 'title' => _t('SilvercartRevocationForm.RevocationOrderData'), 'value' => $orderPositions), 'Email' => array('type' => 'TextField', 'title' => _t('SilvercartAddress.EMAIL'), 'value' => $email, 'checkRequirements' => array('isFilledIn' => true)), 'OrderDate' => array('type' => 'TextField', 'title' => _t('SilvercartRevocationForm.OrderDate'), 'value' => $orderDate), 'OrderNumber' => array('type' => 'TextField', 'title' => _t('SilvercartRevocationForm.OrderNumber'), 'value' => $orderNumber), 'Salutation' => array('type' => 'DropdownField', 'title' => $address->fieldLabel('Salutation'), 'value' => array('' => _t('SilvercartEditAddressForm.EMPTYSTRING_PLEASECHOOSE'), "Frau" => _t('SilvercartAddress.MISSES'), "Herr" => _t('SilvercartAddress.MISTER')), 'selectedValue' => $address->Salutation), 'FirstName' => array('type' => 'TextField', 'title' => $address->fieldLabel('FirstName'), 'value' => $address->FirstName, 'checkRequirements' => array('isFilledIn' => true)), 'Surname' => array('type' => 'TextField', 'title' => $address->fieldLabel('Surname'), 'value' => $address->Surname, 'checkRequirements' => array('isFilledIn' => true)), 'Addition' => array('type' => 'TextField', 'title' => $address->fieldLabel('Addition'), 'value' => $address->Addition), 'Street' => array('type' => 'TextField', 'title' => $address->fieldLabel('Street'), 'value' => $address->Street), 'StreetNumber' => array('type' => 'TextField', 'title' => $address->fieldLabel('StreetNumber'), 'value' => $address->StreetNumber), 'Postcode' => array('type' => 'TextField', 'title' => $address->fieldLabel('Postcode'), 'value' => $address->Postcode), 'City' => array('type' => 'TextField', 'title' => $address->fieldLabel('City'), 'value' => $address->City), 'Country' => array('type' => 'DropdownField', 'title' => $address->fieldLabel('SilvercartCountry'), 'value' => SilvercartCountry::getPrioritiveDropdownMap(true, _t('SilvercartEditAddressForm.EMPTYSTRING_PLEASECHOOSE')), 'selectedValue' => $address->SilvercartCountryID));
         if (!empty($existingOrder)) {
             $this->formFields['ExistingOrder'] = $existingOrder;
         }
     }
     return parent::getFormFields($withUpdate);
 }
 /**
  * Defines additional searchable fields.
  *
  * @param array &$fields The searchable fields from the decorated object
  * 
  * @return void
  * 
  * @author Sebastian Diel <*****@*****.**>,
  *         Sascha Koehler <*****@*****.**>
  * @since 25.06.2014
  */
 public function updateSearchableFields(&$fields)
 {
     $address = singleton('SilvercartAddress');
     $addressesCountryFilter = array('SilvercartAddresses.SilvercartCountryID' => array('title' => $address->fieldLabel('SilvercartCountry'), 'filter' => 'ExactMatchFilter', 'field' => new DropdownField('SilvercartAddresses.SilvercartCountryID', $address->fieldLabel('SilvercartCountry'), SilvercartCountry::getPrioritiveDropdownMap(false, ''))));
     $fields = array_merge($fields, array('CustomerNumber' => array('title' => $this->owner->fieldLabel('CustomerNumber'), 'filter' => 'PartialMatchFilter'), 'FirstName' => array('title' => $this->owner->fieldLabel('FirstName'), 'filter' => 'PartialMatchFilter'), 'Groups.ID' => array('title' => $this->owner->fieldLabel('GroupNames'), 'filter' => 'ExactMatchFilter'), 'SubscribedToNewsletter' => array('title' => $this->owner->fieldLabel('SubscribedToNewsletter'), 'filter' => 'ExactMatchFilter'), 'SilvercartAddresses.FirstName' => array('title' => $address->fieldLabel('FirstName'), 'filter' => 'PartialMatchFilter'), 'SilvercartAddresses.Surname' => array('title' => $address->fieldLabel('Surname'), 'filter' => 'PartialMatchFilter'), 'SilvercartAddresses.Street' => array('title' => $address->fieldLabel('Street'), 'filter' => 'PartialMatchFilter'), 'SilvercartAddresses.StreetNumber' => array('title' => $address->fieldLabel('StreetNumber'), 'filter' => 'PartialMatchFilter'), 'SilvercartAddresses.Postcode' => array('title' => $address->fieldLabel('Postcode'), 'filter' => 'PartialMatchFilter'), 'SilvercartAddresses.City' => array('title' => $address->fieldLabel('City'), 'filter' => 'PartialMatchFilter')), $addressesCountryFilter, array('SilvercartInvoiceAddress.FirstName' => array('title' => $address->fieldLabel('FirstName'), 'filter' => 'PartialMatchFilter'), 'SilvercartInvoiceAddress.Surname' => array('title' => $address->fieldLabel('Surname'), 'filter' => 'PartialMatchFilter'), 'SilvercartInvoiceAddress.Street' => array('title' => $address->fieldLabel('Street'), 'filter' => 'PartialMatchFilter'), 'SilvercartInvoiceAddress.StreetNumber' => array('title' => $address->fieldLabel('StreetNumber'), 'filter' => 'PartialMatchFilter'), 'SilvercartInvoiceAddress.Postcode' => array('title' => $address->fieldLabel('Postcode'), 'filter' => 'PartialMatchFilter'), 'SilvercartInvoiceAddress.City' => array('title' => $address->fieldLabel('City'), 'filter' => 'PartialMatchFilter'), 'SilvercartInvoiceAddress.SilvercartCountry.ID' => array('title' => $address->fieldLabel('SilvercartCountry'), 'filter' => 'ExactMatchFilter'), 'SilvercartShippingAddress.FirstName' => array('title' => $address->fieldLabel('FirstName'), 'filter' => 'PartialMatchFilter'), 'SilvercartShippingAddress.Surname' => array('title' => $address->fieldLabel('Surname'), 'filter' => 'PartialMatchFilter'), 'SilvercartShippingAddress.Street' => array('title' => $address->fieldLabel('Street'), 'filter' => 'PartialMatchFilter'), 'SilvercartShippingAddress.StreetNumber' => array('title' => $address->fieldLabel('StreetNumber'), 'filter' => 'PartialMatchFilter'), 'SilvercartShippingAddress.Postcode' => array('title' => $address->fieldLabel('Postcode'), 'filter' => 'PartialMatchFilter'), 'SilvercartShippingAddress.City' => array('title' => $address->fieldLabel('City'), 'filter' => 'PartialMatchFilter'), 'SilvercartShippingAddress.SilvercartCountry.ID' => array('title' => $address->fieldLabel('SilvercartCountry'), 'filter' => 'ExactMatchFilter')));
 }
 /**
  * Returns the form fields
  * 
  * @param bool $withUpdate Execute update method of decorators?
  * 
  * @return array
  * 
  * @author Sebastian Diel <*****@*****.**>
  * @since 15.11.2014
  */
 public function getFormFields($withUpdate = true)
 {
     if (empty($this->formFields)) {
         if (Member::currentUserID() > 0) {
             $member = SilvercartCustomer::currentUser();
         } else {
             $member = singleton('Member');
         }
         $address = singleton('SilvercartAddress');
         $this->formFields = array('Salutation' => array('type' => 'DropdownField', 'title' => $address->fieldLabel('Salutation'), 'selectedValue' => $member->Salutation, 'value' => array('' => _t('SilvercartEditAddressForm.EMPTYSTRING_PLEASECHOOSE'), "Frau" => _t('SilvercartAddress.MISSES'), "Herr" => _t('SilvercartAddress.MISTER')), 'checkRequirements' => array('isFilledIn' => true)), 'FirstName' => array('type' => 'TextField', 'title' => $address->fieldLabel('FirstName'), 'value' => $member->FirstName, 'checkRequirements' => array('isFilledIn' => true, 'hasMinLength' => 3)), 'Surname' => array('type' => 'TextField', 'title' => $address->fieldLabel('Surname'), 'value' => $member->Surname, 'checkRequirements' => array('isFilledIn' => true, 'hasMinLength' => 3)), 'Email' => array('type' => 'TextField', 'title' => $member->fieldLabel('Email'), 'value' => $member->Email, 'checkRequirements' => array('isFilledIn' => true, 'isEmailAddress' => true)), 'Message' => array('type' => 'TextareaField', 'title' => _t('SilvercartPage.MESSAGE', 'message'), 'checkRequirements' => array('isFilledIn' => true, 'hasMinLength' => 3)));
         if ($this->EnableStreet()) {
             $requirements = array();
             if ($this->StreetIsRequired()) {
                 $requirements = array('isFilledIn' => true);
             }
             $this->formFields = array_merge($this->formFields, array('Street' => array('type' => 'TextField', 'title' => $address->fieldLabel('Street') . ' / ' . $address->fieldLabel('StreetNumber'), 'checkRequirements' => $requirements), 'StreetNumber' => array('type' => 'TextField', 'title' => $address->fieldLabel('StreetNumber'), 'checkRequirements' => $requirements)));
         }
         if ($this->EnableCity()) {
             $requirements = array();
             if ($this->CityIsRequired()) {
                 $requirements = array('isFilledIn' => true);
             }
             $this->formFields = array_merge($this->formFields, array('Postcode' => array('type' => 'TextField', 'title' => $address->fieldLabel('Postcode'), 'checkRequirements' => $requirements), 'City' => array('type' => 'TextField', 'title' => $address->fieldLabel('Postcode') . ' - ' . $address->fieldLabel('City'), 'checkRequirements' => $requirements)));
         }
         if ($this->EnableCountry()) {
             $requirements = array();
             if ($this->CountryIsRequired()) {
                 $requirements = array('isFilledIn' => true);
             }
             $this->formFields = array_merge($this->formFields, array('SilvercartCountryID' => array('type' => 'DropdownField', 'title' => $address->fieldLabel('SilvercartCountry'), 'value' => SilvercartCountry::getPrioritiveDropdownMap(true, _t('SilvercartEditAddressForm.EMPTYSTRING_PLEASECHOOSE')), 'checkRequirements' => $requirements)));
         }
         if ($this->EnablePhoneNumber()) {
             $requirements = array();
             if ($this->PhoneNumberIsRequired()) {
                 $requirements = array('isFilledIn' => true);
             }
             $this->formFields = array_merge($this->formFields, array('Phone' => array('type' => 'TextField', 'title' => $address->fieldLabel('Phone'), 'checkRequirements' => $requirements)));
         }
     }
     return parent::getFormFields($withUpdate);
 }
 /**
  * Builds and returns the CMS fields.
  *
  * @return FieldList the CMS tabs and fields
  *
  * @author Sebastian Diel <*****@*****.**>
  * @since 22.02.2013
  */
 public function getCMSFieldsForSilvercart(FieldList $fields)
 {
     //$tab = $fields->findOrMakeTab('Root.Silvercart', 'SilverCart Shop');
     //$tab->setTitle('SilverCart Shop');
     // Build general toggle group
     $generalConfigurationField = ToggleCompositeField::create('GeneralConfiguration', $this->owner->fieldLabel('GeneralConfiguration'), array(SilvercartLanguageHelper::prepareLanguageDropdownField($this->owner, 'SiteTree', 'DefaultLocale'), new CheckboxField('useDefaultLanguageAsFallback', $this->owner->fieldLabel('useDefaultLanguageAsFallback')), new TextField('DefaultCurrency', $this->owner->fieldLabel('DefaultCurrency')), new DropdownField('DefaultPriceType', $this->owner->fieldLabel('DefaultPriceType'))))->setHeadingLevel(4)->setStartClosed(false);
     // Build email toggle group
     $emailConfigurationField = ToggleCompositeField::create('EmailConfiguration', $this->owner->fieldLabel('EmailConfiguration'), array(new TextField('EmailSender', $this->owner->fieldLabel('EmailSender')), new TextField('GlobalEmailRecipient', $this->owner->fieldLabel('GlobalEmailRecipient')), new TextField('DefaultMailRecipient', $this->owner->fieldLabel('DefaultMailRecipient')), new TextField('DefaultMailOrderNotificationRecipient', $this->owner->fieldLabel('DefaultMailOrderNotificationRecipient')), new TextField('DefaultContactMessageRecipient', $this->owner->fieldLabel('DefaultContactMessageRecipient'))))->setHeadingLevel(4);
     // Build customer toggle group
     $customerConfigurationField = ToggleCompositeField::create('CustomerConfiguration', $this->owner->fieldLabel('CustomerConfiguration'), array(new CheckboxField('enableBusinessCustomers', $this->owner->fieldLabel('enableBusinessCustomers')), new CheckboxField('enablePackstation', $this->owner->fieldLabel('enablePackstation')), new CheckboxField('demandBirthdayDateOnRegistration', $this->owner->fieldLabel('demandBirthdayDateOnRegistration'))))->setHeadingLevel(4);
     // Build product toggle group
     $productConfigurationField = ToggleCompositeField::create('ProductConfiguration', $this->owner->fieldLabel('ProductConfiguration'), array(new CheckboxField('enableStockManagement', $this->owner->fieldLabel('enableStockManagement')), new CheckboxField('isStockManagementOverbookable', $this->owner->fieldLabel('isStockManagementOverbookable')), new TextField('productsPerPage', $this->owner->fieldLabel('productsPerPage')), new TextField('productGroupsPerPage', $this->owner->fieldLabel('productGroupsPerPage')), new TextField('displayedPaginationPages', $this->owner->fieldLabel('displayedPaginationPages')), new UploadField('SilvercartNoImage', $this->owner->fieldLabel('SilvercartNoImage')), new CheckboxField('useStrictSearchRelevance', $this->owner->fieldLabel('useStrictSearchRelevance')), new DropdownField('StandardProductConditionID', $this->owner->fieldLabel('StandardProductConditionID'))))->setHeadingLevel(4);
     // Build checkout toggle group
     $checkoutConfigurationField = ToggleCompositeField::create('CheckoutConfiguration', $this->owner->fieldLabel('CheckoutConfiguration'), array(new CheckboxField('enableSSL', $this->owner->fieldLabel('enableSSL')), new CheckboxField('redirectToCartAfterAddToCart', $this->owner->fieldLabel('redirectToCartAfterAddToCart')), new CheckboxField('redirectToCheckoutWhenInCart', $this->owner->fieldLabel('redirectToCheckoutWhenInCart')), new CheckboxField('useProductDescriptionFieldForCart', $this->owner->fieldLabel('useProductDescriptionFieldForCart')), new DropdownField('productDescriptionFieldForCart', $this->owner->fieldLabel('productDescriptionFieldForCart')), new TextField('addToCartMaxQuantity', $this->owner->fieldLabel('addToCartMaxQuantity')), new CheckboxField('useMinimumOrderValue', $this->owner->fieldLabel('useMinimumOrderValue')), new SilvercartMoneyField('minimumOrderValue', $this->owner->fieldLabel('minimumOrderValue')), new CheckboxField('useFreeOfShippingCostsFrom', $this->owner->fieldLabel('useFreeOfShippingCostsFrom')), new SilvercartMoneyField('freeOfShippingCostsFrom', $this->owner->fieldLabel('freeOfShippingCostsFrom')), new CheckboxField('SkipShippingStepIfUnique', $this->owner->fieldLabel('SkipShippingStepIfUnique')), new CheckboxField('SkipPaymentStepIfUnique', $this->owner->fieldLabel('SkipPaymentStepIfUnique')), new CheckboxField('DisplayWeightsInKilogram', $this->owner->fieldLabel('DisplayWeightsInKilogram')), new CheckboxField('ShowTaxAndDutyHint', $this->owner->fieldLabel('ShowTaxAndDutyHint')), new CheckboxField('InvoiceAddressIsAlwaysShippingAddress', $this->owner->fieldLabel('InvoiceAddressIsAlwaysShippingAddress'))))->setHeadingLevel(4);
     // Build shop data toggle group
     $shopDataConfigurationField = ToggleCompositeField::create('ShopDataConfiguration', $this->owner->fieldLabel('ShopDataConfiguration'), array(new TextField('ShopName', $this->owner->fieldLabel('ShopName')), new TextField('ShopStreet', $this->owner->fieldLabel('ShopStreet')), new TextField('ShopStreetNumber', $this->owner->fieldLabel('ShopStreetNumber')), new TextField('ShopPostcode', $this->owner->fieldLabel('ShopPostcode')), new TextField('ShopCity', $this->owner->fieldLabel('ShopCity')), new DropdownField('ShopCountryID', $this->owner->fieldLabel('ShopCountry'), SilvercartCountry::getPrioritiveDropdownMap())))->setHeadingLevel(4);
     // Build security toggle group
     $securityConfigurationField = ToggleCompositeField::create('SecurityConfiguration', $this->owner->fieldLabel('SecurityConfiguration'), array(new TextareaField('userAgentBlacklist', $this->owner->fieldLabel('userAgentBlacklist'))))->setHeadingLevel(4);
     // Build example data toggle group
     $addExampleDataButton = new InlineFormAction('add_example_data', $this->owner->fieldLabel('addExampleData'));
     $addExampleConfigButton = new InlineFormAction('add_example_config', $this->owner->fieldLabel('addExampleConfig'));
     $exampleDataField = ToggleCompositeField::create('ExampleData', $this->owner->fieldLabel('addExampleData'), array($addExampleDataButton, $addExampleConfigButton))->setHeadingLevel(4);
     $addExampleDataButton->setRightTitle($this->owner->fieldLabel('addExampleDataDesc'));
     $addExampleDataButton->includeDefaultJS(false);
     $addExampleDataButton->setAttribute('data-icon', 'addpage');
     $addExampleConfigButton->setRightTitle($this->owner->fieldLabel('addExampleConfigDesc'));
     $addExampleConfigButton->includeDefaultJS(false);
     $addExampleConfigButton->setAttribute('data-icon', 'addpage');
     // Add groups to Root.Main
     $fields->addFieldToTab('Root.Main', $generalConfigurationField);
     $fields->addFieldToTab('Root.Main', $emailConfigurationField);
     $fields->addFieldToTab('Root.Main', $customerConfigurationField);
     $fields->addFieldToTab('Root.Main', $productConfigurationField);
     $fields->addFieldToTab('Root.Main', $checkoutConfigurationField);
     $fields->addFieldToTab('Root.Main', $shopDataConfigurationField);
     $fields->addFieldToTab('Root.Main', $securityConfigurationField);
     $fields->addFieldToTab('Root.Main', $exampleDataField);
     // Modify field data
     $fields->dataFieldByName('DefaultLocale')->setTitle($this->owner->fieldLabel('DefaultLocale'));
     $fields->dataFieldByName('EmailSender')->setRightTitle($this->owner->fieldLabel('EmailSenderRightTitle'));
     $fields->dataFieldByName('GlobalEmailRecipient')->setRightTitle($this->owner->fieldLabel('GlobalEmailRecipientRightTitle'));
     $fields->dataFieldByName('DefaultMailRecipient')->setRightTitle($this->owner->fieldLabel('DefaultMailRecipientRightTitle'));
     $fields->dataFieldByName('DefaultMailOrderNotificationRecipient')->setRightTitle($this->owner->fieldLabel('DefaultMailOrderNotificationRecipientRightTitle'));
     $fields->dataFieldByName('DefaultContactMessageRecipient')->setRightTitle($this->owner->fieldLabel('DefaultContactMessageRecipientRightTitle'));
     $fields->dataFieldByName('userAgentBlacklist')->setRightTitle($this->owner->fieldLabel('userAgentBlacklistRightTitle'));
     // Add i18n to DefaultPriceType source
     $i18nForDefaultPriceTypeField = array();
     foreach ($this->owner->dbObject('DefaultPriceType')->enumValues() as $value => $label) {
         $i18nForDefaultPriceTypeField[$value] = _t('SilvercartCustomer.' . strtoupper($label), $label);
     }
     $fields->dataFieldByName('DefaultPriceType')->setSource($i18nForDefaultPriceTypeField);
     // Add i18n to productDescriptionFieldForCart source
     $i18nForProductDescriptionField = array();
     foreach ($this->owner->dbObject('productDescriptionFieldForCart')->enumValues() as $productDescriptionField) {
         $i18nForProductDescriptionField[$productDescriptionField] = singleton('SilvercartProduct')->fieldLabel($productDescriptionField);
     }
     $fields->dataFieldByName('productDescriptionFieldForCart')->setSource($i18nForProductDescriptionField);
     $fields->dataFieldByName('StandardProductConditionID')->setEmptyString($this->owner->fieldLabel('StandardProductConditionEmptyString'));
     $this->getCMSFieldsForColorScheme($fields);
     return $fields;
 }