<td align="center"> <?php $diff_total = (int) ($totalBudget * $factor - $totalCost); echo $diff_total < 0 ? '<span style="color: red;">' : ''; echo $w2Pconfig['currency_symbol'] . $diff_total; echo $diff_total < 0 ? '</span>' : ''; ?> </td> </tr><?php $pdfdata[] = array(sprintf('%.1f%%', $project->project_percent_complete), ' ' . $projectName, $contactName, $AppUI->formatTZAwareTime($project->project_start_date, $df), $AppUI->formatTZAwareTime($criticalTasks[0]['task_end_date'], $df), $targetBudget, $actualCost, $w2Pconfig['currency_symbol'] . $diff_total); } if ($log_pdf) { // make the PDF file $temp_dir = W2P_BASE_DIR . '/files/temp'; $output = new w2p_Output_PDFRenderer('A4', 'landscape'); $output->addTitle($AppUI->_('Costs By Project')); $output->addDate($df); $output->addSubtitle($companies[$company_id]); $pdfheaders = array($AppUI->_('Work', UI_OUTPUT_JS), ' ' . $AppUI->_('Project Name', UI_OUTPUT_JS), $AppUI->_('Project Owner', UI_OUTPUT_JS), $AppUI->_('Start Date', UI_OUTPUT_JS), $AppUI->_('Finish Date', UI_OUTPUT_JS), $AppUI->_('Target Budget', UI_OUTPUT_JS), $AppUI->_('Actual Cost', UI_OUTPUT_JS), $AppUI->_('Difference', UI_OUTPUT_JS)); $options = array('showLines' => 1, 'fontSize' => 9, 'rowGap' => 1, 'colGap' => 1, 'xPos' => 50, 'xOrientation' => 'right', 'width' => '500', 'cols' => array(0 => array('justification' => 'center', 'width' => 45), 1 => array('justification' => 'left', 'width' => 175), 2 => array('justification' => 'center', 'width' => 75), 3 => array('justification' => 'center', 'width' => 65), 4 => array('justification' => 'center', 'width' => 65), 5 => array('justification' => 'center', 'width' => 65), 6 => array('justification' => 'center', 'width' => 65), 7 => array('justification' => 'center', 'width' => 65))); $output->addTable($title, $pdfheaders, $pdfdata, $options); $w2pReport = new CReport(); if ($output->writeFile($w2pReport->getFilename())) { echo '<tr><td colspan="13">'; echo '<a href="' . W2P_BASE_URL . '/files/temp/' . $w2pReport->getFilename() . '.pdf" target="pdf">'; echo $AppUI->_('View PDF File'); echo '</a>'; echo '</td></tr>'; } else { echo '<tr><td colspan="13">'; echo 'Could not open file to save PDF. ';
$start_date = new w2p_Utilities_Date($task['task_start_date']); $end_date = new w2p_Utilities_Date($task['task_end_date']); $spacer = str_repeat(' ', $task['depth']); $pdfdata[] = array($spacer . $task['task_name'], $task['task_description'], implode($users, ', '), $start_date != ' ' ? $start_date->format($df) : ' ', $end_date != ' ' ? $end_date->format($df) : ' ', $task['task_percent_complete'] . '%'); } } } echo '</table>'; if ($log_pdf) { // make the PDF file $project = new CProject(); $project->load((int) $project_id); $pname = $project->project_name; $temp_dir = W2P_BASE_DIR . '/files/temp'; $output = new w2p_Output_PDFRenderer('A4', 'landscape'); $output->addTitle($AppUI->_('Project Task Report')); $output->addDate($df); $output->addSubtitle(w2PgetConfig('company_name')); if ($project_id != 0) { $output->addSubtitle($pname); } $subhead = ''; if ($log_all) { $title = $AppUI->_('All task entries'); } else { if ($end_date != ' ') { $title = $AppUI->_('Task entries from') . ' ' . $start_date->format($df) . $AppUI->_('to') . ' ' . $end_date->format($df); } else { $title = $AppUI->_('Task entries from') . ' ' . $start_date->format($df); } }
} else { $q->addTable('companies'); $q->addQuery('company_id'); foreach ($q->loadColumn() as $company) { $total += showcompany($company, true); } } echo '<h2>' . $AppUI->_('Total Hours') . ': '; printf("%.2f", $total); echo '</h2>'; $pdfdata[] = array($AppUI->_('Total Hours'), round($total, 2)); if ($log_pdf) { // make the PDF file $temp_dir = W2P_BASE_DIR . '/files/temp'; $output = new w2p_Output_PDFRenderer(); $output->addTitle($AppUI->_('Overall Report')); $output->addDate($df); if ($log_all) { $date = new w2p_Utilities_Date(); $title = "All hours as of " . $date->format($df); } else { $sdate = new w2p_Utilities_Date($log_start_date); $edate = new w2p_Utilities_Date($log_end_date); $title = "Hours from " . $sdate->format($df) . ' to ' . $edate->format($df); } foreach ($allpdfdata as $company => $data) { $title = $company; $options = array('showLines' => 1, 'showHeadings' => 0, 'fontSize' => 8, 'rowGap' => 2, 'colGap' => 5, 'xPos' => 50, 'xOrientation' => 'right', 'width' => '500', 'cols' => array(0 => array('justification' => 'left', 'width' => 250), 1 => array('justification' => 'right', 'width' => 120))); $output->addTable($title, null, $data, $options); } $w2pReport = new CReport();
$cname = 'Company: ' . $company->company_name; } else { $cname = 'All Companies and All Projects'; } if ($log_userfilter) { $q = new w2p_Database_Query(); $q->addTable('contacts'); $q->addQuery('contact_display_name'); $q->addJoin('users', '', 'user_contact = contact_id', 'inner'); $q->addWhere('user_id =' . (int) $log_userfilter); $uname = 'User: '******'All Users'; } $output = new w2p_Output_PDFRenderer(); $output->addTitle($AppUI->_('Task Log Report')); $output->addDate($df); $subtitle = $company_id ? $cname : $pname; $output->addSubtitle($subtitle); $output->addSubtitle($uname); if ($log_all) { $title = 'All Task Log entries'; } else { $title = 'Task Log entries from ' . $start_date->format($df) . ' to ' . $end_date->format($df); } $pdfheaders = array($AppUI->_('Creator', UI_OUTPUT_JS), $AppUI->_('Company', UI_OUTPUT_JS), $AppUI->_('Project', UI_OUTPUT_JS), $AppUI->_('Task', UI_OUTPUT_JS), $AppUI->_('Date', UI_OUTPUT_JS), $AppUI->_('Description', UI_OUTPUT_JS), $AppUI->_('Billing Code', UI_OUTPUT_JS), $AppUI->_('Hours', UI_OUTPUT_JS)); $options = array('showLines' => 1, 'fontSize' => 7, 'rowGap' => 1, 'colGap' => 1, 'xPos' => 50, 'xOrientation' => 'right', 'width' => '500', 'cols' => array(0 => array('justification' => 'left', 'width' => 50), 1 => array('justification' => 'left', 'width' => 60), 2 => array('justification' => 'left', 'width' => 60), 3 => array('justification' => 'left', 'width' => 60), 4 => array('justification' => 'center', 'width' => 40), 5 => array('justification' => 'left', 'width' => 170), 6 => array('justification' => 'left', 'width' => 30), 7 => array('justification' => 'right', 'width' => 30))); $output->addTable($title, $pdfheaders, $pdfdata, $options); $w2pReport = new CReport(); if ($output->writeFile($w2pReport->getFilename())) { echo '<a href="' . W2P_BASE_URL . '/files/temp/' . $w2pReport->getFilename() . '.pdf" target="pdf">';
$pdfRow[] = round($sumBudget); $pdfRow[] = round($sumConsumed); echo '<td align="center">'; $sumDiff = (int) ($sumBudget - $sumConsumed); echo $sumDiff < 0 ? '<span style="color: red;">' : ''; echo $symbol . $sumDiff; echo $sumDiff < 0 ? '</span>' : ''; $pdfRow[] = round($sumDiff); echo '</td>'; echo '</tr>'; $pdfdata[] = $pdfRow; if ($log_pdf) { // make the PDF file $temp_dir = W2P_BASE_DIR . '/files/temp'; $output = new w2p_Output_PDFRenderer('A4', 'landscape'); $output->addTitle($AppUI->_('Costs By Project and Billing Category')); $output->addDate($df); $output->addSubtitle($companies[$company_id]); $columns = array(); $pdfheaders = array($AppUI->_('Work', UI_OUTPUT_JS), ' ' . $AppUI->_('Project Name', UI_OUTPUT_JS)); $columns[] = array('justification' => 'center', 'width' => 40); $columns[] = array('justification' => 'left', 'width' => 130); foreach ($billingCategory as $id => $category) { $pdfheaders[] = $AppUI->_($category . "\n" . $AppUI->_('Budgetted', UI_OUTPUT_JS), UI_OUTPUT_JS); $pdfheaders[] = "\n(" . $AppUI->_('Used', UI_OUTPUT_JS) . ")"; $columns[] = array('justification' => 'center', 'width' => 45); $columns[] = array('justification' => 'center', 'width' => 45); } $pdfheaders[] = $AppUI->_("Unidentified\n(Used)", UI_OUTPUT_JS); $pdfheaders[] = $AppUI->_('Budgetted', UI_OUTPUT_JS); $pdfheaders[] = $AppUI->_('Used', UI_OUTPUT_JS);
} $q->clear(); $q->addQuery('a.*, b.resource_name'); $q->addTable('resource_tasks', 'a'); $q->addJoin('resources', 'b', 'a.resource_id = b.resource_id', 'inner'); $q->addWhere('a.task_id IN (' . implode(',', $task_list) . ')'); $rows = $q->loadHashList('resource_id'); foreach ($rows as $row) { $resources[$row['task_id']][$row['resource_id']] = $row['resource_name'] . ' [' . $row['percent_allocated'] . '%]'; } $q->clear(); } // Build the data columns foreach ($tasks as $task_id => $detail) { $row =& $pdfdata[]; $row[] = $detail['task_name']; $row[] = $detail['user_username']; $row[] = implode("\n", $assigned_users[$task_id]); if ($hasResources) { $row[] = implode("\n", $resources[$task_id]); } $end_date = new w2p_Utilities_Date($detail['task_end_date']); $row[] = $end_date->format($df); } $output = new w2p_Output_PDFRenderer('A4', 'landscape'); $output->addTitle($AppUI->_('Project Completed Task Report')); $output->addDate($df); $output->addSubtitle(w2PgetConfig('company_name')); $output->addSubtitle($pname); $output->addTable($title, $columns, $pdfdata, $options); $output->getStream();
} // Output the PDF // make the PDF file if ($project_id != 0) { $project = new CProject(); $project->load($project_id); $pname = 'Project: ' . $project->project_name; } else { $pname = $AppUI->_('All Projects'); } if ($err = db_error()) { $AppUI->setMsg($err, UI_MSG_ERROR); $AppUI->redirect('m=' . $m); } $output = new w2p_Output_PDFRenderer('A4', 'landscape'); $output->addTitle($AppUI->_('Project Upcoming Task Report')); $output->addDate($df); $output->addSubtitle(w2PgetConfig('company_name')); $output->addSubtitle($pname); $date = new w2p_Utilities_Date(); $next_week = new w2p_Utilities_Date($date); $next_week->addSpan(new Date_Span(array(7, 0, 0, 0))); $title = $AppUI->_('Tasks Due to be Completed By') . ' ' . $next_week->format($df); $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))); $hasResources = $AppUI->isActiveModule('resources'); $perms =& $AppUI->acl(); if ($hasResources) { $hasResources = canView('resources'); } // Build the data to go into the table. $pdfdata = array();
<td align="center"> <?php $diff_total = (int) ($task->task_target_budget * $factor - $costs['totalCosts']); echo $diff_total < 0 ? '<span style="color: red;">' : ''; echo $w2Pconfig['currency_symbol'] . $diff_total; echo $diff_total < 0 ? '</span>' : ''; ?> </td> </tr><?php $pdfdata[] = array(sprintf('%.1f%%', $task->task_percent_complete), ' ' . $taskName, $contactName, $AppUI->formatTZAwareTime($task->task_start_date, $df), $AppUI->formatTZAwareTime($task->task_end_date, $df), $targetBudget, $actualCost, $w2Pconfig['currency_symbol'] . $diff_total); } if ($log_pdf) { // make the PDF file $temp_dir = W2P_BASE_DIR . '/files/temp'; $output = new w2p_Output_PDFRenderer('A4', 'landscape'); $output->addTitle($AppUI->_('Costs By Task')); $output->addDate($df); $output->addSubtitle($projectList[$project_id]['project_name']); $pdfheaders = array($AppUI->_('Work', UI_OUTPUT_JS), ' ' . $AppUI->_('Project Name', UI_OUTPUT_JS), $AppUI->_('Project Owner', UI_OUTPUT_JS), $AppUI->_('Start Date', UI_OUTPUT_JS), $AppUI->_('Finish Date', UI_OUTPUT_JS), $AppUI->_('Target Budget', UI_OUTPUT_JS), $AppUI->_('Actual Cost', UI_OUTPUT_JS), $AppUI->_('Difference', UI_OUTPUT_JS)); $options = array('showLines' => 1, 'fontSize' => 9, 'rowGap' => 1, 'colGap' => 1, 'xPos' => 50, 'xOrientation' => 'right', 'width' => '500', 'cols' => array(0 => array('justification' => 'center', 'width' => 45), 1 => array('justification' => 'left', 'width' => 175), 2 => array('justification' => 'center', 'width' => 75), 3 => array('justification' => 'center', 'width' => 65), 4 => array('justification' => 'center', 'width' => 65), 5 => array('justification' => 'center', 'width' => 65), 6 => array('justification' => 'center', 'width' => 65), 7 => array('justification' => 'center', 'width' => 65))); $output->addTable($title, $pdfheaders, $pdfdata, $options); $w2pReport = new CReport(); if ($output->writeFile($w2pReport->getFilename())) { echo '<tr><td colspan="13">'; echo '<a href="' . W2P_BASE_URL . '/files/temp/' . $w2pReport->getFilename() . '.pdf" target="pdf">'; echo $AppUI->_('View PDF File'); echo '</a>'; echo '</td></tr>'; } else { echo '<tr><td colspan="13">'; echo 'Could not open file to save PDF. ';