<?php
/* Smarty version 4.5.2, created on 2024-05-11 15:34:02
  from '/Users/nikolaimv/Sites/yzb.loc/admin/templates/views/type-content/content.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.5.2',
  'unifunc' => 'content_663f499aa3d679_55406841',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    'b3e92b9c67db96a2e5433bc1cd91b67369c01752' => 
    array (
      0 => '/Users/nikolaimv/Sites/yzb.loc/admin/templates/views/type-content/content.tpl',
      1 => 1682069371,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
    'file:components/group-buttons.tpl' => 1,
    'file:components/page-header.tpl' => 1,
    'file:components/fields/select.tpl' => 1,
    'file:tinymce_init.tpl' => 1,
  ),
),false)) {
function content_663f499aa3d679_55406841 (Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_checkPlugins(array(0=>array('file'=>'/Users/nikolaimv/Sites/yzb.loc/includes/composer/vendor/smarty/smarty/libs/plugins/function.html_options.php','function'=>'smarty_function_html_options',),));
?>
<form method="post" enctype="multipart/form-data">
	<!-- Page header -->
    <?php $_smarty_tpl->_subTemplateRender("file:components/group-buttons.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array('url'=>((string)$_smarty_tpl->tpl_vars['adminUrl']->value)."/typecontents"), 0, false);
?>

    <?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);?>
/typecontents" class="breadcrumb-item"><?php if ((isset($_smarty_tpl->tpl_vars['title']->value))) {
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 class="row">
			<div class="col-md-12">
				<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 class="row">
								<div class="col-md-4">
									<div class="form-group mb-3">
										<label class="form-label is-visible <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['name']))) {?>text-danger<?php }?>">Заголовок</label>
										<input type="text" class="form-control" id="name" autocomplete="off" name="type[name]" value="<?php if ((isset($_smarty_tpl->tpl_vars['type']->value['name']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['type']->value['name'], ENT_QUOTES, 'UTF-8', true);
}?>">
									</div>
								</div>
								<div class="col-md-4">
									<div class="form-group mb-3">
										<label class="form-label is-visible <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['fileName'])) || (isset($_smarty_tpl->tpl_vars['errors']->value['fileNameExists'])) || (isset($_smarty_tpl->tpl_vars['errors']->value['fileNameProhibited'])) || (isset($_smarty_tpl->tpl_vars['errors']->value['fileNameCharacters']))) {?>text-danger<?php }?>">URL (только буквы)</label>
										<input type="text" class="form-control" id="fileName" name="type[fileName]" value="<?php if ((isset($_smarty_tpl->tpl_vars['type']->value['fileName']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['type']->value['fileName'], ENT_QUOTES, 'UTF-8', true);
}?>">
									</div>
								</div>

                                                                <?php $_smarty_tpl->_subTemplateRender("file:components/fields/select.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array('col'=>"col-md-4",'id'=>"status",'title'=>"Статус",'field'=>"type[status]",'array'=>$_smarty_tpl->tpl_vars['statuses']->value,'selected'=>(($tmp = $_smarty_tpl->tpl_vars['type']->value['status'] ?? null)===null||$tmp==='' ? 'V' ?? null : $tmp),'class'=>"form-group mb-3"), 0, false);
?>
                                
								<div class="col-md-12">
									<div class="form-group mb-3">
										<label class="form-label is-visible">Группа пользователей</label>
                                        <?php echo smarty_function_html_options(array('options'=>$_smarty_tpl->tpl_vars['userGroups']->value,'name'=>"groupIds[]",'id'=>"privileges",'selected'=>(($tmp = $_smarty_tpl->tpl_vars['type']->value['privilege'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp),'class'=>"form-control select",'data-width'=>"100%",'multiple'=>''),$_smarty_tpl);?>

									</div>
								</div>

							</div>
						</div>
					</div>
				</div>

								<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 flex-column flex-md-row m-0  p-0">
							<table class="table table-xs table-togglable table-striped table-hover" id="fields">
								<thead>
								<tr>
									<th class="text-center" width="30">#</th>
									<th>Название поля</th>
									<th>Код поля</th>
									<th data-toggle="true">Тип поля</th>
									<th data-hide="phone" class="text-center">Статус</th>
									<th class="text-center text-muted" width="30"><i class="ph-check"></i></th>
								</tr>
								</thead>
                                <?php if (!empty($_smarty_tpl->tpl_vars['typeContentFields']->value)) {?>
									<tbody class="sortable">
                                    <?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['typeContentFields']->value, 'typeContentField');
$_smarty_tpl->tpl_vars['typeContentField']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['typeContentField']->value) {
$_smarty_tpl->tpl_vars['typeContentField']->do_else = false;
?>
										<tr id="field-<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['typeContentField']->value['fieldId'], ENT_QUOTES, 'UTF-8', true);?>
" data-id="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['typeContentField']->value['fieldId'], ENT_QUOTES, 'UTF-8', true);?>
" <?php if ($_smarty_tpl->tpl_vars['typeContentField']->value['status'] == 'H') {?>class="table-warning"<?php }?>>
											<td class="text-center text-nowrap"><i class="ph-dots-six text-muted"></i></td>
											<td class="text-start"> <?php echo $_smarty_tpl->tpl_vars['typeContentField']->value['name'];?>
</td>
											<td class="text-start"> <?php echo $_smarty_tpl->tpl_vars['typeContentField']->value['fileName'];?>
</td>
											<td class="text-start"> <?php echo $_smarty_tpl->tpl_vars['typeContentField']->value['typeName'];?>
</td>
											<td class="text-center" id="status-<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['typeContentField']->value['fieldId'], ENT_QUOTES, 'UTF-8', true);?>
"><?php echo $_smarty_tpl->tpl_vars['typeContentField']->value['statusName'];?>
</td>
											<td class="text-center">
												<div class="d-inline-flex">
													<a class="text-primary" data-bs-popup="tooltip" title="Редактировать" data-bs-placement="top" href="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['adminUrl']->value, ENT_QUOTES, 'UTF-8', true);?>
/field?action=edit<?php if ((isset($_smarty_tpl->tpl_vars['type']->value['typeId']))) {?>&typeId=<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['type']->value['typeId'], ENT_QUOTES, 'UTF-8', true);
}?>&id=<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['typeContentField']->value['fieldId'], ENT_QUOTES, 'UTF-8', true);?>
"><i class="ph-note-pencil me-2"></i></a>

													<div class="list-icons-item dropdown">
														<a class="text-body" data-bs-toggle="dropdown"><i class="ph-list"></i></a>

														<div class="dropdown-menu dropdown-menu-right">
															<a class="dropdown-item" href="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['adminUrl']->value, ENT_QUOTES, 'UTF-8', true);?>
/field?action=edit<?php if ((isset($_smarty_tpl->tpl_vars['type']->value['typeId']))) {?>&typeId=<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['type']->value['typeId'], ENT_QUOTES, 'UTF-8', true);
}?>&id=<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['typeContentField']->value['fieldId'], ENT_QUOTES, 'UTF-8', true);?>
"><i class="ph-note-pencil me-2"></i> Редактировать</a>
															<button type="button" class="dropdown-item ajax_action" data-module="field" data-action="status" data-id="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['typeContentField']->value['fieldId'], ENT_QUOTES, 'UTF-8', true);?>
"><i class="<?php if ($_smarty_tpl->tpl_vars['typeContentField']->value['status'] == 'V') {?>ph-eye<?php } else { ?>ph-eye-slash<?php }?> me-2"></i> Статус</button>
															<div class="dropdown-divider"></div>
															<button type="button" class="dropdown-item text-danger" onclick="removeField(<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['typeContentField']->value['fieldId'], ENT_QUOTES, 'UTF-8', true);?>
, '<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['typeContentField']->value['name'], ENT_QUOTES, 'UTF-8', true);?>
');"><i class="ph-trash me-2"></i> Удалить</button>
														</div>
													</div>
												</div>
											</td>
										</tr>
                                    <?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>

									</tbody>
                                <?php } else { ?>
									<tbody><tr class="odd"><td class="text-center" colspan="8">- Не найдено -</td></tr></tbody>
                                <?php }?>
							</table>
						</div>
						<div class="card-footer bg-white d-sm-flex justify-content-sm-between align-items-sm-center">
							<a class="btn btn-sm btn-primary" href="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['adminUrl']->value, ENT_QUOTES, 'UTF-8', true);?>
/field?action=add<?php if ((isset($_smarty_tpl->tpl_vars['type']->value['typeId']))) {?>&typeId=<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['type']->value['typeId'], ENT_QUOTES, 'UTF-8', true);
}?>"><i class="ph-plus me-2"></i>Добавить поле</a>
						</div>
					</div>
				</div>
                			</div>

			<div class="col-md-12 text-center">
                <?php if ((isset($_smarty_tpl->tpl_vars['type']->value['typeId']))) {?><input type="hidden" class="form-control" id="id" name="id" value="<?php echo htmlspecialchars((string)(($tmp = $_smarty_tpl->tpl_vars['type']->value['typeId'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp), ENT_QUOTES, 'UTF-8', true);?>
"><?php }?>
                <?php echo $_smarty_tpl->smarty->ext->_capture->getBuffer($_smarty_tpl, 'buttons');?>

			</div>

		</div>
	</div>
</form>

<?php $_smarty_tpl->_subTemplateRender('file:tinymce_init.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0, false);
?>

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

    function notFound()
    {
        new Noty({ text: 'Контент не найден или доступ запрещен.', layout: 'topRight', type: 'error', timeout: 1500 }).show();
    }
    function deleteMessage()
    {
        new Noty({ text: 'Контент удален.', type: 'success', timeout: 1500 }).show();
    }

    $(document).ready(function () {
        <?php if ((isset($_smarty_tpl->tpl_vars['messages']->value['saved']))) {?>
	        new Noty({ text: 'Тип контента "<?php if ((isset($_smarty_tpl->tpl_vars['type']->value['name']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['type']->value['name'], ENT_QUOTES, 'UTF-8', true);
}?>" сохранен', type: 'success', timeout: 1500 }).show();
	    <?php }?>

        <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['name']))) {?> new Noty({ text: 'Введите название контента', type: 'error', timeout: 2500 }).show();<?php }?>
        <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['not_saved']))) {?> new Noty({ text: 'Тип контента "<?php if ((isset($_smarty_tpl->tpl_vars['type']->value['name']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['type']->value['name'], ENT_QUOTES, 'UTF-8', true);
}?>" не сохранен', type: 'error', timeout: 2500 }).show(); <?php }?>

        <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['fileName']))) {?> new Noty({ text: 'Введите название свойства на анг. языке', type: 'error', timeout: 2500 }).show(); <?php }?>
        <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['fileNameExists']))) {?> new Noty({ text: 'Введите название свойства на анг. языке', type: 'error', timeout: 2500 }).show(); <?php }?>
        <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['fileNameProhibited']))) {?> new Noty({ text: 'Такое название нельзя использовать', type: 'error', timeout: 2500 }).show(); <?php }?>
        <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['fileNameCharacters']))) {?> new Noty({ text: 'Имя файла может содержать только буквы', type: 'error', timeout: 2500 }).show(); <?php }?>

    });

    $(document).on('click', '.sortable_save_button', function () {
        var ids = new Array();
        $('.sortable tr').each(function () {
            console.log($(this).attr('data-id'))

            ids.push($(this).attr('data-id'));
        })
        $.post( "<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['adminUrl']->value, ENT_QUOTES, 'UTF-8', true);?>
/field?action=reorder", { ids : ids }, function( data ) {
            $('.sortable_footer_navbar').removeClass('show');
            new Noty({ text: 'Поле перемещено', type: 'success', timeout: 1500 }).show();
        });
    })
    $(document).on('click', '.sortable_cancel_button', function () {
        $('.sortable_footer_navbar').removeClass('show');
        location.reload();
    })

    // рабочее удаление id, заголовок, ссылка
    function removeField(id, title) {
        bootbox.confirm({
            closeButton: false,
            message: lang['sureToDelete'] + ' "'+title+'"?',
            callback: function(result) {
                if (result === true) {
                    $.post('index.php?mod=field&action=remove&id='+id, function (response) {
                        console.log(response);
                        if (response.status == 200) {
                            removeElement(id, 'field');
                        }
                        new Noty({ text: response.message, layout: 'topRight', type: response.type, timeout: 1500 }).show();

                    }, 'json');
                }
            }
        });
        return false;
    }

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




<?php }
}
