<!DOCTYPE html>
<html>
<head>
  <title></title>
  <style>
    body {
        font-family: Helvetica, Arial, sans-serif;
        font-size:14px;
    }
    footer {
        position: fixed;
        bottom: -20px;
        left: 0px;
        right: 0px;
        height: 50px;

    }
    </style>
</head>
<body>
    <img src="{{public_path() . env('LOGO')}}" width="200">
    <br><br><br>
    <div align="right"><b>RICEVUTA DI PAGAMENTO N. {{$receipt->number . "/" . $receipt->year}} del {{date("d/m/Y", strtotime($receipt->created_at))}}</b></div><br><br>
    @if($receipt->status == 99)
        <div align="right"><b style="color:red">ANNULLATA</b></div><br><br>
    @endif
    <br>
    {{env('RAGIONE_SOCIALE', '')}}<br><br>
    <b>Indirizzo</b>: {{env('INDIRIZZO', '')}} {{env('LOCALITA', '')}} ({{env('PROVINCIA', '')}})<br><br>
    <b>C.F.</b>: {{env('CODICE_FISCALE', '')}}<br><br>
    <b>P.IVA</b>: {{env('PARTITA_IVA', '')}}<br><br>
    <hr><br>

    <b>Intestata a</b><br><br>
    @if(!$receipt->member->isAdult())
        <b>Genitore</b>: {{$receipt->parent}}<br><br>
    @endif
    @if($receipt->member->last_name != '')
        <b>Cognome</b>: {{$receipt->member->last_name}}<br><br>
    @endif
    @if($receipt->member->first_name != '')
        <b>Nome</b>: {{$receipt->member->first_name}}<br><br>
    @endif
    @if(@$receipt->member->birth_city->name != '' || @$receipt->member->birth_province->name != '' || @$receipt->member->birth_date != '')
        <b>Nato/a a</b>:
            @if(@$receipt->member->birth_city->name != '')
                {{@$receipt->member->birth_city->name}}
            @endif
            @if(@$receipt->member->birth_province->name != '')
                ({{@$receipt->member->birth_province->name}})
            @endif
            @if(@$receipt->member->birth_date != '')
                il {{$receipt->member->birth_date ? date("d/m/Y", strtotime($receipt->member->birth_date)) : ""}}
            @endif
        <br><br>
    @endif
    @if($receipt->member->address != '' || @$receipt->member->city->name != ''  || @$receipt->member->province->name != '')
        <b>Residente in</b>:
            @if($receipt->member->address != '')
                {{$receipt->member->address}}
            @endif
            @if(@$receipt->member->city->name != '')
                {{@$receipt->member->city->name}}
            @endif
            @if(@$receipt->member->province->name != '')
                ({{@$receipt->member->province->name}})
            @endif
            <br><br>
    @endif
    @if($receipt->member->fiscal_code != '')
        <b>Codice Fiscale</b>: {{$receipt->member->fiscal_code}}<br><br>
    @endif
    <hr><br>

    @php
    $total = 0;
    @endphp
    @foreach($receipt->rows as $row)
        <b>Causale</b>: {{@$row->causal->getTree()}}<br><br>
        <b>Dettaglio causale</b>: {{$row->note != '' ? $row->note : ''}}<br><br>
        <b>Importo</b>: {{formatPrice($row->amount)}}<br><br>
        @php
        $total += $row->amount;
        @endphp
    @endforeach
    <br><br>
    <b>Totale</b>: {{formatPrice($total)}}
    <footer>
        <small>{{env('LOCALITA', '')}} ({{env('PROVINCIA', '')}}) li {{date("d/m/Y", strtotime($receipt->created_at))}}</small>
    </footer>

</body>
</html>
