@extends('adminlte::layouts.app')

@section('htmlheader_title')
	Reseller Home
@endsection
@section('page_title')
	{{ $o->full_name }}
@endsection

@section('contentheader_title')
	{{ $o->full_name }}
@endsection
@section('contentheader_description')
	Reseller Home
@endsection

@section('main-content')
	<div class="row">
		@include('common.account.widget.summary')
	</div>

	<div class="row">
		<div class="col-md-12">
			<div class="card">
				<div class="card-header p-2">
					<ul class="nav nav-pills">
						<li class="nav-item"><a class="nav-link active" href="#tab-services" data-toggle="tab">Services</a></li>
						<li class="nav-item"><a class="nav-link" href="#tab-clients" data-toggle="tab">Clients</a></li>
					</ul>
				</div>

				<div class="card-body">
					<div class="tab-content">
						<div class="active tab-pane" id="tab-services">
							<div class="row">
								<div class="col-7">
									@include('common.service.widget.active')
								</div>

								<div class="col-5">
									<!-- Show outstanding invoices -->
									<div class="card card-warning card-outline">
										<div class="card-header">
											<h4 class="card-title">Outstanding Invoices</h4>

											<div class="card-tools">
												<button type="button" class="btn btn-tool" data-widget="collapse"><i class="fas fa-minus"></i></button>
											</div>
										</div>

										<div class="card-body">
											@include('widgets.invoice',[
												'o'=>$o->query_invoice_summary()->whereIN('account_id',$o->accounts()->pluck('id')->toArray())->having('balance','>',0),
												'widget_invoice_name'=>'widget-invoice-outstanding'
												])
										</div>
									</div>

									<!-- Show last 10 invoices -->
									<div class="card card-warning card-outline">
										<div class="card-header">
											<h4 class="card-title">Invoices - Last 12 Months</h4>

											<div class="card-tools">
												<button type="button" class="btn btn-tool" data-widget="collapse"><i class="fas fa-minus"></i></button>
											</div>
										</div>

										<div class="card-body">
											@include('widgets.invoice',[
												'o'=>$o->query_invoice_summary()->whereIN('account_id',$o->accounts()->pluck('id')->toArray())->where('due_date','>',now()->subYear()->timestamp)->having('balance','=',0),
												'widget_invoice_name'=>'widget-invoice-last'
												])
										</div>
									</div>

									<!-- Show last 10 invoices -->
									<div class="card card-warning card-outline">
										<div class="card-header">
											<h4 class="card-title">Payments - Last 12 Months</h4>

											<div class="card-tools">
												<button type="button" class="btn btn-tool" data-widget="collapse"><i class="fas fa-minus"></i></button>
											</div>
										</div>

										<div class="card-body">
											@include('widgets.payment',[
												'o'=>$o->query_payment_summary()->whereIN('account_id',$o->accounts()->pluck('id')->toArray())->where('date_payment','>',now()->subYear()->timestamp)->with(['items']),
												'widget_payment_name'=>'widget-payment-last'
												])
										</div>
									</div>
								</div>
							</div>
						</div>

						<div class="tab-pane" id="tab-clients">
							<div class="row">
								<div class="col-4">
									@include('r.account.widget.list')
								</div>

								<div class="col-8">
									@include('r.service.widget.movement')

									<!-- Show outstanding invoices -->
									<div class="card card-warning card-outline">
										<div class="card-header">
											<h4 class="card-title">Outstanding Invoices</h4>

											<div class="card-tools">
												<button type="button" class="btn btn-tool" data-widget="collapse"><i class="fas fa-minus"></i></button>
											</div>
										</div>

										<div class="card-body">
											@include('widgets.invoice',[
												'o'=>$o->query_invoice_summary()->having('balance','>',0),
												'widget_invoice_name'=>'widget-invoice-outstanding-client'
												])
										</div>
									</div>
								</div>
{{--

								<div class="col-xs-6">
									@include('r.agents')
								</div>
								<div class="col-xs-6">
									@include('r.clients')
								</div>
--}}

							</div>
						</div>
					</div>
				</div>

			</div>
		</div>
	</div>
@endsection