source: branches/feature-module-update/data/class/pages/admin/products/LC_Page_Admin_Products_ProductSelect.php @ 15557

Revision 15557, 5.4 KB checked in by nanasess, 17 years ago (diff)

クラス化に伴う修正

  • Property svn:keywords set to "Id Revision Date"
Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7
8// {{{ requires
9require_once(CLASS_PATH . "pages/LC_Page.php");
10
11/**
12 * 商品選択 のページクラス.
13 *
14 * @package Page
15 * @author LOCKON CO.,LTD.
16 * @version $Id$
17 */
18class LC_Page_Admin_Products_ProductSelect extends LC_Page {
19
20    // }}}
21    // {{{ functions
22
23    /**
24     * Page を初期化する.
25     *
26     * @return void
27     */
28    function init() {
29        parent::init();
30        $this->tpl_mainpage = 'products/product_select.tpl';
31        $this->tpl_mainno = 'products';
32        $this->tpl_subnavi = '';
33        $this->tpl_subno = "";
34        $this->tpl_subtitle = '商品選択';
35
36    }
37
38    /**
39     * Page のプロセス.
40     *
41     * @return void
42     */
43    function process() {
44        $conn = new SC_DBConn();
45        $objView = new SC_AdminView();
46        $objSess = new SC_Session();
47        $objDb = new SC_Helper_DB_Ex();
48
49        // 認証可否の判定
50        SC_Utils_Ex::sfIsSuccess($objSess);
51
52        if (!isset($_POST['mode'])) $_POST['mode'] = "";
53
54        if ($_POST['mode'] == "search") {
55
56            // POST値の引き継ぎ
57            $this->arrForm = $_POST;
58            // 入力文字の強制変換
59            $this->lfConvertParam();
60
61            $where = "del_flg = 0";
62
63            /* 入力エラーなし */
64            foreach ($this->arrForm as $key => $val) {
65                if($val == "") {
66                    continue;
67                }
68
69                switch ($key) {
70                case 'search_name':
71                    $where .= " AND name ILIKE ?";
72                    $arrval[] = "%$val%";
73                    break;
74                case 'search_category_id':
75                    // 子カテゴリIDの取得
76                    $arrRet = $objDb->sfGetChildsID("dtb_category", "parent_category_id", "category_id", $val);
77                    $tmp_where = "";
78                    foreach ($arrRet as $val) {
79                        if($tmp_where == "") {
80                            $tmp_where.= " AND ( category_id = ?";
81                        } else {
82                            $tmp_where.= " OR category_id = ?";
83                        }
84                        $arrval[] = $val;
85                    }
86                    $where.= $tmp_where . " )";
87                    break;
88                case 'search_product_code':
89                    $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code ILIKE ? GROUP BY product_id)";
90                    $arrval[] = "$val%";
91                    break;
92                default:
93                    break;
94                }
95            }
96
97            $order = "update_date DESC, product_id DESC ";
98
99            // 読み込む列とテーブルの指定
100            $col = "product_id, name, category_id, main_list_image, status, product_code, price01, stock, stock_unlimited";
101            $from = "vw_products_nonclass AS noncls ";
102
103            $objQuery = new SC_Query();
104            // 行数の取得
105            $linemax = $objQuery->count("dtb_products", $where, $arrval);
106            $this->tpl_linemax = $linemax;              // 何件が該当しました。表示用
107
108            // ページ送りの処理
109            if(isset($_POST['search_page_max'])
110               && is_numeric($_POST['search_page_max'])) {
111                $page_max = $_POST['search_page_max'];
112            } else {
113                $page_max = SEARCH_PMAX;
114            }
115
116            // ページ送りの取得
117            $objNavi = new SC_PageNavi($_POST['search_pageno'], $linemax, $page_max, "fnNaviSearchOnlyPage", NAVI_PMAX);
118            $this->tpl_strnavi = $objNavi->strnavi;     // 表示文字列
119            $startno = $objNavi->start_row;
120
121            // 取得範囲の指定(開始行番号、行数のセット)
122            if(DB_TYPE != "mysql") $objQuery->setlimitoffset($page_max, $startno);
123            // 表示順序
124            $objQuery->setorder($order);
125
126            // viewも絞込みをかける(mysql用)
127            //sfViewWhere("&&noncls_where&&", $where, $arrval, $objQuery->order . " " .  $objQuery->setlimitoffset($page_max, $startno, true));
128
129            // 検索結果の取得
130            $this->arrProducts = $objQuery->select($col, $from, $where, $arrval);
131        }
132
133        // カテゴリ取得
134        $this->arrCatList = $objDb->sfGetCategoryList();
135
136        //---- ページ表示
137        $objView->assignobj($this);
138        $objView->display($this->tpl_mainpage);
139    }
140
141    /**
142     * デストラクタ.
143     *
144     * @return void
145     */
146    function destroy() {
147        parent::destroy();
148    }
149
150    /* 取得文字列の変換 */
151    function lfConvertParam() {
152        /*
153         *  文字列の変換
154         *  K :  「半角(ハンカク)片仮名」を「全角片仮名」に変換
155         *  C :  「全角ひら仮名」を「全角かた仮名」に変換
156         *  V :  濁点付きの文字を一文字に変換。"K","H"と共に使用します
157         *  n :  「全角」数字を「半角(ハンカク)」に変換
158         */
159        $arrConvList['search_name'] = "KVa";
160        $arrConvList['search_product_code'] = "KVa";
161
162        // 文字変換
163        foreach ($arrConvList as $key => $val) {
164            // POSTされてきた値のみ変換する。
165            if(isset($this->arrForm[$key])) {
166                $this->arrForm[$key] = mb_convert_kana($this->arrForm[$key] ,$val);
167            }
168        }
169    }
170}
171?>
Note: See TracBrowser for help on using the repository browser.