Ignore:
Timestamp:
2011/02/11 11:55:39 (13 years ago)
Author:
AMUAMU
Message:

#961 (リファクタリング [管理画面]ログイン/ホーム) ホーム画面の修正。
#674 (サイト情報の送信を任意に設定できるように) の実装。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/pages/admin/LC_Page_Admin_Home.php

    r20116 r20134  
    6666     */ 
    6767    function action() { 
    68         $objQuery = new SC_Query(); 
    69         $objSess = new SC_Session(); 
    7068 
    7169        // 認証可否の判定 
    72         SC_Utils_Ex::sfIsSuccess($objSess); 
     70        SC_Utils_Ex::sfIsSuccess(new SC_Session()); 
    7371 
    7472        // DBバージョンの取得 
    75         $objDb = new SC_Helper_DB_Ex(); 
    76         $this->db_version = $objDb->sfGetDBVersion(); 
     73        $this->db_version = $this->lfGetDBVersion(); 
    7774 
    7875        // PHPバージョンの取得 
    79         $this->php_version = "PHP " . phpversion(); 
     76        $this->php_version = $this->lfGetPHPVersion(); 
    8077 
    8178        // 現在の会員数 
    82         $this->customer_cnt = $this->lfGetCustomerCnt($objQuery); 
     79        $this->customer_cnt = $this->lfGetCustomerCnt(); 
    8380 
    8481        // 昨日の売上高 
    85         $this->order_yesterday_amount = $this->lfGetOrderYesterday($objQuery, "SUM"); 
     82        $this->order_yesterday_amount = $this->lfGetOrderYesterday("SUM"); 
    8683 
    8784        // 昨日の売上件数 
    88         $this->order_yesterday_cnt = $this->lfGetOrderYesterday($objQuery, "COUNT"); 
     85        $this->order_yesterday_cnt = $this->lfGetOrderYesterday("COUNT"); 
    8986 
    9087        // 今月の売上高 
    91         $this->order_month_amount = $this->lfGetOrderMonth($objQuery, "SUM"); 
     88        $this->order_month_amount = $this->lfGetOrderMonth("SUM"); 
    9289 
    9390        // 今月の売上件数 
    94         $this->order_month_cnt = $this->lfGetOrderMonth($objQuery, "COUNT"); 
     91        $this->order_month_cnt = $this->lfGetOrderMonth("COUNT"); 
    9592 
    9693        // 顧客の累計ポイント 
     
    9895 
    9996        //昨日のレビュー書き込み数 
    100         $this->review_yesterday_cnt = $this->lfGetReviewYesterday($objQuery); 
     97        $this->review_yesterday_cnt = $this->lfGetReviewYesterday(); 
    10198 
    10299        //レビュー書き込み非表示数 
    103         $this->review_nondisp_cnt = $this->lfGetReviewNonDisp($objQuery); 
     100        $this->review_nondisp_cnt = $this->lfGetReviewNonDisp(); 
    104101 
    105102        // 品切れ商品 
     
    107104 
    108105        // 新規受付一覧 
    109         $arrNewOrder = $this->lfGetNewOrder(); 
    110  
    111         foreach ($arrNewOrder as $key => $val){ 
    112             $arrNewOrder[$key]['create_date'] = str_replace("-", "/", substr($val['create_date'], 0,19)); 
    113  
    114         } 
    115         $this->arrNewOrder = $arrNewOrder; 
     106        $this->arrNewOrder = $this->lfGetNewOrder(); 
    116107 
    117108        // お知らせ一覧の取得 
     
    128119    } 
    129120 
    130     // 会員数 
    131     function lfGetCustomerCnt(&$objQuery){ 
    132  
    133         $sql = "SELECT COUNT(customer_id) FROM dtb_customer WHERE del_flg = 0 AND status = 2"; 
    134         $return = $objQuery->getOne($sql); 
    135         return $return; 
    136     } 
    137  
    138     // 昨日の売上高・売上件数 
    139     function lfGetOrderYesterday(&$objQuery, $method){ 
    140         if ( $method == 'SUM' or $method == 'COUNT'){ 
    141             $dbFactory = SC_DB_DBFactory::getInstance(); 
    142             $sql = $dbFactory->getOrderYesterdaySql($method); 
    143             $return = $objQuery->getOne($sql); 
    144         } 
    145         return $return; 
    146     } 
    147  
    148     function lfGetOrderMonth(&$objQuery, $method){ 
    149  
     121    /** 
     122     * PHPバージョンの取得 
     123     * 
     124     * @return string PHPバージョン情報 
     125     */ 
     126    function lfGetPHPVersion() { 
     127        return "PHP " . phpversion(); 
     128    } 
     129     
     130    /** 
     131     * DBバージョンの取得 
     132     * 
     133     * @return mixed DBバージョン情報 
     134     */ 
     135    function lfGetDBVersion() { 
     136        $objDb = new SC_Helper_DB_Ex(); 
     137        return $objDb->sfGetDBVersion(); 
     138    } 
     139 
     140    /** 
     141     * 現在の会員数の取得 
     142     * 
     143     * @return integer 会員数 
     144     */ 
     145    function lfGetCustomerCnt(){ 
     146        $objQuery =& SC_Query::getSingletonInstance(); 
     147        $col = "COUNT(customer_id)"; 
     148        $table = "dtb_customer"; 
     149        $where = "del_flg = 0 AND status = 2"; 
     150        return $objQuery->get($col, $table, $where); 
     151    } 
     152 
     153    /** 
     154     * 昨日の売上データの取得 
     155     * 
     156     * @param string $method 取得タイプ 件数:"COUNT" or 金額:"SUM" 
     157     * @return integer 結果数値 
     158     */ 
     159    function lfGetOrderYesterday($method){ 
     160        $objQuery =& SC_Query::getSingletonInstance(); 
     161         
     162        // TODO: DBFactory使わないでも共通化できそうな気もしますが 
     163        $dbFactory = SC_DB_DBFactory::getInstance(); 
     164        $sql = $dbFactory->getOrderYesterdaySql($method); 
     165        return $objQuery->getOne($sql); 
     166    } 
     167 
     168    /** 
     169     * 今月の売上データの取得 
     170     * 
     171     * @param string $method 取得タイプ 件数:"COUNT" or 金額:"SUM" 
     172     * @return integer 結果数値 
     173     */ 
     174    function lfGetOrderMonth($method){ 
     175        $objQuery =& SC_Query::getSingletonInstance(); 
    150176        $month = date("Y/m", mktime()); 
    151  
    152         if ( $method == 'SUM' or $method == 'COUNT'){ 
    153             $dbFactory = SC_DB_DBFactory::getInstance(); 
    154             $sql = $dbFactory->getOrderMonthSql($method); 
    155             $return = $objQuery->getOne($sql, array($month)); 
    156         } 
    157         return $return; 
    158     } 
    159  
     177         
     178        // TODO: DBFactory使わないでも共通化できそうな気もしますが 
     179        $dbFactory = SC_DB_DBFactory::getInstance(); 
     180        $sql = $dbFactory->getOrderMonthSql($method); 
     181        return $objQuery->getOne($sql, array($month)); 
     182    } 
     183 
     184    /** 
     185     * 顧客の保持ポイント合計の取得 
     186     * 
     187     * @return integer 顧客の保持ポイント合計 
     188     */ 
    160189    function lfGetTotalCustomerPoint() { 
    161         $objQuery = new SC_Query(); 
     190        $objQuery =& SC_Query::getSingletonInstance(); 
     191         
    162192        $col = "SUM(point)"; 
    163193        $where = "del_flg = 0"; 
    164194        $from = "dtb_customer"; 
    165         $ret = $objQuery->get($col, $from, $where); 
    166         return $ret; 
    167     } 
    168  
    169     function lfGetReviewYesterday(&$objQuery){ 
     195        return $objQuery->get($col, $from, $where); 
     196    } 
     197 
     198    /** 
     199     * 昨日のレビュー書き込み数の取得 
     200     * 
     201     * @return integer 昨日のレビュー書き込み数 
     202     */ 
     203    function lfGetReviewYesterday(){ 
     204        $objQuery =& SC_Query::getSingletonInstance(); 
     205 
     206        // TODO: DBFactory使わないでも共通化できそうな気もしますが 
    170207        $dbFactory = SC_DB_DBFactory::getInstance(); 
    171208        $sql = $dbFactory->getReviewYesterdaySql(); 
    172         $return = $objQuery->getOne($sql); 
    173         return $return; 
    174     } 
    175  
    176     function lfGetReviewNonDisp(&$objQuery){ 
    177         $sql = "SELECT COUNT(*) FROM dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id WHERE A.del_flg=0 AND A.status=2 AND B.del_flg=0"; 
    178         $return = $objQuery->getOne($sql); 
    179         return $return; 
    180     } 
    181  
    182     // 品切れ商品IDの取得 
     209        return $objQuery->getOne($sql); 
     210    } 
     211 
     212    /** 
     213     * レビュー書き込み非表示数の取得 
     214     * 
     215     * @return integer レビュー書き込み非表示数 
     216     */ 
     217    function lfGetReviewNonDisp(){ 
     218        $objQuery =& SC_Query::getSingletonInstance(); 
     219         
     220        $table = "dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id"; 
     221        $where = "A.del_flg = 0 AND A.status = 2 AND B.del_flg = 0"; 
     222        return $objQuery->count($table, $where); 
     223    } 
     224 
     225    /** 
     226     * 品切れ商品の取得 
     227     * 
     228     * @return array 品切れ商品一覧 
     229     */ 
    183230    function lfGetSoldOut() { 
    184         $objQuery = new SC_Query(); 
    185         $where = "product_id IN (SELECT product_id FROM dtb_products_class WHERE stock_unlimited = 0 AND stock <= 0)"; 
    186         $arrRet = $objQuery->select("product_id, name", "dtb_products", $where); 
    187         return $arrRet; 
    188     } 
    189  
    190     // 新規受付一覧 
     231        $objQuery =& SC_Query::getSingletonInstance(); 
     232         
     233        $cols = "product_id, name"; 
     234        $table = "dtb_products"; 
     235        $where = "product_id IN (" 
     236                  . "SELECT product_id FROM dtb_products_class " 
     237                  . "WHERE stock_unlimited = ? AND stock <= 0)"; 
     238        return $objQuery->select($cols, $table, $where, array(UNLIMITED_FLG_LIMITED)); 
     239    } 
     240 
     241    /** 
     242     * 新規受付一覧の取得 
     243     * 
     244     * @return array 新規受付一覧配列 
     245     */ 
    191246    function lfGetNewOrder() { 
    192         $objQuery = new SC_Query(); 
     247        $objQuery =& SC_Query::getSingletonInstance(); 
     248         
    193249        $sql = "SELECT 
    194250                    ord.order_id, 
     
    228284                        create_date DESC LIMIT 10 OFFSET 0 
    229285                ) AS ord"; 
    230         $arrRet = $objQuery->getAll($sql); 
    231         return $arrRet; 
     286        $arrNewOrder = $objQuery->getAll($sql); 
     287        foreach ($arrNewOrder as $key => $val){ 
     288            $arrNewOrder[$key]['create_date'] = str_replace("-", "/", substr($val['create_date'], 0,19)); 
     289 
     290        } 
     291        return $arrNewOrder; 
    232292    } 
    233293 
     
    235295     * リリース情報を取得する. 
    236296     * 
    237      * @return unknown 
     297     * @return array 取得した情報配列 
    238298     */ 
    239299    function lfGetInfo() { 
     300        // 更新情報の取得ON/OFF確認 
     301        if (!ECCUBE_INFO) return array(); 
    240302 
    241303        // パラメータ「UPDATE_HTTP」が空文字の場合、処理しない。 
     
    252314 
    253315        $url = UPDATE_HTTP . $query; 
    254         $jsonStr = @file_get_contents($url); 
     316 
     317        // タイムアウト時間設定 
     318        $context = array('http' => array('timeout' => HTTP_REQUEST_TIMEOUT)); 
     319         
     320        $jsonStr = @file_get_contents($url, false, stream_context_create($context)); 
    255321 
    256322        $objJson = new Services_JSON; 
     
    261327            return array(); 
    262328        } 
    263  
    264329        $arrInfo = array(); 
    265330        foreach ($arrTmpData as $objData) { 
    266331            $arrInfo[] = get_object_vars($objData); 
    267332        } 
    268  
    269333        return $arrInfo; 
    270334    } 
Note: See TracChangeset for help on using the changeset viewer.