@php
    $total_original_count = 0;
    $total_original_price = 0;
    $total_qty_in = 0;
    $total_price_in = 0;
    $total_qty_out = 0;
    $total_price_out = 0;
    $total_balance = 0;
    $total_balance_price = 0;
@endphp

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<style>
    table {
        font-family: 'aealarabiya', sans-serif;
        border-collapse: collapse;
        width: 100%;
        border-color:#2770c0;
    }

    td, th {
        border: 2px solid #2770c0;
        text-align: center;
        padding: 8px;
        width: 10px;
    }

    body{
        font-family: 'Lato', sans-serif;
        font-family:  'aealarabiya', sans-serif;
    }
</style>

<table width="100%" style=" font-family: aealarabiya, sans-serif; border-collapse: collapse;">
    <thead style="background-color: #fdf2cc">
    <tr>
        <th style="background-color: #fdf2cc" rowspan="2">الصنف</th>
        <th style="background-color: #fdf2cc" colspan="2">الرصيد الإفتتاحي</th>
        <th style="background-color: #fdf2cc" colspan="2">الكمية المضافة</th>
        <th style="background-color: #fdf2cc" colspan="2">الكمية المنصرفة</th>
        <th style="background-color: #fdf2cc" colspan="2">الرصيد</th>
    </tr>
    <tr>
        <th style="background-color: #fdf2cc">كمية</th>
        <th style="background-color: #fdf2cc">قيمة</th>
        <th style="background-color: #fdf2cc">كمية</th>
        <th style="background-color: #fdf2cc">قيمة</th>
        <th style="background-color: #fdf2cc">كمية</th>
        <th style="background-color: #fdf2cc">قيمة</th>
        <th style="background-color: #fdf2cc">كمية</th>
        <th style="background-color: #fdf2cc">قيمة</th>
    </tr>
    </thead>
    @foreach($report as $key=> $row)
        <tr >
            <td >{{ $row->product->currentDescription->title }}</td>
            <td >{{ $row->original_count }}</td>
            <td >{{ $row->original_price }}</td>
            <td >{{ $row->qty_in }}</td>
            <td >{{ $row->price_in }}</td>
            <td >{{ $row->qty_out }}</td>
            <td >{{ $row->price_out }}</td>
            <td >{{ $row->balance }}</td>
            <td >{{ $row->balance_price }}</td>
        </tr>
        @php
            $total_original_count += $row->original_count;
            $total_original_price += $row->original_price;
            $total_qty_in += $row->qty_in;
            $total_price_in += $row->price_in;
            $total_qty_out += $row->qty_out;
            $total_price_out += $row->price_out;
            $total_balance += $row->balance;
            $total_balance_price += $row->balance_price;
        @endphp
    @endforeach
    <tr>
        <td>الاجمالي</td>
        <td >{{ $total_original_count }}</td>
        <td >{{ $total_original_price }}</td>
        <td >{{ $total_qty_in }}</td>
        <td >{{ $total_price_in }}</td>
        <td >{{ $total_qty_out }}</td>
        <td >{{ $total_price_out }}</td>
        <td >{{ $total_balance }}</td>
        <td >{{ $total_balance_price }}</td>
    </tr>
</table>
