mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fixed the charts, added some todo items.
This commit is contained in:
parent
953d68c3a2
commit
58d8b6f95b
@ -464,8 +464,8 @@ class GoogleChartController extends BaseController
|
||||
$chart->addColumn('Name', 'string');
|
||||
$chart->addColumn('Amount', 'number');
|
||||
|
||||
/** @var \FireflyIII\Database\RecurringTransaction $rcr */
|
||||
$rcr = App::make('FireflyIII\Database\RecurringTransaction');
|
||||
/** @var \FireflyIII\Database\Recurring $rcr */
|
||||
$rcr = App::make('FireflyIII\Database\Recurring');
|
||||
|
||||
/** @var \FireflyIII\Shared\Toolkit\Date $dateKit */
|
||||
$dateKit = App::make('FireflyIII\Shared\Toolkit\Date');
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
use FireflyIII\Exception\NotImplementedException;
|
||||
|
||||
/**
|
||||
* Class SearchController
|
||||
@ -11,7 +10,10 @@ class SearchController extends BaseController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
throw new NotImplementedException;
|
||||
|
||||
/** @var \FireflyIII\Search\Search $searcher */
|
||||
$searcher = App::make('FireflyIII\Search\Search');
|
||||
|
||||
$subTitle = null;
|
||||
$rawQuery = null;
|
||||
$result = [];
|
||||
@ -20,11 +22,11 @@ class SearchController extends BaseController
|
||||
$words = explode(' ', $rawQuery);
|
||||
$subTitle = 'Results for "' . e($rawQuery) . '"';
|
||||
|
||||
$transactions = $this->_helper->searchTransactions($words);
|
||||
$accounts = $this->_helper->searchAccounts($words);
|
||||
$categories = $this->_helper->searchCategories($words);
|
||||
$budgets = $this->_helper->searchBudgets($words);
|
||||
$tags = $this->_helper->searchTags($words);
|
||||
$transactions = $searcher->searchTransactions($words);
|
||||
$accounts = $searcher->searchAccounts($words);
|
||||
$categories = $searcher->searchCategories($words);
|
||||
$budgets = $searcher->searchBudgets($words);
|
||||
$tags = $searcher->searchTags($words);
|
||||
$result = ['transactions' => $transactions, 'accounts' => $accounts, 'categories' => $categories, 'budgets' => $budgets, 'tags' => $tags];
|
||||
|
||||
}
|
||||
|
@ -330,7 +330,6 @@ class Recurring implements CUD, CommonDatabaseCalls, RecurringInterface
|
||||
* @param \RecurringTransaction $recurring
|
||||
*
|
||||
* @return bool
|
||||
* @throws NotImplementedException
|
||||
*/
|
||||
public function scanEverything(\RecurringTransaction $recurring)
|
||||
{
|
||||
|
107
app/lib/FireflyIII/Search/Search.php
Normal file
107
app/lib/FireflyIII/Search/Search.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sander
|
||||
* Date: 13/11/14
|
||||
* Time: 21:01
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Search;
|
||||
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class Search
|
||||
{
|
||||
/**
|
||||
* @param array $words
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function searchAccounts(array $words)
|
||||
{
|
||||
return \Auth::user()->accounts()->with('accounttype')->where(
|
||||
function ($q) use ($words) {
|
||||
foreach ($words as $word) {
|
||||
$q->orWhere('name', 'LIKE', '%' . e($word) . '%');
|
||||
}
|
||||
}
|
||||
)->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $words
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function searchBudgets(array $words)
|
||||
{
|
||||
/** @var Collection $set */
|
||||
$set = \Auth::user()->budgets()->get();
|
||||
$newSet = $set->filter(
|
||||
function (\Budget $b) use ($words) {
|
||||
$found = 0;
|
||||
foreach ($words as $word) {
|
||||
if (!(strpos(strtolower($b->name), strtolower($word)) === false)) {
|
||||
$found++;
|
||||
}
|
||||
}
|
||||
|
||||
return $found > 0;
|
||||
}
|
||||
);
|
||||
|
||||
return $newSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $words
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function searchCategories(array $words)
|
||||
{
|
||||
/** @var Collection $set */
|
||||
$set = \Auth::user()->categories()->get();
|
||||
$newSet = $set->filter(
|
||||
function (\Category $c) use ($words) {
|
||||
$found = 0;
|
||||
foreach ($words as $word) {
|
||||
if (!(strpos(strtolower($c->name), strtolower($word)) === false)) {
|
||||
$found++;
|
||||
}
|
||||
}
|
||||
|
||||
return $found > 0;
|
||||
}
|
||||
);
|
||||
|
||||
return $newSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $words
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function searchTags(array $words)
|
||||
{
|
||||
return new Collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $words
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function searchTransactions(array $words)
|
||||
{
|
||||
return \Auth::user()->transactionjournals()->withRelevantData()->where(
|
||||
function ($q) use ($words) {
|
||||
foreach ($words as $word) {
|
||||
$q->orWhere('description', 'LIKE', '%' . e($word) . '%');
|
||||
}
|
||||
}
|
||||
)->get();
|
||||
}
|
||||
}
|
@ -85,6 +85,7 @@ class Transaction extends Ardent
|
||||
*/
|
||||
public function connectPiggybank(\Piggybank $piggybank = null)
|
||||
{
|
||||
// TODO connect a piggy bank to a transaction.
|
||||
throw new NotImplementedException;
|
||||
// if (is_null($piggybank)) {
|
||||
// return true;
|
||||
|
@ -41,7 +41,7 @@
|
||||
<li class="sidebar-search">
|
||||
<form action="{{route('search')}}" method="GET" class="form-inline">
|
||||
<div class="input-group custom-search-form">
|
||||
<input type="text" name="q" class="form-control" placeholder="Search...">
|
||||
<input type="text" name="q" class="form-control" value="@if(Input::get('q')){{{Input::get('q')}}}@endif" placeholder="Search...">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="submit">
|
||||
<i class="fa fa-search"></i>
|
||||
|
@ -228,6 +228,11 @@ function googleSankeyChart(URL, container) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO fix this method so the layout is nice and dandy.
|
||||
* @param URL
|
||||
* @param container
|
||||
*/
|
||||
function googleTable(URL, container) {
|
||||
if ($('#' + container).length == 1) {
|
||||
$.getJSON(URL).success(function (data) {
|
||||
|
Loading…
Reference in New Issue
Block a user