receipt.blade.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title></title>
  5. <style>
  6. body {
  7. font-family: Helvetica, Arial, sans-serif;
  8. font-size:14px;
  9. }
  10. footer {
  11. position: fixed;
  12. bottom: -20px;
  13. left: 0px;
  14. right: 0px;
  15. height: 50px;
  16. }
  17. .logo {
  18. max-width: 200px;
  19. max-height: 100px;
  20. object-fit: contain;
  21. }
  22. </style>
  23. </head>
  24. <body>
  25. @php
  26. $azienda = App\Models\Azienda::first();
  27. $logoService = app(App\Services\LogoUploadServices::class);
  28. $logoUrl = $azienda ? $logoService->getLogoUrl($azienda) : null;
  29. $display_date = $receipt->created_at;
  30. if ($receipt->receipt_date) {
  31. $display_date = $receipt->receipt_date;
  32. }
  33. @endphp
  34. {{-- Display logo from database/Wasabi instead of env --}}
  35. @if($logoUrl)
  36. <img src="{{ $logoUrl }}" class="logo" alt="Logo">
  37. @elseif($azienda && $azienda->logo)
  38. {{-- Fallback if URL generation fails --}}
  39. <div style="width: 200px; height: 100px; border: 1px dashed #ccc; display: flex; align-items: center; justify-content: center;">
  40. <small>Logo non disponibile</small>
  41. </div>
  42. @endif
  43. <br><br><br>
  44. <div align="right"><b>RICEVUTA DI PAGAMENTO N. {{$receipt->number . "/" . $receipt->year}} del {{date("d/m/Y", strtotime($display_date))}}</b></div><br><br>
  45. @if($receipt->status == 99)
  46. <div align="right"><b style="color:red">ANNULLATA</b></div><br><br>
  47. @endif
  48. <br>
  49. @if($azienda)
  50. @if($azienda->ragione_sociale)
  51. {{$azienda->ragione_sociale}}
  52. @elseif($azienda->nome_associazione)
  53. {{$azienda->nome_associazione}}
  54. @endif
  55. <br><br>
  56. <b>Indirizzo</b>:
  57. @php
  58. $addressParts = array_filter([
  59. $azienda->sede_legale_indirizzo,
  60. $azienda->sede_legale_cap,
  61. $azienda->sede_legale_comune,
  62. $azienda->sede_legale_provincia ? '(' . $azienda->sede_legale_provincia . ')' : null
  63. ]);
  64. @endphp
  65. {{ implode(' ', $addressParts) }}
  66. <br><br>
  67. @if($azienda->codice_fiscale)
  68. <b>C.F.</b>: {{$azienda->codice_fiscale}}<br><br>
  69. @endif
  70. @if($azienda->partita_iva)
  71. <b>P.IVA</b>: {{$azienda->partita_iva}}<br><br>
  72. @endif
  73. @if($azienda->email)
  74. <b>Email</b>: {{$azienda->email}}<br><br>
  75. @endif
  76. @if($azienda->pec)
  77. <b>PEC</b>: {{$azienda->pec}}<br><br>
  78. @endif
  79. @else
  80. <div style="color: red; font-weight: bold;">
  81. ATTENZIONE: Configurare i dati aziendali nel sistema
  82. </div><br><br>
  83. @endif
  84. <hr><br>
  85. <b>Intestata a</b><br><br>
  86. @if(!$receipt->member->isAdult())
  87. <b>Genitore</b>: {{$receipt->parent}}<br><br>
  88. @endif
  89. @if($receipt->member->last_name != '')
  90. <b>Cognome</b>: {{$receipt->member->last_name}}<br><br>
  91. @endif
  92. @if($receipt->member->first_name != '')
  93. <b>Nome</b>: {{$receipt->member->first_name}}<br><br>
  94. @endif
  95. @if(@$receipt->member->birth_city->name != '' || @$receipt->member->birth_province->name != '' || @$receipt->member->birth_date != '')
  96. <b>Nato/a a</b>:
  97. @if(@$receipt->member->birth_city->name != '')
  98. {{@$receipt->member->birth_city->name}}
  99. @endif
  100. @if(@$receipt->member->birth_province->name != '')
  101. ({{@$receipt->member->birth_province->name}})
  102. @endif
  103. @if(@$receipt->member->birth_date != '')
  104. il {{$receipt->member->birth_date ? date("d/m/Y", strtotime($receipt->member->birth_date)) : ""}}
  105. @endif
  106. <br><br>
  107. @endif
  108. @if($receipt->member->address != '' || @$receipt->member->city->name != '' || @$receipt->member->province->name != '')
  109. <b>Residente in</b>:
  110. @if($receipt->member->address != '')
  111. {{$receipt->member->address}}
  112. @endif
  113. @if(@$receipt->member->city->name != '')
  114. {{@$receipt->member->city->name}}
  115. @endif
  116. @if(@$receipt->member->province->name != '')
  117. ({{@$receipt->member->province->name}})
  118. @endif
  119. <br><br>
  120. @endif
  121. @if($receipt->member->fiscal_code != '')
  122. <b>Codice Fiscale</b>: {{$receipt->member->fiscal_code}}<br><br>
  123. @endif
  124. <hr><br>
  125. @php
  126. $total = 0;
  127. $totalSconto = 0;
  128. $totalPrediscount = 0;
  129. $hasDiscount = false;
  130. @endphp
  131. @foreach($receipt->rows as $row)
  132. <b>Causale</b>: {{@$row->causal->getTree()}}<br><br>
  133. @if ($row->course)
  134. <b>Corso</b>: {{$row->course->getDetailsName()}}<br><br>
  135. @endif
  136. @if ($row->subscription)
  137. <b>Abbonamento</b>: {{$row->subscription->name}}<br><br>
  138. @endif
  139. @if ($row->note != '')
  140. <b>Dettaglio causale</b>: {{$row->note}}<br><br>
  141. @endif
  142. @if($row->sconto > 0)
  143. @php $hasDiscount = true; @endphp
  144. <b>Importo</b>: {{formatPrice($row->prediscount_amount)}}<br><br>
  145. <b>Sconto</b>: {{formatPrice($row->sconto)}}<br><br>
  146. @endif
  147. <b>{{$row->sconto > 0 ? 'Importo finale' : 'Importo'}}</b>: {{formatPrice($row->amount)}}<br><br>
  148. <hr><br>
  149. @php
  150. $totalSconto += $row->sconto;
  151. $totalPrediscount += $row->prediscount_amount;
  152. $total += $row->amount;
  153. @endphp
  154. @endforeach
  155. <br><br>
  156. @if($hasDiscount)
  157. <b>Totale</b>: {{formatPrice($totalPrediscount)}}<br><br>
  158. <b>Sconto totale</b>: {{formatPrice($totalSconto)}}<br><br>
  159. @endif
  160. <b>Totale</b>: {{formatPrice($total)}}<br><br>
  161. <footer>
  162. <small>
  163. @if($azienda)
  164. @php
  165. $locationParts = array_filter([
  166. $azienda->sede_legale_comune,
  167. $azienda->sede_legale_provincia ? '(' . $azienda->sede_legale_provincia . ')' : null
  168. ]);
  169. $location = implode(' ', $locationParts);
  170. @endphp
  171. {{ $location ?: 'Sede legale' }} li {{date("d/m/Y", strtotime($display_date))}}
  172. @else
  173. {{date("d/m/Y", strtotime($display_date))}}
  174. @endif
  175. </small>
  176. </footer>
  177. </body>
  178. </html>