1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2008 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 |
---|
25 | require_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 | */ |
---|
34 | class 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 | $this->httpCacheControl('nocache'); |
---|
50 | } |
---|
51 | |
---|
52 | /** |
---|
53 | * Page のプロセス. |
---|
54 | * |
---|
55 | * @return void |
---|
56 | */ |
---|
57 | function process() |
---|
58 | { |
---|
59 | // 認証可否の判定 |
---|
60 | $objSess = new SC_Session(); |
---|
61 | SC_Utils_Ex::sfIsSuccess($objSess); |
---|
62 | |
---|
63 | $objView = new SC_AdminView(); |
---|
64 | // POSTのモードがsearchなら顧客検索開始 |
---|
65 | if($_POST['mode'] == 'search'){ |
---|
66 | $this->objFormParam = new SC_FormParam(); |
---|
67 | // 値の初期化 |
---|
68 | $this->lfInitParam(); |
---|
69 | // POST値の取得 |
---|
70 | $this->objFormParam->setParam($_POST); |
---|
71 | // 入力値の変換 |
---|
72 | $this->objFormParam->convParam(); |
---|
73 | |
---|
74 | // 入力された値を取得する |
---|
75 | $arrForm = $this->objFormParam->getHashArray(); |
---|
76 | |
---|
77 | // エラーチェック |
---|
78 | $this->arrErr = $this->lfCheckError(); |
---|
79 | $is_select = empty($this->arrErr); |
---|
80 | if ($is_select) { |
---|
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 | |
---|
115 | |
---|
116 | if( $is_select === true ){ |
---|
117 | $objQuery = new SC_Query(); |
---|
118 | |
---|
119 | // 既に購入した事がある顧客を取得 |
---|
120 | $col = '*'; |
---|
121 | $from = 'dtb_customer'; |
---|
122 | $order = 'customer_id'; |
---|
123 | $arrCustomer = $objQuery->select($col, $from, $where, $sqlval); |
---|
124 | |
---|
125 | // 顧客情報を取得できたら、テンプレートに |
---|
126 | if( is_array($arrCustomer) === true && count($arrCustomer) > 0){ |
---|
127 | $customer_count = count($arrCustomer); |
---|
128 | if( $customer_count != 0 ){ |
---|
129 | $this->tpl_linemax = $customer_count; |
---|
130 | } |
---|
131 | } else { |
---|
132 | $this->tpl_linemax = null; |
---|
133 | } |
---|
134 | |
---|
135 | // ページ送りの処理 |
---|
136 | if(isset($_POST['search_page_max']) |
---|
137 | && is_numeric($_POST['search_page_max'])) { |
---|
138 | $page_max = $_POST['search_page_max']; |
---|
139 | } else { |
---|
140 | $page_max = SEARCH_PMAX; |
---|
141 | } |
---|
142 | |
---|
143 | // ページ送りの取得 |
---|
144 | $objNavi = new SC_PageNavi($_POST['search_pageno'], $customer_count, $page_max, "fnNaviSearchOnlyPage", NAVI_PMAX); |
---|
145 | $this->tpl_strnavi = $objNavi->strnavi; // 表示文字列 |
---|
146 | $startno = $objNavi->start_row; |
---|
147 | |
---|
148 | // 取得範囲の指定(開始行番号、行数のセット) |
---|
149 | $objQuery->setlimitoffset($page_max, $startno); |
---|
150 | // 表示順序 |
---|
151 | $objQuery->setorder($order); |
---|
152 | // 検索結果の取得 |
---|
153 | $this->arrCustomer = $objQuery->select($col, $from, $where, $sqlval); |
---|
154 | } |
---|
155 | |
---|
156 | } |
---|
157 | // 画面の表示 |
---|
158 | $this->arrForm = $arrForm; |
---|
159 | $objView->assignobj($this); |
---|
160 | $objView->display($this->tpl_mainpage); |
---|
161 | } |
---|
162 | |
---|
163 | /** |
---|
164 | * デストラクタ. |
---|
165 | * |
---|
166 | * @return void |
---|
167 | */ |
---|
168 | function destroy() |
---|
169 | { |
---|
170 | parent::destroy(); |
---|
171 | } |
---|
172 | |
---|
173 | /* パラメータ情報の初期化 */ |
---|
174 | function lfInitParam() { |
---|
175 | $this->objFormParam->addParam("顧客ID", "search_customer_id", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
176 | $this->objFormParam->addParam("顧客名(姓)", "search_name01", STEXT_LEN, "aKV", array("NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK")); |
---|
177 | $this->objFormParam->addParam("顧客名(名)", "search_name02", STEXT_LEN, "aKV", array("NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK")); |
---|
178 | $this->objFormParam->addParam("顧客名(カナ)", 'search_kana01', STEXT_LEN, "CKV", array("NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK")); |
---|
179 | $this->objFormParam->addParam("顧客名(カナ/名)", 'search_kana02', STEXT_LEN, "CKV", array("NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK")); |
---|
180 | } |
---|
181 | |
---|
182 | /* 入力内容のチェック */ |
---|
183 | function lfCheckError() { |
---|
184 | // 入力データを渡す。 |
---|
185 | $arrRet = $this->objFormParam->getHashArray(); |
---|
186 | $objErr = new SC_CheckError($arrRet); |
---|
187 | $objErr->arrErr = $this->objFormParam->checkError(); |
---|
188 | |
---|
189 | return $objErr->arrErr; |
---|
190 | } |
---|
191 | } |
---|
192 | ?> |
---|