New JSON routes and code.

This commit is contained in:
James Cole
2014-09-12 17:28:58 +02:00
parent decad6830b
commit 15ef0bab1d
2 changed files with 22 additions and 4 deletions

View File

@@ -1,5 +1,8 @@
$.getJSON('json/beneficiaries').success(function (data) {
$('input[name="beneficiary"]').typeahead({ source: data });
$.getJSON('json/expense-accounts').success(function (data) {
$('input[name="expense_account"]').typeahead({ source: data });
});
$.getJSON('json/revenue-accounts').success(function (data) {
$('input[name="revenue_account"]').typeahead({ source: data });
});
$.getJSON('json/categories').success(function (data) {

View File

@@ -34,9 +34,24 @@ class JsonController extends BaseController
/**
* Returns a JSON list of all beneficiaries.
*/
public function beneficiaries()
public function expenseAccounts()
{
$list = $this->_accounts->getBeneficiaries();
$list = $this->_accounts->getOfTypes(['Expense account','Beneficiary account']);
$return = [];
foreach ($list as $entry) {
$return[] = $entry->name;
}
return Response::json($return);
}
/**
* Returns a JSON list of all revenue accounts.
*/
public function revenueAccounts()
{
$list = $this->_accounts->getOfTypes(['Revenue account']);
$return = [];
foreach ($list as $entry) {
$return[] = $entry->name;