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

Revision 16582, 11.3 KB checked in by nanasess, 16 years ago (diff)

ライセンス表記変更

  • 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        session_start(); // TODO 必要?
48        $this->tpl_mainpage = 'products/review.tpl';
49        $this->tpl_subnavi = 'products/subnavi.tpl';
50        $this->tpl_mainno = 'products';
51        $this->tpl_subno = 'review';
52        $this->tpl_pager = TEMPLATE_DIR . 'admin/pager.tpl';
53        $this->tpl_subtitle = 'レビュー管理';
54
55        $masterData = new SC_DB_MasterData_Ex();
56        $this->arrPageMax = $masterData->getMasterData("mtb_page_max");
57        $this->arrRECOMMEND = $masterData->getMasterData("mtb_recommend");
58        $this->arrSex = $masterData->getMasterData("mtb_sex");
59    }
60
61    /**
62     * Page のプロセス.
63     *
64     * @return void
65     */
66    function process() {
67        $objView = new SC_AdminView();
68        $objSess = new SC_Session();
69        $objDate = new SC_Date();
70        $objQuery = new SC_Query();
71
72        // 登録・更新検索開始年
73        $objDate->setStartYear(RELEASE_YEAR);
74        $objDate->setEndYear(DATE("Y"));
75        $this->arrStartYear = $objDate->getYear();
76        $this->arrStartMonth = $objDate->getMonth();
77        $this->arrStartDay = $objDate->getDay();
78        // 登録・更新検索終了年
79        $objDate->setStartYear(RELEASE_YEAR);
80        $objDate->setEndYear(DATE("Y"));
81        $this->arrEndYear = $objDate->getYear();
82        $this->arrEndMonth = $objDate->getMonth();
83        $this->arrEndDay = $objDate->getDay();
84
85        // 認証可否の判定
86        SC_Utils_Ex::sfIsSuccess($objSess);
87
88        //レビュー情報のカラムの取得
89        $select="review_id, A.product_id, reviewer_name, sex, recommend_level, ";
90        $select.="reviewer_url, title, comment, A.status, A.create_date, A.update_date, name";
91        $from = "dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ";
92
93        // 検索ワードの引き継ぎ
94        foreach ($_POST as $key => $val) {
95            if (ereg("^search_", $key)) {
96                switch ($key){
97                case 'search_sex':
98                    $this->arrHidden[$key] = SC_Utils_Ex::sfMergeParamCheckBoxes($val);
99                    if(!is_array($val)) {
100                        $this->arrForm[$key] = split("-", $val);
101                    }
102                    break;
103
104                default:
105                    $this->arrHidden[$key] = $val;
106                    break;
107                }
108            }
109        }
110
111        if (!isset($_POST['mode'])) $_POST['mode'] = "";
112
113        if ($_POST['mode'] == "delete"){
114            //レビューの削除
115            $objQuery->exec("UPDATE dtb_review SET del_flg=1 WHERE review_id=?", array($_POST['review_id']));
116        }
117
118        if ($_POST['mode'] == 'search' || $_POST['mode'] == 'csv' || $_POST['mode'] == 'delete'){
119
120            //削除されていない商品を検索
121            $where="A.del_flg = 0 AND B.del_flg = 0";
122            $this->arrForm = $_POST;
123            if (isset($_POST['search_sex']) && !is_array($_POST['search_sex'])){
124                $this->arrForm['search_sex'] = split("-", $_POST['search_sex']);
125            }
126            //エラーチェック
127            $this->arrErr = $this->lfCheckError();
128
129            if (!$this->arrErr){
130                foreach ($_POST as $key => $val){
131
132                    $val = SC_Utils_Ex::sfManualEscape($val);
133
134                    if($val == "") {
135                        continue;
136                    }
137
138                    switch ($key){
139                    case 'search_reviewer_name':
140                        $val = ereg_replace(" ", "%", $val);
141                        $val = ereg_replace(" ", "%", $val);
142                        $where.= " AND reviewer_name ILIKE ? ";
143                        $arrval[] = "%$val%";
144                        break;
145
146                    case 'search_reviewer_url':
147                        $val = ereg_replace(" ", "%", $val);
148                        $val = ereg_replace(" ", "%", $val);
149                        $where.= " AND reviewer_url ILIKE ? ";
150                        $arrval[] = "%$val%";
151                        break;
152
153                    case 'search_name':
154                        $val = ereg_replace(" ", "%", $val);
155                        $val = ereg_replace(" ", "%", $val);
156                        $where.= " AND name ILIKE ? ";
157                        $arrval[] = "%$val%";
158                        break;
159
160                    case 'search_product_code':
161                        $val = ereg_replace(" ", "%", $val);
162                        $val = ereg_replace(" ", "%", $val);
163                        $where.= " AND A.product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ? )";
164                        $arrval[] = "%$val%";
165                        break;
166
167                    case 'search_sex':
168                        $tmp_where = "";
169                        //$val=配列の中身,$element=各キーの値(1,2)
170                        if (is_array($val)){
171                            foreach($val as $element) {
172                                if($element != "") {
173                                    if($tmp_where == "") {
174                                        $tmp_where .= " AND (sex = ?";
175                                    } else {
176                                        $tmp_where .= " OR sex = ?";
177                                    }
178                                    $arrval[] = $element;
179                                }
180                            }
181                            if($tmp_where != "") {
182                                $tmp_where .= ")";
183                                $where .= " $tmp_where ";
184                            }
185                        }
186
187                        break;
188
189                    case 'search_recommend_level':
190                        $where.= " AND recommend_level LIKE ? ";
191                        $arrval[] = $val;
192                        break;
193
194                    case 'search_startyear':
195                        if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])){
196                            $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_startyear'], $_POST['search_startmonth'], $_POST['search_startday']);
197                            $where.= " AND A.create_date >= ? ";
198                            $arrval[] = $date;
199                        }
200                        break;
201
202                    case 'search_endyear':
203                        if (isset($_POST['search_startyear']) && isset($_POST['search_startmonth']) && isset($_POST['search_startday'])){
204                            $date = SC_Utils_Ex::sfGetTimestamp($_POST['search_endyear'], $_POST['search_endmonth'], $_POST['search_endday']);
205
206                            $end_date = date("Y/m/d",strtotime("1 day" ,strtotime($date)));
207
208                            $where.= " AND A.create_date <= cast('$end_date' as date) ";
209                        }
210                        break;
211                    }
212
213                }
214
215            }
216
217            $order = "A.create_date DESC";
218
219            // ページ送りの処理
220            if(is_numeric($_POST['search_page_max'])) {
221                $page_max = $_POST['search_page_max'];
222            } else {
223                $page_max = SEARCH_PMAX;
224            }
225
226            if (!isset($arrval)) $arrval = array();
227
228            $linemax = $objQuery->count($from, $where, $arrval);
229            $this->tpl_linemax = $linemax;
230
231            $this->tpl_pageno =
232                isset($_POST['search_pageno']) ? $_POST['search_pageno'] : "";
233
234            // ページ送りの取得
235            $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, $page_max,
236                                       "fnNaviSearchPage", NAVI_PMAX);
237            $this->arrPagenavi = $objNavi->arrPagenavi;
238            $startno = $objNavi->start_row;
239
240
241
242            // 取得範囲の指定(開始行番号、行数のセット)
243            $objQuery->setlimitoffset($page_max, $startno);
244
245            // 表示順序
246            $objQuery->setorder($order);
247
248            //検索結果の取得
249            $this->arrReview = $objQuery->select($select, $from, $where, $arrval);
250
251            //CSVダウンロード
252            if ($_POST['mode'] == 'csv'){
253
254                $objCSV = new SC_Helper_CSV_Ex();
255                // オプションの指定
256                $option = "ORDER BY review_id";
257                // CSV出力タイトル行の作成
258                $head = SC_Utils_Ex::sfGetCSVList($objCSV->arrREVIEW_CVSTITLE);
259                $data = $objCSV->lfGetReviewCSV($where, '', $arrval);
260                // CSVを送信する。
261                SC_Utils_Ex::sfCSVDownload($head.$data);
262                exit;
263            }
264        }
265
266        $objView->assignobj($this);
267        $objView->display(MAIN_FRAME);
268    }
269
270    /**
271     * デストラクタ.
272     *
273     * @return void
274     */
275    function destroy() {
276        parent::destroy();
277    }
278
279    // 入力エラーチェック
280    function lfCheckError() {
281        $objErr = new SC_CheckError();
282
283        if (!isset($_POST['mode'])) $_POST['mode'] = "";
284
285        switch ($_POST['mode']){
286        case 'search':
287            $objErr->doFunc(array("投稿者", "search_startyear", "search_startmonth", "search_startday"), array("CHECK_DATE"));
288            $objErr->doFunc(array("開始日", "search_startyear", "search_startmonth", "search_startday"), array("CHECK_DATE"));
289            $objErr->doFunc(array("終了日", "search_endyear", "search_endmonth", "search_endday"), array("CHECK_DATE"));
290            $objErr->doFunc(array("開始日", "終了日", "search_startyear", "search_startmonth", "search_startday", "search_endyear", "search_endmonth", "search_endday"), array("CHECK_SET_TERM"));
291            break;
292
293        case 'complete':
294            $objErr->doFunc(array("おすすめレベル", "recommend_level"), array("SELECT_CHECK"));
295            $objErr->doFunc(array("タイトル", "title", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
296            $objErr->doFunc(array("コメント", "comment", LTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
297            break;
298        }
299        return $objErr->arrErr;
300    }
301}
302?>
Note: See TracBrowser for help on using the repository browser.