293 lines
14 KiB
Smarty
293 lines
14 KiB
Smarty
<script>
|
|
$(document).ready(function () {
|
|
|
|
$('.psi_addfile').parent().parent().hide();
|
|
|
|
function getfilesize()
|
|
{
|
|
var filename = $('#saveas').val();
|
|
|
|
$.get(
|
|
"{$smarty.const.__PS_BASE_URI__}modules/pshowimporter/getfilesize.php?filename=" + filename,
|
|
function (r) {
|
|
$('.full-screen-loader .loader #uploadStatus').html(r);
|
|
setTimeout(function () {
|
|
getfilesize()
|
|
}, 100);
|
|
}
|
|
);
|
|
}
|
|
|
|
$(document).on('submit', '#filesendform', function (e) {
|
|
|
|
if ($('.csvdelim-form-group input').val() === '' && ($('input#file').val().split('.').pop() === 'csv' || $('select[name="fileext"]').val() === 'csv')) {
|
|
e.preventDefault();
|
|
alert("CSV column delimiter is required!");
|
|
return false;
|
|
}
|
|
|
|
$('.full-screen-loader .loader')
|
|
.append('<br><br><br><div id="uploadStatus" style="background: #000; color: #fff; padding:5px;"><strong>Downloading: 0B</strong></div>');
|
|
|
|
if ($('input#file').val() !== "")
|
|
{
|
|
$('.full-screen-loader .loader #uploadStatus').html('<strong>Uploading...</strong>');
|
|
|
|
return;
|
|
}
|
|
|
|
getfilesize();
|
|
|
|
});
|
|
|
|
$(document).on('change', 'select[name="fileext"]', function () {
|
|
if ($(this).val() === 'csv') {
|
|
$('.csvdelim-form-group').removeClass('hidden');
|
|
$('.csvdelim-form-group input').attr('required', 'required');
|
|
} else {
|
|
$('.csvdelim-form-group').addClass('hidden');
|
|
$('.csvdelim-form-group input').removeAttr('required');
|
|
}
|
|
});
|
|
|
|
$(document).on('change', 'input#file', function () {
|
|
console.log($(this).val().split('.').pop());
|
|
if ($(this).val().split('.').pop() === 'csv') {
|
|
$('.csvdelim-form-group').removeClass('hidden');
|
|
$('.csvdelim-form-group input').attr('required', 'required');
|
|
} else {
|
|
$('.csvdelim-form-group').addClass('hidden');
|
|
$('.csvdelim-form-group input').removeAttr('required');
|
|
}
|
|
});
|
|
|
|
});
|
|
</script>
|
|
|
|
<div class="panel">
|
|
<form class="defaultForm form-horizontal" id="filesendform" action="" method="post" enctype="multipart/form-data" novalidate="">
|
|
<div class="psi_addfile">
|
|
<div class="panel-heading">
|
|
<i class="icon-folder-close"></i>
|
|
{l s='Add new file' mod='pshowimporter'}
|
|
</div>
|
|
<div class="panel-wrapper">
|
|
|
|
|
|
<ul class="nav nav-tabs">
|
|
<li class="active"><a data-toggle="tab" href="#home">{l s='Upload file from local disk'}</a></li>
|
|
<li><a data-toggle="tab" href="#menu1">{l s='Download file from URL'}</a></li>
|
|
</ul>
|
|
|
|
<div class="panel tab-content">
|
|
<div id="home" class="tab-pane fade in active">
|
|
{if isset($upload_max_filesize_error)}
|
|
<div class="alert alert-warning">
|
|
{l s='Ask administrator to change the value of upload_max_filesize for a minimum of 100M to allow you to upload larger files.' mod='pshowimporter'}
|
|
<small>{l s='Actual'}: {ini_get("upload_max_filesize")}</small>
|
|
</div>
|
|
{/if}
|
|
{if isset($post_max_size_error)}
|
|
<div class="alert alert-warning">
|
|
{l s='Ask administrator to change the value of post_max_size for a minimum of 150M to allow you to upload larger files.' mod='pshowimporter'}
|
|
<small>{l s='Actual'}: {ini_get("post_max_size")}</small>
|
|
</div>
|
|
{/if}
|
|
{if isset($memory_limit_error)}
|
|
<div class="alert alert-warning">
|
|
{l s='Ask administrator to change the value of memory_limit for a minimum of 200M to allow you to upload larger files.' mod='pshowimporter'}
|
|
<small>{l s='Actual'}: {ini_get("memory_limit")}</small>
|
|
</div>
|
|
{/if}
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="file" class="control-label col-lg-4">
|
|
<span title="" data-toggle="tooltip" class="label-tooltip" data-original-title="Plik zostanie przesłany z twojego dysku">
|
|
{l s='Upload file from local disk' mod='pshowimporter'}
|
|
</span>
|
|
</label>
|
|
<div class="col-md-8">
|
|
<input id="file" type="file" name="file" class="hidden">
|
|
|
|
<button onclick="javascript:$('#filesendform #file').click().removeClass('hidden');
|
|
$(this).remove();" class="ladda-button btn btn-default" data-style="expand-right" data-size="s" type="button" id="file-add-button">
|
|
<span class="ladda-label">
|
|
<i class="icon-folder-open"></i>
|
|
{l s='Upload file' mod='pshowimporter'}
|
|
</span>
|
|
</button>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
<div id="menu1" class="tab-pane fade">
|
|
<div class="form-group">
|
|
|
|
<label for="url" class="control-label col-lg-4">
|
|
<span title="" data-toggle="tooltip" class="label-tooltip" data-original-title="{l s='The file will be downloaded from the specified address' mod='pshowimporter'}">
|
|
{l s='Add file from URL address' mod='pshowimporter'}
|
|
</span>
|
|
</label>
|
|
<div class="col-md-8">
|
|
<select name="fileext" class="pull-left" style="width: 10%;">
|
|
<option value="xml">XML</option>
|
|
<option value="csv">CSV</option>
|
|
</select>
|
|
<input id="url" style="width: 88%;" class="pull-right label-tooltip" placeholder="http://" type="text" name="url" autocomplete="off"
|
|
readonly="readonly" onfocus="this.removeAttribute('readonly');" data-toggle="tooltip" data-original-title="Click to edit">
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<label class="control-label col-lg-4">
|
|
{l s='Authorization required' mod='pshowimporter'}
|
|
</label>
|
|
|
|
<div class="col-lg-8">
|
|
|
|
<span class="switch prestashop-switch fixed-width-lg">
|
|
<input type="radio" name="auth_req" id="auth_req_on" value="1">
|
|
<label for="auth_req_on">{l s='Yes' mod='pshowimporter'}</label>
|
|
<input type="radio" name="auth_req" id="auth_req_off" value="0" checked="checked">
|
|
<label for="auth_req_off">{l s='No' mod='pshowimporter'}</label>
|
|
<a class="slide-button btn"></a>
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group form-upload-auth">
|
|
<label class="control-label col-lg-4">
|
|
{l s='Login' mod='pshowimporter'}
|
|
</label>
|
|
<div class="col-lg-8">
|
|
<input type="text" name="login" class="label-tooltip" value="" autocomplete="off" readonly="readonly"
|
|
onfocus="this.removeAttribute('readonly');" data-toggle="tooltip" data-original-title="Click to edit">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group form-upload-auth">
|
|
<label class="control-label col-lg-4">
|
|
{l s='Password' mod='pshowimporter'}
|
|
</label>
|
|
<div class="col-lg-8">
|
|
<input type="password" name="password" class="label-tooltip" value="" autocomplete="off" readonly="readonly"
|
|
onfocus="this.removeAttribute('readonly');" data-toggle="tooltip" data-original-title="Click to edit">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="clearfix"></div>
|
|
|
|
<hr>
|
|
|
|
<div class="form-group">
|
|
<label for="saveas" class="control-label col-lg-4">
|
|
<span title="" data-toggle="tooltip" class="label-tooltip" data-original-title="">
|
|
{l s='Save as' mod='pshowimporter'}:
|
|
</span>
|
|
</label>
|
|
<div class="col-md-8">
|
|
<input id="saveas" value="import__{$smarty.now|date_format:'H_i__d_m_Y'}" type="text" name="saveas">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group csvdelim-form-group hidden">
|
|
<label for="csvdelim" class="control-label col-lg-4">
|
|
<span title="" data-toggle="tooltip" class="label-tooltip" data-original-title="">
|
|
{l s='CSV column delimiter' mod='pshowimporter'} ({l s='one character!' mod='pshowimporter'}):
|
|
</span>
|
|
</label>
|
|
<div class="col-md-8">
|
|
<input id="csvdelim" value="" type="text" name="csvdelim"><br>
|
|
<small>{l s='For tabulation enter: tab' mod='pshowimporter'}</small>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group csvdelim-form-group hidden">
|
|
|
|
<label class="control-label col-lg-4" for="file_encoding">
|
|
<span title="" data-toggle="tooltip" class="label-tooltip" data-original-title="">
|
|
{l s='File encoding' mod='pshowimporter'}
|
|
</span>
|
|
</label>
|
|
|
|
<div class="col-lg-8">
|
|
|
|
<select class="form-control" id="file_encoding" name="file_encoding">
|
|
<option value="UTF-8">UTF-8 (default)</option>
|
|
<option value="ISO-8859-2">Latin 2 (ISO-8859-2)</option>
|
|
<option disabled>{l s='write to us if your file has other encoding' mod='pshowimporter'}</option>
|
|
</select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group csvdelim-form-group hidden">
|
|
<label for="headers_in_the_file_on" class="control-label col-lg-4">
|
|
<span title="" data-toggle="tooltip" class="label-tooltip" data-original-title="">
|
|
{l s='First row contains column headers' mod='pshowimporter'}:
|
|
</span>
|
|
</label>
|
|
<div class="col-md-8">
|
|
<span class="switch prestashop-switch fixed-width-lg">
|
|
<input type="radio" name="headers_in_the_file" id="headers_in_the_file_on" value="1" checked="checked">
|
|
<label for="headers_in_the_file_on">Tak</label>
|
|
<input type="radio" name="headers_in_the_file" id="headers_in_the_file_off" value="0">
|
|
<label for="headers_in_the_file_off">Nie</label>
|
|
<a class="slide-button btn"></a>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="panel-footer">
|
|
<button type="submit" value="1" id="cms_category_form_submit_btn" name="submit_sendfile" class="btn btn-default pull-right">
|
|
<i class="process-icon-upload"></i> {l s='Upload' mod='pshowimporter'}
|
|
</button>
|
|
<a href="" onclick="$('.psi_addfile').parent().parent().hide();" class="btn btn-default">
|
|
<i class="process-icon-cancel"></i> {l s='Cancel' mod='pshowimporter'}
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
{literal}
|
|
|
|
$(document).on('keyup', '#saveas', function () {
|
|
|
|
var newname = $(this).val().replace(/[^A-Z0-9]/ig, "_");
|
|
$(this).val(newname);
|
|
|
|
});
|
|
|
|
$(document).on('click', 'button[name="submit_sendfile"]', function () {
|
|
|
|
$('.full-screen-loader').fadeIn();
|
|
$('.bootstrap#footer').hide();
|
|
|
|
});
|
|
|
|
{/literal}
|
|
</script>
|
|
|
|
<div class="alert alert-warning">
|
|
<p><strong>{l s='Proceed with caution, the changes are irreversible. Remember to back up the store before the import.' mod='pshowimporter'}</strong></p>
|
|
<p>
|
|
{l s='If your import was not successful, you can clear the catalog using the standard module located in your store - ' mod='pshowimporter'}
|
|
<a href="{$link->getAdminLink('AdminModules', true)}&module_name=pscleaner&anchor=Pscleaner">PrestaShop Cleaner</a>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
<div class="panel"> |