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

Revision 19805, 8.0 KB checked in by Seasoft, 13 years ago (diff)

#834(パラメータの定数名に「URL」を含むにもかかわらず、パスのみのものがある) 一部実装

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