2019-07-22 05:54:34 +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
|
|
|
|
*/
|
|
|
|
|
2019-07-23 01:25:53 +02:00
|
|
|
namespace App\Http\Controllers\ClientPortal;
|
2019-07-22 05:54:34 +02:00
|
|
|
|
|
|
|
use App\Filters\InvoiceFilters;
|
2019-07-23 05:31:53 +02:00
|
|
|
use App\Http\Controllers\Controller;
|
2019-07-22 05:54:34 +02:00
|
|
|
use App\Jobs\Entity\ActionEntity;
|
|
|
|
use App\Models\Invoice;
|
|
|
|
use App\Repositories\BaseRepository;
|
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
use Illuminate\Http\Request;
|
2019-07-26 00:05:13 +02:00
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
use Yajra\DataTables\Facades\DataTables;
|
2019-07-25 06:51:00 +02:00
|
|
|
use Yajra\DataTables\Html\Builder;
|
2019-07-22 05:54:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class InvoiceController
|
|
|
|
* @package App\Http\Controllers\ClientPortal\InvoiceController
|
|
|
|
*/
|
|
|
|
|
2019-07-23 05:31:53 +02:00
|
|
|
class InvoiceController extends Controller
|
2019-07-22 05:54:34 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
use MakesHash;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the list of Invoices
|
|
|
|
*
|
|
|
|
* @param \App\Filters\InvoiceFilters $filters The filters
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
2019-07-25 06:51:00 +02:00
|
|
|
public function index(InvoiceFilters $filters, Builder $builder)
|
2019-07-22 05:54:34 +02:00
|
|
|
{
|
2019-07-26 00:19:01 +02:00
|
|
|
$invoices = Invoice::filter($filters);
|
|
|
|
|
2019-07-25 06:51:00 +02:00
|
|
|
if (request()->ajax()) {
|
2019-07-26 00:19:01 +02:00
|
|
|
|
|
|
|
return DataTables::of(Invoice::filter($filters))->addColumn('action', function ($invoice) {
|
2019-07-29 05:59:28 +02:00
|
|
|
return '<a href="/client/invoices/'. $invoice->hashed_id .'/edit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
|
2019-07-26 00:05:13 +02:00
|
|
|
})
|
|
|
|
->addColumn('checkbox', function ($invoice){
|
2019-07-29 05:59:28 +02:00
|
|
|
return '<input type="checkbox" name="bulk" value="'. $invoice->hashed_id .'"/>';
|
2019-07-26 00:05:13 +02:00
|
|
|
})
|
|
|
|
->rawColumns(['checkbox', 'action'])
|
2019-07-25 06:51:00 +02:00
|
|
|
->make(true);
|
2019-07-26 00:19:01 +02:00
|
|
|
|
2019-07-25 06:51:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$builder->addAction();
|
|
|
|
$builder->addCheckbox();
|
|
|
|
|
2019-07-29 05:59:28 +02:00
|
|
|
/**todo this is redundant, but keep in case we want to build this serverside*/
|
2019-07-25 06:51:00 +02:00
|
|
|
$html = $builder->columns([
|
|
|
|
['data' => 'checkbox', 'name' => 'checkbox', 'title' => '', 'searchable' => false, 'orderable' => false],
|
|
|
|
['data' => 'invoice_number', 'name' => 'invoice_number', 'title' => trans('texts.invoice_number'), 'visible'=> true],
|
2019-07-26 00:19:01 +02:00
|
|
|
['data' => 'invoice_date', 'name' => 'invoice_date', 'title' => trans('texts.invoice_date'), 'visible'=> true],
|
|
|
|
['data' => 'amount', 'name' => 'amount', 'title' => trans('texts.total'), 'visible'=> true],
|
|
|
|
['data' => 'balance', 'name' => 'balance', 'title' => trans('texts.balance'), 'visible'=> true],
|
|
|
|
['data' => 'due_date', 'name' => 'due_date', 'title' => trans('texts.due_date'), 'visible'=> true],
|
|
|
|
['data' => 'status_id', 'name' => 'status_id', 'title' => trans('texts.status'), 'visible'=> true],
|
2019-07-26 00:05:13 +02:00
|
|
|
['data' => 'action', 'name' => 'action', 'title' => '', 'searchable' => false, 'orderable' => false],
|
2019-07-25 06:51:00 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
$builder->ajax([
|
|
|
|
'url' => route('client.invoices.index'),
|
|
|
|
'type' => 'GET',
|
|
|
|
'data' => 'function(d) { d.key = "value"; }',
|
|
|
|
]);
|
|
|
|
|
|
|
|
$data['html'] = $html;
|
2019-07-22 05:54:34 +02:00
|
|
|
|
2019-07-25 06:51:00 +02:00
|
|
|
return view('portal.default.invoices.index', $data);
|
2019-07-22 05:54:34 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the specified resource.
|
|
|
|
*
|
|
|
|
* @param \App\Models\Invoice $invoice The invoice
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function show(Invoice $invoice)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Perform bulk actions on the list view
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function bulk()
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|