1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/app/Http/Controllers/ClientPortal/RecurringInvoiceController.php

83 lines
2.4 KiB
PHP
Raw Normal View History

2019-08-15 06:31:03 +02:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
namespace App\Http\Controllers\ClientPortal;
use App\Http\Controllers\Controller;
use App\Models\RecurringInvoice;
use App\Utils\Traits\MakesHash;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Yajra\DataTables\Facades\DataTables;
use Yajra\DataTables\Html\Builder;
/**
* Class InvoiceController
* @package App\Http\Controllers\ClientPortal\InvoiceController
*/
class RecurringInvoiceController extends Controller
{
use MakesHash;
/**
* Show the list of Invoices
*
* @param \App\Filters\InvoiceFilters $filters The filters
*
* @return \Illuminate\Http\Response
*/
2019-08-15 13:10:02 +02:00
public function index(Builder $builder)
2019-08-15 07:19:00 +02:00
{
2019-08-15 13:10:02 +02:00
$invoices = RecurringInvoice::whereClientId(auth()->user()->client->id)
->whereIn('status_id', [RecurringInvoice::STATUS_PENDING, RecurringInvoice::STATUS_ACTIVE, RecurringInvoice::STATUS_COMPLETED])
->orderBy('status_id', 'asc')
->get();
2019-08-15 06:31:03 +02:00
if (request()->ajax()) {
2019-08-15 07:19:00 +02:00
return DataTables::of($invoices)->addColumn('action', function ($invoice) {
2019-08-15 06:31:03 +02:00
return '<a href="/client/recurring_invoices/'. $invoice->hashed_id .'/edit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i>'.ctrans('texts.view').'</a>';
2019-08-15 13:10:02 +02:00
})->addColumn('frequency_id', function ($invoice) {
return RecurringInvoice::frequencyForKey($invoice->frequency_id);
2019-08-15 06:31:03 +02:00
})
->editColumn('status_id', function ($invoice){
2019-08-15 13:10:02 +02:00
return RecurringInvoice::badgeForStatus($invoice->status);
2019-08-15 06:31:03 +02:00
})
2019-08-15 13:10:02 +02:00
->rawColumns(['action', 'status_id'])
2019-08-15 06:31:03 +02:00
->make(true);
}
$data['html'] = $builder;
return view('portal.default.recurring_invoices.index', $data);
}
/**
* Display the specified resource.
*
* @param \App\Models\Invoice $invoice The invoice
*
* @return \Illuminate\Http\Response
*/
public function show(RecurringInvoice $invoice)
{
}
}