PluginProbe
Welcart e-Commerce / 1.3.17
Welcart e-Commerce v1.3.17
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
usc-e-shop / js / usces_admin.js

usces_admin.js in Welcart e-Commerce 1.3.17, at js/usces_admin.js

1,085 lines 38.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // JavaScript
2 (function($) {
3 itemOpt = {
4 settings: {
5 url: uscesL10n.requestFile,
6 type: 'POST',
7 cache: false,
8 success: function(data, dataType){
9 $("tbody#item-opt-list").html( data );
10 },
11 error: function(msg){
12 $("#ajax-response").html(msg);
13 }
14 },
15
16 post : function(action, arg) {
17 if( action == 'updateitemopt' ) {
18 itemOpt.updateitemopt(arg);
19 } else if( action == 'deleteitemopt' ) {
20 itemOpt.deleteitemopt(arg);
21 } else if( action == 'additemopt' ) {
22 itemOpt.additemopt();
23 } else if( action == 'addcommonopt' ) {
24 itemOpt.addcommonopt();
25 } else if( action == 'keyselect' ) {
26 itemOpt.keyselect(arg);
27 }
28 },
29
30 additemopt : function() {
31 if($("#optkeyselect").val() == "#NONE#") return;
32
33 var id = $("#post_ID").val();
34 var name = $("#optkeyselect option:selected").html();
35 var value = $("#newoptvalue").val();
36 var means = $("#newoptmeans").val();
37 if($("input#newoptessential").attr("checked")){
38 var essential = '1';
39 }else{
40 var essential = '0';
41 }
42
43 var mes = '';
44 if( '' == name ){
45 mes += '<p>オプション名を�
46 �力してください。</p>';
47 } else {
48 var check = true;
49 $("input[name*='\[name\]']").each(function(){ if( name == $(this).val() ){ check = false; }});
50 if( !check ){
51 mes += '<p>同じ名前のオプションが存在します。</p>';
52 }
53 }
54 if( '' == value && (0 == means || 1 == means || 3 == means || 4 == means) ){
55 mes += '<p>セレクト値を�
56 �力してください。</p>';
57 }else if( '' != value && (2 == means || 5 == means) ){
58 mes += '<p>テキスト、テキストエリアの場合はセレクト値を空白にしてください。</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);
69 s.success = function(data, dataType){
70 $("#itemopt_ajax-response").html('');
71 $("#newitemopt_loading").html('');
72 $("table#optlist-table").removeAttr("style");
73 strs = data.split('#usces#');
74 meta_id = strs[1];
75 $("tbody#item-opt-list").html( strs[0] );
76 $("#optkeyselect").val('#NONE#');
77 $("#newoptvalue").html('');
78 $("#newoptmeans").val(0);
79 $("#newoptessential").attr({checked: false});
80 $("#itemopt-" + meta_id).css({'background-color': '#FF4'});
81 $("#itemopt-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 2000 );
82 };
83 s.error = function(msg){
84 $("#itemopt_ajax-response").html(msg);
85 $("#newitemopt_loading").html('');
86 };
87 $.ajax( s );
88 return false;
89 },
90
91 addcommonopt : function() {
92 var id = $("#post_ID").val();
93 var name = $("#newoptname").val();
94 var value = $("#newoptvalue").val();
95 var means = $("#newoptmeans").val();
96 if($("input#newoptessential").attr("checked")){
97 var essential = '1';
98 }else{
99 var essential = '0';
100 }
101
102 var mes = '';
103 if( '' == name ){
104 mes += '<p>オプション名を�
105 �力してください。</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>同じ名前のオプションが存在します。</p>';
111 }
112 }
113 if( '' == value && (0 == means || 1 == means || 3 == means || 4 == means) ){
114 mes += '<p>セレクト値を�
115 �力してください。</p>';
116 }else if( '' != value && (2 == means || 5 == means) ){
117 mes += '<p>テキスト、テキストエリアの場合はセレクト値を空白にしてください。</p>';
118 }
119 if( '' != mes ){
120 $("#itemopt_ajax-response").html('<div class="error">' + mes + '</div>');
121 return false;
122 }
123
124 $("#newcomopt_loading").html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />');
125
126 var s = itemOpt.settings;
127 s.data = "action=item_option_ajax&ID=" + id + "&newoptname=" + encodeURIComponent(name) + "&newoptvalue=" +encodeURIComponent(value) + "&newoptmeans=" + encodeURIComponent(means) + "&newoptessential=" + encodeURIComponent(essential);
128 s.success = function(data, dataType){
129 $("#newcomopt_loading").html('');
130 $("#itemopt_ajax-response").html('');
131 strs = data.split('#usces#');
132 $("table#optlist-table").removeAttr("style");
133 var meta_id = strs[1];
134 if( 0 > meta_id ){
135 $("#itemopt_ajax-response").html('<div class="error"><p>同じ名前のオプションが存在します。</p></div>');
136 }else{
137 $("tbody#item-opt-list").html( strs[0] );
138 $("#newoptname").val('');
139 $("#newoptvalue").val('');
140 $("#newoptmeans").val(0);
141 $("#newoptessential").attr({checked: false});
142 $("#itemopt-" + meta_id).css({'background-color': '#FF4'});
143 $("#itemopt-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 2000 );
144 }
145 };
146 s.error = function(msg){
147 $("#comopt_ajax-response").html(msg);
148 $("#newcomopt_loading").html('');
149 };
150 $.ajax( s );
151 return false;
152 },
153
154 updateitemopt : function(meta_id) {
155 var id = $("#post_ID").val();
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).attr("checked")){
166 var essential = '1';
167 }else{
168 var essential = '0';
169 }
170
171 var mes = '';
172 if( '' == name ){
173 mes += '<p>オプション名を�
174 �力してください。</p>';
175 }
176 if( '' == value && (0 == means || 1 == means || 3 == means || 4 == means) ){
177 mes += '<p>セレクト値を�
178 �力してください。</p>';
179 }else if( '' != value && (2 == means || 5 == means) ){
180 mes += '<p>テキスト、テキストエリアの場合はセレクト値を空白にしてください。</p>';
181 }
182 if( '' != mes ){
183 $("#itemopt_ajax-response").html('<div class="error">' + mes + '</div>');
184 return false;
185 }
186
187 $("#itemopt_loading-" + meta_id).html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />');
188
189 var s = itemOpt.settings;
190 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;
191 s.success = function(data, dataType){
192 $("#itemopt_ajax-response").html('');
193 $("#itemopt_loading-" + meta_id).html('');
194 strs = data.split('#usces#');
195 $("tbody#item-opt-list").html( strs[0] );
196 $("#itemopt-" + meta_id).css({'background-color': '#FF4'});
197 $("#itemopt-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 2000 );
198 };
199 s.error = function(msg){
200 $("#itemopt_ajax-response").html(msg);
201 $("#itemopt_loading-" + meta_id).html('');
202 };
203 $.ajax( s );
204 return false;
205 },
206
207 deleteitemopt : function(meta_id) {
208 $("#itemopt-" + meta_id).css({'background-color': '#F00'});
209 $("#itemopt-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 1000 );
210 var id = $("#post_ID").val();
211 var s = itemOpt.settings;
212 s.data = "action=item_option_ajax&ID=" + id + "&delete=1&optmetaid=" + meta_id;
213 s.success = function(data, dataType){
214 $("#itemopt_ajax-response").html("");
215 strs = data.split('#usces#');
216 $("tbody#item-opt-list").html( strs[0] );
217 };
218 s.error = function(msg){
219
220 };
221 $.ajax( s );
222 return false;
223 },
224
225 keyselect : function( meta_id ) {
226 if(meta_id == '#NONE#'){
227 $("#newoptvalue").val('');
228 $("#newoptmeans").val(0);
229 $("#newoptessential").attr({checked: false});
230 return;
231 }
232 var id = uscesL10n.cart_number;
233
234 $("#newitemopt_loading").html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />');
235 $("#add_itemopt").attr("disabled", true);
236
237 var s = itemOpt.settings;
238 s.data = "action=item_option_ajax&ID=" + id + "&select=1&meta_id=" + meta_id;
239 s.success = function(data, dataType){
240 $("#itemopt_ajax-response").html("");
241 strs = data.split('#usces#');
242 var means = strs[0];
243 var essential = strs[1];
244 var value = strs[2];
245 if( 2 == means || 5 == means ){
246 value = '';
247 }
248 $("#newoptvalue").html(value);
249 $("#newoptmeans").val(means);
250 if( essential == '1') {
251 $("#newoptessential").attr({checked: true});
252 }else{
253 $("#newoptessential").attr({checked: false});
254 }
255 $("#newitemopt_loading").html('');
256 $("#add_itemopt").attr("disabled", false);
257 };
258 s.error = function(msg){
259 $("#itemopt_ajax-response").html(msg);
260 $("#newitemopt_loading").html('');
261 };
262 $.ajax( s );
263 return false;
264 },
265
266 dosort : function( str ) {
267 if( !str ) return;
268 var id = $("#post_ID").val();
269 var meta_id_str = str.replace(/itemopt-/g, "");
270 var meta_ids = meta_id_str.split(',');
271 if( 2 > meta_ids.length ) return;
272
273 for(i=0; i<meta_ids.length; i++){
274 $("#itemopt_loading-" + meta_ids[i]).html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />');
275 }
276 var s = itemOpt.settings;
277 s.data = "action=item_option_ajax&ID=" + id + "&sort=1&meta=" + encodeURIComponent(meta_id_str);
278 s.success = function(data, dataType){
279 $("#itemopt_ajax-response").html("");
280 strs = data.split('#usces#');
281 $("tbody#item-opt-list").html( strs[0] );
282 for(i=0; i<meta_ids.length; i++){
283 $("#itemopt_loading-" + meta_ids[i]).html('');
284 $("#itemopt-" + meta_ids[i]).css({'background-color': '#FF4'});
285 $("#itemopt-" + meta_ids[i]).animate({ 'background-color': '#FFFFEE' }, 2000 );
286 }
287 };
288 s.error = function(msg){
289 $("#opt_ajax-response").html('<div class="error"><p>error sort</p></div>');
290 };
291 $.ajax( s );
292 return false;
293 }
294 };
295
296 itemSku = {
297 settings: {
298 url: uscesL10n.requestFile,
299 type: 'POST',
300 cache: false,
301 success: function(data, dataType){
302 strs = data.split('#usces#');
303 //alert(strs[1]);return;
304 $("tbody#item-sku-list").html( strs[0] );
305 $("select#skukeyselect").html( strs[1] );
306 },
307 error: function(msg){
308 $("#skuajax-response").html(msg);
309 }
310 },
311
312 post : function(action, arg) {
313 if( action == 'updateitemsku' ) {
314 itemSku.updateitemsku(arg);
315 } else if( action == 'deleteitemsku' ) {
316 itemSku.deleteitemsku(arg);
317 } else if( action == 'additemsku' ) {
318 itemSku.additemsku();
319 } else if( action == 'keyselect' ) {
320 itemSku.keyselect(arg);
321 }
322 },
323
324 additemsku : function() {
325 var id = $("#post_ID").val();
326 var name = $("#newskuname").val();
327 var cprice = $("#newskucprice").val();
328 var price = $("#newskuprice").val();
329 var zaikonum = $("#newskuzaikonum").val();
330 var zaiko = $("#newskuzaikoselect").val();
331 var skudisp = $("#newskudisp").val();
332 var skuunit = $("#newskuunit").val();
333 var skugptekiyo = $("#newskugptekiyo").val();
334
335 var mes = '';
336 if( '' == name )
337 mes += '<p>SKUコードの値を�
338 �力してください。</p>';
339 if( '' == price )
340 mes += '<p>売価の値を�
341 �力してください。</p>';
342 // if( ! checkCode( name ) )
343 // mes += '<p>SKUコードは半角英数(-_を含む)で�
344 �力して下さい。</p>';
345 if( ! checkMoney( cprice ) )
346 mes += '<p>通常価は数値で�
347 �力して下さい。</p>';
348 if( ! checkMoney( price ) )
349 mes += '<p>売価は数値で�
350 �力して下さい。</p>';
351 if( ! checkNum( zaikonum ) )
352 mes += '<p>在庫数は数値で�
353 �力して下さい。</p>';
354 if( '' != mes ){
355 $("#sku_ajax-response").html('<div class="error">' + mes + '</div>');
356 return false;
357 }
358
359 var skuadvance = '';
360 if( undefined != $("input[name*='newskuadvance']") ) {
361 if( 1 == $("input[name='newskuadvance']").length ) {
362 skuadvance = '&newskuadvance='+encodeURIComponent($("input[name*='newskuadvance']").val());
363 } else {
364 $("input[name*='newskuadvance']").each(function() {
365 skuadvance += '&newskuadvance['+$(this).attr("id")+']='+encodeURIComponent($(this).val());
366 });
367 }
368 }
369
370 $("#newitemsku_loading").html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />');
371
372 var s = itemSku.settings;
373 s.data = "action=item_sku_ajax&ID=" + id + "&newskuname=" + encodeURIComponent(name) + "&newskucprice=" + cprice + "&newskuprice=" + price + "&newskuzaikonum=" + zaikonum + "&newskuzaikoselect=" + encodeURIComponent(zaiko) + "&newskudisp=" + encodeURIComponent(skudisp) + "&newskuunit=" + encodeURIComponent(skuunit) + "&newskugptekiyo=" + skugptekiyo + skuadvance;
374 s.success = function(data, dataType){
375 $("#newitemsku_loading").html('');
376 $("#sku_ajax-response").html("");
377 strs = data.split('#usces#');
378 $("table#skulist-table").removeAttr("style");
379 var meta_id = strs[1];
380 if( 0 > meta_id ){
381 $("#sku_ajax-response").html('<div class="error"><p>同じSKUコードが存在します。</p></div>');
382 }else{
383 $("tbody#item-sku-list").html( strs[0] );
384 $("#itemsku-" + meta_id).css({'background-color': '#FF4'});
385 $("#itemsku-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 2000 );
386 $("#newskuname").val("");
387 $("#newskucprice").val("");
388 $("#newskuprice").val("");
389 $("#newskuzaikonum").val("");
390 $("#newskuzaikonum").val("");
391 $("#newskuzaikoselect").val(0);
392 $("#newskudisp").val("");
393 $("#newskuunit").val("");
394 $("#newskugptekiyo").val(0);
395 if( 0 < $("input[name*='newskuadvance']").length ) {
396 $("input[name*='newskuadvance']").each(function(index, element) {
397 $(this).val("");
398 });
399 }
400 if( 0 < $("select[name*='newskuadvance']").length ) {
401 $("select[name*='newskuadvance']").each(function(index, element) {
402 $(this).val("");
403 });
404 }
405 }
406 //$("#itemsku-" + meta_id).css({'background-color': '#FF4'});
407 //$("#itemsku-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 2000 );
408 };
409 s.error = function(msg){
410 $("#sku_ajax-response").html(msg);
411 $("#newitemsku_loading").html('');
412 };
413 $.ajax( s );
414 return false;
415 },
416
417 updateitemsku : function(meta_id) {
418 var id = $("#post_ID").val();
419 ks = document.getElementById('itemsku\['+meta_id+'\]\[key\]');
420 cs = document.getElementById('itemsku\['+meta_id+'\]\[cprice\]');
421 ps = document.getElementById('itemsku\['+meta_id+'\]\[price\]');
422 ns = document.getElementById('itemsku\['+meta_id+'\]\[zaikonum\]');
423 zs = document.getElementById('itemsku\['+meta_id+'\]\[zaiko\]');
424 ds = document.getElementById('itemsku\['+meta_id+'\]\[skudisp\]');
425 us = document.getElementById('itemsku\['+meta_id+'\]\[skuunit\]');
426 gs = document.getElementById('itemsku\['+meta_id+'\]\[skugptekiyo\]');
427 //ad = document.getElementById('itemsku\['+meta_id+'\]\[skuadvance\]');
428 ad = $("input[name*='itemsku\["+meta_id+"\]\[skuadvance\]']");
429 so = document.getElementById('itemsku\['+meta_id+'\]\[sort\]');
430 var name = $(ks).val();
431 var cprice = $(cs).val();
432 var price = $(ps).val();
433 var zaikonum = $(ns).val();
434 var zaiko = $(zs).val();
435 var skudisp = $(ds).val();
436 var skuunit = $(us).val();
437 var skugptekiyo = $(gs).val();
438 var sortnum = $(so).val();
439
440 var mes = '';
441 if( '' == name )
442 mes += '<p>SKUコードの値を�
443 �力してください。</p>';
444 if( '' == price )
445 mes += '<p>売価の値を�
446 �力してください。</p>';
447 if( ! checkMoney( cprice ) )
448 mes += '<p>通常価は数値で�
449 �力して下さい。</p>';
450 if( ! checkMoney( price ) )
451 mes += '<p>売価は数値で�
452 �力して下さい。</p>';
453 if( ! checkNum( zaikonum ) )
454 mes += '<p>在庫数は数値で�
455 �力して下さい。</p>';
456 if( '' != mes ){
457 $("#sku_ajax-response").html('<div class="error">' + mes + '</div>');
458 return false;
459 }
460
461 var skuadvance = '';
462 if( undefined != $(ad) ) {
463 if( 1 == $(ad).length ) {
464 skuadvance = '&skuadvance='+encodeURIComponent($(ad).val());
465 } else {
466 $(ad).each(function() {
467 skuadvance += '&skuadvance['+$(this).attr("id")+']='+encodeURIComponent($(this).val());
468 });
469 }
470 }
471
472 $("#itemsku_loading-" + meta_id).html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />');
473 var s = itemSku.settings;
474 s.data = "action=item_sku_ajax&ID=" + id + "&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;
475 s.success = function(data, dataType){
476 $("#itemsku_loading-" + meta_id).html('');
477 $("#sku_ajax-response").html("");
478 strs = data.split('#usces#');
479 $("table#skulist-table").removeAttr("style");
480 var id = strs[1];
481 if( 0 > id ){
482 $("#sku_ajax-response").html('<div class="error"><p>同じSKUコードが存在します。</p></div>');
483 }else{
484 $("tbody#item-sku-list").html( strs[0] );
485 $("#itemsku-" + meta_id).css({'background-color': '#FF4'});
486 $("#itemsku-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 2000 );
487 }
488 };
489 s.error = function(msg){
490 $("#sku_ajax-response").html(msg);
491 $("#itemsku_loading-" + meta_id).html('');
492 };
493 $.ajax( s );
494 return false;
495 },
496
497 deleteitemsku : function(meta_id) {
498 var data=[];
499 $("#itemsku-" + meta_id).css({'background-color': '#F00'});
500 $("#itemsku-" + meta_id).animate({ 'background-color': '#FFFFEE' }, 1000 );
501 var id = $("#post_ID").val();
502 var s = itemSku.settings;
503 s.data = "action=item_sku_ajax&ID=" + id + "&delete=1&skumetaid=" + meta_id;
504 s.success = function(data, dataType){
505 $("#itemsku_loading-" + meta_id).html('');
506 $("#sku_ajax-response").html("");
507 strs = data.split('#usces#');
508 $("tbody#item-sku-list").html( strs[0] );
509 };
510 s.error = function(msg){
511 $("#sku_ajax-response").html(msg);
512 $("#itemsku_loading-" + meta_id).html('');
513 };
514 $.ajax( s );
515 return false;
516 },
517
518 dosort : function( str ) {
519 if( !str ) return;
520 var id = $("#post_ID").val();
521 var meta_id_str = str.replace(/itemsku-/g, "");
522 var meta_ids = meta_id_str.split(',');
523 if( 2 > meta_ids.length ) return;
524
525 for(i=0; i<meta_ids.length; i++){
526 $("#itemsku_loading-" + meta_ids[i]).html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />');
527 }
528 var s = itemSku.settings;
529 s.data = "action=item_sku_ajax&ID=" + id + "&sort=1&meta=" + encodeURIComponent(meta_id_str);
530 s.success = function(data, dataType){
531 $("#sku_ajax-response").html("");
532 strs = data.split('#usces#');
533 $("tbody#item-sku-list").html( strs[0] );
534 for(i=0; i<meta_ids.length; i++){
535 //$("#itemsku_loading-" + meta_ids[i]).html('');
536 $("#itemsku-" + meta_ids[i]).css({'background-color': '#FF4'});
537 $("#itemsku-" + meta_ids[i]).animate({ 'background-color': '#FFFFEE' }, 2000 );
538 }
539 };
540 s.error = function(msg){
541 $("#sku_ajax-response").html('<div class="error"><p>error sort</p></div>');
542 };
543 $.ajax( s );
544 return false;
545 }
546 };
547
548 payment = {
549 settings: {
550 url: uscesL10n.requestFile,
551 type: 'POST',
552 cache: false,
553 success: function(data, dataType){
554 $("tbody#payment-list").html( data );
555
556 },
557 error: function(msg){
558 $("#payment-response").html(msg);
559 }
560 },
561
562 post : function(action, arg) {
563 if( action == 'update' ) {
564 payment.update(arg);
565 } else if( action == 'del' ) {
566 payment.del(arg);
567 } else if( action == 'add' ) {
568 payment.add();
569 }
570 },
571
572 add : function() {
573 var name = $("#newname").val();
574 var explanation = $("#newexplanation").val();
575 var settlement = $("#newsettlement").val();
576 var module = $("#newmodule").val();
577
578 var mes = '';
579 if( '' == name ){
580 mes += '<p>支払方法名の値を�
581 �力してください。</p>';
582 }
583 if( '#NONE#' == settlement ) {
584 mes += '<p>決済種別を選択してください。</p>';
585 }
586 if( 'acting' == settlement ) {//代行業�
587 決済のとき
588 if( '' == module ) {
589 mes += '<p>決済モジュールの値を�
590 �力してください。</p>';
591 }
592 }
593 if( '' != mes ){
594 $("#payment_ajax-response").html('<div class="error">' + mes + '</div>');
595 return false;
596 }
597
598 $("#newpayment_loading").html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />');
599
600 var s = payment.settings;
601 s.data = "action=payment_ajax&newname=" + encodeURIComponent(name) + "&newexplanation=" + encodeURIComponent(explanation) + "&newsettlement=" + encodeURIComponent(settlement) + "&newmodule=" + encodeURIComponent(module);
602 s.success = function(data, dataType){
603 $("#newpayment_loading").html('');
604 $("#payment_ajax-response").html('');
605 strs = data.split('#usces#');
606 $("table#payment-table").removeAttr("style");
607 if( -1 == strs[1] ){
608 $("#payment_ajax-response").html('<div class="error"><p>同じ支払方法名が存在します。</p></div>');
609 }else{
610 $("tbody#payment-list").html( strs[0] );
611 $("#newname").val("");
612 $("#newexplanation").val("");
613 $("#newsettlement").val('acting');
614 $("#newmodule").val("");
615 $("#payment-" + strs[1]).css({'background-color': '#FF4'});
616 $("#payment-" + strs[1]).animate({ 'background-color': '#FFFFEE' }, 2000 );
617 }
618 };
619 s.error = function(msg){
620 $("#payment_ajax-response").html(msg);
621 $("#newpayment_loading").html('');
622 };
623 $.ajax( s );
624 return false;
625 },
626
627 update : function(id) {
628 vn = document.getElementById('payment\[' + id + '\]\[name\]');
629 ve = document.getElementById('payment\[' + id + '\]\[explanation\]');
630 vs = document.getElementById('payment\[' + id + '\]\[settlement\]');
631 vm = document.getElementById('payment\[' + id + '\]\[module\]');
632 so = document.getElementById('payment\[' + id + '\]\[sort\]');
633 var name = $(vn).val();
634 var explanation = $(ve).val();
635 var settlement = $(vs).val();
636 var module = $(vm).val();
637 var sortid = $(so).val();
638 var use = $("input[name='payment[" + id + "][use]']:checked").val();
639 var s = payment.settings;
640
641 var mes = '';
642 if( '' == name ){
643 mes += '<p>支払方法名の値を�
644 �力してください。</p>';
645 }
646 if( '#NONE#' == settlement ) {
647 mes += '<p>決済種別を選択してください。</p>';
648 }
649 if( 'acting' == settlement ) {//代行業�
650 決済のとき
651 if( '' == module ) {
652 mes += '<p>決済モジュールの値を�
653 �力してください。</p>';
654 }
655 }
656 if( '' != mes ){
657 $("#payment_ajax-response").html('<div class="error">' + mes + '</div>');
658 return false;
659 }
660
661 $("#payment_loading-" + id).html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />');
662
663 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;
664 s.success = function(data, dataType){
665 $("#payment_loading-" + id).html('');
666 $("#payment_ajax-response").html("");
667 strs = data.split('#usces#');
668 if( -1 == strs[1] ){
669 $("#payment_ajax-response").html('<div class="error"><p>同じ支払方法名が存在します。</p></div>');
670 }else{
671 $("tbody#payment-list").html( strs[0] );
672 $("#payment-" + id).css({'background-color': '#FF4'});
673 $("#payment-" + id).animate({ 'background-color': '#FFFFEE' }, 2000 );
674 }
675 };
676 s.error = function(msg){
677 $("#payment_ajax-response").html(msg);
678 $("#newpayment_loading").html('');
679 };
680 $.ajax( s );
681 return false;
682 },
683
684 del : function(id) {
685 $("#payment-" + id).css({'background-color': '#F00'});
686 $("#payment-" + id).animate({ 'background-color': '#FFFFEE' }, 1000 );
687 var s = payment.settings;
688 s.data = "action=payment_ajax&delete=1&id=" + id;
689 s.success = function(data, dataType){
690 strs = data.split('#usces#');
691 $("tbody#payment-list").html( strs[0] );
692 };
693 s.error = function(msg){
694 $("#payment_ajax-response").html(msg);
695 };
696 $.ajax( s );
697 return false;
698 },
699
700 dosort : function( str ) {
701 if( !str ) return;
702 var meta_id_str = str.replace(/payment-/g, "");
703 var meta_ids = meta_id_str.split(',');
704 if( 2 > meta_ids.length ) return;
705
706 for(i=0; i<meta_ids.length; i++){
707 $("#payment_loading-" + meta_ids[i]).html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading.gif" />');
708 }
709 var s = payment.settings;
710 s.data = "action=payment_ajax&sort=1&idstr=" + encodeURIComponent(meta_id_str);
711 s.success = function(data, dataType){
712 strs = data.split('#usces#');
713 $("tbody#payment-list").html( strs[0] );
714 for(i=0; i<meta_ids.length; i++){
715 $("#payment_loading-" + meta_ids[i]).html('');
716 $("#payment-" + meta_ids[i]).css({'background-color': '#FF4'});
717 $("#payment-" + meta_ids[i]).animate({ 'background-color': '#FFFFEE' }, 2000 );
718 }
719 };
720 s.error = function(msg){
721 $("#payment_ajax-response").html('<div class="error"><p>error sort</p></div>');
722 };
723 $.ajax( s );
724 return false;
725 }
726 };
727
728 orderItem = {
729 settings: {
730 url: uscesL10n.requestFile,
731 type: 'POST',
732 cache: false,
733 success: function(data, dataType){
734 $("#newitemform").html( data );
735
736 },
737 error: function(msg){
738 $("#order-response").html(msg);
739 }
740 },
741
742 add2cart : function(newid, newsku) {
743 var ID = $("input[name='order_id']").val();
744 var cnum = $("#orderitemlist").children().length;
745 var priceob = $("input[name*='skuPrice']");
746 var quantob = $("input[name*='quant']");
747 var name = '';
748 var strs = '';
749 var post_ids = [];
750 var skus = [];
751 var optob;
752 var optvalue = '';
753 var query = 'action=order_item2cart_ajax&order_id='+ID;
754 for( var i = 0; i < cnum; i++) {
755 name = $(priceob[i]).attr("name");
756 strs = name.split('[');
757 post_ids[i] = strs[2].replace(/[\]]+$/g, '');
758 skus[i] = strs[3].replace(/[\]]+$/g, '');
759
760 query += "&skuPrice["+i+"]["+post_ids[i]+"]["+skus[i]+"]="+$("input[name='skuPrice\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]']").val();
761 query += "&quant["+i+"]["+post_ids[i]+"]["+skus[i]+"]="+$("input[name='quant\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]']").val();
762
763 optob = $("input[name*='optName\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]']");
764 optvalue = '';
765 for( var o = 0; o < optob.length; o++) {
766 //20110715ysk start 0000202
767 //optvalue = $("input[name='itemOption\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]\[" + $(optob[o]).val() + "\]']").val();
768 //if( '#NONE#' != optvalue){
769 // query += "&itemOption["+i+"]["+post_ids[i]+"]["+skus[i]+"][" + $(optob[o]).val() + "]="+optvalue;
770 //}
771 var cnt = 0;
772 $("input[name^='itemOption\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]\[" + $(optob[o]).val() + "\]\[']").each(function(idx, obj) {
773 cnt++;
774 });
775 if(0 < cnt) {
776 $("input[name^='itemOption\[" + i + "\]\[" + post_ids[i] + "\]\[" + skus[i] + "\]\[" + $(optob[o]).val() + "\]\[']").each(function(idx, obj) {
777 query += "&itemOption["+i+"]["+post_ids[i]+"]["+skus[i]+"][" + $(optob[o]).val() + "][" + $(this).val() + "]="+$(this).val();
778 });
779 } else {
780 optvalue = $("input[name='itemOption\["+i+"\]\["+post_ids[i]+"\]\["+skus[i]+"\]\["+$(optob[o]).val()+"\]']").val();
781 query += "&itemOption["+i+"]["+post_ids[i]+"]["+skus[i]+"]["+$(optob[o]).val()+"]="+optvalue;
782 }
783 //20110715ysk end
784 }
785 }
786 query += "&skuPrice["+cnum+"]["+newid+"]["+newsku+"]="+$("input[name='skuNEWPrice\[" + newid + "\]\[" + newsku + "\]']").val();
787 query += "&quant["+cnum+"]["+newid+"]["+newsku+"]=1";
788 var newoptob = $("input[name*='optNEWCode\[" + newid + "\]\[" + newsku + "\]']");
789 var newoptvalue = '';
790 var mes = '';
791 for( var n = 0; n < newoptob.length; n++) {
792 //20110715ysk start 0000202
793 //newoptvalue = $("select[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").val();
794 newoptvalue = $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").val();
795 var newoptclass = $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").attr("class");
796 var essential = $(":input[name='optNEWEssential\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]']").val();
797 switch(newoptclass) {
798 case 'iopt_select_multiple':
799 var sel = 0;
800 if( essential == 1 ) {
801 $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]'] option:selected").each(function(idx, obj) {
802 if( '#NONE#' != $(this).val()) {
803 sel++;
804 }
805 });
806 }
807 if( sel == 0 ) {
808 mes += decodeURIComponent($(newoptob[n]).val())+'を選択してください'+"\n";
809 } else {
810 $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + $(newoptob[n]).val() + "\]'] option:selected").each(function(idx, obj) {
811 if( '#NONE#' != $(this).val()) {
812 query += "&itemOption["+cnum+"]["+newid+"]["+newsku+"][" + $(newoptob[n]).val() + "][" + $(this).val() + "]="+$(this).val();
813 }
814 });
815 }
816 break;
817 case 'iopt_select':
818 if( essential == 1 && newoptvalue == '#NONE#' ) {
819 mes += decodeURIComponent($(newoptob[n]).val())+'を選択してください'+"\n";
820 } else {
821 query += "&itemOption["+cnum+"]["+newid+"]["+newsku+"][" + $(newoptob[n]).val() + "]="+newoptvalue;
822 }
823 break;
824 case 'iopt_text':
825 case 'iopt_textarea':
826 if( essential == 1 && newoptvalue == '' ) {
827 mes += decodeURIComponent($(newoptob[n]).val())+'を�
828 �力してください'+"\n";
829 } else {
830 query += "&itemOption["+cnum+"]["+newid+"]["+newsku+"][" + $(newoptob[n]).val() + "]="+newoptvalue;
831 }
832 break;
833 }
834 //20110715ysk end
835 }
836 if( mes != '' ) {
837 alert(mes);
838 return;
839 }
840
841 var s = orderItem.settings;
842 s.data = query;
843 s.success = function(data, dataType){
844 //20120613ysk start 0000500
845 //if(data == 'nodata'){return;}
846 strs = data.split('#usces#');
847 if( 0 > parseInt(strs[0]) ) return;
848 //20120613ysk end
849 var pict = "<img src='" + $("#newitemform img").attr("src") + "' width='" + $("#newitemform img").attr("width") + "' height='" + $("#newitemform img").attr("height") + "' alt='' />";
850 //20120613ysk start 0000500
851 //var itemName = $("input[name='itemNEWName\["+newid+"\]\["+newsku+"\]']").val() + ' ' + $("input[name='itemNEWCode\["+newid+"\]\["+newsku+"\]']").val() + ' ' + $("input[name='skuNEWName\["+newid+"\]\["+newsku+"\]']").val();
852 var itemName = strs[1];
853 //20120613ysk end
854 var zaiko = $("input[name='zaiNEWko\["+newid+"\]\["+newsku+"\]']").val();
855 //20120528ysk start 0000485
856 //var price = "<input name='skuPrice[" + cnum + "][" + newid + "][" + newsku + "]' class='text price' type='text' value='" + $("input[name='skuNEWPrice\["+newid+"\]\["+newsku+"\]']").val() + "' onchange='orderfunc.sumPrice()' />";
857 //var quant = "<input name='quant[" + cnum + "][" + newid + "][" + newsku + "]' class='text quantity' type='text' value='1' onchange='orderfunc.sumPrice()' />";
858 //20120613ysk start 0000500
859 //var price = "<input name='skuPrice[" + cnum + "][" + newid + "][" + newsku + "]' class='text price' type='text' value='" + $("input[name='skuNEWPrice\["+newid+"\]\["+newsku+"\]']").val() + "' />";
860 var price = "<input name='skuPrice[" + cnum + "][" + newid + "][" + newsku + "]' class='text price' type='text' value='" + strs[0] + "' />";
861 //20120613ysk end
862 var quant = "<input name='quant[" + cnum + "][" + newid + "][" + newsku + "]' class='text quantity' type='text' value='1' />";
863 //20120528ysk end
864 var delButton = "<input name='delButton[" + cnum + "][" + newid + "][" + newsku + "]' class='delCartButton' type='submit' value='削除' />\n<input name='advance[" + cnum + "][" + newid + "][" + newsku + "]' type='hidden' value='' />\n";
865
866 var sucoptob = $("input[name*='optNEWCode\[" + newid + "\]\[" + newsku + "\]']");
867 var skuOptValue = '';
868 var skuoptval = '';
869 var hiddenopt = '';
870 var hiddenoptname = '';
871 for( var i = 0; i < sucoptob.length; i++) {
872 skuoptcode = $(sucoptob[i]).val();
873 skuoptname = decodeURIComponent($(sucoptob[i]).val());
874 hiddenoptname += "<input name='optName[" + newid + "][" + newsku + "][" + skuoptcode + "]' type='hidden' value='"+skuoptcode+"' />\n";
875 //20110715ysk start 0000202
876 //skuoptval = $("select[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + skuoptcode + "\]']").val();
877 skuoptval = $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + skuoptcode + "\]']").val();
878 //if( '#NONE#' != skuoptval){
879 // skuOptValue += skuoptval + ' ';
880 // hiddenopt += "<input name='itemOption[" + cnum + "][" + newid + "][" + newsku + "][" + skuoptcode + "]' type='hidden' value='"+skuoptval+"' />";
881 // hiddenoptname += "<input name='optName[" + cnum + "][" + newid + "][" + newsku + "][" + skuoptcode + "]' type='hidden' value='"+skuoptcode+"' />";
882 //}
883 skuOptValue += skuoptname + ' : ';
884 var sucoptclass = $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + skuoptcode + "\]']").attr("class");
885 switch(sucoptclass) {
886 case 'iopt_select_multiple':
887 var c = '';
888 $(":input[name='itemNEWOption\[" + newid + "\]\[" + newsku + "\]\[" + skuoptcode + "\]'] option:selected").each(function(idx, obj) {
889 if( '#NONE#' != $(this).val() ) {
890 skuOptValue += c + $(this).val();
891 c = ', ';
892 hiddenopt += "<input name='itemOption[" + cnum + "][" + newid + "][" + newsku + "][" + skuoptcode + "][" + encodeURIComponent($(this).val()) + "]' type='hidden' value='"+encodeURIComponent($(this).val())+"' />\n";
893 }
894 });
895 break;
896 case 'iopt_select':
897 if( '#NONE#' != skuoptval ) {
898 skuOptValue += skuoptval;
899 hiddenopt += "<input name='itemOption[" + cnum + "][" + newid + "][" + newsku + "][" + skuoptcode + "]' type='hidden' value='"+encodeURIComponent(skuoptval)+"' />\n";
900 }
901 break;
902 case 'iopt_text':
903 case 'iopt_textarea':
904 skuOptValue += skuoptval;
905 hiddenopt += "<input name='itemOption[" + cnum + "][" + newid + "][" + newsku + "][" + skuoptcode + "]' type='hidden' value='"+encodeURIComponent(skuoptval)+"' />\n";
906 break;
907 }
908 skuOptValue += '<br />';
909 //20110715ysk end
910 }
911 var htm = "<tr>\n";
912 htm += "<td>"+(cnum+1)+"</td>\n";
913 htm += "<td>"+pict+"</td>\n";
914 htm += "<td class='aleft'>"+itemName+"<br />"+skuOptValue+"</td>\n";
915 htm += "<td>"+price+"</td>\n";
916 htm += "<td>"+quant+"</td>\n";
917 htm += "<td id='sub_total["+cnum+"]' class='aright'>&nbsp;</td>\n";
918 htm += "<td>"+zaiko+"</td>\n";
919 htm += "<td>"+delButton+hiddenoptname+hiddenopt+"</td>\n";
920 htm += "</tr>\n";
921
922 $("#orderitemlist").append( htm );
923 //20120307ysk start 0000432
924 orderfunc.sumPrice(null);
925
926 $("input[name='skuPrice["+cnum+"]["+newid+"]["+newsku+"]']").bind("change", {index:cnum, post_id:newid, sku:newsku}, function(e){ orderfunc.sumPrice($(this)); });
927 $("input[name='quant["+cnum+"]["+newid+"]["+newsku+"]']").bind("change", {index:cnum, post_id:newid, sku:newsku}, function(e){ orderfunc.sumPrice($(this)); });
928 $("input[name='delButton["+cnum+"]["+newid+"]["+newsku+"]']").bind("click", {index:cnum, post_id:newid, sku:newsku}, function(e){ return delConfirm($(this)); });
929 //20120307ysk end
930 //20120528ysk start 0000485
931 $("input[name*='skuPrice[" + cnum + "][" + newid + "][" + newsku + "]']").bind("change", function(){ orderfunc.sumPrice($(this)); });
932 $("input[name*='quant[" + cnum + "][" + newid + "][" + newsku + "]']").bind("change", function(){ orderfunc.sumPrice($(this)); });
933 $("input[name*='delButton[" + cnum + "][" + newid + "][" + newsku + "]']").bind("click", function(){ orderfunc.sumPrice(null); });
934 //20120528ysk end
935 };
936 $.ajax( s );
937 return false;
938 },
939
940 getitem : function() {
941 if($("#newitemcode").val() == '') return;
942
943 var itemcode = $("#newitemcode").val();
944 var s = orderItem.settings;
945 s.data = "action=order_item_ajax&mode=get_order_item&itemcode=" + encodeURIComponent(itemcode);
946 s.success = function(data, dataType){
947 $("#newitemform").html( data );
948 };
949 $.ajax( s );
950 return false;
951 },
952
953 getmailmessage : function( flag ) {
954 $("#sendmailmessage").val( uscesL10n.now_loading );
955 var order_id = $("input[name='order_id']").val();
956 var s = orderItem.settings;
957 s.data = "action=order_item_ajax&mode=" + flag + "&order_id=" + order_id;
958 s.success = function(data, dataType){
959 $("#sendmailmessage").val( data );
960 };
961 $.ajax( s );
962 return false;
963 }
964
965 };
966
967 uscesInformation = {
968 settings: {
969 url: 'http://www.welcart.com/util/welcart_information.php',
970 type: 'POST',
971 cache: false,
972 success: function(data, dataType){
973 //$("#newitemform").html( data );
974
975 },
976 error: function(msg){
977 $("#wc_information").html( 'error : ' + msg );
978 }
979 },
980
981 getinfo : function() {
982 var s = uscesInformation.settings;
983 s.data = "v=" + encodeURIComponent(uscesL10n.version);
984 s.data += "&wcid=" + encodeURIComponent(uscesL10n.wcid);
985 s.data += "&wcurl=" + encodeURIComponent(uscesL10n.USCES_PLUGIN_URL);
986 s.data += "&locale=" + encodeURIComponent(uscesL10n.locale);
987 s.data += "&theme=" + encodeURIComponent(uscesL10n.theme);
988 s.data += "&wcex=";
989 var de = '';
990 for( var i = 0; i < uscesL10n.wcex.length; i++) {
991 s.data += de + encodeURIComponent(uscesL10n.wcex[i]);
992 de =',';
993 }
994 s.success = function(data, dataType){
995 $("#wc_information").html( data );
996 };
997 $.ajax( s );
998 return false;
999 },
1000
1001 getinfo2 : function() {
1002 var s = uscesInformation.settings;
1003 s.url = uscesL10n.requestFile;
1004 s.data = 'action=getinfo_ajax';
1005 s.success = function(data, dataType){
1006 $("#wc_information").html( data );
1007 };
1008 $.ajax( s );
1009 return false;
1010 }
1011
1012 };
1013
1014 uscesItem = {
1015
1016 newdraft : function(itemName) {
1017 if(jQuery("#title").val().length == 0 || jQuery("#title").val() == '') {
1018 $("#title").val(itemName);
1019 }
1020 //autosave();
1021
1022 },
1023
1024 cahngepict : function(code) {
1025 $("div#item-select-pict").html(code);
1026 },
1027
1028 trim : function(target){
1029 target = target.replace(/(^\s+)|(\s+$)|(^\n+)|(\n+$)/g, "");
1030 return target;
1031 }
1032
1033 };
1034
1035 })(jQuery);
1036
1037 function usces_check_num(obj) {
1038 if(!checkNum(obj.val())) {
1039 alert('数値で�
1040 �力して下さい。');
1041 obj.focus();
1042 return false;
1043 }
1044 return true;
1045 }
1046 function usces_check_money(obj) {
1047 if(!checkMoney(obj.val())) {
1048 alert('数値で�
1049 �力して下さい。');
1050 obj.focus();
1051 return false;
1052 }
1053 return true;
1054 }
1055 function checkAlp(argValue) {
1056 if(argValue.match(/[^a-z|^A-Z]/g)) {
1057 return false;
1058 }
1059 return true;
1060 }
1061 function checkCode(argValue) {
1062 if(argValue.match(/[^0-9|^a-z|^A-Z|^\-|^_]/g)) {
1063 return false;
1064 }
1065 return true;
1066 }
1067 function checkNum(argValue) {
1068 if(argValue.match(/[^0-9]/g)) {
1069 return false;
1070 }
1071 return true;
1072 }
1073 function checkMoney(argValue) {
1074 if(argValue.match(/[^0-9|^\.]/g)) {
1075 return false;
1076 }
1077 return true;
1078 }
1079 function checkPrice(argValue) {
1080 if(argValue.match(/[^0-9|^\-|^\,|^\.]/g)) {
1081 return false;
1082 }
1083 return true;
1084 }
1085