@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>Report Summary Payment Contractor</h3>
					</div>
				</div>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<hr>
			</div>
		</div>
		<div class="row">
			<div class="col-md-12">
				<table class="table table-print" width="100%">
					<tbody>
						<tr align="right">
							<th>No</th>
							<th>Date</th>
							<th>Contractor</th>
							<th>Zone Name</th>
							<th>Type of house</th>
							<th>Date Start Work</th>
							<th>Duration</th>
							<th>Work Group</th>
							<th>Total Amount</th>
							<th>Paid Amount</th>
							<th>Paid Cash Advance</th>
							<th>Balance Amount</th>
							<th>Bunous</th>
							<th>Penalty</th>
						</tr>
						<?php $total_amount = 0; $total_deposit = 0; $total_paid = 0; $total_cash_advance = 0;$total_balance = 0;$total_bunous = 0;$total_penalty = 0; ?>
						@foreach($data as $key => $value)
						<tr align="center">
							<td>{{ $key+1 }}</td>
							<td>{{ date('d-m-Y',strtotime($value->date)) }}</td>
							<td>{{ $value->constructor_name }}</td>
							<td>{{ $value->block_name }}</td>
							<td>{{ $value->type_of_house }}</td>
							<td>{{ date("d-m-Y",strtotime($value->start_work_date)) }}</td>
							<td>{{ $value->duration }} Day</td>
							<td>{{ $value->work_group }}</td>
							<td>${{ number_format($value->total_amount,2) }}</td>
							<td>${{ number_format($value->total_paid_amount,2) }}</td>
							<td>${{ number_format($value->total_cash_advance,2) }}</td>
							<td>${{ number_format(($value->total_amount - $value->total_paid_amount),2)}}</td>
							<td>${{ number_format($value->total_bonus,2) }}</td>
							<td>${{ number_format($value->total_penalty,2) }}</td>
						</tr>
						<?php $total_amount += $value->total_amount; $total_deposit += $value->deposit_amount; $total_paid += $value->total_paid_amount; $total_cash_advance += $value->total_cash_advance;$total_balance += ($value->total_amount - $value->total_paid_amount);$total_bunous +=  $value->total_bonus;$total_penalty += $value->total_penalty; ?>
						@endforeach()
						<tr align="right" class="tr-right">
							<td colspan="8" id="text-algin-right">Total : </td>
							<td>${{ number_format($total_amount,2) }}</td>
							<td>${{ number_format($total_paid,2) }}</td>
							<td>${{ number_format($total_cash_advance,2) }}</td>
							<td>${{ number_format($total_balance,2) }}</td>
							<td>${{ number_format($total_bunous,2) }}</td>
							<td>${{ number_format($total_penalty,2) }}</td>
						</td>
					</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-algin-right{
		text-align: right !important;
	}
</style>


