Ejemplo n.º 1
0
Archivo: model.php Proyecto: leowh/crm
 /**
  * Count amount.
  * 
  * @param  array  $orders 
  * @param  string $type 
  * @access public
  * @return array
  */
 public function countAmount($orders)
 {
     $totalAmount = array();
     $currencyList = $this->loadModel('common', 'sys')->getCurrencyList();
     $currencySign = $this->common->getCurrencySign();
     foreach ($orders as $order) {
         if ($order->status == 'closed' and $order->closedReason != 'payed') {
             continue;
         }
         foreach ($currencyList as $key => $currency) {
             if ($order->currency == $key) {
                 if (!isset($totalAmount['plan'][$key])) {
                     $totalAmount['plan'][$key] = 0;
                 }
                 if (!isset($totalAmount['real'][$key])) {
                     $totalAmount['real'][$key] = 0;
                 }
                 $totalAmount['plan'][$key] += $order->plan;
                 $totalAmount['real'][$key] += $order->real;
             }
         }
     }
     foreach ($totalAmount as $type => $currencyAmount) {
         foreach ($currencyAmount as $currency => $amount) {
             $totalAmount[$type][$currency] = "<span title='{$amount}'>" . $currencySign[$currency] . commonModel::tidyMOney($amount) . "</span>";
         }
     }
     return $totalAmount;
 }