diff --git a/app/Http/Controllers/JsonController.php b/app/Http/Controllers/JsonController.php index 5f1bb43549..d741936111 100644 --- a/app/Http/Controllers/JsonController.php +++ b/app/Http/Controllers/JsonController.php @@ -10,7 +10,8 @@ use Input; use Preferences; use Response; use Session; - +use Config; +use FireflyIII\Models\TransactionType; /** * Class JsonController * @@ -19,7 +20,6 @@ use Session; class JsonController extends Controller { - /** * */ @@ -156,16 +156,6 @@ class JsonController extends Controller } - /** - * @return \Symfony\Component\HttpFoundation\Response - */ - public function showSharedReports() - { - $pref = Preferences::get('showSharedReports', false); - - return Response::json(['value' => $pref->data]); - } - /** * @return \Symfony\Component\HttpFoundation\Response */ @@ -179,4 +169,31 @@ class JsonController extends Controller return Response::json(['value' => $new]); } + /** + * @return \Symfony\Component\HttpFoundation\Response + */ + public function showSharedReports() + { + $pref = Preferences::get('showSharedReports', false); + + return Response::json(['value' => $pref->data]); + } + + public function transactionJournals($what) + { + $descriptions = []; + $dbType = TransactionType::whereType($what)->first(); + $journals = Auth::user()->transactionjournals()->where('transaction_type_id', $dbType->id) + ->orderBy('id','DESC')->take(50) + ->get(); + foreach($journals as $j) { + $descriptions[] = $j->description; + } + + $descriptions = array_unique($descriptions); + return Response::json($descriptions); + + + } + } diff --git a/app/Http/routes.php b/app/Http/routes.php index 299799ea5b..cf1bb3f2e3 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -261,6 +261,7 @@ Route::group( Route::get('/json/categories', ['uses' => 'JsonController@categories', 'as' => 'json.categories']); Route::get('/json/box', ['uses' => 'JsonController@box', 'as' => 'json.box']); Route::get('/json/show-shared-reports', 'JsonController@showSharedReports'); + Route::get('/json/transaction-journals/{what}', 'JsonController@transactionJournals'); Route::get('/json/show-shared-reports/set', 'JsonController@setSharedReports'); diff --git a/config/firefly.php b/config/firefly.php index 6d9714f9a3..da0ceee692 100644 --- a/config/firefly.php +++ b/config/firefly.php @@ -73,9 +73,9 @@ return [ ], 'accountTypeByIdentifier' => [ - 'asset' => 'Asset account', - 'expense' => 'Expense account', - 'revenue' => 'Revenue account', + 'asset' => 'Asset account', + 'expense' => 'Expense account', + 'revenue' => 'Revenue account' ], 'shortNamesByFullName' => [ diff --git a/favicon.pxm b/favicon.pxm index 03998f3b15..18998b1f1c 100644 Binary files a/favicon.pxm and b/favicon.pxm differ diff --git a/public/js/transactions.js b/public/js/transactions.js index b607a98cd1..9a5eee1356 100644 --- a/public/js/transactions.js +++ b/public/js/transactions.js @@ -8,6 +8,16 @@ if ($('input[name="revenue_account"]').length > 0) { $('input[name="revenue_account"]').typeahead({source: data}); }); } + +if ($('input[name="description"]').length > 0 && what != undefined) { + $.getJSON('json/transaction-journals/' + what).success(function (data) { + $('input[name="description"]').typeahead({source: data}); + }); +} + + + + if ($('input[name="category"]').length > 0) { $.getJSON('json/categories').success(function (data) { $('input[name="category"]').typeahead({source: data}); diff --git a/resources/views/transactions/create.blade.php b/resources/views/transactions/create.blade.php index ece7b4478f..d56f5b2cd3 100644 --- a/resources/views/transactions/create.blade.php +++ b/resources/views/transactions/create.blade.php @@ -92,6 +92,9 @@ @stop @section('scripts') + @stop