<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
	<meta name="viewport" content="width=device-width, maximum-scale=1, initial-scale=1, user-scalable=0">
	<title><?=$this->title ? $this->title : 'Cockpit'?></title>
	<link href="/assets/css/core/core.css" media="screen" rel="stylesheet" type="text/css" />

	<link rel="stylesheet" type="text/css" href="/assets/css/admin.css">

	<link rel="stylesheet" type="text/css" href="/assets/css/sprites.css">
	<link rel="stylesheet" type="text/css" href="/assets/css/introjs.css">
	<link rel="stylesheet" type="text/css" href="/assets/css/datepicker.css">
	<link rel="stylesheet" type="text/css" href="/assets/css/chosen.css">


	<script src="/assets/js/core/core.js" type="text/javascript"></script>
	<script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js"></script>
	<script src="/assets/js/admin.js" type="text/javascript"></script>
	<script src="/assets/js/chosen.jquery.js" type="text/javascript"></script>
	<script src="/assets/js/highcharts.src.js" type="text/javascript"></script>
	<? if( c::env() == 'local' ): ?>
		<link rel="shortcut icon" href="/assets/images/favicon-admin-dev.png">
	<? else : ?>
		<link rel="shortcut icon" href="/assets/images/favicon-admin.png">
	<? endif ; ?>
</head>

<body>

<!-- top nav -->
<div class="navbar navbar-top navbar-inverse">
	<div class="navbar-inner">
		<div class="container-fluid">
			<a class="brand" href="/"><img src="/assets/images/admin/logo-top.png">Cockpit</a>

			<ul class="nav pull-right">
				<li class="toggle-primary-sidebar hidden-desktop" data-toggle="collapse" data-target=".nav-collapse-primary"><button type="button" class="btn btn-navbar"><i class="icon-th-list"></i></button></li>
				<li class="hidden-desktop" data-toggle="collapse" data-target=".nav-collapse-top"><button type="button" class="btn btn-navbar"><i class="icon-align-justify"></i></button></li>
			</ul>

			<div class="nav-collapse nav-collapse-top collapse">

				<ul class="nav full pull-right">
					<li class="dropdown user-avatar">

						<a href="#" class="dropdown-toggle" data-toggle="dropdown">
							<span>
								<img class="menu-avatar" src="/assets/images/admin/user.jpg" /> <span><?=c::admin()->name?> <i class="icon-caret-down"></i></span>
								<span class="badge badge-dark-red" style="display: none;">5</span>
							</span>
						</a>

						<ul class="dropdown-menu">

							<li class="with-image">
								<div class="avatar">
									<img src="/assets/images/admin/user.jpg" />
								</div>
								<span><?=c::admin()->name?></span>
							</li>

							<li class="divider"></li>
							<li><a href="http://log:out@<?=$_SERVER['HTTP_HOST']?>"><i class="icon-off"></i> <span>Logout</span></a></li>
						</ul>
					</li>
				</ul>
				<? if ( c::admin()->permission()->check( [ 'global','orders'] ) ) : ?>
				<form class="navbar-search pull-right" action="/orders" method="get">
					<input type="text" class="search-query animated" placeholder="Search Orders" name="s">
					<i class="icon-search"></i>
				</form>
				<? endif ; ?>
				<ul class="nav pull-right">

					<li class="active">
						<a href="/support/" title="tickets waiting for an anwser">
							<i class="icon-comments"></i> Support
							<span class="badge badge-dark-red" id="support-badge" style="display:none;position:absolute;margin-top:-5px;margin-left:5px;">5</span>
						</a>
					</li>
				</ul>
			</div>
		</div>
	</div>
</div>
<!-- // top nav -->

<div class="sidebar-background">
	<div class="primary-sidebar-background"></div>
</div>

