Sort by alphabet.

This commit is contained in:
James Cole
2016-01-20 15:23:36 +01:00
parent c84f4e2bc0
commit c9e4a09da6
11 changed files with 713 additions and 720 deletions

View File

@@ -17,6 +17,17 @@ use Preferences as Prefs;
class Amount
{
/**
* @param $amount
* @param bool $coloured
*
* @return string
*/
public function format($amount, $coloured = true)
{
return $this->formatAnything($this->getDefaultCurrency(), $amount, $coloured);
}
/**
* This method will properly format the given number, in color or "black and white",
* as a currency, given two things: the currency required and the current locale.
@@ -48,48 +59,6 @@ class Amount
return $result;
}
/**
* @param $amount
* @param bool $coloured
*
* @return string
*/
public function format($amount, $coloured = true)
{
return $this->formatAnything($this->getDefaultCurrency(), $amount, $coloured);
}
/**
* @return string
*/
public function getCurrencySymbol()
{
$cache = new CacheProperties;
$cache->addProperty('getCurrencySymbol');
if ($cache->has()) {
return $cache->get();
} else {
$currencyPreference = Prefs::get('currencyPreference', env('DEFAULT_CURRENCY', 'EUR'));
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
$cache->store($currency->symbol);
return $currency->symbol;
}
}
/**
* @param string $symbol
* @param float $amount
* @param bool $coloured
*
* @return string
*/
public function formatWithSymbol($symbol, $amount, $coloured = true)
{
return $this->formatAnything($this->getDefaultCurrency(), $amount, $coloured);
}
/**
*
* @param TransactionJournal $journal
@@ -139,6 +108,18 @@ class Amount
return $this->formatAnything($currency, $transaction->amount, $coloured);
}
/**
* @param string $symbol
* @param float $amount
* @param bool $coloured
*
* @return string
*/
public function formatWithSymbol($symbol, $amount, $coloured = true)
{
return $this->formatAnything($this->getDefaultCurrency(), $amount, $coloured);
}
/**
* @return Collection
*/
@@ -173,6 +154,25 @@ class Amount
}
}
/**
* @return string
*/
public function getCurrencySymbol()
{
$cache = new CacheProperties;
$cache->addProperty('getCurrencySymbol');
if ($cache->has()) {
return $cache->get();
} else {
$currencyPreference = Prefs::get('currencyPreference', env('DEFAULT_CURRENCY', 'EUR'));
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
$cache->store($currency->symbol);
return $currency->symbol;
}
}
/**
* @return TransactionCurrency
*/

View File

@@ -71,6 +71,14 @@ class CacheProperties
return Cache::has($this->md5);
}
/**
* @param $data
*/
public function store($data)
{
Cache::forever($this->md5, $data);
}
/**
* @return void
*/
@@ -95,12 +103,4 @@ class CacheProperties
$this->md5 = md5($this->md5);
}
/**
* @param $data
*/
public function store($data)
{
Cache::forever($this->md5, $data);
}
}

View File

