// Virtual Product bootsraping

This commit is contained in:
Jerome Nadaud
2013-12-10 13:51:34 +01:00
parent d511828a91
commit 992dddcbb4
2 changed files with 159 additions and 172 deletions
@@ -48,193 +48,193 @@
var fileName = data.getAttribute("filename"); var fileName = data.getAttribute("filename");
if (result == "error") if (result == "error")
{ {
$("#upload-confirmation").hide(); $("#upload-confirmation").closest('.form-group.').hide();
$("#upload-error td").html('<div class="error">{l s='Error:'} ' + msg + '</div>'); $("#upload-error").html('{l s='Error:'} ' + msg);
$("#upload-error").show(); $("#upload-error").closest('.form-group.').show();
} }
else else
{ {
$('#upload-error').hide(); $('#upload-error').closest('.form-group.').hide();
$('#file_missing').hide(); $('#file_missing').closest('.form-group.').hide();
$('#virtual_product_name').attr('value', fileName); $('#virtual_product_name').attr('value', fileName);
$("#upload-confirmation .error").remove(); $("#upload-confirmation .error").remove();
$('#upload-confirmation div').find('span').remove(); $('#upload-confirmation').find('span').remove();
$('#upload-confirmation div').prepend('<span>{l s='The file'}&nbsp;"<a class="link" href="get-file-admin.php?file='+msg+'&filename='+fileName+'">'+fileName+'</a>"&nbsp;{l s='has successfully been uploaded'}' + $('#upload-confirmation').prepend('<span>{l s='The file'}&nbsp;"<a class="link" href="get-file-admin.php?file='+msg+'&filename='+fileName+'">'+fileName+'</a>"&nbsp;{l s='has successfully been uploaded'}&nbsp;' +
'<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="' + msg + '" /></span>'); '<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="' + msg + '" /></span>');
$("#upload-confirmation").show(); $("#upload-confirmation").closest('.form-group.').show();
} }
} }
} }
); );
} }
function uploadFile2() $(document).ready(function(){
{ $('#virtual_product_file-selectbutton').click(function(e) {
var link = ''; $('#virtual_product_file').trigger('click');
$.ajaxFileUpload ( });
$('#virtual_product_file-name').click(function(e) {
$('#virtual_product_file').trigger('click');
});
$('#virtual_product_file').change(function(e) {
if ($(this)[0].files !== undefined)
{ {
url:'./uploadProductFileAttribute.php', var files = $(this)[0].files;
secureuri:false, var name = '';
fileElementId:'virtual_product_file_attribute',
dataType: 'xml',
success: function (data, status)
{
data = data.getElementsByTagName('return')[0];
var result = data.getAttribute("result");
var msg = data.getAttribute("msg");
var fileName = data.getAttribute("filename");
if(result == "error")
$("#upload-confirmation2").html('<p>error: ' + msg + '</p>');
else
{
$('#virtual_product_file_attribute').remove();
$('#virtual_product_file_label').hide();
$('#file_missing').hide();
$('#delete_downloadable_product_attribute').show();
$('#upload-confirmation2').html(
'<a class="link" href="get-file-admin.php?file='+msg+'&filename='+fileName+'">{l s='The file'}&nbsp;"' + fileName + '"&nbsp;{l s='has successfully been uploaded'}</a>' +
'<input type="hidden" id="virtual_product_filename_attribute" name="virtual_product_filename_attribute" value="' + msg + '" />');
$('#virtual_product_name_attribute').attr('value', fileName);
link = $("#delete_downloadable_product_attribute").attr('href'); $.each(files, function(index, value) {
$("#delete_downloadable_product_attribute").attr('href', link+"&file="+msg); name += value.name+', ';
} });
}
$('#virtual_product_file-name').val(name.slice(0, -2));
} }
); else // Internet Explorer 9 Compatibility
} {
var name = $(this).val().split(/[\\/]/);
$('#virtual_product_file-name').val(name[name.length-1]);
}
uploadFile();
});
});
</script> </script>
<div id="product-virtualproduct" class="panel product-tab">
<input type="hidden" name="submitted_tabs[]" value="VirtualProduct" /> <input type="hidden" name="submitted_tabs[]" value="VirtualProduct" />
<h4>{l s='Virtual Product (services, booking or downloadable products)'}</h4> <h3>{l s='Virtual Product (services, booking or downloadable products)'}</h3>
<div class="separation"></div> <div class="is_virtual_good" class="form-group">
<div> <input type="checkbox" id="is_virtual_good" name="is_virtual_good" value="true" {if $product->is_virtual && $product->productDownload->active}checked="checked"{/if} />
<div class="is_virtual_good"> <label for="is_virtual_good" class="t bold">{l s='Is this a virtual product?'}</label>
<input type="checkbox" id="is_virtual_good" name="is_virtual_good" value="true" {if $product->is_virtual && $product->productDownload->active}checked="checked"{/if} /> </div>
<label for="is_virtual_good" class="t bold">{l s='Is this a virtual product?'}</label> <div id="virtual_good" {if !$product->productDownload->id || $product->productDownload->active}style="display:none"{/if} class="form-group">
</div> <div class="form-group">
{* [begin] virtual product *} <label class="control-label col-lg-3">{l s='Does this product have an associated file?'}</label>
<div id="virtual_good" {if !$product->productDownload->id || $product->productDownload->active}style="display:none"{/if} > <div class="col-lg-9">
<div> <label class="switch-light prestashop-switch fixed-width-lg">
<label>{l s='Does this product have an associated file?'}</label> <input name="is_virtual_file" id="is_virtual_file" type="checkbox"{if $product_downloaded} checked="checked"{/if} value="{if $product_downloaded}1{else}0{/if}" />
<label style="width:50px"><input type="radio" value="1" name="is_virtual_file" {if $product_downloaded}checked="checked"{/if} />{l s='Yes'}</label> <span>
<label style="width:50px;"><input type="radio" value="0" name="is_virtual_file" {if !$product_downloaded}checked="checked"{/if} />{l s='No'}</label> <span>{l s='Yes'}</span>
</div><br /> <span>{l s='No'}</span>
<div class="separation"></div> </span>
{if $download_product_file_missing} <a class="slide-button btn btn-default"></a>
<p class="alert" id="file_missing"> </label>
<b>{$download_product_file_missing} :<br/> </div>
{$smarty.const._PS_DOWNLOAD_DIR_}/{$product->productDownload->filename}</b> </div>
</p> <div id="is_virtual_file_product" style="display:none;">
{/if} {if $download_product_file_missing}
<div class="form-group">
<div id="is_virtual_file_product" style="display:none;"> <div class="col-lg-push-3 col-lg-9">
{if !$download_dir_writable} <div class="alert alert-danger" id="file_missing">
<p class="alert"> {$download_product_file_missing} :<br/>
{l s='Your download repository is not writable.'}<br/> <strong>{l s='Server file name : %s'|sprintf:$product->productDownload->filename}</strong>
{$smarty.const._PS_DOWNLOAD_DIR_} </div>
</p> </div>
{/if} </div>
{* Don't display file form if the product has combinations *}
{if empty($product->cache_default_attribute)}
{if $product->productDownload->id}
<input type="hidden" id="virtual_product_id" name="virtual_product_id" value="{$product->productDownload->id}" />
{/if} {/if}
<table cellpadding="5" style="float: left; margin-left: 10px;"> {if !$download_dir_writable}
<tr id="upload_input" {if $is_file}style="display:none"{/if}> <div class="form-group">
<td class="col-left"> <div class="col-lg-push-3 col-lg-9">
<label id="virtual_product_file_label" for="virtual_product_file" class="t">{l s='Upload a file'}</label> <div class="alert alert-danger">
</td> {l s='Your download repository is not writable.'}
<td class="col-right"> </div>
<input type="file" id="virtual_product_file" name="virtual_product_file" onchange="uploadFile();" maxlength="{$upload_max_filesize}" /> </div>
<p class="preference_description">{l s='Your server\'s maximum file-upload size is'}:&nbsp;{$upload_max_filesize} {l s='MB'}</p> </div>
</td> {/if}
</tr> {* Don't display file form if the product has combinations *}
<tr id="upload-error" style="display:none"> {if empty($product->cache_default_attribute)}
<td colspan=2></td> {if $product->productDownload->id}
</tr> <input type="hidden" id="virtual_product_id" name="virtual_product_id" value="{$product->productDownload->id}" />
<tr id="upload-confirmation" style="display:none"> {/if}
<td colspan=2> <div class="form-group"{if $is_file} style="display:none"{/if}>
{if $up_filename} <label id="virtual_product_file_label" for="virtual_product_file" class="control-label col-lg-3">{l s='Upload a file'}</label>
<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="{$up_filename}" /> <div class="col-lg-9">
{/if} <input id="virtual_product_file" type="file" name="virtual_product_file" class="hide" maxlength="{$upload_max_filesize}" />
<div class="alert"> <div class="dummyfile input-group">
<script> <span class="input-group-addon"><i class="icon-file"></i></span>
delete_this_file = '{l s='Delete this file'}'; <input id="virtual_product_file-name" type="text" class="disabled" name="filename" readonly />
</script> <span class="input-group-btn">
<a class="delete_virtual_product" id="delete_downloadable_product" href="{$currentIndex}&deleteVirtualProduct=true&token={$token}&id_product={$product->id}" class="red"> <button id="virtual_product_file-selectbutton" type="button" name="submitAddAttachments" class="btn btn-default">
<img src="../img/admin/delete.gif" alt="{l s='Delete this file'}"/> <i class="icon-folder-open"></i> {l s='Add file'}
</button>
</span>
</div>
<p class="help-block">{l s='Your server\'s maximum file-upload size is'}:&nbsp;{$upload_max_filesize} {l s='MB'}</p>
</div>
</div>
<div class="form-group" style="display:none">
<div class="col-lg-push-3 col-lg-9">
<div class="alert alert-error col-lg-push-3 col-lg-9" id="upload-error"></div>
</div>
</div>
<div class="form-group" style="display:none">
<div class="col-lg-push-3 col-lg-9">
{if $up_filename}
<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="{$up_filename}" />
{/if}
<div class="alert alert-info" id="upload-confirmation">
<a class="btn btn-default" id="delete_downloadable_product" href="{$currentIndex}&deleteVirtualProduct=true&token={$token}&id_product={$product->id}"><i class="icon-trash"></i> {l s='Delete this file'}
</a> </a>
</div> </div>
</td> </div>
</tr> </div>
{if $is_file} {if $is_file}
<tr> <div class="form-group">
<td class="col-left"> <label class="control-label col-lg-3">{l s='Link to the file:'}</label>
<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="{$product->productDownload->filename}" /> <div class="col-lg-9">
<label class="t">{l s='Link to the file:'}</label> <input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="{$product->productDownload->filename}" />
</td> <a href="{$product->productDownload->getTextLink(true)}" class="btn btn-default"><i class="icon-download"></i> {l s='Download file'}</a>
<td class="col-right"> <a href="{$currentIndex}&deleteVirtualProduct=true&token={$token}&id_product={$product->id}" class="btn btn-default"><i class="icon-trash"></i> {l s='Delete this file'}</a>
{$product->productDownload->getHtmlLink(false, true)} </div>
<a href="{$currentIndex}&deleteVirtualProduct=true&token={$token}&id_product={$product->id}" class="red delete_virtual_product"> </div>
<img src="../img/admin/delete.gif" alt="{l s='Delete this file'}"/>
</a>
</td>
</tr>
{/if} {/if}
<tr> <div class="form-group">
<td class="col-left"> <label class="control-label col-lg-3">{l s='Filename'}</label>
<label for="virtual_product_name" class="t">{l s='Filename'}</label> <div class="col-lg-9">
</td>
<td class="col-right">
<input type="text" id="virtual_product_name" name="virtual_product_name" style="width:200px" value="{$product->productDownload->display_filename|escape:'html':'UTF-8'}" /> <input type="text" id="virtual_product_name" name="virtual_product_name" style="width:200px" value="{$product->productDownload->display_filename|escape:'html':'UTF-8'}" />
<p class="preference_description" name="help_box">{l s='The full filename with its extension (e.g. Book.pdf)'}</p> <p class="help-block">{l s='The full filename with its extension (e.g. Book.pdf)'}</p>
</td> </div>
</tr> </div>
<tr> <div class="form-group">
<td class="col-left"> <label class="control-label col-lg-3">{l s='Number of allowed downloads'}</label>
<label for="virtual_product_nb_downloable" class="t">{l s='Number of allowed downloads'}</label> <div class="col-lg-9">
</td>
<td class="col-right">
<input type="text" id="virtual_product_nb_downloable" name="virtual_product_nb_downloable" value="{$product->productDownload->nb_downloadable|htmlentities}" class="" size="6" /> <input type="text" id="virtual_product_nb_downloable" name="virtual_product_nb_downloable" value="{$product->productDownload->nb_downloadable|htmlentities}" class="" size="6" />
<p class="preference_description">{l s='Number of downloads allowed per customer. (Set to 0 for unlimited downloads)'}</p> <p class="help-block">{l s='Number of downloads allowed per customer. (Set to 0 for unlimited downloads)'}</p>
</td> </div>
</tr> </div>
<tr> <div class="form-group">
<td class="col-left"> <label class="control-label col-lg-3">
<label for="virtual_product_expiration_date" class="t">{l s='Expiration date'}</label> <span class="label-tooltip" data-toggle="tooltip" title="" data-original-title="{l s='Format: YYYY-MM-DD'}">
</td> {l s='Expiration date'}
<td class="col-right"> </span>
<input class="datepicker" type="text" id="virtual_product_expiration_date" name="virtual_product_expiration_date" value="{$product->productDownload->date_expiration}" size="11" maxlength="10" autocomplete="off" /> {l s='Format: YYYY-MM-DD'} </label>
<p class="preference_description">{l s='If set, the file will not be downloadable after this date. Leave blank if you do not wish to attach an expiration date.'}</p> <div class="col-lg-9">
</td> <input class="datepicker" type="text" id="virtual_product_expiration_date" name="virtual_product_expiration_date" value="{$product->productDownload->date_expiration}" size="11" maxlength="10" autocomplete="off" />
</tr> <p class="help-block">{l s='If set, the file will not be downloadable after this date. Leave blank if you do not wish to attach an expiration date.'}</p>
<td class="col-left"> </div>
<label for="virtual_product_nb_days" class="t">{l s='Number of days'}</label> </div>
</td> <div class="form-group">
<td class="col-right"> <label class="control-label col-lg-3 required">{l s='Number of days'}</label>
<input type="text" id="virtual_product_nb_days" name="virtual_product_nb_days" value="{$product->productDownload->nb_days_accessible|htmlentities}" class="" size="4" /><sup> *</sup> <div class="col-lg-9">
<p class="preference_description">{l s='Number of days this file can be accessed by customers'} - <em>({l s='Set to zero for unlimited access.'})</em></p> <input type="text" id="virtual_product_nb_days" name="virtual_product_nb_days" value="{$product->productDownload->nb_days_accessible|htmlentities}" class="" size="4" />
</td> <p class="help-block">{l s='Number of days this file can be accessed by customers'} - <em>({l s='Set to zero for unlimited access.'})</em></p>
</tr> </div>
</div>
{* Feature not implemented *} {* Feature not implemented *}
{*<tr>*} {*<div class="form-group">*}
{*<td class="col-left">*} {*<label for="virtual_product_is_shareable" class="control-label col-lg-3">{l s='is shareable'}</label>*}
{*<label for="virtual_product_is_shareable" class="t">{l s='is shareable'}</label>*} {*<div class="col-lg-9">*}
{*</td>*}
{*<td class="col-right">*}
{*<input type="checkbox" id="virtual_product_is_shareable" name="virtual_product_is_shareable" value="1" {if $product->productDownload->is_shareable}checked="checked"{/if} />*} {*<input type="checkbox" id="virtual_product_is_shareable" name="virtual_product_is_shareable" value="1" {if $product->productDownload->is_shareable}checked="checked"{/if} />*}
{*<span class="alert alert-info" name="help_box" style="display:none">{l s='Please specify if the file can be shared.'}</span>*} {*<span class="alert alert-info" name="help_box" style="display:none">{l s='Please specify if the file can be shared.'}</span>*}
{*</td>*} {*</div>*}
{*</tr>*} {*</div>*}
{else} <div class="alert alert-info">
<div class="alert alert-info" style="display: block;width: 70%;">{l s='You cannot edit your file here because you used combinations. Please edit this file in the Combinations tab.'}</div> {l s='You cannot edit your file here because you used combinations. Please edit this file in the Combinations tab.'}
<br /> </div>
{if isset($error_product_download)}{$error_product_download}{/if} {if isset($error_product_download)}{$error_product_download}{/if}
{/if} {/if}
</table> </div>
</div> </div>
</div> </div>
<div style="clear:both"></div>
</div> </div>
+1 -14
View File
@@ -1332,33 +1332,20 @@ product_tabs['VirtualProduct'] = new function(){
if ($('#is_virtual_good').prop('checked')) if ($('#is_virtual_good').prop('checked'))
{ {
$('#virtual_good').show(); $('#virtual_good').show();
$('#virtual_good_more').show();
} }
$('.is_virtual_good').hide(); $('.is_virtual_good').hide();
if ( $('input[name=is_virtual_file]:checked').val() == 1) if ( $('input[name=is_virtual_file]:checked').val() == 1)
{
$('#virtual_good_more').show();
$('#is_virtual_file_product').show(); $('#is_virtual_file_product').show();
}
else else
{
$('#virtual_good_more').hide();
$('#is_virtual_file_product').hide(); $('#is_virtual_file_product').hide();
}
$('input[name=is_virtual_file]').live('change', function(e) { $('input[name=is_virtual_file]').live('change', function(e) {
if($(this).val() == '1') if($(this).prop('checked'))
{
$('#virtual_good_more').show();
$('#is_virtual_file_product').show(); $('#is_virtual_file_product').show();
}
else else
{
$('#virtual_good_more').hide();
$('#is_virtual_file_product').hide(); $('#is_virtual_file_product').hide();
}
}); });
// Bind file deletion // Bind file deletion