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

Revision 21866, 9.8 KB checked in by h_yoshimoto, 12 years ago (diff)

#1831 Copyrightを更新を誤っているので戻します

  • 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     *
112     * @return void
113     */
114    function destroy() {
115        parent::destroy();
116    }
117
118    /**
119     * PHPバージョンの取得
120     *
121     * @return string PHPバージョン情報
122     */
123    function lfGetPHPVersion() {
124        return 'PHP ' . phpversion();
125    }
126
127    /**
128     * DBバージョンの取得
129     *
130     * @return mixed DBバージョン情報
131     */
132    function lfGetDBVersion() {
133        $dbFactory = SC_DB_DBFactory_Ex::getInstance();
134        return $dbFactory->sfGetDBVersion();
135    }
136
137    /**
138     * 現在の会員数の取得
139     *
140     * @return integer 会員数
141     */
142    function lfGetCustomerCnt() {
143        $objQuery =& SC_Query_Ex::getSingletonInstance();
144        $col = 'COUNT(customer_id)';
145        $table = 'dtb_customer';
146        $where = 'del_flg = 0 AND status = 2';
147        return $objQuery->get($col, $table, $where);
148    }
149
150    /**
151     * 昨日の売上データの取得
152     *
153     * @param string $method 取得タイプ 件数:'COUNT' or 金額:'SUM'
154     * @return integer 結果数値
155     */
156    function lfGetOrderYesterday($method) {
157        $objQuery =& SC_Query_Ex::getSingletonInstance();
158
159        // TODO: DBFactory使わないでも共通化できそうな気もしますが
160        $dbFactory = SC_DB_DBFactory_Ex::getInstance();
161        $sql = $dbFactory->getOrderYesterdaySql($method);
162        return $objQuery->getOne($sql);
163    }
164
165    /**
166     * 今月の売上データの取得
167     *
168     * @param string $method 取得タイプ 件数:'COUNT' or 金額:'SUM'
169     * @return integer 結果数値
170     */
171    function lfGetOrderMonth($method) {
172        $objQuery =& SC_Query_Ex::getSingletonInstance();
173        $month = date('Y/m', mktime());
174
175        // TODO: DBFactory使わないでも共通化できそうな気もしますが
176        $dbFactory = SC_DB_DBFactory_Ex::getInstance();
177        $sql = $dbFactory->getOrderMonthSql($method);
178        return $objQuery->getOne($sql, array($month));
179    }
180
181    /**
182     * 会員の保持ポイント合計の取得
183     *
184     * @return integer 会員の保持ポイント合計
185     */
186    function lfGetTotalCustomerPoint() {
187        $objQuery =& SC_Query_Ex::getSingletonInstance();
188
189        $col = 'SUM(point)';
190        $where = 'del_flg = 0';
191        $from = 'dtb_customer';
192        return $objQuery->get($col, $from, $where);
193    }
194
195    /**
196     * 昨日のレビュー書き込み数の取得
197     *
198     * @return integer 昨日のレビュー書き込み数
199     */
200    function lfGetReviewYesterday() {
201        $objQuery =& SC_Query_Ex::getSingletonInstance();
202
203        // TODO: DBFactory使わないでも共通化できそうな気もしますが
204        $dbFactory = SC_DB_DBFactory_Ex::getInstance();
205        $sql = $dbFactory->getReviewYesterdaySql();
206        return $objQuery->getOne($sql);
207    }
208
209    /**
210     * レビュー書き込み非表示数の取得
211     *
212     * @return integer レビュー書き込み非表示数
213     */
214    function lfGetReviewNonDisp() {
215        $objQuery =& SC_Query_Ex::getSingletonInstance();
216
217        $table = 'dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id';
218        $where = 'A.del_flg = 0 AND A.status = 2 AND B.del_flg = 0';
219        return $objQuery->count($table, $where);
220    }
221
222    /**
223     * 品切れ商品の取得
224     *
225     * @return array 品切れ商品一覧
226     */
227    function lfGetSoldOut() {
228        $objQuery =& SC_Query_Ex::getSingletonInstance();
229
230        $cols = 'product_id, name';
231        $table = 'dtb_products';
232        $where = 'product_id IN ('
233               . 'SELECT product_id FROM dtb_products_class '
234               . 'WHERE stock_unlimited = ? AND stock <= 0)'
235               . ' AND del_flg = 0';
236        return $objQuery->select($cols, $table, $where, array(UNLIMITED_FLG_LIMITED));
237    }
238
239    /**
240     * 新規受付一覧の取得
241     *
242     * @return array 新規受付一覧配列
243     */
244    function lfGetNewOrder() {
245        $objQuery =& SC_Query_Ex::getSingletonInstance();
246
247        $sql = <<< __EOS__
248            SELECT
249                ord.order_id,
250                ord.customer_id,
251                ord.order_name01 AS name01,
252                ord.order_name02 AS name02,
253                ord.total,
254                ord.create_date,
255                (SELECT
256                    det.product_name
257                FROM
258                    dtb_order_detail AS det
259                WHERE
260                    ord.order_id = det.order_id
261                ORDER BY det.order_detail_id
262                LIMIT 1
263                ) AS product_name,
264                (SELECT
265                    pay.payment_method
266                FROM
267                    dtb_payment AS pay
268                WHERE
269                    ord.payment_id = pay.payment_id
270                ) AS payment_method
271            FROM (
272                SELECT
273                    order_id,
274                    customer_id,
275                    order_name01,
276                    order_name02,
277                    total,
278                    create_date,
279                    payment_id
280                FROM
281                    dtb_order AS ord
282                WHERE
283                    del_flg = 0 AND status <> ?
284                ORDER BY
285                    create_date DESC LIMIT 10 OFFSET 0
286            ) AS ord
287__EOS__;
288        $arrNewOrder = $objQuery->getAll($sql, ORDER_CANCEL);
289        foreach ($arrNewOrder as $key => $val) {
290            $arrNewOrder[$key]['create_date'] = str_replace('-', '/', substr($val['create_date'], 0,19));
291
292        }
293        return $arrNewOrder;
294    }
295
296    /**
297     * リリース情報を取得する.
298     *
299     * @return array 取得した情報配列
300     */
301    function lfGetInfo() {
302        // 更新情報の取得ON/OFF確認
303        if (!ECCUBE_INFO) return array();
304
305        // パラメーター「UPDATE_HTTP」が空文字の場合、処理しない。
306        // XXX これと別に on/off を持たせるべきか。
307        if (strlen(UPDATE_HTTP) == 0) return array();
308
309        $query = '';
310        // サイト情報の送信可否設定
311        // XXX インストール時に問い合わせて送信可否設定を行うように設定すべきか。
312        // XXX (URLは強制送信すべきではないと思うが)バージョンは強制送信すべきか。
313        if (UPDATE_SEND_SITE_INFO === true) {
314            $query = '?site_url=' . HTTP_URL . '&eccube_version=' . ECCUBE_VERSION;
315        }
316
317        $url = UPDATE_HTTP . $query;
318
319        // タイムアウト時間設定
320        $context = array('http' => array('timeout' => HTTP_REQUEST_TIMEOUT));
321
322        $jsonStr = @file_get_contents($url, false, stream_context_create($context));
323
324        $arrTmpData = is_string($jsonStr) ? SC_Utils_Ex::jsonDecode($jsonStr) : null;
325
326        if (empty($arrTmpData)) {
327            SC_Utils_Ex::sfErrorHeader('>> 更新情報の取得に失敗しました。');
328            return array();
329        }
330        $arrInfo = array();
331        foreach ($arrTmpData as $objData) {
332            $arrInfo[] = get_object_vars($objData);
333        }
334        return $arrInfo;
335    }
336}
Note: See TracBrowser for help on using the repository browser.