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

Revision 19802, 8.2 KB checked in by Seasoft, 13 years ago (diff)

#834(パラメータの定数名に「URL」を含むにもかかわらず、パスのみのものがある) 一部改修

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • 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-2010 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_PATH . "pages/admin/LC_Page_Admin.php";
27require_once DATA_FILE_PATH . 'module/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 {
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    }
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        $objQuery = new SC_Query();
68        $objSess = new SC_Session();
69
70        // 認証可否の判定
71        SC_Utils_Ex::sfIsSuccess($objSess);
72
73        // DBバージョンの取得
74        $objDb = new SC_Helper_DB_Ex();
75        $this->db_version = $objDb->sfGetDBVersion();
76
77        // PHPバージョンの取得
78        $this->php_version = "PHP " . phpversion();
79
80        // 現在の会員数
81        $this->customer_cnt = $this->lfGetCustomerCnt($objQuery);
82
83        // 昨日の売上高
84        $this->order_yesterday_amount = $this->lfGetOrderYesterday($objQuery, "SUM");
85
86        // 昨日の売上件数
87        $this->order_yesterday_cnt = $this->lfGetOrderYesterday($objQuery, "COUNT");
88
89        // 今月の売上高
90        $this->order_month_amount = $this->lfGetOrderMonth($objQuery, "SUM");
91
92        // 今月の売上件数
93        $this->order_month_cnt = $this->lfGetOrderMonth($objQuery, "COUNT");
94
95        // 顧客の累計ポイント
96        $this->customer_point = $this->lfGetTotalCustomerPoint();
97
98        //昨日のレビュー書き込み数
99        $this->review_yesterday_cnt = $this->lfGetReviewYesterday($objQuery);
100
101        //レビュー書き込み非表示数
102        $this->review_nondisp_cnt = $this->lfGetReviewNonDisp($objQuery);
103
104        // 品切れ商品
105        $this->arrSoldout = $this->lfGetSoldOut();
106
107        // 新規受付一覧
108        $arrNewOrder = $this->lfGetNewOrder();
109
110        foreach ($arrNewOrder as $key => $val){
111            $arrNewOrder[$key]['create_date'] = str_replace("-", "/", substr($val['create_date'], 0,19));
112
113        }
114        $this->arrNewOrder = $arrNewOrder;
115
116        // お知らせ一覧の取得
117        $this->arrInfo = $this->lfGetInfo();
118    }
119
120    /**
121     * デストラクタ.
122     *
123     * @return void
124     */
125    function destroy() {
126        parent::destroy();
127    }
128
129    // 会員数
130    function lfGetCustomerCnt(&$objQuery){
131
132        $sql = "SELECT COUNT(customer_id) FROM dtb_customer WHERE del_flg = 0 AND status = 2";
133        $return = $objQuery->getOne($sql);
134        return $return;
135    }
136
137    // 昨日の売上高・売上件数
138    function lfGetOrderYesterday(&$objQuery, $method){
139        if ( $method == 'SUM' or $method == 'COUNT'){
140            $dbFactory = SC_DB_DBFactory::getInstance();
141            $sql = $dbFactory->getOrderYesterdaySql($method);
142            $return = $objQuery->getOne($sql);
143        }
144        return $return;
145    }
146
147    function lfGetOrderMonth(&$objQuery, $method){
148
149        $month = date("Y/m", mktime());
150
151        if ( $method == 'SUM' or $method == 'COUNT'){
152            $dbFactory = SC_DB_DBFactory::getInstance();
153            $sql = $dbFactory->getOrderMonthSql($method);
154            $return = $objQuery->getOne($sql, array($month));
155        }
156        return $return;
157    }
158
159    function lfGetTotalCustomerPoint() {
160        $objQuery = new SC_Query();
161        $col = "SUM(point)";
162        $where = "del_flg = 0";
163        $from = "dtb_customer";
164        $ret = $objQuery->get($col, $from, $where);
165        return $ret;
166    }
167
168    function lfGetReviewYesterday(&$objQuery){
169        $dbFactory = SC_DB_DBFactory::getInstance();
170        $sql = $dbFactory->getReviewYesterdaySql();
171        $return = $objQuery->getOne($sql);
172        return $return;
173    }
174
175    function lfGetReviewNonDisp(&$objQuery){
176        $sql = "SELECT COUNT(*) FROM dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id WHERE A.del_flg=0 AND A.status=2 AND B.del_flg=0";
177        $return = $objQuery->getOne($sql);
178        return $return;
179    }
180
181    // 品切れ商品IDの取得
182    function lfGetSoldOut() {
183        $objQuery = new SC_Query();
184        $where = "product_id IN (SELECT product_id FROM dtb_products_class WHERE stock_unlimited = 0 AND stock <= 0)";
185        $arrRet = $objQuery->select("product_id, name", "dtb_products", $where);
186        return $arrRet;
187    }
188
189    // 新規受付一覧
190    function lfGetNewOrder() {
191        $objQuery = new SC_Query();
192        $sql = "SELECT
193                    ord.order_id,
194                    ord.customer_id,
195                    ord.order_name01 AS name01,
196                    ord.order_name02 AS name02,
197                    ord.total,
198                    ord.create_date,
199                    (SELECT
200                        det.product_name
201                    FROM
202                        dtb_order_detail AS det
203                    WHERE
204                        ord.order_id = det.order_id LIMIT 1
205                    ) AS product_name,
206                    (SELECT
207                        pay.payment_method
208                    FROM
209                        dtb_payment AS pay
210                    WHERE
211                        ord.payment_id = pay.payment_id
212                    ) AS payment_method
213                FROM (
214                    SELECT
215                        order_id,
216                        customer_id,
217                        order_name01,
218                        order_name02,
219                        total,
220                        create_date,
221                        payment_id
222                    FROM
223                        dtb_order AS ord
224                    WHERE
225                        del_flg = 0 AND status <> " . ORDER_CANCEL . "
226                    ORDER BY
227                        create_date DESC LIMIT 10 OFFSET 0
228                ) AS ord";
229        $arrRet = $objQuery->getAll($sql);
230        return $arrRet;
231    }
232
233    /**
234     * リリース情報を取得する.
235     *
236     * @return unknown
237     */
238    function lfGetInfo() {
239
240        // パラメータ「UPDATE_HTTP」が空文字の場合、処理しない。
241        // XXX これと別に on/off を持たせるべきか。
242        if (strlen(UPDATE_HTTP) == 0) return array();
243
244        $query = '';
245        // サイト情報の送信可否設定
246        // XXX インストール時に問い合わせて送信可否設定を行うように設定すべきか。
247        // XXX (URLは強制送信すべきではないと思うが)バージョンは強制送信すべきか。
248        if (UPDATE_SEND_SITE_INFO === true) {
249            $query = '?site_url=' . HTTP_URL . '&eccube_version=' . ECCUBE_VERSION;
250        }
251
252        $url = UPDATE_HTTP . $query;
253        $jsonStr = @file_get_contents($url);
254
255        $objJson = new Services_JSON;
256        $arrTmpData = is_string($jsonStr) ? $objJson->decode($jsonStr) : null;
257
258        if (empty($arrTmpData)) {
259            SC_Utils_Ex::sfErrorHeader(">> 更新情報の取得に失敗しました。");
260            return array();
261        }
262
263        $arrInfo = array();
264        foreach ($arrTmpData as $objData) {
265            $arrInfo[] = get_object_vars($objData);
266        }
267
268        return $arrInfo;
269    }
270}
271?>
Note: See TracBrowser for help on using the repository browser.