// Added logo remove link in carrier wizard

This commit is contained in:
Damien Metzger
2013-07-18 10:54:05 +02:00
parent d7c6516c32
commit 9a0e3ca81e
4 changed files with 29 additions and 7 deletions
@@ -29,12 +29,24 @@
<input id="carrier_logo_input" type="file" onchange="uploadCarrierLogo();" name="carrier_logo_input" /> <input id="carrier_logo_input" type="file" onchange="uploadCarrierLogo();" name="carrier_logo_input" />
<input type="hidden" id="logo" name="logo" value="" /> <input type="hidden" id="logo" name="logo" value="" />
</p> </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> <p>
{l s='Format:'} JPG, GIF, PNG. {l s='Filesize:'} {$max_image_size|string_format:"%.2f"} {l s='MB max.'} {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> </p>
</div> </div>
<script type="text/javascript"> <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() function uploadCarrierLogo()
{ {
$.ajaxFileUpload({ $.ajaxFileUpload({
@@ -49,6 +61,7 @@
{ {
$('#carrier_logo_img').attr('src', message); $('#carrier_logo_img').attr('src', message);
$('#logo').val(message); $('#logo').val(message);
$('#carrier_logo_remove').show();
fixCarrierLogoDisplay(); fixCarrierLogoDisplay();
} }
else else
@@ -63,6 +76,7 @@
var maxHeight = 200; var maxHeight = 200;
var maxWidth = 200; var maxWidth = 200;
var res = this.width / this.height; 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').width(this.width);
$('#carrier_logo_img').height(this.height); $('#carrier_logo_img').height(this.height);
if ($('#carrier_logo_img').width() > maxWidth) if ($('#carrier_logo_img').width() > maxWidth)
@@ -74,7 +88,9 @@
{ {
$('#carrier_logo_img').height(maxHeight); $('#carrier_logo_img').height(maxHeight);
$('#carrier_logo_img').width(maxHeight * res); $('#carrier_logo_img').width(maxHeight * res);
} }
if ($('#logo').val() == 'null')
$('#carrier_logo_size').text(carrier_translation_undefined);
}); });
} }
@@ -38,7 +38,8 @@
</script> </script>
<fieldset> <fieldset>
<legend>{l s='Summary'} - <span id="summary_name"></span></legend> {l s='Carrier name:'} <strong id="summary_name"></strong>
<div class="clear">&nbsp;</div>
<div id="summary_meta_informations"></div> <div id="summary_meta_informations"></div>
<div class="clear">&nbsp;</div> <div class="clear">&nbsp;</div>
<div id="summary_shipping_cost"></div> <div id="summary_shipping_cost"></div>
@@ -635,11 +635,16 @@ class AdminCarrierWizardControllerCore extends AdminController
if (Tools::getValue('logo')) if (Tools::getValue('logo'))
{ {
$logo = basename(Tools::getValue('logo')); if (Tools::getValue('logo') == 'null' && file_exists(_PS_SHIP_IMG_DIR_.$carrier->id.'.jpg'))
if (!file_exists(_PS_TMP_IMG_DIR_.$logo) || !copy(_PS_TMP_IMG_DIR_.$logo, _PS_SHIP_IMG_DIR_.$carrier->id.'.jpg')) unlink(_PS_SHIP_IMG_DIR_.$carrier->id.'.jpg');
else
{ {
$return['has_error'] = true; $logo = basename(Tools::getValue('logo'));
$return['errors'][] = $this->l('An error occurred while saving carrier 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; $return['id_carrier'] = $carrier->id;
+1 -1
View File
@@ -91,7 +91,7 @@ function displaySummary()
$('#summary_name').html($('#name').val()); $('#summary_name').html($('#name').val());
// Delay and pricing // Delay and pricing
tmp = summary_translation_meta_informations.replace('@s2', $('#delay_1').val()); tmp = summary_translation_meta_informations.replace('@s2', '<strong>' + $('#delay_1').val() + '</strong>');
if ($('#is_free_on').attr('checked')) if ($('#is_free_on').attr('checked'))
tmp = tmp.replace('@s1', summary_translation_free); tmp = tmp.replace('@s1', summary_translation_free);
else else