[ PHPXref.com ] [ Generated: Sun Jul 20 19:13:40 2008 ] [ osCommRes 1.2.0 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/includes/functions/ -> wallet_general.php (source)

   1  <?php
   2  /*

   3    osCommRes, Services Online

   4    http://www.oscommres.com

   5  

   6    Copyright (c) 2005 osCommRes

   7  

   8    Released under the GNU General Public License

   9  */
  10  
  11  // To Find the users wallet balance

  12  	function tep_get_wallet_balance($customer_id){
  13      
  14          //total of amount uploads

  15          $upload_query=tep_db_query("select sum(amount) as upload_total from ". TABLE_WALLET_UPLOADS. " where customers_id='" . $customer_id . "'  and payment_status>1");
  16          $upload_result=tep_db_fetch_array($upload_query);
  17          $upload_total=$upload_result['upload_total'];
  18  
  19          // total of amount drawn

  20          $drawn_query=tep_db_query("select sum(amount) as drawn_total from ". TABLE_WALLET_HISTORY. " where customers_id='" . $customer_id . "'");
  21          $drawn_result=tep_db_fetch_array($drawn_query);
  22          $drawn_total=$drawn_result['drawn_total'];
  23          
  24          return $upload_total-$drawn_total;
  25      }
  26  
  27  	function tep_get_wallet_min_balance($customers_id){
  28          $amount=(int) WALLET_MINIMUM_AMOUNT;
  29          $type=WALLET_MINIMUM_TYPE;
  30          if ($type=="P"){ // percentage of last 3 orders
  31              $order_sql="SELECT count(*) as orders_count,sum(value) as total from " . TABLE_WALLET_HISTORY . " wh, " . TABLE_ORDERS_TOTAL . " ot where wh.customers_id='" . $customers_id . "' " .
  32                          " and wh.orders_id=ot.orders_id order by wh.drawn_date limit 3";
  33              $order_query=tep_db_query($order_sql);
  34              $order_result=tep_db_fetch_array($order_query);
  35              if ($order_result["orders_count"]>0 && $order_result["total"]>0){
  36                  $final_amount=($order_result["total"]/$order_result["orders_count"])* WALLET_MINIMUM_AMOUNT/100;
  37              } else {
  38                  $type="C";
  39              }
  40          }
  41          if ($type!="P") $final_amount=$amount;
  42          
  43          return $final_amount;
  44      }
  45      
  46  	function tep_count_wallet_uploads() {
  47          global $customer_id;
  48  
  49          $wallet_upload_query = tep_db_query("select count(*) as total from " . TABLE_WALLET_UPLOADS . " where customers_id = '" . (int)$customer_id . "'");
  50          $wallet_upload = tep_db_fetch_array($wallet_upload_query);
  51  
  52          return $wallet_upload['total'];
  53    }
  54  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]