<?php
    function createTodayJob(){
        
    }
?>

<!DOCTYPE html>
</html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="author" content="AR Group">
    <title>Dashboard | PT. AR GROUP BERKAH BERSAMA</title>
    
    <!-- font icons -->
    <!--<link rel="stylesheet" href="assets/vendors/themify-icons/css/themify-icons.css">-->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

    <!-- Bootstrap + Creative Studio main styles -->
	<link rel="stylesheet" href="assets/css/creative-studio.css">
    <script src="assets/vendors/jquery/jquery-3.4.1.js"></script>

    @include('ar-css')

</head>

<body>
@include('admin/admin_header')

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

            <div style="flex:0 0 85%;max-width:85%">
                <div style="margin:10px;text-align:center">

                    <section style="padding:40px 0">
                        <h3>Job Waiting List</h3>
                        
                        <div class="container" style="text-align:left">
                            <div class="row">
                                <div class="col">
                                    <?
                                        $todayJob = '';
                                        $nextJob = '';
                                    
                                        if(isset($bookings)){
                                            foreach($bookings as $booking){
                                                $formattedDate = date('d-m-Y',strtotime($booking->appointment_date));
                                                if($booking->appointment_date == date('Y-m-d')){
                                                    
                                                    $todayJob .= '<div style="background-color:lightgray;padding:10px;border-radius:10px">
                                                                    <div style="display:table;margin-left:10px">
                                                                        <div style="display:table-row">
                                                                            <div style="display:table-cell;padding:0 10px">Tanggal</div>
                                                                            <div>:</div>
                                                                            <div style="display:table-cell;padding:0 10px">'. $formattedDate .'</div>
                                                                        </div>
                                                                        <div style="display:table-row">
                                                                            <div style="display:table-cell;padding:0 10px">Waktu Kunjungan</div>
                                                                                <div>:</div>
                                                                            <div style="display:table-cell;padding:0 10px">'. $booking->appointment_name .'</div>
                                                                        </div>
                                                                        <div style="display:table-row">
                                                                            <div style="display:table-cell;padding:0 10px">Customer</div>
                                                                                <div>:</div>
                                                                            <div style="display:table-cell;padding:0 10px">'. $booking->name .'</div>
                                                                        </div>
                                                                        <div style="display:table-row">
                                                                            <div style="display:table-cell;padding:0 10px">Telepon:</div>
                                                                                <div>:</div>
                                                                            <div style="display:table-cell;padding:0 10px">'. $booking->phone .'</div>
                                                                        </div>
                                                                        <div style="display:table-row">
                                                                            <div style="display:table-cell;padding:0 10px">Alamat</div>
                                                                                <div>:</div>
                                                                            <div style="display:table-cell;padding:0 10px">'. $booking->address .'</div>
                                                                        </div>
                                                                    </div>
                                                                 </div>';
                                                    
                                                }else{
                                                    $nextJob .= '<div style="background-color:lightgray;padding:10px;border-radius:5px">
                                                                    <div style="background-color:lightgray;padding:10px;border-radius:10px">
                                                                        <div style="display:table;margin-left:10px">
                                                                            <div style="display:table-row">
                                                                                <div style="display:table-cell;padding:0 10px">Tanggal</div>
                                                                                <div style="display:table-cell;padding:0 10px">'. $formattedDate .'</div>
                                                                            </div>
                                                                            <div style="display:table-row">
                                                                                <div style="display:table-cell;padding:0 10px">Waktu Kunjungan</div>
                                                                                <div style="display:table-cell;padding:0 10px">'. $booking->appointment_name .'</div>
                                                                            </div>
                                                                            <div style="display:table-row">
                                                                                <div style="display:table-cell;padding:0 10px">Customer</div>
                                                                                <div style="display:table-cell;padding:0 10px">'. $booking->name .'</div>
                                                                            </div>
                                                                            <div style="display:table-row">
                                                                                <div style="display:table-cell;padding:0 10px">Telepon</div>
                                                                                <div style="display:table-cell;padding:0 10px">'. $booking->phone .'</div>
                                                                            </div>
                                                                            <div style="display:table-row">
                                                                                <div style="display:table-cell;padding:0 10px">Alamat</div>
                                                                                <div style="display:table-cell;padding:0 10px">'. $booking->address .'</div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>';
                                                }
                                            }
                                        }
                                        
                                    if($todayJob != ''){
                                        echo '<a style="color:red">Pekerjaan hari ini:</a><br>';
                                        echo $todayJob;
                                    }
                                    
                                    if($nextJob != ''){
                                        echo '<p></p>Pekerjaan hari berikutnya:<br>';
                                        echo $nextJob;
                                    }
                                        
                                    ?>
                                </div>
                            </div>
                        </div>
                    </section>

                    <section style="padding:40px 0">
                        <h3 style="color:red">Pending Invoices</h3>
                        <div class="container" style="text-align:left">
                            <div class="row">
                                <div class="col">
                                    <?
                                        if(isset($billings)){
                                            $output = '';
                                            foreach($billings as $billing){
                                                $output =   '<div style="background-color:lightgray;padding:10px;border-radius:5px">
                                                                <div style="display:table;margin-left:10px">
                                                                    <div style="display:table-row">
                                                                        <div style="display:table-cell;padding:0 10px">Customer</div>
                                                                        <div>:</div>
                                                                        <div style="display:table-cell;padding:0 10px">'. $billing->name .'</div>
                                                                    </div>
                                                                    <div style="display:table-row">
                                                                        <div style="display:table-cell;padding:0 10px">Billing ID</div>
                                                                        <div>:</div>
                                                                        <div style="display:table-cell;padding:0 10px">'. $billing->id .'</div>
                                                                    </div>
                                                                    <div style="display:table-row">
                                                                        <div style="display:table-cell;padding:0 10px">Tgl/Waktu Invoice</div>
                                                                        <div>:</div>
                                                                        <div style="display:table-cell;padding:0 10px">'. date("d-m-Y H:i:s",strtotime($billing->created_at)) .'</div>
                                                                    </div>
                                                                </div>
                                                            </div>';
                                                
                                            }
                                            echo $output;
                                        }
                                    ?>
                                </div>
                            </div>
                        </div>
                    </section>
                    
                </div>
            </div>
        </div>
    </section>
</body>
</html>