mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Ability to dismiss reminders, added some logic to pre fill transaction form.
This commit is contained in:
parent
359c71ef2f
commit
07388dd58a
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
|
||||
/**
|
||||
* Class ReminderController
|
||||
@ -18,24 +19,9 @@ class ReminderController extends BaseController
|
||||
*/
|
||||
public function show(Reminder $reminder)
|
||||
{
|
||||
// $subTitle = $reminder->title;
|
||||
// $model = null; // related model.
|
||||
//
|
||||
// if(isset($reminder->data->model) && isset($reminder->data->type)) {
|
||||
// switch($reminder->data->type) {
|
||||
// case 'Test':
|
||||
// break;
|
||||
// case 'Piggybank':
|
||||
// break;
|
||||
// default:
|
||||
// throw new FireflyException('Cannot handle model of type '.$reminder->data->model);
|
||||
// break;
|
||||
// }
|
||||
// } else {
|
||||
//
|
||||
// }
|
||||
//
|
||||
|
||||
$amount = null;
|
||||
$actionURL = '#';
|
||||
if (get_class($reminder->remindersable) == 'Piggybank') {
|
||||
/** @var \FireflyIII\Shared\Toolkit\Reminders $toolkit */
|
||||
$reminderKit = App::make('FireflyIII\Shared\Toolkit\Reminders');
|
||||
@ -45,4 +31,36 @@ class ReminderController extends BaseController
|
||||
|
||||
return View::make('reminders.show', compact('reminder', 'amount'));
|
||||
}
|
||||
|
||||
public function act(Reminder $reminder) {
|
||||
/** @var \FireflyIII\Shared\Toolkit\Reminders $toolkit */
|
||||
$reminderKit = App::make('FireflyIII\Shared\Toolkit\Reminders');
|
||||
|
||||
switch(get_class($reminder->remindersable)) {
|
||||
default:
|
||||
throw new FireflyException('Cannot act on reminder for ' . get_class($reminder->remindersable));
|
||||
break;
|
||||
break;
|
||||
case 'Piggybank':
|
||||
$amount = $reminderKit->amountForReminder($reminder);
|
||||
$prefilled = [
|
||||
'amount' => round($amount,2),
|
||||
'description' => 'Money for ' . $reminder->remindersable->name,
|
||||
'piggybank_id' => $reminder->remindersable_id,
|
||||
'account_to_id' => $reminder->remindersable->account_id
|
||||
];
|
||||
Session::flash('prefilled',$prefilled);
|
||||
return Redirect::route('transactions.create','transfer');
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function dismiss(Reminder $reminder) {
|
||||
$reminder->active = 0;
|
||||
$reminder->save();
|
||||
Session::flash('success','Reminder dismissed');
|
||||
return Redirect::route('index');
|
||||
}
|
||||
|
||||
}
|
@ -203,6 +203,8 @@ Route::group(
|
||||
|
||||
// reminder controller
|
||||
Route::get('/reminders/{reminder}',['uses' => 'ReminderController@show','as' => 'reminders.show']);
|
||||
Route::get('/reminders/{reminder}/dismiss',['uses' => 'ReminderController@dismiss','as' => 'reminders.dismiss']);
|
||||
Route::get('/reminders/{reminder}/act',['uses' => 'ReminderController@act','as' => 'reminders.act']);
|
||||
|
||||
// search controller:
|
||||
Route::get('/search', ['uses' => 'SearchController@index', 'as' => 'search']);
|
||||
|
@ -19,9 +19,9 @@
|
||||
</p>
|
||||
<p>
|
||||
<!-- TODO implement all options -->
|
||||
<a href="#" class="btn btn-primary"><i class="fa fa-fw fa-thumbs-o-up"></i> I want to do this</a>
|
||||
<a href="#" class="btn btn-success"><i class="fa fa-smile-o fa-fw"></i> I already did this</a>
|
||||
<a href="#" class="btn btn-danger"><i class="fa fa-fw fa-clock-o"></i> Not this time</a>
|
||||
<a href="{{route('reminders.act',$reminder->id)}}" class="btn btn-primary"><i class="fa fa-fw fa-thumbs-o-up"></i> I want to do this</a>
|
||||
<a href="{{route('reminders.dismiss',$reminder->id)}}" class="btn btn-success"><i class="fa fa-smile-o fa-fw"></i> I already did this</a>
|
||||
<a href="{{route('reminders.dismiss',$reminder->id)}}" class="btn btn-danger"><i class="fa fa-fw fa-clock-o"></i> Not this time</a>
|
||||
|
||||
</p>
|
||||
</div>
|
||||
|
@ -69,7 +69,7 @@
|
||||
|
||||
<!-- RELATE THIS TRANSFER TO A PIGGY BANK -->
|
||||
@if($what == 'transfer' && count($piggies) > 0)
|
||||
{{Form::ffSelect('piggybank_id',$piggies,0)}}
|
||||
{{Form::ffSelect('piggybank_id',$piggies)}}
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user