ajax()) {
return DataTables::of(Invoice::filter($filters))->addColumn('action', function ($invoice) {
return ''.ctrans('texts.view').'';
})
->addColumn('checkbox', function ($invoice){
return '';
})
->editColumn('status_id', function ($invoice){
return Invoice::badgeForStatus($invoice->status);
})
->rawColumns(['checkbox', 'action', 'status_id'])
->make(true);
}
$data['html'] = $builder;
return view('portal.default.invoices.index', $data);
}
/**
* Display the specified resource.
*
* @param \App\Models\Invoice $invoice The invoice
*
* @return \Illuminate\Http\Response
*/
public function show(Invoice $invoice)
{
}
/**
* Pay one or more invoices
*
* @return View
*/
public function bulk()
{
$transformed_ids = $this->transformKeys(explode(",",request()->input('hashed_ids')));
if(request()->input('action') == 'payment')
return $this->makePayment($transformed_ids);
else if(request()->input('action') == 'download')
return $this->downloadInvoicePDF($transformed_ids);
}
private function makePayment(array $ids)
{
$invoices = Invoice::whereIn('id', $ids)
->whereClientId(auth()->user()->client->id)
->get()
->filter(function ($invoice){
return $invoice->isPayable();
});
$data = [
'invoices' => $invoices,
];
return view('portal.default.invoices.payment', $data);
}
private function downloadInvoicePDF(array $ids)
{
$invoices = Invoice::whereIn('id', $ids)
->whereClientId(auth()->user()->client->id)
->get()
->filter(function ($invoice){
return $invoice->isPayable();
});
//generate pdf's of invoices locally
//if only 1 pdf, output to buffer for download
//if multiple pdf's, output to zip stream using Barracuda lib
/*
$zip = Archive::instance_by_useragent(date('Y-m-d') . '_' . str_replace(' ', '_', trans('texts.invoices')));
$zip->add_file($name, $document->getRaw());
$zip->finish();
*/
}
}