source: branches/version-2_5-dev/data/class/pages/admin/customer/LC_Page_Admin_Customer_SearchCustomer.php @ 20116

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