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

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