@extends('layouts.print')
 
@section('content')
<style>
    table.m-table th,table.m-table td{
        text-align: center !important;
    }
</style>
<style>
    .table-inv-head td {
        border: none;
        font-size: 18px !important;
    }

    .table th {
        vertical-align: middle !important;
    }

    table tr:nth-child(even), table tr:hover {
        background: none;
    }

    .table > thead > tr > th {
        border: 1px solid white;
        text-align: center;
    }

    .footer-box {
        width: 100%;
        border: 0.01px solid rgb(95, 94, 94) !important;
        height: 200px;
        position: relative;
    }

    .footer-box span {
        margin-left: 10px
    }

    .footer-box span:last-child {
        position: absolute;
        bottom: 35px;
        left: 0px;
    }

    .footer-box span:first-child {
        position: absolute;
        top: 10px;
    }

    .report-capital.layout-print .table tr td{
        font-size: 17px !important;
    }
    .report-capital.layout-print .table tr th,.fdiv {
        font-size: 18px !important;
    }

    @media print {
        .title-page, .main-footer, button {
            display: none;
        }

        .footer-box {
            height: 150px;
            font-size: 18px !important;
        }
    }
</style>
<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>
									
								</div>  
                                
                                <h4 class="text-center table-inv-head" style="margin-top: 25px;"><u><b>របាយការណ៍ស្នើសុំទិញសំភារៈ</b></u>
                                </h4>
                                <table width="70%" class="table-inv-head">
                                    <tr>
                                        @php $project = \App\ProjectModel::find($purchase->project_id); @endphp
                                        <td>លេខ <span style="margin-left:44px">៖ {{str_pad($purchase->id,6,"0",STR_PAD_LEFT)}}</span></td>
                                        <td>ឈ្មោះគម្រោង <span style="margin-left:7.5px">៖ {{$project->project_name}}</span></td>
                                    </tr>
                                    <tr>
                                        <td>ស្នើសុំដោយ <span>៖ {{$purchase->request_by}}</span></td>
                                        <td>តួនាទី <span style="margin-left:58px">៖ {{$purchase->stock_position}}</span></td>
                                    </tr>
                                </table>
                                <table style="margin-top: 30px" class="table">
                                    <thead>
                                    <tr>
                                        <th rowspan="2">លរ</th>
                                        <th rowspan="2">បរិយាយមុខទំនិញ</th>
                                        <th rowspan="2">ខ្នាត</th>
                                        <th rowspan="2">ចំនួន</th>
                                        <th colspan="2">តម្លៃ</th>
                                        <th>ក្រុមហ៊ុន</th>
                                        <th>គោលបំណង និង</th>
                                    </tr>
                                    <tr>
                                        <th>រាយ</th>
                                        <th>សរុប</th>
                                        <th>ផ្គត់ផ្គង់</th>
                                        <th>ទីតាំងការងារ</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    @php
                                        $g_total = 0;
                                        $table_row = 10;
                                        $count = count($detail);
                                        $row_span = $table_row;
                                        $left_row = $table_row-$count;
                                        if($count>$left_row){
                                            $row_span = $count;
                                        }
                                    @endphp
                                    @foreach($detail as $key => $row)
                                        @php
                                            $product = \App\ConstructionModel\ProductModel::find($row->product_id);  
                                            $unit = \Illuminate\Support\Facades\DB::table('nso007_unit_construction')->where('id',$product->unit_id)->first();
                                            $sup = \App\ConstuctionModel\SuppliersModel::find($purchase->supplier_id);
                                            $total=$row->price*$row->qty;
                                            $g_total+=$total;
                                        @endphp
                                        <tr>
                                            <td>{{$key+1}}</td>
                                            <td>{{$product->name}}</td>
                                            <td>{{optional($unit)->name}}</td>
                                            <td>{{$row->qty}}</td>
                                            <td class="nowrap">${{number_format($row->price,2)}}</td>
                                            <td class="nowrap">${{number_format($total,2)}}</td>
                                            @if($key==0)
                                                <td rowspan="{{$row_span}}"
                                                    style="vertical-align: middle!important;text-align: center">{{$sup->name}}<br/>
                                                    {{!empty($supplier_phone)?("លេខទូរស័ព្ទ៖".$supplier_phone):""}}
                                                </td>
                                            @endif
                                            <td>{{$row->purpose_and_location}}</td>
                                        </tr>
                                    @endforeach
                                    @if(($left_row>0))
                                        @for($i = 0;$i<$left_row;$i++)
                                                <tr>
                                                    <td>&nbsp;</td>
                                                    <td></td>
                                                    <td></td>
                                                    <td></td>
                                                    <td></td>
                                                    <td></td>
                                                    <td></td>
                                                </tr>
                                        @endfor
                                    @endif
                                    <tr>
                                        <td colspan="4" class="text-center"><b><u>ចំនួនសរុប</u></b></td>
                                        <td colspan="2" class="text-center">
                                            <b><u>$ {{number_format($g_total,2)}}</u></b></td>
                                        <td colspan="2" class="text-center"></td>
                                    </tr>
                                    </tbody>
                                </table>

                                <div class="row" style="margin-top: 50px">
                                    <div class="col-sm-12 col-xs-12">
                                        <div class="col-sm-3 col-xs-3">
                                            <div class="footer-box">
                                                <span>ស្នើសុំដោយ:</span>
                                                <span>កាលបរិច្ឆេទ:</span>
                                            </div>
                                        </div>
                                        <div class="col-sm-3 col-xs-3">
                                            <div class="footer-box">
                                                <span>ត្រួតពិនិត្យដោយ:</span>
                                                <span>កាលបរិច្ឆេទ:</span>
                                            </div>
                                        </div>
                                        <div class="col-sm-3 col-xs-3">
                                            <div class="footer-box">
                                                <span>បានឃើញ:</span>
                                                <span>កាលបរិច្ឆេទ:</span>
                                            </div>
                                        </div>
                                        <div class="col-sm-3 col-xs-3">
                                            <div class="footer-box">
                                                <span>ឯកភាពដោយ:</span>
                                                <span>កាលបរិច្ឆេទ:</span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
							</div>
						</div>
							
						
					</div>
					
					
				</div>
			</div>
		</div>
	</div>
</div>
<style>
</style>

@endsection


