@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="150px">
								</div>
								<div class="title">
									<h2>{{$branch->branch_kh}}</h2>
									<h2>{{$branch->branch_en}}</h2>
									<h3>Report Deposit</h3>
								</div>
								<div class="clear"></div>
								<div class="border-bottom"></div>
								<div class="table">
									<table>
										<thead>
						                    <tr>
                                            <th>No</th>
                                            <th>Deposit Date</th>
                                            <th>Sale Date</th>
                                            <th>Name</th>
                                            <th>Phone</th>
                                            <th>Project Name</th>
                                            <th>Category</th>
                                            <th>Item Code</th>
                                            <th>Contract Date</th>
                                            <th>Payment Policy</th>
                                            <th>Total Sale Cost</th>
                                            <th>Sale Discount</th>
                                            <th>Sale Price</th>
                                            <th>Deposit Amount</th>
						                    </tr>
						                </thead>
										<tbody>
											@foreach($sale as $key => $value)
											<tr>
												<td>{{$key+1}}</td>
												<td>{{date('d-m-Y',strtotime($value->deposit_date))}}</td>
												<td>{{date('d-m-Y',strtotime($value->sale_date))}}</td>
                                                <td>{{$value->client_fullname}}</td>
												<td>{{$value->client_phone1}}</td>
                                                <td>{{$value->project_name}}</td>
                                                <td>{{$value->category_name}}</td>
                                                <td>{{$value->item_name}}</td>
                                                <td>{{date('d-m-Y',strtotime($value->sale_datecontract))}}</td>
                                                <?php 
                                                    if(!empty($value->policy_detail_id)) {
                                                        echo "<td>".DB::table("nso007_payment_policy_detail")->where("id",$value->policy_detail_id)->first()->name."</td>";
                                                    }
                                                    else if(!empty($value->payment_policy_id)){ 
                                                       echo "<td>".DB::table("nso007_payment_policy")->where('id',$value->payment_policy_id)->first()->name."</td>";
                                                    }
													else {
														echo "<td></td>";
													}
                                                ?>
                                                
                                                
												<td>${{number_format($value->saledetail_price,2)}}</td>
												<td>${{number_format($value->sale_discount,2)}}</td>
                                                <td>${{number_format(($value->saledetail_price-$value->sale_discount),2)}}</td>
                                                <td>${{number_format($value->deposit_amount,2)}}</td>
											</tr>
											@endforeach()
											<tr>
                                                <td colspan="10" class="text-right">Total :</td>
                                                <td>${{number_format($total_sale,2)}}</td>
                                                <td>${{number_format($total_discount,2)}}</td>
                                                <td>${{number_format($total_sale_amount,2)}}</td>
                                                <td>${{number_format($total_deposit_amount,2)}}</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


