diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index 55e7c8c1ed..0682c1fd7e 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -46,7 +46,6 @@ class ClientController extends BaseController 'entityType' => ENTITY_CLIENT, 'datatable' => new ClientDatatable(), 'title' => trans('texts.clients'), - 'sortCol' => '4', 'statuses' => Client::getStatuses(), ]); } diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php index a192e34496..7634ffb1e2 100644 --- a/app/Http/Controllers/CreditController.php +++ b/app/Http/Controllers/CreditController.php @@ -38,7 +38,6 @@ class CreditController extends BaseController 'entityType' => ENTITY_CREDIT, 'datatable' => new CreditDatatable(), 'title' => trans('texts.credits'), - 'sortCol' => '4', ]); } diff --git a/app/Http/Controllers/ExpenseCategoryController.php b/app/Http/Controllers/ExpenseCategoryController.php index 283ab03462..63e1851677 100644 --- a/app/Http/Controllers/ExpenseCategoryController.php +++ b/app/Http/Controllers/ExpenseCategoryController.php @@ -32,7 +32,6 @@ class ExpenseCategoryController extends BaseController return View::make('list', [ 'entityType' => ENTITY_EXPENSE_CATEGORY, 'title' => trans('texts.expense_categories'), - 'sortCol' => '1', 'columns' => Utils::trans([ 'checkbox', 'name', diff --git a/app/Http/routes.php b/app/Http/routes.php index 71ddb0b107..7a3b5100c7 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -138,22 +138,22 @@ Route::group(['middleware' => 'auth:user'], function() { Route::post('users/change_password', 'UserController@changePassword'); Route::resource('clients', 'ClientController'); - Route::get('api/clients', ['as'=>'api.clients', 'uses'=>'ClientController@getDatatable']); - Route::get('api/activities/{client_id?}', ['as'=>'api.activities', 'uses'=>'ActivityController@getDatatable']); + Route::get('api/clients', 'ClientController@getDatatable'); + Route::get('api/activities/{client_id?}', 'ActivityController@getDatatable'); Route::post('clients/bulk', 'ClientController@bulk'); Route::resource('tasks', 'TaskController'); - Route::get('api/tasks/{client_id?}', ['as'=>'api.tasks', 'uses'=>'TaskController@getDatatable']); + Route::get('api/tasks/{client_id?}', 'TaskController@getDatatable'); Route::get('tasks/create/{client_id?}', 'TaskController@create'); Route::post('tasks/bulk', 'TaskController@bulk'); - Route::get('api/recurring_invoices/{client_id?}', ['as'=>'api.recurring_invoices', 'uses'=>'InvoiceController@getRecurringDatatable']); + Route::get('api/recurring_invoices/{client_id?}', 'InvoiceController@getRecurringDatatable'); Route::get('invoices/invoice_history/{invoice_id}', 'InvoiceController@invoiceHistory'); Route::get('quotes/quote_history/{invoice_id}', 'InvoiceController@invoiceHistory'); Route::resource('invoices', 'InvoiceController'); - Route::get('api/invoices/{client_id?}', ['as'=>'api.invoices', 'uses'=>'InvoiceController@getDatatable']); + Route::get('api/invoices/{client_id?}', 'InvoiceController@getDatatable'); Route::get('invoices/create/{client_id?}', 'InvoiceController@create'); Route::get('recurring_invoices/create/{client_id?}', 'InvoiceController@createRecurring'); Route::get('recurring_invoices', 'RecurringInvoiceController@index'); @@ -175,20 +175,20 @@ Route::group(['middleware' => 'auth:user'], function() { Route::get('quotes/{invoices}', 'InvoiceController@edit'); Route::post('quotes', 'InvoiceController@store'); Route::get('quotes', 'QuoteController@index'); - Route::get('api/quotes/{client_id?}', ['as'=>'api.quotes', 'uses'=>'QuoteController@getDatatable']); + Route::get('api/quotes/{client_id?}', 'QuoteController@getDatatable'); Route::post('quotes/bulk', 'QuoteController@bulk'); Route::resource('payments', 'PaymentController'); Route::get('payments/create/{client_id?}/{invoice_id?}', 'PaymentController@create'); - Route::get('api/payments/{client_id?}', ['as'=>'api.payments', 'uses'=>'PaymentController@getDatatable']); + Route::get('api/payments/{client_id?}', 'PaymentController@getDatatable'); Route::post('payments/bulk', 'PaymentController@bulk'); Route::resource('credits', 'CreditController'); Route::get('credits/create/{client_id?}/{invoice_id?}', 'CreditController@create'); - Route::get('api/credits/{client_id?}', ['as'=>'api.credits', 'uses'=>'CreditController@getDatatable']); + Route::get('api/credits/{client_id?}', 'CreditController@getDatatable'); Route::post('credits/bulk', 'CreditController@bulk'); - Route::get('api/products', ['as'=>'api.products', 'uses'=>'ProductController@getDatatable']); + Route::get('api/products', 'ProductController@getDatatable'); Route::resource('products', 'ProductController'); Route::post('products/bulk', 'ProductController@bulk'); @@ -199,17 +199,17 @@ Route::group(['middleware' => 'auth:user'], function() { // vendor Route::resource('vendors', 'VendorController'); - Route::get('api/vendor', ['as'=>'api.vendors', 'uses'=>'VendorController@getDatatable']); + Route::get('api/vendors', 'VendorController@getDatatable'); Route::post('vendors/bulk', 'VendorController@bulk'); // Expense Route::resource('expenses', 'ExpenseController'); Route::get('expenses/create/{vendor_id?}/{client_id?}', 'ExpenseController@create'); - Route::get('api/expense', ['as'=>'api.expenses', 'uses'=>'ExpenseController@getDatatable']); - Route::get('api/vendor_expense/{id}', ['as'=>'api.expense', 'uses'=>'ExpenseController@getDatatableVendor']); + Route::get('api/expenses', 'ExpenseController@getDatatable'); + Route::get('api/vendor_expenses/{id}', 'ExpenseController@getDatatableVendor'); Route::post('expenses/bulk', 'ExpenseController@bulk'); Route::get('expense_categories', 'ExpenseCategoryController@index'); - Route::get('api/expense_categories', ['as'=>'api.expense_categories', 'uses'=>'ExpenseCategoryController@getDatatable']); + Route::get('api/expense_categories', 'ExpenseCategoryController@getDatatable'); Route::get('expense_categories/create', 'ExpenseCategoryController@create'); Route::post('expense_categories', 'ExpenseCategoryController@store'); Route::put('expense_categories/{expense_categories}', 'ExpenseCategoryController@update'); @@ -226,7 +226,7 @@ Route::group([ 'middleware' => ['auth:user', 'permissions.required'], 'permissions' => 'admin', ], function() { - Route::get('api/users', ['as'=>'api.users', 'uses'=>'UserController@getDatatable']); + Route::get('api/users', 'UserController@getDatatable'); Route::resource('users', 'UserController'); Route::post('users/bulk', 'UserController@bulk'); Route::get('send_confirmation/{user_id}', 'UserController@sendConfirmation'); @@ -236,11 +236,11 @@ Route::group([ Route::get('/unlink_account/{user_account_id}/{user_id}', 'UserController@unlinkAccount'); Route::get('/manage_companies', 'UserController@manageCompanies'); - Route::get('api/tokens', ['as'=>'api.tokens', 'uses'=>'TokenController@getDatatable']); + Route::get('api/tokens', 'TokenController@getDatatable'); Route::resource('tokens', 'TokenController'); Route::post('tokens/bulk', 'TokenController@bulk'); - Route::get('api/tax_rates', ['as'=>'api.tax_rates', 'uses'=>'TaxRateController@getDatatable']); + Route::get('api/tax_rates', 'TaxRateController@getDatatable'); Route::resource('tax_rates', 'TaxRateController'); Route::post('tax_rates/bulk', 'TaxRateController@bulk'); @@ -265,13 +265,13 @@ Route::group([ Route::get('gateways/create/{show_wepay?}', 'AccountGatewayController@create'); Route::resource('gateways', 'AccountGatewayController'); Route::get('gateways/{public_id}/resend_confirmation', 'AccountGatewayController@resendConfirmation'); - Route::get('api/gateways', ['as'=>'api.gateways', 'uses'=>'AccountGatewayController@getDatatable']); + Route::get('api/gateways', 'AccountGatewayController@getDatatable'); Route::post('account_gateways/bulk', 'AccountGatewayController@bulk'); Route::get('bank_accounts/import_ofx', 'BankAccountController@showImportOFX'); Route::post('bank_accounts/import_ofx', 'BankAccountController@doImportOFX'); Route::resource('bank_accounts', 'BankAccountController'); - Route::get('api/bank_accounts', ['as'=>'api.bank_accounts', 'uses'=>'BankAccountController@getDatatable']); + Route::get('api/bank_accounts', 'BankAccountController@getDatatable'); Route::post('bank_accounts/bulk', 'BankAccountController@bulk'); Route::post('bank_accounts/validate', 'BankAccountController@validateAccount'); Route::post('bank_accounts/import_expenses/{bank_id}', 'BankAccountController@importExpenses'); diff --git a/app/Ninja/Datatables/ClientDatatable.php b/app/Ninja/Datatables/ClientDatatable.php index b8c0602eed..bbad2be036 100644 --- a/app/Ninja/Datatables/ClientDatatable.php +++ b/app/Ninja/Datatables/ClientDatatable.php @@ -7,6 +7,7 @@ use Auth; class ClientDatatable extends EntityDatatable { public $entityType = ENTITY_CLIENT; + public $sortCol = 4; public function columns() { diff --git a/app/Ninja/Datatables/CreditDatatable.php b/app/Ninja/Datatables/CreditDatatable.php index 7f258e377d..c27bf8466f 100644 --- a/app/Ninja/Datatables/CreditDatatable.php +++ b/app/Ninja/Datatables/CreditDatatable.php @@ -7,7 +7,8 @@ use Auth; class CreditDatatable extends EntityDatatable { public $entityType = ENTITY_CREDIT; - + public $sortCol = 4; + public function columns() { return [ diff --git a/app/Ninja/Datatables/EntityDatatable.php b/app/Ninja/Datatables/EntityDatatable.php index 0fc2b5a3d5..0631f6eb3e 100644 --- a/app/Ninja/Datatables/EntityDatatable.php +++ b/app/Ninja/Datatables/EntityDatatable.php @@ -5,6 +5,7 @@ class EntityDatatable public $entityType; public $isBulkEdit; public $hideClient; + public $sortCol = 1; public function __construct($isBulkEdit = true, $hideClient = false, $entityType = false) { diff --git a/app/Ninja/Datatables/ExpenseCategoryDatatable.php b/app/Ninja/Datatables/ExpenseCategoryDatatable.php index 7ef850b0a4..82206b8f8c 100644 --- a/app/Ninja/Datatables/ExpenseCategoryDatatable.php +++ b/app/Ninja/Datatables/ExpenseCategoryDatatable.php @@ -7,6 +7,7 @@ use Auth; class ExpenseCategoryDatatable extends EntityDatatable { public $entityType = ENTITY_EXPENSE_CATEGORY; + public $sortCol = 1; public function columns() { diff --git a/resources/views/datatable.blade.php b/resources/views/datatable.blade.php index 03d1e42635..91a135b30f 100644 --- a/resources/views/datatable.blade.php +++ b/resources/views/datatable.blade.php @@ -60,7 +60,6 @@ }, "bAutoWidth": false, @if (isset($hasCheckboxes) && $hasCheckboxes) - 'aaSorting': [['1', 'asc']], // Disable sorting on the first column "aoColumnDefs": [ { diff --git a/resources/views/list.blade.php b/resources/views/list.blade.php index dde9679a8e..3480774240 100644 --- a/resources/views/list.blade.php +++ b/resources/views/list.blade.php @@ -71,7 +71,7 @@ ->setCustomValues('entityType', Utils::pluralizeEntityType($entityType)) ->setCustomValues('clientId', isset($clientId) && $clientId) ->setOptions('sPaginationType', 'bootstrap') - ->setOptions('aaSorting', [[isset($sortCol) ? $sortCol : '1', 'desc']]) + ->setOptions('aaSorting', [[$datatable->sortCol, 'desc']]) ->render('datatable') !!} @if ($entityType == ENTITY_PAYMENT)