<!DOCTYPE html>
<?php
use App\Models\OrderProducts;
use App\Models\User;
use App\Models\CustomerDetails;
use App\Models\Products;

$products=OrderProducts::withTrashed()->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();
?>
<html lang="en">
<style type="text/css">

</style>


<table style="width:100%;border: none;">
    <tr style="vertical-align:middle;">
        <td style="width:50%;border: none;text-align:left;">
            <p >Promo EMR B.V.<br> Lange Nering 98<br>8302 EG Emmeloord<br> Nederland</p>
        </td>
        <td style="width:50%;border: none;text-align:right;">
            <p ><b><?php echo e($other_details->customer_name ?? '-'); ?></b><br>
            <?php echo e($other_details->address ?? '-'); ?><br>
Tel: <?php echo e($other_details->phone ?? '-'); ?><br>
E: mail: <?php echo e($user_details->email ?? '-'); ?><br>
Website: www.ferolis.com<br>
BTW-nr: <?php echo e($other_details->vat_no ?? '-'); ?><br>
Kvk: <?php echo e($other_details->kvk_no ?? '-'); ?><br>
IBAN: NL10 INGB 0398 6281 30</p>
        </td>
    </tr>
</table>

<h2 style="text-align:center;">FACTUUR</h2>

<table style="width:100%;border: none;">
    <tr style="vertical-align:middle;">
        <td style="width:20%;border: none;text-align:left;padding:0;">
            <p style="margin:0;">Datum:</p>
        </td>
        <td style="width:80%;border: none;text-align:left;padding:0;">
            <p style="margin:0;"><?php echo e($order->order_date); ?></p>
        </td>
    </tr>
    <tr style="vertical-align:middle;">
        <td style="width:20%;border: none;text-align:left;padding:0;">
            <p style="margin:0;">Factuurnummer::</p>
        </td>
        <td style="width:80%;border: none;text-align:left;padding:0;">
            <p style="margin:0;"><?php echo e($order->sales_order_number); ?></p>
        </td>
    </tr>
    <tr style="vertical-align:middle;">
        <td style="width:20%;border: none;text-align:left;padding:0;">
            <p style="margin:0;">Vervaldatum::</p>
        </td>
        <td style="width:80%;border: none;text-align:left;padding:0;">
            <p style="margin:0;"><?php echo e($order->due_date); ?></p>
        </td>
    </tr>
</table>

