<style>
    table { border: none !important; }
    .admintable td {
        padding: 2px;
        border: solid #eee 0px !important;
        text-align:left;
    }
    .admintable th { background:#fff; height:1px !important; text-align:left; padding:0px !important; border: solid #eee 0px !important; }
    .littlelabel { color:#bbb; font-size:11px; font-weight:600; }
    .receipt { padding:0px; font-size: 15px; font-weight:400; }
    .fmb { display: inline-block; padding:10px 10px 3px; font-weight:600; }
</style>

<!-- BULLETS &#9702;  &#x25E6; -->

<div class="form form-profile aif" style='width:auto;'>
    <h2 style="margin-top:0px; margin-bottom:5px;">
        Orders
    </h2>
    
    <span style="font-weight:300;">All the Orders made from Pre-Order Mobile + Pre-Order Online</span>
   <br />
   <div class="fixed_menu_bar" style="background:#fff; padding:0px; border-bottom:2px solid #ddd;">
        <div class="fmb" style="width:85px; padding:10px 10px 0px 3px">CUSTOMER</div>
        <div class="fmb" style="width:130px; text-align:left;">PICKUP @</div>
        <div class="fmb" style="width:130px; text-align:left;">P/U/DELIV TIME</div>
        <div class="fmb" style="width:130px; text-align:left;">CREATED AT</div>
        <div class="fmb" style="width:290px; text-align:left;">ORDER ID</div>
        <div class="fmb" style="width:100px; text-align:left;">EDIT</div>
        <div class="fmb" style="width:50px; text-align:left;">&nbsp;</div>
    </div>
    
    <div id="tablewindow" style="position:relative; overflow-y: auto; height:485px; overflow-x:hidden;">
    	
    <table class="admintable" style="position:relative; width:100%; overflow:hidden; border:none !important; border-spacing:0; margin-top:0px; border: solid #eee 0px !important;">

   		<tr style="display:none; color:#fff; padding:0px !important; height:1px !important; margin-top:-20px !important; font-size:1px">
        <th width="170" style="color:#fff; padding:0px !important; height:1px !important">CUSTOMER</th>
        <th width="250" style="color:#fff; padding:0px !important; height:1px !important">PICKUP @</th>
        <th width="300" style="color:#fff; padding:0px !important; height:1px !important">P/U/DELIV TIME</th>
        <th width="300" style="color:#fff; padding:0px !important; height:1px !important">CREATED AT</th>
        <th width="150" style="color:#fff; padding:0px !important; height:1px !important">ORDER ID</th>
        <th width="300" style="color:#fff; padding:0px !important; height:1px !important">EDIT</th>
        <th width="50"   style="color:#fff; padding:0px !important; height:1px !important">&nbsp;</th>   
  		</tr>
    
        <?php
        foreach ($ordrs as $ordr) {
            if($ordr['delivery'] == 1){
                $type = 'Delivery';
            } else {
                $type = 'Pickup';
            }
            $pickup_or_deliv_time = date("D g:i A", strtotime($ordr['pickup_at']));
            $created_at = date("m/d g:i A", strtotime($ordr['date']));
            
            echo "<tr style='border-top:0px solid #ddd; padding-top:10px; padding-bottom:20px;'>   
                <td colspan='7' style='padding:0px; line-height:10px; height:10px;'>&nbsp;</td>
            </tr>    
            <tr>   
                    <td style='width:90px;'>
                        <div class='receipt' style='background:none; width:auto; display:inline-block; float:left; text-align:left'>                   
                            {$ordr['customer_name']}
                        </div>
                    </td>
                    <td style='width:130px;'>                    
                        <div class='receipt' style='background:none; width:auto; display:inline-block; float:left;'>                   
                           {$ordr['locationname']}
                        </div>
                     </td>          
                    <td style='width:130px;'>                                  
                        <div class='receipt' style='background:none; width:auto; display:inline-block; float:left;'>                   
                          <span style='color:#cd1000;'>{$pickup_or_deliv_time}</span>
                        </div>  
                     </td>                        
                    <td style='width:130px;'>                     
                         <div class='receipt' style='background:none; width:auto; display:inline-block; float:left; color:#bbb; font-weight:300;'>                   
                           {$created_at}
                        </div> 
                    </td>      
                    <td style='width:255px;'>                                              
                        <div class='receipt' style='background:none; width:auto; display:inline-block; float:left; color:#bbb; font-weight:300;'>                   
                           {$ordr['theorderid']}
                        </div>  
                    </td>      
                    <td style='width:100px;'>                                                                 
                        <div class='receipt' style='background:none; width:auto; display:inline-block; float:left; color:#bbb; font-weight:300;'>                   
                            <a href='?ordr&edit={$ordr['id']}'>edit</a> | <a href='?ordr&delete={$ordr['id']}' class='confirm' style='font-size:14px;'>delete</a>               
                        </div>      
                    </td>
                    <td style='width:50px;'>
                    &nbsp;
                    </td>
                </tr>
                <tr style='padding:0px; background:none; height:2px; line-height:2px;'>          
                    <td colspan='7'>&nbsp;</td>   
               </tr>            
            <tr>
                    <td style='text-transform:uppercase; color:#cd1000;'>&nbsp;</td> 
                    
                    <td colspan='1' style='color:#bbb; text-shadow:0px 1px 0px #fff; padding:3px 3px 3px 5px; background:#fff; border-bottom:1px solid #ccc; font-weight:600;'>Item Name</td>
                    <td colspan='2' style='color:#bbb; text-shadow:0px 1px 0px #fff; padding:3px 3px 3px 5px; background:#fff; border-bottom:1px solid #ccc; font-weight:600;'>Item Options</td>
                    <td colspan='1' style='color:#bbb; text-shadow:0px 1px 0px #fff; padding:3px 3px 3px 5px; background:#fff; border-bottom:1px solid #ccc; font-weight:600; text-align:center;'>Qty</td>
                    <td colspan='1' style='color:#bbb; text-shadow:0px 1px 0px #fff; padding:3px 3px 3px 5px; background:#fff; border-bottom:1px solid #ccc; font-weight:600; text-align:center;'>Amount</td>
                    <td colspan='1' style='color:#bbb; text-shadow:0px 1px 0px #fff; padding:3px 7px 3px 5px; background:#fff; border-bottom:1px solid #ccc; font-weight:600; text-align:left;'>Discount?</td>
            </tr>"; 
            
                // Start of Order Items
                foreach ($ordr['items'] as $item) {
                    $itemamt_dolls = $item['amount']/100;
                    $itemamt = '$' . number_format($itemamt_dolls,2,".",",");
                    //$itemamt = '$' . $item['amount'];
                    // Statements
                    echo "<tr>
                        <td>&nbsp;</td>                         
                        <td colspan='1' style='color:#000; padding-top:5px; padding-right:10px;'><span style='color:#000; font-size:17px; font-weight:600;'>
                        &#9702; {$item['name']}</span></td>
                        <td colspan=2' style='color:#000; padding-top:5px;'><span style='color:#000; font-size:17px; font-weight:600;'>{$item['options']}</span></td>
                        <td colspan='1' style='text-align:center; padding-top:5px; font-size:17px; color:#cd1000; font-weight:600;'>{$item['quantity']}</td>
                        <td colspan='1' style='text-align:center; padding-top:5px; font-size:17px;'>{$itemamt}</td>
                        <td colspan='1' style='color:#000; padding-top:5px; text-align:center; font-size:17px;'><span style='color:#ccc;'></span> {$item['discount']}</td>
                    </tr>
                   ";
                }  
                
                echo " <tr>
                    <td colspan='7'>&nbsp;</td>
                    </tr>
                    <tr style='border-bottom:1px solid #ddd; padding-top:20px; padding-bottom:20px;'>   
                <td colspan='7' style='padding:0px; line-height:10px; height:10px;'>&nbsp;</td>
            </tr>";        
        }
        ?>
    </table>
    </div>
    
    <!--
            ORDER DETAILS                                                                   
        	PICKUP/DELIVERY DETAILS
            ORDER ITEMS
            date
            order id
            app_id
            location_id
            customer_id
            customer_name
            date
            
            pickup_at
            is_fulfilled
            note
            amount
            device_id
            paid
            status
            receipt_id
            coupon_id
            discount_stars
            delivery
            customer_phone
            customer_email
        -->
    
    <div style="margin:10px; display:none;">
        <a href='?ordr&add' class='btn btn-blue'>Add New Order</a>
    </div>
</div>