<div class="container community-invoice-container">	 
	 <div class="box">	 
		<div class="box-title">
        	 {!! Theme::section('user.purchase.menu',['page'=>'invoices']) !!}	
        </div>
		
		<div class="box-content">
			
			@php
				$activeTab = $tab ?? (request()->get('tab') ?: 'unpaid');
				if (! in_array($activeTab, ['paid', 'unpaid'], true)) {
					$activeTab = 'unpaid';
				}
			@endphp
			{!! Theme::section('theme/user.purchase.invoices-sub-menu',['subpage'=>$activeTab]) !!}
			
			<div class="invoice-lists-box">
			   	@if(count($invoices)>0)
					<div class="invoice-lists-tbl">
					 <table class="table table-bordered">
						<thead>
							<tr>
								<th style="width: 10%">{{ trans('invoices.lists.invoice-no') }}</th>
								<th style="width: 10%">{{ trans('invoices.lists.user') }}</th>
								<th style="width: 10%">{{ trans('invoices.lists.invoice-date') }}</th>
								<th style="width: 10%">{{ trans('invoices.lists.due-date') }}</th>
								<th style="width: 10%">{{ trans('invoices.lists.amount') }}</th>
								<th style="width: 10%">{{ trans('invoices.lists.status') }}</th>								
								<!--<th style="width: 10%">Action</th>-->
							</tr>
						</thead>
						<tbody>							
							@foreach($invoices as $invoice)
								<tr>
									<td><a class="view-invoice-link" href="{{URL::route('community-invoice-view',['slug'=>0,'id'=>$invoice->id])}}">{{$invoice->invoice_number}}</a></td>
									<td>
										@if($invoice->from_user)
											<?php
												$user=$invoice->from_user;
											?>
											   <div class="invoice-user-dtls-box">	
												   <a href="{{$user->present()->url()}}" data-ajaxify="true">
														<!--<img src="{{$user->present()->getAvatar(100)}}" class="invoice-user-img"/>-->											  
														<p class="invoice-user-dtls">{!! $user->fullname !!}</p>
												   </a>
											   </div> 	   
										@endif
									</td>
									<td>{{date("M j, Y",strtotime($invoice->invoice_date))}}</td>
									<td>{{date("M j, Y",strtotime($invoice->due_date))}}</td>
									<td>${{number_format($invoice->total_amount, 2, '.', ',')}}</td>
									<td>
										@if($invoice->status==0) 
											<a class="brand-colored-texts" href="{{URL::route('community-invoice-view',['slug'=>0,'id'=>$invoice->id])}}">{{ trans('invoices.lists.pay-now') }}</a> 
										@else 
											{{ trans('invoices.lists.paid') }} 
										@endif
									</td>
									<!--<td></td>-->
								</tr>
							@endforeach
						</tbody>
					</table>
				   
					{!! $invoices->appends(request()->except('page'))->render() !!}
			      </div>
				@else
					@php
						$emptyKey = ($activeTab === 'paid') ? 'invoices.lists.no-paid-received' : 'invoices.lists.no-unpaid-received';
					@endphp
					<div class="no-invoice-found">{{ trans($emptyKey) }}</div>
				@endif
			</div>	
		</div>	
	 </div>
</div>	

