2014-08-23 22:32:12 +02:00
|
|
|
<?php
|
2014-11-20 07:51:01 +01:00
|
|
|
use FireflyIII\Exception\FireflyException;
|
2014-08-23 22:32:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ReminderController
|
2014-09-09 20:00:04 +02:00
|
|
|
*
|
2014-08-23 22:32:12 +02:00
|
|
|
*/
|
|
|
|
class ReminderController extends BaseController
|
|
|
|
{
|
|
|
|
|
2014-11-17 23:08:36 +01:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
View::share('title', 'Reminders');
|
|
|
|
View::share('mainTitleIcon', 'fa-lightbulb-o');
|
2014-11-17 20:18:14 +01:00
|
|
|
}
|
|
|
|
|
2014-12-06 17:34:39 +01:00
|
|
|
public function act(Reminder $reminder)
|
2014-11-17 10:10:57 +01:00
|
|
|
{
|
2014-11-20 07:51:01 +01:00
|
|
|
|
2014-12-06 17:34:39 +01:00
|
|
|
switch (get_class($reminder->remindersable)) {
|
2014-11-20 07:51:01 +01:00
|
|
|
default:
|
|
|
|
throw new FireflyException('Cannot act on reminder for ' . get_class($reminder->remindersable));
|
|
|
|
break;
|
2014-12-06 17:34:39 +01:00
|
|
|
break;
|
2014-11-20 07:51:01 +01:00
|
|
|
case 'Piggybank':
|
2014-12-06 17:34:39 +01:00
|
|
|
$amount = Reminders::amountForReminder($reminder);
|
2014-11-20 07:51:01 +01:00
|
|
|
$prefilled = [
|
2014-12-06 17:34:39 +01:00
|
|
|
'amount' => round($amount, 2),
|
|
|
|
'description' => 'Money for ' . $reminder->remindersable->name,
|
|
|
|
'piggybank_id' => $reminder->remindersable_id,
|
2014-11-20 07:51:01 +01:00
|
|
|
'account_to_id' => $reminder->remindersable->account_id
|
|
|
|
];
|
2014-12-06 17:34:39 +01:00
|
|
|
Session::flash('prefilled', $prefilled);
|
|
|
|
|
|
|
|
return Redirect::route('transactions.create', 'transfer');
|
2014-11-20 07:51:01 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-06 17:34:39 +01:00
|
|
|
public function dismiss(Reminder $reminder)
|
|
|
|
{
|
2014-11-20 07:51:01 +01:00
|
|
|
$reminder->active = 0;
|
|
|
|
$reminder->save();
|
2014-12-06 17:34:39 +01:00
|
|
|
Session::flash('success', 'Reminder dismissed');
|
|
|
|
|
2014-11-20 07:51:01 +01:00
|
|
|
return Redirect::route('index');
|
|
|
|
}
|
2014-12-06 17:34:39 +01:00
|
|
|
|
|
|
|
public function notnow(Reminder $reminder)
|
|
|
|
{
|
2014-11-24 18:06:21 +01:00
|
|
|
$reminder->active = 0;
|
|
|
|
$reminder->notnow = 1;
|
|
|
|
$reminder->save();
|
2014-12-06 17:34:39 +01:00
|
|
|
Session::flash('success', 'Reminder dismissed');
|
|
|
|
|
2014-11-24 18:06:21 +01:00
|
|
|
return Redirect::route('index');
|
|
|
|
}
|
2014-11-20 07:51:01 +01:00
|
|
|
|
2014-12-06 17:34:39 +01:00
|
|
|
/**
|
|
|
|
* @param Reminder $reminder
|
|
|
|
*/
|
|
|
|
public function show(Reminder $reminder)
|
|
|
|
{
|
|
|
|
|
|
|
|
$amount = null;
|
|
|
|
if (get_class($reminder->remindersable) == 'Piggybank') {
|
|
|
|
|
|
|
|
$amount = Reminders::amountForReminder($reminder);
|
|
|
|
}
|
|
|
|
|
|
|
|
return View::make('reminders.show', compact('reminder', 'amount'));
|
|
|
|
}
|
|
|
|
|
2014-10-12 09:34:10 +02:00
|
|
|
}
|