2014-08-23 15:32:12 -05:00
|
|
|
<?php
|
2014-11-20 00:51:01 -06:00
|
|
|
use FireflyIII\Exception\FireflyException;
|
2014-08-23 15:32:12 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ReminderController
|
2014-09-09 13:00:04 -05:00
|
|
|
*
|
2014-08-23 15:32:12 -05:00
|
|
|
*/
|
|
|
|
class ReminderController extends BaseController
|
|
|
|
{
|
|
|
|
|
2014-11-17 16:08:36 -06:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
View::share('title', 'Reminders');
|
|
|
|
View::share('mainTitleIcon', 'fa-lightbulb-o');
|
2014-11-17 13:18:14 -06:00
|
|
|
}
|
|
|
|
|
2014-11-17 03:10:57 -06:00
|
|
|
/**
|
|
|
|
* @param Reminder $reminder
|
|
|
|
*/
|
|
|
|
public function show(Reminder $reminder)
|
|
|
|
{
|
2014-11-20 00:51:01 -06:00
|
|
|
|
2014-11-17 16:08:36 -06:00
|
|
|
$amount = null;
|
|
|
|
if (get_class($reminder->remindersable) == 'Piggybank') {
|
|
|
|
|
2014-11-21 04:12:22 -06:00
|
|
|
$amount = Reminders::amountForReminder($reminder);
|
2014-11-17 16:08:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return View::make('reminders.show', compact('reminder', 'amount'));
|
2014-11-17 03:10:57 -06:00
|
|
|
}
|
2014-11-20 00:51:01 -06:00
|
|
|
|
|
|
|
public function act(Reminder $reminder) {
|
|
|
|
|
|
|
|
switch(get_class($reminder->remindersable)) {
|
|
|
|
default:
|
|
|
|
throw new FireflyException('Cannot act on reminder for ' . get_class($reminder->remindersable));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 'Piggybank':
|
2014-11-21 04:12:22 -06:00
|
|
|
$amount = Reminders::amountForReminder($reminder);
|
2014-11-20 00:51:01 -06:00
|
|
|
$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');
|
|
|
|
}
|
|
|
|
|
2014-10-12 02:34:10 -05:00
|
|
|
}
|