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

Revision 22856, 9.9 KB checked in by Seasoft, 11 years ago (diff)

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

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