Beispiel #1
0
 function getDataAll($user_id, $from_date, $to_date)
 {
     $cur_mod = new Application_Model_DbTable_DbCurrencies();
     $usr_mod = new Application_Model_DbTable_DbUsers();
     $rsCur = $cur_mod->getCurrencyList();
     $rsUser = null;
     $tmp_summary = null;
     $return_araray = array();
     if ($user_id == -1) {
         $rsUser = $usr_mod->getUserListSelect();
         if (!empty($rsCur)) {
             $tmp_summary = array();
             foreach ($rsCur as $k => $rc) {
                 $cur_type = $rc['symbol'];
                 $bought = $this->sumValue($cur_type, null, "in", $from_date, $to_date);
                 $sale = $this->sumValue($cur_type, null, "out", $from_date, $to_date);
                 $tmp_summary[$k]['saleamount'] = $sale;
                 $tmp_summary[$k]['boughtamount'] = $bought;
                 $tmp_summary[$k]['currncytype'] = $rc['name'];
                 $tmp_summary[$k]['currncysymbol'] = $cur_type;
             }
             $return_araray['summary'] = $tmp_summary;
         }
     } else {
         $rsUser = $usr_mod->getUserInfoByfetchAll($user_id);
     }
     //print_r($return_araray); exit();
     if (!empty($rsUser)) {
         $tmp_data = array();
         $row_index = 0;
         foreach ($rsUser as $i => $ru) {
             if (empty($rsCur)) {
                 break;
             }
             foreach ($rsCur as $k => $rc) {
                 $cur_type = $rc['symbol'];
                 $bought = $this->sumValue($cur_type, $ru['id'], "in", $from_date, $to_date);
                 $sale = $this->sumValue($cur_type, $ru['id'], "out", $from_date, $to_date);
                 if ($bought != 0 || $sale != 0) {
                     $tmp_data[$row_index]['username'] = $ru['name'];
                     $tmp_data[$row_index]['userid'] = $ru['id'];
                     $tmp_data[$row_index]['saleamount'] = $sale;
                     $tmp_data[$row_index]['boughtamount'] = $bought;
                     $tmp_data[$row_index]['currncytype'] = $rc['name'];
                     $tmp_data[$row_index]['currncysymbol'] = $cur_type;
                     $row_index++;
                 }
             }
         }
         if (!empty($tmp_data)) {
             $return_araray['data'] = $tmp_data;
         }
     }
     return $return_araray;
 }