PluginProbe
Welcart e-Commerce / 1.3.9
Welcart e-Commerce v1.3.9
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
usc-e-shop / classes / itemList.class.php

itemList.class.php in Welcart e-Commerce 1.3.9, at classes/itemList.class.php

611 lines 24.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 $action_status, $action_message;
26 //20101202ysk start
27 var $pageLimit; //ページ制限
28 //20101202ysk end
29 var $exportMode; //IDのみ
30
31 //Constructor
32 function dataList($tableName, $arr_column)
33 {
34 $this->table = $tableName;
35 $this->columns = $arr_column;
36 //$this->parent_term = $parent_term;
37 $this->rows = array();
38
39 $this->maxRow = 30;
40 $this->naviMaxButton = 11;
41 $this->firstPage = 1;
42 $this->action_status = 'none';
43 $this->action_message = '';
44 //20101202ysk start
45 $this->pageLimit = 'on';
46 //20101202ysk end
47 $this->exportMode = false;
48
49 $this->SetParamByQuery();
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
63 case 'searchIn':
64 $this->SearchIn();
65 //$this->SetSelectedRow();
66 $res = $this->GetRows();
67 break;
68
69 case 'searchOut':
70 $this->SearchOut();
71 //$this->SetSelectedRow();
72 $res = $this->GetRows();
73 break;
74
75 case 'changeSort':
76 $res = $this->GetRows();
77 break;
78
79 case 'changePage':
80 $res = $this->GetRows();
81 break;
82
83 case 'collective_zaiko':
84 usces_all_change_zaiko($this);
85 $res = $this->GetRows();
86 break;
87
88 case 'collective_display_status':
89 usces_all_change_itemdisplay($this);
90 $res = $this->GetRows();
91 break;
92
93 case 'collective_delete':
94 usces_all_delete_itemdata($this);
95 $this->SetTotalRow();
96 $res = $this->GetRows();
97 break;
98
99 case 'refresh':
100 default:
101 $this->SetDefaultParam();
102 $res = $this->GetRows();
103 break;
104 }
105
106 if( ! $this->exportMode ){
107 $this->SetNavi();
108 $this->SetHeaders();
109 $this->SetSESSION();
110 }
111
112 if($res){
113
114 return TRUE;
115
116 }else{
117 return FALSE;
118 }
119 }
120
121 //DefaultParam
122 function SetDefaultParam()
123 {
124 unset($_SESSION[$this->table]);
125 $this->startRow = 0;
126 $this->currentPage = 1;
127 if(isset($_SESSION[$this->table]['arr_search'])){
128 $this->arr_search = $_SESSION[$this->table]['arr_search'];
129 }else{
130 $this->arr_search = array('period'=>'3', 'column'=>'', 'word'=>array());
131 }
132 if(isset($_SESSION[$this->table]['searchSwitchStatus'])){
133 $this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus'];
134 }else{
135 $this->searchSwitchStatus = 'OFF';
136 }
137 $this->searchSql = '';
138 $column = apply_filters( 'usces_filter_item_class_sortColumn', 'post.ID');
139 $this->sortColumn = $column;
140 $this->sortSwitchs[$column] = apply_filters( 'usces_filter_item_class_sortSwitchs', 'DESC');
141
142 foreach($this->columns as $value ){
143 $this->sortSwitchs[$value] = 'ASC';
144 }
145
146
147 $this->SetTotalRow();
148 //$this->SetSelectedRow();
149
150 }
151
152 function SetParam()
153 {
154 $this->startRow = ($this->currentPage-1) * $this->maxRow;
155 }
156
157 function SetParamByQuery()
158 {
159
160 if(isset($_REQUEST['changePage'])){
161
162 $this->action = 'changePage';
163 $this->currentPage = $_REQUEST['changePage'];
164
165 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
166 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
167 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
168 $this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus'];
169 $this->searchSql = $_SESSION[$this->table]['searchSql'];
170 $this->arr_search = $_SESSION[$this->table]['arr_search'];
171 $this->totalRow = $_SESSION[$this->table]['totalRow'];
172 $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
173
174 }else if(isset($_REQUEST['changeSort'])){
175
176 $this->action = 'changeSort';
177 $this->sortOldColumn = $this->sortColumn;
178 $this->sortColumn = $_REQUEST['changeSort'];
179 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
180 $this->sortSwitchs[$this->sortColumn] = $_REQUEST['switch'];
181
182 $this->currentPage = $_SESSION[$this->table]['currentPage'];
183 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
184 $this->searchSql = $_SESSION[$this->table]['searchSql'];
185 $this->arr_search = $_SESSION[$this->table]['arr_search'];
186 $this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus'];
187 $this->totalRow = $_SESSION[$this->table]['totalRow'];
188 $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
189
190 } else if(isset($_REQUEST['searchIn'])){
191
192 $this->action = 'searchIn';
193 $this->arr_search['column'] = isset($_REQUEST['search']['column']) ? $_REQUEST['search']['column'] : '';
194 $this->arr_search['word'] = isset($_REQUEST['search']['word']) ? $_REQUEST['search']['word'] : '';
195 $this->arr_search['period'] = isset($_REQUEST['search']['period']) ? (int)$_REQUEST['search']['period'] : '';
196 $this->searchSwitchStatus = isset($_REQUEST['searchSwitchStatus']) ? $_REQUEST['searchSwitchStatus'] : '';
197
198 $this->currentPage = 1;
199 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
200 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
201 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
202 $this->totalRow = $_SESSION[$this->table]['totalRow'];
203
204 }else if(isset($_REQUEST['searchOut'])){
205
206 $this->action = 'searchOut';
207 $this->arr_search['column'] = '';
208 $this->arr_search['word'] = '';
209 $this->arr_search['period'] = $_SESSION[$this->table]['arr_search']['period'];
210 $this->searchSwitchStatus = isset($_REQUEST['searchSwitchStatus']) ? $_REQUEST['searchSwitchStatus'] : '';
211
212 $this->currentPage = 1;
213 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
214 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
215 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
216 $this->totalRow = $_SESSION[$this->table]['totalRow'];
217
218
219 }else if(isset($_REQUEST['refresh'])){
220
221 $this->action = 'refresh';
222
223 $this->currentPage = $_SESSION[$this->table]['currentPage'];
224 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
225 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
226 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
227 $this->searchSql = $_SESSION[$this->table]['searchSql'];
228 $this->arr_search = $_SESSION[$this->table]['arr_search'];
229 $this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus'];
230 $this->totalRow = $_SESSION[$this->table]['totalRow'];
231 $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
232
233 }else if(isset($_REQUEST['collective'])){
234
235 $this->action = 'collective_' . $_POST['allchange']['column'];
236 $this->currentPage = $_SESSION[$this->table]['currentPage'];
237 $this->sortColumn = $_SESSION[$this->table]['sortColumn'];
238 $this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs'];
239 $this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames'];
240 $this->searchSql = $_SESSION[$this->table]['searchSql'];
241 $this->arr_search = $_SESSION[$this->table]['arr_search'];
242 $this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus'];
243 $this->totalRow = $_SESSION[$this->table]['totalRow'];
244 $this->selectedRow = $_SESSION[$this->table]['selectedRow'];
245
246 }else{
247
248 $this->action = 'default';
249 }
250 }
251
252 //GetRows
253 function GetRows()
254 {
255 global $wpdb;
256 //$wpdb->show_errors();
257 $where = $this->GetWhere();
258 $order = ' ORDER BY ' . $this->sortColumn . ' ' . $this->sortSwitchs[$this->sortColumn];
259 //$limit = ' LIMIT ' . $this->startRow . ', ' . $this->maxRow;
260
261 if(USCES_MYSQL_VERSION >= 5){
262 if( $this->exportMode ){
263 $query = $wpdb->prepare("SELECT post.ID
264 FROM {$this->table} AS post
265 LEFT JOIN $wpdb->postmeta AS mc ON post.ID = mc.post_id AND %s = mc.meta_key
266 LEFT JOIN $wpdb->postmeta AS mn ON post.ID = mn.post_id AND %s = mn.meta_key
267 LEFT JOIN $wpdb->postmeta AS meta ON post.ID = meta.post_id AND %s = meta.meta_key
268 LEFT JOIN $wpdb->term_relationships AS tr ON post.ID = tr.object_id
269 LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id "
270 , '_itemCode', '_itemName', '_isku_');
271 }else{
272 // $query = $wpdb->prepare("SELECT mc.meta_value AS item_code, mn.meta_value AS item_name,
273 // meta.meta_key AS sku_key, meta.meta_value AS sku_value, te.term_id AS category, post.post_status,
274 // CASE post.post_status
275 // WHEN 'publish' THEN '" . __('Published', 'usces') . "'
276 // WHEN 'future' THEN '" . __('Scheduled', 'usces') . "'
277 // WHEN 'draft' THEN '" . __('Draft', 'usces') . "'
278 // WHEN 'pending' THEN '" . __('Pending Review', 'usces') . "'
279 // WHEN 'trash' THEN '" . __('Trash', 'usces') . "'
280 // ELSE '" . __('Closed', 'usces') . "'
281 // END AS display_status,
282 // post.post_type, post.post_mime_type, post.ID
283 // FROM {$this->table} AS post
284 // LEFT JOIN $wpdb->postmeta AS mc ON post.ID = mc.post_id AND mc.meta_key = '_itemCode'
285 // LEFT JOIN $wpdb->postmeta AS mn ON post.ID = mn.post_id AND mn.meta_key = '_itemName'
286 // LEFT JOIN $wpdb->postmeta AS meta ON post.ID = meta.post_id AND meta.meta_key = %s
287 // LEFT JOIN $wpdb->term_relationships AS tr ON tr.object_id = post.ID
288 // LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
289 // LEFT JOIN $wpdb->terms AS te ON te.term_id = tt.term_id ",
290 // '_isku_');
291 $query = $wpdb->prepare("SELECT post.ID, mc.meta_value AS item_code, mn.meta_value AS item_name
292 FROM {$this->table} AS post
293 LEFT JOIN $wpdb->postmeta AS mc ON post.ID = mc.post_id AND %s = mc.meta_key
294 LEFT JOIN $wpdb->postmeta AS mn ON post.ID = mn.post_id AND %s = mn.meta_key
295 LEFT JOIN $wpdb->postmeta AS meta ON post.ID = meta.post_id AND %s = meta.meta_key
296 LEFT JOIN $wpdb->term_relationships AS tr ON post.ID = tr.object_id
297 LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id "
298 , '_itemCode', '_itemName', '_isku_');
299 // $query = $wpdb->prepare("SELECT
300 // (SELECT meta_value FROM $wpdb->postmeta WHERE post_id = post.ID AND meta_key = '_itemCode') AS item_code,
301 // (SELECT meta_value FROM $wpdb->postmeta WHERE post_id = post.ID AND meta_key = '_itemName') AS item_name,
302 // meta.meta_key AS sku_key, meta.meta_value AS sku_value, te.name AS category, post.post_status,
303 // CASE post.post_status
304 // WHEN 'publish' THEN '" . __('Published', 'usces') . "'
305 // WHEN 'future' THEN '" . __('Scheduled', 'usces') . "'
306 // WHEN 'draft' THEN '" . __('Draft', 'usces') . "'
307 // WHEN 'pending' THEN '" . __('Pending Review', 'usces') . "'
308 // WHEN 'trash' THEN '" . __('Trash', 'usces') . "'
309 // ELSE '" . __('Closed', 'usces') . "'
310 // END AS display_status,
311 // post.post_type, post.post_mime_type, post.ID
312 // FROM {$this->table} AS post
313 // LEFT JOIN $wpdb->postmeta AS meta ON post.ID = meta.post_id AND SUBSTRING(meta.meta_key, 1, 6) = %s
314 // LEFT JOIN $wpdb->term_relationships AS tr ON tr.object_id = post.ID
315 // LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
316 // LEFT JOIN $wpdb->terms AS te ON te.term_id = tt.term_id ",
317 // '_isku_');
318 }
319 } else {
320 if( $this->exportMode ){
321 // $query = $wpdb->prepare("SELECT mc.meta_value AS item_code, mn.meta_value AS item_name,
322 // CASE post.post_status
323 // WHEN 'publish' THEN '" . __('Published', 'usces') . "'
324 // WHEN 'future' THEN '" . __('Scheduled', 'usces') . "'
325 // WHEN 'draft' THEN '" . __('Draft', 'usces') . "'
326 // WHEN 'pending' THEN '" . __('Pending Review', 'usces') . "'
327 // WHEN 'trash' THEN '" . __('Trash', 'usces') . "'
328 // ELSE '" . __('Closed', 'usces') . "'
329 // END AS display_status, post.post_status, post.ID
330 // FROM {$this->table} AS post
331 // LEFT JOIN $wpdb->postmeta AS mc ON post.ID = mc.post_id AND mc.meta_key = '_itemCode'
332 // LEFT JOIN $wpdb->postmeta AS mn ON post.ID = mn.post_id AND mn.meta_key = '_itemName'
333 // LEFT JOIN $wpdb->postmeta AS meta ON post.ID = meta.post_id AND meta.meta_key = %s
334 // LEFT JOIN $wpdb->term_relationships AS tr ON tr.object_id = post.ID
335 // LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
336 // LEFT JOIN $wpdb->terms AS te ON te.term_id = tt.term_id ",
337 // '_isku_');
338 }else{
339 $query = $wpdb->prepare("SELECT
340 'item_code' AS item_code,
341 post.post_title,
342 meta.meta_key AS sku_key, meta.meta_value AS sku_value, te.name AS category, post.post_status,
343 CASE post.post_status
344 WHEN 'publish' THEN '" . __('Published', 'usces') . "'
345 WHEN 'future' THEN '" . __('Scheduled', 'usces') . "'
346 WHEN 'draft' THEN '" . __('Draft', 'usces') . "'
347 WHEN 'pending' THEN '" . __('Pending Review', 'usces') . "'
348 WHEN 'trash' THEN '" . __('Trash', 'usces') . "'
349 ELSE '" . __('Closed', 'usces') . "'
350 END AS display_status,
351 post.post_type, post.post_mime_type, post.ID
352 FROM {$this->table} AS post
353 LEFT JOIN $wpdb->postmeta AS meta ON post.ID = meta.post_id AND meta.meta_key = %s
354 LEFT JOIN $wpdb->term_relationships AS tr ON tr.object_id = post.ID
355 LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id
356 LEFT JOIN $wpdb->terms AS te ON te.term_id = tt.term_id ",
357 '_isku_');
358 }
359 }
360
361 $query .= $where . $order;// . $limit;
362 //var_dump($query);
363
364 $rows = $wpdb->get_results($query, ARRAY_A);
365 $this->selectedRow = count($rows);
366 if($this->pageLimit == 'off') {
367 $this->rows = $rows;
368 } else {
369 $this->rows = array_slice((array)$rows, $this->startRow, $this->maxRow);
370 }
371
372 return $this->rows;
373 }
374
375 function SetTotalRow()
376 {
377 global $wpdb;
378 $query = "SELECT COUNT(ID) AS ct FROM {$this->table} WHERE post_mime_type = 'item' AND post_type = 'post' AND post_status <> 'trash'";
379 $res = $wpdb->get_var($query);
380 $this->totalRow = $res;
381 }
382
383 // function SetSelectedRow()
384 // {
385 // global $wpdb;
386 // $where = $this->GetWhere();
387 // $query = $wpdb->prepare("SELECT
388 // (SELECT meta_value FROM $wpdb->postmeta WHERE post_id = post.ID AND meta_key = '_itemCode') AS item_code,
389 // (SELECT meta_value FROM $wpdb->postmeta WHERE post_id = post.ID AND meta_key = '_itemName') AS item_name,
390 // meta.meta_key AS sku_key, meta.meta_value AS sku_value, te.name AS category,
391 // CASE WHEN post.post_status = 'publish' THEN '�
392 �開済み' ELSE '非�
393 �開' END AS display_status,
394 // post.post_type, post.post_mime_type, post.ID
395 // (FROM {$this->table} AS post
396 // LEFT JOIN $wpdb->postmeta AS meta ON post.ID = meta.post_id AND SUBSTRING(meta.meta_key, 1, 6) = %s
397 // LEFT JOIN $wpdb->term_relationships AS tr ON tr.object_id = post.ID
398 // LEFT JOIN $wpdb->term_taxonomy AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id)
399 // LEFT JOIN $wpdb->terms AS te ON te.term_id = tt.term_id ",
400 // '_isku_');
401 //
402 // $query .= $where;
403 // $rows = $wpdb->get_results($query, ARRAY_A);
404 // $this->selectedRow = count($rows);
405 //
406 // }
407
408 function GetWhere()
409 {
410 if( $this->searchSql != '' ){
411 if( 'display_status' == $this->arr_search['column'] )
412 $str = "WHERE post.post_mime_type = 'item' AND post.post_type = 'post' AND " . $this->searchSql . " GROUP BY post.ID";
413 // if( 'item_code' == $this->arr_search['column'] || 'item_name' == $this->arr_search['column'] )
414 // $str = "WHERE post.post_mime_type = 'item' AND post.post_type = 'post' AND post.post_status <> 'trash' GROUP BY post.ID HAVING " . $this->searchSql;
415 else
416 $str = "WHERE post.post_mime_type = 'item' AND post.post_type = 'post' AND post.post_status <> 'trash' AND " . $this->searchSql . " GROUP BY post.ID";
417 }else{
418 $str = "WHERE post.post_mime_type = 'item' AND post.post_type = 'post' AND post.post_status <> 'trash' GROUP BY post.ID";
419 }
420 return $str;
421 }
422
423 function SearchIn()
424 {
425 switch ($this->arr_search['column']) {
426 case 'item_code':
427 $column = 'mc.meta_value';
428 $this->searchSql = $column . ' LIKE '."'%" . mysql_real_escape_string($this->arr_search['word']['item_code']) . "%'";
429 break;
430 case 'item_name':
431 $column = 'mn.meta_value';
432 $this->searchSql = $column . ' LIKE '."'%" . mysql_real_escape_string($this->arr_search['word']['item_name']) . "%'";
433 break;
434 case 'post_title':
435 $column = 'post.post_title';
436 $this->searchSql = $column . ' LIKE '."'%" . mysql_real_escape_string($this->arr_search['word']['post_title']) . "%'";
437 break;
438 case 'zaiko_num':
439 $column = 'meta.meta_value';
440 $this->searchSql = '(' . $column . ' LIKE '."'%" . mysql_real_escape_string('"stocknum";i:0') . "%' OR " . $column . ' LIKE '."'%" . mysql_real_escape_string('"stocknum";s:1:"0"')."%')";
441 break;
442 case 'zaiko':
443 $column = 'meta.meta_value';
444 $this->searchSql = '(' . $column . ' LIKE '."'%" . mysql_real_escape_string('stock";i:'.$this->arr_search['word']['zaiko']) . "%' OR " . $column . ' LIKE '."'%" . mysql_real_escape_string('stock";s:1:"'.$this->arr_search['word']['zaiko']) . "%')";
445 break;
446 case 'category':
447 $column = 'tt.term_id';
448 $this->searchSql = $column . " = '" . mysql_real_escape_string($this->arr_search['word']['category']) . "'";
449 break;
450 case 'display_status':
451 $column = 'post_status';
452 $this->searchSql = $column . " = '" . mysql_real_escape_string($this->arr_search['word']['display_status']) . "'";
453 break;
454 // case 'post_status':
455 // $column = 'post.post_status';
456 // $this->searchSql = $column . " = 'trash'";
457 // break;
458 }
459 // if($this->arr_search['column'] == 'none' || $this->arr_search['column'] == '' || $this->arr_search['word'] == '')
460 // return;//$this->searchSql = $sql;
461 // else
462 // $this->searchSql = $column . ' LIKE '."'%" . mysql_real_escape_string($this->arr_search['word']) . "%'";
463 }
464
465 function SearchOut()
466 {
467 $this->searchSql = '';
468 }
469
470 function SetNavi()
471 {
472
473 $this->lastPage = ceil($this->selectedRow / $this->maxRow);
474 $this->previousPage = ($this->currentPage - 1 == 0) ? 1 : $this->currentPage - 1;
475 $this->nextPage = ($this->currentPage + 1 > $this->lastPage) ? $this->lastPage : $this->currentPage + 1;
476
477 for($i=0; $i<$this->naviMaxButton; $i++){
478 if($i > $this->lastPage-1) break;
479 if($this->lastPage <= $this->naviMaxButton) {
480 $box[] = $i+1;
481 }else{
482 if($this->currentPage <= 6) {
483 $label = $i + 1;
484 $box[] = $label;
485 }else{
486 $label = $i + 1 + $this->currentPage - 6;
487 $box[] = $label;
488 if($label == $this->lastPage) break;
489 }
490 }
491 }
492
493 $html = '';
494 $html .= '<ul class="clearfix">'."\n";
495 $html .= '<li class="rowsnum">' . $this->selectedRow . ' / ' . $this->totalRow . ' '.__('cases', 'usces').'' . "\n";
496 if(($this->currentPage == 1) || ($this->selectedRow == 0)){
497 $html .= '<li class="navigationStr">first&lt;&lt;</li>' . "\n";
498 $html .= '<li class="navigationStr">prev&lt;</li>'."\n";
499 }else{
500 $html .= '<li class="navigationStr"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_itemedit&changePage=1">first&lt;&lt;</a></li>' . "\n";
501 $html .= '<li class="navigationStr"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_itemedit&changePage=' . $this->previousPage . '">prev&lt;</a></li>'."\n";
502 }
503 if($this->selectedRow > 0) {
504 for($i=0; $i<count($box); $i++){
505 if($box[$i] == $this->currentPage){
506 $html .= '<li class="navigationButtonSelected">' . $box[$i] . '</li>'."\n";
507 }else{
508 $html .= '<li class="navigationButton"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_itemedit&changePage=' . $box[$i] . '">' . $box[$i] . '</a></li>'."\n";
509 }
510 }
511 }
512 if(($this->currentPage == $this->lastPage) || ($this->selectedRow == 0)){
513 $html .= '<li class="navigationStr">&gt;next</li>'."\n";
514 $html .= '<li class="navigationStr">&gt;&gt;last</li>'."\n";
515 }else{
516 $html .= '<li class="navigationStr"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_itemedit&changePage=' . $this->nextPage . '">&gt;next</a></li>'."\n";
517 $html .= '<li class="navigationStr"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_itemedit&changePage=' . $this->lastPage . '">&gt;&gt;last</a></li>'."\n";
518 }
519 if($this->searchSwitchStatus == 'OFF'){
520 $html .= '<li class="navigationStr"><a style="cursor:pointer;" id="searchVisiLink" onclick="toggleVisibility(\'searchBox\');">' . __('Show the Operation field', 'usces') . '</a>'."\n";
521 }else{
522 $html .= '<li class="navigationStr"><a style="cursor:pointer;" id="searchVisiLink" onclick="toggleVisibility(\'searchBox\');">' . __('hide the Operation field', 'usces') . '</a>'."\n";
523 }
524
525 $html .= '<li class="refresh"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_itemedit&refresh">' . __('updates it to latest information', 'usces') . '</a></li>' . "\n";
526 $html .= '</ul>'."\n";
527
528 $this->dataTableNavigation = $html;
529 }
530
531 function SetSESSION()
532 {
533
534 $_SESSION[$this->table]['startRow'] = $this->startRow; //表示開始行番号
535 $_SESSION[$this->table]['sortColumn'] = $this->sortColumn; //現在ソート中のフィールド
536 $_SESSION[$this->table]['totalRow'] = $this->totalRow; //�
537 �行数
538 $_SESSION[$this->table]['selectedRow'] = $this->selectedRow; //絞り込まれた行数
539 $_SESSION[$this->table]['currentPage'] = $this->currentPage; //現在のページNo
540 $_SESSION[$this->table]['previousPage'] = $this->previousPage; //前のページNo
541 $_SESSION[$this->table]['nextPage'] = $this->nextPage; //次のページNo
542 $_SESSION[$this->table]['lastPage'] = $this->lastPage; //最終ページNo
543 $_SESSION[$this->table]['userHeaderNames'] = $this->userHeaderNames;//�
544 �てのフィールド
545 $_SESSION[$this->table]['headers'] = $this->headers;//表示するヘッダ文字列
546 $_SESSION[$this->table]['rows'] = $this->rows; //表示する行オブジェクト
547 $_SESSION[$this->table]['sortSwitchs'] = $this->sortSwitchs; //各フィールド毎の昇順降順スイッチ
548 $_SESSION[$this->table]['dataTableNavigation'] = $this->dataTableNavigation;
549 $_SESSION[$this->table]['searchSql'] = $this->searchSql;
550 $_SESSION[$this->table]['arr_search'] = $this->arr_search;
551 $_SESSION[$this->table]['searchSwitchStatus'] = $this->searchSwitchStatus;
552 }
553
554 function SetHeaders()
555 {
556 foreach ($this->columns as $key => $value){
557 if($value == $this->sortColumn){
558 if($this->sortSwitchs[$value] == 'ASC'){
559 $str = __('[ASC]', 'usces');
560 $switch = 'DESC';
561 }else{
562 $str = __('[DESC]', 'usces');
563 $switch = 'ASC';
564 }
565 if( (USCES_MYSQL_VERSION >= 5 AND ($value == 'item_name' || $value == 'item_code')) || (USCES_MYSQL_VERSION < 5 AND $value == 'post_title') )
566 $this->headers[$value] = '<a href="' . site_url() . '/wp-admin/admin.php?page=usces_itemedit&changeSort=' . $value . '&switch=' . $switch . '"><span class="sortcolumn">' . $key . ' ' . $str . '</span></a>';
567 else
568 $this->headers[$value] = '<span class="sortcolumn">' . $key . '</span>';
569 }else{
570 $switch = $this->sortSwitchs[$value];
571 if( (USCES_MYSQL_VERSION >= 5 AND ($value == 'item_name' || $value == 'item_code')) || (USCES_MYSQL_VERSION < 5 AND $value == 'post_title') )
572 $this->headers[$value] = '<a href="' . site_url() . '/wp-admin/admin.php?page=usces_itemedit&changeSort=' . $value . '&switch=' . $switch . '"><span>' . $key . '</span></a>';
573 else
574 $this->headers[$value] = '<span class="sortcolumn">' . $key . '</span>';
575 }
576 }
577 //$this->headers = array_keys($this->columns);
578 }
579
580 function GetSearchs()
581 {
582 return $this->arr_search;
583 }
584
585 function GetListheaders()
586 {
587 return $this->headers;
588 }
589
590 function GetDataTableNavigation()
591 {
592 return $this->dataTableNavigation;
593 }
594
595 function set_action_status($status, $message)
596 {
597 $this->action_status = $status;
598 $this->action_message = $message;
599 }
600 function get_action_status()
601 {
602 return $this->action_status;
603 }
604 function get_action_message()
605 {
606 return $this->action_message;
607 }
608 }
609
610
611 ?>