2014-11-12 03:54:53 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FireflyIII\Shared\Toolkit;
|
2014-12-30 11:44:58 -06:00
|
|
|
|
2014-12-21 10:59:47 -06:00
|
|
|
use Carbon\Carbon;
|
2014-12-06 05:12:55 -06:00
|
|
|
use FireflyIII\Exception\FireflyException;
|
2014-11-12 03:54:53 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class Navigation
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Shared\Toolkit
|
|
|
|
*/
|
|
|
|
class Navigation
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @return bool
|
2014-12-06 05:12:55 -06:00
|
|
|
* @throws FireflyException
|
2014-11-12 03:54:53 -06:00
|
|
|
*/
|
|
|
|
public function next()
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Get the start date and the range from the session
|
|
|
|
*/
|
|
|
|
|
|
|
|
$filter = new Filter;
|
|
|
|
|
|
|
|
$range = $filter->setSessionRangeValue();
|
2014-12-21 10:59:47 -06:00
|
|
|
$start = \Session::get('start', Carbon::now()->startOfMonth());
|
2014-11-12 03:54:53 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add some period to $start.
|
|
|
|
*/
|
|
|
|
$next = $filter->next($range, clone $start);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save in session:
|
|
|
|
*/
|
|
|
|
\Session::put('start', $next);
|
2014-11-12 15:37:09 -06:00
|
|
|
|
2014-11-12 03:54:53 -06:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
2014-12-06 05:12:55 -06:00
|
|
|
* @throws FireflyException
|
2014-11-12 03:54:53 -06:00
|
|
|
*/
|
|
|
|
public function prev()
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Get the start date and the range from the session
|
|
|
|
*/
|
|
|
|
$filter = new Filter;
|
|
|
|
|
|
|
|
$range = $filter->setSessionRangeValue();
|
2014-12-21 10:59:47 -06:00
|
|
|
$start = \Session::get('start', Carbon::now()->startOfMonth());
|
2014-11-12 03:54:53 -06:00
|
|
|
|
|
|
|
/*
|
2014-12-31 10:15:59 -06:00
|
|
|
* Subtract some period to $start.
|
2014-11-12 03:54:53 -06:00
|
|
|
*/
|
|
|
|
$prev = $filter->previous($range, clone $start);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save in session:
|
|
|
|
*/
|
|
|
|
\Session::put('start', $prev);
|
2014-11-12 15:37:09 -06:00
|
|
|
|
2014-11-12 03:54:53 -06:00
|
|
|
return true;
|
|
|
|
}
|
2015-01-01 23:16:49 -06:00
|
|
|
}
|