// JavaScript (function($) { $("#aAdditionalURLs").click(function () { $("#AdditionalURLs").toggle(); }); itemOpt = { settings: { url: uscesL10n.requestFile, type: 'POST', cache: false }, post : function(action, arg) { if( action == 'updateitemopt' ) { itemOpt.updateitemopt(arg); } else if( action == 'deleteitemopt' ) { itemOpt.deleteitemopt(arg); } else if( action == 'additemopt' ) { itemOpt.additemopt(); } else if( action == 'addcommonopt' ) { itemOpt.addcommonopt(); } else if( action == 'keyselect' ) { itemOpt.keyselect(arg); } }, additemopt : function() { if( undefined == $("#optkeyselect").val() || $("#optkeyselect").val() == "#NONE#") return; var id = $("#post_ID").val(); var name = $("#optkeyselect option:selected").html(); var value = $("#newoptvalue").val(); var means = $("#newoptmeans").val(); var wc_nonce = $("#wc_nonce").val(); var _wp_http_referer = $("input[name='_wp_http_referer']").val(); if($("input#newoptessential").prop("checked")){ var essential = '1'; }else{ var essential = '0'; } var mes = ''; if( '' == name ){ mes += '
'+uscesL10n.message[0]+'
'; } else { var check = true; $("input[name*='\[name\]']").each(function(){ if( name == $(this).val() ){ check = false; }}); if( !check ){ mes += ''+uscesL10n.message[1]+'
'; } } if( '' == value && (0 == means || 1 == means || 3 == means || 4 == means) ){ mes += ''+uscesL10n.message[2]+'
'; }else if( '' != value && (2 == means || 5 == means) ){ mes += ''+uscesL10n.message[3]+'
'; } if( '' != mes ){ $("#itemopt_ajax-response").html('
');
var s = itemOpt.settings;
s.data = "action=item_option_ajax&ID=" + id + "&newoptname=" + encodeURIComponent(name) + "&newoptvalue=" + encodeURIComponent(value) + "&newoptmeans=" + encodeURIComponent(means) + "&newoptessential=" + encodeURIComponent(essential) + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer);
$.ajax( s ).done(function( data ){
var meta_id = data.meta_id;
$("#itemopt_ajax-response").html('');
$("#newitemopt_loading").html('');
$("table#optlist-table").removeAttr("style");
$("tbody#item-opt-list").html( data.meta_row );
$("#optkeyselect").val('#NONE#');
$("#newoptvalue").html('');
$("#newoptmeans").val(0);
$("#newoptessential").prop( "checked", false );
$("#itemopt-" + meta_id).css({'background-color': '#FF4'});
$("#itemopt-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 2000 );
}).fail(function( msg ){
$("#itemopt_ajax-response").html(msg);
$("#newitemopt_loading").html('');
});
return false;
},
addcommonopt : function() {
var id = $("#post_ID").val();
var name = $("#newoptname").val();
var value = $("#newoptvalue").val();
var means = $("#newoptmeans").val();
var wc_nonce = $("#wc_nonce").val();
var _wp_http_referer = $("input[name='_wp_http_referer']").val();
if($("input#newoptessential").prop("checked")){
var essential = '1';
}else{
var essential = '0';
}
var mes = '';
if( '' == name ){
mes += ''+uscesL10n.message[0]+'
'; } else { var check = true; $("input[name*='\[name\]']").each(function(){ if( name == $(this).val() ){ check = false; }}); if( !check ){ mes += ''+uscesL10n.message[1]+'
'; } } if( '' == value && (0 == means || 1 == means || 3 == means || 4 == means) ){ mes += ''+uscesL10n.message[2]+'
'; }else if( '' != value && (2 == means || 5 == means) ){ mes += ''+uscesL10n.message[3]+'
'; } if( '' != mes ){ $("#itemopt_ajax-response").html('
');
var s = itemOpt.settings;
s.data = "action=item_option_ajax&ID=" + id + "&newoptname=" + encodeURIComponent(name) + "&newoptvalue=" +encodeURIComponent(value) + "&newoptmeans=" + encodeURIComponent(means) + "&newoptessential=" + encodeURIComponent(essential) + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer);
$.ajax( s ).done(function( data ){
var meta_id = data.meta_id;
$("#newcomopt_loading").html('');
$("#itemopt_ajax-response").html('');
$("table#optlist-table").removeAttr("style");
if( 0 > meta_id ){
$("#itemopt_ajax-response").html(''+uscesL10n.message[1]+'
'+uscesL10n.message[0]+'
'; } else { var check = true; $("input[name*='[name]']").each(function() { var thisName = $(this).attr('name'); var match = thisName.match(/itemopt\[(\d+)\]/); if (match && match[1]) { var thisId = +match[1]; if (thisId != meta_id && $(this).val() == name) { check = false; } } }); if( !check ){ mes += ''+uscesL10n.message[1]+'
'; } } if( '' == value && (0 == means || 1 == means || 3 == means || 4 == means) ){ mes += ''+uscesL10n.message[2]+'
'; }else if( '' != value && (2 == means || 5 == means) ){ mes += ''+uscesL10n.message[3]+'
'; } if( '' != mes ){ $("#itemopt_ajax-response").html('
');
var s = itemOpt.settings;
s.data = "action=item_option_ajax&ID=" + id + "&update=1&optname=" + encodeURIComponent(name) + "&optvalue=" + encodeURIComponent(value) + "&optmeans=" + means + "&optessential=" + essential + "&sort=" + sortnum + "&optmetaid=" + meta_id + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer);
$.ajax( s ).done(function( data ){
$("#itemopt_ajax-response").html('');
$("#itemopt_loading-" + meta_id).html('');
$("tbody#item-opt-list").html( data.meta_row );
$("#itemopt-" + meta_id).css({'background-color': '#FF4'});
$("#itemopt-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 2000 );
}).fail(function( msg ){
$("#itemopt_ajax-response").html(msg);
$("#itemopt_loading-" + meta_id).html('');
});
return false;
},
deleteitemopt : function(meta_id) {
$("#itemopt-" + meta_id).css({'background-color': '#F00'});
$("#itemopt-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 1000 );
var id = $("#post_ID").val();
var wc_nonce = $("#wc_nonce").val();
var _wp_http_referer = $("input[name='_wp_http_referer']").val();
var s = itemOpt.settings;
s.data = "action=item_option_ajax&ID=" + id + "&delete=1&optmetaid=" + meta_id + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer);
$.ajax( s ).done(function( data ){
$("#itemopt_ajax-response").html("");
$("tbody#item-opt-list").html( data.meta_row );
}).fail(function( msg ){ });
return false;
},
keyselect : function( meta_id ) {
if(meta_id == '#NONE#'){
$("#newoptvalue").val('');
$("#newoptmeans").val(0);
$("#newoptessential").prop( "checked", false );
return;
}
var id = uscesL10n.cart_number;
var wc_nonce = $("#wc_nonce").val();
var _wp_http_referer = $("input[name='_wp_http_referer']").val();
$("#newitemopt_loading").html('
');
$("#add_itemopt").prop( "disabled", true );
var s = itemOpt.settings;
s.data = "action=item_option_ajax&ID=" + id + "&select=1&meta_id=" + meta_id + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer);
$.ajax( s ).done(function( data ){
$("#itemopt_ajax-response").html("");
var means = data.means;
var essential = data.essential;
var value = ( 2 == means || 5 == means ) ? '' : data.value;
value = esc_js( String( value ) );
$("#newoptvalue").html(value);
$("#newoptmeans").val(means);
$("#newoptessential").prop( "checked", essential == '1' );
$("#newitemopt_loading").html('');
$("#add_itemopt").prop( "disabled", false );
}).fail(function(msg){
$("#itemopt_ajax-response").html(msg);
$("#newitemopt_loading").html('');
});
return false;
},
dosort : function( str ) {
if( !str ) return;
var id = $("#post_ID").val();
var meta_id_str = str.replace(/itemopt-/g, "");
var meta_ids = meta_id_str.split(',');
var wc_nonce = $("#wc_nonce").val();
var _wp_http_referer = $("input[name='_wp_http_referer']").val();
if( 2 > meta_ids.length ) return;
for(i=0; ierror sort
'); }); return false; } }; itemSku = { settings: { url: uscesL10n.requestFile, type: 'POST', cache: false }, post : function(action, arg) { if( action == 'updateitemsku' ) { itemSku.updateitemsku(arg); } else if( action == 'deleteitemsku' ) { var ele_sku_key = $( '#itemsku-' + arg + ' input[name="itemsku[' + arg + '][key]"]' ); if ( ele_sku_key.length ) { if( ! confirm( uscesL10n.message[25].replace( '********', ele_sku_key.val() ) ) ) { return; } } itemSku.deleteitemsku(arg); } else if( action == 'additemsku' ) { itemSku.additemsku(); } else if( action == 'keyselect' ) { itemSku.keyselect(arg); } }, additemsku : function() { var id = $("#post_ID").val(); var name = $("#newskuname").val(); var cprice = $("#newskucprice").val(); var price = $("#newskuprice").val(); var zaikonum = $("#newskuzaikonum").val(); var zaiko = $("#newskuzaikoselect").val(); var skudisp = $("#newskudisp").val(); var skuunit = $("#newskuunit").val(); var skugptekiyo = $("#newskugptekiyo").val(); var applicable_taxrate = ''; if( undefined != $( "#newsku_applicable_taxrate" ) ) { applicable_taxrate = $( "#newsku_applicable_taxrate option:selected" ).val(); } var mes = ''; if( '' == name ) mes += ''+uscesL10n.message[4]+'
'; if( '' == price ) mes += ''+uscesL10n.message[5]+'
'; // if( ! checkCode( name ) ) // mes += ''+uscesL10n.message[6]+'
'; if( ! checkMoney( cprice ) ) mes += ''+uscesL10n.message[7]+'
'; if( ! checkMoney( price ) ) mes += ''+uscesL10n.message[8]+'
'; if( undefined != $("#itemOrderAcceptable") && $("#itemOrderAcceptable").prop("checked") ) { if( ! checkNumMinus( zaikonum ) ) mes += ''+uscesL10n.message[9]+'
'; } else { if( ! checkNum( zaikonum ) ) mes += ''+uscesL10n.message[9]+'
'; } if( '' != mes ){ $("#sku_ajax-response").html('
');
var s = itemSku.settings;
var wc_nonce = $("#wc_nonce").val();
s.data = "action=item_sku_ajax&ID=" + id + "&wc_nonce=" + wc_nonce + "&newskuname=" + encodeURIComponent(name) + "&newskucprice=" + cprice + "&newskuprice=" + price + "&newskuzaikonum=" + zaikonum + "&newskuzaikoselect=" + encodeURIComponent(zaiko) + "&newskudisp=" + encodeURIComponent(skudisp) + "&newskuunit=" + encodeURIComponent(skuunit) + "&newskugptekiyo=" + skugptekiyo + skuadvance;
if( '' != applicable_taxrate ) {
s.data += "&newskutaxrate=" + applicable_taxrate;
}
var hookargs = {
postId: id,
price,
cprice,
zaikonum,
zaiko,
name,
skudisp,
skuunit,
skugptekiyo,
applicable_taxrate,
skuadvance
}
$.ajax( s ).done(function( data ){
$("#newitemsku_loading").html('');
$("#sku_ajax-response").html("");
$("table#skulist-table").removeAttr("style");
var meta_id = data.meta_id;
hookargs.metaId = meta_id;
hookargs.response = data;
if( data.meta_msg && '' != data.meta_msg ) {
$("#sku_ajax-response").html(''+data.meta_msg+'
'+uscesL10n.message[10]+'
'+uscesL10n.message[4]+'
'; if( '' == price ) mes += ''+uscesL10n.message[5]+'
'; if( ! checkMoney( cprice ) ) mes += ''+uscesL10n.message[7]+'
'; if( ! checkMoney( price ) ) mes += ''+uscesL10n.message[8]+'
'; //if( ! checkNum( zaikonum ) ) // mes += ''+uscesL10n.message[9]+'
'; if( undefined != $("#itemOrderAcceptable") && $("#itemOrderAcceptable").prop("checked") ) { if( ! checkNumMinus( zaikonum ) ) mes += ''+uscesL10n.message[9]+'
'; } else { if( ! checkNum( zaikonum ) ) mes += ''+uscesL10n.message[9]+'
'; } if( '' != mes ){ $("#sku_ajax-response").html('
');
var s = itemSku.settings;
var wc_nonce = $("#wc_nonce").val();
s.data = "action=item_sku_ajax&ID=" + id + "&wc_nonce=" + wc_nonce + "&update=1&skuprice=" + price + "&skucprice=" + cprice + "&skuzaikonum=" + zaikonum + "&skuzaiko=" + encodeURIComponent(zaiko) + "&skuname=" + encodeURIComponent(name) + "&skudisp=" + encodeURIComponent(skudisp) + "&skuunit=" + encodeURIComponent(skuunit) + "&skugptekiyo=" + skugptekiyo + "&sort=" + sortnum + "&skumetaid=" + meta_id + skuadvance;
if( '' != applicable_taxrate ) {
s.data += "&skutaxrate=" + applicable_taxrate;
}
var hookargs = {
metaId: meta_id,
postId: id,
price,
cprice,
zaikonum,
zaiko,
name,
skudisp,
skuunit,
skugptekiyo,
sortnum,
skuadvance
}
$.ajax( s ).done(function( data ){
hookargs.response = data;
$("#itemsku_loading-" + meta_id).html('');
$("#sku_ajax-response").html("");
$("table#skulist-table").removeAttr("style");
var id = data.meta_id;
if( data.meta_msg && '' != data.meta_msg ) {
$("#sku_ajax-response").html(''+data.meta_msg+'
'+uscesL10n.message[10]+'
'+data.meta_msg+'
error sort
'); }); return false; } }; payment = { settings: { url: uscesL10n.requestFile, type: 'POST', cache: false }, post : function(action, arg) { if( action == 'update' ) { payment.update(arg); } else if( action == 'del' ) { payment.del(arg); } else if( action == 'add' ) { payment.add(); } }, add : function() { var name = $("#newname").val(); var explanation = $("#newexplanation").val(); var settlement = $("#newsettlement").val(); var module = $("#newmodule").val(); var wc_nonce = $("#wc_nonce").val(); var _wp_http_referer = $("input[name='_wp_http_referer']").val(); var mes = ''; if( '' == name ){ mes += ''+uscesL10n.message[11]+'
'; } if( '#NONE#' == settlement ) { mes += ''+uscesL10n.message[12]+'
'; } if( 'acting' == settlement ) { if( '' == module ) { mes += ''+uscesL10n.message[13]+'
'; } } if( '' != mes ){ $("#payment_ajax-response").html('
');
var s = payment.settings;
s.data = "action=payment_ajax&newname=" + encodeURIComponent(name) + "&newexplanation=" + encodeURIComponent(explanation) + "&newsettlement=" + encodeURIComponent(settlement) + "&newmodule=" + encodeURIComponent(module) + "&wc_nonce=" + encodeURIComponent(wc_nonce) + "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer);
$.ajax( s ).done(function( data ){
$("#newpayment_loading").html('');
$("#payment_ajax-response").html('');
$("table#payment-table").removeAttr("style");
if( -1 == data.meta_id ){
$("#payment_ajax-response").html(''+uscesL10n.message[14]+'
'+uscesL10n.message[11]+'
'; } if( '#NONE#' == settlement && 'activate' == use ) { mes += ''+uscesL10n.message[12]+'
'; } if( 'acting' == settlement ) { if( '' == module ) { mes += ''+uscesL10n.message[13]+'
'; } } if( '' != mes ){ $("#payment_ajax-response").html('
');
s.data = "action=payment_ajax&update=1&id=" + id + "&name=" + encodeURIComponent(name) + "&explanation=" + encodeURIComponent(explanation) + "&settlement=" + encodeURIComponent(settlement) + "&module=" + encodeURIComponent(module) + "&sort=" + sortid + "&use=" + use + "&wc_nonce=" + encodeURIComponent(wc_nonce) + "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer);
$.ajax( s ).done(function( data ){
$("#payment_loading-" + id).html('');
$("#payment_ajax-response").html("");
if( -1 == data.meta_id ){
$("#payment_ajax-response").html(''+uscesL10n.message[14]+'
error sort
'); }); return false; } }; orderItem = { settings: { url: uscesL10n.requestFile, type: 'POST', cache: false }, add2cart : function(newid, newsku) { var ID = $("input[name='order_id']").val(); var wc_nonce = $("#wc_nonce").val(); var optob; var optvalue = ''; var query = 'action=order_item2cart_ajax&order_id='+ID+'&post_id='+newid+'&sku='+newsku + '&wc_nonce=' + encodeURIComponent(wc_nonce); var newoptob = $("input[name*='optNEWCode\[" + newid + "\]\[" + newsku + "\]']"); var newoptvalue = ''; var mes = ''; for( var n = 0; n < newoptob.length; n++) { newoptvalue = $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").val(); var newoptclass = $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").attr("class"); var essential = $(":input[name='optNEWEssential\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").val(); switch(newoptclass) { case 'iopt_select_multiple': var sel = 0; if( essential == 1 ) { $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]'] option:selected").each(function(idx, obj) { if( '#NONE#' != $(this).val()) { sel++; } }); if( sel == 0 ) { mes += uscesL10n.message[15].replace( "%s", decodeURIComponent($(newoptob[n]).val()) )+"\n"; } } $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]'] option:selected").each(function(idx, obj) { if( '#NONE#' != $(this).val()) { query += "&itemOption[" + $(newoptob[n]).val() + "][" + encodeURIComponent($(this).val()) + "]="+encodeURIComponent($(this).val()); } }); break; case 'iopt_select': if( essential == 1 && newoptvalue == '#NONE#' ) { mes += uscesL10n.message[15].replace( "%s", decodeURIComponent($(newoptob[n]).val()) )+"\n"; } else { query += "&itemOption[" + $(newoptob[n]).val() + "]="+encodeURIComponent(newoptvalue); } break; case 'iopt_radio': var sel = 0; var ra = ''; if( $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']:checked").val() ) { sel++; ra = $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']:checked").val(); } if( essential == 1 && sel == 0 ) { mes += uscesL10n.message[15].replace( "%s", decodeURIComponent($(newoptob[n]).val()) )+"\n"; } query += "&itemOption[" + $(newoptob[n]).val() + "]=" + ra; break; case 'iopt_checkbox': var sel = 0; if( essential == 1 ) { $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']:checked").each(function(idx, obj) { if( '' != $(this).val()) { sel++; } }); if( sel == 0 ) { mes += uscesL10n.message[15].replace( "%s", decodeURIComponent($(newoptob[n]).val()) )+"\n"; } } $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']:checked").each(function(idx, obj) { if( $(this).val()) { query += "&itemOption[" + $(newoptob[n]).val() + "][" + $(this).val() + "]=" + $(this).val(); } }); break; case 'iopt_text': case 'iopt_textarea': if( essential == 1 && newoptvalue == '' ) { mes += uscesL10n.message[16].replace( "%s", decodeURIComponent($(newoptob[n]).val()) )+"\n"; } else { query += "&itemOption[" + $(newoptob[n]).val() + "]="+encodeURIComponent(newoptvalue); } break; } } if( mes != '' ) { alert(mes); return; } var s = orderItem.settings; s.data = query; $.ajax( s ).done(function( data ){ $("#orderitemlist").html(data); orderfunc.sumPrice(null); }).fail(function( msg ){ $("#order-response").html(msg); }); return false; }, add2cart_old : function(newid, newsku) { var ID = $("input[name='order_id']").val(); var cnum = $("#orderitemlist").children().length; var priceob = $("input[name*='skuPrice']"); var quantob = $("input[name*='quant']"); var wc_nonce = $("#wc_nonce").val(); var name = ''; var strs = ''; var post_ids = []; var skus = []; var optob; var optvalue = ''; var query = 'action=order_item2cart_ajax&order_id='+ID + '&wc_nonce=' + encodeURIComponent(wc_nonce); for( var i = 0; i < cnum; i++) { name = $(priceob[i]).attr("name"); strs = name.split('['); post_ids[i] = strs[2].replace(/[\]]+$/g, ''); skus[i] = strs[3].replace(/[\]]+$/g, ''); query += "&skuPrice["+i+"]["+post_ids[i]+"]["+skus[i]+"]="+$("input[name='skuPrice\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]']").val(); query += "&quant["+i+"]["+post_ids[i]+"]["+skus[i]+"]="+$("input[name='quant\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]']").val(); optob = $("input[name*='optName\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]']"); optvalue = ''; for( var o = 0; o < optob.length; o++) { //optvalue = $("input[name='itemOption\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]\[" + $(optob[o]).val() + "\]']").val(); //if( '#NONE#' != optvalue){ // query += "&itemOption["+i+"]["+post_ids[i]+"]["+skus[i]+"][" + $(optob[o]).val() + "]="+optvalue; //} var cnt = 0; $("input[name^='itemOption\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]\[" + $(optob[o]).val() + "\]\[']").each(function(idx, obj) { cnt++; }); if(0 < cnt) { $("input[name^='itemOption\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]\[" + $(optob[o]).val() + "\]\[']").each(function(idx, obj) { query += "&itemOption["+i+"]["+post_ids[i]+"]["+skus[i]+"][" + $(optob[o]).val() + "][" + $(this).val() + "]="+$(this).val(); }); } else { optvalue = $("input[name='itemOption\["+i+"\]\["+post_ids[i]+"\]\["+skus[i]+"\]\["+$(optob[o]).val()+"\]']").val(); query += "&itemOption["+i+"]["+post_ids[i]+"]["+skus[i]+"]["+$(optob[o]).val()+"]="+optvalue; } } } query += "&skuPrice["+cnum+"]["+newid+"]["+newsku+"]="+$("input[name='skuNEWPrice\[" + newid + "\]\[" + newsku + "\]']").val(); query += "&quant["+cnum+"]["+newid+"]["+newsku+"]=1"; var newoptob = $("input[name*='optNEWCode\[" + newid + "\]\[" + newsku + "\]']"); var newoptvalue = ''; var mes = ''; for( var n = 0; n < newoptob.length; n++) { //newoptvalue = $("select[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").val(); newoptvalue = $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").val(); var newoptclass = $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").attr("class"); var essential = $(":input[name='optNEWEssential\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").val(); switch(newoptclass) { case 'iopt_select_multiple': var sel = 0; if( essential == 1 ) { $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]'] option:selected").each(function(idx, obj) { if( '#NONE#' != $(this).val()) { sel++; } }); } if( sel == 0 ) { mes += uscesL10n.message[15].replace( "%s", decodeURIComponent($(newoptob[n]).val()) )+"\n"; } else { $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]'] option:selected").each(function(idx, obj) { if( '#NONE#' != $(this).val()) { query += "&itemOption["+cnum+"]["+newid+"]["+newsku+"][" + $(newoptob[n]).val() + "][" + $(this).val() + "]="+$(this).val(); } }); } break; case 'iopt_select': if( essential == 1 && newoptvalue == '#NONE#' ) { mes += uscesL10n.message[15].replace( "%s", decodeURIComponent($(newoptob[n]).val()) )+"\n"; } else { query += "&itemOption["+cnum+"]["+newid+"]["+newsku+"][" + $(newoptob[n]).val() + "]="+newoptvalue; } break; case 'iopt_text': case 'iopt_textarea': if( essential == 1 && newoptvalue == '' ) { mes += uscesL10n.message[16].replace( "%s", decodeURIComponent($(newoptob[n]).val()) )+"\n"; } else { query += "&itemOption["+cnum+"]["+newid+"]["+newsku+"][" + $(newoptob[n]).val() + "]="+newoptvalue; } break; } } if( mes != '' ) { alert(mes); return; } var s = orderItem.settings; s.data = query; $.ajax( s ).done(function( data ){ //if(data == 'nodata'){return;} if( 0 > parseInt(data.meta_row) ) return; var pict = "
');
var wc_nonce = $("#wc_nonce").val();
var s = orderItem.settings;
s.data = "action=order_item_ajax&mode=get_item_select_option&cat_id=" + cat_id + "&wc_nonce=" + wc_nonce;
$.ajax( s ).done(function( data ){
$("#loading").html('');
$("#newitemcode").html( data );
}).fail(function( msg ){
$("#order-response").html(msg);
});
return false;
},
getitem : function(itemcode) {
if(itemcode == '-1'){
$("#newitemform").html('');
return false;
}
$("#loading").html('
');
var wc_nonce = $("#wc_nonce").val();
var s = orderItem.settings;
s.data = "action=order_item_ajax&mode=get_order_item&itemcode=" + itemcode + "&wc_nonce=" + wc_nonce;
$.ajax( s ).done(function( data ){
$("#loading").html('');
$("#newitemform").html( data );
}).fail(function( msg ){
$("#order-response").html(msg);
});
return false;
},
getmailmessage : function( flag ) {
$("#sendmailmessage").val( uscesL10n.now_loading );
$("#usces_email_bnt_send").prop("disabled", true);
var order_id = $("input[name='order_id']").val();
var s = orderItem.settings;
var wc_nonce = $("#wc_nonce").val();
s.data = "action=order_item_ajax&mode=" + flag + "&order_id=" + order_id + "&wc_nonce=" + wc_nonce;
$.ajax( s ).done(function( data ){
$("#sendmailmessage").val( data );
$("#usces_email_bnt_send").removeAttr('disabled');
}).fail(function( msg ){
$("#order-response").html(msg);
$("#usces_email_bnt_send").removeAttr('disabled');
});
return false;
},
getMailMessageRichEditor : function(usceAdminUrl, mode ) {
$("#loading_iframe").text(uscesL10n.now_loading);
$("#usces_email_bnt_preview").prop("disabled", true);
$("#usces_email_bnt_send").prop("disabled", true);
$("#loading_iframe").show();
var order_id = $("input[name='order_id']").val();
usceAdminUrl += '?page=usces_orderlist&order_action=load_rich_editor&orderid='+order_id+'&mode='+mode+'&noheader=true' + '&wc_nonce=' + $("#wc_nonce").val();
$('#iframeLoadEditor').attr('src', usceAdminUrl);
$('#iframeLoadEditor').load(function(){
$("#loading_iframe").hide();
$(this).show();
$("#usces_email_bnt_preview").removeAttr('disabled');
$("#usces_email_bnt_send").removeAttr('disabled');
});
}
};
uscesInformation = {
settings: {
url: 'http://www.welcart.com/util/welcart_information.php',
type: 'POST',
cache: false
},
getinfo : function() {
var s = uscesInformation.settings;
s.data = "v=" + encodeURIComponent(uscesL10n.version);
s.data += "&wcid=" + encodeURIComponent(uscesL10n.wcid);
s.data += "&wcurl=" + encodeURIComponent(uscesL10n.USCES_PLUGIN_URL);
s.data += "&locale=" + encodeURIComponent(uscesL10n.locale);
s.data += "&theme=" + encodeURIComponent(uscesL10n.theme);
s.data += "&wcex=";
var de = '';
for( var i = 0; i < uscesL10n.wcex.length; i++) {
s.data += de + encodeURIComponent(uscesL10n.wcex[i]);
de =',';
}
$.ajax( s ).done(function( data ){
$("#wc_information").html( data );
}).fail(function( msg ){
$("#wc_information").html( 'error : ' + msg );
});
return false;
},
getinfo2 : function() {
var s = uscesInformation.settings;
s.url = uscesL10n.requestFile;
s.data = 'action=getinfo_ajax';
$.ajax( s ).done(function( data ){
$("#wc_information").html( data );
}).fail(function( msg ){
$("#wc_information").html( 'error : ' + msg );
});
return false;
}
};
uscesItem = {
newdraft : function(itemName) {
if(jQuery("#title").val().length == 0 || jQuery("#title").val() == '') {
$("#title").val(itemName);
}
//autosave();
},
cahngepict : function(code) {
$("div#item-select-pict").html(code);
},
trim : function(target){
target = target.replace(/(^\s+)|(\s+$)|(^\n+)|(\n+$)/g, "");
return target;
}
};
welPageNav = {
checkShowNextprevPage : function( key_current_page_ids, sub_uri_link, current_id ) {
var current_id = parseInt(current_id);
if (0 > current_id) {
return false;
}
try {
var current_page_ids = window.localStorage.getItem(key_current_page_ids);
} catch (e) {
var current_page_ids = '';
}
if ( current_page_ids ) {
var arr_current_page_ids = current_page_ids.split(",");
if (0 > arr_current_page_ids.length) {
return false;
}
var index_prev = -1;
var index_next = -1;
for (var i = 0; i < arr_current_page_ids.length; ++i) {
if (arr_current_page_ids[i] == current_id) {
index_prev = i - 1;
index_next = i + 1;
break;
}
}
if ( arr_current_page_ids[index_prev] ) {
var prev_link = sub_uri_link + arr_current_page_ids[index_prev];
jQuery(".edit_pagenav .prev-page").attr('href', prev_link);
jQuery(".edit_pagenav .prev-page").show();
}
if ( arr_current_page_ids[index_next] ) {
var next_link = sub_uri_link + arr_current_page_ids[index_next];
jQuery(".edit_pagenav .next-page").attr('href', next_link);
jQuery(".edit_pagenav .next-page").show();
}
}
}
};
$( document ).on( "change", "#newitemcategory", function() {
orderItem.getSelitem( $(this).val() );
});
$( document ).on( "change", "#newitemcode", function() {
orderItem.getitem( $(this).val() );
});
$("#getitembutton").click( function(){
orderItem.getitem( encodeURIComponent($("#newitemcodein").val()) );
});
adminOperation = {
setActionStatus : function( status, message ) {
if( $("#usces_admin_status") == undefined || status == "" || message == "" ) return;
var notice_class = "";
if( status == "success" ) {
notice_class = "updated";
} else if( status == "caution" ){
notice_class = "update-nag";
} else if( status == "error" ) {
notice_class = "error";
}
if( "" != notice_class ) {
$("#usces_admin_status").html( "" );
$("#usces_admin_status").html( ''+message+'