<?php
/* Smarty version 4.5.2, created on 2024-05-13 14:06:56
  from '/Users/nikolaimv/Sites/yzb.loc/admin/templates/views/type-content/field.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.5.2',
  'unifunc' => 'content_6641d830d224a5_83541097',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '75cff61180695e81f175955baa41a524204ae018' => 
    array (
      0 => '/Users/nikolaimv/Sites/yzb.loc/admin/templates/views/type-content/field.tpl',
      1 => 1680185495,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
    'file:components/group-buttons.tpl' => 1,
    'file:components/page-header.tpl' => 1,
    'file:components/fields/select.tpl' => 5,
    'file:tinymce_init.tpl' => 1,
  ),
),false)) {
function content_6641d830d224a5_83541097 (Smarty_Internal_Template $_smarty_tpl) {
?><form method="post" enctype="multipart/form-data">
	<!-- Page header -->
    <?php ob_start();
if ((isset($_smarty_tpl->tpl_vars['typeId']->value))) {
echo "&id=";
echo (string)$_smarty_tpl->tpl_vars['typeId']->value;
}
$_prefixVariable1=ob_get_clean();
$_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)."/typecontent?action=edit".$_prefixVariable1), 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">Тип контента</a>
		<a href="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['adminUrl']->value, ENT_QUOTES, 'UTF-8', true);?>
/typecontent?action=edit<?php if ((isset($_smarty_tpl->tpl_vars['typeId']->value))) {?>&id=<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['typeId']->value, ENT_QUOTES, 'UTF-8', true);
}?>" 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 p-0">
						<ul class="nav nav-tabs nav-tabs-overline border-top-0">
							<li class="nav-item">
								<a href="#general" class="nav-link active show" data-bs-toggle="tab" id="tab_general">Основное</a>
							</li>

							<li class="nav-item collapse <?php if ((isset($_smarty_tpl->tpl_vars['field']->value['type'])) && ($_smarty_tpl->tpl_vars['field']->value['type'] == 'R' || $_smarty_tpl->tpl_vars['field']->value['type'] == 'S' || $_smarty_tpl->tpl_vars['field']->value['type'] == 'M')) {?>show<?php }?>" id="tab_variants">
								<a href="#tabProperties" class="nav-link" data-bs-toggle="tab">Варианты</a></li>
						</ul>
					</div>
					<div class="card-body">
						<div class="tab-content border-top-0 rounded-top-0 mb-0">

							<div class="tab-pane fade show active" id="general">
								<div class="row mb-3">
									<label class="col-lg-3 col-form-label <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['name']))) {?>text-danger<?php }?>">Название поля:</label>
									<div class="col-lg-9">
										<input type="text" class="form-control" id="name" autocomplete="off" name="field[name]" value="<?php if ((isset($_smarty_tpl->tpl_vars['field']->value['name']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['field']->value['name'], ENT_QUOTES, 'UTF-8', true);
}?>">
									</div>
								</div>
								<div class="row mb-3">
									<label class="col-lg-3 col-form-label <?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['fileNameCharacters']))) {?>text-danger<?php }?>">Ключ поля:</label>
									<div class="col-lg-9">
										<input type="text" class="form-control" id="fileName" autocomplete="off" name="field[fileName]" value="<?php if ((isset($_smarty_tpl->tpl_vars['field']->value['fileName']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['field']->value['fileName'], ENT_QUOTES, 'UTF-8', true);
}?>">
										<div class="form-control form-control-plaintext fs-sm text-danger">
											<p>Последовательность символов, используемая в качестве идентификатора. Вы можете использовать цифры от 0 до 9, символы английского алфавита и знак "_".</p>
										</div>
									</div>
								</div>
								<div class="row mb-3">
									<label class="col-lg-3 col-form-label">Тип:</label>
									<div class="col-lg-9">
																				<?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'=>"typeFields",'title'=>'','field'=>"field[type]",'array'=>$_smarty_tpl->tpl_vars['typeFields']->value,'selected'=>(($tmp = $_smarty_tpl->tpl_vars['field']->value['type'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp),'class'=>"form-group",'width'=>'300'), 0, false);
?>
																			</div>
								</div>
								<div class="row mb-3 radio_group_position collapse <?php if ((isset($_smarty_tpl->tpl_vars['field']->value['type'])) && $_smarty_tpl->tpl_vars['field']->value['type'] == 'R') {?>show<?php }?>">
									<label class="col-lg-3 col-form-label">Расположение радиогруппы:</label>
									<div class="col-lg-9">
                                        <?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'=>"radio_group_position",'title'=>'','field'=>"field[radio_group_position]",'array'=>$_smarty_tpl->tpl_vars['radioGroupPositions']->value,'selected'=>(($tmp = $_smarty_tpl->tpl_vars['field']->value['radio_group_position'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp),'class'=>"form-group",'width'=>'300'), 0, true);
?>
									</div>
								</div>

								<div class="row mb-3 radio_group_sql collapse <?php if ((isset($_smarty_tpl->tpl_vars['field']->value['type'])) && $_smarty_tpl->tpl_vars['field']->value['type'] == 'R' || $_smarty_tpl->tpl_vars['field']->value['type'] == 'S' || $_smarty_tpl->tpl_vars['field']->value['type'] == 'C') {?>show<?php }?>">
									<label class="col-lg-3 col-form-label">SQL <br>VARCHAR( 255 ) NULL, <br> CHAR( 1 ) NOT NULL DEFAULT 0:</label>
									<div class="col-lg-9">
										<input type="text" class="form-control" id="type_sql" autocomplete="off" name="field[type_sql]" value="<?php if ((isset($_smarty_tpl->tpl_vars['field']->value['type_sql']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['field']->value['type_sql'], ENT_QUOTES, 'UTF-8', true);
}?>">
									</div>
								</div>


								<div class="row mb-3">
									<label class="col-lg-3 col-form-label <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['typeId']))) {?>text-danger<?php }?>">Тип контента:</label>
									<div class="col-lg-9">
																				<?php ob_start();
if ((isset($_smarty_tpl->tpl_vars['typeId']->value)) && $_smarty_tpl->tpl_vars['typeId']->value > 0) {
echo (string)$_smarty_tpl->tpl_vars['typeId']->value;
} else {
echo htmlspecialchars((string)(($tmp = $_smarty_tpl->tpl_vars['field']->value['typeId'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp), ENT_QUOTES, 'UTF-8', true);
}
$_prefixVariable2=ob_get_clean();
$_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'=>"selectTypeContents",'title'=>'','field'=>"field[typeId]",'array'=>$_smarty_tpl->tpl_vars['selectTypeContents']->value,'selected'=>$_prefixVariable2,'class'=>"form-group",'width'=>'300'), 0, true);
?>
																			</div>
								</div>


								<div class="row mb-3">
									<label class="col-lg-3 col-form-label">Пользовательский CSS-класс:</label>
									<div class="col-lg-9">
										<input type="text" class="form-control" id="css" autocomplete="off" name="field[class]" value="<?php if ((isset($_smarty_tpl->tpl_vars['field']->value['class']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['field']->value['class'], ENT_QUOTES, 'UTF-8', true);
}?>">
									</div>
								</div>
								<div class="row mb-3">
									<label class="col-lg-3 col-form-label">Пользовательский CSS-класс оболочки:</label>
									<div class="col-lg-9">
										<input type="text" class="form-control" id="css" autocomplete="off" name="field[wrapper_class]" value="<?php if ((isset($_smarty_tpl->tpl_vars['field']->value['wrapper_class']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['field']->value['wrapper_class'], ENT_QUOTES, 'UTF-8', true);
}?>">
									</div>
								</div>
								<div class="row mb-3">
									<label class="col-lg-3 col-form-label">Статус:</label>
									<div class="col-lg-9">
	                                    	                                    <?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'=>"field[status]",'array'=>$_smarty_tpl->tpl_vars['statuses']->value,'selected'=>(($tmp = $_smarty_tpl->tpl_vars['field']->value['status'] ?? null)===null||$tmp==='' ? 'V' ?? null : $tmp),'class'=>"form-group",'width'=>'300'), 0, true);
?>
	                                    									</div>
								</div>
								<div class="row mb-3">
									<label class="col-lg-3 col-form-label">Раположение:</label>
									<div class="col-lg-9">
                                                                                <?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'=>"position",'title'=>'','field'=>"field[position]",'array'=>$_smarty_tpl->tpl_vars['positions']->value,'selected'=>(($tmp = $_smarty_tpl->tpl_vars['field']->value['position'] ?? null)===null||$tmp==='' ? 'M' ?? null : $tmp),'class'=>"form-group",'width'=>'300'), 0, true);
?>
                                        									</div>
								</div>
							</div>

							<div class="tab-pane fade collapse<?php if ((isset($_smarty_tpl->tpl_vars['field']->value['type'])) && ($_smarty_tpl->tpl_vars['field']->value['type'] == 'R' || $_smarty_tpl->tpl_vars['field']->value['type'] == 'S' || $_smarty_tpl->tpl_vars['field']->value['type'] == 'M')) {?>show<?php }?>" id="tabProperties">
								<table class="table table-xs table-togglable table-striped table-hover">
									<thead>
										<tr>
											<th width="150">Ключ</th>
											<th>Значение</th>
											<th class="text-center text-muted" width="300"><i class="icon-checkmark3"></i></th>
										</tr>
									</thead>
									<tbody class="selectable-demo-list" id="properties">
									<?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['properties']->value, 'property');
$_smarty_tpl->tpl_vars['property']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['property']->value) {
$_smarty_tpl->tpl_vars['property']->do_else = false;
?>
										<tr class="">
											<td class="text-start">
												<input type="hidden" class="form-control" name="field_data[<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['property']->value['propertyId'], ENT_QUOTES, 'UTF-8', true);?>
][propertyId]" value="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['property']->value['propertyId'], ENT_QUOTES, 'UTF-8', true);?>
">
												<input type="text" class="form-control" name="field_data[<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['property']->value['propertyId'], ENT_QUOTES, 'UTF-8', true);?>
][propertyKey]" value="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['property']->value['propertyKey'], ENT_QUOTES, 'UTF-8', true);?>
">
											</td>
											<td class="text-start">
												<input type="text" class="form-control" name="field_data[<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['property']->value['propertyId'], ENT_QUOTES, 'UTF-8', true);?>
][name]" value="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['property']->value['name'], ENT_QUOTES, 'UTF-8', true);?>
">
											</td>
											<td class="text-end">
												<div class="input-group">
													<button type="button" class="btn btn-outline-primary add_property"><i class="ph-plus me-2"></i>Добавить</button>
													<button type="button" class="btn btn-outline-primary del_variant"><i class="ph-trash me-2"></i> Удалить</button>
												</div>
											</td>
										</tr>
										<?php
}
if ($_smarty_tpl->tpl_vars['property']->do_else) {
?>
										<tr class="">
											<td class="text-start">
												<input type="hidden" class="form-control" name="field_data[0][propertyId]">
												<input type="text" class="form-control" name="field_data[0][propertyKey]">
											</td>
											<td class="text-start">
												<input type="text" class="form-control" name="field_data[0][name]">
											</td>
											<td class="text-end">
												<div class="input-group">
													<button type="button" class="btn btn-outline-primary add_property"><i class="ph-plus me-2"></i>Добавить</button>
													<button type="button" class="btn btn-outline-primary "><i class="ph-trash me-2"></i> Удалить</button>
												</div>
											</td>
										</tr>
									<?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?>
									</tbody>
								</table>
							</div>

						</div>
					</div>

				</div>
			</div>

			<div class="col-md-12 text-center">
                <?php if ((isset($_smarty_tpl->tpl_vars['field']->value['fieldId']))) {?><input type="hidden" class="form-control" id="id" name="id" value="<?php echo htmlspecialchars((string)(($tmp = $_smarty_tpl->tpl_vars['field']->value['fieldId'] ?? 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['field']->value['name']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['field']->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['field']->value['name']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['field']->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['fileNameCharacters']))) {?> new Noty({ text: 'Ключ может содержать только следующие символы: A-Z a-z _', type: 'error', timeout: 2500 }).show(); <?php }?>

        <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['typeId']))) {?> new Noty({ text: 'Выберите тип контента', type: 'error', timeout: 2500 }).show(); <?php }?>
    });


    $(document).on('change', '#typeFields', function() {
        console.log($(this).val())
        if ($(this).val() == 'R' || $(this).val() == 'S') {
            $('#tab_variants').addClass('show')
            $('.radio_group_sql').addClass('show')

        } else {
            $('#tab_variants').removeClass('show')
            $('.radio_group_sql').removeClass('show')
        }
        if ($(this).val() == 'R') {
            $('.radio_group_position').addClass('show')
        } else {
            $('.radio_group_position').removeClass('show')
        }

    })

    var property = $('#new_property').clone(true);
    $('#new_property').remove().removeAttr('id');

    $(document).on('click', '.add_property', function() {
        var parent = $(this).parents('tbody:first');
        var clone = parent.children(':last').clone();
        var index = parseInt(clone.find('input:first').attr('name').match(/\[([0-9]+)\]/)[1]) + 1;

        // Очистить значения клонирования и обновить индекс
        clone.find('input, select').val('').each(function() {
            $(this).attr('name', $(this).attr('name').replace(/\[[0-9]+\]/, '[' + index + ']'));
        }).end().appendTo(parent);
    });

    // Удаление варианта
    $(document).on('click', '.del_variant', function() {
        if($("#properties tr").length > 1) {
            $(this).closest("tr").fadeOut(200, function() {
                $(this).remove();
            });
        } else {
            $('#variants_block td.variant_name').hide();
            $('#variants_block th.variant_name').hide();
            $('#variants_block').addClass('single_variant');
        }
        return false;
    });

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