mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 04:03:26 +00:00
Fixed budget controller. [skip ci]
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'index_periods' => '1D', '1W', '1M', '3M', '6M', 'custom',
|
'index_periods' => '1D', '1W', '1M', '3M', '6M', 'custom',
|
||||||
'budget_periods' => 'daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly',
|
'budget_periods' => 'daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly',
|
||||||
@@ -25,19 +27,4 @@ return [
|
|||||||
'6M' => 'half-year',
|
'6M' => 'half-year',
|
||||||
'custom' => 'monthly'
|
'custom' => 'monthly'
|
||||||
],
|
],
|
||||||
|
|
||||||
'date_formats_by_period' => [
|
|
||||||
'monthly' => [
|
|
||||||
'group_date' => 'Y-m',
|
|
||||||
'display_date' => 'F Y'
|
|
||||||
],
|
|
||||||
'weekly' => [
|
|
||||||
'group_date' => 'Y-W',
|
|
||||||
'display_date' => '\W\e\e\k W, Y'
|
|
||||||
],
|
|
||||||
'quarterly' => [
|
|
||||||
'group_date' => 'Y-m',
|
|
||||||
'display_date' => '\T\O\D\O \C\L\O\S\U\R\E m-Y'
|
|
||||||
]
|
|
||||||
]
|
|
||||||
];
|
];
|
@@ -14,7 +14,7 @@ class AccountController extends \BaseController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ARI $repository
|
* @param ARI $repository
|
||||||
* @param AI $accounts
|
* @param AI $accounts
|
||||||
*/
|
*/
|
||||||
public function __construct(ARI $repository, AI $accounts)
|
public function __construct(ARI $repository, AI $accounts)
|
||||||
{
|
{
|
||||||
@@ -54,6 +54,7 @@ class AccountController extends \BaseController
|
|||||||
} else {
|
} else {
|
||||||
Session::flash('error', 'Could not delete the account. Check the logs to be sure.');
|
Session::flash('error', 'Could not delete the account. Check the logs to be sure.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return Redirect::route('accounts.index');
|
return Redirect::route('accounts.index');
|
||||||
|
|
||||||
|
|
||||||
|
@@ -15,7 +15,7 @@ class BudgetController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param BI $budgets
|
* @param BI $budgets
|
||||||
* @param BRI $repository
|
* @param BRI $repository
|
||||||
*/
|
*/
|
||||||
public function __construct(BI $budgets, BRI $repository)
|
public function __construct(BI $budgets, BRI $repository)
|
||||||
@@ -35,6 +35,35 @@ class BudgetController extends BaseController
|
|||||||
return View::make('budgets.create')->with('periods', $periods);
|
return View::make('budgets.create')->with('periods', $periods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete(Budget $budget)
|
||||||
|
{
|
||||||
|
return View::make('budgets.delete')->with('budget', $budget);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy()
|
||||||
|
{
|
||||||
|
$result = $this->_repository->destroy(Input::get('id'));
|
||||||
|
if ($result === true) {
|
||||||
|
Session::flash('success', 'The budget was deleted.');
|
||||||
|
if (Input::get('from') == 'date') {
|
||||||
|
return Redirect::route('budgets.index');
|
||||||
|
} else {
|
||||||
|
return Redirect::route('budgets.index.budget');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Session::flash('error', 'Could not delete the budget. Check the logs to be sure.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return Redirect::route('budgets.index');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function edit(Budget $budget)
|
||||||
|
{
|
||||||
|
return View::make('budgets.edit')->with('budget', $budget);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return $this|\Illuminate\View\View
|
* @return $this|\Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
@@ -62,48 +91,6 @@ class BudgetController extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function edit(Budget $budget)
|
|
||||||
{
|
|
||||||
return View::make('budgets.edit')->with('budget', $budget);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function update()
|
|
||||||
{
|
|
||||||
$budget = $this->_repository->update(Input::all());
|
|
||||||
Session::flash('success', 'Budget "' . $budget->name . '" updated.');
|
|
||||||
|
|
||||||
if (Input::get('from') == 'date') {
|
|
||||||
return Redirect::route('budgets.index');
|
|
||||||
} else {
|
|
||||||
return Redirect::route('budgets.index.budget');
|
|
||||||
}
|
|
||||||
|
|
||||||
return Redirect::route('budgets.index');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function delete(Budget $budget)
|
|
||||||
{
|
|
||||||
return View::make('budgets.delete')->with('budget', $budget);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function destroy()
|
|
||||||
{
|
|
||||||
$result = $this->_repository->destroy(Input::get('id'));
|
|
||||||
if ($result === true) {
|
|
||||||
Session::flash('success', 'The budget was deleted.');
|
|
||||||
if (Input::get('from') == 'date') {
|
|
||||||
return Redirect::route('budgets.index');
|
|
||||||
} else {
|
|
||||||
return Redirect::route('budgets.index.budget');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Session::flash('error', 'Could not delete the budget. Check the logs to be sure.');
|
|
||||||
}
|
|
||||||
return Redirect::route('budgets.index');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Budget $budget
|
* @param Budget $budget
|
||||||
*
|
*
|
||||||
@@ -111,43 +98,26 @@ class BudgetController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function show(Budget $budget)
|
public function show(Budget $budget)
|
||||||
{
|
{
|
||||||
return $budget->id;
|
$filters = [];
|
||||||
// /** @var \Budget $budget */
|
|
||||||
// $budget = $this->_budgets->find($budgetId);
|
|
||||||
//
|
|
||||||
// $list = $budget->transactionjournals()->get();
|
|
||||||
// $return = [];
|
|
||||||
// /** @var \TransactionJournal $entry */
|
|
||||||
// foreach ($list as $entry) {
|
|
||||||
// $month = $entry->date->format('F Y');
|
|
||||||
// $return[$month] = isset($return[$month]) ? $return[$month] : [];
|
|
||||||
// $return[$month][] = $entry;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// $str = '';
|
|
||||||
//
|
|
||||||
// foreach ($return as $month => $set) {
|
|
||||||
// $str .= '<h1>' . $month . '</h1>';
|
|
||||||
// /** @var \TransactionJournal $tj */
|
|
||||||
// $sum = 0;
|
|
||||||
// foreach ($set as $tj) {
|
|
||||||
// $str .= '#' . $tj->id . ' ' . $tj->description . ': ';
|
|
||||||
//
|
|
||||||
// foreach ($tj->transactions as $index => $t) {
|
|
||||||
// $str .= $t->amount . ', ';
|
|
||||||
// if ($index == 0) {
|
|
||||||
// $sum += $t->amount;
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// $str .= '<br>';
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// $str .= 'sum: ' . $sum . '<br><br>';
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return $str;
|
|
||||||
|
|
||||||
|
if (!is_null(Input::get('rep'))) {
|
||||||
|
$repetitionId = intval(Input::get('rep'));
|
||||||
|
$repetitions = $this->_budgets->organizeRepetition($budget, $repetitionId);
|
||||||
|
$filters[] = $repetitions[0]['limit'];
|
||||||
|
$filters[] = $repetitions[0]['limitrepetition'];
|
||||||
|
} else {
|
||||||
|
if (Input::get('noenvelope') == 'true') {
|
||||||
|
$repetitions = $this->_budgets->outsideRepetitions($budget);
|
||||||
|
$filters[] = 'no_envelope';
|
||||||
|
} else {
|
||||||
|
// grab all limit repetitions, order them, show them:
|
||||||
|
$repetitions = $this->_budgets->organizeRepetitions($budget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return View::make('budgets.show')->with('budget', $budget)->with('repetitions', $repetitions)->with(
|
||||||
|
'filters', $filters
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -177,5 +147,19 @@ class BudgetController extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function update()
|
||||||
|
{
|
||||||
|
$budget = $this->_repository->update(Input::all());
|
||||||
|
Session::flash('success', 'Budget "' . $budget->name . '" updated.');
|
||||||
|
|
||||||
|
if (Input::get('from') == 'date') {
|
||||||
|
return Redirect::route('budgets.index');
|
||||||
|
} else {
|
||||||
|
return Redirect::route('budgets.index.budget');
|
||||||
|
}
|
||||||
|
|
||||||
|
return Redirect::route('budgets.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@@ -21,11 +21,11 @@ class ChartController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ARI $accounts
|
* @param ARI $accounts
|
||||||
* @param TJRI $journals
|
* @param TJRI $journals
|
||||||
* @param PHI $preferences
|
* @param PHI $preferences
|
||||||
* @param tk $toolkit
|
* @param tk $toolkit
|
||||||
* @param BRI $budgets
|
* @param BRI $budgets
|
||||||
*/
|
*/
|
||||||
public function __construct(ARI $accounts, TJRI $journals, PHI $preferences, tk $toolkit, BRI $budgets)
|
public function __construct(ARI $accounts, TJRI $journals, PHI $preferences, tk $toolkit, BRI $budgets)
|
||||||
{
|
{
|
||||||
@@ -85,6 +85,7 @@ class ChartController extends BaseController
|
|||||||
$current->addDay();
|
$current->addDay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response::json($return);
|
return Response::json($return);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,6 +119,7 @@ class ChartController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return View::make('charts.info')->with('rows', $result)->with('sum', $sum);
|
return View::make('charts.info')->with('rows', $result)->with('sum', $sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,14 +181,9 @@ class ChartController extends BaseController
|
|||||||
|
|
||||||
$repeatFreq = Config::get('firefly.range_to_repeat_freq.' . Session::get('range'));
|
$repeatFreq = Config::get('firefly.range_to_repeat_freq.' . Session::get('range'));
|
||||||
|
|
||||||
$dateFormats = Config::get('firefly.date_formats_by_period.' . $repeatFreq);
|
|
||||||
if (is_null($dateFormats)) {
|
|
||||||
throw new FireflyException('No date formats for ' . \Session::get('range'));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$limitInPeriod = 'Envelope for XXX';
|
||||||
$limitInPeriod = 'Envelope for ' . $start->format($dateFormats['display_date']);
|
$spentInPeriod = 'Spent in XXX';
|
||||||
$spentInPeriod = 'Spent in ' . $start->format($dateFormats['display_date']);
|
|
||||||
|
|
||||||
$data['series'] = [
|
$data['series'] = [
|
||||||
[
|
[
|
||||||
@@ -217,6 +214,7 @@ class ChartController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response::json($data);
|
return Response::json($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -17,11 +17,11 @@ class HomeController extends BaseController
|
|||||||
protected $_tk;
|
protected $_tk;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ARI $accounts
|
* @param ARI $accounts
|
||||||
* @param PHI $preferences
|
* @param PHI $preferences
|
||||||
* @param TJRI $journal
|
* @param TJRI $journal
|
||||||
* @param Toolkit $toolkit
|
* @param Toolkit $toolkit
|
||||||
* @param BRI $budgets
|
* @param BRI $budgets
|
||||||
*/
|
*/
|
||||||
public function __construct(ARI $accounts, PHI $preferences, TJRI $journal, Toolkit $toolkit, BRI $budgets)
|
public function __construct(ARI $accounts, PHI $preferences, TJRI $journal, Toolkit $toolkit, BRI $budgets)
|
||||||
{
|
{
|
||||||
@@ -72,6 +72,7 @@ class HomeController extends BaseController
|
|||||||
} else {
|
} else {
|
||||||
$transactions = array_chunk($transactions, 3);
|
$transactions = array_chunk($transactions, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// build the home screen:
|
// build the home screen:
|
||||||
return View::make('index')->with('count', $count)->with('transactions', $transactions)->with(
|
return View::make('index')->with('count', $count)->with('transactions', $transactions)->with(
|
||||||
'budgets', $budgets
|
'budgets', $budgets
|
||||||
@@ -84,6 +85,7 @@ class HomeController extends BaseController
|
|||||||
public function flush()
|
public function flush()
|
||||||
{
|
{
|
||||||
Cache::flush();
|
Cache::flush();
|
||||||
|
|
||||||
return Redirect::route('index');
|
return Redirect::route('index');
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -33,11 +33,12 @@ class LimitController extends BaseController
|
|||||||
{
|
{
|
||||||
$periods = \Config::get('firefly.periods_to_text');
|
$periods = \Config::get('firefly.periods_to_text');
|
||||||
$prefilled = [
|
$prefilled = [
|
||||||
'startdate' => Input::get('startdate') ? : date('Y-m-d'),
|
'startdate' => Input::get('startdate') ? : date('Y-m-d'),
|
||||||
'repeat_freq' => Input::get('repeat_freq') ? : 'monthly'
|
'repeat_freq' => Input::get('repeat_freq') ? : 'monthly'
|
||||||
];
|
];
|
||||||
|
|
||||||
$budgets = $this->_budgets->getAsSelectList();
|
$budgets = $this->_budgets->getAsSelectList();
|
||||||
|
|
||||||
return View::make('limits.create')->with('budgets', $budgets)->with('budget_id', $budgetId)->with(
|
return View::make('limits.create')->with('budgets', $budgets)->with('budget_id', $budgetId)->with(
|
||||||
'periods', $periods
|
'periods', $periods
|
||||||
)->with('prefilled', $prefilled);
|
)->with('prefilled', $prefilled);
|
||||||
@@ -54,11 +55,11 @@ class LimitController extends BaseController
|
|||||||
$budgets = $this->_budgets->getAsSelectList();
|
$budgets = $this->_budgets->getAsSelectList();
|
||||||
|
|
||||||
$periods = [
|
$periods = [
|
||||||
'weekly' => 'A week',
|
'weekly' => 'A week',
|
||||||
'monthly' => 'A month',
|
'monthly' => 'A month',
|
||||||
'quarterly' => 'A quarter',
|
'quarterly' => 'A quarter',
|
||||||
'half-year' => 'Six months',
|
'half-year' => 'Six months',
|
||||||
'yearly' => 'A year',
|
'yearly' => 'A year',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
@@ -67,6 +68,7 @@ class LimitController extends BaseController
|
|||||||
'periods', $periods
|
'periods', $periods
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return View::make('error')->with('message', 'No such limit.');
|
return View::make('error')->with('message', 'No such limit.');
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -87,15 +89,18 @@ class LimitController extends BaseController
|
|||||||
$limit->amount = floatval(Input::get('amount'));
|
$limit->amount = floatval(Input::get('amount'));
|
||||||
if (!$limit->save()) {
|
if (!$limit->save()) {
|
||||||
Session::flash('error', 'Could not save new limit: ' . $limit->errors()->first());
|
Session::flash('error', 'Could not save new limit: ' . $limit->errors()->first());
|
||||||
|
|
||||||
return Redirect::route('budgets.limits.edit', $limit->id)->withInput();
|
return Redirect::route('budgets.limits.edit', $limit->id)->withInput();
|
||||||
} else {
|
} else {
|
||||||
Session::flash('success', 'Limit saved!');
|
Session::flash('success', 'Limit saved!');
|
||||||
foreach ($limit->limitrepetitions()->get() as $rep) {
|
foreach ($limit->limitrepetitions()->get() as $rep) {
|
||||||
$rep->delete();
|
$rep->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Redirect::route('budgets.index');
|
return Redirect::route('budgets.index');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return View::make('error')->with('message', 'No limit!');
|
return View::make('error')->with('message', 'No limit!');
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -143,6 +148,7 @@ class LimitController extends BaseController
|
|||||||
|
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
$limit->delete();
|
$limit->delete();
|
||||||
|
|
||||||
return Redirect::route('budgets.index');
|
return Redirect::route('budgets.index');
|
||||||
} else {
|
} else {
|
||||||
return View::make('error')->with('message', 'No such limit!');
|
return View::make('error')->with('message', 'No such limit!');
|
||||||
|
@@ -39,6 +39,7 @@ class MigrationController extends BaseController
|
|||||||
throw new \Firefly\Exception\FireflyException('Invalid file.');
|
throw new \Firefly\Exception\FireflyException('Invalid file.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<a href="' . route('index') . '">home</a>';
|
return '<a href="' . route('index') . '">home</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +68,7 @@ class MigrationController extends BaseController
|
|||||||
return View::make('error')->with('message', 'Invalid JSON content.');
|
return View::make('error')->with('message', 'Invalid JSON content.');
|
||||||
}
|
}
|
||||||
$this->_migration->migrate();
|
$this->_migration->migrate();
|
||||||
|
|
||||||
return Redirect::route('index');
|
return Redirect::route('index');
|
||||||
} else {
|
} else {
|
||||||
return View::make('error')->with('message', 'No file selected');
|
return View::make('error')->with('message', 'No file selected');
|
||||||
|
@@ -35,6 +35,7 @@ class PreferencesController extends BaseController
|
|||||||
|
|
||||||
// pref:
|
// pref:
|
||||||
$frontpage = $this->_preferences->get('frontpageAccounts', []);
|
$frontpage = $this->_preferences->get('frontpageAccounts', []);
|
||||||
|
|
||||||
return View::make('preferences.index')->with('accounts', $accounts)->with('frontpageAccounts', $frontpage)
|
return View::make('preferences.index')->with('accounts', $accounts)->with('frontpageAccounts', $frontpage)
|
||||||
->with('viewRange', $viewRangeValue);
|
->with('viewRange', $viewRangeValue);
|
||||||
}
|
}
|
||||||
@@ -60,6 +61,7 @@ class PreferencesController extends BaseController
|
|||||||
Session::forget('range');
|
Session::forget('range');
|
||||||
|
|
||||||
Session::flash('success', 'Preferences saved!');
|
Session::flash('success', 'Preferences saved!');
|
||||||
|
|
||||||
return Redirect::route('preferences');
|
return Redirect::route('preferences');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,19 +44,23 @@ class ProfileController extends BaseController
|
|||||||
/** @noinspection PhpUndefinedFieldInspection */
|
/** @noinspection PhpUndefinedFieldInspection */
|
||||||
if (!Hash::check(Input::get('old'), Auth::user()->password)) {
|
if (!Hash::check(Input::get('old'), Auth::user()->password)) {
|
||||||
Session::flash('error', 'Invalid current password!');
|
Session::flash('error', 'Invalid current password!');
|
||||||
|
|
||||||
return View::make('profile.change-password');
|
return View::make('profile.change-password');
|
||||||
}
|
}
|
||||||
if (strlen(Input::get('new1')) == 0 || strlen(Input::get('new2')) == 0) {
|
if (strlen(Input::get('new1')) == 0 || strlen(Input::get('new2')) == 0) {
|
||||||
Session::flash('error', 'Do fill in a password!');
|
Session::flash('error', 'Do fill in a password!');
|
||||||
|
|
||||||
return View::make('profile.change-password');
|
return View::make('profile.change-password');
|
||||||
}
|
}
|
||||||
if (Input::get('new1') == Input::get('old')) {
|
if (Input::get('new1') == Input::get('old')) {
|
||||||
Session::flash('error', 'The idea is to change your password.');
|
Session::flash('error', 'The idea is to change your password.');
|
||||||
|
|
||||||
return View::make('profile.change-password');
|
return View::make('profile.change-password');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input::get('new1') !== Input::get('new2')) {
|
if (Input::get('new1') !== Input::get('new2')) {
|
||||||
Session::flash('error', 'New passwords do not match!');
|
Session::flash('error', 'New passwords do not match!');
|
||||||
|
|
||||||
return View::make('profile.change-password');
|
return View::make('profile.change-password');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,6 +69,7 @@ class ProfileController extends BaseController
|
|||||||
$this->user->updatePassword(Auth::user(), Input::get('new1'));
|
$this->user->updatePassword(Auth::user(), Input::get('new1'));
|
||||||
|
|
||||||
Session::flash('success', 'Password changed!');
|
Session::flash('success', 'Password changed!');
|
||||||
|
|
||||||
return Redirect::route('profile');
|
return Redirect::route('profile');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,9 +18,9 @@ class TransactionController extends BaseController
|
|||||||
protected $_journal;
|
protected $_journal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ARI $accounts
|
* @param ARI $accounts
|
||||||
* @param Bud $budgets
|
* @param Bud $budgets
|
||||||
* @param Cat $categories
|
* @param Cat $categories
|
||||||
* @param TJRI $journal
|
* @param TJRI $journal
|
||||||
*/
|
*/
|
||||||
public function __construct(ARI $accounts, Bud $budgets, Cat $categories, TJRI $journal)
|
public function __construct(ARI $accounts, Bud $budgets, Cat $categories, TJRI $journal)
|
||||||
@@ -129,6 +129,7 @@ class TransactionController extends BaseController
|
|||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$transactions = $this->_journal->paginate(25);
|
$transactions = $this->_journal->paginate(25);
|
||||||
|
|
||||||
return View::make('transactions.index')->with('transactions', $transactions);
|
return View::make('transactions.index')->with('transactions', $transactions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,6 +144,7 @@ class TransactionController extends BaseController
|
|||||||
if ($journal) {
|
if ($journal) {
|
||||||
return View::make('transactions.show')->with('journal', $journal);
|
return View::make('transactions.show')->with('journal', $journal);
|
||||||
}
|
}
|
||||||
|
|
||||||
return View::make('error')->with('message', 'Invalid journal');
|
return View::make('error')->with('message', 'Invalid journal');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,8 +169,8 @@ class TransactionController extends BaseController
|
|||||||
|
|
||||||
// data to properly display form:
|
// data to properly display form:
|
||||||
$data = [
|
$data = [
|
||||||
'date' => $journal->date->format('Y-m-d'),
|
'date' => $journal->date->format('Y-m-d'),
|
||||||
'category' => '',
|
'category' => '',
|
||||||
'budget_id' => 0
|
'budget_id' => 0
|
||||||
];
|
];
|
||||||
$category = $journal->categories()->first();
|
$category = $journal->categories()->first();
|
||||||
@@ -196,10 +198,12 @@ class TransactionController extends BaseController
|
|||||||
$data['amount'] = floatval($journal->transactions[1]->amount);
|
$data['amount'] = floatval($journal->transactions[1]->amount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return View::make('transactions.edit')->with('journal', $journal)->with('accounts', $accounts)->with(
|
return View::make('transactions.edit')->with('journal', $journal)->with('accounts', $accounts)->with(
|
||||||
'what', $what
|
'what', $what
|
||||||
)->with('budgets', $budgets)->with('data', $data);
|
)->with('budgets', $budgets)->with('data', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return View::make('error')->with('message', 'Invalid journal');
|
return View::make('error')->with('message', 'Invalid journal');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,6 +274,7 @@ class TransactionController extends BaseController
|
|||||||
$journal->transactions[0]->save();
|
$journal->transactions[0]->save();
|
||||||
$journal->transactions[1]->save();
|
$journal->transactions[1]->save();
|
||||||
$journal->save();
|
$journal->save();
|
||||||
|
|
||||||
return Redirect::route('transactions.edit', $journal->id);
|
return Redirect::route('transactions.edit', $journal->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,14 +42,16 @@ class UserController extends BaseController
|
|||||||
{
|
{
|
||||||
$rememberMe = Input::get('remember_me') == '1';
|
$rememberMe = Input::get('remember_me') == '1';
|
||||||
$data = [
|
$data = [
|
||||||
'email' => Input::get('email'),
|
'email' => Input::get('email'),
|
||||||
'password' => Input::get('password')
|
'password' => Input::get('password')
|
||||||
];
|
];
|
||||||
if (Auth::attempt($data, $rememberMe)) {
|
if (Auth::attempt($data, $rememberMe)) {
|
||||||
Session::flash('success', 'Logged in!');
|
Session::flash('success', 'Logged in!');
|
||||||
|
|
||||||
return Redirect::route('index');
|
return Redirect::route('index');
|
||||||
}
|
}
|
||||||
Session::flash('error', 'No good!');
|
Session::flash('error', 'No good!');
|
||||||
|
|
||||||
return View::make('user.login');
|
return View::make('user.login');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,6 +65,7 @@ class UserController extends BaseController
|
|||||||
if (Config::get('auth.allow_register') !== true) {
|
if (Config::get('auth.allow_register') !== true) {
|
||||||
return View::make('error')->with('message', 'Not possible');
|
return View::make('error')->with('message', 'Not possible');
|
||||||
}
|
}
|
||||||
|
|
||||||
return View::make('user.register');
|
return View::make('user.register');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,11 +88,14 @@ class UserController extends BaseController
|
|||||||
if ($user) {
|
if ($user) {
|
||||||
if (Config::get('auth.verify_mail') === true) {
|
if (Config::get('auth.verify_mail') === true) {
|
||||||
$this->email->sendVerificationMail($user);
|
$this->email->sendVerificationMail($user);
|
||||||
|
|
||||||
return View::make('user.verification-pending');
|
return View::make('user.verification-pending');
|
||||||
}
|
}
|
||||||
$this->email->sendPasswordMail($user);
|
$this->email->sendPasswordMail($user);
|
||||||
|
|
||||||
return View::make('user.registered');
|
return View::make('user.registered');
|
||||||
}
|
}
|
||||||
|
|
||||||
return View::make('user.register');
|
return View::make('user.register');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +108,7 @@ class UserController extends BaseController
|
|||||||
{
|
{
|
||||||
Auth::logout();
|
Auth::logout();
|
||||||
Session::flush();
|
Session::flush();
|
||||||
|
|
||||||
return Redirect::route('index');
|
return Redirect::route('index');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,13 +133,16 @@ class UserController extends BaseController
|
|||||||
$user = $this->user->findByEmail(Input::get('email'));
|
$user = $this->user->findByEmail(Input::get('email'));
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
Session::flash('error', 'No good!');
|
Session::flash('error', 'No good!');
|
||||||
|
|
||||||
return View::make('user.remindme');
|
return View::make('user.remindme');
|
||||||
}
|
}
|
||||||
if (Config::get('auth.verify_reset') === true) {
|
if (Config::get('auth.verify_reset') === true) {
|
||||||
$this->email->sendResetVerification($user);
|
$this->email->sendResetVerification($user);
|
||||||
|
|
||||||
return View::make('user.verification-pending');
|
return View::make('user.verification-pending');
|
||||||
}
|
}
|
||||||
$this->email->sendPasswordMail($user);
|
$this->email->sendPasswordMail($user);
|
||||||
|
|
||||||
return View::make('user.registered');
|
return View::make('user.registered');
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -149,8 +159,10 @@ class UserController extends BaseController
|
|||||||
$user = $this->user->findByReset($reset);
|
$user = $this->user->findByReset($reset);
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$this->email->sendPasswordMail($user);
|
$this->email->sendPasswordMail($user);
|
||||||
|
|
||||||
return View::make('user.registered');
|
return View::make('user.registered');
|
||||||
}
|
}
|
||||||
|
|
||||||
return View::make('error')->with('message', 'Yo no hablo reset code!');
|
return View::make('error')->with('message', 'Yo no hablo reset code!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,15 +29,14 @@ class Budget implements BudgetInterface
|
|||||||
|
|
||||||
foreach ($budgets as $budget) {
|
foreach ($budgets as $budget) {
|
||||||
foreach ($budget->limits as $limit) {
|
foreach ($budget->limits as $limit) {
|
||||||
$dateFormats = \Config::get('firefly.date_formats_by_period.' . $limit->repeat_freq);
|
|
||||||
if (is_null($dateFormats)) {
|
|
||||||
throw new \Firefly\Exception\FireflyException('No date formats for ' . $limit->repeat_freq);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($limit->limitrepetitions as $rep) {
|
foreach ($limit->limitrepetitions as $rep) {
|
||||||
$periodOrder = $rep->startdate->format($dateFormats['group_date']);
|
$periodOrder = $rep->periodOrder();
|
||||||
$period = $rep->startdate->format($dateFormats['display_date']);
|
$period = $rep->periodShow();
|
||||||
$return[$periodOrder] = isset($return[$periodOrder]) ? $return[$periodOrder] : ['date' => $period];
|
$return[$periodOrder] = isset($return[$periodOrder])
|
||||||
|
? $return[$periodOrder]
|
||||||
|
: ['date' => $period,
|
||||||
|
'budget_id' => $limit->budget_id];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,17 +44,177 @@ class Budget implements BudgetInterface
|
|||||||
// put all the budgets under their respective date:
|
// put all the budgets under their respective date:
|
||||||
foreach ($budgets as $budget) {
|
foreach ($budgets as $budget) {
|
||||||
foreach ($budget->limits as $limit) {
|
foreach ($budget->limits as $limit) {
|
||||||
$dateFormats = \Config::get('firefly.date_formats_by_period.' . $limit->repeat_freq);
|
|
||||||
foreach ($limit->limitrepetitions as $rep) {
|
foreach ($limit->limitrepetitions as $rep) {
|
||||||
$rep->left = $rep->left();
|
$rep->left = $rep->left();
|
||||||
|
|
||||||
$month = $rep->startdate->format($dateFormats['group_date']);
|
$month = $rep->periodOrder();
|
||||||
$return[$month]['limitrepetitions'][] = $rep;
|
$return[$month]['limitrepetitions'][] = $rep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
krsort($return);
|
krsort($return);
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
/**
|
||||||
|
* @param \Budget $budget
|
||||||
|
* @param $repetitionId
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function organizeRepetition(\Budget $budget, $repetitionId)
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
$inRepetition = [];
|
||||||
|
$repetition = \LimitRepetition::with('limit', 'limit.budget')->leftJoin(
|
||||||
|
'limits', 'limit_repetitions.limit_id', '=', 'limits.id'
|
||||||
|
)->leftJoin('components', 'limits.component_id', '=', 'components.id')->where(
|
||||||
|
'components.user_id', \Auth::user()->id
|
||||||
|
)
|
||||||
|
->where('limit_repetitions.id', $repetitionId)->first(['limit_repetitions.*']);
|
||||||
|
|
||||||
|
// get transactions:
|
||||||
|
$set = $repetition->limit->budget->transactionjournals()->with(
|
||||||
|
'transactions', 'transactions.account', 'components', 'transactiontype'
|
||||||
|
)->leftJoin(
|
||||||
|
'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
|
||||||
|
)->where('transaction_types.type', 'Withdrawal')->where(
|
||||||
|
'date', '>=', $repetition->startdate->format('Y-m-d')
|
||||||
|
)->where('date', '<=', $repetition->enddate->format('Y-m-d'))->orderBy('date', 'DESC')->orderBy(
|
||||||
|
'id', 'DESC'
|
||||||
|
)->get(['transaction_journals.*']);
|
||||||
|
|
||||||
|
$result[0] = [
|
||||||
|
'date' => $repetition->periodShow(),
|
||||||
|
'limit' => $repetition->limit,
|
||||||
|
'limitrepetition' => $repetition,
|
||||||
|
'journals' => $set,
|
||||||
|
'paginated' => false
|
||||||
|
];
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Budget $budget
|
||||||
|
*
|
||||||
|
* @return mixed|void
|
||||||
|
*/
|
||||||
|
public function organizeRepetitions(\Budget $budget)
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
$inRepetition = [];
|
||||||
|
foreach ($budget->limits as $limit) {
|
||||||
|
foreach ($limit->limitrepetitions as $repetition) {
|
||||||
|
$order = $repetition->periodOrder();
|
||||||
|
$result[$order] = [
|
||||||
|
'date' => $repetition->periodShow(),
|
||||||
|
'limitrepetition' => $repetition,
|
||||||
|
'limit' => $limit,
|
||||||
|
'journals' => [],
|
||||||
|
'paginated' => false
|
||||||
|
];
|
||||||
|
$transactions = [];
|
||||||
|
$set = $budget->transactionjournals()->with(
|
||||||
|
'transactions', 'transactions.account', 'components', 'transactiontype'
|
||||||
|
)->leftJoin(
|
||||||
|
'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
|
||||||
|
)->where('transaction_types.type', 'Withdrawal')->where(
|
||||||
|
'date', '>=', $repetition->startdate->format('Y-m-d')
|
||||||
|
)->where('date', '<=', $repetition->enddate->format('Y-m-d'))->orderBy('date', 'DESC')->orderBy(
|
||||||
|
'id', 'DESC'
|
||||||
|
)->get(['transaction_journals.*']);
|
||||||
|
foreach ($set as $entry) {
|
||||||
|
$transactions[] = $entry;
|
||||||
|
$inRepetition[] = $entry->id;
|
||||||
|
}
|
||||||
|
$result[$order]['journals'] = $transactions;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$query = $budget->transactionjournals()->with(
|
||||||
|
'transactions', 'transactions.account', 'components', 'transactiontype',
|
||||||
|
'transactions.account.accounttype'
|
||||||
|
)->whereNotIn(
|
||||||
|
'transaction_journals.id', $inRepetition
|
||||||
|
)->orderBy('date', 'DESC')->orderBy(
|
||||||
|
'transaction_journals.id', 'DESC'
|
||||||
|
);
|
||||||
|
|
||||||
|
// build paginator:
|
||||||
|
$perPage = 25;
|
||||||
|
$totalItems = $query->count();
|
||||||
|
$page = intval(\Input::get('page')) > 1 ? intval(\Input::get('page')) : 1;
|
||||||
|
$skip = ($page - 1) * $perPage;
|
||||||
|
$set = $query->skip($skip)->take($perPage)->get();
|
||||||
|
|
||||||
|
// stupid paginator!
|
||||||
|
$items = [];
|
||||||
|
/** @var $item \TransactionJournal */
|
||||||
|
foreach ($set as $item) {
|
||||||
|
$items[] = $item;
|
||||||
|
}
|
||||||
|
$paginator = \Paginator::make($items, $totalItems, $perPage);
|
||||||
|
$result['0000'] = ['date' => 'Not in an envelope', 'limit' => null, 'paginated' => true,
|
||||||
|
'journals' => $paginator];
|
||||||
|
|
||||||
|
krsort($result);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Budget $budget
|
||||||
|
*
|
||||||
|
* @return mixed|void
|
||||||
|
*/
|
||||||
|
public function outsideRepetitions(\Budget $budget)
|
||||||
|
{
|
||||||
|
$inRepetitions = [];
|
||||||
|
foreach ($budget->limits as $limit) {
|
||||||
|
foreach ($limit->limitrepetitions as $repetition) {
|
||||||
|
$set = $budget->transactionjournals()->leftJoin(
|
||||||
|
'transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id'
|
||||||
|
)->where('transaction_types.type', 'Withdrawal')->where(
|
||||||
|
'date', '>=', $repetition->startdate->format('Y-m-d')
|
||||||
|
)->where('date', '<=', $repetition->enddate->format('Y-m-d'))->orderBy('date', 'DESC')->get(
|
||||||
|
['transaction_journals.id']
|
||||||
|
);
|
||||||
|
foreach ($set as $item) {
|
||||||
|
$inRepetitions[] = $item->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $budget->transactionjournals()->with(
|
||||||
|
'transactions', 'transactions.account', 'components', 'transactiontype',
|
||||||
|
'transactions.account.accounttype'
|
||||||
|
)->whereNotIn(
|
||||||
|
'transaction_journals.id', $inRepetitions
|
||||||
|
)->orderBy('date', 'DESC')->orderBy(
|
||||||
|
'transaction_journals.id', 'DESC'
|
||||||
|
);
|
||||||
|
|
||||||
|
// build paginator:
|
||||||
|
$perPage = 25;
|
||||||
|
$totalItems = $query->count();
|
||||||
|
$page = intval(\Input::get('page')) > 1 ? intval(\Input::get('page')) : 1;
|
||||||
|
$skip = ($page - 1) * $perPage;
|
||||||
|
$set = $query->skip($skip)->take($perPage)->get();
|
||||||
|
|
||||||
|
// stupid paginator!
|
||||||
|
$items = [];
|
||||||
|
/** @var $item \TransactionJournal */
|
||||||
|
foreach ($set as $item) {
|
||||||
|
$items[] = $item;
|
||||||
|
}
|
||||||
|
$paginator = \Paginator::make($items, $totalItems, $perPage);
|
||||||
|
$result = [0 => ['date' => 'Not in an envelope', 'limit' => null, 'paginated' => true,
|
||||||
|
'journals' => $paginator]];
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
@@ -15,4 +15,27 @@ interface BudgetInterface {
|
|||||||
*/
|
*/
|
||||||
public function organizeByDate(Collection $budgets);
|
public function organizeByDate(Collection $budgets);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Budget $budget
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function organizeRepetitions(\Budget $budget);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Budget $budget
|
||||||
|
* @param $repetitionId
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function organizeRepetition(\Budget $budget, $repetitionId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Budget $budget
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function outsideRepetitions(\Budget $budget);
|
||||||
|
|
||||||
}
|
}
|
@@ -81,5 +81,74 @@ class LimitRepetition extends Ardent
|
|||||||
return $this->belongsTo('Limit');
|
return $this->belongsTo('Limit');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string used to sort this particular repetition
|
||||||
|
* based on the date and period it falls into. Ie. the limit
|
||||||
|
* repeats monthly and the start date is 12 dec 2012, this will
|
||||||
|
* return 2012-12.
|
||||||
|
*/
|
||||||
|
public function periodOrder()
|
||||||
|
{
|
||||||
|
if (is_null($this->repeat_freq)) {
|
||||||
|
$this->repeat_freq = $this->limit->repeat_freq;
|
||||||
|
}
|
||||||
|
switch ($this->repeat_freq) {
|
||||||
|
default:
|
||||||
|
throw new \Firefly\Exception\FireflyException('No date formats for frequency "' . $this->repeat_freq
|
||||||
|
. '"!');
|
||||||
|
break;
|
||||||
|
case 'daily':
|
||||||
|
return $this->startdate->format('Ymd').'-5';
|
||||||
|
break;
|
||||||
|
case 'weekly':
|
||||||
|
return $this->startdate->format('Ymd').'4';
|
||||||
|
break;
|
||||||
|
case 'monthly':
|
||||||
|
return $this->startdate->format('Ymd') . '-3';
|
||||||
|
break;
|
||||||
|
case 'quarterly':
|
||||||
|
return $this->startdate->format('Ymd') . '-2';
|
||||||
|
break;
|
||||||
|
case 'half-year':
|
||||||
|
return $this->startdate->format('Ymd') . '-1';
|
||||||
|
break;
|
||||||
|
case 'yearly':
|
||||||
|
return $this->startdate->format('Ymd').'-0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Same as above, just with a more natural view. So "March 2012".
|
||||||
|
*/
|
||||||
|
public function periodShow()
|
||||||
|
{
|
||||||
|
if (is_null($this->repeat_freq)) {
|
||||||
|
$this->repeat_freq = $this->limit->repeat_freq;
|
||||||
|
}
|
||||||
|
switch ($this->repeat_freq) {
|
||||||
|
default:
|
||||||
|
throw new \Firefly\Exception\FireflyException('No date formats for frequency "' . $this->repeat_freq
|
||||||
|
. '"!');
|
||||||
|
break;
|
||||||
|
case 'daily':
|
||||||
|
return $this->startdate->format('j F Y');
|
||||||
|
break;
|
||||||
|
case 'weekly':
|
||||||
|
return $this->startdate->format('\W\e\e\k W, Y');
|
||||||
|
break;
|
||||||
|
case 'monthly':
|
||||||
|
return $this->startdate->format('F Y');
|
||||||
|
break;
|
||||||
|
case 'half-year':
|
||||||
|
case 'quarterly':
|
||||||
|
return $this->startdate->format('M Y') . ' - ' . $this->enddate->format('M Y');
|
||||||
|
break;
|
||||||
|
case 'yearly':
|
||||||
|
return $this->startdate->format('Y');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@@ -74,7 +74,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<small>
|
<small>
|
||||||
CLOSURE TODO
|
{{$rep->periodShow()}}
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
@if($limit->repeats == 1)
|
@if($limit->repeats == 1)
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
@endforeach
|
@endforeach
|
||||||
<p style="margin-top:5px;">
|
<p style="margin-top:5px;">
|
||||||
<a href="{{route('budgets.limits.create',$budget->id)}}" class="btn btn-default btn-xs"><span
|
<a href="{{route('budgets.limits.create',$budget->id)}}?from=budget" class="btn btn-default btn-xs"><span
|
||||||
class="glyphicon-plus-sign glyphicon"></span> Add another envelope</a>
|
class="glyphicon-plus-sign glyphicon"></span> Add another envelope</a>
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
|
@@ -53,7 +53,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{route('budgets.show',$repetition->limit->budget->id)}}#transactions-in-this-period">
|
<a href="{{route('budgets.show',$repetition->limit->budget->id)}}?rep={{$repetition->id}}">
|
||||||
{{{$repetition->limit->budget->name}}}
|
{{{$repetition->limit->budget->name}}}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
@@ -1,4 +1,69 @@
|
|||||||
@extends('layouts.default')
|
@extends('layouts.default')
|
||||||
@section('content')
|
@section('content')
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
|
<h1>Firefly
|
||||||
|
<small>Overview for budget "{{{$budget->name}}}"</small>
|
||||||
|
</h1>
|
||||||
|
@if(count($filters) == 0)
|
||||||
|
<p class="lead">Budgets can help you cut back on spending.</p>
|
||||||
|
@else
|
||||||
|
<p class="lead">
|
||||||
|
@if(isset($filters[0]) && is_object($filters[0]) && get_class($filters[0]) == 'Limit')
|
||||||
|
{{{$repetitions[0]['limitrepetition']->periodShow()}}}, {{mf($repetitions[0]['limit']->amount,false)}}
|
||||||
|
@elseif(isset($filters[0]) && $filters[0] == 'no_envelope')
|
||||||
|
These transactions are not caught in an envelope.
|
||||||
|
@endif
|
||||||
|
</p>
|
||||||
|
<p class="text-info">
|
||||||
|
<a href="{{route('budgets.show',$budget->id)}}">See the whole picture</a>
|
||||||
|
</p>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
|
<p class="small text-center">(Some sort of chart here)</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@foreach($repetitions as $repetition)
|
||||||
|
@if(isset($repetition['journals']) && count($repetition['journals']) > 0)
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
|
||||||
|
|
||||||
|
@if($repetition['paginated'] == true)
|
||||||
|
<h4>
|
||||||
|
<a href="{{route('budgets.show',$budget->id)}}?noenvelope=true">
|
||||||
|
{{$repetition['date']}}</a> <small>paginated</small></h4>
|
||||||
|
@else
|
||||||
|
<h4>
|
||||||
|
<a href="{{route('budgets.show',$budget->id)}}?rep={{$repetition['limitrepetition']->id}}">
|
||||||
|
{{$repetition['date']}}
|
||||||
|
</a>
|
||||||
|
</h4>
|
||||||
|
<small>{{mf($repetition['limit']->amount,false)}} (left: {{mf($repetition['limitrepetition']->left(),false)}})</small>
|
||||||
|
@endif
|
||||||
|
</h4>
|
||||||
|
@if($repetition['paginated'] == true)
|
||||||
|
@include('paginated.transactions',['journals' => $repetition['journals']])
|
||||||
|
@else
|
||||||
|
@include('lists.transactions',['journals' => $repetition['journals'],'sum' => true])
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<h4>{{$repetition['date']}}
|
||||||
|
</h4>
|
||||||
|
<p><em>No transactions</em></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
|
||||||
@stop
|
@stop
|
79
app/views/lists/transactions.blade.php
Normal file
79
app/views/lists/transactions.blade.php
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<table class="table table-striped table-condensed">
|
||||||
|
<tr>
|
||||||
|
<th colspan="2"></th>
|
||||||
|
<th>Date</th>
|
||||||
|
<th>Description</th>
|
||||||
|
<th>Amount (€)</th>
|
||||||
|
<th>From</th>
|
||||||
|
<th>To</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
<?php $total = 0; ?>
|
||||||
|
@foreach($journals as $journal)
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@if($journal->transactiontype->type == 'Withdrawal')
|
||||||
|
<span class="glyphicon glyphicon-arrow-left" title="Withdrawal"></span>
|
||||||
|
@endif
|
||||||
|
@if($journal->transactiontype->type == 'Deposit')
|
||||||
|
<span class="glyphicon glyphicon-arrow-right" title="Deposit"></span>
|
||||||
|
@endif
|
||||||
|
@if($journal->transactiontype->type == 'Transfer')
|
||||||
|
<span class="glyphicon glyphicon-resize-full" title="Transfer"></span>
|
||||||
|
@endif
|
||||||
|
@if($journal->transactiontype->type == 'Opening balance')
|
||||||
|
<span class="glyphicon glyphicon-ban-circle" title="Opening balance"></span>
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@foreach($journal->components as $component)
|
||||||
|
@if($component->class == 'Budget')
|
||||||
|
<a href="#budget-overview"><span class="glyphicon glyphicon-tasks" title="Budget: {{{$component->name}}}"></span></a>
|
||||||
|
@endif
|
||||||
|
@if($component->class == 'Category')
|
||||||
|
<a href="#category-overview"><span class="glyphicon glyphicon-tag" title="Category: {{{$component->name}}}"></span></a>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{$journal->date->format('d F Y')}}
|
||||||
|
</td>
|
||||||
|
<td><a href="{{route('transactions.show',$journal->id)}}" title="{{{$journal->description}}}">{{{$journal->description}}}</a></td>
|
||||||
|
<td>
|
||||||
|
@if($journal->transactiontype->type == 'Withdrawal')
|
||||||
|
<span class="text-danger">{{mf($journal->transactions[1]->amount,false)}}</span>
|
||||||
|
<?php $total -= $journal->transactions[1]->amount;?>
|
||||||
|
@endif
|
||||||
|
@if($journal->transactiontype->type == 'Deposit')
|
||||||
|
<span class="text-success">{{mf($journal->transactions[1]->amount,false)}}</span>
|
||||||
|
@endif
|
||||||
|
@if($journal->transactiontype->type == 'Transfer')
|
||||||
|
<span class="text-info">{{mf($journal->transactions[1]->amount,false)}}</span>
|
||||||
|
|
||||||
|
@endif
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{route('accounts.show',$journal->transactions[0]->account_id)}}">{{{$journal->transactions[0]->account->name}}}</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{route('accounts.show',$journal->transactions[1]->account_id)}}">{{{$journal->transactions[1]->account->name}}}</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="btn-group btn-group-xs">
|
||||||
|
<a href="{{route('transactions.edit',$journal->id)}}" class="btn btn-default">
|
||||||
|
<span class="glyphicon glyphicon-pencil"></span>
|
||||||
|
<a href="{{route('transactions.delete',$journal->id)}}" class="btn btn-danger">
|
||||||
|
<span class="glyphicon glyphicon-trash"></span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
@if(isset($sum) && $sum == true)
|
||||||
|
<tr>
|
||||||
|
<td colspan="4">Sum:</td>
|
||||||
|
<td colspan="4">{{mf($total)}}</td>
|
||||||
|
</tr>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
</table>
|
@@ -1,71 +1,3 @@
|
|||||||
<table class="table table-striped table-condensed">
|
{{$journals->links()}}
|
||||||
<tr>
|
@include('lists.transactions')
|
||||||
<th colspan="2"></th>
|
|
||||||
<th>Date</th>
|
|
||||||
<th>Description</th>
|
|
||||||
<th>Amount (€)</th>
|
|
||||||
<th>From</th>
|
|
||||||
<th>To</th>
|
|
||||||
<th></th>
|
|
||||||
</tr>
|
|
||||||
@foreach($journals as $journal)
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
@if($journal->transactiontype->type == 'Withdrawal')
|
|
||||||
<span class="glyphicon glyphicon-arrow-left" title="Withdrawal"></span>
|
|
||||||
@endif
|
|
||||||
@if($journal->transactiontype->type == 'Deposit')
|
|
||||||
<span class="glyphicon glyphicon-arrow-right" title="Deposit"></span>
|
|
||||||
@endif
|
|
||||||
@if($journal->transactiontype->type == 'Transfer')
|
|
||||||
<span class="glyphicon glyphicon-resize-full" title="Transfer"></span>
|
|
||||||
@endif
|
|
||||||
@if($journal->transactiontype->type == 'Opening balance')
|
|
||||||
<span class="glyphicon glyphicon-ban-circle" title="Opening balance"></span>
|
|
||||||
@endif
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@foreach($journal->components as $component)
|
|
||||||
@if($component->class == 'Budget')
|
|
||||||
<a href="#budget-overview"><span class="glyphicon glyphicon-tasks" title="Budget: {{{$component->name}}}"></span></a>
|
|
||||||
@endif
|
|
||||||
@if($component->class == 'Category')
|
|
||||||
<a href="#category-overview"><span class="glyphicon glyphicon-tag" title="Category: {{{$component->name}}}"></span></a>
|
|
||||||
@endif
|
|
||||||
@endforeach
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{{$journal->date->format('d F Y')}}
|
|
||||||
</td>
|
|
||||||
<td><a href="{{route('transactions.show',$journal->id)}}" title="{{{$journal->description}}}">{{{$journal->description}}}</a></td>
|
|
||||||
<td>
|
|
||||||
@if($journal->transactiontype->type == 'Withdrawal')
|
|
||||||
<span class="text-danger">{{mf($journal->transactions[1]->amount,false)}}</span>
|
|
||||||
@endif
|
|
||||||
@if($journal->transactiontype->type == 'Deposit')
|
|
||||||
<span class="text-success">{{mf($journal->transactions[1]->amount,false)}}</span>
|
|
||||||
@endif
|
|
||||||
@if($journal->transactiontype->type == 'Transfer')
|
|
||||||
<span class="text-info">{{mf($journal->transactions[1]->amount,false)}}</span>
|
|
||||||
@endif
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="{{route('accounts.show',$journal->transactions[0]->account_id)}}">{{{$journal->transactions[0]->account->name}}}</a>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<a href="{{route('accounts.show',$journal->transactions[1]->account_id)}}">{{{$journal->transactions[1]->account->name}}}</a>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div class="btn-group btn-group-xs">
|
|
||||||
<a href="{{route('transactions.edit',$journal->id)}}" class="btn btn-default">
|
|
||||||
<span class="glyphicon glyphicon-pencil"></span>
|
|
||||||
<a href="{{route('transactions.delete',$journal->id)}}" class="btn btn-danger">
|
|
||||||
<span class="glyphicon glyphicon-trash"></span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
@endforeach
|
|
||||||
</table>
|
|
||||||
|
|
||||||
{{$journals->links()}}
|
{{$journals->links()}}
|
@@ -1,17 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
use Carbon\Carbon;
|
||||||
|--------------------------------------------------------------------------
|
use Firefly\Exception\FireflyException;
|
||||||
| Create The Application
|
|
||||||
|--------------------------------------------------------------------------
|
|
||||||
|
|
|
||||||
| The first thing we will do is create a new Laravel application instance
|
|
||||||
| which serves as the "glue" for all the components of Laravel, and is
|
|
||||||
| the IoC container for the system binding all of the various parts.
|
|
||||||
|
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!function_exists('mf')) {
|
if (!function_exists('mf')) {
|
||||||
function mf($n, $coloured = true)
|
function mf($n, $coloured = true)
|
||||||
@@ -30,12 +20,13 @@ if (!function_exists('mf')) {
|
|||||||
if ($coloured === true && $n < 0) {
|
if ($coloured === true && $n < 0) {
|
||||||
return '<span class="text-danger">€ ' . $string . '</span>';
|
return '<span class="text-danger">€ ' . $string . '</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return '€ ' . $string;
|
return '€ ' . $string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$app = new Illuminate\Foundation\Application;
|
|
||||||
|
|
||||||
|
$app = new Illuminate\Foundation\Application;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -102,7 +93,8 @@ Event::subscribe('Firefly\Helper\Form\FormTrigger');
|
|||||||
// do something with events:
|
// do something with events:
|
||||||
Event::subscribe('Firefly\Trigger\Limits\EloquentLimitTrigger');
|
Event::subscribe('Firefly\Trigger\Limits\EloquentLimitTrigger');
|
||||||
|
|
||||||
App::booted(function() {
|
App::booted(
|
||||||
|
function () {
|
||||||
$forms = new \Firefly\Helper\Form\FormTrigger;
|
$forms = new \Firefly\Helper\Form\FormTrigger;
|
||||||
$forms->registerFormExtensions();
|
$forms->registerFormExtensions();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user