<div class="navbar navbar-inverse navbar-fixed-top grayscale_menu <?php if (!$auth->isAuth()) {echo 'grayscale_menu';} ?>" role="navigation">
	<div class="container<?php global $designView; echo $designView; ?>" style="position:relative;">
		<div class="navbar-header">
			<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
				<span class="sr-only">Toggle navigation</span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
			</button>
			<div class="navbar-header-btns hidden-lg hidden-md hidden-sm">
				<?php if(isset($filters) AND $filters == '1' AND !isset($_GET['new']) AND !isset($_GET['edit'])) {?>
				<button type="button" class="btn-filter" onclick="$('.filters').toggle(0);$('body').scrollTo('.filters',500);"><i class="fa fa-fw fa-filter"></i></button>
				<?php } ?>
				<?php if(isset($moreinfo) AND $moreinfo == '1' AND !isset($_GET['new']) AND !isset($_GET['edit'])) {?>
				<button type="button" class="btn-filter" onclick="$('.filters').toggle(0);$('body').scrollTo('.filters',500);"><i class="fa fa-fw fa-info-circle"></i></button>
				<?php } ?>
			</div>
			<a class="navbar-brand" href="/<?php echo $folder; ?>/"></a>
		</div>
		
		<?php if ($auth->isAuth() and $_SESSION["folder"] == $folder) { ?>
		
		<a href="/<?php echo $folder; ?>/" class="crm_name hidden-lg hidden-md hidden-sm"><?php echo $CRMnameFull; ?></a>
		<div class="navbar-collapse collapse" data-hover="dropdown" data-animations="">
			<ul class="nav navbar-nav menu_select">
				<?php if ($GroupCheck == 'admin') { ?>
					<?php if (file_exists($fileA)) { ?>
						<li></span></a></li>
						<li class="dropdown">
							<a href="/<?php echo $folder; ?>/admin"><i class="fa fa-fw fa-gear" aria-hidden="true"></i><span class="hidden-lg hidden-md hidden-sm"> <?=Dict::_('CONTROL')?></span> <span class="caret hidden-sm hidden-xs"></span></a>
							<ul class="dropdown-menu">
								<li><a href="/<?php echo $folder; ?>/admin">Панель управления CRM</a></li>
								<?php if ($aliases_arr[1] != 'admin') { ?>
								<li><a href="/<?php echo $folder; ?>/admin/#actions">Действия сотрудников</a></li>
								<li><a href="/<?php echo $folder; ?>/admin/#backups">Базы данных / BackUp</a></li>
								<li><a href="/<?php echo $folder; ?>/admin/#settings">Настройки системы</a></li>
								<li class="divider"></li>
								<li><a href="/<?php echo $folder; ?>/admin/#support">Техническая поддержка</a></li>
								<li><a href="/<?php echo $folder; ?>/admin/#update">Обновление системы</a></li>
								<?php } ?>
								<li class="divider"></li>
								<li><a href="/<?php echo $folder; ?>/donate">Поддержать проект</a></li>
								
							</ul>
						</li>
					<?php } ?>
				<?php } ?>
				<?php if($nCRMsn != '' and $nCRMdateTo > $nCRMdateFrom) { ?>
					<?php if ($GroupCheck != 'guest') { ?>
						<?php if ($GroupCheck == 'admin' or $GroupCheck == 'manager') { ?>
							<?php if (file_exists($baseT) and file_exists($fileT)) { ?>
								<li class="dropdown">
									<a href="/<?php echo $folder; ?>/tasks"><i class="fa fa-fw fa-check" aria-hidden="true"></i><span class="hidden-sm"> <?=Dict::_('TASKS')?></span> <span class="caret hidden-sm hidden-xs"></span></a>
									<a class="add hidden-lg hidden-md hidden-sm" href="/<?php echo $folder; ?>/tasks/?new"><i class="fa fa-fw fa-plus" aria-hidden="true"></i></a>
									<ul class="dropdown-menu">
										<li><a href="/<?php echo $folder; ?>/tasks/?new">Добавить</a></li>
										<li class="divider"></li>
										<li><a href="/<?php echo $folder; ?>/tasks">Действующие задачи • <?php echo $countIndexTaskStatusInWork;?></a></li>
										<li><a href="/<?php echo $folder; ?>/tasks-archive">Архив задач • <?php echo $countTaskStatusDone; ?></a></li>
										<li class="divider"></li>
										<li><a href="/<?php echo $folder; ?>/timeline">График загрузки</a></li>
									</ul>
									
								</li>
								<li class="hidden-lg hidden-md">
									<a href="/<?php echo $folder; ?>/timeline"><i class="fa fa-line-chart" aria-hidden="true"></i><span class="hidden-sm"> График загрузки</span></a>
								</li>
							<?php } ?>
						<?php } ?>
						<?php if ($GroupCheck == 'admin' or $GroupCheck == 'manager') { ?>
							<?php if (file_exists($baseC) and file_exists($fileC)) { ?>
								<li class="dropdown">
									<a href="/<?php echo $folder; ?>/clients"><i class="fa fa-fw fa-address-book" aria-hidden="true"></i><span class="hidden-sm"> <?=Dict::_('CLIENTS')?></span> <span class="caret hidden-sm hidden-xs"></span></a>
									<a class="add hidden-lg hidden-md hidden-sm" href="/<?php echo $folder; ?>/clients/?new"><i class="fa fa-fw fa-plus" aria-hidden="true"></i></a>
									<ul class="dropdown-menu">
										<li><a href="/<?php echo $folder; ?>/clients/?new">Добавить</a></li>
										<li class="divider"></li>
										<li><a href="/<?php echo $folder; ?>/clients">Все клиенты • <?php echo $countIndexClient;?></a></li>
										<li class="divider"></li>
										<li><a href="/<?php echo $folder; ?>/requests">Запросы клиентов</a></li>
									</ul>
								</li>
								<li class="hidden-lg hidden-md">
									<a href="/<?php echo $folder; ?>/requests"><i class="fa fa-fw fa-file-text-o" aria-hidden="true"></i><span class="hidden-sm"> Запросы клиентов</span></a>
								</li>
							<?php } ?>
							
							<?php if (!strstr($nCRMdealaccess,$LoginCheck)) {} else { ?>
								<?php if (file_exists($baseD) and file_exists($fileD)) { ?>
									<li class="dropdown">
										<a href="/<?php echo $folder; ?>/deals" ><i class="fa fa-fw fa-briefcase" aria-hidden="true"></i><span class="hidden-sm"> <?=Dict::_('DEALS')?></span> <span class="caret hidden-sm hidden-xs"></span></a>
										<a class="add hidden-lg hidden-md hidden-sm" href="/<?php echo $folder; ?>/deals/?new"><i class="fa fa-fw fa-plus" aria-hidden="true"></i></a>
										<ul class="dropdown-menu">
											<li><a href="/<?php echo $folder; ?>/deals/?new">Добавить</a></li>
											<li class="divider"></li>
											<li><a href="/<?php echo $folder; ?>/deals">Активные сделки • <?php echo $countIndexDealA;?></a></li>
											<li><a href="/<?php echo $folder; ?>/deals-archive">Архив сделок • <?php echo ($countIndexDealC+$countIndexDealA+$countIndexOffer);?></a></li>
											<li class="divider"></li>
											<li><a href="/<?php echo $folder; ?>/payments">Список платежей</a></li>
										</ul>
									</li>
									<li class="hidden-lg hidden-md">
										<a href="/<?php echo $folder; ?>/payments"><i class="fa fa-fw fa-rub" aria-hidden="true"></i><span class="hidden-sm"> Список платежей</span></a>
									</li>
								<?php } ?>
							<?php } ?>
							
						<?php } ?>
					<?php } ?>
					<?php if (file_exists($baseU) and file_exists($fileU)) { ?>
						<li class="dropdown">
							<a href="/<?php echo $folder; ?>/users"><i class="fa fa-fw fa-user" aria-hidden="true"></i><span class="hidden-sm"> <?=Dict::_('USERS')?></span> <span class="caret hidden-sm hidden-xs"></span></a>
							<a class="add hidden-lg hidden-md hidden-sm" href="/<?php echo $folder; ?>/users/?new"><i class="fa fa-fw fa-plus" aria-hidden="true"></i></a>
							<ul class="dropdown-menu">
								<?php if ($GroupCheck == 'admin' or $GroupCheck == 'manager') { ?>
								<li><a href="/<?php echo $folder; ?>/users/?new">Добавить</a></li>
								<li class="divider"></li>
								<?php } ?>
								<li><a href="/<?php echo $folder; ?>/users">Все сотрудники • <?php echo $countIndexUser;?></a></li>
								<li class="divider"></li>
								<li><a href="/<?php echo $folder; ?>/vacations">График отпусков</a></li>
							</ul>
						</li>
					<?php } ?>
					<?php if (file_exists($baseE) and file_exists($fileE)) { ?>
						<li class="dropdown">
							<a href="/<?php echo $folder; ?>/events"><i class="fa fa-fw fa-calendar" aria-hidden="true"></i><span class="hidden-sm"> <?=Dict::_('EVENTS')?></span> <span class="caret hidden-sm hidden-xs"></span></a>
							<a class="add hidden-lg hidden-md hidden-sm" href="/<?php echo $folder; ?>/events/?new"><i class="fa fa-fw fa-plus" aria-hidden="true"></i></a>
							<ul class="dropdown-menu">
								<li><a href="/<?php echo $folder; ?>/events/?new">Добавить</a></li>
								<li class="divider"></li>
								<li><a href="/<?php echo $folder; ?>/events">Все события • <?php echo $countIndexEvents;?></a></li>
							</ul>
						</li>
					<?php } ?>
					<?php if (file_exists($baseLT) and file_exists($fileLT)) { ?>
						<li class="dropdown">
							<a href="/<?php echo $folder; ?>/letters" >
								<?php if(count_letters('notread') > 0){
									$notices[] = 'У вас есть непрочитанное письмо';
								?> 
								<i class="fa fa-fw fa-envelope" aria-hidden="true"></i><span class="hidden-sm"> <?=Dict::_('LETTERS')?></span><?php echo ' ( ' . count_letters('notread') . ' )';?> 
								<?php } else { ?> 
								<i class="fa fa-fw fa-envelope" aria-hidden="true"></i><span class="hidden-sm"> <?=Dict::_('LETTERS')?></span>
								<?php } ?> <span class="caret hidden-sm hidden-xs"></span>
							</a>
							<a class="add hidden-lg hidden-md hidden-sm" href="/<?php echo $folder; ?>/letters/?new"><i class="fa fa-fw fa-plus" aria-hidden="true"></i></a>
							<ul class="dropdown-menu">
								<li><a href="/<?php echo $folder; ?>/letters/?new">Написать письмо</a></li>
								<li class="divider"></li>
								<li><a href="/<?php echo $folder; ?>/letters/?folder=inbox">Входящие • <?php echo count_letters('inbox');?></a></li>
								<li><a href="/<?php echo $folder; ?>/letters/?folder=notread">Непрочитанные • <?php echo count_letters('notread');?></a></li>
								<li><a href="/<?php echo $folder; ?>/letters/?folder=outbox">Отправленные • <?php echo count_letters('outbox');?></a></li>
							</ul>
						</li>
					<?php } ?>
					<?php if (!strstr($nCRMdealaccess,$LoginCheck)) {} else { ?>
					<li class="hidden-lg hidden-md">
						<a href="/<?php echo $folder; ?>/statistic"><i class="fa fa-fw fa-pie-chart" aria-hidden="true"></i><span class="hidden-sm"> Статистика компании</span></a>
					</li>
					<? } ?>
				<?php } ?>
			</ul>
			<ul class="nav navbar-nav navbar-right">
				<?php if (file_exists($baseQ) and file_exists($fileQ)) {
				$dom = new DOMDocument;
				$dom->load($baseQ);
				$xpath = new DOMXPath($dom);
				$messages = $xpath->query('/messages/message');
				$countM = 0;
				foreach ($messages as $message) {
					$time			= date("H:i:s", time()-60*5);
					$date			= date("Y-m-d");
					$qchatTime 		= $message->getElementsByTagName("time")->item(0)->nodeValue;
					$qchatDate 		= $message->getElementsByTagName("date")->item(0)->nodeValue;
					if( $qchatDate == $date and $qchatTime >= $time){
						for ($i = 0; $i < $messages->length; $i++) {
							$qchatMessages 	= $xpath->query('/messages/message[date="'.$date.'"]')->item($i)->getElementsByTagName("time")->item(0)->nodeValue >= $time;
						}
					}
					$countM += count($qchatMessages);
				}
				if ($countM > 0 ){?>
				<li><a href="/<?php echo $folder; ?>/users" title="Кол-во сообщений в чате за последние 5 минут">+<?php echo $countM; ?><i class="fa fa-fw fa-commenting qchat-informer" aria-hidden="true"></i></a></li>
				<?php }} ?>
				<li class="dropdown">
					<a href="/<?php echo $folder; ?>/users/?view=<?php echo $auth->getUserId(); ?>">
						<?
						$doc = new DOMDocument;
						$doc->load($baseU);
						$xpath = new DOMXPath($doc);
						$userphoto 		= $xpath->query('/users/user[@login="'.$LoginCheck.'"]/userphoto')->item(0)->nodeValue;
						$userinitials 	= mb_substr($auth->getUserSurName(), 0, 1,'utf-8') . mb_substr($auth->getUserName(), 0, 1,'utf-8');
						if(file_exists(ROOT .'/crmdata/upload/_user-photo/'. $userphoto) and $userphoto != ''){
							echo '<div group="'.$GroupCheck.'" class="small-user-photo satur50" style="background:#fff url(\'/'. $folder . '/crmdata/upload/_user-photo/' . $userphoto . '?'.rand(1,1000).'\');"><div class="loader_smphoto"></div></div>';
						}else{
							echo '<div group="'.$GroupCheck.'" class="small-user-photo empty satur50" style="padding-right:0px;line-height:35px;text-align:center;font-size:17px;background:' . get_color2($userinitials) . ';">' . $userinitials . '</div>';
						}
						?>
						<span class="hidden-sm"><?=Dict::_('HELLO')?><?php echo ", " . $auth->getUserName(); ?></span>
					</a>
					<ul class="dropdown-menu">
						<?php if (!strstr($nCRMdealaccess,$LoginCheck)) {} else { ?>
						<li><a href="/<?php echo $folder; ?>/statistic">Статистика компании</a></li>
						<?php } ?>
						<li><a href="/<?php echo $folder; ?>/users/?view=<?php echo $auth->getUserId(); ?>">Личный профиль</a></li>
						<li class="divider"></li>
						<li><a href="/<? echo $folder; ?>/donate">Поддержать проект</a></li>
						<li class="divider"></li>
						<li><a href="?is_exit=1">Выйти из CRM</a></li>
					</ul>
				</li>
				<li class="hidden-lg"><a href="?is_exit=1"><i class="fa fa-fw fa-sign-out" aria-hidden="true"></i><span class="hidden-md hidden-sm"> <?=Dict::_('EXIT')?></span></a></li>
			</ul>
		</div>
		
		<?php } else { ?>
		
		<a href="/<?php echo $folder; ?>/" class="crm_name"><?php echo $_SERVER['HTTP_HOST']; ?></a>
		<div class="navbar-collapse collapse" data-hover="dropdown" data-animations="">
			<ul class="nav navbar-nav navbar-right" style="margin-top:0px;">
				<?php if(!isset($_GET["change_pass"])){ ?>
				<li><a href="/<?php echo $folder; ?>/?change_pass">Забыл пароль</a></li>
				<?php } else { ?>
				<li><a href="/<?php echo $folder; ?>/">Авторизация</a></li>
				<?php } ?>
			</ul>
		</div>
		
		<?php } ?>
		
	</div>
</div>