<table style="width:100%;border: none;margin-top:40px;">
    <tr style="vertical-align:middle;">
        <th style="width:40%;border: none;text-align:left;padding:0;border-bottom:1px solid #000;padding-bottom:5px;">
            <p style="margin:0;">Omschrijving</p>
        </th>
        <th style="width:10%;border: none;text-align:left;padding:0;border-bottom:1px solid #000;padding-bottom:5px;">
            <p style="margin:0;">Aantal</p>
        </th>
        <th style="width:10%;border: none;text-align:left;padding:0;border-bottom:1px solid #000;padding-bottom:5px;">
            <p style="margin:0;">Eenheid</p>
        </th>
        <th style="width:10%;border: none;text-align:left;padding:0;border-bottom:1px solid #000;padding-bottom:5px;">
            <p style="margin:0;">Stukprijs</p>
        </th>
        <th style="width:10%;border: none;text-align:left;padding:0;border-bottom:1px solid #000;padding-bottom:5px;">
            <p style="margin:0;">Totaal</p>
        </th>
        <th style="width:10%;border: none;text-align:left;padding:0;border-bottom:1px solid #000;padding-bottom:5px;">
            <p style="margin:0;">Btw</p>
        </th>

    </tr>
    <?php foreach($products as $product){ 
        $product_name = Products::withTrashed()->where('id', $product->product)->value('product_name');
        $units = Products::withTrashed()->where('id', $product->product)->value('units');
    ?>

    <tr style="vertical-align:middle;">
        <td style="width:40%;border: none;text-align:left;padding:0;border-bottom:1px solid #000;padding-bottom:5px;">
            <p style="margin:0;"><?php echo e($product_name); ?></p>
        </td>
        <td style="width:10%;border: none;text-align:left;padding:0;border-bottom:1px solid #000;padding-bottom:5px;">
            <p style="margin:0;"><?php echo e($product->quantity); ?></p>
        </td>
        <td style="width:10%;border: none;text-align:left;padding:0;border-bottom:1px solid #000;padding-bottom:5px;">
            <p style="margin:0;"><?php echo e($units); ?></p>
        </td>
        <td style="width:10%;border: none;text-align:left;padding:0;border-bottom:1px solid #000;padding-bottom:5px;">
            <p style="margin:0;">€ <?php echo e(number_format($product->price)); ?></p>
        </td>
        <td style="width:10%;border: none;text-align:left;padding:0;border-bottom:1px solid #000;padding-bottom:5px;">
            <p style="margin:0;">€ <?php echo e(number_format($product->price*$product->quantity)); ?></p>
        </td>
        <td style="width:10%;border: none;text-align:left;padding:0;border-bottom:1px solid #000;padding-bottom:5px;">
            <p style="margin:0;"><?php echo e($order->tax); ?>%</p>
        </td>

    </tr>
    <?php  } ?>

    <tr style="vertical-align:middle;">
        <td style="border: none;text-align:right;padding:0;padding-bottom:5px;padding-right:20px;" colspan="4">
            <p style="margin:0;">Totaal excl btw</p>
        </td>
        <td style="width:10%;border: none;text-align:left;padding:0;padding-bottom:5px;">
            <p style="margin:0;">€ <?php echo e(number_format($order->sub_total)); ?></p>
        </td>
        <td style="width:10%;border: none;text-align:left;padding:0;padding-bottom:5px;">
            
        </td>

    </tr>
    <tr style="vertical-align:middle;">
        <td style="border: none;text-align:right;padding:0;padding-bottom:5px;padding-right:20px;" colspan="4">
            <p style="margin:0;">Btw hoog <?php echo e($order->tax); ?>% (€ <?php echo e(number_format($order->sub_total)); ?>)</p>
        </td>
        <td style="width:10%;border: none;text-align:left;padding:0;padding-bottom:5px;">
            <p style="margin:0;">+ € <?php echo e(number_format(($order->sub_total/100)*$order->tax)); ?></p>
        </td>
        <td style="width:10%;border: none;text-align:left;padding:0;padding-bottom:5px;">
            
        </td>

    </tr>
    <tr style="vertical-align:middle;">
        <td style="border: none;text-align:right;padding:0;padding-bottom:5px;padding-right:20px;" colspan="4">
            <p style="margin:0;">Korting <?php echo e($order->discount); ?>% (€ <?php echo e(number_format($order->sub_total)); ?>)</p>
        </td>
        <td style="width:10%;border: none;text-align:left;padding:0;padding-bottom:5px;border-bottom:1px solid #000;">
            <p style="margin:0;">- € <?php echo e(number_format(($order->sub_total/100)*$order->discount)); ?></p>
        </td>
        <td style="width:10%;border: none;text-align:left;padding:0;padding-bottom:5px;">
            
        </td>

    </tr>

    <tr style="vertical-align:middle;">
        <td style="border: none;text-align:right;padding:0;padding-bottom:5px;padding-right:20px;" colspan="4">
            <p style="margin:0;"><b>Totaal te betalen</b></p>
        </td>
        <td style="width:10%;border: none;text-align:left;padding:0;padding-bottom:5px;">
            <p style="margin:0;">€ <?php echo e(number_format($order->total)); ?></p>
        </td>
        <td style="width:10%;border: none;text-align:left;padding:0;padding-bottom:5px;">
            
        </td>

    </tr>
   
</table>

<p style="text-align:left;margin-top:50px;">Gelieve het factuurbedrag ad 698,90 vóór <?php echo e($order->due_date); ?> betalen o.v.v. factuurnummer te betalen op IBAN NL10 INGB 0398 6281
30 t.n.v. Ferolis B.V..</p><?php /**PATH /home/dilsnoon/orionuxerp.store/ferolis/Modules/Admin/resources/views/pdf/invoice.blade.php ENDPATH**/ ?>