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

Revision 21481, 10.0 KB checked in by Seasoft, 12 years ago (diff)

#1613 (ソース整形・ソースコメントの改善)

  • Zend Framework PHP 標準コーディング規約への準拠を高めた
  • 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';
27require_once DATA_REALDIR . 'module/HTTP/Request.php';
28
29/**
30 * 管理画面ホーム のページクラス.
31 *
32 * @package Page
33 * @author LOCKON CO.,LTD.
34 * @version $Id$
35 */
36class LC_Page_Admin_Home extends LC_Page_Admin_Ex {
37
38    // }}}
39    // {{{ functions
40
41    /**
42     * Page を初期化する.
43     *
44     * @return void
45     */
46    function init() {
47        parent::init();
48        $this->tpl_mainpage = 'home.tpl';
49        $this->tpl_subtitle = 'ホーム';
50    }
51
52    /**
53     * Page のプロセス.
54     *
55     * @return void
56     */
57    function process() {
58        $this->action();
59        $this->sendResponse();
60    }
61
62    /**
63     * Page のアクション.
64     *
65     * @return void
66     */
67    function action() {
68
69        // DBバージョンの取得
70        $this->db_version = $this->lfGetDBVersion();
71
72        // PHPバージョンの取得
73        $this->php_version = $this->lfGetPHPVersion();
74
75        // 現在の会員数
76        $this->customer_cnt = $this->lfGetCustomerCnt();
77
78        // 昨日の売上高
79        $this->order_yesterday_amount = $this->lfGetOrderYesterday('SUM');
80
81        // 昨日の売上件数
82        $this->order_yesterday_cnt = $this->lfGetOrderYesterday('COUNT');
83
84        // 今月の売上高
85        $this->order_month_amount = $this->lfGetOrderMonth('SUM');
86
87        // 今月の売上件数
88        $this->order_month_cnt = $this->lfGetOrderMonth('COUNT');
89
90        // 会員の累計ポイント
91        $this->customer_point = $this->lfGetTotalCustomerPoint();
92
93        //昨日のレビュー書き込み数
94        $this->review_yesterday_cnt = $this->lfGetReviewYesterday();
95
96        //レビュー書き込み非表示数
97        $this->review_nondisp_cnt = $this->lfGetReviewNonDisp();
98
99        // 品切れ商品
100        $this->arrSoldout = $this->lfGetSoldOut();
101
102        // 新規受付一覧
103        $this->arrNewOrder = $this->lfGetNewOrder();
104
105        // お知らせ一覧の取得
106        $this->arrInfo = $this->lfGetInfo();
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        return $objQuery->select($cols, $table, $where, array(UNLIMITED_FLG_LIMITED));
236    }
237
238    /**
239     * 新規受付一覧の取得
240     *
241     * @return array 新規受付一覧配列
242     */
243    function lfGetNewOrder() {
244        $objQuery =& SC_Query_Ex::getSingletonInstance();
245
246        $sql = "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 <> " . ORDER_CANCEL . "
282                    ORDER BY
283                        create_date DESC LIMIT 10 OFFSET 0
284                ) AS ord";
285        $arrNewOrder = $objQuery->getAll($sql);
286        foreach ($arrNewOrder as $key => $val) {
287            $arrNewOrder[$key]['create_date'] = str_replace("-", "/", substr($val['create_date'], 0,19));
288
289        }
290        return $arrNewOrder;
291    }
292
293    /**
294     * リリース情報を取得する.
295     *
296     * @return array 取得した情報配列
297     */
298    function lfGetInfo() {
299        // 更新情報の取得ON/OFF確認
300        if (!ECCUBE_INFO) return array();
301
302        // パラメーター「UPDATE_HTTP」が空文字の場合、処理しない。
303        // XXX これと別に on/off を持たせるべきか。
304        if (strlen(UPDATE_HTTP) == 0) return array();
305
306        $query = '';
307        // サイト情報の送信可否設定
308        // XXX インストール時に問い合わせて送信可否設定を行うように設定すべきか。
309        // XXX (URLは強制送信すべきではないと思うが)バージョンは強制送信すべきか。
310        if (UPDATE_SEND_SITE_INFO === true) {
311            $query = '?site_url=' . HTTP_URL . '&eccube_version=' . ECCUBE_VERSION;
312        }
313
314        $url = UPDATE_HTTP . $query;
315
316        // タイムアウト時間設定
317        $context = array('http' => array('timeout' => HTTP_REQUEST_TIMEOUT));
318
319        $jsonStr = @file_get_contents($url, false, stream_context_create($context));
320
321        $arrTmpData = is_string($jsonStr) ? SC_Utils_Ex::jsonDecode($jsonStr) : null;
322
323        if (empty($arrTmpData)) {
324            SC_Utils_Ex::sfErrorHeader(">> 更新情報の取得に失敗しました。");
325            return array();
326        }
327        $arrInfo = array();
328        foreach ($arrTmpData as $objData) {
329            $arrInfo[] = get_object_vars($objData);
330        }
331        return $arrInfo;
332    }
333}
Note: See TracBrowser for help on using the repository browser.