mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-31 19:27:51 -06:00
All kinds of new code, especially for the piggy banks.
This commit is contained in:
parent
3231effd20
commit
2f8b10e82c
@ -2,10 +2,14 @@
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'index_periods' => ['1D', '1W', '1M', '3M', '6M','1Y', 'custom'],
|
'index_periods' => ['1D', '1W', '1M', '3M', '6M', '1Y', 'custom'],
|
||||||
'budget_periods' => ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly'],
|
'budget_periods' => ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly'],
|
||||||
'piggybank_periods' => ['day', 'week', 'month', 'year'],
|
'piggybank_periods' => [
|
||||||
'periods_to_text' => [
|
'week' => 'Week',
|
||||||
|
'month' => 'Month',
|
||||||
|
'year' => 'Year'
|
||||||
|
],
|
||||||
|
'periods_to_text' => [
|
||||||
'weekly' => 'A week',
|
'weekly' => 'A week',
|
||||||
'monthly' => 'A month',
|
'monthly' => 'A month',
|
||||||
'quarterly' => 'A quarter',
|
'quarterly' => 'A quarter',
|
||||||
@ -13,7 +17,7 @@ return [
|
|||||||
'yearly' => 'A year',
|
'yearly' => 'A year',
|
||||||
],
|
],
|
||||||
|
|
||||||
'range_to_text' => [
|
'range_to_text' => [
|
||||||
'1D' => 'day',
|
'1D' => 'day',
|
||||||
'1W' => 'week',
|
'1W' => 'week',
|
||||||
'1M' => 'month',
|
'1M' => 'month',
|
||||||
@ -21,15 +25,15 @@ return [
|
|||||||
'6M' => 'half year',
|
'6M' => 'half year',
|
||||||
'custom' => '(custom)'
|
'custom' => '(custom)'
|
||||||
],
|
],
|
||||||
'range_to_name' => [
|
'range_to_name' => [
|
||||||
'1D' => 'one day',
|
'1D' => 'one day',
|
||||||
'1W' => 'one week',
|
'1W' => 'one week',
|
||||||
'1M' => 'one month',
|
'1M' => 'one month',
|
||||||
'3M' => 'three months',
|
'3M' => 'three months',
|
||||||
'6M' => 'six months',
|
'6M' => 'six months',
|
||||||
'1Y' => 'one year',
|
'1Y' => 'one year',
|
||||||
],
|
],
|
||||||
'range_to_repeat_freq' => [
|
'range_to_repeat_freq' => [
|
||||||
'1D' => 'weekly',
|
'1D' => 'weekly',
|
||||||
'1W' => 'weekly',
|
'1W' => 'weekly',
|
||||||
'1M' => 'monthly',
|
'1M' => 'monthly',
|
||||||
|
@ -340,28 +340,50 @@ class AccountController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function update(Account $account)
|
public function update(Account $account)
|
||||||
{
|
{
|
||||||
/** @var \Account $account */
|
|
||||||
$account = $this->_repository->update($account, Input::all());
|
|
||||||
if ($account->validate()) {
|
|
||||||
Session::flash('success', 'Account "' . $account->name . '" updated.');
|
|
||||||
switch ($account->accountType->type) {
|
|
||||||
case 'Asset account':
|
|
||||||
case 'Default account':
|
|
||||||
return Redirect::route('accounts.asset');
|
|
||||||
break;
|
|
||||||
case 'Expense account':
|
|
||||||
case 'Beneficiary account':
|
|
||||||
return Redirect::route('accounts.expense');
|
|
||||||
break;
|
|
||||||
case 'Revenue account':
|
|
||||||
return Redirect::route('accounts.revenue');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
/** @var \FireflyIII\Database\Account $acct */
|
||||||
Session::flash('error', 'Could not update account: ' . $account->errors()->first());
|
$acct = App::make('FireflyIII\Database\Account');
|
||||||
|
$data = Input::except('_token');
|
||||||
|
|
||||||
return Redirect::route('accounts.edit', $account->id)->withInput()->withErrors($account->errors());
|
switch($account->accountType->type) {
|
||||||
|
default:
|
||||||
|
throw new FireflyException('Cannot handle account type "' . e($account->accountType->type) . '"');
|
||||||
|
break;
|
||||||
|
case 'Default account':
|
||||||
|
$data['what'] = 'asset';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (Input::get('post_submit_action')) {
|
||||||
|
default:
|
||||||
|
throw new FireflyException('Cannot handle post_submit_action "' . e(Input::get('post_submit_action')) . '"');
|
||||||
|
break;
|
||||||
|
case 'create_another':
|
||||||
|
case 'store':
|
||||||
|
$messages = $acct->validate($data);
|
||||||
|
/** @var MessageBag $messages ['errors'] */
|
||||||
|
if ($messages['errors']->count() > 0) {
|
||||||
|
Session::flash('warnings', $messages['warnings']);
|
||||||
|
Session::flash('successes', $messages['successes']);
|
||||||
|
Session::flash('error', 'Could not save account: ' . $messages['errors']->first());
|
||||||
|
return Redirect::route('accounts.create', $data['what'])->withInput()->withErrors($messages['errors']);
|
||||||
|
}
|
||||||
|
// store!
|
||||||
|
$acct->update($account, $data);
|
||||||
|
Session::flash('success', 'Account updated!');
|
||||||
|
|
||||||
|
if ($data['post_submit_action'] == 'create_another') {
|
||||||
|
return Redirect::route('accounts.edit', $account->id);
|
||||||
|
} else {
|
||||||
|
return Redirect::route('accounts.edit', $account->id);
|
||||||
|
}
|
||||||
|
case 'validate_only':
|
||||||
|
$messageBags = $acct->validate($data);
|
||||||
|
Session::flash('warnings', $messageBags['warnings']);
|
||||||
|
Session::flash('successes', $messageBags['successes']);
|
||||||
|
Session::flash('errors', $messageBags['errors']);
|
||||||
|
return Redirect::route('accounts.edit', $account->id)->withInput();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,11 +43,11 @@ class GoogleChartController extends BaseController
|
|||||||
$row = [clone $current];
|
$row = [clone $current];
|
||||||
|
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
if ($current > Carbon::now()) {
|
//if ($current > Carbon::now()) {
|
||||||
$row[] = null;
|
// $row[] = 0;
|
||||||
} else {
|
//} else {
|
||||||
$row[] = $account->balance($current);
|
$row[] = $account->balance($current);
|
||||||
}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use Firefly\Exception\FireflyException;
|
use Firefly\Exception\FireflyException;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PiggybankController
|
* Class PiggybankController
|
||||||
@ -23,7 +24,19 @@ class PiggybankController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException;
|
|
||||||
|
/** @var \FireflyIII\Database\Account $acct */
|
||||||
|
$acct = App::make('FireflyIII\Database\Account');
|
||||||
|
|
||||||
|
/** @var \FireflyIII\Shared\Toolkit\Form $toolkit */
|
||||||
|
$toolkit = App::make('FireflyIII\Shared\Toolkit\Form');
|
||||||
|
|
||||||
|
$periods = Config::get('firefly.piggybank_periods');
|
||||||
|
|
||||||
|
|
||||||
|
$accounts = $toolkit->makeSelectList($acct->getAssetAccounts());
|
||||||
|
return View::make('piggybanks.create', compact('accounts', 'periods'))->with('title', 'Piggy banks')->with('mainTitleIcon', 'fa-sort-amount-asc')
|
||||||
|
->with('subTitle', 'Create new piggy bank')->with('subTitleIcon', 'fa-plus');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -96,9 +109,36 @@ class PiggybankController extends BaseController
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function edit(Piggybank $piggyBank)
|
public function edit(Piggybank $piggybank)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException;
|
|
||||||
|
/** @var \FireflyIII\Database\Account $acct */
|
||||||
|
$acct = App::make('FireflyIII\Database\Account');
|
||||||
|
|
||||||
|
/** @var \FireflyIII\Shared\Toolkit\Form $toolkit */
|
||||||
|
$toolkit = App::make('FireflyIII\Shared\Toolkit\Form');
|
||||||
|
|
||||||
|
$periods = Config::get('firefly.piggybank_periods');
|
||||||
|
|
||||||
|
$accounts = $toolkit->makeSelectList($acct->getAssetAccounts());
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Flash some data to fill the form.
|
||||||
|
*/
|
||||||
|
$prefilled = [
|
||||||
|
'name' => $piggybank->name,
|
||||||
|
'account_id' => $piggybank->account_id,
|
||||||
|
'targetamount' => $piggybank->targetamount,
|
||||||
|
'targetdate' => $piggybank->targetdate,
|
||||||
|
'remind_me' => intval($piggybank->remind_me) == 1 ? true : false
|
||||||
|
];
|
||||||
|
Session::flash('prefilled', $prefilled);
|
||||||
|
|
||||||
|
return View::make('piggybanks.edit', compact('piggybank', 'accounts', 'periods','prefilled'))->with('title', 'Piggybanks')->with(
|
||||||
|
'mainTitleIcon', 'fa-sort-amount-asc'
|
||||||
|
)
|
||||||
|
->with('subTitle', 'Edit piggy bank "' . e($piggybank->name) . '"')->with('subTitleIcon', 'fa-pencil');
|
||||||
|
//throw new NotImplementedException;
|
||||||
// /** @var \Firefly\Helper\Toolkit\Toolkit $toolkit */
|
// /** @var \Firefly\Helper\Toolkit\Toolkit $toolkit */
|
||||||
// $toolkit = App::make('Firefly\Helper\Toolkit\Toolkit');
|
// $toolkit = App::make('Firefly\Helper\Toolkit\Toolkit');
|
||||||
//
|
//
|
||||||
@ -258,9 +298,6 @@ class PiggybankController extends BaseController
|
|||||||
/** @var \FireflyIII\Database\Piggybank $repos */
|
/** @var \FireflyIII\Database\Piggybank $repos */
|
||||||
$repos = App::make('FireflyIII\Database\Piggybank');
|
$repos = App::make('FireflyIII\Database\Piggybank');
|
||||||
|
|
||||||
/** @var \FireflyIII\Database\Account $acct */
|
|
||||||
$acct = App::make('FireflyIII\Database\Account');
|
|
||||||
|
|
||||||
/** @var Collection $piggybanks */
|
/** @var Collection $piggybanks */
|
||||||
$piggybanks = $repos->get();
|
$piggybanks = $repos->get();
|
||||||
|
|
||||||
@ -291,7 +328,7 @@ class PiggybankController extends BaseController
|
|||||||
$accounts[$account->id]['leftToSave'] += $piggybank->leftToSave;
|
$accounts[$account->id]['leftToSave'] += $piggybank->leftToSave;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return View::make('piggybanks.index', compact('piggybanks','accounts'))->with('title', 'Piggy banks')->with('mainTitleIcon', 'fa-sort-amount-asc');
|
return View::make('piggybanks.index', compact('piggybanks', 'accounts'))->with('title', 'Piggy banks')->with('mainTitleIcon', 'fa-sort-amount-asc');
|
||||||
|
|
||||||
//throw new NotImplementedException;
|
//throw new NotImplementedException;
|
||||||
// $countRepeating = $this->_repository->countRepeating();
|
// $countRepeating = $this->_repository->countRepeating();
|
||||||
@ -410,12 +447,49 @@ class PiggybankController extends BaseController
|
|||||||
// ->with('balance', $balance);
|
// ->with('balance', $balance);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * @return $this|\Illuminate\Http\RedirectResponse
|
*
|
||||||
// */
|
*/
|
||||||
public function store()
|
public function store()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException;
|
$data = Input::all();
|
||||||
|
$data['repeats'] = 0;
|
||||||
|
/** @var \FireflyIII\Database\Piggybank $repos */
|
||||||
|
$repos = App::make('FireflyIII\Database\Piggybank');
|
||||||
|
|
||||||
|
switch ($data['post_submit_action']) {
|
||||||
|
default:
|
||||||
|
throw new FireflyException('Cannot handle post_submit_action "' . e($data['post_submit_action']) . '"');
|
||||||
|
break;
|
||||||
|
case 'create_another':
|
||||||
|
case 'store':
|
||||||
|
$messages = $repos->validate($data);
|
||||||
|
/** @var MessageBag $messages ['errors'] */
|
||||||
|
if ($messages['errors']->count() > 0) {
|
||||||
|
Session::flash('warnings', $messages['warnings']);
|
||||||
|
Session::flash('successes', $messages['successes']);
|
||||||
|
Session::flash('error', 'Could not save piggy bank: ' . $messages['errors']->first());
|
||||||
|
return Redirect::route('piggybanks.create')->withInput()->withErrors($messages['errors']);
|
||||||
|
}
|
||||||
|
// store!
|
||||||
|
$repos->store($data);
|
||||||
|
Session::flash('success', 'New piggy bank stored!');
|
||||||
|
|
||||||
|
if ($data['post_submit_action'] == 'create_another') {
|
||||||
|
return Redirect::route('piggybanks.create');
|
||||||
|
} else {
|
||||||
|
return Redirect::route('piggybanks.index');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'validate_only':
|
||||||
|
$messageBags = $repos->validate($data);
|
||||||
|
Session::flash('warnings', $messageBags['warnings']);
|
||||||
|
Session::flash('successes', $messageBags['successes']);
|
||||||
|
Session::flash('errors', $messageBags['errors']);
|
||||||
|
|
||||||
|
return Redirect::route('piggybanks.create')->withInput();
|
||||||
|
break;
|
||||||
|
}
|
||||||
// $data = Input::all();
|
// $data = Input::all();
|
||||||
// unset($data['_token']);
|
// unset($data['_token']);
|
||||||
//
|
//
|
||||||
|
@ -33,6 +33,7 @@ class CreatePiggybanksTable extends Migration
|
|||||||
$table->smallInteger('rep_times')->unsigned()->nullable();
|
$table->smallInteger('rep_times')->unsigned()->nullable();
|
||||||
$table->enum('reminder', ['day', 'week', 'month', 'year'])->nullable();
|
$table->enum('reminder', ['day', 'week', 'month', 'year'])->nullable();
|
||||||
$table->smallInteger('reminder_skip')->unsigned();
|
$table->smallInteger('reminder_skip')->unsigned();
|
||||||
|
$table->boolean('remind_me');
|
||||||
$table->integer('order')->unsigned();
|
$table->integer('order')->unsigned();
|
||||||
|
|
||||||
// connect account to piggybank.
|
// connect account to piggybank.
|
||||||
|
@ -10,9 +10,10 @@ class Form
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param null $value
|
* @param null $value
|
||||||
* @param array $options
|
* @param array $options
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
@ -40,7 +41,7 @@ class Form
|
|||||||
public static function ffAmount($name, $value = null, array $options = [])
|
public static function ffAmount($name, $value = null, array $options = [])
|
||||||
{
|
{
|
||||||
$options['step'] = 'any';
|
$options['step'] = 'any';
|
||||||
$options['min'] = '0.01';
|
$options['min'] = '0.01';
|
||||||
return self::ffInput('amount', $name, $value, $options);
|
return self::ffInput('amount', $name, $value, $options);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -61,9 +62,10 @@ class Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param null $value
|
* @param null $value
|
||||||
* @param array $options
|
* @param array $options
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
@ -73,9 +75,10 @@ class Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param null $value
|
* @param null $value
|
||||||
* @param array $options
|
* @param array $options
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
@ -86,10 +89,11 @@ class Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param array $list
|
* @param array $list
|
||||||
* @param null $selected
|
* @param null $selected
|
||||||
* @param array $options
|
* @param array $options
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
@ -99,9 +103,10 @@ class Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param null $value
|
* @param null $value
|
||||||
* @param array $options
|
* @param array $options
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
@ -111,16 +116,25 @@ class Form
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function label($name)
|
/**
|
||||||
|
* @param $name
|
||||||
|
* @param $options
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function label($name, $options)
|
||||||
{
|
{
|
||||||
|
if (isset($options['label'])) {
|
||||||
|
return $options['label'];
|
||||||
|
}
|
||||||
$labels = [
|
$labels = [
|
||||||
'amount_min' => 'Amount (min)',
|
'amount_min' => 'Amount (min)',
|
||||||
'amount_max' => 'Amount (max)',
|
'amount_max' => 'Amount (max)',
|
||||||
'match' => 'Matches on',
|
'match' => 'Matches on',
|
||||||
'repeat_freq' => 'Repetition',
|
'repeat_freq' => 'Repetition',
|
||||||
'account_from_id' => 'Account from',
|
'account_from_id' => 'Account from',
|
||||||
'account_to_id' => 'Account to',
|
'account_to_id' => 'Account to',
|
||||||
'account_id' => 'Asset account'
|
'account_id' => 'Asset account'
|
||||||
];
|
];
|
||||||
|
|
||||||
return isset($labels[$name]) ? $labels[$name] : str_replace('_', ' ', ucfirst($name));
|
return isset($labels[$name]) ? $labels[$name] : str_replace('_', ' ', ucfirst($name));
|
||||||
@ -174,28 +188,29 @@ class Form
|
|||||||
case 'create':
|
case 'create':
|
||||||
$return = '<div class="form-group"><label for="return_to_form" class="col-sm-4 control-label">';
|
$return = '<div class="form-group"><label for="return_to_form" class="col-sm-4 control-label">';
|
||||||
$return .= 'Return here</label><div class="col-sm-8"><div class="radio"><label>';
|
$return .= 'Return here</label><div class="col-sm-8"><div class="radio"><label>';
|
||||||
$return .= \Form::radio('post_submit_action','create_another', $previousValue == 'create_another');
|
$return .= \Form::radio('post_submit_action', 'create_another', $previousValue == 'create_another');
|
||||||
$return .= 'After storing, return here to create another one.</label></div></div></div>';
|
$return .= 'After storing, return here to create another one.</label></div></div></div>';
|
||||||
break;
|
break;
|
||||||
case 'update':
|
case 'update':
|
||||||
$return = '<div class="form-group"><label for="return_to_edit" class="col-sm-4 control-label">';
|
$return = '<div class="form-group"><label for="return_to_edit" class="col-sm-4 control-label">';
|
||||||
$return .= 'Return here</label><div class="col-sm-8"><div class="radio"><label>';
|
$return .= 'Return here</label><div class="col-sm-8"><div class="radio"><label>';
|
||||||
$return .= \Form::radio('post_submit_action','return_to_edit', $previousValue == 'return_to_edit');
|
$return .= \Form::radio('post_submit_action', 'return_to_edit', $previousValue == 'return_to_edit');
|
||||||
$return .= 'After updating, return here.</label></div></div></div>';
|
$return .= 'After updating, return here.</label></div></div></div>';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new FireflyException('Cannot create ffOptionsList for option (store+return) ' . $type);
|
throw new FireflyException('Cannot create ffOptionsList for option (store+return) ' . $type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $store.$validate.$return;
|
return $store . $validate . $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $type
|
* @param $type
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param null $value
|
* @param null $value
|
||||||
* @param array $options
|
* @param array $options
|
||||||
* @param array $list
|
* @param array $list
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
@ -204,10 +219,10 @@ class Form
|
|||||||
/*
|
/*
|
||||||
* add some defaults to this method:
|
* add some defaults to this method:
|
||||||
*/
|
*/
|
||||||
$options['class'] = 'form-control';
|
$options['class'] = 'form-control';
|
||||||
$options['id'] = 'ffInput_' . $name;
|
$options['id'] = 'ffInput_' . $name;
|
||||||
$options['autocomplete'] = 'off';
|
$options['autocomplete'] = 'off';
|
||||||
$label = self::label($name);
|
$label = self::label($name, $options);
|
||||||
/*
|
/*
|
||||||
* Make label and placeholder look nice.
|
* Make label and placeholder look nice.
|
||||||
*/
|
*/
|
||||||
@ -216,9 +231,9 @@ class Form
|
|||||||
/*
|
/*
|
||||||
* Get prefilled value:
|
* Get prefilled value:
|
||||||
*/
|
*/
|
||||||
if(\Session::has('prefilled')) {
|
if (\Session::has('prefilled')) {
|
||||||
$prefilled = \Session::get('prefilled');
|
$prefilled = \Session::get('prefilled');
|
||||||
$value = isset($prefilled[$name]) && is_null($value) ? $prefilled[$name] : $value;
|
$value = isset($prefilled[$name]) && is_null($value) ? $prefilled[$name] : $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -193,7 +193,7 @@ class EloquentPiggybankTrigger
|
|||||||
'Firefly\Trigger\Piggybanks\EloquentPiggybankTrigger@updateRelatedTransfer'
|
'Firefly\Trigger\Piggybanks\EloquentPiggybankTrigger@updateRelatedTransfer'
|
||||||
);
|
);
|
||||||
$events->listen(
|
$events->listen(
|
||||||
'piggybanks.check', 'Firefly\Trigger\Piggybanks\EloquentPiggybankTrigger@checkRepeatingPiggies'
|
'piggybanks.storepiggybanks.check', 'Firefly\Trigger\Piggybanks\EloquentPiggybankTrigger@checkRepeatingPiggies'
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,37 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
|
|||||||
$this->setUser(\Auth::user());
|
$this->setUser(\Auth::user());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Ardent $model
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function update(Ardent $model, array $data)
|
||||||
|
{
|
||||||
|
$model->name = $data['name'];
|
||||||
|
$model->active = isset($data['active']) ? intval($data['active']) : 0;
|
||||||
|
$model->save();
|
||||||
|
|
||||||
|
if (isset($data['openingbalance']) && isset($data['openingbalancedate'])) {
|
||||||
|
$openingBalance = $this->openingBalanceTransaction($model);
|
||||||
|
|
||||||
|
$openingBalance->date = new Carbon($data['openingbalancedate']);
|
||||||
|
$openingBalance->save();
|
||||||
|
$amount = floatval($data['openingbalance']);
|
||||||
|
/** @var \Transaction $transaction */
|
||||||
|
foreach ($openingBalance->transactions as $transaction) {
|
||||||
|
if ($transaction->account_id == $model->id) {
|
||||||
|
$transaction->amount = $amount;
|
||||||
|
} else {
|
||||||
|
$transaction->amount = $amount * -1;
|
||||||
|
}
|
||||||
|
$transaction->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all asset accounts. Optional JSON based parameters.
|
* Get all asset accounts. Optional JSON based parameters.
|
||||||
*
|
*
|
||||||
|
@ -24,6 +24,7 @@ class AccountType implements AccountTypeInterface, CUD, CommonDatabaseCalls
|
|||||||
* @param $what
|
* @param $what
|
||||||
*
|
*
|
||||||
* @return \AccountType|null
|
* @return \AccountType|null
|
||||||
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function findByWhat($what)
|
public function findByWhat($what)
|
||||||
{
|
{
|
||||||
@ -125,4 +126,15 @@ class AccountType implements AccountTypeInterface, CUD, CommonDatabaseCalls
|
|||||||
{
|
{
|
||||||
// TODO: Implement getByIds() method.
|
// TODO: Implement getByIds() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Ardent $model
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function update(Ardent $model, array $data)
|
||||||
|
{
|
||||||
|
// TODO: Implement update() method.
|
||||||
|
}
|
||||||
}
|
}
|
@ -154,4 +154,15 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
|
|||||||
}
|
}
|
||||||
)->before($end)->after($start)->lessThan(0)->transactionTypes(['Withdrawal'])->get();
|
)->before($end)->after($start)->lessThan(0)->transactionTypes(['Withdrawal'])->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Ardent $model
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function update(Ardent $model, array $data)
|
||||||
|
{
|
||||||
|
// TODO: Implement update() method.
|
||||||
|
}
|
||||||
}
|
}
|
@ -115,4 +115,15 @@ class Category implements CUD, CommonDatabaseCalls, CategoryInterface
|
|||||||
{
|
{
|
||||||
// TODO: Implement findByWhat() method.
|
// TODO: Implement findByWhat() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Ardent $model
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function update(Ardent $model, array $data)
|
||||||
|
{
|
||||||
|
// TODO: Implement update() method.
|
||||||
|
}
|
||||||
}
|
}
|
@ -46,4 +46,12 @@ interface CUD
|
|||||||
*/
|
*/
|
||||||
public function store(array $data);
|
public function store(array $data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Ardent $model
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function update(Ardent $model, array $data);
|
||||||
|
|
||||||
}
|
}
|
@ -2,6 +2,7 @@
|
|||||||
namespace FireflyIII\Database;
|
namespace FireflyIII\Database;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
use LaravelBook\Ardent\Ardent;
|
use LaravelBook\Ardent\Ardent;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
@ -76,7 +77,81 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
|
|||||||
*/
|
*/
|
||||||
public function validate(array $model)
|
public function validate(array $model)
|
||||||
{
|
{
|
||||||
// TODO: Implement validate() method.
|
$warnings = new MessageBag;
|
||||||
|
$successes = new MessageBag;
|
||||||
|
$errors = new MessageBag;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Name validation:
|
||||||
|
*/
|
||||||
|
if (!isset($model['name'])) {
|
||||||
|
$errors->add('name', 'Name is mandatory');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($model['name']) && strlen($model['name']) == 0) {
|
||||||
|
$errors->add('name', 'Name is too short');
|
||||||
|
}
|
||||||
|
if (isset($model['name']) && strlen($model['name']) > 100) {
|
||||||
|
$errors->add('name', 'Name is too long');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (intval($model['account_id']) == 0) {
|
||||||
|
$errors->add('account_id', 'Account is mandatory');
|
||||||
|
}
|
||||||
|
if ($model['targetdate'] == '' && isset($model['remind_me']) && intval($model['remind_me']) == 1) {
|
||||||
|
$errors->add('targetdate', 'Target date is mandatory when setting reminders.');
|
||||||
|
}
|
||||||
|
if ($model['targetdate'] != '') {
|
||||||
|
try {
|
||||||
|
new Carbon($model['targetdate']);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$errors->add('date', 'Invalid date.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (floatval($model['targetamount']) < 0.01) {
|
||||||
|
$errors->add('targetamount', 'Amount should be above 0.01.');
|
||||||
|
}
|
||||||
|
if (!in_array(ucfirst($model['reminder']), \Config::get('firefly.piggybank_periods'))) {
|
||||||
|
$errors->add('reminder', 'Invalid reminder period (' . $model['reminder'] . ')');
|
||||||
|
}
|
||||||
|
// check period.
|
||||||
|
if (!$errors->has('reminder') && !$errors->has('targetdate') && isset($model['remind_me']) && intval($model['remind_me']) == 1) {
|
||||||
|
$today = new Carbon;
|
||||||
|
$target = new Carbon($model['targetdate']);
|
||||||
|
switch ($model['reminder']) {
|
||||||
|
case 'week':
|
||||||
|
$today->addWeek();
|
||||||
|
break;
|
||||||
|
case 'month':
|
||||||
|
$today->addMonth();
|
||||||
|
break;
|
||||||
|
case 'year':
|
||||||
|
$today->addYear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ($today > $target) {
|
||||||
|
$errors->add('reminder', 'Target date is too close to today to set reminders.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$validator = \Validator::make($model, \Piggybank::$rules);
|
||||||
|
if ($validator->invalid()) {
|
||||||
|
$errors->merge($errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add ok messages.
|
||||||
|
$list = ['name', 'account_id', 'targetamount', 'targetdate', 'remind_me', 'reminder'];
|
||||||
|
foreach ($list as $entry) {
|
||||||
|
if (!$errors->has($entry) && !$warnings->has($entry)) {
|
||||||
|
$successes->add($entry, 'OK');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'errors' => $errors,
|
||||||
|
'warnings' => $warnings,
|
||||||
|
'successes' => $successes
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,7 +161,22 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
|
|||||||
*/
|
*/
|
||||||
public function store(array $data)
|
public function store(array $data)
|
||||||
{
|
{
|
||||||
// TODO: Implement store() method.
|
$data['rep_every'] = isset($data['rep_every']) ? $data['rep_every'] : 0;
|
||||||
|
$data['reminder_skip'] = isset($data['reminder_skip']) ? $data['reminder_skip'] : 0;
|
||||||
|
$data['order'] = isset($data['order']) ? $data['order'] : 0;
|
||||||
|
$data['remind_me'] = isset($data['remind_me']) ? intval($data['remind_me']) : 0;
|
||||||
|
$data['startdate'] = isset($data['startdate']) ? $data['startdate'] : Carbon::now()->format('Y-m-d');
|
||||||
|
$data['targetdate'] = isset($data['targetdate']) && $data['targetdate'] != '' ? $data['targetdate'] : null;
|
||||||
|
|
||||||
|
|
||||||
|
$piggybank = new \Piggybank($data);
|
||||||
|
if (!$piggybank->validate()) {
|
||||||
|
var_dump($piggybank->errors()->all());
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
$piggybank->save();
|
||||||
|
\Event::fire('piggybanks.store', [$piggybank]);
|
||||||
|
$piggybank->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,8 +29,8 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \RecurringTransaction $recurring
|
* @param \RecurringTransaction $recurring
|
||||||
* @param Carbon $current
|
* @param Carbon $start
|
||||||
* @param Carbon $currentEnd
|
* @param Carbon $end
|
||||||
*
|
*
|
||||||
* @return \TransactionJournal|null
|
* @return \TransactionJournal|null
|
||||||
*/
|
*/
|
||||||
@ -129,4 +129,15 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
|||||||
{
|
{
|
||||||
// TODO: Implement findByWhat() method.
|
// TODO: Implement findByWhat() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Ardent $model
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function update(Ardent $model, array $data)
|
||||||
|
{
|
||||||
|
// TODO: Implement update() method.
|
||||||
|
}
|
||||||
}
|
}
|
@ -171,4 +171,25 @@ class Transaction implements TransactionInterface, CUD, CommonDatabaseCalls
|
|||||||
{
|
{
|
||||||
// TODO: Implement findByWhat() method.
|
// TODO: Implement findByWhat() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Ardent $model
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function update(Ardent $model, array $data)
|
||||||
|
{
|
||||||
|
// TODO: Implement update() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $ids
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getByIds(array $ids)
|
||||||
|
{
|
||||||
|
// TODO: Implement getByIds() method.
|
||||||
|
}
|
||||||
}
|
}
|
@ -116,4 +116,15 @@ class TransactionCurrency implements TransactionCurrencyInterface, CUD, CommonDa
|
|||||||
{
|
{
|
||||||
// TODO: Implement getByIds() method.
|
// TODO: Implement getByIds() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Ardent $model
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function update(Ardent $model, array $data)
|
||||||
|
{
|
||||||
|
// TODO: Implement update() method.
|
||||||
|
}
|
||||||
}
|
}
|
@ -267,4 +267,15 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
|
|||||||
{
|
{
|
||||||
// TODO: Implement getByIds() method.
|
// TODO: Implement getByIds() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Ardent $model
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function update(Ardent $model, array $data)
|
||||||
|
{
|
||||||
|
// TODO: Implement update() method.
|
||||||
|
}
|
||||||
}
|
}
|
@ -115,4 +115,15 @@ class TransactionType implements TransactionTypeInterface, CUD, CommonDatabaseCa
|
|||||||
{
|
{
|
||||||
// TODO: Implement getByIds() method.
|
// TODO: Implement getByIds() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Ardent $model
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function update(Ardent $model, array $data)
|
||||||
|
{
|
||||||
|
// TODO: Implement update() method.
|
||||||
|
}
|
||||||
}
|
}
|
50
app/lib/FireflyIII/Shared/Toolkit/Form.php
Normal file
50
app/lib/FireflyIII/Shared/Toolkit/Form.php
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Shared\Toolkit;
|
||||||
|
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Form
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Shared\Toolkit
|
||||||
|
*/
|
||||||
|
class Form {
|
||||||
|
/**
|
||||||
|
* Takes any collection and tries to make a sensible select list compatible array of it.
|
||||||
|
*
|
||||||
|
* @param Collection $set
|
||||||
|
* @param null $titleField
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function makeSelectList(Collection $set, $titleField = null)
|
||||||
|
{
|
||||||
|
$selectList = [];
|
||||||
|
/** @var Model $entry */
|
||||||
|
foreach ($set as $entry) {
|
||||||
|
$id = intval($entry->id);
|
||||||
|
$title = null;
|
||||||
|
if (is_null($titleField)) {
|
||||||
|
// try 'title' field.
|
||||||
|
if (isset($entry->title)) {
|
||||||
|
$title = $entry->title;
|
||||||
|
}
|
||||||
|
// try 'name' field
|
||||||
|
if (is_null($title)) {
|
||||||
|
$title = $entry->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// try 'description' field
|
||||||
|
if (is_null($title)) {
|
||||||
|
$title = $entry->description;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$title = $entry->$titleField;
|
||||||
|
}
|
||||||
|
$selectList[$id] = $title;
|
||||||
|
}
|
||||||
|
return $selectList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -56,6 +56,7 @@ class Piggybank extends Ardent
|
|||||||
'rep_times' => 'min:1|max:100', // how many times do you want to save this amount? eg. 3 times
|
'rep_times' => 'min:1|max:100', // how many times do you want to save this amount? eg. 3 times
|
||||||
'reminder' => 'in:day,week,month,year', // want a reminder to put money in this?
|
'reminder' => 'in:day,week,month,year', // want a reminder to put money in this?
|
||||||
'reminder_skip' => 'required|min:0|max:100', // every week? every 2 months?
|
'reminder_skip' => 'required|min:0|max:100', // every week? every 2 months?
|
||||||
|
'remind_me' => 'required|boolean',
|
||||||
'order' => 'required:min:1', // not yet used.
|
'order' => 'required:min:1', // not yet used.
|
||||||
];
|
];
|
||||||
public $fillable
|
public $fillable
|
||||||
@ -71,6 +72,7 @@ class Piggybank extends Ardent
|
|||||||
'rep_times',
|
'rep_times',
|
||||||
'reminder',
|
'reminder',
|
||||||
'reminder_skip',
|
'reminder_skip',
|
||||||
|
'remind_me',
|
||||||
'order'
|
'order'
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -90,7 +92,6 @@ class Piggybank extends Ardent
|
|||||||
$rep->targetdate = $target;
|
$rep->targetdate = $target;
|
||||||
$rep->currentamount = 0;
|
$rep->currentamount = 0;
|
||||||
$rep->save();
|
$rep->save();
|
||||||
|
|
||||||
\Event::fire('piggybanks.repetition', [$rep]);
|
\Event::fire('piggybanks.repetition', [$rep]);
|
||||||
|
|
||||||
return $rep;
|
return $rep;
|
||||||
|
@ -202,13 +202,15 @@ Route::group(
|
|||||||
Route::get('/piggybanks', ['uses' => 'PiggybankController@index', 'as' => 'piggybanks.index']);
|
Route::get('/piggybanks', ['uses' => 'PiggybankController@index', 'as' => 'piggybanks.index']);
|
||||||
Route::get('/piggybanks/add/{piggybank}', ['uses' => 'PiggybankController@add']);
|
Route::get('/piggybanks/add/{piggybank}', ['uses' => 'PiggybankController@add']);
|
||||||
Route::get('/piggybanks/remove/{piggybank}', ['uses' => 'PiggybankController@remove']);
|
Route::get('/piggybanks/remove/{piggybank}', ['uses' => 'PiggybankController@remove']);
|
||||||
|
Route::get('/piggybanks/edit/{piggybank}', ['uses' => 'PiggybankController@edit','as' => 'piggybanks.edit']);
|
||||||
|
Route::get('/piggybanks/create', ['uses' => 'PiggybankController@create', 'as' => 'piggybanks.create']);
|
||||||
|
|
||||||
|
|
||||||
// Route::get('/repeated',['uses' => 'PiggybankController@repeated','as' => 'piggybanks.index.repeated']);
|
// Route::get('/repeated',['uses' => 'PiggybankController@repeated','as' => 'piggybanks.index.repeated']);
|
||||||
// Route::get('/piggybanks/create/piggybank', ['uses' => 'PiggybankController@createPiggybank','as' => 'piggybanks.create.piggybank']);
|
|
||||||
// Route::get('/piggybanks/create/repeated', ['uses' => 'PiggybankController@createRepeated','as' => 'piggybanks.create.repeated']);
|
// Route::get('/piggybanks/create/repeated', ['uses' => 'PiggybankController@createRepeated','as' => 'piggybanks.create.repeated']);
|
||||||
// Route::get('/piggybanks/addMoney/{piggybank}', ['uses' => 'PiggybankController@addMoney','as' => 'piggybanks.amount.add']);
|
// Route::get('/piggybanks/addMoney/{piggybank}', ['uses' => 'PiggybankController@addMoney','as' => 'piggybanks.amount.add']);
|
||||||
// Route::get('/piggybanks/removeMoney/{piggybank}', ['uses' => 'PiggybankController@removeMoney','as' => 'piggybanks.amount.remove']);
|
// Route::get('/piggybanks/removeMoney/{piggybank}', ['uses' => 'PiggybankController@removeMoney','as' => 'piggybanks.amount.remove']);
|
||||||
// Route::get('/piggybanks/show/{piggybank}', ['uses' => 'PiggybankController@show','as' => 'piggybanks.show']);
|
// Route::get('/piggybanks/show/{piggybank}', ['uses' => 'PiggybankController@show','as' => 'piggybanks.show']);
|
||||||
// Route::get('/piggybanks/edit/{piggybank}', ['uses' => 'PiggybankController@edit','as' => 'piggybanks.edit']);
|
|
||||||
// Route::get('/piggybanks/delete/{piggybank}', ['uses' => 'PiggybankController@delete','as' => 'piggybanks.delete']);
|
// Route::get('/piggybanks/delete/{piggybank}', ['uses' => 'PiggybankController@delete','as' => 'piggybanks.delete']);
|
||||||
// Route::post('/piggybanks/updateAmount/{piggybank}',['uses' => 'PiggybankController@updateAmount','as' => 'piggybanks.updateAmount']);
|
// Route::post('/piggybanks/updateAmount/{piggybank}',['uses' => 'PiggybankController@updateAmount','as' => 'piggybanks.updateAmount']);
|
||||||
|
|
||||||
@ -282,7 +284,7 @@ Route::group(
|
|||||||
|
|
||||||
|
|
||||||
// piggy bank controller
|
// piggy bank controller
|
||||||
#Route::post('/piggybanks/store/piggybank', ['uses' => 'PiggybankController@storePiggybank', 'as' => 'piggybanks.store.piggybank']);
|
Route::post('/piggybanks/store', ['uses' => 'PiggybankController@store', 'as' => 'piggybanks.store']);
|
||||||
#Route::post('/piggybanks/store/repeated', ['uses' => 'PiggybankController@storeRepeated', 'as' => 'piggybanks.store.repeated']);
|
#Route::post('/piggybanks/store/repeated', ['uses' => 'PiggybankController@storeRepeated', 'as' => 'piggybanks.store.repeated']);
|
||||||
#Route::post('/piggybanks/update/{piggybank}', ['uses' => 'PiggybankController@update', 'as' => 'piggybanks.update']);
|
#Route::post('/piggybanks/update/{piggybank}', ['uses' => 'PiggybankController@update', 'as' => 'piggybanks.update']);
|
||||||
#Route::post('/piggybanks/destroy/{piggybank}', ['uses' => 'PiggybankController@destroy', 'as' => 'piggybanks.destroy']);
|
#Route::post('/piggybanks/destroy/{piggybank}', ['uses' => 'PiggybankController@destroy', 'as' => 'piggybanks.destroy']);
|
||||||
|
93
app/views/piggybanks/create.blade.php
Normal file
93
app/views/piggybanks/create.blade.php
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
@extends('layouts.default')
|
||||||
|
@section('content')
|
||||||
|
{{Form::open(['class' => 'form-horizontal','url' => route('piggybanks.store')])}}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-6 col-md-12 col-sm-6">
|
||||||
|
<div class="panel panel-primary">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<i class="fa fa-fw fa-exclamation"></i> Mandatory fields
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
{{Form::ffText('name')}}
|
||||||
|
{{Form::ffSelect('account_id',$accounts,null,['label' => 'Save on account'])}}
|
||||||
|
{{Form::ffAmount('targetamount')}}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
|
<button type="submit" class="btn btn-lg btn-success">
|
||||||
|
<i class="fa fa-plus-circle"></i> Store new piggy bank
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6 col-md-12 col-sm-12">
|
||||||
|
<!-- panel for optional fields -->
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<i class="fa fa-smile-o"></i> Optional fields
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
{{Form::ffDate('targetdate')}}
|
||||||
|
{{Form::ffCheckbox('remind_me','1',false,['label' => 'Remind me'])}}
|
||||||
|
{{Form::ffSelect('reminder',$periods,'month',['label' => 'Remind every'])}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- panel for options -->
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<i class="fa fa-bolt"></i> Options
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
{{Form::ffOptionsList('create','piggy bank')}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{--
|
||||||
|
|
||||||
|
<h4>Mandatory fields</h4>
|
||||||
|
|
||||||
|
<h4>Optional fields</h4>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
{{ Form::label('reminder', 'Remind you every', ['class' => 'col-sm-4 control-label'])}}
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input type="number" step="1" min="1" value="{{Input::old('reminder_skip') ?: 1}}" style="width:50px;display:inline;" max="100" name="reminder_skip" class="form-control" />
|
||||||
|
|
||||||
|
<select class="form-control" name="reminder" style="width:150px;display: inline">
|
||||||
|
<option value="none" label="do not remind me">do not remind me</option>
|
||||||
|
@foreach($periods as $period)
|
||||||
|
<option value="{{$period}}" label="{{$period}}">{{$period}}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@if($errors->has('reminder'))
|
||||||
|
<p class="text-danger">{{$errors->first('reminder')}}</p>
|
||||||
|
@else
|
||||||
|
<span class="help-block">Enter a number and a period and Firefly will remind you to add money
|
||||||
|
to this piggy bank every now and then.</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-6 col-md-12 col-sm-6">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-4 col-sm-8">
|
||||||
|
<button type="submit" class="btn btn-default btn-success">Create the piggy bank</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
--}}
|
||||||
|
|
||||||
|
{{Form::close()}}
|
||||||
|
@stop
|
93
app/views/piggybanks/edit.blade.php
Normal file
93
app/views/piggybanks/edit.blade.php
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
@extends('layouts.default')
|
||||||
|
@section('content')
|
||||||
|
{{Form::open(['class' => 'form-horizontal','url' => route('piggybanks.store')])}}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-6 col-md-12 col-sm-6">
|
||||||
|
<div class="panel panel-primary">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<i class="fa fa-fw fa-exclamation"></i> Mandatory fields
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
{{Form::ffText('name')}}
|
||||||
|
{{Form::ffSelect('account_id',$accounts,null,['label' => 'Save on account'])}}
|
||||||
|
{{Form::ffAmount('targetamount')}}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
|
<button type="submit" class="btn btn-lg btn-success">
|
||||||
|
<i class="fa fa-plus-circle"></i> Store new piggy bank
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-6 col-md-12 col-sm-12">
|
||||||
|
<!-- panel for optional fields -->
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<i class="fa fa-smile-o"></i> Optional fields
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
{{Form::ffDate('targetdate')}}
|
||||||
|
{{Form::ffCheckbox('remind_me','1',$prefilled['remind_me'],['label' => 'Remind me'])}}
|
||||||
|
{{Form::ffSelect('reminder',$periods,'month',['label' => 'Remind every'])}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- panel for options -->
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<i class="fa fa-bolt"></i> Options
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
{{Form::ffOptionsList('create','piggy bank')}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{--
|
||||||
|
|
||||||
|
<h4>Mandatory fields</h4>
|
||||||
|
|
||||||
|
<h4>Optional fields</h4>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
{{ Form::label('reminder', 'Remind you every', ['class' => 'col-sm-4 control-label'])}}
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input type="number" step="1" min="1" value="{{Input::old('reminder_skip') ?: 1}}" style="width:50px;display:inline;" max="100" name="reminder_skip" class="form-control" />
|
||||||
|
|
||||||
|
<select class="form-control" name="reminder" style="width:150px;display: inline">
|
||||||
|
<option value="none" label="do not remind me">do not remind me</option>
|
||||||
|
@foreach($periods as $period)
|
||||||
|
<option value="{{$period}}" label="{{$period}}">{{$period}}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
@if($errors->has('reminder'))
|
||||||
|
<p class="text-danger">{{$errors->first('reminder')}}</p>
|
||||||
|
@else
|
||||||
|
<span class="help-block">Enter a number and a period and Firefly will remind you to add money
|
||||||
|
to this piggy bank every now and then.</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-6 col-md-12 col-sm-6">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-4 col-sm-8">
|
||||||
|
<button type="submit" class="btn btn-default btn-success">Create the piggy bank</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
--}}
|
||||||
|
|
||||||
|
{{Form::close()}}
|
||||||
|
@stop
|
@ -40,7 +40,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-lg-8 col-md-6 col-sm-4">
|
<div class="col-lg-8 col-md-6 col-sm-4">
|
||||||
<div class="btn-group btn-group-xs">
|
<div class="btn-group btn-group-xs">
|
||||||
<a href="#" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a>
|
<a href="{{route('piggybanks.edit',$piggybank->id)}}" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||||
<a href="#" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
|
<a href="#" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -60,7 +60,11 @@
|
|||||||
<i class="fa fa-fw fa-plus"></i> Create piggy bank
|
<i class="fa fa-fw fa-plus"></i> Create piggy bank
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<a href="#" class="btn btn-success btn-lg">Create new piggy bank</a>
|
<div class="row">
|
||||||
|
<div class="col-lg-8 col-md-6 col-sm-4 col-lg-offset-2 col-md-offset-3 col-sm-offset-4">
|
||||||
|
<a href="{{route('piggybanks.create')}}" class="btn btn-success">Create new piggy bank</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,6 +3,7 @@ var defaultLineChartOptions = {
|
|||||||
legend: {
|
legend: {
|
||||||
position: 'none'
|
position: 'none'
|
||||||
},
|
},
|
||||||
|
interpolateNulls: true,
|
||||||
lineWidth: 1,
|
lineWidth: 1,
|
||||||
chartArea: {
|
chartArea: {
|
||||||
left: 50,
|
left: 50,
|
||||||
|
@ -2,7 +2,6 @@ google.setOnLoadCallback(drawChart);
|
|||||||
|
|
||||||
|
|
||||||
function drawChart() {
|
function drawChart() {
|
||||||
console.log(1);
|
|
||||||
googleLineChart('chart/home/account', 'accounts-chart');
|
googleLineChart('chart/home/account', 'accounts-chart');
|
||||||
googleBarChart('chart/home/budgets','budgets-chart');
|
googleBarChart('chart/home/budgets','budgets-chart');
|
||||||
googleColumnChart('chart/home/categories','categories-chart');
|
googleColumnChart('chart/home/categories','categories-chart');
|
||||||
|
Loading…
Reference in New Issue
Block a user