示例#1
0
 public function renderEditForm($tpl = null)
 {
     if (!isset($this->context)) {
         $this->context = JeproshopContext::getContext();
     }
     $image = COM_JEPROSHOP_SUPPLIER_IMAGE_DIR . $this->supplier->supplier_id . '.jpg';
     $imageUrl = JeproshopImageManager::thumbnail($image, 'supplier_' . $this->supplier->supplier_id . '.' . $this->imageType, 350, $this->imageType, true, true);
     $imageSize = file_exists($image) ? filesize($image) / 1000 : false;
     $helper = new JeproshopHelper();
     $this->assignRef('helper', $helper);
     $address = $this->supplier->getSupplierAddress();
     $this->assignRef('address', $address);
     $countries = JeproshopCountryModelCountry::getStaticCountries($this->context->language->lang_id, false);
     $this->assignRef('countries', $countries);
     $this->addToolBar();
     $this->sideBar = JHtmlSideBar::render();
     parent::display($tpl);
 }
示例#2
0
echo JText::_('COM_JEPROSHOP_YOU_ARE_ABOUT_TO_ADD_LABEL') . ' ' . JText::_('COM_JEPROSHOP_A_NEW_TAX_RULE_LABEL');
?>
</div>
            <div class="panel-content well" >
                <div class="control-group" >
                    <div class="control-label" ><label for="jform_country_id" title="<?php 
echo JText::_('COM_JEPROSHOP_COUNTRY_TITLE_DESC');
?>
" ><?php 
echo JText::_('COM_JEPROSHOP_COUNTRY_LABEL');
?>
</label> </div>
                    <div class="controls" >
                        <?php 
$default_country_id = (int) $this->context->country->country_id;
$countries = JeproshopCountryModelCountry::getStaticCountries($this->context->language->lang_id);
?>
                        <select id="jform_country_id" name="jform[country_id]" >
                            <option value="0" ><?php 
echo JText::_('COM_JEPROSHOP_ALL_LABEL');
?>
</option>
                            <?php 
