<th width="60%" class="nowrap " ><?php echo JText::_('COM_JEPROSHOP_TAX_RULES_NAME_LABEL'); ?> </th> <th width="5%" class="nowrap " ><span class="pull-right" ><?php echo JText::_('COM_JEPROSHOP_ACTIONS_LABEL'); ?> </span></th> </tr> </thead> <tbody> <?php if (isset($this->tax_rules_groups)) { foreach ($this->tax_rules_groups as $index => $tax_rules_group) { $taxRulesGroupLink = JRoute::_('index.php?option=com_jeproshop&view=tax&task=edit_rules_group&tax_rules_group_id=' . (int) $tax_rules_group->tax_rules_group_id . '&' . JeproshopTools::getTaxToken() . '=1'); $taxRulesGroupDeleteLink = JRoute::_('index.php?option=com_jeproshop&view=tax&task=delete_rules_group&tax_rules_group_id=' . (int) $tax_rules_group->tax_rules_group_id . '&' . JeproshopTools::getTaxToken() . '=1'); ?> <tr class="row_<?php echo $index % 2; ?> " > <td width="1%" class="nowrap center hidden-phone"><?php echo $index + 1; ?> </td> <td width="1%" class="nowrap center hidden-phone"><?php echo JHtml::_('grid.id', $index, $tax_rules_group->tax_rules_group_id); ?> </td> <td width="3%" class="nowrap center"><i class="icon-<?php echo ($tax_rules_group->published ? '' : 'un') . 'publish';
public function update() { if ($this->viewAccess() && JeproshopTools::checkTaxToken()) { $app = JFactory::getApplication(); $tax_id = $app->input->get('tax_id'); if (isset($tax_id) && $tax_id > 0) { $taxModel = new JeproshopTaxModelTax($tax_id); if ($taxModel->updateTax()) { $link = 'index.php?option=com_jeproshop&view=tax'; } else { $link = 'index.php?option=com_jeproshop&view=tax&task=edit&tax_id=' . (int) $tax_id . '&' . JeproshopTools::getTaxToken() . '=1'; JError::raiseError(500, JText::_('COM_JEPROSHOP_WE_ENCOUNTER_AN_ERROR_WHILE_UPDATING_TAX_MESSAGE')); } $app->redirect($link); } } }
"/></div> </div> <div class="control-group" > <div class="control-label" ><label for="jform_published" title="<?php echo JText::_('COM_JEPROSHOP_TITLE_DESC'); ?> " ><?php echo JText::_('COM_JEPROSHOP_PUBLISHED_LABEL'); ?> </label></div> <div class="controls" ><?php echo $this->helper->radioButton('published', 'edit', $this->tax->published); ?> </div> </div> </div> </div> <input type="hidden" name="task" value="" /> <input type="hidden" name="tax_id" value="<?php echo $this->tax->tax_id; ?> " /> <input type="hidden" name="<?php echo JeproshopTools::getTaxToken(); ?> " value="1" /> <?php echo JHtml::_('form.token'); ?> </div> </form>
<th class="nowrap" ><?php echo JText::_('COM_JEPROSHOP_DESCRIPTION_LABEL'); ?> </th> <th class="nowrap" ><span class="pull-right" ><?php echo JText::_('COM_JEPROSHOP_ACTIONS_LABEL'); ?> </span></th> </tr> </thead> <tbody> <?php if (isset($this->tax_rules)) { foreach ($this->tax_rules as $index => $tax_rule) { $taxLink = JRoute::_('index.php?option=com_jeproshop&view=tax&task=edit_rule&tax_rule_id=' . (int) $tax_rule->tax_rule_id . '&' . JeproshopTools::getTaxToken() . '=1', true, 1); $deleteTaxLink = JRoute::_('index.php?option=com_jeproshop&view=tax&task=delete_rule&tax_rule_id=' . (int) $tax_rule->tax_rule_id . '&' . JeproshopTools::getTaxToken() . '=1', true, 1); ?> <tr class="row_<?php echo $index % 2; ?> " > <td width="1%" class="nowrap center hidden-phone"><?php echo $index + 1; ?> </td> <td width="1%" class="nowrap center hidden-phone"><?php echo JHtml::_('grid.id', $index, $tax_rule->tax_rule_id); ?> </td> <td width="4%" class="nowrap"><a href="<?php echo $taxLink;
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); } } }