<?php

/**
 * core\lib\broker\BrokerGroup.php
 */

/**
 * 经纪人权限组积分和成长值情况
 *
 * @author xue
 */
class BrokerGroup {
    //put your code here    
    private $dbback;
    private $mc;    
    private $table;
    private $cityFlag;
    private $fields;
    private $table2;
    private $fields2;
    private $sort;
    public function __construct() {
       GLOBAL $dbback,$mc,$conf_cityflag;
       $this->dbback = $dbback;
       $this->mc = $mc;
       $this->cityFlag = $conf_cityflag;   
       $this->table2 = "broker";
       
       if($this->cityFlag == 'nj'){
           $this->table =  'broker_package';
           $this->fields = "package_id as id,package_name as groupname";
           $this->sort ="package_valid_num";
		   $this->fields2 = "uid,username,truename,agentcode,package_id,package_id as groupid";
       }else{
            $this->table =  'broker_group';
            $this->fields = "id,groupname";
            $this->sort = "post";
			$this->fields2 = "uid,username,truename,agentcode,groupid";
       }
     
    }
    
     /**
     * 获取成长值套餐
     * @param 无
     * @return array 
     * @author xue 2014-2-14
     */    
     public function getExpBrokerGroup(){  
         $sql = SqlCombinHelper::select_sql($this->table, $this->fields, 
                 "exp_status = 1 order by $this->sort asc");        
         return $this->dbback->getAll($sql);         
     }
     
     /**
     * 获取积分值套餐
     * @param 无
     * @return array 
     * @author xue 2014-2-14
     */    
     public function getCreditBrokerGroup(){      
        
         $sql = SqlCombinHelper::select_sql($this->table, $this->fields, 
                 "credit_status = 1 order by $this->sort asc");
         return $this->dbback->getAll($sql);         
     }
     
    /**
     * 获取经纪人权限组信息
     * @param 无
     * @return array 
     * @author xue 2014-2-22
     */    
     public function getBrokerGroupInfo($id){  
         $sql = SqlCombinHelper::select_sql($this->table2, $this->fields2, 
                 "uid = $id");        
         return $this->dbback->getRow($sql);         
     }
     
      /**
     * 获取经纪人信息
     * @param 无
     * @return array 
     * @author xue 2014-2-22
     */    
     public function getBrokerInfo($brokerid){  
         $sql = SqlCombinHelper::select_sql($this->table2, $this->fields2, 
                 "username = '".$brokerid."'"); 
         return $this->dbback->getRow($sql);         
     }
     
     
     
     
    
    
}
