| 1 |
|
| 2 |
function wpsc_init(wpsc_setting_action,attrs){ |
| 3 |
|
| 4 |
jQuery('#wpsc_tickets_container').html(wpsc_admin.loading_html); |
| 5 |
var data = { |
| 6 |
action: 'wpsc_tickets', |
| 7 |
setting_action : wpsc_setting_action |
| 8 |
}; |
| 9 |
|
| 10 |
jQuery.each( attrs, function( key, value ) { |
| 11 |
data[key] = value; |
| 12 |
}); |
| 13 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 14 |
jQuery('#wpsc_tickets_container').html(response); |
| 15 |
}); |
| 16 |
|
| 17 |
} |
| 18 |
|
| 19 |
function wpsc_signup_user(){ |
| 20 |
|
| 21 |
jQuery('#wpsc_tickets_container').html(wpsc_admin.loading_html); |
| 22 |
//wpsc_doScrolling('#wpsc_tickets_container',1000); |
| 23 |
|
| 24 |
var data = { |
| 25 |
action: 'wpsc_tickets', |
| 26 |
setting_action : 'sign_up_user' |
| 27 |
}; |
| 28 |
|
| 29 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 30 |
jQuery('#wpsc_tickets_container').html(response); |
| 31 |
}); |
| 32 |
} |
| 33 |
|
| 34 |
function wpsc_get_ticket_list(){ |
| 35 |
var is_tinymce = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden(); |
| 36 |
if(is_tinymce){ |
| 37 |
var description = tinyMCE.activeEditor.getContent().trim(); |
| 38 |
if(description.length != 0){ |
| 39 |
if(!confirm(wpsc_admin.warning_message)) { |
| 40 |
return; |
| 41 |
} |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
jQuery('#wpsc_tickets_container').html(wpsc_admin.loading_html); |
| 46 |
|
| 47 |
var data = { |
| 48 |
action: 'wpsc_tickets', |
| 49 |
setting_action : 'ticket_list' |
| 50 |
}; |
| 51 |
|
| 52 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 53 |
jQuery('#wpsc_tickets_container').html(response); |
| 54 |
}); |
| 55 |
if (is_tinymce) { |
| 56 |
tinyMCE.activeEditor.setContent(''); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
function wpsc_get_individual_ticket(e){ |
| 61 |
|
| 62 |
var ticket_id = jQuery(e).data('id'); |
| 63 |
wpsc_open_ticket(ticket_id); |
| 64 |
|
| 65 |
} |
| 66 |
|
| 67 |
function wpsc_open_ticket(ticket_id){ |
| 68 |
jQuery('#wpsc_tickets_container').html(wpsc_admin.loading_html); |
| 69 |
//wpsc_doScrolling('#wpsc_tickets_container',1000); |
| 70 |
var data = { |
| 71 |
action: 'wpsc_tickets', |
| 72 |
setting_action : 'individual_ticket', |
| 73 |
ticket_id : ticket_id |
| 74 |
}; |
| 75 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 76 |
jQuery('#wpsc_tickets_container').html(response); |
| 77 |
}); |
| 78 |
} |
| 79 |
|
| 80 |
function wpsc_get_create_ticket(){ |
| 81 |
|
| 82 |
var wpsc_cturl = jQuery('#wpsc_ctu').val(); |
| 83 |
if(wpsc_cturl){ |
| 84 |
window.location = wpsc_cturl; |
| 85 |
return; |
| 86 |
} |
| 87 |
|
| 88 |
var is_tinymce = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden(); |
| 89 |
if (jQuery('#wpsc_individual_new_ticket_btn').is(":visible") && is_tinymce){ |
| 90 |
var description = tinyMCE.activeEditor.getContent().trim(); |
| 91 |
if(description.length != 0){ |
| 92 |
if(!confirm(wpsc_admin.warning_message)) { |
| 93 |
return; |
| 94 |
} |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
jQuery('#wpsc_tickets_container').html(wpsc_admin.loading_html); |
| 99 |
|
| 100 |
var data = { |
| 101 |
action: 'wpsc_tickets', |
| 102 |
setting_action : 'create_ticket' |
| 103 |
}; |
| 104 |
|
| 105 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 106 |
jQuery('#wpsc_tickets_container').html(response); |
| 107 |
}); |
| 108 |
|
| 109 |
if(is_tinymce) tinyMCE.activeEditor.setContent(''); |
| 110 |
} |
| 111 |
|
| 112 |
function wpsc_create_ticket_init(wpsc_setting_action,attrs){ |
| 113 |
|
| 114 |
jQuery('#wpsc_tickets_container').html(wpsc_admin.loading_html); |
| 115 |
var data = { |
| 116 |
action: 'wpsc_tickets', |
| 117 |
setting_action : wpsc_setting_action, |
| 118 |
}; |
| 119 |
|
| 120 |
jQuery.each( attrs, function( key, value ) { |
| 121 |
data[key] = value; |
| 122 |
}); |
| 123 |
|
| 124 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 125 |
jQuery('#wpsc_tickets_container').html(response); |
| 126 |
jQuery('.wpsc_tl_action_bar').hide(); |
| 127 |
jQuery('#wpsc_insert_macros').hide(); |
| 128 |
}); |
| 129 |
} |
| 130 |
|
| 131 |
function validateEmail(email) { |
| 132 |
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; |
| 133 |
return re.test(email); |
| 134 |
} |
| 135 |
|
| 136 |
function validateURL(url){ |
| 137 |
var re = /^(http[s]?:\/\/){0,1}(www\.){0,1}[a-zA-Z0-9\.\-]+\.[a-zA-Z]{2,5}[\.]{0,1}/; |
| 138 |
return re.test(url); |
| 139 |
} |
| 140 |
|
| 141 |
function attachment_cancel( obj ){ |
| 142 |
jQuery(obj).parent().remove(); |
| 143 |
} |
| 144 |
|
| 145 |
function wpsc_doScrolling(element, duration) { |
| 146 |
var startingY = window.pageYOffset; |
| 147 |
var elementY = wpsc_getElementY(element); |
| 148 |
var targetY = document.body.scrollHeight - elementY < window.innerHeight ? document.body.scrollHeight - window.innerHeight : elementY; |
| 149 |
var diff = targetY - startingY; |
| 150 |
var easing = function (t) { return t<.5 ? 4*t*t*t : (t-1)*(2*t-2)*(2*t-2)+1 } |
| 151 |
var start; |
| 152 |
if (!diff) return; |
| 153 |
window.requestAnimationFrame(function step(timestamp) { |
| 154 |
if (!start) start = timestamp; |
| 155 |
var time = timestamp - start; |
| 156 |
var percent = Math.min(time / duration, 1); |
| 157 |
percent = easing(percent); |
| 158 |
window.scrollTo(0, startingY + diff * percent); |
| 159 |
if (time < duration) { |
| 160 |
window.requestAnimationFrame(step); |
| 161 |
} |
| 162 |
}); |
| 163 |
} |
| 164 |
|
| 165 |
function wpsc_getElementY(query) { |
| 166 |
return window.pageYOffset + document.querySelector(query).getBoundingClientRect().top |
| 167 |
} |
| 168 |
|
| 169 |
function show_custom_filters(){ |
| 170 |
jQuery('.wpsp_custom_filter_container').show(); |
| 171 |
} |
| 172 |
|
| 173 |
function wpsc_close_custom_filter(){ |
| 174 |
jQuery('.wpsp_custom_filter_container').hide(); |
| 175 |
} |
| 176 |
|
| 177 |
function wpsc_get_save_ticket_filter(){ |
| 178 |
wpsc_modal_open(wpsc_admin.save_filter); |
| 179 |
var data = { |
| 180 |
action: 'wpsc_tickets', |
| 181 |
setting_action: 'get_save_ticket_filter' |
| 182 |
}; |
| 183 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 184 |
jQuery('#wpsc_popup_body').html(response.body); |
| 185 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 186 |
}); |
| 187 |
} |
| 188 |
function wpsc_set_saved_filter(key, nonce){ |
| 189 |
var data = { |
| 190 |
action: 'wpsc_tickets', |
| 191 |
setting_action : 'set_saved_filter', |
| 192 |
key: key, |
| 193 |
_ajax_nonce: nonce |
| 194 |
}; |
| 195 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 196 |
wpsc_get_ticket_list(); |
| 197 |
}); |
| 198 |
} |
| 199 |
|
| 200 |
function wpsc_delete_saved_filter(key, nonce){ |
| 201 |
if( !confirm(wpsc_admin.are_you_sure) ){ |
| 202 |
return; |
| 203 |
} |
| 204 |
var data = { |
| 205 |
action: 'wpsc_tickets', |
| 206 |
setting_action : 'delete_saved_filter', |
| 207 |
key: key, |
| 208 |
_ajax_nonce: nonce |
| 209 |
}; |
| 210 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 211 |
wpsc_get_ticket_list(); |
| 212 |
}); |
| 213 |
} |
| 214 |
|
| 215 |
function wpsc_set_default_filter(label, nonce){ |
| 216 |
jQuery('.checkbox_depend').addClass('hidden'); |
| 217 |
|
| 218 |
jQuery('.wpsp_sidebar_labels').removeClass('active'); |
| 219 |
jQuery('.wpsp_sidebar_labels.'+label).addClass('active'); |
| 220 |
jQuery('.wpsc_ticket_list_container').html(wpsc_admin.loading_html); |
| 221 |
var data = { |
| 222 |
action: 'wpsc_tickets', |
| 223 |
setting_action : 'set_default_filter', |
| 224 |
label: label, |
| 225 |
_ajax_nonce: nonce |
| 226 |
}; |
| 227 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 228 |
wpsc_get_tickets(); |
| 229 |
}); |
| 230 |
} |
| 231 |
|
| 232 |
function wpsc_get_tickets(){ |
| 233 |
var data = { |
| 234 |
action: 'wpsc_tickets', |
| 235 |
setting_action : 'get_ticket_list' |
| 236 |
}; |
| 237 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 238 |
jQuery('.wpsc_ticket_list_container').html(response); |
| 239 |
}); |
| 240 |
} |
| 241 |
|
| 242 |
function wpsc_set_custom_filter(){ |
| 243 |
var dataform = new FormData(jQuery('#frm_additional_filters')[0]); |
| 244 |
jQuery('.wpsc_ticket_list_container').html(wpsc_admin.loading_html); |
| 245 |
jQuery.ajax({ |
| 246 |
url: wpsc_admin.ajax_url, |
| 247 |
type: 'POST', |
| 248 |
data: dataform, |
| 249 |
processData: false, |
| 250 |
contentType: false |
| 251 |
}) |
| 252 |
.done(function (response_str) { |
| 253 |
wpsc_get_tickets(); |
| 254 |
//wpsc_doScrolling('#wpsc_tickets_container',1000); |
| 255 |
}); |
| 256 |
} |
| 257 |
|
| 258 |
function wpsc_header_sort(slug){ |
| 259 |
var orderby = jQuery('#wpsc_th_orderby').val().trim(); |
| 260 |
var order = jQuery('#wpsc_th_order').val().trim(); |
| 261 |
if (orderby == slug) { |
| 262 |
orderby = slug; |
| 263 |
order = (order == wpsc_admin.asc ? wpsc_admin.desc: wpsc_admin.asc); |
| 264 |
} else { |
| 265 |
orderby = slug; |
| 266 |
order = wpsc_admin.asc; |
| 267 |
} |
| 268 |
jQuery('#wpsc_th_orderby').val(orderby); |
| 269 |
jQuery('#wpsc_th_order').val(order); |
| 270 |
jQuery('#wpsc_pg_no').val('1'); |
| 271 |
wpsc_set_custom_filter(); |
| 272 |
} |
| 273 |
|
| 274 |
|
| 275 |
function toggle_list_checkboxes(obj){ |
| 276 |
if(jQuery(obj).is(':checked')){ |
| 277 |
jQuery('.chk_ticket_list_item:enabled').prop('checked',true); |
| 278 |
}else{ |
| 279 |
jQuery('.chk_ticket_list_item:enabled').prop('checked',false); |
| 280 |
} |
| 281 |
toggle_ticket_list_actions(); |
| 282 |
} |
| 283 |
|
| 284 |
function wpsc_ticket_next_page(){ |
| 285 |
var page_no = parseInt(jQuery('#wpsc_pg_no').val().trim()); |
| 286 |
if( page_no){ |
| 287 |
page_no++; |
| 288 |
jQuery('#wpsc_pg_no').val(page_no); |
| 289 |
wpsc_set_custom_filter(); |
| 290 |
} |
| 291 |
} |
| 292 |
|
| 293 |
function wpsc_ticket_prev_page(){ |
| 294 |
var page_no = parseInt(jQuery('#wpsc_pg_no').val().trim()); |
| 295 |
if( page_no > 1){ |
| 296 |
page_no--; |
| 297 |
jQuery('#wpsc_pg_no').val(page_no); |
| 298 |
wpsc_set_custom_filter(); |
| 299 |
} |
| 300 |
} |
| 301 |
|
| 302 |
function toggle_ticket_list_actions(){ |
| 303 |
|
| 304 |
var checked = jQuery('#tbl_wpsc_ticket_list').find('.chk_ticket_list_item:checked'); |
| 305 |
if(checked.length==0){ |
| 306 |
jQuery('.checkbox_depend').addClass('hidden'); |
| 307 |
} else { |
| 308 |
//jQuery('.checkbox_depend').removeClass('hidden'); |
| 309 |
var class_list=jQuery('.wpsp_sidebar_labels.active').prop('class'); |
| 310 |
var index=class_list.indexOf('deleted'); |
| 311 |
|
| 312 |
if(index!=-1){ |
| 313 |
//deleted filter active |
| 314 |
jQuery('.checkbox_depend').addClass('hidden'); |
| 315 |
jQuery('#btn_delete_permanently_bulk_ticket').removeClass('hidden'); |
| 316 |
}else{ |
| 317 |
//other filters |
| 318 |
jQuery('.checkbox_depend').removeClass('hidden'); |
| 319 |
jQuery('#btn_delete_permanently_bulk_ticket').addClass('hidden'); |
| 320 |
jQuery('#btn_restore_tickets').addClass('hidden'); |
| 321 |
} |
| 322 |
|
| 323 |
} |
| 324 |
} |
| 325 |
|
| 326 |
function show_custom_filters(){ |
| 327 |
jQuery('.wpsp_custom_filter_container').toggle('show'); |
| 328 |
} |
| 329 |
|
| 330 |
function wpsc_get_agent_setting(){ |
| 331 |
wpsc_modal_open(wpsc_admin.agent_setting); |
| 332 |
var data = { |
| 333 |
action: 'wpsc_support_agents', |
| 334 |
setting_action : 'get_agent_setting' |
| 335 |
}; |
| 336 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 337 |
jQuery('#wpsc_popup_body').html(response.body); |
| 338 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 339 |
}); |
| 340 |
} |
| 341 |
|
| 342 |
function wpsc_set_agent_setting(){ |
| 343 |
var is_tinymce = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden(); |
| 344 |
if (is_tinymce){ |
| 345 |
var agent_setting = tinyMCE.get('wpsc_agent_signature').getContent().trim(); |
| 346 |
}else{ |
| 347 |
var agent_setting = jQuery('#wpsc_agent_signature').val(); |
| 348 |
} |
| 349 |
var dataform = new FormData(jQuery('#wpsc_frm_agent_setting')[0]); |
| 350 |
dataform.append('wpsc_agent_signature', agent_setting); |
| 351 |
dataform.append('action', 'wpsc_support_agents'); |
| 352 |
dataform.append('setting_action', 'set_agent_setting'); |
| 353 |
wpsc_modal_close(); |
| 354 |
jQuery('.wpsc_ticket_list_container').html(wpsc_admin.loading_html); |
| 355 |
jQuery.ajax({ |
| 356 |
url: wpsc_admin.ajax_url, |
| 357 |
type: 'POST', |
| 358 |
data: dataform, |
| 359 |
processData: false, |
| 360 |
contentType: false |
| 361 |
}) |
| 362 |
.done(function (response_str) { |
| 363 |
wpsc_get_ticket_list(); |
| 364 |
}); |
| 365 |
if (is_tinymce) { |
| 366 |
tinyMCE.activeEditor.setContent(''); |
| 367 |
} |
| 368 |
} |
| 369 |
|
| 370 |
function wpsc_get_bulk_change_status(){ |
| 371 |
wpsc_modal_open(wpsc_admin.change_ticket_status); |
| 372 |
var checked = jQuery('#tbl_wpsc_ticket_list').find('.chk_ticket_list_item:checked'); |
| 373 |
if(checked.length!=0){ |
| 374 |
var values = jQuery('.chk_ticket_list_item:checked').map(function(){return this.value;}).get(); |
| 375 |
var ticket_id = String(values); |
| 376 |
var data = { |
| 377 |
action: 'wpsc_tickets', |
| 378 |
setting_action : 'get_bulk_change_status', |
| 379 |
ticket_id: ticket_id |
| 380 |
} |
| 381 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 382 |
jQuery('#wpsc_popup_body').html(response.body); |
| 383 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 384 |
}); |
| 385 |
} |
| 386 |
} |
| 387 |
|
| 388 |
function wpsc_set_bulk_change_status(){ |
| 389 |
var dataform = new FormData(jQuery('#frm_ticket_change_status')[0]); |
| 390 |
wpsc_modal_close(); |
| 391 |
jQuery('.wpsc_ticket_list_container').html(wpsc_admin.loading_html); |
| 392 |
jQuery.ajax({ |
| 393 |
url: wpsc_admin.ajax_url, |
| 394 |
type: 'POST', |
| 395 |
data: dataform, |
| 396 |
processData: false, |
| 397 |
contentType: false |
| 398 |
}) |
| 399 |
.done(function (response_str) { |
| 400 |
toggle_ticket_list_actions(); |
| 401 |
wpsc_get_tickets(); |
| 402 |
}); |
| 403 |
} |
| 404 |
|
| 405 |
function wpsc_get_delete_bulk_ticket(){ |
| 406 |
wpsc_modal_open(wpsc_admin.delete_tickets); |
| 407 |
var checked = jQuery('#tbl_wpsc_ticket_list').find('.chk_ticket_list_item:checked'); |
| 408 |
if(checked.length!=0){ |
| 409 |
var values = jQuery('.chk_ticket_list_item:checked').map(function () { |
| 410 |
return this.value; |
| 411 |
}).get(); |
| 412 |
|
| 413 |
var ticket_id=String(values); |
| 414 |
|
| 415 |
var data = { |
| 416 |
action: 'wpsc_tickets', |
| 417 |
setting_action : 'get_delete_bulk_ticket', |
| 418 |
ticket_id: ticket_id |
| 419 |
} |
| 420 |
|
| 421 |
jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { |
| 422 |
var response = JSON.parse(response_str); |
| 423 |
jQuery('#wpsc_popup_body').html(response.body); |
| 424 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 425 |
}); |
| 426 |
} |
| 427 |
} |
| 428 |
|
| 429 |
function wpsc_get_bulk_assign_agent(){ |
| 430 |
wpsc_modal_open(wpsc_admin.assign_agent); |
| 431 |
var checked = jQuery('#tbl_wpsc_ticket_list').find('.chk_ticket_list_item:checked'); |
| 432 |
|
| 433 |
if(checked.length!=0){ |
| 434 |
var values = jQuery('.chk_ticket_list_item:checked').map(function () { |
| 435 |
return this.value; |
| 436 |
}).get(); |
| 437 |
|
| 438 |
var ticket_id=String(values); |
| 439 |
|
| 440 |
var data = { |
| 441 |
action: 'wpsc_tickets', |
| 442 |
setting_action : 'get_bulk_assign_agent', |
| 443 |
ticket_id: ticket_id |
| 444 |
} |
| 445 |
|
| 446 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 447 |
jQuery('#wpsc_popup_body').html(response.body); |
| 448 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 449 |
}); |
| 450 |
} |
| 451 |
} |
| 452 |
|
| 453 |
function wpsc_set_delete_bulk_ticket(){ |
| 454 |
var dataform = new FormData(jQuery('#frm_delete_bulk_ticket')[0]); |
| 455 |
wpsc_modal_close(); |
| 456 |
jQuery('.wpsc_ticket_list_container').html(wpsc_admin.loading_html); |
| 457 |
jQuery.ajax({ |
| 458 |
url: wpsc_admin.ajax_url, |
| 459 |
type: 'POST', |
| 460 |
data: dataform, |
| 461 |
processData: false, |
| 462 |
contentType: false |
| 463 |
}) |
| 464 |
.done(function (response_str) { |
| 465 |
toggle_ticket_list_actions(); |
| 466 |
wpsc_get_tickets(); |
| 467 |
}); |
| 468 |
} |
| 469 |
|
| 470 |
function wpsc_set_bulk_assign_agent(){ |
| 471 |
var dataform = new FormData(jQuery('#frm_bulk_assigned_agents')[0]); |
| 472 |
wpsc_modal_close(); |
| 473 |
jQuery('.wpsc_ticket_list_container').html(wpsc_admin.loading_html); |
| 474 |
jQuery.ajax({ |
| 475 |
url: wpsc_admin.ajax_url, |
| 476 |
type: 'POST', |
| 477 |
data: dataform, |
| 478 |
processData: false, |
| 479 |
contentType: false |
| 480 |
}) |
| 481 |
.done(function (response_str) { |
| 482 |
toggle_ticket_list_actions(); |
| 483 |
wpsc_get_tickets(); |
| 484 |
}); |
| 485 |
|
| 486 |
} |
| 487 |
|
| 488 |
function wpsc_ticket_thread_expander_toggle(obj){ |
| 489 |
var height = parseInt(jQuery(obj).parent().find('.thread_messege').height()); |
| 490 |
if( height === 100 ){ |
| 491 |
jQuery(obj).parent().find('.thread_messege').height('auto'); |
| 492 |
jQuery(obj).text(wpsc_admin.view_less); |
| 493 |
} else { |
| 494 |
jQuery(obj).parent().find('.thread_messege').height(100); |
| 495 |
jQuery(obj).text(wpsc_admin.view_more); |
| 496 |
} |
| 497 |
} |
| 498 |
|
| 499 |
function wpsc_get_change_ticket_status(ticket_id){ |
| 500 |
wpsc_modal_open(wpsc_admin.change_ticket_status); |
| 501 |
var data = { |
| 502 |
action: 'wpsc_tickets', |
| 503 |
setting_action : 'get_change_ticket_status', |
| 504 |
ticket_id: ticket_id |
| 505 |
} |
| 506 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 507 |
jQuery('#wpsc_popup_body').html(response.body); |
| 508 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 509 |
}); |
| 510 |
} |
| 511 |
|
| 512 |
function wpsc_get_change_ticket_fields(ticket_id){ |
| 513 |
wpsc_modal_open(wpsc_admin.change_ticket_fields); |
| 514 |
var data = { |
| 515 |
action: 'wpsc_tickets', |
| 516 |
setting_action : 'get_change_ticket_fields', |
| 517 |
ticket_id: ticket_id |
| 518 |
} |
| 519 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 520 |
jQuery('#wpsc_popup_body').html(response.body); |
| 521 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 522 |
}); |
| 523 |
} |
| 524 |
|
| 525 |
function wpsc_set_change_ticket_status(ticket_id){ |
| 526 |
|
| 527 |
if (wpsc_check_desc_empty()) { |
| 528 |
if(!confirm(wpsc_admin.warning_message)) { |
| 529 |
wpsc_modal_close(); |
| 530 |
return; |
| 531 |
} |
| 532 |
} |
| 533 |
var dataform = new FormData(jQuery('#frm_get_ticket_change_status')[0]); |
| 534 |
wpsc_modal_close(); |
| 535 |
jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html); |
| 536 |
jQuery.ajax({ |
| 537 |
url: wpsc_admin.ajax_url, |
| 538 |
type: 'POST', |
| 539 |
data: dataform, |
| 540 |
processData: false, |
| 541 |
contentType: false |
| 542 |
}) |
| 543 |
.done(function (response_str) { |
| 544 |
wpsc_open_ticket(ticket_id); |
| 545 |
}); |
| 546 |
|
| 547 |
} |
| 548 |
|
| 549 |
function wpsc_get_change_assign_agent(ticket_id){ |
| 550 |
wpsc_modal_open(wpsc_admin.assign_agent); |
| 551 |
var data = { |
| 552 |
action: 'wpsc_tickets', |
| 553 |
setting_action : 'get_change_assign_agent', |
| 554 |
ticket_id: ticket_id |
| 555 |
} |
| 556 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 557 |
jQuery('#wpsc_popup_body').html(response.body); |
| 558 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 559 |
}); |
| 560 |
} |
| 561 |
|
| 562 |
function wpsc_get_delete_ticket(ticket_id){ |
| 563 |
wpsc_modal_open(wpsc_admin.delete_ticket); |
| 564 |
var data = { |
| 565 |
action: 'wpsc_tickets', |
| 566 |
setting_action : 'get_delete_ticket', |
| 567 |
ticket_id: ticket_id |
| 568 |
} |
| 569 |
jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { |
| 570 |
var response = JSON.parse(response_str); |
| 571 |
jQuery('#wpsc_popup_body').html(response.body); |
| 572 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 573 |
}); |
| 574 |
} |
| 575 |
|
| 576 |
function wpsc_set_change_assign_agent(ticket_id){ |
| 577 |
|
| 578 |
if (wpsc_check_desc_empty()) { |
| 579 |
if(!confirm(wpsc_admin.warning_message)) { |
| 580 |
wpsc_modal_close(); |
| 581 |
return; |
| 582 |
} |
| 583 |
} |
| 584 |
|
| 585 |
var dataform = new FormData(jQuery('#frm_get_ticket_assign_agent')[0]); |
| 586 |
wpsc_modal_close(); |
| 587 |
jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html); |
| 588 |
jQuery.ajax({ |
| 589 |
url: wpsc_admin.ajax_url, |
| 590 |
type: 'POST', |
| 591 |
data: dataform, |
| 592 |
processData: false, |
| 593 |
contentType: false |
| 594 |
}) |
| 595 |
.done(function (response_str) { |
| 596 |
wpsc_open_ticket(ticket_id); |
| 597 |
}); |
| 598 |
} |
| 599 |
|
| 600 |
function wpsc_get_edit_thread(ticket_id,thread_id){ |
| 601 |
|
| 602 |
wpsc_modal_open(wpsc_admin.edit_this_thread); |
| 603 |
var data = { |
| 604 |
action: 'wpsc_tickets', |
| 605 |
setting_action : 'get_edit_thread', |
| 606 |
ticket_id: ticket_id, |
| 607 |
thread_id : thread_id |
| 608 |
} |
| 609 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 610 |
jQuery('#wpsc_popup_body').html(response.body); |
| 611 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 612 |
}); |
| 613 |
} |
| 614 |
|
| 615 |
function wpsc_get_close_ticket(ticket_id){ |
| 616 |
wpsc_modal_open(wpsc_admin.close_ticket); |
| 617 |
var data = { |
| 618 |
action: 'wpsc_tickets', |
| 619 |
setting_action : 'get_close_ticket', |
| 620 |
ticket_id: ticket_id |
| 621 |
} |
| 622 |
jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { |
| 623 |
var response = JSON.parse(response_str); |
| 624 |
jQuery('#wpsc_popup_body').html(response.body); |
| 625 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 626 |
}); |
| 627 |
} |
| 628 |
|
| 629 |
function wpsc_get_clone_ticket(ticket_id){ |
| 630 |
wpsc_modal_open(wpsc_admin.clone_ticket); |
| 631 |
var data = { |
| 632 |
action: 'wpsc_tickets', |
| 633 |
setting_action : 'get_clone_ticket', |
| 634 |
ticket_id: ticket_id |
| 635 |
} |
| 636 |
jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { |
| 637 |
var response = JSON.parse(response_str); |
| 638 |
jQuery('#wpsc_popup_body').html(response.body); |
| 639 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 640 |
}); |
| 641 |
} |
| 642 |
|
| 643 |
function wpsc_set_edit_thread(ticket_id){ |
| 644 |
|
| 645 |
var is_tinymce = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden(); |
| 646 |
if(is_tinymce){ |
| 647 |
var description = tinyMCE.get('wpsc_therad_edit').getContent().trim(); |
| 648 |
}else{ |
| 649 |
var description = jQuery('#wpsc_therad_edit').val(); |
| 650 |
} |
| 651 |
var dataform = new FormData(jQuery('#frm_edit_thread')[0]); |
| 652 |
dataform.append('body', description); |
| 653 |
dataform.append('action', 'wpsc_tickets'); |
| 654 |
dataform.append('setting_action', 'set_edit_thread'); |
| 655 |
wpsc_modal_close(); |
| 656 |
jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html); |
| 657 |
jQuery.ajax({ |
| 658 |
url: wpsc_admin.ajax_url, |
| 659 |
type: 'POST', |
| 660 |
data: dataform, |
| 661 |
processData: false, |
| 662 |
contentType: false |
| 663 |
}) |
| 664 |
.done(function (response_str) { |
| 665 |
wpsc_open_ticket(ticket_id); |
| 666 |
}); |
| 667 |
} |
| 668 |
|
| 669 |
function wpsc_get_delete_thread(ticket_id,thread_id){ |
| 670 |
|
| 671 |
wpsc_modal_open(wpsc_admin.delete_this_thread); |
| 672 |
var data = { |
| 673 |
action: 'wpsc_tickets', |
| 674 |
setting_action : 'get_delete_thread', |
| 675 |
ticket_id: ticket_id, |
| 676 |
thread_id : thread_id |
| 677 |
} |
| 678 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 679 |
jQuery('#wpsc_popup_body').html(response.body); |
| 680 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 681 |
}); |
| 682 |
} |
| 683 |
|
| 684 |
function wpsc_edit_ticket_subject(ticket_id){ |
| 685 |
wpsc_modal_open(wpsc_admin.edit_subject); |
| 686 |
var data = { |
| 687 |
action: 'wpsc_tickets', |
| 688 |
setting_action : 'get_edit_ticket_subject', |
| 689 |
ticket_id: ticket_id |
| 690 |
} |
| 691 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 692 |
jQuery('#wpsc_popup_body').html(response.body); |
| 693 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 694 |
}); |
| 695 |
} |
| 696 |
|
| 697 |
function wpsc_set_delete_thread(ticket_id){ |
| 698 |
var dataform = new FormData(jQuery('#frm_delete_thread')[0]); |
| 699 |
wpsc_modal_close(); |
| 700 |
jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html); |
| 701 |
jQuery.ajax({ |
| 702 |
url: wpsc_admin.ajax_url, |
| 703 |
type: 'POST', |
| 704 |
data: dataform, |
| 705 |
processData: false, |
| 706 |
contentType: false |
| 707 |
}) |
| 708 |
.done(function (response_str) { |
| 709 |
wpsc_open_ticket(ticket_id); |
| 710 |
}); |
| 711 |
} |
| 712 |
|
| 713 |
function wpsc_set_edit_ticket_subject(ticket_id){ |
| 714 |
var dataform = new FormData(jQuery('#frm_edit_subject')[0]); |
| 715 |
var subject = jQuery('#subject').val(); |
| 716 |
jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html); |
| 717 |
wpsc_modal_close(); |
| 718 |
jQuery.ajax({ |
| 719 |
url: wpsc_admin.ajax_url, |
| 720 |
type: 'POST', |
| 721 |
data: dataform, |
| 722 |
processData: false, |
| 723 |
contentType: false |
| 724 |
}) |
| 725 |
.done(function (response_str) { |
| 726 |
wpsc_open_ticket(ticket_id); |
| 727 |
}); |
| 728 |
} |
| 729 |
|
| 730 |
function wpsc_set_clone_ticket(){ |
| 731 |
|
| 732 |
if (wpsc_check_desc_empty()) { |
| 733 |
if(!confirm(wpsc_admin.warning_message)) { |
| 734 |
wpsc_modal_close(); |
| 735 |
return; |
| 736 |
} |
| 737 |
} |
| 738 |
var dataform = new FormData(jQuery('#frm_edit_clone_subject')[0]); |
| 739 |
var subject = jQuery('#subject').val(); |
| 740 |
jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html); |
| 741 |
wpsc_modal_close(); |
| 742 |
jQuery.ajax({ |
| 743 |
url: wpsc_admin.ajax_url, |
| 744 |
type: 'POST', |
| 745 |
data: dataform, |
| 746 |
processData: false, |
| 747 |
contentType: false |
| 748 |
}) |
| 749 |
.done(function (response_str) { |
| 750 |
|
| 751 |
ticket_id = JSON.parse(response_str); |
| 752 |
wpsc_open_ticket(ticket_id); |
| 753 |
}); |
| 754 |
} |
| 755 |
|
| 756 |
function wpsc_set_delete_ticket(){ |
| 757 |
|
| 758 |
if (wpsc_check_desc_empty()) { |
| 759 |
if(!confirm(wpsc_admin.warning_message)) { |
| 760 |
wpsc_modal_close(); |
| 761 |
return; |
| 762 |
} |
| 763 |
} |
| 764 |
var dataform = new FormData(jQuery('#frm_delete_ticket')[0]); |
| 765 |
wpsc_modal_close(); |
| 766 |
jQuery.ajax({ |
| 767 |
url: wpsc_admin.ajax_url, |
| 768 |
type: 'POST', |
| 769 |
data: dataform, |
| 770 |
processData: false, |
| 771 |
contentType: false |
| 772 |
}) |
| 773 |
.done(function (response_str) { |
| 774 |
wpsc_get_ticket_list(); |
| 775 |
}); |
| 776 |
} |
| 777 |
|
| 778 |
function wpsc_get_change_raised_by(ticket_id){ |
| 779 |
wpsc_modal_open(wpsc_admin.change_raised_by); |
| 780 |
var data = { |
| 781 |
action: 'wpsc_tickets', |
| 782 |
setting_action : 'get_change_raised_by', |
| 783 |
ticket_id: ticket_id |
| 784 |
} |
| 785 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 786 |
jQuery('#wpsc_popup_body').html(response.body); |
| 787 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 788 |
}) |
| 789 |
} |
| 790 |
|
| 791 |
function wpsc_set_change_raised_by(ticket_id){ |
| 792 |
|
| 793 |
if (wpsc_check_desc_empty()) { |
| 794 |
if(!confirm(wpsc_admin.warning_message)) { |
| 795 |
wpsc_modal_close(); |
| 796 |
return; |
| 797 |
} |
| 798 |
} |
| 799 |
var dataform = new FormData(jQuery('#frm_get_ticket_raised_by')[0]); |
| 800 |
if(jQuery('#customer_name').val().trim()==''){ |
| 801 |
alert(wpsc_admin.customer_name); |
| 802 |
return; |
| 803 |
} |
| 804 |
|
| 805 |
if(jQuery('#customer_email').val().trim()==''){ |
| 806 |
alert(wpsc_admin.customer_email); |
| 807 |
return; |
| 808 |
} |
| 809 |
wpsc_modal_close(); |
| 810 |
jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html); |
| 811 |
jQuery.ajax({ |
| 812 |
url: wpsc_admin.ajax_url, |
| 813 |
type: 'POST', |
| 814 |
data: dataform, |
| 815 |
processData: false, |
| 816 |
contentType: false |
| 817 |
}) |
| 818 |
.done(function (response_str) { |
| 819 |
wpsc_open_ticket(ticket_id); |
| 820 |
}); |
| 821 |
} |
| 822 |
|
| 823 |
function wpsc_get_restore_bulk_ticket(){ |
| 824 |
wpsc_modal_open(wpsc_admin.restore_deleted_tickets); |
| 825 |
var checked = jQuery('#tbl_wpsc_ticket_list').find('.chk_ticket_list_item:checked'); |
| 826 |
if(checked.length!=0){ |
| 827 |
var values = jQuery('.chk_ticket_list_item:checked').map(function () { |
| 828 |
return this.value; |
| 829 |
}).get(); |
| 830 |
|
| 831 |
var ticket_id=String(values); |
| 832 |
|
| 833 |
var data = { |
| 834 |
action: 'wpsc_tickets', |
| 835 |
setting_action : 'get_bulk_restore_ticket', |
| 836 |
ticket_id: ticket_id |
| 837 |
} |
| 838 |
|
| 839 |
jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { |
| 840 |
var response = JSON.parse(response_str); |
| 841 |
jQuery('#wpsc_popup_body').html(response.body); |
| 842 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 843 |
}); |
| 844 |
} |
| 845 |
} |
| 846 |
|
| 847 |
function wpsc_set_bulk_restore_ticket(){ |
| 848 |
var dataform = new FormData(jQuery('#frm_bulk_restore_ticket')[0]); |
| 849 |
wpsc_modal_close(); |
| 850 |
jQuery('.wpsc_ticket_list_container').html(wpsc_admin.loading_html); |
| 851 |
jQuery.ajax({ |
| 852 |
url: wpsc_admin.ajax_url, |
| 853 |
type: 'POST', |
| 854 |
data: dataform, |
| 855 |
processData: false, |
| 856 |
contentType: false |
| 857 |
}) |
| 858 |
.done(function (response_str) { |
| 859 |
toggle_ticket_list_actions(); |
| 860 |
wpsc_get_tickets(); |
| 861 |
}); |
| 862 |
|
| 863 |
} |
| 864 |
|
| 865 |
function get_restore_ticket(ticket_id){ |
| 866 |
wpsc_modal_open(wpsc_admin.restore_ticket); |
| 867 |
var data = { |
| 868 |
action: 'wpsc_tickets', |
| 869 |
setting_action : 'get_restore_ticket', |
| 870 |
ticket_id: ticket_id |
| 871 |
} |
| 872 |
jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { |
| 873 |
var response = JSON.parse(response_str); |
| 874 |
jQuery('#wpsc_popup_body').html(response.body); |
| 875 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 876 |
}); |
| 877 |
} |
| 878 |
|
| 879 |
function wpsc_set_restore_ticket(ticket_id){ |
| 880 |
var dataform = new FormData(jQuery('#frm_restore_ticket')[0]); |
| 881 |
jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html); |
| 882 |
wpsc_modal_close(); |
| 883 |
jQuery.ajax({ |
| 884 |
url: wpsc_admin.ajax_url, |
| 885 |
type: 'POST', |
| 886 |
data: dataform, |
| 887 |
processData: false, |
| 888 |
contentType: false |
| 889 |
}) |
| 890 |
.done(function (response_str) { |
| 891 |
wpsc_open_ticket(ticket_id); |
| 892 |
}); |
| 893 |
} |
| 894 |
|
| 895 |
function wpsc_set_change_ticket_fields(ticket_id){ |
| 896 |
|
| 897 |
if (wpsc_check_desc_empty()) { |
| 898 |
if(!confirm(wpsc_admin.warning_message)) { |
| 899 |
wpsc_modal_close(); |
| 900 |
return; |
| 901 |
} |
| 902 |
} |
| 903 |
var dataform = new FormData(jQuery('#frm_get_ticket_fields')[0]); |
| 904 |
wpsc_modal_close(); |
| 905 |
jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html); |
| 906 |
jQuery.ajax({ |
| 907 |
url: wpsc_admin.ajax_url, |
| 908 |
type: 'POST', |
| 909 |
data: dataform, |
| 910 |
processData: false, |
| 911 |
contentType: false |
| 912 |
}) |
| 913 |
.done(function (response_str) { |
| 914 |
wpsc_open_ticket(ticket_id); |
| 915 |
}); |
| 916 |
} |
| 917 |
|
| 918 |
function wpsc_delete_attached_files(attachment_id,ticket_id,attachment_slug,nonce){ |
| 919 |
var flag = confirm(wpsc_admin.are_you_sure); |
| 920 |
if (flag) { |
| 921 |
var data = { |
| 922 |
action: 'wpsc_tickets', |
| 923 |
setting_action: 'set_delete_attached_files', |
| 924 |
attachment_id: attachment_id, |
| 925 |
ticket_id: ticket_id, |
| 926 |
attachment_slug: attachment_slug, |
| 927 |
_ajax_nonce: nonce |
| 928 |
} |
| 929 |
jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { |
| 930 |
jQuery('#attach_'+attachment_id).remove(); |
| 931 |
if( jQuery('#frm_get_ticket_fields').is(':visible') && jQuery('#frm_get_ticket_fields .wpsc_attachment_tbl input:hidden[name="'+attachment_slug+'[]"]').length==0){ |
| 932 |
jQuery('#frm_get_ticket_fields .wpsc_attachment_tbl').append('<input type="hidden" name="'+attachment_slug+'" value="">'); |
| 933 |
}else if(jQuery('#frm_get_agent_fields').is(':visible') && jQuery('#frm_get_agent_fields .wpsc_attachment_tbl input:hidden[name="'+attachment_slug+'[]"]').length==0){ |
| 934 |
jQuery('#frm_get_agent_fields .wpsc_attachment_tbl').append('<input type="hidden" name="'+attachment_slug+'" value="">'); |
| 935 |
} |
| 936 |
}); |
| 937 |
} |
| 938 |
} |
| 939 |
function wpsc_get_change_agent_fields(ticket_id){ |
| 940 |
wpsc_modal_open(wpsc_admin.change_agent_fields); |
| 941 |
var data = { |
| 942 |
action: 'wpsc_tickets', |
| 943 |
setting_action : 'get_change_agent_fields', |
| 944 |
ticket_id: ticket_id |
| 945 |
} |
| 946 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 947 |
jQuery('#wpsc_popup_body').html(response.body); |
| 948 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 949 |
}); |
| 950 |
} |
| 951 |
|
| 952 |
function wpsc_set_change_agent_fields(ticket_id){ |
| 953 |
|
| 954 |
if (wpsc_check_desc_empty()) { |
| 955 |
if(!confirm(wpsc_admin.warning_message)) { |
| 956 |
wpsc_modal_close(); |
| 957 |
return; |
| 958 |
} |
| 959 |
} |
| 960 |
var dataform = new FormData(jQuery('#frm_get_agent_fields')[0]); |
| 961 |
wpsc_modal_close(); |
| 962 |
jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html); |
| 963 |
jQuery.ajax({ |
| 964 |
url: wpsc_admin.ajax_url, |
| 965 |
type: 'POST', |
| 966 |
data: dataform, |
| 967 |
processData: false, |
| 968 |
contentType: false |
| 969 |
}) |
| 970 |
.done(function (response_str) { |
| 971 |
wpsc_open_ticket(ticket_id); |
| 972 |
}); |
| 973 |
} |
| 974 |
|
| 975 |
function wpsc_signup_user(){ |
| 976 |
jQuery('#wpsc_tickets_container').html(wpsc_admin.loading_html); |
| 977 |
|
| 978 |
var data = { |
| 979 |
action: 'wpsc_tickets', |
| 980 |
setting_action : 'sign_up_user' |
| 981 |
}; |
| 982 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 983 |
jQuery('#wpsc_tickets_container').html(response); |
| 984 |
}); |
| 985 |
} |
| 986 |
|
| 987 |
function wpsc_delete_ticket_permanently(ticket_id){ |
| 988 |
wpsc_modal_open(wpsc_admin.delete_ticket_permanently); |
| 989 |
var data = { |
| 990 |
action: 'wpsc_tickets', |
| 991 |
setting_action : 'get_delete_ticket_permanently', |
| 992 |
ticket_id: ticket_id |
| 993 |
} |
| 994 |
jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { |
| 995 |
var response = JSON.parse(response_str); |
| 996 |
jQuery('#wpsc_popup_body').html(response.body); |
| 997 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 998 |
}); |
| 999 |
} |
| 1000 |
|
| 1001 |
function wpsc_set_delete_ticket_permanently(){ |
| 1002 |
var dataform = new FormData(jQuery('#frm_delete_ticket')[0]); |
| 1003 |
jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html); |
| 1004 |
wpsc_modal_close(); |
| 1005 |
jQuery.ajax({ |
| 1006 |
url: wpsc_admin.ajax_url, |
| 1007 |
type: 'POST', |
| 1008 |
data: dataform, |
| 1009 |
processData: false, |
| 1010 |
contentType: false |
| 1011 |
}) |
| 1012 |
.done(function (response_str) { |
| 1013 |
wpsc_get_ticket_list(); |
| 1014 |
}); |
| 1015 |
} |
| 1016 |
|
| 1017 |
function wpsc_get_delete_permanently_bulk_ticket(){ |
| 1018 |
wpsc_modal_open(wpsc_admin.delete_tickets_permanently); |
| 1019 |
var checked = jQuery('#tbl_wpsc_ticket_list').find('.chk_ticket_list_item:checked'); |
| 1020 |
if(checked.length!=0){ |
| 1021 |
var values = jQuery('.chk_ticket_list_item:checked').map(function () { |
| 1022 |
return this.value; |
| 1023 |
}).get(); |
| 1024 |
|
| 1025 |
var ticket_id =String(values); |
| 1026 |
|
| 1027 |
var data = { |
| 1028 |
action: 'wpsc_tickets', |
| 1029 |
setting_action : 'get_delete_permanently_bulk_ticket', |
| 1030 |
ticket_id: ticket_id |
| 1031 |
} |
| 1032 |
|
| 1033 |
jQuery.post(wpsc_admin.ajax_url, data, function(response_str) { |
| 1034 |
var response = JSON.parse(response_str); |
| 1035 |
jQuery('#wpsc_popup_body').html(response.body); |
| 1036 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 1037 |
}); |
| 1038 |
} |
| 1039 |
} |
| 1040 |
|
| 1041 |
function wpsc_set_delete_permanently_bulk_ticket(){ |
| 1042 |
var dataform = new FormData(jQuery('#frm_bulk_delete_ticket')[0]); |
| 1043 |
wpsc_modal_close(); |
| 1044 |
jQuery('.wpsc_ticket_list_container').html(wpsc_admin.loading_html); |
| 1045 |
jQuery.ajax({ |
| 1046 |
url: wpsc_admin.ajax_url, |
| 1047 |
type: 'POST', |
| 1048 |
data: dataform, |
| 1049 |
processData: false, |
| 1050 |
contentType: false |
| 1051 |
}) |
| 1052 |
.done(function (response_str) { |
| 1053 |
toggle_ticket_list_actions(); |
| 1054 |
wpsc_get_ticket_list(); |
| 1055 |
}); |
| 1056 |
|
| 1057 |
} |
| 1058 |
|
| 1059 |
function wpsc_get_create_thread(ticket_id,thread_id){ |
| 1060 |
|
| 1061 |
wpsc_modal_open(wpsc_admin.create_thread_ticket); |
| 1062 |
var data = { |
| 1063 |
action: 'wpsc_tickets', |
| 1064 |
setting_action : 'get_create_thread', |
| 1065 |
ticket_id: ticket_id, |
| 1066 |
thread_id : thread_id |
| 1067 |
} |
| 1068 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 1069 |
jQuery('#wpsc_popup_body').html(response.body); |
| 1070 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 1071 |
}); |
| 1072 |
} |
| 1073 |
|
| 1074 |
/** |
| 1075 |
* wpsc_set_new_ticket_thread |
| 1076 |
*/ |
| 1077 |
function wpsc_set_new_ticket_thread(){ |
| 1078 |
|
| 1079 |
var dataform = new FormData(jQuery('#create_ticket_thread')[0]); |
| 1080 |
var subject = jQuery('#subject').val(); |
| 1081 |
jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html); |
| 1082 |
wpsc_modal_close(); |
| 1083 |
jQuery.ajax({ |
| 1084 |
url: wpsc_admin.ajax_url, |
| 1085 |
type: 'POST', |
| 1086 |
data: dataform, |
| 1087 |
processData: false, |
| 1088 |
contentType: false |
| 1089 |
}) |
| 1090 |
.done(function (response_str) { |
| 1091 |
ticket_id = JSON.parse(response_str); |
| 1092 |
wpsc_open_ticket(ticket_id); |
| 1093 |
}); |
| 1094 |
} |
| 1095 |
|
| 1096 |
function wpsc_get_tinymce(selector,body_id){ |
| 1097 |
jQuery('#visual').addClass('btn btn-primary'); |
| 1098 |
jQuery('#text').removeClass('btn btn-primary'); |
| 1099 |
jQuery('#text').addClass('btn btn-default'); |
| 1100 |
tinymce.init({ |
| 1101 |
selector:'#'+selector, |
| 1102 |
body_id: body_id, |
| 1103 |
menubar: false, |
| 1104 |
statusbar: false, |
| 1105 |
height : '200', |
| 1106 |
plugins: [ |
| 1107 |
'lists link image directionality' |
| 1108 |
], |
| 1109 |
image_advtab: true, |
| 1110 |
toolbar: 'bold italic underline blockquote | alignleft aligncenter alignright | bullist numlist | rtl | link image', |
| 1111 |
branding: false, |
| 1112 |
autoresize_bottom_margin: 20, |
| 1113 |
browser_spellcheck : true, |
| 1114 |
relative_urls : false, |
| 1115 |
remove_script_host : false, |
| 1116 |
convert_urls : true, |
| 1117 |
setup: function (editor) { |
| 1118 |
} |
| 1119 |
}); |
| 1120 |
} |
| 1121 |
|
| 1122 |
function wpsc_get_textarea(){ |
| 1123 |
jQuery('#visual').removeClass('btn btn-primary'); |
| 1124 |
jQuery('#visual').addClass('btn btn-default'); |
| 1125 |
jQuery('#text').addClass('btn btn-primary'); |
| 1126 |
tinymce.remove(); |
| 1127 |
} |
| 1128 |
|
| 1129 |
function wpsc_get_add_ticket_users(ticket_id){ |
| 1130 |
wpsc_modal_open(wpsc_admin.additional_recipients); |
| 1131 |
var data = { |
| 1132 |
action: 'wpsc_tickets', |
| 1133 |
setting_action : 'get_add_ticket_users', |
| 1134 |
ticket_id: ticket_id |
| 1135 |
} |
| 1136 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 1137 |
jQuery('#wpsc_popup_body').html(response.body); |
| 1138 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 1139 |
}) |
| 1140 |
} |
| 1141 |
|
| 1142 |
function wpsc_set_add_ticket_users(ticket_id){ |
| 1143 |
|
| 1144 |
if (wpsc_check_desc_empty()) { |
| 1145 |
if(!confirm(wpsc_admin.warning_message)) { |
| 1146 |
wpsc_modal_close(); |
| 1147 |
return; |
| 1148 |
} |
| 1149 |
} |
| 1150 |
|
| 1151 |
validation = true; |
| 1152 |
var email = jQuery('textarea:input[name=wpsc_ticket_et_user]').val().trim(); |
| 1153 |
if (email) { |
| 1154 |
var lines = email.split("\n"); |
| 1155 |
|
| 1156 |
for (var i = 0; i < lines.length; i++) { |
| 1157 |
if (!validateEmail(lines[i])) { |
| 1158 |
validation = false; |
| 1159 |
} |
| 1160 |
} |
| 1161 |
|
| 1162 |
if (!validation) { |
| 1163 |
alert(wpsc_admin.validate_email); |
| 1164 |
return false; |
| 1165 |
} |
| 1166 |
} |
| 1167 |
|
| 1168 |
var dataform = new FormData(jQuery('#frm_get_add_ticket_users')[0]); |
| 1169 |
wpsc_modal_close(); |
| 1170 |
jQuery('.wpsc_reply_widget').html(wpsc_admin.loading_html); |
| 1171 |
jQuery.ajax({ |
| 1172 |
url: wpsc_admin.ajax_url, |
| 1173 |
type: 'POST', |
| 1174 |
data: dataform, |
| 1175 |
processData: false, |
| 1176 |
contentType: false |
| 1177 |
}) |
| 1178 |
.done(function (response_str) { |
| 1179 |
wpsc_open_ticket(ticket_id); |
| 1180 |
}); |
| 1181 |
} |
| 1182 |
|
| 1183 |
function wpsc_get_thread_info(ticket_id,thread_id,source){ |
| 1184 |
|
| 1185 |
if(source == 'thread'){ |
| 1186 |
wpsc_modal_open(wpsc_admin.extra_thread_info); |
| 1187 |
}else { |
| 1188 |
wpsc_modal_open(wpsc_admin.extra_ticket_info); |
| 1189 |
} |
| 1190 |
var data = { |
| 1191 |
action: 'wpsc_tickets', |
| 1192 |
setting_action : 'get_thread_info', |
| 1193 |
ticket_id: ticket_id, |
| 1194 |
thread_id : thread_id, |
| 1195 |
source : source |
| 1196 |
} |
| 1197 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 1198 |
jQuery('#wpsc_popup_body').html(response.body); |
| 1199 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 1200 |
}); |
| 1201 |
} |
| 1202 |
|
| 1203 |
function wpsc_get_all_tickets_of_user(ticket_id, customer_name){ |
| 1204 |
wpsc_modal_open(customer_name + ' (' + wpsc_admin.users_all_tickets + ')'); |
| 1205 |
var data = { |
| 1206 |
action: 'wpsc_tickets', |
| 1207 |
setting_action : 'get_all_tickets_of_user', |
| 1208 |
ticket_id: ticket_id |
| 1209 |
} |
| 1210 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 1211 |
jQuery('#wpsc_popup_body').html(response.body); |
| 1212 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 1213 |
}) |
| 1214 |
} |
| 1215 |
|
| 1216 |
function wpsc_text_limit(event,element,limit){ |
| 1217 |
if(limit != '0'){ |
| 1218 |
if(element.value.length > limit-1) { |
| 1219 |
event.preventDefault(); |
| 1220 |
} |
| 1221 |
} |
| 1222 |
} |
| 1223 |
|
| 1224 |
function wpsc_check_desc_empty(){ |
| 1225 |
var is_tinymce = (typeof tinyMCE != "undefined") && tinyMCE.activeEditor && !tinyMCE.activeEditor.isHidden(); |
| 1226 |
if(is_tinymce){ |
| 1227 |
var description = tinyMCE.activeEditor.getContent().trim(); |
| 1228 |
}else { |
| 1229 |
var description = jQuery('#wpsc_reply_box').val(); |
| 1230 |
} |
| 1231 |
var flag = false; |
| 1232 |
if(description.length != 0){ |
| 1233 |
var flag = true; |
| 1234 |
} |
| 1235 |
return flag; |
| 1236 |
} |
| 1237 |
|
| 1238 |
function wpsc_thread_attachment_remove(obj,attachment,post_id,ticket_id,nonce){ |
| 1239 |
if( confirm(wpsc_admin.are_you_sure) ){ |
| 1240 |
var data = { |
| 1241 |
action: 'wpsc_tickets', |
| 1242 |
setting_action : 'remove_attachment', |
| 1243 |
attachment : attachment, |
| 1244 |
post_id : post_id, |
| 1245 |
ticket_id : ticket_id, |
| 1246 |
_ajax_nonce: nonce |
| 1247 |
}; |
| 1248 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 1249 |
jQuery(obj).parent('td').parent('tr').remove(); |
| 1250 |
wpsc_open_ticket(ticket_id); |
| 1251 |
}); |
| 1252 |
} |
| 1253 |
} |
| 1254 |
|
| 1255 |
function wpsc_edit_saved_filter(key){ |
| 1256 |
wpsc_modal_open(wpsc_admin.edit_custom_filter); |
| 1257 |
var data = { |
| 1258 |
action: 'wpsc_tickets', |
| 1259 |
setting_action : 'update_filter', |
| 1260 |
key: key |
| 1261 |
}; |
| 1262 |
jQuery.post(wpsc_admin.ajax_url, data, function(response) { |
| 1263 |
jQuery('#wpsc_popup_body').html(response.body); |
| 1264 |
jQuery('#wpsc_popup_footer').html(response.footer); |
| 1265 |
}); |
| 1266 |
} |
| 1267 |
|
| 1268 |
function wpsc_get_update_ticket_filter(){ |
| 1269 |
if(jQuery('#filter_save_label').val().trim()==''){ |
| 1270 |
alert(wpsc_admin.filter_title); |
| 1271 |
return; |
| 1272 |
} |
| 1273 |
var dataform = new FormData(jQuery('#frm_edit_additional_custom_filters')[0]); |
| 1274 |
jQuery('.wpsc_popup_action').text(wpsc_admin.popup_wait); |
| 1275 |
jQuery.ajax({ |
| 1276 |
url: wpsc_admin.ajax_url, |
| 1277 |
type: 'POST', |
| 1278 |
data: dataform, |
| 1279 |
processData: false, |
| 1280 |
contentType: false |
| 1281 |
}) |
| 1282 |
.done(function (response_str) { |
| 1283 |
wpsc_modal_close(); |
| 1284 |
wpsc_get_ticket_list(); |
| 1285 |
}); |
| 1286 |
} |