@extends('layouts.master')

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

@section('content')

	<div class="row-fluid" ng-app="archDB" ng-controller="NotificationsMainCtrl" ng-cloak>
		<div class="span7">
			<div class="widget">
				<div class="widget-content">
					<div class="row-fluid">
						<div class="span6">
							<h4>Latest Notifications</h4>
						</div>
						<div class="span6 text-right" style="margin-bottom:10px;">
							<button class="btn btn-danger btn-small" ng-show="notifications.length > 0" ng-click="clearAll()" style="margin-top: 5px;">Mark All as Read</button>
						</div>
					</div>
					<h5 ng-show="notifications.length == 0"><small>You have no notifications.</small></h5>
					<table ng-show="notifications.length > 0" class="table table-condensed table-hover">
						<tr ng-repeat="notification in notifications" ng-class="{warning: notification.read == 0}" ng-click="redirect(notification)">
							<td>
								{[{ notification.message }]}
							</td>
							<td>
								<small>{[{ notification.created_at | fromNow }]}</small>
							</td>
						</tr>
					</table>
					<br />
					<div class="row-fluid">
						<div class="span12">
							<div paginator="paginator"></div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="span5">
			<div class="widget">
				<div class="widget-content">
					<h4>Configure Notifications</h4>
					<form name="notificationsForm" ng-submit="update()">
						<table class="table table-condensed">
							<thead>
								<th></th>
								<th>Email</th>
								<th>Alert</th>
							</thead>
							<tbody>
								<tr>
									<td>A new repair is assigned to me.</td>
									<td><input type="checkbox" name="assigned_new_repair[email]" ng-model="data.assigned_new_repair.email" ng-checked="data.assigned_new_repair.email == '1'" value="1"></td>
									<td><input type="checkbox" name="assigned_new_repair[alert]" ng-model="data.assigned_new_repair.alert" ng-checked="data.assigned_new_repair.alert == '1'" value="1"></td>
								</tr>
								<tr>
									<td>A new remote support job is assigned to me.</td>
									<td><input type="checkbox" name="assigned_new_remote_support[email]" ng-model="data.assigned_new_remote_support.email" ng-checked="data.assigned_new_remote_support.email == '1'" value="1"></td>
									<td><input type="checkbox" name="assigned_new_remote_support[alert]" ng-model="data.assigned_new_remote_support.alert" ng-checked="data.assigned_new_remote_support.alert == '1'" value="1"></td>
								</tr>
								<tr>
									<td>A new onsite job is assigned to me.</td>
									<td><input type="checkbox" name="assigned_new_onsite[email]" ng-model="data.assigned_new_onsite.email" ng-checked="data.assigned_new_onsite.email == '1'" value="1"></td>
									<td><input type="checkbox" name="assigned_new_onsite[alert]" ng-model="data.assigned_new_onsite.alert" ng-checked="data.assigned_new_onsite.alert == '1'" value="1"></td>
								</tr>
								<tr>
									<td>A new QA job is assigned to me.</td>
									<td><input type="checkbox" name="assigned_new_qa[email]" ng-model="data.assigned_new_qa.email" ng-checked="data.assigned_new_qa.email == '1'" value="1"></td>
									<td><input type="checkbox" name="assigned_new_qa[alert]" ng-model="data.assigned_new_qa.alert" ng-checked="data.assigned_new_qa.alert == '1'" value="1"></td>
								</tr>
								<tr>
									<td>A new message is assigned to me.</td>
									<td><input type="checkbox" name="assigned_new_message[email]" ng-model="data.assigned_new_message.email" ng-checked="data.assigned_new_message.email == '1'" value="1"></td>
									<td><input type="checkbox" name="assigned_new_message[alert]" ng-model="data.assigned_new_message.alert" ng-checked="data.assigned_new_message.alert == '1'" value="1"></td>
								</tr>
								<tr>
									<td>A new comment is posted on one of my repairs.</td>
									<td><input type="checkbox" name="new_comment_repairs[email]" ng-model="data.new_comment_repairs.email" ng-checked="data.new_comment_repairs.email == '1'" value="1"></td>
									<td><input type="checkbox" name="new_comment_repairs[alert]" ng-model="data.new_comment_repairs.alert" ng-checked="data.new_comment_repairs.alert == '1'" value="1"></td>
								</tr>
								<tr>
									<td>A new comment is posted on one of my remote support jobs.</td>
									<td><input type="checkbox" name="new_comment_remote_support[email]" ng-model="data.new_comment_remote_support.email" ng-checked="data.new_comment_remote_support.email == '1'" value="1"></td>
									<td><input type="checkbox" name="new_comment_remote_support[alert]" ng-model="data.new_comment_remote_support.alert" ng-checked="data.new_comment_remote_support.alert == '1'" value="1"></td>
								</tr>
								<tr>
									<td>A new comment is posted on one of my onsite jobs.</td>
									<td><input type="checkbox" name="new_comment_onsite[email]" ng-model="data.new_comment_onsite.email" ng-checked="data.new_comment_onsite.email == '1'" value="1"></td>
									<td><input type="checkbox" name="new_comment_onsite[alert]" ng-model="data.new_comment_onsite.alert" ng-checked="data.new_comment_onsite.alert == '1'" value="1"></td>
								</tr>
								<tr>
									<td>A new comment is posted on one of my orders.</td>
									<td><input type="checkbox" name="new_comment_orders[email]" ng-model="data.new_comment_orders.email" ng-checked="data.new_comment_orders.email == '1'" value="1"></td>
									<td><input type="checkbox" name="new_comment_orders[alert]" ng-model="data.new_comment_orders.alert" ng-checked="data.new_comment_orders.alert == '1'" value="1"></td>
								</tr>
								<tr>
									<td>One of my repairs changes status.</td>
									<td><input type="checkbox" name="change_status_repairs[email]" ng-model="data.change_status_repairs.email" ng-checked="data.change_status_repairs.email == '1'" value="1"></td>
									<td><input type="checkbox" name="change_status_repairs[alert]" ng-model="data.change_status_repairs.alert" ng-checked="data.change_status_repairs.alert == '1'" value="1"></td>
								</tr>
								<tr>
									<td>One of my orders changes status.</td>
									<td><input type="checkbox" name="change_status_orders[email]" ng-model="data.change_status_orders.email" ng-checked="data.change_status_orders.email == '1'" value="1"></td>
									<td><input type="checkbox" name="change_status_orders[alert]" ng-model="data.change_status_orders.alert" ng-checked="data.change_status_orders.alert == '1'" value="1"></td>
								</tr>
							</tbody>
						</table>
						<div class="widget-footer text-right">
							<button class="btn btn-primary btn-small" ng-disabled="!notificationsForm.$dirty">Update</button>
						</div>
						@csrf
					</form>
				</div>
			</div>
		</div>
	</div>
@stop