All kinds of new code, especially for the piggy banks.

This commit is contained in:
Sander Dorigo 2014-11-02 14:58:12 +01:00
parent 3231effd20
commit 2f8b10e82c
26 changed files with 676 additions and 89 deletions

View File

@ -2,10 +2,14 @@
use Carbon\Carbon;
return [
'index_periods' => ['1D', '1W', '1M', '3M', '6M','1Y', 'custom'],
'budget_periods' => ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly'],
'piggybank_periods' => ['day', 'week', 'month', 'year'],
'periods_to_text' => [
'index_periods' => ['1D', '1W', '1M', '3M', '6M', '1Y', 'custom'],
'budget_periods' => ['daily', 'weekly', 'monthly', 'quarterly', 'half-year', 'yearly'],
'piggybank_periods' => [
'week' => 'Week',
'month' => 'Month',
'year' => 'Year'
],
'periods_to_text' => [
'weekly' => 'A week',
'monthly' => 'A month',
'quarterly' => 'A quarter',
@ -13,7 +17,7 @@ return [
'yearly' => 'A year',
],
'range_to_text' => [
'range_to_text' => [
'1D' => 'day',
'1W' => 'week',
'1M' => 'month',
@ -21,15 +25,15 @@ return [
'6M' => 'half year',
'custom' => '(custom)'
],
'range_to_name' => [
'1D' => 'one day',
'1W' => 'one week',
'1M' => 'one month',
'3M' => 'three months',
'6M' => 'six months',
'1Y' => 'one year',
'range_to_name' => [
'1D' => 'one day',
'1W' => 'one week',
'1M' => 'one month',
'3M' => 'three months',
'6M' => 'six months',
'1Y' => 'one year',
],
'range_to_repeat_freq' => [
'range_to_repeat_freq' => [
'1D' => 'weekly',
'1W' => 'weekly',
'1M' => 'monthly',

View File

@ -340,28 +340,50 @@ class AccountController extends BaseController
*/
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 {
Session::flash('error', 'Could not update account: ' . $account->errors()->first());
/** @var \FireflyIII\Database\Account $acct */
$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;
}
}

View File

@ -43,11 +43,11 @@ class GoogleChartController extends BaseController
$row = [clone $current];
foreach ($accounts as $account) {
if ($current > Carbon::now()) {
$row[] = null;
} else {
//if ($current > Carbon::now()) {
// $row[] = 0;
//} else {
$row[] = $account->balance($current);
}
//}
}

View File

@ -3,6 +3,7 @@
use Firefly\Exception\FireflyException;
use FireflyIII\Exception\NotImplementedException;
use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;
/**
* Class PiggybankController
@ -23,7 +24,19 @@ class PiggybankController extends BaseController
*/
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
*/
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 */
// $toolkit = App::make('Firefly\Helper\Toolkit\Toolkit');
//
@ -258,9 +298,6 @@ class PiggybankController extends BaseController
/** @var \FireflyIII\Database\Piggybank $repos */
$repos = App::make('FireflyIII\Database\Piggybank');
/** @var \FireflyIII\Database\Account $acct */
$acct = App::make('FireflyIII\Database\Account');
/** @var Collection $piggybanks */
$piggybanks = $repos->get();
@ -291,7 +328,7 @@ class PiggybankController extends BaseController
$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;
// $countRepeating = $this->_repository->countRepeating();
@ -410,12 +447,49 @@ class PiggybankController extends BaseController
// ->with('balance', $balance);
}
// /**
// * @return $this|\Illuminate\Http\RedirectResponse
// */
/**
*
*/
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();
// unset($data['_token']);
//

View File

@ -33,6 +33,7 @@ class CreatePiggybanksTable extends Migration
$table->smallInteger('rep_times')->unsigned()->nullable();
$table->enum('reminder', ['day', 'week', 'month', 'year'])->nullable();
$table->smallInteger('reminder_skip')->unsigned();
$table->boolean('remind_me');
$table->integer('order')->unsigned();
// connect account to piggybank.

View File

@ -10,9 +10,10 @@ class Form
{
/**
* @param $name
* @param null $value
* @param $name
* @param null $value
* @param array $options
*
* @return string
* @throws FireflyException
*/
@ -40,7 +41,7 @@ class Form
public static function ffAmount($name, $value = null, array $options = [])
{
$options['step'] = 'any';
$options['min'] = '0.01';
$options['min'] = '0.01';
return self::ffInput('amount', $name, $value, $options);
}
@ -61,9 +62,10 @@ class Form
}
/**
* @param $name
* @param null $value
* @param $name
* @param null $value
* @param array $options
*
* @return string
* @throws FireflyException
*/
@ -73,9 +75,10 @@ class Form
}
/**
* @param $name
* @param null $value
* @param $name
* @param null $value
* @param array $options
*
* @return string
* @throws FireflyException
*/
@ -86,10 +89,11 @@ class Form
}
/**
* @param $name
* @param $name
* @param array $list
* @param null $selected
* @param null $selected
* @param array $options
*
* @return string
* @throws FireflyException
*/
@ -99,9 +103,10 @@ class Form
}
/**
* @param $name
* @param null $value
* @param $name
* @param null $value
* @param array $options
*
* @return string
* @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 = [
'amount_min' => 'Amount (min)',
'amount_max' => 'Amount (max)',
'match' => 'Matches on',
'repeat_freq' => 'Repetition',
'amount_min' => 'Amount (min)',
'amount_max' => 'Amount (max)',
'match' => 'Matches on',
'repeat_freq' => 'Repetition',
'account_from_id' => 'Account from',
'account_to_id' => 'Account to',
'account_id' => 'Asset account'
'account_to_id' => 'Account to',
'account_id' => 'Asset account'
];
return isset($labels[$name]) ? $labels[$name] : str_replace('_', ' ', ucfirst($name));
@ -174,28 +188,29 @@ class Form
case 'create':
$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 .= \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>';
break;
case 'update':
$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 .= \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>';
break;
default:
throw new FireflyException('Cannot create ffOptionsList for option (store+return) ' . $type);
break;
}
return $store.$validate.$return;
return $store . $validate . $return;
}
/**
* @param $type
* @param $name
* @param null $value
* @param $type
* @param $name
* @param null $value
* @param array $options
* @param array $list
*
* @return string
* @throws FireflyException
*/
@ -204,10 +219,10 @@ class Form
/*
* add some defaults to this method:
*/
$options['class'] = 'form-control';
$options['id'] = 'ffInput_' . $name;
$options['class'] = 'form-control';
$options['id'] = 'ffInput_' . $name;
$options['autocomplete'] = 'off';
$label = self::label($name);
$label = self::label($name, $options);
/*
* Make label and placeholder look nice.
*/
@ -216,9 +231,9 @@ class Form
/*
* Get prefilled value:
*/
if(\Session::has('prefilled')) {
if (\Session::has('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;
}
/*

View File

@ -193,7 +193,7 @@ class EloquentPiggybankTrigger
'Firefly\Trigger\Piggybanks\EloquentPiggybankTrigger@updateRelatedTransfer'
);
$events->listen(
'piggybanks.check', 'Firefly\Trigger\Piggybanks\EloquentPiggybankTrigger@checkRepeatingPiggies'
'piggybanks.storepiggybanks.check', 'Firefly\Trigger\Piggybanks\EloquentPiggybankTrigger@checkRepeatingPiggies'
);
}

View File

@ -27,6 +27,37 @@ class Account implements CUD, CommonDatabaseCalls, AccountInterface
$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.
*

View File

@ -24,6 +24,7 @@ class AccountType implements AccountTypeInterface, CUD, CommonDatabaseCalls
* @param $what
*
* @return \AccountType|null
* @throws FireflyException
*/
public function findByWhat($what)
{
@ -125,4 +126,15 @@ class AccountType implements AccountTypeInterface, CUD, CommonDatabaseCalls
{
// TODO: Implement getByIds() method.
}
/**
* @param Ardent $model
* @param array $data
*
* @return bool
*/
public function update(Ardent $model, array $data)
{
// TODO: Implement update() method.
}
}

View File

@ -154,4 +154,15 @@ class Budget implements CUD, CommonDatabaseCalls, BudgetInterface
}
)->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.
}
}

View File

@ -115,4 +115,15 @@ class Category implements CUD, CommonDatabaseCalls, CategoryInterface
{
// TODO: Implement findByWhat() method.
}
/**
* @param Ardent $model
* @param array $data
*
* @return bool
*/
public function update(Ardent $model, array $data)
{
// TODO: Implement update() method.
}
}