<!-- side nav -->
<div class="primary-sidebar">
	<ul class="nav nav-collapse collapse nav-collapse-primary">

		<? if ( c::admin()->permission()->check( [ 'global','restaurants-all','restaurants-list-page','restaurants-crud','restaurants-create'] ) ) : ?>
			<li class="<?=$this->page == 'restaurants' ? 'active' : ''?>">
				<span class="glow"></span>
				<a href="/restaurants">
					<i class="icon-food icon-2x"></i>
					<span>Restaurants</span>
				</a>
			</li>
		<? endif ; ?>


		<? if ( c::admin()->permission()->check( [ 'global','community-page'] ) ) : ?>
			<li class="<?=$this->page == 'community' ? 'active' : ''?>">
				<span class="glow"></span>
				<a href="/community">
					<i class="icon-group icon-2x"></i>
					<span>Communities</span>
				</a>
			</li>
		<? endif ; ?>



		<? if (c::admin()->permission()->check(['global', 'suggestions-all', 'suggestions-list-page', 'gift-card-all', 'gift-card-list-page', 'gift-card-list-all' ,'support-all', 'support-view', 'support-crud', 'support-settings' ])) : ?>

			<li class="dark-nav">
				<span class="glow"></span>

				<a class="accordion-toggle collapsed" href="#admin-nav-customers" data-toggle="collapse" >
					<i class="icon-smile icon-2x"></i>
					<span>Customers <i class="icon-caret-down"></i></span>
				</a>
				<ul id="admin-nav-customers" class="collapse">

					<? if (c::admin()->permission()->check(['global', 'gift-card-all', 'gift-card-list-page', 'gift-card-list-all'])) { ?>
						<li class="">
							<a href="/giftcards">
								<i class="icon-gift"></i> Gift cards
							</a>
						</li>
					<? } ?>
					<? if ( c::admin()->permission()->check( [ 'global','support-all', 'support-view', 'support-crud', 'support-settings' ] ) ) { ?>
						<li class="">
							<a href="/support">
								<i class="icon-comments"></i> Support
							</a>
						</li>
					<? } ?>

				</ul>
			</li>
		<? endif ; ?>

		<? if ( c::admin()->permission()->check( [ 'global','drivers-page'] ) || c::admin()->isDriver() ) : ?>
			<li class="dark-nav">
				<span class="glow"></span>

				<a class="accordion-toggle collapsed" href="#admin-nav-drivers" data-toggle="collapse" >
					<i class="icon-road icon-2x"></i>
					<span>Drivers <i class="icon-caret-down"></i></span>
				</a>
				<ul id="admin-nav-drivers" class="collapse">

					<? if ( c::admin()->permission()->check( [ 'global','drivers-all', 'drivers-working-hours', 'drivers-working-hours-view' ] ) ) { ?>
					<li class="">
						<a href="/drivers/shift/summary">
							<i class="icon-file-alt"></i> Scheduled Shifts
						</a>
					</li>
					<? } ?>

					<? if ( c::admin()->permission()->check( [ 'global'] )  ) { ?>
					<li class="">
						<a href="/drivers/shift/status/shift">
							<i class="icon-file-alt"></i> List All Drivers
						</a>
					</li>
					<? } ?>

					<? if ( c::admin()->permission()->check( [ 'global','drivers-all', 'drivers-orders-view' ] ) ) { ?>
						<li class="">
							<a href="/drivers/deliveries">
								<i class="icon-truck"></i> Delivered orders
							</a>
						</li>
					<? } ?>
					<? if ( c::admin()->permission()->check( [ 'global','drivers-all', 'drivers-assign' ] ) ) { ?>
						<li class="">
							<a href="/drivers/assign">
								<i class="icon-magnet"></i> Assign to R/C
							</a>
						</li>
					<? } ?>
<!--
					<? if ( c::admin()->permission()->check( [ 'global','drivers-all', 'drivers-working-hours', 'drivers-working-hours-view' ] ) ) { ?>
						<li class="">
							<a href="/drivers/schedule">
								<i class="icon-calendar"></i> Schedule
							</a>
						</li>
					<? } ?>
-->
					<? if ( c::admin()->permission()->check( [ 'global','drivers-all', 'drivers-working-hours', 'drivers-working-hours-view' ] ) ) { ?>
					<li class="">
						<a href="/drivers/shift/community">
							<i class="icon-truck"></i> Community shifts
						</a>
					</li>
					<? } ?>

				</ul>
			</li>
		<? endif ; ?>

	<? if ( c::admin()->permission()->check( [ 'global', 'metrics-all', 'metrics-main', 'metrics-investors', 'metrics-detailed-analytics', 'metrics-no-grouped-charts', 'metrics-communities', 'metrics-communities-page', 'locations' ] ) ) { ?>

		<li class="dark-nav">
			<span class="glow"></span>

			<a class="accordion-toggle collapsed" href="#admin-nav-reports" data-toggle="collapse" >
				<i class="icon-bar-chart icon-2x"></i>
				<span>Reports <i class="icon-caret-down"></i></span>
			</a>
			<ul id="admin-nav-reports" class="collapse">
				<? if ( c::admin()->permission()->check( [ 'global', 'metrics-all', 'metrics-main', 'metrics-investors', 'metrics-detailed-analytics', 'metrics-no-grouped-charts' ] ) ) { ?>
					<li class="">
						<a href="/charts">
							<i class="icon-bar-chart"></i> Overview
						</a>
					</li>
				<? } ?>
				<? if ( c::admin()->permission()->check( [ 'global', 'metrics-all', 'metrics-communities', 'metrics-communities-page'] ) ) { ?>
					<li class="">
						<a href="/charts/community">
							<i class="icon-group"></i> Community metrics
						</a>
					</li>
				<? } ?>
				<? if ( c::admin()->permission()->check( [ 'global', 'metrics-all', 'metrics-communities', 'metrics-communities-page'] ) ) { ?>
					<li class="">
						<a href="/charts/restaurant">
							<i class="icon-food"></i> Restaurant metrics
						</a>
					</li>
				<? } ?>
				<? if ( c::admin()->permission()->check( [ 'global', 'metrics-all', 'metrics-communities', 'metrics-communities-page'] ) ) { ?>
					<li class="">
						<a href="/home/marketing">
							<i class="icon-bullhorn"></i> Marketing
						</a>
					</li>
				<? } ?>

			</ul>
		</li>

		<? } ?>

	</ul>

	<? /*
	<div class="hidden-tablet hidden-phone">


		<hr class="divider" style="margin-top: 60px">

		<div class="sparkline-box side">

			<div class="sparkline-row">
				<h4 class="gray"><span>Orders</span> 847</h4>
				<div class="sparkline big" data-color="gray"><!--28,11,24,24,8,20,26,22,16,6,12,15--></div>
			</div>

			<hr class="divider">
			<div class="sparkline-row">
				<h4 class="dark-green"><span>Income</span> $43.330</h4>
				<div class="sparkline big" data-color="darkGreen"><!--16,20,6,19,25,22,9,13,7,10,15,4--></div>
			</div>

			<hr class="divider">
			<div class="sparkline-row">
				<h4 class="blue"><span>Reviews</span> 223</h4>
				<div class="sparkline big" data-color="blue"><!--20,18,21,17,5,7,29,9,8,14,23,8--></div>
			</div>

			<hr class="divider">
		</div>
	</div>
	*/ ?>
