| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
global $current_user; |
| 7 |
|
| 8 |
if( apply_filters('wpsc_allow_get_change_ticket_fields',true) ){ |
| 9 |
if (!($current_user->ID && $current_user->has_cap('wpsc_agent'))) {exit;} |
| 10 |
} |
| 11 |
|
| 12 |
$ticket_id = isset($_POST['ticket_id']) ? intval($_POST['ticket_id']) : 0 ; |
| 13 |
$wpsc_appearance_modal_window = get_option('wpsc_modal_window'); |
| 14 |
$fields = get_terms([ |
| 15 |
'taxonomy' => 'wpsc_ticket_custom_fields', |
| 16 |
'hide_empty' => false, |
| 17 |
'orderby' => 'meta_value_num', |
| 18 |
'meta_key' => 'wpsc_tf_load_order', |
| 19 |
'order' => 'ASC', |
| 20 |
'meta_query' => array( |
| 21 |
array( |
| 22 |
'key' => 'agentonly', |
| 23 |
'value' => '0', |
| 24 |
'compare' => '=' |
| 25 |
) |
| 26 |
), |
| 27 |
]); |
| 28 |
|
| 29 |
|
| 30 |
include WPSC_ABSPATH . 'includes/admin/tickets/create_ticket/class-ticket-list-format.php'; |
| 31 |
|
| 32 |
$ticket_fields = new WPSC_Ticket_List(); |
| 33 |
ob_start(); |
| 34 |
?> |
| 35 |
<form id="frm_get_ticket_fields" method="post"> |
| 36 |
<div id="wpsc_search_cf" class="row form-group col-md-4 col-xs-12" style="float:right;"> |
| 37 |
<input type="text" id="search_cf" class="form-control" placeholder="<?php _e('Search','supportcandy') ?>" name="search_cf" autocomplete="off"> |
| 38 |
</div> |
| 39 |
<div class="row" id="wpsc_edit_form_fields" style="clear:both"> |
| 40 |
|
| 41 |
<?php |
| 42 |
if($fields){ |
| 43 |
foreach ($fields as $field) { |
| 44 |
$wpsc_tf_type = get_term_meta( $field->term_id, 'wpsc_tf_type',true); |
| 45 |
if(!$wpsc_tf_type)continue; |
| 46 |
$ticket_fields->print_field($field); |
| 47 |
} |
| 48 |
} |
| 49 |
else{ |
| 50 |
_e('No Ticket Fields','supportcandy'); |
| 51 |
} |
| 52 |
?> |
| 53 |
</div> |
| 54 |
<input type="hidden" name="action" value="wpsc_tickets" /> |
| 55 |
<input type="hidden" name="setting_action" value="set_change_ticket_fields" /> |
| 56 |
<input type="hidden" name="ticket_id" value="<?php echo esc_attr($ticket_id) ?>" /> |
| 57 |
<input type="hidden" name="_ajax_nonce" value="<?php echo wp_create_nonce('set_change_ticket_fields')?>"> |
| 58 |
<script> |
| 59 |
jQuery('#search_cf').keyup(function(e) { |
| 60 |
if (e.which == 13) return; |
| 61 |
var searchText = jQuery(this).val().trim(); |
| 62 |
//console.log(searchText); |
| 63 |
jQuery('#wpsc_edit_form_fields > .wpsc_form_field').each(function(){ |
| 64 |
var name = jQuery(this).find('label').text(); |
| 65 |
var re = new RegExp(searchText, "i"); |
| 66 |
var index = name.search(re); |
| 67 |
if (index < 0) { |
| 68 |
jQuery(this).hide(); |
| 69 |
} else { |
| 70 |
jQuery(this).show(); |
| 71 |
} |
| 72 |
}) |
| 73 |
}) |
| 74 |
</script> |
| 75 |
</form> |
| 76 |
|
| 77 |
<?php |
| 78 |
$body = ob_get_clean(); |
| 79 |
ob_start(); |
| 80 |
?> |
| 81 |
<button type="button" class="btn wpsc_popup_close" style="background-color:<?php echo esc_attr($wpsc_appearance_modal_window['wpsc_close_button_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_modal_window['wpsc_close_button_text_color'])?> !important;" onclick="wpsc_modal_close();"><?php _e('Close','supportcandy');?></button> |
| 82 |
<button type="button" class="btn wpsc_popup_action" style="background-color:<?php echo esc_attr($wpsc_appearance_modal_window['wpsc_action_button_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_modal_window['wpsc_action_button_text_color'])?> !important;" onclick="wpsc_set_change_ticket_fields(<?php echo esc_attr($ticket_id) ?>);"><?php _e('Save','supportcandy');?></button> |
| 83 |
<?php |
| 84 |
$footer = ob_get_clean(); |
| 85 |
|
| 86 |
$output = array( |
| 87 |
'body' => $body, |
| 88 |
'footer' => $footer |
| 89 |
); |
| 90 |
|
| 91 |
wp_send_json($output); |
| 92 |
|