PluginProbe
Welcart e-Commerce / 2.12.4
Welcart e-Commerce v2.12.4
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
← All changes | classes/dataList.class.php +462 -728 1.4.112.12.4 View file →
@@ -1,728 +1,462 @@
1 -<?php
2 -class dataList
3 -{
4 - var $table; //テーブル名
5 - var $rows; //データ
6 - var $action; //アクション
7 - var $startRow; //表示開始行番号
8 - var $maxRow; //最大表示行数
9 - var $currentPage; //現在のページNo
10 - var $firstPage; //最初のページNo
11 - var $previousPage; //前のページNo
12 - var $nextPage; //次のページNo
13 - var $lastPage; //最終ページNo
14 - var $naviMaxButton; //ページネーション・ナビのボタンの数
15 - var $dataTableNavigation; //ナヴィゲーションhtmlコード
16 - var $arr_period; //表示データ期間
17 - var $arr_search; //サーチ条件
18 - var $searchSql; //簡易絞込みSQL
19 - var $searchSwitchStatus; //サーチ表示スイッチ
20 - var $columns; //データカラム
21 - var $sortColumn; //現在ソート中のフィールド
22 - var $sortOldColumn;
23 - var $sortSwitchs; //各フィールド毎の昇順降順スイッチ
24 - var $userHeaderNames; //ユーザー指定のヘッダ名
25 -//20101202ysk start
26 - var $pageLimit; //ページ制限
27 -//20101202ysk end
28 -
29 - //Constructor
30 - function dataList($tableName, $arr_column)
31 - {
32 -
33 - $this->table = $tableName;
34 - $this->columns = $arr_column;
35 - $this->rows = array();
36 -
37 - $this->maxRow = 30;
38 - $this->naviMaxButton = 11;
39 - $this->firstPage = 1;
40 -//20101202ysk start
41 - $this->pageLimit = 'on';
42 -//20101202ysk end
43 -
44 - $this->SetParamByQuery();
45 -
46 - $this->arr_period = array(__('This month', 'usces'), __('Last month', 'usces'), __('The past one week', 'usces'), __('Last 30 days', 'usces'), __('Last 90days', 'usces'), __('All', 'usces'));
47 -
48 -
49 - }
50 -
51 - function MakeTable()
52 - {
53 -
54 - $this->SetParam();
55 -
56 - switch ($this->action){
57 -
58 - case 'searchIn':
59 - $this->SearchIn();
60 - $this->SetSelectedRow();
61 - $res = $this->GetRows();
62 - break;
63 -
64 - case 'searchOut':
65 - $this->SearchOut();
66 - $this->SetSelectedRow();
67 - $res = $this->GetRows();
68 - break;
69 -
70 - case 'changeSort':
71 - $res = $this->GetRows();
72 - break;
73 -
74 - case 'changePage':
75 - $res = $this->GetRows();
76 - break;
77 -
78 - case 'refresh':
79 - default:
80 - $this->SetDefaultParam();
81 - $res = $this->GetRows();
82 - break;
83 - }
84 -
85 - $this->SetNavi();
86 - $this->SetHeaders();
87 - $this->SetSESSION();
88 -
89 - if($res){
90 -
91 - return TRUE;
92 -
93 - }else{
94 - return FALSE;
95 - }
96 - }
97 -
98 - //DefaultParam
99 - function SetDefaultParam()
100 - {
101 - unset($_SESSION[$this->table]);
102 - $this->startRow = 0;
103 - $this->currentPage = 1;
104 - if(isset($_SESSION[$this->table]['arr_search'])){
105 - $this->arr_search = $_SESSION[$this->table]['arr_search'];
106 - }else{
107 - $this->arr_search = array('period'=>'3', 'column'=>'', 'word'=>'');
108 - }
109 - if(isset($_SESSION[$this->table]['searchSwitchStatus'])){
110 - $this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus'];
111 - }else{
112 - $this->searchSwitchStatus = 'OFF';
113 - }
114 - $this->searchSql = '';
115 - $this->sortColumn = 'ID';
116 - foreach($this->columns as $value ){
117 - $this->sortSwitchs[$value] = 'DESC';
118 - }
119 -// $this->SetDefaultColumns();
120 -
121 -
122 -// if($optionValue = $this->GetOptions($this->table, 'userHeaderNames')){
123 -// $this->userHeaderNames = $optionValue;
124 -// }else{
125 -// for($i=0; $i<count($this->defaultColumns); $i++){
126 -// $headerKey = $this->defaultColumns[$i];
127 -// $this->userHeaderNames[$headerKey] = $this->defaultColumns[$i];
128 -// }
129 -// $this->SetOptions($this->table, 'userHeaderNames', $this->userHeaderNames);
130 -// }
131 -// if($optionValue = $this->GetOptions($this->table, 'displayColumns')){
132 -// $this->displayColumns = $optionValue;
133 -// }else{
134 -// $this->displayColumns = $this->defaultColumns;
135 -// $this->SetOptions($this->table, 'displayColumns', $this->displayColumns);
136 -// }
137 -// //フィールドのデータタイプ
138 -// if($optionValue = $this->GetOptions($this->table, 'columnTypes')){
139 -// $this->columnTypes = $optionValue;
140 -// }else{
141 -// for($i=1; $i<count($this->defaultColumns); $i++){
142 -// $headerKey = $this->defaultColumns[$i];
143 -// $this->columnTypes[$headerKey] = 0;
144 -// }
145 -// $this->SetOptions($this->table, 'columnTypes', $this->columnTypes);
146 -// }
147 -// //選択タイプ用ヴァリュー
148 -// if($optionValue = $this->GetOptions($this->table, 'valueLabels')){
149 -// $this->valueLabels = $optionValue;
150 -// }else{
151 -// for($i=1; $i<count($this->defaultColumns); $i++){
152 -// $headerKey = $this->defaultColumns[$i];
153 -// $this->valueLabels[$headerKey] = '';
154 -// }
155 -// $this->SetOptions($this->table, 'valueLabels', $this->valueLabels);
156 -// }
157 -
158 -
159 - $this->SetTotalRow();
160 - $this->SetSelectedRow();
161 -
162 - }
163 -
164 - function SetParam()
165 - {
166 - $this->startRow = ($this->currentPage-1) * $this->maxRow;
167 - //$this->totalRow = $_SESSION[$this->table]['totalRow'];
168 -// $this->defaultColumns = $_SESSION[$this->table]['defaultColumns'];
169 -// $this->listPatternRows = $_SESSION[$this->table]['listPatternRows'];
170 -// $this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus'];
171 - }
172 -
173 - function SetParamByQuery()
174 - {
175 -
176 -// if(isset($_REQUEST['changeDispColumn'])){
177 -//
178 -// $this->action = 'changeDispColumn';
179 -// $this->displayColumns = $_POST['checkedColumns'];
180 -// $this->SetOptions($this->table, 'displayColumns', $this->displayColumns);
181 -// $getnames = $_POST['userHeaderNames'];
182 -// $coltypes = $_POST['columnTypes'];
183 -// $vallabels = $_POST['valueLabels'];
184 -// $this->SetDefaultColumns();
185 -// for($i=0; $i< count($this->defaultColumns); $i++){
186 -// $headerKey = $this->defaultColumns[$i];
187 -// if($getnames[$i] == ''){
188 -// $this->userHeaderNames[$headerKey] = $this->defaultColumns[$i];
189 -// }else{
190 -// $this->userHeaderNames[$headerKey] = htmlspecialchars($getnames[$i]);
191 -// }
192 -// }
193 -// $this->SetOptions($this->table, 'userHeaderNames', $this->userHeaderNames);
194 -// for($i=1; $i< count($this->defaultColumns); $i++){
195 -// $headerKey = $this->defaultColumns[$i];
196 -// if(($coltypes[$i-1] == 1 || $coltypes[$i-1] == 2) && $vallabels[$i-1] == ''){
197 -// $valstr = $this->GetSelectData($headerKey);
198 -// $this->valueLabels[$headerKey] = $valstr;
199 -// }else{
200 -// $this->valueLabels[$headerKey] = htmlspecialchars($vallabels[$i-1]);
201 -// }
202 -// $this->columnTypes[$headerKey] = htmlspecialchars($coltypes[$i-1]);
203 -// }
204 -// $this->SetOptions($this->table, 'columnTypes', $this->columnTypes);
205 -// $this->SetOptions($this->table, 'valueLabels', $this->valueLabels);
206 -//
207 -// $this->currentPage = $_SESSION[$this->table]['currentPage'];
208 -// $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
209 -// $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
210 -// $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
211 -// $this->searchSql = $_SESSION[$this->table]['searchSql'];
212 -// $this->searchs = $_SESSION[$this->table]['searchs'];
213 -// $this->totalRow = $_SESSION[$this->table]['totalRow'];
214 -// $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
215 -//
216 -//
217 - if(isset($_REQUEST['changePage'])){
218 -
219 - $this->action = 'changePage';
220 - $this->currentPage = $_REQUEST['changePage'];
221 -
222 - $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
223 - $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
224 - $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
225 - $this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus'];
226 -// $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
227 -// $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
228 - $this->searchSql = $_SESSION[$this->table]['searchSql'];
229 -// $this->arr_search = $_SESSION[$this->table]['searchs'];
230 - $this->totalRow = $_SESSION[$this->table]['totalRow'];
231 - $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
232 -// $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
233 -// $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
234 -
235 - }else if(isset($_REQUEST['changeSort'])){
236 -
237 - $this->action = 'changeSort';
238 - $this->sortOldColumn = $this->sortColumn;
239 - $this->sortColumn = $_REQUEST['changeSort'];
240 - $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
241 - $this->sortSwitchs[$this->sortColumn] = $_REQUEST['switch'];
242 -
243 - $this->currentPage = $_SESSION[$this->table]['currentPage'];
244 - $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
245 -// $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
246 -// $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
247 - $this->searchSql = $_SESSION[$this->table]['searchSql'];
248 - $this->arr_search = $_SESSION[$this->table]['arr_search'];
249 - $this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus'];
250 - $this->totalRow = $_SESSION[$this->table]['totalRow'];
251 - $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
252 -// $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
253 -// $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
254 -
255 - } else if(isset($_REQUEST['searchIn'])){
256 -
257 - $this->action = 'searchIn';
258 - $this->arr_search['column'] = $_REQUEST['search']['column'];
259 - $this->arr_search['word'] = $_REQUEST['search']['word'];
260 - $this->arr_search['period'] = isset($_REQUEST['search']['period']) ? intval($_REQUEST['search']['period']) : 0;
261 - $this->searchSwitchStatus = $_REQUEST['searchSwitchStatus'];
262 -
263 - $this->currentPage = 1;
264 - $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
265 - $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
266 - $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
267 -// $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
268 -// $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
269 -// $this->searchSql = $_SESSION[$this->table]['searchSql'];
270 - $this->totalRow = $_SESSION[$this->table]['totalRow'];
271 -// $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
272 -// $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
273 -//
274 - }else if(isset($_REQUEST['searchOut'])){
275 -
276 - $this->action = 'searchOut';
277 - $this->arr_search['column'] = '';
278 - $this->arr_search['word'] = '';
279 - $this->arr_search['period'] = $_SESSION[$this->table]['arr_search']['period'];
280 - $this->searchSwitchStatus = $_REQUEST['searchSwitchStatus'];
281 -
282 - $this->currentPage = 1;
283 - $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
284 - $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
285 - $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
286 -// $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
287 -// $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
288 -// $this->searchSql = $_SESSION[$this->table]['searchSql'];
289 - $this->totalRow = $_SESSION[$this->table]['totalRow'];
290 -// $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
291 -// $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
292 -
293 -// }else if(isset($_REQUEST['changeListPattern'])){
294 -//
295 -// $this->action = 'changeListPattern';
296 -// $this->listPatternId = $_REQUEST['changeListPattern'];
297 -// setcookie($this->table.'listPatternId', $this->listPatternId, $this->expiration);;
298 -//
299 -// $this->currentPage = 1;
300 -// $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
301 -// $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
302 -// $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
303 -// $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
304 -// $this->searchSql = $_SESSION[$this->table]['searchSql'];
305 -// $this->searchs = $_SESSION[$this->table]['searchs'];
306 -// $this->totalRow = $_SESSION[$this->table]['totalRow'];
307 -// $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
308 -// $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
309 -//
310 -// }else if(isset($_POST['tableAction']) && ($_POST['tableAction'] == 'deletListMember')){
311 -//
312 -// $this->action = 'deletListMember';
313 -//
314 -// $this->currentPage = 1;
315 -// $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
316 -// $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
317 -// $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
318 -// $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
319 -// $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
320 -// $this->searchSql = $_SESSION[$this->table]['searchSql'];
321 -// $this->searchs = $_SESSION[$this->table]['searchs'];
322 -// $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
323 -// $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
324 -//
325 -// }else if(isset($_REQUEST['uploadCSV'])){
326 -//
327 -// $this->action = 'uploadCSV';
328 -//
329 -// $this->currentPage = $_SESSION[$this->table]['currentPage'];
330 -// $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
331 -// $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
332 -// $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
333 -// $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
334 -// $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
335 -// $this->searchSql = $_SESSION[$this->table]['searchSql'];
336 -// $this->searchs = $_SESSION[$this->table]['searchs'];
337 -// $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
338 -// $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
339 -//
340 -// }else if(isset($_REQUEST['tableAction']) && ($_POST['tableAction'] == 'downloadCSV')){
341 -//
342 -// $this->action = 'downloadCSV';
343 -//
344 -// $this->currentPage = $_SESSION[$this->table]['currentPage'];
345 -// $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
346 -// $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
347 -// $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
348 -// $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
349 -// $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
350 -// $this->searchSql = $_SESSION[$this->table]['searchSql'];
351 -// $this->searchs = $_SESSION[$this->table]['searchs'];
352 -// $this->totalRow = $_SESSION[$this->table]['totalRow'];
353 -// $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
354 -// $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
355 -// $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
356 -//
357 - }else if(isset($_REQUEST['refresh'])){
358 -
359 - $this->action = 'refresh';
360 -
361 - $this->currentPage = $_SESSION[$this->table]['currentPage'];
362 - $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
363 - $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
364 - $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
365 -// $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
366 -// $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
367 - $this->searchSql = $_SESSION[$this->table]['searchSql'];
368 - $this->arr_search = $_SESSION[$this->table]['arr_search'];
369 - $this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus'];
370 - $this->totalRow = $_SESSION[$this->table]['totalRow'];
371 - $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
372 -// $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
373 -// $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
374 -
375 -// }else if(isset($_REQUEST['editMember']) && ($_POST['editMember'] == 'edit')){
376 -//
377 -// $this->action = 'editMember';
378 -// $this->editMemberId = $_POST['memberId'];
379 -// $this->currentPage = $_SESSION[$this->table]['currentPage'];
380 -// $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
381 -// $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
382 -// $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
383 -// $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
384 -// $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
385 -// $this->searchSql = $_SESSION[$this->table]['searchSql'];
386 -// $this->searchs = $_SESSION[$this->table]['searchs'];
387 -// $this->totalRow = $_SESSION[$this->table]['totalRow'];
388 -// $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
389 -// $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
390 -//
391 -// }else if(isset($_REQUEST['editMember']) && ($_POST['editMember'] == 'add')){
392 -//
393 -// $this->action = 'addMember';
394 -// $this->editMemberId = $_POST['memberId'];
395 -// $this->currentPage = $_SESSION[$this->table]['currentPage'];
396 -// $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
397 -// $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
398 -// $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
399 -// $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
400 -// $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
401 -// $this->searchSql = $_SESSION[$this->table]['searchSql'];
402 -// $this->searchs = $_SESSION[$this->table]['searchs'];
403 -// $this->totalRow = $_SESSION[$this->table]['totalRow'];
404 -// $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
405 -// $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
406 -//
407 -// }else if(isset($_REQUEST['getMemberData'])){
408 -//
409 -// $this->action = 'getMemberData';
410 -// $this->editMemberId = $_REQUEST['getMemberData'];
411 -//
412 -// $this->currentPage = $_SESSION[$this->table]['currentPage'];
413 -// $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
414 -// $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
415 -// $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
416 -// $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
417 -// $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
418 -// $this->searchSql = $_SESSION[$this->table]['searchSql'];
419 -// $this->searchs = $_SESSION[$this->table]['searchs'];
420 -// $this->totalRow = $_SESSION[$this->table]['totalRow'];
421 -// $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
422 -// $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
423 -// $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
424 -//
425 -// }else if(isset($_REQUEST['editListPattern'])){
426 -//
427 -// if($_REQUEST['editListPattern'] == 'add'){
428 -// $this->action = 'addListPattern';
429 -// }
430 -// $this->editListPatternName = $_POST['patternName'];
431 -// $this->editListPatternShikis = $_POST['shikis'];
432 -// $this->editListPatternFieldNames = $_POST['fieldNames'];
433 -// $this->editListPatternFieldDatas = $_POST['fieldDatas'];
434 -//
435 -// $this->currentPage = $_SESSION[$this->table]['currentPage'];
436 -// $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
437 -// $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
438 -// $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
439 -// $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
440 -// $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
441 -// $this->searchSql = $_SESSION[$this->table]['searchSql'];
442 -// $this->searchs = $_SESSION[$this->table]['searchs'];
443 -// $this->totalRow = $_SESSION[$this->table]['totalRow'];
444 -// $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
445 -// $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
446 -// $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
447 -//
448 -// }else if(isset($_REQUEST['tableAction']) && ($_POST['tableAction'] == 'rowButtonDelete')){
449 -//
450 -// $this->action = 'rowButtonDelete';
451 -// $this->tableValue = $_POST['tableValue'];
452 -//
453 -// $this->currentPage = $_SESSION[$this->table]['currentPage'];
454 -// $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
455 -// $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
456 -// $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
457 -// $this->listPatternId = $_SESSION[$this->table]['listPatternId'];
458 -// $this->displayColumns = $_SESSION[$this->table]['displayColumns'];
459 -// $this->searchSql = $_SESSION[$this->table]['searchSql'];
460 -// $this->searchs = $_SESSION[$this->table]['searchs'];
461 -// $this->totalRow = $_SESSION[$this->table]['totalRow'];
462 -// $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
463 -// $this->columnTypes = $_SESSION[$this->table]['columnTypes'];
464 -// $this->valueLabels = $_SESSION[$this->table]['valueLabels'];
465 -//
466 -// }else if(isset($_REQUEST['changeSearchSwitch'])){
467 -//
468 -// $this->action = 'changeSearchSwitch';
469 -// $this->searchSwitchStatus = $_REQUEST['changeSearchSwitch'];
470 -//
471 -// }else if(isset($_REQUEST['changeListPatternAjax'])){
472 -//
473 -// $this->action = 'changeListPatternAjax';
474 -// $this->listPatternId = $_REQUEST['changeListPatternAjax'];
475 -// if(isset($_REQUEST['overlap'])){
476 -// $this->overlap = $_REQUEST['overlap'];
477 -// }else{
478 -// $this->overlap = '';
479 -// }
480 -//
481 - }else{
482 -
483 - $this->action = 'default';
484 - }
485 - }
486 -
487 - //GetRows
488 - function GetRows()
489 - {
490 - global $wpdb;
491 - $where = $this->GetWhere();
492 - $order = ' ORDER BY `' . $this->sortColumn . '` ' . $this->sortSwitchs[$this->sortColumn];
493 -//20101202ysk start
494 - if($this->pageLimit == 'on') {
495 -//20101202ysk end
496 - $limit = ' LIMIT ' . $this->startRow . ', ' . $this->maxRow;
497 -//20101202ysk start
498 - }else{
499 - $limit = '';
500 - }
501 -//20101202ysk end
502 -
503 - $query = $wpdb->prepare("SELECT ID, CONCAT(mem_name1, ' ', mem_name2) AS name,
504 - CONCAT(mem_pref, mem_address1, mem_address2, ' ', mem_address3) AS address,
505 - mem_tel AS tel, mem_email AS email, DATE_FORMAT(mem_registered, %s) AS date,
506 - mem_point AS point
507 - FROM {$this->table}",
508 - '%Y-%m-%d %H:%i');
509 -
510 - $query .= $where . $order . $limit;
511 - //var_dump($query);
512 -
513 - $this->rows = $wpdb->get_results($query, ARRAY_A);
514 - return $this->rows;
515 - }
516 -
517 - function SetTotalRow()
518 - {
519 - global $wpdb;
520 - $query = "SELECT COUNT(ID) AS ct FROM {$this->table}";
521 - $res = $wpdb->get_var($query);
522 - $this->totalRow = $res;
523 - }
524 -
525 - function SetSelectedRow()
526 - {
527 - global $wpdb;
528 - $where = $this->GetWhere();
529 - $query = $wpdb->prepare("SELECT ID, CONCAT(mem_name1, ' ', mem_name2) AS name,
530 - CONCAT(mem_pref, mem_address1, mem_address2, ' ', mem_address3) AS address,
531 - mem_tel AS tel, mem_email AS email, DATE_FORMAT(mem_registered, %s) AS date,
532 - mem_point AS point
533 - FROM {$this->table}",
534 - '%Y-%m-%d %H:%i');
535 -
536 - $query .= $where;
537 - $rows = $wpdb->get_results($query, ARRAY_A);
538 - $this->selectedRow = count($rows);
539 -
540 - }
541 -
542 - function GetWhere()
543 - {
544 - $str = '';
545 - $thismonth = date('Y-m-01 00:00:00');
546 - $lastmonth = date('Y-m-01 00:00:00', mktime(0, 0, 0, date('m')-1, 1, date('Y')));
547 - $lastweek = date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m'), date('d')-7, date('Y')));
548 - $last30 = date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m'), date('d')-30, date('Y')));
549 - $last90 = date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m'), date('d')-90, date('Y')));
550 -// switch ( $this->arr_search['period'] ) {
551 -// case 0:
552 -// $str = " WHERE order_date >= '{$thismonth}'";
553 -// break;
554 -// case 1:
555 -// $str = " WHERE order_date >= '{$lastmonth}' AND order_date < '{$thismonth}'";
556 -// break;
557 -// case 2:
558 -// $str = " WHERE order_date >= '{$lastweek}'";
559 -// break;
560 -// case 3:
561 -// $str = " WHERE order_date >= '{$last30}'";
562 -// break;
563 -// case 4:
564 -// $str = " WHERE order_date >= '{$last90}'";
565 -// break;
566 -// case 5:
567 -// $str = "";
568 -// break;
569 -// }
570 -
571 - if( WCUtils::is_blank($str) && !WCUtils::is_blank($this->searchSql) ){
572 - $str = ' HAVING ' . $this->searchSql;
573 - }else if($str != '' && $this->searchSql != ''){
574 - $str .= ' HAVING ' . $this->searchSql;
575 - }
576 - return $str;
577 - }
578 -
579 - function SearchIn()
580 - {
581 - if($this->arr_search['column'] == 'none' || WCUtils::is_blank($this->arr_search['column']) || WCUtils::is_blank($this->arr_search['word']) )
582 - return;//$this->searchSql = $sql;
583 - else
584 - $this->searchSql = '`' . $this->arr_search['column'] . '` LIKE '."'%" . esc_sql($this->arr_search['word']) . "%'";
585 - }
586 -
587 - function SearchOut()
588 - {
589 - $this->searchSql = '';
590 - }
591 -
592 - function SetNavi()
593 - {
594 -
595 - $this->lastPage = ceil($this->selectedRow / $this->maxRow);
596 - $this->previousPage = ($this->currentPage - 1 == 0) ? 1 : $this->currentPage - 1;
597 - $this->nextPage = ($this->currentPage + 1 > $this->lastPage) ? $this->lastPage : $this->currentPage + 1;
598 -
599 - for($i=0; $i<$this->naviMaxButton; $i++){
600 - if($i > $this->lastPage-1) break;
601 - if($this->lastPage <= $this->naviMaxButton) {
602 - $box[] = $i+1;
603 - }else{
604 - if($this->currentPage <= 6) {
605 - $label = $i + 1;
606 - $box[] = $label;
607 - }else{
608 - $label = $i + 1 + $this->currentPage - 6;
609 - $box[] = $label;
610 - if($label == $this->lastPage) break;
611 - }
612 - }
613 - }
614 -
615 - $html = '';
616 - $html .= '<ul class="clearfix">'."\n";
617 - $html .= '<li class="rowsnum">' . $this->selectedRow . ' / ' . $this->totalRow . ' ' . __('cases', 'usces') . '</li>' . "\n";
618 - if(($this->currentPage == 1) || ($this->selectedRow == 0)){
619 - $html .= '<li class="navigationStr">first&lt;&lt;</li>' . "\n";
620 - $html .= '<li class="navigationStr">prev&lt;</li>'."\n";
621 - }else{
622 - $html .= '<li class="navigationStr"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_memberlist&changePage=1">first&lt;&lt;</a></li>' . "\n";
623 - $html .= '<li class="navigationStr"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_memberlist&changePage=' . $this->previousPage . '">prev&lt;</a></li>'."\n";
624 - }
625 - if($this->selectedRow > 0) {
626 - for($i=0; $i<count($box); $i++){
627 - if($box[$i] == $this->currentPage){
628 - $html .= '<li class="navigationButtonSelected">' . $box[$i] . '</li>'."\n";
629 - }else{
630 - $html .= '<li class="navigationButton"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_memberlist&changePage=' . $box[$i] . '">' . $box[$i] . '</a></li>'."\n";
631 - }
632 - }
633 - }
634 - if(($this->currentPage == $this->lastPage) || ($this->selectedRow == 0)){
635 - $html .= '<li class="navigationStr">&gt;next</li>'."\n";
636 - $html .= '<li class="navigationStr">&gt;&gt;last</li>'."\n";
637 - }else{
638 - $html .= '<li class="navigationStr"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_memberlist&changePage=' . $this->nextPage . '">&gt;next</a></li>'."\n";
639 - $html .= '<li class="navigationStr"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_memberlist&changePage=' . $this->lastPage . '">&gt;&gt;last</a></li>'."\n";
640 - }
641 - if($this->searchSwitchStatus == 'OFF'){
642 - $html .= '<li class="rowsnum"><a style="cursor:pointer;" id="searchVisiLink" onclick="toggleVisibility(\'searchBox\');">' . __('Show the Operation field', 'usces') . '</a>'."\n";
643 - }else{
644 - $html .= '<li class="rowsnum"><a style="cursor:pointer;" id="searchVisiLink" onclick="toggleVisibility(\'searchBox\');">' . __('hide the Operation field', 'usces') . '</a>'."\n";
645 - }
646 -
647 - $html .= '<li class="refresh"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_memberlist&refresh">' . __('updates it to latest information', 'usces') . '</a></li>' . "\n";
648 - $html .= '</ul>'."\n";
649 -
650 - $this->dataTableNavigation = $html;
651 - }
652 -
653 - function SetSESSION()
654 - {
655 -
656 - $_SESSION[$this->table]['startRow'] = $this->startRow; //表示開始行番号
657 - $_SESSION[$this->table]['sortColumn'] = $this->sortColumn; //現在ソート中のフィールド
658 - $_SESSION[$this->table]['totalRow'] = $this->totalRow; //全行数
659 - $_SESSION[$this->table]['selectedRow'] = $this->selectedRow; //絞り込まれた行数
660 - $_SESSION[$this->table]['currentPage'] = $this->currentPage; //現在のページNo
661 - $_SESSION[$this->table]['previousPage'] = $this->previousPage; //前のページNo
662 - $_SESSION[$this->table]['nextPage'] = $this->nextPage; //次のページNo
663 - $_SESSION[$this->table]['lastPage'] = $this->lastPage; //最終ページNo
664 -// $_SESSION[$this->table]['displayColumns'] = $this->displayColumns;//実際に表示するフィールド
665 -// $_SESSION[$this->table]['defaultColumns'] = $this->defaultColumns;//全てのフィールド
666 - $_SESSION[$this->table]['userHeaderNames'] = $this->userHeaderNames;//全てのフィールド
667 - $_SESSION[$this->table]['headers'] = $this->headers;//表示するヘッダ文字列
668 - $_SESSION[$this->table]['rows'] = $this->rows; //表示する行オブジェクト
669 - $_SESSION[$this->table]['sortSwitchs'] = $this->sortSwitchs; //各フィールド毎の昇順降順スイッチ
670 - $_SESSION[$this->table]['dataTableNavigation'] = $this->dataTableNavigation;
671 -// $_SESSION[$this->table]['listPatternId'] = $this->listPatternId; //絞込みSQL文(listPatternテーブルより取得)
672 -// $_SESSION[$this->table]['listPatternRows'] = $this->listPatternRows;
673 - $_SESSION[$this->table]['searchSql'] = $this->searchSql;
674 -// $_SESSION[$this->table]['listPatternNavigation'] = $this->listPatternNavigation;
675 -// $_SESSION[$this->table]['listPatternSelect'] = $this->listPatternSelect;
676 - $_SESSION[$this->table]['arr_search'] = $this->arr_search;
677 - $_SESSION[$this->table]['searchSwitchStatus'] = $this->searchSwitchStatus;
678 -// $_SESSION[$this->table]['useListPattern'] = $this->useListPattern;
679 -// $_SESSION[$this->table]['useEditField'] = $this->useEditField;
680 -// $_SESSION[$this->table]['useUpload'] = $this->useUpload;
681 -// $_SESSION[$this->table]['useDownload'] = $this->useDownload;
682 -// $_SESSION[$this->table]['useAllDelete'] = $this->useAllDelete;
683 -// $_SESSION[$this->table]['useBackButton'] = $this->useBackButton;
684 -// $_SESSION[$this->table]['useNewButton'] = $this->useNewButton;
685 -// $_SESSION[$this->table]['useDoubleClickEdit'] = $this->useDoubleClickEdit;
686 -// $_SESSION[$this->table]['columnTypes'] = $this->columnTypes;
687 -// $_SESSION[$this->table]['valueLabels'] = $this->valueLabels;
688 - }
689 -
690 - function SetHeaders()
691 - {
692 - foreach ($this->columns as $key => $value){
693 - if($value == $this->sortColumn){
694 - if($this->sortSwitchs[$value] == 'ASC'){
695 - $str = __('[ASC]', 'usces');
696 - $switch = 'DESC';
697 - }else{
698 - $str = __('[DESC]', 'usces');
699 - $switch = 'ASC';
700 - }
701 - $this->headers[$value] = '<a href="' . site_url() . '/wp-admin/admin.php?page=usces_memberlist&changeSort=' . $value . '&switch=' . $switch . '"><span class="sortcolumn">' . $key . ' ' . $str . '</span></a>';
702 - }else{
703 - $switch = $this->sortSwitchs[$value];
704 - $this->headers[$value] = '<a href="' . site_url() . '/wp-admin/admin.php?page=usces_memberlist&changeSort=' . $value . '&switch=' . $switch . '"><span>' . $key . '</span></a>';
705 - }
706 - }
707 - //$this->headers = array_keys($this->columns);
708 - }
709 -
710 - function GetSearchs()
711 - {
712 - return $this->arr_search;
713 - }
714 -
715 - function GetListheaders()
716 - {
717 - return $this->headers;
718 - }
719 -
720 - function GetDataTableNavigation()
721 - {
722 - return $this->dataTableNavigation;
723 - }
724 -
725 -}
726 -
727 -
728 -?>
1 +<?php
2 +class dataList
3 +{
4 + var $table; //テーブル名
5 + var $rows; //データ
6 + var $action; //アクション
7 + var $startRow; //表示開始行番号
8 + var $maxRow; //最大表示行数
9 + var $currentPage; //現在のページNo
10 + var $firstPage; //最初のページNo
11 + var $previousPage; //前のページNo
12 + var $nextPage; //次のページNo
13 + var $lastPage; //最終ページNo
14 + var $naviMaxButton; //ページネーション・ナビのボタンの数
15 + var $dataTableNavigation; //ナヴィゲーションhtmlコード
16 + var $arr_period; //表示データ期間
17 + var $arr_search; //サーチ条件
18 + var $searchSql; //簡易絞込みSQL
19 + var $searchSwitchStatus; //サーチ表示スイッチ
20 + var $columns; //データカラム
21 + var $sortColumn; //現在ソート中のフィールド
22 + var $sortOldColumn;
23 + var $sortSwitchs; //各フィールド毎の昇順降順スイッチ
24 + var $userHeaderNames; //ユーザー指定のヘッダ名
25 + var $pageLimit; //ページ制限
26 + var $placeholder_escape;
27 + var $data_cookie;
28 +
29 + public $totalRow;
30 + public $selectedRow;
31 + public $headers;
32 +
33 + //Constructor
34 + function __construct($tableName, $arr_column)
35 + {
36 +
37 + $this->table = $tableName;
38 + $this->columns = $arr_column;
39 + $this->rows = array();
40 +
41 + $this->maxRow = apply_filters( 'usces_filter_memberlist_maxrow', 30 );
42 + $this->naviMaxButton = 11;
43 + $this->firstPage = 1;
44 + $this->pageLimit = 'on';
45 +
46 + $this->getCookie();
47 + $this->SetDefaultParam();
48 + $this->SetParamByQuery();
49 + $this->validationSearchParameters();
50 +
51 + $this->arr_period = array(__('This month', 'usces'), __('Last month', 'usces'), __('The past one week', 'usces'), __('Last 30 days', 'usces'), __('Last 90days', 'usces'), __('All', 'usces'));
52 +
53 +
54 + }
55 +
56 + function MakeTable()
57 + {
58 +
59 + $this->SetParam();
60 +
61 + switch ($this->action){
62 + case 'searchOut':
63 + $this->SearchOut();
64 + $this->SetSelectedRow();
65 + $res = $this->GetRows();
66 + break;
67 +
68 + case 'changeSort':
69 + case 'changePage':
70 + case 'searchIn':
71 + case 'refresh':
72 + default:
73 + $this->SearchIn();
74 + $this->SetSelectedRow();
75 + $res = $this->GetRows();
76 + break;
77 + }
78 +
79 + $this->SetNavi();
80 + $this->SetHeaders();
81 +
82 + if($res){
83 +
84 + return TRUE;
85 +
86 + }else{
87 + return FALSE;
88 + }
89 + }
90 +
91 + //DefaultParam
92 + function SetDefaultParam()
93 + {
94 + $this->startRow = isset($this->data_cookie['startRow']) ? $this->data_cookie['startRow'] : 0;
95 + $this->currentPage = isset($this->data_cookie['currentPage']) ? $this->data_cookie['currentPage'] : 1;
96 + $this->sortColumn = (isset($this->data_cookie['sortColumn'])) ? $this->data_cookie['sortColumn'] :'ID';
97 + $this->searchSql = (isset($this->data_cookie['searchSql'])) ? $this->data_cookie['searchSql'] :'';
98 + $this->searchSwitchStatus = (isset($this->data_cookie['searchSwitchStatus'])) ? $this->data_cookie['searchSwitchStatus'] :'OFF';
99 + if (isset($this->data_cookie['arr_search'])) {
100 + $this->arr_search = wp_parse_args(
101 + $this->data_cookie['arr_search'],
102 + array(
103 + 'period' => '3',
104 + 'column' => '',
105 + 'word' => '',
106 + )
107 + );
108 + } else {
109 + $this->arr_search = array('period'=>'3', 'column'=>'', 'word'=>'');
110 + }
111 + if (isset($this->data_cookie['sortSwitchs'])) {
112 + $this->sortSwitchs = $this->data_cookie['sortSwitchs'];
113 + foreach ( $this->columns as $key => $value ) {
114 + if ( ! isset( $this->sortSwitchs[ $value ] ) ) {
115 + $this->sortSwitchs[ $value ] = 'DESC';
116 + }
117 + }
118 + } else {
119 + foreach($this->columns as $key => $value ){
120 + $this->sortSwitchs[$value] = 'DESC';
121 + }
122 + }
123 + $this->SetTotalRow();
124 + $this->SetSelectedRow();
125 +
126 + }
127 +
128 + function SetParam()
129 + {
130 + $this->startRow = ($this->currentPage-1) * $this->maxRow;
131 + }
132 +
133 + function SetParamByQuery()
134 + {
135 + global $wpdb;
136 +
137 + if(isset($_REQUEST['changePage'])){
138 +
139 + $this->action = 'changePage';
140 + $this->currentPage = (int)$_REQUEST['changePage'];
141 + $this->sortColumn = (isset($this->data_cookie['sortColumn'])) ? $this->data_cookie['sortColumn'] : $this->sortColumn;
142 + $this->sortSwitchs = (isset($this->data_cookie['sortSwitchs'])) ? $this->data_cookie['sortSwitchs'] : $this->sortSwitchs;
143 + $this->userHeaderNames = (isset($this->data_cookie['userHeaderNames'])) ? $this->data_cookie['userHeaderNames'] : $this->userHeaderNames;
144 + $this->searchSql = (isset($this->data_cookie['searchSql'])) ? $this->data_cookie['searchSql'] : $this->searchSql;
145 + $this->arr_search = (isset($this->data_cookie['arr_search'])) ? $this->data_cookie['arr_search'] : $this->arr_search;
146 + $this->totalRow = (isset($this->data_cookie['totalRow'])) ? $this->data_cookie['totalRow'] : $this->totalRow;
147 + $this->selectedRow = (isset($this->data_cookie['selectedRow'])) ? $this->data_cookie['selectedRow'] : $this->selectedRow;
148 + $this->placeholder_escape = (isset($this->data_cookie['placeholder_escape'])) ? $this->data_cookie['placeholder_escape'] : $this->placeholder_escape;
149 +
150 + }else if(isset($_REQUEST['changeSort'])){
151 +
152 + $this->action = 'changeSort';
153 + $this->sortOldColumn = $this->sortColumn;
154 + // Validate sortColumn.
155 + if ( in_array( $_REQUEST['changeSort'], $this->columns ) ) {
156 + $this->sortColumn = $_REQUEST['changeSort'];
157 + } else {
158 + $this->sortColumn = 'ID'; // default.
159 + }
160 + $this->sortSwitchs = (isset($this->data_cookie['sortSwitchs'])) ? $this->data_cookie['sortSwitchs'] : $this->sortSwitchs;
161 + // Validate sortSwitchs.
162 + if (isset($_REQUEST['switch']) && in_array($_REQUEST['switch'], array('ASC', 'DESC'))) {
163 + $this->sortSwitchs[$this->sortColumn] = $_REQUEST['switch'];
164 + } else {
165 + $this->sortSwitchs[$this->sortColumn] = 'DESC'; // default.
166 + }
167 + $this->currentPage = (isset($this->data_cookie['currentPage'])) ? $this->data_cookie['currentPage'] : $this->currentPage;
168 + $this->userHeaderNames = (isset($this->data_cookie['userHeaderNames'])) ? $this->data_cookie['userHeaderNames'] : $this->userHeaderNames;
169 + $this->searchSql = (isset($this->data_cookie['searchSql'])) ? $this->data_cookie['searchSql'] : $this->searchSql;
170 + $this->searchSwitchStatus = (isset($this->data_cookie['searchSwitchStatus'])) ? $this->data_cookie['searchSwitchStatus'] : $this->searchSwitchStatus;
171 + $this->arr_search = (isset($this->data_cookie['arr_search'])) ? $this->data_cookie['arr_search'] : $this->arr_search;
172 + $this->totalRow = (isset($this->data_cookie['totalRow'])) ? $this->data_cookie['totalRow'] : $this->totalRow;
173 + $this->selectedRow = (isset($this->data_cookie['selectedRow'])) ? $this->data_cookie['selectedRow'] : $this->selectedRow;
174 + $this->placeholder_escape = (isset($this->data_cookie['placeholder_escape'])) ? $this->data_cookie['placeholder_escape'] : $this->placeholder_escape;
175 +
176 + } else if(isset($_REQUEST['searchIn'])){
177 +
178 + $this->action = 'searchIn';
179 + $this->arr_search['column'] = str_replace('`', '', $_REQUEST['search']['column']);
180 + $this->arr_search['word'] = $_REQUEST['search']['word'];
181 + $this->arr_search['period'] = isset($_REQUEST['search']['period']) ? intval($_REQUEST['search']['period']) : 0;
182 + $this->searchSwitchStatus = str_replace(',', '', $_REQUEST['searchSwitchStatus']);
183 +
184 + $this->currentPage = 1;
185 + $this->sortColumn = (isset($this->data_cookie['sortColumn'])) ? $this->data_cookie['sortColumn'] : $this->sortColumn;
186 + $this->sortSwitchs = (isset($this->data_cookie['sortSwitchs'])) ? $this->data_cookie['sortSwitchs'] : $this->sortSwitchs;
187 + $this->userHeaderNames = (isset($this->data_cookie['userHeaderNames'])) ? $this->data_cookie['userHeaderNames'] : $this->userHeaderNames;
188 + $this->totalRow = (isset($this->data_cookie['totalRow'])) ? $this->data_cookie['totalRow'] : $this->totalRow;
189 + $this->placeholder_escape = $wpdb->placeholder_escape();
190 +
191 + }else if(isset($_REQUEST['searchOut'])){
192 +
193 + $this->action = 'searchOut';
194 + $this->arr_search['column'] = '';
195 + $this->arr_search['word'] = '';
196 + $this->arr_search['period'] = (isset($this->data_cookie['arr_search']['period'])) ? $this->data_cookie['arr_search']['period'] : $this->arr_search['period'];
197 + $this->searchSwitchStatus = str_replace(',', '', $_REQUEST['searchSwitchStatus']);
198 +
199 + $this->currentPage = 1;
200 + $this->sortColumn = (isset($this->data_cookie['sortColumn'])) ? $this->data_cookie['sortColumn'] : $this->sortColumn;
201 + $this->sortSwitchs = (isset($this->data_cookie['sortSwitchs'])) ? $this->data_cookie['sortSwitchs'] : $this->sortSwitchs;
202 + $this->userHeaderNames = (isset($this->data_cookie['userHeaderNames'])) ? $this->data_cookie['userHeaderNames'] : $this->userHeaderNames;
203 + $this->totalRow = (isset($this->data_cookie['totalRow'])) ? $this->data_cookie['totalRow'] : $this->totalRow;
204 + $this->placeholder_escape = '';
205 +
206 + }else if(isset($_REQUEST['refresh'])){
207 +
208 + $this->action = 'refresh';
209 +
210 + $this->currentPage = (isset($this->data_cookie['currentPage'])) ? $this->data_cookie['currentPage'] : $this->currentPage;
211 + $this->sortColumn = (isset($this->data_cookie['sortColumn'])) ? $this->data_cookie['sortColumn'] : $this->sortColumn;
212 + $this->sortSwitchs = (isset($this->data_cookie['sortSwitchs'])) ? $this->data_cookie['sortSwitchs'] : $this->sortSwitchs;
213 + $this->userHeaderNames = (isset($this->data_cookie['userHeaderNames'])) ? $this->data_cookie['userHeaderNames'] : $this->userHeaderNames;
214 + $this->searchSql = (isset($this->data_cookie['searchSql'])) ? $this->data_cookie['searchSql'] : $this->searchSql;
215 + $this->searchSwitchStatus = (isset($this->data_cookie['searchSwitchStatus'])) ? $this->data_cookie['searchSwitchStatus'] : $this->searchSwitchStatus;
216 + $this->arr_search = (isset($this->data_cookie['arr_search'])) ? $this->data_cookie['arr_search'] : $this->arr_search;
217 + $this->totalRow = (isset($this->data_cookie['totalRow'])) ? $this->data_cookie['totalRow'] : $this->totalRow;
218 + $this->selectedRow = (isset($this->data_cookie['selectedRow'])) ? $this->data_cookie['selectedRow'] : $this->selectedRow;
219 + $this->placeholder_escape = '';
220 +
221 + }else{
222 +
223 + $this->action = 'default';
224 + $this->placeholder_escape = '';
225 + }
226 + }
227 +
228 + function validationSearchParameters(){
229 + if( 'none' != $this->arr_search['column'] && !in_array($this->arr_search['column'], $this->columns)){
230 + $this->arr_search['column'] = reset($this->columns);
231 + }
232 + }
233 +
234 + //GetRows
235 + function GetRows()
236 + {
237 + global $wpdb;
238 +
239 + $member_meta_table = usces_get_tablename( 'usces_member_meta' );
240 +
241 + if($this->arr_search['column'] == 'none' || WCUtils::is_blank($this->arr_search['column']) || WCUtils::is_blank($this->arr_search['word']) ){
242 + $join = "";
243 + }else{
244 + if( 'csmb_' === substr($this->arr_search['column'], 0, 5) ){
245 + $join = $wpdb->prepare(" LEFT JOIN {$member_meta_table} AS `mm` ON ID=mm.member_id AND mm.meta_key = %s", esc_sql($this->arr_search['column']) );
246 + }else{
247 + $join = "";
248 + }
249 + }
250 +
251 + $where = $this->GetWhere();
252 +
253 + $init_column = 'ID';
254 + $sort_column = in_array( $this->sortColumn, $this->columns, true ) ? $this->sortColumn : $init_column;
255 + $init_switch = 'DESC';
256 + $sort_switch = $this->sortSwitchs[ $sort_column ] ?? $init_switch;
257 + $sort_switch = in_array( strtoupper( $sort_switch ), array( 'ASC', 'DESC' ), true ) ? $sort_switch : $init_switch;
258 + $order = ' ORDER BY ' . esc_sql( $sort_column ) . ' ' . esc_sql( $sort_switch );
259 +
260 + if($this->pageLimit == 'on') {
261 + $limit = $wpdb->prepare(' LIMIT %d, %d', $this->startRow, $this->maxRow);
262 + }else{
263 + $limit = '';
264 + }
265 + $mem_point = ( usces_is_membersystem_point() ) ? ', mem_point AS `point`' : '';
266 + $query = $wpdb->prepare("SELECT ID, CONCAT(mem_name1, ' ', mem_name2) AS `name`,
267 + CONCAT(mem_pref, mem_address1, mem_address2, ' ', mem_address3) AS `address`,
268 + mem_tel AS `tel`, mem_email AS `email`, DATE_FORMAT(mem_registered, %s) AS `date`{$mem_point}
269 + FROM {$this->table}",
270 + '%Y-%m-%d %H:%i');
271 +
272 + $query .= $join . $where . $order . $limit;
273 +
274 + if( $this->placeholder_escape ){
275 + add_filter( 'query', array( $this, 'remove_ph') );
276 + }
277 +
278 + $this->rows = $wpdb->get_results($query, ARRAY_A);
279 + return $this->rows;
280 + }
281 +
282 + public function remove_ph( $query ) {
283 + return str_replace( $this->placeholder_escape, '%', $query );
284 + }
285 +
286 + function SetTotalRow()
287 + {
288 + global $wpdb;
289 + $query = "SELECT COUNT(ID) AS `ct` FROM {$this->table}";
290 + $res = $wpdb->get_var($query);
291 + $this->totalRow = $res;
292 + }
293 +
294 + function SetSelectedRow()
295 + {
296 + global $wpdb;
297 +
298 + $member_meta_table = usces_get_tablename( 'usces_member_meta' );
299 + if($this->arr_search['column'] == 'none' || WCUtils::is_blank($this->arr_search['column']) || WCUtils::is_blank($this->arr_search['word']) ){
300 + $join = "";
301 + }else{
302 + if( 'csmb_' === substr($this->arr_search['column'], 0, 5) ){
303 + $join = $wpdb->prepare(" LEFT JOIN {$member_meta_table} AS `mm` ON ID=mm.member_id AND mm.meta_key = %s", esc_sql($this->arr_search['column']) );
304 + }else{
305 + $join = "";
306 + }
307 + }
308 + $where = $this->GetWhere();
309 + $mem_point = ( usces_is_membersystem_point() ) ? ', mem_point AS `point`' : '';
310 + $query = $wpdb->prepare("SELECT ID, CONCAT(mem_name1, ' ', mem_name2) AS `name`,
311 + CONCAT(mem_pref, mem_address1, mem_address2, ' ', mem_address3) AS `address`,
312 + mem_tel AS `tel`, mem_email AS `email`, DATE_FORMAT(mem_registered, %s) AS `date`{$mem_point}
313 + FROM {$this->table}",
314 + '%Y-%m-%d %H:%i');
315 + $query .= $join . $where;
316 + $rows = $wpdb->get_results($query, ARRAY_A);
317 + $this->selectedRow = ( $rows && is_array( $rows ) ) ? count( $rows ) : 0;
318 +
319 + }
320 +
321 + function GetWhere()
322 + {
323 + $str = '';
324 + $thismonth = date('Y-m-01 00:00:00');
325 + $lastmonth = date('Y-m-01 00:00:00', mktime(0, 0, 0, date('m')-1, 1, date('Y')));
326 + $lastweek = date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m'), date('d')-7, date('Y')));
327 + $last30 = date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m'), date('d')-30, date('Y')));
328 + $last90 = date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m'), date('d')-90, date('Y')));
329 +
330 + if(!WCUtils::is_blank($this->searchSql)){
331 + if( 'csmb_' === substr($this->arr_search['column'], 0, 5) ){
332 + $str .= ' WHERE ' . $this->searchSql;
333 + }else{
334 + $str .= ' HAVING ' . $this->searchSql;
335 + }
336 + }
337 +
338 + return $str;
339 + }
340 +
341 + function SearchIn()
342 + {
343 + global $wpdb;
344 + if($this->arr_search['column'] == 'none' || WCUtils::is_blank($this->arr_search['column']) || WCUtils::is_blank($this->arr_search['word']) ){
345 + $this->searchSql = '';
346 + }else{
347 + if( 'csmb_' === substr($this->arr_search['column'], 0, 5) ){
348 + $this->searchSql = $wpdb->prepare('`meta_value` LIKE %s', "%".$this->arr_search['word']."%");
349 + }else{
350 + $this->searchSql = $wpdb->prepare('`' . esc_sql($this->arr_search['column']) . '` LIKE %s', "%".$this->arr_search['word']."%");
351 + }
352 + }
353 + }
354 +
355 + function SearchOut()
356 + {
357 + $this->searchSql = '';
358 + }
359 +
360 + function SetNavi()
361 + {
362 +
363 + $this->lastPage = ceil($this->selectedRow / $this->maxRow);
364 + $this->previousPage = ($this->currentPage - 1 == 0) ? 1 : $this->currentPage - 1;
365 + $this->nextPage = ($this->currentPage + 1 > $this->lastPage) ? $this->lastPage : $this->currentPage + 1;
366 + $box = array();
367 +
368 + for($i=0; $i<$this->naviMaxButton; $i++){
369 + if($i > $this->lastPage-1) break;
370 + if($this->lastPage <= $this->naviMaxButton) {
371 + $box[] = $i+1;
372 + }else{
373 + if($this->currentPage <= 6) {
374 + $label = $i + 1;
375 + $box[] = $label;
376 + }else{
377 + $label = $i + 1 + $this->currentPage - 6;
378 + $box[] = $label;
379 + if($label == $this->lastPage) break;
380 + }
381 + }
382 + }
383 +
384 + $html = '';
385 + $html .= '<ul class="clearfix">'."\n";
386 + $html .= '<li class="rowsnum">' . $this->selectedRow . ' / ' . $this->totalRow . ' ' . __('cases', 'usces') . '</li>' . "\n";
387 + if(($this->currentPage == 1) || ($this->selectedRow == 0)){
388 + $html .= '<li class="navigationStr">first&lt;&lt;</li>' . "\n";
389 + $html .= '<li class="navigationStr">prev&lt;</li>'."\n";
390 + }else{
391 + $html .= '<li class="navigationStr"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_memberlist&changePage=1">first&lt;&lt;</a></li>' . "\n";
392 + $html .= '<li class="navigationStr"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_memberlist&changePage=' . $this->previousPage . '">prev&lt;</a></li>'."\n";
393 + }
394 + if($this->selectedRow > 0) {
395 + $box_count = count( $box );
396 + for($i=0; $i<$box_count; $i++){
397 + if($box[$i] == $this->currentPage){
398 + $html .= '<li class="navigationButtonSelected">' . $box[$i] . '</li>'."\n";
399 + }else{
400 + $html .= '<li class="navigationButton"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_memberlist&changePage=' . $box[$i] . '">' . $box[$i] . '</a></li>'."\n";
401 + }
402 + }
403 + }
404 + if(($this->currentPage == $this->lastPage) || ($this->selectedRow == 0)){
405 + $html .= '<li class="navigationStr">&gt;next</li>'."\n";
406 + $html .= '<li class="navigationStr">&gt;&gt;last</li>'."\n";
407 + }else{
408 + $html .= '<li class="navigationStr"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_memberlist&changePage=' . $this->nextPage . '">&gt;next</a></li>'."\n";
409 + $html .= '<li class="navigationStr"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_memberlist&changePage=' . $this->lastPage . '">&gt;&gt;last</a></li>'."\n";
410 + }
411 + if($this->searchSwitchStatus == 'OFF'){
412 + $html .= '<li class="rowsnum"><a style="cursor:pointer;" id="searchVisiLink">' . __('Show the Operation field', 'usces') . '</a>'."\n";
413 + }else{
414 + $html .= '<li class="rowsnum"><a style="cursor:pointer;" id="searchVisiLink">' . __('Hide the Operation field', 'usces') . '</a>'."\n";
415 + }
416 +
417 + $html .= '<li class="refresh"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_memberlist&refresh">' . __('updates it to latest information', 'usces') . '</a></li>' . "\n";
418 + $html .= '</ul>'."\n";
419 +
420 + $this->dataTableNavigation = $html;
421 + }
422 +
423 +
424 + function getCookie(){
425 + $this->data_cookie = (isset($_COOKIE[$this->table])) ? json_decode(str_replace("\'","'",str_replace('\"','"', $_COOKIE[$this->table])),true) : [];
426 + }
427 +
428 + function SetHeaders()
429 + {
430 + foreach ($this->columns as $key => $value){
431 + if($value == $this->sortColumn){
432 + if($this->sortSwitchs[$value] == 'ASC'){
433 + $str = __('[ASC]', 'usces');
434 + $switch = 'DESC';
435 + }else{
436 + $str = __('[DESC]', 'usces');
437 + $switch = 'ASC';
438 + }
439 + $this->headers[$value] = '<a href="' . site_url() . '/wp-admin/admin.php?page=usces_memberlist&changeSort=' . $value . '&switch=' . $switch . '"><span class="sortcolumn">' . $key . ' ' . $str . '</span></a>';
440 + }else{
441 + $switch = $this->sortSwitchs[$value];
442 + $this->headers[$value] = '<a href="' . site_url() . '/wp-admin/admin.php?page=usces_memberlist&changeSort=' . $value . '&switch=' . $switch . '"><span>' . $key . '</span></a>';
443 + }
444 + }
445 + }
446 +
447 + function GetSearchs()
448 + {
449 + return $this->arr_search;
450 + }
451 +
452 + function GetListheaders()
453 + {
454 + return $this->headers;
455 + }
456 +
457 + function GetDataTableNavigation()
458 + {
459 + return $this->dataTableNavigation;
460 + }
461 +
462 +}