source: branches/feature-module-update/data/class/pages/admin/products/LC_Page_Admin_Products_Review.php @ 16741

Revision 16741, 11.3 KB checked in by adachi, 16 years ago (diff)

set eol-style:LF

  • Property svn:eol-style set to LF
  • Property svn:keywords set to "Id Revision Date"
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24// {{{ requires
25require_once(CLASS_PATH . "pages/LC_Page.php");
26require_once(CLASS_EX_PATH . "helper_extends/SC_Helper_CSV_Ex.php");
27
28/**
29 * レビュー管理 のページクラス.
30 *
31 * @package Page
32 * @author LOCKON CO.,LTD.
33 * @version $Id$
34 */
35class LC_Page_Admin_Products_Review extends LC_Page {
36
37    // }}}
38    // {{{ functions
39
40    /**
41     * Page を初期化する.
42     *
43     * @return void
44     */
45    function init() {
46        parent::init();
47        $this->tpl_mainpage = 'products/review.tpl';
48        $this->tpl_subnavi = 'products/subnavi.tpl';
49        $this->tpl_mainno = 'products';
50        $this->tpl_subno = 'review';
51        $this->tpl_pager = TEMPLATE_DIR . 'admin/pager.tpl';
52        $this->tpl_subtitle = 'レビュー管理';
53
54        $masterData = new SC_DB_MasterData_Ex();
55        $this->arrPageMax = $masterData->getMasterData("mtb_page_max");
56        $this->arrRECOMMEND = $masterData->getMasterData("mtb_recommend");
57        $this->arrSex = $masterData->getMasterData("mtb_sex");
58    }
59
60    /**
61     * Page のプロセス.
62     *
63     * @return void
64     */
65    function process() {
66        $objView = new SC_AdminView();
67        $objSess = new SC_Session();
68        $objDate = new SC_Date();
69        $objQuery = new SC_Query();
70
71        // 登録・更新検索開始年
72        $objDate->setStartYear(RELEASE_YEAR);
73        $objDate->setEndYear(DATE("Y"));
74        $this->arrStartYear = $objDate->getYear();
75        $this->arrStartMonth = $objDate->getMonth();
76        $this->arrStartDay = $objDate->getDay();
77        // 登録・更新検索終了年
78        $objDate->setStartYear(RELEASE_YEAR);
79        $objDate->setEndYear(DATE("Y"));
80        $this->arrEndYear = $objDate->getYear();
81        $this->arrEndMonth = $objDate->getMonth();
82        $this->arrEndDay = $objDate->getDay();
83
84        // 認証可否の判定
85        SC_Utils_Ex::sfIsSuccess($objSess);
86
87        //レビュー情報のカラムの取得
88        $select="review_id, A.product_id, reviewer_name, sex, recommend_level, ";
89        $select.="reviewer_url, title, comment, A.status, A.create_date, A.update_date, name";
90        $from = "dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ";
91
92        // 検索ワードの引き継ぎ
93        foreach ($_POST as $key => $val) {
94            if (ereg("^search_", $key)) {
95                switch ($key){
96                case 'search_sex':
97                    $this->arrHidden[$key] = SC_Utils_Ex::sfMergeParamCheckBoxes($val);
98                    if(!is_array($val)) {
99                        $this->arrForm[$key] = split("-", $val);
100                    }
101                    break;
102
103                default:
104                    $this->arrHidden[$key] = $val;
105                    break;
106                }
107            }
108        }
109
110        if (!isset($_POST['mode'])) $_POST['mode'] = "";
111
112        if ($_POST['mode'] == "delete"){
113            //レビューの削除
114            $objQuery->exec("UPDATE dtb_review SET del_flg=1 WHERE review_id=?", array($_POST['review_id']));
115        }
116
117        if ($_POST['mode'] == 'search' || $_POST['mode'] == 'csv' || $_POST['mode'] == 'delete'){
118
119            //削除されていない商品を検索
120            $where="A.del_flg = 0 AND B.del_flg = 0";
121            $this->arrForm = $_POST;
122            if (isset($_POST['search_sex']) && !is_array($_POST['search_sex'])){
123                $this->arrForm['search_sex'] = split("-", $_POST['search_sex']);
124            }
125            //エラーチェック
126            $this->arrErr = $this->lfCheckError();
127
128            if (!$this->arrErr){
129                foreach ($_POST as $key => $val){
130
131                    $val = SC_Utils_Ex::sfManualEscape($val);
132
133                    if($val == "") {
134                        continue;
135                    }
136
137                    switch ($key){
138                    case 'search_reviewer_name':
139                        $val = ereg_replace(" ", "%", $val);
140                        $val = ereg_replace(" ", "%", $val);
141                        $where.= " AND reviewer_name ILIKE ? ";
142                        $arrval[] = "%$val%";
143                        break;
144
145                    case 'search_reviewer_url':
146                        $val = ereg_replace(" ", "%", $val);
147                        $val = ereg_replace(" ", "%", $val);
148                        $where.= " AND reviewer_url ILIKE ? ";
149                        $arrval[] = "%$val%";
150                        break;
151
152                    case 'search_name':
153                        $val = ereg_replace(" ", "%", $val);
154                        $val = ereg_replace(" ", "%", $val);
155                        $where.= " AND name ILIKE ? ";
156                        $arrval[] = "%$val%";
157                        break;
158
159                    case 'search_product_code':
160                        $val = ereg_replace(" ", "%", $val);
161                        $val = ereg_replace(" ", "%", $val);
162                        $where.= " AND A.product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ? )";
163                        $arrval[] = "%$val%";
164                        break;
165
166                    case 'search_sex':
167                        $tmp_where = "";
168                        //$val=配列の中身,$element=各キーの値(1,2)
169                        if (is_array($val)){
170                            foreach($val as $element) {
171                                if($element != "") {
172                                    if($tmp_where == "") {
173                                        $tmp_where .= " AND (sex = ?";
174                                    } else {
175                                        $tmp_where .= " OR sex = ?";
176                                    }
177                                    $arrval[] = $element;
178                                }
179                            }
180                            if($tmp_where != "") {
181                                $tmp_where .= ")";
182                                $where .= " $tmp_where ";
183                            }
184                        }
185
186                        break;
187
188                    case 'search_recommend_level':
189                        $where.= " AND recommend_level LIKE ? ";
190                        $arrval[] = $val;
191                        break;
192
193                    case 'search_startyear':
194                        if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])){
195                            $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_startyear'], $_POST['search_startmonth'], $_POST['search_startday']);
196                            $where.= " AND A.create_date >= ? ";
197                            $arrval[] = $date;
198                        }
199                        break;
200
201                    case 'search_endyear':
202                        if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])){
203                            $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_endyear'], $_POST['search_endmonth'], $_POST['search_endday']);
204
205                            $end_date = date("Y/m/d",strtotime("1 day" ,strtotime($date)));
206
207                            $where.= " AND A.create_date <= cast('$end_date' as date) ";
208                        }
209                        break;
210                    }
211
212                }
213
214            }
215
216            $order = "A.create_date DESC";
217
218            // ページ送りの処理
219            if(is_numeric($_POST['search_page_max'])) {
220                $page_max = $_POST['search_page_max'];
221            } else {
222                $page_max = SEARCH_PMAX;
223            }
224
225            if (!isset($arrval)) $arrval = array();
226
227            $linemax = $objQuery->count($from, $where, $arrval);
228            $this->tpl_linemax = $linemax;
229
230            $this->tpl_pageno =
231                isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
232
233            // ページ送りの取得
234            $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $page_max,
235                                       "fnNaviSearchPage", NAVI_PMAX);
236            $this->arrPagenavi = $objNavi->arrPagenavi;
237            $startno = $objNavi->start_row;
238
239
240
241            // 取得範囲の指定(開始行番号、行数のセット)
242            $objQuery->setlimitoffset($page_max, $startno);
243
244            // 表示順序
245            $objQuery->setorder($order);
246
247            //検索結果の取得
248            $this->arrReview = $objQuery->select($select, $from, $where, $arrval);
249
250            //CSVダウンロード
251            if ($_POST['mode'] == 'csv'){
252
253                $objCSV = new SC_Helper_CSV_Ex();
254                // オプションの指定
255                $option = "ORDER BY review_id";
256                // CSV出力タイトル行の作成
257                $head = SC_Utils_Ex::sfGetCSVList($objCSV->arrREVIEW_CVSTITLE);
258                $data = $objCSV->lfGetReviewCSV($where, '', $arrval);
259                // CSVを送信する。
260                SC_Utils_Ex::sfCSVDownload($head.$data);
261                exit;
262            }
263        }
264
265        $objView->assignobj($this);
266        $objView->display(MAIN_FRAME);
267    }
268
269    /**
270     * デストラクタ.
271     *
272     * @return void
273     */
274    function destroy() {
275        parent::destroy();
276    }
277
278    // 入力エラーチェック
279    function lfCheckError() {
280        $objErr = new SC_CheckError();
281
282        if (!isset($_POST['mode'])) $_POST['mode'] = "";
283
284        switch ($_POST['mode']){
285        case 'search':
286            $objErr->doFunc(array("投稿者", "search_startyear", "search_startmonth", "search_startday"), array("CHECK_DATE"));
287            $objErr->doFunc(array("開始日", "search_startyear", "search_startmonth", "search_startday"), array("CHECK_DATE"));
288            $objErr->doFunc(array("終了日", "search_endyear", "search_endmonth", "search_endday"), array("CHECK_DATE"));
289            $objErr->doFunc(array("開始日", "終了日", "search_startyear", "search_startmonth", "search_startday", "search_endyear", "search_endmonth", "search_endday"), array("CHECK_SET_TERM"));
290            break;
291
292        case 'complete':
293            $objErr->doFunc(array("おすすめレベル", "recommend_level"), array("SELECT_CHECK"));
294            $objErr->doFunc(array("タイトル", "title", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
295            $objErr->doFunc(array("コメント", "comment", LTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
296            break;
297        }
298        return $objErr->arrErr;
299    }
300}
301?>
Note: See TracBrowser for help on using the repository browser.