View File

@ -46,4 +46,12 @@ interface CUD
*/
public function store(array $data);
/**
* @param Ardent $model
* @param array $data
*
* @return bool
*/
public function update(Ardent $model, array $data);
}

View File

@ -2,6 +2,7 @@
namespace FireflyIII\Database;
use Carbon\Carbon;
use FireflyIII\Exception\NotImplementedException;
use Illuminate\Support\MessageBag;
use LaravelBook\Ardent\Ardent;
use Illuminate\Support\Collection;
@ -76,7 +77,81 @@ class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
*/
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)
{
// 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();
}
/**

View File

@ -29,8 +29,8 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
/**
* @param \RecurringTransaction $recurring
* @param Carbon $current
* @param Carbon $currentEnd
* @param Carbon $start
* @param Carbon $end
*
* @return \TransactionJournal|null
*/
@ -129,4 +129,15 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
{
// TODO: Implement findByWhat() method.
}
/**
* @param Ardent $model
* @param array $data
*
* @return bool
*/
public function update(Ardent $model, array $data)
{
// TODO: Implement update() method.
}
}

View File

@ -171,4 +171,25 @@ class Transaction implements TransactionInterface, CUD, CommonDatabaseCalls
{
// 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.
}
}

View File

@ -116,4 +116,15 @@ class TransactionCurrency implements TransactionCurrencyInterface, CUD, CommonDa
{
// TODO: Implement getByIds() method.
}
/**
* @param Ardent $model
* @param array $data
*
* @return bool
*/
public function update(Ardent $model, array $data)
{
// TODO: Implement update() method.
}
}

