| 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 $searchSkuSql; //SKU絞り込み |
| 20 |
var $searchSwitchStatus; //サーチ表示スイッチ |
| 21 |
var $columns; //データカラム |
| 22 |
var $sortColumn; //現在ソート中のフィールド |
| 23 |
var $sortOldColumn; |
| 24 |
var $sortSwitchs; //各フィールド毎の昇順降順スイッチ |
| 25 |
var $userHeaderNames; //ユーザー指定のヘッダ名 |
| 26 |
var $action_status, $action_message; |
| 27 |
//20101202ysk start |
| 28 |
var $pageLimit; //ページ制限 |
| 29 |
//20101202ysk end |
| 30 |
var $management_status; //処理ステータス |
| 31 |
var $selectSql; |
| 32 |
var $joinTableSql; |
| 33 |
|
| 34 |
//Constructor |
| 35 |
function dataList($tableName, $arr_column) |
| 36 |
{ |
| 37 |
$this->table = $tableName; |
| 38 |
$this->columns = $arr_column; |
| 39 |
$this->rows = array(); |
| 40 |
|
| 41 |
$this->maxRow = 30; |
| 42 |
$this->naviMaxButton = 11; |
| 43 |
$this->firstPage = 1; |
| 44 |
$this->action_status = 'none'; |
| 45 |
$this->action_message = ''; |
| 46 |
//20101202ysk start |
| 47 |
$this->pageLimit = 'on'; |
| 48 |
//20101202ysk end |
| 49 |
$this->selectSql = ''; |
| 50 |
$this->joinTableSql = ''; |
| 51 |
|
| 52 |
$this->SetParamByQuery(); |
| 53 |
|
| 54 |
$arr_period = array(__('This month', 'usces'), __('Last month', 'usces'), __('The past one week', 'usces'), __('Last 30 days', 'usces'), __('Last 90days', 'usces'), __('All', 'usces')); |
| 55 |
$this->arr_period = apply_filters( 'usces_filter_order_list_arr_period', $arr_period, $this ); |
| 56 |
|
| 57 |
$management_status = array( |
| 58 |
'duringorder' => __('temporaly out of stock', 'usces'), |
| 59 |
'cancel' => __('Cancel', 'usces'), |
| 60 |
'completion' => __('It has sent it out.', 'usces'), |
| 61 |
'estimate' => __('An estimate', 'usces'), |
| 62 |
'adminorder' => __('Management of Note', 'usces'), |
| 63 |
'continuation' => __('Continuation', 'usces'), |
| 64 |
'termination' => __('Termination', 'usces') |
| 65 |
); |
| 66 |
$this->management_status = apply_filters( 'usces_filter_management_status', $management_status, $this ); |
| 67 |
|
| 68 |
$this->SetSelects(); |
| 69 |
$this->SetJoinTables(); |
| 70 |
} |
| 71 |
|
| 72 |
function SetSelects() |
| 73 |
{ |
| 74 |
$status_sql = ''; |
| 75 |
foreach( $this->management_status as $status_key => $status_name ) { |
| 76 |
$status_sql .= " WHEN LOCATE('".$status_key."', order_status) > 0 THEN '".$status_name."'"; |
| 77 |
} |
| 78 |
|
| 79 |
$select = array( |
| 80 |
"ID", |
| 81 |
"meta.meta_value AS deco_id", |
| 82 |
"DATE_FORMAT(order_date, '%Y-%m-%d %H:%i') AS date", |
| 83 |
"mem_id", |
| 84 |
"CONCAT(order_name1, ' ', order_name2) AS name", |
| 85 |
"order_pref AS pref", |
| 86 |
"order_delivery_method AS delivery_method", |
| 87 |
"(order_item_total_price - order_usedpoint + order_discount + order_shipping_charge + order_cod_fee + order_tax) AS total_price", |
| 88 |
"order_payment_name AS payment_name", |
| 89 |
"CASE WHEN LOCATE('noreceipt', order_status) > 0 THEN '".__('unpaid', 'usces')."' |
| 90 |
WHEN LOCATE('receipted', order_status) > 0 THEN '".__('payment confirmed', 'usces')."' |
| 91 |
WHEN LOCATE('pending', order_status) > 0 THEN '".__('Pending', 'usces')."' |
| 92 |
ELSE ' ' |
| 93 |
END AS receipt_status", |
| 94 |
"CASE {$status_sql} |
| 95 |
ELSE '".__('new order', 'usces')."' |
| 96 |
END AS order_status", |
| 97 |
"order_modified" |
| 98 |
); |
| 99 |
$this->selectSql = apply_filters( 'usces_filter_order_list_sql_select', $select, $status_sql, $this ); |
| 100 |
} |
| 101 |
|
| 102 |
function SetJoinTables() |
| 103 |
{ |
| 104 |
global $wpdb; |
| 105 |
$meta_table = $wpdb->prefix.'usces_order_meta'; |
| 106 |
$ordercart_table = $wpdb->prefix.'usces_ordercart'; |
| 107 |
$ordercartmeta_table = $wpdb->prefix.'usces_ordercart_meta'; |
| 108 |
$join_table = array( |
| 109 |
" LEFT JOIN {$meta_table} AS meta ON ID = meta.order_id AND meta.meta_key = 'dec_order_id'"." \n", |
| 110 |
" LEFT JOIN {$ordercart_table} AS cart ON ID = cart.order_id"." \n" |
| 111 |
); |
| 112 |
$this->joinTableSql = apply_filters( 'usces_filter_order_list_sql_jointable', $join_table, $meta_table, $this ); |
| 113 |
} |
| 114 |
|
| 115 |
function MakeTable() |
| 116 |
{ |
| 117 |
$this->SetParam(); |
| 118 |
|
| 119 |
switch ($this->action){ |
| 120 |
|
| 121 |
case 'searchIn': |
| 122 |
$this->SearchIn(); |
| 123 |
$res = $this->GetRows(); |
| 124 |
break; |
| 125 |
|
| 126 |
case 'searchOut': |
| 127 |
$this->SearchOut(); |
| 128 |
$res = $this->GetRows(); |
| 129 |
break; |
| 130 |
|
| 131 |
case 'changeSort': |
| 132 |
$res = $this->GetRows(); |
| 133 |
break; |
| 134 |
|
| 135 |
case 'changePage': |
| 136 |
$res = $this->GetRows(); |
| 137 |
break; |
| 138 |
|
| 139 |
case 'collective_order_reciept': |
| 140 |
usces_all_change_order_reciept($this); |
| 141 |
$res = $this->GetRows(); |
| 142 |
break; |
| 143 |
|
| 144 |
case 'collective_order_status': |
| 145 |
usces_all_change_order_status($this); |
| 146 |
$res = $this->GetRows(); |
| 147 |
break; |
| 148 |
|
| 149 |
case 'collective_delete': |
| 150 |
usces_all_delete_order_data($this); |
| 151 |
$this->SetTotalRow(); |
| 152 |
$res = $this->GetRows(); |
| 153 |
break; |
| 154 |
|
| 155 |
case 'refresh': |
| 156 |
default: |
| 157 |
$this->SetDefaultParam(); |
| 158 |
$res = $this->GetRows(); |
| 159 |
break; |
| 160 |
} |
| 161 |
|
| 162 |
$this->SetNavi(); |
| 163 |
$this->SetHeaders(); |
| 164 |
$this->SetSESSION(); |
| 165 |
|
| 166 |
if($res){ |
| 167 |
|
| 168 |
return TRUE; |
| 169 |
|
| 170 |
}else{ |
| 171 |
return FALSE; |
| 172 |
} |
| 173 |
} |
| 174 |
|
| 175 |
//DefaultParam |
| 176 |
function SetDefaultParam() |
| 177 |
{ |
| 178 |
unset($_SESSION[$this->table]); |
| 179 |
$this->startRow = 0; |
| 180 |
$this->currentPage = 1; |
| 181 |
if(isset($_SESSION[$this->table]['arr_search'])){ |
| 182 |
$this->arr_search = $_SESSION[$this->table]['arr_search']; |
| 183 |
}else{ |
| 184 |
$arr_search = array( 'period'=>'3', 'column'=>'', 'word'=>'', 'sku'=>'', 'skuword'=>'' ); |
| 185 |
$this->arr_search = apply_filters( 'usces_filter_order_list_arr_search', $arr_search, $this ); |
| 186 |
} |
| 187 |
if(isset($_SESSION[$this->table]['searchSwitchStatus'])){ |
| 188 |
$this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus']; |
| 189 |
}else{ |
| 190 |
$this->searchSwitchStatus = 'OFF'; |
| 191 |
} |
| 192 |
$this->searchSql = ''; |
| 193 |
$this->searchSkuSql = ''; |
| 194 |
$this->sortColumn = 'ID'; |
| 195 |
foreach($this->columns as $value ){ |
| 196 |
$this->sortSwitchs[$value] = 'DESC'; |
| 197 |
} |
| 198 |
|
| 199 |
$this->SetTotalRow(); |
| 200 |
//$this->SetSelectedRow(); |
| 201 |
} |
| 202 |
|
| 203 |
function SetParam() |
| 204 |
{ |
| 205 |
$this->startRow = ($this->currentPage-1) * $this->maxRow; |
| 206 |
} |
| 207 |
|
| 208 |
function SetParamByQuery() |
| 209 |
{ |
| 210 |
if(isset($_REQUEST['changePage'])){ |
| 211 |
|
| 212 |
$this->action = 'changePage'; |
| 213 |
$this->currentPage = $_REQUEST['changePage']; |
| 214 |
$this->sortColumn = $_SESSION[$this->table]['sortColumn']; |
| 215 |
$this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs']; |
| 216 |
$this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames']; |
| 217 |
$this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus']; |
| 218 |
$this->searchSql = $_SESSION[$this->table]['searchSql']; |
| 219 |
$this->searchSkuSql = $_SESSION[$this->table]['searchSkuSql']; |
| 220 |
$this->arr_search = $_SESSION[$this->table]['arr_search']; |
| 221 |
$this->totalRow = $_SESSION[$this->table]['totalRow']; |
| 222 |
$this->selectedRow = $_SESSION[$this->table]['selectedRow']; |
| 223 |
|
| 224 |
}else if(isset($_REQUEST['changeSort'])){ |
| 225 |
|
| 226 |
$this->action = 'changeSort'; |
| 227 |
$this->sortOldColumn = $this->sortColumn; |
| 228 |
$this->sortColumn = $_REQUEST['changeSort']; |
| 229 |
$this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs']; |
| 230 |
$this->sortSwitchs[$this->sortColumn] = $_REQUEST['switch']; |
| 231 |
$this->currentPage = $_SESSION[$this->table]['currentPage']; |
| 232 |
$this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames']; |
| 233 |
$this->searchSql = $_SESSION[$this->table]['searchSql']; |
| 234 |
$this->searchSkuSql = $_SESSION[$this->table]['searchSkuSql']; |
| 235 |
$this->arr_search = $_SESSION[$this->table]['arr_search']; |
| 236 |
$this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus']; |
| 237 |
$this->totalRow = $_SESSION[$this->table]['totalRow']; |
| 238 |
$this->selectedRow = $_SESSION[$this->table]['selectedRow']; |
| 239 |
|
| 240 |
} else if(isset($_REQUEST['searchIn'])){ |
| 241 |
|
| 242 |
$this->action = 'searchIn'; |
| 243 |
$this->arr_search['column'] = isset($_REQUEST['search']['column']) ? $_REQUEST['search']['column'] : ''; |
| 244 |
$this->arr_search['sku'] = isset($_REQUEST['search']['sku']) ? $_REQUEST['search']['sku'] : ''; |
| 245 |
$this->arr_search['word'] = isset($_REQUEST['search']['word']) ? $_REQUEST['search']['word'] : ''; |
| 246 |
$this->arr_search['skuword'] = isset($_REQUEST['search']['skuword']) ? $_REQUEST['search']['skuword'] : ''; |
| 247 |
$this->arr_search['period'] = isset($_REQUEST['search']['period']) ? (int)$_REQUEST['search']['period'] : 0; |
| 248 |
$this->searchSwitchStatus = isset($_REQUEST['searchSwitchStatus']) ? $_REQUEST['searchSwitchStatus'] : ''; |
| 249 |
$this->currentPage = 1; |
| 250 |
$this->sortColumn = $_SESSION[$this->table]['sortColumn']; |
| 251 |
$this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs']; |
| 252 |
$this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames']; |
| 253 |
$this->totalRow = $_SESSION[$this->table]['totalRow']; |
| 254 |
|
| 255 |
}else if(isset($_REQUEST['searchOut'])){ |
| 256 |
|
| 257 |
$this->action = 'searchOut'; |
| 258 |
$this->arr_search['column'] = ''; |
| 259 |
$this->arr_search['word'] = ''; |
| 260 |
$this->arr_search['sku'] = ''; |
| 261 |
$this->arr_search['skuword'] = ''; |
| 262 |
$this->arr_search['period'] = $_SESSION[$this->table]['arr_search']['period']; |
| 263 |
$this->searchSwitchStatus = isset($_REQUEST['searchSwitchStatus']) ? $_REQUEST['searchSwitchStatus'] : ''; |
| 264 |
$this->currentPage = 1; |
| 265 |
$this->sortColumn = $_SESSION[$this->table]['sortColumn']; |
| 266 |
$this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs']; |
| 267 |
$this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames']; |
| 268 |
$this->totalRow = $_SESSION[$this->table]['totalRow']; |
| 269 |
|
| 270 |
}else if(isset($_REQUEST['refresh'])){ |
| 271 |
|
| 272 |
$this->action = 'refresh'; |
| 273 |
$this->currentPage = $_SESSION[$this->table]['currentPage']; |
| 274 |
$this->sortColumn = $_SESSION[$this->table]['sortColumn']; |
| 275 |
$this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs']; |
| 276 |
$this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames']; |
| 277 |
$this->searchSql = $_SESSION[$this->table]['searchSql']; |
| 278 |
$this->searchSkuSql = $_SESSION[$this->table]['searchSkuSql']; |
| 279 |
$this->arr_search = $_SESSION[$this->table]['arr_search']; |
| 280 |
$this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus']; |
| 281 |
$this->totalRow = $_SESSION[$this->table]['totalRow']; |
| 282 |
$this->selectedRow = $_SESSION[$this->table]['selectedRow']; |
| 283 |
|
| 284 |
}else if(isset($_REQUEST['collective'])){ |
| 285 |
|
| 286 |
$this->action = 'collective_' . $_POST['allchange']['column']; |
| 287 |
$this->currentPage = $_SESSION[$this->table]['currentPage']; |
| 288 |
$this->sortColumn = $_SESSION[$this->table]['sortColumn']; |
| 289 |
$this->sortSwitchs = $_SESSION[$this->table]['sortSwitchs']; |
| 290 |
$this->userHeaderNames = $_SESSION[$this->table]['userHeaderNames']; |
| 291 |
$this->searchSql = $_SESSION[$this->table]['searchSql']; |
| 292 |
$this->searchSkuSql = $_SESSION[$this->table]['searchSkuSql']; |
| 293 |
$this->arr_search = $_SESSION[$this->table]['arr_search']; |
| 294 |
$this->searchSwitchStatus = $_SESSION[$this->table]['searchSwitchStatus']; |
| 295 |
$this->totalRow = $_SESSION[$this->table]['totalRow']; |
| 296 |
$this->selectedRow = $_SESSION[$this->table]['selectedRow']; |
| 297 |
|
| 298 |
}else{ |
| 299 |
|
| 300 |
$this->action = 'default'; |
| 301 |
} |
| 302 |
} |
| 303 |
|
| 304 |
//GetRows |
| 305 |
function GetRows() |
| 306 |
{ |
| 307 |
global $wpdb; |
| 308 |
$where = $this->GetWhere(); |
| 309 |
$order = ' ORDER BY `' . $this->sortColumn . '` ' . $this->sortSwitchs[$this->sortColumn]; |
| 310 |
$order = apply_filters( 'usces_filter_order_list_get_orderby', $order, $this ); |
| 311 |
|
| 312 |
$select = ''; |
| 313 |
foreach( $this->selectSql as $value ) { |
| 314 |
$select .= $value.", "; |
| 315 |
} |
| 316 |
$select = rtrim( $select, ", " ); |
| 317 |
$select .= ", item_name, item_code"; |
| 318 |
$query = apply_filters( 'usces_filter_order_list_select', $select, $this); |
| 319 |
$join_table = ''; |
| 320 |
foreach( $this->joinTableSql as $value ) { |
| 321 |
$join_table .= $value; |
| 322 |
} |
| 323 |
$query = "SELECT ".$select." \n"."FROM {$this->table} "."\n".$join_table.$where."\n".$order; |
| 324 |
$query = apply_filters( 'usces_filter_order_list_get_rows', $query, $this); |
| 325 |
//usces_p($query); |
| 326 |
$wpdb->show_errors(); |
| 327 |
|
| 328 |
$rows = $wpdb->get_results($query, ARRAY_A); |
| 329 |
$this->selectedRow = count($rows); |
| 330 |
if($this->pageLimit == 'off') { |
| 331 |
$this->rows = (array)$rows; |
| 332 |
} else { |
| 333 |
$this->rows = array_slice((array)$rows, $this->startRow, $this->maxRow); |
| 334 |
} |
| 335 |
|
| 336 |
return $this->rows; |
| 337 |
} |
| 338 |
|
| 339 |
function SetTotalRow() |
| 340 |
{ |
| 341 |
global $wpdb; |
| 342 |
$query = "SELECT COUNT(ID) AS ct FROM {$this->table}".apply_filters( 'usces_filter_order_list_sql_where', '', $this ); |
| 343 |
$query = apply_filters( 'usces_filter_order_list_set_total_row', $query, $this); |
| 344 |
$res = $wpdb->get_var($query); |
| 345 |
$this->totalRow = $res; |
| 346 |
} |
| 347 |
|
| 348 |
function GetWhere() |
| 349 |
{ |
| 350 |
$str = ''; |
| 351 |
$thismonth = date('Y-m-01 00:00:00'); |
| 352 |
$lastmonth = date('Y-m-01 00:00:00', mktime(0, 0, 0, date('m')-1, 1, date('Y'))); |
| 353 |
$lastweek = date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m'), date('d')-7, date('Y'))); |
| 354 |
$last30 = date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m'), date('d')-30, date('Y'))); |
| 355 |
$last90 = date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m'), date('d')-90, date('Y'))); |
| 356 |
switch ( $this->arr_search['period'] ) { |
| 357 |
case 0: |
| 358 |
$where = " WHERE order_date >= '{$thismonth}' "; |
| 359 |
break; |
| 360 |
case 1: |
| 361 |
$where = " WHERE order_date >= '{$lastmonth}' AND order_date < '{$thismonth}' "; |
| 362 |
break; |
| 363 |
case 2: |
| 364 |
$where = " WHERE order_date >= '{$lastweek}' "; |
| 365 |
break; |
| 366 |
case 3: |
| 367 |
$where = " WHERE order_date >= '{$last30}' "; |
| 368 |
break; |
| 369 |
case 4: |
| 370 |
$where = " WHERE order_date >= '{$last90}' "; |
| 371 |
break; |
| 372 |
case 5: |
| 373 |
$where = ""; |
| 374 |
break; |
| 375 |
} |
| 376 |
if( !WCUtils::is_blank($where) ){ |
| 377 |
if( !WCUtils::is_blank($this->searchSkuSql) ){ |
| 378 |
$where .= ' AND ' . $this->searchSkuSql; |
| 379 |
} |
| 380 |
}else{ |
| 381 |
if( !WCUtils::is_blank($this->searchSkuSql) ){ |
| 382 |
$where = ' WHERE ' . $this->searchSkuSql; |
| 383 |
} |
| 384 |
} |
| 385 |
$str = apply_filters( 'usces_filter_order_list_sql_where', $where, $this ); |
| 386 |
|
| 387 |
$str .= " \n" . " GROUP BY `ID` "; |
| 388 |
|
| 389 |
$having = ''; |
| 390 |
if( !WCUtils::is_blank($this->searchSql) ){ |
| 391 |
$having = ' HAVING ' . $this->searchSql; |
| 392 |
} |
| 393 |
$having = apply_filters( 'usces_filter_order_list_sql_having', $having, $this ); |
| 394 |
|
| 395 |
if( !WCUtils::is_blank($having) ){ |
| 396 |
$str .= $having; |
| 397 |
} |
| 398 |
|
| 399 |
return apply_filters( 'usces_filter_order_list_get_where', $str, $this ); |
| 400 |
} |
| 401 |
|
| 402 |
function SearchIn() |
| 403 |
{ |
| 404 |
switch ($this->arr_search['column']) { |
| 405 |
case 'ID': |
| 406 |
$column = 'ID'; |
| 407 |
$this->searchSql = $column . ' = ' . (int)$this->arr_search['word']['ID']; |
| 408 |
break; |
| 409 |
case 'deco_id': |
| 410 |
$column = 'deco_id'; |
| 411 |
$this->searchSql = $column . ' LIKE '."'%" . esc_sql($this->arr_search['word']['deco_id']) . "%'"; |
| 412 |
break; |
| 413 |
case 'date': |
| 414 |
$column = 'date'; |
| 415 |
$this->searchSql = $column . ' LIKE '."'%" . esc_sql($this->arr_search['word']['date']) . "%'"; |
| 416 |
break; |
| 417 |
case 'mem_id': |
| 418 |
$column = 'mem_id'; |
| 419 |
$this->searchSql = $column . ' = ' . (int)$this->arr_search['word']['mem_id']; |
| 420 |
break; |
| 421 |
case 'name': |
| 422 |
$column = 'name'; |
| 423 |
$this->searchSql = $column . ' LIKE '."'%" . esc_sql($this->arr_search['word']['name']) . "%'"; |
| 424 |
break; |
| 425 |
case 'order_modified': |
| 426 |
$column = 'order_modified'; |
| 427 |
$this->searchSql = $column . ' LIKE '."'%" . esc_sql($this->arr_search['word']['order_modified']) . "%'"; |
| 428 |
break; |
| 429 |
case 'pref': |
| 430 |
$column = 'pref'; |
| 431 |
$this->searchSql = $column . " = '" . esc_sql($this->arr_search['word']['pref']) . "'"; |
| 432 |
break; |
| 433 |
case 'delivery_method': |
| 434 |
$column = 'delivery_method'; |
| 435 |
$this->searchSql = $column . " = '" . esc_sql($this->arr_search['word']['delivery_method']) . "'"; |
| 436 |
break; |
| 437 |
case 'payment_name': |
| 438 |
$column = 'payment_name'; |
| 439 |
$this->searchSql = $column . " = '" . esc_sql($this->arr_search['word']['payment_name']) . "'"; |
| 440 |
break; |
| 441 |
case 'receipt_status': |
| 442 |
$column = 'receipt_status'; |
| 443 |
$this->searchSql = $column . " = '" . esc_sql($this->arr_search['word']['receipt_status']) . "'"; |
| 444 |
break; |
| 445 |
case 'order_status': |
| 446 |
$column = 'order_status'; |
| 447 |
$this->searchSql = $column . " = '" . esc_sql($this->arr_search['word']['order_status']) . "'"; |
| 448 |
break; |
| 449 |
} |
| 450 |
switch ($this->arr_search['sku']) { |
| 451 |
case 'item_code': |
| 452 |
$column = 'item_code'; |
| 453 |
$this->searchSkuSql = $column . ' LIKE '."'%" . esc_sql($this->arr_search['skuword']['item_code']) . "%'"; |
| 454 |
break; |
| 455 |
case 'item_name': |
| 456 |
$column = 'item_name'; |
| 457 |
$this->searchSkuSql = $column . ' LIKE '."'%" . esc_sql($this->arr_search['skuword']['item_name']) . "%'"; |
| 458 |
break; |
| 459 |
} |
| 460 |
} |
| 461 |
|
| 462 |
function SearchOut() |
| 463 |
{ |
| 464 |
$this->searchSql = ''; |
| 465 |
$this->searchSkuSql = ''; |
| 466 |
} |
| 467 |
|
| 468 |
function SetNavi() |
| 469 |
{ |
| 470 |
$this->lastPage = ceil($this->selectedRow / $this->maxRow); |
| 471 |
$this->previousPage = ($this->currentPage - 1 == 0) ? 1 : $this->currentPage - 1; |
| 472 |
$this->nextPage = ($this->currentPage + 1 > $this->lastPage) ? $this->lastPage : $this->currentPage + 1; |
| 473 |
|
| 474 |
for($i=0; $i<$this->naviMaxButton; $i++){ |
| 475 |
if($i > $this->lastPage-1) break; |
| 476 |
if($this->lastPage <= $this->naviMaxButton) { |
| 477 |
$box[] = $i+1; |
| 478 |
}else{ |
| 479 |
if($this->currentPage <= 6) { |
| 480 |
$label = $i + 1; |
| 481 |
$box[] = $label; |
| 482 |
}else{ |
| 483 |
$label = $i + 1 + $this->currentPage - 6; |
| 484 |
$box[] = $label; |
| 485 |
if($label == $this->lastPage) break; |
| 486 |
} |
| 487 |
} |
| 488 |
} |
| 489 |
|
| 490 |
$html = ''; |
| 491 |
$html .= '<ul class="clearfix">'."\n"; |
| 492 |
$html .= '<li class="rowsnum">' . $this->selectedRow . ' / ' . $this->totalRow . ' ' . __('cases', 'usces') . '</li>' . "\n"; |
| 493 |
if(($this->currentPage == 1) || ($this->selectedRow == 0)){ |
| 494 |
$html .= '<li class="navigationStr">first<<</li>' . "\n"; |
| 495 |
$html .= '<li class="navigationStr">prev<</li>'."\n"; |
| 496 |
}else{ |
| 497 |
$html .= '<li class="navigationStr"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_orderlist&changePage=1">first<<</a></li>' . "\n"; |
| 498 |
$html .= '<li class="navigationStr"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_orderlist&changePage=' . $this->previousPage . '">prev<</a></li>'."\n"; |
| 499 |
} |
| 500 |
if($this->selectedRow > 0) { |
| 501 |
for($i=0; $i<count($box); $i++){ |
| 502 |
if($box[$i] == $this->currentPage){ |
| 503 |
$html .= '<li class="navigationButtonSelected">' . $box[$i] . '</li>'."\n"; |
| 504 |
}else{ |
| 505 |
$html .= '<li class="navigationButton"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_orderlist&changePage=' . $box[$i] . '">' . $box[$i] . '</a></li>'."\n"; |
| 506 |
} |
| 507 |
} |
| 508 |
} |
| 509 |
if(($this->currentPage == $this->lastPage) || ($this->selectedRow == 0)){ |
| 510 |
$html .= '<li class="navigationStr">>next</li>'."\n"; |
| 511 |
$html .= '<li class="navigationStr">>>last</li>'."\n"; |
| 512 |
}else{ |
| 513 |
$html .= '<li class="navigationStr"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_orderlist&changePage=' . $this->nextPage . '">>next</a></li>'."\n"; |
| 514 |
$html .= '<li class="navigationStr"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_orderlist&changePage=' . $this->lastPage . '">>>last</a></li>'."\n"; |
| 515 |
} |
| 516 |
if($this->searchSwitchStatus == 'OFF'){ |
| 517 |
$html .= '<li class="rowsnum"><a style="cursor:pointer;" id="searchVisiLink" onclick="toggleVisibility(\'searchBox\');">' . __('Show the Operation field', 'usces') . '</a>'."\n"; |
| 518 |
}else{ |
| 519 |
$html .= '<li class="rowsnum"><a style="cursor:pointer;" id="searchVisiLink" onclick="toggleVisibility(\'searchBox\');">' . __('hide the Operation field', 'usces') . '</a>'."\n"; |
| 520 |
} |
| 521 |
|
| 522 |
$html .= '<li class="refresh"><a href="' . site_url() . '/wp-admin/admin.php?page=usces_orderlist&refresh">' . __('updates it to latest information', 'usces') . '</a></li>' . "\n"; |
| 523 |
$html .= '</ul>'."\n"; |
| 524 |
|
| 525 |
$this->dataTableNavigation = $html; |
| 526 |
} |
| 527 |
|
| 528 |
function SetSESSION() |
| 529 |
{ |
| 530 |
$_SESSION[$this->table]['startRow'] = $this->startRow; //表示開始行番号 |
| 531 |
$_SESSION[$this->table]['sortColumn'] = $this->sortColumn; //現在ソート中のフィールド |
| 532 |
$_SESSION[$this->table]['totalRow'] = $this->totalRow; //� |
| 533 |
�行数 |
| 534 |
$_SESSION[$this->table]['selectedRow'] = $this->selectedRow; //絞り込まれた行数 |
| 535 |
$_SESSION[$this->table]['currentPage'] = $this->currentPage; //現在のページNo |
| 536 |
$_SESSION[$this->table]['previousPage'] = $this->previousPage; //前のページNo |
| 537 |
$_SESSION[$this->table]['nextPage'] = $this->nextPage; //次のページNo |
| 538 |
$_SESSION[$this->table]['lastPage'] = $this->lastPage; //最終ページNo |
| 539 |
$_SESSION[$this->table]['userHeaderNames'] = $this->userHeaderNames;//� |
| 540 |
�てのフィールド |
| 541 |
$_SESSION[$this->table]['headers'] = $this->headers;//表示するヘッダ文字列 |
| 542 |
$_SESSION[$this->table]['rows'] = $this->rows; //表示する行オブジェクト |
| 543 |
$_SESSION[$this->table]['sortSwitchs'] = $this->sortSwitchs; //各フィールド毎の昇順降順スイッチ |
| 544 |
$_SESSION[$this->table]['dataTableNavigation'] = $this->dataTableNavigation; |
| 545 |
$_SESSION[$this->table]['searchSql'] = $this->searchSql; |
| 546 |
$_SESSION[$this->table]['searchSkuSql'] = $this->searchSkuSql; |
| 547 |
$_SESSION[$this->table]['arr_search'] = $this->arr_search; |
| 548 |
$_SESSION[$this->table]['searchSwitchStatus'] = $this->searchSwitchStatus; |
| 549 |
do_action( 'usces_action_order_list_set_session', $this ); |
| 550 |
} |
| 551 |
|
| 552 |
function SetHeaders() |
| 553 |
{ |
| 554 |
foreach ($this->columns as $key => $value){ |
| 555 |
if($value == $this->sortColumn){ |
| 556 |
if($this->sortSwitchs[$value] == 'ASC'){ |
| 557 |
$str = __('[ASC]', 'usces'); |
| 558 |
$switch = 'DESC'; |
| 559 |
}else{ |
| 560 |
$str = __('[DESC]', 'usces'); |
| 561 |
$switch = 'ASC'; |
| 562 |
} |
| 563 |
$this->headers[$value] = '<a href="' . site_url() . '/wp-admin/admin.php?page=usces_orderlist&changeSort=' . $value . '&switch=' . $switch . '"><span class="sortcolumn">' . $key . ' ' . $str . '</span></a>'; |
| 564 |
}else{ |
| 565 |
$switch = $this->sortSwitchs[$value]; |
| 566 |
$this->headers[$value] = '<a href="' . site_url() . '/wp-admin/admin.php?page=usces_orderlist&changeSort=' . $value . '&switch=' . $switch . '"><span>' . $key . '</span></a>'; |
| 567 |
} |
| 568 |
} |
| 569 |
//$this->headers = array_keys($this->columns); |
| 570 |
} |
| 571 |
|
| 572 |
function GetSearchs() |
| 573 |
{ |
| 574 |
return $this->arr_search; |
| 575 |
} |
| 576 |
|
| 577 |
function GetListheaders() |
| 578 |
{ |
| 579 |
return $this->headers; |
| 580 |
} |
| 581 |
|
| 582 |
function GetDataTableNavigation() |
| 583 |
{ |
| 584 |
return $this->dataTableNavigation; |
| 585 |
} |
| 586 |
|
| 587 |
function set_action_status($status, $message) |
| 588 |
{ |
| 589 |
$this->action_status = $status; |
| 590 |
$this->action_message = $message; |
| 591 |
} |
| 592 |
|
| 593 |
function get_action_status() |
| 594 |
{ |
| 595 |
return $this->action_status; |
| 596 |
} |
| 597 |
|
| 598 |
function get_action_message() |
| 599 |
{ |
| 600 |
return $this->action_message; |
| 601 |
} |
| 602 |
} |
| 603 |
|
| 604 |
|
| 605 |
?> |