@extends('layouts.master')

@section('header')
	@include('common.header')
@stop

@section('content')
	@php
		// Create a map of visible tabs by key for easy lookup
		$tabsMap = [];
		foreach ($dashboardTabs as $tab) {
			$tabsMap[$tab->tab_key] = $tab;
		}

		// Helper function to check if a tab is visible and get it
		$isTabVisible = function($key) use ($tabsMap) {
			return isset($tabsMap[$key]) ? $tabsMap[$key] : null;
		};
	@endphp

	{{-- Declare the main page wrapper and also the AngularJS Controller --}}
	<div id="dashboard" data-ng-controller="DashboardMainCtrl_v2" ng-cloak>
		<span data-ng-init="loggedin_user = {!! Auth::user()->id !!}"></span>
		<span ng-init="subtypes = {{ App\Modules\Bookings\TaskSubtype::support()->get() }}"></span>

					<div id="wotd"> </div>
		<div class="row">
			<div class="col-sm-4">
				{{-- Pie Chart --}}
				<div class="widget widget-classic">
					<div class="widget-content">
						<div class="headline">
							<h4><i class="fa fa-tag"></i> Your general stats</h4>
						</div>

						<!-- Render the user dropdown -->
						<div class="clearfix">
							<select name="user_id" ng-model="selected_user" class="form-control" ui-select2>
								@foreach(App\Models\User::getActiveList()->pluck('name', 'id') as $id => $name)
									<option value="{{ $id }}" {{ $id == Auth::user()->id ? 'selected' : '' }}>{{ $name }}</option>
								@endforeach
							</select>
						</div>

						<!-- Render the date range picker -->
						<div class="clearfix text-center">
							<div style="display: inline-block; margin: 10px 0 5px;" ng-model="dates" ng-daterangepicker data-ranges="daterangepicker.ranges" data-format="MMMM D, YYYY">
								<i class="fa fa-calendar fa-lg"></i>
								<span class="muted">{[{ dates.startDate.format('D MMM YYYY') }]} - {[{ dates.endDate.format('D MMM YYYY') }]}</span> <b class="caret" style="margin-top: 8px;"></b>
							</div>
						</div>

						<div class="well well-small text-center" style="margin-top: 10px; font-size: 14px;">
							Your customer feedback <span tooltip="{[{ feedback }]}" tooltip-placement="right"><uib-rating ng-model="feedback" read-only="true"></uib-rating></span>
						</div>

						<canvas class="chart chart-doughnut" chart-data="charts.user_stats.data" chart-labels="charts.user_stats.labels"></canvas>
					</div>
				</div>
			</div>
			<div class="col-sm-8">
				<div class="row">
					<div class="col-sm-4">
						<div class="widget widget-classic">
							<div class="widget-content">
								<div class="headline">
									<h4><i class="fa fa-bar-chart-o"></i> Repair Stats</h4>
								</div>
								<table class="table table-condensed table-striped">
									<tbody>
										<tr>
											<td>Completed</td>
											<td><span class="pull-right">{[{ stats.repairs.completed || 0 }]}</span></td>
										</tr>
										<tr>
											<td>Returns</td>
											<td><span class="pull-right">{[{ stats.repairs.returns || 0 }]}</span></td>
										</tr>
									</tbody>
								</table>

								@if (Auth::user()->repair_target)
									<div class="headline" style="margin-top: 25px">
										<h4><i class="fa fa-bullseye"></i> Current target</h4>
									</div>
									<div class="progress" tooltip="{[{ targets.repairs.total }]} - {[{ targets.repairs.percent }]}%">
										<div class="progress-bar"
											 ng-class="{
											 	'progress-bar-success': targets.repairs.percent > 80,
											 	'progress-bar-warning': targets.repairs.percent > 50 && targets.repairs.percent < 80,
											 	'progress-bar-danger': targets.repairs.percent < 50
											 }"
											 style="width: {[{ targets.repairs.percent }]}%;">{[{ targets.repairs.total }]}</div>
										<span style="position: absolute; right: 4px; top: 0; width: auto; color: #000; left: auto; font-size: 11px;">{[{ targets.repairs.target }]}</span>
									</div>
									<div class="text-center">
										<a href="#" ng-click="showRepairsLeaderboard()" data-eat-click>View leaderboard</a>
									</div>
								@endif

								@if (Auth::user()->isMemberOf(4))
									<span ng-init="loadPieCharts = true"></span>
									<canvas class="chart chart-pie" chart-data="charts.repairs.data" chart-labels="charts.repairs.labels"></canvas>
								@endif
							</div>
						</div>
					</div>
					<div class="col-sm-4">
						<div class="widget widget-classic">
							<div class="widget-content">
								<div class="headline">
									<h4><i class="fa fa-bar-chart-o"></i> Remote Support Stats</h4>
								</div>
								<table class="table table-condensed table-striped">
									<tbody>
										<tr>
											<td>Completed</td>
											<td><span class="pull-right">{[{ stats.support.completed || 0 }]}</span></td>
										</tr>
									</tbody>
								</table>
								@if (Auth::user()->isMemberOf(4))
									<canvas class="chart chart-pie" chart-data="charts.support.data" chart-labels="charts.support.labels"></canvas>
								@endif
							</div>
						</div>
					</div>
					<div class="col-sm-4">
						<div class="widget widget-classic">
							<div class="widget-content">
								<div class="headline">
									<h4><i class="fa fa-bar-chart-o"></i> Onsite Stats</h4>
								</div>
								<table class="table table-condensed table-striped">
									<tbody>
										<tr>
											<td>Completed</td>
											<td><span class="pull-right">{[{ stats.onsite.completed || 0 }]}</span></td>
										</tr>
									</tbody>
								</table>
								@if (Auth::user()->isMemberOf(4))
									<canvas class="chart chart-pie" chart-data="charts.onsite.data" chart-labels="charts.onsite.labels"></canvas>
								@endif
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

		{{-- Dashboard tabs below --}}
		<uib-tabset tabdrop>
			@if($tab = $isTabVisible('my_tasks'))
			<uib-tab>
				<uib-tab-heading>
					{[{ getSelectedUserName() }]} Tasks <span class="badge badge-inverse">{[{ total_tasks }]}</span>
				</uib-tab-heading>
				<div class="bookings-content repair-tab">
					<script type="module">
						import wotd from '/v2/js/vue/embedded/wotd.js?v={{ time() }}' 
					</script>
					<div class="row" style="margin-left: 0; margin-right: 0;">
						<div class="col-sm-6" style="padding-left: 15px; padding-right: 7.5px;">

							<div class="quick-new-task"></div>
							<br>

							<div data-ng-if="collectionsQueue.length > 0" ng-cloak>
								<div class="headline">
									<h4><i class="fa fa-download"></i> Collections Queue <span class="badge badge-info">{[{ collectionsQueue.length }]}</span></h4>
								</div>
								<table class="table table-striped table-condensed">
									<thead class="table-header">
										<th>ID</th>
										<th></th>
										<th>Title</th>
										<th>Client</th>
										<th>Contract</th>
										<th>Status</th>
										<th>Created</th>
									</thead>
									<tbody>
										<tr ng-repeat="task in collectionsQueue"
											ng-class="{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3', 'prebook-note': task.prebook == '1'}">
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-bind="::task.id"></a></td>
											<td><i class="fa" uib-tooltip="{[{ task.type }]}" data-ng-class="{'fa-wrench': task.type == 'repair', 'fa-laptop': task.type == 'support', 'fa-truck': task.type == 'onsite'}"></i></td>
											<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
											<td class="short-text-ellipsis" ng-bind="::task.client.name"></td>
											<td><span class="label label-danger short-text-ellipsis" ng-hide="task.client_id == '53' && task.client_type == 'client'" ng-bind="::task.client.contract.name"></span></td>
											<td ng-bind="::task.status.name"></td>
											<td><span data-ng-title="::task.created_at" uib-tooltip="{[{ task.created_at }]}" ng-bind="::task.created_at | fromNow"></span></td>
										</tr>
									</tbody>
								</table>
								<br><br>
							</div>

							<div data-ng-if="deliveriesQueue.length > 0" ng-cloak>
								<div class="headline">
									<h4><i class="fa fa-truck"></i> Deliveries Queue <span class="badge badge-info">{[{ deliveriesQueue.length }]}</span></h4>
								</div>
								<table class="table table-striped table-condensed">
									<thead class="table-header">
										<th>ID</th>
										<th></th>
										<th>Title</th>
										<th>Client</th>
										<th>Contract</th>
										<th>Completed By</th>
										<th>Completed</th>
									</thead>
									<tbody>
										<tr ng-repeat="task in deliveriesQueue"
											ng-class="{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3'}">
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-bind="::task.id"></a></td>
											<td><i class="fa" uib-tooltip="{[{ task.type }]}" data-ng-class="{'fa-wrench': task.type == 'repair', 'fa-laptop': task.type == 'support', 'fa-truck': task.type == 'onsite'}"></i></td>
											<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
											<td class="short-text-ellipsis" ng-bind="::task.client.name"></td>
											<td><span class="label label-danger short-text-ellipsis" ng-hide="task.client_id == '53' && task.client_type == 'client'" ng-bind="::task.client.contract.name"></span></td>
											<td ng-bind="::task.user.name"></td>
											<td><span data-ng-title="::task.completed_at" uib-tooltip="{[{ task.completed_at }]}" ng-bind="::task.completed_at | fromNow"></span></td>
										</tr>
									</tbody>
								</table>
								<br><br>
							</div>

							<div ng-if="deliveries.length > 0" ng-cloak>
								<div class="headline">
									<h4><i class="fa fa-desktop"></i> Computers that you need to deliver back: <span class="badge badge-info">{[{ deliveries.length }]}</span></h4>
								</div>
								<table class="table table-striped table-condensed">
									<thead class="table-header">
										<th></th>
										<th>ID</th>
										<th>Customer</th>
										<th>Title</th>
										<th>Completed By</th>
										<th>Completed</th>
										<th></th>
									</thead>
									<tbody>
										<tr ng-repeat="task in deliveries" ng-class="{'line-through': task.delivered == '1'}">
											<td><input type="checkbox" id="delivered-{[{ task.id }]}" name="delivered" ng-change="delivered(task)" ng-model="task.delivered" value="1"><label class="checkbox" for="delivered-{[{ task.id }]}"></label></td>
											<td><a href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}">{[{ ::task.id }]}</a></td>
											<td>{[{ ::task.client.name }]}</td>
											<td>{[{ ::task.title }]}</td>
											<td>{[{ ::task.user.name }]}</td>
											<td><span tooltip="{[{ ::task.completed_at }]}"><i class="fa fa-clock-o"></i> {[{ ::task.completed_at | fromNow }]}</span></td>
											<td><span ng-show="task.delivered == '1'">DELIVERED</span></td>
										</tr>
									</tbody>
								</table>
								<br><br>
							</div>

							<div ng-if="messages.length > 0" ng-cloak>
								<div class="headline">
									<h4><i class="fa fa-envelope"></i> Messages: <span class="badge badge-info">{[{ messages.length }]}</span></h4>
								</div>
								<table class="table table-striped table-condensed">
									<thead class="table-header">
										<th>ID</th>
										<th>Customer</th>
										<th>Message</th>
										<th>Opened</th>
									</thead>
									<tbody>
										<tr ng-repeat="task in messages" ng-class="{'line-through': ::task.delivered == '1'}">
											<td><a href="{!! URL::to('messages') !!}/{[{ task.id }]}">{[{ ::task.id }]}</a></td>
											<td>{[{ ::task.client.name }]}</td>
											<td strip-html="{[{ ::task.message | limitTo:100 }]}"></td>
											<td><span tooltip="{[{ ::task.created_at }]}"><i class="fa fa-clock-o"></i> {[{ ::task.created_at | fromNow }]}</span></td>
										</tr>
									</tbody>
								</table>
								<br><br>
							</div>

							<div ng-if="projects.length > 0" ng-cloak>
								<div class="headline">
									<h4><i class="fa fa-briefcase"></i> Open projects: <span class="badge badge-info">{[{ projects.length }]}</span></h4>
								</div>
								<ul class="media-list">
									<li class="media" ng-repeat="project in projects">
										<div class="pull-left" ng-click="project.collapsed = !project.collapsed">
											<i class="media-object fa fa-lg" ng-class="{'fa-plus-square-o': project.collapsed, 'fa-minus-square-o': !project.collapsed}"></i>
										</div>
										<div class="media-body">
											<a href="{!! URL::to('projects') !!}/{[{ project.id }]}"><small>{[{ ::project.name }]}</small></a>
											<small class="muted">- {[{ ::project.client.name }]}</small>
											<span class="label label-danger">{[{ ::project.client.contract.name }]}</span>
											<span class="pull-right">
												<span class="badge" ng-class="{'badge-warning': project.planning == '0', 'badge-success': project.planning == '1'}" tooltip="Planning">&nbsp;</span>
												<span class="badge" ng-class="{'badge-warning': project.invoiced == '0', 'badge-success': project.invoiced > 0}" tooltip="Invoiced">&nbsp;</span>
												<span class="badge" ng-class="{'badge-warning': project.paid == '0', 'badge-success': project.paid > 0}" tooltip="Paid">&nbsp;</span>
												<span class="badge" ng-class="{'badge-warning': project.completed == '0', 'badge-success': project.completed == '1'}" tooltip="Completed">&nbsp;</span>
												<small class="muted" tooltip="{[{ project.created_at }]}">&nbsp;&nbsp;<i class="fa fa-clock-o"></i> {[{ project.created_at | calendar }]}</small>
											</span>

											<!-- render tasks -->
											<div collapse="project.collapsed" style="margin-top: 5px;">
												<div style="border: 1px solid #DADADA; border-radius: 3px; background: #fbfbfb; margin-top: 5px; position: relative;">
													<input type="text" placeholder="Create a new task" ng-model="project.new_task" ui-keyup="{13: 'createProjectTask(project, $event)'}" class="col-sm-12" style="background: transparent; border: none; margin-bottom: 0;">
													<span class="dropdown" style="position: absolute; right: 15px; top: 4px;">
														<a href="#" data-toggle="dropdown"><i class="fa fa-user"></i></a>
														<ul class="dropdown-menu pull-right">
															<!-- dropdown menu links -->
															<li class="disabled"><a href="#"><b>Assign to:</b></a></li>
															<li>
																<ul class="dropdown-menu scroll-menu">
																	<li><a tabindex="-1" href="#user" ng-click="assignTo(null)" eat-click><i class="fa-fw fa fa-check" ng-show="!data.user.id"></i> No one</a></li>
																	<?php $activeUsers = App\Models\User::getActiveList(); ?>
																	@foreach ($activeUsers as $user)
																		<li><a tabindex="-1" href="#user/{!! $user->id !!}" ng-click="assignTo({{$user->id}})" eat-click><i class="fa-fw fa fa-check" ng-show="data.user.id == {!! $user->id !!}"></i> {!! $user->name !!}</a></li>
																	@endforeach
																</ul>
															</li>
														</ul>
													</span>
												</div>
												<div class="project-task" ng-repeat="task in project.tasks">
													&nbsp;
													<span style="font-size: 13px;">
														<i class="fa-fw" ng-class="{'fa fa-square-o': task.completed == '0', 'fa fa-check-square-o': task.completed == '1'}" tooltip="Mark as completed" tooltip-append-to-body="true" ng-click="triggerCompleted(task)"></i> &nbsp; <a href="{!! URL::to('tasks') !!}/{[{ task.id }]}">{[{ task.id }]}</a> &nbsp; {[{ task.title }]}
													</span>
													<div class="pull-right muted">
														<small>Assigned to: {[{ task.user.name || 'Nobody' }]}</small>
														<span class="label label-success" ng-if="task.completed == '1'" style="margin-left: 5px;">Completed</span>
													</div>
												</div>
											</div>

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

              				<div ng-if="asana_tasks.length > 0" ng-cloak>
								<div class="headline">
									<h4><i class="fa fa-wrench"></i> Asana Tasks: <span class="badge badge-info">{[{ asana_tasks.length }]}</span></h4>
								</div>
								<table class="table table-striped table-hover table-condensed">
									<thead class="table-header">
										<th></th>
										<th>Task</th>
										<th>Project</th>
										<th>Created</th>
										<th>Due</th>
									</thead>
									<tbody>
                    					<tr data-ng-repeat="task in asana_tasks">
											<td>
												<div class="checkbox-inline">
													<input type="checkbox" id="asana-{[{ task.id }]}" name="asanaid" ng-change="asana_complete(task)" ng-model="task.completed" value="1" style="top: 0; margin-top: 0"><label for="asana-{[{ task.id }]}"></label>
												</div>
											</td>
											<td class="medium-text-ellipsis"><a href="https://app.asana.com/0/0/{[{ ::task.id }]}" target="_blank">{[{ ::task.name }]}</a></td>
											<td class="medium-text-ellipsis">{[{ ::task.projects[0].name }]}</td>
											<td class="medium-text-ellipsis">{[{ ::task.created_at | fromNow }]}</td>
											<td class="medium-text-ellipsis">{[{ ::( task.due_at || task.due_on) | fromNow }]}</td>
										</tr>
									</tbody>
								</table>
								<br><br>
							</div>

              				<div ng-if="crm_opportunities.length > 0" ng-cloak>
								<div class="headline">
									<h4><i class="fa fa-wrench"></i> CRM Opportunities: <span class="badge badge-info">{[{ crm_opportunities.length }]}</span></h4>
								</div>
								<table class="table table-striped table-hover table-condensed">
									<thead class="table-header">
										<th>Task</th>
										<th>Account</th>
										<th>Next Step</th>
										<th>Due</th>
									</thead>
									<tbody>
                    					<tr data-ng-repeat="opportunity in crm_opportunities">
											<td class="medium-text-ellipsis"><a href="{[{ ::opportunity.url }]}" target="_blank">{[{ ::opportunity.name }]}</a></td>
											<td class="medium-text-ellipsis">{[{ ::opportunity.accountName }]}</td>
											<td class="medium-text-ellipsis">{[{ ::opportunity.sales_stage }]}</td>
											<td class="medium-text-ellipsis">{[{ ::( opportunity.date_closed) | fromNow }]}</td>
										</tr>
									</tbody>
								</table>
								<br><br>
							</div>

              				<div ng-if="repairs.length > 0" ng-cloak>
								<div class="headline">
									<h4><i class="fa fa-wrench"></i> Repairs: <span class="badge badge-info">{[{ repairs.length }]}</span></h4>
								</div>
								<table class="table table-striped table-hover table-condensed">
									<thead class="table-header">
										<th></th>
										<th><i  class="fa fa-comment"></th>
										<th>ID</th>
										<th>Title</th>
										<th>Client</th>
										<th></th>
										<th>Status</th>
										<th>Created</th>
									</thead>
									<tbody>
										<tr data-ng-repeat="task in repairs"
											ng-class="{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3', 'prebook-note': task.prebook == '1'}"
											uib-popover-html="::task.popover"
											popover-trigger="mouseenter"
											popover-title="{[{ '['+task.id+'] ' + task.title }]}"
											popover-popup-delay="500"
											popover-popup-close-delay="50">
											<td>
												<span class="label label-inverse" ng-show="::task.return_id" uib-tooltip="{[{ ::task.return_id }]}"><i class="fa fa-undo"></i></span>
											</td>
											<td><i data-ng-if="task.comments_count.unread > 0" class="fa fa-comment new-comment-icon"><span class="new-comment-text">{[{ task.comments_count.unread }]}</i></td>
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-bind="::task.id"></a></td>
											<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
											<td class="medium-text-ellipsis" ng-bind="::task.client.name"></td>
											<td><span class="label label-danger" ng-hide="task.client_id == '53' && task.client_type == 'client'" ng-bind="::task.client.contract.name"></span></td>
											<td ng-bind="::task.status.name"></td>
											<td><span uib-tooltip="{[{ ::task.created_at }]}" ng-bind="task.created_at ? (task.created_at | date:'yyyy-MM-dd HH:mm:ss' | fromNow) : 'Invalid Date'"></span></td>
										</tr>
									</tbody>
								</table>
								<br><br>
							</div>

							<div ng-repeat="(subtype_id, subtype_tasks) in support" ng-cloak>
								<div class="headline">
									<h4><i class="fa fa-laptop"></i> Remote support / {[{ ::getSubtypeDisplay(subtype_id) }]}: <span class="badge badge-info">{[{ subtype_tasks.length }]}</span></h4>
								</div>
								<table class="table table-striped table-hover table-condensed">
									<thead class="table-header">
										<th></th>
										<th>ID</th>
										<th>Title</th>
										<th>Client</th>
										<th></th>
										<th>Status</th>
										<th>Due</th>
										<th>Created</th>
									</thead>
									<tbody>
										<tr data-ng-repeat="task in subtype_tasks" ng-class="{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3', 'prebook-note': task.prebook == '1'}"
											uib-popover-html="::task.popover"
											popover-trigger="mouseenter"
											popover-title="{[{ '['+task.id+'] ' + task.title }]}"
											popover-popup-delay="500"
											popover-popup-close-delay="50">
											{{-- <td><span class="text-danger"><i class="fa fa-clock-o"></i> 00:00</span></td> --}}
											<td>
												<span class="label label-inverse" ng-show="::task.return_id" uib-tooltip="{[{ ::task.return_id }]}"><i class="fa fa-undo"></i></span>
											</td>
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-bind="::task.id"></a></td>
											<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
											<td class="medium-text-ellipsis" ng-bind="::task.client.name"></td>
											<td><span class="label label-danger" ng-hide="::task.client_id == '53' && task.client_type == 'client'" ng-bind="::task.client.contract.name"></span></td>
											<td ng-bind="::task.status.name"></td>
											<td><span ng-bind="task.due_date | fromNow" tooltip="{[{ ::task.due_date }]}"></span></td>
											<td><span uib-tooltip="{[{ ::task.created_at }]}" ng-bind="::task.created_at | fromNow"></span></td>
										</tr>
									</tbody>
								</table>
								<br><br>
							</div>

							<div ng-if="onsite.length > 0" ng-cloak>
								<div class="headline">
									<h4><i class="fa fa-truck"></i> Onsite: <span class="badge badge-info">{[{ onsite.length }]}</span></h4>
								</div>
								<table class="table table-striped table-hover table-condensed">
									<thead class="table-header">
										<th></th>
										<th>ID</th>
										<th>Title</th>
										<th>Client</th>
										<th></th>
										<th>Date</th>
										<th>Status</th>
										<th>Created</th>
									</thead>
									<tbody>
										<tr data-ng-repeat="task in onsite | orderBy:'onsite_start'"
											ng-class="{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3', 'prebook-note': task.prebook == '1', 'warning': isToday(task.onsite_start)}"
											uib-popover-html="::task.popover"
											popover-trigger="mouseenter"
											popover-title="{[{ '['+task.id+'] ' + task.title }]}"
											popover-popup-delay="500"
											popover-popup-close-delay="50">
											<td>
												<span class="label label-inverse" ng-show="::task.return_id" uib-tooltip="{[{ ::task.return_id }]}"><i class="fa fa-undo"></i></span>
											</td>
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-bind="::task.id"></a></td>
											<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
											<td class="medium-text-ellipsis" ng-bind="::task.client.name"></td>
											<td><span class="label label-danger" ng-hide="task.client_id == '53' && task.client_type == 'client'" ng-bind="::task.client.contract.name"></span></td>
											<td ng-bind="::task.onsite_start | moment:'ddd, Do MMM [at] HH:mm'"></td>
											<td ng-bind="::task.status.name"></td>
											<td><span uib-tooltip="{[{ ::task.created_at }]}" ng-bind="::task.created_at | fromNow"></span></td>
										</tr>
									</tbody>
								</table>
								<br><br>
							</div>


							<div ng-if="followup.length > 0" ng-cloak>
								<div class="headline">
									<h4><i class="fa fa-truck"></i> Followup: <span class="badge badge-info">{[{ followup.length }]}</span></h4>
								</div>
								<table class="table table-striped table-hover table-condensed">
									<thead class="table-header">
										<th></th>
										<th>ID</th>
										<th>Title</th>
										<th>Client</th>
										<th></th>
										<th>Status</th>
										<th>Created</th>
									</thead>
									<tbody>
										<tr data-ng-repeat="task in followup"
											ng-class="{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3', 'prebook-note': task.prebook == '1', 'warning': isToday(task.onsite_start)}" uib-popover-html="::task.popover"
											popover-trigger="mouseenter"
											popover-title="{[{ '['+task.id+'] ' + task.title }]}"
											popover-popup-delay="500"
											popover-popup-close-delay="50">
											<td>
												<span class="label label-inverse" ng-show="::task.return_id" uib-tooltip="{[{ ::task.return_id }]}"><i class="fa fa-undo"></i></span>
											</td>
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-text="task.id"></a></td>
											<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
											<td class="medium-text-ellipsis" ng-bind="::task.client.name"></td>
											<td><span class="label label-danger" ng-hide="::task.client_id == '53' && task.client_type == 'client'" ng-bind="::task.client.contract.name"></span></td>
											<td ng-bind="::task.status.name"></td>
											<td><span uib-tooltip="{[{ task.created_at }]}" ng-bind="::task.created_at | fromNow"></span></td>
										</tr>
									</tbody>
								</table>
								<br><br>
							</div>
							<div ng-if="qa.length > 0" ng-cloak>
								<div class="headline">
									<h4><i class="fa fa-truck"></i> Quality Assurance: <span class="badge badge-info">{[{ qa.length }]}</span></h4>
								</div>
								<table class="table table-striped table-hover table-condensed">
									<thead class="table-header">
										<th></th>
										<th>ID</th>
										<th>Title</th>
										<th>Client</th>
										<th></th>
										<th>Status</th>
										<th>Created</th>
									</thead>
									<tbody>
										<tr data-ng-repeat="task in qa"
											ng-class="{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3', 'prebook-note': task.prebook == '1', 'warning': isToday(task.onsite_start), 'red-highlight': (task.created_at | diff:'hours') > 4, 'yellow-highlight': 4 > (task.created_at | diff:'hours') > 2  }"
											uib-popover-html="::task.popover"
											popover-trigger="mouseenter"
											popover-title="{[{ '['+task.id+'] ' + task.title }]}"
											popover-popup-delay="500"
											popover-popup-close-delay="50">
											<td>
												<i class="fa" uib-tooltip="{[{ task.original_type }]}" data-ng-class="{'fa-wrench': task.original_type == 'repair', 'fa-laptop': task.original_type == 'support', 'fa-truck': task.original_type == 'onsite' }"></i>
											</td>
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-bind="::task.id"></a></td>
											<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
											<td class="medium-text-ellipsis" ng-bind="::task.client.name"></td>
											<td><span class="label label-danger" ng-hide="task.client_id == '53' && task.client_type == 'client'" ng-bind="::task.client.contract.name"></span></td>
											<td ng-bind="::task.status.name"></td>
											<td><span uib-tooltip="{[{ task.created_at }]}" ng-bind="::task.created_at | fromNow"></span></td>
										</tr>
									</tbody>
								</table>
								<br><br>
							</div>

							<div ng-if="sale_leads.length > 0" ng-cloak>
								<div class="headline">
									<h4><i class="fa fa-money"></i> Sale Leads: <span class="badge badge-info">{[{ sale_leads.length }]}</span></h4>
								</div>
								<table class="table table-striped table-hover table-condensed">
									<thead class="table-header">
										<th></th>
										<th>ID</th>
										<th>Title</th>
										<th>Client</th>
										<th></th>
										<th>Budget</th>
										<th>Lead Quality</th>
										<th>Status</th>
										<th>Created</th>
										<th>Deadline</th>
									</thead>
									<tbody>
										<tr data-ng-repeat="task in sale_leads"
											ng-class="{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3', 'prebook-note': task.prebook == '1'}"
											uib-popover-html="::task.popover"
											popover-trigger="mouseenter"
											popover-title="{[{ '['+task.id+'] ' + task.title }]}"
											popover-popup-delay="500"
											popover-popup-close-delay="50">
											<td>
												<span class="label label-inverse" ng-show="::task.return_id" uib-tooltip="{[{ task.return_id }]}"><i class="fa fa-undo"></i></span>
											</td>
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-bind="::task.id"></a></td>
											<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
											<td class="medium-text-ellipsis" ng-bind="::task.client.name"></td>
											<td><span class="label label-danger" ng-show="task.client.contract" ng-bind="::task.client.contract.name"></span></td>
											<td ng-bind="::task.langur | currency:'£'"></td>
											<td><span class="label" ng-class="{'label-warning': getRatingPercentage(task.time_spent, 5)<30, 'label-info': getRatingPercentage(task.time_spent, 5)>=30 && getRatingPercentage(task.time_spent, 5)<70, 'label-success': getRatingPercentage(task.time_spent, 5)>=70}" ng-bind="getRatingPercentage(task.time_spent, 5) + '%'"></span></td>
											<td ng-bind="::task.status.name"></td>
											<td><span uib-tooltip="{[{ task.created_at }]}" ng-bind="::task.created_at | fromNow"></span></td>
											<td><span uib-tooltip="{[{ task.onsite_end }]}" ng-bind="::task.onsite_end | fromNow"></span></td>
										</tr>
									</tbody>
								</table>
								<br><br>
							</div>

							<div ng-if="subscribed.length > 0" ng-cloak>
								<div class="headline">
									<h4><i class="fa fa-rss-square"></i> Subscribed: <span class="badge badge-info">{[{ subscribed.length }]}</span></h4>
								</div>
								<table class="table table-striped table-hover table-condensed">
									<thead class="table-header">
										<th></th>
										<th>ID</th>
										<th>Title</th>
										<th>Client</th>
										<th></th>
										<th>Assigned To</th>
										<th>Status</th>
										<th>Created</th>
									</thead>
									<tbody>
										<tr data-ng-repeat="task in subscribed" ng-class="{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3', 'prebook-note': task.prebook == '1'}">
											<td>
												<span class="label label-inverse" ng-show="task.return_id" uib-tooltip="{[{ task.return_id }]}"><i class="fa fa-undo"></i></span>
											</td>
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-bind="::task.id"></a></td>
											<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
											<td class="medium-text-ellipsis" ng-bind="::task.client.name"></td>
											<td><span class="label label-danger" ng-show="task.client.contract" ng-bind="::task.client.contract.name"></span></td>
											<td ng-bind="::task.user.name"></td>
											<td ng-bind="::task.status.name"></td>
											<td><span uib-tooltip="{[{ task.created_at }]}" ng-bind="::task.created_at | fromNow"></span></td>
										</tr>
									</tbody>
								</table>
								<br><br>
							</div>

						</div>

						<div class="col-sm-6" style="padding-left: 7.5px; padding-right: 0;">
							<div ng-if="orders.length > 0" ng-cloak>
								<div class="headline">
									<h4><i class="fa fa-wrench"></i> Orders: <span class="badge badge-info">{[{ orders.length }]}</span></h4>
								</div>
								<table class="table table-striped table-hover table-condensed">
									<thead class="table-header">
										<th></th>
										<th>ID</th>
										<th>Ordered By</th>
										<th>Client</th>
										<th></th>
										<th>Status</th>
										<th>Created</th>
									</thead>
									<tbody>
										<tr data-ng-repeat="task in orders"
											ng-class="{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3', 'prebook-note': task.prebook == '1'}"
											uib-popover-html="::task.popover"
											popover-trigger="mouseenter"
											popover-title="{[{ '['+task.id+'] ' + task.title }]}"
											popover-popup-delay="500"
											popover-popup-close-delay="50">
											<td>
												<span class="label label-inverse" ng-show="::task.return_id" uib-tooltip="{[{ ::task.return_id }]}"><i class="fa fa-undo"></i></span>
											</td>
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-bind="::task.id"></a></td>
											<td class="medium-text-ellipsis" ng-bind="::task.creator.name"></td>
											<td class="medium-text-ellipsis" ng-bind="::task.client.name"></td>
											<td><span class="label label-danger" ng-hide="task.client_id == '53' && task.client_type == 'client'" ng-bind="::task.client.contract.name"></span></td>
											<td ng-bind="::task.status.name"></td>
											<td><span uib-tooltip="{[{ ::task.created_at }]}" ng-bind="::task.created_at | fromNow"></span></td>
										</tr>
									</tbody>
								</table>
								<br><br>
							</div>
							<div data-ng-if="unassigned.prebooks.length > 0">
								<div class="headline">
									<h4>Prebooks Queue <span class="badge badge-info">{[{ unassigned.prebooks.length }]}</span></h4>
								</div>
								<table class="table table-striped table-condensed" data-ng-show="unassigned.prebooks.length > 0">
									<thead class="table-header">
										<th></th>
										<th>ID</th>
										<th>Title</th>
										<th>Client</th>
										<th>Contract</th>
										<th>Booked in</th>
									</thead>
									<tbody>
										<tr ng-repeat="task in unassigned.prebooks"
											uib-popover-html="::task.popover"
											popover-trigger="mouseenter"
											popover-title="{[{ '['+task.id+'] ' + task.title }]}"
											popover-popup-delay="500"
											popover-popup-close-delay="50">
											<td>
												<span ng-class="{'text-danger': getHoursLeft(task.prebook_date) == '0', 'text-warning': 0 != getHoursLeft(task.prebook_date) < 24 }" ng-show="getHoursLeft(task.prebook_date) < 24"><i class="fa fa-bell"></i></span>
											</td>
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-bind="::task.id"></a></td>
											<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
											<td class="short-text-ellipsis" ng-bind="::task.client.name"></td>
											<td><span class="label label-danger short-text-ellipsis" ng-hide="task.client_id == '53' && task.client_type == 'client'" ng-bind="::task.client.contract.name"></span></td>
											<td><span uib-tooltip="{[{ ::task.created_at }]}" ng-bind="::task.created_at | fromNow"></span></td>
										</tr>
									</tbody>
								</table>
							</div>
							<br>
							<div data-ng-if="unassigned.repairs.length > 0">
								<div class="headline">
									<h4>Repairs Queue <span class="badge badge-info">{[{ unassigned.repairs.length }]}</span></h4>
								</div>
								<table class="table table-striped table-condensed" data-ng-show="unassigned.repairs.length > 0">
									<thead class="table-header">
										<th style="width: 30px;"></th>
										<th></th>
										<th style="width: 80px;">ID</th>
										<th>Title</th>
										<th>Client</th>
										<th style="width: 71px;">Pre-book</th>
										<th class="centered" style="width: 100px;">Priority</th>
										<th class="centered" style="width: 100px;">Booked in</th>
									</thead>
									<tbody>
										<tr ng-repeat="task in unassigned.repairs"
											ng-class="{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3', 'severity-2': task.severity_id == '2', 'severity-1': task.severity_id == '1', 'prebook-note': task.prebook == '1'}"
											uib-popover-html="::task.popover"
											popover-trigger="mouseenter"
											popover-title="{[{ '['+task.id+'] ' + task.title }]}"
											popover-popup-delay="500"
											popover-popup-close-delay="50">
											<td>
												<span ng-class="{'text-danger': getHoursLeft(task.prebook_date) == '0', 'text-warning': 0 != getHoursLeft(task.prebook_date) < 24 }" ng-show="getHoursLeft(task.prebook_date) < 24 && task.prebook == '1'"><i class="fa fa-bell"></i></span>
											</td>
											<td>
												<span class="label label-inverse" ng-show="::task.return_id" uib-tooltip="{[{ ::task.return_id }]}"><i class="fa fa-undo"></i></span>
											</td>
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-bind="::task.id"></a></td>
											<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
											<td class="short-text-ellipsis" ng-bind="::task.client.name"></td>
											<td class="centered"><i class="fa fa-check" ng-show="task.prebook == '1'"></i></td>
											<td class="centered" ><span class="label" ng-class="{'label-danger': task.severity_id == '4', 'label-warning': task.severity_id == '3', 'label-info': task.severity_id == '2', 'label-default': task.severity_id == '1'}" ng-bind="::task.severity.name" ng-if="task.severity"></span></td>
											<td class="centered"><span uib-tooltip="{[{ ::task.created_at }]}" ng-bind="::task.created_at | fromNow"></span></td>
										</tr>
									</tbody>
								</table>
							</div>
							<div data-ng-if="unassigned.support.length > 0">
								<br>
								<div class="headline">
									<h4>Remote Support Queue <span class="badge badge-info">{[{ unassigned.support.length }]}</span></h4>
								</div>
								<table class="table table-striped table-condensed">
									<thead class="table-header">
										<th>ID</th>
										<th>Title</th>
										<th>Client</th>
										<th>Contract</th>
										<th>Booked in</th>
									</thead>
									<tbody>
										<tr ng-repeat="task in unassigned.support"
											ng-class="{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3', 'prebook-note': task.prebook == '1'}" uib-popover-html="::task.popover"
											popover-trigger="mouseenter"
											popover-title="{[{ '['+task.id+'] ' + task.title }]}"
											popover-popup-delay="500"
											popover-popup-close-delay="50">
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-bind="::task.id"></a></td>
											<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
											<td class="short-text-ellipsis" ng-bind="::task.client.name"></td>
											<td><span class="label label-danger short-text-ellipsis" ng-hide="task.client_id == '53' && task.client_type == 'client'" ng-bind="::task.client.contract.name"></span></td>
											<td><span uib-tooltip="{[{ ::task.created_at }]}" ng-bind="::task.created_at | fromNow"></span></td>
										</tr>
									</tbody>
								</table>
							</div>
							<div data-ng-if="unassigned.onsite.length > 0">
								<br>
								<div class="headline">
									<h4>Onsite Queue <span class="badge badge-info">{[{ unassigned.onsite.length }]}</span></h4>
								</div>
								<table class="table table-striped table-condensed">
									<thead class="table-header">
										<th>ID</th>
										<th>Title</th>
										<th>Client</th>
										<th>Contract</th>
										<th>Booked in</th>
									</thead>
									<tbody>
										<tr ng-repeat="task in unassigned.onsite"
											ng-class="{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3', 'prebook-note': task.prebook == '1'}" uib-popover-html="::task.popover"
											popover-trigger="mouseenter"
											popover-title="{[{ '['+task.id+'] ' + task.title }]}"
											popover-popup-delay="500"
											popover-popup-close-delay="50">
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-bind="::task.id"></a></td>
											<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
											<td class="short-text-ellipsis" ng-bind="::task.client.name"></td>
											<td><span class="label label-danger short-text-ellipsis" ng-bind="::task.client.contract.name"></span></td>
											<td><span uib-tooltip="{[{ ::task.created_at }]}" ng-bind="::task.created_at | fromNow"></span></td>
										</tr>
									</tbody>
								</table>
							</div>
							<!-- <div data-ng-if="unassigned.followup.length > 0">
								<br>
								<div class="headline">
									<h4>Followup Queue <span class="badge badge-info">{[{ unassigned.followup.length }]}</span></h4>
								</div>
								<table class="table table-striped table-condensed">
									<thead class="table-header">
										<th>ID</th>
										<th>Title</th>
										<th>Client</th>
										<th>Contract</th>
										<th>Booked in</th>
									</thead>
									<tbody>
										<tr ng-repeat="task in unassigned.followup"
											ng-class="{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3', 'prebook-note': task.prebook == '1'}"
											uib-popover-html="::task.popover"
											popover-trigger="mouseenter"
											popover-title="{[{ '['+task.id+'] ' + task.title }]}"
											popover-popup-delay="500"
											popover-popup-close-delay="50">
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-bind="::task.id"></a></td>
											<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
											<td class="short-text-ellipsis" ng-bind="::task.client.name"></td>
											<td><span class="label label-danger short-text-ellipsis" ng-hide="task.client_id == '53' && task.client_type == 'client'" ng-bind="::task.client.contract.name"></span></td>
											<td><span uib-tooltip="{[{ ::task.created_at }]}" ng-bind="::task.created_at | fromNow"></span></td>
										</tr>
									</tbody>
								</table>
							</div> -->
							<div data-ng-if="qaQueue.length > 0">
								<br>
								<div class="headline">
									<h4>Quality Assurance <span class="badge badge-info">{[{ qaQueue.length }]}</span></h4>
								</div>
								<table class="table table-striped table-condensed">
									<thead class="table-header">
										<th>ID</th>
										<th></th>
										<th>Title</th>
										<th>Client</th>
										<th>FAO</th>
										<th>Created</th>
									</thead>
									<tbody>
										<tr ng-repeat="task in qaQueue"
											ng-class="{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3', 'prebook-note': task.prebook == '1', 'red-highlight': (task.created_at | diff:'hours') > 4, 'yellow-highlight': 4 > (task.created_at | diff:'hours') > 2  }">
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-bind="::task.id"></a></td>
											<td><i class="fa" uib-tooltip="{[{ task.original_type }]}" data-ng-class="{'fa-wrench': task.original_type == 'repair', 'fa-laptop': task.original_type == 'support', 'fa-truck': task.original_type == 'onsite'}"></i>
											<i class="fa fa-money" uib-tooltip="Labour: {[{ task.original_labour }]} Parts Inc Vat: {[{ task.part_amount_inc_vat }]}" ng-if="task.part_amount_inc_vat || task.original_labour > 0"></i></td>
											<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
											<td class="short-text-ellipsis" ng-bind="::task.client.name"></td>
											<td><span data-ng-bind="::task.original_creator.name"></span></td>
											<td><span data-ng-title="::task.created_at" uib-tooltip="{[{ task.created_at }]}" ng-bind="::task.created_at | fromNow"></span></td>
										</tr>
									</tbody>
								</table>
							</div>
							<div data-ng-if="callQueue.length > 0">
								<br>
								<div class="headline">
									<h4>Customer needs to be called <span class="badge badge-info">{[{ callQueue.length }]}</span></h4>
								</div>
								<table class="table table-striped table-condensed">
									<thead class="table-header">
										<th>ID</th>
										<th></th>
										<th>Title</th>
										<th>Client</th>
										<th>FAO</th>
										<th>Created</th>
									</thead>
									<tbody>
										<tr ng-repeat="task in callQueue"
											ng-class="{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3', 'prebook-note': task.prebook == '1'}">
											<td><a ng-href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}" ng-bind="::task.id"></a></td>
											<td><i class="fa" uib-tooltip="{[{ task.original_type }]}" data-ng-class="{'fa-wrench': task.original_type == 'repair', 'fa-laptop': task.original_type == 'support', 'fa-truck': task.original_type == 'onsite'}"></i></td>
											<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
											<td class="short-text-ellipsis" ng-bind="::task.client.name"></td>
											<td><span data-ng-bind="::task.original_creator.name"></span></td>
											<td><span data-ng-title="::task.created_at" uib-tooltip="{[{ task.created_at }]}" ng-bind="::task.created_at | fromNow"></span></td>
										</tr>
									</tbody>
								</table>
							</div>
							<div class="text-right">
								<br>
								<small>Last updated <span uib-tooltip="{[{ last_updated.format('YYYY-MM-DD HH:mm:ss') }]}">{[{ last_updated.fromNow() }]}</span></small>
							</div>
						</div>
					</div>
				</div>
			</uib-tab>
			@endif
			@if($tab = $isTabVisible('repairs'))
			<uib-tab data-select="selected_tab = 0">
				<uib-tab-heading>
					{{ $tab->tab_label }}
				</uib-tab-heading>
				<div class="bookings-content repair-tab" data-ng-controller="DashboardTaskCtrl">
					<div class="row">
						<div class="col-sm-8">
							<div data-dashboard-summary="repairs-summary" data-template-url="dashboard/summary/repairs.html" data-selected-tab="selected_tab" data-current-tab="0"></div>
						</div>
						<div class="col-sm-4">
							<div data-dashboard-table-filters="filters" data-dashboard-table-filters-selected="filter_id"></div>
						</div>
					</div>

					<div data-dashboard-table data-table-type="repair" data-user="selected_user" data-table-filter="filter_id" data-selected-tab="selected_tab" data-current-tab="0"></div>
				</div>
			</uib-tab>
			@endif
			@if($tab = $isTabVisible('remote_support'))
			<uib-tab data-select="selected_tab = 1">
				<uib-tab-heading>
					{{ $tab->tab_label }}
				</uib-tab-heading>
				<div class="bookings-content repair-tab" data-ng-controller="DashboardTaskCtrl">
					<div class="row">
						<div class="col-sm-8">
							<div data-dashboard-summary="support-summary" data-template-url="dashboard/summary/support.html" data-selected-tab="selected_tab" data-current-tab="1"></div>
						</div>
						<div class="col-sm-4">
							<div data-dashboard-table-filters="filters" data-dashboard-table-filters-selected="filter_id"></div>
						</div>
					</div>

					<div data-dashboard-table data-table-type="support" data-user="selected_user" data-table-filter="filter_id" data-selected-tab="selected_tab" data-current-tab="1"></div>
				</div>
			</uib-tab>
			@endif
			@if($tab = $isTabVisible('onsite'))
			<uib-tab data-select="selected_tab = 2">
				<uib-tab-heading>
					{{ $tab->tab_label }}
				</uib-tab-heading>
				<div class="bookings-content repair-tab" data-ng-controller="DashboardTaskCtrl">
					<div class="row">
						<div class="col-sm-8">
							<div data-dashboard-summary="onsite-summary" data-template-url="dashboard/summary/onsite.html" data-selected-tab="selected_tab" data-current-tab="2"></div>
						</div>
						<div class="col-sm-4">
							<div data-dashboard-table-filters="filters" data-dashboard-table-filters-selected="filter_id"></div>
						</div>
					</div>

					<div data-dashboard-table data-table-type="onsite" data-user="selected_user" data-table-filter="filter_id" data-selected-tab="selected_tab" data-current-tab="2"></div>
				</div>
			</uib-tab>
			@endif
			@if($tab = $isTabVisible('delegated'))
			<uib-tab heading="{{ $tab->tab_label }}" data-select="selected_tab = 3">
				<div class="bookings-content repair-tab" data-ng-controller="DashboardDelegatedCtrl">
					<div class="hero-unit">
						<p>Here you will find a list of tasks that you have assigned (delegated) to other people.</p>
					</div>
					<table class="table table-striped table-hover table-condensed">
						<thead class="table-header">
							<th></th>
							<th>ID</th>
							<th>Title</th>
							<th>Client</th>
							<th></th>
							<th>Status</th>
							<th>Assigned to</th>
							<th>Created</th>
						</thead>
						<tbody>
							<tr data-ng-repeat="task in delegated track by task.id" ng-class="::{'severity-4': task.severity_id == '4', 'severity-3': task.severity_id == '3', 'prebook-note': task.prebook == '1'}">
								<td>
									<span class="label label-inverse" ng-if="::task.return_id" uib-tooltip="{[{ ::task.return_id }]}"><i class="fa fa-undo"></i></span>
								</td>
								<td><a ng-href="{!! URL::to('tasks') !!}/{[{ ::task | taskUrl }]}" ng-bind="::task.id"></a></td>
								<td class="medium-text-ellipsis" ng-bind="::task.title"></td>
								<td class="medium-text-ellipsis" ng-bind="::task.client.name"></td>
								<td><span class="label label-danger" ng-if="::task.client.contract" ng-bind="::task.client.contract.name"></span></td>
								<td><span ng-class="::{'text-success': task.status.completed == '1', 'text-warning': task.status.completed == '0'}" ng-bind="::task.status.name"></span></td>
								<td ng-bind="::task.user.name"></td>
								<td><span tooltip="{[{ ::task.created_at }]}" ng-bind="::task.created_at | fromNow"></span></td>
							</tr>
						</tbody>
					</table>
					<div paginator="paginator"></div>
				</div>
			</uib-tab>
			@endif
			@if($tab = $isTabVisible('sale_leads'))
			<uib-tab data-select="selected_tab = 5">
				<uib-tab-heading>
					{{ $tab->tab_label }}
				</uib-tab-heading>
				<div class="bookings-content repair-tab" data-ng-controller="DashboardTaskCtrl">
					<div class="row">
						<div class="col-sm-8">
							<div data-dashboard-summary="sale-lead-summary" data-template-url="dashboard/summary/sale-lead.html" data-selected-tab="selected_tab" data-current-tab="5"></div>
						</div>
						<div class="col-sm-4">
							<div data-dashboard-table-filters="filters" data-dashboard-table-filters-selected="filter_id"></div>
						</div>
					</div>

					<div data-dashboard-table data-table-type="sale_lead" data-user="selected_user" data-table-filter="filter_id" data-template-url="dashboard/tables/sale-lead.html" data-selected-tab="selected_tab" data-current-tab="5"></div>
				</div>
			</uib-tab>
			@endif
			@if($tab = $isTabVisible('rma'))
			<uib-tab data-select="selected_tab = 6">
				<uib-tab-heading>
					{{ $tab->tab_label }}
				</uib-tab-heading>
				<div class="bookings-content repair-tab" data-ng-controller="DashboardTaskCtrl">
					<div class="row">
						<div class="col-sm-8">
							<div data-dashboard-summary="rma-summary" data-template-url="dashboard/summary/rma.html" data-selected-tab="selected_tab" data-current-tab="6"></div>
						</div>
						<div class="col-sm-4">
							<div data-dashboard-table-filters="filters" data-dashboard-table-filters-selected="filter_id"></div>
						</div>
					</div>

					<div data-dashboard-table data-table-type="rma" data-user="selected_user" data-table-filter="filter_id" data-template-url="dashboard/tables/rma.html" data-selected-tab="selected_tab" data-current-tab="6"></div>
				</div>
			</uib-tab>
			@endif
			@if($tab = $isTabVisible('projects'))
			<uib-tab data-select="selected_tab = 7">
				<uib-tab-heading>
					{{ $tab->tab_label }}
				</uib-tab-heading>
				<div class="bookings-content repair-tab" data-ng-controller="DashboardTaskCtrl">
					<div class="row">
						<div class="col-sm-8">
							<div data-dashboard-summary="projects-summary" data-template-url="dashboard/summary/projects.html" data-selected-tab="selected_tab" data-current-tab="7"></div>
						</div>
						<div class="col-sm-4">
							<div data-dashboard-table-filters="filters" data-dashboard-table-filters-selected="filter_id"></div>
						</div>
					</div>

					<div data-dashboard-table data-table-type="projects" data-user="selected_user" data-table-filter="filter_id" data-template-url="dashboard/tables/projects.html" data-selected-tab="selected_tab" data-current-tab="7"></div>
				</div>
			</uib-tab>
			@endif
			@if($tab = $isTabVisible('my_completed'))
			<uib-tab data-select="selected_tab = 8">
				<uib-tab-heading>
					{{ $tab->tab_label }}
				</uib-tab-heading>
				<div class="bookings-content repair-tab" data-ng-controller="DashboardTaskCtrl">
					<div class="row">
						<div class="col-sm-12">
							<div data-dashboard-summary="completed-summary" data-template-url="dashboard/summary/completed-summary.html" data-selected-tab="selected_tab" data-current-tab="8"></div>
						</div>
					</div>

				</div>
			</uib-tab>
			@endif
			@if($tab = $isTabVisible('holidays_calendar'))
			<uib-tab data-select="loadHolidayCalendar = true">
				<uib-tab-heading>
					{{ $tab->tab_label }}
				</uib-tab-heading>
				<div class="bookings-content repair-tab" data-ng-controller="DashboardHolidaysCalendarCtrl">
					<div class="widget widget-classic">
						<div class="widget-content">
							<div class="headline">
								<h4><i class="fa fa-calendar"></i> Staff Holiday Calendar</h4>
							</div>
							<div calendar="fullCalendar" ui-calendar="calendar" ng-model="eventSources"></div>
						</div>
					</div>
				</div>
			</uib-tab>
			@endif
			@if (DBconfig::get('ews::config.enabled') && ($tab = $isTabVisible('calendar')))
				<uib-tab data-select="loadCalendar = true">
					<uib-tab-heading>
						{{ $tab->tab_label }}
					</uib-tab-heading>
					<div class="bookings-content repair-tab" data-ng-controller="DashboardCalendarCtrl">
						<div calendar="fullCalendar" ui-calendar="calendar" ng-model="eventSources"></div>
					</div>
				</uib-tab>
			@endif
		</uib-tabset>
	</div>

	<script type="text/ng-template" id="dashboard/table-filter.html">
		<ul class="nav nav-pills pull-right">
			<li data-ng-class="{active: selected_filter == $index}" data-ng-repeat="filter in filters"><a href="#" data-ng-click="setFilter($index)" data-eat-click style="text-transform: capitalize;">{[{ filter }]}</a></li>
		</ul>
	</script>

	<script type="text/ng-template" id="templates/quick-new-task.html">
		@include('templates.quick-new-task')
	</script>

	{{-- Load all templates for this page --}}
	@include('dashboard_v2::templates.index')
@stop
