<!DOCTYPE html>
<html lang="zxx">

<head>
    <title>{{ env('APP_NAME') }} Venda Nº {{ $venda->id }}, emitida por {{ $user->sexo }} {{ $user->nome }}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="UTF-8">

    <!-- External CSS libraries -->
    <link type="text/css" rel="stylesheet" href="{{ url('prints') }}/assets/css/bootstrap.min.css">
    <link type="text/css" rel="stylesheet"
        href="{{ url('prints') }}/assets/fonts/font-awesome/css/font-awesome.min.css">

    <!-- Favicon icon -->
    <link rel="shortcut icon" href="{{ url('prints') }}/assets/img/favicon.ico" type="image/x-icon">

    <!-- Google fonts -->
    <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
    <link
        href="https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&amp;display=swap"
        rel="stylesheet">

    <!-- Custom Stylesheet -->
    <link type="text/css" rel="stylesheet" href="{{ url('prints') }}/assets/css/style.css">
</head>

<body>

    <!-- Invoice 6 start -->
    <div class="invoice-6 invoice-content">
        <div class="container">
            <div class="row">
                <div class="col-lg-12">
                    <div class="invoice-inner-6" id="invoice_wrapper">
                        <div class="invoice-top">
                            <div class="row">
                                <div class="col-sm-6">
                                    <div>
                                        <img width="70" src="{{ url('adm') }}/assets/media/logos/logo.png"
                                            alt="logo">
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="invoice">
                                        <h1>Venda Nº {{ $venda->id }}</h1>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="invoice-titel">
                            <div class="row">
                                <div class="invoice2 col-sm-6">
                                    @if (!empty($animal->nome))
                                    <h3>{{ $animal->nome }} - {{ utf8_decode($animal->raca_nome) }}</h3>
                                    @else
                                    <h3>Animal não informado</h3>
                                    @endif
                                </div>
                                <div class="date col-sm-6 text-end">
                                    <h3>Data da emissão <span>{{ date('d/m/Y', strtotime($venda->created_at)) }}</span></h3>
                                </div>
                            </div>
                        </div>
                        <div class="invoice-info border-bottom">
                            <div class="row">
                                <div class="col-sm-6 mb-30">
                                    <div class="invoice-number">
                                        <h4 class="inv-title-1">Cliente</h4>
                                        <p class="invo-addr-1">
                                            @if (!empty($cliente->name))
                                                Nome: {{ $cliente->name }} <br />
                                                Telefone: {{ $cliente->celular }} <br />
                                                Endereço: {{ $cliente->endereco }}, {{ $cliente->numeno }},
                                                {{ $cliente->complemento }} {{ $cliente->bairro }},
                                                {{ $cliente->cidade }}-{{ $cliente->estado }} CEP: {{ $cliente->cep }}
                                            @else
                                                Cliente não informado
                                            @endif
                                            <br />
                                        </p>
                                    </div>
                                </div>
                                <div class="col-sm-6 mb-30">
                                    <div class="invoice-number text-end">
                                        <h4 class="inv-title-1">Animal</h4>
                                        <p class="invo-addr-1">
                                            @if (!empty($animal->nome))
                                                Nome: {{ $animal->nome }}<br />
                                                Espécie: {{ $animal->especie }} |
                                                Raça: {{ utf8_decode($animal->raca_nome) }} <br />
                                                Idade:
                                                <?php
                                                $date1 = date('Y-m-d', strtotime($animal->nascimento));
                                                $date2 = date('Y-m-d');
                                                $diff = abs(strtotime($date2) - strtotime($date1));

                                                $years = floor($diff / (365 * 60 * 60 * 24));
                                                $months = floor(($diff - $years * 365 * 60 * 60 * 24) / (30 * 60 * 60 * 24));
                                                $days = floor(($diff - $years * 365 * 60 * 60 * 24 - $months * 30 * 60 * 60 * 24) / (60 * 60 * 24));
                                                printf("%d ano(s), %d mese(s), %d dia(s)\n", $years, $months, $days);
                                                ?>
                                                <br />
                                                Sexo: {{ $animal->sexo }} |
                                                Castrado: {{ $animal->castrado }} |
                                                Peso: {{ $animal->peso }}<br />
                                            @else
                                                Animal não informado
                                            @endif
                                        </p>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="order-summary">
                            <div class="table-responsive">
                                <table class="table invoice-table">
                                    <thead class="bg-active">
                                    <tr>
                                        <th>Produto</th>
                                        <th class="text-center">Preço</th>
                                        <th class="text-center">QTD</th>
                                        <th class="text-right">Total</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    @foreach ($carrinho as $item)
                                        <tr>
                                            <td>
                                                <div class="item-desc-1">
                                                    <span>{{$item->produto->produto}}</span>
                                                </div>
                                            </td>
                                            <td class="text-center">R$ {{moeda($item->preco)}}</td>
                                            <td class="text-center">{{$item->qtd}}</td>
                                            <td class="text-right">R$ {{moeda($item->total)}}</td>
                                        </tr>
                                    @endforeach
                                    <tr>
                                        <td colspan="3" class="text-end fw-bold">Total</td>
                                        <td class="text-right fw-bold">R$ {{moeda($total)}}</td>
                                    </tr>
                                    </tbody>
                                    @foreach ($venda->FormaPagamento as $pagamento)
                                        <tr>
                                            <td colspan="3" class="text-end fw-bold"><img src="{{url('adm')}}/assets/images/{{setUri2($pagamento->forma_de_pagamento)}}.png" width="20" /> {{$pagamento->forma_de_pagamento}} {{$pagamento->tipo == 2 ? $pagamento->parcelamento : ''}}</td>
                                            <td class="text-right fw-bold">R$
                                            @if ($pagamento->tipo == 1)
                                                {{moeda($pagamento->caixa_dinheiro)}}
                                            @elseif ($pagamento->tipo == 2)
                                                {{moeda($pagamento->caixa_credito)}}
                                            @else
                                                {{moeda($pagamento->caixa_debito)}}
                                            @endif
                                            </td>
                                        </tr>
                                    @endforeach
                                </table>
                            </div>
                        </div>


                        <div class="invoice-informeshon">
                            <div class="row mt-4">
                                <div class="col-sm-12">
                                    <p class="text-1 text-center">
                                        <img width="200px" src="{{ $user->assinatura }}">
                                        <br>
                                        {{ $user->sexo }} {{ $user->name }}<br>
                                        CRMV: {{ $user->crmv }}
                                    </p>
                                    <p class="text-1 text-center">
                                        <img src="{{ url('adm') }}/assets/images/email.png" width="15">
                                        {{ $clinica->email }} <img
                                            src="{{ url('adm') }}/assets/images/zap-azul.png" width="15">
                                        {{ $clinica->celular }} <img
                                            src="{{ url('adm') }}/assets/images/instagram.png" width="15">
                                        {{ $clinica->instagram }}
                                    </p>
                                    @if ($clinica->rodape == 1)
                                        <p class="text-1 text-center">
                                            {{ $clinica->endereco }}, {{ $clinica->numero }}
                                            {{ $clinica->complemento }}, {{ $clinica->bairro }},
                                            {{ $clinica->cidade }}-{{ $clinica->estado }} CEP: {{ $clinica->cep }}
                                        </p>
                                    @endif
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="invoice-btn-section clearfix d-print-none">
                        <a href="javascript:window.print()" class="btn btn-lg btn-print">
                            <i class="fa fa-print"></i> Imprimir
                        </a>
                        <a id="invoice_download_btn" class="btn btn-lg btn-download">
                            <i class="fa fa-download"></i> Baixar
                        </a>
                        <a target="_blank" href="https://api.whatsapp.com/send?text=Olá segue o *Venda Nº {{$venda->id}}* Acesse a termo pelo link: {{env('APP_URL')}}/print/venda/{{$venda->id}}, emitida por *{{$user->sexo}} {{$user->name}} CRMV {{$user->crmv}}*" class="btn btn-lg btn-success">
                            <img src="{{url('adm')}}/assets/images/whatsapp-logo-branca.png" width="15"> Compartilhar
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- Invoice 6 end -->

    <script src="{{ url('prints') }}/assets/js/jquery.min.js"></script>
    <script src="{{ url('prints') }}/assets/js/jspdf.min.js"></script>
    <script src="{{ url('prints') }}/assets/js/html2canvas.js"></script>
    <script src="{{ url('prints') }}/assets/js/app.js"></script>
</body>

</html>
