| 1 |
// JavaScript |
| 2 |
(function($) { |
| 3 |
$("#aAdditionalURLs").click(function () { |
| 4 |
$("#AdditionalURLs").toggle(); |
| 5 |
}); |
| 6 |
|
| 7 |
itemOpt = { |
| 8 |
settings: { |
| 9 |
url: uscesL10n.requestFile, |
| 10 |
type: 'POST', |
| 11 |
cache: false |
| 12 |
}, |
| 13 |
|
| 14 |
post : function(action, arg) { |
| 15 |
if( action == 'updateitemopt' ) { |
| 16 |
itemOpt.updateitemopt(arg); |
| 17 |
} else if( action == 'deleteitemopt' ) { |
| 18 |
itemOpt.deleteitemopt(arg); |
| 19 |
} else if( action == 'additemopt' ) { |
| 20 |
itemOpt.additemopt(); |
| 21 |
} else if( action == 'addcommonopt' ) { |
| 22 |
itemOpt.addcommonopt(); |
| 23 |
} else if( action == 'keyselect' ) { |
| 24 |
itemOpt.keyselect(arg); |
| 25 |
} |
| 26 |
}, |
| 27 |
|
| 28 |
additemopt : function() { |
| 29 |
if( undefined == $("#optkeyselect").val() || $("#optkeyselect").val() == "#NONE#") return; |
| 30 |
|
| 31 |
var id = $("#post_ID").val(); |
| 32 |
var name = $("#optkeyselect option:selected").html(); |
| 33 |
var value = $("#newoptvalue").val(); |
| 34 |
var means = $("#newoptmeans").val(); |
| 35 |
|
| 36 |
var wc_nonce = $("#wc_nonce").val(); |
| 37 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 38 |
|
| 39 |
if($("input#newoptessential").prop("checked")){ |
| 40 |
var essential = '1'; |
| 41 |
}else{ |
| 42 |
var essential = '0'; |
| 43 |
} |
| 44 |
|
| 45 |
var mes = ''; |
| 46 |
if( '' == name ){ |
| 47 |
mes += '<p>'+uscesL10n.message[0]+'</p>'; |
| 48 |
} else { |
| 49 |
var check = true; |
| 50 |
$("input[name*='\[name\]']").each(function(){ if( name == $(this).val() ){ check = false; }}); |
| 51 |
if( !check ){ |
| 52 |
mes += '<p>'+uscesL10n.message[1]+'</p>'; |
| 53 |
} |
| 54 |
} |
| 55 |
if( '' == value && (0 == means || 1 == means || 3 == means || 4 == means) ){ |
| 56 |
mes += '<p>'+uscesL10n.message[2]+'</p>'; |
| 57 |
}else if( '' != value && (2 == means || 5 == means) ){ |
| 58 |
mes += '<p>'+uscesL10n.message[3]+'</p>'; |
| 59 |
} |
| 60 |
if( '' != mes ){ |
| 61 |
$("#itemopt_ajax-response").html('<div class="error">' + mes + '</div>'); |
| 62 |
return false; |
| 63 |
} |
| 64 |
|
| 65 |
$("#newitemopt_loading").html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />'); |
| 66 |
|
| 67 |
var s = itemOpt.settings; |
| 68 |
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); |
| 69 |
$.ajax( s ).done(function( data ){ |
| 70 |
var meta_id = data.meta_id; |
| 71 |
$("#itemopt_ajax-response").html(''); |
| 72 |
$("#newitemopt_loading").html(''); |
| 73 |
$("table#optlist-table").removeAttr("style"); |
| 74 |
$("tbody#item-opt-list").html( data.meta_row ); |
| 75 |
$("#optkeyselect").val('#NONE#'); |
| 76 |
$("#newoptvalue").html(''); |
| 77 |
$("#newoptmeans").val(0); |
| 78 |
$("#newoptessential").prop( "checked", false ); |
| 79 |
$("#itemopt-" + meta_id).css({'background-color': '#FF4'}); |
| 80 |
$("#itemopt-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 2000 ); |
| 81 |
}).fail(function( msg ){ |
| 82 |
$("#itemopt_ajax-response").html(msg); |
| 83 |
$("#newitemopt_loading").html(''); |
| 84 |
}); |
| 85 |
return false; |
| 86 |
}, |
| 87 |
|
| 88 |
addcommonopt : function() { |
| 89 |
var id = $("#post_ID").val(); |
| 90 |
var name = $("#newoptname").val(); |
| 91 |
var value = $("#newoptvalue").val(); |
| 92 |
var means = $("#newoptmeans").val(); |
| 93 |
|
| 94 |
var wc_nonce = $("#wc_nonce").val(); |
| 95 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 96 |
|
| 97 |
if($("input#newoptessential").prop("checked")){ |
| 98 |
var essential = '1'; |
| 99 |
}else{ |
| 100 |
var essential = '0'; |
| 101 |
} |
| 102 |
|
| 103 |
var mes = ''; |
| 104 |
if( '' == name ){ |
| 105 |
mes += '<p>'+uscesL10n.message[0]+'</p>'; |
| 106 |
} else { |
| 107 |
var check = true; |
| 108 |
$("input[name*='\[name\]']").each(function(){ if( name == $(this).val() ){ check = false; }}); |
| 109 |
if( !check ){ |
| 110 |
mes += '<p>'+uscesL10n.message[1]+'</p>'; |
| 111 |
} |
| 112 |
} |
| 113 |
if( '' == value && (0 == means || 1 == means || 3 == means || 4 == means) ){ |
| 114 |
mes += '<p>'+uscesL10n.message[2]+'</p>'; |
| 115 |
}else if( '' != value && (2 == means || 5 == means) ){ |
| 116 |
mes += '<p>'+uscesL10n.message[3]+'</p>'; |
| 117 |
} |
| 118 |
if( '' != mes ){ |
| 119 |
$("#itemopt_ajax-response").html('<div class="error">' + mes + '</div>'); |
| 120 |
return false; |
| 121 |
} |
| 122 |
|
| 123 |
$("#newcomopt_loading").html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />'); |
| 124 |
|
| 125 |
var s = itemOpt.settings; |
| 126 |
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); |
| 127 |
$.ajax( s ).done(function( data ){ |
| 128 |
var meta_id = data.meta_id; |
| 129 |
$("#newcomopt_loading").html(''); |
| 130 |
$("#itemopt_ajax-response").html(''); |
| 131 |
$("table#optlist-table").removeAttr("style"); |
| 132 |
if( 0 > meta_id ){ |
| 133 |
$("#itemopt_ajax-response").html('<div class="error"><p>'+uscesL10n.message[1]+'</p></div>'); |
| 134 |
}else{ |
| 135 |
$("tbody#item-opt-list").html( data.meta_row ); |
| 136 |
$("#newoptname").val(''); |
| 137 |
$("#newoptvalue").val(''); |
| 138 |
$("#newoptmeans").val(0); |
| 139 |
$("#newoptessential").prop( "checked", false ); |
| 140 |
$("#itemopt-" + meta_id).css({'background-color': '#FF4'}); |
| 141 |
$("#itemopt-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 2000 ); |
| 142 |
} |
| 143 |
}).fail(function(msg){ |
| 144 |
$("#comopt_ajax-response").html(msg); |
| 145 |
$("#newcomopt_loading").html(''); |
| 146 |
}); |
| 147 |
return false; |
| 148 |
}, |
| 149 |
|
| 150 |
updateitemopt : function(meta_id) { |
| 151 |
var id = $("#post_ID").val(); |
| 152 |
|
| 153 |
var wc_nonce = $("#wc_nonce").val(); |
| 154 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 155 |
|
| 156 |
nm = document.getElementById('itemopt\['+meta_id+'\]\[name\]'); |
| 157 |
vs = document.getElementById('itemopt\['+meta_id+'\]\[value\]'); |
| 158 |
ms = document.getElementById('itemopt\['+meta_id+'\]\[means\]'); |
| 159 |
es = document.getElementById('itemopt\['+meta_id+'\]\[essential\]'); |
| 160 |
so = document.getElementById('itemopt\['+meta_id+'\]\[sort\]'); |
| 161 |
var name = $(nm).val(); |
| 162 |
var value = uscesItem.trim($(vs).val()); |
| 163 |
var means = $(ms).val(); |
| 164 |
var sortnum = $(so).val(); |
| 165 |
if($(es).prop("checked")){ |
| 166 |
var essential = '1'; |
| 167 |
}else{ |
| 168 |
var essential = '0'; |
| 169 |
} |
| 170 |
|
| 171 |
var mes = ''; |
| 172 |
if( '' == name ){ |
| 173 |
mes += '<p>'+uscesL10n.message[0]+'</p>'; |
| 174 |
} else { |
| 175 |
var check = true; |
| 176 |
$("input[name*='[name]']").each(function() { |
| 177 |
var thisName = $(this).attr('name'); |
| 178 |
var match = thisName.match(/itemopt\[(\d+)\]/); |
| 179 |
if (match && match[1]) { |
| 180 |
var thisId = +match[1]; |
| 181 |
if (thisId != meta_id && $(this).val() == name) { |
| 182 |
check = false; |
| 183 |
} |
| 184 |
} |
| 185 |
}); |
| 186 |
if( !check ){ |
| 187 |
mes += '<p>'+uscesL10n.message[1]+'</p>'; |
| 188 |
} |
| 189 |
} |
| 190 |
if( '' == value && (0 == means || 1 == means || 3 == means || 4 == means) ){ |
| 191 |
mes += '<p>'+uscesL10n.message[2]+'</p>'; |
| 192 |
}else if( '' != value && (2 == means || 5 == means) ){ |
| 193 |
mes += '<p>'+uscesL10n.message[3]+'</p>'; |
| 194 |
} |
| 195 |
if( '' != mes ){ |
| 196 |
$("#itemopt_ajax-response").html('<div class="error">' + mes + '</div>'); |
| 197 |
return false; |
| 198 |
} |
| 199 |
|
| 200 |
$("#itemopt_loading-" + meta_id).html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />'); |
| 201 |
|
| 202 |
var s = itemOpt.settings; |
| 203 |
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); |
| 204 |
$.ajax( s ).done(function( data ){ |
| 205 |
$("#itemopt_ajax-response").html(''); |
| 206 |
$("#itemopt_loading-" + meta_id).html(''); |
| 207 |
$("tbody#item-opt-list").html( data.meta_row ); |
| 208 |
$("#itemopt-" + meta_id).css({'background-color': '#FF4'}); |
| 209 |
$("#itemopt-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 2000 ); |
| 210 |
}).fail(function( msg ){ |
| 211 |
$("#itemopt_ajax-response").html(msg); |
| 212 |
$("#itemopt_loading-" + meta_id).html(''); |
| 213 |
}); |
| 214 |
return false; |
| 215 |
}, |
| 216 |
|
| 217 |
deleteitemopt : function(meta_id) { |
| 218 |
$("#itemopt-" + meta_id).css({'background-color': '#F00'}); |
| 219 |
$("#itemopt-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 1000 ); |
| 220 |
var id = $("#post_ID").val(); |
| 221 |
|
| 222 |
var wc_nonce = $("#wc_nonce").val(); |
| 223 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 224 |
|
| 225 |
var s = itemOpt.settings; |
| 226 |
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); |
| 227 |
$.ajax( s ).done(function( data ){ |
| 228 |
$("#itemopt_ajax-response").html(""); |
| 229 |
$("tbody#item-opt-list").html( data.meta_row ); |
| 230 |
}).fail(function( msg ){ }); |
| 231 |
return false; |
| 232 |
}, |
| 233 |
|
| 234 |
keyselect : function( meta_id ) { |
| 235 |
if(meta_id == '#NONE#'){ |
| 236 |
$("#newoptvalue").val(''); |
| 237 |
$("#newoptmeans").val(0); |
| 238 |
$("#newoptessential").prop( "checked", false ); |
| 239 |
return; |
| 240 |
} |
| 241 |
var id = uscesL10n.cart_number; |
| 242 |
|
| 243 |
var wc_nonce = $("#wc_nonce").val(); |
| 244 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 245 |
|
| 246 |
$("#newitemopt_loading").html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />'); |
| 247 |
$("#add_itemopt").prop( "disabled", true ); |
| 248 |
|
| 249 |
var s = itemOpt.settings; |
| 250 |
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); |
| 251 |
$.ajax( s ).done(function( data ){ |
| 252 |
$("#itemopt_ajax-response").html(""); |
| 253 |
var means = data.means; |
| 254 |
var essential = data.essential; |
| 255 |
var value = ( 2 == means || 5 == means ) ? '' : data.value; |
| 256 |
value = esc_js( String( value ) ); |
| 257 |
$("#newoptvalue").html(value); |
| 258 |
$("#newoptmeans").val(means); |
| 259 |
$("#newoptessential").prop( "checked", essential == '1' ); |
| 260 |
$("#newitemopt_loading").html(''); |
| 261 |
$("#add_itemopt").prop( "disabled", false ); |
| 262 |
}).fail(function(msg){ |
| 263 |
$("#itemopt_ajax-response").html(msg); |
| 264 |
$("#newitemopt_loading").html(''); |
| 265 |
}); |
| 266 |
return false; |
| 267 |
}, |
| 268 |
|
| 269 |
dosort : function( str ) { |
| 270 |
if( !str ) return; |
| 271 |
var id = $("#post_ID").val(); |
| 272 |
var meta_id_str = str.replace(/itemopt-/g, ""); |
| 273 |
var meta_ids = meta_id_str.split(','); |
| 274 |
|
| 275 |
var wc_nonce = $("#wc_nonce").val(); |
| 276 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 277 |
|
| 278 |
if( 2 > meta_ids.length ) return; |
| 279 |
|
| 280 |
for(i=0; i<meta_ids.length; i++){ |
| 281 |
$("#itemopt_loading-" + meta_ids[i]).html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />'); |
| 282 |
} |
| 283 |
var s = itemOpt.settings; |
| 284 |
s.data = "action=item_option_ajax&ID=" + id + "&sort=1&meta=" + encodeURIComponent(meta_id_str) + "&wc_nonce=" + encodeURIComponent(wc_nonce)+ "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer); |
| 285 |
$.ajax( s ).done(function( data ){ |
| 286 |
$("#itemopt_ajax-response").html(""); |
| 287 |
$("tbody#item-opt-list").html( data.meta_row ); |
| 288 |
for(i=0; i<meta_ids.length; i++){ |
| 289 |
$("#itemopt_loading-" + meta_ids[i]).html(''); |
| 290 |
$("#itemopt-" + meta_ids[i]).css({'background-color': '#FF4'}); |
| 291 |
$("#itemopt-" + meta_ids[i]).animate({ 'background-color': '#FFFFEE' }, 2000 ); |
| 292 |
} |
| 293 |
}).fail(function( msg ){ |
| 294 |
$("#opt_ajax-response").html('<div class="error"><p>error sort</p></div>'); |
| 295 |
}); |
| 296 |
return false; |
| 297 |
} |
| 298 |
}; |
| 299 |
|
| 300 |
itemSku = { |
| 301 |
settings: { |
| 302 |
url: uscesL10n.requestFile, |
| 303 |
type: 'POST', |
| 304 |
cache: false |
| 305 |
}, |
| 306 |
|
| 307 |
post : function(action, arg) { |
| 308 |
if( action == 'updateitemsku' ) { |
| 309 |
itemSku.updateitemsku(arg); |
| 310 |
} else if( action == 'deleteitemsku' ) { |
| 311 |
var ele_sku_key = $( '#itemsku-' + arg + ' input[name="itemsku[' + arg + '][key]"]' ); |
| 312 |
if ( ele_sku_key.length ) { |
| 313 |
if( ! confirm( uscesL10n.message[25].replace( '********', ele_sku_key.val() ) ) ) { |
| 314 |
return; |
| 315 |
} |
| 316 |
} |
| 317 |
itemSku.deleteitemsku(arg); |
| 318 |
} else if( action == 'additemsku' ) { |
| 319 |
itemSku.additemsku(); |
| 320 |
} else if( action == 'keyselect' ) { |
| 321 |
itemSku.keyselect(arg); |
| 322 |
} |
| 323 |
}, |
| 324 |
|
| 325 |
additemsku : function() { |
| 326 |
var id = $("#post_ID").val(); |
| 327 |
var name = $("#newskuname").val(); |
| 328 |
var cprice = $("#newskucprice").val(); |
| 329 |
var price = $("#newskuprice").val(); |
| 330 |
var zaikonum = $("#newskuzaikonum").val(); |
| 331 |
var zaiko = $("#newskuzaikoselect").val(); |
| 332 |
var skudisp = $("#newskudisp").val(); |
| 333 |
var skuunit = $("#newskuunit").val(); |
| 334 |
var skugptekiyo = $("#newskugptekiyo").val(); |
| 335 |
var applicable_taxrate = ''; |
| 336 |
if( undefined != $( "#newsku_applicable_taxrate" ) ) { |
| 337 |
applicable_taxrate = $( "#newsku_applicable_taxrate option:selected" ).val(); |
| 338 |
} |
| 339 |
var mes = ''; |
| 340 |
if( '' == name ) |
| 341 |
mes += '<p>'+uscesL10n.message[4]+'</p>'; |
| 342 |
if( '' == price ) |
| 343 |
mes += '<p>'+uscesL10n.message[5]+'</p>'; |
| 344 |
// if( ! checkCode( name ) ) |
| 345 |
// mes += '<p>'+uscesL10n.message[6]+'</p>'; |
| 346 |
if( ! checkMoney( cprice ) ) |
| 347 |
mes += '<p>'+uscesL10n.message[7]+'</p>'; |
| 348 |
if( ! checkMoney( price ) ) |
| 349 |
mes += '<p>'+uscesL10n.message[8]+'</p>'; |
| 350 |
if( undefined != $("#itemOrderAcceptable") && $("#itemOrderAcceptable").prop("checked") ) { |
| 351 |
if( ! checkNumMinus( zaikonum ) ) |
| 352 |
mes += '<p>'+uscesL10n.message[9]+'</p>'; |
| 353 |
} else { |
| 354 |
if( ! checkNum( zaikonum ) ) |
| 355 |
mes += '<p>'+uscesL10n.message[9]+'</p>'; |
| 356 |
} |
| 357 |
if( '' != mes ){ |
| 358 |
$("#sku_ajax-response").html('<div class="error">' + mes + '</div>'); |
| 359 |
return false; |
| 360 |
} |
| 361 |
|
| 362 |
var skuadvance = ''; |
| 363 |
if( undefined != $("*[name*='newskuadvance']") ) { |
| 364 |
if( 1 == $("*[name*='newskuadvance']").length ) { |
| 365 |
skuadvance = '&newskuadvance='+encodeURIComponent($("*[name*='newskuadvance']").val()); |
| 366 |
} else { |
| 367 |
$("*[name*='newskuadvance']").each(function() { |
| 368 |
skuadvance += '&newskuadvance['+$(this).attr("id")+']='+encodeURIComponent($(this).val()); |
| 369 |
}); |
| 370 |
} |
| 371 |
} |
| 372 |
|
| 373 |
$("#newitemsku_loading").html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />'); |
| 374 |
|
| 375 |
var s = itemSku.settings; |
| 376 |
var wc_nonce = $("#wc_nonce").val(); |
| 377 |
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; |
| 378 |
if( '' != applicable_taxrate ) { |
| 379 |
s.data += "&newskutaxrate=" + applicable_taxrate; |
| 380 |
} |
| 381 |
var hookargs = { |
| 382 |
postId: id, |
| 383 |
price, |
| 384 |
cprice, |
| 385 |
zaikonum, |
| 386 |
zaiko, |
| 387 |
name, |
| 388 |
skudisp, |
| 389 |
skuunit, |
| 390 |
skugptekiyo, |
| 391 |
applicable_taxrate, |
| 392 |
skuadvance |
| 393 |
} |
| 394 |
$.ajax( s ).done(function( data ){ |
| 395 |
$("#newitemsku_loading").html(''); |
| 396 |
$("#sku_ajax-response").html(""); |
| 397 |
$("table#skulist-table").removeAttr("style"); |
| 398 |
var meta_id = data.meta_id; |
| 399 |
hookargs.metaId = meta_id; |
| 400 |
hookargs.response = data; |
| 401 |
if( data.meta_msg && '' != data.meta_msg ) { |
| 402 |
$("#sku_ajax-response").html('<div class="error"><p>'+data.meta_msg+'</p></div>'); |
| 403 |
} else if( 0 > meta_id ){ |
| 404 |
$("#sku_ajax-response").html('<div class="error"><p>'+uscesL10n.message[10]+'</p></div>'); |
| 405 |
}else{ |
| 406 |
wp.hooks.doAction('usces.itemSku.additemsku.on-success.before-dom-update', hookargs); |
| 407 |
$("tbody#item-sku-list").html( data.meta_row ); |
| 408 |
wp.hooks.doAction('usces.itemSku.additemsku.on-success.after-dom-update', hookargs); |
| 409 |
$("#itemsku-" + meta_id).css({'background-color': '#FF4'}); |
| 410 |
$("#itemsku-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 2000 ); |
| 411 |
$("#newskuname").val(""); |
| 412 |
$("#newskucprice").val(""); |
| 413 |
$("#newskuprice").val(""); |
| 414 |
$("#newskuzaikonum").val(""); |
| 415 |
$("#newskuzaikonum").val(""); |
| 416 |
$("#newskuzaikoselect").val(0); |
| 417 |
$("#newskudisp").val(""); |
| 418 |
$("#newskuunit").val(""); |
| 419 |
$("#newskugptekiyo").val(0); |
| 420 |
if( 0 < $("*[name*='newskuadvance']").length ) { |
| 421 |
$("*[name*='newskuadvance']").each(function(index, element) { |
| 422 |
$(this).val(""); |
| 423 |
}); |
| 424 |
} |
| 425 |
if( 0 < $("select[name*='newskuadvance']").length ) { |
| 426 |
$("select[name*='newskuadvance']").each(function(index, element) { |
| 427 |
$(this).val(""); |
| 428 |
}); |
| 429 |
} |
| 430 |
} |
| 431 |
//$("#itemsku-" + meta_id).css({'background-color': '#FF4'}); |
| 432 |
//$("#itemsku-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 2000 ); |
| 433 |
}).fail(function( msg ){ |
| 434 |
|
| 435 |
$("#sku_ajax-response").html(msg); |
| 436 |
$("#newitemsku_loading").html(''); |
| 437 |
}); |
| 438 |
return false; |
| 439 |
}, |
| 440 |
|
| 441 |
updateitemsku : function(meta_id) { |
| 442 |
var id = $("#post_ID").val(); |
| 443 |
ks = document.getElementById('itemsku\['+meta_id+'\]\[key\]'); |
| 444 |
cs = document.getElementById('itemsku\['+meta_id+'\]\[cprice\]'); |
| 445 |
ps = document.getElementById('itemsku\['+meta_id+'\]\[price\]'); |
| 446 |
ns = document.getElementById('itemsku\['+meta_id+'\]\[zaikonum\]'); |
| 447 |
zs = document.getElementById('itemsku\['+meta_id+'\]\[zaiko\]'); |
| 448 |
ds = document.getElementById('itemsku\['+meta_id+'\]\[skudisp\]'); |
| 449 |
us = document.getElementById('itemsku\['+meta_id+'\]\[skuunit\]'); |
| 450 |
gs = document.getElementById('itemsku\['+meta_id+'\]\[skugptekiyo\]'); |
| 451 |
//ad = document.getElementById('itemsku\['+meta_id+'\]\[skuadvance\]'); |
| 452 |
//ad = $("*[name*='itemsku\["+meta_id+"\]\[skuadvance\]']"); |
| 453 |
ad = $("*[name*='itemsku\["+meta_id+"\]\[skuadvance\]']:not(:disabled)"); |
| 454 |
so = document.getElementById('itemsku\['+meta_id+'\]\[sort\]'); |
| 455 |
var name = $(ks).val(); |
| 456 |
var cprice = $(cs).val(); |
| 457 |
var price = $(ps).val(); |
| 458 |
var zaikonum = $(ns).val(); |
| 459 |
var zaiko = $(zs).val(); |
| 460 |
var skudisp = $(ds).val(); |
| 461 |
var skuunit = $(us).val(); |
| 462 |
var skugptekiyo = $(gs).val(); |
| 463 |
var sortnum = $(so).val(); |
| 464 |
var applicable_taxrate = ''; |
| 465 |
if( undefined != $( "select[name='itemsku\["+meta_id+"\]\[applicable_taxrate\]']" ) ) { |
| 466 |
applicable_taxrate = $( "select[name='itemsku\["+meta_id+"\]\[applicable_taxrate\]'] option:selected" ).val(); |
| 467 |
} |
| 468 |
|
| 469 |
var mes = ''; |
| 470 |
if( '' == name ) |
| 471 |
mes += '<p>'+uscesL10n.message[4]+'</p>'; |
| 472 |
if( '' == price ) |
| 473 |
mes += '<p>'+uscesL10n.message[5]+'</p>'; |
| 474 |
if( ! checkMoney( cprice ) ) |
| 475 |
mes += '<p>'+uscesL10n.message[7]+'</p>'; |
| 476 |
if( ! checkMoney( price ) ) |
| 477 |
mes += '<p>'+uscesL10n.message[8]+'</p>'; |
| 478 |
//if( ! checkNum( zaikonum ) ) |
| 479 |
// mes += '<p>'+uscesL10n.message[9]+'</p>'; |
| 480 |
if( undefined != $("#itemOrderAcceptable") && $("#itemOrderAcceptable").prop("checked") ) { |
| 481 |
if( ! checkNumMinus( zaikonum ) ) |
| 482 |
mes += '<p>'+uscesL10n.message[9]+'</p>'; |
| 483 |
} else { |
| 484 |
if( ! checkNum( zaikonum ) ) |
| 485 |
mes += '<p>'+uscesL10n.message[9]+'</p>'; |
| 486 |
} |
| 487 |
if( '' != mes ){ |
| 488 |
$("#sku_ajax-response").html('<div class="error">' + mes + '</div>'); |
| 489 |
return false; |
| 490 |
} |
| 491 |
|
| 492 |
var skuadvance = ''; |
| 493 |
if( undefined != $(ad) ) { |
| 494 |
if( 1 == $(ad).length ) { |
| 495 |
skuadvance = '&skuadvance='+encodeURIComponent($(ad).val()); |
| 496 |
} else { |
| 497 |
$(ad).each(function() { |
| 498 |
skuadvance += '&skuadvance['+$(this).attr("id")+']='+encodeURIComponent($(this).val()); |
| 499 |
}); |
| 500 |
} |
| 501 |
} |
| 502 |
|
| 503 |
$("#itemsku_loading-" + meta_id).html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />'); |
| 504 |
var s = itemSku.settings; |
| 505 |
var wc_nonce = $("#wc_nonce").val(); |
| 506 |
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; |
| 507 |
if( '' != applicable_taxrate ) { |
| 508 |
s.data += "&skutaxrate=" + applicable_taxrate; |
| 509 |
} |
| 510 |
var hookargs = { |
| 511 |
metaId: meta_id, |
| 512 |
postId: id, |
| 513 |
price, |
| 514 |
cprice, |
| 515 |
zaikonum, |
| 516 |
zaiko, |
| 517 |
name, |
| 518 |
skudisp, |
| 519 |
skuunit, |
| 520 |
skugptekiyo, |
| 521 |
sortnum, |
| 522 |
skuadvance |
| 523 |
} |
| 524 |
$.ajax( s ).done(function( data ){ |
| 525 |
hookargs.response = data; |
| 526 |
$("#itemsku_loading-" + meta_id).html(''); |
| 527 |
$("#sku_ajax-response").html(""); |
| 528 |
$("table#skulist-table").removeAttr("style"); |
| 529 |
var id = data.meta_id; |
| 530 |
if( data.meta_msg && '' != data.meta_msg ) { |
| 531 |
$("#sku_ajax-response").html('<div class="error"><p>'+data.meta_msg+'</p></div>'); |
| 532 |
} else if( 0 > id ){ |
| 533 |
$("#sku_ajax-response").html('<div class="error"><p>'+uscesL10n.message[10]+'</p></div>'); |
| 534 |
}else{ |
| 535 |
wp.hooks.doAction('usces.itemSku.updateitemsku.on-success.before-dom-update', hookargs); |
| 536 |
$("tbody#item-sku-list").html( data.meta_row ); |
| 537 |
wp.hooks.doAction('usces.itemSku.updateitemsku.on-success.after-dom-update', hookargs); |
| 538 |
$("#itemsku-" + meta_id).css({'background-color': '#FF4'}); |
| 539 |
$("#itemsku-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 2000 ); |
| 540 |
} |
| 541 |
}).fail(function( msg ){ |
| 542 |
$("#sku_ajax-response").html(msg); |
| 543 |
$("#itemsku_loading-" + meta_id).html(''); |
| 544 |
}); |
| 545 |
return false; |
| 546 |
}, |
| 547 |
|
| 548 |
deleteitemsku : function(meta_id) { |
| 549 |
var data=[]; |
| 550 |
$("#itemsku-" + meta_id).css({'background-color': '#F00'}); |
| 551 |
$("#itemsku-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 1000 ); |
| 552 |
var id = $("#post_ID").val(); |
| 553 |
var s = itemSku.settings; |
| 554 |
var wc_nonce = $("#wc_nonce").val(); |
| 555 |
s.data = "action=item_sku_ajax&ID=" + id + "&wc_nonce=" + wc_nonce + "&delete=1&skumetaid=" + meta_id; |
| 556 |
$.ajax( s ).done(function( data ){ |
| 557 |
if( data.meta_msg && '' != data.meta_msg ) { |
| 558 |
$("#sku_ajax-response").html('<div class="error"><p>'+data.meta_msg+'</p></div>'); |
| 559 |
} else { |
| 560 |
$("#itemsku_loading-" + meta_id).html(''); |
| 561 |
$("#sku_ajax-response").html(""); |
| 562 |
var hookargs = { |
| 563 |
data, |
| 564 |
metaId: meta_id, |
| 565 |
postId: id, |
| 566 |
} |
| 567 |
wp.hooks.doAction('usces.itemSku.deleteitemsku.on-success.before-dom-update', hookargs); |
| 568 |
$("tbody#item-sku-list").html( data.meta_row ); |
| 569 |
wp.hooks.doAction('usces.itemSku.deleteitemsku.on-success.after-dom-update', hookargs); |
| 570 |
} |
| 571 |
}).fail(function( msg ){ |
| 572 |
$("#sku_ajax-response").html(msg); |
| 573 |
$("#itemsku_loading-" + meta_id).html(''); |
| 574 |
}); |
| 575 |
return false; |
| 576 |
}, |
| 577 |
|
| 578 |
dosort : function( str ) { |
| 579 |
if( !str ) return; |
| 580 |
var id = $("#post_ID").val(); |
| 581 |
|
| 582 |
var meta_str = ''; |
| 583 |
var meta_ids = []; |
| 584 |
for(i=0; i<str.length; i++){ |
| 585 |
|
| 586 |
if( undefined == str[i] ) continue; |
| 587 |
|
| 588 |
if( str[i].match(/itemsku-/) ){ |
| 589 |
meta_str = str[i].replace(/[itemsku\-|,]/g, "") |
| 590 |
meta_ids.push(meta_str); |
| 591 |
} |
| 592 |
|
| 593 |
} |
| 594 |
var meta_id_str = meta_ids.join(','); |
| 595 |
|
| 596 |
if( 2 > meta_ids.length ) return; |
| 597 |
|
| 598 |
for(i=0; i<meta_ids.length; i++){ |
| 599 |
$("#itemsku_loading-" + meta_ids[i]).html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />'); |
| 600 |
} |
| 601 |
var s = itemSku.settings; |
| 602 |
var wc_nonce = $("#wc_nonce").val(); |
| 603 |
s.data = "action=item_sku_ajax&ID=" + id + "&wc_nonce=" + wc_nonce + "&sort=1&meta=" + encodeURIComponent(meta_id_str); |
| 604 |
$.ajax( s ).done(function( data ){ |
| 605 |
$("#sku_ajax-response").html(""); |
| 606 |
var hookargs = { |
| 607 |
data, |
| 608 |
metaIds: meta_ids, |
| 609 |
postId: id, |
| 610 |
} |
| 611 |
wp.hooks.doAction('usces.itemSku.dosort.on-success.before-dom-update', hookargs); |
| 612 |
$("tbody#item-sku-list").html( data.meta_row ); |
| 613 |
wp.hooks.doAction('usces.itemSku.dosort.on-success.after-dom-update', hookargs); |
| 614 |
for(i=0; i<meta_ids.length; i++){ |
| 615 |
//$("#itemsku_loading-" + meta_ids[i]).html(''); |
| 616 |
$("#itemsku-" + meta_ids[i]).css({'background-color': '#FF4'}); |
| 617 |
$("#itemsku-" + meta_ids[i]).animate({ 'background-color': '#FFFFEE' }, 2000 ); |
| 618 |
} |
| 619 |
}).fail(function( msg ){ |
| 620 |
$("#sku_ajax-response").html('<div class="error"><p>error sort</p></div>'); |
| 621 |
}); |
| 622 |
return false; |
| 623 |
} |
| 624 |
}; |
| 625 |
|
| 626 |
payment = { |
| 627 |
settings: { |
| 628 |
url: uscesL10n.requestFile, |
| 629 |
type: 'POST', |
| 630 |
cache: false |
| 631 |
}, |
| 632 |
|
| 633 |
post : function(action, arg) { |
| 634 |
if( action == 'update' ) { |
| 635 |
payment.update(arg); |
| 636 |
} else if( action == 'del' ) { |
| 637 |
payment.del(arg); |
| 638 |
} else if( action == 'add' ) { |
| 639 |
payment.add(); |
| 640 |
} |
| 641 |
}, |
| 642 |
|
| 643 |
add : function() { |
| 644 |
var name = $("#newname").val(); |
| 645 |
var explanation = $("#newexplanation").val(); |
| 646 |
var settlement = $("#newsettlement").val(); |
| 647 |
var module = $("#newmodule").val(); |
| 648 |
var wc_nonce = $("#wc_nonce").val(); |
| 649 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 650 |
|
| 651 |
var mes = ''; |
| 652 |
if( '' == name ){ |
| 653 |
mes += '<p>'+uscesL10n.message[11]+'</p>'; |
| 654 |
} |
| 655 |
if( '#NONE#' == settlement ) { |
| 656 |
mes += '<p>'+uscesL10n.message[12]+'</p>'; |
| 657 |
} |
| 658 |
if( 'acting' == settlement ) { |
| 659 |
if( '' == module ) { |
| 660 |
mes += '<p>'+uscesL10n.message[13]+'</p>'; |
| 661 |
} |
| 662 |
} |
| 663 |
if( '' != mes ){ |
| 664 |
$("#payment_ajax-response").html('<div class="error">' + mes + '</div>'); |
| 665 |
return false; |
| 666 |
} |
| 667 |
|
| 668 |
$("#newpayment_loading").html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />'); |
| 669 |
|
| 670 |
var s = payment.settings; |
| 671 |
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); |
| 672 |
$.ajax( s ).done(function( data ){ |
| 673 |
$("#newpayment_loading").html(''); |
| 674 |
$("#payment_ajax-response").html(''); |
| 675 |
$("table#payment-table").removeAttr("style"); |
| 676 |
if( -1 == data.meta_id ){ |
| 677 |
$("#payment_ajax-response").html('<div class="error"><p>'+uscesL10n.message[14]+'</p></div>'); |
| 678 |
}else{ |
| 679 |
$("tbody#payment-list").html( data.meta_row ); |
| 680 |
$("#newname").val(""); |
| 681 |
$("#newexplanation").val(""); |
| 682 |
$("#newsettlement").val('acting'); |
| 683 |
$("#newmodule").val(""); |
| 684 |
$("#payment-" + data.meta_id).css({'background-color': '#FF4'}); |
| 685 |
$("#payment-" + data.meta_id).animate({ 'background-color': '#FFFFEE' }, 2000 ); |
| 686 |
} |
| 687 |
}).fail(function( msg ){ |
| 688 |
$("#payment_ajax-response").html(msg); |
| 689 |
$("#newpayment_loading").html(''); |
| 690 |
}); |
| 691 |
return false; |
| 692 |
}, |
| 693 |
|
| 694 |
update : function(id) { |
| 695 |
vn = document.getElementById('payment\[' + id + '\]\[name\]'); |
| 696 |
ve = document.getElementById('payment\[' + id + '\]\[explanation\]'); |
| 697 |
vs = document.getElementById('payment\[' + id + '\]\[settlement\]'); |
| 698 |
vm = document.getElementById('payment\[' + id + '\]\[module\]'); |
| 699 |
so = document.getElementById('payment\[' + id + '\]\[sort\]'); |
| 700 |
var name = $(vn).val(); |
| 701 |
var explanation = $(ve).val(); |
| 702 |
var settlement = $(vs).val(); |
| 703 |
var module = $(vm).val(); |
| 704 |
var sortid = $(so).val(); |
| 705 |
var use = $("input[name='payment[" + id + "][use]']:checked").val(); |
| 706 |
var wc_nonce = $("#wc_nonce").val(); |
| 707 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 708 |
var s = payment.settings; |
| 709 |
|
| 710 |
var mes = ''; |
| 711 |
if( '' == name ){ |
| 712 |
mes += '<p>'+uscesL10n.message[11]+'</p>'; |
| 713 |
} |
| 714 |
if( '#NONE#' == settlement && 'activate' == use ) { |
| 715 |
mes += '<p>'+uscesL10n.message[12]+'</p>'; |
| 716 |
} |
| 717 |
if( 'acting' == settlement ) { |
| 718 |
if( '' == module ) { |
| 719 |
mes += '<p>'+uscesL10n.message[13]+'</p>'; |
| 720 |
} |
| 721 |
} |
| 722 |
if( '' != mes ){ |
| 723 |
$("#payment_ajax-response").html('<div class="error">' + mes + '</div>'); |
| 724 |
return false; |
| 725 |
} |
| 726 |
|
| 727 |
$("#payment_loading-" + id).html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />'); |
| 728 |
|
| 729 |
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); |
| 730 |
$.ajax( s ).done(function( data ){ |
| 731 |
$("#payment_loading-" + id).html(''); |
| 732 |
$("#payment_ajax-response").html(""); |
| 733 |
if( -1 == data.meta_id ){ |
| 734 |
$("#payment_ajax-response").html('<div class="error"><p>'+uscesL10n.message[14]+'</p></div>'); |
| 735 |
}else{ |
| 736 |
$("tbody#payment-list").html( data.meta_row ); |
| 737 |
$("#payment-" + id).css({'background-color': '#FF4'}); |
| 738 |
$("#payment-" + id).animate({ 'background-color': '#FFFFEE' }, 2000 ); |
| 739 |
} |
| 740 |
}).fail(function( msg ){ |
| 741 |
$("#payment_ajax-response").html(msg); |
| 742 |
$("#newpayment_loading").html(''); |
| 743 |
}); |
| 744 |
return false; |
| 745 |
}, |
| 746 |
|
| 747 |
del : function(id) { |
| 748 |
$("#payment-" + id).css({'background-color': '#F00'}); |
| 749 |
$("#payment-" + id).animate({ 'background-color': '#FFFFEE' }, 1000 ); |
| 750 |
var wc_nonce = $("#wc_nonce").val(); |
| 751 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 752 |
var s = payment.settings; |
| 753 |
s.data = "action=payment_ajax&delete=1&id=" + id + "&wc_nonce=" + encodeURIComponent(wc_nonce) + "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer); |
| 754 |
$.ajax( s ).done(function( data ){ |
| 755 |
$("tbody#payment-list").html( data.meta_row ); |
| 756 |
}).fail(function( msg ){ |
| 757 |
$("#payment_ajax-response").html(msg); |
| 758 |
}); |
| 759 |
return false; |
| 760 |
}, |
| 761 |
|
| 762 |
dosort : function( str ) { |
| 763 |
if( !str ) return; |
| 764 |
var meta_id_str = str.replace(/payment-/g, ""); |
| 765 |
var meta_ids = meta_id_str.split(','); |
| 766 |
if( 2 > meta_ids.length ) return; |
| 767 |
|
| 768 |
for(i=0; i<meta_ids.length; i++){ |
| 769 |
$("#payment_loading-" + meta_ids[i]).html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />'); |
| 770 |
} |
| 771 |
var wc_nonce = $("#wc_nonce").val(); |
| 772 |
var _wp_http_referer = $("input[name='_wp_http_referer']").val(); |
| 773 |
var s = payment.settings; |
| 774 |
s.data = "action=payment_ajax&sort=1&idstr=" + encodeURIComponent(meta_id_str) + "&wc_nonce=" + encodeURIComponent(wc_nonce) + "&_wp_http_referer=" + encodeURIComponent(_wp_http_referer); |
| 775 |
$.ajax( s ).done(function( data ){ |
| 776 |
$("tbody#payment-list").html( data.meta_row ); |
| 777 |
for(i=0; i<meta_ids.length; i++){ |
| 778 |
$("#payment_loading-" + meta_ids[i]).html(''); |
| 779 |
$("#payment-" + meta_ids[i]).css({'background-color': '#FF4'}); |
| 780 |
$("#payment-" + meta_ids[i]).animate({ 'background-color': '#FFFFEE' }, 2000 ); |
| 781 |
} |
| 782 |
}).fail(function(msg){ |
| 783 |
$("#payment_ajax-response").html('<div class="error"><p>error sort</p></div>'); |
| 784 |
}); |
| 785 |
return false; |
| 786 |
} |
| 787 |
}; |
| 788 |
|
| 789 |
orderItem = { |
| 790 |
settings: { |
| 791 |
url: uscesL10n.requestFile, |
| 792 |
type: 'POST', |
| 793 |
cache: false |
| 794 |
}, |
| 795 |
|
| 796 |
add2cart : function(newid, newsku) { |
| 797 |
var ID = $("input[name='order_id']").val(); |
| 798 |
var wc_nonce = $("#wc_nonce").val(); |
| 799 |
var optob; |
| 800 |
var optvalue = ''; |
| 801 |
var query = 'action=order_item2cart_ajax&order_id='+ID+'&post_id='+newid+'&sku='+newsku + '&wc_nonce=' + encodeURIComponent(wc_nonce); |
| 802 |
|
| 803 |
var newoptob = $("input[name*='optNEWCode\[" + newid + "\]\[" + newsku + "\]']"); |
| 804 |
var newoptvalue = ''; |
| 805 |
var mes = ''; |
| 806 |
for( var n = 0; n < newoptob.length; n++) { |
| 807 |
newoptvalue = $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").val(); |
| 808 |
var newoptclass = $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").attr("class"); |
| 809 |
var essential = $(":input[name='optNEWEssential\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").val(); |
| 810 |
switch(newoptclass) { |
| 811 |
case 'iopt_select_multiple': |
| 812 |
var sel = 0; |
| 813 |
if( essential == 1 ) { |
| 814 |
$(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]'] option:selected").each(function(idx, obj) { |
| 815 |
if( '#NONE#' != $(this).val()) { |
| 816 |
sel++; |
| 817 |
} |
| 818 |
}); |
| 819 |
if( sel == 0 ) { |
| 820 |
mes += uscesL10n.message[15].replace( "%s", decodeURIComponent($(newoptob[n]).val()) )+"\n"; |
| 821 |
} |
| 822 |
} |
| 823 |
$(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]'] option:selected").each(function(idx, obj) { |
| 824 |
if( '#NONE#' != $(this).val()) { |
| 825 |
query += "&itemOption[" + $(newoptob[n]).val() + "][" + encodeURIComponent($(this).val()) + "]="+encodeURIComponent($(this).val()); |
| 826 |
} |
| 827 |
}); |
| 828 |
break; |
| 829 |
case 'iopt_select': |
| 830 |
if( essential == 1 && newoptvalue == '#NONE#' ) { |
| 831 |
mes += uscesL10n.message[15].replace( "%s", decodeURIComponent($(newoptob[n]).val()) )+"\n"; |
| 832 |
} else { |
| 833 |
query += "&itemOption[" + $(newoptob[n]).val() + "]="+encodeURIComponent(newoptvalue); |
| 834 |
} |
| 835 |
break; |
| 836 |
case 'iopt_radio': |
| 837 |
var sel = 0; |
| 838 |
var ra = ''; |
| 839 |
if( $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']:checked").val() ) { |
| 840 |
sel++; |
| 841 |
ra = $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']:checked").val(); |
| 842 |
} |
| 843 |
if( essential == 1 && sel == 0 ) { |
| 844 |
mes += uscesL10n.message[15].replace( "%s", decodeURIComponent($(newoptob[n]).val()) )+"\n"; |
| 845 |
} |
| 846 |
query += "&itemOption[" + $(newoptob[n]).val() + "]=" + ra; |
| 847 |
break; |
| 848 |
case 'iopt_checkbox': |
| 849 |
var sel = 0; |
| 850 |
if( essential == 1 ) { |
| 851 |
$(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']:checked").each(function(idx, obj) { |
| 852 |
if( '' != $(this).val()) { |
| 853 |
sel++; |
| 854 |
} |
| 855 |
}); |
| 856 |
if( sel == 0 ) { |
| 857 |
mes += uscesL10n.message[15].replace( "%s", decodeURIComponent($(newoptob[n]).val()) )+"\n"; |
| 858 |
} |
| 859 |
} |
| 860 |
$(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']:checked").each(function(idx, obj) { |
| 861 |
if( $(this).val()) { |
| 862 |
query += "&itemOption[" + $(newoptob[n]).val() + "][" + $(this).val() + "]=" + $(this).val(); |
| 863 |
} |
| 864 |
}); |
| 865 |
break; |
| 866 |
case 'iopt_text': |
| 867 |
case 'iopt_textarea': |
| 868 |
if( essential == 1 && newoptvalue == '' ) { |
| 869 |
mes += uscesL10n.message[16].replace( "%s", decodeURIComponent($(newoptob[n]).val()) )+"\n"; |
| 870 |
} else { |
| 871 |
query += "&itemOption[" + $(newoptob[n]).val() + "]="+encodeURIComponent(newoptvalue); |
| 872 |
} |
| 873 |
break; |
| 874 |
} |
| 875 |
} |
| 876 |
if( mes != '' ) { |
| 877 |
alert(mes); |
| 878 |
return; |
| 879 |
} |
| 880 |
|
| 881 |
var s = orderItem.settings; |
| 882 |
s.data = query; |
| 883 |
$.ajax( s ).done(function( data ){ |
| 884 |
$("#orderitemlist").html(data); |
| 885 |
orderfunc.sumPrice(null); |
| 886 |
}).fail(function( msg ){ |
| 887 |
$("#order-response").html(msg); |
| 888 |
}); |
| 889 |
return false; |
| 890 |
}, |
| 891 |
|
| 892 |
add2cart_old : function(newid, newsku) { |
| 893 |
var ID = $("input[name='order_id']").val(); |
| 894 |
var cnum = $("#orderitemlist").children().length; |
| 895 |
var priceob = $("input[name*='skuPrice']"); |
| 896 |
var quantob = $("input[name*='quant']"); |
| 897 |
var wc_nonce = $("#wc_nonce").val(); |
| 898 |
var name = ''; |
| 899 |
var strs = ''; |
| 900 |
var post_ids = []; |
| 901 |
var skus = []; |
| 902 |
var optob; |
| 903 |
var optvalue = ''; |
| 904 |
var query = 'action=order_item2cart_ajax&order_id='+ID + '&wc_nonce=' + encodeURIComponent(wc_nonce); |
| 905 |
for( var i = 0; i < cnum; i++) { |
| 906 |
name = $(priceob[i]).attr("name"); |
| 907 |
strs = name.split('['); |
| 908 |
post_ids[i] = strs[2].replace(/[\]]+$/g, ''); |
| 909 |
skus[i] = strs[3].replace(/[\]]+$/g, ''); |
| 910 |
|
| 911 |
query += "&skuPrice["+i+"]["+post_ids[i]+"]["+skus[i]+"]="+$("input[name='skuPrice\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]']").val(); |
| 912 |
query += "&quant["+i+"]["+post_ids[i]+"]["+skus[i]+"]="+$("input[name='quant\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]']").val(); |
| 913 |
|
| 914 |
optob = $("input[name*='optName\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]']"); |
| 915 |
optvalue = ''; |
| 916 |
for( var o = 0; o < optob.length; o++) { |
| 917 |
//optvalue = $("input[name='itemOption\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]\[" + $(optob[o]).val() + "\]']").val(); |
| 918 |
//if( '#NONE#' != optvalue){ |
| 919 |
// query += "&itemOption["+i+"]["+post_ids[i]+"]["+skus[i]+"][" + $(optob[o]).val() + "]="+optvalue; |
| 920 |
//} |
| 921 |
var cnt = 0; |
| 922 |
$("input[name^='itemOption\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]\[" + $(optob[o]).val() + "\]\[']").each(function(idx, obj) { |
| 923 |
cnt++; |
| 924 |
}); |
| 925 |
if(0 < cnt) { |
| 926 |
$("input[name^='itemOption\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]\[" + $(optob[o]).val() + "\]\[']").each(function(idx, obj) { |
| 927 |
query += "&itemOption["+i+"]["+post_ids[i]+"]["+skus[i]+"][" + $(optob[o]).val() + "][" + $(this).val() + "]="+$(this).val(); |
| 928 |
}); |
| 929 |
} else { |
| 930 |
optvalue = $("input[name='itemOption\["+i+"\]\["+post_ids[i]+"\]\["+skus[i]+"\]\["+$(optob[o]).val()+"\]']").val(); |
| 931 |
query += "&itemOption["+i+"]["+post_ids[i]+"]["+skus[i]+"]["+$(optob[o]).val()+"]="+optvalue; |
| 932 |
} |
| 933 |
} |
| 934 |
} |
| 935 |
query += "&skuPrice["+cnum+"]["+newid+"]["+newsku+"]="+$("input[name='skuNEWPrice\[" + newid + "\]\[" + newsku + "\]']").val(); |
| 936 |
query += "&quant["+cnum+"]["+newid+"]["+newsku+"]=1"; |
| 937 |
var newoptob = $("input[name*='optNEWCode\[" + newid + "\]\[" + newsku + "\]']"); |
| 938 |
var newoptvalue = ''; |
| 939 |
var mes = ''; |
| 940 |
for( var n = 0; n < newoptob.length; n++) { |
| 941 |
//newoptvalue = $("select[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").val(); |
| 942 |
newoptvalue = $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").val(); |
| 943 |
var newoptclass = $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").attr("class"); |
| 944 |
var essential = $(":input[name='optNEWEssential\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").val(); |
| 945 |
switch(newoptclass) { |
| 946 |
case 'iopt_select_multiple': |
| 947 |
var sel = 0; |
| 948 |
if( essential == 1 ) { |
| 949 |
$(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]'] option:selected").each(function(idx, obj) { |
| 950 |
if( '#NONE#' != $(this).val()) { |
| 951 |
sel++; |
| 952 |
} |
| 953 |
}); |
| 954 |
} |
| 955 |
if( sel == 0 ) { |
| 956 |
mes += uscesL10n.message[15].replace( "%s", decodeURIComponent($(newoptob[n]).val()) )+"\n"; |
| 957 |
} else { |
| 958 |
$(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]'] option:selected").each(function(idx, obj) { |
| 959 |
if( '#NONE#' != $(this).val()) { |
| 960 |
query += "&itemOption["+cnum+"]["+newid+"]["+newsku+"][" + $(newoptob[n]).val() + "][" + $(this).val() + "]="+$(this).val(); |
| 961 |
} |
| 962 |
}); |
| 963 |
} |
| 964 |
break; |
| 965 |
case 'iopt_select': |
| 966 |
if( essential == 1 && newoptvalue == '#NONE#' ) { |
| 967 |
mes += uscesL10n.message[15].replace( "%s", decodeURIComponent($(newoptob[n]).val()) )+"\n"; |
| 968 |
} else { |
| 969 |
query += "&itemOption["+cnum+"]["+newid+"]["+newsku+"][" + $(newoptob[n]).val() + "]="+newoptvalue; |
| 970 |
} |
| 971 |
break; |
| 972 |
case 'iopt_text': |
| 973 |
case 'iopt_textarea': |
| 974 |
if( essential == 1 && newoptvalue == '' ) { |
| 975 |
mes += uscesL10n.message[16].replace( "%s", decodeURIComponent($(newoptob[n]).val()) )+"\n"; |
| 976 |
} else { |
| 977 |
query += "&itemOption["+cnum+"]["+newid+"]["+newsku+"][" + $(newoptob[n]).val() + "]="+newoptvalue; |
| 978 |
} |
| 979 |
break; |
| 980 |
} |
| 981 |
} |
| 982 |
if( mes != '' ) { |
| 983 |
alert(mes); |
| 984 |
return; |
| 985 |
} |
| 986 |
|
| 987 |
var s = orderItem.settings; |
| 988 |
s.data = query; |
| 989 |
$.ajax( s ).done(function( data ){ |
| 990 |
//if(data == 'nodata'){return;} |
| 991 |
if( 0 > parseInt(data.meta_row) ) return; |
| 992 |
var pict = "<img src='" + $("#newitemform img").attr("src") + "' width='" + $("#newitemform img").attr("width") + "' height='" + $("#newitemform img").attr("height") + "' alt='' />"; |
| 993 |
//var itemName = $("input[name='itemNEWName\["+newid+"\]\["+newsku+"\]']").val() + ' ' + $("input[name='itemNEWCode\["+newid+"\]\["+newsku+"\]']").val() + ' ' + $("input[name='skuNEWName\["+newid+"\]\["+newsku+"\]']").val(); |
| 994 |
var itemName = data.meta_id; |
| 995 |
var zaiko = $("input[name='zaiNEWko\["+newid+"\]\["+newsku+"\]']").val(); |
| 996 |
//var price = "<input name='skuPrice[" + cnum + "][" + newid + "][" + newsku + "]' class='text price' type='text' value='" + $("input[name='skuNEWPrice\["+newid+"\]\["+newsku+"\]']").val() + "' onchange='orderfunc.sumPrice()' />"; |
| 997 |
//var quant = "<input name='quant[" + cnum + "][" + newid + "][" + newsku + "]' class='text quantity' type='text' value='1' onchange='orderfunc.sumPrice()' />"; |
| 998 |
//var price = "<input name='skuPrice[" + cnum + "][" + newid + "][" + newsku + "]' class='text price' type='text' value='" + $("input[name='skuNEWPrice\["+newid+"\]\["+newsku+"\]']").val() + "' />"; |
| 999 |
var price = "<input name='skuPrice[" + cnum + "][" + newid + "][" + newsku + "]' class='text price' type='text' value='" + data.meta_row + "' />"; |
| 1000 |
var quant = "<input name='quant[" + cnum + "][" + newid + "][" + newsku + "]' class='text quantity' type='text' value='1' />"; |
| 1001 |
var delButton = "<input name='delButton[" + cnum + "][" + newid + "][" + newsku + "]' class='delCartButton' type='submit' value='"+uscesL10n.message[18]+"' />\n<input name='advance[" + cnum + "][" + newid + "][" + newsku + "]' type='hidden' value='' />\n"; |
| 1002 |
|
| 1003 |
var sucoptob = $("input[name*='optNEWCode\[" + newid + "\]\[" + newsku + "\]']"); |
| 1004 |
var skuOptValue = ''; |
| 1005 |
var skuoptval = ''; |
| 1006 |
var hiddenopt = ''; |
| 1007 |
var hiddenoptname = ''; |
| 1008 |
for( var i = 0; i < sucoptob.length; i++) { |
| 1009 |
skuoptcode = $(sucoptob[i]).val(); |
| 1010 |
skuoptname = decodeURIComponent($(sucoptob[i]).val()); |
| 1011 |
hiddenoptname += "<input name='optName[" + newid + "][" + newsku + "][" + skuoptcode + "]' type='hidden' value='"+skuoptcode+"' />\n"; |
| 1012 |
//skuoptval = $("select[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + skuoptcode + "\]']").val(); |
| 1013 |
skuoptval = $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + skuoptcode + "\]']").val(); |
| 1014 |
//if( '#NONE#' != skuoptval){ |
| 1015 |
// skuOptValue += skuoptval + ' '; |
| 1016 |
// hiddenopt += "<input name='itemOption[" + cnum + "][" + newid + "][" + newsku + "][" + skuoptcode + "]' type='hidden' value='"+skuoptval+"' />"; |
| 1017 |
// hiddenoptname += "<input name='optName[" + cnum + "][" + newid + "][" + newsku + "][" + skuoptcode + "]' type='hidden' value='"+skuoptcode+"' />"; |
| 1018 |
//} |
| 1019 |
skuOptValue += skuoptname + ' : '; |
| 1020 |
var sucoptclass = $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + skuoptcode + "\]']").attr("class"); |
| 1021 |
switch(sucoptclass) { |
| 1022 |
case 'iopt_select_multiple': |
| 1023 |
var c = ''; |
| 1024 |
$(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + skuoptcode + "\]'] option:selected").each(function(idx, obj) { |
| 1025 |
if( '#NONE#' != $(this).val() ) { |
| 1026 |
skuOptValue += c + $(this).val(); |
| 1027 |
c = ', '; |
| 1028 |
hiddenopt += "<input name='itemOption[" + cnum + "][" + newid + "][" + newsku + "][" + skuoptcode + "][" + encodeURIComponent($(this).val()) + "]' type='hidden' value='"+encodeURIComponent($(this).val())+"' />\n"; |
| 1029 |
} |
| 1030 |
}); |
| 1031 |
break; |
| 1032 |
case 'iopt_select': |
| 1033 |
if( '#NONE#' != skuoptval ) { |
| 1034 |
skuOptValue += skuoptval; |
| 1035 |
hiddenopt += "<input name='itemOption[" + cnum + "][" + newid + "][" + newsku + "][" + skuoptcode + "]' type='hidden' value='"+encodeURIComponent(skuoptval)+"' />\n"; |
| 1036 |
} |
| 1037 |
break; |
| 1038 |
case 'iopt_text': |
| 1039 |
case 'iopt_textarea': |
| 1040 |
skuOptValue += skuoptval; |
| 1041 |
hiddenopt += "<input name='itemOption[" + cnum + "][" + newid + "][" + newsku + "][" + skuoptcode + "]' type='hidden' value='"+encodeURIComponent(skuoptval)+"' />\n"; |
| 1042 |
break; |
| 1043 |
} |
| 1044 |
skuOptValue += '<br />'; |
| 1045 |
} |
| 1046 |
var htm = "<tr>\n"; |
| 1047 |
htm += "<td>"+(cnum+1)+"</td>\n"; |
| 1048 |
htm += "<td>"+pict+"</td>\n"; |
| 1049 |
htm += "<td class='aleft'>"+itemName+"<br />"+skuOptValue+"</td>\n"; |
| 1050 |
htm += "<td>"+price+"</td>\n"; |
| 1051 |
htm += "<td>"+quant+"</td>\n"; |
| 1052 |
htm += "<td><p id='sub_total["+cnum+"]' class='aright'> </p></td>\n"; |
| 1053 |
htm += "<td>"+zaiko+"</td>\n"; |
| 1054 |
htm += "<td>"+delButton+hiddenoptname+hiddenopt+"</td>\n"; |
| 1055 |
htm += "</tr>\n"; |
| 1056 |
|
| 1057 |
$("#orderitemlist").append( htm ); |
| 1058 |
orderfunc.sumPrice(null); |
| 1059 |
|
| 1060 |
$("input[name='skuPrice["+cnum+"]["+newid+"]["+newsku+"]']").bind("change", {index:cnum, post_id:newid, sku:newsku}, function(e){ orderfunc.sumPrice($(this)); }); |
| 1061 |
$("input[name='quant["+cnum+"]["+newid+"]["+newsku+"]']").bind("change", {index:cnum, post_id:newid, sku:newsku}, function(e){ orderfunc.sumPrice($(this)); }); |
| 1062 |
$("input[name='delButton["+cnum+"]["+newid+"]["+newsku+"]']").bind("click", {index:cnum, post_id:newid, sku:newsku}, function(e){ return delConfirm($(this)); }); |
| 1063 |
$("input[name*='skuPrice[" + cnum + "][" + newid + "][" + newsku + "]']").bind("change", function(){ orderfunc.sumPrice($(this)); }); |
| 1064 |
$("input[name*='quant[" + cnum + "][" + newid + "][" + newsku + "]']").bind("change", function(){ orderfunc.sumPrice($(this)); }); |
| 1065 |
$("input[name*='delButton[" + cnum + "][" + newid + "][" + newsku + "]']").bind("click", function(){ orderfunc.sumPrice(null); }); |
| 1066 |
}).fail(function( msg ){ |
| 1067 |
$("#order-response").html(msg); |
| 1068 |
}); |
| 1069 |
return false; |
| 1070 |
}, |
| 1071 |
|
| 1072 |
getSelitem : function( cat_id ) { |
| 1073 |
if(cat_id == '-1'){ |
| 1074 |
$("#newitemcode").html(''); |
| 1075 |
return false; |
| 1076 |
} |
| 1077 |
$("#loading").html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />'); |
| 1078 |
var wc_nonce = $("#wc_nonce").val(); |
| 1079 |
var s = orderItem.settings; |
| 1080 |
s.data = "action=order_item_ajax&mode=get_item_select_option&cat_id=" + cat_id + "&wc_nonce=" + wc_nonce; |
| 1081 |
$.ajax( s ).done(function( data ){ |
| 1082 |
$("#loading").html(''); |
| 1083 |
$("#newitemcode").html( data ); |
| 1084 |
}).fail(function( msg ){ |
| 1085 |
$("#order-response").html(msg); |
| 1086 |
}); |
| 1087 |
return false; |
| 1088 |
}, |
| 1089 |
|
| 1090 |
getitem : function(itemcode) { |
| 1091 |
if(itemcode == '-1'){ |
| 1092 |
$("#newitemform").html(''); |
| 1093 |
return false; |
| 1094 |
} |
| 1095 |
$("#loading").html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />'); |
| 1096 |
var wc_nonce = $("#wc_nonce").val(); |
| 1097 |
var s = orderItem.settings; |
| 1098 |
s.data = "action=order_item_ajax&mode=get_order_item&itemcode=" + itemcode + "&wc_nonce=" + wc_nonce; |
| 1099 |
$.ajax( s ).done(function( data ){ |
| 1100 |
$("#loading").html(''); |
| 1101 |
$("#newitemform").html( data ); |
| 1102 |
}).fail(function( msg ){ |
| 1103 |
$("#order-response").html(msg); |
| 1104 |
}); |
| 1105 |
return false; |
| 1106 |
}, |
| 1107 |
|
| 1108 |
getmailmessage : function( flag ) { |
| 1109 |
$("#sendmailmessage").val( uscesL10n.now_loading ); |
| 1110 |
$("#usces_email_bnt_send").prop("disabled", true); |
| 1111 |
var order_id = $("input[name='order_id']").val(); |
| 1112 |
var s = orderItem.settings; |
| 1113 |
var wc_nonce = $("#wc_nonce").val(); |
| 1114 |
s.data = "action=order_item_ajax&mode=" + flag + "&order_id=" + order_id + "&wc_nonce=" + wc_nonce; |
| 1115 |
$.ajax( s ).done(function( data ){ |
| 1116 |
$("#sendmailmessage").val( data ); |
| 1117 |
$("#usces_email_bnt_send").removeAttr('disabled'); |
| 1118 |
}).fail(function( msg ){ |
| 1119 |
$("#order-response").html(msg); |
| 1120 |
$("#usces_email_bnt_send").removeAttr('disabled'); |
| 1121 |
}); |
| 1122 |
return false; |
| 1123 |
}, |
| 1124 |
getMailMessageRichEditor : function(usceAdminUrl, mode ) { |
| 1125 |
$("#loading_iframe").text(uscesL10n.now_loading); |
| 1126 |
$("#usces_email_bnt_preview").prop("disabled", true); |
| 1127 |
$("#usces_email_bnt_send").prop("disabled", true); |
| 1128 |
$("#loading_iframe").show(); |
| 1129 |
var order_id = $("input[name='order_id']").val(); |
| 1130 |
usceAdminUrl += '?page=usces_orderlist&order_action=load_rich_editor&orderid='+order_id+'&mode='+mode+'&noheader=true' + '&wc_nonce=' + $("#wc_nonce").val(); |
| 1131 |
$('#iframeLoadEditor').attr('src', usceAdminUrl); |
| 1132 |
$('#iframeLoadEditor').load(function(){ |
| 1133 |
$("#loading_iframe").hide(); |
| 1134 |
$(this).show(); |
| 1135 |
$("#usces_email_bnt_preview").removeAttr('disabled'); |
| 1136 |
$("#usces_email_bnt_send").removeAttr('disabled'); |
| 1137 |
}); |
| 1138 |
} |
| 1139 |
|
| 1140 |
}; |
| 1141 |
|
| 1142 |
uscesInformation = { |
| 1143 |
settings: { |
| 1144 |
url: 'http://www.welcart.com/util/welcart_information.php', |
| 1145 |
type: 'POST', |
| 1146 |
cache: false |
| 1147 |
}, |
| 1148 |
|
| 1149 |
getinfo : function() { |
| 1150 |
var s = uscesInformation.settings; |
| 1151 |
s.data = "v=" + encodeURIComponent(uscesL10n.version); |
| 1152 |
s.data += "&wcid=" + encodeURIComponent(uscesL10n.wcid); |
| 1153 |
s.data += "&wcurl=" + encodeURIComponent(uscesL10n.USCES_PLUGIN_URL); |
| 1154 |
s.data += "&locale=" + encodeURIComponent(uscesL10n.locale); |
| 1155 |
s.data += "&theme=" + encodeURIComponent(uscesL10n.theme); |
| 1156 |
s.data += "&wcex="; |
| 1157 |
var de = ''; |
| 1158 |
for( var i = 0; i < uscesL10n.wcex.length; i++) { |
| 1159 |
s.data += de + encodeURIComponent(uscesL10n.wcex[i]); |
| 1160 |
de =','; |
| 1161 |
} |
| 1162 |
$.ajax( s ).done(function( data ){ |
| 1163 |
$("#wc_information").html( data ); |
| 1164 |
}).fail(function( msg ){ |
| 1165 |
$("#wc_information").html( 'error : ' + msg ); |
| 1166 |
}); |
| 1167 |
return false; |
| 1168 |
}, |
| 1169 |
|
| 1170 |
getinfo2 : function() { |
| 1171 |
var s = uscesInformation.settings; |
| 1172 |
s.url = uscesL10n.requestFile; |
| 1173 |
s.data = 'action=getinfo_ajax'; |
| 1174 |
$.ajax( s ).done(function( data ){ |
| 1175 |
$("#wc_information").html( data ); |
| 1176 |
}).fail(function( msg ){ |
| 1177 |
$("#wc_information").html( 'error : ' + msg ); |
| 1178 |
}); |
| 1179 |
return false; |
| 1180 |
} |
| 1181 |
|
| 1182 |
}; |
| 1183 |
|
| 1184 |
uscesItem = { |
| 1185 |
|
| 1186 |
newdraft : function(itemName) { |
| 1187 |
if(jQuery("#title").val().length == 0 || jQuery("#title").val() == '') { |
| 1188 |
$("#title").val(itemName); |
| 1189 |
} |
| 1190 |
//autosave(); |
| 1191 |
|
| 1192 |
}, |
| 1193 |
|
| 1194 |
cahngepict : function(code) { |
| 1195 |
$("div#item-select-pict").html(code); |
| 1196 |
}, |
| 1197 |
|
| 1198 |
trim : function(target){ |
| 1199 |
target = target.replace(/(^\s+)|(\s+$)|(^\n+)|(\n+$)/g, ""); |
| 1200 |
return target; |
| 1201 |
} |
| 1202 |
|
| 1203 |
}; |
| 1204 |
|
| 1205 |
welPageNav = { |
| 1206 |
checkShowNextprevPage : function( key_current_page_ids, sub_uri_link, current_id ) { |
| 1207 |
var current_id = parseInt(current_id); |
| 1208 |
if (0 > current_id) { |
| 1209 |
return false; |
| 1210 |
} |
| 1211 |
try { |
| 1212 |
var current_page_ids = window.localStorage.getItem(key_current_page_ids); |
| 1213 |
} catch (e) { |
| 1214 |
var current_page_ids = ''; |
| 1215 |
} |
| 1216 |
if ( current_page_ids ) { |
| 1217 |
var arr_current_page_ids = current_page_ids.split(","); |
| 1218 |
if (0 > arr_current_page_ids.length) { |
| 1219 |
return false; |
| 1220 |
} |
| 1221 |
var index_prev = -1; |
| 1222 |
var index_next = -1; |
| 1223 |
for (var i = 0; i < arr_current_page_ids.length; ++i) { |
| 1224 |
if (arr_current_page_ids[i] == current_id) { |
| 1225 |
index_prev = i - 1; |
| 1226 |
index_next = i + 1; |
| 1227 |
break; |
| 1228 |
} |
| 1229 |
} |
| 1230 |
if ( arr_current_page_ids[index_prev] ) { |
| 1231 |
var prev_link = sub_uri_link + arr_current_page_ids[index_prev]; |
| 1232 |
jQuery(".edit_pagenav .prev-page").attr('href', prev_link); |
| 1233 |
jQuery(".edit_pagenav .prev-page").show(); |
| 1234 |
} |
| 1235 |
if ( arr_current_page_ids[index_next] ) { |
| 1236 |
var next_link = sub_uri_link + arr_current_page_ids[index_next]; |
| 1237 |
jQuery(".edit_pagenav .next-page").attr('href', next_link); |
| 1238 |
jQuery(".edit_pagenav .next-page").show(); |
| 1239 |
} |
| 1240 |
} |
| 1241 |
} |
| 1242 |
}; |
| 1243 |
|
| 1244 |
$( document ).on( "change", "#newitemcategory", function() { |
| 1245 |
orderItem.getSelitem( $(this).val() ); |
| 1246 |
}); |
| 1247 |
|
| 1248 |
$( document ).on( "change", "#newitemcode", function() { |
| 1249 |
orderItem.getitem( $(this).val() ); |
| 1250 |
}); |
| 1251 |
|
| 1252 |
$("#getitembutton").click( function(){ |
| 1253 |
orderItem.getitem( encodeURIComponent($("#newitemcodein").val()) ); |
| 1254 |
}); |
| 1255 |
|
| 1256 |
adminOperation = { |
| 1257 |
setActionStatus : function( status, message ) { |
| 1258 |
if( $("#usces_admin_status") == undefined || status == "" || message == "" ) return; |
| 1259 |
|
| 1260 |
var notice_class = ""; |
| 1261 |
if( status == "success" ) { |
| 1262 |
notice_class = "updated"; |
| 1263 |
} else if( status == "caution" ){ |
| 1264 |
notice_class = "update-nag"; |
| 1265 |
} else if( status == "error" ) { |
| 1266 |
notice_class = "error"; |
| 1267 |
} |
| 1268 |
if( "" != notice_class ) { |
| 1269 |
$("#usces_admin_status").html( "" ); |
| 1270 |
$("#usces_admin_status").html( '<div id="wc2-action-status" class="'+notice_class+' notice is-dismissible"><p><strong>'+message+'</strong></p><button type="button" class="notice-dismiss"><span class="screen-reader-text">'+uscesL10n.message[19]+'</span></button></div>' ); |
| 1271 |
} |
| 1272 |
}, |
| 1273 |
|
| 1274 |
removeActionStatus : function() { |
| 1275 |
$("#usces_admin_status").html( "" ); |
| 1276 |
$("#usces_action_status").remove(); |
| 1277 |
} |
| 1278 |
}; |
| 1279 |
|
| 1280 |
$(document).on("click", ".notice-dismiss", function() { |
| 1281 |
adminOperation.removeActionStatus(); |
| 1282 |
}); |
| 1283 |
|
| 1284 |
$( document ).on( "click", ".explanation-label", function() { |
| 1285 |
var idname = $( this ).attr( "id" ); |
| 1286 |
var explanation = "#"+idname.substr( 6 ); |
| 1287 |
if( $( explanation ).css( "display" ) == "table-row" ) { |
| 1288 |
$( explanation ).css( "display", "none" ); |
| 1289 |
} else { |
| 1290 |
$( explanation ).css( "display", "table-row" ); |
| 1291 |
} |
| 1292 |
}); |
| 1293 |
$(document).on('submit',"form#datalistup_form",function () { |
| 1294 |
var wp_usc_member_cookie_path = (typeof $.cookie('wp_usces_member_path') != 'undefined') ? $.cookie('wp_usces_member_path') : '/wp-admin/'; |
| 1295 |
var wp_usc_order_cookie_path = (typeof $.cookie('wp_usces_order_path') != 'undefined') ? $.cookie('wp_usces_order_path') : '/wp-admin/'; |
| 1296 |
|
| 1297 |
$.removeCookie("wp_usces_member", {path: wp_usc_member_cookie_path, domain: window.location.hostname}); |
| 1298 |
$.removeCookie("wp_usces_order", {path: wp_usc_order_cookie_path, domain: window.location.hostname}); |
| 1299 |
return true; |
| 1300 |
}); |
| 1301 |
$(document).on('click','#btn_download_env_info', function () { |
| 1302 |
$.ajax({ |
| 1303 |
url: ajaxurl, |
| 1304 |
type: "POST", |
| 1305 |
data: { |
| 1306 |
'action': 'usces_download_system_information', |
| 1307 |
'_ajax_nonce' : $('#wc_nonce').val(), |
| 1308 |
} |
| 1309 |
}) |
| 1310 |
.done(function (response) { |
| 1311 |
response = jQuery.parseJSON(response); |
| 1312 |
var element = document.createElement('a'); |
| 1313 |
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(response.data)); |
| 1314 |
element.setAttribute('download', response.filename); |
| 1315 |
|
| 1316 |
element.style.display = 'none'; |
| 1317 |
document.body.appendChild(element); |
| 1318 |
|
| 1319 |
element.click(); |
| 1320 |
|
| 1321 |
document.body.removeChild(element); |
| 1322 |
}) |
| 1323 |
.fail(function (error) { |
| 1324 |
alert(error.status + " " + error.statusText); |
| 1325 |
}) |
| 1326 |
}) |
| 1327 |
$(document).on('submit', '#google_recaptcha_form', function (e) { |
| 1328 |
var status = true; |
| 1329 |
var gg_recaptcha_status = $(this).find('input[name="status"]:checked').val(); |
| 1330 |
if(gg_recaptcha_status == 1){ |
| 1331 |
var site_key = $('#site_key').val(); |
| 1332 |
var secret_key = $('#secret_key').val(); |
| 1333 |
if (!site_key.length) { |
| 1334 |
$('#site_key').css('background-color', '#ffffaa'); |
| 1335 |
$('#error_google_recaptcha_site_key').css('display','block'); |
| 1336 |
status = false; |
| 1337 |
} |
| 1338 |
else { |
| 1339 |
$('#site_key').css('background-color', '#fff'); |
| 1340 |
$('#error_google_recaptcha_site_key').css('display','none'); |
| 1341 |
} |
| 1342 |
if (!secret_key.length) { |
| 1343 |
$('#secret_key').css('background-color', '#ffffaa'); |
| 1344 |
$('#error_google_recaptcha_secret_key').css('display','block'); |
| 1345 |
status = false; |
| 1346 |
} |
| 1347 |
else{ |
| 1348 |
$('#secret_key').css('background-color', '#fff'); |
| 1349 |
$('#error_google_recaptcha_secret_key').css('display','none'); |
| 1350 |
} |
| 1351 |
} |
| 1352 |
return status; |
| 1353 |
}); |
| 1354 |
})(jQuery); |
| 1355 |
|
| 1356 |
function usces_check_num(obj) { |
| 1357 |
if(!checkNum(obj.val())) { |
| 1358 |
alert(uscesL10n.message[17]); |
| 1359 |
obj.focus(); |
| 1360 |
return false; |
| 1361 |
} |
| 1362 |
return true; |
| 1363 |
} |
| 1364 |
function usces_check_money(obj) { |
| 1365 |
if(!checkMoney(obj.val())) { |
| 1366 |
alert(uscesL10n.message[17]); |
| 1367 |
obj.focus(); |
| 1368 |
return false; |
| 1369 |
} |
| 1370 |
return true; |
| 1371 |
} |
| 1372 |
function checkAlp(argValue) { |
| 1373 |
if(argValue && argValue.match(/[^a-z|^A-Z]/g)) { |
| 1374 |
return false; |
| 1375 |
} |
| 1376 |
return true; |
| 1377 |
} |
| 1378 |
function checkCode(argValue) { |
| 1379 |
if(argValue && argValue.match(/[^0-9|^a-z|^A-Z|^\-|^_]/g)) { |
| 1380 |
return false; |
| 1381 |
} |
| 1382 |
return true; |
| 1383 |
} |
| 1384 |
function checkNum(argValue) { |
| 1385 |
if(argValue && argValue.match(/[^0-9]/g)) { |
| 1386 |
return false; |
| 1387 |
} |
| 1388 |
return true; |
| 1389 |
} |
| 1390 |
function checkNumMinus(argValue) { |
| 1391 |
if( argValue && argValue.match(/[^0-9|^\-]/g) ) { |
| 1392 |
return false; |
| 1393 |
} |
| 1394 |
if( argValue.match(/[^\-]/g) ) { |
| 1395 |
} else { |
| 1396 |
return false; |
| 1397 |
} |
| 1398 |
var count = 0; |
| 1399 |
for( i = 0; i < argValue.length; i++ ) { |
| 1400 |
if( argValue.charAt(i) == "-" ) { |
| 1401 |
count++; |
| 1402 |
} |
| 1403 |
} |
| 1404 |
if( 2 <= count || (count == 1 && argValue.charAt(0) != "-") ) { |
| 1405 |
return false; |
| 1406 |
} |
| 1407 |
return true; |
| 1408 |
} |
| 1409 |
function checkMoney(argValue) { |
| 1410 |
if(argValue && argValue.match(/[^0-9|^\.]/g)) { |
| 1411 |
return false; |
| 1412 |
} |
| 1413 |
return true; |
| 1414 |
} |
| 1415 |
function checkPrice(argValue) { |
| 1416 |
if(argValue && argValue.match(/[^0-9|^\-|^\,|^\.]/g)) { |
| 1417 |
return false; |
| 1418 |
} |
| 1419 |
return true; |
| 1420 |
} |
| 1421 |
|
| 1422 |
function toggleVisibility(id) { |
| 1423 |
var e = document.getElementById(id); |
| 1424 |
if( e.style.display == 'block' ) { |
| 1425 |
e.style.display = 'none'; |
| 1426 |
} else { |
| 1427 |
e.style.display = 'block'; |
| 1428 |
} |
| 1429 |
} |
| 1430 |
|
| 1431 |
function esc_js( str ) { |
| 1432 |
return str.replace(/"/g,'"').replace(/'/g,''').replace(/</g,'<').replace(/>/g,'>'); |
| 1433 |
} |
| 1434 |
|