mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 12:42:36 +01:00
Fix expense datatable on client overview
This commit is contained in:
parent
4bd2b22bcb
commit
f65a6de202
@ -69,6 +69,11 @@ class ExpenseController extends BaseController
|
||||
return $this->expenseService->getDatatableVendor($vendorPublicId);
|
||||
}
|
||||
|
||||
public function getDatatableClient($clientPublicId = null)
|
||||
{
|
||||
return $this->expenseService->getDatatableClient($clientPublicId);
|
||||
}
|
||||
|
||||
public function create(ExpenseRequest $request)
|
||||
{
|
||||
if ($request->vendor_id != 0) {
|
||||
|
@ -5,6 +5,7 @@ namespace App\Ninja\Repositories;
|
||||
use App\Models\Document;
|
||||
use App\Models\Expense;
|
||||
use App\Models\Vendor;
|
||||
use App\Models\Client;
|
||||
use Auth;
|
||||
use DB;
|
||||
use Utils;
|
||||
@ -42,6 +43,15 @@ class ExpenseRepository extends BaseRepository
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function findClient($clientPublicId)
|
||||
{
|
||||
$clientId = Client::getPrivateId($clientPublicId);
|
||||
|
||||
$query = $this->find()->where('expenses.client_id', '=', $clientId);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function find($filter = null)
|
||||
{
|
||||
$accountid = \Auth::user()->account_id;
|
||||
|
@ -96,4 +96,22 @@ class ExpenseService extends BaseService
|
||||
|
||||
return $this->datatableService->createDatatable($datatable, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $clientPublicId
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function getDatatableClient($clientPublicId)
|
||||
{
|
||||
$datatable = new ExpenseDatatable(true, true);
|
||||
|
||||
$query = $this->expenseRepo->findClient($clientPublicId);
|
||||
|
||||
if (! Utils::hasPermission('view_all')) {
|
||||
$query->where('expenses.user_id', '=', Auth::user()->id);
|
||||
}
|
||||
|
||||
return $this->datatableService->createDatatable($datatable, $query);
|
||||
}
|
||||
}
|
||||
|
@ -283,6 +283,7 @@
|
||||
'entityType' => ENTITY_TASK,
|
||||
'datatable' => new \App\Ninja\Datatables\TaskDatatable(true, true),
|
||||
'clientId' => $client->public_id,
|
||||
'url' => url('api/tasks/' . $client->public_id),
|
||||
])
|
||||
</div>
|
||||
@endif
|
||||
@ -293,6 +294,7 @@
|
||||
'entityType' => ENTITY_EXPENSE,
|
||||
'datatable' => new \App\Ninja\Datatables\ExpenseDatatable(true, true),
|
||||
'clientId' => $client->public_id,
|
||||
'url' => url('api/client_expenses/' . $client->public_id),
|
||||
])
|
||||
</div>
|
||||
@endif
|
||||
@ -303,6 +305,7 @@
|
||||
'entityType' => ENTITY_QUOTE,
|
||||
'datatable' => new \App\Ninja\Datatables\InvoiceDatatable(true, true, ENTITY_QUOTE),
|
||||
'clientId' => $client->public_id,
|
||||
'url' => url('api/quotes/' . $client->public_id),
|
||||
])
|
||||
</div>
|
||||
@endif
|
||||
@ -313,6 +316,7 @@
|
||||
'entityType' => ENTITY_RECURRING_INVOICE,
|
||||
'datatable' => new \App\Ninja\Datatables\RecurringInvoiceDatatable(true, true),
|
||||
'clientId' => $client->public_id,
|
||||
'url' => url('api/recurring_invoices/' . $client->public_id),
|
||||
])
|
||||
</div>
|
||||
@endif
|
||||
@ -322,6 +326,7 @@
|
||||
'entityType' => ENTITY_INVOICE,
|
||||
'datatable' => new \App\Ninja\Datatables\InvoiceDatatable(true, true),
|
||||
'clientId' => $client->public_id,
|
||||
'url' => url('api/invoices/' . $client->public_id),
|
||||
])
|
||||
</div>
|
||||
|
||||
@ -330,6 +335,7 @@
|
||||
'entityType' => ENTITY_PAYMENT,
|
||||
'datatable' => new \App\Ninja\Datatables\PaymentDatatable(true, true),
|
||||
'clientId' => $client->public_id,
|
||||
'url' => url('api/payments/' . $client->public_id),
|
||||
])
|
||||
</div>
|
||||
|
||||
@ -339,6 +345,7 @@
|
||||
'entityType' => ENTITY_CREDIT,
|
||||
'datatable' => new \App\Ninja\Datatables\CreditDatatable(true, true),
|
||||
'clientId' => $client->public_id,
|
||||
'url' => url('api/credits/' . $client->public_id),
|
||||
])
|
||||
</div>
|
||||
@endif
|
||||
|
@ -131,7 +131,7 @@
|
||||
|
||||
{!! Datatable::table()
|
||||
->addColumn(Utils::trans($datatable->columnFields(), $datatable->entityType))
|
||||
->setUrl(url('api/' . Utils::pluralizeEntityType($entityType) . '/' . (isset($clientId) ? (isset($projectId) ? ($clientId . '/' . $projectId) : $clientId) : (isset($vendorId) ? $vendorId : ''))))
|
||||
->setUrl(empty($url) ? url('api/' . Utils::pluralizeEntityType($entityType)) : $url)
|
||||
->setCustomValues('entityType', Utils::pluralizeEntityType($entityType))
|
||||
->setCustomValues('clientId', isset($clientId) && $clientId && empty($projectId))
|
||||
->setOptions('sPaginationType', 'bootstrap')
|
||||
|
@ -126,6 +126,7 @@
|
||||
'datatable' => new \App\Ninja\Datatables\ProjectTaskDatatable(true, true),
|
||||
'projectId' => $project->public_id,
|
||||
'clientId' => $project->client->public_id,
|
||||
'url' => url('api/tasks/' . $project->client->public_id . '/' . $project->public_id),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
1
resources/views/vendors/show.blade.php
vendored
1
resources/views/vendors/show.blade.php
vendored
@ -190,6 +190,7 @@
|
||||
'entityType' => ENTITY_EXPENSE,
|
||||
'datatable' => new \App\Ninja\Datatables\ExpenseDatatable(true, true),
|
||||
'vendorId' => $vendor->public_id,
|
||||
'url' => url('api/vendor_expenses/' . $vendor->public_id),
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
|
@ -269,7 +269,8 @@ Route::group(['middleware' => ['lookup:user', 'auth:user']], function () {
|
||||
Route::get('expenses/create/{vendor_id?}/{client_id?}/{category_id?}', 'ExpenseController@create');
|
||||
Route::get('expenses/{expenses}/clone', 'ExpenseController@cloneExpense');
|
||||
Route::get('api/expenses', 'ExpenseController@getDatatable');
|
||||
Route::get('api/expenses/{id}', 'ExpenseController@getDatatableVendor');
|
||||
Route::get('api/vendor_expenses/{id}', 'ExpenseController@getDatatableVendor');
|
||||
Route::get('api/client_expenses/{id}', 'ExpenseController@getDatatableClient');
|
||||
Route::post('expenses/bulk', 'ExpenseController@bulk');
|
||||
Route::get('expense_categories', 'ExpenseCategoryController@index');
|
||||
Route::get('api/expense_categories', 'ExpenseCategoryController@getDatatable');
|
||||
|
Loading…
Reference in New Issue
Block a user