![]() |
|---|
| [ Index ] |
Source Code Reference for V1.00 |
[Summary view] [Print] [Text view]
1 <?php /* $Id: overdue.php 136 2008-04-04 14:24:17Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/reports/reports/overdue.php $ */ 2 if (!defined('W2P_BASE_DIR')) { 3 die('You should not access this file directly.'); 4 } 5 6 // Output the PDF 7 // make the PDF file 8 if ($project_id != 0) { 9 $q = new DBQuery; 10 $q->addTable('projects'); 11 $q->addQuery('project_name'); 12 $q->addWhere('project_id=' . $project_id); 13 $pname = 'Project: ' . $q->loadResult(); 14 } else { 15 $pname = $AppUI->_('All Projects'); 16 } 17 if ($err = db_error()) { 18 $AppUI->setMsg($err, UI_MSG_ERROR); 19 $AppUI->redirect(); 20 } 21 22 $font_dir = W2P_BASE_DIR . '/lib/ezpdf/fonts'; 23 24 require ($AppUI->getLibraryClass('ezpdf/class.ezpdf')); 25 26 $pdf = &new Cezpdf($paper = 'A4', $orientation = 'landscape'); 27 $pdf->ezSetCmMargins(1, 2, 1.5, 1.5); 28 $pdf->selectFont($font_dir . '/Helvetica.afm'); 29 if ($locale_char_set == 'utf-8' && function_exists('utf8_decode')) { 30 $pdf->ezText(utf8_decode(w2PgetConfig('company_name')), 12); 31 } else { 32 $pdf->ezText(w2PgetConfig('company_name'), 12); 33 } 34 $date = new CDate(); 35 $pdf->ezText("\n" . $date->format($df), 8); 36 $next_week = new CDate($date); 37 $next_week->addSpan(new Date_Span(array(7, 0, 0, 0))); 38 39 $pdf->selectFont($font_dir . '/Helvetica-Bold.afm'); 40 $pdf->ezText("\n" . $AppUI->_('Project Overdue Task Report'), 12); 41 if ($locale_char_set == 'utf-8' && function_exists('utf8_decode')) { 42 $pdf->ezText(utf8_decode($pname), 15); 43 } else { 44 $pdf->ezText($pname, 15); 45 } 46 $pdf->ezText("\n"); 47 $pdf->selectFont($font_dir . '/Helvetica.afm'); 48 $title = null; 49 $options = array('showLines' => 2, 'showHeadings' => 1, 'fontSize' => 9, 'rowGap' => 4, 'colGap' => 5, 'xPos' => 50, 'xOrientation' => 'right', 'width' => '750', 'shaded' => 0, 'cols' => array(0 => array('justification' => 'left', 'width' => 250), 1 => array('justification' => 'left', 'width' => 120), 2 => array('justification' => 'center', 'width' => 120), 3 => array('justification' => 'center', 'width' => 75), 4 => array('justification' => 'center', 'width' => 75))); 50 51 $hasResources = $AppUI->isActiveModule('resources'); 52 $perms = &$AppUI->acl(); 53 if ($hasResources) { 54 $hasResources = $perms->checkModule('resources', 'view'); 55 } 56 // Build the data to go into the table. 57 $pdfdata = array(); 58 $columns = array(); 59 $columns[] = '<b>' . $AppUI->_('Task Name') . '</b>'; 60 $columns[] = '<b>' . $AppUI->_('Owner') . '</b>'; 61 $columns[] = '<b>' . $AppUI->_('Assigned Users') . '</b>'; 62 if ($hasResources) 63 $columns[] = '<b>' . $AppUI->_('Assigned Resources') . '</b>'; 64 $columns[] = '<b>' . $AppUI->_('Finish Date') . '</b>'; 65 66 // Grab the completed items in the last week 67 $q = &new DBQuery; 68 $q->addQuery('a.*'); 69 $q->addQuery('CONCAT(contact_first_name, \' \', contact_last_name) AS user_username'); 70 $q->addTable('tasks', 'a'); 71 $q->addTable('projects', 'pr'); 72 $q->addWhere('a.task_project = pr.project_id'); 73 $q->addJoin('users', 'b', 'a.task_owner = b.user_id', 'inner'); 74 $q->addJoin('contacts', 'ct', 'ct.contact_id = b.user_contact', 'inner'); 75 $q->addWhere('task_percent_complete < 100'); 76 $q->addWhere('pr.project_active = 1'); 77 if (($template_status = w2PgetConfig('template_projects_status_id')) != '') { 78 $q->addWhere('pr.project_status <> ' . (int)$template_status); 79 } 80 if ($project_id != 0) { 81 $q->addWhere('task_project = ' . (int)$project_id); 82 } 83 $q->addWhere('task_end_date < \'' . $date->format(FMT_DATETIME_MYSQL) . '\''); 84 $proj = &new CProject; 85 $proj->setAllowedSQL($AppUI->user_id, $q, null, 'pr'); 86 87 $obj = &new CTask; 88 $obj->setAllowedSQL($AppUI->user_id, $q); 89 $tasks = $q->loadHashList('task_id'); 90 91 if ($err = db_error()) { 92 $AppUI->setMsg($err, UI_MSG_ERROR); 93 $AppUI->redirect(); 94 } 95 // Now grab the resources allocated to the tasks. 96 $task_list = array_keys($tasks); 97 $assigned_users = array(); 98 // Build the array 99 foreach ($task_list as $tid) { 100 $assigned_users[$tid] = array(); 101 } 102 103 if (count($tasks)) { 104 $q->clear(); 105 $q->addQuery('a.task_id, a.perc_assignment, b.*, c.*'); 106 $q->addTable('user_tasks', 'a'); 107 $q->addJoin('users', 'b', 'a.user_id = b.user_id', 'inner'); 108 $q->addJoin('contacts', 'c', 'b.user_contact = c.contact_id', 'inner'); 109 $q->addWhere('a.task_id IN (' . implode(',', $task_list) . ')'); 110 $res = $q->exec(); 111 if (!$res) { 112 $AppUI->setMsg(db_error(), UI_MSG_ERROR); 113 $q->clear(); 114 $AppUI->redirect(); 115 } 116 while ($row = db_fetch_assoc($res)) { 117 $assigned_users[$row['task_id']][$row['user_id']] = $row[contact_first_name] . ' ' . $row[contact_last_name] . ' [' . $row[perc_assignment] . '%]'; 118 } 119 $q->clear(); 120 } 121 122 $resources = array(); 123 if ($hasResources && count($tasks)) { 124 foreach ($task_list as $tid) { 125 $resources[$tid] = array(); 126 } 127 $q->clear(); 128 $q->addQuery('a.*, b.resource_name'); 129 $q->addTable('resource_tasks', 'a'); 130 $q->addJoin('resources', 'b', 'a.resource_id = b.resource_id', 'inner'); 131 $q->addWhere('a.task_id IN (' . implode(',', $task_list) . ')'); 132 $res = $q->exec(); 133 if (!$res) { 134 $AppUI->setMsg(db_error(), UI_MSG_ERROR); 135 $q->clear(); 136 $AppUI->redirect(); 137 } 138 while ($row = db_fetch_assoc($res)) { 139 $resources[$row['task_id']][$row['resource_id']] = $row['resource_name'] . ' [' . $row['percent_allocated'] . '%]'; 140 } 141 $q->clear(); 142 } 143 144 // Build the data columns 145 foreach ($tasks as $task_id => $detail) { 146 $row = &$pdfdata[]; 147 $row[] = $detail['task_name']; 148 $row[] = $detail['user_username']; 149 $row[] = implode("\n", $assigned_users[$task_id]); 150 if ($hasResources) 151 $row[] = implode("\n", $resources[$task_id]); 152 $end_date = new CDate($detail['task_end_date']); 153 $row[] = $end_date->format($df); 154 } 155 156 $pdf->ezTable($pdfdata, $columns, $title, $options); 157 158 $pdf->ezStream(); 159 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jan 8 03:00:03 2009 | Cross-referenced by PHPXref 0.7 |