1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 05:32:39 +01:00
invoiceninja/app/Http/Controllers/ClientPortal/InvoiceController.php

114 lines
3.4 KiB
PHP
Raw Normal View History

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
*/
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);
Log::error('invoice count = ...');
Log::error($invoices->count());
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-26 00:05:13 +02:00
return '<a href="/client/invoices/'. $invoice->id .'/edit" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
})
->addColumn('checkbox', function ($invoice){
return '<input type="checkbox" name="bulk" value="'. $invoice->id .'"/>';
})
->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();
$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()
{
}
}