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

Revision 21866, 5.3 KB checked in by h_yoshimoto, 12 years ago (diff)

#1831 Copyrightを更新を誤っているので戻します

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