| 1 |
<?php |
| 2 |
/** |
| 3 |
* Item administration list. |
| 4 |
* |
| 5 |
* Manage Item actions: search, batch processing, etc. |
| 6 |
* |
| 7 |
* @package Welcart |
| 8 |
*/ |
| 9 |
|
| 10 |
require_once USCES_PLUGIN_DIR . '/classes/itemList.class.php'; |
| 11 |
global $wpdb, $post; |
| 12 |
$wpdb->show_errors(); |
| 13 |
|
| 14 |
$tableName = $wpdb->posts; |
| 15 |
if ( version_compare( USCES_MYSQL_VERSION, '5.0.0', '>=' ) ) { |
| 16 |
$arr_column = array( |
| 17 |
__( 'Post ID', 'usces' ) => 'post_id', |
| 18 |
__( 'item code', 'usces' ) => 'item_code', |
| 19 |
__( 'item name', 'usces' ) => 'item_name', |
| 20 |
__( 'SKU code', 'usces' ) => 'sku_key', |
| 21 |
apply_filters( 'usces_filter_sellingprice_label', __( 'selling price', 'usces' ), null, null ) => 'price', |
| 22 |
__( 'stock', 'usces' ) => 'zaiko_num', |
| 23 |
__( 'stock status', 'usces' ) => 'zaiko', |
| 24 |
__( 'Categories', 'usces' ) => 'category', |
| 25 |
__( 'display status', 'usces' ) => 'display_status', |
| 26 |
); |
| 27 |
} else { |
| 28 |
$arr_column = array( |
| 29 |
__( 'Post ID', 'usces' ) => 'post_id', |
| 30 |
__( 'item code', 'usces' ) => 'item_code', |
| 31 |
__( 'page title', 'usces' ) => 'post_title', |
| 32 |
__( 'SKU code', 'usces' ) => 'sku_key', |
| 33 |
apply_filters( 'usces_filter_sellingprice_label', __( 'selling price', 'usces' ), null, null ) => 'price', |
| 34 |
__( 'stock', 'usces' ) => 'zaiko_num', |
| 35 |
__( 'stock status', 'usces' ) => 'zaiko', |
| 36 |
__( 'Categories', 'usces' ) => 'category', |
| 37 |
__( 'display status', 'usces' ) => 'display_status', |
| 38 |
); |
| 39 |
} |
| 40 |
|
| 41 |
$DT = new dataList( $tableName, $arr_column ); |
| 42 |
$res = $DT->MakeTable(); |
| 43 |
$arr_search = $DT->GetSearchs(); |
| 44 |
$arr_header = apply_filters( 'usces_filter_itemlist_header', $DT->GetListheaders() ); |
| 45 |
$dataTableNavigation = $DT->GetDataTableNavigation(); |
| 46 |
$dataTableNavigationBottom = $DT->GetDataTableNavigationBottom(); |
| 47 |
$rows = $DT->rows; |
| 48 |
$zaiko_status = get_option( 'usces_zaiko_status' ); |
| 49 |
$usces_status = $DT->get_action_status(); |
| 50 |
$usces_message = $DT->get_action_message(); |
| 51 |
$curent_url = urlencode( esc_url( USCES_ADMIN_URL . '?' . $_SERVER['QUERY_STRING'] ) ); |
| 52 |
$usces_opt_item = get_option( 'usces_opt_item' ); |
| 53 |
|
| 54 |
$usces_admin_path = ''; |
| 55 |
$admin_perse = explode( '/', $_SERVER['REQUEST_URI'] ); |
| 56 |
$apct = count( $admin_perse ) - 1; |
| 57 |
for ( $ap = 0; $ap < $apct; $ap++ ) { |
| 58 |
$usces_admin_path .= $admin_perse[ $ap ] . '/'; |
| 59 |
} |
| 60 |
?> |
| 61 |
<script type="text/javascript"> |
| 62 |
jQuery(function($){ |
| 63 |
|
| 64 |
var wc_nonce = $( "#wc_nonce" ).val(); |
| 65 |
|
| 66 |
$("input[name='allcheck']").click(function () { |
| 67 |
if( $(this).prop("checked") ){ |
| 68 |
$("input[name*='listcheck']").prop( "checked", true ); |
| 69 |
}else{ |
| 70 |
$("input[name*='listcheck']").prop( "checked", false ); |
| 71 |
} |
| 72 |
}); |
| 73 |
|
| 74 |
$("#searchselect").change(function () { |
| 75 |
operation.change_search_field(); |
| 76 |
}); |
| 77 |
|
| 78 |
$("#changeselect").change(function () { |
| 79 |
operation.change_collective_field(); |
| 80 |
}); |
| 81 |
|
| 82 |
$("#collective_change").click(function () { |
| 83 |
if( $("input[name*='listcheck']:checked").length == 0 ) { |
| 84 |
alert("<?php esc_html_e( 'no items are selected', 'usces' ); ?>"); |
| 85 |
$("#itemlistaction").val(''); |
| 86 |
return false; |
| 87 |
} |
| 88 |
var coll = $("#changeselect").val(); |
| 89 |
var mes = ''; |
| 90 |
if( coll == 'zaiko' ){ |
| 91 |
mes = <?php echo sprintf( __( "'Stock status of items which you have checked will be changed into ' + %s + ' Stock status of each SKU will be all shown as ' + %s + ' Do you agree with this oparation?'", 'usces' ), |
| 92 |
'$("select\[name=\"change\[word\]\[zaiko\]\"\] option:selected").html()', |
| 93 |
'$("select\[name=\"change\[word\]\[zaiko\]\"\] option:selected").html()'); ?>; |
| 94 |
}else if( coll == 'display_status' ){ |
| 95 |
mes = <?php echo sprintf( __( "'Are you sure of changing all the items you have checked in to ' + %s + ' ?'", 'usces' ), |
| 96 |
'$("select\[name=\"change\[word\]\[display_status\]\"\] option:selected").html()'); ?>; |
| 97 |
}else if(coll == 'delete'){ |
| 98 |
mes = <?php _e( "'Are you sure of deleting all the items you have checked in bulk?'", 'usces' ); ?>; |
| 99 |
} |
| 100 |
if( mes != '' ) { |
| 101 |
if( !confirm(mes) ){ |
| 102 |
$("#itemlistaction").val(''); |
| 103 |
return false; |
| 104 |
} |
| 105 |
} |
| 106 |
<?php do_action( 'usces_action_item_list_collective_change_js' ); ?> |
| 107 |
$("#itemlistaction").val('collective'); |
| 108 |
return true; |
| 109 |
}); |
| 110 |
|
| 111 |
operation = { |
| 112 |
change_search_field :function (){ |
| 113 |
|
| 114 |
var label = ''; |
| 115 |
var html = ''; |
| 116 |
var column = $("#searchselect").val(); |
| 117 |
|
| 118 |
if( 'post_id' === column ) { |
| 119 |
label = '<?php esc_html_e( 'key words', 'usces' ); ?>'; |
| 120 |
html = '<input name="search[word][post_id_from]" type="number" min="1" value="<?php if ( isset( $arr_search['word']['post_id_from'] ) ) echo esc_attr( $arr_search['word']['post_id_from'] ); ?>" class="searchword" maxlength="50" />'; |
| 121 |
html += '<?php esc_html_e( ' - ', 'usces' ); ?><input name="search[word][post_id_to]" type="number" min="1" value="<?php if ( isset( $arr_search['word']['post_id_to'] ) ) echo esc_attr( $arr_search['word']['post_id_to'] ); ?>" class="searchword" maxlength="50" />'; |
| 122 |
}else if( column == 'item_name' ) { |
| 123 |
label = '<?php esc_html_e( 'key words', 'usces' ); ?>'; |
| 124 |
html = '<input name="search[word][item_name]" type="text" value="<?php if ( isset( $arr_search['word']['item_name'] ) ) echo esc_attr( $arr_search['word']['item_name'] ); ?>" class="searchword" maxlength="50" />'; |
| 125 |
}else if( column == 'item_code' ) { |
| 126 |
label = '<?php esc_html_e( 'key words', 'usces' ); ?>'; |
| 127 |
html = '<input name="search[word][item_code]" type="text" value="<?php if ( isset( $arr_search['word']['item_code'] ) ) echo esc_attr( $arr_search['word']['item_code'] ); ?>" class="searchword" maxlength="50" />'; |
| 128 |
}else if( column == 'post_title' ) { |
| 129 |
label = '<?php esc_html_e( 'key words', 'usces' ); ?>'; |
| 130 |
html = '<input name="search[word][post_title]" type="text" value="<?php if ( isset( $arr_search['word']['post_title'] ) ) echo esc_attr( $arr_search['word']['post_title'] ); ?>" class="searchword" maxlength="50" />'; |
| 131 |
}else if( column == 'zaiko_num' ) { |
| 132 |
label = ''; |
| 133 |
html = ''; |
| 134 |
}else if( column == 'zaiko' ) { |
| 135 |
label = ''; |
| 136 |
html = '<select name="search[word][zaiko]" class="searchselect">'; |
| 137 |
<?php |
| 138 |
foreach ( $zaiko_status as $zkey => $zvalue ) { |
| 139 |
if ( isset( $arr_search['word']['zaiko'] ) && $zkey == $arr_search['word']['zaiko'] ) { |
| 140 |
$zselected = ' selected="selected"'; |
| 141 |
} else { |
| 142 |
$zselected = ''; |
| 143 |
} |
| 144 |
?> |
| 145 |
html += '<option value="<?php echo esc_attr( $zkey ); ?>"<?php echo esc_attr( $zselected ); ?>><?php echo esc_html( $zvalue ); ?></option>'; |
| 146 |
<?php } ?> |
| 147 |
html += '</select>'; |
| 148 |
}else if( column == 'category' ) { |
| 149 |
label = ''; |
| 150 |
html = '<select name="search[word][category]" class="searchselect">'; |
| 151 |
<?php |
| 152 |
$category_args = apply_filters( 'usces_filter_itemlist_searchselect_category_args', array( 'child_of' => USCES_ITEM_CAT_PARENT_ID, 'hide_empty' => 0 ) ); |
| 153 |
$categories = get_categories( $category_args ); |
| 154 |
foreach ( $categories as $ckey => $cvalue ) { |
| 155 |
if ( isset( $arr_search['word']['category'] ) && $cvalue->term_id == $arr_search['word']['category'] ) { |
| 156 |
$cselected = ' selected="selected"'; |
| 157 |
} else { |
| 158 |
$cselected = ''; |
| 159 |
} |
| 160 |
?> |
| 161 |
html += '<option value="<?php echo esc_attr( $cvalue->term_id ); ?>"<?php echo esc_attr( $cselected ); ?>><?php echo esc_html( $cvalue->name ); ?></option>'; |
| 162 |
<?php } ?> |
| 163 |
html += '</select>'; |
| 164 |
}else if( column == 'display_status' ) { |
| 165 |
label = ''; |
| 166 |
html = '<select name="search[word][display_status]" class="searchselect">'; |
| 167 |
html += '<option value="publish"<?php if ( isset( $arr_search['word']['display_status'] ) && 'publish' == $arr_search['word']['display_status'] ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Published', 'usces' ); ?></option>'; |
| 168 |
html += '<option value="future"<?php if ( isset( $arr_search['word']['display_status'] ) && 'future' == $arr_search['word']['display_status'] ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Scheduled', 'usces' ); ?></option>'; |
| 169 |
html += '<option value="draft"<?php if ( isset( $arr_search['word']['display_status'] ) && 'draft' == $arr_search['word']['display_status'] ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Draft', 'usces' ); ?></option>'; |
| 170 |
html += '<option value="pending"<?php if ( isset( $arr_search['word']['display_status'] ) && 'pending' == $arr_search['word']['display_status'] ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Pending Review', 'usces' ); ?></option>'; |
| 171 |
html += '<option value="private"<?php if ( isset( $arr_search['word']['display_status'] ) && 'private' == $arr_search['word']['display_status'] ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Closed', 'usces' ); ?></option>'; |
| 172 |
html += '<option value="trash"<?php if ( isset( $arr_search['word']['display_status'] ) && 'trash' == $arr_search['word']['display_status'] ) echo ' selected="selected"'; ?>><?php esc_html_e( 'Trash', 'usces' ); ?></option>'; |
| 173 |
html += '</select>'; |
| 174 |
} |
| 175 |
|
| 176 |
$("#searchlabel").html( label ); |
| 177 |
$("#searchfield").html( html ); |
| 178 |
|
| 179 |
}, |
| 180 |
|
| 181 |
change_collective_field :function (){ |
| 182 |
|
| 183 |
var label = ''; |
| 184 |
var html = ''; |
| 185 |
var column = $("#changeselect").val(); |
| 186 |
|
| 187 |
if( column == 'zaiko' ) { |
| 188 |
label = ''; |
| 189 |
html = '<select name="change[word][zaiko]" class="searchselect">'; |
| 190 |
<?php foreach ( $zaiko_status as $zkey => $zvalue ) { ?> |
| 191 |
html += '<option value="<?php echo esc_html( $zkey ); ?>"><?php echo esc_html( $zvalue ); ?></option>'; |
| 192 |
<?php } ?> |
| 193 |
html += '</select>'; |
| 194 |
}else if( column == 'display_status' ) { |
| 195 |
label = ''; |
| 196 |
html = '<select name="change[word][display_status]" class="searchselect">'; |
| 197 |
html += '<option value="publish"><?php esc_html_e( 'Published', 'usces' ); ?></option>'; |
| 198 |
html += '<option value="draft"><?php esc_html_e( 'Draft', 'usces' ); ?></option>'; |
| 199 |
html += '<option value="private"><?php esc_html_e( 'Closed', 'usces' ); ?></option>'; |
| 200 |
html += '</select>'; |
| 201 |
}else if( column == 'delete' ) { |
| 202 |
label = ''; |
| 203 |
html = ''; |
| 204 |
} |
| 205 |
|
| 206 |
$("#changelabel").html( label ); |
| 207 |
$("#changefield").html( html ); |
| 208 |
|
| 209 |
} |
| 210 |
}; |
| 211 |
|
| 212 |
// Dialog generation |
| 213 |
$("#upload_dialog").dialog({ |
| 214 |
bgiframe: true, |
| 215 |
autoOpen: false, |
| 216 |
height: 470, |
| 217 |
width: 520, |
| 218 |
modal: true, |
| 219 |
buttons: { |
| 220 |
'<?php esc_html_e( 'Cancel', 'usces' ); ?>': function() { |
| 221 |
$(this).dialog('close'); |
| 222 |
} |
| 223 |
}, |
| 224 |
close: function() { |
| 225 |
$("#usces_upcsv").val(''); |
| 226 |
} |
| 227 |
}); |
| 228 |
$('#up_itemlist').click(function() { |
| 229 |
$('#upload_dialog').dialog( 'option' , 'title' , '<?php esc_html_e( 'Collective registration item', 'usces' ); ?>' ); |
| 230 |
$('#dialogExp').html( '<?php _e( 'Upload prescribed CSV file and perform the collective registration of the article.<br />Please choose a file, and push the registration start.', 'usces' ); ?>' ); |
| 231 |
$('#upload_dialog').dialog( 'open' ); |
| 232 |
}); |
| 233 |
$("#dlItemListDialog").dialog({ |
| 234 |
bgiframe: true, |
| 235 |
autoOpen: false, |
| 236 |
height: 360, |
| 237 |
width: 520, |
| 238 |
resizable: true, |
| 239 |
modal: true, |
| 240 |
buttons: { |
| 241 |
'<?php esc_html_e( 'close', 'usces' ); ?>': function() { |
| 242 |
$(this).dialog('close'); |
| 243 |
} |
| 244 |
}, |
| 245 |
close: function() { |
| 246 |
} |
| 247 |
}); |
| 248 |
$('#dl_item').click(function() { |
| 249 |
var args = '&search[column]=' + $( ':input[name="search[column]"]' ).val(); |
| 250 |
const searchField = $( '#searchselect' ).val(); |
| 251 |
if ( 'post_id' == searchField ) { |
| 252 |
args += |
| 253 |
'&search[word][post_id_from]=' + |
| 254 |
$( ':input[name="search[word][post_id_from]"]' ).val(); |
| 255 |
args += |
| 256 |
'&search[word][post_id_to]=' + |
| 257 |
$( ':input[name="search[word][post_id_to]"]' ).val(); |
| 258 |
} else { |
| 259 |
args += |
| 260 |
'&search[word][' + |
| 261 |
searchField + |
| 262 |
']=' + |
| 263 |
$( ':input[name="search[word][' + searchField + ']"]' ).val(); |
| 264 |
} |
| 265 |
args += '&searchSwitchStatus=' + $( ':input[name="searchSwitchStatus"]' ).val(); |
| 266 |
args += '&ftype=csv' + '&mode=' + $( ':input[name="download_mode"]:checked' ).val(); |
| 267 |
if($('#chk_header').prop('checked')) { |
| 268 |
args += '&chk_header=on'; |
| 269 |
} |
| 270 |
location.href = "<?php echo esc_url( USCES_ADMIN_URL ); ?>?page=usces_itemedit&action=dlitemlist&wc_nonce=" + wc_nonce +"&noheader=true"+args<?php echo apply_filters( 'usces_filter_item_list_dlargs', '' ); ?>; |
| 271 |
}); |
| 272 |
$('#dl_itemlist').click(function() { |
| 273 |
$('#dlItemListDialog').dialog('open'); |
| 274 |
}); |
| 275 |
|
| 276 |
<?php echo apply_filters( 'usces_filter_item_list_page_js', '' ); ?> |
| 277 |
|
| 278 |
}); |
| 279 |
|
| 280 |
function deleteconfirm(item_id){ |
| 281 |
if(confirm(<?php _e( "'Are you sure of deleting the item, item code ' + item_id + ' ?'", 'usces' ); ?>)){ |
| 282 |
return true; |
| 283 |
}else{ |
| 284 |
return false; |
| 285 |
} |
| 286 |
}; |
| 287 |
|
| 288 |
jQuery(document).ready(function($){ |
| 289 |
$("table#mainDataTable tr:even").addClass("rowSelection_even"); |
| 290 |
$("table#mainDataTable tr").hover(function() { |
| 291 |
$(this).addClass("rowSelection_hilight"); |
| 292 |
}, |
| 293 |
function() { |
| 294 |
$(this).removeClass("rowSelection_hilight"); |
| 295 |
}); |
| 296 |
(function setCookie() { |
| 297 |
<?php |
| 298 |
$data_cookie = array(); |
| 299 |
$data_cookie['startRow'] = $DT->startRow; /* 表示開始行番号 */ |
| 300 |
$data_cookie['sortColumn'] = $DT->sortColumn; /* 現在ソート中のフィールド */ |
| 301 |
$data_cookie['totalRow'] = $DT->totalRow; /* � |
| 302 |
�行数 */ |
| 303 |
$data_cookie['selectedRow'] = $DT->selectedRow; /* 絞り込まれた行数 */ |
| 304 |
$data_cookie['currentPage'] = $DT->currentPage; /* 現在のページNo */ |
| 305 |
$data_cookie['previousPage'] = $DT->previousPage; /* 前のページNo */ |
| 306 |
$data_cookie['nextPage'] = $DT->nextPage; /* 次のページNo */ |
| 307 |
$data_cookie['lastPage'] = $DT->lastPage; /* 最終ページNo */ |
| 308 |
$data_cookie['userHeaderNames'] = $DT->userHeaderNames; /* � |
| 309 |
�てのフィールド */ |
| 310 |
$data_cookie['sortSwitchs'] = $DT->sortSwitchs; /* 各フィールド毎の昇順降順スイッチ */ |
| 311 |
$data_cookie['arr_search'] = $DT->arr_search; |
| 312 |
$data_cookie['searchSwitchStatus'] = $DT->searchSwitchStatus; |
| 313 |
?> |
| 314 |
$.cookie('<?php echo "{$DT->table}"?>', '<?php echo str_replace( "'", "\'", json_encode( $data_cookie ) ); ?>', { path: "<?php echo esc_attr( $usces_admin_path ); ?>", domain: ""}); |
| 315 |
})(); |
| 316 |
$(document).on( "click", "#searchVisiLink", function() { |
| 317 |
if( $("#searchBox").css("display") == "block" ) { |
| 318 |
$("#searchBox").css("display", "none"); |
| 319 |
$("#searchVisiLink").html('<?php esc_html_e( 'Show the Operation field', 'usces' ); ?>'); |
| 320 |
} else { |
| 321 |
$("#searchBox").css("display", "block"); |
| 322 |
$("#searchVisiLink").html('<?php esc_html_e( 'Hide the Operation field', 'usces' ); ?>'); |
| 323 |
} |
| 324 |
}); |
| 325 |
<?php if ( 'ON' === $DT->searchSwitchStatus ) { ?> |
| 326 |
$("#searchBox").css("display", "block"); |
| 327 |
<?php } ?> |
| 328 |
|
| 329 |
operation.change_search_field(); |
| 330 |
|
| 331 |
}); |
| 332 |
</script> |
| 333 |
<div class="wrap"> |
| 334 |
<div class="usces_admin"> |
| 335 |
<form action="<?php echo esc_url( USCES_ADMIN_URL . '?page=usces_itemedit' ); ?>" method="post" name="tablesearch"> |
| 336 |
<h1>Welcart Shop <?php esc_html_e( 'Item list', 'usces' ); ?></h1> |
| 337 |
<p class="version_info">Version <?php echo esc_html( USCES_VERSION ); ?></p> |
| 338 |
<?php usces_admin_action_status( $usces_status, $usces_message ); ?> |
| 339 |
<?php wp_nonce_field( 'item_master_list', 'wc_nonce' ); ?> |
| 340 |
|
| 341 |
<div id="datatable"> |
| 342 |
<div id="tablenavi"><?php wel_esc_script_e( $dataTableNavigation ); ?></div> |
| 343 |
|
| 344 |
<div id="tablesearch"> |
| 345 |
<div id="searchBox"> |
| 346 |
<table id="search_table"> |
| 347 |
<tr> |
| 348 |
<td><?php esc_html_e( 'search fields', 'usces' ); ?></td> |
| 349 |
<td><select name="search[column]" class="searchselect" id="searchselect"> |
| 350 |
<option value="none"> </option> |
| 351 |
<?php |
| 352 |
foreach ( $arr_column as $key => $value ) : |
| 353 |
if ( $value === $arr_search['column'] ) { |
| 354 |
$selected = ' selected="selected"'; |
| 355 |
} else { |
| 356 |
$selected = ''; |
| 357 |
} |
| 358 |
if ( 'sku_key' !== $value && 'price' !== $value ) : |
| 359 |
if ( 'zaiko_num' === $value ) { |
| 360 |
?> |
| 361 |
<option value="<?php echo esc_attr( $value ); ?>"<?php echo esc_attr( $selected ); ?>><?php esc_html_e( 'items without stock', 'usces' ); ?></option> |
| 362 |
<?php |
| 363 |
} elseif ( version_compare( USCES_MYSQL_VERSION, '5.0.0', '<' ) && 'item_code' === $value ) { |
| 364 |
continue; |
| 365 |
} else { |
| 366 |
?> |
| 367 |
<option value="<?php echo esc_attr( $value ); ?>"<?php echo esc_attr( $selected ); ?>><?php echo esc_html( $key ); ?></option> |
| 368 |
<?php |
| 369 |
} |
| 370 |
endif; |
| 371 |
endforeach; |
| 372 |
?> |
| 373 |
</select></td> |
| 374 |
<td id="searchlabel"></td> |
| 375 |
<td id="searchfield"></td> |
| 376 |
<td><input name="searchIn" type="submit" class="searchbutton button" value="<?php esc_attr_e( 'Search', 'usces' ); ?>" /> |
| 377 |
<input name="searchOut" type="submit" class="searchbutton button" value="<?php esc_attr_e( 'Cancellation', 'usces' ); ?>" /> |
| 378 |
</td> |
| 379 |
</tr> |
| 380 |
</table> |
| 381 |
<table id="change_table"> |
| 382 |
<tr> |
| 383 |
<td><?php esc_html_e( 'Oparation in bulk', 'usces' ); ?></td> |
| 384 |
<td><select name="allchange[column]" class="searchselect" id="changeselect"> |
| 385 |
<option value="none"> </option> |
| 386 |
<option value="zaiko"><?php esc_html_e( 'Changes in stock status', 'usces' ); ?></option> |
| 387 |
<option value="display_status"><?php esc_html_e( 'Edit the display status', 'usces' ); ?></option> |
| 388 |
<option value="delete"><?php esc_html_e( 'Delete in bulk', 'usces' ); ?></option> |
| 389 |
<?php echo apply_filters( 'usces_filter_item_list_allchange_column', '' ); ?> |
| 390 |
</select></td> |
| 391 |
<td id="changelabel"></td> |
| 392 |
<td id="changefield"></td> |
| 393 |
<td><input name="collective" type="submit" class="searchbutton button"" id="collective_change" value="<?php esc_attr_e( 'start', 'usces' ); ?>" /> |
| 394 |
<!--<a href="#" id="up_dlg"><?php esc_html_e( 'Collective registration item', 'usces' ); ?></a>--> |
| 395 |
</td> |
| 396 |
</tr> |
| 397 |
</table> |
| 398 |
<table id="dl_list_table"> |
| 399 |
<tr> |
| 400 |
<?php do_action( 'usces_action_dl_item_list_table' ); ?> |
| 401 |
<?php echo apply_filters( 'usces_filter_dl_item_list_table', '' ); ?> |
| 402 |
<td><input type="button" id="up_itemlist" class="searchbutton button" value="<?php esc_attr_e( 'Collective registration item', 'usces' ); ?>" /></td> |
| 403 |
<td><input type="button" id="dl_itemlist" class="searchbutton button" value="<?php esc_attr_e( 'Download Item List', 'usces' ); ?>" /></td> |
| 404 |
</tr> |
| 405 |
</table> |
| 406 |
<div<?php if ( has_action( 'usces_action_item_list_searchbox_bottom' ) ) echo ' class="searchbox_bottom"'; ?>> |
| 407 |
<?php do_action( 'usces_action_item_list_searchbox_bottom' ); ?> |
| 408 |
</div> |
| 409 |
<input name="action" id="itemlistaction" type="hidden" /> |
| 410 |
</div><!-- #searchBox --> |
| 411 |
</div><!-- #tablesearch --> |
| 412 |
|
| 413 |
<table id="mainDataTable" cellspacing="1"> |
| 414 |
<tr> |
| 415 |
<th scope="col"><input name="allcheck" type="checkbox" value="" /></th> |
| 416 |
<th scope="col"> </th> |
| 417 |
<?php |
| 418 |
foreach ( (array) $arr_header as $key => $value ) : |
| 419 |
if ( 'post_id' === $key ) { |
| 420 |
continue; |
| 421 |
} |
| 422 |
if ( 'item_code' === $key ) : |
| 423 |
?> |
| 424 |
<th scope="col"><?php wel_esc_script_e( $value ); ?> / |
| 425 |
<?php elseif ( 'item_name' === $key || 'post_title' === $key ) : ?> |
| 426 |
<?php wel_esc_script_e( $value ); ?></th> |
| 427 |
<?php elseif ( 'price' === $key ) : ?> |
| 428 |
<th scope="col"><?php wel_esc_script_e( $value ); ?>(<?php usces_crcode(); ?>)</th> |
| 429 |
<?php else : ?> |
| 430 |
<th scope="col"><?php wel_esc_script_e( $value ); ?></th> |
| 431 |
<?php |
| 432 |
endif; |
| 433 |
endforeach; |
| 434 |
?> |
| 435 |
</tr> |
| 436 |
<?php |
| 437 |
foreach ( (array) $rows as $array ) : |
| 438 |
$post_id = $array['ID']; |
| 439 |
$product = wel_get_product( $post_id ); |
| 440 |
$post = $product['_pst']; |
| 441 |
$array['sku'] = $product['_sku']; |
| 442 |
$array['category'] = ''; |
| 443 |
$array['post_status'] = $post->post_status; |
| 444 |
$array['item_code'] = $product['itemCode']; |
| 445 |
$array['item_name'] = $product['itemName']; |
| 446 |
$pctid = wel_get_main_pict_id_by_code( $product['itemCode'] ); |
| 447 |
|
| 448 |
$array = apply_filters( 'usces_filter_itemlist_body', $array ); |
| 449 |
$item_image = wp_get_attachment_image( $pctid, array( 50, 50 ), true ); |
| 450 |
?> |
| 451 |
<tr> |
| 452 |
<td width="20px" align="center"><input name="listcheck[]" type="checkbox" value="<?php echo (int) $post_id; ?>" /></td> |
| 453 |
<td width="50px"> |
| 454 |
<a href="<?php echo esc_url( USCES_ADMIN_URL . '?page=usces_itemedit&action=edit&post=' . $post_id . '&usces_referer=' . $curent_url ); ?>" title="<?php echo esc_attr( $array['item_name'] ); ?>"> |
| 455 |
<?php wel_esc_script_e( apply_filters( 'usces_filter_item_master_thumbnail', $item_image, $pctid, $array ) ); ?> |
| 456 |
</a> |
| 457 |
</td> |
| 458 |
<?php |
| 459 |
foreach ( (array) $array as $key => $value ) : |
| 460 |
if ( 'item_code' === $key ) : |
| 461 |
?> |
| 462 |
<td class="item"> |
| 463 |
<?php if ( '' != $value ) : ?> |
| 464 |
<strong><?php echo esc_html( $value ); ?></strong> |
| 465 |
<?php else : ?> |
| 466 |
|
| 467 |
<?php endif; ?> |
| 468 |
<br /> |
| 469 |
<?php |
| 470 |
elseif ( 'item_name' === $key ) : |
| 471 |
if ( '' != $value ) : |
| 472 |
?> |
| 473 |
<strong><?php echo esc_html( $value ); ?></strong> |
| 474 |
<?php else : ?> |
| 475 |
|
| 476 |
<?php endif; ?> |
| 477 |
<ul class="item_list_navi"> |
| 478 |
<?php |
| 479 |
if ( current_user_can( 'edit_post', $post_id ) ) { |
| 480 |
?> |
| 481 |
<li><a href="<?php echo esc_url( USCES_ADMIN_URL . '?page=usces_itemedit&action=edit&post=' . $post_id . '&usces_referer=' . $curent_url ); ?>"><?php esc_html_e( 'edit', 'usces' ); ?></a></li> |
| 482 |
<li> | </li> |
| 483 |
<?php |
| 484 |
} |
| 485 |
|
| 486 |
if ( current_user_can( 'delete_post', $post_id ) ) { |
| 487 |
if ( 'trash' === $post->post_status ) { |
| 488 |
$actions['untrash'] = "<li><a title='" . esc_attr( __( 'Restore this post from the Trash' ) ) . "' href='" . wp_nonce_url( "post.php?action=untrash&post=$post_id", 'untrash-post_' . $post_id ) . "'>" . __( 'Restore' ) . '</a></li><li> | </li>'; |
| 489 |
wel_esc_script_e( $actions['untrash'] ); |
| 490 |
} elseif ( EMPTY_TRASH_DAYS ) { |
| 491 |
$actions['trash'] = "<li><a class='submitdelete' title='" . esc_attr( __( 'Move this post to the Trash' ) ) . "' href='" . get_delete_post_link( $post_id ) . "'>" . __( 'Trash', 'usces' ) . '</a></li>'; |
| 492 |
wel_esc_script_e( $actions['trash'] ); |
| 493 |
} |
| 494 |
if ( 'trash' === $post->post_status || ! EMPTY_TRASH_DAYS ) { |
| 495 |
$actions['delete'] = "<li><a class='submitdelete' title='" . esc_attr( __( 'Delete this post permanently' ) ) . "' href='" . wp_nonce_url( "post.php?action=delete&post=$post_id", 'delete-post_' . $post_id ) . "'>" . __( 'Delete Permanently' ) . '</a></li>'; |
| 496 |
wel_esc_script_e( $actions['delete'] ); |
| 497 |
} |
| 498 |
echo '<li> | </li>'; |
| 499 |
} |
| 500 |
?> |
| 501 |
<li><a href="<?php echo esc_url( get_permalink( $post_id ) ); ?>"><?php esc_html_e( 'Visible' ); ?></a></li> |
| 502 |
</ul> |
| 503 |
</td> |
| 504 |
<?php |
| 505 |
elseif ( 'sku' === $key ) : |
| 506 |
if ( is_array( $value ) ) { |
| 507 |
$no_sku = ( 0 === count( $value ) ) ? ' ' : ''; |
| 508 |
} else { |
| 509 |
$no_sku = ' '; |
| 510 |
} |
| 511 |
ob_start(); |
| 512 |
?> |
| 513 |
<td class="sku"> |
| 514 |
<?php |
| 515 |
$i = 0; |
| 516 |
foreach ( (array) $value as $skey => $sv ) { |
| 517 |
$bgc = ( $i % 2 === 1 ) ? ' bgc1' : ' bgc2'; |
| 518 |
$i++; |
| 519 |
?> |
| 520 |
<div class="skuline<?php echo esc_attr( $bgc ); ?>"><?php echo esc_html( $sv['code'] ); ?> |
| 521 |
<?php |
| 522 |
if ( ! empty( $sv['name'] ) ) { |
| 523 |
echo '(' . esc_html( $sv['name'] ) . ')'; |
| 524 |
} |
| 525 |
?> |
| 526 |
</div> |
| 527 |
<?php |
| 528 |
} |
| 529 |
echo esc_attr( $no_sku ); |
| 530 |
?> |
| 531 |
</td> |
| 532 |
<td class="price"> |
| 533 |
<?php |
| 534 |
$i = 0; |
| 535 |
foreach ( (array) $value as $skey => $sv ) { |
| 536 |
$bgc = ( $i % 2 === 1 ) ? ' bgc1' : ' bgc2'; |
| 537 |
$i++; |
| 538 |
?> |
| 539 |
<div class="priceline<?php echo esc_attr( $bgc ); ?>"><?php usces_crform( $sv['price'], true, false ); ?></div> |
| 540 |
<?php |
| 541 |
} |
| 542 |
echo esc_attr( $no_sku ); |
| 543 |
?> |
| 544 |
</td> |
| 545 |
<td class="zaikonum"> |
| 546 |
<?php |
| 547 |
$i = 0; |
| 548 |
foreach ( (array) $value as $skey => $sv ) { |
| 549 |
$stocknum = ( ! WCUtils::is_blank( $sv['stocknum'] ) ) ? esc_html( $sv['stocknum'] ) : ' '; |
| 550 |
$bgc = ( $i % 2 === 1 ) ? ' bgc1' : ' bgc2'; |
| 551 |
$i++; |
| 552 |
?> |
| 553 |
<div class="priceline<?php echo esc_attr( $bgc ); ?>"><?php echo $stocknum; ?></div> |
| 554 |
<?php |
| 555 |
} |
| 556 |
echo esc_attr( $no_sku ); |
| 557 |
?> |
| 558 |
</td> |
| 559 |
<td class="zaiko"> |
| 560 |
<?php |
| 561 |
$i = 0; |
| 562 |
foreach ( (array) $value as $skey => $sv ) { |
| 563 |
$zaikokey = $sv['stock']; |
| 564 |
$bgc = ( $i % 2 === 1 ) ? ' bgc1' : ' bgc2'; |
| 565 |
$i++; |
| 566 |
?> |
| 567 |
<div class="zaikoline<?php echo esc_attr( $bgc ); ?>"><?php echo esc_html( $zaiko_status[ $zaikokey ] ); ?></div> |
| 568 |
<?php |
| 569 |
} |
| 570 |
echo esc_attr( $no_sku ); |
| 571 |
?> |
| 572 |
</td> |
| 573 |
<?php |
| 574 |
$skuargs = compact( 'no_sku', 'key', 'value', 'i', 'zaiko_status', 'post_id' ); |
| 575 |
$skufield = apply_filters( 'usces_filter_itemlist_skufield', ob_get_contents(), $skuargs ); |
| 576 |
ob_end_clean(); |
| 577 |
echo $skufield; // no escape due to filter. |
| 578 |
|
| 579 |
elseif ( 'category' === $key ) : |
| 580 |
?> |
| 581 |
<td class="listcat"> |
| 582 |
<?php |
| 583 |
$cat_ids = wp_get_post_categories( $post_id ); |
| 584 |
if ( ! empty( $cat_ids ) ) { |
| 585 |
$out = array(); |
| 586 |
foreach ( $cat_ids as $id ) { |
| 587 |
$out[] = get_cat_name( $id ); |
| 588 |
} |
| 589 |
echo esc_html( join( ', ', $out ) ); |
| 590 |
} else { |
| 591 |
esc_html_e( 'Uncategorized' ); |
| 592 |
} |
| 593 |
?> |
| 594 |
</td> |
| 595 |
<?php elseif ( 'post_status' === $key ) : ?> |
| 596 |
<td> |
| 597 |
<?php |
| 598 |
switch ( $value ) { |
| 599 |
case 'publish': |
| 600 |
esc_html_e( 'Published', 'usces' ); |
| 601 |
break; |
| 602 |
case 'future': |
| 603 |
esc_html_e( 'Scheduled', 'usces' ); |
| 604 |
break; |
| 605 |
case 'draft': |
| 606 |
esc_html_e( 'Draft', 'usces' ); |
| 607 |
break; |
| 608 |
case 'pending': |
| 609 |
esc_html_e( 'Pending Review', 'usces' ); |
| 610 |
break; |
| 611 |
case 'trash': |
| 612 |
esc_html_e( 'Trash', 'usces' ); |
| 613 |
break; |
| 614 |
default: |
| 615 |
esc_html_e( 'Closed', 'usces' ); |
| 616 |
} |
| 617 |
if ( ! empty( $post->post_password ) ) { |
| 618 |
echo '<br />' . esc_html__( 'Password protected' ); |
| 619 |
} |
| 620 |
?> |
| 621 |
</td> |
| 622 |
<?php endif; ?> |
| 623 |
<?php do_action( 'usces_action_itemlist_detail', $key, $value ); ?> |
| 624 |
<?php endforeach; ?> |
| 625 |
</tr> |
| 626 |
<?php endforeach; ?> |
| 627 |
</table><!-- #mainDataTable --> |
| 628 |
<div id="tablenavi_bottom"><?php wel_esc_script_e( $dataTableNavigationBottom ); ?></div> |
| 629 |
</div><!-- #datatable --> |
| 630 |
<?php echo apply_filters( 'usces_filter_item_list_footer', '' ); ?> |
| 631 |
</form> |
| 632 |
|
| 633 |
<div id="upload_dialog" class="upload_dialog"> |
| 634 |
<?php if ( ! current_user_can( 'wel_others_products' ) ) : ?> |
| 635 |
<p><?php esc_html_e( 'You have no permission to upload files.', 'usces' ); ?></p> |
| 636 |
<?php else : ?> |
| 637 |
<p id="dialogExp"></p> |
| 638 |
<form action="<?php echo esc_url( USCES_ADMIN_URL . '?page=usces_itemedit' ); ?>" method="post" enctype="multipart/form-data" name="upform" id="upform" onsubmit="if( jQuery('#usces_upcsv').val() == '' ){alert('<?php esc_attr_e( 'File is not selected.', 'usces' ); ?>'); return false; }else{jQuery('#dialogExp').html('<span><?php esc_attr_e( 'Uploading now', 'usces' ); ?></span>');}"> |
| 639 |
<fieldset> |
| 640 |
<input type="radio" name="upload_mode" id="upload_mode_all" value="all" checked="checked" /><label for="upload_mode_all"><?php esc_html_e( 'All columns', 'usces' ); ?></label> |
| 641 |
<input type="radio" name="upload_mode" id="upload_mode_stock" value="stock" /><label for="upload_mode_stock"><?php esc_html_e( 'Stock columns', 'usces' ); ?></label> |
| 642 |
<input type="radio" name="upload_mode" id="upload_mode_sku" value="sku" /><label for="upload_mode_sku"><?php esc_html_e( 'SKU columns', 'usces' ); ?></label> |
| 643 |
<input type="radio" name="upload_mode" id="upload_mode_meta" value="meta" /><label for="upload_mode_meta"><?php esc_html_e( 'Custom Field columns', 'usces' ); ?></label> |
| 644 |
<?php echo apply_filters( 'usces_filter_item_list_upload_mode', '' ); ?> |
| 645 |
</fieldset> |
| 646 |
<fieldset id="usces_upcsv_button"> |
| 647 |
<input name="usces_upcsv" type="file" id="usces_upcsv" style="width:100%" /> |
| 648 |
</fieldset> |
| 649 |
<?php echo apply_filters( 'usces_filter_item_list_upload_dialog', '' ); ?> |
| 650 |
<input name="itemcsv" type="submit" id="upcsv" class="button" value="<?php esc_attr_e( 'Registration start', 'usces' ); ?>" /> |
| 651 |
<input name="checkcsv" type="submit" id="checkcsv" class="button" value="<?php esc_attr_e( 'Data check', 'usces' ); ?>" /> |
| 652 |
<input name="action" type="hidden" value="upload_register" /> |
| 653 |
<?php wp_nonce_field( 'wel_item' ); ?> |
| 654 |
</form> |
| 655 |
<p><?php esc_html_e( 'Indication is updated after upload completion.', 'usces' ); ?></p> |
| 656 |
<?php endif; ?> |
| 657 |
</div><!-- #upload_dialog --> |
| 658 |
<div id="dlItemListDialog" title="<?php esc_attr_e( 'Download Item List', 'usces' ); ?>"> |
| 659 |
<p><?php esc_html_e( 'Choose the file format, and push the download.', 'usces' ); ?></p> |
| 660 |
<fieldset> |
| 661 |
<input type="radio" name="download_mode" id="download_mode_all" value="all" checked="checked" /><label for="download_mode_all"><?php esc_html_e( 'All columns', 'usces' ); ?></label> |
| 662 |
<input type="radio" name="download_mode" id="download_mode_stock" value="stock" /><label for="download_mode_stock"><?php esc_html_e( 'Stock columns', 'usces' ); ?></label> |
| 663 |
<input type="radio" name="download_mode" id="download_mode_sku" value="sku" /><label for="download_mode_sku"><?php esc_html_e( 'SKU columns', 'usces' ); ?></label> |
| 664 |
<input type="radio" name="download_mode" id="download_mode_custom" value="meta" /><label for="download_mode_custom"><?php esc_html_e( 'Custom Field columns', 'usces' ); ?></label> |
| 665 |
<?php echo apply_filters( 'usces_filter_item_list_download_mode', '' ); ?> |
| 666 |
</fieldset> |
| 667 |
<fieldset> |
| 668 |
<?php $chk_header = ( isset( $usces_opt_item['chk_header'] ) && 1 === (int) $usces_opt_item['chk_header'] ) ? ' checked="checked"' : ''; ?> |
| 669 |
<label for="chk_header"><input type="checkbox" class="check_item" id="chk_header" value="1"<?php echo esc_attr( $chk_header ); ?> /><?php esc_html_e( 'To add a subject title at the first line', 'usces' ); ?></label> |
| 670 |
<?php echo apply_filters( 'usces_filter_item_list_download_dialog', '' ); ?> |
| 671 |
</fieldset> |
| 672 |
<div><input type="button" class="button" id="dl_item" value="<?php esc_attr_e( 'Download', 'usces' ); ?>" /></div> |
| 673 |
<?php do_action( 'usces_action_item_list_download_dialog' ); ?> |
| 674 |
</div><!-- #dlItemListDialog --> |
| 675 |
<?php do_action( 'usces_action_item_list_footer' ); ?> |
| 676 |
|
| 677 |
</div><!-- .usces_admin --> |
| 678 |
</div><!-- .wrap --> |
| 679 |
[memory peak usage] <?php echo esc_attr( round( memory_get_peak_usage() / 1048576, 1 ) ); ?>Mb |
| 680 |
|