firefly-iii/app/Http/Controllers/ReminderController.php

93 lines
2.4 KiB
PHP
Raw Normal View History

2015-03-06 13:33:23 -06:00
<?php namespace FireflyIII\Http\Controllers;
use FireflyIII\Models\Reminder;
2015-05-03 02:55:22 -05:00
use FireflyIII\Repositories\Reminder\ReminderRepositoryInterface;
2015-03-07 02:21:06 -06:00
use Redirect;
2015-03-08 14:20:58 -05:00
use Session;
2015-03-10 11:26:31 -05:00
use URL;
2015-03-07 02:21:06 -06:00
/**
* Class ReminderController
*
* @package FireflyIII\Http\Controllers
*/
2015-03-06 13:33:23 -06:00
class ReminderController extends Controller
{
2015-03-08 14:20:58 -05:00
/**
* @param Reminder $reminder
2015-05-03 05:58:55 -05:00
*
* @return \Illuminate\Http\RedirectResponse
2015-03-08 14:20:58 -05:00
*/
public function act(Reminder $reminder)
{
$data = [
'description' => 'Money for piggy bank "' . $reminder->remindersable->name . '"',
'amount' => round($reminder->metadata->perReminder, 2),
'account_to_id' => $reminder->remindersable->account_id,
2015-03-10 11:26:31 -05:00
'piggy_bank_id' => $reminder->remindersable_id,
'reminder_id' => $reminder->id,
2015-03-08 14:20:58 -05:00
];
2015-03-10 11:26:31 -05:00
Session::flash('_old_input', $data);
2015-03-08 14:20:58 -05:00
2015-05-26 13:37:01 -05:00
return Redirect::route('transactions.create', ['transfer']);
2015-03-08 14:20:58 -05:00
}
2015-03-07 02:29:43 -06:00
/**
* @param Reminder $reminder
2015-05-03 05:58:55 -05:00
*
* @return \Illuminate\Http\RedirectResponse
2015-03-07 02:29:43 -06:00
*/
public function dismiss(Reminder $reminder)
{
$reminder->notnow = true;
$reminder->save();
return Redirect::to(URL::previous());
}
2015-03-06 13:33:23 -06:00
/**
2015-05-03 05:58:55 -05:00
* @param ReminderRepositoryInterface $repository
2015-03-06 13:33:23 -06:00
*
2015-05-03 05:58:55 -05:00
* @return \Illuminate\View\View
2015-03-06 13:33:23 -06:00
*/
2015-05-03 02:55:22 -05:00
public function index(ReminderRepositoryInterface $repository)
2015-03-06 13:33:23 -06:00
{
2015-05-03 02:55:22 -05:00
$active = $repository->getActiveReminders();
$expired = $repository->getExpiredReminders();
$inactive = $repository->getInactiveReminders();
$dismissed = $repository->getDismissedReminders();
2015-03-06 13:33:23 -06:00
$title = 'Reminders';
$mainTitleIcon = 'fa-clock-o';
return view('reminders.index', compact('dismissed', 'expired', 'inactive', 'active', 'title', 'mainTitleIcon'));
}
/**
* @param Reminder $reminder
2015-05-03 05:58:55 -05:00
*
* @return \Illuminate\View\View
2015-03-06 13:33:23 -06:00
*/
public function show(Reminder $reminder)
{
2015-06-09 10:56:08 -05:00
$title = trans('firefly.reminder');
2015-03-07 02:29:43 -06:00
$mainTitleIcon = 'fa-clock-o';
if ($reminder->notnow === true) {
2015-06-09 10:56:08 -05:00
$subTitle = trans('firefly.dismissed_reminder_for_piggy', ['name' => $reminder->remindersable->name]);
2015-03-07 02:29:43 -06:00
} else {
2015-06-09 10:56:08 -05:00
$subTitle = trans('firefly.reminder_for_piggy', ['name' => $reminder->remindersable->name]);
2015-03-07 02:29:43 -06:00
}
2015-03-06 13:33:23 -06:00
2015-03-07 02:29:43 -06:00
return view('reminders.show', compact('reminder', 'title', 'subTitle', 'mainTitleIcon'));
2015-03-07 02:21:06 -06:00
}
2015-03-06 13:33:23 -06:00
}