mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Various updates [skip ci]
This commit is contained in:
parent
00a767cfc9
commit
78d575fbb1
@ -82,6 +82,7 @@ class BudgetController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function indexByDate()
|
public function indexByDate()
|
||||||
{
|
{
|
||||||
|
Event::fire('budgets.change');
|
||||||
// get a list of dates by getting all repetitions:
|
// get a list of dates by getting all repetitions:
|
||||||
$set = $this->_repository->get();
|
$set = $this->_repository->get();
|
||||||
$budgets = $this->_budgets->organizeByDate($set);
|
$budgets = $this->_budgets->organizeByDate($set);
|
||||||
|
@ -29,48 +29,75 @@ class LimitController extends BaseController
|
|||||||
*
|
*
|
||||||
* @return $this|\Illuminate\View\View
|
* @return $this|\Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function create($budgetId = null)
|
public function create(\Budget $budget = null)
|
||||||
{
|
{
|
||||||
$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',
|
||||||
|
'budget_id' => $budget ? $budget->id : null
|
||||||
];
|
];
|
||||||
|
|
||||||
$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(
|
||||||
'periods', $periods
|
'periods', $periods
|
||||||
)->with('prefilled', $prefilled);
|
)->with('prefilled', $prefilled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete(\Limit $limit)
|
||||||
|
{
|
||||||
|
return View::make('limits.delete')->with('limit', $limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($limitId)
|
||||||
|
{
|
||||||
|
$limit = $this->_limits->find($limitId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ($limit) {
|
||||||
|
$limit->delete();
|
||||||
|
|
||||||
|
return Redirect::route('budgets.index');
|
||||||
|
} else {
|
||||||
|
return View::make('error')->with('message', 'No such limit!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param null $limitId
|
* @param null $limitId
|
||||||
*
|
*
|
||||||
* @return $this|\Illuminate\View\View
|
* @return $this|\Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function edit($limitId = null)
|
public function edit(Limit $limit)
|
||||||
{
|
{
|
||||||
$limit = $this->_limits->find($limitId);
|
|
||||||
$budgets = $this->_budgets->getAsSelectList();
|
$budgets = $this->_budgets->getAsSelectList();
|
||||||
|
$periods = \Config::get('firefly.periods_to_text');
|
||||||
|
|
||||||
$periods = [
|
|
||||||
'weekly' => 'A week',
|
|
||||||
'monthly' => 'A month',
|
|
||||||
'quarterly' => 'A quarter',
|
|
||||||
'half-year' => 'Six months',
|
|
||||||
'yearly' => 'A year',
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
if ($limit) {
|
|
||||||
return View::make('limits.edit')->with('limit', $limit)->with('budgets', $budgets)->with(
|
return View::make('limits.edit')->with('limit', $limit)->with('budgets', $budgets)->with(
|
||||||
'periods', $periods
|
'periods', $periods
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return View::make('error')->with('message', 'No such limit.');
|
public function store(Budget $budget = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
// find a limit with these properties, as we might already have one:
|
||||||
|
$limit = $this->_limits->store(Input::all());
|
||||||
|
if ($limit->id) {
|
||||||
|
if (Input::get('from') == 'date') {
|
||||||
|
return Redirect::route('budgets.index');
|
||||||
|
} else {
|
||||||
|
return Redirect::route('budgets.index.budget');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$budgetId = $budget ? $budget->id : null;
|
||||||
|
|
||||||
|
return Redirect::route('budgets.limits.create', [$budgetId, 'from' => Input::get('from')])->withInput();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,14 +117,17 @@ class LimitController extends BaseController
|
|||||||
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, 'from' => Input::get('from')])->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();
|
||||||
}
|
}
|
||||||
|
if (Input::get('from') == 'date') {
|
||||||
return Redirect::route('budgets.index');
|
return Redirect::route('budgets.index');
|
||||||
|
} else {
|
||||||
|
return Redirect::route('budgets.index.budget');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,55 +135,5 @@ class LimitController extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
|
||||||
*/
|
|
||||||
public function store()
|
|
||||||
{
|
|
||||||
// find a limit with these properties, as we might already have one:
|
|
||||||
$limit = $this->_limits->store(Input::all());
|
|
||||||
if ($limit->id) {
|
|
||||||
return Redirect::route('budgets.index');
|
|
||||||
} else {
|
|
||||||
return Redirect::route('budgets.limits.create')->withInput();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $limitId
|
|
||||||
*
|
|
||||||
* @return $this|\Illuminate\View\View
|
|
||||||
*/
|
|
||||||
public function delete($limitId)
|
|
||||||
{
|
|
||||||
$limit = $this->_limits->find($limitId);
|
|
||||||
|
|
||||||
|
|
||||||
if ($limit) {
|
|
||||||
return View::make('limits.delete')->with('limit', $limit);
|
|
||||||
} else {
|
|
||||||
return View::make('error')->with('message', 'No such limit!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param $limitId
|
|
||||||
*
|
|
||||||
* @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
|
||||||
*/
|
|
||||||
public function destroy($limitId)
|
|
||||||
{
|
|
||||||
$limit = $this->_limits->find($limitId);
|
|
||||||
|
|
||||||
|
|
||||||
if ($limit) {
|
|
||||||
$limit->delete();
|
|
||||||
|
|
||||||
return Redirect::route('budgets.index');
|
|
||||||
} else {
|
|
||||||
return View::make('error')->with('message', 'No such limit!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
App::before(
|
App::before(
|
||||||
function ($request) {
|
function ($request) {
|
||||||
Event::fire('app.before');
|
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
$toolkit = App::make('Firefly\Helper\Toolkit\ToolkitInterface');
|
$toolkit = App::make('Firefly\Helper\Toolkit\ToolkitInterface');
|
||||||
return $toolkit->getDateRange($request);
|
return $toolkit->getDateRange($request);
|
||||||
|
@ -88,7 +88,7 @@ class EloquentLimitRepository implements LimitRepositoryInterface
|
|||||||
$limit->repeats = isset($data['repeats']) ? intval($data['repeats']) : 0;
|
$limit->repeats = isset($data['repeats']) ? intval($data['repeats']) : 0;
|
||||||
$limit->repeat_freq = $data['period'];
|
$limit->repeat_freq = $data['period'];
|
||||||
if (!$limit->save()) {
|
if (!$limit->save()) {
|
||||||
Session::flash('error', 'Could not save: ' . $limit->errors()->first());
|
\Session::flash('error', 'Could not save: ' . $limit->errors()->first());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $limit;
|
return $limit;
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
namespace Firefly\Trigger\Limits;
|
namespace Firefly\Trigger\Limits;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Database\QueryException;
|
|
||||||
use Illuminate\Events\Dispatcher;
|
use Illuminate\Events\Dispatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,6 +13,15 @@ use Illuminate\Events\Dispatcher;
|
|||||||
class EloquentLimitTrigger
|
class EloquentLimitTrigger
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Dispatcher $events
|
||||||
|
*/
|
||||||
|
public function subscribe(Dispatcher $events)
|
||||||
|
{
|
||||||
|
$events->listen('budgets.change', 'Firefly\Trigger\Limits\EloquentLimitTrigger@updateLimitRepetitions');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function updateLimitRepetitions()
|
public function updateLimitRepetitions()
|
||||||
{
|
{
|
||||||
if (!\Auth::check()) {
|
if (!\Auth::check()) {
|
||||||
@ -22,149 +30,246 @@ class EloquentLimitTrigger
|
|||||||
|
|
||||||
// get budgets with limits:
|
// get budgets with limits:
|
||||||
$budgets = \Auth::user()->budgets()
|
$budgets = \Auth::user()->budgets()
|
||||||
->with(['limits', 'limits.limitrepetitions'])
|
->with(
|
||||||
->whereNotNull('limits.id')
|
['limits', 'limits.limitrepetitions']
|
||||||
->leftJoin('limits', 'components.id', '=', 'limits.component_id')->get(['components.*']);
|
)
|
||||||
|
->where('components.class', 'Budget')
|
||||||
|
->get(['components.*']);
|
||||||
|
$start = \Session::get('start');
|
||||||
|
$end = new Carbon;
|
||||||
|
|
||||||
// get todays date.
|
|
||||||
|
|
||||||
|
// double check the non-repeating budgetlimits first.
|
||||||
foreach ($budgets as $budget) {
|
foreach ($budgets as $budget) {
|
||||||
// loop limits:
|
\Log::debug('Budgetstart: ' . $budget->name);
|
||||||
foreach ($budget->limits as $limit) {
|
foreach ($budget->limits as $limit) {
|
||||||
// should have a repetition, at the very least
|
if ($limit->repeats == 0) {
|
||||||
// for the period it starts (startdate and onwards).
|
$limit->createRepetition($limit->startdate);
|
||||||
if (count($limit->limitrepetitions) == 0) {
|
}
|
||||||
// create such a repetition:
|
if($limit->repeats == 1) {
|
||||||
$repetition = new \LimitRepetition();
|
$start = $limit->startdate;
|
||||||
$start = clone $limit->startdate;
|
$end = new Carbon;
|
||||||
$end = clone $start;
|
|
||||||
|
|
||||||
// go to end:
|
// repeat for period:
|
||||||
|
$current = clone $start;
|
||||||
|
\Log::debug('Create repeating limit for #'.$limit->id.' starting on ' . $current);
|
||||||
|
while($current <= $end) {
|
||||||
|
\Log::debug('Current is now: ' . $current);
|
||||||
|
$limit->createRepetition(clone $current);
|
||||||
|
// switch period, add time:
|
||||||
switch ($limit->repeat_freq) {
|
switch ($limit->repeat_freq) {
|
||||||
case 'daily':
|
case 'daily':
|
||||||
$end->addDay();
|
$current->addDay();
|
||||||
break;
|
break;
|
||||||
case 'weekly':
|
case 'weekly':
|
||||||
$end->addWeek();
|
$current->addWeek();
|
||||||
break;
|
break;
|
||||||
case 'monthly':
|
case 'monthly':
|
||||||
$end->addMonth();
|
$current->addMonth();
|
||||||
break;
|
break;
|
||||||
case 'quarterly':
|
case 'quarterly':
|
||||||
$end->addMonths(3);
|
$current->addMonths(3);
|
||||||
break;
|
break;
|
||||||
case 'half-year':
|
case 'half-year':
|
||||||
$end->addMonths(6);
|
$current->addMonths(6);
|
||||||
break;
|
break;
|
||||||
case 'yearly':
|
case 'yearly':
|
||||||
$end->addYear();
|
$current->addYear();
|
||||||
break;
|
|
||||||
}
|
|
||||||
$end->subDay();
|
|
||||||
$repetition->startdate = $start;
|
|
||||||
$repetition->enddate = $end;
|
|
||||||
$repetition->amount = $limit->amount;
|
|
||||||
$repetition->limit()->associate($limit);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$repetition->save();
|
|
||||||
} catch (QueryException $e) {
|
|
||||||
// do nothing
|
|
||||||
\Log::error($e->getMessage());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// there are limits already, do they
|
|
||||||
// fall into the range surrounding today?
|
|
||||||
$today = new Carbon;
|
|
||||||
$today->addMonths(2);
|
|
||||||
if ($limit->repeats == 1 && $today >= $limit->startdate) {
|
|
||||||
|
|
||||||
/** @var \Carbon\Carbon $flowStart */
|
|
||||||
$flowStart = clone $today;
|
|
||||||
/** @var \Carbon\Carbon $flowEnd */
|
|
||||||
$flowEnd = clone $today;
|
|
||||||
|
|
||||||
switch ($limit->repeat_freq) {
|
|
||||||
case 'daily':
|
|
||||||
$flowStart->startOfDay();
|
|
||||||
$flowEnd->endOfDay();
|
|
||||||
break;
|
|
||||||
case 'weekly':
|
|
||||||
$flowStart->startOfWeek();
|
|
||||||
$flowEnd->endOfWeek();
|
|
||||||
break;
|
|
||||||
case 'monthly':
|
|
||||||
$flowStart->startOfMonth();
|
|
||||||
$flowEnd->endOfMonth();
|
|
||||||
break;
|
|
||||||
case 'quarterly':
|
|
||||||
$flowStart->firstOfQuarter();
|
|
||||||
$flowEnd->startOfMonth()->lastOfQuarter()->endOfDay();
|
|
||||||
break;
|
|
||||||
case 'half-year':
|
|
||||||
|
|
||||||
if (intval($flowStart->format('m')) >= 7) {
|
|
||||||
$flowStart->startOfYear();
|
|
||||||
$flowStart->addMonths(6);
|
|
||||||
} else {
|
|
||||||
$flowStart->startOfYear();
|
|
||||||
}
|
|
||||||
|
|
||||||
$flowEnd->endOfYear();
|
|
||||||
if (intval($start->format('m')) <= 6) {
|
|
||||||
$flowEnd->subMonths(6);
|
|
||||||
$flowEnd->subDay();
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'yearly':
|
|
||||||
$flowStart->startOfYear();
|
|
||||||
$flowEnd->endOfYear();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$inRange = false;
|
|
||||||
foreach ($limit->limitrepetitions as $rep) {
|
|
||||||
if ($rep->startdate->format('dmY') == $flowStart->format('dmY')
|
|
||||||
&& $rep->enddate->format('dmY') == $flowEnd->format('dmY')
|
|
||||||
) {
|
|
||||||
// falls in current range, do nothing?
|
|
||||||
$inRange = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if there is none that fall in range, create!
|
|
||||||
if ($inRange === false) {
|
|
||||||
// create (but check first)!
|
|
||||||
$count = \LimitRepetition::where('limit_id', $limit->id)->where('startdate', $flowStart)
|
|
||||||
->where('enddate', $flowEnd)->count();
|
|
||||||
if ($count == 0) {
|
|
||||||
$repetition = new \LimitRepetition;
|
|
||||||
$repetition->startdate = $flowStart;
|
|
||||||
$repetition->enddate = $flowEnd;
|
|
||||||
$repetition->amount = $limit->amount;
|
|
||||||
$repetition->limit()->associate($limit);
|
|
||||||
try {
|
|
||||||
$repetition->save();
|
|
||||||
} catch (QueryException $e) {
|
|
||||||
// do nothing
|
|
||||||
\Log::error($e->getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// \Log::debug(
|
||||||
|
// 'Now at budget ' . $budget->name . ', limit #' . $limit->id . ' (' . $limit->repeats . ', '
|
||||||
|
// . $limit->repeat_freq . ', ' . $limit->startdate . ').'
|
||||||
|
// );
|
||||||
|
// $count = count($limit->limitrepetitions);
|
||||||
|
// if ($count == 0) {
|
||||||
|
// // create such a repetition:
|
||||||
|
// $repetition = new \LimitRepetition();
|
||||||
|
// $start = clone $limit->startdate;
|
||||||
|
// $end = clone $start;
|
||||||
|
//
|
||||||
|
// // go to end:
|
||||||
|
// switch ($limit->repeat_freq) {
|
||||||
|
// case 'daily':
|
||||||
|
// $end->addDay();
|
||||||
|
// break;
|
||||||
|
// case 'weekly':
|
||||||
|
// $end->addWeek();
|
||||||
|
// break;
|
||||||
|
// case 'monthly':
|
||||||
|
// $end->addMonth();
|
||||||
|
// break;
|
||||||
|
// case 'quarterly':
|
||||||
|
// $end->addMonths(3);
|
||||||
|
// break;
|
||||||
|
// case 'half-year':
|
||||||
|
// $end->addMonths(6);
|
||||||
|
// break;
|
||||||
|
// case 'yearly':
|
||||||
|
// $end->addYear();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// $end->subDay();
|
||||||
|
// $repetition->startdate = $start;
|
||||||
|
// $repetition->enddate = $end;
|
||||||
|
// $repetition->amount = $limit->amount;
|
||||||
|
// $repetition->limit()->associate($limit);
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// $repetition->save();
|
||||||
|
// \Log::debug('Created new repetition with id #' . $repetition->id);
|
||||||
|
// } catch (QueryException $e) {
|
||||||
|
// // do nothing
|
||||||
|
// \Log::error('Trying to save new Limitrepetition failed!');
|
||||||
|
// \Log::error($e->getMessage());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
//
|
||||||
* @param Dispatcher $events
|
//
|
||||||
*/
|
// exit;
|
||||||
public function subscribe(Dispatcher $events)
|
//
|
||||||
{
|
//
|
||||||
$events->listen('app.before', 'Firefly\Trigger\Limits\EloquentLimitTrigger@updateLimitRepetitions');
|
// // get todays date.
|
||||||
|
//
|
||||||
}
|
// foreach ($budgets as $budget) {
|
||||||
|
// // loop limits:
|
||||||
|
// foreach ($budget->limits as $limit) {
|
||||||
|
// // should have a repetition, at the very least
|
||||||
|
// // for the period it starts (startdate and onwards).
|
||||||
|
// \Log::debug('Limit #' . $limit->id . ' has ' . count($limit->limitrepetitions) . ' limitreps!');
|
||||||
|
// if (count($limit->limitrepetitions) == 0) {
|
||||||
|
//
|
||||||
|
// // create such a repetition:
|
||||||
|
// $repetition = new \LimitRepetition();
|
||||||
|
// $start = clone $limit->startdate;
|
||||||
|
// $end = clone $start;
|
||||||
|
//
|
||||||
|
// // go to end:
|
||||||
|
// switch ($limit->repeat_freq) {
|
||||||
|
// case 'daily':
|
||||||
|
// $end->addDay();
|
||||||
|
// break;
|
||||||
|
// case 'weekly':
|
||||||
|
// $end->addWeek();
|
||||||
|
// break;
|
||||||
|
// case 'monthly':
|
||||||
|
// $end->addMonth();
|
||||||
|
// break;
|
||||||
|
// case 'quarterly':
|
||||||
|
// $end->addMonths(3);
|
||||||
|
// break;
|
||||||
|
// case 'half-year':
|
||||||
|
// $end->addMonths(6);
|
||||||
|
// break;
|
||||||
|
// case 'yearly':
|
||||||
|
// $end->addYear();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// $end->subDay();
|
||||||
|
// $repetition->startdate = $start;
|
||||||
|
// $repetition->enddate = $end;
|
||||||
|
// $repetition->amount = $limit->amount;
|
||||||
|
// $repetition->limit()->associate($limit);
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// $repetition->save();
|
||||||
|
// } catch (QueryException $e) {
|
||||||
|
// // do nothing
|
||||||
|
// \Log::error('Trying to save new Limitrepetition!');
|
||||||
|
// \Log::error($e->getMessage());
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// // there are limits already, do they
|
||||||
|
// // fall into the range surrounding today?
|
||||||
|
// $today = new Carbon;
|
||||||
|
// $today->addMonths(2);
|
||||||
|
// if ($limit->repeats == 1 && $today >= $limit->startdate) {
|
||||||
|
//
|
||||||
|
// /** @var \Carbon\Carbon $flowStart */
|
||||||
|
// $flowStart = clone $today;
|
||||||
|
// /** @var \Carbon\Carbon $flowEnd */
|
||||||
|
// $flowEnd = clone $today;
|
||||||
|
//
|
||||||
|
// switch ($limit->repeat_freq) {
|
||||||
|
// case 'daily':
|
||||||
|
// $flowStart->startOfDay();
|
||||||
|
// $flowEnd->endOfDay();
|
||||||
|
// break;
|
||||||
|
// case 'weekly':
|
||||||
|
// $flowStart->startOfWeek();
|
||||||
|
// $flowEnd->endOfWeek();
|
||||||
|
// break;
|
||||||
|
// case 'monthly':
|
||||||
|
// $flowStart->startOfMonth();
|
||||||
|
// $flowEnd->endOfMonth();
|
||||||
|
// break;
|
||||||
|
// case 'quarterly':
|
||||||
|
// $flowStart->firstOfQuarter();
|
||||||
|
// $flowEnd->startOfMonth()->lastOfQuarter()->endOfDay();
|
||||||
|
// break;
|
||||||
|
// case 'half-year':
|
||||||
|
//
|
||||||
|
// if (intval($flowStart->format('m')) >= 7) {
|
||||||
|
// $flowStart->startOfYear();
|
||||||
|
// $flowStart->addMonths(6);
|
||||||
|
// } else {
|
||||||
|
// $flowStart->startOfYear();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// $flowEnd->endOfYear();
|
||||||
|
// if (intval($start->format('m')) <= 6) {
|
||||||
|
// $flowEnd->subMonths(6);
|
||||||
|
// $flowEnd->subDay();
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
// case 'yearly':
|
||||||
|
// $flowStart->startOfYear();
|
||||||
|
// $flowEnd->endOfYear();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// $inRange = false;
|
||||||
|
// foreach ($limit->limitrepetitions as $rep) {
|
||||||
|
// if ($rep->startdate->format('dmY') == $flowStart->format('dmY')
|
||||||
|
// && $rep->enddate->format('dmY') == $flowEnd->format('dmY')
|
||||||
|
// ) {
|
||||||
|
// // falls in current range, do nothing?
|
||||||
|
// $inRange = true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // if there is none that fall in range, create!
|
||||||
|
// if ($inRange === false) {
|
||||||
|
// // create (but check first)!
|
||||||
|
// $count = \LimitRepetition::where('limit_id', $limit->id)->where('startdate', $flowStart)
|
||||||
|
// ->where('enddate', $flowEnd)->count();
|
||||||
|
// if ($count == 0) {
|
||||||
|
// $repetition = new \LimitRepetition;
|
||||||
|
// $repetition->startdate = $flowStart;
|
||||||
|
// $repetition->enddate = $flowEnd;
|
||||||
|
// $repetition->amount = $limit->amount;
|
||||||
|
// $repetition->limit()->associate($limit);
|
||||||
|
// try {
|
||||||
|
// $repetition->save();
|
||||||
|
// } catch (QueryException $e) {
|
||||||
|
// // do nothing
|
||||||
|
// \Log::error($e->getMessage());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
use LaravelBook\Ardent\Ardent as Ardent;
|
use LaravelBook\Ardent\Ardent as Ardent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,14 +54,63 @@ class Limit extends Ardent
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function budget()
|
||||||
|
{
|
||||||
|
return $this->belongsTo('Budget', 'component_id');
|
||||||
|
}
|
||||||
|
|
||||||
public function component()
|
public function component()
|
||||||
{
|
{
|
||||||
return $this->belongsTo('Component', 'component_id');
|
return $this->belongsTo('Component', 'component_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function budget()
|
public function createRepetition(Carbon $start)
|
||||||
{
|
{
|
||||||
return $this->belongsTo('Budget', 'component_id');
|
|
||||||
|
$end = clone $start;
|
||||||
|
// go to end:
|
||||||
|
switch ($this->repeat_freq) {
|
||||||
|
case 'daily':
|
||||||
|
$end->addDay();
|
||||||
|
break;
|
||||||
|
case 'weekly':
|
||||||
|
$end->addWeek();
|
||||||
|
break;
|
||||||
|
case 'monthly':
|
||||||
|
$end->addMonth();
|
||||||
|
break;
|
||||||
|
case 'quarterly':
|
||||||
|
$end->addMonths(3);
|
||||||
|
break;
|
||||||
|
case 'half-year':
|
||||||
|
$end->addMonths(6);
|
||||||
|
break;
|
||||||
|
case 'yearly':
|
||||||
|
$end->addYear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$end->subDay();
|
||||||
|
$count = $this->limitrepetitions()->where('startdate', $start->format('Y-m-d'))->where(
|
||||||
|
'enddate', $start->format('Y-m-d')
|
||||||
|
)->count();
|
||||||
|
|
||||||
|
if ($count == 0) {
|
||||||
|
|
||||||
|
$repetition = new \LimitRepetition();
|
||||||
|
$repetition->startdate = $start;
|
||||||
|
$repetition->enddate = $end;
|
||||||
|
$repetition->amount = $this->amount;
|
||||||
|
$repetition->limit()->associate($this);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$repetition->save();
|
||||||
|
\Log::debug('Created new repetition with id #' . $repetition->id);
|
||||||
|
} catch (QueryException $e) {
|
||||||
|
// do nothing
|
||||||
|
\Log::error('Trying to save new Limitrepetition failed!');
|
||||||
|
\Log::error($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function limitrepetitions()
|
public function limitrepetitions()
|
||||||
|
@ -101,7 +101,7 @@ class LimitRepetition extends Ardent
|
|||||||
return $this->startdate->format('Ymd') . '-5';
|
return $this->startdate->format('Ymd') . '-5';
|
||||||
break;
|
break;
|
||||||
case 'weekly':
|
case 'weekly':
|
||||||
return $this->startdate->format('Ymd') . '4';
|
return $this->startdate->format('Ymd') . '-4';
|
||||||
break;
|
break;
|
||||||
case 'monthly':
|
case 'monthly':
|
||||||
return $this->startdate->format('Ymd') . '-3';
|
return $this->startdate->format('Ymd') . '-3';
|
||||||
|
@ -30,6 +30,18 @@ Route::bind('category', function($value, $route)
|
|||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::bind('limit', function($value, $route)
|
||||||
|
{
|
||||||
|
if(Auth::check()) {
|
||||||
|
return Limit::
|
||||||
|
where('limits.id', $value)->
|
||||||
|
leftJoin('components','components.id','=','limits.component_id')->
|
||||||
|
where('components.class','Budget')->
|
||||||
|
where('components.user_id',Auth::user()->id)->first();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// protected routes:
|
// protected routes:
|
||||||
Route::group(['before' => 'auth'], function () {
|
Route::group(['before' => 'auth'], function () {
|
||||||
@ -79,9 +91,9 @@ Route::group(['before' => 'auth'], function () {
|
|||||||
Route::get('/budgets/delete/{budget}',['uses' => 'BudgetController@delete', 'as' => 'budgets.delete']);
|
Route::get('/budgets/delete/{budget}',['uses' => 'BudgetController@delete', 'as' => 'budgets.delete']);
|
||||||
|
|
||||||
// limit controller:
|
// limit controller:
|
||||||
Route::get('/budgets/limits/create/{id?}',['uses' => 'LimitController@create','as' => 'budgets.limits.create']);
|
Route::get('/budgets/limits/create/{budget?}',['uses' => 'LimitController@create','as' => 'budgets.limits.create']);
|
||||||
Route::get('/budgets/limits/delete/{id?}',['uses' => 'LimitController@delete','as' => 'budgets.limits.delete']);
|
Route::get('/budgets/limits/delete/{limit}',['uses' => 'LimitController@delete','as' => 'budgets.limits.delete']);
|
||||||
Route::get('/budgets/limits/edit/{id?}',['uses' => 'LimitController@edit','as' => 'budgets.limits.edit']);
|
Route::get('/budgets/limits/edit/{limit}',['uses' => 'LimitController@edit','as' => 'budgets.limits.edit']);
|
||||||
|
|
||||||
// JSON controller:
|
// JSON controller:
|
||||||
Route::get('/json/beneficiaries', ['uses' => 'JsonController@beneficiaries', 'as' => 'json.beneficiaries']);
|
Route::get('/json/beneficiaries', ['uses' => 'JsonController@beneficiaries', 'as' => 'json.beneficiaries']);
|
||||||
@ -106,7 +118,7 @@ Route::group(['before' => 'csrf|auth'], function () {
|
|||||||
Route::post('/profile/change-password', ['uses' => 'ProfileController@postChangePassword']);
|
Route::post('/profile/change-password', ['uses' => 'ProfileController@postChangePassword']);
|
||||||
|
|
||||||
// budget controller:
|
// budget controller:
|
||||||
Route::post('/budgets/store',['uses' => 'BudgetController@store', 'as' => 'budgets.store']);
|
Route::post('/budgets/store/{budget}',['uses' => 'BudgetController@store', 'as' => 'budgets.store']);
|
||||||
Route::post('/budgets/update', ['uses' => 'BudgetController@update', 'as' => 'budgets.update']);
|
Route::post('/budgets/update', ['uses' => 'BudgetController@update', 'as' => 'budgets.update']);
|
||||||
Route::post('/budgets/destroy', ['uses' => 'BudgetController@destroy', 'as' => 'budgets.destroy']);
|
Route::post('/budgets/destroy', ['uses' => 'BudgetController@destroy', 'as' => 'budgets.destroy']);
|
||||||
|
|
||||||
@ -127,7 +139,7 @@ Route::group(['before' => 'csrf|auth'], function () {
|
|||||||
Route::post('/accounts/destroy', ['uses' => 'AccountController@destroy', 'as' => 'accounts.destroy']);
|
Route::post('/accounts/destroy', ['uses' => 'AccountController@destroy', 'as' => 'accounts.destroy']);
|
||||||
|
|
||||||
// limit controller:
|
// limit controller:
|
||||||
Route::post('/budgets/limits/store', ['uses' => 'LimitController@store', 'as' => 'budgets.limits.store']);
|
Route::post('/budgets/limits/store/{budget?}', ['uses' => 'LimitController@store', 'as' => 'budgets.limits.store']);
|
||||||
Route::post('/budgets/limits/destroy/{id?}',['uses' => 'LimitController@destroy','as' => 'budgets.limits.destroy']);
|
Route::post('/budgets/limits/destroy/{id?}',['uses' => 'LimitController@destroy','as' => 'budgets.limits.destroy']);
|
||||||
Route::post('/budgets/limits/update/{id?}',['uses' => 'LimitController@update','as' => 'budgets.limits.update']);
|
Route::post('/budgets/limits/update/{id?}',['uses' => 'LimitController@update','as' => 'budgets.limits.update']);
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
<h1>Firefly
|
<h1>Firefly
|
||||||
<small>Delete "{{{$budget->name}}}"</small>
|
<small>Delete budget "{{{$budget->name}}}"</small>
|
||||||
</h1>
|
</h1>
|
||||||
<p class="lead">
|
<p class="lead">
|
||||||
Remember that deleting something is permanent.
|
Remember that deleting something is permanent.
|
||||||
|
@ -74,8 +74,8 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<a title="Edit envelope for {{{$repetition->limit->budget->name}}} in {{$entry['date']}}" href="{{route('budgets.limits.edit',$repetition->limit->id)}}" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
|
<a title="Edit envelope for {{{$repetition->limit->budget->name}}} in {{$entry['date']}}" href="{{route('budgets.limits.edit',$repetition->limit->id)}}?from=date" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||||
<a title="Delete envelope for {{{$repetition->limit->budget->name}}} in {{$entry['date']}}" href="{{route('budgets.limits.delete',$repetition->limit->id)}}" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
|
<a title="Delete envelope for {{{$repetition->limit->budget->name}}} in {{$entry['date']}}" href="{{route('budgets.limits.delete',$repetition->limit->id)}}?from=date" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
|
||||||
</div>
|
</div>
|
||||||
@if($repetition->limit->repeats == 1)
|
@if($repetition->limit->repeats == 1)
|
||||||
<span class="label label-warning">auto repeats</span>
|
<span class="label label-warning">auto repeats</span>
|
||||||
|
@ -19,16 +19,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{Form::open(['class' => 'form-horizontal','url' => route('budgets.limits.store')])}}
|
{{Form::open(['class' => 'form-horizontal','url' => route('budgets.limits.store',$prefilled['budget_id'])])}}
|
||||||
|
{{Form::hidden('from',e(Input::get('from')))}}
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-6 col-md-12 col-sm-6">
|
<div class="col-lg-6 col-md-12 col-sm-6">
|
||||||
<h4>Mandatory fields</h4>
|
<h4>Mandatory fields</h4>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ Form::label('budget_id', 'Budget', ['class' => 'col-sm-3 control-label'])}}
|
{{ Form::label('budget_id', 'Budget', ['class' => 'col-sm-4 control-label'])}}
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-8">
|
||||||
{{Form::select('budget_id',$budgets,Input::old('budget_id') ?: $budget_id, ['class' =>
|
{{Form::select('budget_id',$budgets,Input::old('budget_id') ?: $prefilled['budget_id'], ['class' =>
|
||||||
'form-control'])}}
|
'form-control'])}}
|
||||||
@if($errors->has('budget_id'))
|
@if($errors->has('budget_id'))
|
||||||
<p class="text-danger">{{$errors->first('name')}}</p>
|
<p class="text-danger">{{$errors->first('name')}}</p>
|
||||||
@ -39,8 +41,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ Form::label('startdate', 'Start date', ['class' => 'col-sm-3 control-label'])}}
|
{{ Form::label('startdate', 'Start date', ['class' => 'col-sm-4 control-label'])}}
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-8">
|
||||||
<input type="date" name="startdate" value="{{Input::old('startdate') ?: $prefilled['startdate']}}"
|
<input type="date" name="startdate" value="{{Input::old('startdate') ?: $prefilled['startdate']}}"
|
||||||
class="form-control"/>
|
class="form-control"/>
|
||||||
<span class="help-block">This date indicates when the envelope "starts". The date you select
|
<span class="help-block">This date indicates when the envelope "starts". The date you select
|
||||||
@ -49,17 +51,17 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="period" class="col-sm-3 control-label">Spending period</label>
|
<label for="period" class="col-sm-4 control-label">Spending period</label>
|
||||||
|
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-8">
|
||||||
{{Form::select('period',$periods,Input::old('period') ?: $prefilled['repeat_freq'],['class' => 'form-control'])}}
|
{{Form::select('period',$periods,Input::old('period') ?: $prefilled['repeat_freq'],['class' => 'form-control'])}}
|
||||||
<span class="help-block">How long will the envelope last? A week, a month, or even longer?</span>
|
<span class="help-block">How long will the envelope last? A week, a month, or even longer?</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="period" class="col-sm-3 control-label">Repeat</label>
|
<label for="period" class="col-sm-4 control-label">Repeat</label>
|
||||||
|
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-8">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" value="1" name="repeats" @if(intval(Input::old('repeats')) == 1) checked @endif>
|
<input type="checkbox" value="1" name="repeats" @if(intval(Input::old('repeats')) == 1) checked @endif>
|
||||||
@ -75,17 +77,17 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ Form::label('amount', 'Amount', ['class' => 'col-sm-3 control-label'])}}
|
{{ Form::label('amount', 'Amount', ['class' => 'col-sm-4 control-label'])}}
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-8">
|
||||||
<input type="number" value="{{Input::old('amount')}}" name="amount" min="0.01" step="any" class="form-control"/>
|
<input type="number" value="{{Input::old('amount')}}" name="amount" min="0.01" step="any" class="form-control"/>
|
||||||
<span class="help-block">Of course, there needs to be money in the envelope.</span>
|
<span class="help-block">Of course, there needs to be money in the envelope.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ Form::label('submit', ' ', ['class' => 'col-sm-3 control-label'])}}
|
{{ Form::label('submit', ' ', ['class' => 'col-sm-4 control-label'])}}
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-8">
|
||||||
<input type="submit" name="submit" value="Save new limit" class="btn btn-default"/>
|
<input type="submit" name="submit" value="Save new envelope" class="btn btn-success"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -93,11 +95,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{Form::open()}}
|
{{Form::close()}}
|
||||||
|
|
||||||
|
|
||||||
@stop
|
@stop
|
||||||
@section('scripts')
|
|
||||||
<script type="text/javascript" src="assets/javascript/moment.min.js"></script>
|
|
||||||
<script type="text/javascript" src="assets/javascript/limits.js"></script>
|
|
||||||
@stop
|
|
@ -3,9 +3,18 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
<h1>Firefly
|
<h1>Firefly
|
||||||
<small>Delete limit</small>
|
<small>Delete envelope</small>
|
||||||
</h1>
|
</h1>
|
||||||
|
<p class="lead">Remember that deleting something is permanent.</p>
|
||||||
|
<p class="text-info">
|
||||||
|
This form allows you to delete the envelope for budget {{{$limit->budget->name}}}, with a content of
|
||||||
|
{{mf($limit->amount,false)}}
|
||||||
|
@if($limit->repeats == 0)
|
||||||
|
in {{$limit->limitrepetitions[0]->startdate->format('M Y')}} ({{$limit->repeat_freq}}).
|
||||||
|
@endif
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{Form::open(['class' => 'form-horizontal','url' => route('budgets.limits.destroy',$limit->id)])}}
|
{{Form::open(['class' => 'form-horizontal','url' => route('budgets.limits.destroy',$limit->id)])}}
|
||||||
@ -13,7 +22,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<p class="text-info">
|
<p class="text-info">
|
||||||
Destroying a limit (an envelope) does not remove any transactions from the budget.
|
Destroying an envelope does not remove any transactions from the budget.
|
||||||
</p>
|
</p>
|
||||||
<p class="text-danger">
|
<p class="text-danger">
|
||||||
Are you sure?
|
Are you sure?
|
||||||
@ -21,7 +30,12 @@
|
|||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input type="submit" name="submit" value="Remove limit" class="btn btn-danger" />
|
<input type="submit" name="submit" value="Remove envelope" class="btn btn-danger" />
|
||||||
|
@if(Input::get('from') == 'date')
|
||||||
|
<a href="{{route('budgets.index')}}" class="btn-default btn">Cancel</a>
|
||||||
|
@else
|
||||||
|
<a href="{{route('budgets.index.budget')}}" class="btn-default btn">Cancel</a>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -29,11 +43,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{{Form::open()}}
|
{{Form::close()}}
|
||||||
|
|
||||||
|
|
||||||
@stop
|
@stop
|
||||||
@section('scripts')
|
|
||||||
<script type="text/javascript" src="assets/javascript/moment.min.js"></script>
|
|
||||||
<script type="text/javascript" src="assets/javascript/limits.js"></script>
|
|
||||||
@stop
|
|
@ -3,14 +3,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
<h1>Firefly
|
<h1>Firefly
|
||||||
<small>Edit limit of {{mf($limit->amount,false)}}
|
<small>Edit envelope</small>
|
||||||
for budget {{{$limit->budget->name}}}
|
|
||||||
|
|
||||||
@if($limit->repeats == 0)
|
|
||||||
in {{$limit->limitrepetitions[0]->startdate->format('M Y')}} ({{$limit->repeat_freq}})
|
|
||||||
@endif
|
|
||||||
|
|
||||||
</small>
|
|
||||||
</h1>
|
</h1>
|
||||||
<p class="text-info">
|
<p class="text-info">
|
||||||
Firefly uses an "<a href="http://en.wikipedia.org/wiki/Envelope_System" class="text-success">envelope
|
Firefly uses an "<a href="http://en.wikipedia.org/wiki/Envelope_System" class="text-success">envelope
|
||||||
@ -20,21 +13,24 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p class="text-info">
|
<p class="text-info">
|
||||||
Firefly gives you the opportunity to create such an envelope when you create a budget. However, you can
|
This form allows you to edit the envelope for budget {{{$limit->budget->name}}}, with a content of
|
||||||
always add more of them.
|
{{mf($limit->amount,false)}}
|
||||||
|
@if($limit->repeats == 0)
|
||||||
|
in {{$limit->limitrepetitions[0]->startdate->format('M Y')}} ({{$limit->repeat_freq}}).
|
||||||
|
@endif
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{Form::open(['class' => 'form-horizontal','url' => route('budgets.limits.update',$limit->id)])}}
|
{{Form::open(['class' => 'form-horizontal','url' => route('budgets.limits.update',$limit->id)])}}
|
||||||
|
{{Form::hidden('from',e(Input::get('from')))}}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-6 col-md-12 col-sm-6">
|
<div class="col-lg-6 col-md-12 col-sm-6">
|
||||||
<h4>Mandatory fields</h4>
|
<h4>Mandatory fields</h4>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ Form::label('budget_id', 'Budget', ['class' => 'col-sm-3 control-label'])}}
|
{{ Form::label('budget_id', 'Budget', ['class' => 'col-sm-4 control-label'])}}
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-8">
|
||||||
{{Form::select('budget_id',$budgets,Input::old('budget_id') ?: $limit->component_id, ['class' =>
|
{{Form::select('budget_id',$budgets,Input::old('budget_id') ?: $limit->component_id, ['class' =>
|
||||||
'form-control'])}}
|
'form-control'])}}
|
||||||
@if($errors->has('budget_id'))
|
@if($errors->has('budget_id'))
|
||||||
@ -46,8 +42,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ Form::label('startdate', 'Start date', ['class' => 'col-sm-3 control-label'])}}
|
{{ Form::label('startdate', 'Start date', ['class' => 'col-sm-4 control-label'])}}
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-8">
|
||||||
<input type="date" name="startdate" value="{{Input::old('startdate') ?: $limit->startdate->format('Y-m-d')}}"
|
<input type="date" name="startdate" value="{{Input::old('startdate') ?: $limit->startdate->format('Y-m-d')}}"
|
||||||
class="form-control"/>
|
class="form-control"/>
|
||||||
<span class="help-block">This date indicates when the envelope "starts". The date you select
|
<span class="help-block">This date indicates when the envelope "starts". The date you select
|
||||||
@ -56,17 +52,17 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="period" class="col-sm-3 control-label">Spending period</label>
|
<label for="period" class="col-sm-4 control-label">Spending period</label>
|
||||||
|
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-8">
|
||||||
{{Form::select('period',$periods,Input::old('period') ?: $limit->repeat_freq,['class' => 'form-control'])}}
|
{{Form::select('period',$periods,Input::old('period') ?: $limit->repeat_freq,['class' => 'form-control'])}}
|
||||||
<span class="help-block">How long will the envelope last? A week, a month, or even longer?</span>
|
<span class="help-block">How long will the envelope last? A week, a month, or even longer?</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="period" class="col-sm-3 control-label">Repeat</label>
|
<label for="period" class="col-sm-4 control-label">Repeat</label>
|
||||||
|
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-8">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" value="1" name="repeats" @if(intval(Input::old('repeats')) == 1 || intval($limit->repeats) == 1) checked @endif>
|
<input type="checkbox" value="1" name="repeats" @if(intval(Input::old('repeats')) == 1 || intval($limit->repeats) == 1) checked @endif>
|
||||||
@ -82,17 +78,17 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ Form::label('amount', 'Amount', ['class' => 'col-sm-3 control-label'])}}
|
{{ Form::label('amount', 'Amount', ['class' => 'col-sm-4 control-label'])}}
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-8">
|
||||||
<input type="number" value="{{Input::old('amount') ?: $limit->amount}}" name="amount" min="0.01" step="any" class="form-control"/>
|
<input type="number" value="{{ is_null(Input::old('amount')) || Input::old('amount') == '' ? $limit->amount : Input::old('amount')}}" name="amount" min="0.01" step="any" class="form-control"/>
|
||||||
<span class="help-block">Of course, there needs to be money in the envelope.</span>
|
<span class="help-block">Of course, there needs to be money in the envelope.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ Form::label('submit', ' ', ['class' => 'col-sm-3 control-label'])}}
|
{{ Form::label('submit', ' ', ['class' => 'col-sm-4 control-label'])}}
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-8">
|
||||||
<input type="submit" name="submit" value="Save new limit" class="btn btn-default"/>
|
<input type="submit" name="submit" value="Update envelope" class="btn btn-success"/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -100,11 +96,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{Form::open()}}
|
{{Form::close()}}
|
||||||
|
|
||||||
|
|
||||||
@stop
|
@stop
|
||||||
@section('scripts')
|
|
||||||
<script type="text/javascript" src="assets/javascript/moment.min.js"></script>
|
|
||||||
<script type="text/javascript" src="assets/javascript/limits.js"></script>
|
|
||||||
@stop
|
|
Loading…
Reference in New Issue
Block a user