mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-22 03:56:42 +00:00
Cleanup and fix everything related to piggy banks.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
use Firefly\Exception\FireflyException;
|
use Firefly\Exception\FireflyException;
|
||||||
use FireflyIII\Exception\NotImplementedException;
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class PiggybankController
|
* Class PiggybankController
|
||||||
@@ -17,45 +18,16 @@ class PiggybankController extends BaseController
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @param Piggybank $piggyBank
|
|
||||||
// *
|
|
||||||
// * @return $this
|
|
||||||
// */
|
|
||||||
// public function addMoney(Piggybank $piggyBank)
|
|
||||||
// {
|
|
||||||
// throw new NotImplementedException;
|
|
||||||
// $what = 'add';
|
|
||||||
// $maxAdd = $this->_repository->leftOnAccount($piggyBank->account);
|
|
||||||
// $maxRemove = null;
|
|
||||||
//
|
|
||||||
// return View::make('piggybanks.modifyAmount')->with('what', $what)->with('maxAdd', $maxAdd)->with(
|
|
||||||
// 'maxRemove', $maxRemove
|
|
||||||
// )->with('piggybank', $piggyBank);
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return $this
|
* @throws NotImplementedException
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException;
|
throw new NotImplementedException;
|
||||||
// /** @var \Firefly\Helper\Toolkit\Toolkit $toolkit */
|
|
||||||
// $toolkit = App::make('Firefly\Helper\Toolkit\Toolkit');
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// $periods = Config::get('firefly.piggybank_periods');
|
|
||||||
// $list = $this->_accounts->getActiveDefault();
|
|
||||||
// $accounts = $toolkit->makeSelectList($list);
|
|
||||||
//
|
|
||||||
// View::share('title', 'Piggy banks');
|
|
||||||
// View::share('subTitle', 'Create new');
|
|
||||||
// View::share('mainTitleIcon', 'fa-sort-amount-asc');
|
|
||||||
//
|
|
||||||
// return View::make('piggybanks.create-piggybank')->with('accounts', $accounts)
|
|
||||||
// ->with('periods', $periods);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * @return $this
|
// * @return $this
|
||||||
// */
|
// */
|
||||||
@@ -201,15 +173,127 @@ class PiggybankController extends BaseController
|
|||||||
// return Redirect::route($route);
|
// return Redirect::route($route);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @return $this
|
/**
|
||||||
// */
|
* @param Piggybank $piggybank
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function add(Piggybank $piggybank)
|
||||||
|
{
|
||||||
|
/** @var \FireflyIII\Database\Piggybank $acct */
|
||||||
|
$repos = App::make('FireflyIII\Database\Piggybank');
|
||||||
|
|
||||||
|
$leftOnAccount = $repos->leftOnAccount($piggybank->account);
|
||||||
|
$savedSoFar = $piggybank->currentRelevantRep()->currentamount;
|
||||||
|
$leftToSave = $piggybank->targetamount - $savedSoFar;
|
||||||
|
$amount = min($leftOnAccount, $leftToSave);
|
||||||
|
|
||||||
|
|
||||||
|
return View::make('piggybanks.add', compact('piggybank'))->with('maxAmount', $amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Piggybank $piggybank
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function postAdd(Piggybank $piggybank)
|
||||||
|
{
|
||||||
|
$amount = floatval(Input::get('amount'));
|
||||||
|
|
||||||
|
/** @var \FireflyIII\Database\Piggybank $acct */
|
||||||
|
$repos = App::make('FireflyIII\Database\Piggybank');
|
||||||
|
|
||||||
|
$leftOnAccount = $repos->leftOnAccount($piggybank->account);
|
||||||
|
$savedSoFar = $piggybank->currentRelevantRep()->currentamount;
|
||||||
|
$leftToSave = $piggybank->targetamount - $savedSoFar;
|
||||||
|
$maxAmount = min($leftOnAccount, $leftToSave);
|
||||||
|
|
||||||
|
if ($amount <= $maxAmount) {
|
||||||
|
$repetition = $piggybank->currentRelevantRep();
|
||||||
|
$repetition->currentamount += $amount;
|
||||||
|
$repetition->save();
|
||||||
|
Session::flash('success', 'Added ' . mf($amount, false) . ' to "' . e($piggybank->name) . '".');
|
||||||
|
} else {
|
||||||
|
Session::flash('error', 'Could not add ' . mf($amount, false) . ' to "' . e($piggybank->name) . '".');
|
||||||
|
}
|
||||||
|
return Redirect::route('piggybanks.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Piggybank $piggybank
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function remove(Piggybank $piggybank)
|
||||||
|
{
|
||||||
|
return View::make('piggybanks.remove', compact('piggybank'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Piggybank $piggybank
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function postRemove(Piggybank $piggybank)
|
||||||
|
{
|
||||||
|
$amount = floatval(Input::get('amount'));
|
||||||
|
|
||||||
|
$savedSoFar = $piggybank->currentRelevantRep()->currentamount;
|
||||||
|
|
||||||
|
if ($amount <= $savedSoFar) {
|
||||||
|
$repetition = $piggybank->currentRelevantRep();
|
||||||
|
$repetition->currentamount -= $amount;
|
||||||
|
$repetition->save();
|
||||||
|
Session::flash('success', 'Removed ' . mf($amount, false) . ' from "' . e($piggybank->name) . '".');
|
||||||
|
} else {
|
||||||
|
Session::flash('error', 'Could not remove ' . mf($amount, false) . ' from "' . e($piggybank->name) . '".');
|
||||||
|
}
|
||||||
|
return Redirect::route('piggybanks.index');
|
||||||
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
/** @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();
|
||||||
|
|
||||||
throw new NotImplementedException;
|
$accounts = [];
|
||||||
|
/** @var Piggybank $piggybank */
|
||||||
|
foreach ($piggybanks as $piggybank) {
|
||||||
|
$piggybank->savedSoFar = floatval($piggybank->currentRelevantRep()->currentamount);
|
||||||
|
$piggybank->percentage = intval($piggybank->savedSoFar / $piggybank->targetamount * 100);
|
||||||
|
$piggybank->leftToSave = $piggybank->targetamount - $piggybank->savedSoFar;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fill account information:
|
||||||
|
*/
|
||||||
|
$account = $piggybank->account;
|
||||||
|
if (!isset($accounts[$account->id])) {
|
||||||
|
$accounts[$account->id] = [
|
||||||
|
'name' => $account->name,
|
||||||
|
'balance' => $account->balance(),
|
||||||
|
'leftForPiggybanks' => $account->balance() - $piggybank->savedSoFar,
|
||||||
|
'sumOfSaved' => $piggybank->savedSoFar,
|
||||||
|
'sumOfTargets' => floatval($piggybank->targetamount),
|
||||||
|
'leftToSave' => $piggybank->leftToSave
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$accounts[$account->id]['leftForPiggybanks'] -= $piggybank->savedSoFar;
|
||||||
|
$accounts[$account->id]['sumOfSaved'] += $piggybank->savedSoFar;
|
||||||
|
$accounts[$account->id]['sumOfTargets'] += floatval($piggybank->targetamount);
|
||||||
|
$accounts[$account->id]['leftToSave'] += $piggybank->leftToSave;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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();
|
// $countRepeating = $this->_repository->countRepeating();
|
||||||
// $countNonRepeating = $this->_repository->countNonrepeating();
|
// $countNonRepeating = $this->_repository->countNonrepeating();
|
||||||
//
|
//
|
||||||
@@ -416,3 +500,20 @@ class PiggybankController extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * @param Piggybank $piggyBank
|
||||||
|
// *
|
||||||
|
// * @return $this
|
||||||
|
// */
|
||||||
|
// public function addMoney(Piggybank $piggyBank)
|
||||||
|
// {
|
||||||
|
// throw new NotImplementedException;
|
||||||
|
// $what = 'add';
|
||||||
|
// $maxAdd = $this->_repository->leftOnAccount($piggyBank->account);
|
||||||
|
// $maxRemove = null;
|
||||||
|
//
|
||||||
|
// return View::make('piggybanks.modifyAmount')->with('what', $what)->with('maxAdd', $maxAdd)->with(
|
||||||
|
// 'maxRemove', $maxRemove
|
||||||
|
// )->with('piggybank', $piggyBank);
|
||||||
|
// }
|
19
app/lib/FireflyIII/Database/Ifaces/PiggybankInterface.php
Normal file
19
app/lib/FireflyIII/Database/Ifaces/PiggybankInterface.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Database\Ifaces;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface PiggybankInterface
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Database\Ifaces
|
||||||
|
*/
|
||||||
|
interface PiggybankInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Account $account
|
||||||
|
*
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public function leftOnAccount(\Account $account);
|
||||||
|
}
|
135
app/lib/FireflyIII/Database/Piggybank.php
Normal file
135
app/lib/FireflyIII/Database/Piggybank.php
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
<?php
|
||||||
|
namespace FireflyIII\Database;
|
||||||
|
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\MessageBag;
|
||||||
|
use LaravelBook\Ardent\Ardent;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use FireflyIII\Database\Ifaces\CommonDatabaseCalls;
|
||||||
|
use FireflyIII\Database\Ifaces\CUD;
|
||||||
|
use FireflyIII\Database\Ifaces\PiggybankInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Piggybank
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Database
|
||||||
|
*/
|
||||||
|
class Piggybank implements CUD, CommonDatabaseCalls, PiggybankInterface
|
||||||
|
{
|
||||||
|
use SwitchUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Account $account
|
||||||
|
*
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public function leftOnAccount(\Account $account)
|
||||||
|
{
|
||||||
|
$balance = $account->balance();
|
||||||
|
/** @var \Piggybank $p */
|
||||||
|
foreach ($account->piggybanks()->get() as $p) {
|
||||||
|
$balance -= $p->currentRelevantRep()->currentamount;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $balance;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->setUser(\Auth::user());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Ardent $model
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function destroy(Ardent $model)
|
||||||
|
{
|
||||||
|
// TODO: Implement destroy() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates a model. Returns an array containing MessageBags
|
||||||
|
* errors/warnings/successes.
|
||||||
|
*
|
||||||
|
* @param Ardent $model
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function validateObject(Ardent $model)
|
||||||
|
{
|
||||||
|
// TODO: Implement validateObject() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates an array. Returns an array containing MessageBags
|
||||||
|
* errors/warnings/successes.
|
||||||
|
*
|
||||||
|
* @param array $model
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function validate(array $model)
|
||||||
|
{
|
||||||
|
// TODO: Implement validate() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
*
|
||||||
|
* @return Ardent
|
||||||
|
*/
|
||||||
|
public function store(array $data)
|
||||||
|
{
|
||||||
|
// TODO: Implement store() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an object with id $id.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
*
|
||||||
|
* @return Ardent
|
||||||
|
*/
|
||||||
|
public function find($id)
|
||||||
|
{
|
||||||
|
// TODO: Implement find() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all objects.
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function get()
|
||||||
|
{
|
||||||
|
return $this->getUser()->piggybanks()->where('repeats', 0)->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $ids
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getByIds(array $ids)
|
||||||
|
{
|
||||||
|
// TODO: Implement getByIds() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
|
||||||
|
*
|
||||||
|
* @param $what
|
||||||
|
*
|
||||||
|
* @return \AccountType|null
|
||||||
|
*/
|
||||||
|
public function findByWhat($what)
|
||||||
|
{
|
||||||
|
// TODO: Implement findByWhat() method.
|
||||||
|
}
|
||||||
|
}
|
@@ -200,6 +200,8 @@ Route::group(
|
|||||||
|
|
||||||
// piggy bank controller
|
// piggy bank controller
|
||||||
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/remove/{piggybank}', ['uses' => 'PiggybankController@remove']);
|
||||||
// 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/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']);
|
||||||
@@ -280,11 +282,13 @@ Route::group(
|
|||||||
|
|
||||||
|
|
||||||
// piggy bank controller
|
// piggy bank controller
|
||||||
Route::post('/piggybanks/store/piggybank', ['uses' => 'PiggybankController@storePiggybank', 'as' => 'piggybanks.store.piggybank']);
|
#Route::post('/piggybanks/store/piggybank', ['uses' => 'PiggybankController@storePiggybank', 'as' => 'piggybanks.store.piggybank']);
|
||||||
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']);
|
||||||
Route::post('/piggybanks/mod/{piggybank}', ['uses' => 'PiggybankController@modMoney', 'as' => 'piggybanks.modMoney']);
|
#Route::post('/piggybanks/mod/{piggybank}', ['uses' => 'PiggybankController@modMoney', 'as' => 'piggybanks.modMoney']);
|
||||||
|
Route::post('/piggybanks/add/{piggybank}', ['uses' => 'PiggybankController@postAdd', 'as' => 'piggybanks.add']);
|
||||||
|
Route::post('/piggybanks/remove/{piggybank}', ['uses' => 'PiggybankController@postRemove', 'as' => 'piggybanks.remove']);
|
||||||
|
|
||||||
|
|
||||||
// preferences controller
|
// preferences controller
|
||||||
|
@@ -179,14 +179,16 @@
|
|||||||
<a href="#"><i class="fa fa-euro fa-fw"></i> Money management<span class="fa arrow"></span></a>
|
<a href="#"><i class="fa fa-euro fa-fw"></i> Money management<span class="fa arrow"></span></a>
|
||||||
<ul class="nav nav-second-level">
|
<ul class="nav nav-second-level">
|
||||||
<li>
|
<li>
|
||||||
<a @if($r == 'piggybanks.index.piggybanks') class="active" @endif href="{{route('piggybanks.index.piggybanks')}}"><i class="fa fa-sort-amount-asc fa-fw"></i> Piggy banks</a>
|
<a @if($r == 'piggybanks.index') class="active" @endif href="{{route('piggybanks.index')}}"><i class="fa fa-sort-amount-asc fa-fw"></i> Piggy banks</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a @if($r == 'recurring.index') class="active" @endif href="{{route('recurring.index')}}"><i class="fa fa-rotate-right fa-fw"></i> Recurring transactions</a>
|
<a @if($r == 'recurring.index') class="active" @endif href="{{route('recurring.index')}}"><i class="fa fa-rotate-right fa-fw"></i> Recurring transactions</a>
|
||||||
</li>
|
</li>
|
||||||
|
{{--
|
||||||
<li>
|
<li>
|
||||||
<a @if($r == 'piggybanks.index.repeated') class="active" @endif href="{{route('piggybanks.index.repeated')}}"><i class="fa fa-rotate-left fa-fw"></i> Repeated expenses</a>
|
<a @if($r == 'piggybanks.index.repeated') class="active" @endif href="{{route('piggybanks.index.repeated')}}"><i class="fa fa-rotate-left fa-fw"></i> Repeated expenses</a>
|
||||||
</li>
|
</li>
|
||||||
|
--}}
|
||||||
</ul>
|
</ul>
|
||||||
<!-- /.nav-second-level -->
|
<!-- /.nav-second-level -->
|
||||||
</li>
|
</li>
|
||||||
@@ -217,15 +219,19 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="#"><i class="fa fa-bar-chart fa-fw"></i> Category</a>
|
<a href="#"><i class="fa fa-bar-chart fa-fw"></i> Category</a>
|
||||||
</li>
|
</li>
|
||||||
|
{{--
|
||||||
<li>
|
<li>
|
||||||
<a href="{{route('piggybanks.create.piggybank')}}"><i class="fa fa-envelope-o fa-fw"></i> Piggy bank</a>
|
<a href="{{route('piggybanks.create.piggybank')}}"><i class="fa fa-envelope-o fa-fw"></i> Piggy bank</a>
|
||||||
</li>
|
</li>
|
||||||
|
--}}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{route('recurring.create')}}"><i class="fa fa-rotate-right fa-fw"></i> Recurring transaction</a>
|
<a href="{{route('recurring.create')}}"><i class="fa fa-rotate-right fa-fw"></i> Recurring transaction</a>
|
||||||
</li>
|
</li>
|
||||||
|
{{--
|
||||||
<li>
|
<li>
|
||||||
<a href="{{route('piggybanks.create.repeated')}}"><i class="fa fa-rotate-left fa-fw"></i> Repeated expense</a>
|
<a href="{{route('piggybanks.create.repeated')}}"><i class="fa fa-rotate-left fa-fw"></i> Repeated expense</a>
|
||||||
</li>
|
</li>
|
||||||
|
--}}
|
||||||
</ul>
|
</ul>
|
||||||
<!-- /.nav-second-level -->
|
<!-- /.nav-second-level -->
|
||||||
</li>
|
</li>
|
||||||
|
24
app/views/piggybanks/add.blade.php
Normal file
24
app/views/piggybanks/add.blade.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<form style="display: inline;" action="{{route('piggybanks.add',$piggybank->id)}}" method="POST">
|
||||||
|
{{Form::token()}}
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||||
|
<h4 class="modal-title" id="myModalLabel">Add money to {{{$piggybank->name}}}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>
|
||||||
|
The maximum amount you can add is {{mf($maxAmount)}}
|
||||||
|
</p>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-addon">€</div>
|
||||||
|
<input step="any" class="form-control" id="amount" autocomplete="off" name="amount" max="{{$maxAmount}}" type="number">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Add</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
223
app/views/piggybanks/index.blade.old.php
Normal file
223
app/views/piggybanks/index.blade.old.php
Normal file
@@ -0,0 +1,223 @@
|
|||||||
|
@extends('layouts.default')
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
@if($countNonRepeating > 0)
|
||||||
|
<div class="row">
|
||||||
|
@foreach($piggybanks as $piggyBank)
|
||||||
|
@if($piggyBank->repeats == 0)
|
||||||
|
<div class="col-lg-2 col-md-4 col-sm-6">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<a href="{{route('piggybanks.show',$piggyBank->id)}}">{{{$piggyBank->name}}}</a>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="progress" style="height:3px;">
|
||||||
|
<div class="progress-bar @if($piggyBank->currentRelevantRep()->pct() == 100)progress-bar-success @endif " role="progressbar" aria-valuenow="{{$piggyBank->currentRelevantRep()->pct()}}" aria-valuemin="0" aria-valuemax="100" style="width: {{$piggyBank->currentRelevantRep()->pct()}}%">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p class="small">
|
||||||
|
{{mf($piggyBank->currentRelevantRep()->currentamount)}} of {{mf($piggyBank->targetamount)}}<br />
|
||||||
|
@if($piggyBank->targetamount-$piggyBank->currentRelevantRep()->currentamount > 0)
|
||||||
|
{{mf($piggyBank->targetamount-$piggyBank->currentRelevantRep()->currentamount)}} to go.
|
||||||
|
@endif
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="btn-group btn-group-xs">
|
||||||
|
<a href="{{route('piggybanks.edit',$piggyBank->id)}}" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||||
|
<a href="{{route('piggybanks.delete',$piggyBank->id)}}" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
|
||||||
|
@if($accounts[$piggyBank->account_id]['account']->leftOnAccount > 0)
|
||||||
|
<a data-toggle="modal" href="{{route('piggybanks.amount.add',$piggyBank->id)}}" data-target="#modal" class="btn btn-default"><span class="glyphicon glyphicon-plus-sign"></span></a>
|
||||||
|
@endif
|
||||||
|
@if($piggyBank->currentRelevantRep()->currentamount > 0)
|
||||||
|
<a data-toggle="modal" href="{{route('piggybanks.amount.remove',$piggyBank->id)}}" data-target="#modal" class="btn btn-default"><span class="glyphicon glyphicon-minus-sign"></span></a>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
<div class="col-lg-2 col-md-4 col-sm-6">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
<a href="{{route('piggybanks.create.piggybank')}}" class="btn btn-success btn-block">Add new piggybank</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
{{--
|
||||||
|
|
||||||
|
|
||||||
|
<h3>Current piggy banks</h3>
|
||||||
|
@if($countNonRepeating == 0)
|
||||||
|
<p class="text-warning">No piggy banks found.</p>
|
||||||
|
@else
|
||||||
|
@foreach($piggybanks as $piggyBank)
|
||||||
|
@if($piggyBank->repeats == 0)
|
||||||
|
<h4></h4>
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<tr>
|
||||||
|
<td style="width:10%;">{{mf($piggyBank->currentRelevantRep()->currentamount)}}</td>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="progress">
|
||||||
|
<div class="progress-bar
|
||||||
|
@if($piggyBank->currentRelevantRep()->pct() == 100)
|
||||||
|
progress-bar-success
|
||||||
|
@endif
|
||||||
|
" role="progressbar" aria-valuenow="{{$piggyBank->currentRelevantRep()->pct()}}" aria-valuemin="0" aria-valuemax="100" style="width: {{$piggyBank->currentRelevantRep()->pct()}}%;min-width: 30px;">
|
||||||
|
{{$piggyBank->currentRelevantRep()->pct()}}%
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td style="width:10%;">{{mf($piggyBank->targetamount)}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td style="width:40%;">
|
||||||
|
<div class="btn-group-xs btn-group">
|
||||||
|
@if($accounts[$piggyBank->account_id]['account']->leftOnAccount > 0)
|
||||||
|
<a data-toggle="modal" href="{{route('piggybanks.amount.add',$piggyBank->id)}}" data-target="#modal" class="btn btn-default"><span class="glyphicon glyphicon-plus-sign"></span> Add money</a>
|
||||||
|
@endif
|
||||||
|
@if($piggyBank->currentRelevantRep()->currentamount > 0)
|
||||||
|
<a data-toggle="modal" href="{{route('piggybanks.amount.remove',$piggyBank->id)}}" data-target="#modal" class="btn btn-default"><span class="glyphicon glyphicon-minus-sign"></span> Remove money</a>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td style="width:40%;">
|
||||||
|
<p class="small">
|
||||||
|
@if(!is_null($piggyBank->targetdate))
|
||||||
|
Target date: {{$piggyBank->targetdate->format('M jS, Y')}}<br />
|
||||||
|
@endif
|
||||||
|
@if(!is_null($piggyBank->reminder))
|
||||||
|
Next reminder: TODO
|
||||||
|
@endif
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="btn-group btn-group-xs">
|
||||||
|
<a href="{{route('piggybanks.edit',$piggyBank->id)}}" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||||
|
<a href="{{route('piggybanks.delete',$piggyBank->id)}}" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||||
|
<h3>Current repeated expenses</h3>
|
||||||
|
@if($countRepeating == 0)
|
||||||
|
<p class="text-warning">No repeated expenses found.</p>
|
||||||
|
@else
|
||||||
|
@foreach($piggybanks as $repeated)
|
||||||
|
@if($repeated->repeats == 1)
|
||||||
|
<h4><a href="{{route('piggybanks.show',$repeated->id)}}">{{{$repeated->name}}}</a></h4>
|
||||||
|
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<tr>
|
||||||
|
<td style="width:10%;">{{mf($repeated->currentRelevantRep()->currentamount)}}</td>
|
||||||
|
<td colspan="2">
|
||||||
|
<div class="progress">
|
||||||
|
<div class="progress-bar
|
||||||
|
@if($repeated->currentRelevantRep()->pct() == 100)
|
||||||
|
progress-bar-success
|
||||||
|
@endif
|
||||||
|
" role="progressbar" aria-valuenow="{{$repeated->currentRelevantRep()->pct()}}" aria-valuemin="0" aria-valuemax="100" style="width: {{$repeated->currentRelevantRep()->pct()}}%;min-width: 30px;">
|
||||||
|
{{$repeated->currentRelevantRep()->pct()}}%
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td style="width:10%;">{{mf($repeated->targetamount)}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
</td>
|
||||||
|
<td style="width:40%;">
|
||||||
|
<div class="btn-group-xs btn-group">
|
||||||
|
@if($accounts[$repeated->account_id]['account']->leftOnAccount > 0)
|
||||||
|
<a data-toggle="modal" href="{{route('piggybanks.amount.add',$repeated->id)}}" data-target="#modal" class="btn btn-default"><span class="glyphicon glyphicon-plus-sign"></span> Add money</a>
|
||||||
|
@endif
|
||||||
|
@if($repeated->currentRelevantRep()->currentamount > 0)
|
||||||
|
<a data-toggle="modal" href="{{route('piggybanks.amount.remove',$repeated->id)}}" data-target="#modal" class="btn btn-default"><span class="glyphicon glyphicon-minus-sign"></span> Remove money</a>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td style="width:40%;">
|
||||||
|
|
||||||
|
@if(!is_null($repeated->reminder))
|
||||||
|
<small>
|
||||||
|
Next reminder: TODO
|
||||||
|
</small>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="btn-group btn-group-xs">
|
||||||
|
<a href="{{route('piggybanks.edit',$repeated->id)}}" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||||
|
<a href="{{route('piggybanks.delete',$repeated->id)}}" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--}}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<h4>Account information</h4>
|
||||||
|
<table class="table">
|
||||||
|
<tr>
|
||||||
|
<th>Account</th>
|
||||||
|
<th>Left for piggy banks</th>
|
||||||
|
<th>Total planned savings</th>
|
||||||
|
<th>Saved so far</th>
|
||||||
|
<th>Left to save</th>
|
||||||
|
</tr>
|
||||||
|
@foreach($accounts as $account)
|
||||||
|
<tr>
|
||||||
|
<td>{{{$account['account']->name}}}</td>
|
||||||
|
<td>{{mf($account['left'])}}</td>
|
||||||
|
<td>{{mf($account['tosave'])}}</td>
|
||||||
|
<td>{{mf($account['saved'])}}</td>
|
||||||
|
<td>{{mf($account['tosave']-$account['saved'])}}</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- MODAL -->
|
||||||
|
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="modal" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@stop
|
@@ -1,223 +1,123 @@
|
|||||||
@extends('layouts.default')
|
@extends('layouts.default')
|
||||||
@section('content')
|
@section('content')
|
||||||
|
|
||||||
@if($countNonRepeating > 0)
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@foreach($piggybanks as $piggyBank)
|
@foreach($piggybanks as $piggybank)
|
||||||
@if($piggyBank->repeats == 0)
|
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||||
<div class="col-lg-2 col-md-4 col-sm-6">
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<a href="{{route('piggybanks.show',$piggyBank->id)}}">{{{$piggyBank->name}}}</a>
|
<i class="fa fa-fw fa-rocket"></i> <a href="#" title="{{{$piggybank->name}}}">{{{$piggybank->name}}}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="progress" style="height:3px;">
|
<div class="row">
|
||||||
<div class="progress-bar @if($piggyBank->currentRelevantRep()->pct() == 100)progress-bar-success @endif " role="progressbar" aria-valuenow="{{$piggyBank->currentRelevantRep()->pct()}}" aria-valuemin="0" aria-valuemax="100" style="width: {{$piggyBank->currentRelevantRep()->pct()}}%">
|
<div class="col-lg-2 col-md-3 col-sm-4">
|
||||||
|
{{mf($piggybank->savedSoFar,true)}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="col-lg-8 col-md-6 col-sm-4">
|
||||||
<p class="small">
|
<div class="progress progress-striped">
|
||||||
{{mf($piggyBank->currentRelevantRep()->currentamount)}} of {{mf($piggyBank->targetamount)}}<br />
|
<div
|
||||||
@if($piggyBank->targetamount-$piggyBank->currentRelevantRep()->currentamount > 0)
|
@if($piggybank->percentage == 100)
|
||||||
{{mf($piggyBank->targetamount-$piggyBank->currentRelevantRep()->currentamount)}} to go.
|
class="progress-bar progress-bar-success"
|
||||||
@endif
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="btn-group btn-group-xs">
|
|
||||||
<a href="{{route('piggybanks.edit',$piggyBank->id)}}" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a>
|
|
||||||
<a href="{{route('piggybanks.delete',$piggyBank->id)}}" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
|
|
||||||
@if($accounts[$piggyBank->account_id]['account']->leftOnAccount > 0)
|
|
||||||
<a data-toggle="modal" href="{{route('piggybanks.amount.add',$piggyBank->id)}}" data-target="#modal" class="btn btn-default"><span class="glyphicon glyphicon-plus-sign"></span></a>
|
|
||||||
@endif
|
|
||||||
@if($piggyBank->currentRelevantRep()->currentamount > 0)
|
|
||||||
<a data-toggle="modal" href="{{route('piggybanks.amount.remove',$piggyBank->id)}}" data-target="#modal" class="btn btn-default"><span class="glyphicon glyphicon-minus-sign"></span></a>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
@endforeach
|
|
||||||
<div class="col-lg-2 col-md-4 col-sm-6">
|
|
||||||
<div class="panel panel-default">
|
|
||||||
<div class="panel-heading">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="panel-body">
|
|
||||||
<a href="{{route('piggybanks.create.piggybank')}}" class="btn btn-success btn-block">Add new piggybank</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
{{--
|
|
||||||
|
|
||||||
|
|
||||||
<h3>Current piggy banks</h3>
|
|
||||||
@if($countNonRepeating == 0)
|
|
||||||
<p class="text-warning">No piggy banks found.</p>
|
|
||||||
@else
|
@else
|
||||||
@foreach($piggybanks as $piggyBank)
|
class="progress-bar progress-bar-info"
|
||||||
@if($piggyBank->repeats == 0)
|
|
||||||
<h4></h4>
|
|
||||||
<table class="table table-bordered">
|
|
||||||
<tr>
|
|
||||||
<td style="width:10%;">{{mf($piggyBank->currentRelevantRep()->currentamount)}}</td>
|
|
||||||
<td colspan="2">
|
|
||||||
<div class="progress">
|
|
||||||
<div class="progress-bar
|
|
||||||
@if($piggyBank->currentRelevantRep()->pct() == 100)
|
|
||||||
progress-bar-success
|
|
||||||
@endif
|
@endif
|
||||||
" role="progressbar" aria-valuenow="{{$piggyBank->currentRelevantRep()->pct()}}" aria-valuemin="0" aria-valuemax="100" style="width: {{$piggyBank->currentRelevantRep()->pct()}}%;min-width: 30px;">
|
role="progressbar" aria-valuenow="{{$piggybank->percentage}}" aria-valuemin="0" aria-valuemax="100" style="width: {{$piggybank->percentage}}%;">
|
||||||
{{$piggyBank->currentRelevantRep()->pct()}}%
|
{{$piggybank->percentage}}%
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
|
||||||
<td style="width:10%;">{{mf($piggyBank->targetamount)}}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td style="width:40%;">
|
|
||||||
<div class="btn-group-xs btn-group">
|
|
||||||
@if($accounts[$piggyBank->account_id]['account']->leftOnAccount > 0)
|
|
||||||
<a data-toggle="modal" href="{{route('piggybanks.amount.add',$piggyBank->id)}}" data-target="#modal" class="btn btn-default"><span class="glyphicon glyphicon-plus-sign"></span> Add money</a>
|
|
||||||
@endif
|
|
||||||
@if($piggyBank->currentRelevantRep()->currentamount > 0)
|
|
||||||
<a data-toggle="modal" href="{{route('piggybanks.amount.remove',$piggyBank->id)}}" data-target="#modal" class="btn btn-default"><span class="glyphicon glyphicon-minus-sign"></span> Remove money</a>
|
|
||||||
@endif
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
<div class="col-lg-2 col-md-3 col-sm-4">
|
||||||
<td style="width:40%;">
|
{{mf($piggybank->targetamount,true)}}
|
||||||
<p class="small">
|
</div>
|
||||||
@if(!is_null($piggyBank->targetdate))
|
</div>
|
||||||
Target date: {{$piggyBank->targetdate->format('M jS, Y')}}<br />
|
<div class="row">
|
||||||
@endif
|
<div class="col-lg-2 col-md-3 col-sm-4">
|
||||||
@if(!is_null($piggyBank->reminder))
|
|
||||||
Next reminder: TODO
|
|
||||||
@endif
|
|
||||||
</p>
|
|
||||||
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div class="btn-group btn-group-xs">
|
<div class="btn-group btn-group-xs">
|
||||||
<a href="{{route('piggybanks.edit',$piggyBank->id)}}" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a>
|
@if($piggybank->leftToSave > 0)
|
||||||
<a href="{{route('piggybanks.delete',$piggyBank->id)}}" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
|
<a href="#" class="btn btn-default addMoney" data-id="{{{$piggybank->id}}}"><span data-id="{{{$piggybank->id}}}" class="glyphicon glyphicon-plus"></span></a>
|
||||||
|
@endif
|
||||||
|
<a href="#" class="btn btn-default removeMoney" data-id="{{{$piggybank->id}}}"><span data-id="{{{$piggybank->id}}}" class="glyphicon glyphicon-minus"></span></a>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</div>
|
||||||
</tr>
|
<div class="col-lg-8 col-md-6 col-sm-4">
|
||||||
</table>
|
<div class="btn-group btn-group-xs">
|
||||||
|
<a href="#" 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>
|
||||||
|
<div class="col-lg-2 col-md-3 col-sm-4">
|
||||||
|
@if($piggybank->leftToSave > 0)
|
||||||
|
{{mf($piggybank->leftToSave)}}
|
||||||
@endif
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<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">
|
||||||
<h3>Current repeated expenses</h3>
|
<div class="panel panel-default">
|
||||||
@if($countRepeating == 0)
|
<div class="panel-heading">
|
||||||
<p class="text-warning">No repeated expenses found.</p>
|
<i class="fa fa-fw fa-money"></i> Account status
|
||||||
@else
|
|
||||||
@foreach($piggybanks as $repeated)
|
|
||||||
@if($repeated->repeats == 1)
|
|
||||||
<h4><a href="{{route('piggybanks.show',$repeated->id)}}">{{{$repeated->name}}}</a></h4>
|
|
||||||
|
|
||||||
<table class="table table-bordered">
|
|
||||||
<tr>
|
|
||||||
<td style="width:10%;">{{mf($repeated->currentRelevantRep()->currentamount)}}</td>
|
|
||||||
<td colspan="2">
|
|
||||||
<div class="progress">
|
|
||||||
<div class="progress-bar
|
|
||||||
@if($repeated->currentRelevantRep()->pct() == 100)
|
|
||||||
progress-bar-success
|
|
||||||
@endif
|
|
||||||
" role="progressbar" aria-valuenow="{{$repeated->currentRelevantRep()->pct()}}" aria-valuemin="0" aria-valuemax="100" style="width: {{$repeated->currentRelevantRep()->pct()}}%;min-width: 30px;">
|
|
||||||
{{$repeated->currentRelevantRep()->pct()}}%
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="panel-body">
|
||||||
</td>
|
<table class="table table-striped">
|
||||||
<td style="width:10%;">{{mf($repeated->targetamount)}}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
</td>
|
|
||||||
<td style="width:40%;">
|
|
||||||
<div class="btn-group-xs btn-group">
|
|
||||||
@if($accounts[$repeated->account_id]['account']->leftOnAccount > 0)
|
|
||||||
<a data-toggle="modal" href="{{route('piggybanks.amount.add',$repeated->id)}}" data-target="#modal" class="btn btn-default"><span class="glyphicon glyphicon-plus-sign"></span> Add money</a>
|
|
||||||
@endif
|
|
||||||
@if($repeated->currentRelevantRep()->currentamount > 0)
|
|
||||||
<a data-toggle="modal" href="{{route('piggybanks.amount.remove',$repeated->id)}}" data-target="#modal" class="btn btn-default"><span class="glyphicon glyphicon-minus-sign"></span> Remove money</a>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td style="width:40%;">
|
|
||||||
|
|
||||||
@if(!is_null($repeated->reminder))
|
|
||||||
<small>
|
|
||||||
Next reminder: TODO
|
|
||||||
</small>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div class="btn-group btn-group-xs">
|
|
||||||
<a href="{{route('piggybanks.edit',$repeated->id)}}" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a>
|
|
||||||
<a href="{{route('piggybanks.delete',$repeated->id)}}" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
@endif
|
|
||||||
@endforeach
|
|
||||||
@endif
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--}}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-12">
|
|
||||||
<h4>Account information</h4>
|
|
||||||
<table class="table">
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Account</th>
|
<th>Account</th>
|
||||||
|
<th>Balance</th>
|
||||||
<th>Left for piggy banks</th>
|
<th>Left for piggy banks</th>
|
||||||
<th>Total planned savings</th>
|
<th>Sum of piggy banks</th>
|
||||||
<th>Saved so far</th>
|
<th>Saved so far</th>
|
||||||
<th>Left to save</th>
|
<th>Left to save</th>
|
||||||
</tr>
|
</tr>
|
||||||
@foreach($accounts as $account)
|
@foreach($accounts as $id => $info)
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{{$account['account']->name}}}</td>
|
<td><a href="{{route('accounts.show',$id)}}">{{{$info['name']}}}</a></td>
|
||||||
<td>{{mf($account['left'])}}</td>
|
<td>{{mf($info['balance'])}}</td>
|
||||||
<td>{{mf($account['tosave'])}}</td>
|
<td>{{mf($info['leftForPiggybanks'])}}</td>
|
||||||
<td>{{mf($account['saved'])}}</td>
|
<td>{{mf($info['sumOfTargets'])}}</td>
|
||||||
<td>{{mf($account['tosave']-$account['saved'])}}</td>
|
<td>{{mf($info['sumOfSaved'])}}</td>
|
||||||
|
<td>{{mf($info['leftToSave'])}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- this is the modal for the add/remove money routine: -->
|
||||||
|
<div class="modal fade" id="moneyManagementModal">
|
||||||
<!-- MODAL -->
|
|
||||||
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="modal" aria-hidden="true">
|
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||||
|
<h4 class="modal-title">Modal title</h4>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>One fine body…</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||||
|
<button type="button" class="btn btn-primary">Save changes</button>
|
||||||
|
</div>
|
||||||
|
</div><!-- /.modal-content -->
|
||||||
|
</div><!-- /.modal-dialog -->
|
||||||
|
</div><!-- /.modal -->
|
||||||
|
|
||||||
@stop
|
@stop
|
||||||
|
@section('scripts')
|
||||||
|
{{HTML::script('assets/javascript/firefly/piggybanks.js')}}
|
||||||
|
@stop
|
24
app/views/piggybanks/remove.blade.php
Normal file
24
app/views/piggybanks/remove.blade.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<form style="display: inline;" action="{{route('piggybanks.remove',$piggybank->id)}}" method="POST">
|
||||||
|
{{Form::token()}}
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||||
|
<h4 class="modal-title" id="myModalLabel">Remove money from {{{$piggybank->name}}}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>
|
||||||
|
The maximum amount you can remove is {{mf($piggybank->currentRelevantRep()->currentamount)}}
|
||||||
|
</p>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-addon">€</div>
|
||||||
|
<input step="any" class="form-control" id="amount" autocomplete="off" name="amount" max="{{$piggybank->currentRelevantRep()->currentamount}}" type="number">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Remove</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
@@ -1,6 +1,3 @@
|
|||||||
/*
|
|
||||||
This line is required to be properly triggered by Google.
|
|
||||||
*/
|
|
||||||
google.setOnLoadCallback(drawChart);
|
google.setOnLoadCallback(drawChart);
|
||||||
|
|
||||||
|
|
||||||
|
19
public/assets/javascript/firefly/piggybanks.js
Normal file
19
public/assets/javascript/firefly/piggybanks.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
$(function () {
|
||||||
|
$('.addMoney').on('click',addMoney);
|
||||||
|
$('.removeMoney').on('click',removeMoney);
|
||||||
|
});
|
||||||
|
|
||||||
|
function addMoney(e) {
|
||||||
|
var pigID = parseInt($(e.target).data('id'));
|
||||||
|
$('#moneyManagementModal').empty().load('piggybanks/add/' + pigID).modal('show');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeMoney(e) {
|
||||||
|
var pigID = parseInt($(e.target).data('id'));
|
||||||
|
var pigID = parseInt($(e.target).data('id'));
|
||||||
|
$('#moneyManagementModal').empty().load('piggybanks/remove/' + pigID).modal('show');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
Reference in New Issue
Block a user