<?php
/* Smarty version 4.5.2, created on 2024-06-10 12:29:06
  from '/Users/nikolaimv/Sites/admin.panel.11.loc/admin/templates/views/users/developer.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.5.2',
  'unifunc' => 'content_6666ab424805a1_82237458',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '6cb759c0ec126c3bae72143276ef0ec3c958e0e3' => 
    array (
      0 => '/Users/nikolaimv/Sites/admin.panel.11.loc/admin/templates/views/users/developer.tpl',
      1 => 1711183463,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
    'file:components/group-buttons.tpl' => 1,
    'file:components/page-header.tpl' => 1,
    'file:components/fields/select.tpl' => 1,
    'file:uploads_init.tpl' => 1,
  ),
),false)) {
function content_6666ab424805a1_82237458 (Smarty_Internal_Template $_smarty_tpl) {
$_smarty_tpl->_checkPlugins(array(0=>array('file'=>'/Users/nikolaimv/Sites/admin.panel.11.loc/includes/composer/vendor/smarty/smarty/libs/plugins/function.html_options.php','function'=>'smarty_function_html_options',),1=>array('file'=>'/Users/nikolaimv/Sites/admin.panel.11.loc/includes/composer/vendor/smarty/smarty/libs/plugins/modifier.date_format.php','function'=>'smarty_modifier_date_format',),));
?>
<form method="post" enctype="multipart/form-data" id="manager">

	<!-- 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)."/developers"), 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);?>
/developers" class="breadcrumb-item"><?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['title']->value, ENT_QUOTES, 'UTF-8', true);?>
</a>
        <?php if ((isset($_smarty_tpl->tpl_vars['action']->value)) && $_smarty_tpl->tpl_vars['action']->value == 'edit') {?>
			<span class="breadcrumb-item active">Редактирование менеджера</span>
        <?php } else { ?>
			<span class="breadcrumb-item active">Добавление нового менеджера</span>
        <?php }?>
    <?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="profile-cover">
		<div class="profile-cover-img" style="background-image: url('/admin/assets/img/wallpaper_3.jpg')"></div>
		<div class="d-flex align-items-center text-center text-lg-start flex-column flex-lg-row position-absolute start-0 end-0 bottom-0 mx-3 mb-3">

			<div class="me-lg-3 mb-2 mb-lg-0">
				<div class="profile-thumb">
					<img src="<?php if ((isset($_smarty_tpl->tpl_vars['manager']->value['image']['medium']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['manager']->value['image']['medium'], ENT_QUOTES, 'UTF-8', true);
} else { ?>/admin/assets/img/no_images.jpg<?php }?>" class="img-thumbnail rounded-circle shadow" width="100" height="100" alt="">
				</div>
			</div>


			<div class="profile-cover-text text-white">
				<h1 class="mb-0"><?php if ((isset($_smarty_tpl->tpl_vars['manager']->value['fullName']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['manager']->value['fullName'], ENT_QUOTES, 'UTF-8', true);
}?></h1>
				<span class="d-block"><?php if ((isset($_smarty_tpl->tpl_vars['manager']->value['accessLevelName']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['manager']->value['accessLevelName'], ENT_QUOTES, 'UTF-8', true);
}?></span>
			</div>

			<div class="ms-lg-auto mt-2 mt-lg-0">
				<ul class="d-inline-flex">


						<button class="btn btn-light btn-upload read-more"
					       data-type="image"
					       data-path="admin"
					       data-action="read_more"><i class="ph-image me-2"></i> <?php if ((isset($_smarty_tpl->tpl_vars['manager']->value['image']->medium))) {?>Заменить файл<?php } else { ?>Загрузить файл<?php }?></button>
				</ul>
			</div>
		</div>
	</div>

	<div class="navbar navbar-expand-lg border-bottom py-2">
		<div class="container-fluid">
			<div class="text-center d-lg-none w-100">
				<button type="button" class="navbar-toggler dropdown-toggle" data-toggle="collapse" data-target="#navbar-second">
					<i class="icon-menu7 mr-2"></i>
					Profile navigation
				</button>
			</div>

			<ul class="nav navbar-nav flex-row flex-fill">
				<?php if ($_smarty_tpl->tpl_vars['adminManager']->value['userType'] == $_smarty_tpl->tpl_vars['DEVELOPER']->value) {?>
					<li class="nav-item me-1">
						<a href="javascript:void('');" class="navbar-nav-link navbar-nav-link-icon rounded" data-bs-toggle="collapse" data-bs-target="#collapse-notice"><i class="icon-stack-text me-2"></i>Заметки</a>
					</li>
				<?php }?>

				<li class="nav-item me-1">
					<a href="javascript:void('');" class="navbar-nav-link navbar-nav-link-icon rounded" >
						<div class="d-flex align-items-center mx-lg-1">
							<i class="ph-calendar"></i>
							<span class="d-none d-lg-inline-block ms-2">
								Публикаций
								<span class="badge bg-success rounded-pill ms-auto ms-lg-2"><?php if ((isset($_smarty_tpl->tpl_vars['totalArticle']->value))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['totalArticle']->value, ENT_QUOTES, 'UTF-8', true);
} else { ?>0<?php }?></span>
							</span>
						</div>
					</a>

				</li>
			</ul>
		</div>
	</div>

    <!-- Content area -->
    <div class="content">
        <div class="row">
	        <div class="col-md-12">
		        <div class="card collapse" id="collapse-notice">
			        <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">
					        <textarea class="form-control p-2" style="width:100%;height:200px;" readonly><?php if ((isset($_smarty_tpl->tpl_vars['manager']->value['notice']))) {
echo $_smarty_tpl->tpl_vars['manager']->value['notice'];
}?></textarea>
				        </div>
			        </div>
		        </div>
	        </div>

            <div class="col-md-8">
    		    <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-6">
	                                <div class="form-group mb-3">
	                                    <label class="form-label is-visible <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['fullName']))) {?>text-danger<?php }?>">Полное имя</label>
	                                    <input type="text" class="form-control" autocomplete="off" id="fullName" name="manager[fullName]" value="<?php if ((isset($_smarty_tpl->tpl_vars['manager']->value['fullName']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['manager']->value['fullName'], ENT_QUOTES, 'UTF-8', true);
}?>" />
	                                </div>
					                <div class="form-group mb-3">
						                <label class="form-label is-visible <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['login_empty'])) || (isset($_smarty_tpl->tpl_vars['errors']->value['login_exists'])) || (isset($_smarty_tpl->tpl_vars['errors']->value['loginName']))) {?>text-danger<?php }?>">Логин</label>
						                <input type="text" class="form-control" autocomplete="off" id="loginName" name="manager[loginName]" value="<?php if ((isset($_smarty_tpl->tpl_vars['manager']->value['loginName']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['manager']->value['loginName'], ENT_QUOTES, 'UTF-8', true);
}?>" />
					                </div>
	                                <div class="form-group mb-3">
	                                    <label for="email" class="form-label is-visible <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['email']))) {?>text-danger<?php }?>">E-mail</label>
	                                    <input type="email" class="form-control" autocomplete="off" id="email" name="manager[email]" value="<?php if ((isset($_smarty_tpl->tpl_vars['manager']->value['email']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['manager']->value['email'], ENT_QUOTES, 'UTF-8', true);
}?>"/>
	                                </div>
	                            </div>

	                            <div class="col-md-6">
		                            <div class="form-group mb-3">
			                            <label class="form-label is-visible">Номер телефона</label>
			                            <input type="tel" class="form-control" autocomplete="off" id="phone" data-mask="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['config']->value['phone_mask'], ENT_QUOTES, 'UTF-8', true);?>
" name="manager[phone]" value="<?php if ((isset($_smarty_tpl->tpl_vars['manager']->value['phone']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['manager']->value['phone'], ENT_QUOTES, 'UTF-8', true);
}?>" />
		                            </div>
		                            <div class="form-group mb-3">
			                            <label for="email" class="form-label is-visible">Адрес</label>
			                            <input type="text" class="form-control maxlength-threshold" maxlength="100" autocomplete="off" id="address" name="manager[address]" value="<?php if ((isset($_smarty_tpl->tpl_vars['manager']->value['address']))) {
echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['manager']->value['address'], ENT_QUOTES, 'UTF-8', true);
}?>"/>
		                            </div>

	                                <?php if (!empty($_smarty_tpl->tpl_vars['manager']->value['userId'])) {?>
		                                <div class="form-group mb-3">
			                                <label class="form-label is-visible <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['password']))) {?>text-danger<?php }?>">Новый пароль</label>
			                                <div class="input-group">
				                                <input  type="text" class="form-control group-indicator" id="newPassword" name="manager[newPassword]" />
				                                <span class="input-group-text password-indicator-group">No password</span>
			                                </div>
		                                </div>
	                                <?php } else { ?>
		                                <div class="form-group mb-3">
			                                <label for="password" class="form-label is-visible <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['password']))) {?>text-danger<?php }?>">Пароль</label>
			                                <div class="input-group">
				                                <input type="text" class="form-control group-indicator" id="password" name="manager[password]"/>
				                                <span class="input-group-text  password-indicator-group">No password</span>
			                                </div>
		                                </div>
	                                <?php }?>

		                            <button type="button" class="btn btn-info generate-group">Сгенерировать пароль</button>

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

            <div class="col-md-4">
        		<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 border-top-0">
						    <div class="form-group mb-3">
							    <div class="form-check form-switch mb-2">
								    <input type="checkbox" class="form-check-input form-check-input-success" id="receiveEmails" name="manager[receiveEmails]" value="1" <?php if ((isset($_smarty_tpl->tpl_vars['manager']->value['receiveEmails'])) && $_smarty_tpl->tpl_vars['manager']->value['receiveEmails'] == 1) {?>checked<?php }?> >
								    <label class="form-check-label" for="receiveEmails">Не получать писем</label>
							    </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('id'=>"status",'title'=>"Статус",'field'=>"manager[status]",'array'=>$_smarty_tpl->tpl_vars['statuses']->value,'selected'=>(($tmp = $_smarty_tpl->tpl_vars['manager']->value['status'] ?? null)===null||$tmp==='' ? 'visible' ?? null : $tmp),'class'=>"form-group mb-3"), 0, false);
?>
                            
	                        <div class="form-group mb-3">
	                            <label class="form-label is-visible <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['no_more_admins'])) || (isset($_smarty_tpl->tpl_vars['errors']->value['no_more_developers'])) || (isset($_smarty_tpl->tpl_vars['errors']->value['access_level_empty']))) {?>text-danger<?php }?>">Группа</label>
	                            <?php echo smarty_function_html_options(array('options'=>$_smarty_tpl->tpl_vars['groups']->value,'selected'=>(($tmp = $_smarty_tpl->tpl_vars['manager']->value['accessLevel'] ?? null)===null||$tmp==='' ? '' ?? null : $tmp),'id'=>"accessLevel",'name'=>"manager[accessLevel]",'class'=>"form-control select"),$_smarty_tpl);?>

	                        </div>
	                    </div>

                        <?php if ((isset($_smarty_tpl->tpl_vars['manager']->value['addedOn'])) && (isset($_smarty_tpl->tpl_vars['manager']->value['last_login']))) {?>
				        <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>
						        </ul>
					        </div>
					        <div class="hstack gap-1">
						        <ul class="list list-unstyled mb-0 fs-sm">
                                    <li><?php echo htmlspecialchars((string)smarty_modifier_date_format($_smarty_tpl->tpl_vars['manager']->value['addedOn'],"%d.%m.%Y %H:%M"), ENT_QUOTES, 'UTF-8', true);?>
</li>
                                    <li><?php echo htmlspecialchars((string)smarty_modifier_date_format($_smarty_tpl->tpl_vars['manager']->value['last_login'],"%d.%m.%Y %H:%M"), ENT_QUOTES, 'UTF-8', true);?>
</li>
						        </ul>
					        </div>
				        </div>
                        <?php }?>
			        </div>
    			</div>
            </div>


	        <div class="col-md-12 text-center">
                <?php if ((isset($_smarty_tpl->tpl_vars['manager']->value['userId']))) {?><input type="hidden" class="form-control" id="id" name="id" value="<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['manager']->value['userId'], 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:uploads_init.tpl', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array(), 0, false);
?>

<?php echo '<script'; ?>
>
$(document).ready(function () {

    <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['login_empty']))) {?>     new Noty({ text: 'Поле логин не должно быть пустым', type: 'error' }).show(); <?php }?>
    <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['login_exists']))) {?>    new Noty({ text: 'Указанное имя менеджера уже существует.', type: 'error' }).show(); <?php }?>
    <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['user_not_found']))) {?>  new Noty({ text: 'Менеджер не найден.', type: 'error' }).show();  <?php }?>
    <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['loginName']))) {?>       new Noty({ text: 'Введите логин. (только цифры и латинские буквы)', type: 'error' }).show(); <?php }?>
    <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['fullName']))) {?>        new Noty({ text: 'Введите имя и фамилию менеджера.', type: 'error' }).show(); <?php }?>
    <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['password']))) {?>        new Noty({ text: 'Введите пароль.', 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['no_more_admins']))) {?>  new Noty({ text: 'Невозможно удалить или изменить уровень доступа менеджера, т.к. остался всего один менеджер с правами администратора.', type: 'error' }).show(); <?php }?>

    <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['developer_status']))) {?>    new Noty({ text: 'У Вас нет прав получить статус разработчика', type: 'error' }).show(); <?php }?>
    <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['no_more_developers']))) {?>  new Noty({ text: 'Невозможно удалить или изменить уровень доступа разработчика, т.к. остался всего один разработчик для техподдержки.', type: 'error' }).show(); <?php }?>
    <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['access_level_empty']))) {?>  new Noty({ text: 'Менеджеру необходимо назначить группу .', type: 'error' }).show(); <?php }?>
    <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['invalid_email']))) {?>       new Noty({ text: 'Необходимо указать правильный и действующий email', type: 'error' }).show(); <?php }?>
    <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['image_not_saved']))) {?>     new Noty({ text: 'Картинка не добавлена', type: 'error' }).show();<?php }?>
    <?php if ((isset($_smarty_tpl->tpl_vars['errors']->value['status_empty']))) {?>     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 accessLevelChange() {
	    var accessLevelId = document.getElementById('accessLevel').value;
		//console.log(accessLevelId)
	    $.post('<?php echo htmlspecialchars((string)$_smarty_tpl->tpl_vars['adminUrl']->value, ENT_QUOTES, 'UTF-8', true);?>
/manager?action=accessLevel', { accessLevelId: accessLevelId}, function (response) {
	        console.log(response)
		    if (response.status === 200) {
	            $('.boxed').replaceWith('<div class="boxed fn_toggle_wrap">' + response.permission + '</div>');
	        }
	    })
    }


    // $(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 }
}