foreach ($countries as $country) {
    ?>
                                <option value="<?php 
    echo $country->country_id;
    ?>
" ><?php 
    echo $country->name;
    ?>
示例#3
0
 public function renderAddState($tpl = null)
 {
     if (!isset($this->context)) {
         $this->context = JeproshopContext::getContext();
     }
     $this->helper = new JeproshopHelper();
     $countries = JeproshopCountryModelCountry::getStaticCountries($this->context->language->lang_id);
     $zones = JeproshopZoneModelZone::getZones();
     $this->assignRef('countries', $countries);
     $this->assignRef('zones', $zones);
     $this->addToolBar();
     $this->sideBar = JHtmlSidebar::render();
     parent::display($tpl);
 }
示例#4
0
 private function initPriceForm()
 {
     if ($this->context == null) {
         $this->context = JeproshopContext::getContext();
     }
     if ($this->product->product_id) {
         $shops = JeproshopShopModelShop::getShops();
         $countries = JeproshopCountryModelCountry::getStaticCountries($this->context->language->lang_id);
         $groups = JeproshopGroupModelGroup::getStaticGroups($this->context->language->lang_id);
         $currencies = JeproshopCurrencyModelCurrency::getStaticCurrencies();
         $attributes = $this->product->getAttributesGroups((int) $this->context->language->lang_id);
         $combinations = array();
         if (count($attributes)) {
             foreach ($attributes as $attribute) {
                 $combinations[$attribute->product_attribute_id] = new JObject();
                 $combinations[$attribute->product_attribute_id]->product_attribute_id = $attribute->product_attribute_id;
                 if (!isset($combinations[$attribute->product_attribute_id]->attributes)) {
                     $combinations[$attribute->product_attribute_id]->attributes = '';
                 }
                 if (isset($combinations[$attribute->product_attribute_id])) {
                     $combinations[$attribute->product_attribute_id]->attributes .= $attribute->attribute_name . ' - ';
                     $combinations[$attribute->product_attribute_id]->price = JeproshopTools::displayPrice(JeproshopTools::convertPrice(JeproshopProductModelProduct::getStaticPrice((int) $this->product->product_id, false, $attribute->product_attribute_id), $this->context->currency), $this->context->currency);
                 }
             }
             foreach ($combinations as $combination) {
                 if (isset($combination->attributes)) {
                     $combination->attributes = rtrim($combination->attributes, ' - ');
                 }
             }
         }
         $specificPriceModificationForm = $this->displaySpecificPriceModificationForm($this->context->currency, $shops, $currencies, $countries, $groups);
         $this->assignRef('specific_price_modification_form', $specificPriceModificationForm);
         $this->assignRef('ecotax_tax_excluded', $this->product->ecotax);
         //$this->applyTaxToEcotax();
         $this->assignRef('shops', $shops);
         /*$admin_one_shop = count($this->context->employee->getAssociatedShops()) == 1;
           $this->assignRef('admin_one_shop', $admin_one_shop); */
         $this->assignRef('currencies', $currencies);
         $this->assignRef('currency', $this->context->currency);
         $this->assignRef('countries', $countries);
         $this->assignRef('groups', $groups);
         $this->assignRef('combinations', $combinations);
         $multiShop = JeproshopShopModelShop::isFeaturePublished();
         $this->assignRef('multi_shop', $multiShop);
     } else {
         JError::raiseWarnig(JText::_('COM_JEPROSHOP_YOU_MUST_SAVE_THIS_PRODUCT_BEFORE_ADDING_SPECIFIC_PRICING_MESSAGE'));
         $this->product->tax_rules_group_id = JeproshopProductModelProduct::getTaxRulesMostUsedGroupId();
         $this->assignRef('ecotax_tax_excluded', 0);
     }
     $use_tax = JeproshopSettingModelSetting::getValue('use_tax');
     $this->assignRef('use_tax', $use_tax);
     $use_ecotax = JeproshopSettingModelSetting::getValue('use_eco_tax');
     $this->assignRef('use_ecotax', $use_ecotax);
     $tax_rules_groups = JeproshopTaxRulesGroupModelTaxRulesGroup::getTaxRulesGroups(true);
     $this->assignRef('tax_rules_groups', $tax_rules_groups);
     $taxesRatesByGroup = JeproshopTaxRulesGroupModelTaxRulesGroup::getAssociatedTaxRatesByCountryId($this->context->country->country_id);
     $this->assignRef('taxesRatesByGroup', $taxesRatesByGroup);
     $ecotaxTaxRate = JeproshopTaxModelTax::getProductEcotaxRate();
     $this->assignRef('ecotaxTaxRate', $ecotaxTaxRate);
     $tax_exclude_tax_option = JeproshopTaxModelTax::taxExcludedOption();
     $this->assignRef('tax_exclude_tax_option', $tax_exclude_tax_option);
     $this->product->price = JeproshopTools::convertPrice($this->product->price, $this->context->currency, true, $this->context);
     if ($this->product->unit_price_ratio != 0) {
         $unit_price = JeproshopTools::roundPrice($this->product->price / $this->product->unit_price_ratio, 2);
     } else {
         $unit_price = 0;
     }
     $this->assignRef('unit_price', $unit_price);
 }
示例#5
0
 public function add()
 {
     $db = JFactory::getDBO();
     $context = JeproshopContext::getContext();
     $input = JRequest::get('post');
     $inputData = $input['jform'];
     $selectedCountries = array();
     $app = JFactory::getApplication();
     $taxId = isset($inputData['tax_id']) ? $inputData['tax_id'] : $app->input->get('tax_id', 0);
     $taxRuleId = isset($inputData['tax_rule_id']) ? $inputData['tax_rule_id'] : $app->input->get('tax_rule_id', 0);
     $zipCode = $inputData['zipcode'];
     $behavior = $inputData['behavior'];
     $description = $inputData['description'];
     $country_id = $inputData['country_id'];
     if ($country_id == 0) {
         $countries = JeproshopCountryModelCountry::getStaticCountries($context->language->lang_id);
         foreach ($countries as $country) {
             $selectedCountries[] = $country->country_id;
         }
     } else {
         $selectedCountries[] = $country_id;
     }
     $selectedStates = array();
     $state_id = $inputData['state_id'];
     if ($state_id != 0) {
         $selectedStates[] = $state_id;
     } else {
         $selectedStates[] = 0;
     }
     $taxRulesGroupId = (int) $app->input->get('tax_rules_group_id');
     echo $taxRulesGroupId;
     $taxRuleGroup = new JeproshopTaxRulesGroupModelTaxRulesGroup($taxRulesGroupId);
     foreach ($selectedCountries as $country_id) {
         $first = true;
         foreach ($selectedStates as $state_id) {
             if ($taxRuleGroup->hasUniqueTaxRuleForCountry($country_id, $state_id, $taxRuleId)) {
                 JError::raiseWarning(500, JText::_('COM_JEPROSHOP_A_TAX_ALREADY_EXISTS_FOR_THIS_COUNTRY_STATE_WITH_TAX_ONLY_BEHAVIOR_LABEL'));
                 continue;
             }
             $taxRule = new JeproshopTaxRuleModelTaxRule();
             // update or creation?
             if (isset($taxRuleId) && $first) {
                 $taxRule->tax_rule_id = $taxRuleId;
                 $first = false;
             }
             $taxRule->tax_id = $taxId;
             $taxRule->tax_rules_group_id = (int) $taxRulesGroupId;
             $taxRule->country_id = $country_id;
             $taxRule->state_id = (int) $state_id;
             list($taxRule->zipcode_from, $taxRule->zipcode_to) = $taxRule->breakDownZipCode($zipCode);
             $country = new JeproshopCountryModelCountry((int) $country_id, (int) $context->language->lang_id);
             if ($zipCode && $country->need_zip_code) {
                 if ($country->zip_code_format) {
                     foreach (array($taxRule->zipcode_from, $taxRule->zipcode_to) as $zip_code) {
                         if ($zip_code) {
                             if (!$country->checkZipCode($zip_code)) {
                                 JError::raiseError(500, JText::_('COM_JEPROSHOP_THE_ZIP_POSTAL_CODE_IS_INVALID_AND_MUST_BE_TYPED_AS_FOLLOWS_MESSAGE') . JText::_('COM_JEPROSHOP_FOR_LABEL'));
                             }
                         }
                     }
                 }
             }
             $taxRule->behavior = $behavior;
             $taxRule->description = $description;
             $query = "INSERT INTO " . $db->quoteName('#__jeproshop_tax_rule') . "(" . $db->quoteName('tax_rules_group_id') . ", " . $db->quoteName('country_id') . ", " . $db->quoteName('state_id') . ", " . $db->quoteName('zipcode_from') . ", ";
             $query .= $db->quoteName('zipcode_to') . ", " . $db->quoteName('tax_id') . ", " . $db->quoteName('behavior') . ", " . $db->quoteName('description') . ") VALUES (" . (int) $taxRulesGroupId . ", " . (int) $country_id . ", " . (int) $state_id;
             $query .= ", " . $db->quote($taxRule->zipcode_from) . ", " . $db->quote($taxRule->zipcode_to) . ", " . (int) $taxId . ", " . (int) $behavior . ", " . $db->quote($description) . ")";
             $db->setQuery($query);
             $link = 'index.php?option=com_jeproshop&view=tax&task=';
             if ($db->query()) {
                 $link .= 'edit_rules_group&tax_rules_group_id=' . (int) $taxRulesGroupId . '&' . JeproshopTools::getTaxToken() . '=1';
             } else {
                 $link .= '';
             }
             $app->redirect($link);
         }
     }
 }