[+] BO: Add a wizard to create and edit your carriers
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
{*
|
||||
* 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
|
||||
*}
|
||||
{extends file="helpers/form/form.tpl"}
|
||||
{block name="script"}
|
||||
var string_price = '{l s="Will be applied when the price will be:" js=1}';
|
||||
var string_weight = '{l s="Will be applied when the weight will be:" js=1}';
|
||||
{/block}
|
||||
|
||||
{block name="field"}
|
||||
{if $input.name == 'zones'}
|
||||
{include file='controllers/carrier_wizard/helpers/form/form_ranges.tpl'}
|
||||
<div class="new_range">
|
||||
<a href="#" onclick="add_new_range();return false;" class="button" id="add_new_range">{l s="Add new range"}<img src="../img/admin/add.gif"/></a>
|
||||
</div>
|
||||
{/if}
|
||||
{$smarty.block.parent}
|
||||
{/block}
|
||||
@@ -0,0 +1,56 @@
|
||||
<div style="float:left" id="zone_ranges">
|
||||
<table cellpadding="5" cellspacing="0" id="zones_table">
|
||||
<tr class="range_inf">
|
||||
<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[{$range.id_range|intval}]" type="text" value="{$range.delimiter1|string_format:"%.6f"}" /></td>
|
||||
{foreachelse}
|
||||
<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[{$range.id_range|intval}]" type="text" value="{$range.delimiter2|string_format:"%.6f"}" /></td>
|
||||
{foreachelse}
|
||||
<td class="center"><input name="range_sup[{$range.id_range|intval}]" type="text" /></td>
|
||||
{/foreach}
|
||||
</tr>
|
||||
<tr class="fees_all">
|
||||
<td class="border_top border_bottom border_bold"><span class="fees_all" {if $ranges|count == 0}style="display:none" {/if}>All</span></td>
|
||||
<td></td>
|
||||
{foreach from=$ranges key=r item=range}
|
||||
<td class="center border_top border_bottom">
|
||||
<input type="text" />
|
||||
</td>
|
||||
{foreachelse}
|
||||
<td class="center border_top border_bottom">
|
||||
<input style="display:none" type="text" />
|
||||
<button class="button">{l s="Validate"}</button>
|
||||
</td>
|
||||
{/foreach}
|
||||
</tr>
|
||||
{foreach from=$zones key=i item=zone}
|
||||
<tr class="fees {if $i is odd}alt_row{/if}" data-zoneid="{$zone.id_zone}">
|
||||
<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 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}
|
||||
<tr class="delete_range">
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
{foreach from=$ranges name=ranges key=r item=range}
|
||||
{if $smarty.foreach.ranges.first}
|
||||
<td class="center"> </td>
|
||||
{else}
|
||||
<td class="center"><button class="button">{l s="Delete"}</button</td>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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;
|
||||
@@ -31,5 +31,5 @@ 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: ../../../../../../');
|
||||
header('Location: ../../../../../../../');
|
||||
exit;
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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;
|
||||
@@ -0,0 +1,59 @@
|
||||
{*
|
||||
* 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
|
||||
*}
|
||||
|
||||
{extends file="helpers/view/view.tpl"}
|
||||
{block name="override_tpl"}
|
||||
<script>
|
||||
var labelNext = '{$labels.next|addslashes}';
|
||||
var labelPrevious = '{$labels.previous|addslashes}';
|
||||
var labelFinish = '{$labels.finish|addslashes}';
|
||||
var labelDelete = '{l s="Delete" js=1}';
|
||||
var labelValidate = '{l s="Validate" js=1}';
|
||||
var validate_url = '{$validate_url|addslashes}';
|
||||
var carrierlist_url = '{$carrierlist_url|addslashes}';
|
||||
var nbr_steps = {$wizard_steps.steps|count};
|
||||
var enableAllSteps = {if $enableAllSteps|intval == 1}true{else}false{/if};
|
||||
</script>
|
||||
<div id="carrier_wizard" class="swMain">
|
||||
<ul class="nbr_steps_{$wizard_steps.steps|count}">
|
||||
{foreach from=$wizard_steps.steps key=step_nbr item=step}
|
||||
<li>
|
||||
<a href="#step-{$step_nbr + 1}">
|
||||
<label class="stepNumber">{$step_nbr + 1}</label>
|
||||
<span class="stepDesc">
|
||||
{$step.title}<br />
|
||||
{if isset($step.desc)}<small>{$step.desc}</small>{/if}
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
{foreach from=$wizard_contents.contents key=step_nbr item=content}
|
||||
<div id="step-{$step_nbr + 1}" style="padding-bottom:10px">
|
||||
{$content}
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
{/block}
|
||||
@@ -0,0 +1,98 @@
|
||||
{*
|
||||
* 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
|
||||
*}
|
||||
|
||||
<div id="carrier_logo_block" style="position:absolute;top:15px;right:15px">
|
||||
<img id="carrier_logo_img" src="{if $carrier_logo}{$carrier_logo}{else}../img/404.gif{/if}" />
|
||||
<p>
|
||||
<input id="carrier_logo_input" type="file" onchange="uploadCarrierLogo();" name="carrier_logo_input" />
|
||||
<input type="hidden" id="logo" name="logo" value="" />
|
||||
</p>
|
||||
<a id="carrier_logo_remove" {if !$carrier_logo}style="display:none"{/if} href="javascript:removeCarrierLogo();"><img src="../img/admin/disabled.gif" /> {l s='Remove the logo'}</a>
|
||||
<p>
|
||||
{l s='Format:'} JPG, GIF, PNG. {l s='Filesize:'} {$max_image_size|string_format:"%.2f"} {l s='MB max.'}
|
||||
<br />{l s='Current size:'} <span id="carrier_logo_size">{l s='undefined'}</span>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var carrier_translation_undefined = '{l s='undefined' js='1'}';
|
||||
|
||||
function removeCarrierLogo()
|
||||
{
|
||||
$('#carrier_logo_img').attr('src', '../img/404.gif');
|
||||
$('#logo').val('null');
|
||||
fixCarrierLogoDisplay();
|
||||
$('#carrier_logo_remove').hide();
|
||||
}
|
||||
|
||||
function uploadCarrierLogo()
|
||||
{
|
||||
$.ajaxFileUpload({
|
||||
url: 'ajax-tab.php?tab=AdminCarrierWizard&token={$token|addslashes}&action=uploadLogo',
|
||||
secureuri: false,
|
||||
fileElementId: 'carrier_logo_input',
|
||||
dataType: 'xml',
|
||||
success: function (data, status) {
|
||||
data = data.getElementsByTagName('return')[0];
|
||||
var message = data.getAttribute("message");
|
||||
if (data.getAttribute("result") == "success")
|
||||
{
|
||||
$('#carrier_logo_img').attr('src', message);
|
||||
$('#logo').val(message);
|
||||
$('#carrier_logo_remove').show();
|
||||
fixCarrierLogoDisplay();
|
||||
}
|
||||
else
|
||||
alert(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function fixCarrierLogoDisplay()
|
||||
{
|
||||
$('<img/>').attr('src', $('#carrier_logo_img').attr('src')).load(function(){
|
||||
var maxHeight = 200;
|
||||
var maxWidth = 200;
|
||||
var res = this.width / this.height;
|
||||
$('#carrier_logo_size').text(this.width + 'x' + this.height + ' px');
|
||||
$('#carrier_logo_img').width(this.width);
|
||||
$('#carrier_logo_img').height(this.height);
|
||||
if ($('#carrier_logo_img').width() > maxWidth)
|
||||
{
|
||||
$('#carrier_logo_img').width(maxWidth);
|
||||
$('#carrier_logo_img').height(maxWidth / res);
|
||||
}
|
||||
if ($('#carrier_logo_img').height() > maxHeight)
|
||||
{
|
||||
$('#carrier_logo_img').height(maxHeight);
|
||||
$('#carrier_logo_img').width(maxHeight * res);
|
||||
}
|
||||
if ($('#logo').val() == 'null')
|
||||
$('#carrier_logo_size').text(carrier_translation_undefined);
|
||||
});
|
||||
}
|
||||
|
||||
fixCarrierLogoDisplay();
|
||||
</script>
|
||||
@@ -0,0 +1,63 @@
|
||||
{*
|
||||
* 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
|
||||
*}
|
||||
|
||||
<script type="text/javascript">
|
||||
var summary_translation_undefined = '{l s='[undefined]' js='1'}';
|
||||
|
||||
var summary_translation_meta_informations = '{l s='This carrier is @s1 and display to the customers the following delay: @s2.' js='1'}';
|
||||
var summary_translation_free = '<strong>{l s='free' js='1'}</strong>';
|
||||
var summary_translation_paid = '<strong>{l s='paid' js='1'}</strong>';
|
||||
|
||||
var summary_translation_range = '{l s='This carrier can deliver orders from @s1 to @s2. If the order is out of range, the behavior is to @s3.' js='1'}';
|
||||
|
||||
var summary_translation_shipping_cost = '{l s='The shipping cost is calculated @s1 and the tax rule @s2 is applied.' js='1'}';
|
||||
var summary_translation_price = '<strong>{l s='according to the price' js='1'}</strong>';
|
||||
var summary_translation_weight = '<strong>{l s='according to the weight' js='1'}</strong>';
|
||||
</script>
|
||||
|
||||
<fieldset>
|
||||
{l s='Carrier name:'} <strong id="summary_name"></strong>
|
||||
<div class="clear"> </div>
|
||||
<div id="summary_meta_informations"></div>
|
||||
<div class="clear"> </div>
|
||||
<div id="summary_shipping_cost"></div>
|
||||
<div class="clear"> </div>
|
||||
<div id="summary_range"></div>
|
||||
<div class="clear"> </div>
|
||||
<div>
|
||||
{l s='It will be displayed only for the following zones:'}
|
||||
<ul id="summary_zones"></ul>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
<div>
|
||||
{l s='It will be displayed only for the following groups:'}
|
||||
<ul id="summary_groups"></ul>
|
||||
</div>
|
||||
<div class="clear"> </div>
|
||||
<div>
|
||||
{l s='It will be displayed only for the following shops:'}
|
||||
<ul id="summary_shops"></ul>
|
||||
</div>
|
||||
</fieldset>
|
||||
@@ -0,0 +1,40 @@
|
||||
{*
|
||||
* 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
|
||||
*}
|
||||
|
||||
{extends file="helpers/list/list_content.tpl"}
|
||||
{block name="open_td"}
|
||||
<td
|
||||
{if isset($params.position)}
|
||||
id="td_{if !empty($id_category)}{$id_category}{else}0{/if}_{$tr.$identifier}"
|
||||
{/if}
|
||||
class="{if !$no_link}pointer{/if}
|
||||
{if isset($params.position) && $order_by == 'position' && $order_way != 'DESC'} dragHandle{/if}
|
||||
{if isset($params.align)} {$params.align}{/if}"
|
||||
{if (!isset($params.position) && !$no_link && !isset($params.remove_onclick))}
|
||||
onclick="document.location = '{$link->getAdminLink('AdminCarrierWizard', true)}&{$identifier}={$tr.$identifier}'">
|
||||
{else}
|
||||
>
|
||||
{/if}
|
||||
{/block}
|
||||
@@ -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>
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
{if isset($fields.title)}<h2>{$fields.title}</h2>{/if}
|
||||
{block name="defaultForm"}
|
||||
<form id="{$table}_form" class="defaultForm {$name_controller}" action="{$current}&{if !empty($submit_action)}{$submit_action}=1{/if}&token={$token}" method="post" enctype="multipart/form-data" {if isset($style)}style="{$style}"{/if}>
|
||||
<form id="{if isset($fields.form.form.id_form)}{$fields.form.form.id_form|escape:'htmlall':'UTF-8'}{else}{$table}_form{/if}" class="defaultForm {$name_controller}" action="{$current}&{if !empty($submit_action)}{$submit_action}=1{/if}&token={$token}" method="post" enctype="multipart/form-data" {if isset($style)}style="{$style}"{/if}>
|
||||
{if $form_id}
|
||||
<input type="hidden" name="{$identifier}" id="{$identifier}" value="{$form_id}" />
|
||||
{/if}
|
||||
|
||||
@@ -165,6 +165,14 @@ class CarrierCore extends ObjectModel
|
||||
public function __construct($id = null, $id_lang = null)
|
||||
{
|
||||
parent::__construct($id, $id_lang);
|
||||
|
||||
/**
|
||||
* keep retrocompatibility SHIPPING_METHOD_DEFAULT
|
||||
* @deprecated 1.5.5
|
||||
*/
|
||||
if ($this->shipping_method == Carrier::SHIPPING_METHOD_DEFAULT)
|
||||
$this->shipping_method = ((int)Configuration::get('PS_SHIPPING_METHOD') ? Carrier::SHIPPING_METHOD_WEIGHT : Carrier::SHIPPING_METHOD_PRICE);
|
||||
|
||||
/**
|
||||
* keep retrocompatibility id_tax_rules_group
|
||||
* @deprecated 1.5.0
|
||||
@@ -370,13 +378,12 @@ class CarrierCore extends ObjectModel
|
||||
*/
|
||||
public static function getDeliveryPriceByRanges($range_table, $id_carrier)
|
||||
{
|
||||
$range_table = pSQL($range_table);
|
||||
$sql = 'SELECT d.id_'.$range_table.', d.id_carrier, d.id_zone, d.price
|
||||
$sql = 'SELECT d.`id_'.bqSQL($range_table).'`, d.id_carrier, d.id_zone, d.price
|
||||
FROM '._DB_PREFIX_.'delivery d
|
||||
LEFT JOIN '._DB_PREFIX_.$range_table.' r ON r.id_'.$range_table.' = d.id_'.$range_table.'
|
||||
LEFT JOIN `'._DB_PREFIX_.bqSQL($range_table).'` r ON r.`id_'.bqSQL($range_table).'` = d.`id_'.bqSQL($range_table).'`
|
||||
WHERE d.id_carrier = '.(int)$id_carrier.'
|
||||
AND d.id_'.$range_table.' IS NOT NULL
|
||||
AND d.id_'.$range_table.' != 0
|
||||
AND d.`id_'.bqSQL($range_table).'` IS NOT NULL
|
||||
AND d.`id_'.bqSQL($range_table).'` != 0
|
||||
'.Carrier::sqlDeliveryRangeShop($range_table).'
|
||||
ORDER BY r.delimiter1';
|
||||
return Db::getInstance()->executeS($sql);
|
||||
@@ -456,6 +463,22 @@ class CarrierCore extends ObjectModel
|
||||
return $carriers;
|
||||
}
|
||||
|
||||
public static function getIdTaxRulesGroupMostUsed()
|
||||
{
|
||||
return Db::getInstance()->getValue('
|
||||
SELECT id_tax_rules_group
|
||||
FROM (
|
||||
SELECT COUNT(*) n, c.id_tax_rules_group
|
||||
FROM '._DB_PREFIX_.'carrier c
|
||||
JOIN '._DB_PREFIX_.'tax_rules_group trg ON (c.id_tax_rules_group = trg.id_tax_rules_group)
|
||||
WHERE trg.active = 1
|
||||
GROUP BY c.id_tax_rules_group
|
||||
ORDER BY n DESC
|
||||
LIMIT 1
|
||||
) most_used'
|
||||
);
|
||||
}
|
||||
|
||||
public static function getDeliveredCountries($id_lang, $active_countries = false, $active_carriers = false, $contain_states = null)
|
||||
{
|
||||
if (!Validate::isBool($active_countries) || !Validate::isBool($active_carriers))
|
||||
@@ -712,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';
|
||||
@@ -912,9 +935,11 @@ class CarrierCore extends ObjectModel
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getRangeObject()
|
||||
public function getRangeObject($shipping_method = false)
|
||||
{
|
||||
$shipping_method = $this->getShippingMethod();
|
||||
if (!$shipping_method)
|
||||
$shipping_method = $this->getShippingMethod();
|
||||
|
||||
if ($shipping_method == Carrier::SHIPPING_METHOD_WEIGHT)
|
||||
return new RangeWeight();
|
||||
elseif ($shipping_method == Carrier::SHIPPING_METHOD_PRICE)
|
||||
@@ -1032,9 +1057,9 @@ class CarrierCore extends ObjectModel
|
||||
$sql = 'AND '.$alias.'.id_delivery = (
|
||||
SELECT d2.id_delivery
|
||||
FROM '._DB_PREFIX_.'delivery d2
|
||||
WHERE d2.id_carrier = '.$alias.'.id_carrier
|
||||
AND d2.id_zone = '.$alias.'.id_zone
|
||||
AND d2.id_'.$range_table.' = '.$alias.'.id_'.$range_table.'
|
||||
WHERE d2.id_carrier = `'.bqSQL($alias).'`.id_carrier
|
||||
AND d2.id_zone = `'.bqSQL($alias).'`.id_zone
|
||||
AND d2.`id_'.bqSQL($range_table).'` = `'.bqSQL($alias).'`.`id_'.bqSQL($range_table).'`
|
||||
'.$where.'
|
||||
ORDER BY d2.id_shop DESC, d2.id_shop_group DESC
|
||||
LIMIT 1
|
||||
|
||||
@@ -1632,4 +1632,4 @@ abstract class ObjectModelCore
|
||||
{
|
||||
$this->update_fields = $fields;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1286,7 +1286,7 @@ class AdminControllerCore extends Controller
|
||||
$current_id = Tab::getCurrentParentId();
|
||||
foreach ($tabs as $index => $tab)
|
||||
{
|
||||
if ($tab['class_name'] == 'AdminStock' && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 0)
|
||||
if (($tab['class_name'] == 'AdminStock' && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') == 0) || $tab['class_name'] == 'AdminCarrierWizard')
|
||||
{
|
||||
unset($tabs[$index]);
|
||||
continue;
|
||||
@@ -1326,7 +1326,7 @@ class AdminControllerCore extends Controller
|
||||
foreach ($sub_tabs as $index2 => $sub_tab)
|
||||
{
|
||||
// class_name is the name of the class controller
|
||||
if (Tab::checkTabRights($sub_tab['id_tab']) === true && (bool)$sub_tab['active'])
|
||||
if (Tab::checkTabRights($sub_tab['id_tab']) === true && (bool)$sub_tab['active'] && $sub_tab['class_name'] != 'AdminCarrierWizard')
|
||||
{
|
||||
$sub_tabs[$index2]['href'] = $this->context->link->getAdminLink($sub_tab['class_name']);
|
||||
$sub_tabs[$index2]['current'] = ($sub_tab['class_name'].'Controller' == get_class($this));
|
||||
|
||||
@@ -254,7 +254,7 @@ class OrderCore extends ObjectModel
|
||||
public function __construct($id = null, $id_lang = null)
|
||||
{
|
||||
parent::__construct($id, $id_lang);
|
||||
|
||||
|
||||
$is_admin = (is_object(Context::getContext()->controller) && Context::getContext()->controller->controller_type == 'admin');
|
||||
if ($this->id_customer && !$is_admin)
|
||||
{
|
||||
|
||||
817
controllers/admin/AdminCarrierWizardController.php
Normal file
817
controllers/admin/AdminCarrierWizardController.php
Normal file
@@ -0,0 +1,817 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
class AdminCarrierWizardControllerCore extends AdminController
|
||||
{
|
||||
protected $wizard_access;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->display = 'view';
|
||||
$this->table = 'carrier';
|
||||
$this->identifier = 'id_carrier';
|
||||
$this->className = 'Carrier';
|
||||
$this->lang = false;
|
||||
$this->deleted = true;
|
||||
$this->step_number = 0;
|
||||
|
||||
$this->fieldImageSettings = array(
|
||||
'name' => 'logo',
|
||||
'dir' => 's'
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->wizard_access = Profile::getProfileAccess($this->context->employee->id_profile, Tab::getIdFromClassName('AdminCarrierWizard'));
|
||||
}
|
||||
|
||||
public function setMedia()
|
||||
{
|
||||
parent::setMedia();
|
||||
$this->addJqueryPlugin('smartWizard');
|
||||
$this->addJs(_PS_JS_DIR_.'admin_carrier_wizard.js');
|
||||
}
|
||||
|
||||
public function initWizard()
|
||||
{
|
||||
$this->wizard_steps = array(
|
||||
'name' => 'carrier_wizard',
|
||||
'steps' => array(
|
||||
array(
|
||||
'title' => $this->l('General'),
|
||||
'desc' => $this->l('General'),
|
||||
),
|
||||
array(
|
||||
'title' => $this->l('Where and how much ?'),
|
||||
'desc' => $this->l('Where and how much ?'),
|
||||
),
|
||||
array(
|
||||
'title' => $this->l('What and to who ?'),
|
||||
'desc' => $this->l('What and to who ?'),
|
||||
),
|
||||
array(
|
||||
'title' => $this->l('Resume'),
|
||||
'desc' => $this->l('Resume'),
|
||||
),
|
||||
|
||||
));
|
||||
|
||||
if (Shop::isFeatureActive())
|
||||
{
|
||||
$multistore_step = array(
|
||||
array(
|
||||
'title' => $this->l('MultiStore'),
|
||||
'desc' => $this->l('MultiStore'),
|
||||
)
|
||||
);
|
||||
array_splice($this->wizard_steps['steps'], 1, 0, $multistore_step);
|
||||
}
|
||||
}
|
||||
|
||||
public function renderView()
|
||||
{
|
||||
$this->initWizard();
|
||||
|
||||
if (Tools::getValue('id_carrier') && $this->wizard_access['edit'])
|
||||
$carrier = $this->loadObject();
|
||||
elseif ($this->wizard_access['add'])
|
||||
$carrier = new Carrier();
|
||||
else
|
||||
{
|
||||
$this->errors[] = Tools::displayError('You do not have permission to use this wizard.');
|
||||
return ;
|
||||
}
|
||||
|
||||
$this->tpl_view_vars = array(
|
||||
'enableAllSteps' => Validate::isLoadedObject($carrier),
|
||||
'wizard_steps' => $this->wizard_steps,
|
||||
'validate_url' => $this->context->link->getAdminLink('AdminCarrierWizard'),
|
||||
'carrierlist_url' => $this->context->link->getAdminLink('AdminCarriers').'&conf='.((int)Validate::isLoadedObject($carrier) ? 4 : 3),
|
||||
'wizard_contents' => array(
|
||||
'contents' => array(
|
||||
0 => $this->renderStepOne($carrier),
|
||||
1 => $this->renderStepThree($carrier),
|
||||
2 => $this->renderStepFour($carrier),
|
||||
3 => $this->renderStepFive(),
|
||||
)),
|
||||
'labels' => array('next' => $this->l('Next'), 'previous' => $this->l('Previous'), 'finish' => $this->l('Finish'))
|
||||
);
|
||||
|
||||
if (Shop::isFeatureActive())
|
||||
array_splice($this->tpl_view_vars['wizard_contents']['contents'], 1, 0, array(0 => $this->renderStepTwo($carrier)));
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'max_image_size' => (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE') / 1024 / 1024,
|
||||
'carrier_logo' => (Validate::isLoadedObject($carrier) && file_exists(_PS_SHIP_IMG_DIR_.$carrier->id.'.jpg') ? _THEME_SHIP_DIR_.$carrier->id.'.jpg' : false)
|
||||
));
|
||||
$this->content .= $this->createTemplate('logo.tpl')->fetch();
|
||||
$this->addjQueryPlugin(array('ajaxfileupload'));
|
||||
|
||||
return parent::renderView();
|
||||
}
|
||||
|
||||
public function initToolbarTitle()
|
||||
{
|
||||
$bread_extended = array_unique($this->breadcrumbs);
|
||||
|
||||
if (Tools::getValue('id_carrier'))
|
||||
$bread_extended[1] = $this->l('Edit');
|
||||
else
|
||||
$bread_extended[1] = $this->l('Add new');
|
||||
|
||||
$this->toolbar_title = $bread_extended;
|
||||
}
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
parent::initToolbar();
|
||||
$this->toolbar_btn['back']['href'] = $this->context->link->getAdminLink('AdminCarriers');
|
||||
}
|
||||
|
||||
public function renderStepOne($carrier)
|
||||
{
|
||||
$this->fields_form = array(
|
||||
'form' => array(
|
||||
'id_form' => 'step_carrier_general',
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Company:'),
|
||||
'name' => 'name',
|
||||
'size' => 25,
|
||||
'required' => true,
|
||||
'hint' => sprintf($this->l('Allowed characters: letters, spaces and %s'), '().-'),
|
||||
'desc' => array(
|
||||
$this->l('Carrier name displayed during checkout'),
|
||||
$this->l('For in-store pickup, enter 0 to replace the carrier name with your shop name.')
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Transit time:'),
|
||||
'name' => 'delay',
|
||||
'lang' => true,
|
||||
'required' => true,
|
||||
'size' => 41,
|
||||
'maxlength' => 128,
|
||||
'desc' => $this->l('Estimated delivery time will be displayed during checkout.')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Speed Grade:'),
|
||||
'name' => 'grade',
|
||||
'required' => false,
|
||||
'size' => 1,
|
||||
'desc' => $this->l('Enter "0" for a longest shipping delay, or "9" for the shortest shipping delay.')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('URL:'),
|
||||
'name' => 'url',
|
||||
'size' => 40,
|
||||
'desc' => $this->l('Delivery tracking URL: Type \'@\' where the tracking number should appear. It will then be automatically replaced by the tracking number.')
|
||||
),
|
||||
)),
|
||||
);
|
||||
|
||||
$fields_value = $this->getStepOneFieldsValues($carrier);
|
||||
return $this->renderGenericForm(array('form' => $this->fields_form), $fields_value);
|
||||
}
|
||||
|
||||
public function renderStepTwo($carrier)
|
||||
{
|
||||
$this->fields_form = array(
|
||||
'form' => array(
|
||||
'id_form' => 'step_carrier_shops',
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'shop',
|
||||
'label' => $this->l('Shop association:'),
|
||||
'name' => 'checkBoxShopAsso',
|
||||
),
|
||||
))
|
||||
);
|
||||
$fields_value = $this->getStepTwoFieldsValues($carrier);
|
||||
return $this->renderGenericForm(array('form' => $this->fields_form), $fields_value);
|
||||
}
|
||||
|
||||
public function renderStepThree($carrier)
|
||||
{
|
||||
$this->fields_form = array(
|
||||
'form' => array(
|
||||
'id_form' => 'step_carrier_ranges',
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Apply shipping cost:'),
|
||||
'name' => 'is_free',
|
||||
'required' => false,
|
||||
'class' => 't',
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'is_free_off',
|
||||
'value' => 0,
|
||||
'label' => '<img src="../img/admin/enabled.gif" alt="'.$this->l('Yes').'" title="'.$this->l('Yes').'" />'
|
||||
),
|
||||
array(
|
||||
'id' => 'is_free_on',
|
||||
'value' => 1,
|
||||
'label' => '<img src="../img/admin/disabled.gif" alt="'.$this->l('No').'" title="'.$this->l('No').'" />'
|
||||
)
|
||||
),
|
||||
'desc' => $this->l('Apply both regular shipping cost and product-specific shipping costs.')
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Shipping and handling:'),
|
||||
'name' => 'shipping_handling',
|
||||
'required' => false,
|
||||
'class' => 't',
|
||||
'is_bool' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'shipping_handling_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'shipping_handling_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
'desc' => $this->l('Include the shipping and handling costs in the carrier price.')
|
||||
),
|
||||
array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Billing:'),
|
||||
'name' => 'shipping_method',
|
||||
'required' => false,
|
||||
'class' => 't',
|
||||
'br' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'billing_price',
|
||||
'value' => Carrier::SHIPPING_METHOD_PRICE,
|
||||
'label' => $this->l('According to total price')
|
||||
),
|
||||
array(
|
||||
'id' => 'billing_weight',
|
||||
'value' => Carrier::SHIPPING_METHOD_WEIGHT,
|
||||
'label' => $this->l('According to total weight')
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Tax:'),
|
||||
'name' => 'id_tax_rules_group',
|
||||
'options' => array(
|
||||
'query' => TaxRulesGroup::getTaxRulesGroups(true),
|
||||
'id' => 'id_tax_rules_group',
|
||||
'name' => 'name',
|
||||
'default' => array(
|
||||
'label' => $this->l('No Tax'),
|
||||
'value' => 0
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'zone',
|
||||
'name' => 'zones'
|
||||
)
|
||||
)
|
||||
));
|
||||
|
||||
$tpl_vars = array();
|
||||
$fields_value = $this->getStepThreeFieldsValues($carrier);
|
||||
|
||||
$this->getTplRangesVarsAndValues($carrier, &$tpl_vars, &$fields_value);
|
||||
return $this->renderGenericForm(array('form' => $this->fields_form), $fields_value, $tpl_vars);
|
||||
}
|
||||
|
||||
protected function getTplRangesVarsAndValues($carrier, $tpl_vars, $fields_value)
|
||||
{
|
||||
$tpl_vars['zones'] = Zone::getZones(false);
|
||||
$carrier_zones = $carrier->getZones();
|
||||
$carrier_zones_ids = array();
|
||||
if (is_array($carrier_zones))
|
||||
foreach ($carrier_zones as $carrier_zone)
|
||||
$carrier_zones_ids[] = $carrier_zone['id_zone'];
|
||||
|
||||
|
||||
$shipping_method = $carrier->getShippingMethod();
|
||||
if ($shipping_method == Carrier::SHIPPING_METHOD_FREE)
|
||||
{
|
||||
$range_table = array();
|
||||
$range_obj = $carrier->getRangeObject($carrier->shipping_method);
|
||||
$price_by_range = array();
|
||||
}
|
||||
else
|
||||
{
|
||||
$range_table = $carrier->getRangeTable();
|
||||
$range_obj = $carrier->getRangeObject();
|
||||
$price_by_range = Carrier::getDeliveryPriceByRanges($range_table, (int)$carrier->id);
|
||||
|
||||
}
|
||||
$zones = Zone::getZones(false);
|
||||
foreach ($zones as $zone)
|
||||
$fields_value['zones'][$zone['id_zone']] = Tools::getValue('zone_'.$zone['id_zone'], (in_array($zone['id_zone'], $carrier_zones_ids)));
|
||||
|
||||
foreach ($price_by_range as $price)
|
||||
$tpl_vars['price_by_range'][$price['id_'.$range_table]][$price['id_zone']] = $price['price'];
|
||||
|
||||
$tmp_range = $range_obj->getRanges((int)$carrier->id);
|
||||
$tpl_vars['ranges'] = array();
|
||||
foreach ($tmp_range as $id => $range)
|
||||
{
|
||||
$tpl_vars['ranges'][$range['id_'.$range_table]] = $range;
|
||||
$tpl_vars['ranges'][$range['id_'.$range_table]]['id_range'] = $range['id_'.$range_table];
|
||||
}
|
||||
|
||||
// init blank range
|
||||
if (!count($tpl_vars['ranges']))
|
||||
$tpl_vars['ranges'][] = array('id_range' => -1, 'delimiter1' => 0, 'delimiter2' => 100000);
|
||||
}
|
||||
|
||||
public function renderStepFour($carrier)
|
||||
{
|
||||
$this->fields_form = array(
|
||||
'form' => array(
|
||||
'id_form' => 'step_carrier_conf',
|
||||
'input' => array(
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Out-of-range behavior:'),
|
||||
'name' => 'range_behavior',
|
||||
'options' => array(
|
||||
'query' => array(
|
||||
array(
|
||||
'id' => 0,
|
||||
'name' => $this->l('Apply the cost of the highest defined range')
|
||||
),
|
||||
array(
|
||||
'id' => 1,
|
||||
'name' => $this->l('Disable carrier')
|
||||
)
|
||||
),
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
),
|
||||
'desc' => $this->l('Out-of-range behavior occurs when none is defined (e.g. when a customer\'s cart weight is greater than the highest range limit)')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Maximium package height:'),
|
||||
'name' => 'max_height',
|
||||
'required' => false,
|
||||
'size' => 10,
|
||||
'desc' => $this->l('Maximum height managed by this carrier. Set the value to "0," or leave this field blank to ignore.')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Maximium package width:'),
|
||||
'name' => 'max_width',
|
||||
'required' => false,
|
||||
'size' => 10,
|
||||
'desc' => $this->l('Maximum width managed by this carrier. Set the value to "0," or leave this field blank to ignore.')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Maximium package depth:'),
|
||||
'name' => 'max_depth',
|
||||
'required' => false,
|
||||
'size' => 10,
|
||||
'desc' => $this->l('Maximum depth managed by this carrier. Set the value to "0," or leave this field blank to ignore.')
|
||||
),
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Maximium package weight:'),
|
||||
'name' => 'max_weight',
|
||||
'required' => false,
|
||||
'size' => 10,
|
||||
'desc' => $this->l('Maximum weight managed by this carrier. Set the value to "0," or leave this field blank to ignore.')
|
||||
),
|
||||
array(
|
||||
'type' => 'group',
|
||||
'label' => $this->l('Group access:'),
|
||||
'name' => 'groupBox',
|
||||
'values' => Group::getGroups(Context::getContext()->language->id),
|
||||
'desc' => $this->l('Mark the groups that are allowed access to this carrier.')
|
||||
)
|
||||
)
|
||||
));
|
||||
$fields_value = $this->getStepFourFieldsValues($carrier);
|
||||
|
||||
|
||||
// Added values of object Group
|
||||
$carrier_groups = $carrier->getGroups();
|
||||
$carrier_groups_ids = array();
|
||||
if (is_array($carrier_groups))
|
||||
foreach ($carrier_groups as $carrier_group)
|
||||
$carrier_groups_ids[] = $carrier_group['id_group'];
|
||||
|
||||
$groups = Group::getGroups($this->context->language->id);
|
||||
|
||||
foreach ($groups as $group)
|
||||
$fields_value['groupBox_'.$group['id_group']] = Tools::getValue('groupBox_'.$group['id_group'], (in_array($group['id_group'], $carrier_groups_ids) || empty($carrier_groups_ids) && !$carrier->id));
|
||||
|
||||
return $this->renderGenericForm(array('form' => $this->fields_form), $fields_value);
|
||||
}
|
||||
|
||||
public function renderStepFive()
|
||||
{
|
||||
return $this->context->smarty->fetch('controllers/carrier_wizard/summary.tpl');
|
||||
}
|
||||
|
||||
public function renderGenericForm($fields_form, $fields_value, $tpl_vars = array())
|
||||
{
|
||||
$helper = new HelperForm();
|
||||
$helper->show_toolbar = false;
|
||||
$helper->table = $this->table;
|
||||
$helper->default_form_language = $this->context->language->id;
|
||||
$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
|
||||
$this->fields_form = array();
|
||||
$helper->id = (int)Tools::getValue('id_carrier');
|
||||
$helper->identifier = $this->identifier;
|
||||
$helper->tpl_vars = array_merge(array(
|
||||
'fields_value' => $fields_value,
|
||||
'languages' => $this->getLanguages(),
|
||||
'id_language' => $this->context->language->id
|
||||
), $tpl_vars);
|
||||
$helper->override_folder = 'carrier_wizard/';
|
||||
|
||||
return $helper->generateForm($fields_form);
|
||||
}
|
||||
|
||||
public function getStepOneFieldsValues($carrier)
|
||||
{
|
||||
return array(
|
||||
'id_carrier' => $this->getFieldValue($carrier, 'id_carrier'),
|
||||
'name' => $this->getFieldValue($carrier, 'name'),
|
||||
'delay' => $this->getFieldValue($carrier, 'delay'),
|
||||
'grade' => $this->getFieldValue($carrier, 'grade'),
|
||||
'url' => $this->getFieldValue($carrier, 'url'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getStepTwoFieldsValues($carrier)
|
||||
{
|
||||
return array('shop' => $this->getFieldValue($carrier, 'shop'));
|
||||
|
||||
}
|
||||
|
||||
public function getStepThreeFieldsValues($carrier)
|
||||
{
|
||||
$id_tax_rules_group = (is_object($this->object) && !$this->object->id) ? Carrier::getIdTaxRulesGroupMostUsed() : $this->getFieldValue($carrier, 'id_tax_rules_group');
|
||||
|
||||
return array(
|
||||
'is_free' => $this->getFieldValue($carrier, 'is_free'),
|
||||
'id_tax_rules_group' => (int)$id_tax_rules_group,
|
||||
'shipping_handling' => $this->getFieldValue($carrier, 'shipping_handling'),
|
||||
'shipping_method' => $this->getFieldValue($carrier, 'shipping_method'),
|
||||
'range_behavior' => $this->getFieldValue($carrier, 'range_behavior'),
|
||||
'zones' => $this->getFieldValue($carrier, 'zones'),
|
||||
);
|
||||
}
|
||||
|
||||
public function getStepFourFieldsValues($carrier)
|
||||
{
|
||||
return array(
|
||||
'range_behavior' => $this->getFieldValue($carrier, 'shop'),
|
||||
'max_height' => $this->getFieldValue($carrier, 'max_height'),
|
||||
'max_width' => $this->getFieldValue($carrier, 'max_width'),
|
||||
'max_depth' => $this->getFieldValue($carrier, 'max_depth'),
|
||||
'max_weight' => $this->getFieldValue($carrier, 'max_weight'),
|
||||
'group' => $this->getFieldValue($carrier, 'group'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function ajaxProcessChangeRanges()
|
||||
{
|
||||
if ((Validate::isLoadedObject($this->object) && !$this->wizard_access['edit']) || !$this->wizard_access['add'])
|
||||
{
|
||||
$this->errors[] = Tools::displayError('You do not have permission to use this wizard.');
|
||||
return;
|
||||
}
|
||||
if ((!(int)$shipping_method = Tools::getValue('shipping_method')) || !in_array($shipping_method, array(Carrier::SHIPPING_METHOD_PRICE, Carrier::SHIPPING_METHOD_WEIGHT)))
|
||||
return ;
|
||||
|
||||
$carrier = $this->loadObject(true);
|
||||
$carrier->shipping_method = $shipping_method;
|
||||
|
||||
$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());
|
||||
}
|
||||
|
||||
public function ajaxProcessValidateStep()
|
||||
{
|
||||
$step_number = (int)Tools::getValue('step_number');
|
||||
$return = array('has_error' => false);
|
||||
|
||||
if (!$this->wizard_access['edit'])
|
||||
$this->errors[] = Tools::displayError('You do not have permission to use this wizard.');
|
||||
else
|
||||
{
|
||||
|
||||
if (Shop::isFeatureActive() && $step_number == 2)
|
||||
{
|
||||
if (!Tools::getValue('checkBoxShopAsso_carrier'))
|
||||
{
|
||||
$return['has_error'] = true;
|
||||
$return['errors'][] = $this->l('You must choose at least one shop or group shop.');
|
||||
}
|
||||
}
|
||||
else
|
||||
$this->validateRules('AdminCarrierWizardControllerCore');
|
||||
}
|
||||
|
||||
if (count($this->errors))
|
||||
{
|
||||
$return['has_error'] = true;
|
||||
$return['errors'] = $this->errors;
|
||||
}
|
||||
die(Tools::jsonEncode($return));
|
||||
}
|
||||
|
||||
public function processRanges($id_carrier)
|
||||
{
|
||||
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 => $delimiter1)
|
||||
{
|
||||
if (!isset($range_sup[$key]))
|
||||
continue;
|
||||
|
||||
if ($range_type == Carrier::SHIPPING_METHOD_WEIGHT)
|
||||
$range = new RangeWeight((int)$key);
|
||||
if ($range_type == Carrier::SHIPPING_METHOD_PRICE)
|
||||
$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()
|
||||
{
|
||||
if (!$this->wizard_access['edit'])
|
||||
die('<return result="error" message="'.Tools::displayError('You do not have permission to use this wizard.').'" />');
|
||||
|
||||
$allowedExtensions = array('jpeg', 'gif', 'png', 'jpg');
|
||||
|
||||
$logo = (isset($_FILES['carrier_logo_input']) ? $_FILES['carrier_logo_input'] : false);
|
||||
if ($logo && !empty($logo['tmp_name']) && $logo['tmp_name'] != 'none'
|
||||
&& (!isset($logo['error']) || !$logo['error'])
|
||||
&& preg_match('/\.(jpe?g|gif|png)$/', $logo['name'])
|
||||
&& is_uploaded_file($logo['tmp_name']))
|
||||
{
|
||||
$file = $logo['tmp_name'];
|
||||
do $tmp_name = uniqid().'.jpg';
|
||||
while (file_exists(_PS_TMP_IMG_DIR_.$tmp_name));
|
||||
if (!ImageManager::resize($file, _PS_TMP_IMG_DIR_.$tmp_name))
|
||||
die('<return result="error" message="Impossible to resize the image into '.Tools::safeOutput(_PS_TMP_IMG_DIR_).'" />');
|
||||
@unlink($file);
|
||||
die('<return result="success" message="'.Tools::safeOutput(_PS_TMP_IMG_.$tmp_name).'" />');
|
||||
}
|
||||
else
|
||||
die('<return result="error" message="Cannot upload file" />');
|
||||
}
|
||||
|
||||
public function ajaxProcessFinishStep()
|
||||
{
|
||||
$return = array('has_error' => false);
|
||||
|
||||
if (!$this->wizard_access['edit'])
|
||||
$return = array(
|
||||
'has_error' => true,
|
||||
$return['errors'][] = Tools::displayError('You do not have permission to use this wizard.')
|
||||
);
|
||||
else
|
||||
{
|
||||
|
||||
if ($id_carrier = Tools::getValue('id_carrier'))
|
||||
{
|
||||
$current_carrier = new Carrier((int)$id_carrier);
|
||||
// if update we duplicate current Carrier
|
||||
$carrier = $current_carrier->duplicateObject();
|
||||
if (Validate::isLoadedObject($carrier))
|
||||
{
|
||||
// Set flag deteled to true for historization
|
||||
$current_carrier->deleted = true;
|
||||
$current_carrier->update();
|
||||
|
||||
// Fill the new carrier object
|
||||
$this->copyFromPost($carrier, $this->table);
|
||||
$carrier->position = $current_carrier->position;
|
||||
$carrier->update();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$carrier = new Carrier();
|
||||
$this->copyFromPost($carrier, $this->table);
|
||||
if (!$carrier->add())
|
||||
{
|
||||
$return['has_error'] = true;
|
||||
$return['errors'][] = $this->l('An error occurred while saving this carrier.');
|
||||
}
|
||||
}
|
||||
if (Validate::isLoadedObject($carrier))
|
||||
{
|
||||
if (!$this->changeGroups((int)$carrier->id))
|
||||
{
|
||||
$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'))
|
||||
unlink(_PS_SHIP_IMG_DIR_.$carrier->id.'.jpg');
|
||||
else
|
||||
{
|
||||
$logo = basename(Tools::getValue('logo'));
|
||||
if (!file_exists(_PS_TMP_IMG_DIR_.$logo) || !copy(_PS_TMP_IMG_DIR_.$logo, _PS_SHIP_IMG_DIR_.$carrier->id.'.jpg'))
|
||||
{
|
||||
$return['has_error'] = true;
|
||||
$return['errors'][] = $this->l('An error occurred while saving carrier logo.');
|
||||
}
|
||||
}
|
||||
}
|
||||
$return['id_carrier'] = $carrier->id;
|
||||
}
|
||||
}
|
||||
die(Tools::jsonEncode($return));
|
||||
}
|
||||
|
||||
protected function changeGroups($id_carrier, $delete = true)
|
||||
{
|
||||
if ($delete)
|
||||
Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'carrier_group WHERE id_carrier = '.(int)$id_carrier);
|
||||
$groups = Db::getInstance()->executeS('SELECT id_group FROM `'._DB_PREFIX_.'group`');
|
||||
foreach ($groups as $group)
|
||||
if (Tools::getIsset('groupBox') && in_array($group['id_group'], Tools::getValue('groupBox')))
|
||||
return Db::getInstance()->execute('
|
||||
INSERT INTO '._DB_PREFIX_.'carrier_group (id_group, id_carrier)
|
||||
VALUES('.(int)$group['id_group'].','.(int)$id_carrier.')
|
||||
');
|
||||
}
|
||||
|
||||
public function changeZones($id)
|
||||
{
|
||||
$return = true;
|
||||
$carrier = new Carrier($id);
|
||||
if (!Validate::isLoadedObject($carrier))
|
||||
die (Tools::displayError('The object cannot be loaded.'));
|
||||
$zones = Zone::getZones(false);
|
||||
foreach ($zones as $zone)
|
||||
if (count($carrier->getZone($zone['id_zone'])))
|
||||
{
|
||||
if (!isset($_POST['zone_'.$zone['id_zone']]) || !$_POST['zone_'.$zone['id_zone']])
|
||||
$return &= $carrier->deleteZone($zone['id_zone']);
|
||||
}
|
||||
else
|
||||
if (isset($_POST['zone_'.$zone['id_zone']]) && $_POST['zone_'.$zone['id_zone']])
|
||||
$return &= $carrier->addZone($zone['id_zone']);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function getValidationRules()
|
||||
{
|
||||
$step_number = Tools::getValue('step_number');
|
||||
$step_fields = array(
|
||||
1 => array('name', 'delay', 'grade', 'url'),
|
||||
2 => array('is_free', 'id_tax_rules_group', 'shipping_handling', 'shipping_method', 'range_behavior'),
|
||||
3 => array('range_behavior', 'max_height', 'max_width', 'max_depth', 'max_weight'),
|
||||
);
|
||||
|
||||
if (Shop::isFeatureActive())
|
||||
{
|
||||
$multistore_field = array(array('shop'));
|
||||
$tmp = $step_fields;
|
||||
$step_fields = array(1 => $tmp[1]) + $multistore_field;
|
||||
array_shift($tmp);
|
||||
foreach ($tmp as $row)
|
||||
$step_field[] = $row;
|
||||
}
|
||||
|
||||
$rules = array();
|
||||
|
||||
if ($step_number == 1)
|
||||
$rules = Carrier::getValidationRules('Carrier');
|
||||
|
||||
foreach ($rules as $key_r => $rule)
|
||||
foreach ($rule as $key_f => $field)
|
||||
{
|
||||
if (in_array($key_r, array('required', 'requiredLang')))
|
||||
{
|
||||
if(!in_array($field, $step_fields[$step_number]))
|
||||
unset($rules[$key_r][$key_f]);
|
||||
}
|
||||
else if(!in_array($key_f, $step_fields[$step_number]))
|
||||
unset($rules[$key_r][$key_f]);
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public static function displayFieldName($field)
|
||||
{
|
||||
return $field;
|
||||
}
|
||||
}
|
||||
@@ -156,33 +156,16 @@ class AdminCarriersControllerCore extends AdminController
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function initToolbar()
|
||||
{
|
||||
parent::initToolbar();
|
||||
|
||||
if (isset($this->toolbar_btn['new']))
|
||||
$this->toolbar_btn['new']['href'] = $this->context->link->getAdminLink('AdminCarrierWizard');
|
||||
}
|
||||
|
||||
public function renderList()
|
||||
{
|
||||
$this->displayInformation(
|
||||
' <b>'.$this->l('How do I create a new carrier?').'</b>
|
||||
<br />
|
||||
<ul>
|
||||
<li>'.$this->l('Click "Add New."').'<br /></li>
|
||||
<li>'.$this->l('Fill in the fields and click "Save."').'</li>
|
||||
<li>'.
|
||||
$this->l('You need to set a price range -- or weight range -- for which the new carrier will be available.').' '.
|
||||
$this->l('Under the "Shipping" menu, click either "Price ranges" or "Weight ranges.".').'
|
||||
</li>
|
||||
<li>'.$this->l('Click "Add New."').'</li>
|
||||
<li>'.
|
||||
$this->l('Select the name of the carrier before defining the price or weight range.').' '.
|
||||
$this->l('For example, the carrier can be made available for a weight range between 0 and 5lbs. Another carrier can have a range between 5 and 10lbs.').'
|
||||
</li>
|
||||
<li>'.$this->l('When you\'re done, click "Save."').'</li>
|
||||
<li>'.$this->l('Click on the "Shipping" menu.').'</li>
|
||||
<li>'.
|
||||
$this->l('You need to set the fees that will be applied for this carrier.').' '.
|
||||
$this->l('At the bottom on the page -- in the "Fees" section -- select the name of the carrier.').'
|
||||
</li>
|
||||
<li>'.$this->l('For each zone, enter a price and then click "Save."').'</li>
|
||||
<li>'.$this->l('You\'re all set! The new carrier will now be displayed to customers.').'</li>
|
||||
</ul>'
|
||||
);
|
||||
$this->_select = 'b.*';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'carrier_lang` b ON a.id_carrier = b.id_carrier'.Shop::addSqlRestrictionOnLang('b').'
|
||||
LEFT JOIN `'._DB_PREFIX_.'carrier_tax_rules_group_shop` ctrgs ON (a.`id_carrier` = ctrgs.`id_carrier`
|
||||
@@ -696,6 +679,11 @@ class AdminCarriersControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function displayEditLink($token = null, $id, $name = null)
|
||||
{
|
||||
return '<a href="'.$this->context->link->getAdminLink('AdminCarrierWizard').'&id_carrier='.(int)$id.'"><img src="../img/admin/edit.gif"/></a>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -68,75 +68,11 @@ class AdminShippingControllerCore extends AdminController
|
||||
<li>'.$this->l('Coupons are not taken into account when calculating free shipping').'</li>
|
||||
</ul>',
|
||||
'submit' => array()
|
||||
),
|
||||
'billing' => array(
|
||||
'title' => $this->l('Billing'),
|
||||
'icon' => 'money',
|
||||
'fields' => array(
|
||||
'PS_SHIPPING_METHOD' => array(
|
||||
'title' => $this->l('Billing'),
|
||||
'cast' => 'intval',
|
||||
'type' => 'radio',
|
||||
'choices' => array(
|
||||
0 => $this->l('According to total price'),
|
||||
1 => $this->l('According to total weight')
|
||||
),
|
||||
'validation' => 'isBool'
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function initContent()
|
||||
{
|
||||
$array_carrier = array();
|
||||
$carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE);
|
||||
foreach ($carriers as $key => $carrier)
|
||||
if ($carrier['is_free'])
|
||||
unset($carriers[$key]);
|
||||
else
|
||||
$array_carrier[] = $carrier['id_carrier'];
|
||||
|
||||
$id_carrier = (int)Tools::getValue('id_carrier');
|
||||
|
||||
if (count($carriers) && isset($array_carrier[0]))
|
||||
{
|
||||
if (!$id_carrier)
|
||||
$id_carrier = (int)$array_carrier[0];
|
||||
|
||||
$carrierSelected = new Carrier((int)$id_carrier);
|
||||
}
|
||||
else
|
||||
$carrierSelected = new Carrier((int)$id_carrier);
|
||||
|
||||
$currency = $this->context->currency;
|
||||
$rangeObj = $carrierSelected->getRangeObject();
|
||||
$rangeTable = $carrierSelected->getRangeTable();
|
||||
$suffix = $carrierSelected->getRangeSuffix();
|
||||
|
||||
$rangeIdentifier = 'id_'.$rangeTable;
|
||||
$ranges = $rangeObj->getRanges($id_carrier);
|
||||
$delivery = Carrier::getDeliveryPriceByRanges($rangeTable, $id_carrier);
|
||||
$deliveryArray = array();
|
||||
foreach ($delivery as $deliv)
|
||||
$deliveryArray[$deliv['id_zone']][$deliv['id_carrier']][$deliv[$rangeIdentifier]] = $deliv['price'];
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'zones' => $carrierSelected->getZones(),
|
||||
'carriers' => $carriers,
|
||||
'ranges' => $ranges,
|
||||
'currency' => $currency,
|
||||
'deliveryArray' => $deliveryArray,
|
||||
'carrierSelected' => $carrierSelected,
|
||||
'id_carrier' => $id_carrier,
|
||||
'suffix' => $suffix,
|
||||
'rangeIdentifier' => $rangeIdentifier,
|
||||
'action_fees' => self::$currentIndex.'&token='.$this->token
|
||||
));
|
||||
|
||||
parent::initContent();
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
|
||||
114
css/admin.css
114
css/admin.css
@@ -2401,3 +2401,117 @@ margin-bottom:7px;
|
||||
min-width: 205px;
|
||||
width: 205px;
|
||||
}
|
||||
|
||||
|
||||
/******************** CSS Carrier Wizard ************************/
|
||||
|
||||
#carrier_wizard.swMain{width: 100%;}
|
||||
#carrier_wizard.swMain ul.anchor{width: 100%;}
|
||||
|
||||
#carrier_wizard.swMain ul.anchor li{
|
||||
margin-bottom:10px;
|
||||
background: transparent url(../img/admin/steps-carrierwizard.png) no-repeat 0 0 !important;
|
||||
border: medium none;
|
||||
padding-left: 0;
|
||||
width:auto;
|
||||
padding-right: 62px;
|
||||
padding-top:0
|
||||
}
|
||||
|
||||
#carrier_wizard.swMain ul.nbr_steps_3 li{min-width: 29.9%;}
|
||||
#carrier_wizard.swMain ul.nbr_steps_4 li{min-width: 21.6%;}
|
||||
#carrier_wizard.swMain ul.nbr_steps_5 li{ min-width: 16.6%;}
|
||||
|
||||
#carrier_wizard.swMain ul.anchor li.disabled{background: transparent url(../img/admin/steps-carrierwizard.png) no-repeat right -64px !important;}
|
||||
#carrier_wizard.swMain ul.anchor li.selected{background: transparent url(../img/admin/steps-carrierwizard.png) no-repeat right -32px !important;}
|
||||
#carrier_wizard.swMain ul.anchor li.done{background: transparent url(../img/admin/steps-carrierwizard.png) no-repeat right 0 !important;}
|
||||
|
||||
#carrier_wizard.swMain ul.anchor li a{
|
||||
padding: 3px 20px;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
min-height: 24px !important;
|
||||
border-radius:0;
|
||||
}
|
||||
|
||||
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { /*** IE10 ***/
|
||||
#carrier_wizard.swMain ul.anchor li a{padding: 3px 19px 3px 19px;}
|
||||
#carrier_wizard.swMain ul.anchor li{padding-right: 60px;}
|
||||
#carrier_wizard.swMain ul.nbr_steps_3 li{ min-width: 30%;}
|
||||
#carrier_wizard.swMain ul.nbr_steps_4 li{ min-width: 21.7%;}
|
||||
#carrier_wizard.swMain ul.nbr_steps_5 li{ min-width: 16.7%;}
|
||||
|
||||
}
|
||||
|
||||
.ie9 #carrier_wizard.swMain ul.anchor li a,
|
||||
.ie8 #carrier_wizard.swMain ul.anchor li a{padding: 3px 19px 3px 19px;}
|
||||
|
||||
.ie9 #carrier_wizard.swMain ul.anchor li,
|
||||
.ie8 #carrier_wizard.swMain ul.anchor li,
|
||||
.ie7 #carrier_wizard.swMain ul.anchor li{padding-right: 60px;}
|
||||
|
||||
.ie7 #carrier_wizard.swMain ul.anchor li a{padding: 3px 19px 3px 19px;}
|
||||
|
||||
.ie9 #carrier_wizard.swMain ul.nbr_steps_3 li,
|
||||
.ie8 #carrier_wizard.swMain ul.nbr_steps_3 li{ min-width: 30%;}
|
||||
|
||||
.ie9 #carrier_wizard.swMain ul.nbr_steps_4 li,
|
||||
.ie8 #carrier_wizard.swMain ul.nbr_steps_4 li{ min-width: 21.7%;}
|
||||
|
||||
.ie9 #carrier_wizard.swMain ul.nbr_steps_5 li,
|
||||
.ie8 #carrier_wizard.swMain ul.nbr_steps_5 li{ min-width: 16.7%;}
|
||||
|
||||
|
||||
.ie7 #carrier_wizard.swMain ul.nbr_steps_3 li{ width: 312px;}
|
||||
.ie7 #carrier_wizard.swMain ul.nbr_steps_4 li{ width: 312px;}
|
||||
.ie7 #carrier_wizard.swMain ul.nbr_steps_5 li{ width: 312px;}
|
||||
|
||||
|
||||
#carrier_wizard.swMain ul.anchor li a.disabled {
|
||||
background: #CCCCCC;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
#carrier_wizard.swMain ul.anchor li a.selected,
|
||||
#carrier_wizard.swMain ul.anchor li a.done,
|
||||
#carrier_wizard.swMain ul.anchor li a.error {
|
||||
background: #414A56 !important;
|
||||
border: none !important;
|
||||
box-shadow: none;
|
||||
color: #ffffff;
|
||||
cursor: text;
|
||||
margin:0
|
||||
}
|
||||
|
||||
|
||||
#carrier_wizard.swMain ul.anchor li a .stepNumber {font: bold 23px/21px Verdana,Arial,Helvetica,sans-serif;color: #747C88;padding-bottom: 0;}
|
||||
#carrier_wizard.swMain ul.anchor li a.selected .stepNumber{color: #ffffff;}
|
||||
#carrier_wizard.swMain ul.anchor li a.done .stepNumber {color: #A9B6C8;text-shadow: none;}
|
||||
|
||||
#carrier_wizard.swMain ul.anchor li a .stepDesc {
|
||||
font: bold 13px/12px Verdana,Arial,Helvetica,sans-serif;
|
||||
color: #747C88;
|
||||
padding:0 5px;
|
||||
cursor:pointer
|
||||
}
|
||||
#carrier_wizard.swMain ul.anchor li a.selected .stepDesc{color: #ffffff;}
|
||||
#carrier_wizard.swMain ul.anchor li a.done .stepDesc {color: #A9B6C8;}
|
||||
|
||||
#carrier_wizard.swMain ul.anchor li a .stepDesc small {font: 11px Verdana,Arial,Helvetica,sans-serif;}
|
||||
|
||||
#carrier_wizard.swMain .stepContainer div.content{width:99%}
|
||||
#carrier_wizard.swMain div.actionBar{width:99.5%}
|
||||
|
||||
#carrier_wizard .border_top {border-top:solid 1px #C0C0C0;}
|
||||
#carrier_wizard .border_bottom {border-bottom:solid 1px #C0C0C0;}
|
||||
#carrier_wizard .border_left {border-left:solid 1px #C0C0C0;}
|
||||
#carrier_wizard .border_right {border-right:solid 1px #C0C0C0;}
|
||||
#carrier_wizard .border_all {border:solid 1px #C0C0C0;}
|
||||
#carrier_wizard input.field_error {border : solid 1px red; background-color:#FFCCCC}
|
||||
#carrier_wizard table td.center {text-align: center}
|
||||
.new_range {float: left;margin: 20px 0 0 10px;}
|
||||
#carrier_wizard tr.fees_all { background: #CCCCCC}
|
||||
|
||||
#carrier_wizard #zones_table input[type=text] {width: 45px;}
|
||||
@@ -51,6 +51,7 @@
|
||||
<access id="access_1_45" id_profile="SuperAdmin" id_tab="Outstanding" view="1" add="1" edit="1" delete="1"/>
|
||||
<access id="access_1_46" id_profile="SuperAdmin" id_tab="Cart_Rules" view="1" add="1" edit="1" delete="1"/>
|
||||
<access id="access_1_47" id_profile="SuperAdmin" id_tab="Catalog_price_rules" view="1" add="1" edit="1" delete="1"/>
|
||||
<access id="access_1_49" id_profile="SuperAdmin" id_tab="CarrierWizard" view="1" add="1" edit="1" delete="1"/>
|
||||
<access id="access_1_49" id_profile="SuperAdmin" id_tab="Carriers" view="1" add="1" edit="1" delete="1"/>
|
||||
<access id="access_1_50" id_profile="SuperAdmin" id_tab="Price_Ranges" view="1" add="1" edit="1" delete="1"/>
|
||||
<access id="access_1_51" id_profile="SuperAdmin" id_tab="Weight_Ranges" view="1" add="1" edit="1" delete="1"/>
|
||||
|
||||
@@ -156,11 +156,8 @@
|
||||
<tab id="Carriers" id_parent="Shipping" active="1">
|
||||
<class_name>AdminCarriers</class_name>
|
||||
</tab>
|
||||
<tab id="Price_Ranges" id_parent="Shipping" active="1">
|
||||
<class_name>AdminRangePrice</class_name>
|
||||
</tab>
|
||||
<tab id="Weight_Ranges" id_parent="Shipping" active="1">
|
||||
<class_name>AdminRangeWeight</class_name>
|
||||
<tab id="CarrierWizard" id_parent="Shipping" active="1">
|
||||
<class_name>AdminCarrierWizard</class_name>
|
||||
</tab>
|
||||
<tab id="Localization_1" id_parent="Localization" active="1">
|
||||
<class_name>AdminLocalization</class_name>
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
<tab id="Positions" name="Posições"/>
|
||||
<tab id="Preferences_1" name="Preferências"/>
|
||||
<tab id="Preferences" name="Preferências"/>
|
||||
<tab id="Price_Ranges" name="Faixas de preços"/>
|
||||
<tab id="Price_Rules" name="Regras de Preços"/>
|
||||
<tab id="Products_1" name="Produtos"/>
|
||||
<tab id="Products" name="Produtos"/>
|
||||
@@ -100,6 +99,5 @@
|
||||
<tab id="Translations" name="Traduções"/>
|
||||
<tab id="Warehouses" name="Armazéns"/>
|
||||
<tab id="Webservice" name="Serviço Web"/>
|
||||
<tab id="Weight_Ranges" name="Faixas de peso"/>
|
||||
<tab id="Zones" name="Regiões"/>
|
||||
</entity_tab>
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
<tab id="Positions" name="Positionen"/>
|
||||
<tab id="Preferences_1" name="Voreinstellungen"/>
|
||||
<tab id="Preferences" name="Voreinstellungen"/>
|
||||
<tab id="Price_Ranges" name="Preisspannen"/>
|
||||
<tab id="Price_Rules" name="Preisregeln"/>
|
||||
<tab id="Products_1" name="Produkte"/>
|
||||
<tab id="Products" name="Produkte"/>
|
||||
@@ -100,6 +99,5 @@
|
||||
<tab id="Translations" name="Übersetzungen"/>
|
||||
<tab id="Warehouses" name="Lagerort"/>
|
||||
<tab id="Webservice" name="Webdienste"/>
|
||||
<tab id="Weight_Ranges" name="Gewichtsspannen"/>
|
||||
<tab id="Zones" name="Zonen"/>
|
||||
</entity_tab>
|
||||
|
||||
@@ -50,8 +50,6 @@
|
||||
<tab id="Marketing" name="Marketing"/>
|
||||
<tab id="Shipping_1" name="Shipping"/>
|
||||
<tab id="Carriers" name="Carriers"/>
|
||||
<tab id="Price_Ranges" name="Price Ranges"/>
|
||||
<tab id="Weight_Ranges" name="Weight Ranges"/>
|
||||
<tab id="Localization_1" name="Localization"/>
|
||||
<tab id="Languages" name="Languages"/>
|
||||
<tab id="Zones" name="Zones"/>
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
<tab id="Positions" name="Posiciones"/>
|
||||
<tab id="Preferences_1" name="Preferencias"/>
|
||||
<tab id="Preferences" name="Preferencias"/>
|
||||
<tab id="Price_Ranges" name="Rangos de precio"/>
|
||||
<tab id="Price_Rules" name="Precio de las normas"/>
|
||||
<tab id="Products_1" name="Productos"/>
|
||||
<tab id="Products" name="Productos"/>
|
||||
@@ -100,6 +99,5 @@
|
||||
<tab id="Translations" name="Traducciones"/>
|
||||
<tab id="Warehouses" name="Almacenes"/>
|
||||
<tab id="Webservice" name="Servicio Web"/>
|
||||
<tab id="Weight_Ranges" name="Rangos de peso"/>
|
||||
<tab id="Zones" name="Zonas"/>
|
||||
</entity_tab>
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
<tab id="Positions" name="Positions"/>
|
||||
<tab id="Preferences_1" name="Préférences"/>
|
||||
<tab id="Preferences" name="Préférences"/>
|
||||
<tab id="Price_Ranges" name="Tranches de prix"/>
|
||||
<tab id="Price_Rules" name="Promotions"/>
|
||||
<tab id="Products_1" name="Produits"/>
|
||||
<tab id="Products" name="Produits"/>
|
||||
@@ -100,6 +99,5 @@
|
||||
<tab id="Translations" name="Traductions"/>
|
||||
<tab id="Warehouses" name="Entrepôts"/>
|
||||
<tab id="Webservice" name="Service web"/>
|
||||
<tab id="Weight_Ranges" name="Tranches de poids"/>
|
||||
<tab id="Zones" name="Zones"/>
|
||||
</entity_tab>
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
<tab id="Positions" name="Posizioni"/>
|
||||
<tab id="Preferences_1" name="Preferenze"/>
|
||||
<tab id="Preferences" name="Preferenze"/>
|
||||
<tab id="Price_Ranges" name="Fasce di prezzi"/>
|
||||
<tab id="Price_Rules" name="Regole Prezzi"/>
|
||||
<tab id="Products_1" name="Prodotti"/>
|
||||
<tab id="Products" name="Prodotti"/>
|
||||
@@ -100,6 +99,5 @@
|
||||
<tab id="Translations" name="Traduzioni"/>
|
||||
<tab id="Warehouses" name="Magazzino"/>
|
||||
<tab id="Webservice" name="Webservice"/>
|
||||
<tab id="Weight_Ranges" name="Fasce di pesi"/>
|
||||
<tab id="Zones" name="Zone"/>
|
||||
</entity_tab>
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
<tab id="Positions" name="Pozycje"/>
|
||||
<tab id="Preferences_1" name="Preferencje"/>
|
||||
<tab id="Preferences" name="Preferencje"/>
|
||||
<tab id="Price_Ranges" name="Zakresy cen"/>
|
||||
<tab id="Price_Rules" name="Reguły ustalania cen"/>
|
||||
<tab id="Products_1" name="Produkty"/>
|
||||
<tab id="Products" name="Produkty"/>
|
||||
@@ -100,6 +99,5 @@
|
||||
<tab id="Translations" name="Tłumaczenia"/>
|
||||
<tab id="Warehouses" name="Hurtownie"/>
|
||||
<tab id="Webservice" name="Usługi internetowe"/>
|
||||
<tab id="Weight_Ranges" name="Zakres wag"/>
|
||||
<tab id="Zones" name="Strefy"/>
|
||||
</entity_tab>
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
<tab id="Positions" name="Расположение"/>
|
||||
<tab id="Preferences_1" name="Настройки"/>
|
||||
<tab id="Preferences" name="Настройки"/>
|
||||
<tab id="Price_Ranges" name="Шкала цен"/>
|
||||
<tab id="Price_Rules" name="Ценовые правила"/>
|
||||
<tab id="Products_1" name="товары"/>
|
||||
<tab id="Products" name="товары"/>
|
||||
@@ -100,6 +99,5 @@
|
||||
<tab id="Translations" name="Переводы"/>
|
||||
<tab id="Warehouses" name="Склады"/>
|
||||
<tab id="Webservice" name="WEB службы"/>
|
||||
<tab id="Weight_Ranges" name="Шкала веса"/>
|
||||
<tab id="Zones" name="Зоны"/>
|
||||
</entity_tab>
|
||||
|
||||
@@ -19,6 +19,8 @@ CHANGE `module_name` `module_name` VARCHAR(64) NULL DEFAULT NULL;
|
||||
/* PHP:add_module_to_hook(blockmyaccountfooter, actionModuleRegisterHookAfter); */;
|
||||
/* PHP:add_module_to_hook(blockmyaccount, actionModuleUnRegisterHookAfter); */;
|
||||
/* PHP:add_module_to_hook(blockmyaccountfooter, actionModuleUnRegisterHookAfter); */;
|
||||
/* PHP:remove_tab(AdminRangePrice); */;
|
||||
/* PHP:remove_tab(AdminRangeWeight); */;
|
||||
|
||||
ALTER TABLE `PREFIX_log` ADD `id_employee` INT(10) UNSIGNED NULL DEFAULT NULL AFTER `object_id`;
|
||||
|
||||
|
||||
417
js/admin_carrier_wizard.js
Normal file
417
js/admin_carrier_wizard.js
Normal file
@@ -0,0 +1,417 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
bind_inputs();
|
||||
initCarrierWizard();
|
||||
});
|
||||
|
||||
function initCarrierWizard()
|
||||
{
|
||||
$("#carrier_wizard").smartWizard({
|
||||
'labelNext' : labelNext,
|
||||
'labelPrevious' : labelPrevious,
|
||||
'labelFinish' : labelFinish,
|
||||
'fixHeight' : 1,
|
||||
'onShowStep' : onShowStepCallback,
|
||||
'onLeaveStep' : onLeaveStepCallback,
|
||||
'onFinish' : onFinishCallback,
|
||||
'transitionEffect' : 'slideleft',
|
||||
'enableAllSteps' : enableAllSteps
|
||||
});
|
||||
displayRangeType();
|
||||
}
|
||||
|
||||
function displayRangeType()
|
||||
{
|
||||
if ($('input[name="shipping_method"]:checked').val() == 1)
|
||||
string = string_weight;
|
||||
else
|
||||
string = string_price;
|
||||
|
||||
$('.range_type').html(string);
|
||||
}
|
||||
|
||||
function onShowStepCallback()
|
||||
{
|
||||
$('.anchor li a').each( function () {
|
||||
$(this).parent('li').addClass($(this).attr('class'));
|
||||
});
|
||||
$('#carrier_logo_block').prependTo($('div.content').filter(function() { return $(this).css('display') != 'none' }).children('.defaultForm').children('fieldset'));
|
||||
resizeWizard();
|
||||
}
|
||||
|
||||
function onFinishCallback(obj, context)
|
||||
{
|
||||
$('.wizard_error').remove();
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
url : validate_url,
|
||||
async: false,
|
||||
dataType: 'json',
|
||||
data : $('#carrier_wizard .stepContainer .content form').serialize() + '&action=finish_step&ajax=1',
|
||||
success : function(data) {
|
||||
if (data.has_error)
|
||||
{
|
||||
displayError(data.errors, context.fromStep);
|
||||
resizeWizard();
|
||||
}
|
||||
else
|
||||
window.location.href = carrierlist_url;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onLeaveStepCallback(obj, context)
|
||||
{
|
||||
if (context.toStep == nbr_steps)
|
||||
displaySummary();
|
||||
|
||||
return validateSteps(context.fromStep); // return false to stay on step and true to continue navigation
|
||||
}
|
||||
|
||||
function displaySummary()
|
||||
{
|
||||
// used as buffer - you must not replace directly in the translation vars
|
||||
var tmp;
|
||||
|
||||
// Carrier name
|
||||
$('#summary_name').html($('#name').val());
|
||||
|
||||
// Delay and pricing
|
||||
tmp = summary_translation_meta_informations.replace('@s2', '<strong>' + $('#delay_1').val() + '</strong>');
|
||||
if ($('#is_free_on').attr('checked'))
|
||||
tmp = tmp.replace('@s1', summary_translation_free);
|
||||
else
|
||||
tmp = tmp.replace('@s1', summary_translation_paid);
|
||||
$('#summary_meta_informations').html(tmp);
|
||||
|
||||
// Tax and calculation mode for the shipping cost
|
||||
tmp = summary_translation_shipping_cost.replace('@s2', '<strong>' + $('#id_tax_rules_group option:selected').text() + '</strong>');
|
||||
if ($('#billing_price').attr('checked'))
|
||||
tmp = tmp.replace('@s1', summary_translation_price);
|
||||
else if ($('#billing_weight').attr('checked'))
|
||||
tmp = tmp.replace('@s1', summary_translation_weight);
|
||||
else
|
||||
tmp = tmp.replace('@s1', '<strong>' + summary_translation_undefined + '</strong>');
|
||||
$('#summary_shipping_cost').html(tmp);
|
||||
|
||||
// Weight or price ranges
|
||||
$('#summary_range').html(summary_translation_range);
|
||||
var range_inf = summary_translation_undefined;
|
||||
var range_sup = summary_translation_undefined;
|
||||
$('input[name$="range_inf[]"]').each(function(){
|
||||
if (!isNaN(parseFloat($(this).val())) && (range_inf == summary_translation_undefined || range_inf < $(this).val()))
|
||||
range_inf = $(this).val();
|
||||
});
|
||||
$('input[name$="range_sup[]"]').each(function(){
|
||||
if (!isNaN(parseFloat($(this).val())) && (range_sup == summary_translation_undefined || range_sup > $(this).val()))
|
||||
range_sup = $(this).val();
|
||||
});
|
||||
$('#summary_range').html(
|
||||
$('#summary_range').html()
|
||||
.replace('@s1', '<strong>' + range_inf + '</strong>')
|
||||
.replace('@s2', '<strong>' + range_sup + '</strong>')
|
||||
.replace('@s3', '<strong>' + $('#range_behavior option:selected').text().toLowerCase() + '</strong>')
|
||||
);
|
||||
|
||||
// Delivery zones
|
||||
$('#summary_zones').html('');
|
||||
$('.input_zone').each(function(){
|
||||
if ($(this).attr('checked'))
|
||||
$('#summary_zones').html($('#summary_zones').html() + '<li><strong>' + $(this).parent().prev().text() + '</strong></li>');
|
||||
});
|
||||
|
||||
// Group restrictions
|
||||
$('#summary_groups').html('');
|
||||
$('input[name$="groupBox[]"]').each(function(){
|
||||
if ($(this).attr('checked'))
|
||||
$('#summary_groups').html($('#summary_groups').html() + '<li><strong>' + $(this).parent().next().next().text() + '</strong></li>');
|
||||
});
|
||||
|
||||
// shop restrictions
|
||||
$('#summary_shops').html('');
|
||||
$('.input_shop').each(function(){
|
||||
if ($(this).attr('checked'))
|
||||
$('#summary_shops').html($('#summary_shops').html() + '<li><strong>' + $(this).parent().text() + '</strong></li>');
|
||||
});
|
||||
}
|
||||
|
||||
function validateSteps(step_number)
|
||||
{
|
||||
$('.wizard_error').remove();
|
||||
var is_ok = true;
|
||||
form = $('#carrier_wizard #step-'+step_number+' form');
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
url : validate_url,
|
||||
async: false,
|
||||
dataType: 'json',
|
||||
data : form.serialize()+'&step_number='+step_number+'&action=validate_step&ajax=1',
|
||||
success : function(datas)
|
||||
{
|
||||
if (datas.has_error)
|
||||
{
|
||||
is_ok = false;
|
||||
|
||||
$('input').focus( function () {
|
||||
$(this).removeClass('field_error');
|
||||
});
|
||||
displayError(datas.errors, step_number);
|
||||
resizeWizard();
|
||||
}
|
||||
}
|
||||
});
|
||||
return is_ok;
|
||||
}
|
||||
|
||||
function displayError(errors, step_number)
|
||||
{
|
||||
$('.wizard_error').remove();
|
||||
str_error = '<div class="error wizard_error"><span style="float:right"><a id="hideError" href="#"><img alt="X" src="../img/admin/close.png" /></a></span><ul>';
|
||||
for (var error in errors)
|
||||
{
|
||||
$('#carrier_wizard').smartWizard('setError',{stepnum:step_number,iserror:true});
|
||||
$('input[name="'+error+'"]').addClass('field_error');
|
||||
str_error += '<li>'+errors[error]+'</li>';
|
||||
}
|
||||
$('#step-'+step_number).prepend(str_error+'</ul></div>');
|
||||
}
|
||||
|
||||
function resizeWizard()
|
||||
{
|
||||
resizeInterval = setInterval(function (){$("#carrier_wizard").smartWizard('fixHeight'); clearInterval(resizeInterval)}, 100);
|
||||
}
|
||||
|
||||
function bind_inputs()
|
||||
{
|
||||
$('tr.delete_range td button').off('click').on('click', function () {
|
||||
index = $(this).parent('td').index();
|
||||
$('tr.range_sup td:eq('+index+'), tr.range_inf td:eq('+index+'), tr.fees_all td:eq('+index+'), tr.delete_range td:eq('+index+')').remove();
|
||||
$('tr.fees').each( function () {
|
||||
$(this).children('td:eq('+index+')').remove();
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('tr.fees_all td button').off('click').on('click', function () {
|
||||
index = $(this).parent('td').index();
|
||||
if (validateRange(index))
|
||||
enableRange(index);
|
||||
else
|
||||
disableRange(index);
|
||||
return false;
|
||||
});
|
||||
|
||||
$('tr.fees td input:checkbox').off('change').on('change', function () {
|
||||
|
||||
if($(this).is(':checked'))
|
||||
{
|
||||
$(this).closest('tr').children('td').each( function (){
|
||||
index = $(this).index();
|
||||
if ($('tr.fees_all td:eq('+index+')').hasClass('validated'))
|
||||
$(this).children('input:text').removeAttr('disabled');
|
||||
});
|
||||
}
|
||||
else
|
||||
$(this).closest('tr').children('td').children('input:text').attr('disabled', 'disabled');
|
||||
return false;
|
||||
});
|
||||
|
||||
$('tr.range_sup td input:text, tr.range_inf td input:text').focus( function () {
|
||||
$(this).removeClass('field_error');
|
||||
});
|
||||
|
||||
$('tr.range_sup td input:text, tr.range_inf td input:text').off('change').on('change', function () {
|
||||
index = $(this).parent('td').index();
|
||||
|
||||
if ($('tr.fees_all td:eq('+index+')').hasClass('validated') || $('tr.fees_all td:eq('+index+')').hasClass('not_validated'))
|
||||
{
|
||||
if (validateRange(index))
|
||||
enableRange(index);
|
||||
else
|
||||
disableRange(index);
|
||||
}
|
||||
});
|
||||
|
||||
$('tr.fees_all td input').off('change').on('change', function () {
|
||||
index = $(this).parent('td').index();
|
||||
val = $(this).val();
|
||||
$('tr.fees td input:text').not('disabled').val(val);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('input[name="is_free"]').on('click', function() {
|
||||
var is_free = $(this);
|
||||
$("#step_carrier_ranges .margin-form").each(function() {
|
||||
var field = $(this).children().attr('name');
|
||||
if (typeof(field) != 'undefined' && field != 'is_free')
|
||||
{
|
||||
if (parseInt(is_free.val()))
|
||||
{
|
||||
$(this).hide();
|
||||
$(this).prev().hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).show();
|
||||
$(this).prev().show();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (parseInt(is_free.val()))
|
||||
{
|
||||
$('#zones_table').hide();
|
||||
$('.new_range').hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#zones_table').show();
|
||||
$('.new_range').show();
|
||||
}
|
||||
});
|
||||
$('input[name="is_free"]:checked').click();
|
||||
|
||||
$('input[name="shipping_method"]').on('click', function() {
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
url : validate_url,
|
||||
async: false,
|
||||
dataType: 'html',
|
||||
data : 'id_carrier='+parseInt($('#id_carrier').val())+'&shipping_method='+parseInt($(this).val())+'&action=changeRanges&ajax=1',
|
||||
success : function(data) {
|
||||
$('#zone_ranges').replaceWith(data);
|
||||
displayRangeType();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function validateRange(index)
|
||||
{
|
||||
//reset error css
|
||||
$('tr.range_sup td input:text').removeClass('field_error');
|
||||
$('tr.range_inf td input:text').removeClass('field_error');
|
||||
|
||||
is_ok = true;
|
||||
range_sup = parseInt($('tr.range_sup td:eq('+index+')').children('input:text').val().trim());
|
||||
range_inf = parseInt($('tr.range_inf td:eq('+index+')').children('input:text').val().trim());
|
||||
|
||||
if (isNaN(range_sup) || range_sup.length === 0)
|
||||
{
|
||||
$('tr.range_sup td:eq('+index+')').children('input:text').addClass('field_error');
|
||||
is_ok = false;
|
||||
}
|
||||
|
||||
if (isNaN(range_inf) || range_inf.length === 0)
|
||||
{
|
||||
$('tr.range_inf td:eq('+index+')').children('input:text').addClass('field_error');
|
||||
is_ok = false;
|
||||
}
|
||||
|
||||
if (is_ok)
|
||||
{
|
||||
if (range_inf >= range_sup)
|
||||
{
|
||||
$('tr.range_sup td:eq('+index+')').children('input:text').addClass('field_error');
|
||||
$('tr.range_inf td:eq('+index+')').children('input:text').addClass('field_error');
|
||||
is_ok = false;
|
||||
}
|
||||
//check if previous range is inf only if it's not the first range
|
||||
if (index > 2)
|
||||
{
|
||||
previous_range_sup = parseInt($('tr.range_sup td:eq('+(index -1)+')').children('input:text').val().trim());
|
||||
console.log(range_inf+' < '+previous_range_sup);
|
||||
if (range_inf < previous_range_sup)
|
||||
{
|
||||
$('tr.range_inf td:eq('+index+')').children('input:text').addClass('field_error');
|
||||
}
|
||||
}
|
||||
//check if next range is sup only if it's not the last range
|
||||
if ($('tr.range_inf td:eq('+(index + 1)+')').length)
|
||||
{
|
||||
next_range_inf = parseInt($('tr.range_inf td:eq('+(index +1)+')').children('input:text').val().trim());
|
||||
|
||||
if ((isNaN(range_sup) || range_sup.length === 0) && range_sup > next_range_inf)
|
||||
{
|
||||
$('tr.range_sup td:eq('+index+')').children('input:text').addClass('field_error');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return is_ok;
|
||||
}
|
||||
|
||||
function enableRange(index)
|
||||
{
|
||||
$('tr.fees').each( function () {
|
||||
//only enable fees for enabled zones
|
||||
if ($(this).children('td').children('input:checkbox').attr('checked') == 'checked')
|
||||
$(this).children('td:eq('+index+')').children('input').removeAttr('disabled');
|
||||
});
|
||||
$('span.fees_all').show();
|
||||
$('tr.fees_all td:eq('+index+')').children('input').show().removeAttr('disabled');
|
||||
$('tr.fees_all td:eq('+index+')').addClass('validated').removeClass('not_validated');
|
||||
$('tr.fees_all td:eq('+index+')').children('button').remove();
|
||||
}
|
||||
|
||||
function disableRange(index)
|
||||
{
|
||||
$('tr.fees').each( function () {
|
||||
//only enable fees for enabled zones
|
||||
if ($(this).children('td').children('input:checkbox').attr('checked') == 'checked')
|
||||
$(this).children('td:eq('+index+')').children('input').attr('disabled', 'disabled');
|
||||
});
|
||||
$('tr.fees_all td:eq('+index+')').children('input').attr('disabled', 'disabled');
|
||||
$('tr.fees_all td:eq('+index+')').removeClass('validated').addClass('not_validated');
|
||||
}
|
||||
|
||||
function add_new_range()
|
||||
{
|
||||
//add new rand sup input
|
||||
$('tr.range_sup td:last').after('<td class="center"><input name="range_sup[]" type="text" /></td>');
|
||||
//add new rand inf input
|
||||
$('tr.range_inf td:last').after('<td class="border_bottom center"><input name="range_inf[]" type="text" /></td>');
|
||||
|
||||
$('tr.fees_all td:last').after('<td class="center border_top border_bottom"><input style="display:none" type="text" /> <button class="button">'+labelValidate+'</button</td>');
|
||||
|
||||
$('tr.fees').each( function () {
|
||||
$(this).children('td:last').after('<td><input disabled="disabled" name="fees['+$(this).data('zoneid')+'][]" type="text" /></td>');
|
||||
});
|
||||
$('tr.delete_range td:last').after('<td class="center"><button class="button">'+labelDelete+'</button</td>');
|
||||
|
||||
resizeWizard();
|
||||
bind_inputs();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function delete_new_range()
|
||||
{
|
||||
if ($('#new_range_form_placeholder').children('td').length = 1)
|
||||
return false;
|
||||
}
|
||||
305
js/jquery/plugins/smartWizard/jquery.smartWizard.css
Normal file
305
js/jquery/plugins/smartWizard/jquery.smartWizard.css
Normal file
@@ -0,0 +1,305 @@
|
||||
/*
|
||||
SmartWizard 2.0 plugin
|
||||
jQuery Wizard control Plugin
|
||||
by Dipu
|
||||
|
||||
http://www.techlaboratory.net
|
||||
http://tech-laboratory.blogspot.com
|
||||
*/
|
||||
.swMain {
|
||||
position:relative;
|
||||
display:block;
|
||||
margin:0;
|
||||
padding:0;
|
||||
border: 0px solid #CCC;
|
||||
overflow:visible;
|
||||
float:left;
|
||||
width:980px;
|
||||
}
|
||||
.swMain .stepContainer {
|
||||
display:block;
|
||||
position: relative;
|
||||
margin: 0;
|
||||
padding:0;
|
||||
border: 0px solid #CCC;
|
||||
overflow:hidden;
|
||||
clear:both;
|
||||
height:300px;
|
||||
}
|
||||
|
||||
.swMain .stepContainer div.content {
|
||||
display:block;
|
||||
position: absolute;
|
||||
float:left;
|
||||
margin: 0;
|
||||
padding:5px;
|
||||
border: 1px solid #CCC;
|
||||
font: normal 12px Verdana, Arial, Helvetica, sans-serif;
|
||||
color:#5A5655;
|
||||
background-color:#F8F8F8;
|
||||
height:300px;
|
||||
text-align:left;
|
||||
overflow:visible;
|
||||
z-index:88;
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius : 5px;
|
||||
width:968px;
|
||||
clear:both;
|
||||
}
|
||||
|
||||
.swMain div.actionBar {
|
||||
display:block;
|
||||
position: relative;
|
||||
clear:both;
|
||||
margin: 3px 0 0 0;
|
||||
border: 1px solid #CCC;
|
||||
padding: 0;
|
||||
color: #5A5655;
|
||||
background-color: #F8F8F8;
|
||||
height:40px;
|
||||
text-align:left;
|
||||
overflow:auto;
|
||||
z-index:88;
|
||||
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius : 5px;
|
||||
left:0;
|
||||
}
|
||||
|
||||
.swMain .stepContainer .StepTitle {
|
||||
display:block;
|
||||
position: relative;
|
||||
margin:0;
|
||||
border:1px solid #E0E0E0;
|
||||
padding:5px;
|
||||
font: bold 16px Verdana, Arial, Helvetica, sans-serif;
|
||||
color:#5A5655;
|
||||
background-color:#E0E0E0;
|
||||
clear:both;
|
||||
text-align:left;
|
||||
z-index:88;
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius : 5px;
|
||||
}
|
||||
.swMain ul.anchor {
|
||||
position: relative;
|
||||
display:block;
|
||||
float:left;
|
||||
list-style: none;
|
||||
padding: 0px;
|
||||
margin: 10px 0;
|
||||
clear: both;
|
||||
border: 0px solid #CCCCCC;
|
||||
background: transparent; /*#EEEEEE */
|
||||
}
|
||||
.swMain ul.anchor li{
|
||||
position: relative;
|
||||
display:block;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
padding-left:3px;
|
||||
padding-right: 3px;
|
||||
border: 0px solid #E0E0E0;
|
||||
float: left;
|
||||
}
|
||||
/* Anchor Element Style */
|
||||
.swMain ul.anchor li a {
|
||||
display:block;
|
||||
position:relative;
|
||||
float:left;
|
||||
margin:0;
|
||||
padding:3px;
|
||||
height:60px;
|
||||
width:230px;
|
||||
text-decoration: none;
|
||||
outline-style:none;
|
||||
-moz-border-radius : 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
z-index:99;
|
||||
}
|
||||
.swMain ul.anchor li a .stepNumber{
|
||||
position:relative;
|
||||
float:left;
|
||||
width:30px;
|
||||
text-align: center;
|
||||
padding:5px;
|
||||
padding-top:0;
|
||||
font: bold 45px Verdana, Arial, Helvetica, sans-serif;
|
||||
}
|
||||
.swMain ul.anchor li a .stepDesc{
|
||||
position:relative;
|
||||
display:block;
|
||||
float:left;
|
||||
text-align: left;
|
||||
padding:5px;
|
||||
|
||||
font: bold 20px Verdana, Arial, Helvetica, sans-serif;
|
||||
}
|
||||
.swMain ul.anchor li a .stepDesc small{
|
||||
font: normal 12px Verdana, Arial, Helvetica, sans-serif;
|
||||
}
|
||||
.swMain ul.anchor li a.selected{
|
||||
color:#F8F8F8;
|
||||
background: #EA8511; /* EA8511 */
|
||||
border: 1px solid #EA8511;
|
||||
cursor:text;
|
||||
-moz-box-shadow: 5px 5px 8px #888;
|
||||
-webkit-box-shadow: 5px 5px 8px #888;
|
||||
box-shadow: 5px 5px 8px #888;
|
||||
}
|
||||
.swMain ul.anchor li a.selected:hover {
|
||||
color:#F8F8F8;
|
||||
background: #EA8511;
|
||||
}
|
||||
|
||||
.swMain ul.anchor li a.done {
|
||||
position:relative;
|
||||
color:#FFF;
|
||||
background: #8CC63F;
|
||||
border: 1px solid #8CC63F;
|
||||
z-index:99;
|
||||
}
|
||||
.swMain ul.anchor li a.done:hover {
|
||||
color:#5A5655;
|
||||
background: #8CC63F;
|
||||
border: 1px solid #5A5655;
|
||||
}
|
||||
.swMain ul.anchor li a.disabled {
|
||||
color:#CCCCCC;
|
||||
background: #F8F8F8;
|
||||
border: 1px solid #CCC;
|
||||
cursor:text;
|
||||
}
|
||||
.swMain ul.anchor li a.disabled:hover {
|
||||
color:#CCCCCC;
|
||||
background: #F8F8F8;
|
||||
}
|
||||
|
||||
.swMain ul.anchor li a.error {
|
||||
color:#6c6c6c !important;
|
||||
background: #f08f75 !important;
|
||||
border: 1px solid #fb3500 !important;
|
||||
}
|
||||
.swMain ul.anchor li a.error:hover {
|
||||
color:#000 !important;
|
||||
}
|
||||
|
||||
.swMain .buttonNext {
|
||||
display:block;
|
||||
float:right;
|
||||
margin:5px 3px 0 3px;
|
||||
padding:5px;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
font: bold 13px Verdana, Arial, Helvetica, sans-serif;
|
||||
width:100px;
|
||||
color:#FFF;
|
||||
outline-style:none;
|
||||
background-color: #5A5655;
|
||||
border: 1px solid #5A5655;
|
||||
-moz-border-radius : 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
}
|
||||
.swMain .buttonDisabled {
|
||||
color:#F8F8F8 !important;
|
||||
background-color: #CCCCCC !important;
|
||||
border: 1px solid #CCCCCC !important;
|
||||
cursor:text;
|
||||
}
|
||||
.swMain .buttonPrevious {
|
||||
display:block;
|
||||
float:right;
|
||||
margin:5px 3px 0 3px;
|
||||
padding:5px;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
font: bold 13px Verdana, Arial, Helvetica, sans-serif;
|
||||
width:100px;
|
||||
color:#FFF;
|
||||
outline-style:none;
|
||||
background-color: #5A5655;
|
||||
border: 1px solid #5A5655;
|
||||
-moz-border-radius : 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
}
|
||||
.swMain .buttonFinish {
|
||||
display:block;
|
||||
float:right;
|
||||
margin:5px 10px 0 3px;
|
||||
padding:5px;
|
||||
text-decoration: none;
|
||||
text-align: center;
|
||||
font: bold 13px Verdana, Arial, Helvetica, sans-serif;
|
||||
width:100px;
|
||||
color:#FFF;
|
||||
outline-style:none;
|
||||
background-color: #5A5655;
|
||||
border: 1px solid #5A5655;
|
||||
-moz-border-radius : 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
}
|
||||
|
||||
/* Form Styles */
|
||||
|
||||
.txtBox {
|
||||
border:1px solid #CCCCCC;
|
||||
color:#5A5655;
|
||||
font:13px Verdana,Arial,Helvetica,sans-serif;
|
||||
padding:2px;
|
||||
width:430px;
|
||||
}
|
||||
.txtBox:focus {
|
||||
border:1px solid #EA8511;
|
||||
}
|
||||
|
||||
.swMain .loader {
|
||||
position:relative;
|
||||
display:none;
|
||||
float:left;
|
||||
margin: 2px 0 0 2px;
|
||||
padding:8px 10px 8px 40px;
|
||||
border: 1px solid #FFD700;
|
||||
font: bold 13px Verdana, Arial, Helvetica, sans-serif;
|
||||
color:#5A5655;
|
||||
background: #FFF url(loader.gif) no-repeat 5px;
|
||||
-moz-border-radius : 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
z-index:998;
|
||||
}
|
||||
.swMain .msgBox {
|
||||
position:relative;
|
||||
display:none;
|
||||
float:left;
|
||||
margin: 4px 0 0 5px;
|
||||
padding:5px;
|
||||
border: 1px solid #FFD700;
|
||||
background-color: #FFFFDD;
|
||||
font: normal 12px Verdana, Arial, Helvetica, sans-serif;
|
||||
color:#5A5655;
|
||||
-moz-border-radius : 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
z-index:999;
|
||||
min-width:200px;
|
||||
}
|
||||
.swMain .msgBox .content {
|
||||
font: normal 12px Verdana,Arial,Helvetica,sans-serif;
|
||||
padding: 0px;
|
||||
float:left;
|
||||
}
|
||||
.swMain .msgBox .close {
|
||||
border: 1px solid #CCC;
|
||||
border-radius: 3px;
|
||||
color: #CCC;
|
||||
display: block;
|
||||
float: right;
|
||||
margin: 0 0 0 5px;
|
||||
outline-style: none;
|
||||
padding: 0 2px 0 2px;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
}
|
||||
.swMain .msgBox .close:hover{
|
||||
color: #EA8511;
|
||||
border: 1px solid #EA8511;
|
||||
}
|
||||
450
js/jquery/plugins/smartWizard/jquery.smartWizard.js
Normal file
450
js/jquery/plugins/smartWizard/jquery.smartWizard.js
Normal file
@@ -0,0 +1,450 @@
|
||||
/*
|
||||
* SmartWizard 3.3.1 plugin
|
||||
* jQuery Wizard control Plugin
|
||||
* by Dipu
|
||||
*
|
||||
* Refactored and extended:
|
||||
* https://github.com/mstratman/jQuery-Smart-Wizard
|
||||
*
|
||||
* Original URLs:
|
||||
* http://www.techlaboratory.net
|
||||
* http://tech-laboratory.blogspot.com
|
||||
*/
|
||||
|
||||
function SmartWizard(target, options) {
|
||||
this.target = target;
|
||||
this.options = options;
|
||||
this.curStepIdx = options.selected;
|
||||
this.steps = $(target).children("ul").children("li").children("a"); // Get all anchors
|
||||
this.contentWidth = 0;
|
||||
this.msgBox = $('<div class="msgBox"><div class="content"></div><a href="#" class="close">X</a></div>');
|
||||
this.elmStepContainer = $('<div></div>').addClass("stepContainer");
|
||||
this.loader = $('<div>Loading</div>').addClass("loader");
|
||||
this.buttons = {
|
||||
next : $('<a>'+options.labelNext+'</a>').attr("href","#").addClass("buttonNext"),
|
||||
previous : $('<a>'+options.labelPrevious+'</a>').attr("href","#").addClass("buttonPrevious"),
|
||||
finish : $('<a>'+options.labelFinish+'</a>').attr("href","#").addClass("buttonFinish")
|
||||
};
|
||||
|
||||
/*
|
||||
* Private functions
|
||||
*/
|
||||
|
||||
var _init = function($this) {
|
||||
var elmActionBar = $('<div></div>').addClass("actionBar");
|
||||
elmActionBar.append($this.msgBox);
|
||||
$('.close',$this.msgBox).click(function() {
|
||||
$this.msgBox.fadeOut("normal");
|
||||
return false;
|
||||
});
|
||||
|
||||
var allDivs = $this.target.children('div');
|
||||
$this.target.children('ul').addClass("anchor");
|
||||
allDivs.addClass("content");
|
||||
|
||||
// highlight steps with errors
|
||||
if($this.options.errorSteps && $this.options.errorSteps.length>0){
|
||||
$.each($this.options.errorSteps, function(i, n){
|
||||
$this.setError({ stepnum: n, iserror:true });
|
||||
});
|
||||
}
|
||||
|
||||
$this.elmStepContainer.append(allDivs);
|
||||
elmActionBar.append($this.loader);
|
||||
$this.target.append($this.elmStepContainer);
|
||||
elmActionBar.append($this.buttons.finish)
|
||||
.append($this.buttons.next)
|
||||
.append($this.buttons.previous);
|
||||
$this.target.append(elmActionBar);
|
||||
this.contentWidth = $this.elmStepContainer.width();
|
||||
|
||||
$($this.buttons.next).click(function() {
|
||||
$this.goForward();
|
||||
return false;
|
||||
});
|
||||
$($this.buttons.previous).click(function() {
|
||||
$this.goBackward();
|
||||
return false;
|
||||
});
|
||||
$($this.buttons.finish).click(function() {
|
||||
if(!$(this).hasClass('buttonDisabled')){
|
||||
if($.isFunction($this.options.onFinish)) {
|
||||
var context = { fromStep: $this.curStepIdx + 1 };
|
||||
if(!$this.options.onFinish.call(this,$($this.steps), context)){
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
var frm = $this.target.parents('form');
|
||||
if(frm && frm.length){
|
||||
frm.submit();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
$($this.steps).bind("click", function(e){
|
||||
if($this.steps.index(this) == $this.curStepIdx){
|
||||
return false;
|
||||
}
|
||||
var nextStepIdx = $this.steps.index(this);
|
||||
var isDone = $this.steps.eq(nextStepIdx).attr("isDone") - 0;
|
||||
if(isDone == 1){
|
||||
_loadContent($this, nextStepIdx);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
// Enable keyboard navigation
|
||||
if($this.options.keyNavigation){
|
||||
$(document).keyup(function(e){
|
||||
if(e.which==39){ // Right Arrow
|
||||
$this.goForward();
|
||||
}else if(e.which==37){ // Left Arrow
|
||||
$this.goBackward();
|
||||
}
|
||||
});
|
||||
}
|
||||
// Prepare the steps
|
||||
_prepareSteps($this);
|
||||
// Show the first slected step
|
||||
_loadContent($this, $this.curStepIdx);
|
||||
};
|
||||
|
||||
var _prepareSteps = function($this) {
|
||||
if(! $this.options.enableAllSteps){
|
||||
$($this.steps, $this.target).removeClass("selected").removeClass("done").addClass("disabled");
|
||||
$($this.steps, $this.target).attr("isDone",0);
|
||||
}else{
|
||||
$($this.steps, $this.target).removeClass("selected").removeClass("disabled").addClass("done");
|
||||
$($this.steps, $this.target).attr("isDone",1);
|
||||
}
|
||||
|
||||
$($this.steps, $this.target).each(function(i){
|
||||
$($(this).attr("href").replace(/^.+#/, '#'), $this.target).hide();
|
||||
$(this).attr("rel",i+1);
|
||||
});
|
||||
};
|
||||
|
||||
var _step = function ($this, selStep) {
|
||||
return $(
|
||||
$(selStep, $this.target).attr("href").replace(/^.+#/, '#'),
|
||||
$this.target
|
||||
);
|
||||
};
|
||||
|
||||
var _loadContent = function($this, stepIdx) {
|
||||
var selStep = $this.steps.eq(stepIdx);
|
||||
var ajaxurl = $this.options.contentURL;
|
||||
var ajaxurl_data = $this.options.contentURLData;
|
||||
var hasContent = selStep.data('hasContent');
|
||||
var stepNum = stepIdx+1;
|
||||
if (ajaxurl && ajaxurl.length>0) {
|
||||
if ($this.options.contentCache && hasContent) {
|
||||
_showStep($this, stepIdx);
|
||||
} else {
|
||||
var ajax_args = {
|
||||
url: ajaxurl,
|
||||
type: $this.options.ajaxType,
|
||||
data: ({step_number : stepNum}),
|
||||
dataType: "text",
|
||||
beforeSend: function(){
|
||||
$this.loader.show();
|
||||
},
|
||||
error: function(){
|
||||
$this.loader.hide();
|
||||
},
|
||||
success: function(res){
|
||||
$this.loader.hide();
|
||||
if(res && res.length>0){
|
||||
selStep.data('hasContent',true);
|
||||
_step($this, selStep).html(res);
|
||||
_showStep($this, stepIdx);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (ajaxurl_data) {
|
||||
ajax_args = $.extend(ajax_args, ajaxurl_data(stepNum));
|
||||
}
|
||||
$.ajax(ajax_args);
|
||||
}
|
||||
}else{
|
||||
_showStep($this,stepIdx);
|
||||
}
|
||||
};
|
||||
|
||||
var _showStep = function($this, stepIdx) {
|
||||
var selStep = $this.steps.eq(stepIdx);
|
||||
var curStep = $this.steps.eq($this.curStepIdx);
|
||||
if(stepIdx != $this.curStepIdx){
|
||||
if($.isFunction($this.options.onLeaveStep)) {
|
||||
var context = { fromStep: $this.curStepIdx+1, toStep: stepIdx+1 };
|
||||
if (! $this.options.onLeaveStep.call($this,$(curStep), context)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this.elmStepContainer.height(_step($this, selStep).outerHeight());
|
||||
var prevCurStepIdx = $this.curStepIdx;
|
||||
$this.curStepIdx = stepIdx;
|
||||
if ($this.options.transitionEffect == 'slide'){
|
||||
_step($this, curStep).slideUp("fast",function(e){
|
||||
_step($this, selStep).slideDown("fast");
|
||||
_setupStep($this,curStep,selStep);
|
||||
});
|
||||
} else if ($this.options.transitionEffect == 'fade'){
|
||||
_step($this, curStep).fadeOut("fast",function(e){
|
||||
_step($this, selStep).fadeIn("fast");
|
||||
_setupStep($this,curStep,selStep);
|
||||
});
|
||||
} else if ($this.options.transitionEffect == 'slideleft'){
|
||||
var nextElmLeft = 0;
|
||||
var nextElmLeft1 = null;
|
||||
var nextElmLeft = null;
|
||||
var curElementLeft = 0;
|
||||
if(stepIdx > prevCurStepIdx){
|
||||
nextElmLeft1 = $this.elmStepContainer.width() + 10;
|
||||
nextElmLeft2 = 0;
|
||||
curElementLeft = 0 - _step($this, curStep).outerWidth();
|
||||
} else {
|
||||
nextElmLeft1 = 0 - _step($this, selStep).outerWidth() + 20;
|
||||
nextElmLeft2 = 0;
|
||||
curElementLeft = 10 + _step($this, curStep).outerWidth();
|
||||
}
|
||||
if (stepIdx == prevCurStepIdx) {
|
||||
nextElmLeft1 = $($(selStep, $this.target).attr("href"), $this.target).outerWidth() + 20;
|
||||
nextElmLeft2 = 0;
|
||||
curElementLeft = 0 - $($(curStep, $this.target).attr("href"), $this.target).outerWidth();
|
||||
} else {
|
||||
$($(curStep, $this.target).attr("href"), $this.target).animate({left:curElementLeft},"fast",function(e){
|
||||
$($(curStep, $this.target).attr("href"), $this.target).hide();
|
||||
});
|
||||
}
|
||||
|
||||
_step($this, selStep).css("left",nextElmLeft1).show().animate({left:nextElmLeft2},"fast",function(e){
|
||||
_setupStep($this,curStep,selStep);
|
||||
});
|
||||
} else {
|
||||
_step($this, curStep).hide();
|
||||
_step($this, selStep).show();
|
||||
_setupStep($this,curStep,selStep);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
var _setupStep = function($this, curStep, selStep) {
|
||||
$(curStep, $this.target).removeClass("selected");
|
||||
$(curStep, $this.target).addClass("done");
|
||||
|
||||
$(selStep, $this.target).removeClass("disabled");
|
||||
$(selStep, $this.target).removeClass("done");
|
||||
$(selStep, $this.target).addClass("selected");
|
||||
|
||||
$(selStep, $this.target).attr("isDone",1);
|
||||
|
||||
_adjustButton($this);
|
||||
|
||||
if($.isFunction($this.options.onShowStep)) {
|
||||
var context = { fromStep: parseInt($(curStep).attr('rel')), toStep: parseInt($(selStep).attr('rel')) };
|
||||
if(! $this.options.onShowStep.call(this,$(selStep),context)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($this.options.noForwardJumping) {
|
||||
// +2 == +1 (for index to step num) +1 (for next step)
|
||||
for (var i = $this.curStepIdx + 2; i <= $this.steps.length; i++) {
|
||||
$this.disableStep(i);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var _adjustButton = function($this) {
|
||||
if (! $this.options.cycleSteps){
|
||||
if (0 >= $this.curStepIdx) {
|
||||
$($this.buttons.previous).addClass("buttonDisabled");
|
||||
if ($this.options.hideButtonsOnDisabled) {
|
||||
$($this.buttons.previous).hide();
|
||||
}
|
||||
}else{
|
||||
$($this.buttons.previous).removeClass("buttonDisabled");
|
||||
if ($this.options.hideButtonsOnDisabled) {
|
||||
$($this.buttons.previous).show();
|
||||
}
|
||||
}
|
||||
if (($this.steps.length-1) <= $this.curStepIdx){
|
||||
$($this.buttons.next).addClass("buttonDisabled");
|
||||
if ($this.options.hideButtonsOnDisabled) {
|
||||
$($this.buttons.next).hide();
|
||||
}
|
||||
}else{
|
||||
$($this.buttons.next).removeClass("buttonDisabled");
|
||||
if ($this.options.hideButtonsOnDisabled) {
|
||||
$($this.buttons.next).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Finish Button
|
||||
if (! $this.steps.hasClass('disabled') || $this.options.enableFinishButton){
|
||||
$($this.buttons.finish).removeClass("buttonDisabled");
|
||||
if ($this.options.hideButtonsOnDisabled) {
|
||||
$($this.buttons.finish).show();
|
||||
}
|
||||
}else{
|
||||
$($this.buttons.finish).addClass("buttonDisabled");
|
||||
if ($this.options.hideButtonsOnDisabled) {
|
||||
$($this.buttons.finish).hide();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Public methods
|
||||
*/
|
||||
|
||||
SmartWizard.prototype.goForward = function(){
|
||||
var nextStepIdx = this.curStepIdx + 1;
|
||||
if (this.steps.length <= nextStepIdx){
|
||||
if (! this.options.cycleSteps){
|
||||
return false;
|
||||
}
|
||||
nextStepIdx = 0;
|
||||
}
|
||||
_loadContent(this, nextStepIdx);
|
||||
};
|
||||
|
||||
SmartWizard.prototype.goBackward = function(){
|
||||
var nextStepIdx = this.curStepIdx-1;
|
||||
if (0 > nextStepIdx){
|
||||
if (! this.options.cycleSteps){
|
||||
return false;
|
||||
}
|
||||
nextStepIdx = this.steps.length - 1;
|
||||
}
|
||||
_loadContent(this, nextStepIdx);
|
||||
};
|
||||
|
||||
SmartWizard.prototype.goToStep = function(stepNum){
|
||||
var stepIdx = stepNum - 1;
|
||||
if (stepIdx >= 0 && stepIdx < this.steps.length) {
|
||||
_loadContent(this, stepIdx);
|
||||
}
|
||||
};
|
||||
SmartWizard.prototype.enableStep = function(stepNum) {
|
||||
var stepIdx = stepNum - 1;
|
||||
if (stepIdx == this.curStepIdx || stepIdx < 0 || stepIdx >= this.steps.length) {
|
||||
return false;
|
||||
}
|
||||
var step = this.steps.eq(stepIdx);
|
||||
$(step, this.target).attr("isDone",1);
|
||||
$(step, this.target).removeClass("disabled").removeClass("selected").addClass("done");
|
||||
}
|
||||
SmartWizard.prototype.disableStep = function(stepNum) {
|
||||
var stepIdx = stepNum - 1;
|
||||
if (stepIdx == this.curStepIdx || stepIdx < 0 || stepIdx >= this.steps.length) {
|
||||
return false;
|
||||
}
|
||||
var step = this.steps.eq(stepIdx);
|
||||
$(step, this.target).attr("isDone",0);
|
||||
$(step, this.target).removeClass("done").removeClass("selected").addClass("disabled");
|
||||
}
|
||||
SmartWizard.prototype.currentStep = function() {
|
||||
return this.curStepIdx + 1;
|
||||
}
|
||||
|
||||
SmartWizard.prototype.showMessage = function (msg) {
|
||||
$('.content', this.msgBox).html(msg);
|
||||
this.msgBox.show();
|
||||
}
|
||||
SmartWizard.prototype.hideMessage = function () {
|
||||
this.msgBox.fadeOut("normal");
|
||||
}
|
||||
SmartWizard.prototype.showError = function(stepnum) {
|
||||
this.setError(stepnum, true);
|
||||
}
|
||||
SmartWizard.prototype.hideError = function(stepnum) {
|
||||
this.setError(stepnum, false);
|
||||
}
|
||||
SmartWizard.prototype.setError = function(stepnum,iserror) {
|
||||
if (typeof stepnum == "object") {
|
||||
iserror = stepnum.iserror;
|
||||
stepnum = stepnum.stepnum;
|
||||
}
|
||||
|
||||
if (iserror){
|
||||
$(this.steps.eq(stepnum-1), this.target).addClass('error')
|
||||
}else{
|
||||
$(this.steps.eq(stepnum-1), this.target).removeClass("error");
|
||||
}
|
||||
}
|
||||
|
||||
SmartWizard.prototype.fixHeight = function(){
|
||||
var height = 0;
|
||||
|
||||
var selStep = this.steps.eq(this.curStepIdx);
|
||||
var stepContainer = _step(this, selStep);
|
||||
stepContainer.children().each(function() {
|
||||
height += $(this).outerHeight();
|
||||
});
|
||||
|
||||
// These values (5 and 20) are experimentally chosen.
|
||||
stepContainer.height(height + 5);
|
||||
this.elmStepContainer.height(height + 20);
|
||||
}
|
||||
|
||||
_init(this);
|
||||
};
|
||||
|
||||
|
||||
|
||||
(function($){
|
||||
|
||||
$.fn.smartWizard = function(method) {
|
||||
var args = arguments;
|
||||
var rv = undefined;
|
||||
var allObjs = this.each(function() {
|
||||
var wiz = $(this).data('smartWizard');
|
||||
if (typeof method == 'object' || ! method || ! wiz) {
|
||||
var options = $.extend({}, $.fn.smartWizard.defaults, method || {});
|
||||
if (! wiz) {
|
||||
wiz = new SmartWizard($(this), options);
|
||||
$(this).data('smartWizard', wiz);
|
||||
}
|
||||
} else {
|
||||
if (typeof SmartWizard.prototype[method] == "function") {
|
||||
rv = SmartWizard.prototype[method].apply(wiz, Array.prototype.slice.call(args, 1));
|
||||
return rv;
|
||||
} else {
|
||||
$.error('Method ' + method + ' does not exist on jQuery.smartWizard');
|
||||
}
|
||||
}
|
||||
});
|
||||
if (rv === undefined) {
|
||||
return allObjs;
|
||||
} else {
|
||||
return rv;
|
||||
}
|
||||
};
|
||||
|
||||
// Default Properties and Events
|
||||
$.fn.smartWizard.defaults = {
|
||||
selected: 0, // Selected Step, 0 = first step
|
||||
keyNavigation: true, // Enable/Disable key navigation(left and right keys are used if enabled)
|
||||
enableAllSteps: false,
|
||||
transitionEffect: 'fade', // Effect on navigation, none/fade/slide/slideleft
|
||||
contentURL:null, // content url, Enables Ajax content loading
|
||||
contentCache:true, // cache step contents, if false content is fetched always from ajax url
|
||||
cycleSteps: false, // cycle step navigation
|
||||
enableFinishButton: false, // make finish button enabled always
|
||||
hideButtonsOnDisabled: false, // when the previous/next/finish buttons are disabled, hide them instead?
|
||||
errorSteps:[], // Array Steps with errors
|
||||
labelNext:'Next',
|
||||
labelPrevious:'Previous',
|
||||
labelFinish:'Finish',
|
||||
noForwardJumping: false,
|
||||
ajaxType: "POST",
|
||||
onLeaveStep: null, // triggers when leaving a step
|
||||
onShowStep: null, // triggers when showing a step
|
||||
onFinish: null // triggers when Finish button is clicked
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
BIN
js/jquery/plugins/smartWizard/loader.gif
Normal file
BIN
js/jquery/plugins/smartWizard/loader.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.7 KiB |
Reference in New Issue
Block a user