PluginProbe
Taskbuilder – Project Management & Task Management Tool With Kanban Board / 6.0.6
Taskbuilder – Project Management & Task Management Tool With Kanban Board v6.0.6
6.0.6 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 All 58 releases
← All changes | includes/admin/projects/open_project/wppm_view_project_tasks.php +1335 -860 6.0.16.0.6 View file →
@@ -1,861 +1,1336 @@
1 -<?php
2 -if ( ! defined( 'ABSPATH' ) ) {
3 - exit; // Exit if accessed directly
4 -}
5 -global $wpdb,$current_user, $wppmfunction;
6 -$task_per_page = 20;
7 -$total_no_of_rows = 0;
8 -$totalrows_tasks = 0;
9 -$appearance_settings = get_option("wppm-ap-grid-view");
10 -$cu_id = absint($current_user->ID);
11 -$page_no = isset($_POST['page_no']) ? intval((sanitize_text_field(wp_unslash($_POST['page_no'])))) : '0';
12 -$orderby_sql = (sanitize_sql_orderby( "load_order ASC" ));
13 -$task_status = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}wppm_task_statuses ORDER BY $orderby_sql");
14 -$wppm_task_time = get_option('wppm_task_time');
15 -$page = isset($_POST['page']) ? sanitize_text_field(wp_unslash($_POST['page'])) : '';
16 -$id = isset($_POST['id']) ? intval(sanitize_text_field(wp_unslash($_POST['id']))) : 0;
17 -$project_id = isset($_POST['project_id']) ? intval(sanitize_text_field(wp_unslash($_POST['project_id']))) : "0";
18 -$wppm_date_setting = get_option('wppm_date_setting');
19 -$search_tag = isset($_POST['task_search']) ? sanitize_text_field(wp_unslash($_POST['task_search'])) : '';
20 -$filter_by = isset($_POST['wppm_task_filter']) ? sanitize_text_field(wp_unslash($_POST['wppm_task_filter'])) : "all";
21 -$proj_filter = isset($_POST['wppm_proj_filter']) ? absint(wp_unslash($_POST['wppm_proj_filter'])) : "0";
22 -$public_projects = isset($_POST['public_projects']) ? sanitize_text_field(wp_unslash($_POST['public_projects'])):"0";
23 -$wppm_current_user_capability = get_user_meta( $current_user->ID, 'wppm_capability', true );
24 -$wppm_hide_completed_status_task = get_option('wppm_hide_completed_status_task');
25 -$wppm_hide_task_statuses_from_frontend = get_option('wppm_hide_task_statuses_from_frontend');
26 -$wppm_deafault_time_duration_task = get_option('wppm_display_time_duration_task');
27 -if(!empty($wppm_hide_task_statuses_from_frontend)){
28 - $wppm_hide_task_statuses_from_frontend = explode(",",$wppm_hide_task_statuses_from_frontend);
29 -} else {
30 - $wppm_hide_task_statuses_from_frontend = '';
31 -}
32 -$filters = array(
33 - 'search' => $search_tag,
34 - 'filter'=>$filter_by,
35 - 'proj_filter'=>$proj_filter
36 -);
37 -$grid_view_filter = $filters ;
38 -$tl_filters = isset( $_COOKIE['wppm_grid_view_filters'] ) ? sanitize_text_field( wp_unslash( $_COOKIE['wppm_grid_view_filters'] ) ) : $grid_view_filter;
39 -$current_date = wp_date('Y-m-d');
40 -$proj_attr = isset($_POST['wppm_project_attr']) ? absint(wp_unslash($_POST['wppm_project_attr'])):"";
41 -$archived_where = " AND Task.is_archived = 0";
42 -if ( isset($page) && $page === 'wppm-archived-tasks' ) {
43 - $archived_where = " AND Task.is_archived = 1";
44 -}
45 -if( isset($page) && $page === 'wppm-tasks'){
46 - $archived_where = " AND Task.is_archived = 0";
47 -}
48 -if (!empty($proj_attr)) {
49 - $wppm_proj_attr = $wpdb->prepare(
50 - ' AND proj.project_name = %s',
51 - $proj_attr
52 - );
53 -} else {
54 - $wppm_proj_attr = '';
55 -}
56 -if ($id != 0 || $project_id != 0) {
57 - $final_project_id = ($project_id != 0) ? intval($project_id) : intval($id);
58 - $wppm_project_filter = $wpdb->prepare(
59 - ' AND Task.project = %d',
60 - $final_project_id
61 - );
62 -} else {
63 -
64 - $wppm_project_filter = '';
65 -}
66 -
67 -$query = ("SELECT proj.*
68 - FROM {$wpdb->prefix}wppm_project AS proj
69 - Left join {$wpdb->prefix}wppm_project_meta proj_meta ON proj.id = proj_meta.project_id");
70 -$santitize_order_by = esc_sql(sanitize_sql_orderby( "project_name ASC" ));
71 -if($current_user->has_cap('manage_options') || $wppm_current_user_capability == 'wppm_admin'){
72 - if(!empty($proj_attr )){
73 - $proj_attr = esc_sql($proj_attr);
74 - $where = $wpdb->prepare(
75 - " WHERE proj.project_name = %s AND proj.is_archived = 0
76 - GROUP BY proj.id
77 - ORDER BY {$santitize_order_by}",
78 - $proj_attr
79 - );
80 - }else{
81 - if(!empty($public_projects)){
82 - $where = $wpdb->prepare(
83 - " WHERE proj.id = proj_meta.project_id
84 - AND proj_meta.meta_key = %s
85 - AND proj_meta.meta_value = %d
86 - AND proj.is_archived = 0
87 - {$wppm_proj_attr}
88 - GROUP BY proj.id
89 - ORDER BY {$santitize_order_by}",
90 - 'public_project',
91 - 1
92 - );
93 - }else{
94 - $where = " WHERE proj.is_archived = 0 GROUP BY proj.id ORDER BY '$santitize_order_by'";
95 - }
96 - }
97 -}else{
98 - if(!empty($public_projects)){
99 - $where = $wpdb->prepare(
100 - " WHERE (
101 - proj.id = proj_meta.project_id
102 - AND proj_meta.meta_key = %s
103 - AND proj_meta.meta_value = %d
104 - )
105 - {$wppm_proj_attr} AND proj.is_archived = 0
106 - GROUP BY proj.id
107 - ORDER BY {$santitize_order_by}",
108 - 'public_project',
109 - 1
110 - );
111 - } else{
112 - $where = $wpdb->prepare(
113 - " WHERE (
114 - FIND_IN_SET(%d, proj.users) AND proj.is_archived = 0
115 - OR (
116 - proj.id = proj_meta.project_id
117 - AND proj_meta.meta_key = %s
118 - AND proj_meta.meta_value = %d
119 - )
120 - OR (
121 - proj.created_by = %d
122 - )
123 - )
124 - {$wppm_proj_attr}
125 - GROUP BY proj.id
126 - ORDER BY {$santitize_order_by}",
127 - $current_user->ID,
128 - 'public_project',
129 - 1,
130 - $cu_id
131 - );
132 - }
133 -}
134 -$where = apply_filters('wppm_project_filter_in_task_list_grid_view_where',$where);
135 -$query.= $where;
136 -$projects = $wpdb->get_results($query);
137 -$wppm_tl_filter = "1=1";
138 -if(!is_array($tl_filters)){
139 - $tl_filters = json_decode($tl_filters);
140 - $tl_filters_arr = (array) $tl_filters;
141 -} else{
142 -$tl_filters_arr = $filters;
143 -}
144 -$search_tag = isset($_POST['task_search']) ? sanitize_text_field(wp_unslash($_POST['task_search'])) : $tl_filters_arr['search'];
145 -$filter_by = isset($_POST['wppm_task_filter']) ? sanitize_text_field(wp_unslash($_POST['wppm_task_filter'])) : $tl_filters_arr['filter'];
146 -$proj_filter = isset($_POST['wppm_proj_filter']) ? absint(wp_unslash($_POST['wppm_proj_filter'])) : $tl_filters_arr['proj_filter'];
147 -$filters = array(
148 - 'search'=>$search_tag,
149 - 'filter'=>$filter_by,
150 - 'proj_filter' =>$proj_filter
151 -);
152 -setcookie('wppm_grid_view_filters',wp_json_encode( $filters ),time() + 3600);
153 -if($filter_by=='all'){
154 - if($wppm_hide_completed_status_task == 0){
155 - $wppm_tl_filter = "Task.status!='4'";
156 - }
157 -}
158 -if($filter_by=='4'){
159 - $wppm_tl_filter = "Task.status='4'";
160 -}elseif($filter_by=='overdue'){
161 - $wppm_tl_filter = "Task.status!='4' AND (CAST(Task.end_date AS DATE)) < '$current_date'";
162 -}elseif($filter_by == 'unassigned'){
163 - $wppm_tl_filter = "Task.users=''";
164 -}elseif($filter_by == '1'){
165 - $wppm_tl_filter = "Task.status='1'";
166 -}elseif($filter_by == '2'){
167 - $wppm_tl_filter = "Task.status='2'";
168 -}elseif($filter_by == '3'){
169 - $wppm_tl_filter = "Task.status='3'";
170 -}elseif($filter_by == 'mine'){
171 - $wppm_tl_filter = "(FIND_IN_SET('$current_user->ID',Task.users)>0)";
172 -}elseif($filter_by == 'archived'){
173 - $wppm_tl_filter = "Task.is_archived = 1";
174 -}
175 -
176 -if(!empty($wppm_hide_task_statuses_from_frontend) && is_array($wppm_hide_task_statuses_from_frontend) && (isset($_POST['is_frontend']) && sanitize_text_field($_POST['is_frontend'])==1)){
177 - foreach($wppm_hide_task_statuses_from_frontend as $status){
178 - $wppm_tl_filter .= " AND Task.status != '$status'";
179 - }
180 -}
181 -
182 -if($proj_filter!=0){
183 - $proj_filter = absint( $proj_filter );
184 - $wppm_task_by_proj_filter = $wpdb->prepare(
185 - "Task.project = %d AND proj.is_archived = 0",
186 - $proj_filter
187 - );
188 -}else{
189 - $wppm_task_by_proj_filter ="1=1";
190 -}
191 -if(!empty($task_status)){
192 - foreach($task_status as $status) {
193 - $status_id = absint($status->id);
194 - if(!empty($search_tag)){
195 - $search_tag_text = '%'.$wpdb->esc_like($search_tag).'%';
196 - if($current_user->has_cap('manage_options') || $wppm_current_user_capability == 'wppm_admin'){
197 - $query = ("SELECT Task.*
198 - FROM {$wpdb->prefix}wppm_task AS Task
199 - Left join {$wpdb->prefix}wppm_project proj ON Task.project = proj.id
200 - Left join {$wpdb->prefix}wppm_task_statuses task_statuses ON Task.status = task_statuses.id
201 - Left join {$wpdb->prefix}wppm_task_priorities task_priorities ON Task.priority = task_priorities.id
202 - Left join {$wpdb->base_prefix}users user ON (FIND_IN_SET(user.ID,Task.users)>0)
203 - Left join {$wpdb->prefix}wppm_project_meta proj_meta ON Task.project = proj_meta.project_id
204 - ");
205 - $no_of_rows = ( "SELECT count(*) FROM ($query");
206 - if(!empty($public_projects)){
207 - $where = $wpdb->prepare(
208 - " WHERE (
209 - proj_meta.meta_key = %s
210 - AND proj_meta.meta_value = %d
211 - )
212 - AND proj.is_archived = 0
213 - AND {$wppm_tl_filter}
214 - AND {$wppm_task_by_proj_filter}
215 - AND (
216 - Task.task_name LIKE %s
217 - OR proj.project_name LIKE %s
218 - OR task_statuses.name LIKE %s
219 - OR task_priorities.name LIKE %s
220 - OR user.display_name LIKE %s
221 - )
222 - AND Task.status = %d ",
223 - 'public_project',
224 - 1,
225 - $search_tag_text,
226 - $search_tag_text,
227 - $search_tag_text,
228 - $search_tag_text,
229 - $search_tag_text,
230 - $status_id
231 - );
232 - }else{
233 - $where = $wpdb->prepare(
234 - " WHERE {$wppm_tl_filter} AND proj.is_archived = 0
235 - AND {$wppm_task_by_proj_filter}
236 - AND (
237 - Task.task_name LIKE %s
238 - OR proj.project_name LIKE %s
239 - OR task_statuses.name LIKE %s
240 - OR task_priorities.name LIKE %s
241 - OR user.display_name LIKE %s
242 - )
243 - AND Task.status = %d ",
244 - $search_tag_text,
245 - $search_tag_text,
246 - $search_tag_text,
247 - $search_tag_text,
248 - $search_tag_text,
249 - $status_id
250 - );
251 - }
252 - } else{
253 - $query = ("SELECT Task.*
254 - FROM {$wpdb->prefix}wppm_task AS Task
255 - Left join {$wpdb->prefix}wppm_project proj ON Task.project = proj.id
256 - Left join {$wpdb->prefix}wppm_task_statuses task_statuses ON Task.status = task_statuses.id
257 - Left join {$wpdb->prefix}wppm_task_priorities task_priorities ON Task.priority = task_priorities.id
258 - Left join {$wpdb->prefix}wppm_project_users proj_users ON Task.project = proj_users.proj_id
259 - Left join {$wpdb->base_prefix}users user ON (FIND_IN_SET(user.ID,Task.users)>0)
260 - Left join {$wpdb->prefix}wppm_project_meta proj_meta ON Task.project = proj_meta.project_id
261 - ");
262 - $no_of_rows = ( "SELECT count(*) FROM ($query");
263 - if(!empty($public_projects)){
264 - $where = $wpdb->prepare(
265 - " WHERE (
266 - proj_meta.meta_key = %s
267 - AND proj_meta.meta_value = %d
268 - )
269 - AND proj.is_archived = 0
270 - AND {$wppm_tl_filter}
271 - AND {$wppm_task_by_proj_filter}
272 - AND (
273 - Task.task_name LIKE %s
274 - OR proj.project_name LIKE %s
275 - OR task_statuses.name LIKE %s
276 - OR task_priorities.name LIKE %s
277 - OR user.display_name LIKE %s
278 - )
279 - AND Task.status = %d ",
280 - 'public_project',
281 - 1,
282 - $search_tag_text,
283 - $search_tag_text,
284 - $search_tag_text,
285 - $search_tag_text,
286 - $search_tag_text,
287 - $status_id
288 - );
289 - }else{
290 - $where = $wpdb->prepare(
291 - " WHERE {$wppm_tl_filter} AND proj.is_archived = 0
292 - AND {$wppm_task_by_proj_filter}
293 - AND (
294 - (
295 - FIND_IN_SET(%d, Task.users) > 0
296 - OR Task.created_by = %d
297 - OR (
298 - proj_users.user_id = %d
299 - AND proj_users.role_id = %d
300 - AND FIND_IN_SET(%d, proj.users) > 0
301 - )
302 - OR (
303 - Task.project = proj_meta.project_id
304 - AND proj_meta.meta_key = %s
305 - AND proj_meta.meta_value = %d
306 - )
307 - OR proj.created_by = %d
308 - )
309 - AND (
310 - Task.task_name LIKE %s
311 - OR proj.project_name LIKE %s
312 - OR task_statuses.name LIKE %s
313 - OR task_priorities.name LIKE %s
314 - OR user.display_name LIKE %s
315 - )
316 - )
317 - AND Task.status = %d ",
318 - $current_user->ID,
319 - $cu_id,
320 - $cu_id,
321 - 1,
322 - $current_user->ID,
323 - 'public_project',
324 - 1,
325 - $cu_id,
326 - $search_tag_text,
327 - $search_tag_text,
328 - $search_tag_text,
329 - $search_tag_text,
330 - $search_tag_text,
331 - $status_id
332 - );
333 - }
334 - }
335 - }else{
336 - if($current_user->has_cap('manage_options') || $wppm_current_user_capability == 'wppm_admin'){
337 - $query = ( "SELECT Task.* FROM {$wpdb->prefix}wppm_task AS Task
338 - Left join {$wpdb->prefix}wppm_project proj ON Task.project = proj.id
339 - Left join {$wpdb->prefix}wppm_project_meta proj_meta ON Task.project = proj_meta.project_id
340 - ");
341 - $no_of_rows = ( "SELECT count(*) FROM ($query");
342 - if(!empty($public_projects)){
343 - $where = $wpdb->prepare(
344 - " WHERE (
345 - proj_meta.meta_key = %s
346 - AND proj_meta.meta_value = %d
347 - )
348 - AND {$wppm_tl_filter}
349 - AND proj.is_archived = 0
350 - AND {$wppm_task_by_proj_filter}
351 - AND Task.status = %d ",
352 - 'public_project',
353 - 1,
354 - $status_id
355 - );
356 - }else{
357 - $where = $wpdb->prepare(
358 - " WHERE {$wppm_tl_filter}
359 - AND {$wppm_task_by_proj_filter}
360 - AND proj.is_archived = 0
361 - AND Task.status = %d ",
362 - $status_id
363 - );
364 - }
365 - }else{
366 - $query = ( "SELECT Task.*
367 - FROM {$wpdb->prefix}wppm_task AS Task
368 - Left join {$wpdb->prefix}wppm_project proj ON Task.project = proj.id
369 - Left join {$wpdb->prefix}wppm_project_users proj_users ON Task.project = proj_users.proj_id
370 - Left join {$wpdb->prefix}wppm_project_meta proj_meta ON Task.project = proj_meta.project_id
371 - ");
372 - $no_of_rows = ( "SELECT count(*) FROM ($query");
373 - if(!empty($public_projects)){
374 - $where = $wpdb->prepare(
375 - " WHERE (
376 - proj_meta.meta_key = %s
377 - AND proj_meta.meta_value = %d
378 - )
379 - AND {$wppm_tl_filter}
380 - AND proj.is_archived = 0
381 - AND {$wppm_task_by_proj_filter}
382 - AND Task.status = %d ",
383 - 'public_project',
384 - 1,
385 - $status_id
386 - );
387 - } else{
388 - $where = $wpdb->prepare(
389 - " WHERE {$wppm_tl_filter}
390 - AND {$wppm_task_by_proj_filter}
391 - AND proj.is_archived = 0
392 - AND (
393 - FIND_IN_SET(%d, Task.users) > 0
394 - OR Task.created_by = %d
395 - OR (
396 - proj_users.user_id = %d
397 - AND proj_users.role_id = %d
398 - AND FIND_IN_SET(%d, proj.users) > 0
399 - )
400 - OR (
401 - Task.project = proj_meta.project_id
402 - AND proj_meta.meta_key = %s
403 - AND proj_meta.meta_value = %d
404 - )
405 - OR proj.created_by = %d
406 - )
407 - AND Task.status = %d ",
408 - $current_user->ID,
409 - $cu_id,
410 - $cu_id,
411 - 1,
412 - $current_user->ID,
413 - 'public_project',
414 - 1,
415 - $cu_id,
416 - $status_id
417 - );
418 - }
419 - }
420 - }
421 - $query = apply_filters('wppm_query_for_grid_view',$query);
422 - $no_of_rows = apply_filters('wppm_number_of_rows_query_for_grid_view',$no_of_rows);
423 - $where.= $wppm_proj_attr;
424 - if($filter_by != 'archived'){
425 - $where .= $archived_where;
426 - }
427 - if($id!=0){
428 - $where .=$wppm_project_filter;
429 - }
430 - $where = apply_filters('wppm_task_list_where_for_grid_view',$where,$wppm_tl_filter,$search_tag);
431 - $no_of_rows .= $where;
432 - $no_of_rows .= " Group by Task.id) AS Task";
433 - $no_of_rows = apply_filters('wppm_task_list_no_of_rows_for_grid_view',$no_of_rows);
434 - $totalrows = $wpdb->get_var($no_of_rows);
435 - $totalrows_tasks +=$totalrows;
436 - if($total_no_of_rows > $totalrows){
437 - $totalrows = $total_no_of_rows;
438 - }else{
439 - $total_no_of_rows = $totalrows;
440 - }
441 - $limit_start=$page_no*$task_per_page;
442 - $limit="\n LIMIT ".$limit_start.",".$task_per_page." ";
443 - $current_page=$page_no+1;
444 - $query = apply_filters('wppm_tasks_grid_view_query',$query,$search_tag);
445 - $where .= " Group by Task.id";
446 - $query .= $where;
447 - $query = apply_filters('wppm_task_list_grid_view_query',$query);
448 - $query = $query.$limit;
449 - $wppm_task_fillter[] = $wpdb->get_results($query);
450 - }
451 - $total_pages=ceil($total_no_of_rows/$task_per_page);
452 - $prev_page_no=$current_page-1;
453 - $prev_class=(!$prev_page_no)?'disabled':'';
454 - $next_page_no=($total_pages==$current_page)? $current_page-1:$current_page;
455 - $next_class=($total_pages==$current_page)?'disabled':'';
456 - $flag = false;
457 - if(!empty($wppm_task_fillter)){
458 - foreach($wppm_task_fillter as $key_filter=>$val_filter){
459 - foreach($val_filter as $key=>$val){
460 - $val_array = (array) $val;
461 - $tusers = $val_array['users'];
462 - $tusers_arr = explode(',',$tusers);
463 - $tproject_id = ($val_array['project']);
464 - if(!empty($tusers) && in_array($current_user->ID,$tusers_arr)){
465 - $project_user_role = $wpdb->get_var( $wpdb->prepare("SELECT role_id FROM {$wpdb->prefix}wppm_project_users WHERE proj_id = %d AND user_id = %d", absint($tproject_id), absint($cu_id)));
466 - $project_users = $wpdb->get_var( $wpdb->prepare( "SELECT users FROM {$wpdb->prefix}wppm_project WHERE id = %d", absint($tproject_id)));
467 - $project_users_arr = explode(',',(string)$project_users);
468 - if((!empty($project_user_role)) && ($project_user_role == 1) && in_array($current_user->ID,$project_users_arr)){
469 - $flag = true;
470 - break;
471 - }
472 - }
473 - }
474 - }
475 - }
476 -}
477 -$todo_status_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->prefix}wppm_task_statuses where id=%d",1));
478 -$inp_status_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->prefix}wppm_task_statuses where id=%d",2));
479 -$hold_status_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->prefix}wppm_task_statuses where id=%d",3));
480 -$completed_status_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->prefix}wppm_task_statuses where id=%d",4));
481 -$todo_status_style = (!empty($todo_status_name))? "display:inline" :"display:none;";
482 -$inp_status_style = (!empty($inp_status_name))? "display:inline" :"display:none;";
483 -$hold_status_style = (!empty($hold_status_name))? "display:inline" :"display:none;";
484 -$completed_status_style = (!empty($completed_status_name))? "display:inline" :"display:none;";
485 -if ( empty( $id ) ) {
486 - $proj_filter_style = 'display:inline;';
487 -} else {
488 - $proj_filter_style = 'display:none;';
489 -}
490 -if( isset($page) && $page === 'wppm-tasks'){
491 - $arch_filter_style = "display:inline;";
492 - $dashboard_style = "display:inline;";
493 -}else{
494 - $arch_filter_style = "display:none;";
495 - $dashboard_style = "display:none;";
496 -}
497 -
498 -if ( isset($page) && $page === 'wppm-archived-tasks' ) {
499 - $arch_filter_style = "display:none;";
500 -} else {
501 - $arch_filter_style = "display:flex;";
502 -}
503 -?>
504 -<form name="wppm_view_project_task" id="wppm_view_project_task">
505 - <div class="row">
506 - <div class="col-sm-12">
507 - <?php
508 - if(($current_user->has_cap('manage_options') || $wppmfunction->has_permission('add_new_task',0) || $wppm_current_user_capability=='wppm_manager'|| ($flag==true)) && (isset($page) && $page != 'wppm-archived-tasks' )){
509 - $style = "display:inline;";
510 - }else{
511 - $style = "display:none;";
512 - }
513 - $style = apply_filters('wppm_add_new_task_btn_style_grid_view',$style);
514 - ?>
515 - <span class="wppm-heading-inline" style="<?php echo esc_attr($proj_filter_style);?>"><?php echo (isset($page) && $page === 'wppm-archived-tasks' ) ? esc_html_e('Archived Tasks','taskbuilder'): esc_html_e('Tasks','taskbuilder');?> </span>
516 - <span class="wppm-add-new-btn btn-primary" onclick="wppm_add_new_task('',<?php echo (int)$id; ?>)" style="background-color:<?php echo esc_attr($appearance_settings['menu-button-bg-color'])?>;color:<?php echo esc_attr($appearance_settings['menu-button-text-color'])?>;<?php echo esc_attr($style) ?>;<?php echo esc_attr($proj_filter_style);?>"><img class="wppm_add_new_task_img" src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/plus_icon.svg'); ?>" alt="add"><?php echo esc_html__('Add New','taskbuilder');?></span>
517 - <!-- Dashboard Button -->
518 - <span class="wppm-add-new-btn btn-primary" style="<?php echo esc_attr($dashboard_style);?>;background-color:<?php echo esc_attr($appearance_settings['menu-button-bg-color'])?>;color:<?php echo esc_attr($appearance_settings['menu-button-text-color'])?>;margin-right:3px;"><a href="<?php echo esc_url( admin_url('admin.php?page=wppm-dashboard') ); ?>"
519 - style="margin-right:10px;">
520 - <img src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/dashboard.svg'); ?>" alt="dashboard_icon">
521 - <?php esc_html_e('Dashboard','taskbuilder'); ?>
522 - </a></span>
523 - <span class="wppm-add-new-btn btn-primary" style="background-color:<?php echo esc_attr($appearance_settings['menu-button-bg-color'])?>;<?php echo esc_attr($proj_filter_style);?>; id="wppm_task_list" onclick="wppm_get_task_list()" ><span><img class="wppm_task_list_image" src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/list-symbol.svg'); ?>" alt="list"></span><span style="color:<?php echo esc_attr($appearance_settings['menu-button-text-color'])?>;<?php echo esc_attr($proj_filter_style);?>"><?php echo esc_html__('Task List','taskbuilder');?></span></span>
524 - </div>
525 - </div>
526 - <div style="display:flex;justify-content:space-between;margin-top: 20px;flex-wrap: wrap;">
527 - <div style="display:flex;flex-wrap: wrap;">
528 - <div id="wppm_task_filter_container">
529 - <div class="wppm-filter-item">
530 - <label for="wppm_task_filter"> <?php echo esc_html__('Filter','taskbuilder');?></label>
531 - <select id="wppm_task_filter" name="wppm_task_filter" onchange="wppm_apply_task_filter_grid_view('<?php echo esc_attr($page)?>','<?php echo esc_attr($id)?>')" class="form-control">
532 - <option value="all"<?php echo ($filter_by == "all")? 'selected':""?>><?php echo esc_html__('All','taskbuilder');?></option>
533 - <option value="1" style="<?php echo esc_attr($todo_status_style) ?>" <?php echo ($filter_by == "1")? 'selected':""?>><?php echo esc_html__($todo_status_name);?></option>
534 - <option value="2" style="<?php echo esc_attr($inp_status_style) ?>" <?php echo ($filter_by == "2")? 'selected':""?>><?php echo esc_html__($inp_status_name);?></option>
535 - <option value="3" style="<?php echo esc_attr($hold_status_style) ?>" <?php echo ($filter_by == "3")? 'selected':""?>><?php echo esc_html__($hold_status_name);?></option>
536 - <option value="4" style="<?php echo esc_attr($completed_status_style) ?>" <?php echo ($filter_by == "4")? 'selected':""?>><?php echo esc_html__($completed_status_name);?></option>
537 - <option value="mine" <?php echo ($filter_by == "mine")? 'selected':""?>><?php echo esc_html__('Mine','taskbuilder');?></option>
538 - <option value="unassigned" <?php echo ($filter_by == "unassigned")? 'selected':""?>><?php echo esc_html__('Unassigned','taskbuilder');?></option>
539 - <option value="overdue" <?php echo ($filter_by == "overdue")? 'selected':""?>><?php echo esc_html__('Overdue','taskbuilder');?></option>
540 - <option value="archived" style="<?php echo esc_attr($arch_filter_style) ?>" <?php echo ($filter_by == "archived")? 'selected':""?>><?php echo esc_html__('Archived','taskbuilder');?></option>
541 - </select>
542 - </div>
543 - <div class="wppm-filter-item wppm_project_autocomplete_container" style="<?php echo esc_attr($proj_filter_style)?>">
544 - <label for="wppm_task_list_proj_filter">
545 - <?php echo esc_html__('Project','taskbuilder');?>
546 - </label><br>
547 - <select searchable="search here" onchange="wppm_tasks_by_select_project_grid_view('<?php echo esc_attr($page)?>')" class="form-control" size="40" name="wppm_task_list_proj_filter" id="wppm_task_list_proj_filter">
548 - <option value="0" <?php echo ($proj_filter == 0)? 'selected':""?>><?php echo esc_html__('All','taskbuilder');?></option>
549 - <?php
550 - if(!empty($projects)){
551 - foreach($projects as $proj) {
552 - ?>
553 - <option value="<?php echo esc_attr($proj->id)?>" <?php echo ($proj_filter == $proj->id)? 'selected':""?>><?php echo esc_html($proj->project_name,'taskbuilder');?></option>
554 - <?php }
555 - } ?>
556 - </select>
557 - </div>
558 - <div class="wppm_display_submit">
559 - <div class="wppm-filter-actions">
560 - <span class="wppm-link" onclick="wppm_tl_reset_grid_view_filter('<?php echo esc_attr($page)?>',<?php echo esc_attr($id)?>)"> <?php echo esc_html__('Reset','taskbuilder');?></span>
561 - </div>
562 - </div>
563 - </div>
564 - </div>
565 - <div id="wppm_task_search" style="display:flex;justify-content:flex-end;">
566 - <img width="25px" height="15" class="wppm_task_search_filter_img" style="position: relative;top: 10px;left: 30px;" height="15px" src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/search.svg'); ?>" alt="search">
567 - <input type="search" id="wppm_view_task_search_filter" style="margin-right:10px;" name="wppm_view_task_search_filter" class="form-control form-control-sm" aria-controls="selection-datatable" placeholder="<?php echo esc_attr__('Search','taskbuilder');?>" value="<?php echo (!empty($search_tag)) ? esc_attr($search_tag) : "" ?>">
568 - </div>
569 - </div>
570 - <input type="hidden" name="wppm_proj_id" id="wppm_proj_id" value="<?php echo esc_attr($id);?>">
571 - <div style="display:flex;justify-content:flex-end;margin-right:10px;">
572 - <span id="wppm_list_view_btn" style="margin: 0 0 -30px 0;<?php echo esc_attr($proj_filter_style);?>" onclick="wppm_get_task_list(0,<?php echo esc_attr($id)?>)"><img src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/listv.svg'); ?>" alt="list"><span style="margin-left:5px;"><?php echo esc_html__('List view','taskbuilder');?></span></span>
573 - </div>
574 - <div class="wppm_task_container" id="wppm_task_container" style="display:flex;">
575 - <?php
576 - if(!empty($task_status)){
577 - foreach($task_status as $status) {
578 - ?>
579 - <div class="wppm_task_list" id="wppm_task_list_<?php echo esc_attr($status->id)?>" style="display:flex;justify-content:space-between;flex-direction: column;flex-basis: 20%;">
580 - <div>
581 - <div style="background-color:<?php echo esc_attr($status->bg_color)?>;color:<?php echo esc_attr($status->color);?>;padding:5px;">
582 - <span class="wppm_status_name"><?php echo esc_html($status->name);?></span>
583 - <span class="wppm_add_new_icon" onclick="wppm_add_new_task('',<?php echo (int)$id; ?>)"><img src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/add_new1.svg'); ?>" alt="add"></span>
584 - </div>
585 - </div>
586 - <div id="wppm_card_body_container_<?php echo esc_attr($status->id) ?>" style="height:100%;">
587 - <?php
588 - $total_checklist_items=0;
589 - $total_checked_items=0;
590 - $task_per_status = false;
591 - $total_tasks = 0;
592 - if(!empty($wppm_task_fillter)){
593 - foreach($wppm_task_fillter as $key=>$tasks){
594 - foreach($tasks as $task){
595 - $total_tasks++;
596 - $wppm_task_duration = $wppmfunction->wppm_get_duration($task->start_date,$task->end_date);
597 - if((!empty($task)) && $task->status==$status->id){
598 - $task_per_status = true;
599 - if(isset($task->priority)){
600 - $tpriority = ($task->priority);
601 - $task_priority = $wpdb->get_row(
602 - $wpdb->prepare(
603 - "SELECT * FROM {$wpdb->prefix}wppm_task_priorities
604 - WHERE id = %d",
605 - absint($tpriority)
606 - )
607 - );
608 - }
609 - if($wppm_task_time == 1){
610 - $task_end_date = $task->end_date;
611 - $teDate = new DateTime($task->end_date);
612 - if($task->end_date=='0000-00-00 00:00:00'){
613 - if($wppm_date_setting=='Y-m-d H:i:s'){
614 - $task_end_date = '0000-00-00 00:00:00';
615 - }elseif($wppm_date_setting=='d-m-Y H:i:s'){
616 - $task_end_date = '00-00-0000 00:00:00';
617 - }elseif($wppm_date_setting=='m-d-Y H:i:s'){
618 - $task_end_date = '00-00-0000 00:00:00';
619 - }else{
620 - $task_end_date = '0000-00-00 00:00:00';
621 - }
622 - }else{
623 - $task_end_date = $teDate->format($wppm_date_setting);
624 - }
625 - }elseif($wppm_task_time == 0){
626 - $teDate = new DateTime($task->end_date);
627 - $task_end_date = $teDate->format('Y-m-d');
628 - if($task->end_date=='0000-00-00 00:00:00'){
629 - if($wppm_date_setting=='Y-m-d H:i:s'){
630 - $task_end_date = '0000-00-00';
631 - }elseif($wppm_date_setting=='d-m-Y H:i:s'){
632 - $task_end_date = '00-00-0000';
633 - }elseif($wppm_date_setting=='m-d-Y H:i:s'){
634 - $task_end_date = '00-00-0000';
635 - }else{
636 - $task_end_date = '0000-00-00';
637 - }
638 - }else{
639 - if($wppm_date_setting=='Y-m-d H:i:s'){
640 - $task_end_date = $teDate->format('Y-m-d');
641 - }elseif($wppm_date_setting=='d-m-Y H:i:s'){
642 - $task_end_date = $teDate->format('d-m-Y');
643 - }elseif($wppm_date_setting=='m-d-Y H:i:s'){
644 - $task_end_date = $teDate->format('m-d-Y');
645 - }else{
646 - $task_end_date = $teDate->format('Y-m-d');
647 - }
648 - }
649 - }
650 - if(!empty($task->id)){
651 - $tid = absint( $task->id );
652 - $checklists = $wpdb->get_results(
653 - $wpdb->prepare(
654 - "SELECT * FROM {$wpdb->prefix}wppm_checklist WHERE task_id = %d",
655 - $tid
656 - )
657 - );
658 - $total = $wpdb->get_var(
659 - $wpdb->prepare(
660 - "SELECT COUNT(Items.id)
661 - FROM {$wpdb->prefix}wppm_checklist_items AS Items
662 - LEFT JOIN {$wpdb->prefix}wppm_checklist AS checklist
663 - ON Items.checklist_id = checklist.id
664 - WHERE checklist.task_id = %d",
665 - $tid
666 - )
667 - );
668 - $total_checked_items = (int) $wpdb->get_var(
669 - $wpdb->prepare(
670 - "SELECT COUNT(Items.id)
671 - FROM {$wpdb->prefix}wppm_checklist_items AS Items
672 - INNER JOIN {$wpdb->prefix}wppm_checklist AS checklist
673 - ON Items.checklist_id = checklist.id
674 - WHERE checklist.task_id = %d
675 - AND Items.checked = 1",
676 - absint($tid)
677 - )
678 - );
679 - $project_data = $wppmfunction->get_project($task->project);
680 - ?>
681 - <div class="wppm_card_body" style="background-color:<?php echo esc_attr($appearance_settings['grid-background-color'])?>!important;color:<?php echo esc_attr($appearance_settings['grid-header-text-color'])?>!important;" onclick="wppm_open_task(<?php echo esc_attr($task->id)?>,<?php echo esc_attr($id);?>)" id="wppm_draggable_card_<?php echo esc_attr($task->id)?>">
682 - <div>
683 - <div>
684 - <span class="wppm_td_task_priority" style="background-color:<?php echo (!empty($task_priority->bg_color))? esc_attr($task_priority->bg_color):"";?>;color:<?php echo (!empty($task_priority->color))? esc_attr($task_priority->color):"";?>"><?php echo (!empty($task_priority->name))? esc_html($task_priority->name):"" ?></span>
685 - </div>
686 - <div class="wppm_card_task_action">
687 - <span class="wppm_checklist_total_checked_item"><?php echo esc_html($total_checked_items.'/'.$total)?></span><span class="wppm_total_checked_item"><img src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/checked.svg'); ?>" alt="checked"></span>
688 - <span class="wppm_show_dropdown_menu" onclick="wppm_show_dropdown_menu(<?php echo esc_attr($task->id);?>)" data-popover="wppm-dropdown-menu-<?php echo esc_attr($task->id);?>" id="wppm_task_action_<?php echo esc_attr($task->id);?>"><img src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/vertical_dot.svg'); ?>" alt="vertical_dot"></span>
689 - <div class="gpopover" id="wppm-dropdown-menu-<?php echo esc_attr($task->id);?>">
690 - <a class="dropdown-item" href="#"><?php echo esc_html__('Edit','taskbuilder');?></a>
691 - <a class="dropdown-item" href="#"><?php echo esc_html__('Delete','taskbuilder');?></a>
692 - </div>
693 - </div>
694 - </div>
695 - <div>
696 - <div>
697 - <span class="wppm_task_name_grid_view" style="margin-left: 5px;"><?php echo esc_html($task->task_name);?></span>
698 - <span class="wppm_proj_name_grid_view">(<?php echo isset($project_data['project_name']) ? esc_html($project_data['project_name']):"";?>)</span>
699 - </div>
700 - </div>
701 - <div>
702 - <?php if($wppm_deafault_time_duration_task==0) { ?>
703 - <div class="wppm_task_due_date_grid_view" style="margin-left: 5px;">
704 - <?php $style = ($task->status!=4 && $task->end_date < $current_date) ? "color:#FF0000":"color:#2C3E50"; ?>
705 - <small style="<?php echo esc_attr($style); ?>"><?php echo (isset($task_end_date))? esc_html($task_end_date):"" ?></small>
706 - </div>
707 - <?php }elseif( $wppm_deafault_time_duration_task==1){ ?>
708 - <div class="wppm_task_due_date_grid_view" style="margin-left: 5px;">
709 - <?php $style = ($task->status!=4 && $task->end_date < $current_date) ? "color:#FF0000":"color:#2C3E50"; ?>
710 - <small style="<?php echo esc_attr($style); ?>"><?php echo (isset($wppm_task_duration))? esc_html($wppm_task_duration):"" ?></small>
711 - </div>
712 - <?php } ?>
713 - <div class="wppm_card_task_users" style="text-align:right;">
714 - <?php
715 - $task_users = explode(',',$task->users);
716 - $i=0;
717 - if(!empty($project_data['users'])){
718 - $proj_users = explode(',',$project_data['users']);
719 - }
720 - if(!empty($task_users)){
721 - foreach($task_users as $user){
722 - if( (!empty($proj_users)) && (in_array($user,$proj_users))){
723 - $i++;
724 - if( $i <= 4 ){
725 - if(!empty($user)){
726 - $userdata = get_userdata( $user );
727 - ?>
728 - <a href="#" title="<?php echo esc_attr($userdata->display_name)?>">
729 - <?php echo get_avatar($user, 25, "mysteryman");?>
730 - </a>
731 - <?php }
732 - }
733 - }
734 - }
735 - }
736 - if($i > 4){
737 - ?>
738 - <a href="#" class="wppm_avatar">
739 - <span id="wppm_avatar" style="background-color:black;" class="avatar">+<?php echo esc_html($i-4) ?></span>
740 - </a>
741 - <?php } ?>
742 - </div>
743 - </div>
744 - </div>
745 - <?php
746 - }
747 - }
748 - }
749 - }
750 - }
751 - if($task_per_status==false){
752 - ?>
753 - <div>
754 - <div style="margin-left:5px;font-family: 'OpenSans-Semibold', 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 14px;">
755 - <?php echo esc_html__('Empty','taskbuilder'); ?>
756 - </div>
757 - </div>
758 - <?php
759 - }
760 - ?>
761 - </div>
762 - </div>
763 - <?php }
764 - }
765 - ?>
766 - <input type="hidden" action="wppm_drag_and_drop_card">
767 - <input type="hidden" name="wppm_drag_and_drop_card_ajax_nonce" id="wppm_drag_and_drop_card_ajax_nonce" value="<?php echo esc_attr( wp_create_nonce( 'wppm_drag_and_drop_card' ) ); ?>">
768 - </div>
769 - <div class="row wppm_task_pagination_container">
770 - <div class="col-sm-4">
771 - <?php echo esc_html__('Total:','taskbuilder'); ?>&nbsp;<?php echo esc_html($total_tasks); ?>&nbsp;<?php echo esc_html__('of','taskbuilder') ?>&nbsp;<?php echo esc_html($totalrows_tasks) ?>&nbsp;<?php echo esc_html__('Tasks','taskbuilder')?>
772 - </div>
773 - <div class="wppm_task_pagination col-sm-4" style="<?php echo (esc_attr($total_pages)==0)? "display:none;":"display:flex;"?>">
774 - <span class="wppm-pagination-txt">
775 - <span><?php echo esc_html($current_page)?>&nbsp;<?php echo esc_html__('of','taskbuilder');?>&nbsp;<?php echo esc_html($total_pages); ?>&nbsp;<?php echo esc_html__('Page','taskbuilder'); ?></span>
776 - </span>
777 - <span <?php echo esc_attr($prev_class) ?>
778 - style="<?php echo (isset($prev_class) && esc_attr($prev_class) == 'disabled') ? 'display:none;':'display:block;'?>cursor:pointer;">
779 - <a class="wppm_pagination_prev" onclick="return wppm_load_prev_task_page_card_view(<?php echo esc_attr($prev_page_no) ?>,<?php echo esc_attr($page_no)?>);"><?php echo esc_html__('PREV','taskbuilder');?></a>
780 - </span>
781 - <span <?php echo esc_attr($next_class) ?>
782 - style="<?php echo (isset($next_class) && esc_attr($next_class) == 'disabled')?'display:none;':'display:block;'?>cursor:pointer;">
783 - <a class="wppm_pagination_next" onclick="return wppm_load_next_task_page_card_view(<?php echo esc_attr($next_page_no) ?>,<?php echo esc_attr($page_no) ?>);"><?php echo esc_html__('NEXT','taskbuilder');?></a>
784 - </span>
785 - </div>
786 - </div>
787 -</form>
788 -<style>
789 - .select2-selection--single {
790 - height: 30px!important;
791 - }
792 - .select2-dropdown:hover {
793 - color: #23527c!important;;
794 - }
795 - .select2-results__options{
796 - font:15px "Helvetica Neue",Arial,Helvetica,sans-serif !important;
797 - margin: 0!important;
798 - line-height: inherit!important;
799 - }
800 - .select2-selection__rendered{
801 - font:15px "Helvetica Neue",Arial,Helvetica,sans-serif !important;
802 - margin-top: 5px!important;
803 - }
804 - .select2-selection__rendered:hover{
805 - color: #2271b1 !important;
806 - }
807 - .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable{
808 - background-color: #e85f08!important;
809 - color: white !important;
810 - }
811 - .select2-container {
812 - max-width: 150px !important;
813 - min-width: 150px !important;
814 - }
815 - #wppm_task_filter{
816 - min-height: 30px !important;
817 - max-height: 35px !important;
818 - }
819 - #wppm_view_project_task .wppm-add-new-btn:hover{
820 - background-color: <?php echo esc_attr($appearance_settings['menu-button-hover-color'])?>!important;
821 - }
822 -</style>
823 -<script type="text/javascript">
824 - jQuery( document ).ready( function( jQuery ) {
825 - dragula([
826 - <?php foreach($task_status as $status) { ?>
827 - document.getElementById("wppm_card_body_container_<?php echo esc_attr($status->id) ?>"),
828 - <?php } ?>
829 - ], {removeOnSpill: false})
830 - .on('drop', function (el,target,source) {
831 - wppm_drag_drop_card(el,target,source);
832 - });
833 -
834 - jQuery("input[name='wppm_view_task_search_filter']").keypress(function(e) {
835 - //Enter key
836 - if (e.which == 13) {
837 - e.preventDefault();
838 - wppm_display_grid_view('<?php echo esc_js($page) ?>','<?php echo esc_js($id) ?>');
839 - }
840 - });
841 - })
842 - function wppm_show_dropdown_menu(task_id){
843 - jQuery("#wppm_task_action_"+task_id).gpopover({width: 50});
844 - }
845 -
846 - function wppm_drag_drop_card(el,target,source){
847 - var data = {
848 - action: 'wppm_drag_and_drop_card',
849 - el:el.id,
850 - target: target.id,
851 - source:source.id,
852 - _ajax_nonce:jQuery("#wppm_drag_and_drop_card_ajax_nonce").val()
853 - };
854 - jQuery.post(wppm_admin.ajax_url, data, function(response) {
855 - wppm_display_grid_view('<?php echo esc_js($page) ?>','<?php echo esc_js($id) ?>');
856 - });
857 - }
858 - jQuery('#wppm_task_list_proj_filter').select2({ dropdownAutoWidth: true, width: 'auto' });
859 - jQuery('#wppm_task_list_proj_filter').val(<?php echo esc_attr($proj_filter) ?>);
860 -
1 +<?php
2 +if ( ! defined( 'ABSPATH' ) ) {
3 + exit; // Exit if accessed directly
4 +}
5 +global $wpdb,$current_user, $wppmfunction;
6 +$task_per_page = 20;
7 +$total_no_of_rows = 0;
8 +$totalrows_tasks = 0;
9 +$appearance_settings = get_option("wppm-ap-grid-view");
10 +$cu_id = absint($current_user->ID);
11 +$page_no = isset($_POST['page_no']) ? intval((sanitize_text_field(wp_unslash($_POST['page_no'])))) : '0';
12 +$orderby_sql = (sanitize_sql_orderby( "load_order ASC" ));
13 +$task_status = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}wppm_task_statuses ORDER BY $orderby_sql");
14 +$wppm_task_time = get_option('wppm_task_time');
15 +$page = isset($_POST['page']) ? sanitize_text_field(wp_unslash($_POST['page'])) : '';
16 +$id = isset($_POST['id']) ? intval(sanitize_text_field(wp_unslash($_POST['id']))) : 0;
17 +$project_id = isset($_POST['project_id']) ? intval(sanitize_text_field(wp_unslash($_POST['project_id']))) : "0";
18 +$wppm_date_setting = get_option('wppm_date_setting');
19 +$search_tag = isset($_POST['task_search']) ? sanitize_text_field(wp_unslash($_POST['task_search'])) : '';
20 +$filter_by = isset($_POST['wppm_task_filter']) ? sanitize_text_field(wp_unslash($_POST['wppm_task_filter'])) : "all";
21 +$proj_filter = isset($_POST['wppm_proj_filter']) ? absint(wp_unslash($_POST['wppm_proj_filter'])) : "0";
22 +$public_projects = isset($_POST['public_projects']) ? sanitize_text_field(wp_unslash($_POST['public_projects'])):"0";
23 +/**
24 + * PRIORITIES
25 + */
26 +$priorities = $wpdb->get_results("SELECT id, name FROM {$wpdb->prefix}wppm_task_priorities ORDER BY id ASC");
27 +/**
28 + * USERS
29 + */
30 +$users = get_users(array('orderby' => 'display_name','order' => 'ASC',));
31 +/**
32 + * ASSIGNED USERS
33 + */
34 +$assigned_rows = $wpdb->get_col( "SELECT users FROM {$wpdb->prefix}wppm_task WHERE users IS NOT NULL AND users != ''");
35 +$all_assigned = array();
36 +if (!empty($assigned_rows)) {
37 + foreach ($assigned_rows as $row) {
38 + // Handle comma separated IDs
39 + $ids = explode(',', $row);
40 + foreach ($ids as $uid) {
41 + $uid = absint(trim($uid));
42 + if ($uid > 0) {
43 + $all_assigned[$uid] = $uid;
44 + }
45 + }
46 + }
47 +}
48 +// Final unique IDs
49 +$all_assigned = array_values($all_assigned);
50 +if (isset($_POST['filters'])) {
51 + if (is_string($_POST['filters'])) {
52 + $advanced_filter = json_decode(stripslashes( sanitize_text_field(wp_unslash($_POST['filters']) ) ),true );
53 + } elseif (is_array($_POST['filters'])) {
54 + $raw_filters = wp_unslash($_POST['filters']);
55 + $advanced_filter = [
56 + 'created_by' => array_map('absint', (array) ($raw_filters['created_by'] ?? [])),
57 + 'assigned' => array_map('absint', (array) ($raw_filters['assigned'] ?? [])),
58 + 'priority' => array_map('absint', (array) ($raw_filters['priority'] ?? [])),
59 + 'start_date' => sanitize_text_field($raw_filters['start_date'] ?? ''),
60 + 'end_date' => sanitize_text_field($raw_filters['end_date'] ?? ''),
61 + ];
62 + } else {
63 + $advanced_filter = [];
64 + }
65 +}else{
66 + $advanced_filter = [];
67 +}
68 +$wppm_current_user_capability = get_user_meta( $current_user->ID, 'wppm_capability', true );
69 +$wppm_hide_completed_status_task = get_option('wppm_hide_completed_status_task');
70 +$wppm_hide_task_statuses_from_frontend = get_option('wppm_hide_task_statuses_from_frontend');
71 +$wppm_deafault_time_duration_task = get_option('wppm_display_time_duration_task');
72 +if(!empty($wppm_hide_task_statuses_from_frontend)){
73 + $wppm_hide_task_statuses_from_frontend = explode(",",$wppm_hide_task_statuses_from_frontend);
74 +} else {
75 + $wppm_hide_task_statuses_from_frontend = '';
76 +}
77 +$filters = array(
78 + 'search' => $search_tag,
79 + 'filter'=>$filter_by,
80 + 'proj_filter'=>$proj_filter
81 +);
82 +$grid_view_filter = $filters ;
83 +$tl_filters = isset( $_COOKIE['wppm_grid_view_filters'] ) ? sanitize_text_field( wp_unslash( $_COOKIE['wppm_grid_view_filters'] ) ) : $grid_view_filter;
84 +$tl_advanced_filters = [];
85 +if($id != 0){
86 + if ( isset($_COOKIE['tb_kanban_filters']) ) {
87 + $tl_advanced_filters = json_decode(
88 + stripslashes($_COOKIE['tb_kanban_filters']),
89 + true
90 + );
91 + if ( ! is_array($tl_advanced_filters) ) {
92 + $tl_advanced_filters = [];
93 + }
94 + }
95 +}else{
96 + if ( isset($_COOKIE['tb_filters']) ) {
97 + $tl_advanced_filters = json_decode(
98 + stripslashes($_COOKIE['tb_filters']),
99 + true
100 + );
101 + if ( ! is_array($tl_advanced_filters) ) {
102 + $tl_advanced_filters = [];
103 + }
104 + }
105 +}
106 +
107 +//$tl_advanced_filters = isset( $_COOKIE['wppm_advanced_filters'] ) ? sanitize_text_field( wp_unslash( $_COOKIE['wppm_advanced_filters'] ) ) : $tl_advanced_filters;
108 +$filter_values = !empty($advanced_filter)
109 + ? $advanced_filter
110 + : $tl_advanced_filters;
111 +$current_date = wp_date('Y-m-d');
112 +$proj_attr = isset($_POST['wppm_project_attr']) ? absint(wp_unslash($_POST['wppm_project_attr'])):"";
113 +$archived_where = " AND Task.is_archived = 0";
114 +if ( isset($page) && $page === 'wppm-archived-tasks' ) {
115 + $archived_where = " AND Task.is_archived = 1";
116 +}
117 +if( isset($page) && $page === 'wppm-tasks'){
118 + $archived_where = " AND Task.is_archived = 0";
119 +}
120 +if (!empty($proj_attr)) {
121 + $wppm_proj_attr = $wpdb->prepare(
122 + ' AND proj.project_name = %s',
123 + $proj_attr
124 + );
125 +} else {
126 + $wppm_proj_attr = '';
127 +}
128 +if ($id != 0 || $project_id != 0) {
129 + $final_project_id = ($project_id != 0) ? intval($project_id) : intval($id);
130 + $wppm_project_filter = $wpdb->prepare(
131 + ' AND Task.project = %d',
132 + $final_project_id
133 + );
134 +} else {
135 +
136 + $wppm_project_filter = '';
137 +}
138 +
139 +$query = ("SELECT proj.*
140 + FROM {$wpdb->prefix}wppm_project AS proj
141 + Left join {$wpdb->prefix}wppm_project_meta proj_meta ON proj.id = proj_meta.project_id");
142 +$santitize_order_by = esc_sql(sanitize_sql_orderby( "project_name ASC" ));
143 +if($current_user->has_cap('manage_options') || $wppm_current_user_capability == 'wppm_admin'){
144 + if(!empty($proj_attr )){
145 + $proj_attr = esc_sql($proj_attr);
146 + $where = $wpdb->prepare(
147 + " WHERE proj.project_name = %s AND proj.is_archived = 0
148 + GROUP BY proj.id
149 + ORDER BY {$santitize_order_by}",
150 + $proj_attr
151 + );
152 + }else{
153 + if(!empty($public_projects)){
154 + $where = $wpdb->prepare(
155 + " WHERE proj.id = proj_meta.project_id
156 + AND proj_meta.meta_key = %s
157 + AND proj_meta.meta_value = %d
158 + AND proj.is_archived = 0
159 + {$wppm_proj_attr}
160 + GROUP BY proj.id
161 + ORDER BY {$santitize_order_by}",
162 + 'public_project',
163 + 1
164 + );
165 + }else{
166 + $where = " WHERE proj.is_archived = 0 GROUP BY proj.id ORDER BY '$santitize_order_by'";
167 + }
168 + }
169 +}else{
170 + if(!empty($public_projects)){
171 + $where = $wpdb->prepare(
172 + " WHERE (
173 + proj.id = proj_meta.project_id
174 + AND proj_meta.meta_key = %s
175 + AND proj_meta.meta_value = %d
176 + )
177 + {$wppm_proj_attr} AND proj.is_archived = 0
178 + GROUP BY proj.id
179 + ORDER BY {$santitize_order_by}",
180 + 'public_project',
181 + 1
182 + );
183 + } else{
184 + $where = $wpdb->prepare(
185 + " WHERE (
186 + FIND_IN_SET(%d, proj.users) AND proj.is_archived = 0
187 + OR (
188 + proj.id = proj_meta.project_id
189 + AND proj_meta.meta_key = %s
190 + AND proj_meta.meta_value = %d
191 + )
192 + OR (
193 + proj.created_by = %d
194 + )
195 + )
196 + {$wppm_proj_attr}
197 + GROUP BY proj.id
198 + ORDER BY {$santitize_order_by}",
199 + $current_user->ID,
200 + 'public_project',
201 + 1,
202 + $cu_id
203 + );
204 + }
205 +}
206 +$where = apply_filters('wppm_project_filter_in_task_list_grid_view_where',$where);
207 +$query.= $where;
208 +$projects = $wpdb->get_results($query);
209 +$wppm_tl_filter = "1=1";
210 +if(!is_array($tl_filters)){
211 + $tl_filters = json_decode($tl_filters);
212 + $tl_filters_arr = (array) $tl_filters;
213 +} else{
214 +$tl_filters_arr = $filters;
215 +}
216 +$search_tag = isset($_POST['task_search']) ? sanitize_text_field(wp_unslash($_POST['task_search'])) : $tl_filters_arr['search'];
217 +$filter_by = isset($_POST['wppm_task_filter']) ? sanitize_text_field(wp_unslash($_POST['wppm_task_filter'])) : $tl_filters_arr['filter'];
218 +$proj_filter = isset($_POST['wppm_proj_filter']) ? absint(wp_unslash($_POST['wppm_proj_filter'])) : $tl_filters_arr['proj_filter'];
219 +$filters = array(
220 + 'search'=>$search_tag,
221 + 'filter'=>$filter_by,
222 + 'proj_filter' =>$proj_filter
223 +);
224 +setcookie('wppm_grid_view_filters',wp_json_encode( $filters ),time() + 3600);
225 +if($filter_by=='all'){
226 + if($wppm_hide_completed_status_task == 0){
227 + $wppm_tl_filter = "Task.status!='4'";
228 + }
229 +}
230 +if($filter_by=='4'){
231 + $wppm_tl_filter = "Task.status='4'";
232 +}elseif($filter_by=='overdue'){
233 + $wppm_tl_filter = "Task.status!='4' AND (CAST(Task.end_date AS DATE)) < '$current_date'";
234 +}elseif($filter_by == 'unassigned'){
235 + $wppm_tl_filter = "Task.users=''";
236 +}elseif($filter_by == '1'){
237 + $wppm_tl_filter = "Task.status='1'";
238 +}elseif($filter_by == '2'){
239 + $wppm_tl_filter = "Task.status='2'";
240 +}elseif($filter_by == '3'){
241 + $wppm_tl_filter = "Task.status='3'";
242 +}elseif($filter_by == 'mine'){
243 + $wppm_tl_filter = "(FIND_IN_SET('$current_user->ID',Task.users)>0)";
244 +}elseif($filter_by == 'archived'){
245 + $wppm_tl_filter = "Task.is_archived = 1";
246 +}elseif($filter_by == 'today'){
247 + $wppm_tl_filter = "DATE(Task.end_date) = CURDATE()";
248 +}elseif($filter_by == 'upcoming'){
249 + $wppm_tl_filter = "DATE(Task.end_date) BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 7 DAY) AND Task.status != 4 AND Task.active = 1 AND Task.is_archived = 0";
250 +}elseif ($filter_by == 'mytasks') {
251 + $wppm_tl_filter = "(
252 + FIND_IN_SET('$current_user->ID', Task.users)
253 + OR Task.created_by = '$current_user->ID'
254 + )
255 + AND Task.status != 4
256 + AND Task.active = 1
257 + AND Task.is_archived = 0";
258 +
259 +}
260 +
261 +if(!empty($tl_advanced_filters['created_by'])){
262 + $created_by_ids = array_map('intval', $tl_advanced_filters['created_by']);
263 + $wppm_tl_filter .= " AND Task.created_by IN (" . implode(',', $created_by_ids) . ")";
264 +}
265 +if(!empty($tl_advanced_filters['assigned'])){
266 + $assigned_ids = array_map('intval', $tl_advanced_filters['assigned']);
267 + $assigned_sql = [];
268 + foreach ($assigned_ids as $user_id) {
269 + $assigned_sql[] = "FIND_IN_SET('$user_id', Task.users)";
270 + }
271 + $wppm_tl_filter .= " AND (" . implode(' OR ', $assigned_sql) . ")";
272 +}
273 +if(!empty($tl_advanced_filters['priority'])){
274 + $priority = array_map('intval', $tl_advanced_filters['priority']);
275 + $wppm_tl_filter .= " AND Task.priority IN (" . implode(',', $priority) . ")";
276 +}
277 +if(!empty($tl_advanced_filters['start_date'])){
278 + $start_date = sanitize_text_field($tl_advanced_filters['start_date']);
279 + $wppm_tl_filter .= $wpdb->prepare(" AND (CAST(Task.start_date AS DATE)) >= %s", $start_date);
280 +}
281 +if(!empty($tl_advanced_filters['end_date'])){
282 + $end_date = sanitize_text_field($tl_advanced_filters['end_date']);
283 + $wppm_tl_filter .= $wpdb->prepare(" AND (CAST(Task.end_date AS DATE)) <= %s", $end_date);
284 +}
285 +
286 +$advanced_conditions = [];
287 +// Created By
288 +if (!empty($advanced_filter['created_by'])) {
289 + $created_by_ids = array_map('intval', $advanced_filter['created_by']);
290 + $advanced_conditions[] = "Task.created_by IN (" . implode(',', $created_by_ids) . ")";
291 +}
292 +// Assigned Users
293 +if (!empty($advanced_filter['assigned'])) {
294 + $assigned_ids = array_map('intval', $advanced_filter['assigned']);
295 + $assigned_sql = [];
296 + foreach ($assigned_ids as $user_id) {
297 + $assigned_sql[] = "FIND_IN_SET('$user_id', Task.users)";
298 + }
299 + $advanced_conditions[] = "(" . implode(' OR ', $assigned_sql) . ")";
300 +}
301 +// Priority
302 +if (!empty($advanced_filter['priority'])) {
303 + $priority = array_map('intval', $advanced_filter['priority']);
304 + $advanced_conditions[] = "Task.priority IN (" . implode(',', $priority) . ")";
305 +}
306 +// Start Date
307 +if (!empty($advanced_filter['start_date'])) {
308 + $start_date = sanitize_text_field($advanced_filter['start_date']);
309 + $advanced_conditions[] = $wpdb->prepare("(CAST(Task.start_date AS DATE)) >= %s", $start_date);
310 +}
311 +// End Date
312 +if (!empty($advanced_filter['end_date'])) {
313 + $end_date = sanitize_text_field($advanced_filter['end_date']);
314 + $advanced_conditions[] = $wpdb->prepare("(CAST(Task.end_date AS DATE)) <= %s", $end_date);
315 +}
316 +if (!empty($advanced_conditions)) {
317 + $wppm_tl_filter .= " AND " . implode(" AND ", $advanced_conditions);
318 +}
319 +// Subtasks are shown only within their parent task, never as their own row/card in project views.
320 +$wppm_tl_filter .= " AND (Task.parent_task_id = 0 OR Task.parent_task_id IS NULL)";
321 +
322 +if(!empty($wppm_hide_task_statuses_from_frontend) && is_array($wppm_hide_task_statuses_from_frontend) && (isset($_POST['is_frontend']) && sanitize_text_field($_POST['is_frontend'])==1)){
323 + foreach($wppm_hide_task_statuses_from_frontend as $status){
324 + $wppm_tl_filter .= " AND Task.status != '$status'";
325 + }
326 +}
327 +
328 +if($proj_filter!=0){
329 + $proj_filter = absint( $proj_filter );
330 + $wppm_task_by_proj_filter = $wpdb->prepare(
331 + "Task.project = %d AND proj.is_archived = 0",
332 + $proj_filter
333 + );
334 +}else{
335 + $wppm_task_by_proj_filter ="1=1";
336 +}
337 +if(!empty($task_status)){
338 + foreach($task_status as $status) {
339 + $status_id = absint($status->id);
340 + if(!empty($search_tag)){
341 + $search_tag_text = '%'.$wpdb->esc_like($search_tag).'%';
342 + if($current_user->has_cap('manage_options') || $wppm_current_user_capability == 'wppm_admin'){
343 + $query = ("SELECT Task.*
344 + FROM {$wpdb->prefix}wppm_task AS Task
345 + Left join {$wpdb->prefix}wppm_project proj ON Task.project = proj.id
346 + Left join {$wpdb->prefix}wppm_task_statuses task_statuses ON Task.status = task_statuses.id
347 + Left join {$wpdb->prefix}wppm_task_priorities task_priorities ON Task.priority = task_priorities.id
348 + Left join {$wpdb->base_prefix}users user ON (FIND_IN_SET(user.ID,Task.users)>0)
349 + Left join {$wpdb->prefix}wppm_project_meta proj_meta ON Task.project = proj_meta.project_id
350 + ");
351 + $no_of_rows = ( "SELECT count(*) FROM ($query");
352 + if(!empty($public_projects)){
353 + $where = $wpdb->prepare(
354 + " WHERE (
355 + proj_meta.meta_key = %s
356 + AND proj_meta.meta_value = %d
357 + )
358 + AND {$wppm_tl_filter}
359 + AND {$wppm_task_by_proj_filter}
360 + AND (
361 + Task.task_name LIKE %s
362 + OR proj.project_name LIKE %s
363 + OR task_statuses.name LIKE %s
364 + OR task_priorities.name LIKE %s
365 + OR user.display_name LIKE %s
366 + )
367 + AND Task.status = %d ",
368 + 'public_project',
369 + 1,
370 + $search_tag_text,
371 + $search_tag_text,
372 + $search_tag_text,
373 + $search_tag_text,
374 + $search_tag_text,
375 + $status_id
376 + );
377 + }else{
378 + $where = $wpdb->prepare(
379 + " WHERE {$wppm_tl_filter}
380 + AND {$wppm_task_by_proj_filter}
381 + AND (
382 + Task.task_name LIKE %s
383 + OR proj.project_name LIKE %s
384 + OR task_statuses.name LIKE %s
385 + OR task_priorities.name LIKE %s
386 + OR user.display_name LIKE %s
387 + )
388 + AND Task.status = %d ",
389 + $search_tag_text,
390 + $search_tag_text,
391 + $search_tag_text,
392 + $search_tag_text,
393 + $search_tag_text,
394 + $status_id
395 + );
396 + }
397 + } else{
398 + $query = ("SELECT Task.*
399 + FROM {$wpdb->prefix}wppm_task AS Task
400 + Left join {$wpdb->prefix}wppm_project proj ON Task.project = proj.id
401 + Left join {$wpdb->prefix}wppm_task_statuses task_statuses ON Task.status = task_statuses.id
402 + Left join {$wpdb->prefix}wppm_task_priorities task_priorities ON Task.priority = task_priorities.id
403 + Left join {$wpdb->prefix}wppm_project_users proj_users ON Task.project = proj_users.proj_id
404 + Left join {$wpdb->base_prefix}users user ON (FIND_IN_SET(user.ID,Task.users)>0)
405 + Left join {$wpdb->prefix}wppm_project_meta proj_meta ON Task.project = proj_meta.project_id
406 + ");
407 + $no_of_rows = ( "SELECT count(*) FROM ($query");
408 + if(!empty($public_projects)){
409 + $where = $wpdb->prepare(
410 + " WHERE (
411 + proj_meta.meta_key = %s
412 + AND proj_meta.meta_value = %d
413 + )
414 + AND proj.is_archived = 0
415 + AND {$wppm_tl_filter}
416 + AND {$wppm_task_by_proj_filter}
417 + AND (
418 + Task.task_name LIKE %s
419 + OR proj.project_name LIKE %s
420 + OR task_statuses.name LIKE %s
421 + OR task_priorities.name LIKE %s
422 + OR user.display_name LIKE %s
423 + )
424 + AND Task.status = %d ",
425 + 'public_project',
426 + 1,
427 + $search_tag_text,
428 + $search_tag_text,
429 + $search_tag_text,
430 + $search_tag_text,
431 + $search_tag_text,
432 + $status_id
433 + );
434 + }else{
435 + $where = $wpdb->prepare(
436 + " WHERE {$wppm_tl_filter} AND proj.is_archived = 0
437 + AND {$wppm_task_by_proj_filter}
438 + AND (
439 + (
440 + FIND_IN_SET(%d, Task.users) > 0
441 + OR Task.created_by = %d
442 + OR (
443 + proj_users.user_id = %d
444 + AND proj_users.role_id = %d
445 + AND FIND_IN_SET(%d, proj.users) > 0
446 + )
447 + OR (
448 + Task.project = proj_meta.project_id
449 + AND proj_meta.meta_key = %s
450 + AND proj_meta.meta_value = %d
451 + )
452 + OR proj.created_by = %d
453 + )
454 + AND (
455 + Task.task_name LIKE %s
456 + OR proj.project_name LIKE %s
457 + OR task_statuses.name LIKE %s
458 + OR task_priorities.name LIKE %s
459 + OR user.display_name LIKE %s
460 + )
461 + )
462 + AND Task.status = %d ",
463 + $current_user->ID,
464 + $cu_id,
465 + $cu_id,
466 + 1,
467 + $current_user->ID,
468 + 'public_project',
469 + 1,
470 + $cu_id,
471 + $search_tag_text,
472 + $search_tag_text,
473 + $search_tag_text,
474 + $search_tag_text,
475 + $search_tag_text,
476 + $status_id
477 + );
478 + }
479 + }
480 + }else{
481 + if($current_user->has_cap('manage_options') || $wppm_current_user_capability == 'wppm_admin'){
482 + $query = ( "SELECT Task.* FROM {$wpdb->prefix}wppm_task AS Task
483 + Left join {$wpdb->prefix}wppm_project proj ON Task.project = proj.id
484 + Left join {$wpdb->prefix}wppm_project_meta proj_meta ON Task.project = proj_meta.project_id
485 + ");
486 + $no_of_rows = ( "SELECT count(*) FROM ($query");
487 + if(!empty($public_projects)){
488 + $where = $wpdb->prepare(
489 + " WHERE (
490 + proj_meta.meta_key = %s
491 + AND proj_meta.meta_value = %d
492 + )
493 + AND {$wppm_tl_filter}
494 + AND proj.is_archived = 0
495 + AND {$wppm_task_by_proj_filter}
496 + AND Task.status = %d ",
497 + 'public_project',
498 + 1,
499 + $status_id
500 + );
501 + }else{
502 + $where = $wpdb->prepare(
503 + " WHERE {$wppm_tl_filter}
504 + AND {$wppm_task_by_proj_filter}
505 + AND proj.is_archived = 0
506 + AND Task.status = %d ",
507 + $status_id
508 + );
509 + }
510 + }else{
511 + $query = ( "SELECT Task.*
512 + FROM {$wpdb->prefix}wppm_task AS Task
513 + Left join {$wpdb->prefix}wppm_project proj ON Task.project = proj.id
514 + Left join {$wpdb->prefix}wppm_project_users proj_users ON Task.project = proj_users.proj_id
515 + Left join {$wpdb->prefix}wppm_project_meta proj_meta ON Task.project = proj_meta.project_id
516 + ");
517 + $no_of_rows = ( "SELECT count(*) FROM ($query");
518 + if(!empty($public_projects)){
519 + $where = $wpdb->prepare(
520 + " WHERE (
521 + proj_meta.meta_key = %s
522 + AND proj_meta.meta_value = %d
523 + )
524 + AND {$wppm_tl_filter}
525 + AND proj.is_archived = 0
526 + AND {$wppm_task_by_proj_filter}
527 + AND Task.status = %d ",
528 + 'public_project',
529 + 1,
530 + $status_id
531 + );
532 + } else{
533 + $where = $wpdb->prepare(
534 + " WHERE {$wppm_tl_filter}
535 + AND {$wppm_task_by_proj_filter}
536 + AND proj.is_archived = 0
537 + AND (
538 + FIND_IN_SET(%d, Task.users) > 0
539 + OR Task.created_by = %d
540 + OR (
541 + proj_users.user_id = %d
542 + AND proj_users.role_id = %d
543 + AND FIND_IN_SET(%d, proj.users) > 0
544 + )
545 + OR (
546 + Task.project = proj_meta.project_id
547 + AND proj_meta.meta_key = %s
548 + AND proj_meta.meta_value = %d
549 + )
550 + OR proj.created_by = %d
551 + )
552 + AND Task.status = %d ",
553 + $current_user->ID,
554 + $cu_id,
555 + $cu_id,
556 + 1,
557 + $current_user->ID,
558 + 'public_project',
559 + 1,
560 + $cu_id,
561 + $status_id
562 + );
563 + }
564 + }
565 + }
566 + $query = apply_filters('wppm_query_for_grid_view',$query);
567 + $no_of_rows = apply_filters('wppm_number_of_rows_query_for_grid_view',$no_of_rows);
568 + $where.= $wppm_proj_attr;
569 + if($filter_by != 'archived'){
570 + $where .= $archived_where;
571 + }
572 + if($id!=0){
573 + $where .=$wppm_project_filter;
574 + }
575 + $where = apply_filters('wppm_task_list_where_for_grid_view',$where,$wppm_tl_filter,$search_tag);
576 + $no_of_rows .= $where;
577 + $no_of_rows .= " Group by Task.id) AS Task";
578 + $no_of_rows = apply_filters('wppm_task_list_no_of_rows_for_grid_view',$no_of_rows);
579 + $totalrows = $wpdb->get_var($no_of_rows);
580 + $totalrows_tasks +=$totalrows;
581 + if($total_no_of_rows > $totalrows){
582 + $totalrows = $total_no_of_rows;
583 + }else{
584 + $total_no_of_rows = $totalrows;
585 + }
586 + $limit_start=$page_no*$task_per_page;
587 + $limit="\n LIMIT ".$limit_start.",".$task_per_page." ";
588 + $current_page=$page_no+1;
589 + $query = apply_filters('wppm_tasks_grid_view_query',$query,$search_tag);
590 + $where .= " Group by Task.id";
591 + $query .= $where;
592 + $query = apply_filters('wppm_task_list_grid_view_query',$query);
593 + $query = $query.$limit;
594 + $wppm_task_fillter[] = $wpdb->get_results($query);
595 + }
596 + $total_pages=ceil($total_no_of_rows/$task_per_page);
597 + $prev_page_no=$current_page-1;
598 + $prev_class=(!$prev_page_no)?'disabled':'';
599 + $next_page_no=($total_pages==$current_page)? $current_page-1:$current_page;
600 + $next_class=($total_pages==$current_page)?'disabled':'';
601 + $flag = false;
602 + if(!empty($wppm_task_fillter)){
603 + foreach($wppm_task_fillter as $key_filter=>$val_filter){
604 + foreach($val_filter as $key=>$val){
605 + $val_array = (array) $val;
606 + $tusers = $val_array['users'];
607 + $tusers_arr = explode(',',$tusers);
608 + $tproject_id = ($val_array['project']);
609 + if(!empty($tusers) && in_array($current_user->ID,$tusers_arr)){
610 + $project_user_role = $wpdb->get_var( $wpdb->prepare("SELECT role_id FROM {$wpdb->prefix}wppm_project_users WHERE proj_id = %d AND user_id = %d", absint($tproject_id), absint($cu_id)));
611 + $project_users = $wpdb->get_var( $wpdb->prepare( "SELECT users FROM {$wpdb->prefix}wppm_project WHERE id = %d", absint($tproject_id)));
612 + $project_users_arr = explode(',',(string)$project_users);
613 + if((!empty($project_user_role)) && ($project_user_role == 1) && in_array($current_user->ID,$project_users_arr)){
614 + $flag = true;
615 + break;
616 + }
617 + }
618 + }
619 + }
620 + }
621 +}
622 +$todo_status_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->prefix}wppm_task_statuses where id=%d",1));
623 +$inp_status_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->prefix}wppm_task_statuses where id=%d",2));
624 +$hold_status_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->prefix}wppm_task_statuses where id=%d",3));
625 +$completed_status_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->prefix}wppm_task_statuses where id=%d",4));
626 +$todo_status_style = (!empty($todo_status_name))? "display:inline" :"display:none;";
627 +$inp_status_style = (!empty($inp_status_name))? "display:inline" :"display:none;";
628 +$hold_status_style = (!empty($hold_status_name))? "display:inline" :"display:none;";
629 +$completed_status_style = (!empty($completed_status_name))? "display:inline" :"display:none;";
630 +if ( empty( $id ) ) {
631 + $proj_filter_style = 'display:inline;';
632 +} else {
633 + $proj_filter_style = 'display:none;';
634 +}
635 +if( isset($page) && $page === 'wppm-tasks'){
636 + $arch_filter_style = "display:inline;";
637 + $dashboard_style = "display:inline;";
638 +}else{
639 + $arch_filter_style = "display:none;";
640 + $dashboard_style = "display:none;";
641 +}
642 +
643 +if ( isset($page) && $page === 'wppm-archived-tasks' ) {
644 + $arch_filter_style = "display:none;";
645 +} else {
646 + $arch_filter_style = "display:flex;";
647 +}
648 +?>
649 +<form name="wppm_view_project_task" id="wppm_view_project_task">
650 + <div class="row">
651 + <div class="col-sm-12">
652 + <?php
653 + if(($current_user->has_cap('manage_options') || $wppmfunction->has_permission('add_new_task',0) || $wppm_current_user_capability=='wppm_manager'|| ($flag==true)) && (isset($page) && $page != 'wppm-archived-tasks' )){
654 + $style = "display:inline;";
655 + }else{
656 + $style = "display:none;";
657 + }
658 + $style = apply_filters('wppm_add_new_task_btn_style_grid_view',$style);
659 + ?>
660 + <span class="wppm-heading-inline" style="<?php echo esc_attr($proj_filter_style);?>"><?php echo (isset($page) && $page === 'wppm-archived-tasks' ) ? esc_html_e('Archived Tasks','taskbuilder'): esc_html_e('Tasks','taskbuilder');?> </span>
661 + <span class="wppm-add-new-btn btn-primary" onclick="wppm_add_new_task('',<?php echo (int)$id; ?>)" style="background-color:<?php echo esc_attr($appearance_settings['menu-button-bg-color'])?>;color:<?php echo esc_attr($appearance_settings['menu-button-text-color'])?>;<?php echo esc_attr($style) ?>;<?php echo esc_attr($proj_filter_style);?>"><img class="wppm_add_new_task_img" src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/plus_icon.svg'); ?>" alt="add"><?php echo esc_html__('Add New','taskbuilder');?></span>
662 + <!-- Dashboard Button -->
663 + <a class="wppm-add-new-btn btn-primary" style="background-color:<?php echo esc_attr($appearance_settings['menu-button-bg-color'])?>;color:<?php echo esc_attr($appearance_settings['menu-button-text-color'])?>;margin-right:3px;!important;<?php echo esc_attr($style)?>;<?php echo esc_attr($proj_filter_style);?>" href="<?php echo esc_url( admin_url('admin.php?page=wppm-dashboard') ); ?>" title="<?php echo esc_attr_e('Go to Dashboard','taskbuilder'); ?>">
664 + <img src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/dashboard.svg'); ?>" alt="dashboard_icon">
665 + <?php esc_html_e('Dashboard','taskbuilder'); ?>
666 + </a>
667 + <span class="wppm-add-new-btn btn-primary" style="background-color:<?php echo esc_attr($appearance_settings['menu-button-bg-color'])?>;<?php echo esc_attr($proj_filter_style);?>; id="wppm_task_list" onclick="wppm_get_task_list()" ><span><img class="wppm_task_list_image" src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/list-symbol.svg'); ?>" alt="list"></span><span style="color:<?php echo esc_attr($appearance_settings['menu-button-text-color'])?>;<?php echo esc_attr($proj_filter_style);?>"><?php echo esc_html_e('Task List','taskbuilder');?></span></span>
668 + </a></span>
669 + </div>
670 + </div>
671 + <div style="display:flex;justify-content:space-between;margin-top: 20px;flex-wrap: wrap;">
672 + <div style="display:flex;flex-wrap: wrap;">
673 + <div id="wppm_task_filter_container">
674 + <div class="wppm-filter-item">
675 + <label for="wppm_task_filter"> <?php echo esc_html__('Filter','taskbuilder');?></label>
676 + <select id="wppm_task_filter" name="wppm_task_filter" onchange="wppm_apply_task_filter_grid_view('<?php echo esc_attr($page)?>','<?php echo esc_attr($id)?>')" class="form-control">
677 + <option value="all"<?php echo ($filter_by == "all")? 'selected':""?>><?php echo esc_html__('All','taskbuilder');?></option>
678 + <option value="1" style="<?php echo esc_attr($todo_status_style) ?>" <?php echo ($filter_by == "1")? 'selected':""?>><?php echo esc_html__($todo_status_name);?></option>
679 + <option value="2" style="<?php echo esc_attr($inp_status_style) ?>" <?php echo ($filter_by == "2")? 'selected':""?>><?php echo esc_html__($inp_status_name);?></option>
680 + <option value="3" style="<?php echo esc_attr($hold_status_style) ?>" <?php echo ($filter_by == "3")? 'selected':""?>><?php echo esc_html__($hold_status_name);?></option>
681 + <option value="4" style="<?php echo esc_attr($completed_status_style) ?>" <?php echo ($filter_by == "4")? 'selected':""?>><?php echo esc_html__($completed_status_name);?></option>
682 + <option value="mine" <?php echo ($filter_by == "mine")? 'selected':""?>><?php echo esc_html__('Mine','taskbuilder');?></option>
683 + <option value="unassigned" <?php echo ($filter_by == "unassigned")? 'selected':""?>><?php echo esc_html__('Unassigned','taskbuilder');?></option>
684 + <option value="overdue" <?php echo ($filter_by == "overdue")? 'selected':""?>><?php echo esc_html__('Overdue','taskbuilder');?></option>
685 + <option value="archived" style="<?php echo esc_attr($arch_filter_style) ?>" <?php echo ($filter_by == "archived")? 'selected':""?>><?php echo esc_html__('Archived','taskbuilder');?></option>
686 + </select>
687 + </div>
688 + <div class="wppm-filter-item wppm_project_autocomplete_container" style="<?php echo esc_attr($proj_filter_style)?>">
689 + <label for="wppm_task_list_proj_filter">
690 + <?php echo esc_html__('Project','taskbuilder');?>
691 + </label><br>
692 + <select searchable="search here" onchange="wppm_tasks_by_select_project_grid_view('<?php echo esc_attr($page)?>')" class="form-control" size="40" name="wppm_task_list_proj_filter" id="wppm_task_list_proj_filter">
693 + <option value="0" <?php echo ($proj_filter == 0)? 'selected':""?>><?php echo esc_html__('All','taskbuilder');?></option>
694 + <?php
695 + if(!empty($projects)){
696 + foreach($projects as $proj) {
697 + ?>
698 + <option value="<?php echo esc_attr($proj->id)?>" <?php echo ($proj_filter == $proj->id)? 'selected':""?>><?php echo esc_html($proj->project_name,'taskbuilder');?></option>
699 + <?php }
700 + } ?>
701 + </select>
702 + </div>
703 + <!-- FILTER BUTTON -->
704 + <div class="tb-filters" class="wppm-filter-item" style="display:flex;margin-left: 4px;">
705 + <div class="tb-filter-bar">
706 + <span id="tb-advanced-toggle" class="tb-btn" style="margin-bottom: 10px;">
707 + <?php echo esc_html_e('⚙️ Filters', 'taskbuilder'); ?>
708 + </span>
709 + <!-- ACTIVE FILTER CHIPS -->
710 + <div id="tb-active-filters" class="tb-chips"></div>
711 +
712 + <!-- POPOVER -->
713 + <div id="tb-advanced-panel" class="tb-popover">
714 + <div class="tb-mobile-header">
715 + <span><?php echo esc_html_e('Filters', 'taskbuilder'); ?></span>
716 + <button id="tb-close-filters">✕</button>
717 + </div>
718 + <div class="tb-arrow"></div>
719 +
720 + <div class="tb-section">
721 + <h4><?php echo esc_html_e('Created By', 'taskbuilder'); ?></h4>
722 + <select id="tb-created-by" class="form-control" multiple>
723 + <?php
724 + if(!empty($users)){
725 + foreach($users as $user): ?>
726 + <option value="<?php echo esc_attr($user->ID); ?>"><?php echo esc_html($user->display_name); ?></option>
727 + <?php endforeach; }?>
728 + </select>
729 + <h4><?php echo esc_html_e('Assigned To', 'taskbuilder'); ?></h4>
730 + <select id="tb-assigned" multiple>
731 + <?php
732 + if(!empty($all_assigned)){
733 + foreach($all_assigned as $uid){
734 + $user = get_userdata($uid);
735 + if($user){
736 + ?>
737 + <option value="<?php echo esc_attr($uid); ?>">
738 + <?php echo esc_html($user->display_name); ?>
739 + </option>
740 + <?php } }
741 + } ?>
742 + </select>
743 + </div>
744 + <div class="tb-section">
745 + <h4><?php echo esc_html_e('Priority', 'taskbuilder'); ?></h4>
746 + <select id="tb-priority" class="form-control" multiple>
747 + <?php if(!empty($priorities)) {
748 + foreach($priorities as $priority){ ?>
749 + <option value="<?php echo esc_attr($priority->id); ?>">
750 + <?php echo esc_html($priority->name); ?>
751 + </option>
752 + <?php } } ?>
753 + </select>
754 + </div>
755 + <div class="tb-section">
756 + <h4><?php echo esc_html_e('Date', 'taskbuilder'); ?></h4>
757 + <input type="date" class="form-control" id="tb-start-date">
758 + <input type="date" class="form-control"id="tb-end-date">
759 + </div>
760 + <div id="tb-filter-actions">
761 + <button class="wppm-submit-btn" id="tb-apply-filter" type="button"><?php echo esc_html_e('Apply', 'taskbuilder'); ?></button>
762 + <button class="wppm_reset_btn" id="tb-reset-filter" type="button"><?php echo esc_html_e('Reset', 'taskbuilder'); ?></button>
763 + </div>
764 + </div>
765 + </div>
766 + <div id="tb-backdrop"></div>
767 + </div>
768 + <div class="wppm_display_submit">
769 + <div class="wppm-filter-actions">
770 + <span class="wppm-link" onclick="wppm_tl_reset_grid_view_filter('<?php echo esc_attr($page)?>',<?php echo esc_attr($id)?>)"> <?php echo esc_html__('Reset','taskbuilder');?></span>
771 + </div>
772 + </div>
773 + </div>
774 + </div>
775 + <div id="wppm_task_search" style="display:flex;justify-content:flex-end;margin-left: auto;">
776 + <img width="25px" height="15" class="wppm_task_search_filter_img" style="position: relative;top: 10px;left: 30px;" height="15px" src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/search.svg'); ?>" alt="search">
777 + <input type="search" id="wppm_view_task_search_filter" style="margin-right:10px; min-height:30px!important;" name="wppm_view_task_search_filter" class="form-control form-control-sm" aria-controls="selection-datatable" placeholder="<?php echo esc_attr__('Search','taskbuilder');?>" value="<?php echo (!empty($search_tag)) ? esc_attr($search_tag) : "" ?>">
778 + </div>
779 + </div>
780 + <input type="hidden" name="wppm_proj_id" id="wppm_proj_id" value="<?php echo esc_attr($id);?>">
781 + <div style="display:flex;justify-content:flex-end;margin-right:10px;">
782 + <span id="wppm_list_view_btn" style="margin: 5px 0 -30px 0;<?php echo esc_attr($proj_filter_style);?>" onclick="wppm_get_task_list(0,<?php echo esc_attr($id)?>)"><img src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/listv.svg'); ?>" alt="list"><span style="margin-left:5px;"><?php echo esc_html_e('List view','taskbuilder');?></span></span>
783 + </div>
784 + <div class="wppm_task_container" id="wppm_task_container" style="display:flex;">
785 + <?php
786 + if(!empty($task_status)){
787 + foreach($task_status as $status) {
788 + ?>
789 + <div class="wppm_task_list" id="wppm_task_list_<?php echo esc_attr($status->id)?>" style="display:flex;justify-content:space-between;flex-direction: column;flex-basis: 20%;">
790 + <div>
791 + <div style="background-color:<?php echo esc_attr($status->bg_color)?>;color:<?php echo esc_attr($status->color);?>;padding:5px;">
792 + <span class="wppm_status_name"><?php echo esc_html($status->name);?></span>
793 + <span class="wppm_add_new_icon" onclick="wppm_add_new_task('',<?php echo (int)$id; ?>)"><img src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/add_new1.svg'); ?>" alt="add"></span>
794 + </div>
795 + </div>
796 + <div id="wppm_card_body_container_<?php echo esc_attr($status->id) ?>" style="height:100%;">
797 + <?php
798 + $total_checklist_items=0;
799 + $total_checked_items=0;
800 + $task_per_status = false;
801 + $total_tasks = 0;
802 + if(!empty($wppm_task_fillter)){
803 + foreach($wppm_task_fillter as $key=>$tasks){
804 + foreach($tasks as $task){
805 + $total_tasks++;
806 + $wppm_task_duration = $wppmfunction->wppm_get_duration($task->start_date,$task->end_date);
807 + if((!empty($task)) && $task->status==$status->id){
808 + $task_per_status = true;
809 + if(isset($task->priority)){
810 + $tpriority = ($task->priority);
811 + $task_priority = $wpdb->get_row(
812 + $wpdb->prepare(
813 + "SELECT * FROM {$wpdb->prefix}wppm_task_priorities
814 + WHERE id = %d",
815 + absint($tpriority)
816 + )
817 + );
818 + }
819 + if($wppm_task_time == 1){
820 + $task_end_date = $task->end_date;
821 + $teDate = new DateTime($task->end_date);
822 + if($task->end_date=='0000-00-00 00:00:00'){
823 + if($wppm_date_setting=='Y-m-d H:i:s'){
824 + $task_end_date = '0000-00-00 00:00:00';
825 + }elseif($wppm_date_setting=='d-m-Y H:i:s'){
826 + $task_end_date = '00-00-0000 00:00:00';
827 + }elseif($wppm_date_setting=='m-d-Y H:i:s'){
828 + $task_end_date = '00-00-0000 00:00:00';
829 + }else{
830 + $task_end_date = '0000-00-00 00:00:00';
831 + }
832 + }else{
833 + $task_end_date = $teDate->format($wppm_date_setting);
834 + }
835 + }elseif($wppm_task_time == 0){
836 + $teDate = new DateTime($task->end_date);
837 + $task_end_date = $teDate->format('Y-m-d');
838 + if($task->end_date=='0000-00-00 00:00:00'){
839 + if($wppm_date_setting=='Y-m-d H:i:s'){
840 + $task_end_date = '0000-00-00';
841 + }elseif($wppm_date_setting=='d-m-Y H:i:s'){
842 + $task_end_date = '00-00-0000';
843 + }elseif($wppm_date_setting=='m-d-Y H:i:s'){
844 + $task_end_date = '00-00-0000';
845 + }else{
846 + $task_end_date = '0000-00-00';
847 + }
848 + }else{
849 + if($wppm_date_setting=='Y-m-d H:i:s'){
850 + $task_end_date = $teDate->format('Y-m-d');
851 + }elseif($wppm_date_setting=='d-m-Y H:i:s'){
852 + $task_end_date = $teDate->format('d-m-Y');
853 + }elseif($wppm_date_setting=='m-d-Y H:i:s'){
854 + $task_end_date = $teDate->format('m-d-Y');
855 + }else{
856 + $task_end_date = $teDate->format('Y-m-d');
857 + }
858 + }
859 + }
860 + if(!empty($task->id)){
861 + $tid = absint( $task->id );
862 + $checklists = $wpdb->get_results(
863 + $wpdb->prepare(
864 + "SELECT * FROM {$wpdb->prefix}wppm_checklist WHERE task_id = %d",
865 + $tid
866 + )
867 + );
868 + $total = $wpdb->get_var(
869 + $wpdb->prepare(
870 + "SELECT COUNT(Items.id)
871 + FROM {$wpdb->prefix}wppm_checklist_items AS Items
872 + LEFT JOIN {$wpdb->prefix}wppm_checklist AS checklist
873 + ON Items.checklist_id = checklist.id
874 + WHERE checklist.task_id = %d",
875 + $tid
876 + )
877 + );
878 + $total_checked_items = (int) $wpdb->get_var(
879 + $wpdb->prepare(
880 + "SELECT COUNT(Items.id)
881 + FROM {$wpdb->prefix}wppm_checklist_items AS Items
882 + INNER JOIN {$wpdb->prefix}wppm_checklist AS checklist
883 + ON Items.checklist_id = checklist.id
884 + WHERE checklist.task_id = %d
885 + AND Items.checked = 1",
886 + absint($tid)
887 + )
888 + );
889 + $project_data = $wppmfunction->get_project($task->project);
890 + ?>
891 + <div class="wppm_card_body" style="background-color:<?php echo esc_attr($appearance_settings['grid-background-color'])?>!important;color:<?php echo esc_attr($appearance_settings['grid-header-text-color'])?>!important;" onclick="wppm_open_task(<?php echo esc_attr($task->id)?>,<?php echo esc_attr($id);?>)" id="wppm_draggable_card_<?php echo esc_attr($task->id)?>">
892 + <div>
893 + <div>
894 + <span class="wppm_td_task_priority" style="background-color:<?php echo (!empty($task_priority->bg_color))? esc_attr($task_priority->bg_color):"";?>;color:<?php echo (!empty($task_priority->color))? esc_attr($task_priority->color):"";?>"><?php echo (!empty($task_priority->name))? esc_html($task_priority->name):"" ?></span>
895 + </div>
896 + <div class="wppm_card_task_action">
897 + <span class="wppm_checklist_total_checked_item"><?php echo esc_html($total_checked_items.'/'.$total)?></span><span class="wppm_total_checked_item"><img src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/checked.svg'); ?>" alt="checked"></span>
898 + <span class="wppm_show_dropdown_menu" onclick="wppm_show_dropdown_menu(<?php echo esc_attr($task->id);?>)" data-popover="wppm-dropdown-menu-<?php echo esc_attr($task->id);?>" id="wppm_task_action_<?php echo esc_attr($task->id);?>"><img src="<?php echo esc_url( WPPM_PLUGIN_URL . 'asset/images/vertical_dot.svg'); ?>" alt="vertical_dot"></span>
899 + <div class="gpopover" id="wppm-dropdown-menu-<?php echo esc_attr($task->id);?>">
900 + <a class="dropdown-item" href="#"><?php echo esc_html__('Edit','taskbuilder');?></a>
901 + <a class="dropdown-item" href="#"><?php echo esc_html__('Delete','taskbuilder');?></a>
902 + </div>
903 + </div>
904 + </div>
905 + <div>
906 + <div>
907 + <span class="wppm_task_name_grid_view" style="margin-left: 5px;"><?php echo esc_html($task->task_name);?></span>
908 + <span class="wppm_proj_name_grid_view">(<?php echo isset($project_data['project_name']) ? esc_html($project_data['project_name']):"";?>)</span>
909 + </div>
910 + </div>
911 + <div>
912 + <?php if($wppm_deafault_time_duration_task==0) { ?>
913 + <div class="wppm_task_due_date_grid_view" style="margin-left: 5px;">
914 + <?php $style = ($task->status!=4 && $task->end_date < $current_date) ? "color:#FF0000":"color:#2C3E50"; ?>
915 + <small style="<?php echo esc_attr($style); ?>"><?php echo (isset($task_end_date))? esc_html($task_end_date):"" ?></small>
916 + </div>
917 + <?php }elseif( $wppm_deafault_time_duration_task==1){ ?>
918 + <div class="wppm_task_due_date_grid_view" style="margin-left: 5px;">
919 + <?php $style = ($task->status!=4 && $task->end_date < $current_date) ? "color:#FF0000":"color:#2C3E50"; ?>
920 + <small style="<?php echo esc_attr($style); ?>"><?php echo (isset($wppm_task_duration))? esc_html($wppm_task_duration):"" ?></small>
921 + </div>
922 + <?php } ?>
923 + <div class="wppm_card_task_users" style="text-align:right;">
924 + <?php
925 + $task_users = explode(',',$task->users);
926 + $i=0;
927 + if(!empty($project_data['users'])){
928 + $proj_users = explode(',',$project_data['users']);
929 + }
930 + if(!empty($task_users)){
931 + foreach($task_users as $user){
932 + if( (!empty($proj_users)) && (in_array($user,$proj_users))){
933 + $i++;
934 + if( $i <= 4 ){
935 + if(!empty($user)){
936 + $userdata = get_userdata( $user );
937 + ?>
938 + <a href="#" title="<?php echo esc_attr($userdata->display_name)?>">
939 + <?php echo get_avatar($user, 25, "mysteryman");?>
940 + </a>
941 + <?php }
942 + }
943 + }
944 + }
945 + }
946 + if($i > 4){
947 + ?>
948 + <a href="#" class="wppm_avatar">
949 + <span id="wppm_avatar" style="background-color:black;" class="avatar">+<?php echo esc_html($i-4) ?></span>
950 + </a>
951 + <?php } ?>
952 + </div>
953 + </div>
954 + </div>
955 + <?php
956 + }
957 + }
958 + }
959 + }
960 + }
961 + if($task_per_status==false){
962 + ?>
963 + <div>
964 + <div style="margin-left:5px;font-family: 'OpenSans-Semibold', 'Helvetica Neue', Arial, Helvetica, sans-serif; font-size: 14px;">
965 + <?php echo esc_html__('Empty','taskbuilder'); ?>
966 + </div>
967 + </div>
968 + <?php
969 + }
970 + ?>
971 + </div>
972 + </div>
973 + <?php }
974 + }
975 + ?>
976 + <input type="hidden" action="wppm_drag_and_drop_card">
977 + <input type="hidden" name="wppm_drag_and_drop_card_ajax_nonce" id="wppm_drag_and_drop_card_ajax_nonce" value="<?php echo esc_attr( wp_create_nonce( 'wppm_drag_and_drop_card' ) ); ?>">
978 + </div>
979 + <div class="row wppm_task_pagination_container">
980 + <div class="col-sm-4">
981 + <?php echo esc_html__('Total:','taskbuilder'); ?>&nbsp;<?php echo esc_html($total_tasks); ?>&nbsp;<?php echo esc_html__('of','taskbuilder') ?>&nbsp;<?php echo esc_html($totalrows_tasks) ?>&nbsp;<?php echo esc_html__('Tasks','taskbuilder')?>
982 + </div>
983 + <div class="wppm_task_pagination col-sm-4" style="<?php echo (esc_attr($total_pages)==0)? "display:none;":"display:flex;"?>">
984 + <span class="wppm-pagination-txt">
985 + <span><?php echo esc_html($current_page)?>&nbsp;<?php echo esc_html__('of','taskbuilder');?>&nbsp;<?php echo esc_html($total_pages); ?>&nbsp;<?php echo esc_html__('Page','taskbuilder'); ?></span>
986 + </span>
987 + <span <?php echo esc_attr($prev_class) ?>
988 + style="<?php echo (isset($prev_class) && esc_attr($prev_class) == 'disabled') ? 'display:none;':'display:block;'?>cursor:pointer;">
989 + <a class="wppm_pagination_prev" onclick="return wppm_load_prev_task_page_card_view(<?php echo esc_attr($prev_page_no) ?>,<?php echo esc_attr($page_no)?>);"><?php echo esc_html__('PREV','taskbuilder');?></a>
990 + </span>
991 + <span <?php echo esc_attr($next_class) ?>
992 + style="<?php echo (isset($next_class) && esc_attr($next_class) == 'disabled')?'display:none;':'display:block;'?>cursor:pointer;">
993 + <a class="wppm_pagination_next" onclick="return wppm_load_next_task_page_card_view(<?php echo esc_attr($next_page_no) ?>,<?php echo esc_attr($page_no) ?>);"><?php echo esc_html__('NEXT','taskbuilder');?></a>
994 + </span>
995 + </div>
996 + </div>
997 +</form>
998 +<style>
999 + .select2-selection--single {
1000 + height: 30px!important;
1001 + }
1002 + .select2-dropdown:hover {
1003 + color: #23527c!important;;
1004 + }
1005 + .select2-results__options{
1006 + font:15px "Helvetica Neue",Arial,Helvetica,sans-serif !important;
1007 + margin: 0!important;
1008 + line-height: inherit!important;
1009 + }
1010 + .select2-selection__rendered{
1011 + font:15px "Helvetica Neue",Arial,Helvetica,sans-serif !important;
1012 + margin-top: 5px!important;
1013 + }
1014 + .select2-selection__rendered:hover{
1015 + color: #2271b1 !important;
1016 + }
1017 + .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable{
1018 + background-color: #e85f08!important;
1019 + color: white !important;
1020 + }
1021 + .select2-container {
1022 + max-width: 150px !important;
1023 + min-width: 150px !important;
1024 + }
1025 + .select2-selection--multiple {
1026 + max-width: 290px !important;
1027 + min-width: 290px !important;
1028 + }
1029 + #wppm_task_filter{
1030 + min-height: 30px !important;
1031 + max-height: 35px !important;
1032 + }
1033 + #wppm_view_project_task .wppm-add-new-btn:hover{
1034 + background-color: <?php echo esc_attr($appearance_settings['menu-button-hover-color'])?>!important;
1035 + }
1036 +</style><?php
1037 +if (!isset($advanced_filter) || !is_array($advanced_filter)) {
1038 + $advanced_filter = [];
1039 +}?>
1040 +<script type="text/javascript">
1041 + var link = true;
1042 + window.filters = {
1043 + created_by: [],
1044 + assigned: [],
1045 + priority: [],
1046 + start_date: "",
1047 + end_date: "",
1048 + id: null
1049 +};
1050 +
1051 +<?php if (isset($id) && !empty($id)) { ?>
1052 +window.filters.id = <?php echo esc_attr($id); ?>;
1053 +<?php } ?>
1054 +
1055 +var filters = window.filters;
1056 +var wppm_task_filter = <?php echo wp_json_encode($filter_by); ?>;
1057 + jQuery( document ).ready( function( jQuery ) {
1058 + dragula([
1059 + <?php foreach($task_status as $status) { ?>
1060 + document.getElementById("wppm_card_body_container_<?php echo esc_attr($status->id) ?>"),
1061 + <?php } ?>
1062 + ], {removeOnSpill: false})
1063 + .on('drop', function (el,target,source) {
1064 + wppm_drag_drop_card(el,target,source);
1065 + });
1066 + var isKanban = <?php echo (isset($id) && !empty($id)) ? 'true' : 'false'; ?>;
1067 + var filterId = isKanban
1068 + ? <?php echo isset($id) ? esc_attr($id) : '0'; ?>
1069 + : 0;
1070 + var filterView = isKanban ? 'kanban' : 'grid';
1071 +
1072 +
1073 + // NOW use isKanban/filterId/filterView
1074 + // SET VALUES AFTER INIT
1075 + let createdBy = <?php echo wp_json_encode(array_map('strval', $filter_values['created_by'] ?? [])); ?>;
1076 +
1077 + let assigned = <?php echo wp_json_encode(array_map('strval', $filter_values['assigned'] ?? [])); ?>;
1078 +
1079 + let priority = <?php echo wp_json_encode(array_map('strval', $filter_values['priority'] ?? [])); ?>;
1080 +
1081 + let startDate = <?php echo wp_json_encode($filter_values['start_date'] ?? ''); ?>;
1082 + let endDate = <?php echo wp_json_encode($filter_values['end_date'] ?? ''); ?>;
1083 +
1084 + filters.created_by = createdBy;
1085 + filters.assigned = assigned;
1086 + filters.priority = priority;
1087 + filters.start_date = startDate;
1088 + filters.end_date = endDate;
1089 +
1090 + if (isKanban) {
1091 + filters.id = filterId;
1092 + } else {
1093 + filters.id = null;
1094 + }
1095 + jQuery('#tb-created-by').val(createdBy).trigger('change');
1096 + jQuery('#tb-assigned').val(assigned).trigger('change');
1097 + jQuery('#tb-priority').val(priority).trigger('change');
1098 +
1099 + jQuery('#tb-start-date').val(startDate);
1100 + jQuery('#tb-end-date').val(endDate);
1101 +
1102 + setTimeout(function() {
1103 + renderActiveFilters(filters);
1104 + }, 300);
1105 + jQuery(document)
1106 + .off("click", "#tb-apply-filter")
1107 + .on("click", "#tb-apply-filter", function (e) {
1108 + e.preventDefault();
1109 + filters.created_by = jQuery("#tb-created-by").val() || [];
1110 + filters.assigned = jQuery("#tb-assigned").val() || [];
1111 + filters.priority = jQuery("#tb-priority").val() || [];
1112 + filters.start_date = jQuery("#tb-start-date").val() || "";
1113 + filters.end_date = jQuery("#tb-end-date").val() || "";
1114 + <?php if (isset($id) && !empty($id)) { ?>
1115 + filters.id = <?php echo esc_attr($id); ?>;
1116 + renderActiveFilters(filters);
1117 + setKanbanFilterCookie(filters);
1118 + triggerFilter(
1119 + 1,
1120 + filters,
1121 + 'kanban',
1122 + <?php echo esc_attr($id); ?>
1123 + );
1124 + <?php } else { ?>
1125 + filters.id = null;
1126 + renderActiveFilters(filters);
1127 + setFilterCookie(filters);
1128 + triggerFilter(
1129 + 1,
1130 + filters,
1131 + 'grid',
1132 + 0
1133 + );
1134 + <?php } ?>
1135 + });
1136 + jQuery(document).on("click", ".tb-remove", function () {
1137 + let key = jQuery(this).attr("data-key");
1138 + let value = jQuery(this).attr("data-value");
1139 + // DATE REMOVE
1140 + if (key === "date") {
1141 + filters.start_date = "";
1142 + filters.end_date = "";
1143 + jQuery("#tb-start-date").val("").trigger("change");
1144 + jQuery("#tb-end-date").val("").trigger("change");
1145 + jQuery(this).closest(".tb-chip").remove();
1146 + syncUIWithFilters(filters);
1147 + renderActiveFilters(filters);
1148 + <?php if (isset($id) && !empty($id)) { ?>
1149 + filters.id = <?php echo esc_attr($id); ?>;
1150 + syncUIWithFilters(filters);
1151 + renderActiveFilters(filters);
1152 + setKanbanFilterCookie(filters);
1153 + triggerFilter(
1154 + 1,
1155 + filters,
1156 + 'kanban',
1157 + <?php echo esc_attr($id); ?>
1158 + );
1159 + <?php } else { ?>
1160 + filters.id = null;
1161 + syncUIWithFilters(filters);
1162 + renderActiveFilters(filters);
1163 + setFilterCookie(filters);
1164 + triggerFilter(
1165 + 1,
1166 + filters,
1167 + 'grid',
1168 + 0
1169 + );
1170 + <?php } ?>
1171 + return;
1172 + }
1173 + // REMOVE CREATED BY / ASSIGNED / PRIORITY
1174 + else {
1175 + filters[key] = (filters[key] || [])
1176 + .map(String)
1177 + .filter(v => v !== String(value));
1178 + jQuery(`#tb-${key}`)
1179 + .val(filters[key])
1180 + .trigger("change");
1181 + // Remove chip
1182 + jQuery(this).closest(".tb-chip").remove();
1183 + // Sync UI
1184 + syncUIWithFilters(filters);
1185 + // Render active filters
1186 + renderActiveFilters(filters);
1187 + <?php if (isset($id) && !empty($id)) { ?>
1188 + filters.id = <?php echo esc_attr($id); ?>;
1189 + syncUIWithFilters(filters);
1190 + renderActiveFilters(filters);
1191 + setKanbanFilterCookie(filters);
1192 + triggerFilter(
1193 + 1,
1194 + filters,
1195 + 'kanban',
1196 + <?php echo esc_attr($id); ?>
1197 + );
1198 + <?php } else { ?>
1199 + filters.id = null;
1200 + syncUIWithFilters(filters);
1201 + renderActiveFilters(filters);
1202 + setFilterCookie(filters);
1203 + triggerFilter(
1204 + 1,
1205 + filters,
1206 + 'grid',
1207 + 0
1208 + );
1209 + <?php } ?>
1210 + }
1211 + });
1212 + jQuery(document)
1213 + .off("click", "#tb-reset-filter")
1214 + .on("click", "#tb-reset-filter", function () {
1215 + window.filters = {
1216 + created_by: [],
1217 + assigned: [],
1218 + priority: [],
1219 + start_date: "",
1220 + end_date: "",
1221 + id: isKanban ? filterId : null
1222 + };
1223 + filters = window.filters;
1224 + syncUIWithFilters(filters);
1225 + jQuery("#tb-active-filters").html("");
1226 + if (isKanban) {
1227 + syncUIWithFilters(filters);
1228 + renderActiveFilters(filters);
1229 + setKanbanFilterCookie(filters);
1230 + } else {
1231 + syncUIWithFilters(filters);
1232 + renderActiveFilters(filters);
1233 + setFilterCookie(filters);
1234 + }
1235 + triggerFilter(
1236 + 1,
1237 + filters,
1238 + filterView,
1239 + filterId
1240 + );
1241 + jQuery("#tb-advanced-panel").removeClass("tb-open");
1242 + jQuery("#tb-backdrop").removeClass("active");
1243 + });
1244 + jQuery("input[name='wppm_view_task_search_filter']").keypress(function(e) {
1245 + //Enter key
1246 + if (e.which == 13) {
1247 + e.preventDefault();
1248 + wppm_display_grid_view('<?php echo esc_js($page) ?>','<?php echo esc_js($id) ?>');
1249 + }
1250 + });
1251 + })
1252 + function wppm_show_dropdown_menu(task_id){
1253 + jQuery("#wppm_task_action_"+task_id).gpopover({width: 50});
1254 + }
1255 +
1256 + function wppm_drag_drop_card(el,target,source){
1257 + var data = {
1258 + action: 'wppm_drag_and_drop_card',
1259 + el:el.id,
1260 + target: target.id,
1261 + source:source.id,
1262 + _ajax_nonce:jQuery("#wppm_drag_and_drop_card_ajax_nonce").val()
1263 + };
1264 + jQuery.post(wppm_admin.ajax_url, data, function(response) {
1265 + wppm_display_grid_view('<?php echo esc_js($page) ?>','<?php echo esc_js($id) ?>');
1266 + });
1267 + }
1268 + function wppm_tl_reset_grid_view_filter(page,id){
1269 + var url = new URL(window.location.href);
1270 + if (url.searchParams.has('wppm_task_filter')) {
1271 + url.searchParams.delete('wppm_task_filter');
1272 + window.location.href = url.toString();
1273 + return false;
1274 + }
1275 + jQuery('#wppm_task_container').html(wppm_admin.loading_html);
1276 + var data = {
1277 + action: 'wppm_view_project_tasks',
1278 + wppm_task_filter:'all',
1279 + task_search:"",
1280 + sort_by:"task_name",
1281 + order:"ASC",
1282 + wppm_proj_filter:"0",
1283 + page:page,
1284 + id:id
1285 + };
1286 + jQuery.post(wppm_admin.ajax_url, data, function(response) {
1287 + jQuery('#wppm_task_container').html(response);
1288 + });
1289 + // ✅ close popup
1290 + jQuery("#tb-advanced-panel").removeClass("tb-open");
1291 + jQuery("#tb-backdrop").removeClass("active");
1292 +
1293 + // ✅ clear inputs
1294 + jQuery('#tb-advanced-panel input').val('');
1295 + jQuery('#tb-advanced-panel select').val([]);
1296 +
1297 + // ✅ clear chips
1298 + jQuery("#tb-active-filters").html('');
1299 + if(id!=0){
1300 + resetFilters('kanban');
1301 + }else{
1302 + resetFilters('grid');
1303 + }
1304 + }
1305 + jQuery('#wppm_task_list_proj_filter').select2({ dropdownAutoWidth: true, width: 'auto' });
1306 + jQuery('#wppm_task_list_proj_filter').val(<?php echo esc_attr($proj_filter) ?>);
1307 + jQuery('#tb-created-by').select2({ dropdownAutoWidth: true, width: '100%'});
1308 + jQuery('#tb-created-by').val(<?php echo wp_json_encode($filter_values['created_by'] ?? []); ?>).trigger('change');
1309 + jQuery('#tb-assigned').select2({ dropdownAutoWidth: true, width: '100%' });
1310 + jQuery('#tb-assigned').val(<?php echo wp_json_encode($filter_values['assigned'] ?? []); ?>).trigger('change');
1311 + jQuery('#tb-priority').select2({dropdownAutoWidth: true, width: '100%'});
1312 + jQuery('#tb-priority').val(<?php echo wp_json_encode($filter_values['priority'] ?? []); ?>).trigger('change');
1313 + jQuery(document).off("click", "#tb-advanced-toggle").on("click", "#tb-advanced-toggle", function (e) {
1314 + e.stopPropagation();
1315 + jQuery("#tb-advanced-panel").toggleClass("tb-open");
1316 + });
1317 +
1318 + /* Close on backdrop click */
1319 + jQuery(document).on("click", "#tb-backdrop", function () {
1320 + jQuery("#tb-advanced-panel").removeClass("tb-open");
1321 + jQuery(this).removeClass("active");
1322 + });
1323 +
1324 + /* Close on outside (desktop only) */
1325 + jQuery(document).on("click", function (e) {
1326 + if (window.innerWidth > 768) {
1327 + if (!jQuery(e.target).closest("#tb-advanced-panel, #tb-advanced-toggle").length) {
1328 + jQuery("#tb-advanced-panel").removeClass("tb-open");
1329 + }
1330 + }
1331 + });jQuery(document).on("click", "#tb-close-filters", function () {
1332 + jQuery("#tb-advanced-panel").removeClass("tb-open");
1333 + jQuery("#tb-backdrop").removeClass("active");
1334 + });
1335 +
861 1336 </script>