// ranges
This commit is contained in:
+5
-5
@@ -4,18 +4,18 @@
|
||||
<td class="range_type"></td>
|
||||
<td class="border_left border_bottom">>=</td>
|
||||
{foreach from=$ranges key=r item=range}
|
||||
<td class="border_bottom center"><input name="range_inf[]" type="text" value="{$range.delimiter1|string_format:"%.6f"}" /></td>
|
||||
<td class="border_bottom center"><input name="range_inf[{$range.id_range|intval}]" type="text" value="{$range.delimiter1|string_format:"%.6f"}" /></td>
|
||||
{foreachelse}
|
||||
<td class="border_bottom center"><input name="range_inf[]" type="text" /></td>
|
||||
<td class="border_bottom center"><input name="range_inf[{$range.id_range|intval}]" type="text" /></td>
|
||||
{/foreach}
|
||||
</tr>
|
||||
<tr class="range_sup">
|
||||
<td class="center range_type"></td>
|
||||
<td class="border_left "><</td>
|
||||
{foreach from=$ranges key=r item=range}
|
||||
<td class="center"><input name="range_sup[]" type="text" value="{$range.delimiter2|string_format:"%.6f"}" /></td>
|
||||
<td class="center"><input name="range_sup[{$range.id_range|intval}]" type="text" value="{$range.delimiter2|string_format:"%.6f"}" /></td>
|
||||
{foreachelse}
|
||||
<td class="center"><input name="range_sup[]" type="text" /></td>
|
||||
<td class="center"><input name="range_sup[{$range.id_range|intval}]" type="text" /></td>
|
||||
{/foreach}
|
||||
</tr>
|
||||
<tr class="fees_all">
|
||||
@@ -37,7 +37,7 @@
|
||||
<td>{$zone.name}</td>
|
||||
<td class="zone"><input class="input_zone" name="zone_{$zone.id_zone}" value="1" type="checkbox" {if isset($fields_value[$input.name][$zone.id_zone])} checked="checked"{/if}/></td>
|
||||
{foreach from=$ranges key=r item=range}
|
||||
<td class="center"><input {if !isset($price_by_range[$range.id_range][$zone.id_zone])} disabled="disabled" {/if} name="fees[{$zone.id_zone}][]" type="text" value="{if isset($price_by_range[$range.id_range][$zone.id_zone])} {$price_by_range[$range.id_range][$zone.id_zone]|string_format:"%.6f"} {/if}" /></td>
|
||||
<td class="center"><input name="fees[{$zone.id_zone|intval}][{$range.id_range|intval}]" type="text" value="{if isset($price_by_range[$range.id_range][$zone.id_zone])} {$price_by_range[$range.id_range][$zone.id_zone]|string_format:"%.6f"} {/if}" /></td>
|
||||
{/foreach}
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
@@ -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 <contact@prestashop.com>
|
||||
* @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}
|
||||
<br /><br />
|
||||
<h2>{l s='Fees by carrier, geographical zone and ranges'}</h2>
|
||||
<form action="{$action_fees}" id="fees" name="fees" method="post">
|
||||
<fieldset>
|
||||
<legend><img src="../img/admin/delivery.gif" />{l s='Fees'}</legend>
|
||||
{if empty($carriers)}
|
||||
{l s='If you only have free carriers, there\'s no need to configure delivery prices.'}
|
||||
{else}
|
||||
<b>{l s='Carrier:'} </b>
|
||||
<select name="id_carrier2" onchange="$('#fees').attr('action', $('#fees').attr('action')+'&id_carrier='+$(this).attr('value')+'#fees'); $('#fees').submit();">
|
||||
{foreach $carriers AS $carrier}
|
||||
<option value="{$carrier['id_carrier']|intval}" {if $carrier['id_carrier'] == $id_carrier} selected="selected"{/if}>{$carrier['name']}</option>
|
||||
{/foreach}
|
||||
</select><br />
|
||||
|
||||
<table class="table space" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<th>{l s='Zone / Range'}</th>
|
||||
{if !$carrierSelected->is_free}
|
||||
{foreach $ranges AS $range}
|
||||
<th style="font-size: 11px;">{$range['delimiter1']|floatval}{$suffix} {l s='to'} {$range['delimiter2']|floatval}{$suffix}</th>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</tr>
|
||||
{if sizeof($ranges) && !$carrierSelected->is_free}
|
||||
{if sizeof($zones) > 1}
|
||||
<tr>
|
||||
<th style="height: 30px;">{l s='All'}</th>
|
||||
{foreach $ranges AS $range}
|
||||
<td class="center">
|
||||
{$currency->getSign('left')}
|
||||
<input type="text" id="fees_all_{$range[$rangeIdentifier]}" onchange="this.value = this.value.replace(/,/g, '.');" onkeyup="if ((event.keyCode||event.which) != 9){ spreadFees({$range[$rangeIdentifier]})}" style="width: 45px;" />
|
||||
{$currency->getSign('right')} {l s='(tax excl.)'}
|
||||
</td>
|
||||
{/foreach}
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
{foreach $zones AS $zone}
|
||||
<tr>
|
||||
<th style="height: 30px;">{$zone['name']}</th>
|
||||
{foreach $ranges AS $range}
|
||||
{if isset($deliveryArray[$zone['id_zone']][$id_carrier][$range[$rangeIdentifier]])}
|
||||
{$price = $deliveryArray[$zone['id_zone']][$id_carrier][$range[$rangeIdentifier]]}
|
||||
{else}
|
||||
{$price = '0.00'}
|
||||
{/if}
|
||||
<td class="center">
|
||||
{$currency->getSign('left')}
|
||||
<input
|
||||
type="text"
|
||||
class="fees_{$range[$rangeIdentifier]}"
|
||||
onchange="this.value = this.value.replace(/,/g, '.');" name="fees_{$zone['id_zone']}_{$range[$rangeIdentifier]}" onkeyup="clearAllFees({$range[$rangeIdentifier]})"
|
||||
value="{$price|string_format:"%.6f"}"
|
||||
style="width: 45px;"
|
||||
/>
|
||||
{$currency->getSign('right')} {l s='(tax excl.)'}
|
||||
</td>
|
||||
{/foreach}
|
||||
</tr>
|
||||
{/foreach}
|
||||
{/if}
|
||||
<tr>
|
||||
<td colspan="{$ranges|sizeof + 1}" class="center" style="border-bottom: none; height: 40px;">
|
||||
<input type="hidden" name="submitFees{$table}" value="1" />
|
||||
{if sizeof($ranges) && !$carrierSelected->is_free}
|
||||
<input type="submit" value="{l s=' Save '}" class="button" />
|
||||
{else if $carrierSelected->is_free}
|
||||
{l s='This is a free carrier'}
|
||||
{else}
|
||||
{l s='No ranges is set for this carrier'}
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{/if}
|
||||
<input type="hidden" name="id_carrier" value="{$id_carrier}" />
|
||||
</fieldset>
|
||||
</form>
|
||||
@@ -1,35 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2013 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @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;
|
||||
+1
-1
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user