PluginProbe
Welcart e-Commerce / 1.3.9
Welcart e-Commerce v1.3.9
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.3.9, at functions/admin_page.php

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