akaunting 3.0 (the last dance)
This commit is contained in:
@ -5,7 +5,6 @@ namespace App\Http\Controllers\Portal;
|
||||
use App\Abstracts\Http\Controller;
|
||||
use App\Http\Requests\Portal\InvoiceShow as Request;
|
||||
use App\Models\Document\Document;
|
||||
use App\Models\Setting\Category;
|
||||
use App\Traits\Currencies;
|
||||
use App\Traits\DateTime;
|
||||
use App\Traits\Documents;
|
||||
@ -33,11 +32,7 @@ class Invoices extends Controller
|
||||
->accrued()->where('contact_id', user()->contact->id)
|
||||
->collect(['document_number'=> 'desc']);
|
||||
|
||||
$categories = collect(Category::income()->enabled()->orderBy('name')->pluck('name', 'id'));
|
||||
|
||||
$statuses = $this->getDocumentStatuses(Document::INVOICE_TYPE);
|
||||
|
||||
return $this->response('portal.invoices.index', compact('invoices', 'categories', 'statuses'));
|
||||
return $this->response('portal.invoices.index', compact('invoices'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,6 +51,20 @@ class Invoices extends Controller
|
||||
return view('portal.invoices.show', compact('invoice', 'payment_methods'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for viewing the specified resource.
|
||||
*
|
||||
* @param Document $invoice
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function finish(Document $invoice, Request $request)
|
||||
{
|
||||
$layout = $request->isPortal($invoice->company_id) ? 'portal' : 'signed';
|
||||
|
||||
return view('portal.invoices.finish', compact('invoice', 'layout'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for viewing the specified resource.
|
||||
*
|
||||
@ -98,6 +107,27 @@ class Invoices extends Controller
|
||||
return $pdf->download($file_name);
|
||||
}
|
||||
|
||||
public function preview(Document $invoice)
|
||||
{
|
||||
if (empty($invoice)) {
|
||||
return redirect()->route('login');
|
||||
}
|
||||
|
||||
$payment_actions = [];
|
||||
|
||||
$payment_methods = Modules::getPaymentMethods();
|
||||
|
||||
foreach ($payment_methods as $payment_method_key => $payment_method_value) {
|
||||
$codes = explode('.', $payment_method_key);
|
||||
|
||||
if (!isset($payment_actions[$codes[0]])) {
|
||||
$payment_actions[$codes[0]] = URL::signedRoute('signed.' . $codes[0] . '.invoices.show', [$invoice->id]);
|
||||
}
|
||||
}
|
||||
|
||||
return view('portal.invoices.preview', compact('invoice', 'payment_methods', 'payment_actions'));
|
||||
}
|
||||
|
||||
public function signed(Document $invoice)
|
||||
{
|
||||
if (empty($invoice)) {
|
||||
@ -119,7 +149,10 @@ class Invoices extends Controller
|
||||
$print_action = URL::signedRoute('signed.invoices.print', [$invoice->id]);
|
||||
$pdf_action = URL::signedRoute('signed.invoices.pdf', [$invoice->id]);
|
||||
|
||||
event(new \App\Events\Document\DocumentViewed($invoice));
|
||||
// Guest or Invoice contact user track the invoice viewed.
|
||||
if (empty(user()) || user()->id == $invoice->contact->user_id) {
|
||||
event(new \App\Events\Document\DocumentViewed($invoice));
|
||||
}
|
||||
|
||||
return view('portal.invoices.signed', compact('invoice', 'payment_methods', 'payment_actions', 'print_action', 'pdf_action'));
|
||||
}
|
||||
|
Reference in New Issue
Block a user