<!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;

$setting = Settings::first();
$products=OrderProducts::withTrashed()->where('order_id', $order->id)->where('is_new', 0)->get();
$continuous_products=OrderProducts::withTrashed()->where('order_id', $order->id)->where('is_new',1)->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;margin-top:15px;padding-top:10px;padding-bottom:10px;border-top:1px dashed;border-bottom:1px dashed;">
    <p  style="margin:0;font-size:24px;font-weight:600">KOT - Take Away</p>
</div>
<div style="text-align:center;padding-top:10px;padding-bottom:10px;border-bottom:1px dashed;">
    <p  style="margin:0;font-size:26px;font-weight:600">Token No - <?php echo e($order->token); ?></p>
</div>

<div style="text-align:left;margin-top:15px;">
    <p style="margin:0;"><b>KOT No: </b> KOT<?php echo e(preg_replace('/^INV/', '', $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>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;">Mobile No: <?php echo e($other_details->phone ?? '-'); ?></p> -->
</div>
<table style="width:100%;margin-top:15px;">
     <tr>
        <th style="width:70%; text-align:left;">
        <p style="margin:0;">Item</p>
        </th>
        <th style="width:30%; text-align:right;">
        <p style="margin:0;">QTY</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 style="">
        <td style="width:80%; text-align:left;border-bottom:1px dashed;">
        <p style="margin:0;font-size:22px;font-weight:600;padding-bottom:10px;"><?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:20%; text-align:right;border-bottom:1px dashed;">
        <p style="margin:0;font-size:32px;font-weight:600;padding-bottom:10px;"><?php echo e($product->quantity); ?></p>
        </td>
    </tr>
    <?php  } ?>
</table>

<?php if(!$continuous_products->isEmpty()){ ?>
<div style="text-align:center;padding-top:10px;padding-bottom:10px;border-bottom:5px dashed;border-top:5px dashed;margin-top:25px;">
    <p  style="margin:0;font-size:18px;font-weight:600">Continuous Order</p>
    <table style="width:100%;margin-top:15px;">
     <tr>
        <th style="width:70%; text-align:left;">
        <p style="margin:0;">Item</p>
        </th>
        <th style="width:30%; text-align:right;">
        <p style="margin:0;">QTY</p>
        </th>
    </tr>
</table>
<table style="width:100%;border-top:1px solid;">

    <?php foreach($continuous_products as $continuous_product){ 
         if($continuous_product->type == "service"){
            $product_name = Services::withTrashed()->where('id', $continuous_product->product)->value('name');
        }
        else{
            $product_name = Products::withTrashed()->where('id', $continuous_product->product)->value('product_name');
        }
    ?>
    <tr style="">
        <td style="width:80%; text-align:left;border-bottom:1px dashed;">
        <p style="margin:0;font-size:22px;font-weight:600;padding-bottom:10px;"><?php echo e($product_name); ?><br><span style="font-size:16px;font-weight:400;"><?php echo e($continuous_product->note); ?></span></p>
        </td>
        <td style="width:20%; text-align:right;border-bottom:1px dashed;">
        <p style="margin:0;font-size:32px;font-weight:600;padding-bottom:10px;"><?php echo e($continuous_product->quantity); ?></p>
        </td>
    </tr>
    <?php  } ?>
</table>
</div>
<?php } ?>

</body>

<?php /**PATH D:\Part Time Work\erp-resturant\resources\views/takeaway_token.blade.php ENDPATH**/ ?>