예제 #1
0
 function _buildListArray(&$lists, $state)
 {
     $db = JFactory::getDbo();
     // Build plans dropdown
     $options = array();
     $options[] = JHtml::_('select.option', 0, JText::_('OSM_PLAN'), 'id', 'title');
     $sql = 'SELECT id, title FROM #__osmembership_plans WHERE published=1 ORDER BY ordering ';
     $db->setQuery($sql);
     $options = array_merge($options, $db->loadObjectList());
     $lists['plan_id'] = JHtml::_('select.genericlist', $options, 'plan_id', ' class="inputbox" onchange="submit();"', 'id', 'title', $state->plan_id);
     // Build countries dropdown
     $options = array();
     $options[] = JHtml::_('select.option', 0, JText::_('OSM_SELECT_COUNTRY'));
     $sql = 'SELECT `name` AS value, `name` AS text FROM `#__osmembership_countries` WHERE `published`=1';
     $db->setQuery($sql);
     $options = array_merge($options, $db->loadObjectList());
     $lists['country'] = JHtml::_('select.genericlist', $options, 'country', ' class="inputbox" onchange="submit();" ', 'value', 'text', $state->country);
     $defaultCountry = OSMembershipHelper::getConfigValue('default_country');
     $countryCode = OSmembershipHelper::getCountryCode($defaultCountry);
     if (OSMembershipHelperEuvat::isEUCountry($countryCode)) {
         $this->showVies = true;
         $options = array();
         $options[] = JHtml::_('select.option', -1, JText::_('OSM_VIES'));
         $options[] = JHtml::_('select.option', 0, JText::_('OSM_NO'));
         $options[] = JHtml::_('select.option', 1, JText::_('OSM_YES'));
         $lists['vies'] = JHtml::_('select.genericlist', $options, 'vies', ' class="inputbox" onchange="submit();" ', 'value', 'text', $state->vies);
     } else {
         $this->showVies = false;
     }
 }
예제 #2
0
 /**
  * Build EU tax rules
  */
 public function build_eu_tax_rules()
 {
     $db = JFactory::getDbo();
     $db->truncateTable('#__osmembership_taxes');
     $defaultCountry = OSmembershipHelper::getConfigValue('default_country');
     $defaultCountryCode = OSMembershipHelper::getCountryCode($defaultCountry);
     // Without VAT number, use local tax rate
     foreach (OSMembershipHelperEuvat::$europeanUnionVATInformation as $countryCode => $vatInfo) {
         $countryName = $db->quote($vatInfo[0]);
         $countryTaxRate = OSMembershipHelperEuvat::getEUCountryTaxRate($countryCode);
         $sql = "INSERT INTO #__osmembership_taxes(plan_id, country, rate, vies, published) VALUES(0, {$countryName}, {$countryTaxRate}, 0, 1)";
         $db->setQuery($sql);
         $db->execute();
         if ($countryCode == $defaultCountryCode) {
             $localTaxRate = OSMembershipHelperEuvat::getEUCountryTaxRate($defaultCountryCode);
             $sql = "INSERT INTO #__osmembership_taxes(plan_id, country, rate, vies, published) VALUES(0, {$countryName}, {$localTaxRate}, 1, 1)";
             $db->setQuery($sql);
             $db->execute();
         }
     }
     $this->setRedirect('index.php?option=com_osmembership&view=taxes', JText::_('EU Tax Rules were successfully created'));
 }