//fixed bug on carrier wizard when edit carrier

This commit is contained in:
Vincent Augagneur
2013-08-05 14:06:50 +02:00
parent b8e5ad0e44
commit 5a88dc0f8b
4 changed files with 62 additions and 20 deletions
@@ -14,7 +14,7 @@
<td class="center range_type"></td>
<td class="border_left range_sign"><</td>
{foreach from=$ranges key=r item=range}
<td class="center"><input name="range_sup[{$range.id_range|intval}]" type="text" {if isset($form_id) && !$form_id} value="" {else} value="{if isset($change_ranges) && $range.id_range == -1} {else}{$range.delimiter2|string_format:"%.6f"}{/if}" {/if}/><sup>*</sup><span class="weight_unit">&nbsp; {$PS_WEIGHT_UNIT}</span><span class="price_unit">&nbsp; {$currency_sign}</span></td>
<td class="center"><input name="range_sup[{$range.id_range|intval}]" type="text" {if isset($form_id) && !$form_id} value="" {else} value="{if isset($change_ranges) && $range.id_range == 0} {else}{$range.delimiter2|string_format:"%.6f"}{/if}" {/if}/><sup>*</sup><span class="weight_unit">&nbsp; {$PS_WEIGHT_UNIT}</span><span class="price_unit">&nbsp; {$currency_sign}</span></td>
{foreachelse}
<td class="center"><input name="range_sup[{$range.id_range|intval}]" type="text" /><sup>*</sup><span class="weight_unit">&nbsp; {$PS_WEIGHT_UNIT}</span><span class="price_unit">&nbsp; {$currency_sign}</span></td>
{/foreach}
@@ -23,8 +23,8 @@
<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 {if $range.id_range != -1} validated {/if}" >
<input type="text" {if isset($form_id) && !$form_id} disabled="disabled"{/if} {if $range.id_range == -1} style="display:none"{/if} /><span class="currency_sign" {if $range.id_range == -1} style="display:none" {/if}>&nbsp; {$currency_sign}</span>
<td class="center border_top border_bottom {if $range.id_range != 0} validated {/if}" >
<input type="text" {if isset($form_id) && !$form_id} disabled="disabled"{/if} {if $range.id_range == 0} style="display:none"{/if} /><span class="currency_sign" {if $range.id_range == 0} style="display:none" {/if}>&nbsp; {$currency_sign}</span>
</td>
{foreachelse}
<td class="center border_top border_bottom">
@@ -454,7 +454,7 @@ class AdminCarrierWizardControllerCore extends AdminController
// init blank range
if (!count($tpl_vars['ranges']))
$tpl_vars['ranges'][] = array('id_range' => -1, 'delimiter1' => 0, 'delimiter2' => 0);
$tpl_vars['ranges'][] = array('id_range' => 0, 'delimiter1' => 0, 'delimiter2' => 0);
}
public function renderGenericForm($fields_form, $fields_value, $tpl_vars = array())
@@ -607,17 +607,36 @@ class AdminCarrierWizardControllerCore extends AdminController
{
if (!isset($range_sup[$key]))
continue;
$add_range = true;
if ($range_type == Carrier::SHIPPING_METHOD_WEIGHT)
$range = new RangeWeight((int)$key);
{
if (!RangeWeight::rangeExist((int)$carrier->id, (float)$delimiter1, (float)$range_sup[$key]))
$range = new RangeWeight();
else
{
$range = new RangeWeight((int)$key);
$add_range = false;
}
}
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 (!RangePrice::rangeExist((int)$carrier->id, (float)$delimiter1, (float)$range_sup[$key]))
$range = new RangePrice();
else
{
$range = new RangePrice((int)$key);
$add_range = false;
}
}
if ($add_range)
{
$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();
@@ -632,7 +651,7 @@ class AdminCarrierWizardControllerCore extends AdminController
'price' => (float)$fee[$key]
);
}
if (count($price_list) && !$carrier->addDeliveryPrice($price_list, true))
return false;
}
@@ -692,9 +711,9 @@ class AdminCarrierWizardControllerCore extends AdminController
$new_carrier->position = $current_carrier->position;
$new_carrier->update();
$this->updateAssoShop($new_carrier->id);
$new_carrier->copyCarrierData((int)$current_carrier->id);
$this->changeGroups($new_carrier->id);
$this->updateAssoShop((int)$new_carrier->id);
$this->duplicateLogo((int)$new_carrier->id, (int)$current_carrier->id);
$this->changeGroups((int)$new_carrier->id);
// Call of hooks
Hook::exec('actionCarrierUpdate', array(
'id_carrier' => (int)$current_carrier->id,
@@ -848,4 +867,19 @@ class AdminCarrierWizardControllerCore extends AdminController
{
return $field;
}
public function duplicateLogo($new_id, $old_id)
{
$old_logo = _PS_SHIP_IMG_DIR_.'/'.(int)$old_id.'.jpg';
if (file_exists($old_logo))
copy($old_logo, _PS_SHIP_IMG_DIR_.'/'.(int)$new_id.'.jpg');
$old_tmp_logo = _PS_TMP_IMG_DIR_.'/carrier_mini_'.(int)$old_id.'.jpg';
if (file_exists($old_tmp_logo))
{
if (!isset($_FILES['logo']))
copy($old_tmp_logo, _PS_TMP_IMG_DIR_.'/carrier_mini_'.$new_id.'.jpg');
unlink($old_tmp_logo);
}
}
}
+2 -3
View File
@@ -2593,7 +2593,6 @@ margin-bottom:7px;
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;
@@ -2625,9 +2624,9 @@ margin-bottom:7px;
#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:#FFCCCCheight: 1px;}
#carrier_wizard input.field_error {border : solid 1px red; background-color:#FFCCCC;}
#carrier_wizard table td.center {text-align: center}
#carrier_wizard .new_range {float: left; margin: 20px 0 0 10px; width: 130px;}
#carrier_wizard .new_range, #carrier_wizard .validate_range {float: left; margin: 20px 0 0 10px; width: 130px;}
#carrier_wizard tr.fees_all { background: #CCCCCC}
#carrier_wizard #zones_table input[type=text] {width: 45px;}
#carrier_wizard #fieldset_form { min-height: 190px}
+9
View File
@@ -94,6 +94,9 @@ function onFinishCallback(obj, context)
}
else
window.location.href = carrierlist_url;
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
jAlert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
}
});
}
@@ -202,6 +205,9 @@ function validateSteps(step_number)
displayError(datas.errors, step_number);
resizeWizard();
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
jAlert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
}
});
return is_ok;
@@ -315,6 +321,9 @@ function bind_inputs()
$('#zone_ranges').replaceWith(data);
displayRangeType();
bind_inputs();
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
jAlert("TECHNICAL ERROR: \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
}
});
});