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

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