<!DOCTYPE html>
<?php
use App\Models\OrderProducts;
use App\Models\User;
use App\Models\CustomerDetails;
use App\Models\Products;
use App\Models\AdminDetails;
use App\Models\ManagerDetails;
use App\Models\CashierDetails;
use App\Models\Settings;
use App\Models\Services;
use App\Models\TablesRooms;
use App\Models\Waiters;

$setting = Settings::first();
$products=OrderProducts::where('order_id', $order->id)->get();
$user_details=User::withTrashed()->where('id', $order->customer)->first();
$other_details=CustomerDetails::withTrashed()->where('user_id', $order->customer)->first();

$cashier_role=User::withTrashed()->where('id', $order->sales_person)->value('user_role');
if($cashier_role == 1){
    $cashier_name=AdminDetails::withTrashed()->where('user_id', $order->sales_person)->value('name');
}
if($cashier_role == 3){
    $cashier_name=ManagerDetails::withTrashed()->where('user_id', $order->sales_person)->value('name');
}
if($cashier_role == 4){
    $cashier_name=CashierDetails::withTrashed()->where('user_id', $order->sales_person)->value('name');
}

?>
<html lang="en">

<style type="text/css">
body {
    margin: 0px;
    padding: 15px;
    /* width: 88mm; */
}

div, p {
    margin: 0;
    padding: 0;
}

</style>



<body>
<div style="text-align:center;">
<?php if($setting && $setting->logo != null){ 
?> 
<!--<img src="<?php echo e(asset('db_files/other/'.$setting->logo.'')); ?>" style="width:100px;"> -->
<?php } ?>
<p><span style="font-size:18px;font-weight:600;"><?php echo e($setting->company_name ?? ''); ?></span><br><?php echo e($setting->address ?? ''); ?><br><?php echo e($setting->phone_number ?? ''); ?><br><?php echo e($setting->email ?? ''); ?></p>
</div>
<div style="text-align:center;margin-top:15px;padding-top:10px;padding-bottom:10px;border-top:1px dashed;border-bottom:1px dashed;">
<p  style="margin:0;font-size:22px;font-weight:600">Token No - <span style="font-size:32px;font-weight:600"><?php echo e($order->token); ?></span></p>
</div>
<div style="text-align:center;padding-top:10px;padding-bottom:10px;border-bottom:1px dashed;">

    <p  style="margin:0;font-size:18px;font-weight:600">Invoice - Dine In</p>
</div>

<div style="text-align:left;margin-top:15px;">
    <p style="margin:0;"><b>Invoice No: </b><?php echo e($order->sales_order_number); ?></p>
    <!-- <p style="margin:0;"><b>Date: </b><?php echo e($order->created_at->format('Y/m/d \T\i\m\e:H:i:s')); ?></p> -->
    <p style="margin:0;"><b>Date: </b><?php echo e(now()->format('Y/m/d \T\i\m\e:H:i:s')); ?></p>
    <p style="margin:0;"><b>Cashier: </b><?php echo e($cashier_name); ?></p>
    <p style="margin:0;"><b>Customer: </b><?php echo e($other_details->customer_name ?? 'Cash'); ?></p>
    <p style="margin:0;"><b><?php echo e(TablesRooms::where('id', $order->table)->value('name')); ?></b></p>
    <p style="margin:0;"><b>Waiter: </b><?php echo e(Waiters::where('id', $order->waiter)->value('name')); ?></p>
    <!-- <p style="margin:0;">Mobile No: <?php echo e($other_details->phone ?? '-'); ?></p> -->
</div>
<table style="width:100%;margin-top:15px;">
     <tr>
        <th style="width:60%; text-align:left;">
        <p style="margin:0;">Item </p>
        </th>
        <th style="width:10%; text-align:left;">
        <p style="margin:0;">QTY </p>
        </th>
        <th style="width:30%; text-align:right;">
        <p style="margin:0;">Amount</p>
        </th>
    </tr>
</table>
<table style="width:100%;border-top:1px solid;">

    <?php foreach($products as $product){ 
         if($product->type == "service"){
            $product_name = Services::withTrashed()->where('id', $product->product)->value('name');
        }
        else{
            $product_name = Products::withTrashed()->where('id', $product->product)->value('product_name');
        }
    ?>
    <tr>
        <td style="width:60%; text-align:left;">
        <p style="margin:0;font-size:16px;font-weight:400;padding-bottom:5px;"><?php echo e($product_name); ?><br><span style="font-size:16px;font-weight:400;"><?php echo e($product->note); ?></span></p>
        </td>
        <td style="width:10%; text-align:left;">
        <p style="margin:0;font-size:16px;font-weight:400;padding-bottom:5px;"><?php echo e($product->quantity); ?></p>
        </td>
        <td style="width:30%; text-align:right;">
        <p style="margin:0;font-size:16px;font-weight:400;padding-bottom:5px;">Rs.<?php echo e(number_format($product->price * $product->quantity, 2)); ?></p>
        </td>
    </tr>
    <?php  } ?>
</table>
<div style="text-align:right;margin-top:15px;padding-top:10px;padding-bottom:10px;border-top:1px dashed;border-bottom:1px dashed;">
<p  style="margin:0;font-size:16px;font-weight:400">Sub Total : Rs.<?php echo e(number_format($order->sub_total, 2)); ?></p>
<p  style="margin:0;font-size:16px;font-weight:400">Service Charge (<?php echo e($order->service_charges ?? 0); ?>%) : Rs.<?php echo e(number_format(($order->sub_total / 100) * ($order->service_charges ?? 0), 2)); ?></p>
<p  style="margin:0;font-size:16px;font-weight:400">Discount (<?php echo e($order->discount); ?>%) : Rs.<?php echo e(number_format(($order->sub_total/100)*$order->discount, 2)); ?></p>
<p  style="margin:0;font-size:18px;font-weight:600">Total : Rs.<?php echo e(number_format($order->total, 2)); ?></p>

</div>


<p style="text-align:center;margin-top:15px;">Thank You ! Come Again !</p>
</body>

<script>
    window.onload = function() {
        window.print();
    }

    window.onafterprint = function() {
        window.close();
    }
</script><?php /**PATH /home/zone1futurepos/indianheavenrestaurant.zone1.futurepos.app/resources/views/table_customer_reciept.blade.php ENDPATH**/ ?>