@extends('layouts.print')
@php
	use App\ConstuctionModel\SuppliersModel as Supplier;
@endphp
@section('content')
<div class="main-content-wrapper">
	<div class="main-box">
		<div class="main-content">
			<div class="container">
				<div class="page">
					<div class="row">
						<div class="report-capital layout-print">
							<div class="header">
								<div class="logo">
									<img src="{{asset('assets/images/resize')}}/{{$branch->branch_img}}" alt="" width="150px">
								</div>
								<div class="title">
									<h2>{{$branch->branch_kh}}</h2>
									<h2>{{$branch->branch_en}}</h2>
									<h3>Report Purchase Payment</h3>
								</div>
								<div class="clear"></div>
								<div class="border-bottom"></div>
								<div class="table">
									<table>
										<thead>
						                    <tr>
												<th>NO</th>
												<th>Payment Date</th>
												<th>Request By</th>
												<th>Project</th>
												<th>Supplier</th>
												<th>Phone</th>
												<th>Stock Position</th>
												<th>Total Amount</th>
												<th>Paid Amount</th>
												<th>Method</th>
											</tr>
						                </thead>
										<tbody>
											@php
												$total_amount = 0;
												$total_paid = 0;
											@endphp
											@foreach($data as $key => $value)
												@php
													$total_amount += $value->total_amount;
													$total_paid += $value->total_paid;
												@endphp
												<tr>
													<td>{{ $key+1 }}</td>
													<td>{{ date("d-m-Y",strtotime($value->date)) }}</td>
													<td>{{ $value->request_by }}</td>
													<td>{{ $value->project_name }}</td>
													@php
														$supplier = Supplier::find($value->supplier_id);
													@endphp
													<td>{{ $supplier->name }}</td>
													<td>{{ $supplier->phone }}</td>
													<td>{{ $value->stock_position }}</td>
													<td>{{ "$".number_format($value->total_amount,2) }}</td>
													<td>{{ "$".number_format($value->total_paid,2) }}</td>
													@php
														$method = "";
														if($value->cash_type=="11001") $method = "Cash On Hand";
														else if($value->cash_type=="11002") $method = "Cash In Bank";
														else if($value->cash_type=="11013") $method = "Cheque";
														else $method = "";
													@endphp
													<td>{{ $method }}</td>
												</tr>
											@endforeach()
											<tr>
												<td colspan="7" class="text-center">Total</td>
												<td>${{ number_format($total_amount,2) }}</td>
												<td>${{ number_format($total_paid,2) }}</td>
												<td></td>
											</tr>
										</tbody>
									</table>
									<div class="make-date">
										<p>ធ្វើនៅ​ <strong>ភ្នំពេញ</strong> ថ្ងៃទី <strong>{{\Globals::date_khmers(date('Y-m-d'))}}</strong></p>
									</div>
									<div class="sign">
										<h3>ហត្ថលេខា</h3>
										<p>_________________</p>
									</div>
								</div>
							</div>
						</div>
							
						
					</div>
					
					
				</div>
			</div>
		</div>
	</div>
</div>

@endsection