</div>
<!-- // end side nav -->


<div class="main-content">
	<? /*
	<div class="container-fluid">
		<div class="row-fluid">

			<div class="area-top clearfix">
				<div class="pull-left header">
					<h3 class="title">
						<i class="icon-<?=$this->titleicon?>"></i>
						<?=$this->title?>
					</h3>
					<h5><?=$this->subtitle?></h5>
				</div>

				<ul class="inline pull-right sparkline-box">

					<li class="sparkline-row">
						<h4 class="blue"><span>Orders</span> 847</h4>
						<div class="sparkline big" data-color="blue"><!--10,14,20,21,18,13,24,14,6,7,28,24--></div>
					</li>

					<li class="sparkline-row">
						<h4 class="green"><span>Reviews</span> 223</h4>
						<div class="sparkline big" data-color="green"><!--8,11,26,14,27,28,8,13,10,22,6,15--></div>
					</li>

					<li class="sparkline-row">
						<h4 class="red"><span>New visits</span> 7930</h4>
						<div class="sparkline big"><!--7,3,24,18,24,3,4,9,16,24,16,29--></div>
					</li>

				</ul>
			</div>
		</div>
	</div>
	*/ ?>

	<!-- breadcrumbs -->
	<div class="container-fluid padded">
		<div class="row-fluid">
			<div id="breadcrumbs">
				<div class="breadcrumb-button blue">
					<span class="breadcrumb-label"><i class="icon-home"></i> Home</span>
					<span class="breadcrumb-arrow"><span></span></span>
				</div>

				<? if ($this->title) : ?>
	        		<div class="breadcrumb-button">
	        			<? if ($this->titleLink) : ?><a href="<?=$this->titleLink?>"><? endif ; ?>
							<span class="breadcrumb-label">
								<i class="icon-<?=$this->titleicon?>"></i> <?=$this->title?>
							</span>
						<? if ($this->titleLink) : ?></a><? endif ; ?>
						<span class="breadcrumb-arrow"><span></span></span>
					</div>
				<? endif ; ?>

				<? if ($this->title2) : ?>
	        		<div class="breadcrumb-button">
	        		<? if ($this->title2Link) : ?><a href="<?=$this->title2Link?>"><? endif ; ?>
						<span class="breadcrumb-label">
							<i class="icon-<?=$this->title2icon?>"></i> <?=$this->title2?>
						</span>
						<? if ($this->title2Link) : ?></a><? endif ; ?>
						<span class="breadcrumb-arrow"><span></span></span>
					</div>
				<? endif ; ?>
			</div>
		</div>
	</div>
	<!-- // breadcrumbs -->


	<?=$this->content?>

	</div>
</div>

<script type="text/javascript">
	function supportBadge(){
		var url = '/api/support/count';
		$.getJSON( url, function( json ){
			if (json.total) {
				$( '#support-badge' ).show().html(json.total);
			} else {
				$( '#support-badge' ).hide();
			}

			setTimeout( function(){
				supportBadge();
			}, 10000 );
		} );
	}
	$(document).ready( function(){
		supportBadge();
	} );

</script>

	<!-- <link href="http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css"> -->
	<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css">


</body>
</html><?php exit(); ?>
