PluginProbe
Welcart e-Commerce / 2.12.4
Welcart e-Commerce v2.12.4
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
← All changes | functions/admin_page.php +640 -559 1.3.52.12.4 View file →
@@ -1,559 +1,640 @@
1 -<?php
2 -function admin_prodauct_footer(){
3 - switch( $_GET['page'] ){
4 - case 'usces_itemedit':
5 - if( !isset($_GET['action']) || ( isset($_REQUEST['action']) && 'upload_register' == $_REQUEST['action'] ) ){
6 - break;
7 - }
8 - case 'usces_itemnew':
9 -?>
10 -<script type="text/javascript">
11 -(function($) {
12 - var submit_event = true;
13 - // 下書き保存やプレビューの場合は必須チェックを行わない
14 - $('#post-preview, #save-post').click(function(){
15 - if(!$("#auto_draft").val())
16 - submit_event = false;
17 - return true;
18 - });
19 - $('#post').submit(function(e){
20 - $('form#post').attr('action', '');
21 - var mes = '';
22 - var itemCode = $("#itemCode").val();
23 - var itemName = $("#itemName").val();
24 - var itemsku = $("input[name^='itemsku\[']");
25 - var DeliveryMethod = $("input[name^='itemDeliveryMethod\[']");
26 - var itemDivision = $("input[name='item_division']:checked").val();
27 - if (submit_event) {
28 - if ( 0 == DeliveryMethod.length && (!itemDivision || 'shipped' == itemDivision) ) {
29 - mes += '配送方法が選択できません。商品登録を行う前に「配送設定」より配送方法の登録を済ませてください。<br />';
30 - }
31 - if ( "" == itemCode ) {
32 - mes += '商品コードが入力されていません。<br />';
33 - $("#itemCode").css({'background-color': '#FFA'}).click(function(){
34 - $(this).css({'background-color': '#FFF'});
35 - });
36 - }
37 -// if ( ! checkCode( itemCode ) ) {
38 -// mes += '商品コードは半角英数(-_を含む)で入力して下さい。<br />';
39 -// $("#itemCode").css({'background-color': '#FFA'}).click(function(){
40 -// $(this).css({'background-color': '#FFF'});
41 -// });
42 -// }
43 - if ( "" == itemName ) {
44 - mes += '商品名が入力されていません。<br />';
45 - $("#itemName").css({'background-color': '#FFA'}).click(function(){
46 - $(this).css({'background-color': '#FFF'});
47 - });
48 - }
49 - if ( 0 == itemsku.length ) {
50 - mes += 'SKUが登録されていません。<br />';
51 - $("#newskuname").css({'background-color': '#FFA'}).click(function(){
52 - $(this).css({'background-color': '#FFF'});
53 - });
54 - $("#newskuprice").css({'background-color': '#FFA'}).click(function(){
55 - $(this).css({'background-color': '#FFF'});
56 - });
57 - }
58 - if ( '' != mes) {
59 - $("#major-publishing-actions").append('<div id="usces_mess"></div>');
60 - $('#ajax-loading').css({'visibility': 'hidden'});
61 - $('#draft-ajax-loading').css({'visibility': 'hidden'});
62 - $('#publish').removeClass('button-primary-disabled');
63 - $('#save-post').removeClass('button-disabled');
64 - $("#usces_mess").html(mes);
65 - return false;
66 - } else {
67 - $('#usces_mess').fadeOut();
68 - return true;
69 - }
70 - } else {
71 - return true;
72 - }
73 - });
74 -
75 -// $('#postimagediv h3').html('<span>商品画像</span>');
76 - $('#itemName').blur(
77 - function() {
78 - if ( $("#itemName").val().length == 0 ) return;
79 - uscesItem.newdraft($('#itemName').val());
80 - });
81 -
82 - $( "#item-sku-list" ).sortable({
83 - //placeholder: "ui-state-highlight",
84 - handle : 'th',
85 - axis : 'y',
86 - cursor : "move",
87 - tolerance : "pointer",
88 - forceHelperSize : true,
89 - forcePlaceholderSize : true,
90 - revert : 300,
91 - opacity: 0.6,
92 - cancel: ":input,button",
93 - update : function(){
94 - var data=[];
95 - $("table","#item-sku-list").each(function(i,v){
96 - data.push($(this).attr('id'));
97 - });
98 - if( 1 < data.length ){
99 - itemSku.dosort(data.toString());
100 - }
101 - }
102 - });
103 - $( "#item-opt-list" ).sortable({
104 - //placeholder: "ui-state-highlight",
105 - handle : 'th',
106 - axis : 'y',
107 - cursor : "move",
108 - tolerance : "pointer",
109 - forceHelperSize : true,
110 - forcePlaceholderSize : true,
111 - revert : 300,
112 - opacity: 0.6,
113 - cancel: ":input,button",
114 - update : function(){
115 - var data=[];
116 - $("table","#item-opt-list").each(function(i,v){
117 - data.push($(this).attr('id'));
118 - });
119 - if( 1 < data.length ){
120 - itemOpt.dosort(data.toString());
121 - }
122 - }
123 - });
124 -
125 -})(jQuery);
126 -</script>
127 -<?php
128 - break;
129 - case 'usces_initial':
130 -?>
131 -<script type="text/javascript">
132 -(function($) {
133 - $('#option_form').submit(function(e) {
134 - var error = 0;
135 -
136 - if( "" == $("*[name='order_mail']").val() ) {
137 - error++;
138 - $("*[name='order_mail']").css({'background-color': '#FFA'}).click(function() {
139 - $(this).css({'background-color': '#FFF'});
140 - });
141 - }
142 - if( "" == $("*[name='inquiry_mail']").val() ) {
143 - error++;
144 - $("*[name='inquiry_mail']").css({'background-color': '#FFA'}).click(function() {
145 - $(this).css({'background-color': '#FFF'});
146 - });
147 - }
148 - if( "" == $("*[name='sender_mail']").val() ) {
149 - error++;
150 - $("*[name='sender_mail']").css({'background-color': '#FFA'}).click(function() {
151 - $(this).css({'background-color': '#FFF'});
152 - });
153 - }
154 - if( "" == $("*[name='error_mail']").val() ) {
155 - error++;
156 - $("*[name='error_mail']").css({'background-color': '#FFA'}).click(function() {
157 - $(this).css({'background-color': '#FFF'});
158 - });
159 - }
160 - if( !checkNum( $("*[name='point_num']").val() ) ) {
161 - error++;
162 - $("*[name='point_num']").css({'background-color': '#FFA'}).click(function() {
163 - $(this).css({'background-color': '#FFF'});
164 - });
165 - }
166 - if( !checkNum( $("*[name='discount_num']").val() ) ) {
167 - error++;
168 - $("*[name='discount_num']").css({'background-color': '#FFA'}).click(function() {
169 - $(this).css({'background-color': '#FFF'});
170 - });
171 - }
172 - if( !checkNum( $("*[name='postage_privilege']").val() ) ) {
173 - error++;
174 - $("*[name='postage_privilege']").css({'background-color': '#FFA'}).click(function() {
175 - $(this).css({'background-color': '#FFF'});
176 - });
177 - }
178 - if( !checkNum( $("*[name='purchase_limit']").val() ) ) {
179 - error++;
180 - $("*[name='purchase_limit']").css({'background-color': '#FFA'}).click(function() {
181 - $(this).css({'background-color': '#FFF'});
182 - });
183 - }
184 - if( !checkNum( $("*[name='tax_rate']").val() ) ) {
185 - error++;
186 - $("*[name='tax_rate']").css({'background-color': '#FFA'}).click(function() {
187 - $(this).css({'background-color': '#FFF'});
188 - });
189 - }
190 - if( !checkNum( $("*[name='point_rate']").val() ) ) {
191 - error++;
192 - $("*[name='point_rate']").css({'background-color': '#FFA'}).click(function() {
193 - $(this).css({'background-color': '#FFF'});
194 - });
195 - }
196 - if( !checkNum( $("*[name='start_point']").val() ) ) {
197 - error++;
198 - $("*[name='start_point']").css({'background-color': '#FFA'}).click(function() {
199 - $(this).css({'background-color': '#FFF'});
200 - });
201 - }
202 -
203 - if( 0 < error ) {
204 - $("#aniboxStatus").removeClass("none");
205 - $("#aniboxStatus").addClass("error");
206 - $("#info_image").attr("src", "<?php echo USCES_PLUGIN_URL; ?>/images/list_message_error.gif");
207 - $("#info_massage").html("データに不備があります");
208 - $("#anibox").animate({ backgroundColor: "#FFE6E6" }, 2000);
209 - return false;
210 - } else {
211 - return true;
212 - }
213 - });
214 -
215 - $( "#item-opt-list" ).sortable({
216 - //placeholder: "ui-state-highlight",
217 - handle : 'th',
218 - axis : 'y',
219 - cursor : "move",
220 - tolerance : "pointer",
221 - forceHelperSize : true,
222 - forcePlaceholderSize : true,
223 - revert : 300,
224 - opacity: 0.6,
225 - cancel: ":input,button",
226 - update : function(){
227 - var data=[];
228 - $("table","#item-opt-list").each(function(i,v){
229 - data.push($(this).attr('id'));
230 - });
231 - if( 1 < data.length ){
232 - itemOpt.dosort(data.toString());
233 - }
234 - }
235 - });
236 -
237 - $( "#payment-list" ).sortable({
238 - //placeholder: "ui-state-highlight",
239 - handle : 'th',
240 - axis : 'y',
241 - cursor : "move",
242 - tolerance : "pointer",
243 - forceHelperSize : true,
244 - forcePlaceholderSize : true,
245 - revert : 300,
246 - opacity: 0.6,
247 - cancel: ":input,button",
248 - update : function(){
249 - var data=[];
250 - $("table","#payment-list").each(function(i,v){
251 - data.push($(this).attr('id'));
252 - });
253 - if( 1 < data.length ){
254 - payment.dosort(data.toString());
255 - }
256 - }
257 - });
258 -
259 -})(jQuery);
260 -</script>
261 -<?php
262 - break;
263 - case 'usces_cart':
264 -?>
265 -<script type="text/javascript">
266 -(function($) {
267 - $('#option_form').submit(function(e) {
268 - var error = 0;
269 -
270 - if( !$("#indi_item_name").attr("checked") &&
271 - !$("#indi_item_code").attr("checked") &&
272 - !$("#indi_sku_name").attr("checked") &&
273 - !$("#indi_sku_code").attr("checked") ) {
274 - error++;
275 - $("#indi_item_name").parent().css({'background-color': '#FFA'}).click(function() {
276 - $("#indi_item_name").parent().css({'background-color': '#FFF'});
277 - $("#indi_item_code").parent().css({'background-color': '#FFF'});
278 - $("#indi_sku_name").parent().css({'background-color': '#FFF'});
279 - $("#indi_sku_code").parent().css({'background-color': '#FFF'});
280 - });
281 - $("#indi_item_code").parent().css({'background-color': '#FFA'}).click(function() {
282 - $("#indi_item_name").parent().css({'background-color': '#FFF'});
283 - $("#indi_item_code").parent().css({'background-color': '#FFF'});
284 - $("#indi_sku_name").parent().css({'background-color': '#FFF'});
285 - $("#indi_sku_code").parent().css({'background-color': '#FFF'});
286 - });
287 - $("#indi_sku_name").parent().css({'background-color': '#FFA'}).click(function() {
288 - $("#indi_item_name").parent().css({'background-color': '#FFF'});
289 - $("#indi_item_code").parent().css({'background-color': '#FFF'});
290 - $("#indi_sku_name").parent().css({'background-color': '#FFF'});
291 - $("#indi_sku_code").parent().css({'background-color': '#FFF'});
292 - });
293 - $("#indi_sku_code").parent().css({'background-color': '#FFA'}).click(function() {
294 - $("#indi_item_name").parent().css({'background-color': '#FFF'});
295 - $("#indi_item_code").parent().css({'background-color': '#FFF'});
296 - $("#indi_sku_name").parent().css({'background-color': '#FFF'});
297 - $("#indi_sku_code").parent().css({'background-color': '#FFF'});
298 - });
299 - }
300 - if( !checkNum( $("#pos_item_name").val() ) ) {
301 - error++;
302 - $("#pos_item_name").css({'background-color': '#FFA'}).click(function() {
303 - $(this).css({'background-color': '#FFF'});
304 - });
305 - }
306 - if( !checkNum( $("#pos_item_code").val() ) ) {
307 - error++;
308 - $("#pos_item_code").css({'background-color': '#FFA'}).click(function() {
309 - $(this).css({'background-color': '#FFF'});
310 - });
311 - }
312 - if( !checkNum( $("#pos_sku_name").val() ) ) {
313 - error++;
314 - $("#pos_sku_name").css({'background-color': '#FFA'}).click(function() {
315 - $(this).css({'background-color': '#FFF'});
316 - });
317 - }
318 - if( !checkNum( $("#pos_sku_code").val() ) ) {
319 - error++;
320 - $("#pos_sku_code").css({'background-color': '#FFA'}).click(function() {
321 - $(this).css({'background-color': '#FFF'});
322 - });
323 - }
324 -
325 - if( 0 < error ) {
326 - $("#aniboxStatus").removeClass("none");
327 - $("#aniboxStatus").addClass("error");
328 - $("#info_image").attr("src", "<?php echo USCES_PLUGIN_URL; ?>/images/list_message_error.gif");
329 - $("#info_massage").html("データに不備があります");
330 - $("#anibox").animate({ backgroundColor: "#FFE6E6" }, 2000);
331 - if( $.fn.jquery < "1.10" ) {
332 - $('#uscestabs_cart').tabs("select", 0);
333 - } else {
334 - $('#uscestabs_cart').tabs("option", "active", 0);
335 - }
336 - return false;
337 - } else {
338 - return true;
339 - }
340 - });
341 -})(jQuery);
342 -</script>
343 -<?php
344 - break;
345 - }
346 -}
347 -
348 -function admin_post_footer(){
349 - switch( $GLOBALS['hook_suffix'] ){
350 - case 'post.php':
351 - case 'post-new.php':
352 - $categories = get_categories( array('child_of' => USCES_ITEM_CAT_PARENT_ID) );
353 -?>
354 -<script type="text/javascript">
355 -(function($) {
356 - $("#category-<?php echo USCES_ITEM_CAT_PARENT_ID ?>").remove();
357 - $("#popular-category-<?php echo USCES_ITEM_CAT_PARENT_ID ?>").remove();
358 - <?php
359 - foreach ( $categories as $category ){
360 - ?>
361 - $("#popular-category-<?php echo $category->term_id ?>").remove();
362 - <?php
363 - }
364 - ?>
365 -})(jQuery);
366 -</script>
367 -<?php
368 - break;
369 - }
370 -}
371 -//function usces_action_transition_post_status( $new_status, $old_status, $post){
372 -// global $usces;
373 -// $itemCode = trim($_POST['itemCode' ]);
374 -// //usces_log('postarr : '.print_r($post,true), 'acting_transaction.log');
375 -// if( 'publish' == $new_status && 'post' == $post->post_type && $res = usces_is_same_itemcode($post->ID, $itemCode)) {
376 -// $usces->action_message .= 'post_ID ';
377 -// foreach( $res as $postid )
378 -// $usces->action_message .= $postid . ', ';
379 -// $usces->action_message .= 'に同じ商品コードが登録されています。' . "<br />";
380 -// }
381 -//}
382 -//
383 -//function usces_filter_redirect_post_location( $location, $post_id ){
384 -// global $usces;
385 -//// usces_log('usces_filter_redirect_post_location : '.print_r($location,true), 'acting_transaction.log');
386 -// if( !empty($usces->action_message) )
387 -// $location = add_query_arg( 'usces_notice', urlencode($usces->action_message), $location );
388 -// return $location;
389 -//}
390 -//
391 -//function usces_action_updated_messages(){
392 -// global $notice;
393 -//
394 -// if( isset($_GET['usces_notice']) ){
395 -// $notice = urldecode($_GET['usces_notice']) . $notice;
396 -// }
397 -//}
398 -
399 -function usces_item_duplicate($post_id){
400 - global $wpdb;
401 -
402 - if ( !current_user_can( 'edit_posts' ) )
403 - wp_die( __( 'Sorry, you do not have the right to access this site.' ) );
404 -
405 - if( empty($post_id) )
406 - wp_die( __( 'データが存在しません。', 'usces' ) );
407 -
408 - if ( !$post_data = wp_get_single_post($post_id, ARRAY_A) )
409 - wp_die( __( 'データが存在しません。', 'usces' ) );
410 -
411 - $datas = array();
412 - foreach($post_data as $key => $value){
413 - switch( $key ){
414 - case 'ID':
415 - break;
416 - case 'post_date':
417 - case 'post_modified':
418 - //$datas[$key] = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
419 - break;
420 - case 'post_date_gmt':
421 - case 'post_modified_gmt':
422 - //$datas[$key] = gmdate('Y-m-d H:i:s');
423 - break;
424 - case 'post_status':
425 - $datas[$key] = 'draft';
426 - break;
427 - case 'post_name':
428 - case 'guid':
429 - //$datas[$key] = '';
430 - break;
431 - case 'menu_order':
432 - case 'post_parent':
433 - case 'comment_count':
434 - $datas[$key] = 0;
435 - break;
436 - default:
437 - $datas[$key] = $value;
438 - }
439 - }
440 -
441 - $datas['post_category'] = wp_get_post_categories( $post_id );
442 -
443 - $newpost_id = wp_insert_post( $datas );
444 -
445 - $query = $wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post_id);
446 - $meta_data = $wpdb->get_results( $query );
447 - if(!$meta_data) return;
448 - $valstr = '';
449 - foreach($meta_data as $data){
450 -
451 - $prefix = substr($data->meta_key, 0, 5);
452 - $prefix1 = substr($data->meta_key, 0, 1);
453 - $prefix2 = substr($data->meta_key, 0, 11);
454 -
455 - if( $prefix == '_item' ){
456 -
457 - switch( $data->meta_key ){
458 - case '_itemCode':
459 - $value = $data->meta_value . '(copy)';
460 - break;
461 - default:
462 - $value = $data->meta_value;
463 - }
464 - $key = $data->meta_key;
465 - $valstr .= '(' . $newpost_id . ", '" . $wpdb->escape($key) . "','" . $wpdb->escape($value) . "'),";
466 -
467 - }else if( $prefix == '_isku' || $prefix == '_iopt' ){
468 -
469 - $value = $data->meta_value;
470 - $key = $data->meta_key;
471 - $valstr .= '(' . $newpost_id . ", '" . $wpdb->escape($key) . "','" . $wpdb->escape($value) . "'),";
472 -
473 - }
474 - if( $prefix1 != '_' ){
475 -
476 - $value = $data->meta_value;
477 - $key = $data->meta_key;
478 - $valstr .= '(' . $newpost_id . ", '" . $wpdb->escape($key) . "','" . $wpdb->escape($value) . "'),";
479 -
480 - }
481 -
482 - }
483 - $valstr = rtrim($valstr, ',');
484 - $query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES $valstr", $post_id);
485 - $res = mysql_query($query);
486 - if(!$res ) return;
487 -
488 - do_action('usces_action_item_dupricate', $post_id, $newpost_id);
489 -
490 - return $newpost_id;
491 -}
492 -function usces_item_dupricate($post_id){
493 - return usces_item_duplicate($post_id);
494 -}
495 -
496 -function usces_all_delete_itemdata(&$obj){
497 - global $wpdb;
498 -
499 - if ( !current_user_can( 'edit_posts' ) )
500 - wp_die( __( 'Sorry, you do not have the right to access this site.' ) );
501 -
502 - $ids = $_POST['listcheck'];
503 - $status = true;
504 - foreach ( (array)$ids as $post_id ){
505 - if ( !wp_delete_post($post_id, true) )
506 - $status = false;
507 -// $query = $wpdb->prepare("DELETE FROM $wpdb->posts WHERE ID = %d", $post_id);
508 -// $res = $wpdb->query( $query );
509 -// if( $res !== false ) {
510 -// $query = $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE post_id = %d", $post_id);
511 -// $res = $wpdb->query( $query );
512 -// if( $res === false ) {
513 -// $status = false;
514 -// }
515 -// $query = $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d", $post_id);
516 -// $res = $wpdb->query( $query );
517 -// if( $res === false ) {
518 -// $status = false;
519 -// }
520 -// $query = "SELECT term_taxonomy_id, COUNT(*) AS ct FROM $wpdb->term_relationships
521 -// GROUP BY term_taxonomy_id";
522 -// $relation_data = $wpdb->get_results( $query, ARRAY_A);
523 -// foreach((array)$relation_data as $rows){
524 -//
525 -// $term_ids['term_taxonomy_id'] = $rows['term_taxonomy_id'];
526 -// $updatas['count'] = $rows['ct'];
527 -// $wpdb->update( $wpdb->term_taxonomy, $updatas, $term_ids );
528 -// }
529 -// }
530 -
531 - }
532 - if ( true === $status ) {
533 - $obj->set_action_status('success', __('I completed collective operation.','usces'));
534 - } elseif ( false === $status ) {
535 - $obj->set_action_status('error', __('ERROR: I was not able to complete collective operation','usces'));
536 - } else {
537 - $obj->set_action_status('none', '');
538 - }
539 -}
540 -
541 -function usces_typenow(){
542 - global $typenow;
543 - if( isset($_GET['page']) && ('usces_itemedit' == $_GET['page'] || 'usces_itemnew' == $_GET['page']) )
544 - $typenow = '';
545 -
546 -}
547 -
548 -function usces_admin_notices(){
549 - global $usces;
550 - if( 'on' == $usces->options['acting_settings']['zeus']['activate'] ){
551 - $options = get_option('usces');
552 - if(!isset($options['acting_settings']['zeus']['vercheck']) || '115' != $options['acting_settings']['zeus']['vercheck'] ){
553 - $msg = '<div class="error"><p>決済に「ゼウス」をご利用の場合は、<a href="' . site_url('/wp-admin/admin.php?page=usces_settlement') . '">「セキュリティーコード」の設定内容を確認</a>して更新ボタンを押して下さい。設定を更新するとこのメッセージは表示されなくなります。</p></div>';
554 - echo $msg;
555 - }
556 - }
557 -}
558 -
559 -?>
1 +<?php
2 +/**
3 + * Admin Page Scripts.
4 + *
5 + * @package Welcart
6 + */
7 +
8 +/**
9 + * Admin scripts.
10 + * admin_footer-welcart-shop_page_usces_itemnew
11 + * admin_footer-welcart-shop_page_usces_itemedit
12 + * admin_footer-welcart-shop_page_usces_initial
13 + * admin_footer-welcart-shop_page_usces_cart
14 + */
15 +function admin_prodauct_footer() {
16 + $admin_page = ( isset( $_GET['page'] ) ) ? wp_unslash( $_GET['page'] ) : '';
17 + switch ( $admin_page ) {
18 + case 'usces_itemedit':
19 + if ( ! isset( $_GET['action'] ) || ( isset( $_REQUEST['action'] ) && 'upload_register' == $_REQUEST['action'] ) ) {
20 + break;
21 + }
22 + case 'usces_itemnew':
23 + ?>
24 +<script type="text/javascript">
25 +(function($) {
26 +
27 + itemEdit = {
28 + settings: {
29 + url: uscesL10n.requestFile,
30 + type: 'POST',
31 + dataType: 'json',
32 + cache: false
33 + },
34 + checkItemCode : function( item_code ) {
35 + var s = itemOpt.settings;
36 + var post_id = $('#post_ID').val();
37 + s.data = {
38 + action : 'wel_item_code_exists_ajax',
39 + item_code : item_code,
40 + wc_nonce : '<?php echo wp_create_nonce( 'check_item_code' ); ?>',
41 + noheader : true
42 + }
43 + $.ajax( s ).done(function( data ){
44 + if ( false != data.result && post_id != data.result ) {
45 + alert( data.message );
46 + $('#itemCode').val('');
47 + }
48 + // console.log(data);
49 + }).fail(function( msg ){
50 + console.log(msg);
51 + });
52 + return;
53 + }
54 + }
55 +
56 + $('#itemCode').change( function(e){
57 +
58 + itemEdit.checkItemCode( $('#itemCode').val() );
59 +
60 + });
61 +
62 + $('#itemCode').focusin( function(e){
63 +
64 + $('#save-post').attr('disabled', true);
65 + $('#post-preview').attr('disabled', true);
66 + $('#publish').attr('disabled', true);
67 +
68 + }).focusout( function(e){
69 +
70 + $('#save-post').attr('disabled', false);
71 + $('#post-preview').attr('disabled', false);
72 + $('#publish').attr('disabled', false);
73 +
74 + });
75 +
76 + var submit_event = true;
77 + $('#post-preview, #save-post').click(function(){
78 + if(!$("#auto_draft").val())
79 + submit_event = false;
80 + return true;
81 + });
82 + $('#post').submit(function(e){
83 + $('form#post').attr('action', '');
84 + var mes = '';
85 + var itemCode = $("#itemCode").val();
86 + var itemName = $("#itemName").val();
87 + var itemsku = $("input[name^='itemsku\[']");
88 + var DeliveryMethod = $("input[name^='itemDeliveryMethod\[']");
89 + var itemDivision = $("input[name='item_division']:checked").val();
90 + if ( !itemDivision || 'shipped' == itemDivision ) {
91 + if ( 0 == DeliveryMethod.length ) {
92 + mes += "<?php esc_html_e( "You can not choose the delivery method. Please complete the registration of shipping method than 'delivery setting' before product registration.", 'usces' ); ?><br />";
93 + }
94 + if ( ! $("input[name^='itemDeliveryMethod\[']:checked").length ) {
95 + mes += '<?php esc_html_e( 'Delivery method has not been entered.', 'usces' ); ?><br />';
96 + var eleLabelDeliveryMethod = $("label[for^='itemDeliveryMethod\[']");
97 + eleLabelDeliveryMethod.css({'background-color': '#FFA'}).click(function(){
98 + eleLabelDeliveryMethod.css({'background-color': '#FFF'});
99 + });
100 + }
101 + }
102 + if ( "" == itemCode ) {
103 + mes += '<?php esc_html_e( 'Product code has not been entered.', 'usces' ); ?><br />';
104 + $("#itemCode").css({'background-color': '#FFA'}).click(function(){
105 + $(this).css({'background-color': '#FFF'});
106 + });
107 + }
108 +
109 + if ( "" == itemName ) {
110 + mes += '<?php esc_html_e( 'Brand name has not been entered.', 'usces' ); ?><br />';
111 + $("#itemName").css({'background-color': '#FFA'}).click(function(){
112 + $(this).css({'background-color': '#FFF'});
113 + });
114 + }
115 + <?php if ( defined( 'WCEX_SKU_SELECT' ) ) : ?>
116 + if ( 0 == itemsku.length && ! $("#select_sku_switch").prop('checked') ) {
117 + <?php else : ?>
118 + if ( 0 == itemsku.length ) {
119 + <?php endif; ?>
120 + mes += '<?php esc_html_e( 'SKU is not registered.', 'usces' ); ?><br />';
121 + $("#newskuname").css({'background-color': '#FFA'}).click(function(){
122 + $(this).css({'background-color': '#FFF'});
123 + });
124 + $("#newskuprice").css({'background-color': '#FFA'}).click(function(){
125 + $(this).css({'background-color': '#FFF'});
126 + });
127 + }
128 + if ( '' != mes ) {
129 + $("#major-publishing-actions").append('<div id="usces_mess"></div>');
130 + $('#ajax-loading').css({'visibility': 'hidden'});
131 + $('#draft-ajax-loading').css({'visibility': 'hidden'});
132 + $('#publish').removeClass('button-primary-disabled');
133 + $('#save-post').removeClass('button-disabled');
134 + $("#usces_mess").html(mes);
135 + return false;
136 + } else {
137 + $('#usces_mess').fadeOut();
138 + return true;
139 + }
140 + });
141 +
142 + $('#itemName').blur(
143 + function() {
144 + if ( $("#itemName").val().length == 0 ) return;
145 + uscesItem.newdraft($('#itemName').val());
146 + });
147 +
148 + $( "#item-sku-list" ).sortable({
149 + handle : 'th',
150 + axis : 'y',
151 + cursor : "move",
152 + tolerance : "pointer",
153 + forceHelperSize : true,
154 + forcePlaceholderSize : true,
155 + revert : 300,
156 + opacity: 0.6,
157 + cancel: ":input,button",
158 + update : function(){
159 + var data=[];
160 + $("table, #item-sku-list").each(function(i,v){
161 + data.push($(this).attr('id'));
162 + });
163 + if( 1 < data.length ){
164 + itemSku.dosort(data);
165 + }
166 + }
167 + });
168 + $( "#item-opt-list" ).sortable({
169 + handle : 'th',
170 + axis : 'y',
171 + cursor : "move",
172 + tolerance : "pointer",
173 + forceHelperSize : true,
174 + forcePlaceholderSize : true,
175 + revert : 300,
176 + opacity: 0.6,
177 + cancel: ":input,button",
178 + update : function(){
179 + var data=[];
180 + $("table","#item-opt-list").each(function(i,v){
181 + data.push($(this).attr('id'));
182 + });
183 + if( 1 < data.length ){
184 + itemOpt.dosort(data.toString());
185 + }
186 + }
187 + });
188 +})(jQuery);
189 +</script>
190 + <?php
191 + break;
192 + case 'usces_initial':
193 + ?>
194 +<script type="text/javascript">
195 +(function($) {
196 + $('#option_form').submit(function(e) {
197 + var error = 0;
198 +
199 + if( "" == $("*[name='order_mail']").val() ) {
200 + error++;
201 + $("*[name='order_mail']").css({'background-color': '#FFA'}).click(function() {
202 + $(this).css({'background-color': '#FFF'});
203 + });
204 + }
205 + /*if( "" == $("*[name='inquiry_mail']").val() ) {
206 + error++;
207 + $("*[name='inquiry_mail']").css({'background-color': '#FFA'}).click(function() {
208 + $(this).css({'background-color': '#FFF'});
209 + });
210 + }*/
211 + if( "" == $("*[name='sender_mail']").val() ) {
212 + error++;
213 + $("*[name='sender_mail']").css({'background-color': '#FFA'}).click(function() {
214 + $(this).css({'background-color': '#FFF'});
215 + });
216 + }
217 + if( "" == $("*[name='error_mail']").val() ) {
218 + error++;
219 + $("*[name='error_mail']").css({'background-color': '#FFA'}).click(function() {
220 + $(this).css({'background-color': '#FFF'});
221 + });
222 + }
223 + if( !checkNum( $("*[name='point_num']").val() ) ) {
224 + error++;
225 + $("*[name='point_num']").css({'background-color': '#FFA'}).click(function() {
226 + $(this).css({'background-color': '#FFF'});
227 + });
228 + }
229 + if( !checkNum( $("*[name='discount_num']").val() ) ) {
230 + error++;
231 + $("*[name='discount_num']").css({'background-color': '#FFA'}).click(function() {
232 + $(this).css({'background-color': '#FFF'});
233 + });
234 + }
235 + if( !checkNum( $("*[name='postage_privilege']").val() ) ) {
236 + error++;
237 + $("*[name='postage_privilege']").css({'background-color': '#FFA'}).click(function() {
238 + $(this).css({'background-color': '#FFF'});
239 + });
240 + }
241 + if( !checkNum( $("*[name='purchase_limit']").val() ) ) {
242 + error++;
243 + $("*[name='purchase_limit']").css({'background-color': '#FFA'}).click(function() {
244 + $(this).css({'background-color': '#FFF'});
245 + });
246 + }
247 + if( !checkNum( $("*[name='tax_rate']").val() ) ) {
248 + error++;
249 + $("*[name='tax_rate']").css({'background-color': '#FFA'}).click(function() {
250 + $(this).css({'background-color': '#FFF'});
251 + });
252 + }
253 + if( !checkNum( $("*[name='point_rate']").val() ) ) {
254 + error++;
255 + $("*[name='point_rate']").css({'background-color': '#FFA'}).click(function() {
256 + $(this).css({'background-color': '#FFF'});
257 + });
258 + }
259 + if( !checkNum( $("*[name='start_point']").val() ) ) {
260 + error++;
261 + $("*[name='start_point']").css({'background-color': '#FFA'}).click(function() {
262 + $(this).css({'background-color': '#FFF'});
263 + });
264 + }
265 +
266 + if( 0 < error ) {
267 + $("#aniboxStatus").removeClass("none");
268 + $("#aniboxStatus").addClass("error");
269 + $("#info_image").attr("src", "<?php echo esc_url( USCES_PLUGIN_URL ); ?>/images/list_message_error.gif");
270 + $("#info_massage").html("<?php _e( 'Data have deficiency.', 'usces' ); ?>");
271 + $("#anibox").animate({ backgroundColor: "#FFE6E6" }, 2000);
272 + return false;
273 + } else {
274 + return true;
275 + }
276 + });
277 +
278 + $( "#item-opt-list" ).sortable({
279 + handle : 'th',
280 + axis : 'y',
281 + cursor : "move",
282 + tolerance : "pointer",
283 + forceHelperSize : true,
284 + forcePlaceholderSize : true,
285 + revert : 300,
286 + opacity: 0.6,
287 + cancel: ":input,button",
288 + update : function(){
289 + var data=[];
290 + $("table","#item-opt-list").each(function(i,v){
291 + data.push($(this).attr('id'));
292 + });
293 + if( 1 < data.length ){
294 + itemOpt.dosort(data.toString());
295 + }
296 + }
297 + });
298 +
299 + $( "#payment-list" ).sortable({
300 + handle : 'th',
301 + axis : 'y',
302 + cursor : "move",
303 + tolerance : "pointer",
304 + forceHelperSize : true,
305 + forcePlaceholderSize : true,
306 + revert : 300,
307 + opacity: 0.6,
308 + cancel: ":input,button",
309 + update : function(){
310 + var data=[];
311 + $("table","#payment-list").each(function(i,v){
312 + data.push($(this).attr('id'));
313 + });
314 + if( 1 < data.length ){
315 + payment.dosort(data.toString());
316 + }
317 + }
318 + });
319 +
320 + $( document ).on( "change", "input[name='applicable_taxrate']", function() {
321 + if( 'reduced' == $( "input[name='applicable_taxrate']:checked" ).val() ) {
322 + $( "#tax_rate_reduced" ).css( "display", "" );
323 + $( "#point_coverage0" ).prop( "checked", true );
324 + } else {
325 + $( "#tax_rate_reduced" ).css( "display", "none" );
326 + }
327 + });
328 + $( "input[name='applicable_taxrate']" ).trigger( "change" );
329 +
330 + $( document ).on( "change", "input[name='point_coverage']", function() {
331 + if( '1' == $( this ).val() ) {
332 + if( 'reduced' == $( "input[name='applicable_taxrate']:checked" ).val() ) {
333 + $( "input[value='0']" ).prop( "checked", true );
334 + }
335 + }
336 + });
337 +
338 +})(jQuery);
339 +</script>
340 + <?php
341 + break;
342 + case 'usces_cart':
343 + ?>
344 +<script type="text/javascript">
345 +(function($) {
346 + $('#option_form').submit(function(e) {
347 + var error = 0;
348 +
349 + if( !$("#indi_item_name").prop("checked") &&
350 + !$("#indi_item_code").prop("checked") &&
351 + !$("#indi_sku_name").prop("checked") &&
352 + !$("#indi_sku_code").prop("checked") ) {
353 + error++;
354 + $("#indi_item_name").parent().css({'background-color': '#FFA'}).click(function() {
355 + $("#indi_item_name").parent().css({'background-color': '#FFF'});
356 + $("#indi_item_code").parent().css({'background-color': '#FFF'});
357 + $("#indi_sku_name").parent().css({'background-color': '#FFF'});
358 + $("#indi_sku_code").parent().css({'background-color': '#FFF'});
359 + });
360 + $("#indi_item_code").parent().css({'background-color': '#FFA'}).click(function() {
361 + $("#indi_item_name").parent().css({'background-color': '#FFF'});
362 + $("#indi_item_code").parent().css({'background-color': '#FFF'});
363 + $("#indi_sku_name").parent().css({'background-color': '#FFF'});
364 + $("#indi_sku_code").parent().css({'background-color': '#FFF'});
365 + });
366 + $("#indi_sku_name").parent().css({'background-color': '#FFA'}).click(function() {
367 + $("#indi_item_name").parent().css({'background-color': '#FFF'});
368 + $("#indi_item_code").parent().css({'background-color': '#FFF'});
369 + $("#indi_sku_name").parent().css({'background-color': '#FFF'});
370 + $("#indi_sku_code").parent().css({'background-color': '#FFF'});
371 + });
372 + $("#indi_sku_code").parent().css({'background-color': '#FFA'}).click(function() {
373 + $("#indi_item_name").parent().css({'background-color': '#FFF'});
374 + $("#indi_item_code").parent().css({'background-color': '#FFF'});
375 + $("#indi_sku_name").parent().css({'background-color': '#FFF'});
376 + $("#indi_sku_code").parent().css({'background-color': '#FFF'});
377 + });
378 + }
379 + if( !checkNum( $("#pos_item_name").val() ) ) {
380 + error++;
381 + $("#pos_item_name").css({'background-color': '#FFA'}).click(function() {
382 + $(this).css({'background-color': '#FFF'});
383 + });
384 + }
385 + if( !checkNum( $("#pos_item_code").val() ) ) {
386 + error++;
387 + $("#pos_item_code").css({'background-color': '#FFA'}).click(function() {
388 + $(this).css({'background-color': '#FFF'});
389 + });
390 + }
391 + if( !checkNum( $("#pos_sku_name").val() ) ) {
392 + error++;
393 + $("#pos_sku_name").css({'background-color': '#FFA'}).click(function() {
394 + $(this).css({'background-color': '#FFF'});
395 + });
396 + }
397 + if( !checkNum( $("#pos_sku_code").val() ) ) {
398 + error++;
399 + $("#pos_sku_code").css({'background-color': '#FFA'}).click(function() {
400 + $(this).css({'background-color': '#FFF'});
401 + });
402 + }
403 +
404 + if( 0 < error ) {
405 + $("#aniboxStatus").removeClass("none");
406 + $("#aniboxStatus").addClass("error");
407 + $("#info_image").attr("src", "<?php echo esc_url( USCES_PLUGIN_URL ); ?>/images/list_message_error.gif");
408 + $("#info_massage").html("<?php esc_html_e( 'Data have deficiency.', 'usces' ); ?>");
409 + $("#anibox").animate({ backgroundColor: "#FFE6E6" }, 2000);
410 + if( $.fn.jquery < "1.10" ) {
411 + $('#uscestabs_cart').tabs("select", 0);
412 + } else {
413 + $('#uscestabs_cart').tabs("option", "active", 0);
414 + }
415 + return false;
416 + } else {
417 + return true;
418 + }
419 + });
420 +})(jQuery);
421 +</script>
422 + <?php
423 + break;
424 + }
425 +}
426 +
427 +/**
428 + * Admin scripts.
429 + * admin_footer-post.php
430 + * admin_footer-post-new.php
431 + */
432 +function admin_post_footer() {
433 + switch ( $GLOBALS['hook_suffix'] ) {
434 + case 'post.php':
435 + case 'post-new.php':
436 + $categories = get_categories( array( 'child_of' => USCES_ITEM_CAT_PARENT_ID ) );
437 + ?>
438 +<script type="text/javascript">
439 +(function($) {
440 + $("#category-<?php echo esc_attr( USCES_ITEM_CAT_PARENT_ID ); ?>").remove();
441 + $("#popular-category-<?php echo esc_attr( USCES_ITEM_CAT_PARENT_ID ); ?>").remove();
442 + <?php foreach ( $categories as $category ) : ?>
443 + $("#popular-category-<?php echo esc_attr( $category->term_id ); ?>").remove();
444 + <?php endforeach; ?>
445 +})(jQuery);
446 +</script>
447 + <?php
448 + break;
449 + }
450 +}
451 +
452 +/**
453 + * Item data duplication.
454 + *
455 + * @param int $post_id Post ID.
456 + * @return int Post ID after duplication.
457 + */
458 +function usces_item_duplicate( $post_id ) {
459 + global $wpdb;
460 +
461 + $nonce_action = 'duplicate_post_' . $post_id ;
462 + if ( ! check_admin_referer( $nonce_action, '_wpnonce' ) ) {
463 + wp_die( __( 'Sorry, you do not have the right to access this site.' ) );
464 + }
465 + if ( ! current_user_can( 'edit_post', $post_id ) ) {
466 + wp_die( __( 'Sorry, you do not have the right to access this site.' ) );
467 + }
468 + if ( empty( $post_id ) ) {
469 + wp_die( __( 'Data does not exist.', 'usces' ) );
470 + }
471 +
472 + $product = wel_get_product( $post_id );
473 + if ( false === $product ) {
474 + wp_die( __( 'Data does not exist.', 'usces' ) );
475 + }
476 + $post = $product['_pst'];
477 +
478 + $datas = array();
479 + foreach ( $post as $key => $value ) {
480 + switch ( $key ) {
481 + case 'ID':
482 + break;
483 + case 'post_date':
484 + case 'post_modified':
485 + break;
486 + case 'post_date_gmt':
487 + case 'post_modified_gmt':
488 + break;
489 + case 'post_status':
490 + $datas[ $key ] = 'draft';
491 + break;
492 + case 'post_name':
493 + case 'guid':
494 + break;
495 + case 'menu_order':
496 + case 'post_parent':
497 + case 'comment_count':
498 + $datas[ $key ] = 0;
499 + break;
500 + default:
501 + $datas[ $key ] = $value;
502 + }
503 + }
504 +
505 + $datas['post_category'] = wp_get_post_categories( $post_id );
506 + $data_tag = wp_get_object_terms( $post_id, 'post_tag', array( 'fields' => 'slugs' ) );
507 + if ( $data_tag ) {
508 + $datas['tags_input'] = $data_tag;
509 + }
510 +
511 + $newpost_id = wp_insert_post( $datas );
512 +
513 + $item = wel_get_item( $post_id, false );
514 + $item['itemCode'] .= '(copy)';
515 + $item['itemName'] .= '(copy)';
516 + wel_update_item_data( $item, $newpost_id );
517 +
518 + $skus = wel_get_skus( $post_id, 'sort', false );
519 + foreach ( $skus as $sku ) {
520 + unset( $sku['meta_id'] );
521 + wel_add_sku_data( $newpost_id, $sku );
522 + }
523 +
524 + $opts = wel_get_opts( $post_id, 'name', false );
525 + foreach ( $opts as $opt ) {
526 + unset( $opt['meta_id'] );
527 + wel_add_opt_data( $newpost_id, $opt );
528 + }
529 +
530 + $query = $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post_id );
531 + $meta_data = $wpdb->get_results( $query );
532 +
533 + if ( $meta_data ) {
534 +
535 + $valstr = '';
536 + foreach ( $meta_data as $data ) {
537 + $valstr .= $wpdb->prepare( "(%d, %s, %s),", $newpost_id, $data->meta_key, $data->meta_value ) . "\n";
538 + }
539 + $valstr = rtrim( $valstr, ",\n" );
540 +
541 + $query = "INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES $valstr";
542 + $res = $wpdb->query( $query );
543 + }
544 +
545 + do_action( 'usces_action_item_dupricate', $post_id, $newpost_id );
546 +
547 + return $newpost_id;
548 +}
549 +
550 +/**
551 + * Item data duplication.
552 + * alias usces_item_duplicate()
553 + *
554 + * @param int $post_id Post ID.
555 + * @return int Post ID after duplication.
556 + */
557 +function usces_item_dupricate( $post_id ) {
558 + return usces_item_duplicate( $post_id );
559 +}
560 +
561 +/**
562 + * Bulk delete items.
563 + *
564 + * @param object $obj Item list object.
565 + */
566 +function usces_all_delete_itemdata( &$obj ) {
567 +
568 + if ( ! current_user_can( 'edit_posts' ) ) {
569 + wp_die( __( 'Sorry, you do not have the right to access this site.' ) );
570 + }
571 +
572 + $ids = filter_input( INPUT_POST, 'listcheck', FILTER_VALIDATE_INT, FILTER_REQUIRE_ARRAY );
573 + if ( null === $ids ) {
574 + return;
575 + }
576 + $status = true;
577 + foreach ( (array) $ids as $post_id ) {
578 + if ( ! wp_delete_post( $post_id, true ) ) {
579 + $status = false;
580 + } else {
581 + wel_delete_all_sku_data( $post_id );
582 + wel_delete_all_opt_data( $post_id );
583 + wel_delete_item_data( $post_id );
584 + }
585 + }
586 + if ( true === $status ) {
587 + $obj->set_action_status( 'success', __( 'I completed collective operation.', 'usces' ) );
588 + } elseif ( false === $status ) {
589 + $obj->set_action_status( 'error', __( 'ERROR: I was not able to complete collective operation', 'usces' ) );
590 + } else {
591 + $obj->set_action_status( 'none', '' );
592 + }
593 +}
594 +
595 +/**
596 + * Typenow.
597 + */
598 +function usces_typenow() {
599 + global $typenow;
600 + if ( isset( $_GET['page'] ) && ( 'usces_itemedit' == $_GET['page'] || 'usces_itemnew' == $_GET['page'] ) ) {
601 + $typenow = '';
602 + }
603 +}
604 +
605 +/**
606 + * Admin notices.
607 + * unused
608 + */
609 +function usces_admin_notices() {
610 +
611 +}
612 +
613 +/**
614 + * Field of Member admin page for release the card information update lock.
615 + *
616 + * @since 2.5.8
617 + *
618 + * @param array $data Member data.
619 + * @param array $member_metas Member metadata.
620 + * @param array $usces_member_history Member history.
621 + */
622 +function wel_release_card_update_lock_field( $data, $member_metas, $usces_member_history ) {
623 +
624 + $lock_date = null;
625 + foreach ( $member_metas as $meta ) {
626 + if ( isset( $meta['meta_key'] ) && 'settlement_action_lock' === $meta['meta_key'] ) {
627 + $lock_date = $meta['meta_value'];
628 + break;
629 + }
630 + }
631 +
632 + if ( null !== $lock_date ) {
633 + ?>
634 + <tr>
635 + <td class="label"><input type="checkbox" name="release_card_update_lock" id="release_card_update_lock" value="release"></td>
636 + <td><label for="release_card_update_lock"><?php echo esc_html( sprintf( __( 'Unlock the card information update (Lock date and time: %s)', 'usces' ), $lock_date ) ); ?></label></td>
637 + </tr>
638 + <?php
639 + }
640 +}