source: branches/version-2_5-dev/data/class/pages/admin/order/LC_Page_Admin_Order_ProductSelect.php @ 19670

Revision 19670, 8.0 KB checked in by nanasess, 13 years ago (diff)

スマートフォン対応(#787)

  • r19668 の差し戻し
  • SC_Helper_Session::getToken() 内の SC_Helper_Session::createToken() を static に変更
  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • 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_PATH . 'module/Services/JSON.php');
28
29/**
30 * 商品選択 のページクラス.
31 *
32 * @package Page
33 * @author LOCKON CO.,LTD.
34 * @version $Id$
35 */
36class LC_Page_Admin_Order_ProductSelect 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 = 'order/product_select.tpl';
49        $this->tpl_mainno = 'order';
50        $this->tpl_subnavi = '';
51        $this->tpl_subno = "";
52        $this->tpl_subtitle = '商品選択';
53    }
54
55    /**
56     * Page のプロセス.
57     *
58     * @return void
59     */
60    function process() {
61        $this->action();
62        $this->sendResponse();
63    }
64
65    /**
66     * Page のアクション.
67     *
68     * @return void
69     */
70    function action() {
71        $objSess = new SC_Session();
72        $objDb = new SC_Helper_DB_Ex();
73
74        // 認証可否の判定
75        SC_Utils_Ex::sfIsSuccess($objSess);
76
77        if (!isset($_POST['mode'])) $_POST['mode'] = "";
78
79        if ($_GET['no'] != '') {
80            $this->tpl_no = strval($_GET['no']);
81        } elseif ($_POST['no'] != '') {
82            $this->tpl_no = strval($_POST['no']);
83        }
84
85        if ($_POST['mode'] == "search") {
86
87            // POST値の引き継ぎ
88            $this->arrForm = $_POST;
89            // 入力文字の強制変換
90            $this->lfConvertParam();
91
92            $where = "alldtl.del_flg = 0";
93            $arrval = array();
94
95            /* 入力エラーなし */
96            foreach ($this->arrForm as $key => $val) {
97                if($val == "") {
98                    continue;
99                }
100
101                switch ($key) {
102                case 'search_name':
103                    $where .= " AND name ILIKE ?";
104                    $arrval[] = "%$val%";
105                    break;
106                case 'search_category_id':
107                    list($tmp_where, $tmp_arrval) = $objDb->sfGetCatWhere($val);
108                    if($tmp_where != "") {
109                        $where.= " AND alldtl.product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")";
110                        $arrval = array_merge((array)$arrval, (array)$tmp_arrval);
111                    }
112                    break;
113                case 'search_product_code':
114                    $where .= " AND alldtl.product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code LIKE ? GROUP BY product_id)";
115                    $arrval[] = "$val%";
116                    break;
117                default:
118                    break;
119                }
120            }
121
122            // 検索結果対象となる商品の数を取得
123            $objQuery =& SC_Query::getSingletonInstance();
124            $objQuery->setWhere($where);
125            $objProduct = new SC_Product();
126            $linemax = $objProduct->findProductCount($objQuery, $arrval);
127            $this->tpl_linemax = $linemax;   // 何件が該当しました。表示用
128
129            // ページ送りの処理
130            if(isset($_POST['search_page_max'])
131               && is_numeric($_POST['search_page_max'])) {
132                $page_max = $_POST['search_page_max'];
133            } else {
134                $page_max = SEARCH_PMAX;
135            }
136
137            // ページ送りの取得
138            $objNavi = new SC_PageNavi($_POST['search_pageno'], $linemax, $page_max, "fnNaviSearchOnlyPage", NAVI_PMAX);
139            $this->tpl_strnavi = $objNavi->strnavi;     // 表示文字列
140            $startno = $objNavi->start_row;
141
142            $objProduct = new SC_Product();
143            $objQuery =& SC_Query::getSingletonInstance();
144            $objQuery->setWhere($where);
145
146            // 取得範囲の指定(開始行番号、行数のセット)
147            $objQuery->setLimitOffset($page_max, $startno);
148            // 表示順序
149            $objQuery->setOrder($order);
150
151            // 検索結果の取得
152            $arrProduct_id = $objProduct->findProductIdsOrder($objQuery, $arrval);
153
154            $where = "";
155            if (is_array($arrProduct_id) && !empty($arrProduct_id)) {
156                $where = 'product_id IN (' . implode(',', $arrProduct_id) . ')';
157            } else {
158                // 一致させない
159                $where = '0<>0';
160            }
161            $objQuery =& SC_Query::getSingletonInstance();
162            $objQuery->setWhere($where);
163            $arrProducts = $objProduct->lists($objQuery, $arrProduct_id);
164
165            //取得している並び順で並び替え
166            $arrProducts2 = array();
167            foreach($arrProducts as $item) {
168                $arrProducts2[ $item['product_id'] ] = $item;
169            }
170            $this->arrProducts = array();
171            foreach($arrProduct_id as $product_id) {
172                $this->arrProducts[] = $arrProducts2[$product_id];
173            }
174
175            $objProduct->setProductsClassByProductIds($arrProduct_id);
176            $objJson = new Services_JSON();
177            $this->tpl_javascript .= 'productsClassCategories = ' . $objJson->encode($objProduct->classCategories) . '; ';
178
179            foreach ($this->arrProducts as $arrProduct) {
180                $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});\n";
181            }
182
183            $this->tpl_javascript .= 'function fnOnLoad(){' . $js_fnOnLoad . '}';
184            $this->tpl_onload .= 'fnOnLoad(); ';
185
186            // 規格1クラス名
187            $this->tpl_class_name1 = $objProduct->className1;
188
189            // 規格2クラス名
190            $this->tpl_class_name2 = $objProduct->className2;
191
192            // 規格1
193            $this->arrClassCat1 = $objProduct->classCats1;
194
195            // 規格1が設定されている
196            $this->tpl_classcat_find1 = $objProduct->classCat1_find;
197            // 規格2が設定されている
198            $this->tpl_classcat_find2 = $objProduct->classCat2_find;
199            $this->tpl_product_class_id = $objProduct->product_class_id;
200            $this->tpl_stock_find = $objProduct->stock_find;
201        }
202
203        // カテゴリ取得
204        $this->arrCatList = $objDb->sfGetCategoryList();
205    }
206
207    /**
208     * デストラクタ.
209     *
210     * @return void
211     */
212    function destroy() {
213        parent::destroy();
214    }
215
216    /* 取得文字列の変換 */
217    function lfConvertParam() {
218        /*
219         *  文字列の変換
220         *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
221         *  C :  「全角ひら仮名」を「全角かた仮名」に変換
222         *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
223         *  n :  「全角」数字を「半角(ハンカク)」に変換
224         */
225        $arrConvList['search_name'] = "KVa";
226        $arrConvList['search_product_code'] = "KVa";
227
228        // 文字変換
229        foreach ($arrConvList as $key => $val) {
230            // POSTされてきた値のみ変換する。
231            if(isset($this->arrForm[$key])) {
232                $this->arrForm[$key] = mb_convert_kana($this->arrForm[$key] ,$val);
233            }
234        }
235    }
236}
237?>
Note: See TracBrowser for help on using the repository browser.