<h3>{[{ data.name }]}</h3>

<div class="row">
	<div class="col-sm-10">

		<div data-fade="1" ngModel="activeTab" bs-tabs>
			<div ng-repeat="tab in tabs" data-title="{[{ tab.title }]}" ng-include="tab.template"></div>
		</div>

	</div>

	<div class="col-sm-2">
		<br><br>
		<a href="{!! URL::to('/bookings') !!}/#bookings/customer/{[{ data.id }]}" class="btn btn-success btn-block"><i class="fa fa-plus"></i> New Booking</a>
		<br>
		@if (Auth::user()->isMemberOf(5))
			<a href="{!! URL::to('accounts') !!}/{[{ data.id }]}/customer" class="btn btn-warning btn-block"><i class="fa fa-gbp"></i> View accounts</a>
		@endif
		<button class="btn btn-warning btn-block" ng-click="findDuplicates()"><i class="fa fa-tags"></i> Find duplicates</button>
		<button class="btn btn-warning btn-block" ng-confirm-click="Are you sure you want to convert this customer to a client?" confirmed-click="convert()"><i class="fa fa-refresh"></i> Convert to client</button>
		            <button class="btn btn-warning btn-block" ng-click="syncXero()"><i class="fa fa-exchange"></i> Sync with Xero</button>
		<button class="btn btn-warning btn-block" ng-click="createReport()"><i class="fa fa-exchange"></i> Create Report</button>
		<br>
		@can('delete-client')
			<button class="btn btn-danger btn-block" ng-confirm-click="Are you sure you want to delete this customer?" confirmed-click="deleteCustomer()"><i class="fa fa-times"></i> Delete customer</button>
		@endcan
	</div>
</div>


@include('templates.modals.confirmation')
@include('clients::duplicates')
@include('clients::templates.modals.report_period')

<script type="text/ng-template" id="clients/customer-summary.html">
	<div class="bookings-content repair-tab">
		<div class="row">
			<div class="col-sm-3">
				<div class="well text-center">
					<canvas class="chart chart-doughnut" chart-data="tasks_pie.data" chart-labels="tasks_pie.labels"></canvas>
				</div>
			</div>
			<div class="col-sm-3">
				<div class="well text-center">
						<h4>{[{ summary.stats.spent | currency:"£" }]}</h4>
						<small>Money spent</small>
				</div>
			</div>
			<div class="col-sm-3">
				<div class="well text-center">
						<h4>{[{ summary.stats.last_task.created_at | fromNow }]}</h4>
						<small>Last task</small>
				</div>
			</div>
			<div class="col-sm-3">
				<div class="well text-center">
						<h4>{[{ summary.stats.payment_due | currency:"£" }]}</h4>
						<small>Payment due</small>
				</div>
			</div>
		</div>

		@include('clients::forms.customer')

	</div>
</script>