PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 1.0.2
Taskbuilder – Project Management & Task Management Tool With Kanban Board v1.0.2
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 / includes / admin / settings / wppm_get_category_settings.php

wppm_get_category_settings.php in Taskbuilder – Project Management & Task Management Tool With Kanban Board 1.0.2, at includes/admin/settings/wppm_get_category_settings.php

154 lines 6.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly
4 }
5
6 global $current_user, $wpdb,$wppmfunction;
7 if (!($current_user->ID && $current_user->has_cap('manage_options'))) {
8 exit;
9 }
10 $categories = $wpdb->get_results( "SELECT * FROM {$wpdb->prefix}wppm_project_categories ORDER BY load_order ASC" );
11 $cat_arr = array();
12 $cat_arr = $wpdb->get_results( "SELECT id FROM {$wpdb->prefix}wppm_project_categories" );
13 if(!empty($cat_arr)){
14 foreach($cat_arr as $key=>$val){
15 $categories_array= json_decode(json_encode($val));
16 $cat_ids[] = $categories_array->id;
17 }
18 $cat_ids = $wppmfunction->sanitize_array($cat_ids);
19 }
20 ?>
21 <div id="wppm_category_container">
22 <span class="wppm-title">
23 <?php echo esc_html_e('Project Categories','taskbuilder');?>
24 <span style="margin-left:10px;" class="wppm-add-new-btn wppm_btn btn-primary" onclick="wppm_get_add_category()"><?php echo esc_html_e('+Add New','taskbuilder');?></span>
25 </span>
26 <div class="wppm_padding_space"></div>
27 <ul class="wppm-sortable">
28 <?php if(!empty($categories)){
29 foreach ($categories as $key=>$value){ ?>
30 <li class="ui-state-default" data-id="<?php echo intval(esc_attr($value->id))?>">
31 <div class="wppm-flex-container" style="border:1px solid #ddd">
32 <div class="wppm-sortable-handle"><img src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/filter.svg'); ?>" alt="filter"></div>
33 <div class="wppm-sortable-label"><?php echo esc_html_e($value->name,'taskbuilder') ?></div>
34 <div class="wppm-sortable-edit" onclick="wppm_get_edit_category(<?php echo esc_attr($value->id) ?>);"><img src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/edit1.svg'); ?>" alt="edit"></div>
35 <div class="wppm-sortable-delete" onclick="wppm_delete_category(<?php echo esc_attr($value->id) ?>);"><img src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/trash.svg'); ?>" alt="delete"></div>
36 </div>
37 </li>
38 <?php }
39 }
40 ?>
41 </ul>
42 <div>
43 <script>
44 jQuery(function(){
45 jQuery( ".wppm-sortable" ).sortable({ handle: '.wppm-sortable-handle' });
46 jQuery( ".wppm-sortable" ).on("sortupdate",function(event,ui){
47 var keys = jQuery(this).sortable( "toArray", {attribute: 'data-id'} );
48 var order = <?php echo (!empty($cat_ids)) ? json_encode($cat_ids):"0" ?>;
49 var result = {};
50 for (var i = 0; i < keys.length; i++){
51 result[keys[i]] = order[i];
52 }
53 var data = {
54 action: 'wppm_set_category_order',
55 load_orders : result
56 };
57 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
58 var response = JSON.parse(response_str);
59 if (response.sucess_status==1) {
60 jQuery('#wppm_alert_success').show();
61 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
62 }
63 jQuery('#wppm_alert_success').slideDown('fast',function(){});
64 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 2000);
65 });
66 });
67 });
68
69 function wppm_get_add_category(){
70 wppm_modal_open('Add Category');
71 var data = {
72 action: 'wppm_get_add_category'
73 };
74 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
75 var response = JSON.parse(response_str);
76 jQuery('#wppm_popup_body').html(response.body);
77 jQuery('#wppm_popup_footer').html(response.footer);
78 jQuery('#wppm_cat_name').focus();
79 });
80 }
81
82 function wppm_set_add_category(){
83 var cat_name = jQuery('#wppm_cat_name').val().trim();
84 if (cat_name.length == 0) {
85 jQuery('#wppm_cat_name').val('').focus();
86 return;
87 }
88 jQuery('.wppm_popup_action').text('<?php _e('Please wait ...','taskbuilder')?>');
89 jQuery('.wppm_popup_action, #wppm_popup_body input').attr("disabled", "disabled");
90 var data = {
91 action: 'wppm_set_add_category',
92 cat_name : cat_name
93 };
94 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
95 wppm_modal_close();
96 var response = JSON.parse(response_str);
97 wppm_get_category_settings();
98 if (response.sucess_status=='1') {
99 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
100 jQuery('#wppm_alert_success').slideDown('fast',function(){});
101 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
102 wppm_get_category_settings();
103 } else {
104 jQuery('#wppm_alert_error .wppm_alert_text').text(response.messege);
105 jQuery('#wppm_alert_error').slideDown('fast',function(){});
106 setTimeout(function(){ jQuery('#wppm_alert_error').slideUp('fast',function(){}); }, 3000);
107 }
108 });
109 }
110
111 function wppm_get_edit_category(cat_id){
112 wppm_modal_open(wppm_admin.edit_category);
113 var data = {
114 action : 'wppm_get_edit_category',
115 cat_id:cat_id
116 };
117 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
118 var response = JSON.parse(response_str);
119 jQuery('#wppm_popup_body').html(response.body);
120 jQuery('#wppm_popup_footer').html(response.footer);
121 jQuery('#wppm_cat_name').focus();
122 });
123 }
124
125 function wppm_set_edit_category(cat_id){
126 var cat_name = jQuery('#wppm_edit_cat_name').val().trim();
127 if (cat_name.length == 0) {
128 jQuery('#wppm_edit_cat_name').val('').focus();
129 return;
130 }
131 jQuery('.wppm_popup_action').text('<?php _e('Please wait ...','taskbuilder')?>');
132 jQuery('.wppm_popup_action, #wppm_popup_body input').attr("disabled", "disabled");
133 var data = {
134 action : 'wppm_set_edit_category',
135 cat_id:cat_id,
136 cat_name:cat_name
137 };
138 jQuery.post(wppm_admin.ajax_url, data, function(response_str) {
139 wppm_modal_close();
140 var response = JSON.parse(response_str);
141 wppm_get_category_settings();
142 if (response.sucess_status=='1') {
143 jQuery('#wppm_alert_success .wppm_alert_text').text(response.messege);
144 jQuery('#wppm_alert_success').slideDown('fast',function(){});
145 setTimeout(function(){ jQuery('#wppm_alert_success').slideUp('fast',function(){}); }, 3000);
146 wppm_get_category_settings();
147 } else {
148 jQuery('#wppm_alert_error .wppm_alert_text').text(response.messege);
149 jQuery('#wppm_alert_error').slideDown('fast',function(){});
150 setTimeout(function(){ jQuery('#wppm_alert_error').slideUp('fast',function(){}); }, 3000);
151 }
152 });
153 }
154 </script>