<?php 
	if(isset($_GET['view']) AND $_GET['view'] != ''){
		$pageTitle 	= get_letter_title($_GET['view']);
	} elseif(isset($_GET['new'])){
		$pageTitle 	= "Создание письма";
	} elseif(isset($_GET['folder']) AND $_GET['folder'] == 'inbox'){
		$pageTitle 	= "Входящие письма";
	} elseif(isset($_GET['folder']) AND $_GET['folder'] == 'outbox'){
		$pageTitle 	= "Отправленные письма";
	} elseif(isset($_GET['folder']) AND $_GET['folder'] == 'notread'){
		$pageTitle 	= "Непрочитанные письма";
	} elseif(isset($_GET['folder']) AND $_GET['folder'] == 'important'){
		$pageTitle 	= "Важные письма";
	} else {
		$pageTitle 	= 'Все письма';
	}
	
	if(!isset($_GET['view']) AND !isset($_GET['edit'])){$filters = '1';}

	require_once(ROOT . 'templates/header.php'); 
	
	require_once(ROOT . 'modules/letters/list-letters.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/letters/page-letters-view.php');
		} elseif(isset($_GET['new'])) {
			require_once(ROOT . 'modules/letters/page-letters-edit.php');
		} else {
		?>
		<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 echo $pageTitle; ?><span class="list-num"><i class="fa fa-fw fa-angle-double-down" aria-hidden="true"></i> <?php echo $countUserLetters;?></span></h1>
			
			<?php require_once(ROOT . 'templates/search-form.php'); ?>
			
			<div class="table-responsive">
				<table id="all-letters" class="table table-hover all-letters letters-inwork">
					<thead> 
						<tr> 
							<th width="6%"></th>
							<th>Письмо</th> 
							<th width="6%"></th>
							<th width="17%" data-sorter="shortDate" data-date-format="yyyymmdd">Дата отправки</th>
							<th width="6%"></th>
						</tr> 
					</thead> 
					<tbody>
						<?php require_once(ROOT . 'modules/letters/list-letters-m.php'); ?>
					</tbody>
				</table>
			</div>
			<?php require_once(ROOT . 'templates/table-pager.php'); ?>
		</div>
		<?php } ?>
	</div>
</div>
<?
	require_once(ROOT . 'templates/modal-wind.php');
	require_once(ROOT . 'templates/footer.php');
?>
	</body>
</html>