mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Start cleaning up transactions controller.
This commit is contained in:
parent
78d034d366
commit
d34cc65984
@ -371,7 +371,7 @@ class GoogleChartController extends BaseController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
* @throws \Firefly\Exception\FireflyException
|
* @throws \FireflyIII\Exception\FireflyException
|
||||||
*/
|
*/
|
||||||
public function recurringTransactionsOverview()
|
public function recurringTransactionsOverview()
|
||||||
{
|
{
|
||||||
|
@ -4,20 +4,9 @@ use FireflyIII\Shared\Preferences\PreferencesInterface as Prefs;
|
|||||||
/**
|
/**
|
||||||
* Class HomeController
|
* Class HomeController
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.CamelCasePropertyName)
|
|
||||||
*/
|
*/
|
||||||
class HomeController extends BaseController
|
class HomeController extends BaseController
|
||||||
{
|
{
|
||||||
protected $_preferences;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Prefs $preferences
|
|
||||||
*/
|
|
||||||
public function __construct(Prefs $preferences)
|
|
||||||
{
|
|
||||||
$this->_preferences = $preferences;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
@ -52,8 +41,11 @@ class HomeController extends BaseController
|
|||||||
|
|
||||||
$valid = ['1D', '1W', '1M', '3M', '6M', '1Y',];
|
$valid = ['1D', '1W', '1M', '3M', '6M', '1Y',];
|
||||||
|
|
||||||
|
/** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */
|
||||||
|
$preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface');
|
||||||
|
|
||||||
if (in_array($range, $valid)) {
|
if (in_array($range, $valid)) {
|
||||||
$this->_preferences->set('viewRange', $range);
|
$preferences->set('viewRange', $range);
|
||||||
Session::forget('range');
|
Session::forget('range');
|
||||||
}
|
}
|
||||||
return Redirect::back();
|
return Redirect::back();
|
||||||
@ -85,6 +77,9 @@ class HomeController extends BaseController
|
|||||||
/** @var \FireflyIII\Database\TransactionJournal $jrnls */
|
/** @var \FireflyIII\Database\TransactionJournal $jrnls */
|
||||||
$jrnls = App::make('FireflyIII\Database\TransactionJournal');
|
$jrnls = App::make('FireflyIII\Database\TransactionJournal');
|
||||||
|
|
||||||
|
/** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */
|
||||||
|
$preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface');
|
||||||
|
|
||||||
$count = $acct->countAssetAccounts();
|
$count = $acct->countAssetAccounts();
|
||||||
|
|
||||||
$start = Session::get('start');
|
$start = Session::get('start');
|
||||||
@ -92,7 +87,7 @@ class HomeController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
// get the preference for the home accounts to show:
|
// get the preference for the home accounts to show:
|
||||||
$frontpage = $this->_preferences->get('frontpageAccounts', []);
|
$frontpage = $preferences->get('frontpageAccounts', []);
|
||||||
if ($frontpage->data == []) {
|
if ($frontpage->data == []) {
|
||||||
$accounts = $acct->getAssetAccounts();
|
$accounts = $acct->getAssetAccounts();
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
|
|
||||||
use FireflyIII\Exception\FireflyException;
|
use FireflyIII\Exception\FireflyException;
|
||||||
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
use Illuminate\Support\MessageBag;
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,31 +31,30 @@ class TransactionController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function create($what = 'deposit')
|
public function create($what = 'deposit')
|
||||||
{
|
{
|
||||||
throw new NotImplementedException;
|
|
||||||
/*
|
/*
|
||||||
* The repositories we need:
|
* The repositories we need:
|
||||||
*/
|
*/
|
||||||
/** @var \Firefly\Helper\Toolkit\Toolkit $toolkit */
|
/** @var \FireflyIII\Shared\Toolkit\Form $form */
|
||||||
$toolkit = App::make('Firefly\Helper\Toolkit\Toolkit');
|
$form = App::make('FireflyIII\Shared\Toolkit\Form');
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accountRepository */
|
/** @var \FireflyIII\Database\Account $accountRepository */
|
||||||
$accountRepository = App::make('Firefly\Storage\Account\AccountRepositoryInterface');
|
$accountRepository = App::make('FireflyIII\Database\Account');
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Budget\BudgetRepositoryInterface $budgetRepository */
|
/** @var \FireflyIII\Database\Budget $budgetRepository */
|
||||||
$budgetRepository = App::make('Firefly\Storage\Budget\BudgetRepositoryInterface');
|
$budgetRepository = App::make('FireflyIII\Database\Budget');
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */
|
/** @var \FireflyIII\Database\Piggybank $piggyRepository */
|
||||||
$piggyRepository = App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
|
$piggyRepository = App::make('FireflyIII\Database\Piggybank');
|
||||||
|
|
||||||
// get asset accounts with names and id's.
|
// get asset accounts with names and id's.
|
||||||
$assetAccounts = $toolkit->makeSelectList($accountRepository->getActiveDefault());
|
$assetAccounts = $form->makeSelectList($accountRepository->getAssetAccounts());
|
||||||
|
|
||||||
// get budgets as a select list.
|
// get budgets as a select list.
|
||||||
$budgets = $toolkit->makeSelectList($budgetRepository->get());
|
$budgets = $form->makeSelectList($budgetRepository->get());
|
||||||
$budgets[0] = '(no budget)';
|
$budgets[0] = '(no budget)';
|
||||||
|
|
||||||
// get the piggy banks.
|
// get the piggy banks.
|
||||||
$piggies = $toolkit->makeSelectList($piggyRepository->get());
|
$piggies = $form->makeSelectList($piggyRepository->get());
|
||||||
$piggies[0] = '(no piggy bank)';
|
$piggies[0] = '(no piggy bank)';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -100,19 +100,21 @@ class TransactionController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function destroy(TransactionJournal $transactionJournal)
|
public function destroy(TransactionJournal $transactionJournal)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException;
|
|
||||||
$type = $transactionJournal->transactionType->type;
|
$type = $transactionJournal->transactionType->type;
|
||||||
$transactionJournal->delete();
|
|
||||||
|
/** @var \FireflyIII\Database\TransactionJournal $repository */
|
||||||
|
$repository = App::make('FireflyIII\Database\TransactionJournal');
|
||||||
|
$repository->destroy($transactionJournal);
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'Withdrawal':
|
case 'Withdrawal':
|
||||||
return Redirect::route('transactions.expenses');
|
return Redirect::route('transactions.index', 'withdrawal');
|
||||||
break;
|
break;
|
||||||
case 'Deposit':
|
case 'Deposit':
|
||||||
return Redirect::route('transactions.revenue');
|
return Redirect::route('transactions.index', 'deposit');
|
||||||
break;
|
break;
|
||||||
case 'Transfer':
|
case 'Transfer':
|
||||||
return Redirect::route('transactions.transfers');
|
return Redirect::route('transactions.index', 'transfers');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,30 +128,30 @@ class TransactionController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function edit(TransactionJournal $journal)
|
public function edit(TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException;
|
|
||||||
/*
|
/*
|
||||||
* All the repositories we need:
|
* All the repositories we need:
|
||||||
*/
|
*/
|
||||||
/** @var \Firefly\Helper\Toolkit\Toolkit $toolkit */
|
/** @var \FireflyIII\Shared\Toolkit\Form $form */
|
||||||
$toolkit = App::make('Firefly\Helper\Toolkit\Toolkit');
|
$form = App::make('FireflyIII\Shared\Toolkit\Form');
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Account\AccountRepositoryInterface $accountRepository */
|
/** @var \FireflyIII\Database\Account $accountRepository */
|
||||||
$accountRepository = App::make('Firefly\Storage\Account\AccountRepositoryInterface');
|
$accountRepository = App::make('FireflyIII\Database\Account');
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Budget\BudgetRepositoryInterface $budgetRepository */
|
/** @var \FireflyIII\Database\Budget $budgetRepository */
|
||||||
$budgetRepository = App::make('Firefly\Storage\Budget\BudgetRepositoryInterface');
|
$budgetRepository = App::make('FireflyIII\Database\Budget');
|
||||||
|
|
||||||
|
/** @var \FireflyIII\Database\Piggybank $piggyRepository */
|
||||||
|
$piggyRepository = App::make('FireflyIII\Database\Piggybank');
|
||||||
|
|
||||||
/** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */
|
|
||||||
$piggyRepository = App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
|
|
||||||
|
|
||||||
// type is useful for display:
|
// type is useful for display:
|
||||||
$what = strtolower($journal->transactiontype->type);
|
$what = strtolower($journal->transactiontype->type);
|
||||||
|
|
||||||
// get asset accounts with names and id's.
|
// get asset accounts with names and id's.
|
||||||
$accounts = $toolkit->makeSelectList($accountRepository->getActiveDefault());
|
$accounts = $form->makeSelectList($accountRepository->getAssetAccounts());
|
||||||
|
|
||||||
// get budgets as a select list.
|
// get budgets as a select list.
|
||||||
$budgets = $toolkit->makeSelectList($budgetRepository->get());
|
$budgets = $form->makeSelectList($budgetRepository->get());
|
||||||
$budgets[0] = '(no budget)';
|
$budgets[0] = '(no budget)';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -157,8 +159,8 @@ class TransactionController extends BaseController
|
|||||||
* of the transactions in the journal has this field, it should all fill in nicely.
|
* of the transactions in the journal has this field, it should all fill in nicely.
|
||||||
*/
|
*/
|
||||||
// get the piggy banks.
|
// get the piggy banks.
|
||||||
$piggies = $toolkit->makeSelectList($piggyRepository->get());
|
$piggies = $form->makeSelectList($piggyRepository->get());
|
||||||
$piggies[0] = '(no piggy bank)';
|
$piggies[0] = '(no piggy bank)';
|
||||||
$piggyBankId = 0;
|
$piggyBankId = 0;
|
||||||
foreach ($journal->transactions as $t) {
|
foreach ($journal->transactions as $t) {
|
||||||
if (!is_null($t->piggybank_id)) {
|
if (!is_null($t->piggybank_id)) {
|
||||||
@ -190,23 +192,23 @@ class TransactionController extends BaseController
|
|||||||
*/
|
*/
|
||||||
switch ($what) {
|
switch ($what) {
|
||||||
case 'withdrawal':
|
case 'withdrawal':
|
||||||
$prefilled['account_id'] = $journal->transactions[0]->account->id;
|
$prefilled['account_id'] = $journal->transactions[0]->account->id;
|
||||||
$prefilled['expense_account'] = $journal->transactions[1]->account->name;
|
$prefilled['expense_account'] = $journal->transactions[1]->account->name;
|
||||||
$prefilled['amount'] = floatval($journal->transactions[1]->amount);
|
$prefilled['amount'] = floatval($journal->transactions[1]->amount);
|
||||||
$budget = $journal->budgets()->first();
|
$budget = $journal->budgets()->first();
|
||||||
if (!is_null($budget)) {
|
if (!is_null($budget)) {
|
||||||
$prefilled['budget_id'] = $budget->id;
|
$prefilled['budget_id'] = $budget->id;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'deposit':
|
case 'deposit':
|
||||||
$prefilled['account_id'] = $journal->transactions[1]->account->id;
|
$prefilled['account_id'] = $journal->transactions[1]->account->id;
|
||||||
$prefilled['revenue_account'] = $journal->transactions[0]->account->name;
|
$prefilled['revenue_account'] = $journal->transactions[0]->account->name;
|
||||||
$prefilled['amount'] = floatval($journal->transactions[1]->amount);
|
$prefilled['amount'] = floatval($journal->transactions[1]->amount);
|
||||||
break;
|
break;
|
||||||
case 'transfer':
|
case 'transfer':
|
||||||
$prefilled['account_from_id'] = $journal->transactions[1]->account->id;
|
$prefilled['account_from_id'] = $journal->transactions[1]->account->id;
|
||||||
$prefilled['account_to_id'] = $journal->transactions[0]->account->id;
|
$prefilled['account_to_id'] = $journal->transactions[0]->account->id;
|
||||||
$prefilled['amount'] = floatval($journal->transactions[1]->amount);
|
$prefilled['amount'] = floatval($journal->transactions[1]->amount);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +266,7 @@ class TransactionController extends BaseController
|
|||||||
/*
|
/*
|
||||||
* Collect data to process:
|
* Collect data to process:
|
||||||
*/
|
*/
|
||||||
$data = Input::except(['_token']);
|
$data = Input::except(['_token']);
|
||||||
$data['what'] = $what;
|
$data['what'] = $what;
|
||||||
|
|
||||||
switch (Input::get('post_submit_action')) {
|
switch (Input::get('post_submit_action')) {
|
||||||
@ -312,11 +314,9 @@ class TransactionController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function transfers()
|
public function index($what)
|
||||||
{
|
{
|
||||||
return View::make('transactions.list')->with('subTitle', 'Transfers')->with(
|
return View::make('transactions.index')->with('subTitle', 'Bla bla')->with('subTitleIcon', 'fa-arrows-h')->with('what', $what);
|
||||||
'subTitleIcon', 'fa-arrows-h'
|
|
||||||
)->with('what', 'transfers');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +331,7 @@ class TransactionController extends BaseController
|
|||||||
switch (Input::get('post_submit_action')) {
|
switch (Input::get('post_submit_action')) {
|
||||||
case 'update':
|
case 'update':
|
||||||
case 'return_to_edit':
|
case 'return_to_edit':
|
||||||
$what = strtolower($journal->transactionType->type);
|
$what = strtolower($journal->transactionType->type);
|
||||||
$messageBag = $this->_helper->update($journal, Input::all());
|
$messageBag = $this->_helper->update($journal, Input::all());
|
||||||
if ($messageBag->count() == 0) {
|
if ($messageBag->count() == 0) {
|
||||||
// has been saved, return to index:
|
// has been saved, return to index:
|
||||||
@ -353,9 +353,9 @@ class TransactionController extends BaseController
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case 'validate_only':
|
case 'validate_only':
|
||||||
$data = Input::all();
|
$data = Input::all();
|
||||||
$data['what'] = strtolower($journal->transactionType->type);
|
$data['what'] = strtolower($journal->transactionType->type);
|
||||||
$messageBags = $this->_helper->validate($data);
|
$messageBags = $this->_helper->validate($data);
|
||||||
|
|
||||||
Session::flash('warnings', $messageBags['warnings']);
|
Session::flash('warnings', $messageBags['warnings']);
|
||||||
Session::flash('successes', $messageBags['successes']);
|
Session::flash('successes', $messageBags['successes']);
|
||||||
|
379
app/lib/FireflyIII/Form/Form.php
Normal file
379
app/lib/FireflyIII/Form/Form.php
Normal file
@ -0,0 +1,379 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace FireflyIII\Form;
|
||||||
|
|
||||||
|
|
||||||
|
use FireflyIII\Exception\FireflyException;
|
||||||
|
use Illuminate\Support\MessageBag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Form
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Form
|
||||||
|
*/
|
||||||
|
class Form
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
* @param null $value
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public static function ffInteger($name, $value = null, array $options = [])
|
||||||
|
{
|
||||||
|
$options['step'] = '1';
|
||||||
|
return self::ffInput('number', $name, $value, $options);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
* @param int $value
|
||||||
|
* @param null $checked
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public static function ffCheckbox($name, $value = 1, $checked = null, $options = [])
|
||||||
|
{
|
||||||
|
$options['checked'] = $checked ? true : null;
|
||||||
|
return self::ffInput('checkbox', $name, $value, $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
* @param null $value
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public static function ffAmount($name, $value = null, array $options = [])
|
||||||
|
{
|
||||||
|
$options['step'] = 'any';
|
||||||
|
$options['min'] = '0.01';
|
||||||
|
return self::ffInput('amount', $name, $value, $options);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
* @param null $value
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public static function ffBalance($name, $value = null, array $options = [])
|
||||||
|
{
|
||||||
|
$options['step'] = 'any';
|
||||||
|
return self::ffInput('amount', $name, $value, $options);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
* @param null $value
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public static function ffDate($name, $value = null, array $options = [])
|
||||||
|
{
|
||||||
|
return self::ffInput('date', $name, $value, $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
* @param null $value
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public static function ffTags($name, $value = null, array $options = [])
|
||||||
|
{
|
||||||
|
$options['data-role'] = 'tagsinput';
|
||||||
|
return self::ffInput('text', $name, $value, $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
* @param array $list
|
||||||
|
* @param null $selected
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public static function ffSelect($name, array $list = [], $selected = null, array $options = [])
|
||||||
|
{
|
||||||
|
return self::ffInput('select', $name, $selected, $options, $list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
* @param null $value
|
||||||
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public static function ffText($name, $value = null, array $options = array())
|
||||||
|
{
|
||||||
|
return self::ffInput('text', $name, $value, $options);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $name
|
||||||
|
* @param $options
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function label($name, $options)
|
||||||
|
{
|
||||||
|
if (isset($options['label'])) {
|
||||||
|
return $options['label'];
|
||||||
|
}
|
||||||
|
$labels = [
|
||||||
|
'amount_min' => 'Amount (min)',
|
||||||
|
'amount_max' => 'Amount (max)',
|
||||||
|
'match' => 'Matches on',
|
||||||
|
'repeat_freq' => 'Repetition',
|
||||||
|
'account_from_id' => 'Account from',
|
||||||
|
'account_to_id' => 'Account to',
|
||||||
|
'account_id' => 'Asset account'
|
||||||
|
];
|
||||||
|
|
||||||
|
return isset($labels[$name]) ? $labels[$name] : str_replace('_', ' ', ucfirst($name));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return buttons for update/validate/return.
|
||||||
|
*
|
||||||
|
* @param $type
|
||||||
|
* @param $name
|
||||||
|
*/
|
||||||
|
public static function ffOptionsList($type, $name)
|
||||||
|
{
|
||||||
|
$previousValue = \Input::old('post_submit_action');
|
||||||
|
$previousValue = is_null($previousValue) ? 'store' : $previousValue;
|
||||||
|
/*
|
||||||
|
* Store.
|
||||||
|
*/
|
||||||
|
$store = '';
|
||||||
|
switch ($type) {
|
||||||
|
case 'create':
|
||||||
|
$store = '<div class="form-group"><label for="default" class="col-sm-4 control-label">Store</label>';
|
||||||
|
$store .= '<div class="col-sm-8"><div class="radio"><label>';
|
||||||
|
$store .= \Form::radio('post_submit_action', 'store', $previousValue == 'store');
|
||||||
|
$store .= 'Store ' . $name . '</label></div></div></div>';
|
||||||
|
break;
|
||||||
|
case 'update':
|
||||||
|
$store = '<div class="form-group"><label for="default" class="col-sm-4 control-label">Store</label>';
|
||||||
|
$store .= '<div class="col-sm-8"><div class="radio"><label>';
|
||||||
|
$store .= \Form::radio('post_submit_action', 'update', $previousValue == 'store');
|
||||||
|
$store .= 'Update ' . $name . '</label></div></div></div>';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new FireflyException('Cannot create ffOptionsList for option (store) ' . $type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* validate is always the same:
|
||||||
|
*/
|
||||||
|
$validate = '<div class="form-group"><label for="validate_only" class="col-sm-4 control-label">Validate only';
|
||||||
|
$validate .= '</label><div class="col-sm-8"><div class="radio"><label>';
|
||||||
|
$validate .= \Form::radio('post_submit_action', 'validate_only', $previousValue == 'validate_only');
|
||||||
|
$validate .= 'Only validate, do not save</label></div></div></div>';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Store & return:
|
||||||
|
*/
|
||||||
|
switch ($type) {
|
||||||
|
case 'create':
|
||||||
|
$return = '<div class="form-group"><label for="return_to_form" class="col-sm-4 control-label">';
|
||||||
|
$return .= 'Return here</label><div class="col-sm-8"><div class="radio"><label>';
|
||||||
|
$return .= \Form::radio('post_submit_action', 'create_another', $previousValue == 'create_another');
|
||||||
|
$return .= 'After storing, return here to create another one.</label></div></div></div>';
|
||||||
|
break;
|
||||||
|
case 'update':
|
||||||
|
$return = '<div class="form-group"><label for="return_to_edit" class="col-sm-4 control-label">';
|
||||||
|
$return .= 'Return here</label><div class="col-sm-8"><div class="radio"><label>';
|
||||||
|
$return .= \Form::radio('post_submit_action', 'return_to_edit', $previousValue == 'return_to_edit');
|
||||||
|
$return .= 'After updating, return here.</label></div></div></div>';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new FireflyException('Cannot create ffOptionsList for option (store+return) ' . $type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $store . $validate . $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $type
|
||||||
|
* @param $name
|
||||||
|
* @param null $value
|
||||||
|
* @param array $options
|
||||||
|
* @param array $list
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws FireflyException
|
||||||
|
*/
|
||||||
|
public static function ffInput($type, $name, $value = null, array $options = array(), $list = [])
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* add some defaults to this method:
|
||||||
|
*/
|
||||||
|
$options['class'] = 'form-control';
|
||||||
|
$options['id'] = 'ffInput_' . $name;
|
||||||
|
$options['autocomplete'] = 'off';
|
||||||
|
$label = self::label($name, $options);
|
||||||
|
/*
|
||||||
|
* Make label and placeholder look nice.
|
||||||
|
*/
|
||||||
|
$options['placeholder'] = ucfirst($name);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get prefilled value:
|
||||||
|
*/
|
||||||
|
if (\Session::has('prefilled')) {
|
||||||
|
$prefilled = \Session::get('prefilled');
|
||||||
|
$value = isset($prefilled[$name]) && is_null($value) ? $prefilled[$name] : $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the value.
|
||||||
|
*/
|
||||||
|
if (!is_null(\Input::old($name))) {
|
||||||
|
/*
|
||||||
|
* Old value overrules $value.
|
||||||
|
*/
|
||||||
|
$value = \Input::old($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get errors, warnings and successes from session:
|
||||||
|
*/
|
||||||
|
/** @var MessageBag $errors */
|
||||||
|
$errors = \Session::get('errors');
|
||||||
|
|
||||||
|
/** @var MessageBag $warnings */
|
||||||
|
$warnings = \Session::get('warnings');
|
||||||
|
|
||||||
|
/** @var MessageBag $successes */
|
||||||
|
$successes = \Session::get('successes');
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If errors, add some more classes.
|
||||||
|
*/
|
||||||
|
switch (true) {
|
||||||
|
case (!is_null($errors) && $errors->has($name)):
|
||||||
|
$classes = 'form-group has-error has-feedback';
|
||||||
|
break;
|
||||||
|
case (!is_null($warnings) && $warnings->has($name)):
|
||||||
|
$classes = 'form-group has-warning has-feedback';
|
||||||
|
break;
|
||||||
|
case (!is_null($successes) && $successes->has($name)):
|
||||||
|
$classes = 'form-group has-success has-feedback';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$classes = 'form-group';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Add some HTML.
|
||||||
|
*/
|
||||||
|
$html = '<div class="' . $classes . '">';
|
||||||
|
$html .= '<label for="' . $options['id'] . '" class="col-sm-4 control-label">' . $label . '</label>';
|
||||||
|
$html .= '<div class="col-sm-8">';
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Switch input type:
|
||||||
|
*/
|
||||||
|
unset($options['label']);
|
||||||
|
switch ($type) {
|
||||||
|
case 'text':
|
||||||
|
$html .= \Form::input('text', $name, $value, $options);
|
||||||
|
break;
|
||||||
|
case 'amount':
|
||||||
|
$html .= '<div class="input-group"><div class="input-group-addon">€</div>';
|
||||||
|
$html .= \Form::input('number', $name, $value, $options);
|
||||||
|
$html .= '</div>';
|
||||||
|
break;
|
||||||
|
case 'number':
|
||||||
|
$html .= \Form::input('number', $name, $value, $options);
|
||||||
|
break;
|
||||||
|
case 'checkbox':
|
||||||
|
$checked = $options['checked'];
|
||||||
|
unset($options['checked'], $options['placeholder'], $options['autocomplete'], $options['class']);
|
||||||
|
$html .= '<div class="checkbox"><label>';
|
||||||
|
$html .= \Form::checkbox($name, $value, $checked, $options);
|
||||||
|
$html .= '</label></div>';
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 'date':
|
||||||
|
$html .= \Form::input('date', $name, $value, $options);
|
||||||
|
break;
|
||||||
|
case 'select':
|
||||||
|
$html .= \Form::select($name, $list, $value, $options);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new FireflyException('Cannot handle type "' . $type . '" in FFFormBuilder.');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If errors, respond to them:
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!is_null($errors)) {
|
||||||
|
if ($errors->has($name)) {
|
||||||
|
$html .= '<span class="glyphicon glyphicon-remove form-control-feedback"></span>';
|
||||||
|
$html .= '<p class="text-danger">' . e($errors->first($name)) . '</p>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($errors);
|
||||||
|
/*
|
||||||
|
* If warnings, respond to them:
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!is_null($warnings)) {
|
||||||
|
if ($warnings->has($name)) {
|
||||||
|
$html .= '<span class="glyphicon glyphicon-warning-sign form-control-feedback"></span>';
|
||||||
|
$html .= '<p class="text-warning">' . e($warnings->first($name)) . '</p>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($warnings);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If successes, respond to them:
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!is_null($successes)) {
|
||||||
|
if ($successes->has($name)) {
|
||||||
|
$html .= '<span class="glyphicon glyphicon-ok form-control-feedback"></span>';
|
||||||
|
$html .= '<p class="text-success">' . e($successes->first($name)) . '</p>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($successes);
|
||||||
|
|
||||||
|
$html .= '</div>';
|
||||||
|
$html .= '</div>';
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
121
app/lib/FireflyIII/Shared/SingleTableInheritanceEntity.php
Normal file
121
app/lib/FireflyIII/Shared/SingleTableInheritanceEntity.php
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
<?php
|
||||||
|
namespace FireflyIII\Shared;
|
||||||
|
|
||||||
|
use LaravelBook\Ardent\Ardent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class SingleTableInheritanceEntity
|
||||||
|
*
|
||||||
|
* @package FireflyIII\Shared
|
||||||
|
*/
|
||||||
|
abstract class SingleTableInheritanceEntity extends Ardent
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The field that stores the subclass
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $subclassField = null;
|
||||||
|
/**
|
||||||
|
* must be overridden and set to true in subclasses
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $isSubclass = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $attributes
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Model|static
|
||||||
|
*/
|
||||||
|
public function newFromBuilder($attributes = [])
|
||||||
|
{
|
||||||
|
$instance = $this->mapData((array)$attributes)->newInstance([], true);
|
||||||
|
$instance->setRawAttributes((array)$attributes, true);
|
||||||
|
|
||||||
|
return $instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* if no subclass is defined, function as normal
|
||||||
|
*
|
||||||
|
* @param array $attributes
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Model|static
|
||||||
|
*/
|
||||||
|
public function mapData(array $attributes)
|
||||||
|
{
|
||||||
|
if (!$this->subclassField) {
|
||||||
|
return $this->newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new $attributes[$this->subclassField];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* instead of using $this->newInstance(), call
|
||||||
|
* newInstance() on the object from mapData
|
||||||
|
*
|
||||||
|
* @param bool $excludeDeleted
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder|static
|
||||||
|
*/
|
||||||
|
public function newQuery($excludeDeleted = true)
|
||||||
|
{
|
||||||
|
// If using Laravel 4.0.x then use the following commented version of this command
|
||||||
|
// $builder = new Builder($this->newBaseQueryBuilder());
|
||||||
|
// newEloquentBuilder() was added in 4.1
|
||||||
|
$builder = $this->newEloquentBuilder($this->newBaseQueryBuilder());
|
||||||
|
|
||||||
|
// Once Firefly has the query builders, it will set the model instances so the
|
||||||
|
// builder can easily access any information it may need from the model
|
||||||
|
// while it is constructing and executing various queries against it.
|
||||||
|
$builder->setModel($this)->with($this->with);
|
||||||
|
|
||||||
|
if ($excludeDeleted && $this->softDelete) {
|
||||||
|
$builder->whereNull($this->getQualifiedDeletedAtColumn());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->subclassField && $this->isSubclass()) {
|
||||||
|
$builder->where($this->subclassField, '=', get_class($this));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isSubclass()
|
||||||
|
{
|
||||||
|
return $this->isSubclass;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ensure that the subclass field is assigned on save
|
||||||
|
*
|
||||||
|
* @param array $rules
|
||||||
|
* @param array $customMessages
|
||||||
|
* @param array $options
|
||||||
|
* @param callable $beforeSave
|
||||||
|
* @param callable $afterSave
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function save(
|
||||||
|
array $rules = [],
|
||||||
|
array $customMessages = [],
|
||||||
|
array $options = [],
|
||||||
|
\Closure $beforeSave = null,
|
||||||
|
\Closure $afterSave = null
|
||||||
|
) {
|
||||||
|
if ($this->subclassField) {
|
||||||
|
$this->attributes[$this->subclassField] = get_class($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::save($rules, $customMessages, $options, $beforeSave, $afterSave);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
use Firefly\Database\SingleTableInheritanceEntity;
|
use FireflyIII\Shared\SingleTableInheritanceEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component
|
* Component
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use FireflyIII\Exception\FireflyException;
|
||||||
use LaravelBook\Ardent\Ardent as Ardent;
|
use LaravelBook\Ardent\Ardent as Ardent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,10 +84,7 @@ class LimitRepetition extends Ardent
|
|||||||
}
|
}
|
||||||
switch ($this->repeat_freq) {
|
switch ($this->repeat_freq) {
|
||||||
default:
|
default:
|
||||||
throw new \Firefly\Exception\FireflyException(
|
throw new FireflyException('No date formats for frequency "' . $this->repeat_freq . '"!');
|
||||||
'No date formats for frequency "' . $this->repeat_freq
|
|
||||||
. '"!'
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case 'daily':
|
case 'daily':
|
||||||
return $this->startdate->format('Ymd') . '-5';
|
return $this->startdate->format('Ymd') . '-5';
|
||||||
@ -119,10 +117,7 @@ class LimitRepetition extends Ardent
|
|||||||
}
|
}
|
||||||
switch ($this->repeat_freq) {
|
switch ($this->repeat_freq) {
|
||||||
default:
|
default:
|
||||||
throw new \Firefly\Exception\FireflyException(
|
throw new FireflyException('No date formats for frequency "' . $this->repeat_freq . '"!');
|
||||||
'No date formats for frequency "' . $this->repeat_freq
|
|
||||||
. '"!'
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case 'daily':
|
case 'daily':
|
||||||
return $this->startdate->format('j F Y');
|
return $this->startdate->format('j F Y');
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Firefly\Database\SingleTableInheritanceEntity;
|
|
||||||
use LaravelBook\Ardent\Ardent;
|
use LaravelBook\Ardent\Ardent;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Exception\NotImplementedException;
|
||||||
use LaravelBook\Ardent\Ardent;
|
use LaravelBook\Ardent\Ardent;
|
||||||
use LaravelBook\Ardent\Builder;
|
use LaravelBook\Ardent\Builder;
|
||||||
|
|
||||||
@ -64,18 +65,19 @@ class Transaction extends Ardent
|
|||||||
*/
|
*/
|
||||||
public function connectPiggybank(\Piggybank $piggybank = null)
|
public function connectPiggybank(\Piggybank $piggybank = null)
|
||||||
{
|
{
|
||||||
if (is_null($piggybank)) {
|
throw new NotImplementedException;
|
||||||
return true;
|
// if (is_null($piggybank)) {
|
||||||
}
|
// return true;
|
||||||
/** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */
|
// }
|
||||||
$piggyRepository = \App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
|
// /** @var \Firefly\Storage\Piggybank\PiggybankRepositoryInterface $piggyRepository */
|
||||||
if ($this->account_id == $piggybank->account_id) {
|
// $piggyRepository = \App::make('Firefly\Storage\Piggybank\PiggybankRepositoryInterface');
|
||||||
$this->piggybank()->associate($piggybank);
|
// if ($this->account_id == $piggybank->account_id) {
|
||||||
$this->save();
|
// $this->piggybank()->associate($piggybank);
|
||||||
\Event::fire('piggybanks.createRelatedTransfer', [$piggybank, $this->transactionJournal, $this]);
|
// $this->save();
|
||||||
return true;
|
// \Event::fire('piggybanks.createRelatedTransfer', [$piggybank, $this->transactionJournal, $this]);
|
||||||
}
|
// return true;
|
||||||
return false;
|
// }
|
||||||
|
// return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,47 +74,47 @@ App::down(
|
|||||||
// forms:
|
// forms:
|
||||||
\Form::macro(
|
\Form::macro(
|
||||||
'ffText', function ($name, $value = null, array $options = []) {
|
'ffText', function ($name, $value = null, array $options = []) {
|
||||||
return \Firefly\Form\Form::ffText($name, $value, $options);
|
return \FireflyIII\Form\Form::ffText($name, $value, $options);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
\Form::macro(
|
\Form::macro(
|
||||||
'ffSelect', function ($name, array $list = [], $selected = null, array $options = []) {
|
'ffSelect', function ($name, array $list = [], $selected = null, array $options = []) {
|
||||||
return \Firefly\Form\Form::ffSelect($name, $list, $selected, $options);
|
return \FireflyIII\Form\Form::ffSelect($name, $list, $selected, $options);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
\Form::macro(
|
\Form::macro(
|
||||||
'ffInteger', function ($name, $value = null, array $options = []) {
|
'ffInteger', function ($name, $value = null, array $options = []) {
|
||||||
return \Firefly\Form\Form::ffInteger($name, $value, $options);
|
return \FireflyIII\Form\Form::ffInteger($name, $value, $options);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
\Form::macro(
|
\Form::macro(
|
||||||
'ffAmount', function ($name, $value = null, array $options = []) {
|
'ffAmount', function ($name, $value = null, array $options = []) {
|
||||||
return \Firefly\Form\Form::ffAmount($name, $value, $options);
|
return \FireflyIII\Form\Form::ffAmount($name, $value, $options);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
\Form::macro(
|
\Form::macro(
|
||||||
'ffBalance', function ($name, $value = null, array $options = []) {
|
'ffBalance', function ($name, $value = null, array $options = []) {
|
||||||
return \Firefly\Form\Form::ffBalance($name, $value, $options);
|
return \FireflyIII\Form\Form::ffBalance($name, $value, $options);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
\Form::macro(
|
\Form::macro(
|
||||||
'ffDate', function ($name, $value = null, array $options = []) {
|
'ffDate', function ($name, $value = null, array $options = []) {
|
||||||
return \Firefly\Form\Form::ffDate($name, $value, $options);
|
return \FireflyIII\Form\Form::ffDate($name, $value, $options);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
\Form::macro(
|
\Form::macro(
|
||||||
'ffTags', function ($name, $value = null, array $options = []) {
|
'ffTags', function ($name, $value = null, array $options = []) {
|
||||||
return \Firefly\Form\Form::ffTags($name, $value, $options);
|
return \FireflyIII\Form\Form::ffTags($name, $value, $options);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
\Form::macro(
|
\Form::macro(
|
||||||
'ffCheckbox', function ($name, $value = 1, $checked = null, $options = []) {
|
'ffCheckbox', function ($name, $value = 1, $checked = null, $options = []) {
|
||||||
return \Firefly\Form\Form::ffCheckbox($name, $value, $checked, $options);
|
return \FireflyIII\Form\Form::ffCheckbox($name, $value, $checked, $options);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
\Form::macro(
|
\Form::macro(
|
||||||
'ffOptionsList', function ($type, $name) {
|
'ffOptionsList', function ($type, $name) {
|
||||||
return \Firefly\Form\Form::ffOptionsList($type, $name);
|
return \FireflyIII\Form\Form::ffOptionsList($type, $name);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
|||||||
* Creates the application.
|
* Creates the application.
|
||||||
*
|
*
|
||||||
* @return \Symfony\Component\HttpKernel\HttpKernelInterface
|
* @return \Symfony\Component\HttpKernel\HttpKernelInterface
|
||||||
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
|
|
||||||
*/
|
*/
|
||||||
public function createApplication()
|
public function createApplication()
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,8 @@
|
|||||||
<i class="fa {{$subTitleIcon}}"></i> {{{$subTitle}}}
|
<i class="fa {{$subTitleIcon}}"></i> {{{$subTitle}}}
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<table id="transactionTable" class="table table-striped table-bordered" >
|
<div id="transactionList"></div>
|
||||||
|
<!--<table id="transactionTable" class="table table-striped table-bordered" >
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
@ -19,7 +20,7 @@
|
|||||||
<th>ID</th>
|
<th>ID</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>-->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -29,14 +30,7 @@
|
|||||||
@stop
|
@stop
|
||||||
@section('scripts')
|
@section('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var URL = '{{route('json.'.$what)}}';
|
|
||||||
var display = '{{{$what}}}';
|
var display = '{{{$what}}}';
|
||||||
</script>
|
</script>
|
||||||
{{HTML::script('assets/javascript/typeahead/bootstrap3-typeahead.min.js')}}
|
|
||||||
{{HTML::script('assets/javascript/datatables/jquery.dataTables.min.js')}}
|
|
||||||
{{HTML::script('assets/javascript/datatables/dataTables.bootstrap.js')}}
|
|
||||||
{{HTML::script('assets/javascript/firefly/transactions.js')}}
|
{{HTML::script('assets/javascript/firefly/transactions.js')}}
|
||||||
@stop
|
@stop
|
||||||
@section('styles')
|
|
||||||
{{HTML::style('assets/stylesheets/datatables/dataTables.bootstrap.css')}}
|
|
||||||
@stop
|
|
@ -11,7 +11,7 @@
|
|||||||
Registering an account on Firefly requires an e-mail address.
|
Registering an account on Firefly requires an e-mail address.
|
||||||
All instructions will be sent to you.
|
All instructions will be sent to you.
|
||||||
</p>
|
</p>
|
||||||
{{Form::open()}}
|
{{Form::open(['id' => 'register'])}}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="inputEmail">Email address</label>
|
<label for="inputEmail">Email address</label>
|
||||||
<input type="email" class="form-control" id="inputEmail" name="email" placeholder="Enter email">
|
<input type="email" class="form-control" id="inputEmail" name="email" placeholder="Enter email">
|
||||||
|
@ -15,108 +15,5 @@ if ($('input[name="category"]').length > 0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('#transactionTable').DataTable(
|
|
||||||
{
|
|
||||||
serverSide: true,
|
|
||||||
ajax: URL,
|
|
||||||
paging: true,
|
|
||||||
processing: true,
|
|
||||||
order: [],
|
|
||||||
"lengthMenu": [[50, 100, 250, -1], [50, 100, 250, "All"]],
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
name: 'date',
|
|
||||||
data: 'date',
|
|
||||||
searchable: false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'description',
|
|
||||||
data: 'description',
|
|
||||||
render: function (data, type, full, meta) {
|
|
||||||
var icon = '';
|
|
||||||
if (display == 'expenses') {
|
|
||||||
icon = 'glyphicon-arrow-left';
|
|
||||||
}
|
|
||||||
if (display == 'revenue') {
|
|
||||||
icon = 'glyphicon-arrow-right';
|
|
||||||
}
|
|
||||||
if (display == 'transfers') {
|
|
||||||
icon = 'glyphicon-resize-full';
|
|
||||||
}
|
|
||||||
|
|
||||||
return '<span class="glyphicon ' + icon + '"></span> ' +
|
|
||||||
'<a href="' + data.url + '" title="' + data.description + '">' + data.description + '</a>';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'amount',
|
|
||||||
data: 'amount',
|
|
||||||
'title': 'Amount (\u20AC)',
|
|
||||||
searchable: false,
|
|
||||||
render: function (data, type, full, meta) {
|
|
||||||
if (display == 'expenses') {
|
|
||||||
return '<span class="text-danger">\u20AC ' + data.toFixed(2) + '</span>';
|
|
||||||
}
|
|
||||||
if (display == 'revenue') {
|
|
||||||
return '<span class="text-success">\u20AC ' + data.toFixed(2) + '</span>';
|
|
||||||
}
|
|
||||||
if (display == 'transfers') {
|
|
||||||
return '<span class="text-info">\u20AC ' + data.toFixed(2) + '</span>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'from',
|
|
||||||
data: 'from',
|
|
||||||
searchable: false,
|
|
||||||
render: function (data, type, full, meta) {
|
|
||||||
return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'to',
|
|
||||||
data: 'to',
|
|
||||||
searchable: false,
|
|
||||||
render: function (data, type, full, meta) {
|
|
||||||
return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'components',
|
|
||||||
data: 'components',
|
|
||||||
searchable: true,
|
|
||||||
sortable: false,
|
|
||||||
title: '',
|
|
||||||
render: function (data, type, full, meta) {
|
|
||||||
var html = '';
|
|
||||||
if (data.budget_id > 0) {
|
|
||||||
html += '<a href="' + data.budget_url + '" title="' + data.budget_name + '"><i class="fa fa-tasks fa-fw"></i></a> ';
|
|
||||||
}
|
|
||||||
if (data.category_id > 0) {
|
|
||||||
html += '<a href="' + data.category_url + '" title="' + data.category_name + '"><i class="fa fa-bar-chart fa-fw"></i></a> ';
|
|
||||||
}
|
|
||||||
if(data.recurring_id > 0) {
|
|
||||||
html += '<a href="' + data.recurring_url + '" title="' + data.recurring_name + '"><i class="fa fa-rotate-right fa-fw"></i></a> ';
|
|
||||||
}
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'id',
|
|
||||||
data: 'id',
|
|
||||||
searchable: false,
|
|
||||||
sortable: false,
|
|
||||||
title: '',
|
|
||||||
render: function (data, type, full, meta) {
|
|
||||||
return '<div class="btn-group btn-group-xs">' +
|
|
||||||
'<a class="btn btn-default btn-xs" href="' + data.edit + '">' +
|
|
||||||
'<span class="glyphicon glyphicon-pencil"</a>' +
|
|
||||||
'<a class="btn btn-danger btn-xs" href="' + data.delete + '">' +
|
|
||||||
'<span class="glyphicon glyphicon-trash"</a>' +
|
|
||||||
'</a></div>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user