mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Layout updates and extensions. Found a problem I need closures for. Yay! [skip ci]
This commit is contained in:
parent
2680cd8b7a
commit
b0ddc04a0d
@ -34,6 +34,10 @@ return [
|
||||
'weekly' => [
|
||||
'group_date' => 'Y-W',
|
||||
'display_date' => '\W\e\e\k W, Y'
|
||||
],
|
||||
'quarterly' => [
|
||||
'group_date' => 'Y-m',
|
||||
'display_date' => '\T\O\D\O \C\L\O\S\U\R\E m-Y'
|
||||
]
|
||||
]
|
||||
];
|
@ -13,8 +13,10 @@ class BudgetController extends BaseController
|
||||
protected $_budgets;
|
||||
protected $_repository;
|
||||
|
||||
|
||||
/**
|
||||
* @param BRI $budgets
|
||||
* @param BI $budgets
|
||||
* @param BRI $repository
|
||||
*/
|
||||
public function __construct(BI $budgets, BRI $repository)
|
||||
{
|
||||
@ -60,12 +62,52 @@ class BudgetController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function edit(Budget $budget)
|
||||
{
|
||||
return View::make('budgets.edit')->with('budget', $budget);
|
||||
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$budget = $this->_repository->update(Input::all());
|
||||
Session::flash('success', 'Budget "' . $budget->name . '" updated.');
|
||||
|
||||
if (Input::get('from') == 'date') {
|
||||
return Redirect::route('budgets.index');
|
||||
} else {
|
||||
return Redirect::route('budgets.index.budget');
|
||||
}
|
||||
|
||||
return Redirect::route('budgets.index');
|
||||
}
|
||||
|
||||
public function delete(Budget $budget)
|
||||
{
|
||||
return View::make('budgets.delete')->with('budget', $budget);
|
||||
}
|
||||
|
||||
public function destroy()
|
||||
{
|
||||
$result = $this->_repository->destroy(Input::get('id'));
|
||||
if ($result === true) {
|
||||
Session::flash('success', 'The budget was deleted.');
|
||||
if (Input::get('from') == 'date') {
|
||||
return Redirect::route('budgets.index');
|
||||
} else {
|
||||
return Redirect::route('budgets.index.budget');
|
||||
}
|
||||
} else {
|
||||
Session::flash('error', 'Could not delete the budget. Check the logs to be sure.');
|
||||
}
|
||||
return Redirect::route('budgets.index');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO actual view, actual content.
|
||||
* @param Budget $budget
|
||||
*
|
||||
* @param $budgetId
|
||||
*
|
||||
* @return string
|
||||
* @return int
|
||||
*/
|
||||
public function show(Budget $budget)
|
||||
{
|
||||
|
@ -21,6 +21,12 @@ interface BudgetRepositoryInterface
|
||||
*/
|
||||
public function get();
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($data);
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
*
|
||||
@ -28,6 +34,12 @@ interface BudgetRepositoryInterface
|
||||
*/
|
||||
public function store($data);
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function destroy($data);
|
||||
|
||||
/**
|
||||
* @param $budgetId
|
||||
*
|
||||
|
@ -46,6 +46,31 @@ class EloquentBudgetRepository implements BudgetRepositoryInterface
|
||||
return $set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function update($data) {
|
||||
$budget = $this->find($data['id']);
|
||||
if ($budget) {
|
||||
// update account accordingly:
|
||||
$budget->name = $data['name'];
|
||||
if ($budget->validate()) {
|
||||
$budget->save();
|
||||
}
|
||||
}
|
||||
return $budget;
|
||||
}
|
||||
|
||||
public function destroy($budgetId) {
|
||||
$budget = $this->find($budgetId);
|
||||
if($budget) {
|
||||
$budget->delete();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|mixed
|
||||
*/
|
||||
|
@ -54,12 +54,12 @@ Route::group(['before' => 'auth'], function () {
|
||||
Route::get('/accounts/{account}/delete', ['uses' => 'AccountController@delete', 'as' => 'accounts.delete']);
|
||||
|
||||
// budget controller:
|
||||
Route::get('/budget/create',['uses' => 'BudgetController@create', 'as' => 'budgets.create']);
|
||||
Route::get('/budgets/create',['uses' => 'BudgetController@create', 'as' => 'budgets.create']);
|
||||
Route::get('/budgets',['uses' => 'BudgetController@indexByDate','as' => 'budgets.index']);
|
||||
Route::get('/budgets/budget',['uses' => 'BudgetController@indexByBudget','as' => 'budgets.index.budget']);
|
||||
Route::get('/budget/show/{budget}',['uses' => 'BudgetController@show', 'as' => 'budgets.show']);
|
||||
Route::get('/budget/edit/{budget}',['uses' => 'BudgetController@edit', 'as' => 'budgets.edit']);
|
||||
Route::get('/budget/delete/{budget}',['uses' => 'BudgetController@delete', 'as' => 'budgets.delete']);
|
||||
Route::get('/budgets/show/{budget}',['uses' => 'BudgetController@show', 'as' => 'budgets.show']);
|
||||
Route::get('/budgets/edit/{budget}',['uses' => 'BudgetController@edit', 'as' => 'budgets.edit']);
|
||||
Route::get('/budgets/delete/{budget}',['uses' => 'BudgetController@delete', 'as' => 'budgets.delete']);
|
||||
|
||||
// limit controller:
|
||||
Route::get('/budgets/limits/create/{id?}',['uses' => 'LimitController@create','as' => 'budgets.limits.create']);
|
||||
@ -89,7 +89,9 @@ Route::group(['before' => 'csrf|auth'], function () {
|
||||
Route::post('/profile/change-password', ['uses' => 'ProfileController@postChangePassword']);
|
||||
|
||||
// budget controller:
|
||||
Route::post('/budget/store',['uses' => 'BudgetController@store', 'as' => 'budgets.store']);
|
||||
Route::post('/budgets/store',['uses' => 'BudgetController@store', 'as' => 'budgets.store']);
|
||||
Route::post('/budgets/update', ['uses' => 'BudgetController@update', 'as' => 'budgets.update']);
|
||||
Route::post('/budgets/destroy', ['uses' => 'BudgetController@destroy', 'as' => 'budgets.destroy']);
|
||||
|
||||
// migration controller
|
||||
Route::post('/migrate', ['uses' => 'MigrationController@postIndex']);
|
||||
|
@ -11,10 +11,10 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{Form::model($account, ['class' => 'form-horizontal','url' => route('accounts.destroy')])}}
|
||||
{{Form::open(['class' => 'form-horizontal','url' => route('accounts.destroy')])}}
|
||||
{{Form::hidden('id',$account->id)}}
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-12">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
@if($account->transactions()->count() > 0)
|
||||
<p class="text-info">
|
||||
|
||||
|
51
app/views/budgets/delete.blade.php
Normal file
51
app/views/budgets/delete.blade.php
Normal file
@ -0,0 +1,51 @@
|
||||
@extends('layouts.default')
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<h1>Firefly
|
||||
<small>Delete "{{{$budget->name}}}"</small>
|
||||
</h1>
|
||||
<p class="lead">
|
||||
Remember that deleting something is permanent.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{Form::open(['class' => 'form-horizontal','url' => route('budgets.destroy')])}}
|
||||
{{Form::hidden('id',$budget->id)}}
|
||||
{{Form::hidden('from',e(Input::get('from')))}}
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
@if($budget->transactionjournals()->count() > 0)
|
||||
<p class="text-info">
|
||||
|
||||
Account "{{{$budget->name}}}" still has {{$budget->transactionjournals()->count()}} transaction(s) associated to it.
|
||||
These will NOT be deleted but will lose their connection to the budget.
|
||||
</p>
|
||||
@endif
|
||||
|
||||
<p class="text-danger">
|
||||
Press "Delete permanently" If you are sure you want to delete "{{{$budget->name}}}".
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-8">
|
||||
<button type="submit" class="btn btn-default btn-danger">Delete permanently</button>
|
||||
@if(Input::get('from') == 'date')
|
||||
<a href="{{route('budgets.index')}}" class="btn-default btn">Cancel</a>
|
||||
@else
|
||||
<a href="{{route('budgets.index.budget')}}" class="btn-default btn">Cancel</a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{{Form::close()}}
|
||||
@stop
|
51
app/views/budgets/edit.blade.php
Normal file
51
app/views/budgets/edit.blade.php
Normal file
@ -0,0 +1,51 @@
|
||||
@extends('layouts.default')
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12">
|
||||
<h1>Firefly
|
||||
<small>Edit budget "{{{$budget->name}}}"</small>
|
||||
</h1>
|
||||
<p class="lead">Use budgets to organize and limit your expenses.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{Form::open(['class' => 'form-horizontal','url' => route('budgets.update')])}}
|
||||
|
||||
{{Form::hidden('id',$budget->id)}}
|
||||
{{Form::hidden('from',e(Input::get('from')))}}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-md-12 col-sm-6">
|
||||
<h4>Mandatory fields</h4>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="name" class="col-sm-4 control-label">Name</label>
|
||||
<div class="col-sm-8">
|
||||
<input type="text" name="name" class="form-control" id="name" value="{{Input::old('name') ?: $budget->name}}" placeholder="Name">
|
||||
@if($errors->has('name'))
|
||||
<p class="text-danger">{{$errors->first('name')}}</p>
|
||||
@else
|
||||
<span class="help-block">For example: groceries, bills</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">Update the budget</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{Form::close()}}
|
||||
|
||||
|
||||
@stop
|
@ -74,11 +74,7 @@
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<small>
|
||||
@if($limit->repeat_freq == 'monthly')
|
||||
{{$rep->startdate->format('F Y')}}
|
||||
@else
|
||||
NO FORMAT
|
||||
@endif
|
||||
CLOSURE TODO
|
||||
</small>
|
||||
</div>
|
||||
@if($limit->repeats == 1)
|
||||
@ -104,8 +100,8 @@
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group btn-group-sm">
|
||||
<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>
|
||||
<a href="{{route('budgets.edit',$budget->id)}}?from=budget" class="btn btn-default"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||
<a href="{{route('budgets.delete',$budget->id)}}?from=budget" class="btn btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
|
@ -48,8 +48,8 @@
|
||||
<tr>
|
||||
<td>
|
||||
<div class="btn-group">
|
||||
<a title="Edit budget {{{$repetition->limit->budget->name}}}" href="{{route('budgets.edit',$repetition->limit->budget->id)}}" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||
<a title="Delete budget {{{$repetition->limit->budget->name}}}" href="{{route('budgets.delete',$repetition->limit->budget->id)}}" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
<a title="Edit budget {{{$repetition->limit->budget->name}}}" href="{{route('budgets.edit',$repetition->limit->budget->id)}}?from=date" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a>
|
||||
<a title="Delete budget {{{$repetition->limit->budget->name}}}" href="{{route('budgets.delete',$repetition->limit->budget->id)}}?from=date" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
|
6
ide-helper.bat
Normal file
6
ide-helper.bat
Normal file
@ -0,0 +1,6 @@
|
||||
composer update
|
||||
php artisan clear-compiled --env=local
|
||||
php artisan ide-helper:generate --env=local
|
||||
php artisan ide-helper:models --env=local --write
|
||||
php artisan optimize --env=local
|
||||
php artisan dump-autoload --env=local
|
Loading…
Reference in New Issue
Block a user