mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Moved to high charts.
This commit is contained in:
@@ -17,25 +17,68 @@ class Toolkit implements ToolkitInterface
|
||||
public static function getDateRange()
|
||||
{
|
||||
$preferences = \App::make('Firefly\Helper\Preferences\PreferencesHelperInterface');
|
||||
$viewRange = $preferences->get('viewRange', 'week');
|
||||
$viewRange = $preferences->get('viewRange', '1M');
|
||||
|
||||
// as you can see, this method now only supports "right now":
|
||||
$now = new \Carbon\Carbon;
|
||||
$start = clone $now;
|
||||
$end = clone $now;
|
||||
// default range:
|
||||
$range = $viewRange->data;
|
||||
|
||||
// update range if session has something:
|
||||
if (!is_null(\Session::get('range'))) {
|
||||
$range = \Session::get('range');
|
||||
}
|
||||
|
||||
switch ($viewRange->data) {
|
||||
case 'week':
|
||||
// update view range if the input has something:
|
||||
if (!is_null(\Input::get('range'))) {
|
||||
$range = \Input::get('range');
|
||||
}
|
||||
|
||||
// switch $range, update range or something:
|
||||
$today = new \Carbon\Carbon;
|
||||
$start = clone $today;
|
||||
$end = clone $today;
|
||||
switch ($range) {
|
||||
case 'custom':
|
||||
// when range is custom AND input, we ignore $today
|
||||
if (\Input::get('start') && \Input::get('end')) {
|
||||
$start = new \Carbon\Carbon(\Input::get('start'));
|
||||
$end = new \Carbon\Carbon(\Input::get('end'));
|
||||
} else {
|
||||
$start = \Session::get('start');
|
||||
$end = \Session::get('end');
|
||||
}
|
||||
break;
|
||||
case '1D':
|
||||
$start->startOfDay();
|
||||
$end->endOfDay();
|
||||
break;
|
||||
case '1W':
|
||||
$start->startOfWeek();
|
||||
$end->endOfWeek();
|
||||
break;
|
||||
default:
|
||||
case 'month':
|
||||
case '1M':
|
||||
$start->startOfMonth();
|
||||
$end->endOfMonth();
|
||||
break;
|
||||
case '3M':
|
||||
$start->firstOfQuarter();
|
||||
$end->lastOfQuarter();
|
||||
break;
|
||||
case '6M':
|
||||
if (intval($today->format('m')) >= 7) {
|
||||
$start->startOfYear()->addMonths(6);
|
||||
$end->endOfYear();
|
||||
} else {
|
||||
$start->startOfYear();
|
||||
$end->startOfYear()->addMonths(6);
|
||||
}
|
||||
break;
|
||||
}
|
||||
// save in session:
|
||||
\Session::put('start', $start);
|
||||
\Session::put('end', $end);
|
||||
\Session::put('range', $range);
|
||||
|
||||
// and return:
|
||||
return [$start, $end];
|
||||
|
||||
|
||||
|
||||
@@ -10,12 +10,21 @@ interface AccountRepositoryInterface
|
||||
public function count();
|
||||
|
||||
public function get();
|
||||
|
||||
public function getBeneficiaries();
|
||||
|
||||
public function find($id);
|
||||
|
||||
public function getByIds($ids);
|
||||
|
||||
public function getDefault();
|
||||
|
||||
public function getActiveDefault();
|
||||
|
||||
public function getActiveDefaultAsSelectList();
|
||||
|
||||
public function store($data);
|
||||
public function storeWithInitialBalance($data,\Carbon\Carbon $date, $amount = 0);
|
||||
|
||||
public function storeWithInitialBalance($data, \Carbon\Carbon $date, $amount = 0);
|
||||
|
||||
}
|
||||
@@ -16,6 +16,16 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
||||
return \Auth::user()->accounts()->with('accounttype')->get();
|
||||
}
|
||||
|
||||
public function getBeneficiaries() {
|
||||
$list = \Auth::user()->accounts()->leftJoin(
|
||||
'account_types', 'account_types.id', '=', 'accounts.account_type_id'
|
||||
)
|
||||
->where('account_types.description', 'Beneficiary account')->where('accounts.active', 1)
|
||||
|
||||
->get(['accounts.*']);
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function find($id)
|
||||
{
|
||||
return \Auth::user()->accounts()->where('id', $id)->first();
|
||||
@@ -42,6 +52,21 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
||||
->get(['accounts.*']);
|
||||
}
|
||||
|
||||
public function getActiveDefaultAsSelectList()
|
||||
{
|
||||
$list = \Auth::user()->accounts()->leftJoin(
|
||||
'account_types', 'account_types.id', '=', 'accounts.account_type_id'
|
||||
)
|
||||
->where('account_types.description', 'Default account')->where('accounts.active', 1)
|
||||
|
||||
->get(['accounts.*']);
|
||||
$return = [];
|
||||
foreach ($list as $entry) {
|
||||
$return[intval($entry->id)] = $entry->name;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function count()
|
||||
{
|
||||
return \Auth::user()->accounts()->count();
|
||||
|
||||
@@ -9,6 +9,8 @@ interface ComponentRepositoryInterface
|
||||
|
||||
public function count();
|
||||
|
||||
public function get();
|
||||
|
||||
public function store($data);
|
||||
|
||||
}
|
||||
@@ -13,10 +13,15 @@ class EloquentComponentRepository implements ComponentRepositoryInterface
|
||||
|
||||
public function count()
|
||||
{
|
||||
return \Auth::user()->accounts()->count();
|
||||
return \Auth::user()->components()->count();
|
||||
|
||||
}
|
||||
|
||||
public function get() {
|
||||
die('no impl');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function store($data)
|
||||
{
|
||||
|
||||
@@ -145,7 +145,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
||||
|
||||
// lets make this simple.
|
||||
$types = [];
|
||||
foreach (\TransactionType::whereIn('type', ['Deposit', 'Withdrawal'])->get() as $t) {
|
||||
foreach (\TransactionType::whereIn('type', ['Withdrawal'])->get() as $t) {
|
||||
$types[] = $t->id;
|
||||
}
|
||||
unset($t);
|
||||
@@ -163,6 +163,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
||||
->whereIn('transaction_type_id', $types)
|
||||
->get(['transaction_journals.*']);
|
||||
unset($types);
|
||||
$result = [];
|
||||
|
||||
|
||||
foreach ($journals as $journal) {
|
||||
@@ -196,7 +197,7 @@ class EloquentTransactionJournalRepository implements TransactionJournalReposito
|
||||
|
||||
// lets make this simple.
|
||||
$types = [];
|
||||
foreach (\TransactionType::whereIn('type', ['Deposit', 'Withdrawal'])->get() as $t) {
|
||||
foreach (\TransactionType::whereIn('type', ['Withdrawal'])->get() as $t) {
|
||||
$types[] = $t->id;
|
||||
}
|
||||
unset($t);
|
||||
|
||||
Reference in New Issue
Block a user