@extends('layouts.print')

@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="200px">
								</div>
								<div class="title">
									<h2>{{$branch->branch_kh}}</h2>
									<h2>{{$branch->branch_en}}</h2>
									<h3>Report Collected Deposit</h3>
								</div>
								<div class="clear"></div>
								<div class="border-bottom"></div>
								<div class="table">
									<table>
										<thead>
											<tr>
												<th>No</th>
												<th>Name</th>
												<th>Phone</th>
												<th>Address</th>
												<th>Project Name</th>
												<th>Category</th>
												<th>Item Code</th>
												<th>Street No</th>
												<th>House No</th>
												<th>Zone</th>
												<th>House Size</th>
												<th>Land Size</th>
												<th>Sale Price</th>
												<th>Deposit</th>
												<th>Remain Amount</th>
												<th>Sale Date</th>
												<th>Contract Date</th>
												<th>Status</th>
											</tr>
										</thead>
										<tbody>
											<?php

											use App\SaleStockModel;
											use App\VillageModel;
											$totalPrice 	= 0;
											$totalDeposit 	= 0;
											$totalRemain 	= 0;
											?>
											@foreach($report as $i => $rp)
											<?php
											$village 	= VillageModel::find($rp->p_village);
											$address 	= $village->address();
											$sale 		= SaleStockModel::find($rp->id);
											$totalPrice += $rp->sale_amount;
											$totalDeposit += $rp->sale_receive;
											$totalRemain += ($rp->sale_amount-$rp->sale_receive);
											?>
											<tr>
												<td>{{$i+1}}</td>
												<td>{{$rp->client_name}}</td>
												<td>{{$rp->client_phone1}}</td>
												<td>{{$address}}</td>
												<td>{{$rp->project_name}}</td>
												<td>{{$rp->category_name}}</td>
												<td>{{$sale->itemname()}}</td>
												<td>{{$rp->item_street}}</td>
												<td>{{$sale->itemhouse()}}</td>
												<td>{{$rp->zone_name}}</td>
												<td>{{$sale->housesize()}}</td>
												<td>{{$sale->landsize()}} m<sup>2</sup></td>
												<td>$ {{number_format($rp->sale_amount,2)}}</td>
												<td>$ {{number_format($rp->sale_receive,2)}}</td>
												<td>$ {{number_format($rp->sale_amount-$rp->sale_receive,2)}}</td>
												<td>{{date('d-m-Y',strtotime($rp->sale_date))}}</td>
												<td>{{date('d-m-Y',strtotime($rp->sale_datecontract))}}</td>
												<td>
													@if ($sale->status == 1)
														@if ($sale->sale_deposit == 1)
														<strong class="text-info fa fa-spinner"> BOOKING</strong>
														@elseif ($sale->sale_deposit == 0)
														<strong class="text-warning"><i class="fa fa-ban"></i> CANCELED</strong>
														@else
														<strong class="text-success"><i class="fa fa-check"></i> INSTALLED</strong>
														@endif
													@else
													<strong class="text-danger"><i class="fa fa-remove"></i> CANCELED</strong>
													@endif
												</td>
											</tr>
											@endforeach
										</tbody>
										<tfoot>
											<tr>
												<th colspan="12" style="text-align: right">Total</th>
												<th class="right">$ {{number_format($totalPrice,2)}}</th>
												<th class="right">$ {{number_format($totalDeposit,2)}}</th>
												<th class="right">$ {{number_format($totalRemain,2)}}</th>
												<th class="right"></th>
												<th class="right"></th>
												<th class="right"></th>
											</tr>
										</tfoot>
									</table>
									<div class="make-date">
										<p>ធ្វើនៅ​ <strong>ភ្នំពេញ</strong> ថ្ងៃទី <strong>{{\Globals::date_khmers(date('Y-m-d'))}}</strong></p>
									</div>
									<div class="row">
										<div class="col-lg-12 col-sm-12 col-xs-12 tt">
											<div class="col-lg-4 col-sm-4 col-xs-4">
												<p>អ្នកធ្វើបញ្ជី</p>
												<p>_________________</p>
											</div>
											<div class="col-lg-4 col-sm-4 col-xs-4">
												<p>អ្នកពិនិត្យ</p>
												<p>_________________</p>
											</div>
											<div class="col-lg-4 col-sm-4 col-xs-4">
												<p>ឯកភាព</p>
												<p>_________________</p>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<style>
	.container {
		width: 390mm !important;
		margin-top: 10px;
	}
	.main-content-wrapper{
		background-image: url();
	}
	@media print {
		* {-webkit-print-color-adjust:exact;}
		html,
		body {
			width: 420mm !important;
			margin: 0mm 0 0 0 !important;
			background-color: #FFFFFF;
		}
		@page{
			size: A4 landscape;
		}
	}
</style>
@endsection