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

wppm_get_task_pdf.php in Taskbuilder – Project Management & Task Management Tool With Kanban Board 6.0.0, at includes/admin/wppm_get_task_pdf.php

103 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly
4 }
5 global $current_user,$wpdb,$wppmfunction;
6 $task_id = isset($_GET['id']) ? absint(sanitize_text_field(wp_unslash($_GET['id']))) : '';
7 $wppm_print_settings = get_option('wppm_print_settings');
8 $task = $wppmfunction->get_task($task_id);
9 $project = $wppmfunction->get_project($task['project']);
10 $proj_users = $project['users'] ? explode(',',$project['users']) : array();
11 $task_status = absint($task['status']);
12 $task_priority = absint($task['priority']);
13 $users = array();
14 $assigned_users = array();
15 $assigned_users_name = '';
16 $status_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->prefix}wppm_task_statuses WHERE id = %d", $task_status));
17 $priority_name = $wpdb->get_var($wpdb->prepare("SELECT name FROM {$wpdb->prefix}wppm_task_priorities WHERE id = %d", $task_priority));
18 if(!empty($task['users'])){
19 $users = explode(",",$task['users']);
20 }
21 if(!empty($users)){
22 foreach($users as $user){
23 if( (!empty($proj_users)) && in_array($user,$proj_users)){
24 $userdata = get_userdata( $user );
25 $assigned_users[] = $userdata->display_name;
26 $assigned_users_name = implode(', ',$assigned_users);
27 }
28 }
29 }
30 $task_creator_data = get_userdata( $task['created_by'] );
31 $task_creator_name = $task_creator_data->display_name;
32 $export_colomn_value = array();
33 $unique_id = wp_rand();
34 $file_name = $unique_id.'.pdf';
35 $path_to_export = get_temp_dir().$file_name;
36 $url_to_export = get_home_url().'/?download-wppm-pdf-export='.$unique_id;
37 $upload_dir = wp_upload_dir();
38 $file_path = $upload_dir['basedir'] . '/task-pdf-' . time() . '.pdf';
39 $file_url = $upload_dir['baseurl'] . '/task-pdf-' . time() . '.pdf';
40 $filename=$path_to_export;
41 $counter_rec = 0;
42 if (ob_get_length()) ob_end_clean();
43 require(WPPM_ABSPATH.'asset/lib/fpdf/html2pdf.php');
44 $pdf = new PDF_HTML();
45 $pdf->AddPage();
46 $pdf->SetFont('Arial', 'B', $wppm_print_settings['wppm_print_body_font_size']);
47 $pdf->Cell(45, 10, 'Task Title:', 0, 0);
48 $pdf->SetFont('Arial', '', $wppm_print_settings['wppm_print_body_font_size']);
49 $pdf->Cell(0, 10, $task['task_name'], 0, 1);
50
51 // --- DESCRIPTION
52 $pdf->SetFont('Arial', 'B', $wppm_print_settings['wppm_print_body_font_size']);
53 $pdf->Cell(45, 10, 'Description:', 0, 1);
54 $pdf->SetFont('Arial', '', $wppm_print_settings['wppm_print_body_font_size']);
55 $pdf->MultiCell(0, 10, $pdf->WriteHTML($task['description']), 0, 1);
56
57 // --- OTHER FIELDS
58 $pdf->SetFont('Arial', 'B', $wppm_print_settings['wppm_print_body_font_size']);
59 $pdf->Cell(45, 10, 'Project:', 0, 0);
60 $pdf->SetFont('Arial', '', $wppm_print_settings['wppm_print_body_font_size']);
61 $pdf->Cell(0, 10, $project['project_name'], 0, 1);
62
63 $pdf->SetFont('Arial', 'B', $wppm_print_settings['wppm_print_body_font_size']);
64 $pdf->Cell(45, 10, 'Start Date:', 0, 0);
65 $pdf->SetFont('Arial', '', $wppm_print_settings['wppm_print_body_font_size']);
66 $pdf->Cell(0, 10, $task['start_date'], 0, 1);
67
68 $pdf->SetFont('Arial', 'B', $wppm_print_settings['wppm_print_body_font_size']);
69 $pdf->Cell(45, 10, 'Due Date:', 0, 0);
70 $pdf->SetFont('Arial', '', $wppm_print_settings['wppm_print_body_font_size']);
71 $pdf->Cell(0, 10, $task['end_date'], 0, 1);
72
73 $pdf->SetFont('Arial', 'B', $wppm_print_settings['wppm_print_body_font_size']);
74 $pdf->Cell(45, 10, 'Task Creator:', 0, 0);
75 $pdf->SetFont('Arial', '', $wppm_print_settings['wppm_print_body_font_size']);
76 $pdf->Cell(0, 10, $task_creator_name, 0, 1);
77
78 $pdf->SetFont('Arial', 'B', $wppm_print_settings['wppm_print_body_font_size']);
79 $pdf->Cell(45, 10, 'Status:', 0, 0);
80 $pdf->SetFont('Arial', '', $wppm_print_settings['wppm_print_body_font_size']);
81 $pdf->Cell(0, 10, $status_name, 0, 1);
82
83 $pdf->SetFont('Arial', 'B', $wppm_print_settings['wppm_print_body_font_size']);
84 $pdf->Cell(45, 10, 'Priority:', 0, 0);
85 $pdf->SetFont('Arial', '', $wppm_print_settings['wppm_print_body_font_size']);
86 $pdf->Cell(0, 10, $priority_name, 0, 1);
87
88 $pdf->SetFont('Arial', 'B', $wppm_print_settings['wppm_print_body_font_size']);
89 $pdf->Cell(45, 10, 'Assigned Users:', 0, 0);
90 $pdf->SetFont('Arial', '', $wppm_print_settings['wppm_print_body_font_size']);
91 $pdf->Cell(0, 10, $assigned_users_name, 0, 1);
92
93 $pdf->SetFont('Arial', 'B', $wppm_print_settings['wppm_print_body_font_size']);
94 $pdf->Cell(45, 10, 'Date Created:', 0, 0);
95 $pdf->SetFont('Arial', '', $wppm_print_settings['wppm_print_body_font_size']);
96 $pdf->Cell(0, 10, $task['date_created'], 0, 1);
97 $pdf->Ln();
98 header('Content-Type: application/pdf');
99 header('Content-Disposition: inline; filename="task.pdf"');
100 header('Cache-Control: private, max-age=0, must-revalidate');
101 header('Pragma: public');
102 $pdf->Output( 'I',$file_name); // Save file locally
103 exit;