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

567 lines 17.1 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("データに不備があります");
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("データに不備があります");
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( __( 'データが存在しません。', 'usces' ) );
414
415 if ( !$post_data = wp_get_single_post($post_id, ARRAY_A) )
416 wp_die( __( 'データが存在しません。', 'usces' ) );
417
418 $datas = array();
419 foreach($post_data as $key => $value){
420 switch( $key ){
421 case 'ID':
422 break;
423 case 'post_date':
424 case 'post_modified':
425 //$datas[$key] = get_date_from_gmt(gmdate('Y-m-d H:i:s', time()));
426 break;
427 case 'post_date_gmt':
428 case 'post_modified_gmt':
429 //$datas[$key] = gmdate('Y-m-d H:i:s');
430 break;
431 case 'post_status':
432 $datas[$key] = 'draft';
433 break;
434 case 'post_name':
435 case 'guid':
436 //$datas[$key] = '';
437 break;
438 case 'menu_order':
439 case 'post_parent':
440 case 'comment_count':
441 $datas[$key] = 0;
442 break;
443 default:
444 $datas[$key] = $value;
445 }
446 }
447
448 $datas['post_category'] = wp_get_post_categories( $post_id );
449
450 $newpost_id = wp_insert_post( $datas );
451
452 $query = $wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post_id);
453 $meta_data = $wpdb->get_results( $query );
454 if(!$meta_data) return;
455 $valstr = '';
456 foreach($meta_data as $data){
457
458 $prefix = substr($data->meta_key, 0, 5);
459 $prefix1 = substr($data->meta_key, 0, 1);
460 $prefix2 = substr($data->meta_key, 0, 11);
461
462 if( $prefix == '_item' ){
463
464 switch( $data->meta_key ){
465 case '_itemCode':
466 $value = $data->meta_value . '(copy)';
467 break;
468 default:
469 $value = $data->meta_value;
470 }
471 $key = $data->meta_key;
472 $valstr .= '(' . $newpost_id . ", '" . $wpdb->escape($key) . "','" . $wpdb->escape($value) . "'),";
473
474 }else if( $prefix == '_isku' || $prefix == '_iopt' ){
475
476 $value = $data->meta_value;
477 $key = $data->meta_key;
478 $valstr .= '(' . $newpost_id . ", '" . $wpdb->escape($key) . "','" . $wpdb->escape($value) . "'),";
479
480 }
481 if( $prefix1 != '_' ){
482
483 $value = $data->meta_value;
484 $key = $data->meta_key;
485 $valstr .= '(' . $newpost_id . ", '" . $wpdb->escape($key) . "','" . $wpdb->escape($value) . "'),";
486
487 }
488
489 }
490 $valstr = rtrim($valstr, ',');
491 $query = $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id, meta_key, meta_value) VALUES $valstr", $post_id);
492 $res = mysql_query($query);
493 if(!$res ) return;
494
495 do_action('usces_action_item_dupricate', $post_id, $newpost_id);
496
497 return $newpost_id;
498 }
499 function usces_item_dupricate($post_id){
500 return usces_item_duplicate($post_id);
501 }
502
503 function usces_all_delete_itemdata(&$obj){
504 global $wpdb;
505
506 if ( !current_user_can( 'edit_posts' ) )
507 wp_die( __( 'Sorry, you do not have the right to access this site.' ) );
508
509 $ids = $_POST['listcheck'];
510 $status = true;
511 foreach ( (array)$ids as $post_id ){
512 if ( !wp_delete_post($post_id, true) )
513 $status = false;
514 // $query = $wpdb->prepare("DELETE FROM $wpdb->posts WHERE ID = %d", $post_id);
515 // $res = $wpdb->query( $query );
516 // if( $res !== false ) {
517 // $query = $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE post_id = %d", $post_id);
518 // $res = $wpdb->query( $query );
519 // if( $res === false ) {
520 // $status = false;
521 // }
522 // $query = $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d", $post_id);
523 // $res = $wpdb->query( $query );
524 // if( $res === false ) {
525 // $status = false;
526 // }
527 // $query = "SELECT term_taxonomy_id, COUNT(*) AS ct FROM $wpdb->term_relationships
528 // GROUP BY term_taxonomy_id";
529 // $relation_data = $wpdb->get_results( $query, ARRAY_A);
530 // foreach((array)$relation_data as $rows){
531 //
532 // $term_ids['term_taxonomy_id'] = $rows['term_taxonomy_id'];
533 // $updatas['count'] = $rows['ct'];
534 // $wpdb->update( $wpdb->term_taxonomy, $updatas, $term_ids );
535 // }
536 // }
537
538 }
539 if ( true === $status ) {
540 $obj->set_action_status('success', __('I completed collective operation.','usces'));
541 } elseif ( false === $status ) {
542 $obj->set_action_status('error', __('ERROR: I was not able to complete collective operation','usces'));
543 } else {
544 $obj->set_action_status('none', '');
545 }
546 }
547
548 function usces_typenow(){
549 global $typenow;
550 if( isset($_GET['page']) && ('usces_itemedit' == $_GET['page'] || 'usces_itemnew' == $_GET['page']) )
551 $typenow = '';
552
553 }
554
555 function usces_admin_notices(){
556 global $usces;
557 if( 'on' == $usces->options['acting_settings']['zeus']['activate'] ){
558 $options = get_option('usces');
559 if(!isset($options['acting_settings']['zeus']['vercheck']) || '115' != $options['acting_settings']['zeus']['vercheck'] ){
560 $msg = '<div class="error"><p>決済に「ゼウス」をご利用の場合は、<a href="' . site_url('/wp-admin/admin.php?page=usces_settlement') . '">「セキュリティーコード」の設定�
561 容を確認</a>して更新ボタンを押して下さい。設定を更新するとこのメッセージは表示されなくなります。</p></div>';
562 echo $msg;
563 }
564 }
565 }
566
567 ?>