<div class="container community-invoice-container">
	<div class="box">
		<div class="box-title">
        	 {!! Theme::section('user.purchase.menu',['page'=>'sales']) !!}	
        </div>
		
		<div class="box-content">	

			{!! Theme::section('theme/user.purchase.sales-sub-menu',['subpage'=>'mycreated']) !!}
		
			<div class="invoice-lists-box" style="margin-top:0px;">
			    @if(Session::has('invoice_message'))						
				  <div class="alert alert-dismissible alert-success"> <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>{!! Session::get('invoice_message') !!}</div>
			    @endif
			
				@if(count($invoices)>0)
					<div class="invoice-lists-tbl">
					 <table class="table table-bordered">
						<thead>
							<tr>
								<th style="width: 10%">Invoice No.</th>
								<th style="width: 10%">User Details</th>
								<th style="width: 10%">Invoice date</th>
								<th style="width: 10%">Due Date</th>
								<th style="width: 10%">Amount</th>
								<th style="width: 10%">Status</th>								
								<!--<th style="width: 10%">Action</th>-->
							</tr>
						</thead>
						<tbody>							
							@foreach($invoices as $invoice)
								<tr>
									<td><a class="view-invoice-link" @if($invoice->has_sent==1) href="{{URL::route('community-invoice-view',['slug'=>0,'id'=>$invoice->id])}}" @else href="{{URL::route('community-invoice-preview',['slug'=>0,'id'=>$invoice->id])}}" @endif>{{$invoice->invoice_number}}</a></td>
									<td>
										@if($invoice->to_user)
											<?php
												$user=$invoice->to_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">{{$invoice->name}}<br> {{$invoice->email_addresss}}</p>
												   </a>
											   </div> 
										@else
											<div class="invoice-user-dtls-box">	
												<p class="invoice-user-dtls">{{$invoice->name}} <br> {{$invoice->email_addresss}}</p>	
											</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->has_sent==0) 
											Draft <br> 
											<a class="view-invoice-link" href="{{URL::route('community-invoice-preview',['slug'=>0,'id'=>$invoice->id])}}">Preview</a> 
										@else 
											@if($invoice->status==0) 
												Due 
											@else 
												Paid 
											@endif 
										@endif
									</td>
									<!--<td></td>-->
								</tr>
							@endforeach
						</tbody>
					</table>
				   
					{!! $invoices->appends(request()->except('page'))->render() !!}
			   </div>
				@else
					<div class="no-invoice-found">You haven't created any invoice yet.</div>
				@endif
			</div>	
		</div>	
	 </div>
</div>	

