@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>របាយការណ៍ពីការបង់ប្រាក់ដែលបានប្រមូល​​​</h3>
                                </div>
                                <div class="clear"></div>
                                <div class="border-bottom"></div>
                                <div class="table">
                                    <table>
                                        <thead>
                                            <tr>
                                                <th>No</th>
                                                <th>Cancel Date</th>
                                                <th>Client Name</th>
                                                <th>Agency</th>
                                                <th>Project</th>
                                                <th>Category</th>
                                                <th>Item</th>
                                                <th>Selling Price</th>
                                                <th>Duration</th>
                                                <th>Interest</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php

                                            use App\SaleStockModel;
                                            $totalsale = 0;
                                            ?>
                                            @foreach($data as $key => $value)
                                            <?php
                                            $itemname  = SaleStockModel::find($value->loan_saleid)->itemhouse();
                                            $totalsale += $value->salling_price;
                                            ?>
                                            <tr>
                                                <td>{{$key+1}}</td>
                                                <td>{{date('d-m-Y',strtotime($value->updated_at))}}</td>
                                                <td>{{$value->client_name}}</td>
                                                <td>{{$value->agent_name}}</td>
                                                <td>{{$value->project_name}}</td>
                                                <td>{{$value->category_name}}</td>
                                                <td>{{$itemname}}</td>
                                                <td>$ {{number_format($value->salling_price,2)}}</td>
                                                <td>{{$value->loan_duration}}</td>
                                                <td>{{$value->loan_interest}}</td>
                                            </tr>
                                            @endforeach()
                                        </tbody>
                                        <tfoot>
                                            <tr>
                                                <th colspan="7">Total</th>
                                                <th>${{number_format($totalsale,2)}}</th>
                                                <th></th>
                                                <th></th>
                                            </tr>
                                        </tfoot>
                                    </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