@extends('emails.layout')

@section('content')
    <h1>Gracias por tu pedido</h1>
    <p>Hola {!! htmlentities($order->full_name ?? $order->first_name) !!}</p>
    <p>Solo para que est&eacute;s informado, hemos recibido tu pedido #{{ $order->id }} y ahora se est&aacute; procesando. </p>
    <h2>Pedido #{{ $order->id }} ({{ $order->short_date }})</h2>
    <table class="table table-condensed">
        <thead>
        <tr>
            <th>Producto</th>
            <th>Precio</th>
            <th>Cantidad</th>
            <th>Total</th>
        </tr>
        </thead>
        <tbody>
        @foreach($order->items as &$item)
            <tr>
                <td>
                    @if($item->options)
                        <img src="{{ asset($item->options->image ?? null) }}" alt="" class="img-thumbnail">
                    @endif
                    <span>{{ $item->name }}</span>
                </td>
                <td><div class="text-nowrap">Gs. {{ num_format($item->price) }}</div></td>
                <td><div class="text-center">{{ $item->qty }}</div></td>
                <td><div class="text-nowrap">Gs. {{ num_format($item->price * $item->qty) }}</div></td>
            </tr>
        @endforeach
        <tr>
            <td colspan="3"><b>Subtotal</b></td>
            <td><div class="text-nowrap">Gs. {{ num_format($order->subtotal) }}</div></td>
        </tr>
        @if($order->shipping_price)
            <tr>
                <td colspan="3"><b>Costo de envío</b></td>
                <td><div class="text-nowrap">Gs. {{ num_format($order->shipping_price) }}</div></td>
            </tr>
        @endif
        <tr>
            <td colspan="3"><b>Total</b></td>
            <td><div class="text-nowrap">Gs. {{ num_format($order->total) }}</div></td>
        </tr>
        @if($order->payment_method)
            <tr>
                <td colspan="3"><b>Método de pago</b></td>
                <td><div class="text-nowrap">{{ $order->payment_method }}</div></td>
            </tr>
        @endif
        </tbody>
    </table>
    <table class="table table-condensed">
        <tbody>
        <tr>
            <td>Nombre</td>
            <td>{!! htmlentities($order->first_name) !!}</td>
        </tr>
        <tr>
            <td>Apellido</td>
            <td>{!! htmlentities($order->last_name) !!}</td>
        </tr>
        <tr>
            <td>Tel&eacute;fono</td>
            <td>{!! htmlentities($order->phone) !!}</td>
        </tr>
        <tr>
            <td>Correo electr&oacute;nico</td>
            <td>{!! htmlentities($order->email) !!}</td>
        </tr>
        </tbody>
    </table>
    <table class="table table-condensed">
        <tbody>
        <tr>
            <td>Direcci&oacute;n</td>
            <td>{!! htmlentities($order->address) !!}</td>
        </tr>
        <tr>
            <td>Ciudad</td>
            <td>{!! htmlentities($order->city) !!}</td>
        </tr>
        @if($order->shipping_data)
            <tr>
                <td colspan="2">Enviar a</td>
            </tr>
            <tr>
                <td>Nombre</td>
                <td>{!! htmlentities($order->shipping_data['first_name']) !!}</td>
            </tr>
            <tr>
                <td>Apellido</td>
                <td>{!! htmlentities($order->shipping_data['last_name']) !!}</td>
            </tr>
            <tr>
                <td>Direcci&oacute;n</td>
                <td>{!! htmlentities($order->shipping_data['address']) !!}</td>
            </tr>
            <tr>
                <td>Ciudad</td>
                <td>{!! htmlentities($order->shipping_data['city']) !!}</td>
            </tr>
        @endif
        <tr>
            <td>Observaciones</td>
            <td>{!! htmlentities($order->feedback) !!}</td>
        </tr>
        </tbody>
    </table>
    @if($order->bancard)
        <table class="table table-condensed">
            <tbody>
            <tr>
                <td>N&uacute;mero de pedido</td>
                <td>{{ $order->bancard()->shop_process_id }}</td>
            </tr>
            <tr>
                <td>C&oacute;digo de autorizaci&oacute;n</td>
                <td>{{ $order->bancard()->authorization_number }}</td>
            </tr>
            <tr>
                <td>Importe</td>
                <td>{{ $order->bancard()->currency }} {{ num_format($order->bancard()->amount) }}</td>
            </tr>
            <tr>
                <td>Descripci&oacute;n</td>
                <td>{{ $order->bancard()->response_description }}</td>
            </tr>
            <tr>
                <td>Fecha de transacci&oacute;n</td>
                <td>{{ date('d/m/Y - H:i:s', strtotime($order->bancard()->fecha)) }}</td>
            </tr>
            </tbody>
        </table>
    @endif
@endsection
