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

Revision 21514, 9.8 KB checked in by Seasoft, 12 years ago (diff)

#1625 (typo修正・ソース整形・ソースコメントの改善)

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