Built the 'show'-view for budgets.

This commit is contained in:
Sander Dorigo
2014-11-08 19:11:51 +01:00
parent ac299e7279
commit 873384a34b
8 changed files with 231 additions and 449 deletions

View File

@@ -8,6 +8,9 @@ use FireflyIII\Exception\NotImplementedException;
use Illuminate\Support\MessageBag;
/**
* Class BudgetController
*/
class BudgetController extends BaseController
{
@@ -141,7 +144,16 @@ class BudgetController extends BaseController
App::abort(500);
}
return View::make('budgets.show');
if (is_null($repetition)) {
// get all other repetitions:
$limits = $budget->limits()->orderBy('startdate', 'DESC')->get();
} else {
// get nothing? i dunno
$limits = [$repetition->limit];
}
return View::make('budgets.show', compact('limits', 'budget', 'repetition'));
}
/**
@@ -185,85 +197,6 @@ class BudgetController extends BaseController
}
// /**
// * @return $this|\Illuminate\View\View
// */
// public function indexByBudget()
// {
// View::share('subTitleIcon', 'fa-folder-open');
//
// $budgets = $this->_repository->get();
//
// return View::make('budgets.indexByBudget')->with('budgets', $budgets)->with('today', new Carbon)
// ->with('subTitle', 'Grouped by budget');
//
// }
//
// /**
// * @return $this
// */
// public function indexByDate()
// {
// View::share('subTitleIcon', 'fa-calendar');
//
// // get a list of dates by getting all repetitions:
// $set = $this->_repository->get();
// $budgets = $this->_budgets->organizeByDate($set);
//
// return View::make('budgets.indexByDate')->with('budgets', $budgets)
// ->with('subTitle', 'Grouped by date');
//
//
// }
//
// /**
// * Three use cases for this view:
// *
// * - Show everything.
// * - Show a specific repetition.
// * - Show everything shows NO repetition.
// *
// * @param Budget $budget
// * @param LimitRepetition $repetition
// *
// * @return int
// */
// public function show(Budget $budget, \LimitRepetition $repetition = null)
// {
// $useSessionDates = Input::get('useSession') == 'true' ? true : false;
// $view = null;
// $title = null;
// \Log::debug('Is envelope true? ' . (Input::get('noenvelope') == 'true'));
// switch (true) {
// case (!is_null($repetition)):
// $data = $this->_budgets->organizeRepetition($repetition);
// $view = 1;
// $title = $budget->name . ', ' . $repetition->periodShow() . ', ' . mf(
// $repetition->limit->amount,
// false
// );
// break;
// case (Input::get('noenvelope') == 'true'):
// $data = $this->_budgets->outsideRepetitions($budget);
// $view = 2;
// $title = $budget->name . ', transactions outside an envelope';
// break;
// default:
// $data = $this->_budgets->organizeRepetitions($budget, $useSessionDates);
// $view = $useSessionDates ? 3 : 4;
// $title = $useSessionDates ? $budget->name . ' in session period' : $budget->name;
// break;
// }
//
// return View::make('budgets.show')
// ->with('budget', $budget)
// ->with('repetitions', $data)
// ->with('view', $view)
// ->with('highlight', Input::get('highlight'))
// ->with('useSessionDates', $useSessionDates)
// ->with('subTitle', 'Overview for ' . $title);
// }
//
/**
* @return \Illuminate\Http\RedirectResponse
*/
@@ -306,7 +239,7 @@ class BudgetController extends BaseController
break;
}
}
//
/**
* @param Budget $budget
*
@@ -350,56 +283,5 @@ class BudgetController extends BaseController
return Redirect::route('budgets.edit', $budget->id)->withInput();
break;
}
// $budget = $this->_repository->update($budget, Input::all());
// if ($budget->validate()) {
// Event::fire('budgets.update', [$budget]);
// Session::flash('success', 'Budget "' . $budget->name . '" updated.');
//
// if (Input::get('from') == 'date') {
// return Redirect::route('budgets.index');
// } else {
// return Redirect::route('budgets.index.budget');
// }
// } else {
// Session::flash('error', 'Could not update budget: ' . $budget->errors()->first());
//
// return Redirect::route('budgets.edit', $budget->id)->withInput()->withErrors($budget->errors());
// }
//
}
// public function nobudget($view = 'session') {
// switch($view) {
// default:
// throw new FireflyException('Cannot show transactions without a budget for view "'.$view.'".');
// break;
// case 'session':
// $start = Session::get('start');
// $end = Session::get('end');
// break;
// }
//
// // Add expenses that have no budget:
// $set = \Auth::user()->transactionjournals()->whereNotIn(
// 'transaction_journals.id', function ($query) use ($start, $end) {
// $query->select('transaction_journals.id')->from('transaction_journals')
// ->leftJoin(
// 'component_transaction_journal', 'component_transaction_journal.transaction_journal_id', '=',
// 'transaction_journals.id'
// )
// ->leftJoin('components', 'components.id', '=', 'component_transaction_journal.component_id')
// ->where('transaction_journals.date', '>=', $start->format('Y-m-d'))
// ->where('transaction_journals.date', '<=', $end->format('Y-m-d'))
// ->where('components.class', 'Budget');
// }
// )->before($end)->after($start)->get();
//
// return View::make('budgets.nobudget')
// ->with('view', $view)
// ->with('transactions',$set)
// ->with('subTitle', 'Transactions without a budget');
// }
}
}