Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2498

Přidáno uživatelem David Raška před více než 9 roky(ů)

Novinky:
Zobrazeni aktualniho kreditu v dobe prevodu na podvojnem uctu

Zobrazit rozdíly:

freenetis/branches/1.2/application/controllers/transfers.php
* @param string $order_by_direction
*/
public function show_by_account(
$account_id = NULL, $limit_results = 500, $order_by = 'datetime',
$account_id = NULL, $limit_results = 500, $order_by = 'id',
$order_by_direction = 'desc', $page_word = null, $page = 1)
{
if (!isset($account_id))
......
$transfers_grid->order_callback_field('amount')
->label(__('Amount'))
->callback('callback::amount_field');
$transfers_grid->callback_field('id')
->label('Current credit')
->callback('callback::amount_after_transfer_field', $account_id);
$transfers_grid->order_field('text')
->label(__('Text'));
freenetis/branches/1.2/application/helpers/callback.php
echo $item->amount;
}
}
/**
* @author David Raska
* @param $item
* @param $name
*/
public static function amount_after_transfer_field($item, $name , $args = array())
{
static $tm = null;
if ($tm == null)
{
$tm = new Transfer_Model();
}
if (!isset($args[0]))
{
return;
}
$sum = $tm->sum_transfers_to_id($args[0], $item->id);
if ($sum > 0)
{
echo '<span style="color:green">'
. number_format((float)$sum, 2, ',', ' ')
. '</span>';
}
else if ($sum < 0)
{
echo '<span style="color:red">'
. number_format((float)$sum, 2, ',', ' ')
. '</span>';
}
else
{
echo $sum;
}
}
/**
* API account log type callback - simply prints name of type.
freenetis/branches/1.2/application/models/transfer.php
LIMIT ".intval($limit_from).", ".intval($limit_results)."
");
}
/**
* Function gets all money transfers of double-entry account.
* @param $account_id
* @param $limit_from
* @param $limit_results
* @param $order_by
* @param $order_by_direction
* @return Mysql_Result
*/
public function sum_transfers_to_id($account_id = null, $toid)
{
$account_id = intval($account_id);
// query
return $this->db->query("
SELECT
SUM(IF(t.destination_id = $account_id, t.amount, 0)) -
SUM(IF(t.origin_id = $account_id, t.amount, 0)) AS amount
FROM transfers t
WHERE t.id <= ?
", $toid, $toid)->current()->amount;
}
/**
* Function gets all money transfers of double-entry account.

Také k dispozici: Unified diff