source: branches/version-2_13-dev/data/class/pages/admin/LC_Page_Admin_Home.php @ 23546

Revision 23546, 9.5 KB checked in by shutta, 10 years ago (diff)

#2580 Copyrightを更新
Copyrightを2014に更新

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
RevLine 
[19788]1
[15287]2<?php
3/*
[16582]4 * This file is part of EC-CUBE
5 *
[23546]6 * Copyright(c) 2000-2014 LOCKON CO.,LTD. All Rights Reserved.
[15287]7 *
8 * http://www.lockon.co.jp/
[16582]9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
[15287]23 */
24
[20534]25require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
[15287]26
27/**
28 * 管理画面ホーム のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
[22856]34class LC_Page_Admin_Home extends LC_Page_Admin_Ex
[22567]35{
[15287]36    /**
37     * Page を初期化する.
38     *
39     * @return void
40     */
[23124]41    public function init()
[22567]42    {
[15287]43        parent::init();
44        $this->tpl_mainpage = 'home.tpl';
[19909]45        $this->tpl_subtitle = 'ホーム';
[15287]46    }
47
48    /**
49     * Page のプロセス.
50     *
51     * @return void
52     */
[23124]53    public function process()
[22567]54    {
[19661]55        $this->action();
56        $this->sendResponse();
57    }
58
59    /**
60     * Page のアクション.
61     *
62     * @return void
63     */
[23124]64    public function action()
[22567]65    {
[15287]66        // DBバージョンの取得
[20134]67        $this->db_version = $this->lfGetDBVersion();
[15287]68
69        // PHPバージョンの取得
[20134]70        $this->php_version = $this->lfGetPHPVersion();
[15287]71
72        // 現在の会員数
[20134]73        $this->customer_cnt = $this->lfGetCustomerCnt();
[15287]74
75        // 昨日の売上高
[20538]76        $this->order_yesterday_amount = $this->lfGetOrderYesterday('SUM');
[15287]77
78        // 昨日の売上件数
[20538]79        $this->order_yesterday_cnt = $this->lfGetOrderYesterday('COUNT');
[15287]80
81        // 今月の売上高
[20538]82        $this->order_month_amount = $this->lfGetOrderMonth('SUM');
[15287]83
84        // 今月の売上件数
[20538]85        $this->order_month_cnt = $this->lfGetOrderMonth('COUNT');
[15287]86
[20953]87        // 会員の累計ポイント
[15287]88        $this->customer_point = $this->lfGetTotalCustomerPoint();
89
90        //昨日のレビュー書き込み数
[20134]91        $this->review_yesterday_cnt = $this->lfGetReviewYesterday();
[15287]92
93        //レビュー書き込み非表示数
[20134]94        $this->review_nondisp_cnt = $this->lfGetReviewNonDisp();
[15287]95
96        // 品切れ商品
97        $this->arrSoldout = $this->lfGetSoldOut();
98
99        // 新規受付一覧
[20134]100        $this->arrNewOrder = $this->lfGetNewOrder();
[15287]101
102        // お知らせ一覧の取得
103        $this->arrInfo = $this->lfGetInfo();
104    }
105
106    /**
[20134]107     * PHPバージョンの取得
108     *
109     * @return string PHPバージョン情報
110     */
[23124]111    public function lfGetPHPVersion()
[22567]112    {
[21514]113        return 'PHP ' . phpversion();
[20134]114    }
[20540]115
[20134]116    /**
117     * DBバージョンの取得
118     *
119     * @return mixed DBバージョン情報
120     */
[23124]121    public function lfGetDBVersion()
[22567]122    {
[20732]123        $dbFactory = SC_DB_DBFactory_Ex::getInstance();
[22856]124
[20732]125        return $dbFactory->sfGetDBVersion();
[20134]126    }
[15287]127
[20134]128    /**
129     * 現在の会員数の取得
130     *
131     * @return integer 会員数
132     */
[23124]133    public function lfGetCustomerCnt()
[22567]134    {
[20507]135        $objQuery =& SC_Query_Ex::getSingletonInstance();
[21514]136        $col = 'COUNT(customer_id)';
[21481]137        $table = 'dtb_customer';
[21514]138        $where = 'del_flg = 0 AND status = 2';
[22856]139
[20134]140        return $objQuery->get($col, $table, $where);
[15287]141    }
142
[20134]143    /**
144     * 昨日の売上データの取得
145     *
[23124]146     * @param  string  $method 取得タイプ 件数:'COUNT' or 金額:'SUM'
[20134]147     * @return integer 結果数値
148     */
[23124]149    public function lfGetOrderYesterday($method)
[22567]150    {
[20507]151        $objQuery =& SC_Query_Ex::getSingletonInstance();
[20540]152
[20134]153        // TODO: DBFactory使わないでも共通化できそうな気もしますが
[20484]154        $dbFactory = SC_DB_DBFactory_Ex::getInstance();
[20134]155        $sql = $dbFactory->getOrderYesterdaySql($method);
[22856]156
[20134]157        return $objQuery->getOne($sql);
[15287]158    }
159
[20134]160    /**
161     * 今月の売上データの取得
162     *
[23124]163     * @param  string  $method 取得タイプ 件数:'COUNT' or 金額:'SUM'
[20134]164     * @return integer 結果数値
165     */
[23124]166    public function lfGetOrderMonth($method)
[22567]167    {
[20507]168        $objQuery =& SC_Query_Ex::getSingletonInstance();
[21514]169        $month = date('Y/m', mktime());
[20540]170
[20134]171        // TODO: DBFactory使わないでも共通化できそうな気もしますが
[20484]172        $dbFactory = SC_DB_DBFactory_Ex::getInstance();
[20134]173        $sql = $dbFactory->getOrderMonthSql($method);
[22856]174
[20134]175        return $objQuery->getOne($sql, array($month));
[15287]176    }
177
[20134]178    /**
[20953]179     * 会員の保持ポイント合計の取得
[20134]180     *
[20953]181     * @return integer 会員の保持ポイント合計
[20134]182     */
[23124]183    public function lfGetTotalCustomerPoint()
[22567]184    {
[20507]185        $objQuery =& SC_Query_Ex::getSingletonInstance();
[20540]186
[21514]187        $col = 'SUM(point)';
188        $where = 'del_flg = 0';
[21481]189        $from = 'dtb_customer';
[22856]190
[20134]191        return $objQuery->get($col, $from, $where);
[15287]192    }
193
[20134]194    /**
195     * 昨日のレビュー書き込み数の取得
196     *
197     * @return integer 昨日のレビュー書き込み数
198     */
[23124]199    public function lfGetReviewYesterday()
[22567]200    {
[20507]201        $objQuery =& SC_Query_Ex::getSingletonInstance();
[20134]202
203        // TODO: DBFactory使わないでも共通化できそうな気もしますが
[20484]204        $dbFactory = SC_DB_DBFactory_Ex::getInstance();
[18789]205        $sql = $dbFactory->getReviewYesterdaySql();
[22856]206
[20134]207        return $objQuery->getOne($sql);
[15287]208    }
209
[20134]210    /**
211     * レビュー書き込み非表示数の取得
212     *
213     * @return integer レビュー書き込み非表示数
214     */
[23124]215    public function lfGetReviewNonDisp()
[22567]216    {
[20507]217        $objQuery =& SC_Query_Ex::getSingletonInstance();
[20540]218
[21514]219        $table = 'dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id';
220        $where = 'A.del_flg = 0 AND A.status = 2 AND B.del_flg = 0';
[22856]221
[20134]222        return $objQuery->count($table, $where);
[15287]223    }
224
[20134]225    /**
226     * 品切れ商品の取得
227     *
228     * @return array 品切れ商品一覧
229     */
[23124]230    public function lfGetSoldOut()
[22567]231    {
[20507]232        $objQuery =& SC_Query_Ex::getSingletonInstance();
[20540]233
[21514]234        $cols = 'product_id, name';
[21481]235        $table = 'dtb_products';
[21514]236        $where = 'product_id IN ('
[21527]237               . 'SELECT product_id FROM dtb_products_class '
[22318]238               . 'WHERE del_flg = 0 AND stock_unlimited = ? AND stock <= 0)'
[21836]239               . ' AND del_flg = 0';
[22856]240
[20134]241        return $objQuery->select($cols, $table, $where, array(UNLIMITED_FLG_LIMITED));
[15287]242    }
243
[20134]244    /**
245     * 新規受付一覧の取得
246     *
247     * @return array 新規受付一覧配列
248     */
[23124]249    public function lfGetNewOrder()
[22567]250    {
[20507]251        $objQuery =& SC_Query_Ex::getSingletonInstance();
[20540]252
[23378]253        $objQuery->setOrder('order_detail_id');
[23542]254        $sql_product_name = $objQuery->getSql('product_name', 'dtb_order_detail', 'order_id = dtb_order.order_id');
255        $sql_product_name = $objQuery->dbFactory->addLimitOffset($sql_product_name, 1);
[23378]256
257        $cols = <<< __EOS__
258            dtb_order.order_id,
259            dtb_order.customer_id,
260            dtb_order.order_name01 AS name01,
261            dtb_order.order_name02 AS name02,
262            dtb_order.total,
263            dtb_order.create_date,
264            ($sql_product_name) AS product_name,
265            (SELECT
266                pay.payment_method
267            FROM
268                dtb_payment AS pay
269            WHERE
270                dtb_order.payment_id = pay.payment_id
271            ) AS payment_method
[21514]272__EOS__;
[23378]273        $from = 'dtb_order';
274        $where = 'del_flg = 0 AND status <> ?';
275        $objQuery->setOrder('create_date DESC');
276        $objQuery->setLimit(10);
277        $arrNewOrder = $objQuery->select($cols, $from, $where, ORDER_CANCEL);
278
[21441]279        foreach ($arrNewOrder as $key => $val) {
[23503]280            $arrNewOrder[$key]['create_date'] = str_replace('-', '/', substr($val['create_date'], 0, 19));
[20134]281        }
[22856]282
[20134]283        return $arrNewOrder;
[15287]284    }
285
[16737]286    /**
287     * リリース情報を取得する.
288     *
[20134]289     * @return array 取得した情報配列
[16737]290     */
[23124]291    public function lfGetInfo()
[22567]292    {
[20134]293        // 更新情報の取得ON/OFF確認
294        if (!ECCUBE_INFO) return array();
[17353]295
[20970]296        // パラメーター「UPDATE_HTTP」が空文字の場合、処理しない。
[17353]297        // XXX これと別に on/off を持たせるべきか。
298        if (strlen(UPDATE_HTTP) == 0) return array();
299
[16737]300        $query = '';
[17353]301        // サイト情報の送信可否設定
302        // XXX インストール時に問い合わせて送信可否設定を行うように設定すべきか。
303        // XXX (URLは強制送信すべきではないと思うが)バージョンは強制送信すべきか。
304        if (UPDATE_SEND_SITE_INFO === true) {
[19802]305            $query = '?site_url=' . HTTP_URL . '&eccube_version=' . ECCUBE_VERSION;
[16737]306        }
[15287]307
[16737]308        $url = UPDATE_HTTP . $query;
[17353]309
[20134]310        // タイムアウト時間設定
311        $context = array('http' => array('timeout' => HTTP_REQUEST_TIMEOUT));
[20540]312
[20134]313        $jsonStr = @file_get_contents($url, false, stream_context_create($context));
314
[20434]315        $arrTmpData = is_string($jsonStr) ? SC_Utils_Ex::jsonDecode($jsonStr) : null;
[16737]316
317        if (empty($arrTmpData)) {
[21514]318            SC_Utils_Ex::sfErrorHeader('>> 更新情報の取得に失敗しました。');
[23124]319
[16737]320            return array();
[15287]321        }
[16737]322        $arrInfo = array();
323        foreach ($arrTmpData as $objData) {
324            $arrInfo[] = get_object_vars($objData);
325        }
[22856]326
[16737]327        return $arrInfo;
[15287]328    }
329}
Note: See TracBrowser for help on using the repository browser.