function __construct($controller, $name)
 {
     Requirements::javascript(ECOMMERCE_DIR . '/javascript/OrderFormWithShippingAddress.js');
     parent::__construct($controller, $name);
     if (self::$fixed_country_code) {
         $defaultCountry = self::$fixed_country_code;
     } else {
         $defaultCountry = EcommerceRole::find_country();
     }
     $countryField = new DropdownField('ShippingCountry', 'Country', Geoip::getCountryDropDown(), $defaultCountry, $this);
     $shippingFields = new Tab("ShippingDetails", new HeaderField('Delivery Address', 3, $this), new LiteralField('ShippingNote', '<p class="warningMessage"><em>Your goods will be sent to the address below.</em></p>'), new TextField('ShippingName', 'Name', null, 100, $this), new TextField('ShippingAddress', 'Address', null, 100, $this), new TextField('ShippingAddress2', '', null, 100, $this), new TextField('ShippingCity', 'City', null, 100, $this), $countryField);
     //$this->fields->push($shippingFields);
     $this->fields->addFieldToTab("", new CheckboxField("UseShippingAddress", "Use Alternative Delivery Address"));
     $this->fields->addFieldToTab("", $shippingFields);
     foreach ($this->fields->dataFields() as $i => $child) {
         if (is_object($child)) {
             $name = $child->Name();
             switch ($name) {
                 case "Address":
                     $child->setTitle('Address');
                     break;
                 default:
                     break;
             }
         }
     }
 }
 function __construct($name, $title, $value = '')
 {
     if (!$value) {
         $value = Geoip::visitor_country();
     }
     parent::__construct($name, $title, Geoip::getCountryDropDown(), $value);
 }
 public function getTableTitle()
 {
     if ($this->Country) {
         $countryList = Geoip::getCountryDropDown();
         return _t("SimpleShippingModifier.SHIPPINGTO", "Shipping to") . " " . $countryList[$this->Country];
     } else {
         return _t("SimpleShippingModifier.SHIPPING", "Shipping");
     }
 }
 /**
  * @TODO Add i18n entities to the text.
  * @return string
  */
 function TableTitle()
 {
     if ($this->Country()) {
         $countryList = Geoip::getCountryDropDown();
         return "Shipping to {$countryList[$this->Country()]}";
     } else {
         return 'Shipping';
     }
 }
 /**
  *@param $code String (Code)
  *@return String ( name)
  **/
 public static function find_title($code)
 {
     $options = Geoip::getCountryDropDown();
     // check if code was provided, and is found in the country array
     if ($options && isset($options[$code])) {
         return $options[$code];
     } else {
         return "";
     }
 }
 public function getCMSFields_forPopup()
 {
     $sponsors_manager = new DataObjectManager($this, 'CleanUpSponsors', 'CleanUpSponsor', array('Name' => 'Name', 'Weblink' => 'Weblink', 'getDOMThumbnail' => 'Logo Image'));
     $sponsors_manager->addPermission("duplicate");
     $sponsors_manager->setConfirmDelete(true);
     $source = DataObject::get('Member');
     $members_manager = new MultiSelectField("Members", "CleanUpGroup", $source->map('ID', 'Title'));
     $oCountryField = new DropdownField('Country', 'Country', Geoip::getCountryDropDown(), 'NZ');
     return new FieldSet(new CheckboxField('TopEvent', 'Top Event'), new TextField('Title', 'Title'), new TextField('Subtitle', 'Subtitle'), new TextField('Organisation', 'Organistaion'), new DatePickerField('Date', 'OLD - Event Date'), new DatePickerField('FromDate', 'From'), new DatePickerField('ToDate', 'To'), new TextField('FromTime', 'From time'), new TextField('ToTime', 'To time'), $oCountryField, new TextField('Region', 'Event Region'), new TextField('LocationAddress', 'Location Address'), new GoogleMapSelectableMapField('Location', "Location of the Event", "{$this->LocationLatitude}", "{$this->LocationLongitude}", "575px", "250px", "6"), new TextField('LocationLongitude', 'Longitude (don\'t edit, for reference only)'), new TextField('LocationLatitude', 'Latitude (don\'t edit, for reference only)'), new CheckboxField('LocationShowDetails', 'Show Location Details'), new TextField('LocationDetails', 'Location Meeting Point Details'), new TextField('FacebookLink', 'FacebookLink'), new SimpleHTMLEditorField('Description', 'Description', array('css' => 'mysite/css/my_simple_stylesheet.css', 'insertUnorderedList' => true, 'copy' => true, 'justifyCenter' => false), 30), new CheckboxField('Private', 'Private Event'), new CheckboxField('Agree', 'Agreed to T&C'), new TextField('JoinedCount', 'Number of participants'), new ImageUploadField('EventImage', 'Main Event Image, Only shown for Top Events'), $sponsors_manager, $members_manager);
 }
 function __construct($name, $title = null, $source = null, $value = "", $form = null)
 {
     if (!is_array($source)) {
         $source = Geoip::getCountryDropDown();
     }
     if (!$value) {
         $value = Geoip::visitor_country();
     }
     parent::__construct($name, $title === null ? $name : $title, $source, $value, $form);
 }
 function run($request)
 {
     $count = 0;
     $array = Geoip::getCountryDropDown();
     foreach ($array as $key => $value) {
         if (!DataObject::get_one("EcommerceCountry", "\"Code\" = '" . Convert::raw2sql($key) . "'")) {
             $obj = new EcommerceCountry();
             $obj->Code = $key;
             $obj->Name = $value;
             $obj->write();
             DB::alteration_message("adding {$value} to Ecommerce Country", "created");
             $count++;
         }
     }
     DB::alteration_message("{$count} countries created");
 }
    /**
     * @param IQuerySpecification $specification
     * @return IQueryResult
     */
    public function handle(IQuerySpecification $specification)
    {
        $params = $specification->getSpecificationParams();
        $filter = '';
        if (!empty($term)) {
            $term = @$params['name_pattern'];
            $term = Convert::raw2sql($term);
            $countries = Geoip::getCountryDropDown();
            $matched_countries = array_filter($countries, function ($el) use($term) {
                return strpos(strtolower($el), strtolower($term)) !== false;
            });
            $country_filter = '';
            if (count($matched_countries)) {
                foreach ($matched_countries as $code => $name) {
                    $country_filter .= " OR Country = '{$code}' ";
                }
            } else {
                $country_filter = " OR Country LIKE '%{$term}%' ";
            }
            $filter = "AND City LIKE '%{$term}%' {$country_filter}";
        }
        $locations = array();
        $class_name = $this->getClassName();
        $sql = <<<SQL
        SELECT City,Country,State FROM DataCenterLocation
        INNER JOIN CompanyService ON CompanyService.ID = DataCenterLocation.CloudServiceID
\t\tWHERE CompanyService.ClassName = '{$class_name}'
\t\t{$filter}
\t\tGROUP BY City,Country,State
\t\tORDER BY City,State, Country ASC

SQL;
        $results = DB::query($sql);
        for ($i = 0; $i < $results->numRecords(); $i++) {
            $record = $results->nextRecord();
            $city = $record['City'];
            $state = $record['State'];
            $country = Geoip::countryCode2name($record['Country']);
            if (!empty($state)) {
                $value = sprintf('%s, %s, %s', $city, $state, $country);
            } else {
                $value = sprintf('%s, %s', $city, $country);
            }
            array_push($locations, new SearchDTO($value, $value));
        }
        return new OpenStackImplementationNamesQueryResult($locations);
    }
    /**                                                              
     * Constructor                                                   
     *                                                               
     * @param  object $controller The controller class                           
     * @param  string $name       The name of the form class              
     * @return object The form                                       
     */
    function __construct($controller, $name)
    {
        //FILTER BLOCK 1 : WHERE ARE YOU
        // Create new group
        $oFilterField1 = new CompositeField();
        // Set the field group ID
        $oFilterField1->setID('Group1');
        // Add fields to the group
        $oFilterField1->push(new LiteralField('Group1Title', '<div class="filter-title-block">Where are you?</div>'));
        $oFilterField1->push(new DropdownField('Country', '', Geoip::getCountryDropDown(), 'NZ'));
        //FILTER BLOCK 2: UPLOAD IMAGE
        // Create new group
        $oFilterField2 = new CompositeField();
        // Set the field group ID
        $oFilterField2->setID('Group2');
        // Add fields to the group
        $oFilterField2->push(new LiteralField('Group2Title', '<div class="filter-title-block">When can you help?</div>'));
        //Set Date Defaults
        $tToday = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
        $dToday = date("d/m/Y", $tToday);
        $tNextMonth = mktime(0, 0, 0, date("m") + 2, date("d"), date("Y"));
        $dNextMonth = date("d/m/Y", $tNextMonth);
        //Check if Dates are Set otherwise use Defaults
        $sFromDate = $this->sFromDate != '' ? $this->sFromDate : $dToday;
        $sToDate = $this->sToDate != '' ? $this->sToDate : $dNextMonth;
        //Date Fields
        $oFromDate = new DatePickerField('FromDate', 'From', $sFromDate);
        $oToDate = new DatePickerField('ToDate', 'To', $sToDate);
        $oFilterField2->push($oFromDate);
        $oFilterField2->push($oToDate);
        DatePickerField::$showclear = false;
        // Create new fieldset
        $oFields = new FieldSet();
        // Add the groups to the fieldset
        $oFields->push($oFilterField1);
        $oFields->push($oFilterField2);
        // Create the form action
        $oAction = new FieldSet(new FormAction('SubmitFilter', 'Find events'));
        // Add custom jQuery validation script for requred fields
        Requirements::customScript('
			
		');
        // Construct the form
        parent::__construct($controller, $name, $oFields, $oAction);
    }
 /**
  * Add some fields for managing Members in the CMS.
  * 
  * @return FieldSet
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab('Root.Address', new TextField('Address', _t('Customer.ADDRESS', "Address")));
     $fields->addFieldToTab('Root.Address', new TextField('AddressLine2', ''));
     $fields->addFieldToTab('Root.Address', new TextField('City', _t('Customer.CITY', "City")));
     $fields->addFieldToTab('Root.Address', new TextField('State', _t('Customer.STATE', "State")));
     $fields->addFieldToTab('Root.Address', new TextField('PostalCode', _t('Customer.POSTAL_CODE', "Postal Code")));
     $fields->addFieldToTab('Root.Address', new DropdownField('Country', _t('Customer.COUNTRY', "Country"), Geoip::getCountryDropDown()));
     $fields->removeByName('Street');
     $fields->removeByName('Suburb');
     $fields->removeByName('CityTown');
     $fields->removeByName('DateFormat');
     $fields->removeByName('TimeFormat');
     $fields->removeByName('Notes');
     $fields->removeByName('Orders');
     $fields->removeByName('Addresses');
     $fields->removeByName('Groups');
     $fields->removeByName('Permissions');
     return $fields;
 }
 /**
  * Give the two letter code to resolve the title of the country.
  *
  * @param string $code Country code
  * @return string|boolean String if country found, boolean FALSE if nothing found
  */
 function getEcommerceFields()
 {
     $fields = new FieldSet(new HeaderField(_t('EcommerceRole.PERSONALINFORMATION', 'Personal Information'), 3), new TextField('FirstName', _t('EcommerceRole.FIRSTNAME', 'First Name')), new TextField('Surname', _t('EcommerceRole.SURNAME', 'Surname')), new TextField('HomePhone', _t('EcommerceRole.HOMEPHONE', 'Phone')), new TextField('MobilePhone', _t('EcommerceRole.MOBILEPHONE', 'Mobile')), new EmailField('Email', _t('EcommerceRole.EMAIL', 'Email')), new TextField('Address', _t('EcommerceRole.ADDRESS', 'Address')), new TextField('AddressLine2', _t('EcommerceRole.ADDRESSLINE2', '&nbsp;')), new TextField('City', _t('EcommerceRole.CITY', 'City')), new TextField('PostalCode', _t('EcommerceRole.POSTALCODE', 'Postal Code')), new DropdownField('Country', _t('EcommerceRole.COUNTRY', 'Country'), Geoip::getCountryDropDown(), self::find_country()));
     $this->owner->extend('augmentEcommerceFields', $fields);
     return $fields;
 }
 /**
  * @return FieldSet
  */
 public function getFields()
 {
     $email = ($member = Member::currentUser()) ? $member->Email : "";
     // reduce tinymce
     HtmlEditorConfig::set_active('job');
     HtmlEditorConfig::get('job')->disablePlugins(array('contextmenu', 'table', 'emotions', 'paste', '../../tinymce_advcode', 'spellchecker'));
     HtmlEditorConfig::get('job')->setButtonsForLine('1', array('bold', 'italic', 'underline', 'bullist', 'numlist', 'cut', 'copy', 'paste', 'pastetext', 'pasteword', 'undo', 'redo'));
     HtmlEditorConfig::get('job')->setButtonsForLine('2', array());
     $fields = new FieldList(new HeaderField('JobInformation', 'Job Information'), new TextField('Title', 'Title of Listing <span>(Appears On Main Page)</span>'), new DropdownField('Type', 'Type', $this->dbObject('Type')->enumValues()), $guide = new DropdownField('PriceGuide', 'Price Guide ($USD) <span>(Optional)</span>', self::$price_guides), new HtmlEditorField('Content', 'Job Description'), new HtmlEditorField('ApplyContent', 'How to Apply <span>(Include your Contact Details)</span>'), new HeaderField('YourInformation', 'Your Information'), new EmailField('Email', 'Your Email <span>(Required)</span>', $email), new TextField('Company', 'Company Name <span>(Optional)</span>'), new TextField('URL', 'Company URL <span>(Optional) </span>'), $location = new DropdownField('Location', 'Location', Geoip::getCountryDropDown()));
     $guide->setEmptyString('');
     $location->setEmptyString('');
     if (Permission::check('ADMIN')) {
         $fields->push(new CheckboxField('Moderated'));
     }
     $this->extend('updateFields', $fields);
     return $fields;
 }
 function __construct($controller, $name)
 {
     Requirements::themedCSS('OrderForm');
     // 1) Member and shipping fields
     $member = Member::currentUser() ? Member::currentUser() : singleton('Member');
     $memberFields = new CompositeField($member->getEcommerceFields());
     $requiredFields = $member->getEcommerceRequiredFields();
     if (ShoppingCart::uses_different_shipping_address()) {
         $countryField = new DropdownField('ShippingCountry', 'Country', Geoip::getCountryDropDown(), EcommerceRole::findCountry());
         $shippingFields = new CompositeField(new HeaderField('Send goods to different address', 3), new LiteralField('ShippingNote', '<p class="warningMessage"><em>Your goods will be sent to the address below.</em></p>'), new LiteralField('Help', '<p>You can use this for gift giving. No billing information will be disclosed to this address.</p>'), new TextField('ShippingName', 'Name'), new TextField('ShippingAddress', 'Address'), new TextField('ShippingAddress2', ''), new TextField('ShippingCity', 'City'), $countryField, new HiddenField('UseShippingAddress', '', true), new FormAction_WithoutLabel('useMemberShippingAddress', 'Use Billing Address for Shipping'));
         $requiredFields[] = 'ShippingName';
         $requiredFields[] = 'ShippingAddress';
         $requiredFields[] = 'ShippingCity';
         $requiredFields[] = 'ShippingCountry';
     } else {
         $countryField = $memberFields->fieldByName('Country');
         $shippingFields = new FormAction_WithoutLabel('useDifferentShippingAddress', 'Use Different Shipping Address');
     }
     $countryField->addExtraClass('ajaxCountryField');
     $setCountryLinkID = $countryField->id() . '_SetCountryLink';
     $setContryLink = ShoppingCart_Controller::set_country_link();
     $memberFields->push(new HiddenField($setCountryLinkID, '', $setContryLink));
     $leftFields = new CompositeField($memberFields, $shippingFields);
     $leftFields->setID('LeftOrder');
     $rightFields = new CompositeField();
     $rightFields->setID('RightOrder');
     if (!$member->ID || $member->Password == '') {
         $rightFields->push(new HeaderField('Membership Details', 3));
         $rightFields->push(new LiteralField('MemberInfo', "<p class=\"message good\">If you are already a member, please <a href=\"Security/login?BackURL=" . CheckoutPage::find_link(true) . "/\">log in</a>.</p>"));
         $rightFields->push(new LiteralField('AccountInfo', "<p>Please choose a password, so you can login and check your order history in the future.</p><br/>"));
         $rightFields->push(new FieldGroup(new ConfirmedPasswordField('Password', 'Password')));
         $requiredFields[] = 'Password[_Password]';
         $requiredFields[] = 'Password[_ConfirmPassword]';
     }
     // 2) Payment fields
     $currentOrder = ShoppingCart::current_order();
     $total = '$' . number_format($currentOrder->Total(), 2);
     $paymentFields = Payment::combined_form_fields("{$total} " . $currentOrder->Currency(), $currentOrder->Total());
     foreach ($paymentFields as $field) {
         $rightFields->push($field);
     }
     if ($paymentRequiredFields = Payment::combined_form_requirements()) {
         $requiredFields = array_merge($requiredFields, $paymentRequiredFields);
     }
     // 3) Put all the fields in one FieldSet
     $fields = new FieldSet($leftFields, $rightFields);
     // 4) Terms and conditions field
     // If a terms and conditions page exists, we need to create a field to confirm the user has read it
     if ($controller->TermsPageID && ($termsPage = DataObject::get_by_id('Page', $controller->TermsPageID))) {
         $bottomFields = new CompositeField(new CheckboxField('ReadTermsAndConditions', "I agree to the terms and conditions stated on the <a href=\"{$termsPage->URLSegment}\" title=\"Read the shop terms and conditions for this site\">terms and conditions</a> page"));
         $bottomFields->setID('BottomOrder');
         $fields->push($bottomFields);
         $requiredFields[] = 'ReadTermsAndConditions';
     }
     // 5) Actions and required fields creation
     $actions = new FieldSet(new FormAction('processOrder', 'Place order and make payment'));
     $requiredFields = new CustomRequiredFields($requiredFields);
     // 6) Form construction
     parent::__construct($controller, $name, $fields, $actions, $requiredFields);
     // 7) Member details loading
     if ($member->ID) {
         $this->loadDataFrom($member);
     }
     // 8) Country field value update
     $currentOrder = ShoppingCart::current_order();
     $currentOrderCountry = $currentOrder->findShippingCountry(true);
     $countryField->setValue($currentOrderCountry);
 }
 /**
  * @return Array
  * e.g.
  * "NZ" => "New Zealand"
  * @return Array
  */
 public static function get_country_dropdown($showAllCountries = true)
 {
     if (class_exists("Geoip") && $showAllCountries) {
         return Geoip::getCountryDropDown();
     }
     if ($showAllCountries) {
         $objects = EcommerceCountry::get();
     } else {
         $objects = EcommerceCountry::get()->filter(array("DoNotAllowSales" => 0));
     }
     if ($objects && $objects->count()) {
         return $objects->map("Code", "Name")->toArray();
     }
     return array();
 }
Esempio n. 16
0
 public function moveCreditCardsFromJoomlaToSS()
 {
     die('test2');
     error_reporting(E_ALL);
     ini_set('display_errors', 1);
     ini_set('max_execution_time', 0);
     ini_set('memory_limit', '-1');
     $countries = Geoip::getCountryDropDown();
     $mysqli = $this->getDbConnection();
     $result = $mysqli->query("SELECT *, u.id uid FROM jos_users u\n\t\tINNER JOIN jos_aw_creditcard c ON u.id = c.creditcard_userid\n\t\tLEFT JOIN jos_aw_iscontacts ic ON c.creditcard_userid = ic.member_id\n\t\tLEFT JOIN jos_osemsc_billinginfo bi ON c.creditcard_userid = bi.user_id");
     $totalRec = 0;
     while ($obj = $result->fetch_object()) {
         $ssMember = $this->getSSMember($obj->email);
         if (!$ssMember) {
             continue;
         }
         $creditCard = new CreditCard();
         $creditCard->Created = $obj->creditcard_date;
         $creditCard->LastEdited = $obj->creditcard_date;
         $creditCard->CreditCardType = strtolower($obj->creditcard_type);
         $creditCard->NameOnCard = $obj->creditcard_name;
         $creditCard->CreditCardNumber = $obj->creditcard_number;
         $creditCard->CreditCardCVV = $obj->creditcard_cvv;
         $creditCard->ExpiryMonth = $obj->creditcard_month;
         $creditCard->ExpiryYear = $obj->creditcard_year;
         $creditCard->Company = $obj->company;
         $creditCard->StreetAddress1 = $obj->street1;
         $creditCard->StreetAddress2 = $obj->street2;
         $creditCard->City = $obj->city;
         $creditCard->State = $obj->state_id;
         $creditCard->PostalCode = $obj->postcode;
         $countryCode = array_search($obj->country_id, $countries);
         $creditCard->Country = $countryCode;
         if ($this->joomlaCurrentCreditCard($obj->creditcard_number, $obj->uid)) {
             $creditCard->Current = 1;
         }
         if ($this->joomlaTrialCreditCard($obj->creditcard_number)) {
             $creditCard->UsedForTrial = 1;
         }
         if ($obj->is_contact_id && ($ccID = $this->joomlaGetISCreditCardId($obj->creditcard_number, $obj->is_contact_id))) {
             $creditCard->ISCCID = $ccID;
         }
         $creditCard->MemberID = $ssMember->ID;
         $creditCard->write();
         $totalRec++;
     }
     $mysqli->close();
     echo "Total Cards moved: {$totalRec}";
 }
    function __construct($controller, $name, $TermsAndConditions, $TermsAndConditionsFileURL, $TermsAndConditionsAgreeText, $TermsAndConditionsName)
    {
        // Detail Fields
        // Create new group
        $oCleanDetailFields = new CompositeField();
        // Set the field group ID
        $oCleanDetailFields->setID('CreateDetails');
        // Add fields to the group
        $oCleanDetailFields->push(new LiteralField('Group1Title', '<div class="data-title-block"><img src="themes/lyc2012/img/fileicons/create_png.png" /><h2>Create your own event</h2><span> Enter as much detail as possible to make it easy for others to find and join your event.</span></div>'));
        $oCleanDetailFields->push(new TextField('Title', 'Event name'));
        $oCleanDetailFields->push(new LiteralField('Help', '<p class="help clear"> e.g. Location Name Beach Clean-up. Write something that describes what your event is all about.</p>'));
        $oCleanDetailFields->push(new SimpleHTMLEditorField('Description', 'Event details', '16', '18'));
        $oCleanDetailFields->push(new LiteralField('Help', '<p class="help clear"> Give additional details like what the organiser will provide (e.g. gloves, sacks), what participants will need to bring (e.g. food, drink, strong shoes) and anything else that will help people prepare for the event.</p>'));
        // Date Fields
        // Create new group
        $oCleanDateFields = new CompositeField();
        // Set the field group ID
        $oCleanDateFields->setID('CreateDateTime');
        //$oCleanDateFields->push(new LiteralField('Group3Title', '<div class="data-title-block"><img src="themes/lyc2012/img/s3.jpg" /><h2>When Is Your Event?</h2><span>Please enter these basic details, if you do not wish to provide more, you can submit the form after this stage.</span></div>'));
        $oCleanDateFields->push(new DatePickerField('FromDate', 'Start date'));
        $oCleanDateFields->push(new TextField('FromTime', 'Start time'));
        $oCleanDateFields->push(new DatePickerField('ToDate', 'Finish date'));
        $oCleanDateFields->push(new TextField('ToTime', 'Finish time'));
        //Location Fields
        // Create new group
        $oCleanLocationFields = new CompositeField();
        // Set the field group ID
        $oCleanLocationFields->setID('CreateLocation');
        //$oCleanLocationFields->push(new LiteralField('Group2Title', '<div class="data-title-block"><img src="themes/lyc2012/img/s2.jpg" /><h2>Where Is Your Event?</h2><span>Please enter these basic details, if you do not wish to provide more, you can submit the form after this stage.</span></div>'));
        $oCleanLocationFields->push(new DropdownField('Country', 'Country', Geoip::getCountryDropDown(), 'NZ'));
        //$oCleanLocationFields->push(new TextField('Region', 'Event Region'));
        $oCleanLocationFields->push(new TextField('LocationAddress', 'Location &nbsp;'));
        $oCleanLocationFields->push(new LiteralField('Help', '<p class="help clear">Either type the address of your event location above, or use the map below to zoom-in and drag and drop the red marker onto your event meeting point.</p>'));
        $oCleanLocationFields->push(new GoogleMapSelectableField('Location', "Location map", "-40.996484", "174.067383", "380px", "320px", "6"));
        $oCleanLocationFields->push(new HiddenField('LocationLongitude', 'Longitude (hide this)'));
        $oCleanLocationFields->push(new HiddenField('LocationLatitude', 'Latitude (hide this)'));
        //$oCleanLocationFields->push(new CheckboxField('LocationShowDetails', 'Give a More Detailed Location Description?'));
        //$oCleanLocationFields->push(new TextField('LocationDetails', 'Location Meeting Point Details'));
        //$oCleanLocationFields->push(new LiteralField('Help', '<p class="help clear">Give as much detail as possible. 500 word limit</p>'));
        //Admin Fields
        // Create new group
        $oCleanAdminFields = new CompositeField();
        // Set the field group ID
        $oCleanAdminFields->setID('CreateAdmin');
        $oCleanAdminFields->push(new TextField('Organisation', 'Name of organiser'));
        $oCleanAdminFields->push(new LiteralField('Help', "<p class='help clear'>Name of your school, community group or business. If none of these apply, just use your name.</p>"));
        $oCleanAdminFields->push(new SimpleImageField('EventImage', 'Upload logo/photo'));
        $oCleanAdminFields->push(new LiteralField('Help', "<p class='help clear'>Logo for your school, community group or business. If you don't have one, upload a photo that describes your event. Max file size 2MB</p>"));
        $oCleanAdminFields->push(new TextField('Facebooklink', 'Facebook Link for the event'));
        $oCleanAdminFields->push(new LiteralField('Help', '<p class="help clear">Optional. If you have a Facebook event for this event, copy the web address from your browser and paste it here.</p>'));
        $oCleanAdminFields->push(new CheckboxField('Agree', $TermsAndConditionsAgreeText));
        $oCleanAdminFields->push(new LiteralField('AgreeLink', '<div style="float: left; font-size: 10px; padding:10px;"><a href="#tc" id="tc_inline" class="fancyboxTC">View</a> or 
					 <a href="' . $TermsAndConditionsFileURL . '" Title="Download the ' . $TermsAndConditionsName . '">Download</a> the ' . $TermsAndConditionsName . '</div>' . '<div style="display:none"><div id="tc" style="width: 500px; padding-right: 20px">' . $TermsAndConditions . '</div></div>'));
        // Create new fieldset
        $oFields = new FieldSet();
        // Add the groups to the fieldset
        $oFields->push($oCleanDetailFields);
        $oFields->push($oCleanLocationFields);
        $oFields->push($oCleanDateFields);
        $oFields->push($oCleanAdminFields);
        // Create the form action
        $oAction = new FieldSet(new FormAction('createcleanup', 'Create Event'));
        /*
                $cleanupgroupFields = new CompositeField(
        			new LiteralField('Group1Title', '<div class="data-title-block"><img src="themes/lyc2012/img/s1.jpg" /><h2>Create your own event</h2><span>Please enter these basic details, if you do not wish to provide more, you can submit the form after this stage.</span></div>'),
        			new TextField('Title', 'Event name'),
        			new TextField('Subtitle', 'Event subtitle'),
        			new TextField('Organisation', 'Organisation Name'),
        			new TextField('Facebooklink', 'Facebook Link for the event'),
        			new DatePickerField('Date', 'Date'),
        			new DropdownField('Country', 'Country', Geoip::getCountryDropDown(), 'NZ'),
        			new TextField('Region', 'Event Region'),
        			new TextField('LocationAddress', 'Location Address'),
        			new GoogleMapSelectableMapField('Location', "Location of the Event", "-40.996484", "174.067383", "380px", "320px", "6"),
        			new HiddenField('LocationLongitude', 'Longitude (hide this)'),
        			new HiddenField('LocationLatitude', 'Latitude (hide this)'),
        			
        			new CheckboxField('LocationShowDetails', 'Give a More Detailed Location Description?'),
        			new TextField('LocationDetails', 'Location Meeting Point Details'),
        			new TextareaField('Description', 'Event Description', '30', '48'),
        			new LiteralField('Help', '<p class="help clear">Give as much detail as possible. 500 word limit</p>'),  
        			new CheckboxField('Agree', $TermsAndConditionsAgreeText),
        			new LiteralField('AgreeLink',
        					'<div style="float: left; font-size: 10px;"><a href="#tc" id="tc_inline" class="fancyboxTC">View</a> or 
        					 <a href="' . $TermsAndConditionsFileURL . '" Title="Download the ' . $TermsAndConditionsName . '">Download</a> the ' . $TermsAndConditionsName . '</div>' .
        					'<div style="display:none"><div id="tc" style="width: 500px; padding-right: 20px">' . $TermsAndConditions . '</div></div>')
                );
                $fields = new FieldSet($cleanupgroupFields);
                
        
                //add dropdown stuff
        
        
                $actions = new FieldSet(
                                new FormAction('createcleanup', 'Create')
                );*/
        //Debug::show($fields);
        //Debug::show($actions);
        //validation scripts
        Requirements::javascript("mysite/javascript/CreateFormVal.js");
        parent::__construct($controller, $name, $oFields, $oAction);
    }
 public function search()
 {
     $output = '';
     if (!$this->isJson()) {
         return $this->httpError(500, 'Content Type not allowed');
     }
     try {
         $search_params = json_decode($this->request->getBody(), true);
         $query = new QueryObject(new Consultant());
         $query->addAlias(QueryAlias::create('Company'));
         $query->addAndCondition(QueryCriteria::equal("Active", true));
         $location = @explode(',', @$search_params['location_term']);
         $name = @$search_params['name_term'];
         $service = @$search_params['service_term'];
         if (!empty($name)) {
             $query->addAndCondition(QueryCompoundCriteria::compoundOr(array(QueryCriteria::like('CompanyService.Name', $name), QueryCriteria::like('CompanyService.Overview', $name), QueryCriteria::like('Company.Name', $name))));
         }
         if (!empty($service)) {
             $query->addAlias(QueryAlias::create('ConsultantServiceOfferedType'));
             $query->addAndCondition(QueryCriteria::like("ConsultantServiceOfferedType.Type", $service));
         }
         if (is_array($location) && !empty($location[0])) {
             $query->addAlias(QueryAlias::create('Office'));
             $query->addAndCondition(QueryCriteria::like("Office.City", $location[0]));
         }
         $countries = array_flip(Geoip::getCountryDropDown());
         if (is_array($location) && count($location) == 2) {
             $country = trim($location[1]);
             if (!empty($country) && array_key_exists($country, $countries)) {
                 $query->addAndCondition(QueryCriteria::like("Office.Country", $countries[$country]));
             }
         } else {
             if (is_array($location) && count($location) == 3) {
                 $state = trim($location[1]);
                 $country = trim($location[2]);
                 if (!empty($country) && array_key_exists($country, $countries)) {
                     $query->addAndCondition(QueryCriteria::like("Office.Country", $countries[$country]));
                 }
                 if (!empty($state)) {
                     $query->addAndCondition(QueryCriteria::like("Office.State", $state));
                 }
             }
         }
         list($list, $size) = $this->consultants_repository->getAll($query, 0, 1000);
         foreach ($list as $public_cloud) {
             $output .= $public_cloud->renderWith('ConsultantsDirectoryPage_CloudBox', array('ConsultantLink' => $this->Link()));
         }
     } catch (Exception $ex) {
         return $this->httpError(500, 'Server Error');
     }
     return empty($output) ? $this->httpError(404, '') : $output;
 }
 /**
  * Give the two letter code to resolve the title of the country.
  *
  * @param string $code Country code
  * @return string|boolean String if country found, boolean FALSE if nothing found
  */
 static function findCountryTitle($code)
 {
     $countries = Geoip::getCountryDropDown();
     // check if code was provided, and is found in the country array
     if ($code && $countries[$code]) {
         return $countries[$code];
     } else {
         return false;
     }
 }
 function __construct($controller, $name)
 {
     //Requirements::themedCSS('OrderForm');
     // 1) Member and shipping fields
     $member = Member::currentUser();
     $memberFields = new CompositeField(singleton('Member')->getEcommerceFields());
     $requiredFields = singleton('Member')->getEcommerceRequiredFields();
     if (ShoppingCart::uses_different_shipping_address()) {
         $countryField = new DropdownField('ShippingCountry', _t('OrderForm.Country', 'Country'), Geoip::getCountryDropDown(), EcommerceRole::find_country());
         $shippingFields = new CompositeField(new HeaderField(_t('OrderForm.SendGoodsToDifferentAddress', 'Send goods to different address'), 3), new LiteralField('ShippingNote', '<p class="message warning">' . _t('OrderForm.ShippingNote', 'Your goods will be sent to the address below.') . '</p>'), new LiteralField('Help', '<p>' . _t('OrderForm.Help', 'You can use this for gift giving. No billing information will be disclosed to this address.') . '</p>'), new TextField('ShippingName', _t('OrderForm.Name', 'Name')), new TextField('ShippingAddress', _t('OrderForm.Address', 'Address')), new TextField('ShippingAddress2', _t('OrderForm.Address2', '')), new TextField('ShippingCity', _t('OrderForm.City', 'City')), $countryField, new HiddenField('UseShippingAddress', '', true), $changeshippingbutton = new FormAction_WithoutLabel('useMemberShippingAddress', _t('OrderForm.UseBillingAddress', 'Use Billing Address for Shipping')));
         //Need to to this because 'FormAction_WithoutLabel' has no text on the actual button
         $changeshippingbutton->setButtonContent(_t('OrderForm.UseBillingAddress', 'Use Billing Address for Shipping'));
         $changeshippingbutton->useButtonTag = true;
         $requiredFields[] = 'ShippingName';
         $requiredFields[] = 'ShippingAddress';
         $requiredFields[] = 'ShippingCity';
         $requiredFields[] = 'ShippingCountry';
     } else {
         $countryField = $memberFields->fieldByName('Country');
         $shippingFields = new FormAction_WithoutLabel('useDifferentShippingAddress', _t('OrderForm.useDifferentShippingAddress', 'Use Different Shipping Address'));
         //Need to to this because 'FormAction_WithoutLabel' has no text on the actual button
         $shippingFields->setButtonContent(_t('OrderForm.useDifferentShippingAddress', 'Use Different Shipping Address'));
         $shippingFields->useButtonTag = true;
     }
     if ($countryField) {
         $countryField->addExtraClass('ajaxCountryField');
         $setCountryLinkID = $countryField->id() . '_SetCountryLink';
         $setContryLink = ShoppingCart::set_country_link();
         $memberFields->push(new HiddenField($setCountryLinkID, '', $setContryLink));
     }
     $leftFields = new CompositeField($memberFields, $shippingFields);
     $leftFields->setID('LeftOrder');
     $rightFields = new CompositeField();
     $rightFields->setID('RightOrder');
     if (!$member) {
         $rightFields->push(new HeaderField(_t('OrderForm.MembershipDetails', 'Membership Details'), 3));
         $rightFields->push(new LiteralField('MemberInfo', '<p class="message warning">' . _t('OrderForm.MemberInfo', 'If you are already a member please') . " <a href=\"Security/login?BackURL=" . CheckoutPage::find_link(true) . "/\">" . _t('OrderForm.LogIn', 'log in') . '</a>.</p>'));
         $rightFields->push(new LiteralField('AccountInfo', '<p>' . _t('OrderForm.AccountInfo', 'Please choose a password, so you can login and check your order history in the future') . '</p><br/>'));
         $rightFields->push(new FieldGroup($pwf = new ConfirmedPasswordField('Password', _t('OrderForm.Password', 'Password'))));
         //if user doesn't fill out password, we assume they don't want to become a member
         //TODO: allow different ways of specifying that you want to become a member
         if (self::$user_membership_optional) {
             $pwf->setCanBeEmpty(true);
         }
         if (self::$force_membership || !self::$user_membership_optional) {
             $requiredFields[] = 'Password[_Password]';
             $requiredFields[] = 'Password[_ConfirmPassword]';
             //TODO: allow extending this to provide other ways of indicating that you want to become a member
         }
     } else {
         $rightFields->push(new LiteralField('MemberInfo', '<p class="message good">' . sprintf(_t('OrderForm.LoggedInAs', 'You are logged in as %s.'), $member->getName()) . " <a href=\"Security/logout?BackURL=" . CheckoutPage::find_link(true) . "/\">" . _t('OrderForm.LogOut', 'log out') . '</a>.</p>'));
     }
     // 2) Payment fields
     $currentOrder = ShoppingCart::current_order();
     $totalobj = DBField::create('Currency', $currentOrder->Total());
     //should instead be $totalobj = $currentOrder->dbObject('Total');
     $paymentFields = Payment::combined_form_fields($totalobj->Nice());
     foreach ($paymentFields as $field) {
         $rightFields->push($field);
     }
     if ($paymentRequiredFields = Payment::combined_form_requirements()) {
         $requiredFields = array_merge($requiredFields, $paymentRequiredFields);
     }
     // 3) Put all the fields in one FieldSet
     $fields = new FieldSet($leftFields, $rightFields);
     // 4) Terms and conditions field
     // If a terms and conditions page exists, we need to create a field to confirm the user has read it
     if ($controller->TermsPageID && ($termsPage = $controller->TermsPage())) {
         $bottomFields = new CompositeField(new CheckboxField('ReadTermsAndConditions', sprintf(_t('OrderForm.TERMSANDCONDITIONS', "I agree to the terms and conditions stated on the <a href=\"%s\" title=\"Read the shop terms and conditions for this site\">terms and conditions</a> page"), $termsPage->Link())));
         $bottomFields->setID('BottomOrder');
         $fields->push($bottomFields);
         $requiredFields[] = 'ReadTermsAndConditions';
         //TODO: this doesn't work for check-boxes
     }
     // 5) Actions and required fields creation
     $actions = new FieldSet(new FormAction('processOrder', _t('OrderForm.processOrder', 'Place order and make payment')));
     $requiredFields = new CustomRequiredFields($requiredFields);
     $this->extend('updateValidator', $requiredFields);
     $this->extend('updateFields', $fields);
     // 6) Form construction
     parent::__construct($controller, $name, $fields, $actions, $requiredFields);
     // 7) Member details loading
     if ($member && $member->ID) {
         $this->loadDataFrom($member);
     }
     // 8) Country field value update
     if ($countryField) {
         $currentOrder = ShoppingCart::current_order();
         $currentOrderCountry = $currentOrder->findShippingCountry(true);
         $countryField->setValue($currentOrderCountry);
     }
     //allow updating via decoration
     $this->extend('updateForm', $this);
 }