PluginProbe
Welcart e-Commerce / 1.4.0
Welcart e-Commerce v1.4.0
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 / functions / admin_page.php

admin_page.php in Welcart e-Commerce 1.4.0, at functions/admin_page.php

540 lines 16.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 須チェックを行わない
15 $('#post-preview, #save-post').click(function(){
16 if(!$("#auto_draft").val())
17 submit_event = false;
18 return true;
19 });
20 $('#post').submit(function(e){
21 $('form#post').attr('action', '');
22 var mes = '';
23 var itemCode = $("#itemCode").val();
24 var itemName = $("#itemName").val();
25 var itemsku = $("input[name^='itemsku\[']");
26 var DeliveryMethod = $("input[name^='itemDeliveryMethod\[']");
27 var itemDivision = $("input[name='item_division']:checked").val();
28 if (submit_event) {
29 if ( 0 == DeliveryMethod.length && (!itemDivision || 'shipped' == itemDivision) ) {
30 mes += "<?php _e("You can not choose the delivery method. Please complete the registration of shipping method than 'delivery setting' before product registration.", "usces"); ?><br />";
31 }
32 if ( "" == itemCode ) {
33 mes += '<?php _e("Product code has not been entered.", "usces"); ?><br />';
34 $("#itemCode").css({'background-color': '#FFA'}).click(function(){
35 $(this).css({'background-color': '#FFF'});
36 });
37 }
38 // if ( ! checkCode( itemCode ) ) {
39 // mes += '商品コードは半角英数(-_を含む)で�
40 �力して下さい。<br />';
41 // $("#itemCode").css({'background-color': '#FFA'}).click(function(){
42 // $(this).css({'background-color': '#FFF'});
43 // });
44 // }
45 if ( "" == itemName ) {
46 mes += '<?php _e("Brand name has not been entered.", "usces"); ?><br />';
47 $("#itemName").css({'background-color': '#FFA'}).click(function(){
48 $(this).css({'background-color': '#FFF'});
49 });
50 }
51 if ( 0 == itemsku.length ) {
52 mes += '<?php _e("SKU is not registered.", "usces"); ?><br />';
53 $("#newskuname").css({'background-color': '#FFA'}).click(function(){
54 $(this).css({'background-color': '#FFF'});
55 });
56 $("#newskuprice").css({'background-color': '#FFA'}).click(function(){
57 $(this).css({'background-color': '#FFF'});
58 });
59 }
60 if ( '' != mes) {
61 $("#major-publishing-actions").append('<div id="usces_mess"></div>');
62 $('#ajax-loading').css({'visibility': 'hidden'});
63 $('#draft-ajax-loading').css({'visibility': 'hidden'});
64 $('#publish').removeClass('button-primary-disabled');
65 $('#save-post').removeClass('button-disabled');
66 $("#usces_mess").html(mes);
67 return false;
68 } else {
69 $('#usces_mess').fadeOut();
70 return true;
71 }
72 } else {
73 return true;
74 }
75 });
76
77 // $('#postimagediv h3').html('<span>商品画像</span>');
78 $('#itemName').blur(
79 function() {
80 if ( $("#itemName").val().length == 0 ) return;
81 uscesItem.newdraft($('#itemName').val());
82 });
83
84 $( "#item-sku-list" ).sortable({
85 //placeholder: "ui-state-highlight",
86 handle : 'th',
87 axis : 'y',
88 cursor : "move",
89 tolerance : "pointer",
90 forceHelperSize : true,
91 forcePlaceholderSize : true,
92 revert : 300,
93 opacity: 0.6,
94 cancel: ":input,button",
95 update : function(){
96 var data=[];
97 $("table","#item-sku-list").each(function(i,v){
98 data.push($(this).attr('id'));
99 });
100 if( 1 < data.length ){
101 itemSku.dosort(data.toString());
102 }
103 }
104 });
105 $( "#item-opt-list" ).sortable({
106 //placeholder: "ui-state-highlight",
107 handle : 'th',
108 axis : 'y',
109 cursor : "move",
110 tolerance : "pointer",
111 forceHelperSize : true,
112 forcePlaceholderSize : true,
113 revert : 300,
114 opacity: 0.6,
115 cancel: ":input,button",
116 update : function(){
117 var data=[];
118 $("table","#item-opt-list").each(function(i,v){
119 data.push($(this).attr('id'));
120 });
121 if( 1 < data.length ){
122 itemOpt.dosort(data.toString());
123 }
124 }
125 });
126
127 })(jQuery);
128 </script>
129 <?php
130 break;
131 case 'usces_initial':
132 ?>
133 <script type="text/javascript">
134 (function($) {
135 $('#option_form').submit(function(e) {
136 var error = 0;
137
138 if( "" == $("*[name='order_mail']").val() ) {
139 error++;
140 $("*[name='order_mail']").css({'background-color': '#FFA'}).click(function() {
141 $(this).css({'background-color': '#FFF'});
142 });
143 }
144 if( "" == $("*[name='inquiry_mail']").val() ) {
145 error++;
146 $("*[name='inquiry_mail']").css({'background-color': '#FFA'}).click(function() {
147 $(this).css({'background-color': '#FFF'});
148 });
149 }
150 if( "" == $("*[name='sender_mail']").val() ) {
151 error++;
152 $("*[name='sender_mail']").css({'background-color': '#FFA'}).click(function() {
153 $(this).css({'background-color': '#FFF'});
154 });
155 }
156 if( "" == $("*[name='error_mail']").val() ) {
157 error++;
158 $("*[name='error_mail']").css({'background-color': '#FFA'}).click(function() {
159 $(this).css({'background-color': '#FFF'});
160 });
161 }
162 if( !checkNum( $("*[name='point_num']").val() ) ) {
163 error++;
164 $("*[name='point_num']").css({'background-color': '#FFA'}).click(function() {
165 $(this).css({'background-color': '#FFF'});
166 });
167 }
168 if( !checkNum( $("*[name='discount_num']").val() ) ) {
169 error++;
170 $("*[name='discount_num']").css({'background-color': '#FFA'}).click(function() {
171 $(this).css({'background-color': '#FFF'});
172 });
173 }
174 if( !checkNum( $("*[name='postage_privilege']").val() ) ) {
175 error++;
176 $("*[name='postage_privilege']").css({'background-color': '#FFA'}).click(function() {
177 $(this).css({'background-color': '#FFF'});
178 });
179 }
180 if( !checkNum( $("*[name='purchase_limit']").val() ) ) {
181 error++;
182 $("*[name='purchase_limit']").css({'background-color': '#FFA'}).click(function() {
183 $(this).css({'background-color': '#FFF'});
184 });
185 }
186 if( !checkNum( $("*[name='tax_rate']").val() ) ) {
187 error++;
188 $("*[name='tax_rate']").css({'background-color': '#FFA'}).click(function() {
189 $(this).css({'background-color': '#FFF'});
190 });
191 }
192 if( !checkNum( $("*[name='point_rate']").val() ) ) {
193 error++;
194 $("*[name='point_rate']").css({'background-color': '#FFA'}).click(function() {
195 $(this).css({'background-color': '#FFF'});
196 });
197 }
198 if( !checkNum( $("*[name='start_point']").val() ) ) {
199 error++;
200 $("*[name='start_point']").css({'background-color': '#FFA'}).click(function() {
201 $(this).css({'background-color': '#FFF'});
202 });
203 }
204
205 if( 0 < error ) {
206 $("#aniboxStatus").removeClass("none");
207 $("#aniboxStatus").addClass("error");
208 $("#info_image").attr("src", "<?php echo USCES_PLUGIN_URL; ?>/images/list_message_error.gif");
209 $("#info_massage").html("<?php _e('Data have deficiency.','usces'); ?>");
210 $("#anibox").animate({ backgroundColor: "#FFE6E6" }, 2000);
211 return false;
212 } else {
213 return true;
214 }
215 });
216
217 $( "#item-opt-list" ).sortable({
218 //placeholder: "ui-state-highlight",
219 handle : 'th',
220 axis : 'y',
221 cursor : "move",
222 tolerance : "pointer",
223 forceHelperSize : true,
224 forcePlaceholderSize : true,
225 revert : 300,
226 opacity: 0.6,
227 cancel: ":input,button",
228 update : function(){
229 var data=[];
230 $("table","#item-opt-list").each(function(i,v){
231 data.push($(this).attr('id'));
232 });
233 if( 1 < data.length ){
234 itemOpt.dosort(data.toString());
235 }
236 }
237 });
238
239 $( "#payment-list" ).sortable({
240 //placeholder: "ui-state-highlight",
241 handle : 'th',
242 axis : 'y',
243 cursor : "move",
244 tolerance : "pointer",
245 forceHelperSize : true,
246 forcePlaceholderSize : true,
247 revert : 300,
248 opacity: 0.6,
249 cancel: ":input,button",
250 update : function(){
251 var data=[];
252 $("table","#payment-list").each(function(i,v){
253 data.push($(this).attr('id'));
254 });
255 if( 1 < data.length ){
256 payment.dosort(data.toString());
257 }
258 }
259 });
260
261 })(jQuery);
262 </script>
263 <?php
264 break;
265 case 'usces_cart':
266 ?>
267 <script type="text/javascript">
268 (function($) {
269 $('#option_form').submit(function(e) {
270 var error = 0;
271
272 if( !$("#indi_item_name").attr("checked") &&
273 !$("#indi_item_code").attr("checked") &&
274 !$("#indi_sku_name").attr("checked") &&
275 !$("#indi_sku_code").attr("checked") ) {
276 error++;
277 $("#indi_item_name").parent().css({'background-color': '#FFA'}).click(function() {
278 $("#indi_item_name").parent().css({'background-color': '#FFF'});
279 $("#indi_item_code").parent().css({'background-color': '#FFF'});
280 $("#indi_sku_name").parent().css({'background-color': '#FFF'});
281 $("#indi_sku_code").parent().css({'background-color': '#FFF'});
282 });
283 $("#indi_item_code").parent().css({'background-color': '#FFA'}).click(function() {
284 $("#indi_item_name").parent().css({'background-color': '#FFF'});
285 $("#indi_item_code").parent().css({'background-color': '#FFF'});
286 $("#indi_sku_name").parent().css({'background-color': '#FFF'});
287 $("#indi_sku_code").parent().css({'background-color': '#FFF'});
288 });
289 $("#indi_sku_name").parent().css({'background-color': '#FFA'}).click(function() {
290 $("#indi_item_name").parent().css({'background-color': '#FFF'});
291 $("#indi_item_code").parent().css({'background-color': '#FFF'});
292 $("#indi_sku_name").parent().css({'background-color': '#FFF'});
293 $("#indi_sku_code").parent().css({'background-color': '#FFF'});
294 });
295 $("#indi_sku_code").parent().css({'background-color': '#FFA'}).click(function() {
296 $("#indi_item_name").parent().css({'background-color': '#FFF'});
297 $("#indi_item_code").parent().css({'background-color': '#FFF'});
298 $("#indi_sku_name").parent().css({'background-color': '#FFF'});
299 $("#indi_sku_code").parent().css({'background-color': '#FFF'});
300 });
301 }
302 if( !checkNum( $("#pos_item_name").val() ) ) {
303 error++;
304 $("#pos_item_name").css({'background-color': '#FFA'}).click(function() {
305 $(this).css({'background-color': '#FFF'});
306 });
307 }
308 if( !checkNum( $("#pos_item_code").val() ) ) {
309 error++;
310 $("#pos_item_code").css({'background-color': '#FFA'}).click(function() {
311 $(this).css({'background-color': '#FFF'});
312 });
313 }
314 if( !checkNum( $("#pos_sku_name").val() ) ) {
315 error++;
316 $("#pos_sku_name").css({'background-color': '#FFA'}).click(function() {
317 $(this).css({'background-color': '#FFF'});
318 });
319 }
320 if( !checkNum( $("#pos_sku_code").val() ) ) {
321 error++;
322 $("#pos_sku_code").css({'background-color': '#FFA'}).click(function() {
323 $(this).css({'background-color': '#FFF'});
324 });
325 }
326
327 if( 0 < error ) {
328 $("#aniboxStatus").removeClass("none");
329 $("#aniboxStatus").addClass("error");
330 $("#info_image").attr("src", "<?php echo USCES_PLUGIN_URL; ?>/images/list_message_error.gif");
331 $("#info_massage").html("<?php _e('Data have deficiency.','usces'); ?>");
332 $("#anibox").animate({ backgroundColor: "#FFE6E6" }, 2000);
333 if( $.fn.jquery < "1.10" ) {
334 $('#uscestabs_cart').tabs("select", 0);
335 } else {
336 $('#uscestabs_cart').tabs("option", "active", 0);
337 }
338 return false;
339 } else {
340 return true;
341 }
342 });
343 })(jQuery);
344 </script>
345 <?php
346 break;
347 }
348 }
349
350 function admin_post_footer(){
351 switch( $GLOBALS['hook_suffix'] ){
352 case 'post.php':
353 case 'post-new.php':
354 $categories = get_categories( array('child_of' => USCES_ITEM_CAT_PARENT_ID) );
355 ?>
356 <script type="text/javascript">
357 (function($) {
358 $("#category-<?php echo USCES_ITEM_CAT_PARENT_ID ?>").remove();
359 $("#popular-category-<?php echo USCES_ITEM_CAT_PARENT_ID ?>").remove();
360 <?php
361 foreach ( $categories as $category ){
362 ?>
363 $("#popular-category-<?php echo $category->term_id ?>").remove();
364 <?php
365 }
366 ?>
367 })(jQuery);
368 </script>
369 <?php
370 break;
371 }
372 }
373 //function usces_action_transition_post_status( $new_status, $old_status, $post){
374 // global $usces;
375 // $itemCode = trim($_POST['itemCode' ]);
376 // //usces_log('postarr : '.print_r($post,true), 'acting_transaction.log');
377 // if( 'publish' == $new_status && 'post' == $post->post_type && $res = usces_is_same_itemcode($post->ID, $itemCode)) {
378 // $usces->action_message .= 'post_ID ';
379 // foreach( $res as $postid )
380 // $usces->action_message .= $postid . ', ';
381 // $usces->action_message .= 'に同じ商品コードが登録されています。' . "<br />";
382 // }
383 //}
384 //
385 //function usces_filter_redirect_post_location( $location, $post_id ){
386 // global $usces;
387 //// usces_log('usces_filter_redirect_post_location : '.print_r($location,true), 'acting_transaction.log');
388 // if( !empty($usces->action_message) )
389 // $location = add_query_arg( 'usces_notice', urlencode($usces->action_message), $location );
390 // return $location;
391 //}
392 //
393 //function usces_action_updated_messages(){
394 // global $notice;
395 //
396 // if( isset($_GET['usces_notice']) ){
397 // $notice = urldecode($_GET['usces_notice']) . $notice;
398 // }
399 //}
400
401 function usces_item_duplicate($post_id){
402 global $wpdb;
403
404 if ( !current_user_can( 'edit_posts' ) )
405 wp_die( __( 'Sorry, you do not have the right to access this site.' ) );
406
407 if( empty($post_id) )
408 wp_die( __( 'Data does not exist.', 'usces' ) );
409
410 //if ( !$post_data = wp_get_single_post($post_id, ARRAY_A) )
411 if ( !$post_data = get_post($post_id, ARRAY_A) )
412 wp_die( __( 'Data does not exist.', 'usces' ) );
413
414 $datas = array();
415 foreach($post_data as $key => $value){
416 switch( $key ){
417 case 'ID':
418 break;
419 case 'post_date':
420 case 'post_modified':
421 //$datas[$key] = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
422 break;
423 case 'post_date_gmt':
424 case 'post_modified_gmt':
425 //$datas[$key] = gmdate('Y-m-d H:i:s');
426 break;
427 case 'post_status':
428 $datas[$key] = 'draft';
429 break;
430 case 'post_name':
431 case 'guid':
432 //$datas[$key] = '';
433 break;
434 case 'menu_order':
435 case 'post_parent':
436 case 'comment_count':
437 $datas[$key] = 0;
438 break;
439 default:
440 $datas[$key] = $value;
441 }
442 }
443
444 $datas['post_category'] = wp_get_post_categories( $post_id );
445
446 $newpost_id = wp_insert_post( $datas );
447
448 $query = $wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post_id);
449 $meta_data = $wpdb->get_results( $query );
450 if(!$meta_data) return;
451 $valstr = '';
452 foreach($meta_data as $data){
453
454 $prefix = substr($data->meta_key, 0, 5);
455 $prefix1 = substr($data->meta_key, 0, 1);
456 $prefix2 = substr($data->meta_key, 0, 11);
457
458 if( $prefix == '_item' ){
459
460 switch( $data->meta_key ){
461 case '_itemCode':
462 $value = $data->meta_value . '(copy)';
463 break;
464 default:
465 $value = $data->meta_value;
466 }
467 $key = $data->meta_key;
468 //$valstr .= '(' . $newpost_id . ", '" . $wpdb->escape($key) . "','" . $wpdb->escape($value) . "'),";
469 $valstr .= '(' . $newpost_id . ", '" . esc_sql($key) . "','" . esc_sql($value) . "'),";
470 }else if( $prefix == '_isku' || $prefix == '_iopt' ){
471
472 $value = $data->meta_value;
473 $key = $data->meta_key;
474 //$valstr .= '(' . $newpost_id . ", '" . $wpdb->escape($key) . "','" . $wpdb->escape($value) . "'),";
475 $valstr .= '(' . $newpost_id . ", '" . esc_sql($key) . "','" . esc_sql($value) . "'),";
476 }
477 if( $prefix1 != '_' ){
478
479 $value = $data->meta_value;
480 $key = $data->meta_key;
481 //$valstr .= '(' . $newpost_id . ", '" . $wpdb->escape($key) . "','" . $wpdb->escape($value) . "'),";
482 $valstr .= '(' . $newpost_id . ", '" . esc_sql($key) . "','" . esc_sql($value) . "'),";
483 }
484
485 }
486 $valstr = rtrim($valstr, ',');
487 $query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES $valstr", $post_id);
488 $res = $wpdb->query($query);
489 if(!$res ) return;
490
491 do_action('usces_action_item_dupricate', $post_id, $newpost_id);
492
493 return $newpost_id;
494 }
495 function usces_item_dupricate($post_id){
496 return usces_item_duplicate($post_id);
497 }
498
499 function usces_all_delete_itemdata(&$obj){
500 global $wpdb;
501
502 if ( !current_user_can( 'edit_posts' ) )
503 wp_die( __( 'Sorry, you do not have the right to access this site.' ) );
504
505 $ids = $_POST['listcheck'];
506 $status = true;
507 foreach ( (array)$ids as $post_id ){
508 if ( !wp_delete_post($post_id, true) ){
509 $status = false;
510 }
511 }
512 if ( true === $status ) {
513 $obj->set_action_status('success', __('I completed collective operation.','usces'));
514 } elseif ( false === $status ) {
515 $obj->set_action_status('error', __('ERROR: I was not able to complete collective operation','usces'));
516 } else {
517 $obj->set_action_status('none', '');
518 }
519 }
520
521 function usces_typenow(){
522 global $typenow;
523 if( isset($_GET['page']) && ('usces_itemedit' == $_GET['page'] || 'usces_itemnew' == $_GET['page']) )
524 $typenow = '';
525
526 }
527
528 function usces_admin_notices(){
529 global $usces;
530 if( 'on' == $usces->options['acting_settings']['zeus']['activate'] ){
531 $options = get_option('usces');
532 if(!isset($options['acting_settings']['zeus']['vercheck']) || '115' != $options['acting_settings']['zeus']['vercheck'] ){
533 $msg = '<div class="error"><p>決済に「ゼウス」をご利用の場合は、<a href="' . site_url('/wp-admin/admin.php?page=usces_settlement') . '">「セキュリティーコード」の設定�
534 容を確認</a>して更新ボタンを押して下さい。設定を更新するとこのメッセージは表示されなくなります。</p></div>';
535 echo $msg;
536 }
537 }
538 }
539
540 ?>