PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 6.0.3
Taskbuilder – Project Management & Task Management Tool With Kanban Board v6.0.3
6.0.5 6.0.2 6.0.3 6.0.4 6.0.1 6.0.0 5.0.8 5.0.9 4.0.9 5.0.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 All 57 releases
taskbuilder / asset / js / admin.js

admin.js in Taskbuilder – Project Management & Task Management Tool With Kanban Board 6.0.3, at asset/js/admin.js

2,860 lines 81.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 function getMentionDropdown(editor) {
2 let body = jQuery(editor.getBody());
3 let dropdown = body.find('#wppm_mention_list');
4
5 if (!dropdown.length) {
6 dropdown = jQuery('<div id="wppm_mention_list"></div>');
7 body.append(dropdown);
8 }
9 if (!editor.mentionDropdown) {
10 return editor.mentionDropdown;
11 }else{
12 return dropdown;
13 }
14 }
15
16 function updateActiveItem(items,mentionIndex) {
17 items.removeClass('active').css({
18 background: '#fff',
19 color: '#333'
20 });
21 items.eq(mentionIndex)
22 .addClass('active')
23 .css({
24 background: '#0073aa',
25 color: '#fff'
26 });
27 }
28
29 function wppm_add_new_project(){
30 jQuery('#wppm_project_container').show();
31 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
32 var data = {
33 action: 'wppm_add_new_project'
34 };
35 jQuery.post(wppm_admin.ajax_url, data, function(response) {
36 jQuery('#wppm_project_container').html(response);
37 });
38 }
39
40 function wppm_projects(){
41 jQuery('#wppm_project_container').hide();
42 jQuery('#wppm_project_list').show();
43 }
44
45 function wppm_get_users(proj_id){
46 wppm_modal_open('Add Users');
47 var data = {
48 action: 'wppm_get_users',
49 proj_id: proj_id
50 }
51 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
52 var response = JSON.parse(response_str);
53 jQuery('#wppm_popup_body').html(response.body);
54 jQuery('#wppm_popup_footer').html(response.footer);
55 });
56 }
57
58 function wppm_get_general_settings(){
59 jQuery('.wppm_setting_pills li').removeClass('active');
60 jQuery('#wppm_settings_general').addClass('active');
61 jQuery('.wppm_setting_col2').html(wppm_admin.loading_html);
62 var data = {
63 action: 'wppm_get_general_setings'
64 };
65 jQuery.post(wppm_admin.ajax_url, data, function(response) {
66 jQuery('.wppm_setting_col2').html(response);
67 });
68 }
69
70 function wppm_get_page_settings(){
71 jQuery('.wppm_setting_pills li').removeClass('active');
72 jQuery('#wppm_settings_page').addClass('active');
73 jQuery('.wppm_setting_col2').html(wppm_admin.loading_html);
74 var data = {
75 action: 'wppm_get_page_setings'
76 };
77 jQuery.post(wppm_admin.ajax_url, data, function(response) {
78 jQuery('.wppm_setting_col2').html(response);
79 });
80 }
81
82 function wppm_set_page_settings(){
83 jQuery('.wppm_submit_wait').show();
84 var dataform = new FormData(jQuery('#wppm-frm-ps')[0]);
85 jQuery.ajax({
86 url: wppm_admin.ajax_url,
87 type: 'POST',
88 data: dataform,
89 processData: false,
90 contentType: false
91 })
92 .done(function (response_str) {
93 var response = JSON.parse(response_str);
94 jQuery('.wppm_submit_wait').hide();
95 if (response.sucess_status=='1') {
96 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
97 }
98 jQuery('#wppm_alert_success').slideDown('fast',function(){});
99 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
100 });
101 }
102
103 /*
104 * Category Settings
105 */
106 function wppm_get_category_settings(){
107 jQuery('.wppm_setting_pills li').removeClass('active');
108 jQuery('#wppm_settings_category').addClass('active');
109 jQuery('.wppm_setting_col2').html(wppm_admin.loading_html);
110 var data = {
111 action: 'wppm_get_category_settings'
112 };
113 jQuery.post(wppm_admin.ajax_url, data, function(response) {
114 jQuery('.wppm_setting_col2').html(response);
115 });
116 }
117
118 /**
119 * Delete category
120 */
121 function wppm_delete_category(cat_id) {
122
123 const flag = confirm(wppm_admin.confirm);
124 if (!flag) return;
125
126 var data = { action: 'wppm_delete_category',
127 cat_id,
128 _ajax_nonce:jQuery('#wppm_delete_cat_ajax_nonce').val()
129 };
130 jQuery.post(wppm_admin.ajax_url, data, function (res) {
131 wppm_get_category_settings();
132 });
133 }
134
135 function wppm_get_proj_status_settings(){
136 jQuery('.wppm_setting_pills li').removeClass('active');
137 jQuery('#wppm_settings_proj_status').addClass('active');
138 jQuery('.wppm_setting_col2').html(wppm_admin.loading_html);
139 var data = {
140 action: 'wppm_get_proj_status_settings'
141 };
142 jQuery.post(wppm_admin.ajax_url, data, function(response) {
143 jQuery('.wppm_setting_col2').html(response);
144 });
145 }
146
147 function wppm_get_add_proj_status(){
148 wppm_modal_open(wppm_admin.add_new_status);
149 var data = {
150 action: 'wppm_get_add_proj_status'
151 };
152 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
153 var response = JSON.parse(response_str);
154 jQuery('#wppm_popup_body').html(response.body);
155 jQuery('#wppm_popup_footer').html(response.footer);
156 jQuery('#wppm_proj_status_name').focus();
157 });
158 }
159
160 function wppm_delete_proj_status(status_id){
161 const flag = confirm(wppm_admin.confirm);
162 if (!flag) return;
163
164 var data = { action: 'wppm_delete_status', status_id,
165 _ajax_nonce:jQuery('#wppm_delete_pstatus_ajax_nonce').val()
166 };
167 jQuery.post(wppm_admin.ajax_url, data, function (res) {
168 wppm_get_proj_status_settings();
169 });
170 }
171
172 function wppm_set_project_users(){
173 var dataform = new FormData(jQuery('#frm_get_project_users')[0]);
174 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
175 var proj_id = jQuery('#wppm_proj_id').val();
176 jQuery.ajax({
177 url: wppm_admin.ajax_url,
178 type: 'POST',
179 data: dataform,
180 processData: false,
181 contentType: false
182 })
183 .done(function () {
184 wppm_modal_close();
185 wppm_open_project(proj_id);
186 });
187 }
188
189 function wppm_set_task_users(proj_id,project_id){
190 var dataform = new FormData(jQuery('#frm_get_task_users')[0]);
191 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
192 var task_id = jQuery('#wppm_task_id').val();
193 jQuery.ajax({
194 url: wppm_admin.ajax_url,
195 type: 'POST',
196 data: dataform,
197 processData: false,
198 contentType: false
199 })
200 .done(function () {
201 if((proj_id!=0)||(proj_id!="")){
202 wppm_task_modal_close();
203 wppm_open_project_tasks(task_id,proj_id);
204 }else if((proj_id==0)||(proj_id=="")){
205 wppm_task_modal_close();
206 wppm_open_task(task_id,project_id);
207 }
208 });
209 }
210
211 function wppm_get_project_list(page_no){
212 jQuery('#wppm_project_container').show();
213 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
214 var dataform=new FormData(jQuery('#wppm_project_list_frm')[0]);
215 dataform.append("page_no", page_no);
216 dataform.append("action", 'wppm_get_project_list');
217 dataform.append("page", wppm_admin.page);
218 jQuery.ajax( {
219 url: wppm_admin.ajax_url,
220 type: 'POST',
221 data: dataform,
222 processData: false,
223 contentType: false
224 })
225 .done(function( response ) {
226 jQuery('#wppm_project_container').html(response);
227 });
228 }
229
230 function wppm_add_new_task(proj_id,project_id){
231 jQuery('#wppm_task_container').show();
232 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
233 var data = {
234 action: 'wppm_add_new_task',
235 proj_id:proj_id,
236 project_id:project_id
237 };
238 jQuery.post(wppm_admin.ajax_url, data, function(response) {
239 jQuery('#wppm_task_container').html(response);
240 });
241 }
242
243 function wppm_get_task_list(page_no,id){
244 jQuery('#wppm_task_container').show();
245 // window.history.replaceState( {}, null, 'admin.php?page=wppm-tasks&section=task-list' );
246 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
247 var data = {
248 action: 'wppm_get_task_list',
249 page_no:page_no,
250 page:wppm_admin.page,
251 project_id:id
252 };
253 jQuery.post(wppm_admin.ajax_url, data, function(response) {
254 jQuery('#wppm_task_container').html(response);
255 });
256 }
257
258 function wppm_get_task_prioriy_settings(){
259 jQuery('.wppm_setting_pills li').removeClass('active');
260 jQuery('#wppm_settings_task_priorities').addClass('active');
261 jQuery('.wppm_setting_col2').html(wppm_admin.loading_html);
262 var data = {
263 action: 'wppm_get_priority_settings'
264 };
265 jQuery.post(wppm_admin.ajax_url, data, function(response) {
266 jQuery('.wppm_setting_col2').html(response);
267 });
268 }
269
270 function wppm_add_task_priority(){
271 wppm_modal_open(wppm_admin.add_new_priority);
272 var data = {
273 action: 'wppm_add_task_priority'
274 };
275 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
276 var response = JSON.parse(response_str);
277 jQuery('#wppm_popup_body').html(response.body);
278 jQuery('#wppm_popup_footer').html(response.footer);
279 jQuery('#wppm_cat_name').focus();
280 });
281 }
282
283 function wppm_delete_task_priority(priority_id){
284 const flag = confirm(wppm_admin.confirm);
285 if (!flag) return;
286
287 var data = { action: 'wppm_delete_task_priority', priority_id,
288 _ajax_nonce:jQuery('#wppm_delete_tprio_ajax_nonce').val()
289 };
290 jQuery.post(wppm_admin.ajax_url, data, function (res) {
291 wppm_get_task_prioriy_settings();
292 });
293 }
294
295 function wppm_get_task_status_settings(){
296 jQuery('.wppm_setting_pills li').removeClass('active');
297 jQuery('#wppm_settings_task_status').addClass('active');
298 jQuery('.wppm_setting_col2').html(wppm_admin.loading_html);
299 var data = {
300 action: 'wppm_get_task_status_settings'
301 };
302 jQuery.post(wppm_admin.ajax_url, data, function(response) {
303 jQuery('.wppm_setting_col2').html(response);
304 });
305 }
306
307 function wppm_get_add_task_status(){
308 wppm_modal_open(wppm_admin.add_new_status);
309 var data = {
310 action: 'wppm_get_add_task_status'
311 };
312 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
313 var response = JSON.parse(response_str);
314 jQuery('#wppm_popup_body').html(response.body);
315 jQuery('#wppm_popup_footer').html(response.footer);
316 jQuery('#wppm_cat_name').focus();
317 });
318 }
319
320 function wppm_delete_task_status(status_id){
321 const flag = confirm(wppm_admin.confirm);
322 if (!flag) return;
323
324 var data = { action: 'wppm_delete_task_status', status_id,
325 _ajax_nonce: jQuery('#wppm_delete_tstatus_ajax_nonce').val()};
326 jQuery.post(wppm_admin.ajax_url, data, function (res) {
327 wppm_get_task_status_settings();
328 });
329 }
330
331 function wppm_task_search_filter(page){
332 var task_search = jQuery("#wppm_task_search_filter").val();
333 jQuery('#wppm_task_container').show();
334 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
335 var data = {
336 action: 'wppm_get_task_list',
337 task_search:task_search,
338 page:page
339 };
340 jQuery.post(wppm_admin.ajax_url, data, function(response) {
341 jQuery('#wppm_task_container').html(response);
342 });
343 }
344
345 function wppm_view_task_search_filter(page_no,page,proj_id){
346 var task_search = jQuery("#wppm_view_task_search_filter").val() || '';
347 jQuery('#wppm_task_container').show();
348 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
349
350 var data = {
351 action: 'wppm_get_task_list_card_view',
352 task_search:task_search,
353 page_no:page_no,
354 page:page,
355 project_id:proj_id
356 };
357 jQuery.post(wppm_admin.ajax_url, data, function(response) {
358 jQuery('#wppm_task_container').html(response);
359 });
360 }
361
362 function wppm_open_task(id,proj_id){
363 jQuery('#wppm_task_container').show();
364 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
365 var data = {
366 action: 'wppm_open_task',
367 id:id,
368 auth_code: wppm_admin.auth_code,
369 page:wppm_admin.page,
370 project_id:proj_id
371 };
372 jQuery.post(wppm_admin.ajax_url, data, function(response) {
373 jQuery('#wppm_task_container').html(response);
374 });
375 }
376
377 function wppm_open_dashboard_task(id){
378 window.location.href = 'admin.php?page=wppm-tasks&task_id=' + id;
379 }
380
381 function wppm_open_project_tasks(id,proj_id){
382 wppm_modal_open('Open Tasks');
383 jQuery('#wppm_task_container').show();
384 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
385 var data = {
386 action: 'wppm_open_task',
387 id: id,
388 proj_id:proj_id
389 }
390 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
391 jQuery('#wppm_popup_body').html(response_str);
392 //jQuery('#wppm_task_container').html(response_str);
393 });
394 }
395
396 function wppm_add_new_checklist(task_id,proj_id){
397 if(jQuery('#wppm_checklist_label').val()==''){
398 jQuery('#wppm_checklist_label').focus();
399 return false;
400 }
401 var data = {
402 action: 'wppm_add_new_checklist',
403 task_id: task_id,
404 proj_id: proj_id,
405 checklist_name: jQuery('#wppm_checklist_label').val(),
406 _ajax_nonce:jQuery('#wppm_checklist_ajax_nonce').val()
407 };
408 jQuery.post(wppm_admin.ajax_url, data, function(response) {
409 if((proj_id!=0)||(proj_id!="")){
410 //wppm_modal_close();
411 wppm_open_project_tasks(task_id,proj_id);
412 }else if((proj_id==0)||(proj_id=="")){
413 //wppm_modal_close();
414 wppm_open_task(task_id);
415 }
416 });
417 }
418
419 function wppm_add_new_checklist_item(checklist_id,task_id,proj_id){
420 if(jQuery('#wppm_checklist_item_label_'+checklist_id).val()==''){
421 jQuery('#wppm_checklist_item_label_'+checklist_id).focus();
422 return false;
423 }
424 var data = {
425 action: 'wppm_add_new_checklist_item',
426 checklist_id: checklist_id,
427 proj_id:proj_id,
428 label: jQuery('#wppm_checklist_item_label_'+checklist_id).val(),
429 _ajax_nonce:jQuery('#wppm_checklist_item_ajax_nonce').val()
430 };
431 jQuery.post(wppm_admin.ajax_url, data, function(response) {
432 if((proj_id!=0)||(proj_id!="")){
433 wppm_open_project_tasks(task_id,proj_id);
434 }else if((proj_id==0)||(proj_id=="")){
435 wppm_open_task(task_id);
436 }
437 });
438 }
439
440 function wppm_delete_checklist(checklist_id,task_id,proj_id){
441 const flag = confirm(wppm_admin.confirm);
442 if (!flag) return;
443 var data = {
444 action: 'wppm_delete_checklist',
445 checklist_id: checklist_id,
446 task_id:task_id,
447 proj_id:proj_id,
448 _ajax_nonce:jQuery('#wppm_delete_checklist_ajax_nonce').val()
449 };
450 jQuery.post(wppm_admin.ajax_url, data, function(response) {
451 if((proj_id!=0)||(proj_id!="")){
452 wppm_open_project_tasks(task_id,proj_id);
453 }else if((proj_id==0)||(proj_id=="")){
454 wppm_open_task(task_id);
455 }
456 });
457 }
458
459 function wppm_delete_checklist_item(item_id,checklist_id,proj_id,task_id){
460 const flag = confirm(wppm_admin.confirm);
461 if (!flag) return;
462 var data = {
463 action: 'wppm_remove_checklist_item',
464 item_id:item_id,
465 checklist_id: checklist_id,
466 proj_id:proj_id,
467 task_id:task_id,
468 _ajax_nonce:jQuery('#wppm_delete_checklist_item_ajax_nonce').val()
469 };
470 jQuery.post(wppm_admin.ajax_url, data, function(response) {
471 if((proj_id!=0)||(proj_id!="")){
472 wppm_open_project_tasks(task_id,proj_id);
473 }else if((proj_id==0)||(proj_id=="")){
474 wppm_open_task(task_id);
475 }
476 });
477 }
478
479 function wppm_checklist_progress(checklist_id,item_id,task_id){
480 var $checkboxes = jQuery('.wppm_checklist_item_'+checklist_id);
481 var $progress = jQuery('#CheckProgress_'+checklist_id);
482 var total = $checkboxes.length;
483 var checked = jQuery('.wppm_checklist_item_'+checklist_id).filter(':checked').length;
484 var progressWidth = (checked / total) * 100;
485 var checked_item;
486 jQuery('#CheckProgress_'+checklist_id).css('background','#5ba4cf');
487 jQuery('#CheckProgress_'+checklist_id).css('width', progressWidth + '%');
488 if (jQuery("#wppm_checklist_item_"+item_id).prop("checked")==true) {
489 checked_item=1;
490 }else{
491 checked_item=0;
492 }
493 var data = {
494 action: 'wppm_set_checklist_progress',
495 checklist_id: checklist_id,
496 item_id:item_id,
497 checked_item: checked_item,
498 _ajax_nonce:jQuery('#wppm_checklist_progress_ajax_nonce').val()
499 };
500 jQuery.post(wppm_admin.ajax_url, data, function(response) {
501 wppm_open_task(task_id);
502 });
503 }
504
505 function wppm_open_individual_task(id){
506 jQuery('#wppm_project_container').show();
507 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
508 var data = {
509 action: 'wppm_open_task',
510 id:id
511 };
512 jQuery.post(wppm_admin.ajax_url, data, function(response) {
513 jQuery('#wppm_project_container').html(response);
514 });
515 }
516
517
518 function wppm_display_grid_view(page,id){
519 var task_search = jQuery("#wppm_view_task_search_filter").val() || '';
520 jQuery('#wppm_task_container').show();
521 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
522 var data = {
523 action: 'wppm_get_task_list_card_view',
524 task_search: task_search,
525 page:page,
526 id:id
527 };
528 jQuery.post(wppm_admin.ajax_url, data, function(response) {
529 jQuery('#wppm_task_container').html(response);
530 });
531 }
532
533 function wppm_remove_filter(id){
534 jQuery('#wppm_user_display_container_'+id).remove();
535 }
536
537 function wppm_remove_user_from_project(id){
538 jQuery('#wppm_user_container_'+id).remove();
539 }
540
541 function wppm_remove_task_user_filter(id){
542 jQuery('#wppm_task_user_display_container_'+id).remove();
543 }
544
545 function wppm_attachment_cancel( obj ){
546 jQuery(obj).parent().remove();
547 }
548
549 function wppm_get_en_general_setting(){
550 jQuery('.wppm_setting_pills li').removeClass('active');
551 jQuery('#wppm_en_setting_general').addClass('active');
552 jQuery('.wppm_setting_col2').html(wppm_admin.loading_html);
553
554 var data = {
555 action: 'wppm_get_en_general_setting',
556 };
557
558 jQuery.post(wppm_admin.ajax_url, data, function(response) {
559 jQuery('.wppm_setting_col2').html(response);
560 });
561 }
562
563 function wppm_set_en_general_settings(){
564 jQuery('.wppm_submit_wait').show();
565 var dataform = new FormData(jQuery('#wppm_en_frm_general_settings')[0]);
566
567 jQuery.ajax({
568 url: wppm_admin.ajax_url,
569 type: 'POST',
570 data: dataform,
571 processData: false,
572 contentType: false
573 })
574 .done(function (response_str) {
575 var response = JSON.parse(response_str);
576 jQuery('.wppm_submit_wait').hide();
577 if (response.sucess_status=='1') {
578 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
579 }
580 jQuery('#wppm_alert_success').slideDown('fast',function(){});
581 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
582 });
583 }
584
585 function wppm_get_en_task_notifications(){
586 jQuery('.wppm_setting_pills li').removeClass('active');
587 jQuery('#wppm_en_ticket_notifications').addClass('active');
588 jQuery('.wppm_setting_col2').html(wppm_admin.loading_html);
589
590 var data = {
591 action: 'wppm_get_en_task_notifications'
592 };
593
594 jQuery.post(wppm_admin.ajax_url, data, function(response) {
595 jQuery('.wppm_setting_col2').html(response);
596 });
597 }
598
599 function wppm_edit_task_status(id,proj_id,project_id){
600 if(proj_id==0){
601 wppm_task_modal_open('Edit');
602 }else{
603 wppm_modal_open('Edit');
604 }
605 var data = {
606 action: 'wppm_edit_task_status',
607 task_id: id,
608 proj_id:proj_id,
609 project_id:project_id
610 }
611 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
612 var response = JSON.parse(response_str);
613 if(proj_id==0){
614 jQuery('#wppm_task_popup_body').html(response.body);
615 jQuery('#wppm_task_popup_footer').html(response.footer);
616 }else{
617 jQuery('#wppm_popup_body').html(response.body);
618 jQuery('#wppm_popup_footer').html(response.footer);
619 }
620 });
621 }
622
623 function wppm_edit_task_users(task_id,proj_id,project_id){
624 if(proj_id==0){
625 wppm_task_modal_open('Add Users');
626 }else{
627 wppm_modal_open('Add Users');
628 }
629 var data = {
630 action: 'wppm_get_task_users',
631 task_id: task_id,
632 proj_id:proj_id,
633 project_id:project_id
634 }
635 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
636 var response = JSON.parse(response_str);
637 if(proj_id==0){
638 jQuery('#wppm_task_popup_body').html(response.body);
639 jQuery('#wppm_task_popup_footer').html(response.footer);
640 }else{
641 jQuery('#wppm_popup_body').html(response.body);
642 jQuery('#wppm_popup_footer').html(response.footer);
643 }
644 });
645 }
646
647 function wppm_edit_task_details(id,proj_id,project_id){
648 if(proj_id==0){
649 wppm_task_modal_open('Edit Task Details');
650 }else{
651 wppm_modal_open('Edit Task Details');
652 }
653 var data = {
654 action: 'wppm_edit_task_details',
655 task_id: id,
656 proj_id:proj_id,
657 project_id:project_id
658 }
659 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
660 var response = JSON.parse(response_str);
661 if(proj_id==0){
662 jQuery('#wppm_task_popup_body').html(response.body);
663 jQuery('#wppm_task_popup_footer').html(response.footer);
664 }else{
665 jQuery('#wppm_popup_body').html(response.body);
666 jQuery('#wppm_popup_footer').html(response.footer);
667 }
668 });
669 }
670
671 function wppm_set_change_task_status(task_id,proj_id,project_id){
672 var dataform = new FormData(jQuery('#frm_get_task_change_status')[0]);
673 if(proj_id == 0){
674 wppm_task_modal_close();
675 }else{
676 wppm_modal_close();
677 }
678 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
679 jQuery.ajax({
680 url: wppm_admin.ajax_url,
681 type: 'POST',
682 data: dataform,
683 processData: false,
684 contentType: false
685 })
686 .done(function (response_str) {
687 if((proj_id!=0)||(proj_id!="")){
688 wppm_open_project_tasks(task_id,proj_id);
689 }else if((proj_id==0)||(proj_id=="")){
690 wppm_open_task(task_id,project_id);
691 }
692
693 });
694 }
695
696 function wppm_edit_task_creator(task_id,proj_id,project_id){
697 if(proj_id==0){
698 wppm_task_modal_open('Edit Task Creator');
699 }else{
700 wppm_modal_open('Edit Task Creator');
701 }
702 var data = {
703 action: 'wppm_edit_task_creator',
704 task_id: task_id,
705 proj_id: proj_id,
706 project_id: project_id
707 }
708 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
709 var response = JSON.parse(response_str);
710 if(proj_id==0){
711 jQuery('#wppm_task_popup_body').html(response.body);
712 jQuery('#wppm_task_popup_footer').html(response.footer);
713 }else{
714 jQuery('#wppm_popup_body').html(response.body);
715 jQuery('#wppm_popup_footer').html(response.footer);
716 }
717 });
718 }
719
720 function wppm_set_change_raised_by(task_id,proj_id,project_id){
721 var dataform = new FormData(jQuery('#frm_get_task_creator')[0]);
722 if(proj_id==0){
723 wppm_task_modal_close();
724 }else{
725 wppm_modal_close();
726 }
727 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
728 jQuery.ajax({
729 url: wppm_admin.ajax_url,
730 type: 'POST',
731 data: dataform,
732 processData: false,
733 contentType: false
734 })
735 .done(function (response_str) {
736 if((proj_id!=0)||(proj_id!="")){
737 wppm_open_project_tasks(task_id,proj_id);
738 }else if((proj_id==0)||(proj_id=="")){
739 wppm_open_task(task_id,project_id);
740 }
741 });
742 }
743
744 function wppm_set_change_task_details(task_id, proj_id, project_id) {
745 var dataform = new FormData(jQuery('#frm_get_edit_task_deatils')[0]);
746 var editor = tinyMCE.get('wppm_edit_task_description');
747 var description = '';
748 if (editor) {
749 description = editor.getContent().trim();
750 } else {
751 description = jQuery('#wppm_edit_task_description').val().trim();
752 }
753 dataform.append('wppm_edit_task_description', description);
754 if (proj_id == 0) {
755 wppm_task_modal_close();
756 } else {
757 wppm_modal_close();
758 }
759 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
760 jQuery.ajax({
761 url: wppm_admin.ajax_url,
762 type: 'POST',
763 data: dataform,
764 processData: false,
765 contentType: false
766 }).done(function(response_str) {
767 if (proj_id != 0 && proj_id != "") {
768 wppm_open_project_tasks(task_id, proj_id);
769 } else {
770 wppm_open_task(task_id, project_id);
771 }
772 });
773 }
774
775 function wppm_edit_thread(comment_id,task_id,proj_id){
776 if(proj_id==0){
777 wppm_task_modal_open('Edit Thread');
778 }else{
779 wppm_modal_open('Edit Thread');
780 }
781 var data = {
782 action: 'wppm_edit_task_thread',
783 comment_id:comment_id,
784 task_id: task_id,
785 proj_id: proj_id
786 }
787 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
788 var response = JSON.parse(response_str);
789 if(proj_id==0){
790 jQuery('#wppm_task_popup_body').html(response.body);
791 jQuery('#wppm_task_popup_footer').html(response.footer);
792 }else{
793 jQuery('#wppm_popup_body').html(response.body);
794 jQuery('#wppm_popup_footer').html(response.footer);
795 }
796 });
797 }
798
799 function wppm_edit_proj_thread(comment_id,proj_id){
800 wppm_modal_open('Edit Thread');
801 var data = {
802 action: 'wppm_edit_proj_thread',
803 comment_id:comment_id,
804 proj_id: proj_id
805 }
806 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
807 var response = JSON.parse(response_str);
808 jQuery('#wppm_popup_body').html(response.body);
809 jQuery('#wppm_popup_footer').html(response.footer);
810 });
811 }
812
813 function wppm_set_edit_task_thread(task_id,proj_id){
814 var dataform = new FormData(jQuery('#frm_edit_task_thread')[0]);
815 if(wppm_admin.rich_text_editor == 1){
816 var comment_body = tinyMCE.get('wppm_edit_task_thread_editor').getContent().trim();
817 }else{
818 var comment_body = jQuery('#wppm_edit_task_thread_editor').val().trim();
819 }
820 dataform.append('wppm_edit_task_thread', comment_body);
821 if(proj_id==0){
822 wppm_task_modal_close();
823 }else{
824 wppm_modal_close();
825 }
826 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
827 jQuery.ajax({
828 url: wppm_admin.ajax_url,
829 type: 'POST',
830 data: dataform,
831 processData: false,
832 contentType: false
833 })
834 .done(function (response_str) {
835 if((proj_id!=0)||(proj_id!="")){
836 wppm_open_project_tasks(task_id,proj_id);
837 }else if((proj_id==0)||(proj_id=="")){
838 wppm_open_task(task_id);
839 }
840 });
841 }
842
843 function wppm_set_edit_proj_thread(proj_id){
844 var dataform = new FormData(jQuery('#frm_edit_proj_thread')[0]);
845 if(wppm_admin.rich_text_editor == 1){
846 var comment_body = tinyMCE.get('wppm_edit_proj_thread_editor').getContent().trim();
847 }else{
848 var comment_body = jQuery('#wppm_edit_proj_thread_editor').val().trim();
849 }
850 dataform.append('wppm_edit_proj_thread', comment_body);
851 wppm_modal_close();
852 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
853 jQuery.ajax({
854 url: wppm_admin.ajax_url,
855 type: 'POST',
856 data: dataform,
857 processData: false,
858 contentType: false
859 })
860 .done(function (response_str) {
861 wppm_open_project(proj_id);
862 });
863 }
864
865 function wppm_delete_thread(comment_id,task_id,proj_id){
866 if(proj_id==0){
867 wppm_task_modal_open('Delete Thread');
868 }else{
869 wppm_modal_open('Delete Thread');
870 }
871 var data = {
872 action: 'wppm_delete_task_thread',
873 comment_id:comment_id,
874 task_id: task_id,
875 proj_id:proj_id
876 }
877 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
878 var response = JSON.parse(response_str);
879 if(proj_id==0){
880 jQuery('#wppm_task_popup_body').html(response.body);
881 jQuery('#wppm_task_popup_footer').html(response.footer);
882 }else{
883 jQuery('#wppm_popup_body').html(response.body);
884 jQuery('#wppm_popup_footer').html(response.footer);
885 }
886 });
887 }
888
889 function wppm_delete_proj_thread(comment_id,proj_id){
890 wppm_modal_open('Delete Thread');
891 var data = {
892 action: 'wppm_delete_proj_thread',
893 comment_id:comment_id,
894 proj_id:proj_id
895 }
896 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
897 var response = JSON.parse(response_str);
898 jQuery('#wppm_popup_body').html(response.body);
899 jQuery('#wppm_popup_footer').html(response.footer);
900 });
901 }
902
903 function wppm_set_delete_thread(task_id,proj_id){
904 var dataform = new FormData(jQuery('#frm_delete_task_thread')[0]);
905 if(proj_id==0){
906 wppm_task_modal_close();
907 }else{
908 wppm_modal_close();
909 }
910 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
911 jQuery.ajax({
912 url: wppm_admin.ajax_url,
913 type: 'POST',
914 data: dataform,
915 processData: false,
916 contentType: false
917 })
918 .done(function (response_str) {
919 if((proj_id!=0)||(proj_id!="")){
920 wppm_open_project_tasks(task_id,proj_id);
921 }else if((proj_id==0)||(proj_id=="")){
922 wppm_open_task(task_id);
923 }
924 });
925 }
926
927 function wppm_set_delete_proj_thread(proj_id){
928 var dataform = new FormData(jQuery('#frm_delete_proj_thread')[0]);
929 wppm_modal_close();
930 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
931 jQuery.ajax({
932 url: wppm_admin.ajax_url,
933 type: 'POST',
934 data: dataform,
935 processData: false,
936 contentType: false
937 })
938 .done(function (response_str) {
939 wppm_open_project(proj_id);
940 });
941 }
942
943 function wppm_edit_proj_details(id){
944 wppm_modal_open('Edit Project Details');
945 var data = {
946 action: 'wppm_edit_project_details',
947 id: id
948 }
949 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
950 var response = JSON.parse(response_str);
951 jQuery('#wppm_popup_body').html(response.body);
952 jQuery('#wppm_popup_footer').html(response.footer);
953 });
954 }
955
956 function wppm_set_change_project_details(id){
957 var dataform = new FormData(jQuery('#frm_get_edit_project_deatils')[0]);
958 var description = tinyMCE.get('wppm_edit_project_description').getContent().trim();
959 dataform.append('wppm_edit_project_description', description);
960 wppm_modal_close();
961 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
962 jQuery.ajax({
963 url: wppm_admin.ajax_url,
964 type: 'POST',
965 data: dataform,
966 processData: false,
967 contentType: false
968 })
969 .done(function (response_str) {
970 wppm_open_project(id);
971 });
972 }
973
974 function wppm_edit_project_status(id){
975 wppm_modal_open('Edit Project Status');
976 var data = {
977 action: 'wppm_edit_project_status',
978 id: id
979 }
980 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
981 var response = JSON.parse(response_str);
982 jQuery('#wppm_popup_body').html(response.body);
983 jQuery('#wppm_popup_footer').html(response.footer);
984 });
985 }
986
987 function wppm_set_change_project_status(id){
988 var dataform = new FormData(jQuery('#frm_get_project_change_status')[0]);
989 wppm_modal_close();
990 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
991 jQuery.ajax({
992 url: wppm_admin.ajax_url,
993 type: 'POST',
994 data: dataform,
995 processData: false,
996 contentType: false
997 })
998 .done(function (response_str) {
999 wppm_open_project(id);
1000 });
1001 }
1002
1003 function wppm_edit_project_creator(id){
1004 wppm_modal_open('Edit Project Creator');
1005 var data = {
1006 action: 'wppm_edit_project_creator',
1007 id: id
1008 }
1009 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
1010 var response = JSON.parse(response_str);
1011 jQuery('#wppm_popup_body').html(response.body);
1012 jQuery('#wppm_popup_footer').html(response.footer);
1013 });
1014 }
1015
1016 function wppm_set_change_project_raised_by(id){
1017 var dataform = new FormData(jQuery('#frm_get_project_creator')[0]);
1018 wppm_modal_close();
1019 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
1020 jQuery.ajax({
1021 url: wppm_admin.ajax_url,
1022 type: 'POST',
1023 data: dataform,
1024 processData: false,
1025 contentType: false
1026 })
1027 .done(function (response_str) {
1028 wppm_open_project(id);
1029 });
1030 }
1031
1032 function wppm_edit_project_users(id){
1033 wppm_modal_open('Add Users');
1034 var data = {
1035 action: 'wppm_get_project_users',
1036 id: id
1037 }
1038 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
1039 var response = JSON.parse(response_str);
1040 jQuery('#wppm_popup_body').html(response.body);
1041 jQuery('#wppm_popup_footer').html(response.footer);
1042 });
1043 }
1044
1045 function wppm_delete_project(id){
1046 wppm_modal_open('Delete Project');
1047 var data = {
1048 action: 'wppm_get_delete_project',
1049 id: id
1050 }
1051 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
1052 var response = JSON.parse(response_str);
1053 jQuery('#wppm_popup_body').html(response.body);
1054 jQuery('#wppm_popup_footer').html(response.footer);
1055 });
1056 }
1057
1058 function wppm_set_delete_project(){
1059 var dataform = new FormData(jQuery('#frm_delete_project')[0]);
1060 wppm_modal_close();
1061 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
1062 jQuery.ajax({
1063 url: wppm_admin.ajax_url,
1064 type: 'POST',
1065 data: dataform,
1066 processData: false,
1067 contentType: false
1068 })
1069 .done(function (response_str) {
1070 wppm_get_project_list();
1071 });
1072 }
1073
1074 function wppm_get_delete_task(id,proj_id,project_id){
1075 if(proj_id==0){
1076 wppm_task_modal_open('Delete Task');
1077 }else{
1078 wppm_modal_open('Delete Task');
1079 }
1080 var data = {
1081 action: 'wppm_get_delete_task',
1082 id: id,
1083 proj_id:proj_id,
1084 project_id:project_id
1085 }
1086 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
1087 var response = JSON.parse(response_str);
1088 if(proj_id==0){
1089 jQuery('#wppm_task_popup_body').html(response.body);
1090 jQuery('#wppm_task_popup_footer').html(response.footer);
1091 }else{
1092 jQuery('#wppm_popup_body').html(response.body);
1093 jQuery('#wppm_popup_footer').html(response.footer);
1094 }
1095 });
1096 }
1097
1098 function wppm_set_delete_task(proj_id,project_id){
1099 var dataform = new FormData(jQuery('#frm_delete_task')[0]);
1100 if(proj_id==0){
1101 wppm_task_modal_close();
1102 }else{
1103 wppm_modal_close();
1104 }
1105 jQuery.ajax({
1106 url: wppm_admin.ajax_url,
1107 type: 'POST',
1108 data: dataform,
1109 processData: false,
1110 contentType: false
1111 })
1112 .done(function (response_str) {
1113 if(project_id!=0){
1114 wppm_get_project_tasks_kanban_view(project_id);
1115 }else{
1116 if(proj_id==0){
1117 wppm_get_task_list();
1118 }else{
1119 wppm_get_project_tasks(proj_id);
1120 }
1121 }
1122 });
1123 }
1124
1125 function wppm_get_edit_email_notification(id){
1126 jQuery('.wppm_setting_col2').html(wppm_admin.loading_html);
1127 var data = {
1128 action: 'wppm_get_edit_email_notification',
1129 id : id
1130 };
1131 jQuery.post(wppm_admin.ajax_url, data, function(response) {
1132 jQuery('.wppm_setting_col2').html(response);
1133 });
1134 }
1135
1136 function wppm_get_tinymce(selector,body_id){
1137 jQuery('#visual').addClass('btn btn-primary');
1138 jQuery('#text').removeClass('btn btn-primary');
1139 jQuery('#text').addClass('btn btn-default');
1140 tinymce.init({
1141 selector:'#'+selector,
1142 body_id: body_id,
1143 menubar: false,
1144 statusbar: false,
1145 height : '200',
1146 plugins: [
1147 'lists link image directionality'
1148 ],
1149 image_advtab: true,
1150 toolbar: 'bold italic underline blockquote | alignleft aligncenter alignright | bullist numlist | rtl | link image',
1151 branding: false,
1152 autoresize_bottom_margin: 20,
1153 browser_spellcheck : true,
1154 relative_urls : false,
1155 remove_script_host : false,
1156 convert_urls : true,
1157 setup: function (editor) {
1158 }
1159 });
1160 }
1161
1162 function wppm_get_textarea(){
1163 jQuery('#visual').removeClass('btn btn-primary');
1164 jQuery('#visual').addClass('btn btn-default');
1165 jQuery('#text').addClass('btn btn-primary');
1166 tinymce.remove();
1167 }
1168
1169 function wppm_get_templates(){
1170 wppm_modal_open(wppm_admin.templates);
1171 var data = {
1172 action: 'wppm_get_templates'
1173 };
1174 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
1175 var response = JSON.parse(response_str);
1176 jQuery('#wppm_popup_body').html(response.body);
1177 jQuery('#wppm_popup_footer').html(response.footer);
1178 });
1179 }
1180
1181 function wppm_set_edit_email_notification(){
1182 var dataform = new FormData(jQuery('#wppm_edit_email_notification_settings')[0]);
1183 wppm_modal_close();
1184 jQuery('.wppm_setting_col2').html(wppm_admin.loading_html);
1185 jQuery.ajax({
1186 url: wppm_admin.ajax_url,
1187 type: 'POST',
1188 data: dataform,
1189 processData: false,
1190 contentType: false
1191 })
1192 .done(function (response_str) {
1193 var response = JSON.parse(response_str);
1194 if (response.sucess_status=='1') {
1195 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
1196 }
1197 jQuery('#wppm_alert_success').slideDown('fast',function(){});
1198 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
1199 wppm_get_en_task_notifications();
1200 });
1201 }
1202
1203 function wppm_set_general_settings(){
1204 jQuery('.wppm_submit_wait').show();
1205 var dataform = new FormData(jQuery('#wppm_frm_general_settings')[0]);
1206 jQuery.ajax({
1207 url: wppm_admin.ajax_url,
1208 type: 'POST',
1209 data: dataform,
1210 processData: false,
1211 contentType: false
1212 })
1213 .done(function (response_str) {
1214 var response = JSON.parse(response_str);
1215 jQuery('.wppm_submit_wait').hide();
1216 if (response.sucess_status=='1') {
1217 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
1218 }
1219 jQuery('#wppm_alert_success').slideDown('fast',function(){});
1220 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
1221 });
1222 }
1223
1224 function wppm_get_project_tasks(id){
1225 wppm_modal_open('Tasks');
1226 var data = {
1227 action: 'wppm_get_project_tasks',
1228 id: id
1229 }
1230 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
1231 var response = JSON.parse(response_str);
1232 jQuery('#wppm_popup_body').html(response.body);
1233 jQuery('#wppm_popup_footer').html(response.footer);
1234 });
1235 }
1236
1237 function wppm_create_project_task(id){
1238 wppm_task_modal_open('Tasks');
1239 var data = {
1240 action: 'wppm_add_new_task',
1241 proj_id: id
1242 }
1243 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
1244 jQuery('#wppm_popup_body').html(response_str);
1245 });
1246 }
1247
1248 function wppm_load_prev_page(prev_page_no, page_no, sort_by, order, is_archieved) {
1249 if (prev_page_no != 0) {
1250 page_no = prev_page_no - 1;
1251 if (parseInt(is_archieved) === 1) {
1252 wppm_get_archieve_project_list(
1253 page_no,
1254 sort_by,
1255 order,
1256 1
1257 );
1258 } else {
1259 wppm_get_project_list(
1260 page_no,
1261 sort_by,
1262 order
1263 );
1264 }
1265 }
1266 return false;
1267 }
1268
1269 function wppm_load_next_page(next_page_no, page_no, sort_by, order, is_archieved) {
1270 if (next_page_no != page_no) {
1271 page_no = next_page_no;
1272 if (parseInt(is_archieved) === 1) {
1273 wppm_get_archieve_project_list(
1274 page_no,
1275 sort_by,
1276 order,
1277 1
1278 );
1279 } else {
1280 wppm_get_project_list(
1281 page_no,
1282 sort_by,
1283 order
1284 );
1285 }
1286 }
1287
1288 return false;
1289 }
1290
1291 function wppm_load_prev_task_page(prev_page_no,page_no, sort_by, order){
1292 if(prev_page_no!=0){
1293 page_no=prev_page_no-1;
1294 wppm_get_task_list(page_no,sort_by,order);
1295 }
1296 }
1297
1298 function wppm_load_next_task_page(next_page_no,page_no,sort_by,order){
1299 if(next_page_no!=page_no){
1300 page_no = next_page_no;
1301 wppm_get_task_list(page_no,sort_by,order);
1302 }
1303 }
1304
1305 function wppm_load_prev_task_page_card_view(prev_page_no,page_no){
1306 if(prev_page_no!=0){
1307 page_no=prev_page_no-1;
1308 wppm_view_task_search_filter(page_no);
1309 }
1310 }
1311
1312 function wppm_load_next_task_page_card_view(next_page_no,page_no){
1313 if(next_page_no!=page_no){
1314 page_no = next_page_no;
1315 wppm_view_task_search_filter(page_no);
1316 }
1317 }
1318
1319 function wppm_thread_attachment_remove(obj,attachment,comment_id,task_id,proj_id){
1320 if( confirm(wppm_admin.confirm) ){
1321 var data = {
1322 action: 'wppm_remove_thread_attachment',
1323 attachment : attachment,
1324 comment_id : comment_id,
1325 task_id:task_id,
1326 _ajax_nonce : jQuery('#wppm_ajax_nonce').val()
1327 };
1328 jQuery.post(wppm_admin.ajax_url, data, function(response) {
1329 jQuery(obj).parent('td').parent('tr').remove();
1330 if((proj_id!=0)||(proj_id!="")){
1331 wppm_open_project_tasks(task_id,proj_id);
1332 }else if((proj_id==0)||(proj_id=="")){
1333 wppm_open_task(task_id);
1334 }
1335 });
1336 }
1337 }
1338
1339 function wppm_proj_thread_attachment_remove(obj,attachment,comment_id,id){
1340 if( confirm(wppm_admin.confirm) ){
1341 var data = {
1342 action: 'wppm_remove_proj_thread_attachment',
1343 attachment : attachment,
1344 comment_id : comment_id,
1345 proj_id:id,
1346 _ajax_nonce:jQuery('#wppm_proj_thread_attachment_remove').val()
1347 };
1348 jQuery.post(wppm_admin.ajax_url, data, function(response) {
1349 jQuery(obj).parent('td').parent('tr').remove();
1350 wppm_open_project(id);
1351 });
1352 }
1353 }
1354
1355 function wppm_open_project(id){
1356 jQuery('#wppm_project_list').hide();
1357 jQuery('#wppm_project_container').show();
1358 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
1359 var data = {
1360 action: 'wppm_open_project',
1361 id:id,
1362 auth_code: wppm_admin.auth_code
1363 };
1364 jQuery.post(wppm_admin.ajax_url, data, function(response) {
1365 jQuery('#wppm_project_container').html(response);
1366 });
1367 }
1368
1369 function wppm_project_search_filter(is_archieved){
1370 var project_search = jQuery("#wppm_project_search_filter").val();
1371 jQuery('#wppm_project_container').show();
1372 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
1373 var data = {
1374 action: 'wppm_get_project_list',
1375 project_search:project_search,
1376 page: wppm_admin.page,
1377 is_archieved:is_archieved
1378 };
1379 jQuery.post(wppm_admin.ajax_url, data, function(response) {
1380 jQuery('#wppm_project_container').html(response);
1381 });
1382 }
1383
1384 function wppm_clone_task(id,proj_id,project_id){
1385 if(proj_id==0){
1386 wppm_task_modal_open('Clone Task');
1387 }else{
1388 wppm_modal_open('Clone Task');
1389 }
1390 var data = {
1391 action: 'wppm_clone_task',
1392 id: id,
1393 proj_id: proj_id,
1394 project_id: project_id
1395 }
1396 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
1397 var response = JSON.parse(response_str);
1398 if(proj_id==0){
1399 jQuery('#wppm_task_popup_body').html(response.body);
1400 jQuery('#wppm_task_popup_footer').html(response.footer);
1401 }else{
1402 jQuery('#wppm_popup_body').html(response.body);
1403 jQuery('#wppm_popup_footer').html(response.footer);
1404 }
1405 });
1406 }
1407
1408 function wppm_set_clone_task(proj_id,project_id){
1409 var dataform = new FormData(jQuery('#frm_edit_clone_task_name')[0]);
1410 if(proj_id==0){
1411 wppm_task_modal_close();
1412 }else{
1413 wppm_modal_close();
1414 }
1415 jQuery.ajax({
1416 url: wppm_admin.ajax_url,
1417 type: 'POST',
1418 data: dataform,
1419 processData: false,
1420 contentType: false
1421 })
1422 .done(function (response_str) {
1423 if(project_id!=0){
1424 wppm_get_project_tasks_kanban_view(project_id);
1425 }else{
1426 if(proj_id==0){
1427 wppm_get_task_list();
1428 }else{
1429 wppm_get_project_tasks(proj_id);
1430 }
1431 }
1432 });
1433 }
1434
1435 function wppm_sort_up_task_list(sort_by,order,page){
1436 jQuery('#wppm_task_container').show();
1437 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
1438 var data = {
1439 action: 'wppm_get_task_list',
1440 sort_by:sort_by,
1441 order:order,
1442 page:page
1443 };
1444 jQuery.post(wppm_admin.ajax_url, data, function(response) {
1445 jQuery('#wppm_task_container').html(response);
1446 });
1447 }
1448
1449 function wppm_sort_up_project_list(sort_by,order){
1450 jQuery('#wppm_project_container').show();
1451 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
1452 var data = {
1453 action: 'wppm_get_project_list',
1454 sort_by:sort_by,
1455 order:order,
1456 page: wppm_admin.page
1457 };
1458 jQuery.post(wppm_admin.ajax_url, data, function(response) {
1459 jQuery('#wppm_project_container').html(response);
1460 });
1461 }
1462
1463 function wppm_get_miscellaneous_settings(){
1464 jQuery('.wppm_setting_pills li').removeClass('active');
1465 jQuery('#wppm_settings_miscellaneous').addClass('active');
1466 jQuery('.wppm_setting_col2').html(wppm_admin.loading_html);
1467 var data = {
1468 action: 'wppm_get_advanced_settings'
1469 };
1470 jQuery.post(wppm_admin.ajax_url, data, function(response) {
1471 jQuery('.wppm_setting_col2').html(response);
1472 });
1473 }
1474
1475 function wppm_get_appearance_settings(){
1476 jQuery('.wppm_setting_pills li').removeClass('active');
1477 jQuery('#wppm_settings_appearance').addClass('active');
1478 var data = {
1479 action: 'wppm_get_appearance_settings'
1480 };
1481 jQuery.post(wppm_admin.ajax_url, data, function(response) {
1482 jQuery('.wppm_setting_col2').html(response);
1483 });
1484 }
1485
1486 function wppm_get_coworker_permission_settings(){
1487 jQuery('.wppm_setting_pills li').removeClass('active');
1488 jQuery('#wppm_settings_coworker').addClass('active');
1489 jQuery('.wppm_setting_col2').html(wppm_admin.loading_html);
1490 var data = {
1491 action: 'wppm_get_coworker_permission_settings'
1492 };
1493 jQuery.post(wppm_admin.ajax_url, data, function(response) {
1494 jQuery('.wppm_setting_col2').html(response);
1495 });
1496 }
1497
1498 function wppm_set_coworkers_permission_settings(){
1499 jQuery('.wppm_submit_wait').show();
1500 var dataform = new FormData(jQuery('#wppm_frm_coworkers_permission_settings')[0]);
1501 jQuery.ajax({
1502 url: wppm_admin.ajax_url,
1503 type: 'POST',
1504 data: dataform,
1505 processData: false,
1506 contentType: false
1507 })
1508 .done(function (response_str) {
1509 var response = JSON.parse(response_str);
1510 jQuery('.wppm_submit_wait').hide();
1511 if (response.sucess_status=='1') {
1512 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
1513 }
1514 jQuery('#wppm_alert_success').slideDown('fast',function(){});
1515 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
1516 });
1517 }
1518
1519 function wppm_get_rich_text_editor_settings(){
1520 jQuery('.wppm_setting_pills li').removeClass('active');
1521 jQuery('#wppm_settings_rich_text_editor').addClass('active');
1522 jQuery('.wppm_setting_col2').html(wppm_admin.loading_html);
1523 var data = {
1524 action: 'wppm_get_rich_text_editor_settings'
1525 };
1526 jQuery.post(wppm_admin.ajax_url, data, function(response) {
1527 jQuery('.wppm_setting_col2').html(response);
1528 });
1529 }
1530
1531 function wppm_set_rich_text_editor_settings(){
1532 jQuery('.wppm_submit_wait').show();
1533 var dataform = new FormData(jQuery('#wppm_frm_rich_text_editor_settings')[0]);
1534 jQuery.ajax({
1535 url: wppm_admin.ajax_url,
1536 type: 'POST',
1537 data: dataform,
1538 processData: false,
1539 contentType: false
1540 })
1541 .done(function (response_str) {
1542 var response = JSON.parse(response_str);
1543 jQuery('.wppm_submit_wait').hide();
1544 if (response.sucess_status=='1') {
1545 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
1546 }
1547 jQuery('#wppm_alert_success').slideDown('fast',function(){});
1548 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
1549 });
1550 }
1551
1552 function wppm_get_ap_proj_list(current_tab_class) {
1553 jQuery( '.wppm-setting-tab-container button' ).removeClass( 'active' );
1554 jQuery( '.wppm-setting-tab-container button.' + current_tab_class ).addClass( 'active' );
1555 jQuery('.wppm-setting-section-body').html(wppm_admin.loading_html);
1556 var data = { action: 'wppm_get_ap_proj_list' ,
1557 current_tab:current_tab_class
1558 };
1559 jQuery.post(
1560 wppm_admin.ajax_url,
1561 data,
1562 function (response) {
1563 jQuery( '.wppm-setting-section-body' ).html( response );
1564 }
1565 );
1566 }
1567
1568 function wppm_get_ap_modal_popup(current_tab_class){
1569 jQuery( '.wppm-setting-tab-container button' ).removeClass( 'active' );
1570 jQuery( '.wppm-setting-tab-container button.' + current_tab_class ).addClass( 'active' );
1571 jQuery('.wppm-setting-section-body').html(wppm_admin.loading_html);
1572 var data = { action: 'wppm_get_ap_modal_popup' ,
1573 current_tab:current_tab_class };
1574 jQuery.post(
1575 wppm_admin.ajax_url,
1576 data,
1577 function (response) {
1578 jQuery( '.wppm-setting-section-body' ).html( response );
1579 }
1580 );
1581 }
1582
1583 function wppm_get_ap_task_list(current_tab_class){
1584 jQuery( '.wppm-setting-tab-container button' ).removeClass( 'active' );
1585 jQuery( '.wppm-setting-tab-container button.' + current_tab_class ).addClass( 'active' );
1586 jQuery( '.wppm-setting-section-body').html(wppm_admin.loading_html);
1587 var data = { action: 'wppm_get_ap_task_list' ,
1588 current_tab:current_tab_class
1589 };
1590 jQuery.post(
1591 wppm_admin.ajax_url,
1592 data,
1593 function (response) {
1594 jQuery( '.wppm-setting-section-body' ).html( response );
1595 }
1596 );
1597 }
1598
1599 function wppm_get_ap_individual_proj(current_tab_class){
1600 jQuery( '.wppm-setting-tab-container button' ).removeClass( 'active' );
1601 jQuery( '.wppm-setting-tab-container button.' + current_tab_class ).addClass( 'active' );
1602 jQuery( '.wppm-setting-section-body').html(wppm_admin.loading_html);
1603 var data = { action: 'wppm_get_ap_individual_proj' ,
1604 current_tab:current_tab_class
1605 };
1606 jQuery.post(
1607 wppm_admin.ajax_url,
1608 data,
1609 function (response) {
1610 jQuery( '.wppm-setting-section-body' ).html( response );
1611 }
1612 );
1613 }
1614
1615 function wppm_get_ap_individual_task(current_tab_class){
1616 jQuery( '.wppm-setting-tab-container button' ).removeClass( 'active' );
1617 jQuery( '.wppm-setting-tab-container button.' + current_tab_class ).addClass( 'active' );
1618 jQuery( '.wppm-setting-section-body').html(wppm_admin.loading_html);
1619 var data = { action: 'wppm_get_ap_individual_task' ,
1620 current_tab:current_tab_class
1621 };
1622 jQuery.post(
1623 wppm_admin.ajax_url,
1624 data,
1625 function (response) {
1626 jQuery( '.wppm-setting-section-body' ).html( response );
1627 }
1628 );
1629 }
1630
1631 function wppm_get_ap_grid_view(current_tab_class){
1632 jQuery( '.wppm-setting-tab-container button' ).removeClass( 'active' );
1633 jQuery( '.wppm-setting-tab-container button.' + current_tab_class ).addClass( 'active' );
1634 jQuery( '.wppm-setting-section-body').html(wppm_admin.loading_html);
1635 var data = { action: 'wppm_get_ap_grid_view' ,
1636 current_tab:current_tab_class
1637 };
1638 jQuery.post(
1639 wppm_admin.ajax_url,
1640 data,
1641 function (response) {
1642 jQuery( '.wppm-setting-section-body' ).html( response );
1643 }
1644 );
1645 }
1646
1647 function wppm_get_ap_settings(current_tab_class){
1648 jQuery( '.wppm-setting-tab-container button' ).removeClass( 'active' );
1649 jQuery( '.wppm-setting-tab-container button.' + current_tab_class ).addClass( 'active' );
1650 jQuery( '.wppm-setting-section-body').html(wppm_admin.loading_html);
1651 var data = { action: 'wppm_get_ap_settings' ,
1652 current_tab:current_tab_class
1653 };
1654 jQuery.post(
1655 wppm_admin.ajax_url,
1656 data,
1657 function (response) {
1658 jQuery( '.wppm-setting-section-body' ).html( response );
1659 }
1660 );
1661 }
1662
1663 function wppm_set_ap_settings(){
1664 var form = jQuery( '.wppm-frm-ap-settings' )[0];
1665 var dataform = new FormData( form );
1666 jQuery('.wppm_submit_wait').show();
1667 jQuery.ajax(
1668 {
1669 url: wppm_admin.ajax_url,
1670 type: 'POST',
1671 data: dataform,
1672 processData: false,
1673 contentType: false
1674 }
1675 ).done(
1676 function (response_str) {
1677 var response = JSON.parse(response_str);
1678 jQuery('.wppm_submit_wait').hide();
1679 if (response.sucess_status=='1') {
1680 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
1681 }
1682 jQuery('#wppm_alert_success').slideDown('fast',function(){});
1683 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
1684 }
1685 );
1686 }
1687
1688 function wppm_set_ap_proj_list() {
1689 var form = jQuery( '.wppm-frm-ap-pl' )[0];
1690 var dataform = new FormData( form );
1691 jQuery('.wppm_submit_wait').show();
1692 jQuery.ajax(
1693 {
1694 url: wppm_admin.ajax_url,
1695 type: 'POST',
1696 data: dataform,
1697 processData: false,
1698 contentType: false
1699 }
1700 ).done(
1701 function (response_str) {
1702 var response = JSON.parse(response_str);
1703 jQuery('.wppm_submit_wait').hide();
1704 if (response.sucess_status=='1') {
1705 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
1706 }
1707 jQuery('#wppm_alert_success').slideDown('fast',function(){});
1708 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
1709 }
1710 );
1711 }
1712
1713 function wppm_set_ap_task_list(){
1714 var form = jQuery( '.wppm-frm-ap-tl' )[0];
1715 var dataform = new FormData( form );
1716 jQuery('.wppm_submit_wait').show();
1717 jQuery.ajax(
1718 {
1719 url: wppm_admin.ajax_url,
1720 type: 'POST',
1721 data: dataform,
1722 processData: false,
1723 contentType: false
1724 }
1725 ).done(
1726 function (response_str) {
1727 var response = JSON.parse(response_str);
1728 jQuery('.wppm_submit_wait').hide();
1729 if (response.sucess_status=='1') {
1730 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
1731 }
1732 jQuery('#wppm_alert_success').slideDown('fast',function(){});
1733 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
1734 }
1735 );
1736 }
1737
1738 function wppm_set_ap_individual_proj(){
1739 var form = jQuery( '.wppm-frm-ap-individual_pl' )[0];
1740 var dataform = new FormData( form );
1741 jQuery('.wppm_submit_wait').show();
1742 jQuery.ajax(
1743 {
1744 url: wppm_admin.ajax_url,
1745 type: 'POST',
1746 data: dataform,
1747 processData: false,
1748 contentType: false
1749 }
1750 ).done(
1751 function (response_str) {
1752 var response = JSON.parse(response_str);
1753 jQuery('.wppm_submit_wait').hide();
1754 if (response.sucess_status=='1') {
1755 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
1756 }
1757 jQuery('#wppm_alert_success').slideDown('fast',function(){});
1758 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
1759 }
1760 );
1761 }
1762
1763 function wppm_set_ap_individual_task(){
1764 var form = jQuery( '.wppm-frm-ap-individual_tl' )[0];
1765 var dataform = new FormData( form );
1766 jQuery('.wppm_submit_wait').show();
1767 jQuery.ajax(
1768 {
1769 url: wppm_admin.ajax_url,
1770 type: 'POST',
1771 data: dataform,
1772 processData: false,
1773 contentType: false
1774 }
1775 ).done(
1776 function (response_str) {
1777 var response = JSON.parse(response_str);
1778 jQuery('.wppm_submit_wait').hide();
1779 if (response.sucess_status=='1') {
1780 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
1781 }
1782 jQuery('#wppm_alert_success').slideDown('fast',function(){});
1783 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
1784 }
1785 );
1786 }
1787
1788 function wppm_set_ap_modal_popup(){
1789 var form = jQuery( '.wppm-frm-ap-modal_popup' )[0];
1790 var dataform = new FormData( form );
1791 jQuery('.wppm_submit_wait').show();
1792 jQuery.ajax(
1793 {
1794 url: wppm_admin.ajax_url,
1795 type: 'POST',
1796 data: dataform,
1797 processData: false,
1798 contentType: false
1799 }
1800 ).done(
1801 function (response_str) {
1802 var response = JSON.parse(response_str);
1803 jQuery('.wppm_submit_wait').hide();
1804 if (response.sucess_status=='1') {
1805 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
1806 }
1807 jQuery('#wppm_alert_success').slideDown('fast',function(){});
1808 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
1809 }
1810 );
1811 }
1812
1813 function wppm_set_ap_grid_view(){
1814 var form = jQuery( '.wppm-frm-ap-grid_view' )[0];
1815 var dataform = new FormData( form );
1816 jQuery('.wppm_submit_wait').show();
1817 jQuery.ajax(
1818 {
1819 url: wppm_admin.ajax_url,
1820 type: 'POST',
1821 data: dataform,
1822 processData: false,
1823 contentType: false
1824 }
1825 ).done(
1826 function (response_str) {
1827 var response = JSON.parse(response_str);
1828 jQuery('.wppm_submit_wait').hide();
1829 if (response.sucess_status=='1') {
1830 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
1831 }
1832 jQuery('#wppm_alert_success').slideDown('fast',function(){});
1833 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
1834 }
1835 );
1836 }
1837
1838 function wppm_set_advanced_settings(){
1839 jQuery('.wppm_submit_wait').show();
1840 var dataform = new FormData(jQuery('#wppm_frm_advanced_settings')[0]);
1841 jQuery.ajax({
1842 url: wppm_admin.ajax_url,
1843 type: 'POST',
1844 data: dataform,
1845 processData: false,
1846 contentType: false
1847 })
1848 .done(function (response_str) {
1849 var response = JSON.parse(response_str);
1850 jQuery('.wppm_submit_wait').hide();
1851 if (response.sucess_status=='1') {
1852 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
1853 }
1854 jQuery('#wppm_alert_success').slideDown('fast',function(){});
1855 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
1856 });
1857 }
1858
1859 function wppm_get_project_visibility(id){
1860 wppm_modal_open('Change Visibility');
1861 var data = {
1862 action: 'wppm_get_project_visibility',
1863 id: id
1864 }
1865 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
1866 var response = JSON.parse(response_str);
1867 jQuery('#wppm_popup_body').html(response.body);
1868 jQuery('#wppm_popup_footer').html(response.footer);
1869 });
1870 }
1871
1872 function wppm_select_project_visibility(proj_id){
1873 if(jQuery('input[name="wppm_project_visibility_option"]').is(':checked')){
1874 var project_visibility = jQuery('input[name="wppm_project_visibility_option"]:checked').val();
1875 }else{
1876 var project_visibility = 0;
1877 }
1878 var data = {
1879 action: 'wppm_change_project_visibility',
1880 project_id:proj_id,
1881 project_visibility:project_visibility,
1882 _ajax_nonce:jQuery('#wppm_proj_visibility_ajax_nonce').val()
1883 };
1884 jQuery.post(wppm_admin.ajax_url, data, function() {
1885 });
1886 }
1887
1888 function wppm_apply_project_filter(is_archieved){
1889 wppm_project_filter = jQuery('#wppm_project_filter').find(":selected").val();
1890 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
1891 var data = {
1892 action: 'wppm_get_project_list',
1893 wppm_project_filter:wppm_project_filter,
1894 page:wppm_admin.page,
1895 is_archieved:is_archieved
1896 };
1897 jQuery.post(wppm_admin.ajax_url, data, function(response) {
1898 jQuery('#wppm_project_container').html(response);
1899 });
1900 }
1901
1902 function getWppmCookie(name) {
1903 const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
1904 if (match) return decodeURIComponent(match[2]);
1905 return null;
1906 }
1907
1908 function wppm_apply_task_filter(page = 1, listFilters = null) {
1909 // 🔥 use passed filters OR read from UI
1910 if (!listFilters) {
1911 listFilters = {
1912 created_by: jQuery("#tb-created-by").val() || [],
1913 assigned: jQuery("#tb-assigned").val() || [],
1914 priority: jQuery("#tb-priority").val() || [],
1915 start_date: jQuery("#tb-start-date").val() || "",
1916 end_date: jQuery("#tb-end-date").val() || ""
1917 };
1918 }
1919 // 🔥 get main filter
1920 let wppm_task_filter = jQuery('#wppm_task_filter').val();
1921 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
1922 jQuery.post(wppm_admin.ajax_url, {
1923 action: 'wppm_get_task_list',
1924 wppm_task_filter: wppm_task_filter,
1925 page: page,
1926 listFilters: JSON.stringify(listFilters) // �
1927 ALWAYS stringify
1928 }, function (response) {
1929 jQuery('#wppm_task_container').html(response);
1930 // 🔥 save cookie
1931 setListFilterCookie(listFilters);
1932 // 🔥 sync UI
1933 setTimeout(function () {
1934 syncUIWithFilters(listFilters);
1935 renderActiveFilters(listFilters);
1936 }, 100);
1937
1938 });
1939 }
1940
1941 function wppm_tl_reset_filter(page){
1942 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
1943 var data = {
1944 action: 'wppm_get_task_list',
1945 wppm_task_filter:'all',
1946 task_search:"",
1947 sort_by:"task_name",
1948 order:"ASC",
1949 wppm_proj_filter:0,
1950 page:page
1951 };
1952 jQuery.post(wppm_admin.ajax_url, data, function(response) {
1953 jQuery('#wppm_task_container').html(response);
1954 });
1955 // �
1956 close popup
1957 jQuery("#tb-advanced-panel").removeClass("tb-open");
1958 jQuery("#tb-backdrop").removeClass("active");
1959
1960 // �
1961 clear inputs
1962 jQuery('#tb-advanced-panel input').val('');
1963 jQuery('#tb-advanced-panel select').val([]);
1964
1965 // �
1966 clear chips
1967 jQuery("#tb-active-filters").html('');
1968 resetFilters('list');
1969 }
1970
1971 function wppm_apply_task_filter_grid_view(page,id,filters){
1972 wppm_task_filter = jQuery('#wppm_task_filter').find(":selected").val();
1973 if (!filters) {
1974 filters = {
1975 created_by: jQuery("#tb-created-by").val() || [],
1976 assigned: jQuery("#tb-assigned").val() || [],
1977 priority: jQuery("#tb-priority").val() || [],
1978 start_date: jQuery("#tb-start-date").val() || "",
1979 end_date: jQuery("#tb-end-date").val() || ""
1980 };
1981 }
1982 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
1983 var data = {
1984 action: 'wppm_view_project_tasks',
1985 wppm_task_filter:wppm_task_filter,
1986 page:page,
1987 id:id,
1988 filters: JSON.stringify(filters)
1989 };
1990 jQuery.post(wppm_admin.ajax_url, data, function(response) {
1991 jQuery('#wppm_task_container').html(response);
1992 // 🔥 save cookie
1993 setFilterCookie(filters);
1994
1995 // 🔥 sync UI
1996 setTimeout(function () {
1997 syncUIWithFilters(filters);
1998 renderActiveFilters(filters);
1999 }, 100);
2000 });
2001 }
2002
2003 function wppm_tl_reset_grid_view_filter(page,id){
2004 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
2005 var data = {
2006 action: 'wppm_view_project_tasks',
2007 wppm_task_filter:'all',
2008 task_search:"",
2009 sort_by:"task_name",
2010 order:"ASC",
2011 wppm_proj_filter:"0",
2012 page:page,
2013 id:id
2014 };
2015 jQuery.post(wppm_admin.ajax_url, data, function(response) {
2016 jQuery('#wppm_task_container').html(response);
2017 });
2018 // �
2019 close popup
2020 jQuery("#tb-advanced-panel").removeClass("tb-open");
2021 jQuery("#tb-backdrop").removeClass("active");
2022
2023 // �
2024 clear inputs
2025 jQuery('#tb-advanced-panel input').val('');
2026 jQuery('#tb-advanced-panel select').val([]);
2027
2028 // �
2029 clear chips
2030 jQuery("#tb-active-filters").html('');
2031 if(id!=0){
2032 resetFilters('kanban');
2033 }else{
2034 resetFilters('grid');
2035 }
2036 }
2037
2038 function wppm_pl_reset_filter(is_archieved){
2039 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
2040 var data = {
2041 action: 'wppm_get_project_list',
2042 wppm_project_filter:'all',
2043 project_search:"",
2044 sort_by:"project_name",
2045 order:"ASC",
2046 page:wppm_admin.page,
2047 is_archieved:is_archieved
2048 };
2049 jQuery.post(wppm_admin.ajax_url, data, function(response) {
2050 jQuery('#wppm_project_container').html(response);
2051 });
2052 }
2053
2054 function wppm_tasks_by_select_project(page){
2055 wppm_proj_filter = jQuery('#wppm_task_list_proj_filter').find(":selected").val();
2056 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
2057 var data = {
2058 action: 'wppm_get_task_list',
2059 wppm_proj_filter:wppm_proj_filter,
2060 page:page
2061 };
2062 jQuery.post(wppm_admin.ajax_url, data, function(response) {
2063 jQuery('#wppm_task_container').html(response);
2064 });
2065 }
2066
2067 function wppm_tasks_by_select_project_grid_view(page){
2068 wppm_proj_filter = jQuery('#wppm_task_list_proj_filter').find(":selected").val();
2069 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
2070 var data = {
2071 action: 'wppm_view_project_tasks',
2072 wppm_proj_filter:wppm_proj_filter,
2073 page:page
2074 };
2075 jQuery.post(wppm_admin.ajax_url, data, function(response) {
2076 jQuery('#wppm_task_container').html(response);
2077 });
2078 }
2079
2080 function wppm_reset_ap_proj_list(){
2081 jQuery( "#wppm_reset_ap_proj_list_btn" ).text( wppm_admin.please_wait );
2082 var _ajax_nonce = jQuery("#wppm_reset_ap_proj_list_nonce").val();
2083 var data = { action: 'wppm_reset_ap_proj_list',_ajax_nonce };
2084 jQuery.post(
2085 wppm_admin.ajax_url,
2086 data,
2087 function () {
2088 wppm_get_ap_proj_list('project-list');
2089 }
2090 );
2091 }
2092
2093 function wppm_reset_ap_task_list(){
2094 jQuery( "#wppm_reset_ap_task_list_btn" ).text( wppm_admin.please_wait );
2095 var _ajax_nonce = jQuery("#wppm_reset_ap_task_list_ajax_nonce").val();
2096 var data = { action: 'wppm_reset_ap_task_list',_ajax_nonce };
2097 jQuery.post(
2098 wppm_admin.ajax_url,
2099 data,
2100 function () {
2101 wppm_get_ap_task_list('task-list');
2102 }
2103 );
2104 }
2105
2106 function wppm_reset_ap_individual_proj(){
2107 jQuery( "#wppm_reset_ap_individual_proj_btn" ).text( wppm_admin.please_wait );
2108 var _ajax_nonce = jQuery( "#wppm_reset_ap_individual_proj_ajax_nonce").val();
2109 var data = { action: 'wppm_reset_ap_individual_proj',
2110 _ajax_nonce, };
2111 jQuery.post(
2112 wppm_admin.ajax_url,
2113 data,
2114 function () {
2115 wppm_get_ap_individual_proj('individual-project');
2116 }
2117 );
2118 }
2119
2120 function wppm_reset_ap_individual_task(){
2121 jQuery( "#wppm_reset_ap_individual_task_btn" ).text( wppm_admin.please_wait );
2122 var _ajax_nonce = jQuery( "#wppm_reset_ap_individual_task_ajax_nonce" ).val();
2123 var data = { action: 'wppm_reset_ap_individual_task',_ajax_nonce };
2124 jQuery.post(
2125 wppm_admin.ajax_url,
2126 data,
2127 function () {
2128 wppm_get_ap_individual_task('individual-task');
2129 }
2130 );
2131 }
2132
2133 function wppm_reset_ap_modal_popup(){
2134 jQuery( "#wppm_reset_ap_modal_popup_btn" ).text( wppm_admin.please_wait );
2135 var _ajax_nonce = jQuery( "#wppm_reset_ap_modal_popup_nonce" ).val();
2136 var data = { action: 'wppm_reset_ap_modal_popup',_ajax_nonce };
2137 jQuery.post(
2138 wppm_admin.ajax_url,
2139 data,
2140 function () {
2141 wppm_get_ap_modal_popup('modal-popup');
2142 }
2143 );
2144 }
2145
2146 function wppm_reset_ap_grid_view(){
2147 jQuery( "#wppm_reset_ap_grid_view_btn" ).text( wppm_admin.please_wait );
2148 var wppm_reset_grid_ajax_nonce = jQuery( "#wppm_reset_ap_grid_view_ajax_nonce" ).val();
2149 var data = {
2150 action: 'wppm_reset_ap_grid_view',
2151 wppm_reset_grid_ajax_nonce:wppm_reset_grid_ajax_nonce
2152 };
2153 jQuery.post(wppm_admin.ajax_url, data, function(response) {
2154 wppm_get_ap_grid_view('grid-view');
2155 });
2156 }
2157
2158 function wppm_reset_ap_settings(){
2159 jQuery( "#wppm_reset_ap_settings_btn" ).text( wppm_admin.please_wait );
2160 var _ajax_nonce = jQuery("#wppm_reset_ap_settings_nonce").val();
2161 var data = { action: 'wppm_reset_ap_settings',_ajax_nonce };
2162 jQuery.post(
2163 wppm_admin.ajax_url,
2164 data,
2165 function () {
2166 wppm_get_ap_settings('settings');
2167 }
2168 );
2169 }
2170 /**
2171 * Bulk selector change
2172 */
2173 function wppm_bulk_select_change() {
2174 jQuery("#wppm-bulk-actions-btn").show();
2175 var checked = jQuery(".wppm-bulk-selector").is(":checked");
2176 jQuery(".wppm-bulk-select").prop("checked", checked);
2177 if(!checked){
2178 jQuery("#wppm-bulk-actions-btn").hide();
2179 }
2180 }
2181
2182 function wppm_task_bulk_select_change() {
2183 jQuery("#wppm-task-bulk-actions-btn").show();
2184 var checked = jQuery(".wppm-bulk-selector").is(":checked");
2185 jQuery(".wppm-task-bulk-select").prop("checked", checked);
2186 if(!checked){
2187 jQuery("#wppm-bulk-actions-btn").hide();
2188 }
2189 }
2190
2191 function wppm_bulk_change_status(nonce){
2192 var items = jQuery(".wppm-bulk-select:checked");
2193 var checked = items.length === 0 ? false : true;
2194 jQuery(".wppm-bulk-selector").prop("checked", checked);
2195 if (items.length != 0) {
2196 var proj_ids = jQuery(".wppm-bulk-select:checked")
2197 .map(function () {
2198 return this.value;
2199 })
2200 .get();
2201 wppm_modal_open('Change Status');
2202 var data = {
2203 action: "wppm_get_bulk_change_proj_status",
2204 proj_ids,
2205 _ajax_nonce: nonce,
2206 };
2207 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
2208 var response = JSON.parse(response_str);
2209 jQuery('#wppm_popup_body').html(response.body);
2210 jQuery('#wppm_popup_footer').html(response.footer);
2211 });
2212 }
2213 }
2214
2215 function wppm_set_bulk_change_project_status(){
2216 var dataform = new FormData(jQuery('#frm_get_bulk_project_change_status')[0]);
2217 wppm_modal_close();
2218 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
2219 jQuery.ajax({
2220 url: wppm_admin.ajax_url,
2221 type: 'POST',
2222 data: dataform,
2223 processData: false,
2224 contentType: false
2225 })
2226 .done(function (response_str) {
2227 wppm_get_project_list();
2228 });
2229 }
2230
2231 function wppm_bulk_change_category(nonce){
2232 var items = jQuery(".wppm-bulk-select:checked");
2233 var checked = items.length === 0 ? false : true;
2234 jQuery(".wppm-bulk-selector").prop("checked", checked);
2235 if (items.length != 0) {
2236 var proj_ids = jQuery(".wppm-bulk-select:checked")
2237 .map(function () {
2238 return this.value;
2239 })
2240 .get();
2241 wppm_modal_open('Change Category');
2242 var data = {
2243 action: "wppm_get_bulk_change_proj_cat",
2244 proj_ids,
2245 _ajax_nonce: nonce,
2246 };
2247 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
2248 var response = JSON.parse(response_str);
2249 jQuery('#wppm_popup_body').html(response.body);
2250 jQuery('#wppm_popup_footer').html(response.footer);
2251 });
2252 }
2253 }
2254
2255 function wppm_set_bulk_change_project_category(){
2256 var dataform = new FormData(jQuery('#frm_get_bulk_project_change_category')[0]);
2257 wppm_modal_close();
2258 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
2259 jQuery.ajax({
2260 url: wppm_admin.ajax_url,
2261 type: 'POST',
2262 data: dataform,
2263 processData: false,
2264 contentType: false
2265 })
2266 .done(function (response_str) {
2267 wppm_get_project_list();
2268 });
2269 }
2270
2271 function wppm_bulk_assign_users(nonce){
2272 var items = jQuery(".wppm-bulk-select:checked");
2273 var checked = items.length === 0 ? false : true;
2274 jQuery(".wppm-bulk-selector").prop("checked", checked);
2275 if (items.length != 0) {
2276 var proj_ids = jQuery(".wppm-bulk-select:checked")
2277 .map(function () {
2278 return this.value;
2279 })
2280 .get();
2281 wppm_modal_open('Assign Co-workers');
2282 var data = {
2283 action: "wppm_get_bulk_assign_users",
2284 proj_ids,
2285 _ajax_nonce: nonce,
2286 };
2287 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
2288 var response = JSON.parse(response_str);
2289 jQuery('#wppm_popup_body').html(response.body);
2290 jQuery('#wppm_popup_footer').html(response.footer);
2291 });
2292 }
2293 }
2294
2295 function wppm_set_bulk_project_users(){
2296 var dataform = new FormData(jQuery('#frm_get_bulk_project_users')[0]);
2297 wppm_modal_close();
2298 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
2299 jQuery.ajax({
2300 url: wppm_admin.ajax_url,
2301 type: 'POST',
2302 data: dataform,
2303 processData: false,
2304 contentType: false
2305 })
2306 .done(function (response_str) {
2307 wppm_get_project_list();
2308 });
2309 }
2310
2311 function wppm_bulk_delete_project(nonce){
2312 var items = jQuery(".wppm-bulk-select:checked");
2313 var checked = items.length === 0 ? false : true;
2314 jQuery(".wppm-bulk-selector").prop("checked", checked);
2315 if (items.length != 0) {
2316 var proj_ids = jQuery(".wppm-bulk-select:checked")
2317 .map(function () {
2318 return this.value;
2319 })
2320 .get();
2321 wppm_modal_open('Delete Project');
2322 var data = {
2323 action: "wppm_get_bulk_delete_project",
2324 proj_ids,
2325 _ajax_nonce: nonce,
2326 };
2327 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
2328 var response = JSON.parse(response_str);
2329 jQuery('#wppm_popup_body').html(response.body);
2330 jQuery('#wppm_popup_footer').html(response.footer);
2331 });
2332 }
2333 }
2334
2335 function wppm_set_delete_bulk_projects(){
2336 var dataform = new FormData(jQuery('#frm_delete_bulk_project')[0]);
2337 wppm_modal_close();
2338 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
2339 jQuery.ajax({
2340 url: wppm_admin.ajax_url,
2341 type: 'POST',
2342 data: dataform,
2343 processData: false,
2344 contentType: false
2345 })
2346 .done(function (response_str) {
2347 wppm_get_project_list();
2348 });
2349 }
2350
2351 function wppm_bulk_change_task_status(nonce){
2352 var items = jQuery(".wppm-task-bulk-select:checked");
2353 var checked = items.length === 0 ? false : true;
2354 jQuery(".wppm-bulk-selector").prop("checked", checked);
2355 if (items.length != 0) {
2356 var task_ids = jQuery(".wppm-task-bulk-select:checked")
2357 .map(function () {
2358 return this.value;
2359 })
2360 .get();
2361 wppm_task_modal_open('Change Task Status');
2362 var data = {
2363 action: "wppm_get_bulk_change_task_status",
2364 task_ids,
2365 _ajax_nonce: nonce,
2366 };
2367 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
2368 var response = JSON.parse(response_str);
2369 jQuery('#wppm_task_popup_body').html(response.body);
2370 jQuery('#wppm_task_popup_footer').html(response.footer);
2371 });
2372 }
2373 }
2374
2375 function wppm_set_bulk_change_task_priority(){
2376 var dataform = new FormData(jQuery('#frm_get_bulk_task_change_priority')[0]);
2377 wppm_task_modal_close();
2378 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
2379 jQuery.ajax({
2380 url: wppm_admin.ajax_url,
2381 type: 'POST',
2382 data: dataform,
2383 processData: false,
2384 contentType: false
2385 })
2386 .done(function (response_str) {
2387 wppm_get_task_list();
2388 });
2389 }
2390
2391 function wppm_set_bulk_change_task_status(){
2392 var dataform = new FormData(jQuery('#frm_get_bulk_task_change_status')[0]);
2393 wppm_task_modal_close();
2394 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
2395 jQuery.ajax({
2396 url: wppm_admin.ajax_url,
2397 type: 'POST',
2398 data: dataform,
2399 processData: false,
2400 contentType: false
2401 })
2402 .done(function (response_str) {
2403 wppm_get_task_list();
2404 });
2405 }
2406
2407 function wppm_bulk_change_task_priority(nonce){
2408 var items = jQuery(".wppm-task-bulk-select:checked");
2409 var checked = items.length === 0 ? false : true;
2410 jQuery(".wppm-bulk-selector").prop("checked", checked);
2411 if (items.length != 0) {
2412 var task_ids = jQuery(".wppm-task-bulk-select:checked")
2413 .map(function () {
2414 return this.value;
2415 })
2416 .get();
2417 wppm_task_modal_open('Change Task Priority');
2418 var data = {
2419 action: "wppm_get_bulk_change_task_priority",
2420 task_ids,
2421 _ajax_nonce: nonce
2422 };
2423 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
2424 var response = JSON.parse(response_str);
2425 jQuery('#wppm_task_popup_body').html(response.body);
2426 jQuery('#wppm_task_popup_footer').html(response.footer);
2427 });
2428 }
2429 }
2430
2431 function wppm_bulk_delete_task(nonce){
2432 var items = jQuery(".wppm-task-bulk-select:checked");
2433 var checked = items.length === 0 ? false : true;
2434 jQuery(".wppm-bulk-selector").prop("checked", checked);
2435 if (items.length != 0) {
2436 var task_ids = jQuery(".wppm-task-bulk-select:checked")
2437 .map(function () {
2438 return this.value;
2439 })
2440 .get();
2441 wppm_task_modal_open('Delete Task');
2442 var data = {
2443 action: "wppm_get_bulk_delete_task",
2444 task_ids,
2445 _ajax_nonce: nonce,
2446 };
2447 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
2448 var response = JSON.parse(response_str);
2449 jQuery('#wppm_task_popup_body').html(response.body);
2450 jQuery('#wppm_task_popup_footer').html(response.footer);
2451 });
2452 }
2453 }
2454
2455 function wppm_set_delete_bulk_tasks(){
2456 var dataform = new FormData(jQuery('#frm_delete_bulk_tasks')[0]);
2457 wppm_task_modal_close();
2458 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
2459 jQuery.ajax({
2460 url: wppm_admin.ajax_url,
2461 type: 'POST',
2462 data: dataform,
2463 processData: false,
2464 contentType: false
2465 })
2466 .done(function (response_str) {
2467 wppm_get_task_list();
2468 });
2469 }
2470
2471 function wppm_print_task(id){
2472 jQuery('#wppmprint_menu').css('display', 'flex');
2473 }
2474
2475 function wppm_open_pdf(id){
2476 window.open(wppm_admin.ajax_url + "?action=wppm_get_task_pdf&id=" + id, "_blank");
2477 }
2478
2479 function wppm_download_pdf(id){
2480 window.open(wppm_admin.ajax_url + "?action=wppm_download_pdf&id=" + id, "_blank");
2481 }
2482
2483 function wppm_archive_task(id,is_archived,project_id){
2484 if (!confirm(wppm_admin.confirm)) {
2485 return;
2486 } else {
2487 var data = {
2488 action: 'wppm_archive_task',
2489 id: id,
2490 is_archived: is_archived,
2491 project_id: project_id,
2492 };
2493 jQuery.post(wppm_admin.ajax_url, data, function() {
2494 wppm_open_task(id,project_id);
2495 });
2496 }
2497 }
2498
2499 function wppm_archive_project(project_id,is_archived){
2500 if (!confirm(wppm_admin.confirm)) {
2501 return;
2502 } else {
2503 var data = {
2504 action: 'wppm_archive_project',
2505 project_id: project_id,
2506 is_archived: is_archived,
2507 };
2508 jQuery.post(wppm_admin.ajax_url, data, function() {
2509 wppm_open_project(project_id);
2510 });
2511 }
2512 }
2513
2514 function wppm_get_print_task_settings(){
2515 jQuery('.wppm_setting_pills li').removeClass('active');
2516 jQuery('#wppm_settings_print_task').addClass('active');
2517 jQuery('.wppm_setting_col2').html(wppm_admin.loading_html);
2518 var data = {
2519 action: 'wppm_get_print_task_settings'
2520 };
2521 jQuery.post(wppm_admin.ajax_url, data, function(response) {
2522 jQuery('.wppm_setting_col2').html(response);
2523 });
2524 }
2525
2526 function wppm_set_print_task_settings(){
2527 jQuery('.wppm_submit_wait').show();
2528 var dataform = new FormData(jQuery('#wppm_print_task_settings')[0]);
2529 jQuery.ajax({
2530 url: wppm_admin.ajax_url,
2531 type: 'POST',
2532 data: dataform,
2533 processData: false,
2534 contentType: false
2535 })
2536 .done(function (response_str) {
2537 var response = JSON.parse(response_str);
2538 jQuery('.wppm_submit_wait').hide();
2539 if (response.sucess_status=='1') {
2540 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
2541 }
2542 jQuery('#wppm_alert_success').slideDown('fast',function(){});
2543 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
2544 });
2545 }
2546
2547 function wppm_edit_checklist_item(item_id,checklist_id,proj_id,task_id){
2548 wppm_task_modal_open('Edit Checklist Item') ;
2549 var data = {
2550 action: 'wppm_edit_checklist_item',
2551 item_id:item_id,
2552 checklist_id: checklist_id,
2553 task_id: task_id,
2554 proj_id: proj_id,
2555 _ajax_nonce:jQuery('#wppm_edit_checklist_item_ajax_nonce').val()
2556 };
2557 jQuery.post(wppm_admin.ajax_url, data, function(response) {
2558 var response = JSON.parse(response);
2559 if(proj_id==0){
2560 jQuery('#wppm_task_popup_body').html(response.body);
2561 jQuery('#wppm_task_popup_footer').html(response.footer);
2562 }else{
2563 jQuery('#wppm_popup_body').html(response.body);
2564 jQuery('#wppm_popup_footer').html(response.footer);
2565 }
2566 });
2567 }
2568
2569 function wppm_set_checklist_item_name(item_id,checklist_id,task_id){
2570 var dataform = new FormData(jQuery('#frm_get_edit_checklist_item')[0]);
2571 wppm_task_modal_close();
2572 jQuery('#wppm_task_container').html(wppm_admin.loading_html);
2573 jQuery.ajax({
2574 url: wppm_admin.ajax_url,
2575 type: 'POST',
2576 data: dataform,
2577 processData: false,
2578 contentType: false
2579 })
2580 .done(function (response_str) {
2581 wppm_open_task(task_id);
2582 });
2583 }
2584
2585 function wppm_get_project_tasks_kanban_view(proj_id, KanbanFilters = {}) {
2586 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
2587 var data = {
2588 action: 'wppm_get_project_tasks_kanban_view',
2589 id: proj_id,
2590 filters: JSON.stringify(KanbanFilters)
2591 };
2592 jQuery.post(wppm_admin.ajax_url, data, function(response) {
2593 jQuery('#wppm_project_container').html(response);
2594 });
2595 }
2596
2597 function renderActiveFilters(filters) {
2598 let box = document.getElementById("tb-active-filters");
2599 if (!box) {
2600 return;
2601 }
2602 // CLEAR OLD CHIPS
2603 box.innerHTML = "";
2604 if (!filters || typeof filters !== "object") {
2605 return;
2606 }
2607 // CREATED BY
2608 if (Array.isArray(filters.created_by)) {
2609 filters.created_by.forEach(function(id) {
2610 let text = jQuery('#tb-created-by option[value="' + id + '"]').text();
2611 if (text) {
2612 createChip(text, "created_by", id);
2613 }
2614 });
2615 }
2616 // ASSIGNED
2617 if (Array.isArray(filters.assigned)) {
2618 filters.assigned.forEach(function(id) {
2619 let text = jQuery('#tb-assigned option[value="' + id + '"]').text();
2620 if (text) {
2621 createChip(text, "assigned", id);
2622 }
2623 });
2624 }
2625
2626 // PRIORITY
2627 if (Array.isArray(filters.priority)) {
2628 filters.priority.forEach(function(id) {
2629 let text = jQuery('#tb-priority option[value="' + id + '"]').text();
2630 if (text) {
2631 createChip(text, "priority", id);
2632 }
2633 });
2634 }
2635
2636 // DATE CHIP
2637 if (filters.start_date || filters.end_date) {
2638 let dateText =
2639 (filters.start_date || "") +
2640 "" +
2641 (filters.end_date || "");
2642 createChip(dateText, "date", "");
2643 }
2644 }
2645
2646 function renderMulti(filters, key, selector, label) {
2647 if (!filters || !filters[key]) {
2648 return;
2649 }
2650 let values = filters[key] || [];
2651 if (!Array.isArray(values) || values.length === 0) {
2652 return;
2653 }
2654 jQuery(selector + " option").each(function () {
2655 let val = String(jQuery(this).val());
2656 let text = jQuery(this).text();
2657 if (values.map(String).includes(val)) {
2658 createChip(`${label}: ${text}`, key, val);
2659 }
2660 });
2661 }
2662
2663 function createChip(text, key, value) {
2664 let container = document.getElementById("tb-active-filters");
2665 if (!container) {
2666 return;
2667 }
2668 let chip = document.createElement("span");
2669 chip.className = "tb-chip";
2670 chip.innerHTML = `
2671 ${key.charAt(0).toUpperCase() + key.slice(1)}: ${text}
2672 <span
2673 class="tb-remove"
2674 data-key="${key}"
2675 data-value="${value || ''}"
2676 >
2677
2678 </span>
2679 `;
2680 container.appendChild(chip);
2681 }
2682
2683 function syncUIWithFilters(filters) {
2684 jQuery("#tb-created-by")
2685 .val(filters.created_by || [])
2686 .trigger("change");
2687
2688 jQuery("#tb-assigned")
2689 .val(filters.assigned || [])
2690 .trigger("change");
2691
2692 jQuery("#tb-priority")
2693 .val(filters.priority || [])
2694 .trigger("change");
2695
2696 jQuery("#tb-start-date")
2697 .val(filters.start_date || "");
2698
2699 jQuery("#tb-end-date")
2700 .val(filters.end_date || "");
2701 }
2702
2703 function resetFilters(view_type) {
2704 let emptyFilters = {
2705 created_by: [],
2706 assigned: [],
2707 priority: [],
2708 start_date: "",
2709 end_date: "",
2710 id: jQuery('#wppm_proj_id').val() || 0
2711 };
2712 // Reset UI fields
2713 jQuery("#tb-created-by").val(null).trigger("change");
2714 jQuery("#tb-assigned").val(null).trigger("change");
2715 jQuery("#tb-priority").val(null).trigger("change");
2716 jQuery("#tb-start-date").val("");
2717 jQuery("#tb-end-date").val("");
2718 if (view_type === 'grid') {
2719 window.filters = { ...emptyFilters };
2720 // Delete cookie
2721 document.cookie =
2722 "tb_filters=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
2723 // Apply fresh filters
2724 wppm_apply_task_filter_grid_view('0',emptyFilters.id,window.filters);
2725 }
2726 if (view_type === 'list') {
2727 window.listFilters = { ...emptyFilters };
2728 // Delete cookie
2729 document.cookie =
2730 "tb_list_filters=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
2731 // Apply fresh filters
2732 wppm_apply_task_filter(1, window.listFilters);
2733 }
2734 if (view_type === 'kanban') {
2735 window.KanbanFilters = { ...emptyFilters };
2736 // Delete cookie
2737 document.cookie =
2738 "tb_kanban_filters=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
2739 // Apply fresh filters
2740 wppm_get_project_tasks_kanban_view(
2741 window.KanbanFilters.id,
2742 window.KanbanFilters
2743 );
2744 }
2745 }
2746
2747 function getFilterCookie() {
2748 let name = "tb_filters=";
2749 let arr = document.cookie.split(';');
2750 for (let i = 0; i < arr.length; i++) {
2751 let c = arr[i].trim();
2752 if (c.indexOf(name) === 0) {
2753 try {
2754 return JSON.parse(decodeURIComponent(c.substring(name.length)));
2755 } catch (e) {
2756 return null;
2757 }
2758 }
2759 }
2760 return null;
2761 }
2762
2763 function getListFilterCookie() {
2764 let name = "tb_list_filters=";
2765 let arr = document.cookie.split(';');
2766 for (let i = 0; i < arr.length; i++) {
2767 let c = arr[i].trim();
2768 if (c.indexOf(name) === 0) {
2769 try {
2770 return JSON.parse(decodeURIComponent(c.substring(name.length)));
2771 } catch (e) {
2772 return null;
2773 }
2774 }
2775 }
2776 return null;
2777 }
2778
2779 function getKanbanFilterCookie() {
2780 let name = "tb_kanban_filters=";
2781 let arr = document.cookie.split(';');
2782 for (let i = 0; i < arr.length; i++) {
2783 let c = arr[i].trim();
2784 if (c.indexOf(name) === 0) {
2785 try {
2786 return JSON.parse(decodeURIComponent(c.substring(name.length)));
2787 } catch (e) {
2788 return null;
2789 }
2790 }
2791 }
2792 return null;
2793 }
2794
2795 function setFilterCookie(filters) {
2796 document.cookie =
2797 "tb_filters=" + encodeURIComponent(JSON.stringify(filters)) +
2798 ";path=/;max-age=" + (60 * 60 * 24);
2799 }
2800
2801 function setListFilterCookie(listFilters) {
2802 document.cookie =
2803 "tb_list_filters=" + encodeURIComponent(JSON.stringify(listFilters)) +
2804 ";path=/;max-age=" + (60 * 60 * 24);
2805 }
2806
2807 function setKanbanFilterCookie(KanbanFilters) {
2808 document.cookie =
2809 "tb_kanban_filters=" + encodeURIComponent(JSON.stringify(KanbanFilters)) +
2810 ";path=/;max-age=" + (60 * 60 * 24);
2811 }
2812
2813 let filterTimeout;
2814 function triggerFilter(page = 1, filters = {}, view_type = 'list', proj_id = 0) {
2815 clearTimeout(filterTimeout);
2816 filterTimeout = setTimeout(function () {
2817 if (view_type === 'grid') {
2818 wppm_apply_task_filter_grid_view(
2819 page,
2820 proj_id,
2821 filters
2822 );
2823 }
2824 if (view_type === 'list') {
2825 wppm_apply_task_filter(
2826 page,
2827 filters
2828 );
2829 }
2830 if (view_type === 'kanban') {
2831 wppm_get_project_tasks_kanban_view(
2832 proj_id,
2833 filters
2834 );
2835 }
2836 }, 300);
2837 }
2838
2839 function wppm_archieve_project_list(){
2840 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
2841 var data = {
2842 action: 'wppm_archieve_project_list'
2843 };
2844 jQuery.post(wppm_admin.ajax_url, data, function(response) {
2845 jQuery('#wppm_project_container').html(response);
2846 });
2847 }
2848
2849 function wppm_get_archieve_project_list(page_no){
2850 jQuery('#wppm_project_container').html(wppm_admin.loading_html);
2851 var data = {
2852 action: 'wppm_get_project_list',
2853 page_no:page_no,
2854 is_archieved:1
2855 };
2856 jQuery.post(wppm_admin.ajax_url, data, function(response) {
2857 jQuery('#wppm_project_container').html(response);
2858 });
2859 }
2860