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

Revision 20507, 5.2 KB checked in by shutta, 13 years ago (diff)

SC_Queryクラスのclass_extends対応

  • 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-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_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_subnavi = '';
49        $this->tpl_subno = "";
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
118        /* 入力エラーなし */
119        foreach ($this->arrForm AS $key=>$val) {
120            if($val == "") continue;
121
122            switch ($key) {
123            case 'search_name':
124                $where .= " AND name ILIKE ?";
125                $arrval[] = "%$val%";
126                break;
127            case 'search_category_id':
128                list($tmp_where, $tmp_arrval) = $objDb->sfGetCatWhere($val);
129                if($tmp_where != "") {
130                    $where.= " AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")";
131                    $arrval = array_merge((array)$arrval, (array)$tmp_arrval);
132                }
133                break;
134            case 'search_product_code':
135                $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code LIKE ? GROUP BY product_id)";
136                $arrval[] = "$val%";
137                break;
138            default:
139                break;
140            }
141        }
142
143        $order = "update_date DESC, product_id DESC ";
144
145        $objQuery =& SC_Query_Ex::getSingletonInstance();
146        // 行数の取得
147        if (empty($arrval)) {
148            $arrval = array();
149        }
150        $linemax = $objQuery->count("dtb_products", $where, $arrval);
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, $arrval);
169        return $arrProducts;
170    }
171}
172?>
Note: See TracBrowser for help on using the repository browser.