View File

@ -267,4 +267,15 @@ class TransactionJournal implements TransactionJournalInterface, CUD, CommonData
{
// TODO: Implement getByIds() method.
}
/**
* @param Ardent $model
* @param array $data
*
* @return bool
*/
public function update(Ardent $model, array $data)
{
// TODO: Implement update() method.
}
}

View File

@ -115,4 +115,15 @@ class TransactionType implements TransactionTypeInterface, CUD, CommonDatabaseCa
{
// TODO: Implement getByIds() method.
}
/**
* @param Ardent $model
* @param array $data
*
* @return bool
*/
public function update(Ardent $model, array $data)
{
// TODO: Implement update() method.
}
}

View 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;
}
}

View File

@ -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
'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?
'remind_me' => 'required|boolean',
'order' => 'required:min:1', // not yet used.
];
public $fillable
@ -71,6 +72,7 @@ class Piggybank extends Ardent
'rep_times',
'reminder',
'reminder_skip',
'remind_me',
'order'
];
@ -90,7 +92,6 @@ class Piggybank extends Ardent
$rep->targetdate = $target;
$rep->currentamount = 0;
$rep->save();
\Event::fire('piggybanks.repetition', [$rep]);
return $rep;

View File

@ -202,13 +202,15 @@ Route::group(
Route::get('/piggybanks', ['uses' => 'PiggybankController@index', 'as' => 'piggybanks.index']);
Route::get('/piggybanks/add/{piggybank}', ['uses' => 'PiggybankController@add']);
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('/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/addMoney/{piggybank}', ['uses' => 'PiggybankController@addMoney','as' => 'piggybanks.amount.add']);
// 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/edit/{piggybank}', ['uses' => 'PiggybankController@edit','as' => 'piggybanks.edit']);
// Route::get('/piggybanks/delete/{piggybank}', ['uses' => 'PiggybankController@delete','as' => 'piggybanks.delete']);
// Route::post('/piggybanks/updateAmount/{piggybank}',['uses' => 'PiggybankController@updateAmount','as' => 'piggybanks.updateAmount']);
@ -282,7 +284,7 @@ Route::group(
// 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/update/{piggybank}', ['uses' => 'PiggybankController@update', 'as' => 'piggybanks.update']);
#Route::post('/piggybanks/destroy/{piggybank}', ['uses' => 'PiggybankController@destroy', 'as' => 'piggybanks.destroy']);

View 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

View 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

View File

@ -40,7 +40,7 @@
</div>
<div class="col-lg-8 col-md-6 col-sm-4">
<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>
</div>
</div>
@ -60,7 +60,11 @@
<i class="fa fa-fw fa-plus"></i> Create piggy bank
</div>
<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>

View File

@ -3,6 +3,7 @@ var defaultLineChartOptions = {
legend: {
position: 'none'
},
interpolateNulls: true,
lineWidth: 1,
chartArea: {
left: 50,

View File

@ -2,7 +2,6 @@ google.setOnLoadCallback(drawChart);
function drawChart() {
console.log(1);
googleLineChart('chart/home/account', 'accounts-chart');
googleBarChart('chart/home/budgets','budgets-chart');
googleColumnChart('chart/home/categories','categories-chart');