public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->replaceField("From", $from = new DateField("From", "Valid From - add any date and time"));
     $fields->replaceField("Until", $until = new DateField("Until", "Valid Until - add any date and time"));
     $fields->replaceField("NewPrice", new CurrencyField("NewPrice", "PRICE (OPTION 1 / 3) - only enter if there is a set new price independent of the 'standard' price."));
     $fields->replaceField("Percentage", new NumericField("Percentage", "PERCENTAGE (OPTIONAL 2/ 3) discount from 0 (0% discount) to 100 (100% discount)."));
     $fields->replaceField("Reduction", new CurrencyField("Reduction", "REDUCTION (OPTION 3 /3 ) - e.g. if you enter 2.00 then the new price will be the standard product price minus 2."));
     if (!$this->ID) {
         $fields->addFieldToTab("Root.Main", new LiteralField("SaveFirst", "<p>Please save first - and then select security groups / countries</p>"));
         $fields->removeByName("NoLongerValid");
     }
     if ($groups = Group::get()->count()) {
         $groups = Group::get();
         $fields->replaceField("Groups", new CheckboxSetField("Groups", "Who", $groups->map()->toArray()));
     } else {
         $fields->removeByName("Groups");
     }
     if ($ecommerceCountries = EcommerceCountry::get()) {
         $fields->replaceField("EcommerceCountries", new CheckboxSetField("EcommerceCountries", "Where", $ecommerceCountries->map()->toArray()));
     } else {
         $fields->removeByName("EcommerceCountries");
     }
     if (DiscountCouponOption::get()->count()) {
         $fields->replaceField("DiscountCouponOptions", new CheckboxSetField("DiscountCouponOptions", "Discount Coupons", DiscountCouponOption::get()->map()->toArray()));
     } else {
         $fields->removeByName("DiscountCouponOptions");
     }
     $from->setConfig('showcalendar', true);
     $until->setConfig('showcalendar', true);
     return $fields;
 }
 function updateCMSFields(FieldList $fields)
 {
     $excludedCountries = EcommerceCountry::get()->filter(array("DoNotAllowSales" => 1));
     if ($excludedCountries->count()) {
         $excludedCountries = $excludedCountries->map('ID', 'Name')->toArray();
     }
     $includedCountries = EcommerceCountry::get()->filter(array("DoNotAllowSales" => 0));
     if ($includedCountries->count()) {
         $includedCountries = $includedCountries->map('ID', 'Name')->toArray();
     }
     $tabs = new TabSet('Countries', new Tab('Include', new CheckboxField("AllCountries", "All Countries"), new LiteralField("ExplanationInclude", "<p>Products are not available in the countries listed below.  You can include sales of <i>" . $this->owner->Title . "</i> to new countries by ticking the box(es) next to any country.</p>"), new CheckboxSetField('IncludedCountries', '', $excludedCountries)), new Tab('Exclude', new LiteralField("ExplanationExclude", "<p>Products are available in all countries listed below.  You can exclude sales of <i>" . $this->owner->Title . "</i> from these countries by ticking the box next to any of them.</p>"), new CheckboxSetField('ExcludedCountries', '', $includedCountries)));
     $fields->addFieldToTab('Root.Countries', $tabs);
 }
 /**
  *
  * standard SS method
  */
 function requireDefaultRecords()
 {
     parent::requireDefaultRecords();
     if (!EcommerceCountry::get()->count() || isset($_REQUEST["resetecommercecountries"])) {
         $task = new EcommerceTaskCountryAndRegion();
         $task->run(null);
     }
 }
 function run($request)
 {
     $count = 0;
     $array = EcommerceCountry::get_country_dropdown();
     $allowedArray = EcommerceCountry::get()->filter(array("DoNotAllowSales" => 1));
     if ($allowedArray->count()) {
         foreach ($allowedArray as $obj) {
             $obj->DoNotAllowSales = 0;
             $obj->write();
             DB::alteration_message("Disallowing sales to " . $obj->Name);
         }
     } else {
         DB::alteration_message("Could not find any countries that are not allowed", "created");
     }
 }
 /**
  * description of region and country being shipped to.
  * @return String
  */
 protected function LiveRegionAndCountry()
 {
     $details = array();
     $option = $this->Option();
     if ($option) {
         $regionID = EcommerceRegion::get_region_id();
         if ($regionID) {
             $region = EcommerceRegion::get()->byID($regionID);
             if ($region) {
                 $details[] = $region->Name;
             }
         }
         $countryID = EcommerceCountry::get_country_id();
         if ($countryID) {
             $country = EcommerceCountry::get()->byID($countryID);
             if ($country) {
                 $details[] = $country->Name;
             }
         }
     } else {
         return _t("PickUpOrDeliveryModifier.NOTSELECTED", "No delivery option has been selected");
     }
     if (count($details)) {
         return implode(", ", $details);
     }
 }