| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace App\Http\Livewire;
- use Livewire\Component;
- use Barryvdh\DomPDF\Facade\Pdf;
- class Receipt extends Component
- {
- public $records;
- public $filterStatus = '';
- public $hasFilter = false;
- public $filterFrom = '', $filterTo = '';
- public function updatedFilterFrom()
- {
- $this->emit('destroy-data-table');
- }
- public function updatedFilterTo()
- {
- $this->emit('destroy-data-table');
- }
- public function render()
- {
- if ($this->hasFilter)
- {
- $r = \App\Models\Receipt::with('member');
- if ($this->filterStatus != '')
- $r = $r->where('status', $this->filterStatus);
- if ($this->filterFrom != '')
- $r = $r->where('date', '>=', $this->filterFrom);
- if ($this->filterTo != '')
- $r = $r->where('date', '<=', $this->filterTo);
- $this->records = $r->get();
- }
- else
- {
- $this->records = \App\Models\Receipt::with('member')->get();
- }
- $this->emit('load-data-table');
- return view('livewire.receipt');
- }
- public function printReceipt($id)
- {
- $this->emit('load-data-table');
- $receipt = \App\Models\Receipt::findOrFail($id);
- //$pdf = PDF::loadView('pdf/receipt', array('datas' => $datas, 'from' => $x, 'to' => $y, 'who' => '', 'matricola' => $matricola));
- $pdf = PDF::loadView('receipt', array('receipt' => $receipt));//->output();
- return $pdf->stream();
- /*
- return response()->streamDownload(
- fn () => print($pdf),
- "ricevuta_" . $receipt->number . "_" . $receipt->year . ".pdf"
- );*/
- /*return response()->streamDownload(function () {
- echo $pdf->stream();
- }, 'test.pdf');*/
- }
- public function search()
- {
- $this->hasFilter = true;
- }
- public function disableSearch()
- {
- $this->filterStatus = "";
- $this->filterTo = '';
- $this->filterFrom = '';
- $this->hasFilter = false;
- }
- }
|