| 1 |
<?php |
| 2 |
/** |
| 3 |
* Member List Class. |
| 4 |
* |
| 5 |
* @package Welcart |
| 6 |
*/ |
| 7 |
class WlcMemberList { |
| 8 |
public $table; /* テーブル名 */ |
| 9 |
public $rows; /* データ */ |
| 10 |
public $action; /* アクション */ |
| 11 |
public $startRow; /* 表示開始行番号 */ |
| 12 |
public $maxRow; /* 最大表示行数 */ |
| 13 |
public $currentPage; /* 現在のページNo */ |
| 14 |
public $firstPage; /* 最初のページNo */ |
| 15 |
public $previousPage; /* 前のページNo */ |
| 16 |
public $nextPage; /* 次のページNo */ |
| 17 |
public $lastPage; /* 最終ページNo */ |
| 18 |
public $naviMaxButton; /* ページネーション・ナビのボタンの数 */ |
| 19 |
public $dataTableNavigation; /* ナヴィゲーションhtmlコード */ |
| 20 |
public $arr_period; /* 表示データ期間 */ |
| 21 |
public $arr_search; /* サーチ条件 */ |
| 22 |
public $searchWhere; /* オーダーカラム */ |
| 23 |
public $searchHaving; /* メンバーカラム */ |
| 24 |
public $columns; /* データカラム */ |
| 25 |
public $sortColumn; /* 現在ソート中のフィールド */ |
| 26 |
public $sortOldColumn; |
| 27 |
public $sortSwitchs; /* 各フィールド毎の昇順降順スイッチ */ |
| 28 |
public $userHeaderNames; /* ユーザー指定のヘッダ名 */ |
| 29 |
public $pageLimit; /* ページ制限 */ |
| 30 |
public $listOption; |
| 31 |
public $csmb_meta; |
| 32 |
public $admb_meta; |
| 33 |
public $csod_meta; |
| 34 |
public $action_status; |
| 35 |
public $action_message; |
| 36 |
public $currentPageIds; |
| 37 |
public $placeholder_escape; |
| 38 |
public $data_cookie; |
| 39 |
|
| 40 |
public $totalRow; |
| 41 |
public $selectedRow; |
| 42 |
public $headers; |
| 43 |
|
| 44 |
/** |
| 45 |
* Constructor. |
| 46 |
*/ |
| 47 |
public function __construct() { |
| 48 |
global $wpdb; |
| 49 |
$this->csmb_meta = usces_has_custom_field_meta( 'member' ); |
| 50 |
$this->admb_meta = usces_has_custom_field_meta( 'admin_member' ); |
| 51 |
$this->csod_meta = usces_has_custom_field_meta( 'order' ); |
| 52 |
|
| 53 |
$this->listOption = get_option( 'usces_memberlist_option', array() ); |
| 54 |
|
| 55 |
$this->table = usces_get_tablename( 'usces_member' ); |
| 56 |
$this->set_column(); |
| 57 |
$this->rows = array(); |
| 58 |
|
| 59 |
$this->maxRow = $this->listOption['max_row'] ?? 50; |
| 60 |
$this->naviMaxButton = 11; |
| 61 |
$this->firstPage = 1; |
| 62 |
$this->pageLimit = 'on'; |
| 63 |
$this->action_status = 'none'; |
| 64 |
$this->action_message = ''; |
| 65 |
|
| 66 |
$this->getCookie(); |
| 67 |
$this->SetDefaultParam(); |
| 68 |
$this->SetParamByQuery(); |
| 69 |
$this->validationSearchParameters(); |
| 70 |
$this->arr_period = array( |
| 71 |
__( 'This month', 'usces' ), |
| 72 |
__( 'Last month', 'usces' ), |
| 73 |
__( 'The past one week', 'usces' ), |
| 74 |
__( 'Last 30 days', 'usces' ), |
| 75 |
__( 'Last 90days', 'usces' ), |
| 76 |
__( 'All', 'usces' ), |
| 77 |
); |
| 78 |
|
| 79 |
$wpdb->query( 'SET SQL_BIG_SELECTS=1' ); |
| 80 |
} |
| 81 |
|
| 82 |
/** |
| 83 |
* Set Column. |
| 84 |
*/ |
| 85 |
public function set_column() { |
| 86 |
$arr_column = array(); |
| 87 |
$arr_column['ID'] = __( 'membership number', 'usces' ); |
| 88 |
$arr_column['name1'] = __( 'Last Name', 'usces' ); |
| 89 |
$arr_column['name2'] = __( 'First Name', 'usces' ); |
| 90 |
$arr_column['name3'] = __( 'Last Furigana', 'usces' ); |
| 91 |
$arr_column['name4'] = __( 'First Furigana', 'usces' ); |
| 92 |
$arr_column['zipcode'] = __( 'Zip', 'usces' ); |
| 93 |
$arr_column['country'] = __( 'Country', 'usces' ); |
| 94 |
$arr_column['pref'] = __( 'Province', 'usces' ); |
| 95 |
$arr_column['address1'] = __( 'city', 'usces' ); |
| 96 |
$arr_column['address2'] = __( 'numbers', 'usces' ); |
| 97 |
$arr_column['address3'] = __( 'building name', 'usces' ); |
| 98 |
$arr_column['tel'] = __( 'Phone number', 'usces' ); |
| 99 |
$arr_column['fax'] = __( 'FAX number', 'usces' ); |
| 100 |
$arr_column['email'] = __( 'e-mail', 'usces' ); |
| 101 |
$arr_column['entrydate'] = __( 'Entry date', 'usces' ); |
| 102 |
$arr_column['rank'] = __( 'Rank', 'usces' ); |
| 103 |
$arr_column['point'] = __( 'current point', 'usces' ); |
| 104 |
|
| 105 |
foreach ( (array) $this->csmb_meta as $key => $value ) { |
| 106 |
$csmb_key = 'csmb_' . $key; |
| 107 |
$csmb_name = $value['name']; |
| 108 |
$arr_column[ $csmb_key ] = $csmb_name; |
| 109 |
} |
| 110 |
|
| 111 |
foreach ( (array) $this->admb_meta as $key => $value ) { |
| 112 |
$admb_key = 'admb_' . $key; |
| 113 |
$admb_name = $value['name']; |
| 114 |
$arr_column[ $admb_key ] = $admb_name; |
| 115 |
} |
| 116 |
|
| 117 |
foreach ( (array) $this->csod_meta as $key => $value ) { |
| 118 |
$csod_key = 'csod_' . $key; |
| 119 |
$csod_name = $value['name']; |
| 120 |
$arr_column[ $csod_key ] = $csod_name; |
| 121 |
} |
| 122 |
|
| 123 |
$arr_column = apply_filters( 'usces_filter_memberlist_column', $arr_column, $this ); |
| 124 |
$this->columns = $arr_column; |
| 125 |
} |
| 126 |
|
| 127 |
/** |
| 128 |
* Get Column. |
| 129 |
*/ |
| 130 |
public function get_column() { |
| 131 |
return $this->columns; |
| 132 |
} |
| 133 |
|
| 134 |
/** |
| 135 |
* Action. |
| 136 |
* |
| 137 |
* @return mixed |
| 138 |
*/ |
| 139 |
public function MakeTable() { |
| 140 |
|
| 141 |
$this->SetParam(); |
| 142 |
|
| 143 |
switch ( $this->action ) { |
| 144 |
|
| 145 |
case 'searchOut': |
| 146 |
check_admin_referer( 'member_list', 'wc_nonce' ); |
| 147 |
$this->SearchOut(); |
| 148 |
$res = $this->GetRows(); |
| 149 |
break; |
| 150 |
|
| 151 |
case 'collective_rank': |
| 152 |
check_admin_referer( 'member_list', 'wc_nonce' ); |
| 153 |
usces_all_change_member_rank( $this ); |
| 154 |
$this->SearchIn(); |
| 155 |
$res = $this->GetRows(); |
| 156 |
break; |
| 157 |
|
| 158 |
case 'collective_point': |
| 159 |
check_admin_referer( 'member_list', 'wc_nonce' ); |
| 160 |
usces_all_change_member_point( $this ); |
| 161 |
$this->SearchIn(); |
| 162 |
$res = $this->GetRows(); |
| 163 |
break; |
| 164 |
|
| 165 |
case 'collective_delete': |
| 166 |
check_admin_referer( 'member_list', 'wc_nonce' ); |
| 167 |
usces_all_delete_member_data( $this ); |
| 168 |
$this->SearchIn(); |
| 169 |
$res = $this->GetRows(); |
| 170 |
break; |
| 171 |
|
| 172 |
case 'searchIn': |
| 173 |
case 'returnList': |
| 174 |
case 'changeSort': |
| 175 |
case 'changePage': |
| 176 |
case 'refresh': |
| 177 |
check_admin_referer( 'member_list', 'wc_nonce' ); |
| 178 |
default: |
| 179 |
$this->SearchIn(); |
| 180 |
$res = $this->GetRows(); |
| 181 |
break; |
| 182 |
} |
| 183 |
|
| 184 |
$this->SetNavi(); |
| 185 |
$this->SetHeaders(); |
| 186 |
|
| 187 |
if ( $res ) { |
| 188 |
return true; |
| 189 |
} else { |
| 190 |
return false; |
| 191 |
} |
| 192 |
} |
| 193 |
|
| 194 |
/** |
| 195 |
* Get Default Search Parameters. |
| 196 |
* |
| 197 |
* @return array |
| 198 |
*/ |
| 199 |
public function get_default_arr_search() { |
| 200 |
return array( |
| 201 |
'period' => '3', |
| 202 |
'member_column' => array( '', '' ), |
| 203 |
'member_word' => array( '', '' ), |
| 204 |
'member_word_term' => array( 'contain', 'contain' ), |
| 205 |
'member_term' => 'AND', |
| 206 |
'order_column' => array( '', '' ), |
| 207 |
'order_word' => array( '', '' ), |
| 208 |
'order_word_term' => array( 'contain', 'contain' ), |
| 209 |
'order_term' => 'AND', |
| 210 |
); |
| 211 |
} |
| 212 |
|
| 213 |
/** |
| 214 |
* Default Parameters. |
| 215 |
*/ |
| 216 |
public function SetDefaultParam() { |
| 217 |
$this->startRow = isset( $this->data_cookie['startRow'] ) ? $this->data_cookie['startRow'] : 0; |
| 218 |
$this->currentPage = isset( $this->data_cookie['currentPage'] ) ? $this->data_cookie['currentPage'] : 1; |
| 219 |
$this->sortColumn = ( isset( $this->data_cookie['sortColumn'] ) ) ? $this->data_cookie['sortColumn'] : 'ID'; |
| 220 |
$this->searchWhere = ( isset( $this->data_cookie['searchWhere'] ) ) ? $this->data_cookie['searchWhere'] : ''; |
| 221 |
$this->searchHaving = ( isset( $this->data_cookie['searchHaving'] ) ) ? $this->data_cookie['searchHaving'] : ''; |
| 222 |
if ( isset( $this->data_cookie['arr_search'] ) ) { |
| 223 |
$this->arr_search = $this->data_cookie['arr_search']; |
| 224 |
} else { |
| 225 |
$this->arr_search = $this->get_default_arr_search(); |
| 226 |
} |
| 227 |
if ( isset( $this->data_cookie['sortSwitchs'] ) ) { |
| 228 |
$this->sortSwitchs = $this->data_cookie['sortSwitchs']; |
| 229 |
foreach ( $this->csmb_meta as $key => $value ) { |
| 230 |
$csmb_key = 'csmb_' . $key; |
| 231 |
if ( ! isset( $this->sortSwitchs[ $csmb_key ] ) ) { |
| 232 |
$this->sortSwitchs[ $csmb_key ] = 'DESC'; |
| 233 |
} |
| 234 |
} |
| 235 |
foreach ( $this->admb_meta as $key => $value ) { |
| 236 |
$admb_key = 'admb_' . $key; |
| 237 |
if ( ! isset( $this->sortSwitchs[ $admb_key ] ) ) { |
| 238 |
$this->sortSwitchs[ $admb_key ] = 'DESC'; |
| 239 |
} |
| 240 |
} |
| 241 |
} else { |
| 242 |
$this->sortSwitchs[ $this->sortColumn ] = 'DESC'; |
| 243 |
} |
| 244 |
|
| 245 |
$this->SetTotalRow(); |
| 246 |
} |
| 247 |
|
| 248 |
/** |
| 249 |
* Set Parameters. |
| 250 |
*/ |
| 251 |
public function SetParam() { |
| 252 |
$this->startRow = ( $this->currentPage - 1 ) * $this->maxRow; |
| 253 |
} |
| 254 |
|
| 255 |
/** |
| 256 |
* Set Parameters. |
| 257 |
*/ |
| 258 |
public function SetParamByQuery() { |
| 259 |
global $wpdb; |
| 260 |
if ( isset( $_REQUEST['changePage'] ) ) { |
| 261 |
|
| 262 |
$this->action = 'changePage'; |
| 263 |
$this->currentPage = (int) $_REQUEST['changePage']; |
| 264 |
$this->sortColumn = ( isset( $this->data_cookie['sortColumn'] ) ) ? $this->data_cookie['sortColumn'] : $this->sortColumn; |
| 265 |
$this->sortSwitchs = ( isset( $this->data_cookie['sortSwitchs'] ) ) ? $this->data_cookie['sortSwitchs'] : $this->sortSwitchs; |
| 266 |
$this->userHeaderNames = ( isset( $this->data_cookie['userHeaderNames'] ) ) ? $this->data_cookie['userHeaderNames'] : $this->userHeaderNames; |
| 267 |
$this->arr_search = ( isset( $this->data_cookie['arr_search'] ) ) ? $this->data_cookie['arr_search'] : $this->arr_search; |
| 268 |
$this->totalRow = ( isset( $this->data_cookie['totalRow'] ) ) ? $this->data_cookie['totalRow'] : $this->totalRow; |
| 269 |
$this->selectedRow = ( isset( $this->data_cookie['selectedRow'] ) ) ? $this->data_cookie['selectedRow'] : $this->selectedRow; |
| 270 |
$this->placeholder_escape = ( isset( $this->data_cookie['placeholder_escape'] ) ) ? $this->data_cookie['placeholder_escape'] : $this->placeholder_escape; |
| 271 |
|
| 272 |
} elseif ( isset( $_REQUEST['returnList'] ) ) { |
| 273 |
|
| 274 |
$this->action = 'returnList'; |
| 275 |
$this->currentPage = ( isset( $this->data_cookie['currentPage'] ) ) ? $this->data_cookie['currentPage'] : $this->currentPage; |
| 276 |
$this->sortColumn = ( isset( $this->data_cookie['sortColumn'] ) ) ? $this->data_cookie['sortColumn'] : $this->sortColumn; |
| 277 |
$this->sortSwitchs = ( isset( $this->data_cookie['sortSwitchs'] ) ) ? $this->data_cookie['sortSwitchs'] : $this->sortSwitchs; |
| 278 |
$this->userHeaderNames = ( isset( $this->data_cookie['userHeaderNames'] ) ) ? $this->data_cookie['userHeaderNames'] : $this->userHeaderNames; |
| 279 |
$this->arr_search = ( isset( $this->data_cookie['arr_search'] ) ) ? $this->data_cookie['arr_search'] : $this->arr_search; |
| 280 |
$this->totalRow = ( isset( $this->data_cookie['totalRow'] ) ) ? $this->data_cookie['totalRow'] : $this->totalRow; |
| 281 |
$this->selectedRow = ( isset( $this->data_cookie['selectedRow'] ) ) ? $this->data_cookie['selectedRow'] : $this->selectedRow; |
| 282 |
$this->placeholder_escape = ( isset( $this->data_cookie['placeholder_escape'] ) ) ? $this->data_cookie['placeholder_escape'] : $this->placeholder_escape; |
| 283 |
|
| 284 |
} elseif ( isset( $_REQUEST['changeSort'] ) ) { |
| 285 |
|
| 286 |
$this->action = 'changeSort'; |
| 287 |
$this->sortOldColumn = $this->sortColumn; |
| 288 |
// Validate sortColumn. |
| 289 |
if ( in_array( $_REQUEST['changeSort'], array_keys( $this->columns ) ) ) { |
| 290 |
$this->sortColumn = $_REQUEST['changeSort']; |
| 291 |
} else { |
| 292 |
$this->sortColumn = 'ID'; // default. |
| 293 |
} |
| 294 |
$this->sortSwitchs = ( isset( $this->data_cookie['sortSwitchs'] ) ) ? $this->data_cookie['sortSwitchs'] : $this->sortSwitchs; |
| 295 |
// Validate sortSwitchs. |
| 296 |
if ( isset( $_REQUEST['switch'] ) && in_array( $_REQUEST['switch'], array( 'ASC', 'DESC' ) ) ) { |
| 297 |
$this->sortSwitchs[ $this->sortColumn ] = $_REQUEST['switch']; |
| 298 |
} else { |
| 299 |
$this->sortSwitchs[ $this->sortColumn ] = 'DESC'; // default. |
| 300 |
} |
| 301 |
$this->currentPage = ( isset( $this->data_cookie['currentPage'] ) ) ? $this->data_cookie['currentPage'] : $this->currentPage; |
| 302 |
$this->userHeaderNames = ( isset( $this->data_cookie['userHeaderNames'] ) ) ? $this->data_cookie['userHeaderNames'] : $this->userHeaderNames; |
| 303 |
$this->arr_search = ( isset( $this->data_cookie['arr_search'] ) ) ? $this->data_cookie['arr_search'] : $this->arr_search; |
| 304 |
$this->totalRow = ( isset( $this->data_cookie['totalRow'] ) ) ? $this->data_cookie['totalRow'] : $this->totalRow; |
| 305 |
$this->selectedRow = ( isset( $this->data_cookie['selectedRow'] ) ) ? $this->data_cookie['selectedRow'] : $this->selectedRow; |
| 306 |
$this->placeholder_escape = ( isset( $this->data_cookie['placeholder_escape'] ) ) ? $this->data_cookie['placeholder_escape'] : $this->placeholder_escape; |
| 307 |
|
| 308 |
} elseif ( isset( $_REQUEST['searchIn'] ) ) { |
| 309 |
|
| 310 |
$this->action = 'searchIn'; |
| 311 |
$this->arr_search['member_column'][0] = ! WCUtils::is_blank( $_REQUEST['search']['member_column'][0] ) ? str_replace( '`', '', $_REQUEST['search']['member_column'][0] ) : ''; |
| 312 |
$this->arr_search['member_column'][1] = ! WCUtils::is_blank( $_REQUEST['search']['member_column'][1] ) ? str_replace( '`', '', $_REQUEST['search']['member_column'][1] ) : ''; |
| 313 |
$this->arr_search['member_word'][0] = ! WCUtils::is_blank( $_REQUEST['search']['member_word'][0] ) ? trim( $_REQUEST['search']['member_word'][0] ) : ''; |
| 314 |
$this->arr_search['member_word'][1] = ! WCUtils::is_blank( $_REQUEST['search']['member_word'][1] ) ? trim( $_REQUEST['search']['member_word'][1] ) : ''; |
| 315 |
$this->arr_search['member_word_term'][0] = isset( $_REQUEST['search']['member_word_term'][0] ) ? $_REQUEST['search']['member_word_term'][0] : 'contain'; |
| 316 |
$this->arr_search['member_word_term'][1] = isset( $_REQUEST['search']['member_word_term'][1] ) ? $_REQUEST['search']['member_word_term'][1] : 'contain'; |
| 317 |
if ( WCUtils::is_blank( $_REQUEST['search']['member_column'][0] ) ) { |
| 318 |
$this->arr_search['member_column'][1] = ''; |
| 319 |
$this->arr_search['member_word'][0] = ''; |
| 320 |
$this->arr_search['member_word'][1] = ''; |
| 321 |
$this->arr_search['member_word_term'][0] = 'contain'; |
| 322 |
$this->arr_search['member_word_term'][1] = 'contain'; |
| 323 |
} |
| 324 |
$this->arr_search['member_term'] = $_REQUEST['search']['member_term']; |
| 325 |
$this->arr_search['order_column'][0] = ! WCUtils::is_blank( $_REQUEST['search']['order_column'][0] ) ? str_replace( '`', '', $_REQUEST['search']['order_column'][0] ) : ''; |
| 326 |
$this->arr_search['order_column'][1] = ! WCUtils::is_blank( $_REQUEST['search']['order_column'][1] ) ? str_replace( '`', '', $_REQUEST['search']['order_column'][1] ) : ''; |
| 327 |
$this->arr_search['order_word'][0] = ! WCUtils::is_blank( $_REQUEST['search']['order_word'][0] ) ? trim( $_REQUEST['search']['order_word'][0] ) : ''; |
| 328 |
$this->arr_search['order_word'][1] = ! WCUtils::is_blank( $_REQUEST['search']['order_word'][1] ) ? trim( $_REQUEST['search']['order_word'][1] ) : ''; |
| 329 |
$this->arr_search['order_word_term'][0] = isset( $_REQUEST['search']['order_word_term'][0] ) ? $_REQUEST['search']['order_word_term'][0] : 'contain'; |
| 330 |
$this->arr_search['order_word_term'][1] = isset( $_REQUEST['search']['order_word_term'][1] ) ? $_REQUEST['search']['order_word_term'][1] : 'contain'; |
| 331 |
if ( WCUtils::is_blank( $_REQUEST['search']['order_column'][0] ) ) { |
| 332 |
$this->arr_search['order_column'][1] = ''; |
| 333 |
$this->arr_search['order_word'][0] = ''; |
| 334 |
$this->arr_search['order_word'][1] = ''; |
| 335 |
$this->arr_search['order_word_term'][0] = 'contain'; |
| 336 |
$this->arr_search['order_word_term'][1] = 'contain'; |
| 337 |
} |
| 338 |
$this->arr_search['order_term'] = $_REQUEST['search']['order_term']; |
| 339 |
$this->currentPage = 1; |
| 340 |
$this->sortColumn = ( isset( $this->data_cookie['sortColumn'] ) ) ? $this->data_cookie['sortColumn'] : $this->sortColumn; |
| 341 |
$this->sortSwitchs = ( isset( $this->data_cookie['sortSwitchs'] ) ) ? $this->data_cookie['sortSwitchs'] : $this->sortSwitchs; |
| 342 |
$this->userHeaderNames = ( isset( $this->data_cookie['userHeaderNames'] ) ) ? $this->data_cookie['userHeaderNames'] : $this->userHeaderNames; |
| 343 |
$this->totalRow = ( isset( $this->data_cookie['totalRow'] ) ) ? $this->data_cookie['totalRow'] : $this->totalRow; |
| 344 |
$this->placeholder_escape = $wpdb->placeholder_escape(); |
| 345 |
|
| 346 |
} elseif ( isset( $_REQUEST['searchOut'] ) ) { |
| 347 |
|
| 348 |
$this->action = 'searchOut'; |
| 349 |
$this->arr_search['column'] = ''; |
| 350 |
$this->arr_search['word'] = ''; |
| 351 |
$this->arr_search['member_column'][0] = ''; |
| 352 |
$this->arr_search['member_column'][1] = ''; |
| 353 |
$this->arr_search['member_word'][0] = ''; |
| 354 |
$this->arr_search['member_word'][1] = ''; |
| 355 |
$this->arr_search['member_word_term'][0] = 'contain'; |
| 356 |
$this->arr_search['member_word_term'][1] = 'contain'; |
| 357 |
$this->arr_search['member_term'] = 'AND'; |
| 358 |
$this->arr_search['order_column'][0] = ''; |
| 359 |
$this->arr_search['order_column'][1] = ''; |
| 360 |
$this->arr_search['order_word'][0] = ''; |
| 361 |
$this->arr_search['order_word'][1] = ''; |
| 362 |
$this->arr_search['order_word_term'][0] = 'contain'; |
| 363 |
$this->arr_search['order_word_term'][1] = 'contain'; |
| 364 |
$this->arr_search['order_term'] = 'AND'; |
| 365 |
$this->currentPage = 1; |
| 366 |
$this->sortColumn = ( isset( $this->data_cookie['sortColumn'] ) ) ? $this->data_cookie['sortColumn'] : $this->sortColumn; |
| 367 |
$this->sortSwitchs = ( isset( $this->data_cookie['sortSwitchs'] ) ) ? $this->data_cookie['sortSwitchs'] : $this->sortSwitchs; |
| 368 |
$this->userHeaderNames = ( isset( $this->data_cookie['userHeaderNames'] ) ) ? $this->data_cookie['userHeaderNames'] : $this->userHeaderNames; |
| 369 |
$this->totalRow = ( isset( $this->data_cookie['totalRow'] ) ) ? $this->data_cookie['totalRow'] : $this->totalRow; |
| 370 |
$this->placeholder_escape = ''; |
| 371 |
|
| 372 |
} elseif ( isset( $_REQUEST['collective'] ) ) { |
| 373 |
|
| 374 |
$this->action = 'collective_' . str_replace( ',', '', $_POST['allchange']['column'] ); |
| 375 |
$this->currentPage = ( isset( $this->data_cookie['currentPage'] ) ) ? $this->data_cookie['currentPage'] : $this->currentPage; |
| 376 |
$this->sortColumn = ( isset( $this->data_cookie['sortColumn'] ) ) ? $this->data_cookie['sortColumn'] : $this->sortColumn; |
| 377 |
$this->sortSwitchs = ( isset( $this->data_cookie['sortSwitchs'] ) ) ? $this->data_cookie['sortSwitchs'] : $this->sortSwitchs; |
| 378 |
$this->userHeaderNames = ( isset( $this->data_cookie['userHeaderNames'] ) ) ? $this->data_cookie['userHeaderNames'] : $this->userHeaderNames; |
| 379 |
$this->arr_search = ( isset( $this->data_cookie['arr_search'] ) ) ? $this->data_cookie['arr_search'] : $this->arr_search; |
| 380 |
$this->totalRow = ( isset( $this->data_cookie['totalRow'] ) ) ? $this->data_cookie['totalRow'] : $this->totalRow; |
| 381 |
$this->selectedRow = ( isset( $this->data_cookie['selectedRow'] ) ) ? $this->data_cookie['selectedRow'] : $this->selectedRow; |
| 382 |
$this->selectedRow = ( isset( $this->data_cookie['placeholder_escape'] ) ) ? $this->data_cookie['placeholder_escape'] : $this->placeholder_escape; |
| 383 |
|
| 384 |
} elseif ( isset( $_REQUEST['refresh'] ) ) { |
| 385 |
|
| 386 |
$this->action = 'refresh'; |
| 387 |
$this->currentPage = ( isset( $this->data_cookie['currentPage'] ) ) ? $this->data_cookie['currentPage'] : $this->currentPage; |
| 388 |
$this->sortColumn = ( isset( $this->data_cookie['sortColumn'] ) ) ? $this->data_cookie['sortColumn'] : $this->sortColumn; |
| 389 |
$this->sortSwitchs = ( isset( $this->data_cookie['sortSwitchs'] ) ) ? $this->data_cookie['sortSwitchs'] : $this->sortSwitchs; |
| 390 |
$this->userHeaderNames = ( isset( $this->data_cookie['userHeaderNames'] ) ) ? $this->data_cookie['userHeaderNames'] : $this->userHeaderNames; |
| 391 |
$this->arr_search = ( isset( $this->data_cookie['arr_search'] ) ) ? $this->data_cookie['arr_search'] : $this->arr_search; |
| 392 |
$this->totalRow = ( isset( $this->data_cookie['totalRow'] ) ) ? $this->data_cookie['totalRow'] : $this->totalRow; |
| 393 |
$this->selectedRow = ( isset( $this->data_cookie['selectedRow'] ) ) ? $this->data_cookie['selectedRow'] : $this->selectedRow; |
| 394 |
$this->placeholder_escape = ''; |
| 395 |
|
| 396 |
} else { |
| 397 |
|
| 398 |
$this->action = 'default'; |
| 399 |
$this->placeholder_escape = ''; |
| 400 |
} |
| 401 |
} |
| 402 |
|
| 403 |
/** |
| 404 |
* Validation Search Parameters. |
| 405 |
*/ |
| 406 |
public function validationSearchParameters() { |
| 407 |
$this->arr_search = wp_parse_args( (array) $this->arr_search, $this->get_default_arr_search() ); |
| 408 |
|
| 409 |
$default_member_word_term = [ 'contain', 'notcontain', 'equal', 'morethan', 'lessthan' ]; |
| 410 |
$default_order_word_term = [ 'contain', 'notcontain', 'equal', 'morethan', 'lessthan' ]; |
| 411 |
$default_order_term = [ 'AND', 'OR' ]; |
| 412 |
$default_member_term = [ 'AND', 'OR' ]; |
| 413 |
$default_order_columns = [ 'item_code', 'item_name', 'sku_code', 'sku_name', 'item_option' ]; |
| 414 |
if ( ! empty( $this->arr_search['member_column'][0] ) && ! array_key_exists( $this->arr_search['member_column'][0], $this->columns ) ) { |
| 415 |
$this->arr_search['member_column'][0] = key( $this->columns ); |
| 416 |
} |
| 417 |
if ( ! empty( $this->arr_search['member_column'][1] ) && ! array_key_exists( $this->arr_search['member_column'][1], $this->columns ) ) { |
| 418 |
$this->arr_search['member_column'][1] = key( $this->columns ); |
| 419 |
} |
| 420 |
|
| 421 |
if ( ! empty( $this->arr_search['member_word_term'][0] ) && ! in_array( $this->arr_search['member_word_term'][0], $default_member_word_term ) ) { |
| 422 |
$this->arr_search['member_word_term'][0] = $default_order_word_term[0]; |
| 423 |
} |
| 424 |
if ( ! empty( $this->arr_search['member_word_term'][1] ) && ! in_array( $this->arr_search['member_word_term'][1], $default_order_word_term ) ) { |
| 425 |
$this->arr_search['member_word_term'][1] = $default_order_word_term[0]; |
| 426 |
} |
| 427 |
if ( ! in_array( $this->arr_search['member_term'], $default_member_term ) ) { |
| 428 |
$this->arr_search['member_term'] = $default_member_term[0]; |
| 429 |
} |
| 430 |
|
| 431 |
if ( ! empty( $this->arr_search['order_column'][0] ) && ! in_array( $this->arr_search['order_column'][0], $default_order_columns ) ) { |
| 432 |
$this->arr_search['order_column'][0] = $default_order_columns[0]; |
| 433 |
} |
| 434 |
if ( ! empty( $this->arr_search['order_column'][1] ) && ! in_array( $this->arr_search['order_column'][1], $default_order_columns ) ) { |
| 435 |
$this->arr_search['order_column'][1] = $default_order_columns[0]; |
| 436 |
} |
| 437 |
|
| 438 |
if ( ! empty( $this->arr_search['order_word_term'][0] ) && ! in_array( $this->arr_search['order_word_term'][0], $default_order_word_term ) ) { |
| 439 |
$this->arr_search['order_word_term'][0] = $default_order_word_term[0]; |
| 440 |
} |
| 441 |
if ( ! empty( $this->arr_search['order_word_term'][1] ) && ! in_array( $this->arr_search['order_word_term'][1], $default_order_word_term ) ) { |
| 442 |
$this->arr_search['order_word_term'][1] = $default_order_word_term[0]; |
| 443 |
} |
| 444 |
if ( ! in_array( $this->arr_search['order_term'], $default_order_term ) ) { |
| 445 |
$this->arr_search['order_term'] = $default_order_term[0]; |
| 446 |
} |
| 447 |
} |
| 448 |
|
| 449 |
/** |
| 450 |
* Get Rows. |
| 451 |
* |
| 452 |
* @return array |
| 453 |
*/ |
| 454 |
public function GetRows() { |
| 455 |
global $wpdb; |
| 456 |
|
| 457 |
$member_meta_table = usces_get_tablename( 'usces_member_meta' ); |
| 458 |
$order_table = $wpdb->prefix . 'usces_order'; |
| 459 |
$order_meta_table = $wpdb->prefix . 'usces_order_meta'; |
| 460 |
$ordercart_table = $wpdb->prefix . 'usces_ordercart'; |
| 461 |
$ordercart_meta_table = $wpdb->prefix . 'usces_ordercart_meta'; |
| 462 |
|
| 463 |
$where = $this->GetWhere(); |
| 464 |
$having = $this->GetHaving(); |
| 465 |
|
| 466 |
$join = ''; |
| 467 |
$csmb = ''; |
| 468 |
$admb = ''; |
| 469 |
$csod = ''; |
| 470 |
foreach ( $this->columns as $key => $value ) { |
| 471 |
if ( 'csmb_' === substr( $key, 0, 5 ) ) { |
| 472 |
$join .= $wpdb->prepare( " LEFT JOIN {$member_meta_table} AS `p{$key}` ON mem.ID = `p{$key}`.member_id AND `p{$key}`.meta_key = %s ", $key ) . "\n"; |
| 473 |
$csmb .= ', `p' . $key . '`.meta_value AS `' . $key . "`\n"; |
| 474 |
} |
| 475 |
if ( 'admb_' === substr( $key, 0, 5 ) ) { |
| 476 |
$join .= $wpdb->prepare( " LEFT JOIN {$member_meta_table} AS `p{$key}` ON mem.ID = `p{$key}`.member_id AND `p{$key}`.meta_key = %s ", $key ) . "\n"; |
| 477 |
$admb .= ', `p' . $key . '`.meta_value AS `' . $key . "`\n"; |
| 478 |
} |
| 479 |
} |
| 480 |
|
| 481 |
if ( $where ) { |
| 482 |
$join .= " LEFT JOIN {$order_table} AS `ord` ON mem.ID = ord.mem_id " . "\n"; |
| 483 |
|
| 484 |
foreach ( $this->columns as $key => $value ) { |
| 485 |
if ( 'csod_' === substr( $key, 0, 5 ) ) { |
| 486 |
$join .= $wpdb->prepare(" LEFT JOIN {$order_meta_table} AS `p{$key}` ON ord.ID = `p{$key}`.order_id AND `p{$key}`.meta_key = %s ", $key ) . "\n"; |
| 487 |
$csod .= ', `p' . $key . '`.meta_value ' . "\n"; |
| 488 |
} |
| 489 |
} |
| 490 |
|
| 491 |
$join .= " LEFT JOIN {$ordercart_table} AS `cart` ON ord.ID = cart.order_id " . "\n"; |
| 492 |
$csod .= ', cart.item_code , cart.item_name , cart.sku_code , cart.sku_name ' . "\n"; |
| 493 |
} |
| 494 |
$join = apply_filters( 'usces_filter_memberlist_sql_jointable', $join, $this ); |
| 495 |
|
| 496 |
$group = ' GROUP BY `ID` '; |
| 497 |
|
| 498 |
$init_column = 'ID'; |
| 499 |
$sort_column = in_array( $this->sortColumn, array_keys( $this->columns ), true ) ? $this->sortColumn : $init_column; |
| 500 |
$init_switch = 'DESC'; |
| 501 |
$sort_switch = $this->sortSwitchs[ $sort_column ] ?? $init_switch; |
| 502 |
$sort_switch = in_array( strtoupper( $sort_switch ), array( 'ASC', 'DESC' ), true ) ? $sort_switch : $init_switch; |
| 503 |
$order = ' ORDER BY ' . esc_sql( $sort_column ) . ' ' . esc_sql( $sort_switch ); |
| 504 |
$order = apply_filters( 'usces_filter_memberlist_sql_order', $order, $sort_column, $sort_switch, $this ); |
| 505 |
|
| 506 |
$query = $wpdb->prepare( |
| 507 |
"SELECT |
| 508 |
mem.ID AS `ID`, |
| 509 |
mem.mem_name1 AS `name1`, |
| 510 |
mem.mem_name2 AS `name2`, |
| 511 |
mem.mem_name3 AS `name3`, |
| 512 |
mem.mem_name4 AS `name4`, |
| 513 |
mem.mem_zip AS `zipcode`, |
| 514 |
country.meta_value AS `country`, |
| 515 |
mem.mem_pref AS `pref`, |
| 516 |
mem.mem_address1 AS `address1`, |
| 517 |
mem.mem_address2 AS `address2`, |
| 518 |
mem.mem_address3 AS `address3`, |
| 519 |
mem.mem_tel AS `tel`, |
| 520 |
mem.mem_fax AS `fax`, |
| 521 |
mem.mem_email AS `email`, |
| 522 |
DATE_FORMAT(mem.mem_registered, %s) AS `entrydate`, |
| 523 |
mem.mem_status AS `rank`, |
| 524 |
mem.mem_point AS `point` |
| 525 |
{$csmb} |
| 526 |
{$admb} |
| 527 |
{$csod} |
| 528 |
FROM {$this->table} AS `mem` |
| 529 |
LEFT JOIN {$member_meta_table} AS `country` ON mem.ID = country.member_id AND country.meta_key = %s ", |
| 530 |
'%Y-%m-%d %H:%i', 'customer_country' |
| 531 |
); |
| 532 |
$query = apply_filters( 'usces_filter_memberlist_sql_select', $query, $csmb, $csod, $this ); |
| 533 |
|
| 534 |
$query .= $join . $where . $group . $having . $order; |
| 535 |
|
| 536 |
if ( $this->placeholder_escape ) { |
| 537 |
add_filter( 'query', array( $this, 'remove_ph' ) ); |
| 538 |
} |
| 539 |
|
| 540 |
$rows = $wpdb->get_results( $query, ARRAY_A ); |
| 541 |
|
| 542 |
$this->selectedRow = ( $rows && is_array( $rows ) ) ? count( $rows ) : 0; |
| 543 |
if ( 'on' == $this->pageLimit ) { |
| 544 |
$this->rows = array_slice( $rows, $this->startRow, $this->maxRow ); |
| 545 |
$this->currentPageIds = array(); |
| 546 |
foreach ( $this->rows as $row ) { |
| 547 |
$this->currentPageIds[] = $row['ID']; |
| 548 |
} |
| 549 |
} else { |
| 550 |
$this->rows = $rows; |
| 551 |
} |
| 552 |
return $this->rows; |
| 553 |
} |
| 554 |
|
| 555 |
/** |
| 556 |
* Placeholder clear. |
| 557 |
* |
| 558 |
* @param string $query Query. |
| 559 |
* @return string |
| 560 |
*/ |
| 561 |
public function remove_ph( $query ) { |
| 562 |
return str_replace( $this->placeholder_escape, '%', $query ); |
| 563 |
} |
| 564 |
|
| 565 |
/** |
| 566 |
* Set Total Rows. |
| 567 |
*/ |
| 568 |
public function SetTotalRow() { |
| 569 |
global $wpdb; |
| 570 |
$query = "SELECT COUNT(ID) AS `ct` FROM {$this->table}"; |
| 571 |
$res = $wpdb->get_var( $query ); |
| 572 |
$this->totalRow = $res; |
| 573 |
} |
| 574 |
|
| 575 |
/** |
| 576 |
* Having Condition. |
| 577 |
* |
| 578 |
* @return string |
| 579 |
*/ |
| 580 |
public function GetHaving() { |
| 581 |
global $wpdb; |
| 582 |
|
| 583 |
$str = ''; |
| 584 |
if ( ! WCUtils::is_blank( $this->searchHaving ) ) { |
| 585 |
$str .= ' HAVING ' . $this->searchHaving; |
| 586 |
} |
| 587 |
$str = apply_filters( 'usces_filter_memberlist_sql_having', $str, $this->searchHaving, $this ); |
| 588 |
return $str; |
| 589 |
} |
| 590 |
|
| 591 |
/** |
| 592 |
* Where Condition. |
| 593 |
* |
| 594 |
* @return string |
| 595 |
*/ |
| 596 |
public function GetWhere() { |
| 597 |
$str = ''; |
| 598 |
if ( ! WCUtils::is_blank( $this->searchWhere ) ) { |
| 599 |
$str .= ' WHERE ' . $this->searchWhere; |
| 600 |
} |
| 601 |
$str = apply_filters( 'usces_filter_memberlist_sql_where', $str, $this->searchWhere, $this ); |
| 602 |
return $str; |
| 603 |
} |
| 604 |
|
| 605 |
/** |
| 606 |
* Search. |
| 607 |
*/ |
| 608 |
public function SearchIn() { |
| 609 |
global $wpdb; |
| 610 |
|
| 611 |
$this->searchWhere = ''; |
| 612 |
$this->searchHaving = ''; |
| 613 |
|
| 614 |
if ( ! empty( $this->arr_search['order_column'][0] ) && ! WCUtils::is_blank( $this->arr_search['order_word'][0] ) ) { |
| 615 |
switch ( $this->arr_search['order_word_term'][0] ) { |
| 616 |
case 'notcontain': |
| 617 |
$wordterm0 = ' NOT LIKE %s'; |
| 618 |
$word0 = '%' . $this->arr_search['order_word'][0] . '%'; |
| 619 |
break; |
| 620 |
case 'equal': |
| 621 |
$wordterm0 = ' = %s'; |
| 622 |
$word0 = $this->arr_search['order_word'][0]; |
| 623 |
break; |
| 624 |
case 'morethan': |
| 625 |
$wordterm0 = ' > %d'; |
| 626 |
$word0 = $this->arr_search['order_word'][0]; |
| 627 |
break; |
| 628 |
case 'lessthan': |
| 629 |
$wordterm0 = ' < %d'; |
| 630 |
$word0 = $this->arr_search['order_word'][0]; |
| 631 |
break; |
| 632 |
case 'contain': |
| 633 |
default: |
| 634 |
$wordterm0 = ' LIKE %s'; |
| 635 |
$word0 = '%' . $this->arr_search['order_word'][0] . '%'; |
| 636 |
break; |
| 637 |
} |
| 638 |
|
| 639 |
switch ( $this->arr_search['order_word_term'][1] ) { |
| 640 |
case 'notcontain': |
| 641 |
$wordterm1 = ' NOT LIKE %s'; |
| 642 |
$word1 = '%' . $this->arr_search['order_word'][1] . '%'; |
| 643 |
break; |
| 644 |
case 'equal': |
| 645 |
$wordterm1 = ' = %s'; |
| 646 |
$word1 = $this->arr_search['order_word'][1]; |
| 647 |
break; |
| 648 |
case 'morethan': |
| 649 |
$wordterm1 = ' > %d'; |
| 650 |
$word1 = $this->arr_search['order_word'][1]; |
| 651 |
break; |
| 652 |
case 'lessthan': |
| 653 |
$wordterm1 = ' < %d'; |
| 654 |
$word1 = $this->arr_search['order_word'][1]; |
| 655 |
break; |
| 656 |
case 'contain': |
| 657 |
default: |
| 658 |
$wordterm1 = ' LIKE %s'; |
| 659 |
$word1 = '%' . $this->arr_search['order_word'][1] . '%'; |
| 660 |
break; |
| 661 |
} |
| 662 |
|
| 663 |
$this->searchWhere .= ' ( '; |
| 664 |
|
| 665 |
if ( 'csod_' == substr( $this->arr_search['order_column'][0], 0, 5) ) { |
| 666 |
$this->searchWhere .= $wpdb->prepare( '`p' . esc_sql( $this->arr_search['order_column'][0] ) . '`.meta_value LIKE %s', '%' . $this->arr_search['order_word'][0] . '%' ); |
| 667 |
} else { |
| 668 |
$this->searchWhere .= '`' . $wpdb->prepare( esc_sql( $this->arr_search['order_column'][0] ) . '`' . $wordterm0, $word0 ); |
| 669 |
} |
| 670 |
if ( ! empty( $this->arr_search['order_column'][1] ) && ! WCUtils::is_blank( $this->arr_search['order_word'][1] ) ) { |
| 671 |
$this->searchWhere .= ' ' . $this->arr_search['order_term'] . ' '; |
| 672 |
if ( 'csod_' == substr( $this->arr_search['order_column'][1], 0, 5 ) ) { |
| 673 |
$this->searchWhere .= $wpdb->prepare( '`p' . esc_sql( $this->arr_search['order_column'][1] ) . '`.meta_value LIKE %s', '%' . $this->arr_search['order_word'][1] . '%' ); |
| 674 |
} else { |
| 675 |
$this->searchWhere .= '`' . $wpdb->prepare( esc_sql( $this->arr_search['order_column'][1] ) . '`' . $wordterm1, $word1 ); |
| 676 |
} |
| 677 |
} |
| 678 |
|
| 679 |
$this->searchWhere .= ' ) '; |
| 680 |
} |
| 681 |
|
| 682 |
if ( ! empty( $this->arr_search['member_column'][0] ) && ! WCUtils::is_blank( $this->arr_search['member_word'][0] ) ) { |
| 683 |
|
| 684 |
switch ( $this->arr_search['member_word_term'][0] ) { |
| 685 |
case 'notcontain': |
| 686 |
if ( 'rank' === $this->arr_search['member_column'][0] ) { |
| 687 |
$wordterm0 = ' != %d'; |
| 688 |
$word0 = (int) $this->arr_search['member_word'][0]; |
| 689 |
} else { |
| 690 |
$wordterm0 = ' NOT LIKE %s'; |
| 691 |
$word0 = '%' . $this->arr_search['member_word'][0] . '%'; |
| 692 |
} |
| 693 |
break; |
| 694 |
case 'equal': |
| 695 |
$wordterm0 = ' = %s'; |
| 696 |
$word0 = $this->arr_search['member_word'][0]; |
| 697 |
break; |
| 698 |
case 'morethan': |
| 699 |
$wordterm0 = ' > %d'; |
| 700 |
$word0 = $this->arr_search['member_word'][0]; |
| 701 |
break; |
| 702 |
case 'lessthan': |
| 703 |
$wordterm0 = ' < %d'; |
| 704 |
$word0 = $this->arr_search['member_word'][0]; |
| 705 |
break; |
| 706 |
case 'contain': |
| 707 |
default: |
| 708 |
if ( 'rank' === $this->arr_search['member_column'][0] ) { |
| 709 |
$wordterm0 = ' = %d'; |
| 710 |
$word0 = (int) $this->arr_search['member_word'][0]; |
| 711 |
} else { |
| 712 |
$wordterm0 = ' LIKE %s'; |
| 713 |
$word0 = '%' . $this->arr_search['member_word'][0] . '%'; |
| 714 |
} |
| 715 |
break; |
| 716 |
} |
| 717 |
|
| 718 |
switch ( $this->arr_search['member_word_term'][1] ) { |
| 719 |
case 'notcontain': |
| 720 |
if ( 'rank' === $this->arr_search['member_column'][1] ) { |
| 721 |
$wordterm1 = ' != %d'; |
| 722 |
$word1 = (int) $this->arr_search['member_word'][1]; |
| 723 |
} else { |
| 724 |
$wordterm1 = ' NOT LIKE %s'; |
| 725 |
$word1 = '%' . $this->arr_search['member_word'][1] . '%'; |
| 726 |
} |
| 727 |
break; |
| 728 |
case 'equal': |
| 729 |
$wordterm1 = ' = %s'; |
| 730 |
$word1 = $this->arr_search['member_word'][1]; |
| 731 |
break; |
| 732 |
case 'morethan': |
| 733 |
$wordterm1 = ' > %d'; |
| 734 |
$word1 = $this->arr_search['member_word'][1]; |
| 735 |
break; |
| 736 |
case 'lessthan': |
| 737 |
$wordterm1 = ' < %d'; |
| 738 |
$word1 = $this->arr_search['member_word'][1]; |
| 739 |
break; |
| 740 |
case 'contain': |
| 741 |
default: |
| 742 |
if ( 'rank' === $this->arr_search['member_column'][1] ) { |
| 743 |
$wordterm1 = ' = %d'; |
| 744 |
$word1 = (int) $this->arr_search['member_word'][1]; |
| 745 |
} else { |
| 746 |
$wordterm1 = ' LIKE %s'; |
| 747 |
$word1 = '%' . $this->arr_search['member_word'][1] . '%'; |
| 748 |
} |
| 749 |
break; |
| 750 |
} |
| 751 |
|
| 752 |
$this->searchHaving .= ' ( '; |
| 753 |
$this->searchHaving .= '`' . $wpdb->prepare( esc_sql( $this->arr_search['member_column'][0] ) . '`' . $wordterm0, $word0 ); |
| 754 |
|
| 755 |
if ( ! empty( $this->arr_search['member_column'][1] ) && ! WCUtils::is_blank( $this->arr_search['member_word'][1] ) ) { |
| 756 |
$this->searchHaving .= ' ' . $this->arr_search['member_term'] . ' '; |
| 757 |
$this->searchHaving .= '`' . $wpdb->prepare( esc_sql( $this->arr_search['member_column'][1] ) . '`' . $wordterm1, $word1 ); |
| 758 |
} |
| 759 |
$this->searchHaving .= ' ) '; |
| 760 |
} |
| 761 |
} |
| 762 |
|
| 763 |
/** |
| 764 |
* Search clear. |
| 765 |
*/ |
| 766 |
public function SearchOut() { |
| 767 |
$this->searchWhere = ''; |
| 768 |
$this->searchHaving = ''; |
| 769 |
} |
| 770 |
|
| 771 |
/** |
| 772 |
* Set Navigation. |
| 773 |
*/ |
| 774 |
public function SetNavi() { |
| 775 |
|
| 776 |
$this->lastPage = ceil( $this->selectedRow / $this->maxRow ); |
| 777 |
$this->previousPage = ( $this->currentPage - 1 == 0 ) ? 1 : $this->currentPage - 1; |
| 778 |
$this->nextPage = ( $this->currentPage + 1 > $this->lastPage ) ? $this->lastPage : $this->currentPage + 1; |
| 779 |
$box = array(); |
| 780 |
|
| 781 |
for ( $i = 0; $i < $this->naviMaxButton; $i++ ) { |
| 782 |
if ( $i > $this->lastPage - 1 ) { |
| 783 |
break; |
| 784 |
} |
| 785 |
if ( $this->lastPage <= $this->naviMaxButton ) { |
| 786 |
$box[] = $i + 1; |
| 787 |
} else { |
| 788 |
if ( $this->currentPage <= 6 ) { |
| 789 |
$label = $i + 1; |
| 790 |
$box[] = $label; |
| 791 |
} else { |
| 792 |
$label = $i + 1 + $this->currentPage - 6; |
| 793 |
$box[] = $label; |
| 794 |
if ( $label == $this->lastPage ) { |
| 795 |
break; |
| 796 |
} |
| 797 |
} |
| 798 |
} |
| 799 |
} |
| 800 |
|
| 801 |
$html = ''; |
| 802 |
$html .= '<ul class="clearfix">'; |
| 803 |
$html .= '<li class="rowsnum">' . $this->selectedRow . ' / ' . $this->totalRow . ' ' . __( 'cases', 'usces' ) . '</li>'; |
| 804 |
if ( ( 1 === $this->currentPage ) || ( 0 === $this->selectedRow ) ) { |
| 805 |
$html .= '<li class="navigationStr">first<<</li>'; |
| 806 |
$html .= '<li class="navigationStr">prev<</li>'; |
| 807 |
} else { |
| 808 |
$url = admin_url( 'admin.php?page=usces_memberlist&changePage=1' ); |
| 809 |
$nonce_url = wp_nonce_url( $url, 'member_list', 'wc_nonce' ); |
| 810 |
$html .= '<li class="navigationStr"><a href="' . esc_url( $nonce_url ) . '">first<<</a></li>'; |
| 811 |
|
| 812 |
$url = admin_url( 'admin.php?page=usces_memberlist&changePage=' . $this->previousPage ); |
| 813 |
$nonce_url = wp_nonce_url( $url, 'member_list', 'wc_nonce' ); |
| 814 |
$html .= '<li class="navigationStr"><a href="' . esc_url( $nonce_url ) . '">prev<</a></li>'; |
| 815 |
} |
| 816 |
if ( $this->selectedRow > 0 ) { |
| 817 |
$box_count = count( $box ); |
| 818 |
for ( $i = 0; $i < $box_count; $i ++ ) { |
| 819 |
if ( $box[ $i ] == $this->currentPage ) { |
| 820 |
$html .= '<li class="navigationButtonSelected"><span>' . $box[ $i ] . '</span></li>'; |
| 821 |
} else { |
| 822 |
$url = admin_url( 'admin.php?page=usces_memberlist&changePage=' . $box[ $i ] ); |
| 823 |
$nonce_url = wp_nonce_url( $url, 'member_list', 'wc_nonce' ); |
| 824 |
$html .= '<li class="navigationButton"><a href="' . esc_url( $nonce_url ) . '">' . $box[ $i ] . '</a></li>'; |
| 825 |
} |
| 826 |
} |
| 827 |
} |
| 828 |
if ( ( $this->currentPage == $this->lastPage ) || ( 0 === $this->selectedRow ) ) { |
| 829 |
$html .= '<li class="navigationStr">>next</li>'; |
| 830 |
$html .= '<li class="navigationStr">>>last</li>'; |
| 831 |
} else { |
| 832 |
$url = admin_url( 'admin.php?page=usces_memberlist&changePage=' . $this->nextPage ); |
| 833 |
$nonce_url = wp_nonce_url( $url, 'member_list', 'wc_nonce' ); |
| 834 |
$html .= '<li class="navigationStr"><a href="' . esc_url( $nonce_url ) . '">>next</a></li>'; |
| 835 |
|
| 836 |
$url = admin_url( 'admin.php?page=usces_memberlist&changePage=' . $this->lastPage ); |
| 837 |
$nonce_url = wp_nonce_url( $url, 'member_list', 'wc_nonce' ); |
| 838 |
$html .= '<li class="navigationStr"><a href="' . esc_url( $nonce_url ) . '">>>last</a></li>'; |
| 839 |
} |
| 840 |
|
| 841 |
$html .= '</ul>'; |
| 842 |
|
| 843 |
$this->dataTableNavigation = $html; |
| 844 |
} |
| 845 |
|
| 846 |
/** |
| 847 |
* Get Cookie. |
| 848 |
*/ |
| 849 |
public function getCookie() { |
| 850 |
$this->data_cookie = ( isset( $_COOKIE[ $this->table ] ) ) ? json_decode( str_replace( "\'", "'", str_replace( '\"','"', $_COOKIE[ $this->table ] ) ), true ) : array(); |
| 851 |
} |
| 852 |
|
| 853 |
/** |
| 854 |
* Set Headers. |
| 855 |
*/ |
| 856 |
public function SetHeaders() { |
| 857 |
foreach ( $this->columns as $key => $value ) { |
| 858 |
if ( 'csod_' == substr( $key, 0, 5 ) ) { |
| 859 |
continue; |
| 860 |
} |
| 861 |
if ( $key == $this->sortColumn ) { |
| 862 |
if ( isset( $this->sortSwitchs[ $key ] ) && 'ASC' == $this->sortSwitchs[ $key ] ) { |
| 863 |
$str = __( '[ASC]', 'usces' ); |
| 864 |
$switch = 'DESC'; |
| 865 |
} else { |
| 866 |
$str = __( '[DESC]', 'usces' ); |
| 867 |
$switch = 'ASC'; |
| 868 |
} |
| 869 |
$url = admin_url( 'admin.php?page=usces_memberlist&changeSort=' . $key . '&switch=' . $switch ); |
| 870 |
$nonce_url = wp_nonce_url( $url, 'member_list', 'wc_nonce' ); |
| 871 |
$this->headers[ $key ] = '<a href="' . esc_url( $nonce_url ) . '"><span class="sortcolumn">' . $value . ' ' . $str . '</span></a>'; |
| 872 |
} else { |
| 873 |
$switch = isset( $this->sortSwitchs[ $key ] ) ? $this->sortSwitchs[ $key ] : 'DESC'; |
| 874 |
$url = admin_url( 'admin.php?page=usces_memberlist&changeSort=' . $key . '&switch=' . $switch ); |
| 875 |
$nonce_url = wp_nonce_url( $url, 'member_list', 'wc_nonce' ); |
| 876 |
$this->headers[ $key ] = '<a href="' . esc_url( $nonce_url ) . '"><span>' . $value . '</span></a>'; |
| 877 |
} |
| 878 |
} |
| 879 |
} |
| 880 |
|
| 881 |
/** |
| 882 |
* Get Search. |
| 883 |
* |
| 884 |
* @return string |
| 885 |
*/ |
| 886 |
public function GetSearchs() { |
| 887 |
return $this->arr_search; |
| 888 |
} |
| 889 |
|
| 890 |
/** |
| 891 |
* Get Headers. |
| 892 |
* |
| 893 |
* @return string |
| 894 |
*/ |
| 895 |
public function GetListheaders() { |
| 896 |
return $this->headers; |
| 897 |
} |
| 898 |
|
| 899 |
/** |
| 900 |
* Get Navigation. |
| 901 |
* |
| 902 |
* @return string |
| 903 |
*/ |
| 904 |
public function GetDataTableNavigation() { |
| 905 |
return $this->dataTableNavigation; |
| 906 |
} |
| 907 |
|
| 908 |
/** |
| 909 |
* Set Action Status and Action Message. |
| 910 |
* |
| 911 |
* @param string $status Action status. |
| 912 |
* @param string $message Action message. |
| 913 |
*/ |
| 914 |
public function set_action_status( $status, $message ) { |
| 915 |
$this->action_status = $status; |
| 916 |
$this->action_message = $message; |
| 917 |
} |
| 918 |
|
| 919 |
/** |
| 920 |
* Get Action Status. |
| 921 |
* |
| 922 |
* @return string |
| 923 |
*/ |
| 924 |
public function get_action_status() { |
| 925 |
return $this->action_status; |
| 926 |
} |
| 927 |
|
| 928 |
/** |
| 929 |
* Get Action Message. |
| 930 |
* |
| 931 |
* @return string |
| 932 |
*/ |
| 933 |
public function get_action_message() { |
| 934 |
return $this->action_message; |
| 935 |
} |
| 936 |
} |
| 937 |
|