source: trunk/data/class/pages/admin/customer/LC_Page_Admin_Customer_SearchCustomer.php @ 18758

Revision 18758, 6.9 KB checked in by kajiwara, 16 years ago (diff)

EC-CUBE Ver2.4.4 分コミット。詳細はこちら( http://www.ec-cube.net/release/detail.php?release_id=223

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_PATH . "pages/LC_Page.php");
26
27/**
28 * Admin_Customer_SearchCustomer のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Customer_SearchCustomer extends LC_Page
35{
36
37    // }}}
38    // {{{ functions
39
40    /**
41     * Page を初期化する.
42     *
43     * @return void
44     */
45    function init()
46    {
47        parent::init();
48        $this->tpl_mainpage = 'customer/search_customer.tpl';
49    }
50
51    /**
52     * Page のプロセス.
53     *
54     * @return void
55     */
56    function process()
57    {
58        // 認証可否の判定
59        $objSess = new SC_Session();
60        SC_Utils_Ex::sfIsSuccess($objSess);
61
62        $objView = new SC_AdminView();
63        // POSTのモードがsearchなら顧客検索開始
64        if($_POST['mode'] == 'search'){
65            $this->objFormParam = new SC_FormParam();
66            // 値の初期化
67            $this->lfInitParam();
68            // POST値の取得
69            $this->objFormParam->setParam($_POST);
70            // 入力値の変換
71            $this->objFormParam->convParam();
72
73            // 入力された値を取得する
74            $arrForm = $this->objFormParam->getHashArray();
75
76            // エラーチェック
77            $this->arrErr = $this->lfCheckError();
78            if( is_array($this->arrErr) === true && 0 < count($this->arrErr) ){
79                $is_select = false;
80            }else{
81                $where = "del_flg = 0";
82
83                // 検索
84                foreach($arrForm as $tmp_key => $val){
85                    if( is_array($val) === false && 0 < strlen($val)){
86                        $key = strtr($tmp_key , array('search_' => ''));
87                        switch($key){
88                            case 'customer_id':
89                                $where .= " AND customer_id = ? ";
90                                $sqlval[$key] = $val;
91                                break;
92                            case 'name01':
93                                    $where .= " AND name01 ILIKE ? ";
94                                    $sqlval[$key] = '%'.$val.'%';
95                                break;
96                            case 'name02':
97                                    $where .= " AND name02 ILIKE ? ";
98                                    $sqlval[$key] = '%'.$val.'%';
99                                break;
100                            case 'kana01':
101                                    $where .= " AND kana01 ILIKE ? ";
102                                    $sqlval[$key] = '%'.$val.'%';
103                                break;
104                            case 'kana02':
105                                    $where .= " AND kana02 ILIKE ? ";
106                                    $sqlval[$key] = '%'.$val.'%';
107                                break;
108                            default :
109                                break;
110                        }
111                    }
112                }
113
114                $is_select = true;
115            }
116
117
118            if( $is_select === true ){
119                $objQuery = new SC_Query();
120
121                // 既に購入した事がある顧客を取得
122                $col = '*';
123                $from = 'dtb_customer';
124                $order = 'customer_id';
125                $arrCustomer = $objQuery->select($col, $from, $where, $sqlval);
126
127                // 顧客情報を取得できたら、テンプレートに
128                if( is_array($arrCustomer) === true && count($arrCustomer) > 0){
129                    $customer_count = count($arrCustomer);
130                    if( $customer_count != 0 ){
131                        $this->tpl_linemax = $customer_count;
132                    }
133                } else {
134                    $this->tpl_linemax = null;
135                }
136
137                // ページ送りの処理
138                if(isset($_POST['search_page_max'])
139                   && is_numeric($_POST['search_page_max'])) {
140                    $page_max = $_POST['search_page_max'];
141                } else {
142                    $page_max = SEARCH_PMAX;
143                }
144
145                // ページ送りの取得
146                $objNavi = new SC_PageNavi($_POST['search_pageno'], $customer_count, $page_max, "fnNaviSearchOnlyPage", NAVI_PMAX);
147                $this->tpl_strnavi = $objNavi->strnavi;      // 表示文字列
148                $startno = $objNavi->start_row;
149
150                // 取得範囲の指定(開始行番号、行数のセット)
151                $objQuery->setLimitOffset($page_max, $startno);
152                // 表示順序
153                $objQuery->setOrder($order);
154                // 検索結果の取得
155                $this->arrCustomer = $objQuery->select($col, $from, $where, $sqlval);
156            }
157
158        }
159        // 画面の表示
160        $this->arrForm = $arrForm;
161        $objView->assignobj($this);
162        $objView->display($this->tpl_mainpage);
163    }
164
165    /**
166     * デストラクタ.
167     *
168     * @return void
169     */
170    function destroy()
171    {
172        parent::destroy();
173    }
174
175    /* パラメータ情報の初期化 */
176    function lfInitParam() {
177        $this->objFormParam->addParam("顧客ID", "search_customer_id", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"));
178        $this->objFormParam->addParam("顧客名(姓)", "search_name01", STEXT_LEN, "aKV", array("NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
179        $this->objFormParam->addParam("顧客名(名)", "search_name02", STEXT_LEN, "aKV", array("NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
180        $this->objFormParam->addParam("顧客名(カナ)", 'search_kana01', STEXT_LEN, "CKV", array("NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK"));
181        $this->objFormParam->addParam("顧客名(カナ/名)", 'search_kana02', STEXT_LEN, "CKV", array("NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK"));
182    }
183
184    /* 入力内容のチェック */
185    function lfCheckError() {
186        // 入力データを渡す。
187        $arrRet =  $this->objFormParam->getHashArray();
188        $objErr = new SC_CheckError($arrRet);
189        $objErr->arrErr = $this->objFormParam->checkError();
190
191        return $objErr->arrErr;
192    }
193}
194?>
Note: See TracBrowser for help on using the repository browser.