//fixs carrier wizard

This commit is contained in:
Vincent Augagneur
2013-07-30 17:46:44 +02:00
parent 3d40814739
commit cf694be5a1
3 changed files with 21 additions and 12 deletions
@@ -1,22 +1,23 @@
<script>var zones_nbr = {$zones|count};</script>
<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>
<td class="border_bottom center"><input name="range_inf[{$range.id_range|intval}]" type="text" value="{$range.delimiter1|string_format:"%.6f"}" /><sup>*</sup></td>
{foreachelse}
<td class="border_bottom center"><input name="range_inf[{$range.id_range|intval}]" type="text" /></td>
<td class="border_bottom center"><input name="range_inf[{$range.id_range|intval}]" type="text" /><sup>*</sup></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>
<td class="center"><input name="range_sup[{$range.id_range|intval}]" type="text" {if isset($form_id) && !$form_id} value="" {else} value="{$range.delimiter2|string_format:"%.6f"}" {/if}/><sup>*</sup></td>
{foreachelse}
<td class="center"><input name="range_sup[{$range.id_range|intval}]" type="text" /></td>
<td class="center"><input name="range_sup[{$range.id_range|intval}]" type="text" /><sup>*</sup></td>
{/foreach}
</tr>
<tr class="fees_all">
@@ -24,11 +25,11 @@
<td></td>
{foreach from=$ranges key=r item=range}
<td class="center border_top border_bottom">
<input type="text" />
<input type="text" {if isset($form_id) && !$form_id} disabled="disabled"{/if} />
</td>
{foreachelse}
<td class="center border_top border_bottom">
<input style="display:none" type="text" />
<input style="display:none" type="text" />
<button class="button">{l s="Validate"}</button>
</td>
{/foreach}
@@ -36,9 +37,13 @@
{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>
<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]) && $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>
<td class="center">
<input name="fees[{$zone.id_zone|intval}][{$range.id_range|intval}]" {if isset($form_id) && !$form_id} disabled="disabled"{/if} 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}
@@ -444,7 +444,7 @@ class AdminCarrierWizardControllerCore extends AdminController
// init blank range
if (!count($tpl_vars['ranges']))
$tpl_vars['ranges'][] = array('id_range' => -1, 'delimiter1' => 0, 'delimiter2' => 100000);
$tpl_vars['ranges'][] = array('id_range' => -1, 'delimiter1' => 0, 'delimiter2' => 0);
}
public function renderGenericForm($fields_form, $fields_value, $tpl_vars = array())
+7 -3
View File
@@ -262,7 +262,7 @@ function bind_inputs()
index = $(this).parent('td').index();
val = $(this).val();
$('tr.fees').each( function () {
$(this).find('td:eq('+index+') input:text').not('disabled').val(val);
$(this).find('td:eq('+index+') input:text:enabled').val(val);
});
return false;
});
@@ -316,6 +316,7 @@ function bind_inputs()
function validateRange(index)
{
console.log('index : '+index);
//reset error css
$('tr.range_sup td input:text').removeClass('field_error');
$('tr.range_inf td input:text').removeClass('field_error');
@@ -351,6 +352,7 @@ function validateRange(index)
if (range_inf < previous_range_sup)
{
$('tr.range_inf td:eq('+index+')').children('input:text').addClass('field_error');
is_ok = false;
}
}
//check if next range is sup only if it's not the last range
@@ -361,6 +363,7 @@ function validateRange(index)
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');
is_ok = false;
}
}
@@ -394,10 +397,11 @@ function disableRange(index)
function add_new_range()
{
last_sup_val = $('tr.range_sup td:last input').val();
//add new rand sup input
$('tr.range_sup td:last').after('<td class="center"><input name="range_sup[]" type="text" /></td>');
$('tr.range_sup td:last').after('<td class="center"><input name="range_sup[]" type="text" /><sup>*</sup></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.range_inf td:last').after('<td class="border_bottom center"><input name="range_inf[]" type="text" value="'+last_sup_val+'" /><sup>*</sup></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>');