Exemple #1
0
 private function assignCountries()
 {
     // Select the most appropriate country
     $app = JFactory::getApplication();
     $country_id = $app->input->get('country_id');
     if (isset($country_id) && is_numeric($country_id)) {
         $selectedCountry = (int) $country_id;
     }
     if (!isset($selectedCountry)) {
         $selectedCountry = (int) JeproshopSettingModelSetting::getValue('default_country');
     }
     if (JeproshopSettingModelSetting::getValue('restrict_delivered_countries')) {
         $countries = JeproshopCarrierModelCarrier::getDeliveredCountries($this->context->language->lang_id, true, true);
         print_r($countries);
     } else {
         $countries = JeproshopCountryModelCountry::getCountries($this->context->language->lang_id, true);
     }
     $zones = JeproshopZoneModelZone::getZones();
     $this->assignRef('zones', $zones);
     $this->assignRef('countries', $countries);
     $registrationProcessType = JeproshopSettingModelSetting::getValue('registration_process_type');
     $this->assignRef('registration_process_type', $registrationProcessType);
     $selectedCountry = isset($selectedCountry) ? $selectedCountry : 0;
     $this->assignRef('selected_country', $selectedCountry);
     $vatNumberManagement = JeproshopSettingModelSetting::getValue('vat_number_management');
     $this->assignRef('vat_management', $vatNumberManagement);
 }
Exemple #2
0
 public static function addModuleRestrictions(array $shops = array(), array $countries = array(), array $modules = array())
 {
     if (!count($shops)) {
         $shops = JeproshopShopModelShop::getShops(true, null, true);
     }
     if (!count($countries)) {
         $countries = JeproshopCountryModelCountry::getCountries((int) JeproshopContext::getContext()->cookie->lang_id);
     }
     if (!count($modules)) {
         $modules = Module::getPaymentModules();
     }
     $sql = false;
     foreach ($shops as $id_shop) {
         foreach ($countries as $country) {
             foreach ($modules as $module) {
                 $sql .= '(' . (int) $module['id_module'] . ', ' . (int) $id_shop . ', ' . (int) $country['id_country'] . '),';
             }
         }
     }
     if ($sql) {
         $sql = 'INSERT IGNORE INTO `' . _DB_PREFIX_ . 'module_country` (`id_module`, `id_shop`, `id_country`) VALUES ' . rtrim($sql, ',');
         return Db::getInstance()->execute($sql);
     } else {
         return true;
     }
 }
Exemple #3
0
 public function renderEditRule($tpl = NULL)
 {
     if (!isset($this->context)) {
         $this->context = JeproshopContext::getContext();
     }
     $this->helper = new JeproshopHelper();
     $countryModel = new JeproshopCountryModelCountry();
     $countries = $countryModel->getCountries($this->context->language->lang_id);
     $taxModel = new JeproshopTaxModelTax();
     $taxes = $taxModel->getTaxes((int) $this->context->language->lang_id);
     $this->assignRef('taxes', $taxes);
     $taxRuleModel = new JeproshopTaxRuleModelTaxRule();
     $taxRules = $taxRuleModel->getTaxRuleList();
     $this->assignRef('tax_rules', $taxRules);
     $this->assignRef('countries', $countries);
     $this->addToolBar();
     $this->sideBar = JHtmlSidebar::render();
     parent::display($tpl);
 }
Exemple #4
0
 /**
  * Assign template vars related to countries display
  */
 protected function assignCountries()
 {
     $context = JeproshopContext::getContext();
     $app = JFactory::getApplication();
     $country_id = $app->input->get('country_id');
     // Get selected country
     if (isset($country_id) && !is_null($country_id) && is_numeric($country_id)) {
         $selected_country = (int) $country_id;
     } else {
         if (isset($this->address) && isset($this->address->country_id) && !empty($this->address->country_id) && is_numeric($this->address->country_id)) {
             $selected_country = (int) $this->address->country_id;
         } else {
             if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
                 // get all countries as language (xy) or language-country (wz-XY)
                 $array = array();
                 preg_match("#(?<=-)\\w\\w|\\w\\w(?!-)#", $_SERVER['HTTP_ACCEPT_LANGUAGE'], $array);
                 if (!JeproshopTools::isLanguageIsoCode($array[0]) || !($selected_country = JeproshopCountryModelCountry::getByIso($array[0]))) {
                     $selected_country = (int) JeproshopSettingModelSetting::getValue('default_country');
                 }
             } else {
                 $selected_country = (int) JeproshopSettingModelSetting::getValue('default_country');
             }
         }
     }
     // Generate countries list
     if (JeproshopSettingModelSetting::getValue('restrict_delivered_countries')) {
         $countries = JeproshopCarrierModelCarrier::getDeliveredCountries($context->language->lang_id, true, true);
     } else {
         $countries = JeproshopCountryModelCountry::getCountries($context->language->lang_id, true);
     }
     // @todo use helper
     $list = '';
     foreach ($countries as $country) {
         $selected = $country->country_id == $selected_country ? 'selected="selected"' : '';
         $list .= '<option value="' . (int) $country->country_id . '" ' . $selected . '>' . htmlentities(ucfirst($country->name)) . '</option>';
     }
     // Assign vars
     $this->assignRef('countries_list', $list);
     $this->assignRef('countries', $countries);
 }