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

563 lines 17.0 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 $('#uscestabs_cart').tabs("select", 0);
339 return false;
340 } else {
341 return true;
342 }
343 });
344 })(jQuery);
345 </script>
346 <?php
347 break;
348 }
349 }
350
351 function admin_post_footer(){
352 switch( $GLOBALS['hook_suffix'] ){
353 case 'post.php':
354 case 'post-new.php':
355 $categories = get_categories( array('child_of' => USCES_ITEM_CAT_PARENT_ID) );
356 ?>
357 <script type="text/javascript">
358 (function($) {
359 $("#category-<?php echo USCES_ITEM_CAT_PARENT_ID ?>").remove();
360 $("#popular-category-<?php echo USCES_ITEM_CAT_PARENT_ID ?>").remove();
361 <?php
362 foreach ( $categories as $category ){
363 ?>
364 $("#popular-category-<?php echo $category->term_id ?>").remove();
365 <?php
366 }
367 ?>
368 })(jQuery);
369 </script>
370 <?php
371 break;
372 }
373 }
374 //function usces_action_transition_post_status( $new_status, $old_status, $post){
375 // global $usces;
376 // $itemCode = trim($_POST['itemCode' ]);
377 // //usces_log('postarr : '.print_r($post,true), 'acting_transaction.log');
378 // if( 'publish' == $new_status && 'post' == $post->post_type && $res = usces_is_same_itemcode($post->ID, $itemCode)) {
379 // $usces->action_message .= 'post_ID ';
380 // foreach( $res as $postid )
381 // $usces->action_message .= $postid . ', ';
382 // $usces->action_message .= 'に同じ商品コードが登録されています。' . "<br />";
383 // }
384 //}
385 //
386 //function usces_filter_redirect_post_location( $location, $post_id ){
387 // global $usces;
388 //// usces_log('usces_filter_redirect_post_location : '.print_r($location,true), 'acting_transaction.log');
389 // if( !empty($usces->action_message) )
390 // $location = add_query_arg( 'usces_notice', urlencode($usces->action_message), $location );
391 // return $location;
392 //}
393 //
394 //function usces_action_updated_messages(){
395 // global $notice;
396 //
397 // if( isset($_GET['usces_notice']) ){
398 // $notice = urldecode($_GET['usces_notice']) . $notice;
399 // }
400 //}
401
402 function usces_item_duplicate($post_id){
403 global $wpdb;
404
405 if ( !current_user_can( 'edit_posts' ) )
406 wp_die( __( 'Sorry, you do not have the right to access this site.' ) );
407
408 if( empty($post_id) )
409 wp_die( __( 'データが存在しません。', 'usces' ) );
410
411 if ( !$post_data = wp_get_single_post($post_id, ARRAY_A) )
412 wp_die( __( 'データが存在しません。', '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
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
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
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 = mysql_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 // $query = $wpdb->prepare("DELETE FROM $wpdb->posts WHERE ID = %d", $post_id);
511 // $res = $wpdb->query( $query );
512 // if( $res !== false ) {
513 // $query = $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE post_id = %d", $post_id);
514 // $res = $wpdb->query( $query );
515 // if( $res === false ) {
516 // $status = false;
517 // }
518 // $query = $wpdb->prepare("DELETE FROM $wpdb->term_relationships WHERE object_id = %d", $post_id);
519 // $res = $wpdb->query( $query );
520 // if( $res === false ) {
521 // $status = false;
522 // }
523 // $query = "SELECT term_taxonomy_id, COUNT(*) AS ct FROM $wpdb->term_relationships
524 // GROUP BY term_taxonomy_id";
525 // $relation_data = $wpdb->get_results( $query, ARRAY_A);
526 // foreach((array)$relation_data as $rows){
527 //
528 // $term_ids['term_taxonomy_id'] = $rows['term_taxonomy_id'];
529 // $updatas['count'] = $rows['ct'];
530 // $wpdb->update( $wpdb->term_taxonomy, $updatas, $term_ids );
531 // }
532 // }
533
534 }
535 if ( true === $status ) {
536 $obj->set_action_status('success', __('I completed collective operation.','usces'));
537 } elseif ( false === $status ) {
538 $obj->set_action_status('error', __('ERROR: I was not able to complete collective operation','usces'));
539 } else {
540 $obj->set_action_status('none', '');
541 }
542 }
543
544 function usces_typenow(){
545 global $typenow;
546 if( isset($_GET['page']) && ('usces_itemedit' == $_GET['page'] || 'usces_itemnew' == $_GET['page']) )
547 $typenow = '';
548
549 }
550
551 function usces_admin_notices(){
552 global $usces;
553 if( 'on' == $usces->options['acting_settings']['zeus']['activate'] ){
554 $options = get_option('usces');
555 if(!isset($options['acting_settings']['zeus']['vercheck']) || '115' != $options['acting_settings']['zeus']['vercheck'] ){
556 $msg = '<div class="error"><p>決済に「ゼウス」をご利用の場合は、<a href="' . site_url('/wp-admin/admin.php?page=usces_settlement') . '">「セキュリティーコード」の設定�
557 容を確認</a>して更新ボタンを押して下さい。設定を更新するとこのメッセージは表示されなくなります。</p></div>';
558 echo $msg;
559 }
560 }
561 }
562
563 ?>