<div class="well">
	<div class="row">
		<div class="col-sm-3">
			<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-6 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 ng-click="orderBy('completed_at')">Completed At <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 class="centered">Planning</th>
		<th class="centered">Invoiced</th>
		<th class="centered">Paid</th>
		<th class="centered">Completed</th>
		<th>Project Leader</th>
		<th>Inv. No.</th>
		<th></th>
	</thead>
	<tbody>
		<tr data-ng-repeat="project in projects" ng-form="rowForm">
			<td><input type="checkbox"></td>
			<td><a href="{!! URL::to('projects') !!}/{[{ project.id }]}">{[{ project.id }]}</a></td>
			<td><a href="{!! URL::to('accounts') !!}/{[{ project.client_id }]}/{[{ project.client_type }]}">{[{ project.client.name }]}</a></td>
			<td><span class="label label-info" ng-show="project.client_type == 'client'"><i class="fa fa-star"></i> Business</span></td>
			<td><span class="label label-danger">{[{ project.client.contract.name }]}</span></td>
			<td>{[{ project.name }]}</td>
			<td><span tooltip="{[{ project.completed_at }]}" ng-if="project.completed_at"><i class="fa fa-clock-o"></i> {[{ project.completed_at | fromNow }]}</span></td>
			<td class="centered"><span class="badge" ng-class="{'badge-warning': project.planning == '0', 'badge-success': project.planning == '1'}">&nbsp;</span></td>
			<td class="centered"><span class="badge" ng-class="{'badge-warning': project.invoiced == '0', 'badge-success': project.invoiced > 0}">&nbsp;</span></td>
			<td class="centered"><span class="badge" ng-class="{'badge-warning': project.paid == '0', 'badge-success': project.paid > 0}">&nbsp;</span></td>
			<td class="centered"><span class="badge" ng-class="{'badge-warning': project.completed == '0', 'badge-success': project.completed == '1'}">&nbsp;</span></td>
			<td>{[{ project.user.name }]}</td>
			<td><input type="text" class="form-control" ng-model="project.invoice_number" style="width: 50px;"> <i class="fa fa-clock-o" ng-show="project.invoiced_at" tooltip="{[{ project.invoiced_at }]}"></i></td>
			<td>
				<span class="btn btn-success btn-sm" data-ng-click="save(project, 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="InvoiceService.generateSingleInvoice(project)" ng-if="project.single_invoice == '1'" ng-show=" ! project.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="InvoiceService.show(project)" ng-show="project.invoice_number" data-eat-click><i class="fa-fw fa fa-tag"></i> View Invoice</a></li>
						<li><a tabindex="-1" href="#" ng-click="InvoiceService.print(project)" ng-show="project.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(project)" ng-hide="project.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>