mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-11-27 03:10:32 -06:00
Code clean up and reformat.
This commit is contained in:
parent
2e2c12d6a4
commit
258d6a1688
@ -18,38 +18,6 @@ class AccountController extends BaseController
|
||||
View::share('title', 'Accounts');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $what
|
||||
*
|
||||
* @return View
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function index($what = 'default')
|
||||
{
|
||||
switch ($what) {
|
||||
default:
|
||||
throw new FireflyException('Cannot handle account type "' . e($what) . '".');
|
||||
break;
|
||||
case 'asset':
|
||||
$subTitleIcon = 'fa-money';
|
||||
$subTitle = 'Asset accounts';
|
||||
break;
|
||||
case 'expense':
|
||||
$subTitleIcon = 'fa-shopping-cart';
|
||||
$subTitle = 'Expense accounts';
|
||||
break;
|
||||
case 'revenue':
|
||||
$subTitleIcon = 'fa-download';
|
||||
$subTitle = 'Revenue accounts';
|
||||
break;
|
||||
}
|
||||
return View::make('accounts.index')
|
||||
->with('what', $what)
|
||||
->with(compact('subTitleIcon'))
|
||||
->with(compact('subTitle'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
@ -67,10 +35,7 @@ class AccountController extends BaseController
|
||||
break;
|
||||
}
|
||||
|
||||
return View::make('accounts.create')
|
||||
->with('subTitle', 'Create a new ' . $what . ' account')
|
||||
->with('what', $what)
|
||||
->with(compact('subTitleIcon'));
|
||||
return View::make('accounts.create')->with('subTitle', 'Create a new ' . $what . ' account')->with('what', $what)->with(compact('subTitleIcon'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,10 +45,9 @@ class AccountController extends BaseController
|
||||
*/
|
||||
public function delete(Account $account)
|
||||
{
|
||||
return View::make('accounts.delete')->with('account', $account)
|
||||
->with(
|
||||
'subTitle', 'Delete ' . strtolower($account->accountType->type) . ' "' . $account->name . '"'
|
||||
);
|
||||
return View::make('accounts.delete')->with('account', $account)->with(
|
||||
'subTitle', 'Delete ' . strtolower($account->accountType->type) . ' "' . $account->name . '"'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -193,11 +157,40 @@ class AccountController extends BaseController
|
||||
Session::flash('prefilled', $prefilled);
|
||||
}
|
||||
|
||||
return View::make('accounts.edit')
|
||||
->with('account', $account)
|
||||
->with('openingBalance', $openingBalance)
|
||||
->with(compact('subTitleIcon'))
|
||||
->with('subTitle', 'Edit ' . strtolower($account->accountType->type) . ' "' . $account->name . '"');
|
||||
return View::make('accounts.edit')->with('account', $account)->with('openingBalance', $openingBalance)->with(compact('subTitleIcon'))->with(
|
||||
'subTitle', 'Edit ' . strtolower(
|
||||
$account->accountType->type
|
||||
) . ' "' . $account->name . '"'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $what
|
||||
*
|
||||
* @return View
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function index($what = 'default')
|
||||
{
|
||||
switch ($what) {
|
||||
default:
|
||||
throw new FireflyException('Cannot handle account type "' . e($what) . '".');
|
||||
break;
|
||||
case 'asset':
|
||||
$subTitleIcon = 'fa-money';
|
||||
$subTitle = 'Asset accounts';
|
||||
break;
|
||||
case 'expense':
|
||||
$subTitleIcon = 'fa-shopping-cart';
|
||||
$subTitle = 'Expense accounts';
|
||||
break;
|
||||
case 'revenue':
|
||||
$subTitleIcon = 'fa-download';
|
||||
$subTitle = 'Revenue accounts';
|
||||
break;
|
||||
}
|
||||
|
||||
return View::make('accounts.index')->with('what', $what)->with(compact('subTitleIcon'))->with(compact('subTitle'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -223,10 +216,9 @@ class AccountController extends BaseController
|
||||
|
||||
|
||||
//$data = $this->_accounts->show($account, 40);
|
||||
return View::make('accounts.show')
|
||||
->with('account', $account)
|
||||
->with('subTitle', 'Details for ' . strtolower($account->accountType->type) . ' "' . $account->name . '"')
|
||||
->with(compact('subTitleIcon'));
|
||||
return View::make('accounts.show')->with('account', $account)->with(
|
||||
'subTitle', 'Details for ' . strtolower($account->accountType->type) . ' "' . $account->name . '"'
|
||||
)->with(compact('subTitleIcon'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -236,7 +228,7 @@ class AccountController extends BaseController
|
||||
public function store()
|
||||
{
|
||||
|
||||
$data = Input::all();
|
||||
$data = Input::all();
|
||||
$data['what'] = isset($data['what']) && $data['what'] != '' ? $data['what'] : 'asset';
|
||||
/** @var \FireflyIII\Database\Account $acct */
|
||||
$acct = App::make('FireflyIII\Database\Account');
|
||||
@ -253,6 +245,7 @@ class AccountController extends BaseController
|
||||
Session::flash('warnings', $messages['warnings']);
|
||||
Session::flash('successes', $messages['successes']);
|
||||
Session::flash('error', 'Could not save account: ' . $messages['errors']->first());
|
||||
|
||||
return Redirect::route('accounts.create', $data['what'])->withInput()->withErrors($messages['errors']);
|
||||
}
|
||||
// store!
|
||||
@ -270,6 +263,7 @@ class AccountController extends BaseController
|
||||
Session::flash('warnings', $messageBags['warnings']);
|
||||
Session::flash('successes', $messageBags['successes']);
|
||||
Session::flash('errors', $messageBags['errors']);
|
||||
|
||||
return Redirect::route('accounts.create', $data['what'])->withInput();
|
||||
break;
|
||||
}
|
||||
@ -315,6 +309,7 @@ class AccountController extends BaseController
|
||||
Session::flash('warnings', $messages['warnings']);
|
||||
Session::flash('successes', $messages['successes']);
|
||||
Session::flash('error', 'Could not save account: ' . $messages['errors']->first());
|
||||
|
||||
return Redirect::route('accounts.edit', $account->id)->withInput()->withErrors($messages['errors']);
|
||||
}
|
||||
// store!
|
||||
@ -331,6 +326,7 @@ class AccountController extends BaseController
|
||||
Session::flash('warnings', $messageBags['warnings']);
|
||||
Session::flash('successes', $messageBags['successes']);
|
||||
Session::flash('errors', $messageBags['errors']);
|
||||
|
||||
return Redirect::route('accounts.edit', $account->id)->withInput();
|
||||
break;
|
||||
}
|
||||
|
@ -17,20 +17,6 @@ class BudgetController extends BaseController
|
||||
View::share('mainTitleIcon', 'fa-tasks');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function postUpdateIncome()
|
||||
{
|
||||
/** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */
|
||||
$preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface');
|
||||
$date = Session::get('start');
|
||||
|
||||
$value = intval(Input::get('amount'));
|
||||
$preferences->set('budgetIncomeTotal' . $date->format('FY'), $value);
|
||||
return Redirect::route('budgets.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the amount for a budget's limitrepetition and/or create it.
|
||||
*
|
||||
@ -78,6 +64,49 @@ class BudgetController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return View::make('budgets.create')->with('subTitle', 'Create a new budget');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function delete(Budget $budget)
|
||||
{
|
||||
return View::make('budgets.delete')->with('budget', $budget)->with('subTitle', 'Delete budget "' . $budget->name . '"');
|
||||
}
|
||||
|
||||
public function destroy(Budget $budget)
|
||||
{
|
||||
/** @var \FireflyIII\Database\Budget $repos */
|
||||
$repos = App::make('FireflyIII\Database\Budget');
|
||||
// remove budget
|
||||
$repos->destroy($budget);
|
||||
Session::flash('success', 'The budget was deleted.');
|
||||
|
||||
return Redirect::route('budgets.index');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function edit(Budget $budget)
|
||||
{
|
||||
Session::flash('prefilled', ['name' => $budget->name]);
|
||||
|
||||
return View::make('budgets.edit')->with('budget', $budget)->with('subTitle', 'Edit budget "' . $budget->name . '"');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
@ -137,15 +166,18 @@ class BudgetController extends BaseController
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function updateIncome()
|
||||
public function postUpdateIncome()
|
||||
{
|
||||
$date = Session::get('start');
|
||||
/** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */
|
||||
$preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface');
|
||||
$budgetAmount = $preferences->get('budgetIncomeTotal' . $date->format('FY'), 1000);
|
||||
return View::make('budgets.income')->with('amount', $budgetAmount)->with('date', $date);
|
||||
$date = Session::get('start');
|
||||
|
||||
$value = intval(Input::get('amount'));
|
||||
$preferences->set('budgetIncomeTotal' . $date->format('FY'), $value);
|
||||
|
||||
return Redirect::route('budgets.index');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -172,47 +204,6 @@ class BudgetController extends BaseController
|
||||
return View::make('budgets.show', compact('limits', 'budget', 'repetition'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
return View::make('budgets.create')->with('subTitle', 'Create a new budget');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function delete(Budget $budget)
|
||||
{
|
||||
return View::make('budgets.delete')->with('budget', $budget)->with('subTitle', 'Delete budget "' . $budget->name . '"');
|
||||
}
|
||||
|
||||
public function destroy(Budget $budget)
|
||||
{
|
||||
/** @var \FireflyIII\Database\Budget $repos */
|
||||
$repos = App::make('FireflyIII\Database\Budget');
|
||||
// remove budget
|
||||
$repos->destroy($budget);
|
||||
Session::flash('success', 'The budget was deleted.');
|
||||
return Redirect::route('budgets.index');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function edit(Budget $budget)
|
||||
{
|
||||
Session::flash('prefilled', ['name' => $budget->name]);
|
||||
return View::make('budgets.edit')->with('budget', $budget)->with('subTitle', 'Edit budget "' . $budget->name . '"');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
@ -234,6 +225,7 @@ class BudgetController extends BaseController
|
||||
Session::flash('warnings', $messages['warnings']);
|
||||
Session::flash('successes', $messages['successes']);
|
||||
Session::flash('error', 'Could not save budget: ' . $messages['errors']->first());
|
||||
|
||||
return Redirect::route('budgets.create')->withInput()->withErrors($messages['errors']);
|
||||
}
|
||||
// store!
|
||||
@ -251,6 +243,7 @@ class BudgetController extends BaseController
|
||||
Session::flash('warnings', $messageBags['warnings']);
|
||||
Session::flash('successes', $messageBags['successes']);
|
||||
Session::flash('errors', $messageBags['errors']);
|
||||
|
||||
return Redirect::route('budgets.create')->withInput();
|
||||
break;
|
||||
}
|
||||
@ -280,6 +273,7 @@ class BudgetController extends BaseController
|
||||
Session::flash('warnings', $messages['warnings']);
|
||||
Session::flash('successes', $messages['successes']);
|
||||
Session::flash('error', 'Could not save budget: ' . $messages['errors']->first());
|
||||
|
||||
return Redirect::route('budgets.edit', $budget->id)->withInput()->withErrors($messages['errors']);
|
||||
}
|
||||
// store!
|
||||
@ -296,8 +290,22 @@ class BudgetController extends BaseController
|
||||
Session::flash('warnings', $messageBags['warnings']);
|
||||
Session::flash('successes', $messageBags['successes']);
|
||||
Session::flash('errors', $messageBags['errors']);
|
||||
|
||||
return Redirect::route('budgets.edit', $budget->id)->withInput();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function updateIncome()
|
||||
{
|
||||
$date = Session::get('start');
|
||||
/** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */
|
||||
$preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface');
|
||||
$budgetAmount = $preferences->get('budgetIncomeTotal' . $date->format('FY'), 1000);
|
||||
|
||||
return View::make('budgets.income')->with('amount', $budgetAmount)->with('date', $date);
|
||||
}
|
||||
}
|
@ -46,6 +46,7 @@ class CategoryController extends BaseController
|
||||
|
||||
$repos->destroy($category);
|
||||
Session::flash('success', 'The category was deleted.');
|
||||
|
||||
return Redirect::route('categories.index');
|
||||
}
|
||||
|
||||
@ -56,8 +57,7 @@ class CategoryController extends BaseController
|
||||
*/
|
||||
public function edit(Category $category)
|
||||
{
|
||||
return View::make('categories.edit')->with('category', $category)
|
||||
->with('subTitle', 'Edit category "' . $category->name . '"');
|
||||
return View::make('categories.edit')->with('category', $category)->with('subTitle', 'Edit category "' . $category->name . '"');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,6 +122,7 @@ class CategoryController extends BaseController
|
||||
Session::flash('warnings', $messages['warnings']);
|
||||
Session::flash('successes', $messages['successes']);
|
||||
Session::flash('error', 'Could not save category: ' . $messages['errors']->first());
|
||||
|
||||
return Redirect::route('categories.edit', $category->id)->withInput()->withErrors($messages['errors']);
|
||||
}
|
||||
// store!
|
||||
@ -138,6 +139,7 @@ class CategoryController extends BaseController
|
||||
Session::flash('warnings', $messageBags['warnings']);
|
||||
Session::flash('successes', $messageBags['successes']);
|
||||
Session::flash('errors', $messageBags['errors']);
|
||||
|
||||
return Redirect::route('categories.edit', $category->id)->withInput();
|
||||
break;
|
||||
}
|
||||
|
@ -7,6 +7,162 @@ use Carbon\Carbon;
|
||||
class GoogleChartController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*/
|
||||
public function accountBalanceChart(Account $account)
|
||||
{
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('Day of month', 'date');
|
||||
$chart->addColumn('Balance for ' . $account->name, 'number');
|
||||
|
||||
/*
|
||||
* Loop the date, then loop the accounts, then add balance.
|
||||
*/
|
||||
$start = Session::get('start');
|
||||
$end = Session::get('end');
|
||||
$current = clone $start;
|
||||
|
||||
while ($end >= $current) {
|
||||
$row = [clone $current];
|
||||
if ($current > Carbon::now()) {
|
||||
$row[] = null;
|
||||
} else {
|
||||
$row[] = $account->balance($current);
|
||||
}
|
||||
|
||||
$chart->addRowArray($row);
|
||||
$current->addDay();
|
||||
}
|
||||
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function accountSankeyInChart(Account $account)
|
||||
{
|
||||
// collect all relevant entries.
|
||||
$set = [];
|
||||
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('From', 'string');
|
||||
$chart->addColumn('To', 'string', 'domain');
|
||||
$chart->addColumn('Weight', 'number');
|
||||
|
||||
$transactions = $account->transactions()->with(
|
||||
['transactionjournal', 'transactionjournal.transactions' => function ($q) {
|
||||
$q->where('amount', '<', 0);
|
||||
}, 'transactionjournal.budgets', 'transactionjournal.transactiontype', 'transactionjournal.categories']
|
||||
)->before(Session::get('end'))->after(
|
||||
Session::get('start')
|
||||
)->get();
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$amount = floatval($transaction->amount);
|
||||
$type = $transaction->transactionJournal->transactionType->type;
|
||||
|
||||
if ($amount > 0 && $type != 'Transfer') {
|
||||
|
||||
$otherAccount = $transaction->transactionJournal->transactions[0]->account->name;
|
||||
$categoryName = isset($transaction->transactionJournal->categories[0]) ? $transaction->transactionJournal->categories[0]->name : '(no cat)';
|
||||
$set[] = [$otherAccount, $categoryName, $amount];
|
||||
$set[] = [$categoryName, $account->name, $amount];
|
||||
}
|
||||
}
|
||||
// loop the set, group everything together:
|
||||
$grouped = [];
|
||||
foreach ($set as $entry) {
|
||||
$key = $entry[0] . $entry[1];
|
||||
if (isset($grouped[$key])) {
|
||||
$grouped[$key][2] += $entry[2];
|
||||
} else {
|
||||
$grouped[$key] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
// add rows to the chart:
|
||||
foreach ($grouped as $entry) {
|
||||
$chart->addRow($entry[0], $entry[1], $entry[2]);
|
||||
}
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function accountSankeyOutChart(Account $account)
|
||||
{
|
||||
// collect all relevant entries.
|
||||
$set = [];
|
||||
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('From', 'string');
|
||||
$chart->addColumn('To', 'string', 'domain');
|
||||
$chart->addColumn('Weight', 'number');
|
||||
|
||||
$transactions = $account->transactions()->with(
|
||||
['transactionjournal', 'transactionjournal.transactions', 'transactionjournal.budgets', 'transactionjournal.transactiontype',
|
||||
'transactionjournal.categories']
|
||||
)->before(Session::get('end'))->after(
|
||||
Session::get('start')
|
||||
)->get();
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$amount = floatval($transaction->amount);
|
||||
$type = $transaction->transactionJournal->transactionType->type;
|
||||
|
||||
if ($amount < 0 && $type != 'Transfer') {
|
||||
|
||||
// from account to a budget (if present).
|
||||
$budgetName = isset($transaction->transactionJournal->budgets[0]) ? $transaction->transactionJournal->budgets[0]->name : '(no budget)';
|
||||
$set[] = [$account->name, $budgetName, $amount * -1];
|
||||
|
||||
// from budget to category.
|
||||
$categoryName = isset($transaction->transactionJournal->categories[0]) ? ' ' . $transaction->transactionJournal->categories[0]->name
|
||||
: '(no cat)';
|
||||
$set[] = [$budgetName, $categoryName, $amount * -1];
|
||||
}
|
||||
}
|
||||
// loop the set, group everything together:
|
||||
$grouped = [];
|
||||
foreach ($set as $entry) {
|
||||
$key = $entry[0] . $entry[1];
|
||||
if (isset($grouped[$key])) {
|
||||
$grouped[$key][2] += $entry[2];
|
||||
} else {
|
||||
$grouped[$key] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
// add rows to the chart:
|
||||
foreach ($grouped as $entry) {
|
||||
$chart->addRow($entry[0], $entry[1], $entry[2]);
|
||||
}
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method renders the b
|
||||
*/
|
||||
@ -60,202 +216,11 @@ class GoogleChartController extends BaseController
|
||||
}
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $year
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function yearInExp($year)
|
||||
{
|
||||
try {
|
||||
$start = new Carbon('01-01-' . $year);
|
||||
} catch (Exception $e) {
|
||||
App::abort(500);
|
||||
}
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('Month', 'date');
|
||||
$chart->addColumn('Income', 'number');
|
||||
$chart->addColumn('Expenses', 'number');
|
||||
|
||||
/** @var \FireflyIII\Database\TransactionJournal $tj */
|
||||
$tj = App::make('FireflyIII\Database\TransactionJournal');
|
||||
|
||||
$end = clone $start;
|
||||
$end->endOfYear();
|
||||
while ($start < $end) {
|
||||
|
||||
// total income:
|
||||
$income = $tj->getSumOfIncomesByMonth($start);
|
||||
$expense = $tj->getSumOfExpensesByMonth($start);
|
||||
|
||||
$chart->addRow(clone $start, $income, $expense);
|
||||
$start->addMonth();
|
||||
}
|
||||
|
||||
|
||||
$chart->generate();
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $year
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function yearInExpSum($year)
|
||||
{
|
||||
try {
|
||||
$start = new Carbon('01-01-' . $year);
|
||||
} catch (Exception $e) {
|
||||
App::abort(500);
|
||||
}
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('Summary', 'string');
|
||||
$chart->addColumn('Income', 'number');
|
||||
$chart->addColumn('Expenses', 'number');
|
||||
|
||||
/** @var \FireflyIII\Database\TransactionJournal $tj */
|
||||
$tj = App::make('FireflyIII\Database\TransactionJournal');
|
||||
|
||||
$end = clone $start;
|
||||
$end->endOfYear();
|
||||
$income = 0;
|
||||
$expense = 0;
|
||||
$count = 0;
|
||||
while ($start < $end) {
|
||||
|
||||
// total income:
|
||||
$income += $tj->getSumOfIncomesByMonth($start);
|
||||
$expense += $tj->getSumOfExpensesByMonth($start);
|
||||
$count++;
|
||||
|
||||
$start->addMonth();
|
||||
}
|
||||
$chart->addRow('Sum', $income, $expense);
|
||||
$count = $count > 0 ? $count : 1;
|
||||
$chart->addRow('Average', ($income / $count), ($expense / $count));
|
||||
|
||||
|
||||
$chart->generate();
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function budgetsReportChart($year)
|
||||
{
|
||||
|
||||
try {
|
||||
$start = new Carbon('01-01-' . $year);
|
||||
} catch (Exception $e) {
|
||||
App::abort(500);
|
||||
}
|
||||
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
|
||||
/** @var \FireflyIII\Database\Budget $bdt */
|
||||
$bdt = App::make('FireflyIII\Database\Budget');
|
||||
$budgets = $bdt->get();
|
||||
|
||||
$chart->addColumn('Month', 'date');
|
||||
/** @var \Budget $budget */
|
||||
foreach ($budgets as $budget) {
|
||||
$chart->addColumn($budget->name, 'number');
|
||||
}
|
||||
$chart->addColumn('No budget', 'number');
|
||||
|
||||
/*
|
||||
* Loop budgets this year.
|
||||
*/
|
||||
$end = clone $start;
|
||||
$end->endOfYear();
|
||||
while ($start <= $end) {
|
||||
$row = [clone $start];
|
||||
|
||||
foreach ($budgets as $budget) {
|
||||
$row[] = $bdt->spentInMonth($budget, $start);
|
||||
}
|
||||
|
||||
/*
|
||||
* Without a budget:
|
||||
*/
|
||||
$endOfMonth = clone $start;
|
||||
$endOfMonth->endOfMonth();
|
||||
$set = $bdt->transactionsWithoutBudgetInDateRange($start, $endOfMonth);
|
||||
$row[] = floatval($set->sum('amount')) * -1;
|
||||
|
||||
$chart->addRowArray($row);
|
||||
$start->addMonth();
|
||||
}
|
||||
|
||||
|
||||
$chart->generate();
|
||||
return Response::json($chart->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Component $component
|
||||
* @param $year
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function componentsAndSpending(Component $component, $year)
|
||||
{
|
||||
try {
|
||||
$start = new Carbon('01-01-' . $year);
|
||||
} catch (Exception $e) {
|
||||
App::abort(500);
|
||||
}
|
||||
|
||||
if ($component->class == 'Budget') {
|
||||
/** @var \FireflyIII\Database\Budget $repos */
|
||||
$repos = App::make('FireflyIII\Database\Budget');
|
||||
} else {
|
||||
/** @var \FireflyIII\Database\Category $repos */
|
||||
$repos = App::make('FireflyIII\Database\Category');
|
||||
}
|
||||
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('Month', 'date');
|
||||
$chart->addColumn('Budgeted', 'number');
|
||||
$chart->addColumn('Spent', 'number');
|
||||
|
||||
$end = clone $start;
|
||||
$end->endOfYear();
|
||||
while ($start <= $end) {
|
||||
|
||||
$spent = $repos->spentInMonth($component, $start);
|
||||
$repetition = $repos->repetitionOnStartingOnDate($component, $start);
|
||||
if ($repetition) {
|
||||
$budgeted = floatval($repetition->amount);
|
||||
} else {
|
||||
$budgeted = null;
|
||||
}
|
||||
|
||||
$chart->addRow(clone $start, $budgeted, $spent);
|
||||
|
||||
$start->addMonth();
|
||||
}
|
||||
|
||||
|
||||
$chart->generate();
|
||||
return Response::json($chart->getData());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
@ -321,6 +286,7 @@ class GoogleChartController extends BaseController
|
||||
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
}
|
||||
|
||||
@ -365,10 +331,120 @@ class GoogleChartController extends BaseController
|
||||
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function budgetsReportChart($year)
|
||||
{
|
||||
|
||||
try {
|
||||
$start = new Carbon('01-01-' . $year);
|
||||
} catch (Exception $e) {
|
||||
App::abort(500);
|
||||
}
|
||||
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
|
||||
/** @var \FireflyIII\Database\Budget $bdt */
|
||||
$bdt = App::make('FireflyIII\Database\Budget');
|
||||
$budgets = $bdt->get();
|
||||
|
||||
$chart->addColumn('Month', 'date');
|
||||
/** @var \Budget $budget */
|
||||
foreach ($budgets as $budget) {
|
||||
$chart->addColumn($budget->name, 'number');
|
||||
}
|
||||
$chart->addColumn('No budget', 'number');
|
||||
|
||||
/*
|
||||
* Loop budgets this year.
|
||||
*/
|
||||
$end = clone $start;
|
||||
$end->endOfYear();
|
||||
while ($start <= $end) {
|
||||
$row = [clone $start];
|
||||
|
||||
foreach ($budgets as $budget) {
|
||||
$row[] = $bdt->spentInMonth($budget, $start);
|
||||
}
|
||||
|
||||
/*
|
||||
* Without a budget:
|
||||
*/
|
||||
$endOfMonth = clone $start;
|
||||
$endOfMonth->endOfMonth();
|
||||
$set = $bdt->transactionsWithoutBudgetInDateRange($start, $endOfMonth);
|
||||
$row[] = floatval($set->sum('amount')) * -1;
|
||||
|
||||
$chart->addRowArray($row);
|
||||
$start->addMonth();
|
||||
}
|
||||
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Component $component
|
||||
* @param $year
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function componentsAndSpending(Component $component, $year)
|
||||
{
|
||||
try {
|
||||
$start = new Carbon('01-01-' . $year);
|
||||
} catch (Exception $e) {
|
||||
App::abort(500);
|
||||
}
|
||||
|
||||
if ($component->class == 'Budget') {
|
||||
/** @var \FireflyIII\Database\Budget $repos */
|
||||
$repos = App::make('FireflyIII\Database\Budget');
|
||||
} else {
|
||||
/** @var \FireflyIII\Database\Category $repos */
|
||||
$repos = App::make('FireflyIII\Database\Category');
|
||||
}
|
||||
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('Month', 'date');
|
||||
$chart->addColumn('Budgeted', 'number');
|
||||
$chart->addColumn('Spent', 'number');
|
||||
|
||||
$end = clone $start;
|
||||
$end->endOfYear();
|
||||
while ($start <= $end) {
|
||||
|
||||
$spent = $repos->spentInMonth($component, $start);
|
||||
$repetition = $repos->repetitionOnStartingOnDate($component, $start);
|
||||
if ($repetition) {
|
||||
$budgeted = floatval($repetition->amount);
|
||||
} else {
|
||||
$budgeted = null;
|
||||
}
|
||||
|
||||
$chart->addRow(clone $start, $budgeted, $spent);
|
||||
|
||||
$start->addMonth();
|
||||
}
|
||||
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @throws \FireflyIII\Exception\FireflyException
|
||||
@ -380,14 +456,8 @@ class GoogleChartController extends BaseController
|
||||
* Set of paid transaction journals.
|
||||
* Set of unpaid recurring transactions.
|
||||
*/
|
||||
$paid = [
|
||||
'items' => [],
|
||||
'amount' => 0
|
||||
];
|
||||
$unpaid = [
|
||||
'items' => [],
|
||||
'amount' => 0
|
||||
];
|
||||
$paid = ['items' => [], 'amount' => 0];
|
||||
$unpaid = ['items' => [], 'amount' => 0];
|
||||
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
@ -455,160 +525,93 @@ class GoogleChartController extends BaseController
|
||||
$chart->addRow('Paid: ' . join(', ', $paid['items']), $paid['amount']);
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*/
|
||||
public function accountBalanceChart(Account $account)
|
||||
{
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('Day of month', 'date');
|
||||
$chart->addColumn('Balance for ' . $account->name, 'number');
|
||||
|
||||
/*
|
||||
* Loop the date, then loop the accounts, then add balance.
|
||||
*/
|
||||
$start = Session::get('start');
|
||||
$end = Session::get('end');
|
||||
$current = clone $start;
|
||||
|
||||
while ($end >= $current) {
|
||||
$row = [clone $current];
|
||||
if ($current > Carbon::now()) {
|
||||
$row[] = null;
|
||||
} else {
|
||||
$row[] = $account->balance($current);
|
||||
}
|
||||
|
||||
$chart->addRowArray($row);
|
||||
$current->addDay();
|
||||
}
|
||||
|
||||
|
||||
$chart->generate();
|
||||
return Response::json($chart->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param $year
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function accountSankeyOutChart(Account $account)
|
||||
public function yearInExp($year)
|
||||
{
|
||||
// collect all relevant entries.
|
||||
$set = [];
|
||||
|
||||
try {
|
||||
$start = new Carbon('01-01-' . $year);
|
||||
} catch (Exception $e) {
|
||||
App::abort(500);
|
||||
}
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('From', 'string');
|
||||
$chart->addColumn('To', 'string', 'domain');
|
||||
$chart->addColumn('Weight', 'number');
|
||||
$chart->addColumn('Month', 'date');
|
||||
$chart->addColumn('Income', 'number');
|
||||
$chart->addColumn('Expenses', 'number');
|
||||
|
||||
$transactions = $account->transactions()->with(
|
||||
['transactionjournal', 'transactionjournal.transactions', 'transactionjournal.budgets', 'transactionjournal.transactiontype',
|
||||
'transactionjournal.categories']
|
||||
)->before(Session::get('end'))->after(
|
||||
Session::get('start')
|
||||
)->get();
|
||||
/** @var \FireflyIII\Database\TransactionJournal $tj */
|
||||
$tj = App::make('FireflyIII\Database\TransactionJournal');
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$amount = floatval($transaction->amount);
|
||||
$type = $transaction->transactionJournal->transactionType->type;
|
||||
$end = clone $start;
|
||||
$end->endOfYear();
|
||||
while ($start < $end) {
|
||||
|
||||
if ($amount < 0 && $type != 'Transfer') {
|
||||
// total income:
|
||||
$income = $tj->getSumOfIncomesByMonth($start);
|
||||
$expense = $tj->getSumOfExpensesByMonth($start);
|
||||
|
||||
// from account to a budget (if present).
|
||||
$budgetName = isset($transaction->transactionJournal->budgets[0]) ? $transaction->transactionJournal->budgets[0]->name : '(no budget)';
|
||||
$set[] = [$account->name, $budgetName, $amount * -1];
|
||||
|
||||
// from budget to category.
|
||||
$categoryName = isset($transaction->transactionJournal->categories[0]) ? ' ' . $transaction->transactionJournal->categories[0]->name
|
||||
: '(no cat)';
|
||||
$set[] = [$budgetName, $categoryName, $amount * -1];
|
||||
}
|
||||
}
|
||||
// loop the set, group everything together:
|
||||
$grouped = [];
|
||||
foreach ($set as $entry) {
|
||||
$key = $entry[0] . $entry[1];
|
||||
if (isset($grouped[$key])) {
|
||||
$grouped[$key][2] += $entry[2];
|
||||
} else {
|
||||
$grouped[$key] = $entry;
|
||||
}
|
||||
$chart->addRow(clone $start, $income, $expense);
|
||||
$start->addMonth();
|
||||
}
|
||||
|
||||
// add rows to the chart:
|
||||
foreach ($grouped as $entry) {
|
||||
$chart->addRow($entry[0], $entry[1], $entry[2]);
|
||||
}
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
* @param $year
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function accountSankeyInChart(Account $account)
|
||||
public function yearInExpSum($year)
|
||||
{
|
||||
// collect all relevant entries.
|
||||
$set = [];
|
||||
|
||||
try {
|
||||
$start = new Carbon('01-01-' . $year);
|
||||
} catch (Exception $e) {
|
||||
App::abort(500);
|
||||
}
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('From', 'string');
|
||||
$chart->addColumn('To', 'string', 'domain');
|
||||
$chart->addColumn('Weight', 'number');
|
||||
$chart->addColumn('Summary', 'string');
|
||||
$chart->addColumn('Income', 'number');
|
||||
$chart->addColumn('Expenses', 'number');
|
||||
|
||||
$transactions = $account->transactions()->with(
|
||||
['transactionjournal', 'transactionjournal.transactions' => function ($q) {
|
||||
$q->where('amount', '<', 0);
|
||||
}, 'transactionjournal.budgets', 'transactionjournal.transactiontype', 'transactionjournal.categories']
|
||||
)->before(Session::get('end'))->after(
|
||||
Session::get('start')
|
||||
)->get();
|
||||
/** @var \FireflyIII\Database\TransactionJournal $tj */
|
||||
$tj = App::make('FireflyIII\Database\TransactionJournal');
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$amount = floatval($transaction->amount);
|
||||
$type = $transaction->transactionJournal->transactionType->type;
|
||||
$end = clone $start;
|
||||
$end->endOfYear();
|
||||
$income = 0;
|
||||
$expense = 0;
|
||||
$count = 0;
|
||||
while ($start < $end) {
|
||||
|
||||
if ($amount > 0 && $type != 'Transfer') {
|
||||
// total income:
|
||||
$income += $tj->getSumOfIncomesByMonth($start);
|
||||
$expense += $tj->getSumOfExpensesByMonth($start);
|
||||
$count++;
|
||||
|
||||
$otherAccount = $transaction->transactionJournal->transactions[0]->account->name;
|
||||
$categoryName = isset($transaction->transactionJournal->categories[0]) ? $transaction->transactionJournal->categories[0]->name
|
||||
: '(no cat)';
|
||||
$set[] = [$otherAccount, $categoryName, $amount];
|
||||
$set[] = [$categoryName, $account->name, $amount];
|
||||
}
|
||||
}
|
||||
// loop the set, group everything together:
|
||||
$grouped = [];
|
||||
foreach ($set as $entry) {
|
||||
$key = $entry[0] . $entry[1];
|
||||
if (isset($grouped[$key])) {
|
||||
$grouped[$key][2] += $entry[2];
|
||||
} else {
|
||||
$grouped[$key] = $entry;
|
||||
}
|
||||
$start->addMonth();
|
||||
}
|
||||
$chart->addRow('Sum', $income, $expense);
|
||||
$count = $count > 0 ? $count : 1;
|
||||
$chart->addRow('Average', ($income / $count), ($expense / $count));
|
||||
|
||||
// add rows to the chart:
|
||||
foreach ($grouped as $entry) {
|
||||
$chart->addRow($entry[0], $entry[1], $entry[2]);
|
||||
}
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
@ -7,38 +7,6 @@ use FireflyIII\Exception\FireflyException;
|
||||
class GoogleTableController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function categoryList()
|
||||
{
|
||||
|
||||
/** @var \FireflyIII\Database\Category $repos */
|
||||
$repos = App::make('FireflyIII\Database\Category');
|
||||
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('ID', 'number');
|
||||
$chart->addColumn('ID_Edit', 'string');
|
||||
$chart->addColumn('ID_Delete', 'string');
|
||||
$chart->addColumn('Name_URL', 'string');
|
||||
$chart->addColumn('Name', 'string');
|
||||
|
||||
$list = $repos->get();
|
||||
|
||||
/** @var Category $entry */
|
||||
foreach ($list as $entry) {
|
||||
$chart->addRow(
|
||||
$entry->id, route('categories.edit', $entry->id), route('categories.delete', $entry->id), route('categories.show', $entry->id), $entry->name
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$chart->generate();
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $what
|
||||
*
|
||||
@ -76,20 +44,197 @@ class GoogleTableController extends BaseController
|
||||
|
||||
/** @var \Account $entry */
|
||||
foreach ($list as $entry) {
|
||||
$edit = route('accounts.edit', $entry->id);
|
||||
$edit = route('accounts.edit', $entry->id);
|
||||
$delete = route('accounts.delete', $entry->id);
|
||||
$show = route('accounts.show', $entry->id);
|
||||
$show = route('accounts.show', $entry->id);
|
||||
$chart->addRow($entry->id, $edit, $delete, $show, $entry->name, $entry->balance());
|
||||
}
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Component $component
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function categoryList()
|
||||
{
|
||||
|
||||
/** @var \FireflyIII\Database\Category $repos */
|
||||
$repos = App::make('FireflyIII\Database\Category');
|
||||
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('ID', 'number');
|
||||
$chart->addColumn('ID_Edit', 'string');
|
||||
$chart->addColumn('ID_Delete', 'string');
|
||||
$chart->addColumn('Name_URL', 'string');
|
||||
$chart->addColumn('Name', 'string');
|
||||
|
||||
$list = $repos->get();
|
||||
|
||||
/** @var Category $entry */
|
||||
foreach ($list as $entry) {
|
||||
$chart->addRow(
|
||||
$entry->id, route('categories.edit', $entry->id), route('categories.delete', $entry->id), route('categories.show', $entry->id), $entry->name
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
public function recurringList()
|
||||
{
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('ID', 'number');
|
||||
$chart->addColumn('ID_Edit', 'string');
|
||||
$chart->addColumn('ID_Delete', 'string');
|
||||
$chart->addColumn('Name_URL', 'string');
|
||||
$chart->addColumn('Name', 'string');
|
||||
|
||||
/** @var \FireflyIII\Database\RecurringTransaction $repository */
|
||||
$repository = App::make('FireflyIII\Database\RecurringTransaction');
|
||||
|
||||
$set = $repository->get();
|
||||
|
||||
/** @var \RecurringTransaction $entry */
|
||||
foreach ($set as $entry) {
|
||||
$row = [$entry->id, route('recurring.edit', $entry->id), route('recurring.delete', $entry->id), route('recurring.show', $entry->id), $entry->name];
|
||||
$chart->addRowArray($row);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* <th>name</th>
|
||||
<th>match</th>
|
||||
<th>amount_min</th>
|
||||
<th>amount_max</th>
|
||||
<th>date</th>
|
||||
<th>active</th>
|
||||
<th>automatch</th>
|
||||
<th>repeat_freq</th>
|
||||
<th>id</th>
|
||||
|
||||
*/
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*/
|
||||
public function transactionsByAccount(Account $account)
|
||||
{
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('ID', 'number');
|
||||
$chart->addColumn('ID_Edit', 'string');
|
||||
$chart->addColumn('ID_Delete', 'string');
|
||||
$chart->addColumn('Date', 'date');
|
||||
$chart->addColumn('Description_URL', 'string');
|
||||
$chart->addColumn('Description', 'string');
|
||||
$chart->addColumn('Amount', 'number');
|
||||
$chart->addColumn('From_URL', 'string');
|
||||
$chart->addColumn('From', 'string');
|
||||
$chart->addColumn('To_URL', 'string');
|
||||
$chart->addColumn('To', 'string');
|
||||
$chart->addColumn('Budget_URL', 'string');
|
||||
$chart->addColumn('Budget', 'string');
|
||||
$chart->addColumn('Category_URL', 'string');
|
||||
$chart->addColumn('Category', 'string');
|
||||
|
||||
|
||||
/*
|
||||
* Find transactions:
|
||||
*/
|
||||
$accountID = $account->id;
|
||||
$transactions = $account->transactions()->with(
|
||||
['transactionjournal', 'transactionjournal.transactions' => function ($q) use ($accountID) {
|
||||
$q->where('account_id', '!=', $accountID);
|
||||
}, 'transactionjournal.budgets', 'transactionjournal.transactiontype', 'transactionjournal.categories']
|
||||
)->before(Session::get('end'))->after(
|
||||
Session::get('start')
|
||||
)->orderBy('date', 'DESC')->get();
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$date = $transaction->transactionJournal->date;
|
||||
$descriptionURL = route('transactions.show', $transaction->transaction_journal_id);
|
||||
$description = $transaction->transactionJournal->description;
|
||||
$amount = floatval($transaction->amount);
|
||||
|
||||
if ($transaction->transactionJournal->transactions[0]->account->id == $account->id) {
|
||||
$opposingAccountURI = route('accounts.show', $transaction->transactionJournal->transactions[1]->account->id);
|
||||
$opposingAccountName = $transaction->transactionJournal->transactions[1]->account->name;
|
||||
} else {
|
||||
$opposingAccountURI = route('accounts.show', $transaction->transactionJournal->transactions[0]->account->id);
|
||||
$opposingAccountName = $transaction->transactionJournal->transactions[0]->account->name;
|
||||
}
|
||||
if (isset($transaction->transactionJournal->budgets[0])) {
|
||||
$budgetURL = route('budgets.show', $transaction->transactionJournal->budgets[0]->id);
|
||||
$budget = $transaction->transactionJournal->budgets[0]->name;
|
||||
} else {
|
||||
$budgetURL = '';
|
||||
$budget = '';
|
||||
}
|
||||
|
||||
if (isset($transaction->transactionJournal->categories[0])) {
|
||||
$categoryURL = route('categories.show', $transaction->transactionJournal->categories[0]->id);
|
||||
$category = $transaction->transactionJournal->categories[0]->name;
|
||||
} else {
|
||||
$categoryURL = '';
|
||||
$category = '';
|
||||
}
|
||||
|
||||
|
||||
if ($amount < 0) {
|
||||
$from = $account->name;
|
||||
$fromURL = route('accounts.show', $account->id);
|
||||
|
||||
$to = $opposingAccountName;
|
||||
$toURL = $opposingAccountURI;
|
||||
} else {
|
||||
$to = $account->name;
|
||||
$toURL = route('accounts.show', $account->id);
|
||||
|
||||
$from = $opposingAccountName;
|
||||
$fromURL = $opposingAccountURI;
|
||||
}
|
||||
|
||||
$id = $transaction->transactionJournal->id;
|
||||
$edit = route('transactions.edit', $transaction->transactionJournal->id);
|
||||
$delete = route('transactions.delete', $transaction->transactionJournal->id);
|
||||
$chart->addRow(
|
||||
$id, $edit, $delete, $date, $descriptionURL, $description, $amount, $fromURL, $from, $toURL, $to, $budgetURL, $budget, $categoryURL, $category
|
||||
);
|
||||
}
|
||||
|
||||
// <th>Date</th>
|
||||
// <th>Description</th>
|
||||
// <th>Amount (€)</th>
|
||||
// <th>From</th>
|
||||
// <th>To</th>
|
||||
// <th>Budget / category</th>
|
||||
// <th>ID</th>
|
||||
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Component $component
|
||||
* @param LimitRepetition $repetition
|
||||
*/
|
||||
public function transactionsByComponent(Component $component, LimitRepetition $repetition = null)
|
||||
@ -114,26 +259,25 @@ class GoogleTableController extends BaseController
|
||||
|
||||
if (is_null($repetition)) {
|
||||
$journals = $component->transactionjournals()->with(['budgets', 'categories', 'transactions', 'transactions.account'])->orderBy('date', 'DESC')
|
||||
->get();
|
||||
->get();
|
||||
} else {
|
||||
$journals = $component->transactionjournals()->with(['budgets', 'categories', 'transactions', 'transactions.account'])->after(
|
||||
$repetition->startdate
|
||||
)
|
||||
->before($repetition->enddate)->orderBy('date', 'DESC')->get();
|
||||
)->before($repetition->enddate)->orderBy('date', 'DESC')->get();
|
||||
}
|
||||
/** @var TransactionJournal $transaction */
|
||||
foreach ($journals as $journal) {
|
||||
$date = $journal->date;
|
||||
$date = $journal->date;
|
||||
$descriptionURL = route('transactions.show', $journal->id);
|
||||
$description = $journal->description;
|
||||
$description = $journal->description;
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
if (floatval($transaction->amount) > 0) {
|
||||
$amount = floatval($transaction->amount);
|
||||
$to = $transaction->account->name;
|
||||
$toURL = route('accounts.show', $transaction->account->id);
|
||||
$to = $transaction->account->name;
|
||||
$toURL = route('accounts.show', $transaction->account->id);
|
||||
} else {
|
||||
$from = $transaction->account->name;
|
||||
$from = $transaction->account->name;
|
||||
$fromURL = route('accounts.show', $transaction->account->id);
|
||||
}
|
||||
|
||||
@ -148,15 +292,15 @@ class GoogleTableController extends BaseController
|
||||
|
||||
if (isset($journal->categories[0])) {
|
||||
$categoryURL = route('categories.show', $journal->categories[0]->id);
|
||||
$category = $journal->categories[0]->name;
|
||||
$category = $journal->categories[0]->name;
|
||||
} else {
|
||||
$categoryURL = '';
|
||||
$category = '';
|
||||
$category = '';
|
||||
}
|
||||
|
||||
|
||||
$id = $journal->id;
|
||||
$edit = route('transactions.edit', $journal->id);
|
||||
$id = $journal->id;
|
||||
$edit = route('transactions.edit', $journal->id);
|
||||
$delete = route('transactions.delete', $journal->id);
|
||||
$chart->addRow(
|
||||
$id, $edit, $delete, $date, $descriptionURL, $description, $amount, $fromURL, $from, $toURL, $to, $budgetURL, $component, $categoryURL,
|
||||
@ -166,55 +310,11 @@ class GoogleTableController extends BaseController
|
||||
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
public function recurringList()
|
||||
{
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('ID', 'number');
|
||||
$chart->addColumn('ID_Edit', 'string');
|
||||
$chart->addColumn('ID_Delete', 'string');
|
||||
$chart->addColumn('Name_URL', 'string');
|
||||
$chart->addColumn('Name', 'string');
|
||||
|
||||
/** @var \FireflyIII\Database\RecurringTransaction $repository */
|
||||
$repository = App::make('FireflyIII\Database\RecurringTransaction');
|
||||
|
||||
$set = $repository->get();
|
||||
|
||||
/** @var \RecurringTransaction $entry */
|
||||
foreach ($set as $entry) {
|
||||
$row = [
|
||||
$entry->id,
|
||||
route('recurring.edit', $entry->id),
|
||||
route('recurring.delete', $entry->id),
|
||||
route('recurring.show', $entry->id),
|
||||
$entry->name
|
||||
];
|
||||
$chart->addRowArray($row);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* <th>name</th>
|
||||
<th>match</th>
|
||||
<th>amount_min</th>
|
||||
<th>amount_max</th>
|
||||
<th>date</th>
|
||||
<th>active</th>
|
||||
<th>automatch</th>
|
||||
<th>repeat_freq</th>
|
||||
<th>id</th>
|
||||
|
||||
*/
|
||||
$chart->generate();
|
||||
return Response::json($chart->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $what
|
||||
*
|
||||
@ -261,158 +361,55 @@ class GoogleTableController extends BaseController
|
||||
|
||||
/** @var TransactionJournal $journal */
|
||||
foreach ($list as $journal) {
|
||||
$date = $journal->date;
|
||||
$date = $journal->date;
|
||||
$descriptionURL = route('transactions.show', $journal->id);
|
||||
$description = $journal->description;
|
||||
$id = $journal->id;
|
||||
$description = $journal->description;
|
||||
$id = $journal->id;
|
||||
|
||||
|
||||
if ($journal->transactions[0]->amount < 0) {
|
||||
|
||||
$fromURL = route('accounts.show', $journal->transactions[0]->account->id);
|
||||
$fromURL = route('accounts.show', $journal->transactions[0]->account->id);
|
||||
$fromName = $journal->transactions[0]->account->name;
|
||||
$amount = floatval($journal->transactions[0]->amount);
|
||||
$amount = floatval($journal->transactions[0]->amount);
|
||||
|
||||
$toURL = route('accounts.show', $journal->transactions[1]->account->id);
|
||||
$toURL = route('accounts.show', $journal->transactions[1]->account->id);
|
||||
$toName = $journal->transactions[1]->account->name;
|
||||
|
||||
} else {
|
||||
$fromURL = route('accounts.show', $journal->transactions[1]->account->id);
|
||||
$fromURL = route('accounts.show', $journal->transactions[1]->account->id);
|
||||
$fromName = $journal->transactions[1]->account->name;
|
||||
$amount = floatval($journal->transactions[1]->amount);
|
||||
$amount = floatval($journal->transactions[1]->amount);
|
||||
|
||||
$toURL = route('accounts.show', $journal->transactions[0]->account->id);
|
||||
$toURL = route('accounts.show', $journal->transactions[0]->account->id);
|
||||
$toName = $journal->transactions[0]->account->name;
|
||||
}
|
||||
if (isset($journal->budgets[0])) {
|
||||
$budgetURL = route('budgets.show', $journal->budgets[0]->id);
|
||||
$budget = $journal->budgets[0]->name;
|
||||
$budget = $journal->budgets[0]->name;
|
||||
} else {
|
||||
$budgetURL = '';
|
||||
$budget = '';
|
||||
$budget = '';
|
||||
}
|
||||
|
||||
if (isset($journal->categories[0])) {
|
||||
$categoryURL = route('categories.show', $journal->categories[0]->id);
|
||||
$category = $journal->categories[0]->name;
|
||||
$category = $journal->categories[0]->name;
|
||||
} else {
|
||||
$categoryURL = '';
|
||||
$category = '';
|
||||
$category = '';
|
||||
}
|
||||
$edit = route('transactions.edit', $journal->id);
|
||||
$edit = route('transactions.edit', $journal->id);
|
||||
$delete = route('transactions.delete', $journal->id);
|
||||
$chart->addRow(
|
||||
$id, $edit, $delete, $date, $descriptionURL, $description, $amount,
|
||||
$fromURL, $fromName, $toURL, $toName,
|
||||
$budgetURL, $budget, $categoryURL, $category
|
||||
$id, $edit, $delete, $date, $descriptionURL, $description, $amount, $fromURL, $fromName, $toURL, $toName, $budgetURL, $budget, $categoryURL,
|
||||
$category
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$chart->generate();
|
||||
return Response::json($chart->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*/
|
||||
public function transactionsByAccount(Account $account)
|
||||
{
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('ID', 'number');
|
||||
$chart->addColumn('ID_Edit', 'string');
|
||||
$chart->addColumn('ID_Delete', 'string');
|
||||
$chart->addColumn('Date', 'date');
|
||||
$chart->addColumn('Description_URL', 'string');
|
||||
$chart->addColumn('Description', 'string');
|
||||
$chart->addColumn('Amount', 'number');
|
||||
$chart->addColumn('From_URL', 'string');
|
||||
$chart->addColumn('From', 'string');
|
||||
$chart->addColumn('To_URL', 'string');
|
||||
$chart->addColumn('To', 'string');
|
||||
$chart->addColumn('Budget_URL', 'string');
|
||||
$chart->addColumn('Budget', 'string');
|
||||
$chart->addColumn('Category_URL', 'string');
|
||||
$chart->addColumn('Category', 'string');
|
||||
|
||||
|
||||
/*
|
||||
* Find transactions:
|
||||
*/
|
||||
$accountID = $account->id;
|
||||
$transactions = $account->transactions()->with(
|
||||
['transactionjournal', 'transactionjournal.transactions' => function ($q) use ($accountID) {
|
||||
$q->where('account_id', '!=', $accountID);
|
||||
}, 'transactionjournal.budgets', 'transactionjournal.transactiontype',
|
||||
'transactionjournal.categories']
|
||||
)->before(Session::get('end'))->after(
|
||||
Session::get('start')
|
||||
)->orderBy('date', 'DESC')->get();
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
$date = $transaction->transactionJournal->date;
|
||||
$descriptionURL = route('transactions.show', $transaction->transaction_journal_id);
|
||||
$description = $transaction->transactionJournal->description;
|
||||
$amount = floatval($transaction->amount);
|
||||
|
||||
if ($transaction->transactionJournal->transactions[0]->account->id == $account->id) {
|
||||
$opposingAccountURI = route('accounts.show', $transaction->transactionJournal->transactions[1]->account->id);
|
||||
$opposingAccountName = $transaction->transactionJournal->transactions[1]->account->name;
|
||||
} else {
|
||||
$opposingAccountURI = route('accounts.show', $transaction->transactionJournal->transactions[0]->account->id);
|
||||
$opposingAccountName = $transaction->transactionJournal->transactions[0]->account->name;
|
||||
}
|
||||
if (isset($transaction->transactionJournal->budgets[0])) {
|
||||
$budgetURL = route('budgets.show', $transaction->transactionJournal->budgets[0]->id);
|
||||
$budget = $transaction->transactionJournal->budgets[0]->name;
|
||||
} else {
|
||||
$budgetURL = '';
|
||||
$budget = '';
|
||||
}
|
||||
|
||||
if (isset($transaction->transactionJournal->categories[0])) {
|
||||
$categoryURL = route('categories.show', $transaction->transactionJournal->categories[0]->id);
|
||||
$category = $transaction->transactionJournal->categories[0]->name;
|
||||
} else {
|
||||
$categoryURL = '';
|
||||
$category = '';
|
||||
}
|
||||
|
||||
|
||||
if ($amount < 0) {
|
||||
$from = $account->name;
|
||||
$fromURL = route('accounts.show', $account->id);
|
||||
|
||||
$to = $opposingAccountName;
|
||||
$toURL = $opposingAccountURI;
|
||||
} else {
|
||||
$to = $account->name;
|
||||
$toURL = route('accounts.show', $account->id);
|
||||
|
||||
$from = $opposingAccountName;
|
||||
$fromURL = $opposingAccountURI;
|
||||
}
|
||||
|
||||
$id = $transaction->transactionJournal->id;
|
||||
$edit = route('transactions.edit', $transaction->transactionJournal->id);
|
||||
$delete = route('transactions.delete', $transaction->transactionJournal->id);
|
||||
$chart->addRow(
|
||||
$id, $edit, $delete, $date, $descriptionURL, $description, $amount, $fromURL, $from, $toURL, $to, $budgetURL, $budget, $categoryURL, $category
|
||||
);
|
||||
}
|
||||
|
||||
// <th>Date</th>
|
||||
// <th>Description</th>
|
||||
// <th>Amount (€)</th>
|
||||
// <th>From</th>
|
||||
// <th>To</th>
|
||||
// <th>Budget / category</th>
|
||||
// <th>ID</th>
|
||||
|
||||
|
||||
$chart->generate();
|
||||
return Response::json($chart->getData());
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
use FireflyIII\Shared\Preferences\PreferencesInterface as Prefs;
|
||||
|
||||
/**
|
||||
* Class HomeController
|
||||
@ -7,50 +6,6 @@ use FireflyIII\Shared\Preferences\PreferencesInterface as Prefs;
|
||||
*/
|
||||
class HomeController extends BaseController
|
||||
{
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function sessionPrev()
|
||||
{
|
||||
/** @var \FireflyIII\Shared\Toolkit\Navigation $navigation */
|
||||
$navigation = App::make('FireflyIII\Shared\Toolkit\Navigation');
|
||||
$navigation->prev();
|
||||
return Redirect::back();
|
||||
//return Redirect::route('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function sessionNext()
|
||||
{
|
||||
/** @var \FireflyIII\Shared\Toolkit\Navigation $navigation */
|
||||
$navigation = App::make('FireflyIII\Shared\Toolkit\Navigation');
|
||||
$navigation->next();
|
||||
return Redirect::back();
|
||||
//return Redirect::route('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $range
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function rangeJump($range)
|
||||
{
|
||||
|
||||
$valid = ['1D', '1W', '1M', '3M', '6M', '1Y',];
|
||||
|
||||
/** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */
|
||||
$preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface');
|
||||
|
||||
if (in_array($range, $valid)) {
|
||||
$preferences->set('viewRange', $range);
|
||||
Session::forget('range');
|
||||
}
|
||||
return Redirect::back();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
@ -66,9 +21,9 @@ class HomeController extends BaseController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// Event::fire('limits.check');
|
||||
// Event::fire('piggybanks.check');
|
||||
// Event::fire('recurring.check');
|
||||
// Event::fire('limits.check');
|
||||
// Event::fire('piggybanks.check');
|
||||
// Event::fire('recurring.check');
|
||||
|
||||
// count, maybe Firefly needs some introducing text to show:
|
||||
/** @var \FireflyIII\Database\Account $acct */
|
||||
@ -103,7 +58,54 @@ class HomeController extends BaseController
|
||||
}
|
||||
|
||||
// build the home screen:
|
||||
return View::make('index')->with('count', $count)->with('transactions', $transactions)->with('title', 'Firefly')
|
||||
->with('subTitle', 'What\'s playing?')->with('mainTitleIcon', 'fa-fire');
|
||||
return View::make('index')->with('count', $count)->with('transactions', $transactions)->with('title', 'Firefly')->with('subTitle', 'What\'s playing?')
|
||||
->with('mainTitleIcon', 'fa-fire');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $range
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function rangeJump($range)
|
||||
{
|
||||
|
||||
$valid = ['1D', '1W', '1M', '3M', '6M', '1Y',];
|
||||
|
||||
/** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */
|
||||
$preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface');
|
||||
|
||||
if (in_array($range, $valid)) {
|
||||
$preferences->set('viewRange', $range);
|
||||
Session::forget('range');
|
||||
}
|
||||
|
||||
return Redirect::back();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function sessionNext()
|
||||
{
|
||||
/** @var \FireflyIII\Shared\Toolkit\Navigation $navigation */
|
||||
$navigation = App::make('FireflyIII\Shared\Toolkit\Navigation');
|
||||
$navigation->next();
|
||||
|
||||
return Redirect::back();
|
||||
//return Redirect::route('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function sessionPrev()
|
||||
{
|
||||
/** @var \FireflyIII\Shared\Toolkit\Navigation $navigation */
|
||||
$navigation = App::make('FireflyIII\Shared\Toolkit\Navigation');
|
||||
$navigation->prev();
|
||||
|
||||
return Redirect::back();
|
||||
//return Redirect::route('index');
|
||||
}
|
||||
}
|
@ -16,8 +16,8 @@ class JsonController extends BaseController
|
||||
{
|
||||
/** @var \FireflyIII\Database\Category $categories */
|
||||
$categories = App::make('FireflyIII\Database\Category');
|
||||
$list = $categories->get();
|
||||
$return = [];
|
||||
$list = $categories->get();
|
||||
$return = [];
|
||||
foreach ($list as $entry) {
|
||||
$return[] = $entry->name;
|
||||
}
|
||||
@ -36,8 +36,8 @@ class JsonController extends BaseController
|
||||
{
|
||||
/** @var \FireflyIII\Database\Account $accounts */
|
||||
$accounts = App::make('FireflyIII\Database\Account');
|
||||
$list = $accounts->getExpenseAccounts();
|
||||
$return = [];
|
||||
$list = $accounts->getExpenseAccounts();
|
||||
$return = [];
|
||||
foreach ($list as $entry) {
|
||||
$return[] = $entry->name;
|
||||
}
|
||||
@ -53,8 +53,8 @@ class JsonController extends BaseController
|
||||
{
|
||||
/** @var \FireflyIII\Database\Account $accounts */
|
||||
$accounts = App::make('FireflyIII\Database\Account');
|
||||
$list = $accounts->getRevenueAccounts();
|
||||
$return = [];
|
||||
$list = $accounts->getRevenueAccounts();
|
||||
$return = [];
|
||||
foreach ($list as $entry) {
|
||||
$return[] = $entry->name;
|
||||
}
|
||||
|
@ -19,6 +19,25 @@ class PiggybankController extends BaseController
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Piggybank $piggybank
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function add(Piggybank $piggybank)
|
||||
{
|
||||
/** @var \FireflyIII\Database\Piggybank $acct */
|
||||
$repos = App::make('FireflyIII\Database\Piggybank');
|
||||
|
||||
$leftOnAccount = $repos->leftOnAccount($piggybank->account);
|
||||
$savedSoFar = $piggybank->currentRelevantRep()->currentamount;
|
||||
$leftToSave = $piggybank->targetamount - $savedSoFar;
|
||||
$amount = min($leftOnAccount, $leftToSave);
|
||||
|
||||
|
||||
return View::make('piggybanks.add', compact('piggybank'))->with('maxAmount', $amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
@ -35,8 +54,10 @@ class PiggybankController extends BaseController
|
||||
|
||||
|
||||
$accounts = $toolkit->makeSelectList($acct->getAssetAccounts());
|
||||
return View::make('piggybanks.create', compact('accounts', 'periods'))->with('title', 'Piggy banks')->with('mainTitleIcon', 'fa-sort-amount-asc')
|
||||
->with('subTitle', 'Create new piggy bank')->with('subTitleIcon', 'fa-plus');
|
||||
|
||||
return View::make('piggybanks.create', compact('accounts', 'periods'))->with('title', 'Piggy banks')->with('mainTitleIcon', 'fa-sort-amount-asc')->with(
|
||||
'subTitle', 'Create new piggy bank'
|
||||
)->with('subTitleIcon', 'fa-plus');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,11 +67,9 @@ class PiggybankController extends BaseController
|
||||
*/
|
||||
public function delete(Piggybank $piggybank)
|
||||
{
|
||||
return View::make('piggybanks.delete')
|
||||
->with('piggybank', $piggybank)
|
||||
->with('subTitle', 'Delete "' . $piggybank->name . '"')
|
||||
->with('title', 'Piggy banks')
|
||||
->with('mainTitleIcon', 'fa-sort-amount-asc');
|
||||
return View::make('piggybanks.delete')->with('piggybank', $piggybank)->with('subTitle', 'Delete "' . $piggybank->name . '"')->with(
|
||||
'title', 'Piggy banks'
|
||||
)->with('mainTitleIcon', 'fa-sort-amount-asc');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -89,38 +108,46 @@ class PiggybankController extends BaseController
|
||||
/*
|
||||
* Flash some data to fill the form.
|
||||
*/
|
||||
$prefilled = [
|
||||
'name' => $piggybank->name,
|
||||
'account_id' => $piggybank->account_id,
|
||||
'targetamount' => $piggybank->targetamount,
|
||||
'targetdate' => $piggybank->targetdate,
|
||||
'remind_me' => intval($piggybank->remind_me) == 1 ? true : false
|
||||
];
|
||||
$prefilled = ['name' => $piggybank->name, 'account_id' => $piggybank->account_id, 'targetamount' => $piggybank->targetamount,
|
||||
'targetdate' => $piggybank->targetdate, 'remind_me' => intval($piggybank->remind_me) == 1 ? true : false];
|
||||
Session::flash('prefilled', $prefilled);
|
||||
|
||||
return View::make('piggybanks.edit', compact('piggybank', 'accounts', 'periods', 'prefilled'))->with('title', 'Piggybanks')->with(
|
||||
'mainTitleIcon', 'fa-sort-amount-asc'
|
||||
)
|
||||
->with('subTitle', 'Edit piggy bank "' . e($piggybank->name) . '"')->with('subTitleIcon', 'fa-pencil');
|
||||
)->with('subTitle', 'Edit piggy bank "' . e($piggybank->name) . '"')->with('subTitleIcon', 'fa-pencil');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Piggybank $piggybank
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function add(Piggybank $piggybank)
|
||||
public function index()
|
||||
{
|
||||
/** @var \FireflyIII\Database\Piggybank $acct */
|
||||
/** @var \FireflyIII\Database\Piggybank $repos */
|
||||
$repos = App::make('FireflyIII\Database\Piggybank');
|
||||
|
||||
$leftOnAccount = $repos->leftOnAccount($piggybank->account);
|
||||
$savedSoFar = $piggybank->currentRelevantRep()->currentamount;
|
||||
$leftToSave = $piggybank->targetamount - $savedSoFar;
|
||||
$amount = min($leftOnAccount, $leftToSave);
|
||||
/** @var Collection $piggybanks */
|
||||
$piggybanks = $repos->get();
|
||||
|
||||
$accounts = [];
|
||||
/** @var Piggybank $piggybank */
|
||||
foreach ($piggybanks as $piggybank) {
|
||||
$piggybank->savedSoFar = floatval($piggybank->currentRelevantRep()->currentamount);
|
||||
$piggybank->percentage = intval($piggybank->savedSoFar / $piggybank->targetamount * 100);
|
||||
$piggybank->leftToSave = $piggybank->targetamount - $piggybank->savedSoFar;
|
||||
|
||||
return View::make('piggybanks.add', compact('piggybank'))->with('maxAmount', $amount);
|
||||
/*
|
||||
* Fill account information:
|
||||
*/
|
||||
$account = $piggybank->account;
|
||||
if (!isset($accounts[$account->id])) {
|
||||
$accounts[$account->id] = ['name' => $account->name, 'balance' => $account->balance(),
|
||||
'leftForPiggybanks' => $repos->leftOnAccount($account), 'sumOfSaved' => $piggybank->savedSoFar,
|
||||
'sumOfTargets' => floatval($piggybank->targetamount), 'leftToSave' => $piggybank->leftToSave];
|
||||
} else {
|
||||
$accounts[$account->id]['sumOfSaved'] += $piggybank->savedSoFar;
|
||||
$accounts[$account->id]['sumOfTargets'] += floatval($piggybank->targetamount);
|
||||
$accounts[$account->id]['leftToSave'] += $piggybank->leftToSave;
|
||||
}
|
||||
}
|
||||
|
||||
return View::make('piggybanks.index', compact('piggybanks', 'accounts'))->with('title', 'Piggy banks')->with('mainTitleIcon', 'fa-sort-amount-asc');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,17 +175,8 @@ class PiggybankController extends BaseController
|
||||
} else {
|
||||
Session::flash('error', 'Could not add ' . mf($amount, false) . ' to "' . e($piggybank->name) . '".');
|
||||
}
|
||||
return Redirect::route('piggybanks.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Piggybank $piggybank
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function remove(Piggybank $piggybank)
|
||||
{
|
||||
return View::make('piggybanks.remove', compact('piggybank'));
|
||||
return Redirect::route('piggybanks.index');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -180,47 +198,20 @@ class PiggybankController extends BaseController
|
||||
} else {
|
||||
Session::flash('error', 'Could not remove ' . mf($amount, false) . ' from "' . e($piggybank->name) . '".');
|
||||
}
|
||||
|
||||
return Redirect::route('piggybanks.index');
|
||||
}
|
||||
|
||||
public function index()
|
||||
/**
|
||||
* @param Piggybank $piggybank
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function remove(Piggybank $piggybank)
|
||||
{
|
||||
/** @var \FireflyIII\Database\Piggybank $repos */
|
||||
$repos = App::make('FireflyIII\Database\Piggybank');
|
||||
|
||||
/** @var Collection $piggybanks */
|
||||
$piggybanks = $repos->get();
|
||||
|
||||
$accounts = [];
|
||||
/** @var Piggybank $piggybank */
|
||||
foreach ($piggybanks as $piggybank) {
|
||||
$piggybank->savedSoFar = floatval($piggybank->currentRelevantRep()->currentamount);
|
||||
$piggybank->percentage = intval($piggybank->savedSoFar / $piggybank->targetamount * 100);
|
||||
$piggybank->leftToSave = $piggybank->targetamount - $piggybank->savedSoFar;
|
||||
|
||||
/*
|
||||
* Fill account information:
|
||||
*/
|
||||
$account = $piggybank->account;
|
||||
if (!isset($accounts[$account->id])) {
|
||||
$accounts[$account->id] = [
|
||||
'name' => $account->name,
|
||||
'balance' => $account->balance(),
|
||||
'leftForPiggybanks' => $repos->leftOnAccount($account),
|
||||
'sumOfSaved' => $piggybank->savedSoFar,
|
||||
'sumOfTargets' => floatval($piggybank->targetamount),
|
||||
'leftToSave' => $piggybank->leftToSave
|
||||
];
|
||||
} else {
|
||||
$accounts[$account->id]['sumOfSaved'] += $piggybank->savedSoFar;
|
||||
$accounts[$account->id]['sumOfTargets'] += floatval($piggybank->targetamount);
|
||||
$accounts[$account->id]['leftToSave'] += $piggybank->leftToSave;
|
||||
}
|
||||
}
|
||||
return View::make('piggybanks.index', compact('piggybanks', 'accounts'))->with('title', 'Piggy banks')->with('mainTitleIcon', 'fa-sort-amount-asc');
|
||||
return View::make('piggybanks.remove', compact('piggybank'));
|
||||
}
|
||||
|
||||
|
||||
public function show(Piggybank $piggyBank)
|
||||
{
|
||||
throw new NotImplementedException;
|
||||
@ -249,6 +240,7 @@ class PiggybankController extends BaseController
|
||||
Session::flash('warnings', $messages['warnings']);
|
||||
Session::flash('successes', $messages['successes']);
|
||||
Session::flash('error', 'Could not save piggy bank: ' . $messages['errors']->first());
|
||||
|
||||
return Redirect::route('piggybanks.create')->withInput()->withErrors($messages['errors']);
|
||||
}
|
||||
// store!
|
||||
@ -296,6 +288,7 @@ class PiggybankController extends BaseController
|
||||
Session::flash('warnings', $messages['warnings']);
|
||||
Session::flash('successes', $messages['successes']);
|
||||
Session::flash('error', 'Could not save piggy bank: ' . $messages['errors']->first());
|
||||
|
||||
return Redirect::route('piggybanks.edit', $piggyBank->id)->withInput()->withErrors($messages['errors']);
|
||||
}
|
||||
// store!
|
||||
@ -312,6 +305,7 @@ class PiggybankController extends BaseController
|
||||
Session::flash('warnings', $messageBags['warnings']);
|
||||
Session::flash('successes', $messageBags['successes']);
|
||||
Session::flash('errors', $messageBags['errors']);
|
||||
|
||||
return Redirect::route('piggybanks.edit', $piggyBank->id)->withInput();
|
||||
break;
|
||||
}
|
||||
|
@ -28,13 +28,12 @@ class PreferencesController extends BaseController
|
||||
/** @var \FireflyIII\Shared\Preferences\Preferences $preferences */
|
||||
$preferences = App::make('FireflyIII\Shared\Preferences\Preferences');
|
||||
|
||||
$accounts = $acct->getAssetAccounts();
|
||||
$viewRange = $preferences->get('viewRange', '1M');
|
||||
$accounts = $acct->getAssetAccounts();
|
||||
$viewRange = $preferences->get('viewRange', '1M');
|
||||
$viewRangeValue = $viewRange->data;
|
||||
$frontpage = $preferences->get('frontpageAccounts', []);
|
||||
$frontpage = $preferences->get('frontpageAccounts', []);
|
||||
|
||||
return View::make('preferences.index')->with('accounts', $accounts)->with('frontpageAccounts', $frontpage)
|
||||
->with('viewRange', $viewRangeValue);
|
||||
return View::make('preferences.index')->with('accounts', $accounts)->with('frontpageAccounts', $frontpage)->with('viewRange', $viewRangeValue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -6,15 +6,6 @@
|
||||
class ProfileController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return View::make('profile.index')->with('title', 'Profile')->with('subTitle', Auth::user()->email)->with('mainTitleIcon', 'fa-user');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
@ -25,6 +16,15 @@ class ProfileController extends BaseController
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\View\View
|
||||
*
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return View::make('profile.index')->with('title', 'Profile')->with('subTitle', Auth::user()->email)->with('mainTitleIcon', 'fa-user');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||
*/
|
||||
|
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
|
||||
/**
|
||||
* Class RecurringController
|
||||
*
|
||||
@ -23,9 +21,7 @@ class RecurringController extends BaseController
|
||||
{
|
||||
$periods = \Config::get('firefly.periods_to_text');
|
||||
|
||||
return View::make('recurring.create')
|
||||
->with('periods', $periods)
|
||||
->with('subTitle', 'Create new');
|
||||
return View::make('recurring.create')->with('periods', $periods)->with('subTitle', 'Create new');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -35,9 +31,9 @@ class RecurringController extends BaseController
|
||||
*/
|
||||
public function delete(RecurringTransaction $recurringTransaction)
|
||||
{
|
||||
return View::make('recurring.delete')
|
||||
->with('recurringTransaction', $recurringTransaction)
|
||||
->with('subTitle', 'Delete "' . $recurringTransaction->name . '"');
|
||||
return View::make('recurring.delete')->with('recurringTransaction', $recurringTransaction)->with(
|
||||
'subTitle', 'Delete "' . $recurringTransaction->name . '"'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,10 +68,9 @@ class RecurringController extends BaseController
|
||||
{
|
||||
$periods = \Config::get('firefly.periods_to_text');
|
||||
|
||||
return View::make('recurring.edit')
|
||||
->with('periods', $periods)
|
||||
->with('recurringTransaction', $recurringTransaction)
|
||||
->with('subTitle', 'Edit "' . $recurringTransaction->name . '"');
|
||||
return View::make('recurring.edit')->with('periods', $periods)->with('recurringTransaction', $recurringTransaction)->with(
|
||||
'subTitle', 'Edit "' . $recurringTransaction->name . '"'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,31 +81,32 @@ class RecurringController extends BaseController
|
||||
return View::make('recurring.index');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function show(RecurringTransaction $recurringTransaction)
|
||||
{
|
||||
return View::make('recurring.show')
|
||||
->with('recurring', $recurringTransaction)
|
||||
->with('subTitle', $recurringTransaction->name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RecurringTransaction $recurringTransaction
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function rescan(RecurringTransaction $recurringTransaction)
|
||||
{
|
||||
if (intval($recurringTransaction->active) == 0) {
|
||||
Session::flash('warning', 'Inactive recurring transactions cannot be scanned.');
|
||||
|
||||
return Redirect::back();
|
||||
}
|
||||
throw new NotImplementedException;
|
||||
Session::flash('success', 'Rescanned everything.');
|
||||
|
||||
return Redirect::back();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function show(RecurringTransaction $recurringTransaction)
|
||||
{
|
||||
return View::make('recurring.show')->with('recurring', $recurringTransaction)->with('subTitle', $recurringTransaction->name);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
throw new NotImplementedException;
|
||||
|
@ -49,11 +49,7 @@ class ReportController extends BaseController
|
||||
$end = clone $date;
|
||||
$end->endOfYear();
|
||||
while ($date < $end) {
|
||||
$summary[] = [
|
||||
'month' => $date->format('F'),
|
||||
'income' => $tj->getSumOfIncomesByMonth($date),
|
||||
'expense' => $tj->getSumOfExpensesByMonth($date),
|
||||
];
|
||||
$summary[] = ['month' => $date->format('F'), 'income' => $tj->getSumOfIncomesByMonth($date), 'expense' => $tj->getSumOfExpensesByMonth($date),];
|
||||
$date->addMonth();
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ class SearchController extends BaseController
|
||||
throw new NotImplementedException;
|
||||
$subTitle = null;
|
||||
$rawQuery = null;
|
||||
$result = [];
|
||||
$result = [];
|
||||
if (!is_null(Input::get('q'))) {
|
||||
$rawQuery = trim(Input::get('q'));
|
||||
$words = explode(' ', $rawQuery);
|
||||
@ -25,18 +25,12 @@ class SearchController extends BaseController
|
||||
$categories = $this->_helper->searchCategories($words);
|
||||
$budgets = $this->_helper->searchBudgets($words);
|
||||
$tags = $this->_helper->searchTags($words);
|
||||
$result = [
|
||||
'transactions' => $transactions,
|
||||
'accounts' => $accounts,
|
||||
'categories' => $categories,
|
||||
'budgets' => $budgets,
|
||||
'tags' => $tags
|
||||
];
|
||||
$result = ['transactions' => $transactions, 'accounts' => $accounts, 'categories' => $categories, 'budgets' => $budgets, 'tags' => $tags];
|
||||
|
||||
}
|
||||
|
||||
return View::make('search.index')->with('title', 'Search')->with('subTitle', $subTitle)->with(
|
||||
'mainTitleIcon', 'fa-search'
|
||||
)->with('query', $rawQuery)->with('result',$result);
|
||||
)->with('query', $rawQuery)->with('result', $result);
|
||||
}
|
||||
}
|
@ -23,36 +23,6 @@ class TransactionController extends BaseController
|
||||
View::share('mainTitleIcon', 'fa-repeat');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $what
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function index($what)
|
||||
{
|
||||
|
||||
switch ($what) {
|
||||
case 'expenses':
|
||||
case 'withdrawal':
|
||||
$subTitleIcon = 'fa-long-arrow-left';
|
||||
$subTitle = 'Expenses';
|
||||
break;
|
||||
case 'revenue':
|
||||
case 'deposit':
|
||||
$subTitleIcon = 'fa-long-arrow-right';
|
||||
$subTitle = 'Revenue, income and deposits';
|
||||
break;
|
||||
case 'transfer':
|
||||
case 'transfers':
|
||||
$subTitleIcon = 'fa-arrows-h';
|
||||
$subTitle = 'Transfers';
|
||||
break;
|
||||
}
|
||||
|
||||
return View::make('transactions.index', compact('subTitle', 'subTitleIcon'))->with('what', $what);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the view helping the user to create a new transaction journal.
|
||||
*
|
||||
@ -122,7 +92,6 @@ class TransactionController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $transactionJournal
|
||||
*
|
||||
@ -201,12 +170,7 @@ class TransactionController extends BaseController
|
||||
/*
|
||||
* Data to properly display the edit form.
|
||||
*/
|
||||
$prefilled = [
|
||||
'date' => $journal->date->format('Y-m-d'),
|
||||
'category' => '',
|
||||
'budget_id' => 0,
|
||||
'piggybank_id' => $piggyBankId
|
||||
];
|
||||
$prefilled = ['date' => $journal->date->format('Y-m-d'), 'category' => '', 'budget_id' => 0, 'piggybank_id' => $piggyBankId];
|
||||
|
||||
/*
|
||||
* Fill in the category.
|
||||
@ -245,6 +209,7 @@ class TransactionController extends BaseController
|
||||
/*
|
||||
* Show the view.
|
||||
*/
|
||||
|
||||
return View::make('transactions.edit')->with('journal', $journal)->with('accounts', $accounts)->with(
|
||||
'what', $what
|
||||
)->with('budgets', $budgets)->with('data', $prefilled)->with('piggies', $piggies)->with(
|
||||
@ -252,6 +217,36 @@ class TransactionController extends BaseController
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $what
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function index($what)
|
||||
{
|
||||
|
||||
switch ($what) {
|
||||
case 'expenses':
|
||||
case 'withdrawal':
|
||||
$subTitleIcon = 'fa-long-arrow-left';
|
||||
$subTitle = 'Expenses';
|
||||
break;
|
||||
case 'revenue':
|
||||
case 'deposit':
|
||||
$subTitleIcon = 'fa-long-arrow-right';
|
||||
$subTitle = 'Revenue, income and deposits';
|
||||
break;
|
||||
case 'transfer':
|
||||
case 'transfers':
|
||||
$subTitleIcon = 'fa-arrows-h';
|
||||
$subTitle = 'Transfers';
|
||||
break;
|
||||
}
|
||||
|
||||
return View::make('transactions.index', compact('subTitle', 'subTitleIcon'))->with('what', $what);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
@ -273,8 +268,8 @@ class TransactionController extends BaseController
|
||||
*/
|
||||
public function store($what)
|
||||
{
|
||||
$data = Input::except('_token');
|
||||
$data['what'] = $what;
|
||||
$data = Input::except('_token');
|
||||
$data['what'] = $what;
|
||||
$data['currency'] = 'EUR';
|
||||
|
||||
/** @var \FireflyIII\Database\TransactionJournal $repository */
|
||||
@ -292,6 +287,7 @@ class TransactionController extends BaseController
|
||||
Session::flash('warnings', $messages['warnings']);
|
||||
Session::flash('successes', $messages['successes']);
|
||||
Session::flash('error', 'Could not save transaction: ' . $messages['errors']->first());
|
||||
|
||||
return Redirect::route('transactions.create', $what)->withInput()->withErrors($messages['errors']);
|
||||
}
|
||||
// store!
|
||||
@ -301,7 +297,7 @@ class TransactionController extends BaseController
|
||||
if ($data['post_submit_action'] == 'create_another') {
|
||||
return Redirect::route('transactions.create', $what);
|
||||
} else {
|
||||
return Redirect::route('transactions.index',$what);
|
||||
return Redirect::route('transactions.index', $what);
|
||||
}
|
||||
break;
|
||||
case 'validate_only':
|
||||
@ -310,7 +306,7 @@ class TransactionController extends BaseController
|
||||
Session::flash('successes', $messageBags['successes']);
|
||||
Session::flash('errors', $messageBags['errors']);
|
||||
|
||||
return Redirect::route('transactions.create',$what)->withInput();
|
||||
return Redirect::route('transactions.create', $what)->withInput();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -335,6 +331,7 @@ class TransactionController extends BaseController
|
||||
*/
|
||||
if ($messageBag->count() > 0) {
|
||||
Session::flash('error', 'Could not save transaction: ' . $messageBag->first());
|
||||
|
||||
return Redirect::route('transactions.create', [$what])->withInput()->withErrors($messageBag);
|
||||
}
|
||||
|
||||
@ -359,6 +356,7 @@ class TransactionController extends BaseController
|
||||
Session::flash('warnings', $messageBags['warnings']);
|
||||
Session::flash('successes', $messageBags['successes']);
|
||||
Session::flash('errors', $messageBags['errors']);
|
||||
|
||||
return Redirect::route('transactions.create', [$what])->withInput();
|
||||
break;
|
||||
default:
|
||||
@ -408,6 +406,7 @@ class TransactionController extends BaseController
|
||||
Session::flash('warnings', $messageBags['warnings']);
|
||||
Session::flash('successes', $messageBags['successes']);
|
||||
Session::flash('errors', $messageBags['errors']);
|
||||
|
||||
return Redirect::route('transactions.edit', $journal->id)->withInput();
|
||||
break;
|
||||
default:
|
||||
|
@ -23,6 +23,18 @@ class UserController extends BaseController
|
||||
return View::make('user.login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout user.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
Auth::logout();
|
||||
Session::flush();
|
||||
|
||||
return Redirect::route('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Login.
|
||||
@ -32,10 +44,7 @@ class UserController extends BaseController
|
||||
public function postLogin()
|
||||
{
|
||||
$rememberMe = Input::get('remember_me') == '1';
|
||||
$data = [
|
||||
'email' => Input::get('email'),
|
||||
'password' => Input::get('password')
|
||||
];
|
||||
$data = ['email' => Input::get('email'), 'password' => Input::get('password')];
|
||||
$result = Auth::attempt($data, $rememberMe);
|
||||
if ($result) {
|
||||
return Redirect::route('index');
|
||||
@ -46,20 +55,6 @@ class UserController extends BaseController
|
||||
return View::make('user.login');
|
||||
}
|
||||
|
||||
/**
|
||||
* If allowed, show the register form.
|
||||
*
|
||||
* @return $this|\Illuminate\View\View
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
if (Config::get('auth.allow_register') !== true) {
|
||||
return View::make('error')->with('message', 'Not possible');
|
||||
}
|
||||
|
||||
return View::make('user.register');
|
||||
}
|
||||
|
||||
/**
|
||||
* If allowed, register the user.
|
||||
*
|
||||
@ -85,7 +80,6 @@ class UserController extends BaseController
|
||||
$user = $repository->register(Input::all());
|
||||
|
||||
|
||||
|
||||
//$user = $this->user->register(Input::all());
|
||||
if ($user) {
|
||||
if (Config::get('auth.verify_mail') === true) {
|
||||
@ -101,29 +95,6 @@ class UserController extends BaseController
|
||||
return View::make('user.register');
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout user.
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
Auth::logout();
|
||||
Session::flush();
|
||||
|
||||
return Redirect::route('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show form to help user get a new password.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function remindme()
|
||||
{
|
||||
return View::make('user.remindme');
|
||||
}
|
||||
|
||||
/**
|
||||
* If need to verify, send new reset code.
|
||||
* Otherwise, send new password.
|
||||
@ -157,6 +128,30 @@ class UserController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* If allowed, show the register form.
|
||||
*
|
||||
* @return $this|\Illuminate\View\View
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
if (Config::get('auth.allow_register') !== true) {
|
||||
return View::make('error')->with('message', 'Not possible');
|
||||
}
|
||||
|
||||
return View::make('user.register');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show form to help user get a new password.
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function remindme()
|
||||
{
|
||||
return View::make('user.remindme');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a user a password based on his reset code.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user