mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Removed most, if not all, references to Google Charts (the tables part).
This commit is contained in:
parent
b388dcc7d4
commit
96ab112b22
@ -1,367 +0,0 @@
|
||||
<?php
|
||||
use FireflyIII\Exception\FireflyException;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Class GoogleTableController
|
||||
*/
|
||||
class GoogleTableController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $what
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function accountList($what)
|
||||
{
|
||||
|
||||
/** @var \FireflyIII\Database\Account $acct */
|
||||
$acct = App::make('FireflyIII\Database\Account');
|
||||
|
||||
switch ($what) {
|
||||
default:
|
||||
throw new FireflyException('Cannot handle "' . e($what) . '" in accountList.');
|
||||
break;
|
||||
case 'asset':
|
||||
$list = $acct->getAssetAccounts();
|
||||
break;
|
||||
case 'expense':
|
||||
$list = $acct->getExpenseAccounts();
|
||||
break;
|
||||
case 'revenue':
|
||||
$list = $acct->getRevenueAccounts();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('ID', 'number');
|
||||
$chart->addColumn('ID_Edit', 'string');
|
||||
$chart->addColumn('ID_Delete', 'string');
|
||||
$chart->addColumn('Name_URL', 'string');
|
||||
$chart->addColumn('Name', 'string');
|
||||
$chart->addColumn('Balance', 'number');
|
||||
|
||||
/** @var \Account $entry */
|
||||
foreach ($list as $entry) {
|
||||
$edit = route('accounts.edit', $entry->id);
|
||||
$delete = route('accounts.delete', $entry->id);
|
||||
$show = route('accounts.show', $entry->id);
|
||||
$chart->addRow($entry->id, $edit, $delete, $show, $entry->name, $entry->balance());
|
||||
}
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function categoryList()
|
||||
{
|
||||
|
||||
/** @var \FireflyIII\Database\Category $repos */
|
||||
$repos = App::make('FireflyIII\Database\Category');
|
||||
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('ID', 'number');
|
||||
$chart->addColumn('ID_Edit', 'string');
|
||||
$chart->addColumn('ID_Delete', 'string');
|
||||
$chart->addColumn('Name_URL', 'string');
|
||||
$chart->addColumn('Name', 'string');
|
||||
|
||||
$list = $repos->get();
|
||||
|
||||
/** @var Category $entry */
|
||||
foreach ($list as $entry) {
|
||||
$chart->addRow(
|
||||
$entry->id, route('categories.edit', $entry->id), route('categories.delete', $entry->id), route('categories.show', $entry->id), $entry->name
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
public function recurringList()
|
||||
{
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('ID', 'number');
|
||||
$chart->addColumn('ID_Edit', 'string');
|
||||
$chart->addColumn('ID_Delete', 'string');
|
||||
$chart->addColumn('Name_URL', 'string');
|
||||
$chart->addColumn('Name', 'string');
|
||||
$chart->addColumn('Matches', 'string');
|
||||
$chart->addColumn('Minimum amount', 'number');
|
||||
$chart->addColumn('Maximum amount', 'number');
|
||||
|
||||
/** @var \FireflyIII\Database\Recurring $repository */
|
||||
$repository = App::make('FireflyIII\Database\Recurring');
|
||||
|
||||
$set = $repository->get();
|
||||
|
||||
/** @var \RecurringTransaction $entry */
|
||||
foreach ($set as $entry) {
|
||||
$row = [$entry->id, route('recurring.edit', $entry->id), route('recurring.delete', $entry->id), route('recurring.show', $entry->id), $entry->name,
|
||||
$entry->match, $entry->amount_min, $entry->amount_max
|
||||
|
||||
];
|
||||
$chart->addRowArray($row);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* <th>name</th>
|
||||
<th>match</th>
|
||||
<th>amount_min</th>
|
||||
<th>amount_max</th>
|
||||
<th>date</th>
|
||||
<th>active</th>
|
||||
<th>automatch</th>
|
||||
<th>repeat_freq</th>
|
||||
<th>id</th>
|
||||
|
||||
*/
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Account $account
|
||||
*/
|
||||
public function transactionsByAccount(Account $account)
|
||||
{
|
||||
$table = new \FireflyIII\Shared\Google\Table\Transactions;
|
||||
/*
|
||||
* Find transactions:
|
||||
*/
|
||||
$accountID = $account->id;
|
||||
$transactions = $account->transactions()->with(
|
||||
['transactionjournal', 'transactionjournal.transactions' => function ($q) use ($accountID) {
|
||||
$q->where('account_id', '!=', $accountID);
|
||||
}, 'transactionjournal.budgets', 'transactionjournal.transactiontype', 'transactionjournal.categories']
|
||||
)->before(Session::get('end'))->after(
|
||||
Session::get('start')
|
||||
)->orderBy('date', 'DESC')->get();
|
||||
|
||||
$collection = new Collection;
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($transactions as $transaction) {
|
||||
|
||||
$date = $transaction->transactionJournal->date;
|
||||
$descriptionURL = route('transactions.show', $transaction->transaction_journal_id);
|
||||
$description = $transaction->transactionJournal->description;
|
||||
$amount = floatval($transaction->amount);
|
||||
|
||||
if ($transaction->transactionJournal->transactions[0]->account->id == $account->id) {
|
||||
$opposingAccountURI = route('accounts.show', $transaction->transactionJournal->transactions[1]->account->id);
|
||||
$opposingAccountName = $transaction->transactionJournal->transactions[1]->account->name;
|
||||
} else {
|
||||
$opposingAccountURI = route('accounts.show', $transaction->transactionJournal->transactions[0]->account->id);
|
||||
$opposingAccountName = $transaction->transactionJournal->transactions[0]->account->name;
|
||||
}
|
||||
if (isset($transaction->transactionJournal->budgets[0])) {
|
||||
$budgetURL = route('budgets.show', $transaction->transactionJournal->budgets[0]->id);
|
||||
$budget = $transaction->transactionJournal->budgets[0]->name;
|
||||
} else {
|
||||
$budgetURL = '';
|
||||
$budget = '';
|
||||
}
|
||||
|
||||
if (isset($transaction->transactionJournal->categories[0])) {
|
||||
$categoryURL = route('categories.show', $transaction->transactionJournal->categories[0]->id);
|
||||
$category = $transaction->transactionJournal->categories[0]->name;
|
||||
} else {
|
||||
$categoryURL = '';
|
||||
$category = '';
|
||||
}
|
||||
|
||||
|
||||
if ($amount < 0) {
|
||||
$from = $account->name;
|
||||
$fromURL = route('accounts.show', $account->id);
|
||||
|
||||
$to = $opposingAccountName;
|
||||
$toURL = $opposingAccountURI;
|
||||
} else {
|
||||
$to = $account->name;
|
||||
$toURL = route('accounts.show', $account->id);
|
||||
|
||||
$from = $opposingAccountName;
|
||||
$fromURL = $opposingAccountURI;
|
||||
}
|
||||
|
||||
$id = $transaction->transactionJournal->id;
|
||||
$edit = route('transactions.edit', $transaction->transactionJournal->id);
|
||||
$delete = route('transactions.delete', $transaction->transactionJournal->id);
|
||||
$chart->addRow(
|
||||
$id, $edit, $delete, $date, $descriptionURL, $description, $amount, $fromURL, $from, $toURL, $to, $budgetURL, $budget, $categoryURL, $category
|
||||
);
|
||||
}
|
||||
|
||||
// <th>Date</th>
|
||||
// <th>Description</th>
|
||||
// <th>Amount (€)</th>
|
||||
// <th>From</th>
|
||||
// <th>To</th>
|
||||
// <th>Budget / category</th>
|
||||
// <th>ID</th>
|
||||
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Component $component
|
||||
* @param LimitRepetition $repetition
|
||||
*/
|
||||
public function transactionsByComponent(Component $component, LimitRepetition $repetition = null)
|
||||
{
|
||||
/** @var \Grumpydictator\Gchart\GChart $chart */
|
||||
$chart = App::make('gchart');
|
||||
$chart->addColumn('ID', 'number');
|
||||
$chart->addColumn('ID_Edit', 'string');
|
||||
$chart->addColumn('ID_Delete', 'string');
|
||||
$chart->addColumn('Date', 'date');
|
||||
$chart->addColumn('Description_URL', 'string');
|
||||
$chart->addColumn('Description', 'string');
|
||||
$chart->addColumn('Amount', 'number');
|
||||
$chart->addColumn('From_URL', 'string');
|
||||
$chart->addColumn('From', 'string');
|
||||
$chart->addColumn('To_URL', 'string');
|
||||
$chart->addColumn('To', 'string');
|
||||
$chart->addColumn('Budget_URL', 'string');
|
||||
$chart->addColumn('Budget', 'string');
|
||||
$chart->addColumn('Category_URL', 'string');
|
||||
$chart->addColumn('Category', 'string');
|
||||
|
||||
if (is_null($repetition)) {
|
||||
$journals = $component->transactionjournals()->with(['budgets', 'categories', 'transactions', 'transactions.account'])->orderBy('date', 'DESC')
|
||||
->get();
|
||||
} else {
|
||||
$journals = $component->transactionjournals()->with(['budgets', 'categories', 'transactions', 'transactions.account'])->after(
|
||||
$repetition->startdate
|
||||
)->before($repetition->enddate)->orderBy('date', 'DESC')->get();
|
||||
}
|
||||
/** @var TransactionJournal $transaction */
|
||||
foreach ($journals as $journal) {
|
||||
$date = $journal->date;
|
||||
$descriptionURL = route('transactions.show', $journal->id);
|
||||
$description = $journal->description;
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
if (floatval($transaction->amount) > 0) {
|
||||
$amount = floatval($transaction->amount);
|
||||
$to = $transaction->account->name;
|
||||
$toURL = route('accounts.show', $transaction->account->id);
|
||||
} else {
|
||||
$from = $transaction->account->name;
|
||||
$fromURL = route('accounts.show', $transaction->account->id);
|
||||
}
|
||||
|
||||
}
|
||||
if (isset($journal->budgets[0])) {
|
||||
$budgetURL = route('budgets.show', $journal->budgets[0]->id);
|
||||
$component = $journal->budgets[0]->name;
|
||||
} else {
|
||||
$budgetURL = '';
|
||||
$component = '';
|
||||
}
|
||||
|
||||
if (isset($journal->categories[0])) {
|
||||
$categoryURL = route('categories.show', $journal->categories[0]->id);
|
||||
$category = $journal->categories[0]->name;
|
||||
} else {
|
||||
$categoryURL = '';
|
||||
$category = '';
|
||||
}
|
||||
|
||||
|
||||
$id = $journal->id;
|
||||
$edit = route('transactions.edit', $journal->id);
|
||||
$delete = route('transactions.delete', $journal->id);
|
||||
$chart->addRow(
|
||||
$id, $edit, $delete, $date, $descriptionURL, $description, $amount, $fromURL, $from, $toURL, $to, $budgetURL, $component, $categoryURL,
|
||||
$category
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$chart->generate();
|
||||
|
||||
return Response::json($chart->getData());
|
||||
|
||||
}
|
||||
|
||||
public function transactionsByRecurring(RecurringTransaction $recurring)
|
||||
{
|
||||
|
||||
/** @var \FireflyIII\Shared\Google\Table\Transactions $table */
|
||||
$table = new \FireflyIII\Shared\Google\Table\Transactions;
|
||||
$journals = $recurring->transactionjournals()->get();
|
||||
|
||||
$table->addData($journals);
|
||||
|
||||
return $table->generate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $what
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function transactionsList($what)
|
||||
{
|
||||
/*
|
||||
* Process some google stuff:
|
||||
*/
|
||||
$parameters = explode(' ',trim(Input::get('tq')));
|
||||
$limit = intval($parameters[1]);
|
||||
$offset = intval($parameters[3]);
|
||||
$request = explode(':',Input::get('tqx'));
|
||||
$reqID = $request[1];
|
||||
|
||||
/** @var \FireflyIII\Shared\Google\Table\Transactions $table */
|
||||
$table = new \FireflyIII\Shared\Google\Table\Transactions;
|
||||
$table->setPaging(true);
|
||||
$table->setLimit($limit);
|
||||
$table->setOffset($offset);
|
||||
$table->setReqID($reqID);
|
||||
|
||||
/** @var \FireflyIII\Database\TransactionJournal $repository */
|
||||
$repository = App::make('FireflyIII\Database\TransactionJournal');
|
||||
|
||||
switch ($what) {
|
||||
case 'expenses':
|
||||
case 'withdrawal':
|
||||
$list = $repository->getWithdrawals($limit, $offset);
|
||||
break;
|
||||
case 'revenue':
|
||||
case 'deposit':
|
||||
$list = $repository->getDeposits($limit, $offset);
|
||||
break;
|
||||
case 'transfer':
|
||||
case 'transfers':
|
||||
$list = $repository->getTransfers($limit, $offset);
|
||||
break;
|
||||
}
|
||||
|
||||
$table->addData($list);
|
||||
|
||||
echo $table->generate();
|
||||
exit;
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Shared\Google;
|
||||
|
||||
|
||||
class Table {
|
||||
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace FireflyIII\Shared\Google\Table;
|
||||
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
interface Table {
|
||||
|
||||
public function generate();
|
||||
|
||||
public function addData(Collection $data);
|
||||
}
|
@ -1,192 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sander
|
||||
* Date: 13/11/14
|
||||
* Time: 21:31
|
||||
*/
|
||||
|
||||
namespace FireflyIII\Shared\Google\Table;
|
||||
|
||||
|
||||
use Firefly\Exception\FireflyException;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class Transactions implements Table
|
||||
{
|
||||
/** @var \Grumpydictator\Gchart\GChart */
|
||||
protected $chart;
|
||||
/** @var int */
|
||||
protected $limit;
|
||||
/** @var int */
|
||||
protected $offset;
|
||||
/** @var bool */
|
||||
protected $paging;
|
||||
/** @var string */
|
||||
protected $reqID;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
/** @var \Grumpydictator\Gchart\GChart chart */
|
||||
$this->chart = \App::make('gchart');
|
||||
$this->chart->addColumn('ID', 'number');
|
||||
$this->chart->addColumn('ID_Edit', 'string');
|
||||
$this->chart->addColumn('ID_Delete', 'string');
|
||||
$this->chart->addColumn('Date', 'date');
|
||||
$this->chart->addColumn('Description_URL', 'string');
|
||||
$this->chart->addColumn('Description', 'string');
|
||||
$this->chart->addColumn('Amount', 'number');
|
||||
$this->chart->addColumn('From_URL', 'string');
|
||||
$this->chart->addColumn('From', 'string');
|
||||
$this->chart->addColumn('To_URL', 'string');
|
||||
$this->chart->addColumn('To', 'string');
|
||||
$this->chart->addColumn('Budget_URL', 'string');
|
||||
$this->chart->addColumn('Budget', 'string');
|
||||
$this->chart->addColumn('Category_URL', 'string');
|
||||
$this->chart->addColumn('Category', 'string');
|
||||
}
|
||||
|
||||
public function addData(Collection $data)
|
||||
{
|
||||
/** @var \TransactionJournal $entry */
|
||||
foreach ($data as $entry) {
|
||||
$date = $entry->date;
|
||||
$descriptionURL = route('transactions.show', $entry->id);
|
||||
$description = $entry->description;
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($entry->transactions as $transaction) {
|
||||
if (floatval($transaction->amount) > 0) {
|
||||
$amount = floatval($transaction->amount);
|
||||
$to = $transaction->account->name;
|
||||
$toURL = route('accounts.show', $transaction->account->id);
|
||||
} else {
|
||||
$from = $transaction->account->name;
|
||||
$fromURL = route('accounts.show', $transaction->account->id);
|
||||
}
|
||||
|
||||
}
|
||||
if (isset($entry->budgets[0])) {
|
||||
$budgetURL = route('budgets.show', $entry->budgets[0]->id);
|
||||
$component = $entry->budgets[0]->name;
|
||||
} else {
|
||||
$budgetURL = '';
|
||||
$component = '';
|
||||
}
|
||||
|
||||
if (isset($entry->categories[0])) {
|
||||
$categoryURL = route('categories.show', $entry->categories[0]->id);
|
||||
$category = $entry->categories[0]->name;
|
||||
} else {
|
||||
$categoryURL = '';
|
||||
$category = '';
|
||||
}
|
||||
|
||||
|
||||
$id = $entry->id;
|
||||
$edit = route('transactions.edit', $entry->id);
|
||||
$delete = route('transactions.delete', $entry->id);
|
||||
$this->chart->addRow(
|
||||
$id, $edit, $delete, $date, $descriptionURL, $description, $amount, $fromURL, $from, $toURL, $to, $budgetURL, $component, $categoryURL,
|
||||
$category
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function generate()
|
||||
{
|
||||
if ($this->getPaging() && (is_null($this->getLimit()) || is_null($this->getOffset()) || is_null($this->getReqID()))) {
|
||||
throw new FireflyException('Cannot page without parameters!');
|
||||
}
|
||||
$this->chart->generate();
|
||||
if($this->getPaging()) {
|
||||
$data = [
|
||||
'version' => '0.6',
|
||||
'reqId' => $this->getReqID(),
|
||||
'status' => 'warning',
|
||||
'warnings' => [
|
||||
[
|
||||
'reason' => 'data_truncated',
|
||||
'message' => 'Retrieved data was truncated',
|
||||
'detailed_message' => 'Data has been truncated due to userrequest (LIMIT in query)'
|
||||
]
|
||||
],
|
||||
'sig' => '12345',
|
||||
'table' => $this->chart->getData()
|
||||
];
|
||||
$return = '// Data table response'."\n".'google.visualization.Query.setResponse(' . json_encode($data).');';
|
||||
return $return;
|
||||
//"version":"0.6","reqId":"0","status":"warning","warnings":[{"reason":"data_truncated","message":"Retrieved data was truncated","detailed_message":"Data has been truncated due to userrequest (LIMIT in query)"}],"sig":"253683512","table
|
||||
}
|
||||
|
||||
|
||||
|
||||
return \Response::json($this->chart->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPaging()
|
||||
{
|
||||
return $this->paging;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $paging
|
||||
*/
|
||||
public function setPaging($paging)
|
||||
{
|
||||
$this->paging = $paging;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLimit()
|
||||
{
|
||||
return $this->limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $limit
|
||||
*/
|
||||
public function setLimit($limit)
|
||||
{
|
||||
$this->limit = $limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getOffset()
|
||||
{
|
||||
return $this->offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $offset
|
||||
*/
|
||||
public function setOffset($offset)
|
||||
{
|
||||
$this->offset = $offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getReqID()
|
||||
{
|
||||
return $this->reqID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $reqID
|
||||
*/
|
||||
public function setReqID($reqID)
|
||||
{
|
||||
$this->reqID = $reqID;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -160,15 +160,14 @@ Route::group(
|
||||
Route::get('/chart/component/{component}/spending/{year}', ['uses' => 'GoogleChartController@componentsAndSpending']);
|
||||
|
||||
// google table controller
|
||||
Route::get('/table/account/{account}/transactions', ['uses' => 'GoogleTableController@transactionsByAccount']);
|
||||
Route::get('/table/accounts/{what}', ['uses' => 'GoogleTableController@accountList']);
|
||||
Route::get('/table/categories', ['uses' => 'GoogleTableController@categoryList']);
|
||||
Route::get('/table/recurring', ['uses' => 'GoogleTableController@recurringList']);
|
||||
Route::get('/table/recurring/{recurring}/transactions', ['uses' => 'GoogleTableController@transactionsByRecurring']);
|
||||
Route::get('/table/transactions/{what}', ['uses' => 'GoogleTableController@transactionsList'])->where(['what' => 'expenses|revenue|withdrawal|deposit|transfer|transfers']);
|
||||
|
||||
#Route::get('/table/account/{account}/transactions', ['uses' => 'GoogleTableController@transactionsByAccount']);
|
||||
#Route::get('/table/accounts/{what}', ['uses' => 'GoogleTableController@accountList']);
|
||||
#Route::get('/table/categories', ['uses' => 'GoogleTableController@categoryList']);
|
||||
#Route::get('/table/recurring', ['uses' => 'GoogleTableController@recurringList']);
|
||||
#Route::get('/table/recurring/{recurring}/transactions', ['uses' => 'GoogleTableController@transactionsByRecurring']);
|
||||
#Route::get('/table/transactions/{what}', ['uses' => 'GoogleTableController@transactionsList'])->where(['what' => 'expenses|revenue|withdrawal|deposit|transfer|transfers']);
|
||||
// google table for components (categories + budgets)
|
||||
Route::get('/table/component/{component}/{limitrepetition}/transactions', ['uses' => 'GoogleTableController@transactionsByComponent']);
|
||||
#Route::get('/table/component/{component}/{limitrepetition}/transactions', ['uses' => 'GoogleTableController@transactionsByComponent']);
|
||||
|
||||
|
||||
// home controller
|
||||
|
@ -101,7 +101,7 @@
|
||||
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
@include('transactions.journals-small-index',['transactions' => $data[0],'account' => $data[1]])
|
||||
@include('lists.old.journals-small-index',['transactions' => $data[0],'account' => $data[1]])
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
|
@ -9,7 +9,7 @@
|
||||
<i class="fa fa-repeat"></i> Transactions ({{$result['transactions']->count()}})
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
@include('transactions.journals-small-noaccount',['transactions' => $result['transactions']])
|
||||
@include('...lists.old.journals-small-noaccount',['transactions' => $result['transactions']])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -21,7 +21,6 @@ var what = '{{{$what}}}';
|
||||
</script>
|
||||
<!-- load the libraries and scripts necessary for Google Charts: -->
|
||||
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
||||
{{HTML::script('assets/javascript/google/TableQueryWrapper.js')}}
|
||||
{{HTML::script('assets/javascript/firefly/gcharts.options.js')}}
|
||||
{{HTML::script('assets/javascript/firefly/gcharts.js')}}
|
||||
|
||||
|
@ -226,109 +226,4 @@ function googleSankeyChart(URL, container) {
|
||||
} else {
|
||||
console.log('No container found called "' + 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) {
|
||||
/*
|
||||
Get the data from the JSON
|
||||
*/
|
||||
var gdata = new google.visualization.DataTable(data);
|
||||
|
||||
/*
|
||||
Create a new google charts object.
|
||||
*/
|
||||
var chart = new google.visualization.Table(document.getElementById(container));
|
||||
|
||||
/*
|
||||
Do something with formatters:
|
||||
*/
|
||||
var x = gdata.getNumberOfColumns();
|
||||
var columnsToHide = new Array;
|
||||
var URLFormatter = new google.visualization.PatternFormat('<a href="{0}">{1}</a>');
|
||||
|
||||
var EditButtonFormatter = new google.visualization.PatternFormat('<div class="btn-group btn-group-xs"><a href="{0}" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-pencil"></span></a><a class="btn btn-xs btn-danger" href="{1}"><span class="glyphicon glyphicon-trash"></span></a></div>');
|
||||
|
||||
var money = new google.visualization.NumberFormat({
|
||||
decimalSymbol: ',',
|
||||
groupingSymbol: '.',
|
||||
prefix: '\u20AC '
|
||||
});
|
||||
|
||||
|
||||
for (var i = 0; i < x; i++) {
|
||||
var label = gdata.getColumnLabel(i);
|
||||
/*
|
||||
Format a string using the previous column as URL.
|
||||
*/
|
||||
if (label == 'Description' || label == 'From' || label == 'Name' || label == 'To' || label == 'Budget' || label == 'Category') {
|
||||
URLFormatter.format(gdata, [i - 1, i], i);
|
||||
columnsToHide.push(i - 1);
|
||||
}
|
||||
if (label == 'ID') {
|
||||
EditButtonFormatter.format(gdata, [i + 1, i + 2], i);
|
||||
columnsToHide.push(i + 1, i + 2);
|
||||
}
|
||||
|
||||
/*
|
||||
Format with buttons:
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Format as money
|
||||
*/
|
||||
if (label == 'Amount' || label == 'Balance' || label == 'Minimum amount' || label == 'Maximum amount') {
|
||||
money.format(gdata, i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//var formatter = new google.visualization.PatternFormat('<a href="#">{1}</a>');
|
||||
|
||||
//formatter.format(gdata, [5, 6], 6);
|
||||
//formatter.format(gdata, [7, 8], 8);
|
||||
|
||||
|
||||
var view = new google.visualization.DataView(gdata);
|
||||
// hide certain columns:
|
||||
|
||||
view.hideColumns(columnsToHide);
|
||||
|
||||
|
||||
/*
|
||||
Draw it:
|
||||
*/
|
||||
chart.draw(view, defaultTableOptions);
|
||||
|
||||
}).fail(function () {
|
||||
$('#' + container).addClass('google-chart-error');
|
||||
});
|
||||
} else {
|
||||
console.log('No container found called "' + container + '"');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param URL
|
||||
* @param container
|
||||
*/
|
||||
function googleTablePaged(URL, container) {
|
||||
var query, options;
|
||||
query = new google.visualization.Query(URL);
|
||||
objContainer = document.getElementById(container);
|
||||
options = {'pageSize': 5};
|
||||
|
||||
query.abort();
|
||||
var tableQueryWrapper = new TableQueryWrapper(query, objContainer, options);
|
||||
tableQueryWrapper.sendAndDraw();
|
||||
|
||||
}
|
@ -115,9 +115,4 @@ var defaultPieChartOptions = {
|
||||
|
||||
var defaultSankeyChartOptions = {
|
||||
height: 400
|
||||
}
|
||||
var defaultTableOptions = {
|
||||
allowHtml: true,
|
||||
page: 'enable',
|
||||
pageSize: 50
|
||||
};
|
||||
}
|
@ -1,159 +0,0 @@
|
||||
/**
|
||||
* A wrapper for a query and a table visualization.
|
||||
* The object only requests 1 page + 1 row at a time, by default, in order
|
||||
* to minimize the amount of data held locally.
|
||||
* Table sorting and pagination is executed by issuing
|
||||
* additional requests with appropriate query parameters.
|
||||
* E.g., for getting the data sorted by column 'A' the following query is
|
||||
* attached to the request: 'tq=order by A'.
|
||||
*
|
||||
* Note: Discards query strings set by the user on the query object using
|
||||
* google.visualization.Query#setQuery.
|
||||
*
|
||||
* DISCLAIMER: This is an example code which you can copy and change as
|
||||
* required. It is used with the google visualization API table visualization
|
||||
* which is assumed to be loaded to the page. For more info see:
|
||||
* https://developers.google.com/chart/interactive/docs/gallery/table
|
||||
* https://developers.google.com/chart/interactive/docs/reference#Query
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new table query wrapper for the specified query, container
|
||||
* and tableOptions.
|
||||
*
|
||||
* Note: The wrapper clones the options object to adjust some of its properties.
|
||||
* In particular:
|
||||
* sort {string} set to 'event'.
|
||||
* page {string} set to 'event'.
|
||||
* pageSize {Number} If number <= 0 set to 10.
|
||||
* showRowNumber {boolean} set to true.
|
||||
* firstRowNumber {number} set according to the current page.
|
||||
* sortAscending {boolean} set according to the current sort.
|
||||
* sortColumn {number} set according to the given sort.
|
||||
* @constructor
|
||||
*/
|
||||
var TableQueryWrapper = function(query, container, options) {
|
||||
|
||||
this.table = new google.visualization.Table(container);
|
||||
this.query = query;
|
||||
this.sortQueryClause = '';
|
||||
this.pageQueryClause = '';
|
||||
this.container = container;
|
||||
this.currentDataTable = null;
|
||||
|
||||
var self = this;
|
||||
var addListener = google.visualization.events.addListener;
|
||||
addListener(this.table, 'page', function(e) {self.handlePage(e)});
|
||||
addListener(this.table, 'sort', function(e) {self.handleSort(e)});
|
||||
|
||||
options = options || {};
|
||||
options = TableQueryWrapper.clone(options);
|
||||
|
||||
options['sort'] = 'event';
|
||||
options['page'] = 'event';
|
||||
options['showRowNumber'] = true;
|
||||
var buttonConfig = 'pagingButtonsConfiguration';
|
||||
options[buttonConfig] = options[buttonConfig] || 'both';
|
||||
options['pageSize'] = (options['pageSize'] > 0) ? options['pageSize'] : 10;
|
||||
this.pageSize = options['pageSize'];
|
||||
this.tableOptions = options;
|
||||
this.currentPageIndex = 0;
|
||||
this.setPageQueryClause(0);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Sends the query and upon its return draws the Table visualization in the
|
||||
* container. If the query refresh interval is set then the visualization will
|
||||
* be redrawn upon each refresh.
|
||||
*/
|
||||
TableQueryWrapper.prototype.sendAndDraw = function() {
|
||||
this.query.abort();
|
||||
var queryClause = this.sortQueryClause + ' ' + this.pageQueryClause;
|
||||
this.query.setQuery(queryClause);
|
||||
this.table.setSelection([]);
|
||||
var self = this;
|
||||
this.query.send(function(response) {self.handleResponse(response)});
|
||||
};
|
||||
|
||||
|
||||
/** Handles the query response after a send returned by the data source. */
|
||||
TableQueryWrapper.prototype.handleResponse = function(response) {
|
||||
this.currentDataTable = null;
|
||||
if (response.isError()) {
|
||||
google.visualization.errors.addError(this.container, response.getMessage(),
|
||||
response.getDetailedMessage(), {'showInTooltip': false});
|
||||
} else {
|
||||
// make data:
|
||||
//this.currentDataTable= new google.visualization.DataTable(response);
|
||||
//console.log(response);
|
||||
this.currentDataTable = response.getDataTable();
|
||||
this.table.draw(this.currentDataTable, this.tableOptions);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** Handles a sort event with the given properties. Will page to page=0. */
|
||||
TableQueryWrapper.prototype.handleSort = function(properties) {
|
||||
var columnIndex = properties['column'];
|
||||
var isAscending = properties['ascending'];
|
||||
this.tableOptions['sortColumn'] = columnIndex;
|
||||
this.tableOptions['sortAscending'] = isAscending;
|
||||
// dataTable exists since the user clicked the table.
|
||||
var colID = this.currentDataTable.getColumnId(columnIndex);
|
||||
this.sortQueryClause = 'order by `' + colID + (!isAscending ? '` desc' : '`');
|
||||
// Calls sendAndDraw internally.
|
||||
this.handlePage({'page': 0});
|
||||
};
|
||||
|
||||
|
||||
/** Handles a page event with the given properties. */
|
||||
TableQueryWrapper.prototype.handlePage = function(properties) {
|
||||
var localTableNewPage = properties['page']; // 1, -1 or 0
|
||||
var newPage = 0;
|
||||
if (localTableNewPage != 0) {
|
||||
newPage = this.currentPageIndex + localTableNewPage;
|
||||
}
|
||||
if (this.setPageQueryClause(newPage)) {
|
||||
this.sendAndDraw();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Sets the pageQueryClause and table options for a new page request.
|
||||
* In case the next page is requested - checks that another page exists
|
||||
* based on the previous request.
|
||||
* Returns true if a new page query clause was set, false otherwise.
|
||||
*/
|
||||
TableQueryWrapper.prototype.setPageQueryClause = function(pageIndex) {
|
||||
var pageSize = this.pageSize;
|
||||
|
||||
if (pageIndex < 0) {
|
||||
return false;
|
||||
}
|
||||
var dataTable = this.currentDataTable;
|
||||
if ((pageIndex == this.currentPageIndex + 1) && dataTable) {
|
||||
if (dataTable.getNumberOfRows() <= pageSize) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
this.currentPageIndex = pageIndex;
|
||||
var newStartRow = this.currentPageIndex * pageSize;
|
||||
// Get the pageSize + 1 so that we can know when the last page is reached.
|
||||
this.pageQueryClause = 'limit ' + (pageSize + 1) + ' offset ' + newStartRow;
|
||||
// Note: row numbers are 1-based yet dataTable rows are 0-based.
|
||||
this.tableOptions['firstRowNumber'] = newStartRow + 1;
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
/** Performs a shallow clone of the given object. */
|
||||
TableQueryWrapper.clone = function(obj) {
|
||||
var newObj = {};
|
||||
for (var key in obj) {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
return newObj;
|
||||
};
|
Loading…
Reference in New Issue
Block a user