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 |
---|
25 | require_once(CLASS_PATH . "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 | */ |
---|
34 | class 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 | if($_POST['mode'] == 'search'){ |
---|
73 | $this->objFormParam = new SC_FormParam(); |
---|
74 | // 値の初期化 |
---|
75 | $this->lfInitParam(); |
---|
76 | // POST値の取得 |
---|
77 | $this->objFormParam->setParam($_POST); |
---|
78 | // 入力値の変換 |
---|
79 | $this->objFormParam->convParam(); |
---|
80 | |
---|
81 | // 入力された値を取得する |
---|
82 | $arrForm = $this->objFormParam->getHashArray(); |
---|
83 | |
---|
84 | // エラーチェック |
---|
85 | $this->arrErr = $this->lfCheckError(); |
---|
86 | $is_select = empty($this->arrErr); |
---|
87 | if ($is_select) { |
---|
88 | $where = "del_flg = 0"; |
---|
89 | |
---|
90 | // 検索 |
---|
91 | foreach($arrForm as $tmp_key => $val){ |
---|
92 | if( is_array($val) === false && 0 < strlen($val)){ |
---|
93 | $key = strtr($tmp_key , array('search_' => '')); |
---|
94 | switch($key){ |
---|
95 | case 'customer_id': |
---|
96 | $where .= " AND customer_id = ? "; |
---|
97 | $sqlval[$key] = $val; |
---|
98 | break; |
---|
99 | case 'name01': |
---|
100 | $where .= " AND name01 ILIKE ? "; |
---|
101 | $sqlval[$key] = '%'.$val.'%'; |
---|
102 | break; |
---|
103 | case 'name02': |
---|
104 | $where .= " AND name02 ILIKE ? "; |
---|
105 | $sqlval[$key] = '%'.$val.'%'; |
---|
106 | break; |
---|
107 | case 'kana01': |
---|
108 | $where .= " AND kana01 ILIKE ? "; |
---|
109 | $sqlval[$key] = '%'.$val.'%'; |
---|
110 | break; |
---|
111 | case 'kana02': |
---|
112 | $where .= " AND kana02 ILIKE ? "; |
---|
113 | $sqlval[$key] = '%'.$val.'%'; |
---|
114 | break; |
---|
115 | default : |
---|
116 | break; |
---|
117 | } |
---|
118 | } |
---|
119 | } |
---|
120 | } |
---|
121 | |
---|
122 | |
---|
123 | if( $is_select === true ){ |
---|
124 | $objQuery = new SC_Query(); |
---|
125 | |
---|
126 | // 既に購入した事がある顧客を取得 |
---|
127 | $col = '*'; |
---|
128 | $from = 'dtb_customer'; |
---|
129 | $order = 'customer_id'; |
---|
130 | $arrCustomer = $objQuery->select($col, $from, $where, $sqlval); |
---|
131 | |
---|
132 | // 顧客情報を取得できたら、テンプレートに |
---|
133 | if( is_array($arrCustomer) === true && count($arrCustomer) > 0){ |
---|
134 | $customer_count = count($arrCustomer); |
---|
135 | if( $customer_count != 0 ){ |
---|
136 | $this->tpl_linemax = $customer_count; |
---|
137 | } |
---|
138 | } else { |
---|
139 | $this->tpl_linemax = null; |
---|
140 | } |
---|
141 | |
---|
142 | // ページ送りの処理 |
---|
143 | if(isset($_POST['search_page_max']) |
---|
144 | && is_numeric($_POST['search_page_max'])) { |
---|
145 | $page_max = $_POST['search_page_max']; |
---|
146 | } else { |
---|
147 | $page_max = SEARCH_PMAX; |
---|
148 | } |
---|
149 | |
---|
150 | // ページ送りの取得 |
---|
151 | $objNavi = new SC_PageNavi($_POST['search_pageno'], $customer_count, $page_max, "fnNaviSearchOnlyPage", NAVI_PMAX); |
---|
152 | $this->tpl_strnavi = $objNavi->strnavi; // 表示文字列 |
---|
153 | $startno = $objNavi->start_row; |
---|
154 | |
---|
155 | // 取得範囲の指定(開始行番号、行数のセット) |
---|
156 | $objQuery->setLimitOffset($page_max, $startno); |
---|
157 | // 表示順序 |
---|
158 | $objQuery->setOrder($order); |
---|
159 | // 検索結果の取得 |
---|
160 | $this->arrCustomer = $objQuery->select($col, $from, $where, $sqlval); |
---|
161 | } |
---|
162 | |
---|
163 | } |
---|
164 | $this->arrForm = $arrForm; |
---|
165 | } |
---|
166 | |
---|
167 | /** |
---|
168 | * デストラクタ. |
---|
169 | * |
---|
170 | * @return void |
---|
171 | */ |
---|
172 | function destroy() |
---|
173 | { |
---|
174 | parent::destroy(); |
---|
175 | } |
---|
176 | |
---|
177 | /* パラメータ情報の初期化 */ |
---|
178 | function lfInitParam() { |
---|
179 | $this->objFormParam->addParam("顧客ID", "search_customer_id", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
180 | $this->objFormParam->addParam("顧客名(姓)", "search_name01", STEXT_LEN, "aKV", array("NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK")); |
---|
181 | $this->objFormParam->addParam("顧客名(名)", "search_name02", STEXT_LEN, "aKV", array("NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK")); |
---|
182 | $this->objFormParam->addParam("顧客名(カナ)", 'search_kana01', STEXT_LEN, "CKV", array("NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK")); |
---|
183 | $this->objFormParam->addParam("顧客名(カナ/名)", 'search_kana02', STEXT_LEN, "CKV", array("NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK")); |
---|
184 | } |
---|
185 | |
---|
186 | /* 入力内容のチェック */ |
---|
187 | function lfCheckError() { |
---|
188 | // 入力データを渡す。 |
---|
189 | $arrRet = $this->objFormParam->getHashArray(); |
---|
190 | $objErr = new SC_CheckError($arrRet); |
---|
191 | $objErr->arrErr = $this->objFormParam->checkError(); |
---|
192 | |
---|
193 | return $objErr->arrErr; |
---|
194 | } |
---|
195 | } |
---|
196 | ?> |
---|