<x-layout>
    @section('title', $title.' - ')
    @section('page_title', $title)
    @include('admin/ar-css')
    @include('admin/ar-php-script')
    @include('admin/header_admin')

    <section id="dashboard" class="ar-dashboard-height">
        
        <div class="ar-dashboard-row" style="height:100%;min-height:100%">
            <div id="ar-left-nav">
                @include('admin/left_nav')
            </div>

            <div id="ar-dashboard-content" style="overflow:scroll">
                <div style="overflow:scroll">
                    <?
                        $amount=0;
                        $transport=0;
                        $discount=0;
                        $years = array('2024','2025');
                    ?>
                    
                    <div>
                        <form method="GET" action="" style="margin:10px">
                            Pilih Tahun:
                            <select name="year">
                                @foreach($years as $year)
                                    @if($year == $selectedYear)
                                        <option value="{{$year}}" selected>{{$year}}</option>
                                    @else
                                        <option value="{{$year}}">{{$year}}</option>
                                    @endif
                                @endforeach
                            </select>
                            <input style="padding:0 5px" type="submit"/>
                        </form>
                        
                        @foreach($sales as $sale)
                            <div style="margin:10px;padding:10px;background-color:lightgray;border-radius:5px">
                                <b>Periode : {{ convertMonth($sale->month)." ".$sale->year }}</b><br>
    
                                <div style="display:table">
                                    <div style="display:table-row">
                                        <div style="display:table-cell;padding:0 10px">Jumlah Penerimaan jasa:</div>
                                        <div>Rp.</div>
                                        <div style="display:table-cell;;padding:0 10px;text-align:right">{{rupiahBasic($sale->amount)}}</div>
                                    </div>
                                    <div style="display:table-row">
                                        <div style="display:table-cell;padding:0 10px">Jumlah Penerimaan Transport:</div>
                                        <div>Rp.</div>
                                        <div style="display:table-cell;padding:0 10px;text-align:right">{{rupiahBasic($sale->transport)}}</div>
                                    </div>
                                    <div style="display:table-row">
                                        <div style="display:table-cell;padding:0 10px">Jumlah Discount:</div>
                                        <div>Rp.</div>
                                        <div style="display:table-cell;padding:0 10px;text-align:right">{{rupiahBasic($sale->discount)}}</div>
                                    </div>
                                </div>
                                
                            </div>
                            
                            <?
                                $amount += $sale->amount;
                                $transport += $sale->transport;
                                $discount += $sale->discount;
                            ?>
                        @endforeach
                    </div>
    
                    <div style="display:table;margin-left:10px">
                        <div style="display:table-row">
                            <div style="display:table-cell;padding:0 10px">Total Penerimaan jasa:</div>
                            <div>Rp.</div>
                            <div style="display:table-cell;;padding:0 10px;text-align:right">{{rupiahBasic($amount)}}</div>
                        </div>
                        <div style="display:table-row">
                            <div style="display:table-cell;padding:0 10px">Total Penerimaan Transport:</div>
                            <div>Rp.</div>
                            <div style="display:table-cell;padding:0 10px;text-align:right">{{rupiahBasic($transport)}}</div>
                        </div>
                        <div style="display:table-row">
                            <div style="display:table-cell;padding:0 10px">Total Discount:</div>
                            <div>Rp.</div>
                            <div style="display:table-cell;padding:0 10px;text-align:right">{{rupiahBasic($discount)}}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        
    </section>
</x-layout>