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

Revision 21684, 5.7 KB checked in by Seasoft, 12 years ago (diff)

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