@extends('layouts.report-print')
@section('css')
	<style type="text/css">
	/* size landscape for landscape paper */
		@page{
			size: landscape;
		}
	</style>
@endsection
@section('content')
	<div class="container-print">
		<div class="row">
			<div class="col-md-12">
				<div class="UpperTitle"><img src="{{asset('assets/images/resize')}}/{{$branch->branch_img}}" alt="Logo">
					<div class="title">
						<h2 class="com-name">{{$branch->branch_kh}}</h2>
						<h2>{{$branch->branch_en}}</h2>
						<h3>របាយការណ៍អតិថិជនបង់​ប្រាក់</h3>
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<table class="table table-print" width="100%">
					<tbody>
						<tr>
							<th>No</th>
							<th>Client Name</th>
							<th>Project</th>
							<th>Category</th>
							<th>Item</th>
							<th>Sale Cost</th>
							<th>Discount</th>
							<th>Sell Price</th>
							<th>Deposit Amount</th>
							<th>Received Payment Loan</th>
							<th>Payment Due</th>
							<th>Transfer ownership</th>
							<th>Other</th>
						</tr>
						<?php
							use App\SaleStockModel;
							$column6 = 0;
							$column8 = 0;
							$column9 = 0;
							$column10 = 0;
							$column11 = 0;
							$column12 = 0;
							$column13 = 0;
						?>
						@foreach($client_payment as $key => $value)
						<?php

						$sale 		= SaleStockModel::find($value->sale_id);
						$itemname 	= $sale->itemname();
						$itemhouse 	= $sale->itemhouse();
						$column6 	+= $value->sale_amount;
						$column9 	+= $value->loan_discount;
						$column10 	+= $value->sale_price;
						$column11 	+= $value->deposit_amount;
						$column12 	+= $value->payment_receive;
						$column13 	+= $value->amount_due;
						?>
						<tr>
							<td>{{$key+1}}</td>
							<td>{{$value->client_name}}</td>
							<td>{{$value->project_name}}</td>
							<td>{{$value->category_name}}</td>
							<td>{{$itemhouse}}</td>
							<td>${{number_format($value->sale_amount,2)}}</td>
							<td>${{number_format($value->loan_discount,2)}}</td>
							<td>${{number_format($value->sale_price,2)}}</td>
							<td>${{number_format($value->deposit_amount,2)}}</td>
							<td>${{number_format($value->payment_receive,2)}}</td>
							<td>${{number_format($value->amount_due,2)}}</td>
							<td>
								<?php 
									if($value->transfer_ownership_status==0) echo "pendding";
									else if($value->transfer_ownership_status==1) echo "Finish";
									else echo "";
							 	?>
							</td>
							<td>@if($value->loan_cancel_status==2) Canceled @else @endif</td>
						</tr>
						@endforeach()
						<tr>
							<th colspan="5" id="text-align-right">Total</th>
							<th>$ {{number_format($column6,2)}}</th>
							<th>$ {{number_format($column9,2)}}</th>
							<th>$ {{number_format($column10,2)}}</th>
							<th>$ {{number_format($column11,2)}}</th>
							<th>$ {{number_format($column12,2)}}</th>
							<th>$ {{number_format($column13,2)}}</th>
							<th></th>
							<th></th>
						</tr>
					</tbody>
				</table>
			</div>	
		</div>
		<div class="row">
			<div class="col-md-12">
				<table width="100%"​ class="tb-sign">
					<tr align="right">
						<td>
							<p>ធ្វើនៅ​ <strong>ភ្នំពេញ</strong> ថ្ងៃទី <strong>{{\Globals::date_khmers(date('Y-m-d'))}}</strong></p>
							<p style="padding-bottom: 80px;padding-right:40px">ហត្ថលេខា</p>
							<p>______________________</p>
						</td>
					</tr>	
				</table>
			</div>
		</div>
	</div>
@endsection
<style>
	#text-align-right{
		text-align: right !important ;
	}
</style>