311 lines
16 KiB
PHP
311 lines
16 KiB
PHP
<?php
|
|
/* Smarty version 3.1.39, created on 2023-06-22 13:38:07
|
|
from 'C:\xampp\htdocs\hotelcommerce\admin\themes\default\template\helpers\uploader\ajax.tpl' */
|
|
|
|
/* @var Smarty_Internal_Template $_smarty_tpl */
|
|
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
|
|
'version' => '3.1.39',
|
|
'unifunc' => 'content_6494329f129837_15322620',
|
|
'has_nocache_code' => false,
|
|
'file_dependency' =>
|
|
array (
|
|
'3fcd17fd2eb62a57baf614aa6f77e79870f6a141' =>
|
|
array (
|
|
0 => 'C:\\xampp\\htdocs\\hotelcommerce\\admin\\themes\\default\\template\\helpers\\uploader\\ajax.tpl',
|
|
1 => 1687433793,
|
|
2 => 'file',
|
|
),
|
|
),
|
|
'includes' =>
|
|
array (
|
|
),
|
|
),false)) {
|
|
function content_6494329f129837_15322620 (Smarty_Internal_Template $_smarty_tpl) {
|
|
?><div class="form-group" style="display: none;">
|
|
<div class="col-lg-12" id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-images-thumbnails">
|
|
<?php if ((isset($_smarty_tpl->tpl_vars['files']->value)) && count($_smarty_tpl->tpl_vars['files']->value) > 0) {?>
|
|
<?php
|
|
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['files']->value, 'file');
|
|
$_smarty_tpl->tpl_vars['file']->do_else = true;
|
|
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['file']->value) {
|
|
$_smarty_tpl->tpl_vars['file']->do_else = false;
|
|
?>
|
|
<?php if ((isset($_smarty_tpl->tpl_vars['file']->value['image'])) && $_smarty_tpl->tpl_vars['file']->value['type'] == 'image') {?>
|
|
<div>
|
|
<?php echo $_smarty_tpl->tpl_vars['file']->value['image'];?>
|
|
|
|
<?php if ((isset($_smarty_tpl->tpl_vars['file']->value['size']))) {?><p><?php echo call_user_func_array( $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['l'][0], array( array('s'=>'File size'),$_smarty_tpl ) );?>
|
|
<?php echo $_smarty_tpl->tpl_vars['file']->value['size'];?>
|
|
kb</p><?php }?>
|
|
<?php if ((isset($_smarty_tpl->tpl_vars['file']->value['delete_url']))) {?>
|
|
<p>
|
|
<a class="btn btn-default" href="<?php echo $_smarty_tpl->tpl_vars['file']->value['delete_url'];?>
|
|
">
|
|
<i class="icon-trash"></i> <?php echo call_user_func_array( $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['l'][0], array( array('s'=>'Delete'),$_smarty_tpl ) );?>
|
|
|
|
</a>
|
|
</p>
|
|
<?php }?>
|
|
</div>
|
|
<?php }?>
|
|
<?php
|
|
}
|
|
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
|
|
<?php }?>
|
|
</div>
|
|
</div>
|
|
<?php if ((isset($_smarty_tpl->tpl_vars['max_files']->value)) && count($_smarty_tpl->tpl_vars['files']->value) >= $_smarty_tpl->tpl_vars['max_files']->value) {?>
|
|
<div class="row">
|
|
<div class="alert alert-warning"><?php echo call_user_func_array( $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['l'][0], array( array('s'=>'You have reached the limit (%s) of files to upload, please remove files to continue uploading','sprintf'=>$_smarty_tpl->tpl_vars['max_files']->value),$_smarty_tpl ) );?>
|
|
</div>
|
|
</div>
|
|
<?php echo '<script'; ?>
|
|
type="text/javascript">
|
|
$( document ).ready(function() {
|
|
<?php if ((isset($_smarty_tpl->tpl_vars['files']->value)) && $_smarty_tpl->tpl_vars['files']->value) {?>
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-images-thumbnails').parent().show();
|
|
<?php }?>
|
|
});
|
|
<?php echo '</script'; ?>
|
|
>
|
|
<?php } else { ?>
|
|
<div class="form-group">
|
|
<div class="col-lg-12">
|
|
<input id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
" type="file" name="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
[]"<?php if ((isset($_smarty_tpl->tpl_vars['url']->value))) {?> data-url="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['url']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
"<?php }
|
|
if ((isset($_smarty_tpl->tpl_vars['multiple']->value)) && $_smarty_tpl->tpl_vars['multiple']->value) {?> multiple="multiple"<?php }?> style="width:0px;height:0px;" />
|
|
<button class="btn btn-default" data-style="expand-right" data-size="s" type="button" id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-add-button">
|
|
<i class="icon-folder-open"></i> <?php if ((isset($_smarty_tpl->tpl_vars['multiple']->value)) && $_smarty_tpl->tpl_vars['multiple']->value) {
|
|
echo call_user_func_array( $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['l'][0], array( array('s'=>'Add files...'),$_smarty_tpl ) );
|
|
} else {
|
|
echo call_user_func_array( $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['l'][0], array( array('s'=>'Add file...'),$_smarty_tpl ) );
|
|
}?>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="well" style="display:none">
|
|
<div id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-files-list"></div>
|
|
<button class="ladda-button btn btn-primary" data-style="expand-right" type="button" id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-upload-button" style="display:none;">
|
|
<span class="ladda-label"><i class="icon-check"></i> <?php if ((isset($_smarty_tpl->tpl_vars['multiple']->value)) && $_smarty_tpl->tpl_vars['multiple']->value) {
|
|
echo call_user_func_array( $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['l'][0], array( array('s'=>'Upload files'),$_smarty_tpl ) );
|
|
} else {
|
|
echo call_user_func_array( $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['l'][0], array( array('s'=>'Upload file'),$_smarty_tpl ) );
|
|
}?></span>
|
|
</button>
|
|
</div>
|
|
<div class="row" style="display:none">
|
|
<div class="alert alert-success" id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-success"></div>
|
|
</div>
|
|
<div class="row" style="display:none">
|
|
<div class="alert alert-danger" id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-errors"></div>
|
|
</div>
|
|
<?php echo '<script'; ?>
|
|
type="text/javascript">
|
|
function humanizeSize(bytes)
|
|
{
|
|
if (typeof bytes !== 'number') {
|
|
return '';
|
|
}
|
|
|
|
if (bytes >= 1000000000) {
|
|
return (bytes / 1000000000).toFixed(2) + ' GB';
|
|
}
|
|
|
|
if (bytes >= 1000000) {
|
|
return (bytes / 1000000).toFixed(2) + ' MB';
|
|
}
|
|
|
|
return (bytes / 1000).toFixed(2) + ' KB';
|
|
}
|
|
|
|
$( document ).ready(function() {
|
|
<?php if ((isset($_smarty_tpl->tpl_vars['multiple']->value)) && (isset($_smarty_tpl->tpl_vars['max_files']->value))) {?>
|
|
var <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
_max_files = <?php echo $_smarty_tpl->tpl_vars['max_files']->value-count($_smarty_tpl->tpl_vars['files']->value);?>
|
|
;
|
|
<?php }?>
|
|
|
|
<?php if ((isset($_smarty_tpl->tpl_vars['files']->value)) && $_smarty_tpl->tpl_vars['files']->value) {?>
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-images-thumbnails').parent().show();
|
|
<?php }?>
|
|
|
|
var <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
_upload_button = Ladda.create( document.querySelector('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-upload-button' ));
|
|
var <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
_total_files = 0;
|
|
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
').fileupload({
|
|
dataType: 'json',
|
|
async: false,
|
|
autoUpload: false,
|
|
singleFileUploads: true,
|
|
<?php if ((isset($_smarty_tpl->tpl_vars['post_max_size']->value))) {?>maxFileSize: <?php echo $_smarty_tpl->tpl_vars['post_max_size']->value;?>
|
|
,<?php }?>
|
|
<?php if ((isset($_smarty_tpl->tpl_vars['drop_zone']->value))) {?>dropZone: <?php echo $_smarty_tpl->tpl_vars['drop_zone']->value;?>
|
|
,<?php }?>
|
|
start: function (e) {
|
|
<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
_upload_button.start();
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-upload-button').unbind('click'); //Important as we bind it for every elements in add function
|
|
},
|
|
fail: function (e, data) {
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-errors').html(data.errorThrown.message).parent().show();
|
|
},
|
|
done: function (e, data) {
|
|
if (data.result) {
|
|
if (typeof data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
!== 'undefined') {
|
|
for (var i=0; i<data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
.length; i++) {
|
|
if (data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
[i] !== null) {
|
|
if (typeof data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
[i].error !== 'undefined' && data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
[i].error != '') {
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-errors').html('<strong>'+data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
[i].name+'</strong> : '+data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
[i].error).parent().show();
|
|
}
|
|
else
|
|
{
|
|
$(data.context).appendTo($('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-success'));
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-success').parent().show();
|
|
|
|
if (typeof data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
[i].image !== 'undefined')
|
|
{
|
|
var template = '<div>';
|
|
template += data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
[i].image;
|
|
|
|
if (typeof data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
[i].delete_url !== 'undefined')
|
|
template += '<p><a class="btn btn-default" href="'+data.result.<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['name']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
[i].delete_url+'"><i class="icon-trash"></i> <?php echo call_user_func_array( $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['l'][0], array( array('s'=>'Delete'),$_smarty_tpl ) );?>
|
|
</a></p>';
|
|
|
|
template += '</div>';
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-images-thumbnails').html($('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-images-thumbnails').html()+template);
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-images-thumbnails').parent().show();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
$(data.context).find('button').remove();
|
|
}
|
|
},
|
|
}).on('fileuploadalways', function (e, data) {
|
|
if (typeof <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
_max_files !== 'undefined') {
|
|
<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
_max_files--;
|
|
}
|
|
<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
_total_files--;
|
|
|
|
if (<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
_total_files == 0)
|
|
{
|
|
<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
_upload_button.stop();
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-upload-button').unbind('click');
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-files-list').parent().hide();
|
|
}
|
|
}).on('fileuploadadd', function(e, data) {
|
|
if (typeof <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
_max_files !== 'undefined') {
|
|
if (<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
_total_files >= <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
_max_files) {
|
|
e.preventDefault();
|
|
alert('<?php echo call_user_func_array( $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['l'][0], array( array('s'=>sprintf('You cannot have more than %s images in total. Please remove some of the current images before adding new ones.',$_smarty_tpl->tpl_vars['max_files']->value)),$_smarty_tpl ) );?>
|
|
');
|
|
return;
|
|
}
|
|
}
|
|
|
|
data.context = $('<div/>').addClass('form-group').appendTo($('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-files-list'));
|
|
var file_name = $('<span/>').append('<strong>'+data.files[0].name+'</strong> ('+humanizeSize(data.files[0].size)+')').appendTo(data.context);
|
|
|
|
var button = $('<button/>').addClass('btn btn-default pull-right').prop('type', 'button').html('<i class="icon-trash"></i> <?php echo call_user_func_array( $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['l'][0], array( array('s'=>'Remove file'),$_smarty_tpl ) );?>
|
|
').appendTo(data.context).on('click', function() {
|
|
<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
_total_files--;
|
|
data.files = null;
|
|
|
|
var total_elements = $(this).parent().siblings('div.form-group').length;
|
|
$(this).parent().remove();
|
|
|
|
if (total_elements == 0) {
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-files-list').html('').parent().hide();
|
|
}
|
|
});
|
|
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-files-list').parent().show();
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-upload-button').show().bind('click', function () {
|
|
if (data.files != null)
|
|
data.submit();
|
|
});
|
|
|
|
<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
_total_files++;
|
|
}).on('fileuploadprocessalways', function (e, data) {
|
|
var index = data.index, file = data.files[index];
|
|
|
|
if (file.error) {
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-errors').append('<div class="form-group"><strong>'+file.name+'</strong> ('+humanizeSize(file.size)+') : '+file.error+'</div>').parent().show();
|
|
$(data.context).find('button').trigger('click');
|
|
}
|
|
});
|
|
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-files-list').parent().hide();
|
|
<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
_total_files = 0;
|
|
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-add-button').on('click', function() {
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-success').html('').parent().hide();
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
-errors').html('').parent().hide();
|
|
$('#<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['id']->value, ENT_QUOTES, 'UTF-8', true);?>
|
|
').trigger('click');
|
|
});
|
|
});
|
|
<?php echo '</script'; ?>
|
|
>
|
|
<?php }
|
|
}
|
|
}
|