<?php
/* Smarty version 4.5.2, created on 2024-05-10 23:12:13
  from '/Users/nikolaimv/Sites/yzb.loc/admin/templates/views/users/group.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.5.2',
  'unifunc' => 'content_663e637d5c1003_15955678',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '83076b3c8691fe977c552bcbbfe8c6052f2e103e' => 
    array (
      0 => '/Users/nikolaimv/Sites/yzb.loc/admin/templates/views/users/group.tpl',
      1 => 1715000399,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
    'file:components/group-buttons.tpl' => 1,
    'file:components/page-header.tpl' => 1,
    'file:components/fields/select.tpl' => 1,
  ),
),false)) {
function content_663e637d5c1003_15955678 (Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_checkPlugins(array(0=>array('file'=>'/Users/nikolaimv/Sites/yzb.loc/includes/composer/vendor/smarty/smarty/libs/plugins/modifier.date_format.php','function'=>'smarty_modifier_date_format',),));
?>
<form method="post" class="needs-validation" novalidate>

	<!-- Page header -->
	<?php ob_start();
if (!empty($_smarty_tpl->tpl_vars['page']->value)) {
echo "?page=";
echo (string)$_smarty_tpl->tpl_vars['page']->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)."/roles".$_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);?>
/roles" class="breadcrumb-item"><?php echo htmlspecialchars((string)(($tmp = $_smarty_tpl->tpl_vars['title']->value ?? null)===null||$tmp==='' ? '' ?? null : $tmp), 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);?>
	<?php $_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 -->

	<!-- Content area -->
	<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 for="groupName" class="form-label <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['nameEmpty']))) {?>text-danger<?php }?>">Роль</label>
										<input type="text" class="form-control" autocomplete="off" id="groupName" name="group[groupName]" value="<?php echo htmlspecialchars((string)(($tmp = $_smarty_tpl->tpl_vars['group']->value['groupName'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp), ENT_QUOTES, 'UTF-8', true);?>
"  required=""/>
									</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['fileNameEmpty'])) || (isset($_smarty_tpl->tpl_vars['errors']->value['fileNameExists'])) || (isset($_smarty_tpl->tpl_vars['errors']->value['fileNameCharacters']))) {?>text-danger<?php }?>">Символ (A, B, C) на латинице</label>
																				<input type="text" class="form-control" id="fileName" name="group[fileName]" value="<?php echo htmlspecialchars((string)(($tmp = $_smarty_tpl->tpl_vars['group']->value['fileName'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp), ENT_QUOTES, 'UTF-8', true);?>
" maxlength="1"  required=""/>
									</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'=>"group[status]",'array'=>$_smarty_tpl->tpl_vars['statuses']->value,'selected'=>(($tmp = $_smarty_tpl->tpl_vars['group']->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">Описание</label>
										<textarea rows="3" cols="3" class="form-control" name="group[description]" placeholder="Описание"><?php echo htmlspecialchars((string)(($tmp = $_smarty_tpl->tpl_vars['group']->value['description'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp), ENT_QUOTES, 'UTF-8', true);?>
</textarea>
									</div>
								</div>
							</div>
						</div>
						<?php if ((isset($_smarty_tpl->tpl_vars['group']->value['addedOn'])) && (isset($_smarty_tpl->tpl_vars['group']->value['modifiedOn']))) {?>
							<div class="card-footer hstack gap-3 justify-content-between">
								<div class="text-muted">
									<ul class="list list-unstyled mb-0 fs-sm">
										<li>Пользователей группы</li>
										<li>Создано</li>
										<li>Изменено</li>
									</ul>
								</div>
								<div class="hstack gap-1">
									<ul class="list list-unstyled mb-0 fs-sm">
										<li><?php echo htmlspecialchars((string)(($tmp = $_smarty_tpl->tpl_vars['group']->value['countUsers'] ?? null)===null||$tmp==='' ? 0 ?? null : $tmp), ENT_QUOTES, 'UTF-8', true);?>
</li>
										<li><?php echo htmlspecialchars((string)smarty_modifier_date_format($_smarty_tpl->tpl_vars['group']->value['addedOn'],"%d.%m.%Y %H:%M"), ENT_QUOTES, 'UTF-8', true);?>
 (<?php echo htmlspecialchars((string)(($tmp = $_smarty_tpl->tpl_vars['group']->value['addedBy']['fullName'] ?? null)===null||$tmp==='' ? "Неизвестный пользователь" ?? null : $tmp), ENT_QUOTES, 'UTF-8', true);?>
)</li>
										<li><?php echo htmlspecialchars((string)smarty_modifier_date_format($_smarty_tpl->tpl_vars['group']->value['modifiedOn'],"%d.%m.%Y %H:%M"), ENT_QUOTES, 'UTF-8', true);?>
 (<?php echo htmlspecialchars((string)(($tmp = $_smarty_tpl->tpl_vars['group']->value['modifiedBy']['fullName'] ?? null)===null||$tmp==='' ? "Неизвестный пользователь" ?? null : $tmp), ENT_QUOTES, 'UTF-8', true);?>
)</li>
									</ul>
								</div>
							</div>
						<?php }?>
					</div>
				</div>
			</div>
						<div class="col-md-12">
				<div class="alert bg-info text-white alert-styled-left alert-dismissible">
					<span class="font-weight-semibold">Указать привилегии к пунктам меню</span> которые будут отображаться только для этой группы пользователей, с ограничениями доступа к другим пунктам меню.
				</div>
				<div class="card border shadow-sm">
					<div class="card-header d-flex flex-wrap">
						<h6 class="mb-0 <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['privilegesEmpty']))) {?>text-danger<?php }?>">Настроить привилегии для этой роли сотрудника</h6>
						<div class="d-inline-flex ms-auto">
							<div class="form-check form-check-inline">
								<input type="checkbox" class="form-check-input form-check-input-info  all_perms" id="all_perms" value="">
								<label class="form-check-label" for="all_perms">Все пункты меню</label>
							</div>
							<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">
							<div class="boxed fn_toggle_wrap">
																<div class="toggle_body_wrap on fn_card"><?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['permission']->value, 'items', false, 'title');
$_smarty_tpl->tpl_vars['items']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['title']->value => $_smarty_tpl->tpl_vars['items']->value) {
$_smarty_tpl->tpl_vars['items']->do_else = false;
?><div class="card-body bg-light permission_block mb-2"><?php if ((isset($_smarty_tpl->tpl_vars['items']->value['children']))) {?><h6 class="fw-semibold"><?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['items']->value['name'], ENT_QUOTES, 'UTF-8', true);?>
</h6><div class="permission_boxes row fn_perms_wrap"><?php
$_from = $_smarty_tpl->smarty->ext->_foreach->init($_smarty_tpl, $_smarty_tpl->tpl_vars['items']->value['children'], 'item', false, 'key');
$_smarty_tpl->tpl_vars['item']->do_else = true;
if ($_from !== null) foreach ($_from as $_smarty_tpl->tpl_vars['key']->value => $_smarty_tpl->tpl_vars['item']->value) {
$_smarty_tpl->tpl_vars['item']->do_else = false;
?><div class="col-xl-2 col-lg-3 col-md-6 mb-2"><div class="permission_box"><div class="form-check form-check-inline"><input type="checkbox" class="form-check-input form-check-input-info item_perm" id="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['item']->value['fileName'], ENT_QUOTES, 'UTF-8', true);?>
_<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['key']->value, ENT_QUOTES, 'UTF-8', true);?>
" name="privileges[]" value="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['item']->value['fileName'], ENT_QUOTES, 'UTF-8', true);?>
" <?php if ((isset($_smarty_tpl->tpl_vars['group']->value['privilege'])) && in_array($_smarty_tpl->tpl_vars['item']->value['fileName'],$_smarty_tpl->tpl_vars['group']->value['privilege'])) {?>checked<?php }?>><label class="form-check-label" for="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['item']->value['fileName'], ENT_QUOTES, 'UTF-8', true);?>
_<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['key']->value, ENT_QUOTES, 'UTF-8', true);?>
"><?php echo htmlspecialchars((string)htmlspecialchars((string)$_smarty_tpl->tpl_vars['item']->value['name'], ENT_QUOTES, 'UTF-8', true), ENT_QUOTES, 'UTF-8', true);?>
</label></div></div></div><?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?></div><?php } else { ?><div class="permission_boxes row fn_perms_wrap"><div class="col-xl-2 col-lg-3 col-md-6 mb-2"><div class="permission_box"><div class="form-check form-check-inline"><input type="checkbox" class="form-check-input form-check-input-info item_perm" id="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['items']->value['fileName'], ENT_QUOTES, 'UTF-8', true);?>
_<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['title']->value, ENT_QUOTES, 'UTF-8', true);?>
" name="privileges[]" value="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['items']->value['fileName'], ENT_QUOTES, 'UTF-8', true);?>
" <?php if ((isset($_smarty_tpl->tpl_vars['group']->value['privilege'])) && in_array($_smarty_tpl->tpl_vars['items']->value['fileName'],$_smarty_tpl->tpl_vars['group']->value['privilege'])) {?>checked<?php }?>><label class="form-check-label" for="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['items']->value['fileName'], ENT_QUOTES, 'UTF-8', true);?>
_<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['title']->value, ENT_QUOTES, 'UTF-8', true);?>
"><?php echo htmlspecialchars((string)htmlspecialchars((string)$_smarty_tpl->tpl_vars['items']->value['name'], ENT_QUOTES, 'UTF-8', true), ENT_QUOTES, 'UTF-8', true);?>
</label></div></div></div></div><?php }?></div><?php
}
$_smarty_tpl->smarty->ext->_foreach->restore($_smarty_tpl, 1);?></div>
							</div>
						</div>
					</div>
				</div>
			</div>

			<div class="col-md-12 text-center">
				<?php if ((isset($_smarty_tpl->tpl_vars['group']->value['groupId']))) {?><input type="hidden" class="form-control" id="id" name="id" value="<?php echo htmlspecialchars((string)(($tmp = $_smarty_tpl->tpl_vars['group']->value['groupId'] ?? 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 echo '<script'; ?>
>
	$(document).ready(function () {

		<?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['nameEmpty']))) {?>     new Noty({ text: 'Введите название роли.', type: 'error' }).show(); <?php }?>
		<?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['fileNameEmpty']))) {?>     new Noty({ text: 'Укажите символом роли на латинице.', type: 'error' }).show(); <?php }?>
		<?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['fileNameExists']))) {?>    new Noty({ text: 'Роль с таким символом уже существует', type: 'error' }).show(); <?php }?>
		<?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['fileNameCharacters']))) {?> new Noty({ text: 'Символ может содержать только следующие символы: A-Z', type: 'error' }).show(); <?php }?>
		<?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['not_saved']))) {?>       new Noty({ text: 'Группа не сохранена', type: 'error' }).show(); <?php }?>
		<?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['privilegesEmpty']))) {?> new Noty({ text: 'У группы пользователей должна быть хотя бы одна привилегия.', type: 'error' }).show(); <?php }?>

		<?php if ((isset($_smarty_tpl->tpl_vars['messages']->value['saved']))) {?> new Noty({ text: 'Группа сохранена', type: 'success' }).show(); <?php }?>
	});

	function deleteSuccess(id) {
		new Noty({ text: 'Группа удалена', type: 'success', timeout: 1500 }).show();
		removeElement(id, 'group');
	}
	function deleteError() {
		new Noty({ text: 'Группа не удалена', type: 'error', timeout: 1500 }).show();
	}

	$(document).on("change", ".all_perms", function () {
		if($(this).is(":checked")) {
			$('.item_perm').each(function () {
				if(!$(this).is(":checked")) {
					$(this).trigger("click");
					// console.log($(this).attr('id'))
				}
			});
		} else {
			$('.item_perm').each(function () {
				if($(this).is(":checked")) {
					$(this).trigger("click");
					// console.log($(this).attr('id'))
				}
			})
		}
	});
	$(document).on("change", ".item_perm", function () {
		var id = $(this).attr('id');
		console.log(id);
		if ($(this).is(":checked")) {
			$('#parent_'+id).prop('checked', true);
		} else {
			$('#parent_'+id).prop('checked', false);
		}

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

<?php }
}
