Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2330

Přidáno uživatelem David Raška před asi 10 roky(ů)

Upravy:
- fixes #870: Formatovani castky v seznamu poplatku jako castky, oprava callback::money aby zobrazoval i 0 Kč

Zobrazit rozdíly:

freenetis/branches/1.2/application/controllers/fees.php
$grid->order_callback_field('name')
->callback(array($this, 'name_field'));
$grid->order_field('fee');
$grid->order_callback_field('fee')
->callback('callback::money', 'print_zero');
$grid->order_field('from')
->label(__('Date from'));
freenetis/branches/1.2/application/helpers/callback.php
}
}
/**
* Callback for money, gets price from property with name given by args.
*
* @author Ondrej Fibich
* @param object $item
* @param string $name
*/
public static function money($item, $name)
{
if (empty($item->$name))
{
return; // NULL value
}
$price = number_format($item->$name, 2, ',', ' ') . ' ';
$price = str_replace(' ', ' ', $price);
// has currency?
if (property_exists($item, 'currency'))
{
$price .= __($item->currency);
}
// default currency
else
{
$price .= __(Settings::get('currency'));
}
// has transfer?
if (Settings::get('finance_enabled') && property_exists($item, 'transfer_id') && $item->transfer_id)
{
echo html::anchor('transfers/show/' . $item->transfer_id, $price);
}
// just price
else
{
echo $price;
}
/**
* Callback for money, gets price from property with name given by args.
*
* @author Ondrej Fibich, Honza Dubina
* @param object $item
* @param string $name
* @param array $args
* no_transfer - do not print link to transfer
* round - custom rounding according to rounding type property
* print_zero - prints zero price with correct formating
*/
public static function money($item, $name, $args = array())
{
if (in_array('print_zero', $args))
{
if (is_null($item->$name))
return; // NULL value
}
else
{
if (empty($item->$name))
return; // 0 value
}
$price = $item->$name;
// has rounding type?
if (property_exists($item, 'rounding_type') &&
in_array('round', $args))
{
$price = Invoices_Controller::round_price($price, $item->rounding_type);
}
else
{
$price = round($price, 2);
}
$price = number_format($price, 2, ',', ' ') . ' ';
$price = str_replace(' ', ' ', $price);
// has currency?
if (property_exists($item, 'currency'))
{
$price .= __($item->currency);
}
// default currency
else
{
$price .= __(Settings::get('currency'));
}
// has transfer?
if (Settings::get('finance_enabled') &&
property_exists($item, 'transfer_id') && $item->transfer_id &&
!in_array('no_transfer', $args))
{
echo html::anchor('transfers/show/' . $item->transfer_id, $price);
}
// just price
else
{
echo $price;
}
}
/**

Také k dispozici: Unified diff