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

Revision 21563, 5.3 KB checked in by Seasoft, 12 years ago (diff)

#1669 (変数の初期化漏れ)
#1613 (typo修正・ソース整形・ソースコメントの改善)

  • 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-2011 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_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.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_Admin_Ex {
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_subno = '';
49        $this->tpl_maintitle = '商品管理';
50        $this->tpl_subtitle = '商品選択';
51
52        $masterData = new SC_DB_MasterData_Ex();
53        $this->arrPRODUCTSTATUS_COLOR = $masterData->getMasterData('mtb_product_status_color');
54    }
55
56    /**
57     * Page のプロセス.
58     *
59     * @return void
60     */
61    function process() {
62        $this->action();
63        $this->sendResponse();
64    }
65
66    /**
67     * Page のアクション.
68     *
69     * @return void
70     */
71    function action() {
72        $objDb = new SC_Helper_DB_Ex();
73
74        $objFormParam = new SC_FormParam_Ex();
75        $this->lfInitParam($objFormParam);
76        $objFormParam->setParam($_POST);
77        $objFormParam->convParam();
78        $this->arrForm = $objFormParam->getHashArray();
79
80        switch ($this->getMode()) {
81            case 'search':
82                $this->arrProducts = $this->lfGetProducts($objDb);
83                break;
84            default:
85                break;
86        }
87
88        // カテゴリ取得
89        $this->arrCatList = $objDb->sfGetCategoryList();
90        $this->setTemplate($this->tpl_mainpage);
91    }
92
93    /**
94     * デストラクタ.
95     *
96     * @return void
97     */
98    function destroy() {
99        parent::destroy();
100    }
101
102    /**
103     * パラメーター情報の初期化を行う.
104     *
105     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
106     * @return void
107     */
108    function lfInitParam(&$objFormParam) {
109        $objFormParam->addParam('カテゴリ', 'search_category_id', STEXT_LEN, 'n');
110        $objFormParam->addParam('商品名', 'search_name', STEXT_LEN, 'KVa');
111        $objFormParam->addParam('商品コード', 'search_product_code', STEXT_LEN, 'KVa');
112    }
113
114    /* 商品検索結果取得 */
115    function lfGetProducts(&$objDb) {
116        $where = 'del_flg = 0';
117        $arrWhereVal = array();
118
119        /* 入力エラーなし */
120        foreach ($this->arrForm AS $key=>$val) {
121            if($val == '') continue;
122
123            switch ($key) {
124                case 'search_name':
125                    $where .= ' AND name ILIKE ?';
126                    $arrWhereVal[] = "%$val%";
127                    break;
128                case 'search_category_id':
129                    list($tmp_where, $arrTmp) = $objDb->sfGetCatWhere($val);
130                    if ($tmp_where != '') {
131                        $where.= ' AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE ' . $tmp_where . ')';
132                        $arrWhereVal = array_merge((array)$arrWhereVal, (array)$arrTmp);
133                    }
134                    break;
135                case 'search_product_code':
136                    $where .= ' AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code LIKE ? GROUP BY product_id)';
137                    $arrWhereVal[] = "$val%";
138                    break;
139                default:
140                    break;
141            }
142        }
143
144        $order = 'update_date DESC, product_id DESC ';
145
146        $objQuery =& SC_Query_Ex::getSingletonInstance();
147        // 行数の取得
148        $linemax = $objQuery->count('dtb_products', $where, $arrWhereVal);
149        $this->tpl_linemax = $linemax;              // 何件が該当しました。表示用
150
151        // ページ送りの処理
152        $page_max = SC_Utils_Ex::sfGetSearchPageMax($_POST['search_page_max']);
153
154        // ページ送りの取得
155        $objNavi = new SC_PageNavi_Ex($_POST['search_pageno'], $linemax, $page_max, 'fnNaviSearchOnlyPage', NAVI_PMAX);
156        $this->tpl_strnavi = $objNavi->strnavi;     // 表示文字列
157        $startno = $objNavi->start_row;
158
159        // 取得範囲の指定(開始行番号、行数のセット)
160        $objQuery->setLimitOffset($page_max, $startno);
161        // 表示順序
162        $objQuery->setOrder($order);
163
164        // 検索結果の取得
165        // FIXME 商品コードの表示
166        $arrProducts = $objQuery->select('*', SC_Product_Ex::alldtlSQL(), $where, $arrWhereVal);
167        return $arrProducts;
168    }
169}
Note: See TracBrowser for help on using the repository browser.