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

Revision 18815, 5.6 KB checked in by nanasess, 14 years ago (diff)

規格まわりの内部構成変更に伴う修正(#781)

  • 規格のデータ構造を木構造へ変更
  • 商品検索ロジックを SC_Product クラスへできるだけ集約
  • 以下の VIEW を削除
    • vw_category_count;
    • vw_product_class;
    • vw_products_nonclass;
    • vw_cross_products_class;
    • vw_cross_class;
    • vw_download_class;
  • Property svn:eol-style set to LF
  • Property svn:keywords set to "Id Revision Date"
  • 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_PATH . "pages/LC_Page.php");
26
27/**
28 * 商品選択 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Products_ProductSelect extends LC_Page {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mainpage = 'products/product_select.tpl';
47        $this->tpl_mainno = 'products';
48        $this->tpl_subnavi = '';
49        $this->tpl_subno = "";
50        $this->tpl_subtitle = '商品選択';
51
52    }
53
54    /**
55     * Page のプロセス.
56     *
57     * @return void
58     */
59    function process() {
60        $objView = new SC_AdminView();
61        $objSess = new SC_Session();
62        $objDb = new SC_Helper_DB_Ex();
63
64        // 認証可否の判定
65        SC_Utils_Ex::sfIsSuccess($objSess);
66
67        if (!isset($_POST['mode'])) $_POST['mode'] = "";
68
69        if ($_POST['mode'] == "search") {
70
71            // POST値の引き継ぎ
72            $this->arrForm = $_POST;
73            // 入力文字の強制変換
74            $this->lfConvertParam();
75
76            $where = "del_flg = 0";
77
78            /* 入力エラーなし */
79            foreach ($this->arrForm as $key => $val) {
80                if($val == "") {
81                    continue;
82                }
83
84                switch ($key) {
85                case 'search_name':
86                    $where .= " AND name ILIKE ?";
87                    $arrval[] = "%$val%";
88                    break;
89                case 'search_category_id':
90                    list($tmp_where, $tmp_arrval) = $objDb->sfGetCatWhere($val);
91                    if($tmp_where != "") {
92                        $where.= " AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")";
93                        $arrval = array_merge((array)$arrval, (array)$tmp_arrval);
94                    }
95                    break;
96                case 'search_product_code':
97                    $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code LIKE ? GROUP BY product_id)";
98                    $arrval[] = "$val%";
99                    break;
100                default:
101                    break;
102                }
103            }
104
105            $order = "update_date DESC, product_id DESC ";
106
107            $objQuery = new SC_Query();
108            // 行数の取得
109            if (empty($arrval)) {
110                $arrval = array();
111            }
112            $linemax = $objQuery->count("dtb_products", $where, $arrval);
113            $this->tpl_linemax = $linemax;              // 何件が該当しました。表示用
114
115            // ページ送りの処理
116            if(isset($_POST['search_page_max'])
117               && is_numeric($_POST['search_page_max'])) {
118                $page_max = $_POST['search_page_max'];
119            } else {
120                $page_max = SEARCH_PMAX;
121            }
122
123            // ページ送りの取得
124            $objNavi = new SC_PageNavi($_POST['search_pageno'], $linemax, $page_max, "fnNaviSearchOnlyPage", NAVI_PMAX);
125            $this->tpl_strnavi = $objNavi->strnavi;     // 表示文字列
126            $startno = $objNavi->start_row;
127
128            // 取得範囲の指定(開始行番号、行数のセット)
129            $objQuery->setLimitOffset($page_max, $startno);
130            // 表示順序
131            $objQuery->setOrder($order);
132
133            // 検索結果の取得
134            // FIXME 商品コードの表示
135            $this->arrProducts = $objQuery->select("*", SC_Product::alldtlSQL(), $where, $arrval);
136        }
137
138        // カテゴリ取得
139        $this->arrCatList = $objDb->sfGetCategoryList();
140
141        //---- ページ表示
142        $objView->assignobj($this);
143        $objView->display($this->tpl_mainpage);
144    }
145
146    /**
147     * デストラクタ.
148     *
149     * @return void
150     */
151    function destroy() {
152        parent::destroy();
153    }
154
155    /* 取得文字列の変換 */
156    function lfConvertParam() {
157        /*
158         *  文字列の変換
159         *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
160         *  C :  「全角ひら仮名」を「全角かた仮名」に変換
161         *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
162         *  n :  「全角」数字を「半角(ハンカク)」に変換
163         */
164        $arrConvList['search_name'] = "KVa";
165        $arrConvList['search_product_code'] = "KVa";
166
167        // 文字変換
168        foreach ($arrConvList as $key => $val) {
169            // POSTされてきた値のみ変換する。
170            if(isset($this->arrForm[$key])) {
171                $this->arrForm[$key] = mb_convert_kana($this->arrForm[$key] ,$val);
172            }
173        }
174    }
175}
176?>
Note: See TracBrowser for help on using the repository browser.