<?php 
	if(isset($_GET['view']) AND $_GET['view'] != ''){
		$pageTitle 	= 'Задача: ' . get_task_name($_GET['view'], '');
	} elseif(isset($_GET['edit']) AND $_GET['edit'] != ''){
		$pageTitle 	= 'Редактирование задачи: ' . get_task_name($_GET['edit'], '');
	} elseif(isset($_GET['new'])){
		$pageTitle 	= "Добавление задачи";
	} else {
		$pageTitle 	= 'Действующие задачи';
	}
	
	if(!isset($_GET['view']) AND !isset($_GET['edit'])){$filters = '1';}
	
	require_once(ROOT . 'templates/header.php'); 
	
	require_once(ROOT . 'modules/tasks/list-tasks.php'); 
	
	require_once(ROOT . 'templates/main-menu.php');
	
	
?>

<div class="container<?php global $designView; echo $designView; ?>">
	<div class="row">
		<?php 
		if(isset($_GET['view']) and $_GET['view'] != ''){ 
			require_once(ROOT . 'modules/tasks/page-tasks-view.php');
		} elseif(isset($_GET['edit']) and $_GET['edit'] != '' or isset($_GET['new'])) {
			if(isset($_GET['new']) or $TaskUser == $LoginCheck AND $TaskUserS == '' or $GroupCheck == 'admin' or $GroupCheck == 'manager' or $TaskUserS == $LoginCheck){
				require_once(ROOT . 'modules/tasks/page-tasks-edit.php');
			} else { echo '<meta http-equiv="refresh" content="0;/'.$folder.'/tasks">';}
		} else {
		?>
		<?php if ($GroupCheck != 'guest') { ?>
		<div class="col-lg-3 col-lg-push-9 col-md-4 col-md-push-8 col-sm-12">
			<?php require_once(ROOT . 'templates/side-block.php'); ?>
		</div>
		<div class="col-lg-9 col-lg-pull-3 col-md-8 col-md-pull-4 col-sm-12">
			
			<h1><?php if ( isset( $pageTitleBackLink ) ) { echo $pageTitleBackLink; } ?><?php echo $pageTitle; ?><span class="list-num"><i class="fa fa-fw fa-angle-double-down" aria-hidden="true"></i> <?php echo $countTaskStatusInWork; ?></span></h1>
			
			<?php require_once(ROOT . 'templates/search-form.php'); ?>
			
			<div class="table-responsive">
				<table id="all-tasks" class="table table-hover all-tasks tasks-inwork">
					<thead> 
						<tr> 
							<th width="6%"></th> 
							<th>Наименование</th> 
							<th width="6%" title="Процент выполнения"><i class="fa fa-line-chart" aria-hidden="true"></i></th> 
							<th width="15%" data-sorter="shortDate" data-date-format="yyyymmdd">Добавление</th>
							<th width="15%" data-sorter="shortDate" data-date-format="yyyymmdd">Завершение</th>
							<th width="6%"></th>
							<th width="6%"></th>
						</tr> 
					</thead> 
					<tbody>
						<?php require_once(ROOT . 'modules/tasks/list-tasks-m.php'); ?>
					</tbody>
				</table>
			</div>
			<?php require_once(ROOT . 'templates/table-pager.php'); ?>
		</div>
		<?php } else { include_once(ROOT . 'modules/access-denied.php'); } ?>
		<?php } ?>
	</div>
</div>
<?
	require_once(ROOT . 'templates/modal-wind.php');
	require_once(ROOT . 'templates/footer.php');
?>
	</body>
</html>