<?php
/* Smarty version 4.5.2, created on 2024-05-08 20:37:10
  from '/Users/nikolaimv/Sites/admin.panel.11.loc/admin/templates/views/logo/logo.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.5.2',
  'unifunc' => 'content_663b9c2679f5b3_24162916',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '0227101ffcda835c6c6dcf55d19ceea8610f28b9' => 
    array (
      0 => '/Users/nikolaimv/Sites/admin.panel.11.loc/admin/templates/views/logo/logo.tpl',
      1 => 1682071114,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
    'file:components/page-header.tpl' => 1,
  ),
),false)) {
function content_663b9c2679f5b3_24162916 (Smarty_Internal_Template $_smarty_tpl) {
?><!-- Page header -->
<?php $_smarty_tpl->smarty->ext->_capture->open($_smarty_tpl, "buttons", null, null);?>
	<button class="btn btn-sm btn-primary" data-bs-toggle="collapse" data-bs-target="#add_logo">
		<i class="ph-image me-2"></i>
        <?php if (!empty($_smarty_tpl->tpl_vars['logos']->value->logoUrl)) {?>Изменить логотип<?php } else { ?>Загрузить логотип<?php }?>
	</button>
<?php $_smarty_tpl->smarty->ext->_capture->close($_smarty_tpl);?>

<?php $_smarty_tpl->smarty->ext->_capture->open($_smarty_tpl, "breadcrumb", null, null);?>
	<a href="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['adminUrl']->value, ENT_QUOTES, 'UTF-8', true);?>
/logo" class="breadcrumb-item"><?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['title']->value, ENT_QUOTES, 'UTF-8', true);?>
</a>
<?php $_smarty_tpl->smarty->ext->_capture->close($_smarty_tpl);?>

<?php $_smarty_tpl->smarty->ext->_capture->open($_smarty_tpl, "showBy", null, null);
$_smarty_tpl->smarty->ext->_capture->close($_smarty_tpl);?>

<?php $_smarty_tpl->_subTemplateRender("file:components/page-header.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array('buttons'=>$_smarty_tpl->smarty->ext->_capture->getBuffer($_smarty_tpl, 'buttons'),'breadcrumb'=>$_smarty_tpl->smarty->ext->_capture->getBuffer($_smarty_tpl, 'breadcrumb'),'showBy'=>$_smarty_tpl->smarty->ext->_capture->getBuffer($_smarty_tpl, 'showBy')), 0, false);
?>
<!-- /page header -->

<div class="content">

	<div id="add_logo" class="collapse">
		<div class="card border shadow-sm">
			<div class="card-header d-flex flex-wrap">
				<h6 class="mb-0">Загрузить логотип</h6>
				<div class="d-inline-flex ms-auto">
					<a class="text-body" data-card-action="collapse"><i class="ph-caret-down"></i></a>
				</div>
			</div>
			<div class="collapse show">
				<div class="card-body">
					<div id="upload_files" class="dropzone dropzone-product">
						<div class="dz-default dz-message"></div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<div class="card border shadow-sm">
		<div class="table-responsive">
			<table class="table table-togglable table-striped table-hover" id="logos">
				<thead>
				<tr>
					<th data-hide="ID" class="text-center" width="30">Логотип</th>
					<th data-hide="image" class="text-center" nowrap="nowrap">Имя файла</th>
					<th data-hide="image">Путь</th>
					<th data-hide="image" class="text-center" nowrap="nowrap">Формат файла</th>
					<th class="text-center text-muted" width="30"><i class="ph-check"></i></th>
				</tr>
				</thead>
                <?php if (!empty($_smarty_tpl->tpl_vars['logos']->value['fileName'])) {?>
					<tbody>
					<tr id="logo-1">
						<td><img id="preview" src="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['UPLOAD_URL']->value, ENT_QUOTES, 'UTF-8', true);?>
/<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['logos']->value['fileName'], ENT_QUOTES, 'UTF-8', true);?>
" style="max-width: 200px;max-height: 100px;"></td>
						<td class="text-center"><?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['logos']->value['logoName'], ENT_QUOTES, 'UTF-8', true);?>
</td>
						<td class="text-start text-nowrap"><?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['UPLOAD_URL']->value, ENT_QUOTES, 'UTF-8', true);?>
/<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['logos']->value['fileName'], ENT_QUOTES, 'UTF-8', true);?>
</td>
						<td class="text-center"><?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['logos']->value['logoType'], ENT_QUOTES, 'UTF-8', true);?>
</td>
						<td class="text-center">
							<div class="d-inline-flex">
								<button class="dropdown-item btn btn-link text-danger" onclick="deleteLogo('<?php echo htmlspecialchars((string)htmlspecialchars((string)$_smarty_tpl->tpl_vars['logos']->value['fileName'], ENT_QUOTES, 'UTF-8', true), ENT_QUOTES, 'UTF-8', true);?>
', '<?php echo htmlspecialchars((string)htmlspecialchars((string)$_smarty_tpl->tpl_vars['logos']->value['logoName'], ENT_QUOTES, 'UTF-8', true), ENT_QUOTES, 'UTF-8', true);?>
');" data-bs-popup="tooltip" title="Удалить" data-bs-placement="auto"><i class="ph-trash"></i></button>
							</div>
						</td>
					</tr>
					</tbody>
                <?php } else { ?>
					<tbody><tr><td class="text-center" colspan="5">- Не найдено -</td></tr></tbody>
                <?php }?>
			</table>
		</div>
	</div>

</div>


<?php echo '<script'; ?>
>

    var logoLang = "<?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['LANGUAGES']->value, 'language');
$_smarty_tpl->tpl_vars['language']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['language']->value) {
$_smarty_tpl->tpl_vars['language']->do_else = false;
if (($_smarty_tpl->tpl_vars['SITE_LANG']->value == $_smarty_tpl->tpl_vars['language']->value['codename']) || (!$_smarty_tpl->tpl_vars['SITE_LANG']->value && $_smarty_tpl->tpl_vars['language']->value['isDefault'])) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['language']->value['codename'], ENT_QUOTES, 'UTF-8', true);
}
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>";
    Dropzone.autoDiscover = false;

    $("#upload_files").dropzone({
        paramName: "file",
        url: "<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['adminUrl']->value, ENT_QUOTES, 'UTF-8', true);?>
/logo?action=upload",
        addRemoveLinks: true,
        dictRemoveFile: 'Скрыть',
        maxFilesize: 2,
        maxFiles: 1,
        acceptedFiles: "image/*",
        init: function() {
            this.on("success", function(file, response) {
                console.log(response);
                new Noty({ text: response.message, type: response.type }).show();
                setTimeout(function() {
                    location.reload()
                },2500);
            });
            this.on('error', function (file, response){
                file.previewElement.classList.add("dz-error");
                new Noty({ text: response.message, type: 'error' }).show();
            });

        }
    });

    function deleteLogo(urlFile, name) {
        bootbox.confirm({
            closeButton: false,
            message: lang['sureToDelete'] + ' "'+name+'"?',
            callback: function(res) {
                if (res === true) {
                    $.post("index.php?mod=logo&action=remove&logo[fileName]=" + urlFile, function(response){
	                    console.log(response);
	                    if (response.status == 200) {
	                        const el = document.getElementById("logo-1");
	                        el.parentNode.removeChild(el);
	                    }
                        new Noty({ text: response.message, type: response.type }).show();
                    }, 'json');
                }
            }
        })
    }

<?php echo '</script'; ?>
>





<?php }
}
