| 1 |
<?php |
| 2 |
// Utility.php |
| 3 |
|
| 4 |
function usces_upgrade_141(){ |
| 5 |
global $usces; |
| 6 |
$upgrade = (int)get_option('usces_upgrade2'); |
| 7 |
if( false === ($upgrade & USCES_UP14) || $upgrade & USCES_UP141 ) |
| 8 |
return false; |
| 9 |
|
| 10 |
global $wpdb; |
| 11 |
$rets = array(); |
| 12 |
|
| 13 |
$options = get_option('usces'); |
| 14 |
if(empty($options['tax_rate'])){ |
| 15 |
$options['tax_mode'] = 'include'; |
| 16 |
}else{ |
| 17 |
$options['tax_mode'] = 'exclude'; |
| 18 |
} |
| 19 |
$options['tax_target'] = 'all'; |
| 20 |
update_option('usces', $options); |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
$order_table = $wpdb->prefix . "usces_order"; |
| 25 |
$cart_table = $wpdb->prefix . "usces_ordercart"; |
| 26 |
$cart_meta_table = $wpdb->prefix . "usces_ordercart_meta"; |
| 27 |
|
| 28 |
$query = "SELECT ID, order_cart, order_condition FROM $order_table"; |
| 29 |
$results = $wpdb->get_results( $query ); |
| 30 |
if( $results ){ |
| 31 |
foreach( $results as $order ){ |
| 32 |
|
| 33 |
$query = $wpdb->prepare( "SELECT order_id FROM $cart_table WHERE order_id = %d", $order->ID ); |
| 34 |
$order_id = $wpdb->get_var( $query ); |
| 35 |
if( $order_id == $order->ID ) continue; |
| 36 |
|
| 37 |
$condition = maybe_unserialize($order->order_condition); |
| 38 |
if( !isset($condition['tax_mode']) ){ |
| 39 |
$condition['tax_mode'] = $options['tax_mode']; |
| 40 |
} |
| 41 |
if( !isset($condition['tax_rate']) ){ |
| 42 |
$condition['tax_rate'] = (int)$options['tax_rate']; |
| 43 |
} |
| 44 |
if( !isset($condition['tax_target']) ){ |
| 45 |
$condition['tax_target'] = $options['tax_target']; |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
$cart = unserialize($order->order_cart); |
| 50 |
foreach( (array)$cart as $row_index => $value ){ |
| 51 |
$item_code = get_post_meta( $value['post_id'], '_itemCode', true); |
| 52 |
$item_name = get_post_meta( $value['post_id'], '_itemName', true); |
| 53 |
$skus = $usces->get_skus($value['post_id'], 'code'); |
| 54 |
$sku_code = urldecode($value['sku']); |
| 55 |
$sku_encoded = $value['sku']; |
| 56 |
$sku = isset($skus[$sku_code]) ? $skus[$sku_code] : array('name'=>'notfound', 'cprice'=>0, 'unit'=>''); |
| 57 |
if( empty($condition['tax_rate']) ){ |
| 58 |
$tax = 0; |
| 59 |
|
| 60 |
}else{ |
| 61 |
$tax = ($value['price'] * $value['quantity']) * $condition['tax_rate'] / 100; |
| 62 |
$cr = $usces->options['system']['currency']; |
| 63 |
$decimal = $usces_settings['currency'][$cr][1]; |
| 64 |
$decipad = (int)str_pad( '1', $decimal+1, '0', STR_PAD_RIGHT ); |
| 65 |
switch( $options['tax_method'] ){ |
| 66 |
case 'cutting': |
| 67 |
$tax = floor($tax*$decipad)/$decipad; |
| 68 |
break; |
| 69 |
case 'bring': |
| 70 |
$tax = ceil($tax*$decipad)/$decipad; |
| 71 |
break; |
| 72 |
case 'rounding': |
| 73 |
if( 0 < $decimal ){ |
| 74 |
$tax = round($tax, (int)$decimal); |
| 75 |
}else{ |
| 76 |
$tax = round($tax); |
| 77 |
} |
| 78 |
break; |
| 79 |
} |
| 80 |
} |
| 81 |
$query = $wpdb->prepare("INSERT INTO $cart_table |
| 82 |
( |
| 83 |
order_id, group_id, row_index, |
| 84 |
post_id, item_code, item_name, |
| 85 |
sku_code, sku_name, cprice, price, quantity, unit, |
| 86 |
tax, destination_id, cart_serial |
| 87 |
) VALUES ( |
| 88 |
%d, %d, %d, |
| 89 |
%d, %s, %s, |
| 90 |
%s, %s, %f, %f, %d, %s, |
| 91 |
%f, %d, %s |
| 92 |
)", |
| 93 |
$order->ID, 0, $row_index, |
| 94 |
$value['post_id'], $item_code, $item_name, |
| 95 |
$sku_code, $sku['name'], $sku['cprice'], $value['price'], $value['quantity'], $sku['unit'], |
| 96 |
$tax, NULL, $value['serial'] |
| 97 |
); |
| 98 |
$wpdb->query($query); |
| 99 |
|
| 100 |
$cart_id = $wpdb->insert_id ; |
| 101 |
if( $cart_id ){ |
| 102 |
if($value['options']){ |
| 103 |
foreach((array)$value['options'] as $okey => $ovalue){ |
| 104 |
$okey = urldecode($okey); |
| 105 |
if( is_array($ovalue) ){ |
| 106 |
$ovalue = serialize($ovalue); |
| 107 |
}else{ |
| 108 |
$ovalue = urldecode($ovalue); |
| 109 |
} |
| 110 |
$oquery = $wpdb->prepare("INSERT INTO $cart_meta_table |
| 111 |
( |
| 112 |
cart_id, meta_type, meta_key, meta_value |
| 113 |
) VALUES ( |
| 114 |
%d, 'option', %s, %s |
| 115 |
)", |
| 116 |
$cart_id, $okey, $ovalue |
| 117 |
); |
| 118 |
$wpdb->query($oquery); |
| 119 |
} |
| 120 |
} |
| 121 |
if( $value['advance'] ) { |
| 122 |
foreach( (array)$value['advance'] as $akey => $avalue ) { |
| 123 |
$advance = maybe_unserialize( $avalue ); |
| 124 |
if( is_array($advance) ) { |
| 125 |
$post_id = $value['post_id']; |
| 126 |
if( is_array( $advance[$post_id][$sku_encoded] ) ) { |
| 127 |
$akeys = array_keys( $advance[$post_id][$sku_encoded] ); |
| 128 |
foreach( (array)$akeys as $akey ) { |
| 129 |
$avalue = serialize( $advance[$post_id][$sku_encoded][$akey] ); |
| 130 |
$aquery = $wpdb->prepare("INSERT INTO $cart_meta_table |
| 131 |
( |
| 132 |
cart_id, meta_type, meta_key, meta_value |
| 133 |
) VALUES ( |
| 134 |
%d, 'advance', %s, %s |
| 135 |
)", |
| 136 |
$cart_id, $akey, $avalue |
| 137 |
); |
| 138 |
$wpdb->query( $aquery ); |
| 139 |
} |
| 140 |
} else { |
| 141 |
$akeys = array_keys( $advance ); |
| 142 |
$akey = ( empty($akeys[0]) ) ? 'advance' : $akeys[0]; |
| 143 |
$avalue = serialize( $advance ); |
| 144 |
$aquery = $wpdb->prepare("INSERT INTO $cart_meta_table |
| 145 |
( |
| 146 |
cart_id, meta_type, meta_key, meta_value |
| 147 |
) VALUES ( |
| 148 |
%d, 'advance', %s, %s |
| 149 |
)", |
| 150 |
$cart_id, $akey, $avalue |
| 151 |
); |
| 152 |
$wpdb->query( $aquery ); |
| 153 |
} |
| 154 |
} else { |
| 155 |
$avalue = urldecode( $avalue ); |
| 156 |
$aquery = $wpdb->prepare("INSERT INTO $cart_meta_table |
| 157 |
( |
| 158 |
cart_id, meta_type, meta_key, meta_value |
| 159 |
) VALUES ( |
| 160 |
%d, 'advance', 'advance', %s |
| 161 |
)", |
| 162 |
$cart_id, $avalue |
| 163 |
); |
| 164 |
$wpdb->query( $aquery ); |
| 165 |
} |
| 166 |
} |
| 167 |
} |
| 168 |
} |
| 169 |
} |
| 170 |
|
| 171 |
$upquery = $wpdb->prepare("UPDATE $order_table SET order_condition = %s WHERE ID = %d", |
| 172 |
serialize($condition), $order->ID |
| 173 |
); |
| 174 |
$wpdb->query($upquery); |
| 175 |
} |
| 176 |
} |
| 177 |
usces_log('USCES_UP141 : Completed', 'db'); |
| 178 |
$upgrade += USCES_UP141; |
| 179 |
update_option('usces_upgrade2', $upgrade); |
| 180 |
} |
| 181 |
|
| 182 |
function usces_upgrade_14(){ |
| 183 |
global $usces; |
| 184 |
$upgrade = (int)get_option('usces_upgrade2'); |
| 185 |
if( $upgrade & USCES_UP14 ) |
| 186 |
return false; |
| 187 |
|
| 188 |
global $wpdb; |
| 189 |
$rets = array(); |
| 190 |
|
| 191 |
$options = get_option('usces'); |
| 192 |
if(empty($options['tax_rate'])){ |
| 193 |
$options['tax_mode'] = 'include'; |
| 194 |
}else{ |
| 195 |
$options['tax_mode'] = 'exclude'; |
| 196 |
} |
| 197 |
$options['tax_target'] = 'all'; |
| 198 |
update_option('usces', $options); |
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
$order_table = $wpdb->prefix . "usces_order"; |
| 203 |
$cart_table = $wpdb->prefix . "usces_ordercart"; |
| 204 |
$cart_meta_table = $wpdb->prefix . "usces_ordercart_meta"; |
| 205 |
|
| 206 |
$query = "SELECT ID, order_cart, order_condition FROM $order_table"; |
| 207 |
$results = $wpdb->get_results( $query ); |
| 208 |
if( $results ){ |
| 209 |
foreach( $results as $order ){ |
| 210 |
$condition = maybe_unserialize($order->order_condition); |
| 211 |
if( !isset($condition['tax_mode']) ){ |
| 212 |
$condition['tax_mode'] = $options['tax_mode']; |
| 213 |
} |
| 214 |
if( !isset($condition['tax_rate']) ){ |
| 215 |
$condition['tax_rate'] = (int)$options['tax_rate']; |
| 216 |
} |
| 217 |
if( !isset($condition['tax_target']) ){ |
| 218 |
$condition['tax_target'] = $options['tax_target']; |
| 219 |
} |
| 220 |
|
| 221 |
|
| 222 |
$cart = unserialize($order->order_cart); |
| 223 |
foreach( (array)$cart as $row_index => $value ){ |
| 224 |
$item_code = get_post_meta( $value['post_id'], '_itemCode', true); |
| 225 |
$item_name = get_post_meta( $value['post_id'], '_itemName', true); |
| 226 |
$skus = $usces->get_skus($value['post_id'], 'code'); |
| 227 |
$sku_code = urldecode($value['sku']); |
| 228 |
$sku_encoded = $value['sku']; |
| 229 |
$sku = isset($skus[$sku_code]) ? $skus[$sku_code] : array('name'=>'notfound', 'cprice'=>0, 'unit'=>''); |
| 230 |
if( empty($condition['tax_rate']) ){ |
| 231 |
$tax = 0; |
| 232 |
|
| 233 |
}else{ |
| 234 |
$tax = ($value['price'] * $value['quantity']) * $condition['tax_rate'] / 100; |
| 235 |
$cr = $usces->options['system']['currency']; |
| 236 |
$decimal = $usces_settings['currency'][$cr][1]; |
| 237 |
$decipad = (int)str_pad( '1', $decimal+1, '0', STR_PAD_RIGHT ); |
| 238 |
switch( $options['tax_method'] ){ |
| 239 |
case 'cutting': |
| 240 |
$tax = floor($tax*$decipad)/$decipad; |
| 241 |
break; |
| 242 |
case 'bring': |
| 243 |
$tax = ceil($tax*$decipad)/$decipad; |
| 244 |
break; |
| 245 |
case 'rounding': |
| 246 |
if( 0 < $decimal ){ |
| 247 |
$tax = round($tax, (int)$decimal); |
| 248 |
}else{ |
| 249 |
$tax = round($tax); |
| 250 |
} |
| 251 |
break; |
| 252 |
} |
| 253 |
} |
| 254 |
$query = $wpdb->prepare("INSERT INTO $cart_table |
| 255 |
( |
| 256 |
order_id, group_id, row_index, |
| 257 |
post_id, item_code, item_name, |
| 258 |
sku_code, sku_name, cprice, price, quantity, unit, |
| 259 |
tax, destination_id, cart_serial |
| 260 |
) VALUES ( |
| 261 |
%d, %d, %d, |
| 262 |
%d, %s, %s, |
| 263 |
%s, %s, %f, %f, %d, %s, |
| 264 |
%f, %d, %s |
| 265 |
)", |
| 266 |
$order->ID, 0, $row_index, |
| 267 |
$value['post_id'], $item_code, $item_name, |
| 268 |
$sku_code, $sku['name'], $sku['cprice'], $value['price'], $value['quantity'], $sku['unit'], |
| 269 |
$tax, NULL, $value['serial'] |
| 270 |
); |
| 271 |
$wpdb->query($query); |
| 272 |
|
| 273 |
$cart_id = $wpdb->insert_id ; |
| 274 |
if( $cart_id ){ |
| 275 |
if($value['options']){ |
| 276 |
foreach((array)$value['options'] as $okey => $ovalue){ |
| 277 |
$okey = urldecode($okey); |
| 278 |
if( is_array($ovalue) ){ |
| 279 |
$ovalue = serialize($ovalue); |
| 280 |
}else{ |
| 281 |
$ovalue = urldecode($ovalue); |
| 282 |
} |
| 283 |
$oquery = $wpdb->prepare("INSERT INTO $cart_meta_table |
| 284 |
( |
| 285 |
cart_id, meta_type, meta_key, meta_value |
| 286 |
) VALUES ( |
| 287 |
%d, 'option', %s, %s |
| 288 |
)", |
| 289 |
$cart_id, $okey, $ovalue |
| 290 |
); |
| 291 |
$wpdb->query($oquery); |
| 292 |
} |
| 293 |
} |
| 294 |
if( $value['advance'] ) { |
| 295 |
foreach( (array)$value['advance'] as $akey => $avalue ) { |
| 296 |
$advance = maybe_unserialize( $avalue ); |
| 297 |
if( is_array($advance) ) { |
| 298 |
$post_id = $value['post_id']; |
| 299 |
if( is_array( $advance[$post_id][$sku_encoded] ) ) { |
| 300 |
$akeys = array_keys( $advance[$post_id][$sku_encoded] ); |
| 301 |
foreach( (array)$akeys as $akey ) { |
| 302 |
$avalue = serialize( $advance[$post_id][$sku_encoded][$akey] ); |
| 303 |
$aquery = $wpdb->prepare("INSERT INTO $cart_meta_table |
| 304 |
( |
| 305 |
cart_id, meta_type, meta_key, meta_value |
| 306 |
) VALUES ( |
| 307 |
%d, 'advance', %s, %s |
| 308 |
)", |
| 309 |
$cart_id, $akey, $avalue |
| 310 |
); |
| 311 |
$wpdb->query( $aquery ); |
| 312 |
} |
| 313 |
} else { |
| 314 |
$akeys = array_keys( $advance ); |
| 315 |
$akey = ( empty($akeys[0]) ) ? 'advance' : $akeys[0]; |
| 316 |
$avalue = serialize( $advance ); |
| 317 |
$aquery = $wpdb->prepare("INSERT INTO $cart_meta_table |
| 318 |
( |
| 319 |
cart_id, meta_type, meta_key, meta_value |
| 320 |
) VALUES ( |
| 321 |
%d, 'advance', %s, %s |
| 322 |
)", |
| 323 |
$cart_id, $akey, $avalue |
| 324 |
); |
| 325 |
$wpdb->query( $aquery ); |
| 326 |
} |
| 327 |
} else { |
| 328 |
$avalue = urldecode( $avalue ); |
| 329 |
$aquery = $wpdb->prepare("INSERT INTO $cart_meta_table |
| 330 |
( |
| 331 |
cart_id, meta_type, meta_key, meta_value |
| 332 |
) VALUES ( |
| 333 |
%d, 'advance', 'advance', %s |
| 334 |
)", |
| 335 |
$cart_id, $avalue |
| 336 |
); |
| 337 |
$wpdb->query( $aquery ); |
| 338 |
} |
| 339 |
} |
| 340 |
} |
| 341 |
} |
| 342 |
} |
| 343 |
|
| 344 |
$upquery = $wpdb->prepare("UPDATE $order_table SET order_condition = %s WHERE ID = %d", |
| 345 |
serialize($condition), $order->ID |
| 346 |
); |
| 347 |
$wpdb->query($upquery); |
| 348 |
} |
| 349 |
} |
| 350 |
usces_log('USCES_UP14 : Completed', 'db'); |
| 351 |
$upgrade += USCES_UP14; |
| 352 |
update_option('usces_upgrade2', $upgrade); |
| 353 |
} |
| 354 |
|
| 355 |
function usces_upgrade_07(){ |
| 356 |
$upgrade = (int)get_option('usces_upgrade'); |
| 357 |
if( $upgrade & USCES_UP07 ) return false; |
| 358 |
|
| 359 |
global $wpdb; |
| 360 |
$rets = array(); |
| 361 |
|
| 362 |
$tableName = $wpdb->prefix . "postmeta"; |
| 363 |
$mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'iopt_', '_iopt_') WHERE meta_key LIKE 'iopt_%'"; |
| 364 |
if( $wpdb->query( $mquery ) ) |
| 365 |
$rets[] = 1; |
| 366 |
|
| 367 |
$mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'isku_', '_isku_') WHERE meta_key LIKE 'isku_%'"; |
| 368 |
if( $wpdb->query( $mquery ) ) |
| 369 |
$rets[] = 1; |
| 370 |
|
| 371 |
$mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemCode', '_itemCode') WHERE meta_key LIKE 'itemCode'"; |
| 372 |
if( $wpdb->query( $mquery ) ) |
| 373 |
$rets[] = 1; |
| 374 |
|
| 375 |
$mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemName', '_itemName') WHERE meta_key LIKE 'itemName'"; |
| 376 |
if( $wpdb->query( $mquery ) ) |
| 377 |
$rets[] = 1; |
| 378 |
|
| 379 |
$mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemRestriction', '_itemRestriction') WHERE meta_key LIKE 'itemRestriction'"; |
| 380 |
if( $wpdb->query( $mquery ) ) |
| 381 |
$rets[] = 1; |
| 382 |
|
| 383 |
$mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemPointrate', '_itemPointrate') WHERE meta_key LIKE 'itemPointrate'"; |
| 384 |
if( $wpdb->query( $mquery ) ) |
| 385 |
$rets[] = 1; |
| 386 |
|
| 387 |
$mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemGpNum1', '_itemGpNum1') WHERE meta_key LIKE 'itemGpNum1'"; |
| 388 |
if( $wpdb->query( $mquery ) ) |
| 389 |
$rets[] = 1; |
| 390 |
|
| 391 |
$mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemGpDis1', '_itemGpDis1') WHERE meta_key LIKE 'itemGpDis1'"; |
| 392 |
if( $wpdb->query( $mquery ) ) |
| 393 |
$rets[] = 1; |
| 394 |
|
| 395 |
$mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemGpNum2', '_itemGpNum2') WHERE meta_key LIKE 'itemGpNum2'"; |
| 396 |
if( $wpdb->query( $mquery ) ) |
| 397 |
$rets[] = 1; |
| 398 |
|
| 399 |
$mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemGpDis2', '_itemGpDis2') WHERE meta_key LIKE 'itemGpDis2'"; |
| 400 |
if( $wpdb->query( $mquery ) ) |
| 401 |
$rets[] = 1; |
| 402 |
|
| 403 |
$mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemGpDis3', '_itemGpDis3') WHERE meta_key LIKE 'itemGpDis3'"; |
| 404 |
if( $wpdb->query( $mquery ) ) |
| 405 |
$rets[] = 1; |
| 406 |
|
| 407 |
$mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemGpNum3', '_itemGpNum3') WHERE meta_key LIKE 'itemGpNum3'"; |
| 408 |
if( $wpdb->query( $mquery ) ) |
| 409 |
$rets[] = 1; |
| 410 |
|
| 411 |
$mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemShipping', '_itemShipping') WHERE meta_key LIKE 'itemShipping'"; |
| 412 |
if( $wpdb->query( $mquery ) ) |
| 413 |
$rets[] = 1; |
| 414 |
|
| 415 |
$mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemDeliveryMethod', '_itemDeliveryMethod') WHERE meta_key LIKE 'itemDeliveryMethod'"; |
| 416 |
if( $wpdb->query( $mquery ) ) |
| 417 |
$rets[] = 1; |
| 418 |
|
| 419 |
$mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemShippingCharge', '_itemShippingCharge') WHERE meta_key LIKE 'itemShippingCharge'"; |
| 420 |
if( $wpdb->query( $mquery ) ) |
| 421 |
$rets[] = 1; |
| 422 |
|
| 423 |
$mquery = "UPDATE $tableName SET meta_key = REPLACE(meta_key, 'itemIndividualSCharge', '_itemIndividualSCharge') WHERE meta_key LIKE 'itemIndividualSCharge'"; |
| 424 |
if( $wpdb->query( $mquery ) ) |
| 425 |
$rets[] = 1; |
| 426 |
|
| 427 |
usces_log('USCES_UP07 : '.print_r($rets,true), 'db'); |
| 428 |
$upgrade += USCES_UP07; |
| 429 |
update_option('usces_upgrade', $upgrade); |
| 430 |
return $rets; |
| 431 |
} |
| 432 |
|
| 433 |
function usces_upgrade_11(){ |
| 434 |
$options = get_option('usces'); |
| 435 |
$upgrade = (int)get_option('usces_upgrade'); |
| 436 |
|
| 437 |
if( $upgrade & USCES_UP11 ) return false; |
| 438 |
|
| 439 |
global $wpdb; |
| 440 |
$rets = array(); |
| 441 |
|
| 442 |
/* ITEM SKU DATA */ |
| 443 |
$sort = (int)$options['system']['orderby_itemsku']; |
| 444 |
if( $sort ){ |
| 445 |
$query = "SELECT * FROM $wpdb->postmeta WHERE meta_key <> '_isku_' AND meta_key LIKE '_isku_%' ORDER BY post_id, meta_key"; |
| 446 |
}else{ |
| 447 |
$query = "SELECT * FROM $wpdb->postmeta WHERE meta_key <> '_isku_' AND meta_key LIKE '_isku_%' ORDER BY post_id, meta_id"; |
| 448 |
} |
| 449 |
$res = $wpdb->get_results($query, ARRAY_A); |
| 450 |
|
| 451 |
$conclusion = true; |
| 452 |
$pre_post_id = 0; |
| 453 |
$sort_id = 0; |
| 454 |
$check_code = array(); |
| 455 |
$dep_num = array(); |
| 456 |
foreach( (array)$res as $metarow ){ |
| 457 |
$meta_value = unserialize($metarow['meta_value']); |
| 458 |
$newvalue = array(); |
| 459 |
$newvalue['code'] = substr($metarow['meta_key'], 6); |
| 460 |
if( $pre_post_id == $metarow['post_id'] ){ |
| 461 |
if( in_array( $newvalue['code'], $check_code ) ){ |
| 462 |
$newvalue['code'] .= 'dupricate_' . (int)$dep_num[$newvalue['code']]; |
| 463 |
$dep_num[$newvalue['code']]++; |
| 464 |
} |
| 465 |
}else{ |
| 466 |
$check_code = array(); |
| 467 |
$dep_num = array(); |
| 468 |
$sort_id = 0; |
| 469 |
} |
| 470 |
foreach( (array)$meta_value as $k => $v ){ |
| 471 |
switch ( $k ){ |
| 472 |
case 'disp': |
| 473 |
$newvalue['name'] = $v; |
| 474 |
break; |
| 475 |
case 'cprice': |
| 476 |
$newvalue['cprice'] = $v; |
| 477 |
break; |
| 478 |
case 'price': |
| 479 |
$newvalue['price'] = $v; |
| 480 |
break; |
| 481 |
case 'unit': |
| 482 |
$newvalue['unit'] = $v; |
| 483 |
break; |
| 484 |
case 'zaikonum': |
| 485 |
$newvalue['stocknum'] = $v; |
| 486 |
break; |
| 487 |
case 'zaiko': |
| 488 |
$newvalue['stock'] = $v; |
| 489 |
break; |
| 490 |
case 'gptekiyo': |
| 491 |
$newvalue['gp'] = $v; |
| 492 |
break; |
| 493 |
case 'charging_type': |
| 494 |
break; |
| 495 |
default: |
| 496 |
$newvalue[$k] = $v; |
| 497 |
} |
| 498 |
} |
| 499 |
$newvalue['sort'] = $sort_id; |
| 500 |
|
| 501 |
$id = usces_add_sku($metarow['post_id'], $newvalue, false); |
| 502 |
$pre_post_id = $metarow['post_id']; |
| 503 |
$check_code[] = $newvalue['code']; |
| 504 |
$sort_id++; |
| 505 |
|
| 506 |
$res_key = $metarow['post_id'] . '_' . $newvalue['code']; |
| 507 |
if( $id ) { |
| 508 |
delete_post_meta($metarow['post_id'], $metarow['meta_key']); |
| 509 |
$rets['sku'][$res_key] = 1; |
| 510 |
}else{ |
| 511 |
$rets['sku'][$res_key] = 0; |
| 512 |
usces_log('meta_id ' . $metarow['meta_id'] . ' : ' . __('This SKU-data has not been rebuilt.', 'usces'), 'database_error.log'); |
| 513 |
} |
| 514 |
} |
| 515 |
|
| 516 |
/* ITEM OPTION DATA */ |
| 517 |
$sort = (int)$options['system']['orderby_itemopt']; |
| 518 |
if( $sort ){ |
| 519 |
$query = "SELECT * FROM $wpdb->postmeta WHERE meta_key <> '_iopt_' AND meta_key LIKE '_iopt_%' ORDER BY post_id, meta_key"; |
| 520 |
}else{ |
| 521 |
$query = "SELECT * FROM $wpdb->postmeta WHERE meta_key <> '_iopt_' AND meta_key LIKE '_iopt_%' ORDER BY post_id, meta_id"; |
| 522 |
} |
| 523 |
$res = $wpdb->get_results($query, ARRAY_A); |
| 524 |
|
| 525 |
$conclusion = true; |
| 526 |
$pre_post_id = 0; |
| 527 |
$sort_id = 0; |
| 528 |
$check_code = array(); |
| 529 |
$dep_num = array(); |
| 530 |
foreach( (array)$res as $metarow ){ |
| 531 |
$meta_value = unserialize($metarow['meta_value']); |
| 532 |
$newvalue = array(); |
| 533 |
$newvalue['name'] = substr($metarow['meta_key'], 6); |
| 534 |
if( $pre_post_id == $metarow['post_id'] ){ |
| 535 |
if( in_array( $newvalue['name'], $check_code ) ){ |
| 536 |
$newvalue['name'] .= 'dupricate_' . (int)$dep_num[$newvalue['name']]; |
| 537 |
$dep_num[$newvalue['name']]++; |
| 538 |
} |
| 539 |
}else{ |
| 540 |
$check_code = array(); |
| 541 |
$dep_num = array(); |
| 542 |
$sort_id = 0; |
| 543 |
} |
| 544 |
foreach( (array)$meta_value as $k => $v ){ |
| 545 |
switch ( $k ){ |
| 546 |
case 'means': |
| 547 |
$newvalue['means'] = $v; |
| 548 |
break; |
| 549 |
case 'essential': |
| 550 |
$newvalue['essential'] = $v; |
| 551 |
break; |
| 552 |
case 'value': |
| 553 |
if( is_array($v) ){ |
| 554 |
$nov = ''; |
| 555 |
foreach((array)$v as $vs){ |
| 556 |
if( !WCUtils::is_blank($vs) ) |
| 557 |
//$nov .= str_replace('\\', '¥', trim( $vs )) . "\n"; |
| 558 |
$nov .= $vs . "\n"; |
| 559 |
} |
| 560 |
$newvalue['value'] = trim($nov); |
| 561 |
}else{ |
| 562 |
$newvalue['value'] = trim($v); |
| 563 |
} |
| 564 |
break; |
| 565 |
default: |
| 566 |
$newvalue[$k] = trim($v); |
| 567 |
} |
| 568 |
} |
| 569 |
$newvalue['sort'] = $sort_id; |
| 570 |
|
| 571 |
$id = usces_add_opt($metarow['post_id'], $newvalue, false); |
| 572 |
$pre_post_id = $metarow['post_id']; |
| 573 |
$check_code[] = $newvalue['name']; |
| 574 |
$sort_id++; |
| 575 |
|
| 576 |
$res_key = $metarow['post_id'] . '_' . $newvalue['name']; |
| 577 |
if( $id ) { |
| 578 |
delete_post_meta($metarow['post_id'], $metarow['meta_key']); |
| 579 |
$rets['opt'][$res_key] = 1; |
| 580 |
}else{ |
| 581 |
$rets['opt'][$res_key] = 0; |
| 582 |
usces_log('meta_id ' . $metarow['meta_id'] . ' : ' . __('This Item-Option-data has not been rebuilt.', 'usces'), 'database_error.log'); |
| 583 |
} |
| 584 |
} |
| 585 |
|
| 586 |
/* PAYMENT METHOD DATA */ |
| 587 |
$payment = get_option('usces_payment_method'); |
| 588 |
//usces_log('payment : ' . print_r($payment,true), 'database_error.log'); |
| 589 |
if( empty($payment) ) { |
| 590 |
|
| 591 |
$options = get_option('usces'); |
| 592 |
$old_payment = isset($options['payment_method']) ? $options['payment_method'] : ''; |
| 593 |
usces_log('old_payment : ' . print_r($old_payment,true), 'database_error.log'); |
| 594 |
if( !empty($old_payment) && is_array($old_payment) ) { |
| 595 |
foreach( $old_payment as $key => $value ){ |
| 596 |
$res_key = $key . '_' . $value['name']; |
| 597 |
$id = usces_add_system_option( 'usces_payment_method', $value ); |
| 598 |
if( $id ) { |
| 599 |
$rets['payment'][$res_key] = 1; |
| 600 |
}else{ |
| 601 |
$rets['payment'][$res_key] = 0; |
| 602 |
usces_log('payment_method ' . $value['name'] . ' : ' . __('This Payment-Method-data has not been rebuilt.', 'usces'), 'database_error.log'); |
| 603 |
} |
| 604 |
} |
| 605 |
} |
| 606 |
} |
| 607 |
|
| 608 |
usces_log('USCES_UP11 : ' . print_r($rets,true), 'db'); |
| 609 |
|
| 610 |
$upgrade += USCES_UP11; |
| 611 |
update_option('usces_upgrade', $upgrade); |
| 612 |
return $rets; |
| 613 |
} |
| 614 |
|
| 615 |
function usces_log($log, $file){ |
| 616 |
global $usces; |
| 617 |
|
| 618 |
if( 'db' == $file ){ |
| 619 |
|
| 620 |
global $wpdb; |
| 621 |
$table_name = $wpdb->prefix . 'usces_log'; |
| 622 |
$query = $wpdb->prepare("INSERT INTO $table_name (datetime, log) VALUES(%s, %s)", current_time('mysql'), $log); |
| 623 |
$wpdb->query( $query ); |
| 624 |
|
| 625 |
}else{ |
| 626 |
|
| 627 |
$log = date('[Y-m-d H:i:s]', current_time('timestamp')) . "\t" . $log . "\n"; |
| 628 |
$file_path = USCES_PLUGIN_DIR . '/logs/' . $file; |
| 629 |
if( is_dir($file_path) ) |
| 630 |
return; |
| 631 |
|
| 632 |
$fp = fopen($file_path, 'a'); |
| 633 |
if( false !== $fp ){ |
| 634 |
fwrite($fp, $log); |
| 635 |
fclose($fp); |
| 636 |
} |
| 637 |
} |
| 638 |
} |
| 639 |
|
| 640 |
|
| 641 |
function usces_filter_delivery_secure_check( $mes ){ |
| 642 |
global $usces; |
| 643 |
$usces_secure_link = get_option('usces_secure_link'); |
| 644 |
$paymod_id = ''; |
| 645 |
$settlement = ''; |
| 646 |
$payments = usces_get_system_option( 'usces_payment_method', 'sort' ); |
| 647 |
|
| 648 |
foreach ( (array)$payments as $id => $value ) { |
| 649 |
if( isset($_POST['offer']['payment_name']) && $value['name'] == $_POST['offer']['payment_name']){ |
| 650 |
$settlement = $value['settlement']; |
| 651 |
break; |
| 652 |
} |
| 653 |
} |
| 654 |
switch( $settlement ){ |
| 655 |
case 'acting_zeus_card': |
| 656 |
$cnum1 = trim($_POST["cnum1"]); |
| 657 |
$securecode = (isset($_POST["securecode"])) ? trim($_POST["securecode"]) : ''; |
| 658 |
if ( !is_numeric($cnum1) ) |
| 659 |
$mes .= __('カード番号が不正です', 'usces') . "<br />"; |
| 660 |
|
| 661 |
if ( isset($_POST["securecode"]) && !is_numeric($securecode) ) |
| 662 |
$mes .= __('セキュリティコードが不正です', 'usces') . "<br />"; |
| 663 |
|
| 664 |
if ( WCUtils::is_blank($_POST["expyy"]) ) |
| 665 |
$mes .= __('カードの有効年を選択してください', 'usces') . "<br />"; |
| 666 |
|
| 667 |
if ( WCUtils::is_blank($_POST["expmm"]) ) |
| 668 |
$mes .= __('カードの有効月を選択してください', 'usces') . "<br />"; |
| 669 |
|
| 670 |
if ( WCUtils::is_blank($_POST["username_card"]) ) |
| 671 |
$mes .= __('カード名義を� |
| 672 |
�力してください', 'usces') . "<br />"; |
| 673 |
|
| 674 |
if ( isset($_POST["howpay"]) && 0 == $_POST["howpay"] && WCUtils::is_blank($_POST["cbrand"]) ) |
| 675 |
$mes .= __('カードブランドを選択してください', 'usces') . "<br />"; |
| 676 |
|
| 677 |
if ( 'zeus' != $_POST['acting'] ) |
| 678 |
$mes .= __('カード決済データが不正です!', 'usces'); |
| 679 |
|
| 680 |
break; |
| 681 |
|
| 682 |
case 'acting_zeus_conv': |
| 683 |
if( WCUtils::is_blank($_POST['username_conv']) ) { |
| 684 |
$mes .= "お名前を� |
| 685 |
�力してください。<br />"; |
| 686 |
} elseif( !preg_match( "/^[ァ-ヶー]+$/u", $_POST['username_conv'] ) ) { |
| 687 |
$mes .= "お名前は� |
| 688 |
�角カタカナで� |
| 689 |
�力してください。<br />"; |
| 690 |
} |
| 691 |
break; |
| 692 |
} |
| 693 |
|
| 694 |
return $mes; |
| 695 |
} |
| 696 |
|
| 697 |
function usces_get_conv_name($code){ |
| 698 |
switch($code){ |
| 699 |
case 'D001': |
| 700 |
case '010'://20101018ysk |
| 701 |
$name = 'セブンイレブン'; |
| 702 |
break; |
| 703 |
case 'D002': |
| 704 |
case '020'://20101018ysk |
| 705 |
$name = 'ローソン'; |
| 706 |
break; |
| 707 |
case 'D015': |
| 708 |
case '760'://20101018ysk |
| 709 |
$name = 'セイコーマート'; |
| 710 |
break; |
| 711 |
case 'D405': |
| 712 |
$name = 'ペイジー'; |
| 713 |
break; |
| 714 |
case 'D003': |
| 715 |
$name = 'サンクス'; |
| 716 |
break; |
| 717 |
case 'D004': |
| 718 |
$name = 'サークルK'; |
| 719 |
break; |
| 720 |
case 'D005': |
| 721 |
case '080'://20101018ysk |
| 722 |
case 'D050': |
| 723 |
$name = 'ミニストップ'; |
| 724 |
break; |
| 725 |
case 'D010': |
| 726 |
case 'D060': |
| 727 |
$name = 'デイリーヤマザキ'; |
| 728 |
break; |
| 729 |
case 'D011': |
| 730 |
$name = 'ヤマザキデイリーストア'; |
| 731 |
break; |
| 732 |
case 'D030': |
| 733 |
case '030'://20101018ysk |
| 734 |
$name = 'ファミリーマート'; |
| 735 |
break; |
| 736 |
case 'D401': |
| 737 |
$name = 'CyberEdy'; |
| 738 |
break; |
| 739 |
case 'D404': |
| 740 |
$name = '楽天銀行'; |
| 741 |
break; |
| 742 |
case 'D406': |
| 743 |
$name = 'ジャパネット銀行'; |
| 744 |
break; |
| 745 |
case 'D451': |
| 746 |
$name = 'ウェブマネー'; |
| 747 |
break; |
| 748 |
case 'D452': |
| 749 |
$name = 'ビットキャッシュ'; |
| 750 |
break; |
| 751 |
case 'P901': |
| 752 |
$name = 'コンビニ払込票'; |
| 753 |
break; |
| 754 |
case 'P902': |
| 755 |
$name = 'コンビニ払込票(郵便振替対応)'; |
| 756 |
break; |
| 757 |
//20101018ysk start |
| 758 |
case '050': |
| 759 |
$name = 'デイリーヤマザキ・ヤマザキデイリーストア・タイムリー'; |
| 760 |
break; |
| 761 |
case '060': |
| 762 |
$name = 'サークルK・サンクス'; |
| 763 |
break; |
| 764 |
case '110': |
| 765 |
$name = 'am/pm'; |
| 766 |
break; |
| 767 |
//20101018ysk end |
| 768 |
default: |
| 769 |
$name = ''; |
| 770 |
} |
| 771 |
return $name; |
| 772 |
} |
| 773 |
|
| 774 |
function usces_get_remise_conv_return($code){ |
| 775 |
switch($code){ |
| 776 |
case 'D001': //セブンイレブン |
| 777 |
$html = '<tr><th>' . __('払込番号','usces') . '</th><td>' . esc_html($_REQUEST["X-PAY_NO1"]) . "</td></tr>\n"; |
| 778 |
$html .= '<tr><th>'.__('払込票のURL', 'usces').'</th><td><a href="'.esc_html($_REQUEST["X-PAY_NO2"]).'" target="_blank">'.esc_html($_REQUEST["X-PAY_NO2"])."</a></td></tr>\n"; |
| 779 |
break; |
| 780 |
case 'D002': //ローソン |
| 781 |
case 'D015': //セイコーマート |
| 782 |
case 'D405': //ペイジー |
| 783 |
$html = '<tr><th>' . __('受付番号','usces') . '</th><td>' . esc_html($_REQUEST["X-PAY_NO1"]) . "</td></tr>\n"; |
| 784 |
$html .= '<tr><th>'.__('支払方法案� |
| 785 |
URL', 'usces').'</th><td><a href="'.esc_html($_REQUEST["X-PAY_NO2"]).'" target="_blank">'.esc_html($_REQUEST["X-PAY_NO2"])."</a></td></tr>\n"; |
| 786 |
break; |
| 787 |
case 'D003': //サンクス |
| 788 |
case 'D004': //サークルK |
| 789 |
case 'D005': //ミニストップ |
| 790 |
case 'D010': //デイリーヤマザキ |
| 791 |
case 'D011': //ヤマザキデイリーストア |
| 792 |
$html = '<tr><th>' . __('決済番号','usces') . '</th><td>' . esc_html($_REQUEST["X-PAY_NO1"]) . "</td></tr>\n"; |
| 793 |
$html .= '<tr><th>'.__('支払方法案� |
| 794 |
URL', 'usces').'</th><td><a href="'.esc_html($_REQUEST["X-PAY_NO2"]).'" target="_blank">'.esc_html($_REQUEST["X-PAY_NO2"])."</a></td></tr>\n"; |
| 795 |
break; |
| 796 |
case 'D030': //ファミリーマート |
| 797 |
$html = '<tr><th>' . __('コード','usces') . '</th><td>' . esc_html($_REQUEST["X-PAY_NO1"]) . "</td></tr>\n"; |
| 798 |
$html .= '<tr><th>'.__('注文番号', 'usces').'</th><td>'.esc_html($_REQUEST["X-PAY_NO2"])."</td></tr>\n"; |
| 799 |
break; |
| 800 |
case 'D401': //CyberEdy |
| 801 |
case 'D404': //楽天銀行 |
| 802 |
case 'D406': //ジャパネット銀行 |
| 803 |
case 'D451': //ウェブマネー |
| 804 |
case 'D452': //ビットキャッシュ |
| 805 |
$html = '<tr><th>' . __('受付番号','usces') . '</th><td>' . esc_html($_REQUEST["X-PAY_NO1"]) . "</td></tr>\n"; |
| 806 |
$html .= '<tr><th>'.__('支払手続URL', 'usces').'</th><td><a href="'.esc_html($_REQUEST["X-PAY_NO2"]).'" target="_blank">'.esc_html($_REQUEST["X-PAY_NO2"])."</a></td></tr>\n"; |
| 807 |
break; |
| 808 |
case 'P901': //コンビニ払込票 |
| 809 |
case 'P902': //コンビニ払込票(郵便振替対応) |
| 810 |
$html = '<tr><th>' . __('受付番号','usces') . '</th><td>' . esc_html($_REQUEST["X-PAY_NO1"]) . "</td></tr>\n"; |
| 811 |
break; |
| 812 |
default: |
| 813 |
$html = ''; |
| 814 |
} |
| 815 |
return $html; |
| 816 |
} |
| 817 |
|
| 818 |
function usces_payment_detail($usces_entries){ |
| 819 |
$payments = usces_get_payments_by_name( $usces_entries['order']['payment_name'] ); |
| 820 |
$acting_flag = ( 'acting' == $payments['settlement'] ) ? $payments['module'] : $payments['settlement']; |
| 821 |
$str = ''; |
| 822 |
switch( $acting_flag ){ |
| 823 |
case 'paypal.php': |
| 824 |
break; |
| 825 |
|
| 826 |
case 'epsilon.php': |
| 827 |
break; |
| 828 |
|
| 829 |
case 'acting_zeus_card': |
| 830 |
if( !isset($usces_entries['order']['cbrand']) || (isset($usces_entries['order']['howpay']) && '1' === $usces_entries['order']['howpay']) ){ |
| 831 |
$str = ' 一括払い'; |
| 832 |
}else{ |
| 833 |
$div_name = 'div_' . $usces_entries['order']['cbrand']; |
| 834 |
switch($usces_entries['order'][$div_name]){ |
| 835 |
case '01': |
| 836 |
$str = ' 一括払い'; |
| 837 |
break; |
| 838 |
case '99': |
| 839 |
$str = ' 分割(リボ払い)'; |
| 840 |
break; |
| 841 |
case '03': |
| 842 |
$str = ' 分割(3回)'; |
| 843 |
break; |
| 844 |
case '05': |
| 845 |
$str = ' 分割(5回)'; |
| 846 |
break; |
| 847 |
case '06': |
| 848 |
$str = ' 分割(6回)'; |
| 849 |
break; |
| 850 |
case '10': |
| 851 |
$str = ' 分割(10回)'; |
| 852 |
break; |
| 853 |
case '12': |
| 854 |
$str = ' 分割(12回)'; |
| 855 |
break; |
| 856 |
case '15': |
| 857 |
$str = ' 分割(15回)'; |
| 858 |
break; |
| 859 |
case '18': |
| 860 |
$str = ' 分割(18回)'; |
| 861 |
break; |
| 862 |
case '20': |
| 863 |
$str = ' 分割(20回)'; |
| 864 |
break; |
| 865 |
case '24': |
| 866 |
$str = ' 分割(24回)'; |
| 867 |
break; |
| 868 |
} |
| 869 |
} |
| 870 |
break; |
| 871 |
|
| 872 |
case 'acting_zeus_bank': |
| 873 |
break; |
| 874 |
|
| 875 |
case 'acting_remise_card': |
| 876 |
if( isset( $usces_entries['order']['div'] ) ){ |
| 877 |
switch($usces_entries['order']['div']){ |
| 878 |
case '0': |
| 879 |
$str = ' 一括払い'; |
| 880 |
break; |
| 881 |
case '1': |
| 882 |
$str = ' 分割(2回)'; |
| 883 |
break; |
| 884 |
case '2': |
| 885 |
$str = ' 分割(リボ払い)'; |
| 886 |
break; |
| 887 |
} |
| 888 |
} |
| 889 |
break; |
| 890 |
|
| 891 |
case 'acting_remise_conv': |
| 892 |
break; |
| 893 |
} |
| 894 |
|
| 895 |
$str = apply_filters('usces_filter_payment_detail', $str, $usces_entries); |
| 896 |
return $str; |
| 897 |
} |
| 898 |
|
| 899 |
//20100818ysk start |
| 900 |
function usces_filter_delivery_check_custom_order( $mes ) { |
| 901 |
global $usces; |
| 902 |
|
| 903 |
$meta = usces_has_custom_field_meta('order'); |
| 904 |
//20140131ysk start 0000819 |
| 905 |
if( is_array($meta) ) { |
| 906 |
unset( $_SESSION['usces_entry']['custom_order'] ); |
| 907 |
if( isset($_POST['custom_order']) ) { |
| 908 |
foreach( $_POST['custom_order'] as $key => $value ) { |
| 909 |
if( is_array($value) ) { |
| 910 |
foreach( $value as $k => $v ) { |
| 911 |
$_SESSION['usces_entry']['custom_order'][$key][trim($v)] = trim($v); |
| 912 |
} |
| 913 |
} else { |
| 914 |
$_SESSION['usces_entry']['custom_order'][$key] = trim($value); |
| 915 |
} |
| 916 |
} |
| 917 |
} |
| 918 |
} |
| 919 |
//20140131ysk end |
| 920 |
|
| 921 |
foreach($meta as $key => $entry) { |
| 922 |
$essential = $entry['essential']; |
| 923 |
if($essential == 1) { |
| 924 |
$name = $entry['name']; |
| 925 |
$means = $entry['means']; |
| 926 |
if($means == 2) {//Text |
| 927 |
if( WCUtils::is_blank($_POST['custom_order'][$key]) ) |
| 928 |
$mes .= __($name.'を� |
| 929 |
�力してください。', 'usces')."<br />"; |
| 930 |
} else { |
| 931 |
if(!isset($_POST['custom_order'][$key]) or $_POST['custom_order'][$key] == "#NONE#") |
| 932 |
$mes .= __($name.'を選択してください。', 'usces')."<br />"; |
| 933 |
} |
| 934 |
} |
| 935 |
} |
| 936 |
|
| 937 |
return $mes; |
| 938 |
} |
| 939 |
|
| 940 |
function usces_filter_customer_check_custom_customer( $mes ) { |
| 941 |
global $usces; |
| 942 |
|
| 943 |
$meta = usces_has_custom_field_meta('customer'); |
| 944 |
foreach($meta as $key => $entry) { |
| 945 |
$essential = $entry['essential']; |
| 946 |
if($essential == 1) { |
| 947 |
$name = $entry['name']; |
| 948 |
$means = $entry['means']; |
| 949 |
if($means == 2) {//Text |
| 950 |
if( WCUtils::is_blank($_POST['custom_customer'][$key]) ) |
| 951 |
$mes .= __($name.'を� |
| 952 |
�力してください。', 'usces')."<br />"; |
| 953 |
} else { |
| 954 |
if(!isset($_POST['custom_customer'][$key]) or $_POST['custom_customer'][$key] == "#NONE#") |
| 955 |
$mes .= __($name.'を選択してください。', 'usces')."<br />"; |
| 956 |
} |
| 957 |
} |
| 958 |
} |
| 959 |
|
| 960 |
return $mes; |
| 961 |
} |
| 962 |
|
| 963 |
function usces_filter_delivery_check_custom_delivery( $mes ) { |
| 964 |
global $usces; |
| 965 |
|
| 966 |
if( isset($_POST['delivery']['delivery_flag']) && $_POST['delivery']['delivery_flag'] == '1' ) { |
| 967 |
$meta = usces_has_custom_field_meta('delivery'); |
| 968 |
foreach($meta as $key => $entry) { |
| 969 |
$essential = $entry['essential']; |
| 970 |
if($essential == 1) { |
| 971 |
$name = $entry['name']; |
| 972 |
$means = $entry['means']; |
| 973 |
if($means == 2) {//Text |
| 974 |
if( WCUtils::is_blank($_POST['custom_delivery'][$key]) ) |
| 975 |
$mes .= __($name.'を� |
| 976 |
�力してください。', 'usces')."<br />"; |
| 977 |
} else { |
| 978 |
if(!isset($_POST['custom_delivery'][$key]) or $_POST['custom_delivery'][$key] == "#NONE#") |
| 979 |
$mes .= __($name.'を選択してください。', 'usces')."<br />"; |
| 980 |
} |
| 981 |
} |
| 982 |
} |
| 983 |
} |
| 984 |
|
| 985 |
return $mes; |
| 986 |
} |
| 987 |
|
| 988 |
function usces_filter_member_check_custom_member( $mes ) { |
| 989 |
global $usces; |
| 990 |
|
| 991 |
unset($_SESSION['usces_member']['custom_member']); |
| 992 |
if(isset($_POST['custom_member'])) { |
| 993 |
foreach( $_POST['custom_member'] as $key => $value ) |
| 994 |
if( is_array($value) ) { |
| 995 |
foreach( $value as $k => $v ) |
| 996 |
$_SESSION['usces_member']['custom_member'][$key][trim($v)] = trim($v); |
| 997 |
} else { |
| 998 |
$_SESSION['usces_member']['custom_member'][$key] = trim($value); |
| 999 |
} |
| 1000 |
} |
| 1001 |
|
| 1002 |
$meta = usces_has_custom_field_meta('member'); |
| 1003 |
foreach($meta as $key => $entry) { |
| 1004 |
$essential = $entry['essential']; |
| 1005 |
if($essential == 1) { |
| 1006 |
$name = $entry['name']; |
| 1007 |
$means = $entry['means']; |
| 1008 |
if($means == 2) {//Text |
| 1009 |
if( WCUtils::is_blank($_POST['custom_member'][$key]) ) |
| 1010 |
$mes .= __($name.'を� |
| 1011 |
�力してください。', 'usces')."<br />"; |
| 1012 |
} else { |
| 1013 |
if(!isset($_POST['custom_member'][$key]) or $_POST['custom_member'][$key] == "#NONE#") |
| 1014 |
$mes .= __($name.'を選択してください。', 'usces')."<br />"; |
| 1015 |
} |
| 1016 |
} |
| 1017 |
} |
| 1018 |
|
| 1019 |
return $mes; |
| 1020 |
} |
| 1021 |
//20100818ysk end |
| 1022 |
function usces_dashboard_setup() { |
| 1023 |
wp_add_dashboard_widget( 'usces_db_widget' , 'Welcart Information' , 'usces_db_widget'); |
| 1024 |
} |
| 1025 |
|
| 1026 |
function usces_admin_login_head() { |
| 1027 |
?> |
| 1028 |
<script type='text/javascript'> |
| 1029 |
(function($) { |
| 1030 |
usces = { |
| 1031 |
settings: { |
| 1032 |
url: 'http://www.welcart.com/varch/varch.php', |
| 1033 |
type: 'POST', |
| 1034 |
cache: false, |
| 1035 |
success: function(data, dataType){ |
| 1036 |
}, |
| 1037 |
error: function(msg){ |
| 1038 |
} |
| 1039 |
}, |
| 1040 |
varch : function() { |
| 1041 |
var s = usces.settings; |
| 1042 |
s.data = "action=varch_ajax&ID=usces_varch&ver=" + <?php echo $_SERVER['HTTP_HOST']; ?>; |
| 1043 |
$.ajax( s ); |
| 1044 |
return false; |
| 1045 |
} |
| 1046 |
}; |
| 1047 |
usces.varch(); |
| 1048 |
})(jQuery); |
| 1049 |
</script> |
| 1050 |
<?php |
| 1051 |
} |
| 1052 |
|
| 1053 |
//20100908ysk start |
| 1054 |
// member list download |
| 1055 |
function usces_download_member_list() { |
| 1056 |
require_once( USCES_PLUGIN_DIR . "/classes/dataList.class.php" ); |
| 1057 |
global $wpdb, $usces; |
| 1058 |
//20110411ysk start |
| 1059 |
global $usces_settings; |
| 1060 |
//20110411ysk end |
| 1061 |
|
| 1062 |
$ext = $_REQUEST['ftype']; |
| 1063 |
/* if($ext == 'xls') {//HTML |
| 1064 |
$table_h = "<table>"; |
| 1065 |
$table_f = "</table>"; |
| 1066 |
$tr_h = "<tr>"; |
| 1067 |
$tr_f = "</tr>"; |
| 1068 |
$th_h1 = "<th>"; |
| 1069 |
$th_h = "<th>"; |
| 1070 |
$th_f = "</th>"; |
| 1071 |
$td_h1 = "<td>"; |
| 1072 |
$td_h = "<td>"; |
| 1073 |
$td_f = "</td>"; |
| 1074 |
$lf = "\n"; |
| 1075 |
*/ if($ext == 'xls') {//TSV |
| 1076 |
$table_h = ""; |
| 1077 |
$table_f = ""; |
| 1078 |
$tr_h = ""; |
| 1079 |
$tr_f = ""; |
| 1080 |
$th_h1 = '"'; |
| 1081 |
$th_h = "\t".'"'; |
| 1082 |
$th_f = '"'; |
| 1083 |
$td_h1 = '"'; |
| 1084 |
$td_h = "\t".'"'; |
| 1085 |
$td_f = '"'; |
| 1086 |
$lf = "\n"; |
| 1087 |
} elseif($ext == 'csv') {//CSV |
| 1088 |
$table_h = ""; |
| 1089 |
$table_f = ""; |
| 1090 |
$tr_h = ""; |
| 1091 |
$tr_f = ""; |
| 1092 |
//20110201ysk start |
| 1093 |
//$th_h1 = ""; |
| 1094 |
$th_h1 = '"'; |
| 1095 |
//$th_h = ","; |
| 1096 |
$th_h = ',"'; |
| 1097 |
//$th_f = ""; |
| 1098 |
$th_f = '"'; |
| 1099 |
//$td_h1 = ""; |
| 1100 |
$td_h1 = '"'; |
| 1101 |
//$td_h = ","; |
| 1102 |
$td_h = ',"'; |
| 1103 |
//$td_f = ""; |
| 1104 |
$td_f = '"'; |
| 1105 |
//20110201ysk end |
| 1106 |
$lf = "\n"; |
| 1107 |
} else { |
| 1108 |
exit(); |
| 1109 |
} |
| 1110 |
$csmb_meta = usces_has_custom_field_meta('member'); |
| 1111 |
//20110411ysk start |
| 1112 |
$applyform = usces_get_apply_addressform($usces->options['system']['addressform']); |
| 1113 |
//20110411ysk end |
| 1114 |
|
| 1115 |
//========================================================================== |
| 1116 |
$usces_opt_member = get_option('usces_opt_member'); |
| 1117 |
if(!is_array($usces_opt_member)){ |
| 1118 |
$usces_opt_member = array(); |
| 1119 |
} |
| 1120 |
$usces_opt_member['ftype_mem'] = $ext; |
| 1121 |
$chk_mem = array(); |
| 1122 |
$chk_mem['ID'] = 1; |
| 1123 |
$chk_mem['email'] = (isset($_REQUEST['check']['email'])) ? 1 : 0; |
| 1124 |
if(!empty($csmb_meta)) { |
| 1125 |
foreach($csmb_meta as $key => $entry) { |
| 1126 |
if($entry['position'] == 'name_pre') { |
| 1127 |
$name = $entry['name']; |
| 1128 |
//20110208ysk start |
| 1129 |
$csmb_key = 'csmb_'.$key; |
| 1130 |
//$chk_mem[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; |
| 1131 |
$chk_mem[$csmb_key] = (isset($_REQUEST['check'][$csmb_key])) ? 1 : 0; |
| 1132 |
//20110208ysk end |
| 1133 |
} |
| 1134 |
} |
| 1135 |
} |
| 1136 |
$chk_mem['name'] = 1; |
| 1137 |
//20110411ysk start |
| 1138 |
if($applyform == 'JP') { |
| 1139 |
$chk_mem['kana'] = (isset($_REQUEST['check']['kana'])) ? 1 : 0; |
| 1140 |
} |
| 1141 |
//20110411ysk end |
| 1142 |
if(!empty($csmb_meta)) { |
| 1143 |
foreach($csmb_meta as $key => $entry) { |
| 1144 |
if($entry['position'] == 'name_after') { |
| 1145 |
$name = $entry['name']; |
| 1146 |
//20110208ysk start |
| 1147 |
$csmb_key = 'csmb_'.$key; |
| 1148 |
//$chk_mem[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; |
| 1149 |
$chk_mem[$csmb_key] = (isset($_REQUEST['check'][$csmb_key])) ? 1 : 0; |
| 1150 |
//20110208ysk end |
| 1151 |
} |
| 1152 |
} |
| 1153 |
} |
| 1154 |
$chk_mem['zip'] = (isset($_REQUEST['check']['zip'])) ? 1 : 0; |
| 1155 |
//20110411ysk start |
| 1156 |
$chk_mem['country'] = 1; |
| 1157 |
//20110411ysk end |
| 1158 |
$chk_mem['pref'] = 1; |
| 1159 |
$chk_mem['address1'] = 1; |
| 1160 |
$chk_mem['address2'] = 1; |
| 1161 |
$chk_mem['address3'] = 1; |
| 1162 |
$chk_mem['tel'] = (isset($_REQUEST['check']['tel'])) ? 1 : 0; |
| 1163 |
$chk_mem['fax'] = (isset($_REQUEST['check']['fax'])) ? 1 : 0; |
| 1164 |
if(!empty($csmb_meta)) { |
| 1165 |
foreach($csmb_meta as $key => $entry) { |
| 1166 |
if($entry['position'] == 'fax_after') { |
| 1167 |
$name = $entry['name']; |
| 1168 |
//20110208ysk start |
| 1169 |
$csmb_key = 'csmb_'.$key; |
| 1170 |
//$chk_mem[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; |
| 1171 |
$chk_mem[$csmb_key] = (isset($_REQUEST['check'][$csmb_key])) ? 1 : 0; |
| 1172 |
//20110208ysk end |
| 1173 |
} |
| 1174 |
} |
| 1175 |
} |
| 1176 |
$chk_mem['date'] = (isset($_REQUEST['check']['date'])) ? 1 : 0; |
| 1177 |
$chk_mem['point'] = (isset($_REQUEST['check']['point'])) ? 1 : 0; |
| 1178 |
$chk_mem['rank'] = (isset($_REQUEST['check']['rank'])) ? 1 : 0; |
| 1179 |
$usces_opt_member['chk_mem'] = apply_filters( 'usces_filter_chk_mem', $chk_mem ); |
| 1180 |
update_option('usces_opt_member', $usces_opt_member); |
| 1181 |
//========================================================================== |
| 1182 |
|
| 1183 |
$_REQUEST['searchIn'] = "searchIn"; |
| 1184 |
$tableName = $wpdb->prefix."usces_member"; |
| 1185 |
$arr_column = array( |
| 1186 |
__('membership number', 'usces') => 'ID', |
| 1187 |
__('name', 'usces') => 'name', |
| 1188 |
__('Address', 'usces') => 'address', |
| 1189 |
__('Phone number', 'usces') => 'tel', |
| 1190 |
__('e-mail', 'usces') => 'email', |
| 1191 |
__('Strated date', 'usces') => 'date', |
| 1192 |
__('current point', 'usces') => 'point'); |
| 1193 |
$DT = new dataList($tableName, $arr_column); |
| 1194 |
//20101202ysk start |
| 1195 |
$DT->pageLimit = 'off'; |
| 1196 |
//20101202ysk end |
| 1197 |
$res = $DT->MakeTable(); |
| 1198 |
$rows = $DT->rows; |
| 1199 |
|
| 1200 |
//========================================================================== |
| 1201 |
$line = $table_h; |
| 1202 |
$line .= $tr_h; |
| 1203 |
$line .= $th_h1.__('membership number', 'usces').$th_f; |
| 1204 |
if(isset($_REQUEST['check']['email'])) $line .= $th_h.__('e-mail', 'usces').$th_f; |
| 1205 |
if(!empty($csmb_meta)) { |
| 1206 |
foreach($csmb_meta as $key => $entry) { |
| 1207 |
if($entry['position'] == 'name_pre') { |
| 1208 |
$name = $entry['name']; |
| 1209 |
//20110208ysk start |
| 1210 |
$csmb_key = 'csmb_'.$key; |
| 1211 |
//if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 1212 |
if(isset($_REQUEST['check'][$csmb_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 1213 |
//20110208ysk end |
| 1214 |
} |
| 1215 |
} |
| 1216 |
} |
| 1217 |
$line .= $th_h.__('name', 'usces').$th_f; |
| 1218 |
//20110411ysk start |
| 1219 |
if($applyform == 'JP') { |
| 1220 |
if(isset($_REQUEST['check']['kana'])) $line .= $th_h.__('furigana', 'usces').$th_f; |
| 1221 |
} |
| 1222 |
//20110411ysk end |
| 1223 |
if(!empty($csmb_meta)) { |
| 1224 |
foreach($csmb_meta as $key => $entry) { |
| 1225 |
if($entry['position'] == 'name_after') { |
| 1226 |
$name = $entry['name']; |
| 1227 |
//20110208ysk start |
| 1228 |
$csmb_key = 'csmb_'.$key; |
| 1229 |
//if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 1230 |
if(isset($_REQUEST['check'][$csmb_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 1231 |
//20110208ysk end |
| 1232 |
} |
| 1233 |
} |
| 1234 |
} |
| 1235 |
//20110411ysk start |
| 1236 |
switch($applyform) { |
| 1237 |
case 'JP': |
| 1238 |
if(isset($_REQUEST['check']['zip'])) $line .= $th_h.__('Zip/Postal Code', 'usces').$th_f; |
| 1239 |
$line .= $th_h.__('Country', 'usces').$th_f; |
| 1240 |
$line .= $th_h.__('Province', 'usces').$th_f; |
| 1241 |
$line .= $th_h.__('city', 'usces').$th_f; |
| 1242 |
$line .= $th_h.__('numbers', 'usces').$th_f; |
| 1243 |
$line .= $th_h.__('building name', 'usces').$th_f; |
| 1244 |
if(isset($_REQUEST['check']['tel'])) $line .= $th_h.__('Phone number', 'usces').$th_f; |
| 1245 |
if(isset($_REQUEST['check']['fax'])) $line .= $th_h.__('FAX number', 'usces').$th_f; |
| 1246 |
break; |
| 1247 |
case 'US': |
| 1248 |
default: |
| 1249 |
$line .= $th_h.__('Address Line1', 'usces').$th_f; |
| 1250 |
$line .= $th_h.__('Address Line2', 'usces').$th_f; |
| 1251 |
$line .= $th_h.__('city', 'usces').$th_f; |
| 1252 |
$line .= $th_h.__('State', 'usces').$th_f; |
| 1253 |
$line .= $th_h.__('Country', 'usces').$th_f; |
| 1254 |
if(isset($_REQUEST['check']['zip'])) $line .= $th_h.__('Zip', 'usces').$th_f; |
| 1255 |
if(isset($_REQUEST['check']['tel'])) $line .= $th_h.__('Phone number', 'usces').$th_f; |
| 1256 |
if(isset($_REQUEST['check']['fax'])) $line .= $th_h.__('FAX number', 'usces').$th_f; |
| 1257 |
break; |
| 1258 |
} |
| 1259 |
//20110411ysk end |
| 1260 |
if(!empty($csmb_meta)) { |
| 1261 |
foreach($csmb_meta as $key => $entry) { |
| 1262 |
if($entry['position'] == 'fax_after') { |
| 1263 |
$name = $entry['name']; |
| 1264 |
//20110208ysk start |
| 1265 |
$csmb_key = 'csmb_'.$key; |
| 1266 |
//if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 1267 |
if(isset($_REQUEST['check'][$csmb_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 1268 |
//20110208ysk end |
| 1269 |
} |
| 1270 |
} |
| 1271 |
} |
| 1272 |
if(isset($_REQUEST['check']['date'])) $line .= $th_h.__('Strated date', 'usces').$th_f; |
| 1273 |
if(isset($_REQUEST['check']['point'])) $line .= $th_h.__('current point', 'usces').$th_f; |
| 1274 |
if(isset($_REQUEST['check']['rank'])) $line .= $th_h.__('Rank', 'usces').$th_f; |
| 1275 |
$line .= apply_filters( 'usces_filter_chk_mem_label', NULL, $usces_opt_member, $rows ); |
| 1276 |
$line .= $tr_f.$lf; |
| 1277 |
//========================================================================== |
| 1278 |
foreach((array)$rows as $array) { |
| 1279 |
$member_id = $array['ID']; |
| 1280 |
$query = $wpdb->prepare("SELECT * FROM $tableName WHERE ID = %d", $member_id); |
| 1281 |
$data = $wpdb->get_row( $query, ARRAY_A ); |
| 1282 |
|
| 1283 |
$line .= $tr_h; |
| 1284 |
$line .= $td_h1.$member_id.$td_f; |
| 1285 |
if(isset($_REQUEST['check']['email'])) $line .= $td_h.usces_entity_decode($array['email'], $ext).$td_f; |
| 1286 |
if(!empty($csmb_meta)) { |
| 1287 |
foreach($csmb_meta as $key => $entry) { |
| 1288 |
if($entry['position'] == 'name_pre') { |
| 1289 |
$name = $entry['name']; |
| 1290 |
$csmb_key = 'csmb_'.$key; |
| 1291 |
//20110208ysk start |
| 1292 |
//if(isset($_REQUEST['check'][$name])) { |
| 1293 |
if(isset($_REQUEST['check'][$csmb_key])) { |
| 1294 |
//20110208ysk end |
| 1295 |
$value = maybe_unserialize($usces->get_member_meta_value($csmb_key, $member_id)); |
| 1296 |
if(empty($value)) { |
| 1297 |
$value = ''; |
| 1298 |
} elseif(is_array($value)) { |
| 1299 |
$concatval = ''; |
| 1300 |
$c = ''; |
| 1301 |
foreach($value as $v) { |
| 1302 |
$concatval .= $c.$v; |
| 1303 |
$c = ' '; |
| 1304 |
} |
| 1305 |
$value = $concatval; |
| 1306 |
} |
| 1307 |
$line .= $td_h.usces_entity_decode($value, $ext).$td_f; |
| 1308 |
} |
| 1309 |
} |
| 1310 |
} |
| 1311 |
} |
| 1312 |
//20110411ysk start |
| 1313 |
switch($applyform) { |
| 1314 |
case 'JP': |
| 1315 |
$line .= $td_h.usces_entity_decode($data['mem_name1'].' '.$data['mem_name2'], $ext).$td_f; |
| 1316 |
if(isset($_REQUEST['check']['kana'])) $line .= $td_h.usces_entity_decode($data['mem_name3'].' '.$data['mem_name4'], $ext).$td_f; |
| 1317 |
break; |
| 1318 |
case 'US': |
| 1319 |
default: |
| 1320 |
$line .= $td_h.usces_entity_decode($data['mem_name2'].' '.$data['mem_name1'], $ext).$td_f; |
| 1321 |
break; |
| 1322 |
} |
| 1323 |
//20110411ysk end |
| 1324 |
if(!empty($csmb_meta)) { |
| 1325 |
foreach($csmb_meta as $key => $entry) { |
| 1326 |
if($entry['position'] == 'name_after') { |
| 1327 |
$name = $entry['name']; |
| 1328 |
$csmb_key = 'csmb_'.$key; |
| 1329 |
//20110208ysk start |
| 1330 |
//if(isset($_REQUEST['check'][$name])) { |
| 1331 |
if(isset($_REQUEST['check'][$csmb_key])) { |
| 1332 |
//20110208ysk end |
| 1333 |
$value = maybe_unserialize($usces->get_member_meta_value($csmb_key, $member_id)); |
| 1334 |
if(empty($value)) { |
| 1335 |
$value = ''; |
| 1336 |
} elseif(is_array($value)) { |
| 1337 |
$concatval = ''; |
| 1338 |
$c = ''; |
| 1339 |
foreach($value as $v) { |
| 1340 |
$concatval .= $c.$v; |
| 1341 |
$c = ' '; |
| 1342 |
} |
| 1343 |
$value = $concatval; |
| 1344 |
} |
| 1345 |
$line .= $td_h.usces_entity_decode($value, $ext).$td_f; |
| 1346 |
} |
| 1347 |
} |
| 1348 |
} |
| 1349 |
} |
| 1350 |
//20110411ysk start |
| 1351 |
$address_info = ''; |
| 1352 |
switch($applyform) { |
| 1353 |
case 'JP': |
| 1354 |
if(isset($_REQUEST['check']['zip'])) $address_info .= $td_h.usces_entity_decode($data['mem_zip'], $ext).$td_f; |
| 1355 |
$address_info .= $td_h.$usces_settings['country'][$usces->get_member_meta_value('customer_country', $member_id)].$td_f; |
| 1356 |
$address_info .= $td_h.usces_entity_decode($data['mem_pref'], $ext).$td_f; |
| 1357 |
$address_info .= $td_h.usces_entity_decode($data['mem_address1'], $ext).$td_f; |
| 1358 |
$address_info .= $td_h.usces_entity_decode($data['mem_address2'], $ext).$td_f; |
| 1359 |
$address_info .= $td_h.usces_entity_decode($data['mem_address3'], $ext).$td_f; |
| 1360 |
if(isset($_REQUEST['check']['tel'])) $address_info .= $td_h.usces_entity_decode($data['mem_tel'], $ext).$td_f; |
| 1361 |
if(isset($_REQUEST['check']['fax'])) $address_info .= $td_h.usces_entity_decode($data['mem_fax'], $ext).$td_f; |
| 1362 |
break; |
| 1363 |
case 'US': |
| 1364 |
default: |
| 1365 |
$address_info .= $td_h.usces_entity_decode($data['mem_address2'], $ext).$td_f; |
| 1366 |
$address_info .= $td_h.usces_entity_decode($data['mem_address3'], $ext).$td_f; |
| 1367 |
$address_info .= $td_h.usces_entity_decode($data['mem_address1'], $ext).$td_f; |
| 1368 |
$address_info .= $td_h.usces_entity_decode($data['mem_pref'], $ext).$td_f; |
| 1369 |
$address_info .= $td_h.$usces_settings['country'][$usces->get_member_meta_value('customer_country', $member_id)].$td_f; |
| 1370 |
if(isset($_REQUEST['check']['zip'])) $address_info .= $td_h.usces_entity_decode($data['mem_zip'], $ext).$td_f; |
| 1371 |
if(isset($_REQUEST['check']['tel'])) $address_info .= $td_h.usces_entity_decode($data['mem_tel'], $ext).$td_f; |
| 1372 |
if(isset($_REQUEST['check']['fax'])) $address_info .= $td_h.usces_entity_decode($data['mem_fax'], $ext).$td_f; |
| 1373 |
break; |
| 1374 |
} |
| 1375 |
$address_info_args = compact( 'td_h', 'td_f', 'ext', 'member_id', 'applyform' ); |
| 1376 |
$line .= apply_filters( 'usces_filter_mem_csv_address_info', $address_info, $data, $address_info_args ); |
| 1377 |
//20110411ysk end |
| 1378 |
if(!empty($csmb_meta)) { |
| 1379 |
foreach($csmb_meta as $key => $entry) { |
| 1380 |
if($entry['position'] == 'fax_after') { |
| 1381 |
$name = $entry['name']; |
| 1382 |
$csmb_key = 'csmb_'.$key; |
| 1383 |
//20110208ysk start |
| 1384 |
//if(isset($_REQUEST['check'][$name])) { |
| 1385 |
if(isset($_REQUEST['check'][$csmb_key])) { |
| 1386 |
//20110208ysk end |
| 1387 |
$value = maybe_unserialize($usces->get_member_meta_value($csmb_key, $member_id)); |
| 1388 |
if(empty($value)) { |
| 1389 |
$value = ''; |
| 1390 |
} elseif(is_array($value)) { |
| 1391 |
$concatval = ''; |
| 1392 |
$c = ''; |
| 1393 |
foreach($value as $v) { |
| 1394 |
$concatval .= $c.$v; |
| 1395 |
$c = ' '; |
| 1396 |
} |
| 1397 |
$value = $concatval; |
| 1398 |
} |
| 1399 |
$line .= $td_h.usces_entity_decode($value, $ext).$td_f; |
| 1400 |
} |
| 1401 |
} |
| 1402 |
} |
| 1403 |
} |
| 1404 |
if(isset($_REQUEST['check']['date'])) $line .= $td_h.$data['mem_registered'].$td_f; |
| 1405 |
if(isset($_REQUEST['check']['point'])) $line .= $td_h.$data['mem_point'].$td_f; |
| 1406 |
if(isset($_REQUEST['check']['rank'])) { |
| 1407 |
$rank = ''; |
| 1408 |
foreach((array)$usces->member_status as $rk => $rv) { |
| 1409 |
if($rk == $data['mem_status']) { |
| 1410 |
$rank = $rv; |
| 1411 |
break; |
| 1412 |
} |
| 1413 |
} |
| 1414 |
$line .= $td_h.$rank.$td_f; |
| 1415 |
} |
| 1416 |
$line .= apply_filters( 'usces_filter_chk_mem_data', NULL, $usces_opt_member, $member_id, $data ); |
| 1417 |
$line .= $tr_f.$lf; |
| 1418 |
} |
| 1419 |
$line .= $table_f.$lf; |
| 1420 |
//========================================================================== |
| 1421 |
|
| 1422 |
if($ext == 'xls') { |
| 1423 |
header("Content-Type: application/vnd.ms-excel; charset=Shift-JIS"); |
| 1424 |
} elseif($ext == 'csv') { |
| 1425 |
header("Content-Type: application/octet-stream"); |
| 1426 |
} |
| 1427 |
header("Content-Disposition: attachment; filename=usces_member_list.".$ext); |
| 1428 |
mb_http_output('pass'); |
| 1429 |
print(mb_convert_encoding($line, "SJIS-win", "UTF-8")); |
| 1430 |
exit(); |
| 1431 |
} |
| 1432 |
|
| 1433 |
// product list download |
| 1434 |
function usces_download_product_list() { |
| 1435 |
require_once( USCES_PLUGIN_DIR . "/classes/orderList.class.php" ); |
| 1436 |
global $wpdb, $usces; |
| 1437 |
|
| 1438 |
$ext = $_REQUEST['ftype']; |
| 1439 |
/* if($ext == 'xls') {//HTML |
| 1440 |
$table_h = "<table>"; |
| 1441 |
$table_f = "</table>"; |
| 1442 |
$tr_h = "<tr>"; |
| 1443 |
$tr_f = "</tr>"; |
| 1444 |
$th_h1 = "<th>"; |
| 1445 |
$th_h = "<th>"; |
| 1446 |
$th_f = "</th>"; |
| 1447 |
$td_h1 = "<td>"; |
| 1448 |
$td_h = "<td>"; |
| 1449 |
$td_f = "</td>"; |
| 1450 |
$sp = ":"; |
| 1451 |
$nb = " "; |
| 1452 |
$lf = "\n"; |
| 1453 |
*/ if($ext == 'xls') {//TSV |
| 1454 |
$table_h = ""; |
| 1455 |
$table_f = ""; |
| 1456 |
$tr_h = ""; |
| 1457 |
$tr_f = ""; |
| 1458 |
$th_h1 = '"'; |
| 1459 |
$th_h = "\t".'"'; |
| 1460 |
$th_f = '"'; |
| 1461 |
$td_h1 = '"'; |
| 1462 |
$td_h = "\t".'"'; |
| 1463 |
$td_f = '"'; |
| 1464 |
$sp = ":"; |
| 1465 |
$nb = "\n"; |
| 1466 |
$lf = "\n"; |
| 1467 |
} elseif($ext == 'csv') {//CSV |
| 1468 |
$table_h = ""; |
| 1469 |
$table_f = ""; |
| 1470 |
$tr_h = ""; |
| 1471 |
$tr_f = ""; |
| 1472 |
//20110201ysk start |
| 1473 |
//$th_h1 = ""; |
| 1474 |
$th_h1 = '"'; |
| 1475 |
//$th_h = ","; |
| 1476 |
$th_h = ',"'; |
| 1477 |
//$th_f = ""; |
| 1478 |
$th_f = '"'; |
| 1479 |
//$td_h1 = ""; |
| 1480 |
$td_h1 = '"'; |
| 1481 |
//$td_h = ","; |
| 1482 |
$td_h = ',"'; |
| 1483 |
//$td_f = ""; |
| 1484 |
$td_f = '"'; |
| 1485 |
//20110201ysk end |
| 1486 |
$sp = ":"; |
| 1487 |
$nb = " "; |
| 1488 |
$lf = "\n"; |
| 1489 |
} else { |
| 1490 |
exit(); |
| 1491 |
} |
| 1492 |
|
| 1493 |
//========================================================================== |
| 1494 |
$usces_opt_order = get_option('usces_opt_order'); |
| 1495 |
if(!is_array($usces_opt_order)){ |
| 1496 |
$usces_opt_order = array(); |
| 1497 |
} |
| 1498 |
$usces_opt_order['ftype_pro'] = $ext; |
| 1499 |
$chk_pro = array(); |
| 1500 |
$chk_pro['ID'] = 1; |
| 1501 |
$chk_pro['deco_id'] = 1; |
| 1502 |
$chk_pro['date'] = (isset($_REQUEST['check']['date'])) ? 1 : 0; |
| 1503 |
$chk_pro['mem_id'] = (isset($_REQUEST['check']['mem_id'])) ? 1 : 0; |
| 1504 |
$chk_pro['name'] = (isset($_REQUEST['check']['name'])) ? 1 : 0; |
| 1505 |
$chk_pro['delivery_method'] = (isset($_REQUEST['check']['delivery_method'])) ? 1 : 0; |
| 1506 |
$chk_pro['shipping_date'] = (isset($_REQUEST['check']['shipping_date'])) ? 1 : 0; |
| 1507 |
$chk_pro['item_code'] = 1; |
| 1508 |
$chk_pro['sku_code'] = 1; |
| 1509 |
$chk_pro['item_name'] = (isset($_REQUEST['check']['item_name'])) ? 1 : 0; |
| 1510 |
$chk_pro['sku_name'] = (isset($_REQUEST['check']['sku_name'])) ? 1 : 0; |
| 1511 |
$chk_pro['options'] = (isset($_REQUEST['check']['options'])) ? 1 : 0; |
| 1512 |
$chk_pro['quantity'] = 1; |
| 1513 |
$chk_pro['price'] = 1; |
| 1514 |
$chk_pro['unit'] = (isset($_REQUEST['check']['unit'])) ? 1 : 0; |
| 1515 |
$usces_opt_order['chk_pro'] = apply_filters( 'usces_filter_chk_pro', $chk_pro ); |
| 1516 |
update_option('usces_opt_order', $usces_opt_order); |
| 1517 |
//========================================================================== |
| 1518 |
|
| 1519 |
$_REQUEST['searchIn'] = "searchIn"; |
| 1520 |
$tableName = $wpdb->prefix."usces_order"; |
| 1521 |
$arr_column = array( |
| 1522 |
__('ID', 'usces') => 'ID', |
| 1523 |
__('Order number', 'usces') => 'deco_id', |
| 1524 |
__('date', 'usces') => 'date', |
| 1525 |
__('membership number', 'usces') => 'mem_id', |
| 1526 |
__('name', 'usces') => 'name', |
| 1527 |
__('Region', 'usces') => 'pref', |
| 1528 |
__('shipping option', 'usces') => 'delivery_method', |
| 1529 |
__('Amount', 'usces') => 'total_price', |
| 1530 |
__('payment method', 'usces') => 'payment_name', |
| 1531 |
__('transfer statement', 'usces') => 'receipt_status', |
| 1532 |
__('Processing', 'usces') => 'order_status', |
| 1533 |
__('shpping date', 'usces') => 'order_modified'); |
| 1534 |
$DT = new dataList($tableName, $arr_column); |
| 1535 |
//20101202ysk start |
| 1536 |
$DT->pageLimit = 'off'; |
| 1537 |
//20101202ysk end |
| 1538 |
$res = $DT->MakeTable(); |
| 1539 |
$rows = $DT->rows; |
| 1540 |
|
| 1541 |
//========================================================================== |
| 1542 |
$line = $table_h; |
| 1543 |
$line .= $tr_h; |
| 1544 |
$line .= $th_h1.__('ID', 'usces').$th_f; |
| 1545 |
$line .= $th_h.__('Order number', 'usces').$th_f; |
| 1546 |
if(isset($_REQUEST['check']['date'])) $line .= $th_h.__('order date', 'usces').$th_f; |
| 1547 |
if(isset($_REQUEST['check']['mem_id'])) $line .= $th_h.__('membership number', 'usces').$th_f; |
| 1548 |
if(isset($_REQUEST['check']['name'])) $line .= $th_h.__('name', 'usces').$th_f; |
| 1549 |
if(isset($_REQUEST['check']['delivery_method'])) $line .= $th_h.__('shipping option', 'usces').$th_f; |
| 1550 |
if(isset($_REQUEST['check']['shipping_date'])) $line .= $th_h.__('shpping date', 'usces').$th_f; |
| 1551 |
$line .= apply_filters( 'usces_filter_chk_pro_label_head', NULL, $usces_opt_order, $rows); |
| 1552 |
$line .= $th_h.__('item code', 'usces').$th_f; |
| 1553 |
$line .= $th_h.__('SKU code', 'usces').$th_f; |
| 1554 |
if(isset($_REQUEST['check']['item_name'])) $line .= $th_h.__('item name', 'usces').$th_f; |
| 1555 |
if(isset($_REQUEST['check']['sku_name'])) $line .= $th_h.__('SKU display name ', 'usces').$th_f; |
| 1556 |
if(isset($_REQUEST['check']['options'])) $line .= $th_h.__('options for items', 'usces').$th_f; |
| 1557 |
$line .= $th_h.__('Quantity', 'usces').$th_f; |
| 1558 |
$line .= $th_h.__('Unit price', 'usces').$th_f; |
| 1559 |
if(isset($_REQUEST['check']['unit'])) $line .= $th_h.__('unit', 'usces').$th_f; |
| 1560 |
$line .= apply_filters( 'usces_filter_chk_pro_label_detail', NULL, $usces_opt_order, $rows); |
| 1561 |
$line .= $tr_f.$lf; |
| 1562 |
//========================================================================== |
| 1563 |
foreach((array)$rows as $array) { |
| 1564 |
$order_id = $array['ID']; |
| 1565 |
$query = $wpdb->prepare("SELECT * FROM $tableName WHERE ID = %d", $order_id); |
| 1566 |
$data = $wpdb->get_row( $query, ARRAY_A ); |
| 1567 |
//$cart = stripslashes_deep(unserialize($data['order_cart'])); |
| 1568 |
$cart = unserialize($data['order_cart']); |
| 1569 |
//if(!empty($data)) { |
| 1570 |
// $data = stripslashes_deep($data); |
| 1571 |
//} |
| 1572 |
for($i = 0; $i < count($cart); $i++) { |
| 1573 |
$cart_row = $cart[$i]; |
| 1574 |
$post_id = $cart_row['post_id']; |
| 1575 |
$sku = urldecode($cart_row['sku']); |
| 1576 |
|
| 1577 |
$line .= $tr_h; |
| 1578 |
$line .= $td_h1.$order_id.$td_f; |
| 1579 |
$line .= $td_h.$array['deco_id'].$td_f; |
| 1580 |
if(isset($_REQUEST['check']['date'])) $line .= $td_h.$array['date'].$td_f; |
| 1581 |
if(isset($_REQUEST['check']['mem_id'])) $line .= $td_h.$array['mem_id'].$td_f; |
| 1582 |
if(isset($_REQUEST['check']['name'])) $line .= $td_h.usces_entity_decode($data['order_name1'].$data['order_name2'], $ext).$td_f; |
| 1583 |
if(isset($_REQUEST['check']['delivery_method'])) { |
| 1584 |
$delivery_method = ''; |
| 1585 |
if(strtoupper($data['order_delivery_method']) == '#NONE#') { |
| 1586 |
$delivery_method = __('No preference', 'usces'); |
| 1587 |
} else { |
| 1588 |
foreach((array)$usces->options['delivery_method'] as $dkey => $delivery) { |
| 1589 |
if($delivery['id'] == $data['order_delivery_method']) { |
| 1590 |
$delivery_method = $delivery['name']; |
| 1591 |
break; |
| 1592 |
} |
| 1593 |
} |
| 1594 |
} |
| 1595 |
$line .= $td_h.$delivery_method.$td_f; |
| 1596 |
} |
| 1597 |
if(isset($_REQUEST['check']['shipping_date'])) $line .= $td_h.$data['order_modified'].$td_f; |
| 1598 |
$line .= apply_filters( 'usces_filter_chk_pro_data_head', NULL, $usces_opt_order, $data, $cart_row); |
| 1599 |
|
| 1600 |
$line .= $td_h.$usces->getItemCode($post_id).$td_f; |
| 1601 |
$line .= $td_h.$sku.$td_f; |
| 1602 |
if(isset($_REQUEST['check']['item_name'])) $line .= $td_h.usces_entity_decode($usces->getItemName($post_id), $ext).$td_f; |
| 1603 |
if(isset($_REQUEST['check']['sku_name'])) $line .= $td_h.usces_entity_decode($usces->getItemSkuDisp($post_id, $sku), $ext).$td_f; |
| 1604 |
if(isset($_REQUEST['check']['options'])) { |
| 1605 |
$options = $cart_row['options']; |
| 1606 |
$optstr = ''; |
| 1607 |
if(is_array($options) && count($options) > 0) { |
| 1608 |
foreach((array)$options as $key => $value) { |
| 1609 |
if(!empty($key)) { |
| 1610 |
if(is_array($value)) { |
| 1611 |
foreach($value as $v) { |
| 1612 |
$optstr .= usces_entity_decode(urldecode($key), $ext).$sp; |
| 1613 |
foreach($value as $v) { |
| 1614 |
$optstr .= usces_entity_decode(urldecode($v), $ext).$nb; |
| 1615 |
} |
| 1616 |
} |
| 1617 |
} else { |
| 1618 |
//$optstr .= usces_entity_decode($key, $ext).$sp.usces_entity_decode($value, $ext).$nb; |
| 1619 |
$optstr .= usces_entity_decode(urldecode($key).$sp.urldecode($value), $ext).$nb; |
| 1620 |
} |
| 1621 |
} |
| 1622 |
} |
| 1623 |
} |
| 1624 |
$line .= $td_h.$optstr.$td_f; |
| 1625 |
} |
| 1626 |
$line .= $td_h.$cart_row['quantity'].$td_f; |
| 1627 |
$line .= $td_h.usces_crform($cart_row['price'], false, false, 'return', false).$td_f; |
| 1628 |
if(isset($_REQUEST['check']['unit'])) $line .= $td_h.usces_entity_decode($usces->getItemSkuUnit($post_id, $sku), $ext).$td_f; |
| 1629 |
$line .= apply_filters( 'usces_filter_chk_pro_data_detail', NULL, $usces_opt_order, $data, $cart_row); |
| 1630 |
$line .= $tr_f.$lf; |
| 1631 |
} |
| 1632 |
} |
| 1633 |
$line .= $table_f.$lf; |
| 1634 |
//========================================================================== |
| 1635 |
|
| 1636 |
if($ext == 'xls') { |
| 1637 |
header("Content-Type: application/vnd.ms-excel; charset=Shift-JIS"); |
| 1638 |
} elseif($ext == 'csv') { |
| 1639 |
header("Content-Type: application/octet-stream"); |
| 1640 |
} |
| 1641 |
header("Content-Disposition: attachment; filename=usces_product_list.".$ext); |
| 1642 |
mb_http_output('pass'); |
| 1643 |
print(mb_convert_encoding($line, "SJIS-win", "UTF-8")); |
| 1644 |
exit(); |
| 1645 |
} |
| 1646 |
|
| 1647 |
// order list download |
| 1648 |
function usces_download_order_list() { |
| 1649 |
require_once( USCES_PLUGIN_DIR . "/classes/orderList.class.php" ); |
| 1650 |
global $wpdb, $usces; |
| 1651 |
//20110411ysk start |
| 1652 |
global $usces_settings; |
| 1653 |
//20110411ysk end |
| 1654 |
|
| 1655 |
$ext = $_REQUEST['ftype']; |
| 1656 |
/* if($ext == 'xls') {//HTML |
| 1657 |
$table_h = "<table>"; |
| 1658 |
$table_f = "</table>"; |
| 1659 |
$tr_h = "<tr>"; |
| 1660 |
$tr_f = "</tr>"; |
| 1661 |
$th_h1 = "<th>"; |
| 1662 |
$th_h = "<th>"; |
| 1663 |
$th_f = "</th>"; |
| 1664 |
$td_h1 = "<td>"; |
| 1665 |
$td_h = "<td>"; |
| 1666 |
$td_f = "</td>"; |
| 1667 |
$sp = ":"; |
| 1668 |
$lf = "\n"; |
| 1669 |
*/ if($ext == 'xls') {//TSV |
| 1670 |
$table_h = ""; |
| 1671 |
$table_f = ""; |
| 1672 |
$tr_h = ""; |
| 1673 |
$tr_f = ""; |
| 1674 |
$th_h1 = '"'; |
| 1675 |
$th_h = "\t".'"'; |
| 1676 |
$th_f = '"'; |
| 1677 |
$td_h1 = '"'; |
| 1678 |
$td_h = "\t".'"'; |
| 1679 |
$td_f = '"'; |
| 1680 |
$sp = ":"; |
| 1681 |
$lf = "\n"; |
| 1682 |
} elseif($ext == 'csv') {//CSV |
| 1683 |
$table_h = ""; |
| 1684 |
$table_f = ""; |
| 1685 |
$tr_h = ""; |
| 1686 |
$tr_f = ""; |
| 1687 |
//20110201ysk start |
| 1688 |
//$th_h1 = ""; |
| 1689 |
$th_h1 = '"'; |
| 1690 |
//$th_h = ","; |
| 1691 |
$th_h = ',"'; |
| 1692 |
//$th_f = ""; |
| 1693 |
$th_f = '"'; |
| 1694 |
//$td_h1 = ""; |
| 1695 |
$td_h1 = '"'; |
| 1696 |
//$td_h = ","; |
| 1697 |
$td_h = ',"'; |
| 1698 |
//$td_f = ""; |
| 1699 |
$td_f = '"'; |
| 1700 |
//20110201ysk end |
| 1701 |
$sp = ":"; |
| 1702 |
$lf = "\n"; |
| 1703 |
} else { |
| 1704 |
exit(); |
| 1705 |
} |
| 1706 |
$csod_meta = usces_has_custom_field_meta('order'); |
| 1707 |
$cscs_meta = usces_has_custom_field_meta('customer'); |
| 1708 |
$csde_meta = usces_has_custom_field_meta('delivery'); |
| 1709 |
//20110411ysk start |
| 1710 |
$applyform = usces_get_apply_addressform($usces->options['system']['addressform']); |
| 1711 |
//20110411ysk end |
| 1712 |
|
| 1713 |
//========================================================================== |
| 1714 |
$usces_opt_order = get_option('usces_opt_order'); |
| 1715 |
if(!is_array($usces_opt_order)){ |
| 1716 |
$usces_opt_order = array(); |
| 1717 |
} |
| 1718 |
$usces_opt_order['ftype_ord'] = $ext; |
| 1719 |
$chk_ord = array(); |
| 1720 |
$chk_ord['ID'] = 1; |
| 1721 |
$chk_ord['deco_id'] = 1; |
| 1722 |
$chk_ord['date'] = 1; |
| 1723 |
$chk_ord['mem_id'] = (isset($_REQUEST['check']['mem_id'])) ? 1 : 0; |
| 1724 |
$chk_ord['email'] = (isset($_REQUEST['check']['email'])) ? 1 : 0; |
| 1725 |
if(!empty($cscs_meta)) { |
| 1726 |
foreach($cscs_meta as $key => $entry) { |
| 1727 |
if($entry['position'] == 'name_pre') { |
| 1728 |
$name = $entry['name']; |
| 1729 |
//20110208ysk start |
| 1730 |
$cscs_key = 'cscs_'.$key; |
| 1731 |
//$chk_ord[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; |
| 1732 |
$chk_ord[$cscs_key] = (isset($_REQUEST['check'][$cscs_key])) ? 1 : 0; |
| 1733 |
//20110208ysk end |
| 1734 |
} |
| 1735 |
} |
| 1736 |
} |
| 1737 |
$chk_ord['name'] = 1; |
| 1738 |
//20110411ysk start |
| 1739 |
if($applyform == 'JP') { |
| 1740 |
$chk_ord['kana'] = (isset($_REQUEST['check']['kana'])) ? 1 : 0; |
| 1741 |
} |
| 1742 |
//20110411ysk end |
| 1743 |
if(!empty($cscs_meta)) { |
| 1744 |
foreach($cscs_meta as $key => $entry) { |
| 1745 |
if($entry['position'] == 'name_after') { |
| 1746 |
$name = $entry['name']; |
| 1747 |
//20110208ysk start |
| 1748 |
$cscs_key = 'cscs_'.$key; |
| 1749 |
//$chk_ord[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; |
| 1750 |
$chk_ord[$cscs_key] = (isset($_REQUEST['check'][$cscs_key])) ? 1 : 0; |
| 1751 |
//20110208ysk end |
| 1752 |
} |
| 1753 |
} |
| 1754 |
} |
| 1755 |
$chk_ord['zip'] = (isset($_REQUEST['check']['zip'])) ? 1 : 0; |
| 1756 |
//20110411ysk start |
| 1757 |
$chk_ord['country'] = (isset($_REQUEST['check']['country'])) ? 1 : 0; |
| 1758 |
//20110411ysk end |
| 1759 |
$chk_ord['pref'] = (isset($_REQUEST['check']['pref'])) ? 1 : 0; |
| 1760 |
$chk_ord['address1'] = (isset($_REQUEST['check']['address1'])) ? 1 : 0; |
| 1761 |
$chk_ord['address2'] = (isset($_REQUEST['check']['address2'])) ? 1 : 0; |
| 1762 |
$chk_ord['address3'] = (isset($_REQUEST['check']['address3'])) ? 1 : 0; |
| 1763 |
$chk_ord['tel'] = (isset($_REQUEST['check']['tel'])) ? 1 : 0; |
| 1764 |
$chk_ord['fax'] = (isset($_REQUEST['check']['fax'])) ? 1 : 0; |
| 1765 |
if(!empty($cscs_meta)) { |
| 1766 |
foreach($cscs_meta as $key => $entry) { |
| 1767 |
if($entry['position'] == 'fax_after') { |
| 1768 |
$name = $entry['name']; |
| 1769 |
//20110208ysk start |
| 1770 |
$cscs_key = 'cscs_'.$key; |
| 1771 |
//$chk_ord[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; |
| 1772 |
$chk_ord[$cscs_key] = (isset($_REQUEST['check'][$cscs_key])) ? 1 : 0; |
| 1773 |
//20110208ysk end |
| 1774 |
} |
| 1775 |
} |
| 1776 |
} |
| 1777 |
//-------------------------------------------------------------------------- |
| 1778 |
if(!empty($csde_meta)) { |
| 1779 |
foreach($csde_meta as $key => $entry) { |
| 1780 |
if($entry['position'] == 'name_pre') { |
| 1781 |
$name = $entry['name']; |
| 1782 |
//20110208ysk start |
| 1783 |
$csde_key = 'csde_'.$key; |
| 1784 |
//$chk_ord[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; |
| 1785 |
$chk_ord[$csde_key] = (isset($_REQUEST['check'][$csde_key])) ? 1 : 0; |
| 1786 |
//20110208ysk end |
| 1787 |
} |
| 1788 |
} |
| 1789 |
} |
| 1790 |
$chk_ord['delivery_name'] = (isset($_REQUEST['check']['delivery_name'])) ? 1 : 0; |
| 1791 |
//20110411ysk start |
| 1792 |
if($applyform == 'JP') { |
| 1793 |
$chk_ord['delivery_kana'] = (isset($_REQUEST['check']['delivery_kana'])) ? 1 : 0; |
| 1794 |
} |
| 1795 |
//20110411ysk end |
| 1796 |
if(!empty($csde_meta)) { |
| 1797 |
foreach($csde_meta as $key => $entry) { |
| 1798 |
if($entry['position'] == 'name_after') { |
| 1799 |
$name = $entry['name']; |
| 1800 |
//20110208ysk start |
| 1801 |
$csde_key = 'csde_'.$key; |
| 1802 |
//$chk_ord[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; |
| 1803 |
$chk_ord[$csde_key] = (isset($_REQUEST['check'][$csde_key])) ? 1 : 0; |
| 1804 |
//20110208ysk end |
| 1805 |
} |
| 1806 |
} |
| 1807 |
} |
| 1808 |
$chk_ord['delivery_zip'] = (isset($_REQUEST['check']['delivery_zip'])) ? 1 : 0; |
| 1809 |
//20110411ysk start |
| 1810 |
$chk_ord['delivery_country'] = (isset($_REQUEST['check']['delivery_country'])) ? 1 : 0; |
| 1811 |
//20110411ysk end |
| 1812 |
$chk_ord['delivery_pref'] = (isset($_REQUEST['check']['delivery_pref'])) ? 1 : 0; |
| 1813 |
$chk_ord['delivery_address1'] = (isset($_REQUEST['check']['delivery_address1'])) ? 1 : 0; |
| 1814 |
$chk_ord['delivery_address2'] = (isset($_REQUEST['check']['delivery_address2'])) ? 1 : 0; |
| 1815 |
$chk_ord['delivery_address3'] = (isset($_REQUEST['check']['delivery_address3'])) ? 1 : 0; |
| 1816 |
$chk_ord['delivery_tel'] = (isset($_REQUEST['check']['delivery_tel'])) ? 1 : 0; |
| 1817 |
$chk_ord['delivery_fax'] = (isset($_REQUEST['check']['delivery_fax'])) ? 1 : 0; |
| 1818 |
if(!empty($csde_meta)) { |
| 1819 |
foreach($csde_meta as $key => $entry) { |
| 1820 |
if($entry['position'] == 'fax_after') { |
| 1821 |
$name = $entry['name']; |
| 1822 |
//20110208ysk start |
| 1823 |
$csde_key = 'csde_'.$key; |
| 1824 |
//$chk_ord[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; |
| 1825 |
$chk_ord[$csde_key] = (isset($_REQUEST['check'][$csde_key])) ? 1 : 0; |
| 1826 |
//20110208ysk end |
| 1827 |
} |
| 1828 |
} |
| 1829 |
} |
| 1830 |
//-------------------------------------------------------------------------- |
| 1831 |
$chk_ord['shipping_date'] = (isset($_REQUEST['check']['shipping_date'])) ? 1 : 0; |
| 1832 |
$chk_ord['peyment_method'] = (isset($_REQUEST['check']['peyment_method'])) ? 1 : 0; |
| 1833 |
$chk_ord['delivery_method'] = (isset($_REQUEST['check']['delivery_method'])) ? 1 : 0; |
| 1834 |
//20101208ysk start |
| 1835 |
$chk_ord['delivery_date'] = (isset($_REQUEST['check']['delivery_date'])) ? 1 : 0; |
| 1836 |
//20101208ysk end |
| 1837 |
$chk_ord['delivery_time'] = (isset($_REQUEST['check']['delivery_time'])) ? 1 : 0; |
| 1838 |
$chk_ord['delidue_date'] = (isset($_REQUEST['check']['delidue_date'])) ? 1 : 0; |
| 1839 |
$chk_ord['status'] = (isset($_REQUEST['check']['status'])) ? 1 : 0; |
| 1840 |
$chk_ord['total_amount'] = 1; |
| 1841 |
$chk_ord['getpoint'] = (isset($_REQUEST['check']['getpoint'])) ? 1 : 0; |
| 1842 |
$chk_ord['usedpoint'] = (isset($_REQUEST['check']['usedpoint'])) ? 1 : 0; |
| 1843 |
$chk_ord['discount'] = 1; |
| 1844 |
$chk_ord['shipping_charge'] = 1; |
| 1845 |
$chk_ord['cod_fee'] = 1; |
| 1846 |
$chk_ord['tax'] = 1; |
| 1847 |
$chk_ord['note'] = (isset($_REQUEST['check']['note'])) ? 1 : 0; |
| 1848 |
if(!empty($csod_meta)) { |
| 1849 |
foreach($csod_meta as $key => $entry) { |
| 1850 |
$name = $entry['name']; |
| 1851 |
//20110208ysk start |
| 1852 |
$csod_key = 'csod_'.$key; |
| 1853 |
//$chk_ord[$name] = (isset($_REQUEST['check'][$name])) ? 1 : 0; |
| 1854 |
$chk_ord[$csod_key] = (isset($_REQUEST['check'][$csod_key])) ? 1 : 0; |
| 1855 |
//20110208ysk end |
| 1856 |
} |
| 1857 |
} |
| 1858 |
$usces_opt_order['chk_ord'] = apply_filters( 'usces_filter_chk_ord', $chk_ord ); |
| 1859 |
update_option('usces_opt_order', $usces_opt_order); |
| 1860 |
//========================================================================== |
| 1861 |
|
| 1862 |
if(isset($_REQUEST['check']['status'])) { |
| 1863 |
//$usces_management_status = get_option('usces_management_status'); |
| 1864 |
$usces_management_status = apply_filters( 'usces_filter_management_status', get_option('usces_management_status') );//0000530 |
| 1865 |
$usces_management_status['new'] = __('new order', 'usces'); |
| 1866 |
} |
| 1867 |
|
| 1868 |
$_REQUEST['searchIn'] = "searchIn"; |
| 1869 |
$tableName = $wpdb->prefix."usces_order"; |
| 1870 |
$arr_column = array( |
| 1871 |
__('ID', 'usces') => 'ID', |
| 1872 |
__('Order number', 'usces') => 'deco_id', |
| 1873 |
__('date', 'usces') => 'date', |
| 1874 |
__('membership number', 'usces') => 'mem_id', |
| 1875 |
__('name', 'usces') => 'name', |
| 1876 |
__('Region', 'usces') => 'pref', |
| 1877 |
__('shipping option', 'usces') => 'delivery_method', |
| 1878 |
__('Amount', 'usces') => 'total_price', |
| 1879 |
__('payment method', 'usces') => 'payment_name', |
| 1880 |
__('transfer statement', 'usces') => 'receipt_status', |
| 1881 |
__('Processing', 'usces') => 'order_status', |
| 1882 |
__('shpping date', 'usces') => 'order_modified'); |
| 1883 |
$DT = new dataList($tableName, $arr_column); |
| 1884 |
//20101202ysk start |
| 1885 |
$DT->pageLimit = 'off'; |
| 1886 |
//20101202ysk end |
| 1887 |
$res = $DT->MakeTable(); |
| 1888 |
$rows = $DT->rows; |
| 1889 |
|
| 1890 |
//========================================================================== |
| 1891 |
$line = $table_h; |
| 1892 |
$line .= $tr_h; |
| 1893 |
$line .= $th_h1.__('ID', 'usces').$th_f; |
| 1894 |
$line .= $th_h.__('Order number', 'usces').$th_f; |
| 1895 |
$line .= $th_h.__('order date', 'usces').$th_f; |
| 1896 |
if(isset($_REQUEST['check']['mem_id'])) $line .= $th_h.__('membership number', 'usces').$th_f; |
| 1897 |
if(isset($_REQUEST['check']['email'])) $line .= $th_h.__('e-mail', 'usces').$th_f; |
| 1898 |
if(!empty($cscs_meta)) { |
| 1899 |
foreach($cscs_meta as $key => $entry) { |
| 1900 |
if($entry['position'] == 'name_pre') { |
| 1901 |
$name = $entry['name']; |
| 1902 |
//20110208ysk start |
| 1903 |
$cscs_key = 'cscs_'.$key; |
| 1904 |
//if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 1905 |
if(isset($_REQUEST['check'][$cscs_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 1906 |
//20110208ysk end |
| 1907 |
} |
| 1908 |
} |
| 1909 |
} |
| 1910 |
$line .= $th_h.__('name', 'usces').$th_f; |
| 1911 |
//20110411ysk start |
| 1912 |
if($applyform == 'JP') { |
| 1913 |
if(isset($_REQUEST['check']['kana'])) $line .= $th_h.__('furigana', 'usces').$th_f; |
| 1914 |
} |
| 1915 |
//20110411ysk end |
| 1916 |
if(!empty($cscs_meta)) { |
| 1917 |
foreach($cscs_meta as $key => $entry) { |
| 1918 |
if($entry['position'] == 'name_after') { |
| 1919 |
$name = $entry['name']; |
| 1920 |
//20110208ysk start |
| 1921 |
$cscs_key = 'cscs_'.$key; |
| 1922 |
//if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 1923 |
if(isset($_REQUEST['check'][$cscs_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 1924 |
//20110208ysk end |
| 1925 |
} |
| 1926 |
} |
| 1927 |
} |
| 1928 |
//20110411ysk start |
| 1929 |
switch($applyform) { |
| 1930 |
case 'JP': |
| 1931 |
if(isset($_REQUEST['check']['zip'])) $line .= $th_h.__('Zip/Postal Code', 'usces').$th_f; |
| 1932 |
if(isset($_REQUEST['check']['country'])) $line .= $th_h.__('Country', 'usces').$th_f; |
| 1933 |
if(isset($_REQUEST['check']['pref'])) $line .= $th_h.__('Province', 'usces').$th_f; |
| 1934 |
if(isset($_REQUEST['check']['address1'])) $line .= $th_h.__('city', 'usces').$th_f; |
| 1935 |
if(isset($_REQUEST['check']['address2'])) $line .= $th_h.__('numbers', 'usces').$th_f; |
| 1936 |
if(isset($_REQUEST['check']['address3'])) $line .= $th_h.__('building name', 'usces').$th_f; |
| 1937 |
if(isset($_REQUEST['check']['tel'])) $line .= $th_h.__('Phone number', 'usces').$th_f; |
| 1938 |
if(isset($_REQUEST['check']['fax'])) $line .= $th_h.__('FAX number', 'usces').$th_f; |
| 1939 |
break; |
| 1940 |
case 'US': |
| 1941 |
default: |
| 1942 |
if(isset($_REQUEST['check']['address2'])) $line .= $th_h.__('Address Line1', 'usces').$th_f; |
| 1943 |
if(isset($_REQUEST['check']['address3'])) $line .= $th_h.__('Address Line2', 'usces').$th_f; |
| 1944 |
if(isset($_REQUEST['check']['address1'])) $line .= $th_h.__('city', 'usces').$th_f; |
| 1945 |
if(isset($_REQUEST['check']['pref'])) $line .= $th_h.__('State', 'usces').$th_f; |
| 1946 |
if(isset($_REQUEST['check']['country'])) $line .= $th_h.__('Country', 'usces').$th_f; |
| 1947 |
if(isset($_REQUEST['check']['zip'])) $line .= $th_h.__('Zip', 'usces').$th_f; |
| 1948 |
if(isset($_REQUEST['check']['tel'])) $line .= $th_h.__('Phone number', 'usces').$th_f; |
| 1949 |
if(isset($_REQUEST['check']['fax'])) $line .= $th_h.__('FAX number', 'usces').$th_f; |
| 1950 |
break; |
| 1951 |
} |
| 1952 |
//20110411ysk end |
| 1953 |
if(!empty($cscs_meta)) { |
| 1954 |
foreach($cscs_meta as $key => $entry) { |
| 1955 |
if($entry['position'] == 'fax_after') { |
| 1956 |
$name = $entry['name']; |
| 1957 |
//20110208ysk start |
| 1958 |
$cscs_key = 'cscs_'.$key; |
| 1959 |
//if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 1960 |
if(isset($_REQUEST['check'][$cscs_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 1961 |
//20110208ysk end |
| 1962 |
} |
| 1963 |
} |
| 1964 |
} |
| 1965 |
$line .= apply_filters( 'usces_filter_chk_ord_label_customer', NULL, $usces_opt_order, $rows ); |
| 1966 |
|
| 1967 |
//-------------------------------------------------------------------------- |
| 1968 |
if(!empty($csde_meta)) { |
| 1969 |
foreach($csde_meta as $key => $entry) { |
| 1970 |
if($entry['position'] == 'name_pre') { |
| 1971 |
$name = $entry['name']; |
| 1972 |
//20110208ysk start |
| 1973 |
$csde_key = 'csde_'.$key; |
| 1974 |
//if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 1975 |
if(isset($_REQUEST['check'][$csde_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 1976 |
//20110208ysk end |
| 1977 |
} |
| 1978 |
} |
| 1979 |
} |
| 1980 |
if(isset($_REQUEST['check']['delivery_name'])) $line .= $th_h.__('Shipping Name', 'usces').$th_f; |
| 1981 |
//20110411ysk start |
| 1982 |
if($applyform == 'JP') { |
| 1983 |
if(isset($_REQUEST['check']['delivery_kana'])) $line .= $th_h.__('Shipping Furigana', 'usces').$th_f; |
| 1984 |
} |
| 1985 |
//20110411ysk end |
| 1986 |
if(!empty($csde_meta)) { |
| 1987 |
foreach($csde_meta as $key => $entry) { |
| 1988 |
if($entry['position'] == 'name_after') { |
| 1989 |
$name = $entry['name']; |
| 1990 |
//20110208ysk start |
| 1991 |
$csde_key = 'csde_'.$key; |
| 1992 |
//if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 1993 |
if(isset($_REQUEST['check'][$csde_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 1994 |
//20110208ysk end |
| 1995 |
} |
| 1996 |
} |
| 1997 |
} |
| 1998 |
//20110411ysk start |
| 1999 |
switch($applyform) { |
| 2000 |
case 'JP': |
| 2001 |
if(isset($_REQUEST['check']['delivery_zip'])) $line .= $th_h.__('Shipping Zip', 'usces').$th_f; |
| 2002 |
if(isset($_REQUEST['check']['delivery_country'])) $line .= $th_h.__('Shipping Country', 'usces').$th_f; |
| 2003 |
if(isset($_REQUEST['check']['delivery_pref'])) $line .= $th_h.__('Shipping State', 'usces').$th_f; |
| 2004 |
if(isset($_REQUEST['check']['delivery_address1'])) $line .= $th_h.__('Shipping City', 'usces').$th_f; |
| 2005 |
if(isset($_REQUEST['check']['delivery_address2'])) $line .= $th_h.__('Shipping Address1', 'usces').$th_f; |
| 2006 |
if(isset($_REQUEST['check']['delivery_address3'])) $line .= $th_h.__('Shipping Address2', 'usces').$th_f; |
| 2007 |
if(isset($_REQUEST['check']['delivery_tel'])) $line .= $th_h.__('Shipping Phone', 'usces').$th_f; |
| 2008 |
if(isset($_REQUEST['check']['delivery_fax'])) $line .= $th_h.__('Shipping FAX', 'usces').$th_f; |
| 2009 |
break; |
| 2010 |
case 'US': |
| 2011 |
default: |
| 2012 |
if(isset($_REQUEST['check']['delivery_address2'])) $line .= $th_h.__('Shipping Address1', 'usces').$th_f; |
| 2013 |
if(isset($_REQUEST['check']['delivery_address3'])) $line .= $th_h.__('Shipping Address2', 'usces').$th_f; |
| 2014 |
if(isset($_REQUEST['check']['delivery_address1'])) $line .= $th_h.__('Shipping City', 'usces').$th_f; |
| 2015 |
if(isset($_REQUEST['check']['delivery_pref'])) $line .= $th_h.__('Shipping State', 'usces').$th_f; |
| 2016 |
if(isset($_REQUEST['check']['delivery_country'])) $line .= $th_h.__('Shipping Country', 'usces').$th_f; |
| 2017 |
if(isset($_REQUEST['check']['delivery_zip'])) $line .= $th_h.__('Shipping Zip', 'usces').$th_f; |
| 2018 |
if(isset($_REQUEST['check']['delivery_tel'])) $line .= $th_h.__('Shipping Phone', 'usces').$th_f; |
| 2019 |
if(isset($_REQUEST['check']['delivery_fax'])) $line .= $th_h.__('Shipping FAX', 'usces').$th_f; |
| 2020 |
break; |
| 2021 |
} |
| 2022 |
//20110411ysk end |
| 2023 |
if(!empty($csde_meta)) { |
| 2024 |
foreach($csde_meta as $key => $entry) { |
| 2025 |
if($entry['position'] == 'fax_after') { |
| 2026 |
$name = $entry['name']; |
| 2027 |
//20110208ysk start |
| 2028 |
$csde_key = 'csde_'.$key; |
| 2029 |
//if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 2030 |
if(isset($_REQUEST['check'][$csde_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 2031 |
//20110208ysk end |
| 2032 |
} |
| 2033 |
} |
| 2034 |
} |
| 2035 |
$line .= apply_filters( 'usces_filter_chk_ord_label_delivery', NULL, $usces_opt_order, $rows ); |
| 2036 |
//-------------------------------------------------------------------------- |
| 2037 |
if(isset($_REQUEST['check']['shipping_date'])) $line .= $th_h.__('shpping date', 'usces').$th_f; |
| 2038 |
if(isset($_REQUEST['check']['peyment_method'])) $line .= $th_h.__('payment method', 'usces').$th_f; |
| 2039 |
if(isset($_REQUEST['check']['delivery_method'])) $line .= $th_h.__('shipping option', 'usces').$th_f; |
| 2040 |
//20101208ysk start |
| 2041 |
if(isset($_REQUEST['check']['delivery_date'])) $line .= $th_h.__('Delivery date', 'usces').$th_f; |
| 2042 |
//20101208ysk end |
| 2043 |
if(isset($_REQUEST['check']['delivery_time'])) $line .= $th_h.__('delivery time', 'usces').$th_f; |
| 2044 |
if(isset($_REQUEST['check']['delidue_date'])) $line .= $th_h.__('Shipping date', 'usces').$th_f; |
| 2045 |
if(isset($_REQUEST['check']['status'])) $line .= $th_h.__('Status', 'usces').$th_f; |
| 2046 |
$line .= $th_h.__('Total Amount', 'usces').$th_f; |
| 2047 |
if(isset($_REQUEST['check']['getpoint'])) $line .= $th_h.__('granted points', 'usces').$th_f; |
| 2048 |
if(isset($_REQUEST['check']['usedpoint'])) $line .= $th_h.__('Used points', 'usces').$th_f; |
| 2049 |
$line .= $th_h.__('Disnount', 'usces').$th_f; |
| 2050 |
$line .= $th_h.__('Shipping', 'usces').$th_f; |
| 2051 |
$line .= $th_h.apply_filters('usces_filter_cod_label', __('COD fee', 'usces')).$th_f; |
| 2052 |
$line .= $th_h.__('consumption tax', 'usces').$th_f; |
| 2053 |
if(isset($_REQUEST['check']['note'])) $line .= $th_h.__('Notes', 'usces').$th_f; |
| 2054 |
if(!empty($csod_meta)) { |
| 2055 |
foreach($csod_meta as $key => $entry) { |
| 2056 |
$name = $entry['name']; |
| 2057 |
//20110208ysk start |
| 2058 |
$csod_key = 'csod_'.$key; |
| 2059 |
//if(isset($_REQUEST['check'][$name])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 2060 |
if(isset($_REQUEST['check'][$csod_key])) $line .= $th_h.usces_entity_decode($name, $ext).$th_f; |
| 2061 |
//20110208ysk end |
| 2062 |
} |
| 2063 |
} |
| 2064 |
$line .= apply_filters( 'usces_filter_chk_ord_label_order', NULL, $usces_opt_order, $rows ); |
| 2065 |
$line .= $tr_f.$lf; |
| 2066 |
//========================================================================== |
| 2067 |
foreach((array)$rows as $array) { |
| 2068 |
$order_id = $array['ID']; |
| 2069 |
$query = $wpdb->prepare("SELECT * FROM $tableName WHERE ID = %d", $order_id); |
| 2070 |
$data = $wpdb->get_row( $query, ARRAY_A ); |
| 2071 |
//$deli = stripslashes_deep(unserialize($data['order_delivery'])); |
| 2072 |
$deli = unserialize($data['order_delivery']); |
| 2073 |
//if(!empty($data)) { |
| 2074 |
// $data = stripslashes_deep($data); |
| 2075 |
//} |
| 2076 |
|
| 2077 |
$line .= $tr_h; |
| 2078 |
$line .= $td_h1.$order_id.$td_f; |
| 2079 |
$line .= $td_h.usces_get_deco_order_id( $order_id ).$td_f; |
| 2080 |
$line .= $td_h.$data['order_date'].$td_f; |
| 2081 |
if(isset($_REQUEST['check']['mem_id'])) $line .= $td_h.$data['mem_id'].$td_f; |
| 2082 |
if(isset($_REQUEST['check']['email'])) $line .= $td_h.usces_entity_decode($data['order_email'], $ext).$td_f; |
| 2083 |
if(!empty($cscs_meta)) { |
| 2084 |
foreach($cscs_meta as $key => $entry) { |
| 2085 |
if($entry['position'] == 'name_pre') { |
| 2086 |
$name = $entry['name']; |
| 2087 |
$cscs_key = 'cscs_'.$key; |
| 2088 |
//20110208ysk start |
| 2089 |
//if(isset($_REQUEST['check'][$name])) { |
| 2090 |
if(isset($_REQUEST['check'][$cscs_key])) { |
| 2091 |
//20110208ysk end |
| 2092 |
$value = maybe_unserialize($usces->get_order_meta_value($cscs_key, $order_id)); |
| 2093 |
if(empty($value)) { |
| 2094 |
$value = ''; |
| 2095 |
} elseif(is_array($value)) { |
| 2096 |
$concatval = ''; |
| 2097 |
$c = ''; |
| 2098 |
foreach($value as $v) { |
| 2099 |
$concatval .= $c.$v; |
| 2100 |
$c = ' '; |
| 2101 |
} |
| 2102 |
$value = $concatval; |
| 2103 |
} |
| 2104 |
$line .= $td_h.usces_entity_decode($value, $ext).$td_f; |
| 2105 |
} |
| 2106 |
} |
| 2107 |
} |
| 2108 |
} |
| 2109 |
//20110411ysk start |
| 2110 |
switch($applyform) { |
| 2111 |
case 'JP': |
| 2112 |
$line .= $td_h.usces_entity_decode($data['order_name1'].' '.$data['order_name2'], $ext).$td_f; |
| 2113 |
if(isset($_REQUEST['check']['kana'])) $line .= $td_h.usces_entity_decode($data['order_name3'].' '.$data['order_name4'], $ext).$td_f; |
| 2114 |
break; |
| 2115 |
case 'US': |
| 2116 |
default: |
| 2117 |
$line .= $td_h.usces_entity_decode($data['order_name2'].' '.$data['order_name1'], $ext).$td_f; |
| 2118 |
break; |
| 2119 |
} |
| 2120 |
//20110411ysk end |
| 2121 |
if(!empty($cscs_meta)) { |
| 2122 |
foreach($cscs_meta as $key => $entry) { |
| 2123 |
if($entry['position'] == 'name_after') { |
| 2124 |
$name = $entry['name']; |
| 2125 |
$cscs_key = 'cscs_'.$key; |
| 2126 |
//20110208ysk start |
| 2127 |
//if(isset($_REQUEST['check'][$name])) { |
| 2128 |
if(isset($_REQUEST['check'][$cscs_key])) { |
| 2129 |
//20110208ysk end |
| 2130 |
$value = maybe_unserialize($usces->get_order_meta_value($cscs_key, $order_id)); |
| 2131 |
if(empty($value)) { |
| 2132 |
$value = ''; |
| 2133 |
} elseif(is_array($value)) { |
| 2134 |
$concatval = ''; |
| 2135 |
$c = ''; |
| 2136 |
foreach($value as $v) { |
| 2137 |
$concatval .= $c.$v; |
| 2138 |
$c = ' '; |
| 2139 |
} |
| 2140 |
$value = $concatval; |
| 2141 |
} |
| 2142 |
$line .= $td_h.usces_entity_decode($value, $ext).$td_f; |
| 2143 |
} |
| 2144 |
} |
| 2145 |
} |
| 2146 |
} |
| 2147 |
//20110411ysk start |
| 2148 |
$address_info = ''; |
| 2149 |
switch($applyform) { |
| 2150 |
case 'JP': |
| 2151 |
if(isset($_REQUEST['check']['zip'])) $address_info .= $td_h.usces_entity_decode($data['order_zip'], $ext).$td_f; |
| 2152 |
if(isset($_REQUEST['check']['country'])) $address_info .= $td_h.$usces_settings['country'][$usces->get_order_meta_value('customer_country', $order_id)].$td_f; |
| 2153 |
if(isset($_REQUEST['check']['pref'])) $address_info .= $td_h.usces_entity_decode($data['order_pref'], $ext).$td_f; |
| 2154 |
if(isset($_REQUEST['check']['address1'])) $address_info .= $td_h.usces_entity_decode($data['order_address1'], $ext).$td_f; |
| 2155 |
if(isset($_REQUEST['check']['address2'])) $address_info .= $td_h.usces_entity_decode($data['order_address2'], $ext).$td_f; |
| 2156 |
if(isset($_REQUEST['check']['address3'])) $address_info .= $td_h.usces_entity_decode($data['order_address3'], $ext).$td_f; |
| 2157 |
if(isset($_REQUEST['check']['tel'])) $address_info .= $td_h.usces_entity_decode($data['order_tel'], $ext).$td_f; |
| 2158 |
if(isset($_REQUEST['check']['fax'])) $address_info .= $td_h.usces_entity_decode($data['order_fax'], $ext).$td_f; |
| 2159 |
break; |
| 2160 |
case 'US': |
| 2161 |
default: |
| 2162 |
if(isset($_REQUEST['check']['address2'])) $address_info .= $td_h.usces_entity_decode($data['order_address2'], $ext).$td_f; |
| 2163 |
if(isset($_REQUEST['check']['address3'])) $address_info .= $td_h.usces_entity_decode($data['order_address3'], $ext).$td_f; |
| 2164 |
if(isset($_REQUEST['check']['address1'])) $address_info .= $td_h.usces_entity_decode($data['order_address1'], $ext).$td_f; |
| 2165 |
if(isset($_REQUEST['check']['pref'])) $address_info .= $td_h.usces_entity_decode($data['order_pref'], $ext).$td_f; |
| 2166 |
if(isset($_REQUEST['check']['country'])) $address_info .= $td_h.$usces_settings['country'][$usces->get_order_meta_value('customer_country', $order_id)].$td_f; |
| 2167 |
if(isset($_REQUEST['check']['zip'])) $address_info .= $td_h.usces_entity_decode($data['order_zip'], $ext).$td_f; |
| 2168 |
if(isset($_REQUEST['check']['tel'])) $address_info .= $td_h.usces_entity_decode($data['order_tel'], $ext).$td_f; |
| 2169 |
if(isset($_REQUEST['check']['fax'])) $address_info .= $td_h.usces_entity_decode($data['order_fax'], $ext).$td_f; |
| 2170 |
break; |
| 2171 |
} |
| 2172 |
$address_info_args = compact( 'td_h', 'td_f', 'ext', 'order_id', 'applyform' ); |
| 2173 |
$line .= apply_filters( 'usces_filter_ord_csv_address_info', $address_info, $data, $address_info_args ); |
| 2174 |
//20110411ysk end |
| 2175 |
if(!empty($cscs_meta)) { |
| 2176 |
foreach($cscs_meta as $key => $entry) { |
| 2177 |
if($entry['position'] == 'fax_after') { |
| 2178 |
$name = $entry['name']; |
| 2179 |
$cscs_key = 'cscs_'.$key; |
| 2180 |
//20110208ysk start |
| 2181 |
//if(isset($_REQUEST['check'][$name])) { |
| 2182 |
if(isset($_REQUEST['check'][$cscs_key])) { |
| 2183 |
//20110208ysk end |
| 2184 |
$value = maybe_unserialize($usces->get_order_meta_value($cscs_key, $order_id)); |
| 2185 |
if(empty($value)) { |
| 2186 |
$value = ''; |
| 2187 |
} elseif(is_array($value)) { |
| 2188 |
$concatval = ''; |
| 2189 |
$c = ''; |
| 2190 |
foreach($value as $v) { |
| 2191 |
$concatval .= $c.$v; |
| 2192 |
$c = ' '; |
| 2193 |
} |
| 2194 |
$value = $concatval; |
| 2195 |
} |
| 2196 |
$line .= $td_h.usces_entity_decode($value, $ext).$td_f; |
| 2197 |
} |
| 2198 |
} |
| 2199 |
} |
| 2200 |
} |
| 2201 |
$line .= apply_filters( 'usces_filter_chk_ord_data_customer', NULL, $usces_opt_order, $order_id, $data ); |
| 2202 |
//---------------------------------------------------------------------- |
| 2203 |
if(!empty($csde_meta)) { |
| 2204 |
foreach($csde_meta as $key => $entry) { |
| 2205 |
if($entry['position'] == 'name_pre') { |
| 2206 |
$name = $entry['name']; |
| 2207 |
$csde_key = 'csde_'.$key; |
| 2208 |
//20110208ysk start |
| 2209 |
//if(isset($_REQUEST['check'][$name])) { |
| 2210 |
if(isset($_REQUEST['check'][$csde_key])) { |
| 2211 |
//20110208ysk end |
| 2212 |
$value = maybe_unserialize($usces->get_order_meta_value($csde_key, $order_id)); |
| 2213 |
if(empty($value)) { |
| 2214 |
$value = ''; |
| 2215 |
} elseif(is_array($value)) { |
| 2216 |
$concatval = ''; |
| 2217 |
$c = ''; |
| 2218 |
foreach($value as $v) { |
| 2219 |
$concatval .= $c.$v; |
| 2220 |
$c = ' '; |
| 2221 |
} |
| 2222 |
$value = $concatval; |
| 2223 |
} |
| 2224 |
$line .= $td_h.usces_entity_decode($value, $ext).$td_f; |
| 2225 |
} |
| 2226 |
} |
| 2227 |
} |
| 2228 |
} |
| 2229 |
//20110411ysk start |
| 2230 |
switch($applyform) { |
| 2231 |
case 'JP': |
| 2232 |
if(isset($_REQUEST['check']['delivery_name'])) $line .= $td_h.usces_entity_decode($deli['name1'].' '.$deli['name2'], $ext).$td_f; |
| 2233 |
if(isset($_REQUEST['check']['delivery_kana'])) $line .= $td_h.usces_entity_decode($deli['name3'].' '.$deli['name4'], $ext).$td_f; |
| 2234 |
break; |
| 2235 |
case 'US': |
| 2236 |
default: |
| 2237 |
if(isset($_REQUEST['check']['delivery_name'])) $line .= $td_h.usces_entity_decode($deli['name2'].' '.$deli['name1'], $ext).$td_f; |
| 2238 |
break; |
| 2239 |
} |
| 2240 |
//20110411ysk end |
| 2241 |
if(!empty($csde_meta)) { |
| 2242 |
foreach($csde_meta as $key => $entry) { |
| 2243 |
if($entry['position'] == 'name_after') { |
| 2244 |
$name = $entry['name']."</td>"; |
| 2245 |
$csde_key = 'csde_'.$key; |
| 2246 |
//20110208ysk start |
| 2247 |
//if(isset($_REQUEST['check'][$name])) { |
| 2248 |
if(isset($_REQUEST['check'][$csde_key])) { |
| 2249 |
//20110208ysk end |
| 2250 |
$value = maybe_unserialize($usces->get_order_meta_value($csde_key, $order_id)); |
| 2251 |
if(empty($value)) { |
| 2252 |
$value = ''; |
| 2253 |
} elseif(is_array($value)) { |
| 2254 |
$concatval = ''; |
| 2255 |
$c = ''; |
| 2256 |
foreach($value as $v) { |
| 2257 |
$concatval .= $c.$v; |
| 2258 |
$c = ' '; |
| 2259 |
} |
| 2260 |
$value = $concatval; |
| 2261 |
} |
| 2262 |
$line .= $td_h.usces_entity_decode($value, $ext).$td_f; |
| 2263 |
} |
| 2264 |
} |
| 2265 |
} |
| 2266 |
} |
| 2267 |
//20110411ysk start |
| 2268 |
$address_info = ''; |
| 2269 |
switch($applyform) { |
| 2270 |
case 'JP': |
| 2271 |
if(isset($_REQUEST['check']['delivery_zip'])) $address_info .= $td_h.usces_entity_decode($deli['zipcode'], $ext).$td_f; |
| 2272 |
if(isset($_REQUEST['check']['delivery_country'])) $address_info .= $td_h.$usces_settings['country'][$deli['country']].$td_f; |
| 2273 |
if(isset($_REQUEST['check']['delivery_pref'])) $address_info .= $td_h.usces_entity_decode($deli['pref'], $ext).$td_f; |
| 2274 |
if(isset($_REQUEST['check']['delivery_address1'])) $address_info .= $td_h.usces_entity_decode($deli['address1'], $ext).$td_f; |
| 2275 |
if(isset($_REQUEST['check']['delivery_address2'])) $address_info .= $td_h.usces_entity_decode($deli['address2'], $ext).$td_f; |
| 2276 |
if(isset($_REQUEST['check']['delivery_address3'])) $address_info .= $td_h.usces_entity_decode($deli['address3'], $ext).$td_f; |
| 2277 |
if(isset($_REQUEST['check']['delivery_tel'])) $address_info .= $td_h.usces_entity_decode($deli['tel'], $ext).$td_f; |
| 2278 |
if(isset($_REQUEST['check']['delivery_fax'])) $address_info .= $td_h.usces_entity_decode($deli['fax'], $ext).$td_f; |
| 2279 |
break; |
| 2280 |
case 'US': |
| 2281 |
default: |
| 2282 |
if(isset($_REQUEST['check']['delivery_address2'])) $address_info .= $td_h.usces_entity_decode($deli['address2'], $ext).$td_f; |
| 2283 |
if(isset($_REQUEST['check']['delivery_address3'])) $address_info .= $td_h.usces_entity_decode($deli['address3'], $ext).$td_f; |
| 2284 |
if(isset($_REQUEST['check']['delivery_address1'])) $address_info .= $td_h.usces_entity_decode($deli['address1'], $ext).$td_f; |
| 2285 |
if(isset($_REQUEST['check']['delivery_pref'])) $address_info .= $td_h.usces_entity_decode($deli['pref'], $ext).$td_f; |
| 2286 |
if(isset($_REQUEST['check']['delivery_country'])) $address_info .= $td_h.$usces_settings['country'][$deli['country']].$td_f; |
| 2287 |
if(isset($_REQUEST['check']['delivery_zip'])) $address_info .= $td_h.usces_entity_decode($deli['zipcode'], $ext).$td_f; |
| 2288 |
if(isset($_REQUEST['check']['delivery_tel'])) $address_info .= $td_h.usces_entity_decode($deli['tel'], $ext).$td_f; |
| 2289 |
if(isset($_REQUEST['check']['delivery_fax'])) $address_info .= $td_h.usces_entity_decode($deli['fax'], $ext).$td_f; |
| 2290 |
break; |
| 2291 |
} |
| 2292 |
$line .= apply_filters( 'usces_filter_ord_csv_delivery_address_info', $address_info, $deli, $address_info_args ); |
| 2293 |
//20110411ysk end |
| 2294 |
if(!empty($csde_meta)) { |
| 2295 |
foreach($csde_meta as $key => $entry) { |
| 2296 |
if($entry['position'] == 'fax_after') { |
| 2297 |
$name = $entry['name']; |
| 2298 |
$csde_key = 'csde_'.$key; |
| 2299 |
//20110208ysk start |
| 2300 |
//if(isset($_REQUEST['check'][$name])) { |
| 2301 |
if(isset($_REQUEST['check'][$csde_key])) { |
| 2302 |
//20110208ysk end |
| 2303 |
$value = maybe_unserialize($usces->get_order_meta_value($csde_key, $order_id)); |
| 2304 |
if(empty($value)) { |
| 2305 |
$value = ''; |
| 2306 |
} elseif(is_array($value)) { |
| 2307 |
$concatval = ''; |
| 2308 |
$c = ''; |
| 2309 |
foreach($value as $v) { |
| 2310 |
$concatval .= $c.$v; |
| 2311 |
$c = ' '; |
| 2312 |
} |
| 2313 |
$value = $concatval; |
| 2314 |
} |
| 2315 |
$line .= $td_h.usces_entity_decode($value, $ext).$td_f; |
| 2316 |
} |
| 2317 |
} |
| 2318 |
} |
| 2319 |
} |
| 2320 |
$line .= apply_filters( 'usces_filter_chk_ord_data_delivery', NULL, $usces_opt_order, $order_id, $deli ); |
| 2321 |
//---------------------------------------------------------------------- |
| 2322 |
if(isset($_REQUEST['check']['shipping_date'])) $line .= $td_h.$data['order_modified'].$td_f; |
| 2323 |
if(isset($_REQUEST['check']['peyment_method'])) $line .= $td_h.$data['order_payment_name'].$td_f; |
| 2324 |
if(isset($_REQUEST['check']['delivery_method'])) { |
| 2325 |
$delivery_method = ''; |
| 2326 |
if(strtoupper($data['order_delivery_method']) == '#NONE#') { |
| 2327 |
$delivery_method = __('No preference', 'usces'); |
| 2328 |
} else { |
| 2329 |
foreach((array)$usces->options['delivery_method'] as $dkey => $delivery) { |
| 2330 |
if($delivery['id'] == $data['order_delivery_method']) { |
| 2331 |
$delivery_method = $delivery['name']; |
| 2332 |
break; |
| 2333 |
} |
| 2334 |
} |
| 2335 |
} |
| 2336 |
$line .= $td_h.$delivery_method.$td_f; |
| 2337 |
} |
| 2338 |
//20101208ysk start |
| 2339 |
if(isset($_REQUEST['check']['delivery_date'])) $line .= $td_h.$data['order_delivery_date'].$td_f; |
| 2340 |
//20101208ysk end |
| 2341 |
if(isset($_REQUEST['check']['delivery_time'])) $line .= $td_h.$data['order_delivery_time'].$td_f; |
| 2342 |
if(isset($_REQUEST['check']['delidue_date'])) { |
| 2343 |
$order_delidue_date = (strtoupper($data['order_delidue_date']) == '#NONE#') ? '' : $data['order_delidue_date']; |
| 2344 |
$line .= $td_h.$order_delidue_date.$td_f; |
| 2345 |
} |
| 2346 |
if(isset($_REQUEST['check']['status'])) { |
| 2347 |
$order_status = explode(',', $data['order_status']); |
| 2348 |
$status = ''; |
| 2349 |
foreach( (array)$order_status as $os) { |
| 2350 |
if( isset($usces_management_status[$os]) ) |
| 2351 |
$status .= $usces_management_status[$os].$sp; |
| 2352 |
} |
| 2353 |
$line .= $td_h.trim($status, $sp).$td_f; |
| 2354 |
} |
| 2355 |
$line .= $td_h.usces_crform($array['total_price'], false, false, 'return', false).$td_f; |
| 2356 |
if(isset($_REQUEST['check']['getpoint'])) $line .= $td_h.$data['order_getpoint'].$td_f; |
| 2357 |
if(isset($_REQUEST['check']['usedpoint'])) $line .= $td_h.$data['order_usedpoint'].$td_f; |
| 2358 |
$line .= $td_h.$data['order_discount'].$td_f; |
| 2359 |
$line .= $td_h.$data['order_shipping_charge'].$td_f; |
| 2360 |
$line .= $td_h.$data['order_cod_fee'].$td_f; |
| 2361 |
$line .= $td_h.$data['order_tax'].$td_f; |
| 2362 |
if(isset($_REQUEST['check']['note'])) $line .= $td_h.usces_entity_decode($data['order_note'], $ext).$td_f; |
| 2363 |
if(!empty($csod_meta)) { |
| 2364 |
foreach($csod_meta as $key => $entry) { |
| 2365 |
$name = $entry['name']; |
| 2366 |
$csod_key = 'csod_'.$key; |
| 2367 |
//20110208ysk start |
| 2368 |
//if(isset($_REQUEST['check'][$name])) { |
| 2369 |
if(isset($_REQUEST['check'][$csod_key])) { |
| 2370 |
//20110208ysk end |
| 2371 |
$value = maybe_unserialize($usces->get_order_meta_value($csod_key, $order_id)); |
| 2372 |
if(empty($value)) { |
| 2373 |
$value = ''; |
| 2374 |
} elseif(is_array($value)) { |
| 2375 |
$concatval = ''; |
| 2376 |
$c = ''; |
| 2377 |
foreach($value as $v) { |
| 2378 |
$concatval .= $c.$v; |
| 2379 |
$c = ' '; |
| 2380 |
} |
| 2381 |
$value = $concatval; |
| 2382 |
} |
| 2383 |
$line .= $td_h.usces_entity_decode($value, $ext).$td_f; |
| 2384 |
} |
| 2385 |
} |
| 2386 |
} |
| 2387 |
$line .= apply_filters( 'usces_filter_chk_ord_data_order', NULL, $usces_opt_order, $order_id, $data ); |
| 2388 |
$line .= $tr_f.$lf; |
| 2389 |
} |
| 2390 |
$line .= $table_f.$lf; |
| 2391 |
//========================================================================== |
| 2392 |
|
| 2393 |
if($ext == 'xls') { |
| 2394 |
header("Content-Type: application/vnd.ms-excel; charset=Shift-JIS"); |
| 2395 |
} elseif($ext == 'csv') { |
| 2396 |
header("Content-Type: application/octet-stream"); |
| 2397 |
} |
| 2398 |
header("Content-Disposition: attachment; filename=usces_order_list.".$ext); |
| 2399 |
mb_http_output('pass'); |
| 2400 |
print(mb_convert_encoding($line, "SJIS-win", "UTF-8")); |
| 2401 |
exit(); |
| 2402 |
} |
| 2403 |
|
| 2404 |
function usces_entity_decode($str, $ftype) { |
| 2405 |
$pos = strpos($str, '&'); |
| 2406 |
if($pos !== false) |
| 2407 |
$str = htmlspecialchars_decode($str); |
| 2408 |
|
| 2409 |
if($ftype == 'csv') |
| 2410 |
$str = str_replace('"', '""', $str); |
| 2411 |
|
| 2412 |
return $str; |
| 2413 |
} |
| 2414 |
|
| 2415 |
function usces_is_entity($entity){ |
| 2416 |
$temp = substr($entity, 0, 1); |
| 2417 |
$temp .= substr($entity, -1, 1); |
| 2418 |
if ($temp != '&;') |
| 2419 |
return false; |
| 2420 |
else |
| 2421 |
return true; |
| 2422 |
} |
| 2423 |
|
| 2424 |
function usces_p( $var ){ |
| 2425 |
echo '<pre>' . print_r($var, true) . '</pre>'; |
| 2426 |
} |
| 2427 |
|
| 2428 |
function usces_get_key( $digit ){ |
| 2429 |
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
| 2430 |
$max = strlen($chars) - 1; |
| 2431 |
$str = ''; |
| 2432 |
for($i=0; $i<$digit; $i++){ |
| 2433 |
$str .= $chars[mt_rand(0, $max)]; |
| 2434 |
} |
| 2435 |
return $str; |
| 2436 |
} |
| 2437 |
?> |