/** * Count money. * * @param array $trades * @access public * @return array */ public function countMoney($trades, $mode) { $totalMoney = array(); $currencyList = $this->loadModel('common', 'sys')->getCurrencyList(); foreach ($currencyList as $key => $currency) { $totalMoney[$key]['in'] = 0; $totalMoney[$key]['out'] = 0; foreach ($trades as $trade) { if ($trade->currency != $key) { continue; } if ($trade->type == 'in' or $trade->type == 'out') { $totalMoney[$key][$trade->type] += $trade->money; } } } foreach ($totalMoney as $currency => $money) { if ($money['in'] == 0 and $money['out'] == 0) { continue; } $tidyMoneyIn = "<span title='" . $money['in'] . "'>" . commonModel::tidyMoney($money['in']) . '</span>'; $tidyMoneyOut = "<span title='" . $money['out'] . "'>" . commonModel::tidyMoney($money['out']) . '</span>'; if ($mode == 'in') { printf($this->lang->trade->totalIn, $currencyList[$currency], $tidyMoneyIn); } if ($mode == 'out') { printf($this->lang->trade->totalOut, $currencyList[$currency], $tidyMoneyOut); } if ($mode == 'all' or $mode == 'bysearch') { $profitsMoney = $money['in'] - $money['out']; if ($profitsMoney > 0) { $profits = "<span title='{$profitsMoney}'>" . $this->lang->trade->profit . commonModel::tidyMoney($profitsMoney) . '</span>'; } if ($profitsMoney < 0) { $profits = "<span title='" . -$profitsMoney . "'>" . $this->lang->trade->loss . commonModel::tidyMoney(-$profitsMoney) . '</span>'; } if ($profitsMoney == 0) { $profits = $this->lang->trade->balance; } printf($this->lang->trade->totalAmount, $currencyList[$currency], $tidyMoneyIn, $tidyMoneyOut, $profits); } } }
/** * Count amount. * * @param array $purchases * @access public * @return array */ public function countAmount($purchases) { $totalAmount = array(); $currencyList = $this->loadModel('common', 'sys')->getCurrencyList(); $currencySign = $this->common->getCurrencySign(); $totalReturn = $this->dao->select('*')->from(TABLE_PLAN)->fetchGroup('contract'); foreach ($purchases as $purchase) { if ($purchase->status == 'canceled') { continue; } foreach ($currencyList as $key => $currency) { if ($purchase->currency == $key) { if (!isset($totalAmount['purchase'][$key])) { $totalAmount['purchase'][$key] = 0; } if (!isset($totalAmount['return'][$key])) { $totalAmount['return'][$key] = 0; } $totalAmount['purchase'][$key] += $purchase->amount; if (isset($totalReturn[$purchase->id])) { foreach ($totalReturn[$purchase->id] as $return) { $totalAmount['return'][$key] += $return->amount; } } } } } foreach ($totalAmount as $type => $currencyAmount) { foreach ($currencyAmount as $currency => $amount) { $totalAmount[$type][$currency] = "<span title='{$amount}'>" . $currencySign[$currency] . commonModel::tidyMoney($amount) . "</span>"; } } return $totalAmount; }
<?php foreach ($balances as $currency => $balanceList) { ?> <?php $sum = 0; ?> <?php foreach ($balanceList as $balance) { $sum += $balance->money; } ?> <div class='pull-right'><strong class='text-danger' title='<?php echo $sum; ?> '><?php echo $currencyList[$currency] . $lang->colon . commonModel::tidyMoney($sum); ?> </strong></div> <?php } ?> <?php } ?> </div> <div class='panel-body'> <div class="cards"> <?php foreach ($depositors as $depositor) { ?> <div class='col-md-4 col-sm-6'>