<div class="well">
	<div class="row">
		<div class="col-sm-3">
			<select name="type" class="form-control" ng-model="filters.type">
				<option value="">Task type:</option>
				<option value="repair">Repairs</option>
				<option value="support">Remote Support</option>
				<option value="onsite">Onsite</option>
			</select>
		</div>
		<div class="col-sm-2">
			<select name="client_type" class="form-control" ng-model="filters.client_type" data-ng-hide="clientId">
				<option value="">Client type:</option>
				<option value="client">Business</option>
				<option value="customer">Regular Customer</option>
			</select>
		</div>
		<div class="col-sm-7 text-right">
			<label class="checkbox-inline"><input type="checkbox" name="invoiced" ng-model="filters.invoiced"> Invoiced</label>
			<label class="checkbox-inline"><input type="checkbox" name="notInvoiced" ng-model="filters.notInvoiced"> Not Invoiced</label>
			<label class="checkbox-inline"><input type="checkbox" name="overdue" ng-model="filters.overdue"> Overdue</label>
		</div>
	</div>
</div>
<div class="alert alert-info" data-ng-show="loading">
	<i class="fa fa-spinner fa-spin fa-lg"></i> Updating results...
</div>
<table class="table table-striped">
	<thead class="table-header">
		<th></th>
		<th ng-click="orderBy('id')">ID <i ng-class="{'fa fa-arrow-down': filters.orderBy == 'id' && filters.orderType == 'desc', 'fa fa-arrow-up': filters.orderBy == 'id' && filters.orderType == 'asc'}"></i></th>
		<th>Customer</th>
		<th></th>
		<th>Contract</th>
		<th>Title</th>
		<th>Status</th>
		<th>Amount</th>
		<th>Parts</th>
		<th>Type</th>
		<th ng-click="orderBy('completed_at')">Date Completed <i ng-class="{'fa fa-arrow-down': filters.orderBy == 'completed_at' && filters.orderType == 'desc', 'fa fa-arrow-up': filters.orderBy == 'completed_at' && filters.orderType == 'asc'}"></i></th>
		<th>Assigned To</th>
		<th>Invoice Number</th>
		<th></th>
	</thead>
	<tbody>
		<tr data-ng-repeat="task in tasks" ng-form="rowForm">
			<td><input type="checkbox"></td>
			<td><a href="{!! URL::to('tasks') !!}/{[{ task | taskUrl }]}">{[{ task.id }]}</a></td>
			<td><a href="{!! URL::to('accounts') !!}/{[{ task.client_id }]}/{[{ task.client_type }]}">{[{ task.client.name }]}</a></td>
			<td>
				<span class="label label-info" ng-show="task.client_type == 'client'"><i class="fa fa-star"></i> Business</span>
				<a href="{!! URL::to('projects') !!}/{[{ task.project_id }]}" uib-tooltip="Click to open project" tooltip-placement="right" ng-if="task.project_id"><span class="label label-warning">Project #{[{ task.project_id }]}</span></a>
			</td>
			<td><span class="label label-danger">{[{ task.client.contract.name }]}</span></td>
			<td>{[{ task.title }]}</td>
			<td>{[{ task.status.name }]}</td>
			<td>{[{ task.labour | currency:"£" }]}</td>
			<td>{[{ task.parts_total | currency:"£" }]}</td>
			<td><span class="label label-info">{[{ task.type }]}</span></td>
			<td><i class="fa fa-clock-o"></i> <span uib-tooltip="{[{ task.completed_at }]}">{[{ task.completed_at | fromNow }]}</span></td>
			<td><span class="label label-warning">{[{ task.user.name }]}</span></td>
			<td><input type="text" class="form-control" ng-model="task.invoice_number" style="width: 50px;"> <i class="fa fa-clock-o" ng-show="task.invoiced_at" uib-tooltip="{[{ task.invoiced_at }]}"></i></td>
			<td>
				<span class="btn btn-success btn-sm" data-ng-click="save(task, rowForm)" ng-show="rowForm.$dirty">Save</span>
				<div class="btn-group">
					<a class="btn btn-sm dropdown-toggle" data-toggle="dropdown" href="#" eat-click>
						<i class="fa fa-cog"></i>
						<span class="caret"></span>
					</a>
					<ul class="dropdown-menu pull-right">
						<!-- dropdown menu links -->
						<li><a tabindex="-1" href="#" ng-click="generateInvoice(task)" ng-show=" ! task.invoice_number" data-eat-click><i class="fa-fw fa fa-floppy-o"></i> Generate Invoice</a></li>
						<li><a tabindex="-1" href="#" ng-click="showInvoice(task)" ng-show="task.invoice_number" data-eat-click><i class="fa-fw fa fa-tag"></i> View Invoice</a></li>
						<li><a tabindex="-1" href="#" ng-click="printInvoice(task)" ng-show="task.invoice_number" data-eat-click><i class="fa-fw fa fa-print"></i> Print Invoice</a></li>
						<li><a tabindex="-1" href="#" ng-click="markPaid(task)" ng-hide="task.paid == '1'" data-eat-click><i class="fa-fw fa fa-gbp"></i> Mark as paid</a></li>
					</ul>
				</div>
			</td>
		</tr>
	</tbody>
</table>
<div paginator="paginator"></div>