{/foreach}
diff --git a/admin-dev/themes/default/template/controllers/shipping/content.tpl b/admin-dev/themes/default/template/controllers/shipping/content.tpl
deleted file mode 100644
index 4ab2ff01a..000000000
--- a/admin-dev/themes/default/template/controllers/shipping/content.tpl
+++ /dev/null
@@ -1,105 +0,0 @@
-{*
-* 2007-2013 PrestaShop
-*
-* NOTICE OF LICENSE
-*
-* This source file is subject to the Academic Free License (AFL 3.0)
-* that is bundled with this package in the file LICENSE.txt.
-* It is also available through the world-wide-web at this URL:
-* http://opensource.org/licenses/afl-3.0.php
-* If you did not receive a copy of the license and are unable to
-* obtain it through the world-wide-web, please send an email
-* to license@prestashop.com so we can send you a copy immediately.
-*
-* DISCLAIMER
-*
-* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
-* versions in the future. If you wish to customize PrestaShop for your
-* needs please refer to http://www.prestashop.com for more information.
-*
-* @author PrestaShop SA
-* @copyright 2007-2013 PrestaShop SA
-* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*}
-
-{$content}
-
-
{l s='Fees by carrier, geographical zone and ranges'}
-
diff --git a/admin-dev/themes/default/template/controllers/shipping/index.php b/admin-dev/themes/default/template/controllers/shipping/index.php
deleted file mode 100644
index fcb7f5c2b..000000000
--- a/admin-dev/themes/default/template/controllers/shipping/index.php
+++ /dev/null
@@ -1,35 +0,0 @@
-
-* @copyright 2007-2013 PrestaShop SA
-* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
-* International Registered Trademark & Property of PrestaShop SA
-*/
-
-header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
-header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
-
-header('Cache-Control: no-store, no-cache, must-revalidate');
-header('Cache-Control: post-check=0, pre-check=0', false);
-header('Pragma: no-cache');
-
-header('Location: ../../../../../../');
-exit;
\ No newline at end of file
diff --git a/classes/Carrier.php b/classes/Carrier.php
index 4343d754a..928418647 100644
--- a/classes/Carrier.php
+++ b/classes/Carrier.php
@@ -735,7 +735,7 @@ class CarrierCore extends ObjectModel
*/
public function deleteDeliveryPrice($range_table)
{
- $where = '`id_carrier` = '.(int)$this->id.' AND (`id_'.$range_table.'` IS NOT NULL OR `id_'.$range_table.'` = 0) ';
+ $where = '`id_carrier` = '.(int)$this->id.' AND (`id_'.bqSQL($range_table).'` IS NOT NULL OR `id_'.bqSQL($range_table).'` = 0) ';
if (Shop::getContext() == Shop::CONTEXT_ALL)
$where .= 'AND id_shop IS NULL AND id_shop_group IS NULL';
diff --git a/controllers/admin/AdminCarrierWizardController.php b/controllers/admin/AdminCarrierWizardController.php
index 1070661e4..795623a30 100644
--- a/controllers/admin/AdminCarrierWizardController.php
+++ b/controllers/admin/AdminCarrierWizardController.php
@@ -358,7 +358,7 @@ class AdminCarrierWizardControllerCore extends AdminController
// init blank range
if (!count($tpl_vars['ranges']))
- $tpl_vars['ranges'][] = array('id_range' => -1, 'delimiter1' => 0, 'delimiter2' => 5);
+ $tpl_vars['ranges'][] = array('id_range' => -1, 'delimiter1' => 0, 'delimiter2' => 100000);
}
public function renderStepFour($carrier)
@@ -529,10 +529,12 @@ class AdminCarrierWizardControllerCore extends AdminController
$tpl_vars = array();
$fields_value = $this->getStepThreeFieldsValues($carrier);
$this->getTplRangesVarsAndValues($carrier, &$tpl_vars, &$fields_value);
+
$template = $this->createTemplate('controllers/carrier_wizard/helpers/form/form_ranges.tpl');
$template->assign($tpl_vars);
$template->assign('fields_value', $fields_value);
$template->assign('input', array('type' => 'zone', 'name' => 'zones' ));
+
die ($template->fetch());
}
@@ -566,33 +568,61 @@ class AdminCarrierWizardControllerCore extends AdminController
die(Tools::jsonEncode($return));
}
- public function processRange()
+ public function processRanges($id_carrier)
{
- if ((Validate::isLoadedObject($this->object) && !$this->wizard_access['edit']) || !$this->wizard_access['add'])
+ if (!$this->wizard_access['edit'] || !$this->wizard_access['add'])
{
$this->errors[] = Tools::displayError('You do not have permission to use this wizard.');
return;
}
+ $carrier = new Carrier((int)$id_carrier);
+ if (!Validate::isLoadedObject($carrier))
+ return false;
+
$range_inf = Tools::getValue('range_inf');
$range_sup = Tools::getValue('range_sup');
$range_type = Tools::getValue('shipping_method');
+
+ $fees = Tools::getValue('fees');
+
+ $carrier->deleteDeliveryPrice($carrier->getRangeTable());
if ($range_type != Carrier::SHIPPING_METHOD_FREE)
{
- foreach ($range_inf as $key => $range)
- {
+ foreach ($range_inf as $key => $delimiter1)
+ {
+ if (!isset($range_sup[$key]))
+ continue;
+
if ($range_type == Carrier::SHIPPING_METHOD_WEIGHT)
- $new_range = new RangeWeight();
-
+ $range = new RangeWeight((int)$key);
if ($range_type == Carrier::SHIPPING_METHOD_PRICE)
- $new_range = new RangePrice();
-
-
- /* $this-> */
-
-
- }
+ $range = new RangePrice((int)$key);
+
+ $range->id_carrier = (int)$carrier->id;
+ $range->delimiter1 = (float)$delimiter1;
+ $range->delimiter2 = (float)$range_sup[$key];
+ $range->save();
+
+ if (!Validate::isLoadedObject($range))
+ return false;
+
+ $price_list = array();
+ foreach ($fees as $id_zone => $fee)
+ $price_list[] = array(
+ 'id_range_price' => ($range_type == Carrier::SHIPPING_METHOD_PRICE ? (int)$range->id : null),
+ 'id_range_weight' => ($range_type == Carrier::SHIPPING_METHOD_WEIGHT ? (int)$range->id : null),
+ 'id_carrier' => (int)$carrier->id,
+ 'id_zone' => (int)$id_zone,
+ 'price' => (float)$fee[$key]
+ );
+
+ if (!$carrier->addDeliveryPrice($price_list))
+ return false;
+ }
}
+
+ return true;
}
public function ajaxProcessUploadLogo()
@@ -666,25 +696,31 @@ class AdminCarrierWizardControllerCore extends AdminController
$return['has_error'] = true;
$return['errors'][] = $this->l('An error occurred while saving carrier groups.');
}
-
+
if (!$this->changeZones((int)$carrier->id))
{
$return['has_error'] = true;
$return['errors'][] = $this->l('An error occurred while saving carrier zones.');
}
-
+
+ if (!$this->processRanges((int)$carrier->id))
+ {
+ $return['has_error'] = true;
+ $return['errors'][] = $this->l('An error occurred while saving carrier ranges.');
+ }
+
if (Shop::isFeatureActive() && !$this->updateAssoShop((int)$carrier->id))
{
$return['has_error'] = true;
$return['errors'][] = $this->l('An error occurred while saving associations of shops.');
}
-
+
if (!$carrier->setTaxRulesGroup((int)Tools::getValue('id_tax_rules_group')))
{
$return['has_error'] = true;
$return['errors'][] = $this->l('An error occurred while saving the tax rules group.');
}
-
+
if (Tools::getValue('logo'))
{
if (Tools::getValue('logo') == 'null' && file_exists(_PS_SHIP_IMG_DIR_.$carrier->id.'.jpg'))
@@ -780,4 +816,4 @@ class AdminCarrierWizardControllerCore extends AdminController
{
return $field;
}
-}
\ No newline at end of file
+}