@@ -19,25 +19,6 @@ use Session;
class ExpandedForm
{
/**
* @param $name
* @param null $value
* @param array $options
*
* @return string
*/
public function staticText($name, $value, array $options = [])
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
$classes = $this->getHolderClasses($name);
$value = $this->fillFieldValue($name, $value);
$html = view('form.static', compact('classes', 'name', 'label', 'value', 'options'))->render();
return $html;
}
/**
* @param $name
* @param null $value
@@ -63,86 +44,6 @@ class ExpandedForm
}
/**
* @param $name
* @param $options
*
* @return mixed
*/
protected function label($name, $options)
{
if (isset($options['label'])) {
return $options['label'];
}
return trans('form.' . $name);
}
/**
* @param $name
* @param $label
* @param array $options
*
* @return array
*/
protected function expandOptionArray($name, $label, array $options)
{
$options['class'] = 'form-control';
$options['id'] = 'ffInput_' . $name;
$options['autocomplete'] = 'off';
$options['placeholder'] = ucfirst($label);
return $options;
}
/**
* @param $name
*
* @return string
*/
protected function getHolderClasses($name)
{
/*
* Get errors from session:
*/
/** @var MessageBag $errors */
$errors = Session::get('errors');
$classes = 'form-group';
if (!is_null($errors) && $errors->has($name)) {
$classes = 'form-group has-error has-feedback';
}
return $classes;
}
/**
* @param $name
* @param $value
*
* @return mixed
*/
protected function fillFieldValue($name, $value)
{
if (Session::has('preFilled')) {
$preFilled = Session::get('preFilled');
$value = isset($preFilled[$name]) && is_null($value) ? $preFilled[$name] : $value;
}
// @codeCoverageIgnoreStart
try {
if (!is_null(Input::old($name))) {
$value = Input::old($name);
}
} catch (RuntimeException $e) {
// don't care about session errors.
}
// @codeCoverageIgnoreEnd
return $value;
}
/**
* @param $name
* @param null $value
@@ -208,6 +109,23 @@ class ExpandedForm
return $html;
}
/**
* @param $name
* @param array $options
*
* @return string
*/
public function file($name, array $options = [])
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
$classes = $this->getHolderClasses($name);
$html = view('form.file', compact('classes', 'name', 'label', 'options'))->render();
return $html;
}
/**
* @param $name
* @param null $value
@@ -366,6 +284,25 @@ class ExpandedForm
return $html;
}
/**
* @param $name
* @param null $value
* @param array $options
*
* @return string
*/
public function staticText($name, $value, array $options = [])
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
$classes = $this->getHolderClasses($name);
$value = $this->fillFieldValue($name, $value);
$html = view('form.static', compact('classes', 'name', 'label', 'value', 'options'))->render();
return $html;
}
/**
* @param $name
* @param null $value
@@ -385,23 +322,6 @@ class ExpandedForm
return $html;
}
/**
* @param $name
* @param array $options
*
* @return string
*/
public function file($name, array $options = [])
{
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
$classes = $this->getHolderClasses($name);
$html = view('form.file', compact('classes', 'name', 'label', 'options'))->render();
return $html;
}
/**
* @param $name
* @param null $value
@@ -440,4 +360,84 @@ class ExpandedForm
return $html;
}
/**
* @param $name
* @param $label
* @param array $options
*
* @return array
*/
protected function expandOptionArray($name, $label, array $options)
{
$options['class'] = 'form-control';
$options['id'] = 'ffInput_' . $name;
$options['autocomplete'] = 'off';
$options['placeholder'] = ucfirst($label);
return $options;
}
/**
* @param $name
* @param $value
*
* @return mixed
*/
protected function fillFieldValue($name, $value)
{
if (Session::has('preFilled')) {
$preFilled = Session::get('preFilled');
$value = isset($preFilled[$name]) && is_null($value) ? $preFilled[$name] : $value;
}
// @codeCoverageIgnoreStart
try {
if (!is_null(Input::old($name))) {
$value = Input::old($name);
}
} catch (RuntimeException $e) {
// don't care about session errors.
}
// @codeCoverageIgnoreEnd
return $value;
}
/**
* @param $name
*
* @return string
*/
protected function getHolderClasses($name)
{
/*
* Get errors from session:
*/
/** @var MessageBag $errors */
$errors = Session::get('errors');
$classes = 'form-group';
if (!is_null($errors) && $errors->has($name)) {
$classes = 'form-group has-error has-feedback';
}
return $classes;
}
/**
* @param $name
* @param $options
*
* @return mixed
*/
protected function label($name, $options)
{
if (isset($options['label'])) {
return $options['label'];
}
return trans('form.' . $name);
}
}

View File

@@ -13,16 +13,6 @@ use FireflyIII\Models\Preference;
*/
class Preferences
{
/**
* @return string
*/
public function lastActivity()
{
$preference = $this->get('lastActivity', microtime())->data;
return md5($preference);
}
/**
* @param string $name
* @param string $default
@@ -53,6 +43,26 @@ class Preferences
}
/**
* @return string
*/
public function lastActivity()
{
$preference = $this->get('lastActivity', microtime())->data;
return md5($preference);
}
/**
* @return bool
*/
public function mark()
{
$this->set('lastActivity', microtime());
return true;
}
/**
* @param $name
* @param string $value
@@ -80,14 +90,4 @@ class Preferences
return $pref;
}
/**
* @return bool
*/
public function mark()
{
$this->set('lastActivity', microtime());
return true;
}
}

View File

@@ -16,27 +16,6 @@ use FireflyIII\Models\Transaction;
class Steam
{
/**
* @param array $accounts
*
* @return array
*/
public function getLastActivities(array $accounts)
{
$list = [];
$set = Auth::user()->transactions()
->whereIn('account_id', $accounts)
->groupBy('account_id')
->get(['transactions.account_id', DB::raw('MAX(`transaction_journals`.`date`) as `max_date`')]);
foreach ($set as $entry) {
$list[intval($entry->account_id)] = new Carbon($entry->max_date);
}
return $list;
}
/**
*
* @param \FireflyIII\Models\Account $account
@@ -163,7 +142,29 @@ class Steam
return $result;
}
/**
* @param array $accounts
*
* @return array
*/
public function getLastActivities(array $accounts)
{
$list = [];
$set = Auth::user()->transactions()
->whereIn('account_id', $accounts)
->groupBy('account_id')
->get(['transactions.account_id', DB::raw('MAX(`transaction_journals`.`date`) as `max_date`')]);
foreach ($set as $entry) {
$list[intval($entry->account_id)] = new Carbon($entry->max_date);
}
return $list;
}
// parse PHP size:
/**
* @param $string
*