 @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 Contractor Payment History</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>
							<th>No</th>
							<th>Date</th>
							<th>Contractor</th>
							<th>Project</th>
							<th>Zone Name</th>
							<th>Type of house</th>
							<th>Group Work</th>
							<th>Group Task</th>
							<th>Task</th>
							<th>Work commpleted</th>
							<th>Type</th>
							<th>Task Amount</th>
							<th>Paid Amount</th>
						</tr>
						<?php $total_task_amount = 0; $total_paid = 0; ?>
						@foreach($data as $key => $value)
						<?php $total_task_amount +=$value->task_amount ; $total_paid += ($value->type==0?$value->amount:$value->cash_advance_amount); ?>
						<tr>
							<td>{{ $key+1 }}</td>
							<td>{{ date('d-m-Y',strtotime($value->date)) }}</td>
							<td>{{ $value->constructor_name }}</td>
							<td>{{ $value->project_name }}</td>
							<td>{{ $value->block_name }}</td>
							<td>{{ $value->type_of_house }}</td>
							<td>{{ $value->work_group }}</td>
							<td>{{ $value->task_title }}</td>
							<td>{{ $value->task_name }}</td>
							<td>{{ $value->percentage_work_current }}%</td>
							<td>{{ $value->type==0?"Payment":"Cash advance" }}</td>
							<td>${{ number_format($value->task_amount,2) }}</td>
							<td>${{ $value->type==0?number_format($value->amount,2):number_format($value->cash_advance_amount,2) }}</td>
							
						</tr>
						@endforeach()
						<tr class="tr-right">
							<td colspan="11" class="text-right">Total</td>
							<td>${{ number_format($total_task_amount,2) }}</td>
							<td>${{ number_format($total_paid,2) }}</td>
						</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




