258 lines
11 KiB
PHP
258 lines
11 KiB
PHP
<?php
|
|
/** \file scripts\page\report_project.php
|
|
* \brief DI webinterface project report upload.
|
|
* \author Rob Schalken, Core|Vision
|
|
* \version $Revision: 1.10 $
|
|
* \date $Date: 2015/04/13 15:49:59 $
|
|
*
|
|
* This file contains the report which generates an pdf from the project info.
|
|
*/
|
|
|
|
require_once("report.php");
|
|
|
|
/**
|
|
* Create the mtinfo evaluation report
|
|
*/
|
|
function report_project($id, $destination = "D", $download_by = NULL) {
|
|
GLOBAL $_PAGE_INFO;
|
|
|
|
// Give the script some extra memory and execution time
|
|
ini_set("memory_limit","2048M");
|
|
ini_set("max_execution_time","120");
|
|
|
|
// Get log data from the "report" database
|
|
db_connect("report", "log");
|
|
|
|
// Retrieve info
|
|
$date = date('Y-m-d');
|
|
$datetime = date('Y-m-d / H:i:s');
|
|
$user = (is_null($download_by)) ? db_fetch_user($_PAGE_INFO['login']['user']['id'], "", 1) : $download_by;
|
|
$customer = db_fetch_customer($_PAGE_INFO['login']['customer']['id'], 1);
|
|
|
|
// Fetch project info
|
|
$project = db_fetch_project($id, "", 1);
|
|
|
|
// Set file info
|
|
$_PAGE_INFO['report_type'] = "pdf";
|
|
$_PAGE_INFO['dest'] = $destination;
|
|
$_PAGE_INFO['orientation'] = "portrait";
|
|
$_PAGE_INFO['file'] = _("MTinfo") . "_" . strtolower(_("project")) . "_" .$project['naam'] . "_" . str_replace("-", "", $date) . ".pdf";
|
|
|
|
// Clear/delete array
|
|
$_PAGE_INFO['delete'] = array();
|
|
|
|
// Create header info
|
|
if (strtolower($_PAGE_INFO['report_type']) == "pdf") {
|
|
report_header(array(subject => "Log project" ,
|
|
header => _("Log project") . " - " . $project['naam'] ,
|
|
data => array( array("Date", $datetime) ,
|
|
array("Timezone", ucfirst($customer['tz'])) ,
|
|
array("MTinfo", strtoupper((is_ReleaseCandidate() ? $_SESSION[$_PAGE_INFO['id']]['release_dir'] : VERSION))),
|
|
array("User", getUser($_PAGE_INFO['login']['user']['id'])))));
|
|
|
|
}
|
|
|
|
// Default table layout
|
|
$single_report_data = array(border => array("LBT","RBT"),
|
|
bold => array(0,0),
|
|
align => array("L","L"),
|
|
font_size => array(8,8),
|
|
cell_width => array(1,179),
|
|
check_page_end => 1);
|
|
|
|
$double_report_data = array(border => array("LRBT","LRBT"),
|
|
bold => array(1,0),
|
|
align => array("L","L"),
|
|
font_size => array(8,8),
|
|
cell_width => array(80,100),
|
|
check_page_end => 1);
|
|
|
|
// General information
|
|
report_data(array_merge($double_report_data, array(value => array("General info"), cell_width => array(180,0), ishtml => array(array(type => "bookmark", data => _("General info"), parent => 0, bold => 1)), styling_options => array(array('cell' => "fillcolor={rgb 0.78 0.80 0.78}")))));
|
|
|
|
// General info
|
|
$general_info = array('Project name' => 'naam',
|
|
'Type project' => 'type',
|
|
'WBI' => 'wbi_nummer',
|
|
'Design status' => 'ostatus',
|
|
'Plan status' => 'pstatus',
|
|
'Project status' => 'sstatus',
|
|
'Finished' => 'status',
|
|
'Project description' => 'beschrijving');
|
|
|
|
foreach($general_info as $key => $item) {
|
|
// Pre-action
|
|
switch(strtolower($key)) {
|
|
case 'plan status':
|
|
case 'design status':
|
|
if ($project['type'] != "normaal") {
|
|
report_text(array_merge($double_report_data, array(value => array($key, ($project['sstatus'] == "vrijgegeven" ? "vrijgegeven" : $project[$item]) ))));
|
|
}
|
|
break;
|
|
case 'project status':
|
|
report_text(array_merge($double_report_data, array(value => array($key, ((($project['type'] != "normaal" ? $project[$item] : ($project['pstatus'] == "gereed" ? "vrijgegeven" : $project[$item])) ))))));
|
|
break;
|
|
case 'finished':
|
|
report_text(array_merge($double_report_data, array(value => array($key, (strtolower($project[$item]) == "afgesloten") ? '√' : ''))));
|
|
break;
|
|
default:
|
|
report_text(array_merge($double_report_data, array(value => array($key, $project[$item]))));
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Empty line
|
|
empty_line();
|
|
|
|
// Retrieve project log
|
|
$project_logs = db_fetch_project_comment($id);
|
|
|
|
if (is_array($project_logs)) {
|
|
// Project log
|
|
report_data(array_merge($double_report_data, array(value => array("Project log"), cell_width => array(180,0), ishtml => array(array(type => "bookmark", data => _("Project log"), parent => 0, bold => 1)), styling_options => array(array('cell' => "fillcolor={rgb 0.78 0.80 0.78}")))));
|
|
|
|
foreach($project_logs as $item) {
|
|
report_text(array_merge($double_report_data, array(value => array("[" . $item['datum'] . "] " . getUser($item['gebruiker']) . ":\r\n" . $item['tekst']), cell_width => array(180,0), border => array("LRB"), bold => array(0))));
|
|
}
|
|
|
|
// Empty line
|
|
empty_line();
|
|
}
|
|
|
|
// Retrieve project users
|
|
$project_users = db_fetch_project_users($id);
|
|
|
|
$users = array('normaal_8' => 'gebruikers_8',
|
|
'normaal_9' => 'gebruikers_9',
|
|
'normaal_10' => 'gebruikers_10',
|
|
'wbu' => 'wbu',
|
|
'wbv' => 'wbv',
|
|
'projectleider' => 'projectleider',
|
|
'projectleider-rc' => 'projectleider-rc',
|
|
'projecten:a' => 'projecten:a',
|
|
'projecten:b' => 'projecten:b',
|
|
'projecten:c' => 'projecten:c',
|
|
'projecten:d' => 'projecten:d',
|
|
'projecten:e' => 'projecten:e',
|
|
'projecten:f' => 'projecten:f',
|
|
'projecten:g' => 'projecten:g',
|
|
'projecten:h' => 'projecten:h');
|
|
|
|
if (is_array($project_users)) {
|
|
// Users
|
|
report_data(array_merge($double_report_data, array(value => array("Users"), cell_width => array(180,0), ishtml => array(array(type => "bookmark", data => _("Users"), parent => 0, bold => 1)), styling_options => array(array('cell' => "fillcolor={rgb 0.78 0.80 0.78}")))));
|
|
|
|
foreach($users as $key => $part) {
|
|
$first = TRUE;
|
|
|
|
foreach($project_users as $item) {
|
|
if (($key == $item['rol']) || ($key == $item['rol'] . "_" . $item['level'])) {
|
|
|
|
report_data(array_merge($double_report_data, array(value => (($first) ? array($part, getUser($item['id'])) : array("", getUser($item['id']))), border => (($first) ? array("LRT","LRT") : array("LR","LR")))));
|
|
|
|
// Clear flag
|
|
$first = FALSE;
|
|
}
|
|
}
|
|
}
|
|
|
|
// EOT / Empty line
|
|
report_data(array_merge($double_report_data, array(value => array("", ""), border => array("T","T"))));
|
|
}
|
|
|
|
// Retrieve project equipment/types
|
|
$project_equip = db_fetch_project_lances($id);
|
|
$types = db_fetch_system_devices($_PAGE_INFO['i18n']);
|
|
|
|
if (is_array($project_equip)) {
|
|
// Equipment
|
|
report_data(array_merge($double_report_data, array(value => array("Equipment"), cell_width => array(180,0), ishtml => array(array(type => "bookmark", data => _("Equipment"), parent => 0, bold => 1)), styling_options => array(array('cell' => "fillcolor={rgb 0.78 0.80 0.78}")))));
|
|
|
|
foreach($types as $type) {
|
|
$first = TRUE;
|
|
|
|
foreach($project_equip as $item) {
|
|
if ($type['id'] == $item['device']) {
|
|
report_data(array_merge($double_report_data, array(value => (($first) ? array($type['naam'], $item['idcode']) : array("", $item['idcode'])), border => (($first) ? array("LRT","LRT") : array("LR","LR")))));
|
|
|
|
// Clear flag
|
|
$first = FALSE;
|
|
}
|
|
}
|
|
}
|
|
|
|
// EOT / Empty line
|
|
report_data(array_merge($double_report_data, array(value => array("", ""), border => array("T","T"))));
|
|
}
|
|
|
|
// Retrieve project / all feedback templates
|
|
$project_questionaires = db_fetch_project_questionaire($id);
|
|
$project_templates = db_fetch_questionaires($_SESSION[$_PAGE_INFO['id']]['i18n'], NULL, NULL, "feedback");
|
|
|
|
if (is_array($project_questionaires)) {
|
|
$first = TRUE;
|
|
|
|
foreach($project_templates as $template) {
|
|
foreach($project_questionaires as $item) {
|
|
if ($template['id'] == $item['enquete']) {
|
|
// Script templates
|
|
if ($first) {
|
|
// feedback template
|
|
report_data(array_merge($double_report_data, array(value => array("Feedback templates"), cell_width => array(180,0), ishtml => array(array(type => "bookmark", data => _("Feedback templates"), parent => 0, bold => 1)), styling_options => array(array('cell' => "fillcolor={rgb 0.78 0.80 0.78}")))));
|
|
|
|
// Clear flag
|
|
$first = FALSE;
|
|
}
|
|
|
|
report_data(array_merge($double_report_data, array(value => array($template['titel'],"√"), border => array("LBRT","LBRT"))));
|
|
}
|
|
}
|
|
}
|
|
|
|
// Empty line
|
|
empty_line();
|
|
}
|
|
|
|
// Retrieve project / all script templates
|
|
$project_questionaires = db_fetch_project_questionaire($id);
|
|
$project_templates = db_fetch_questionaires($_SESSION[$_PAGE_INFO['id']]['i18n'], NULL, NULL, "draaiboek");
|
|
|
|
if (is_array($project_questionaires)) {
|
|
$first = TRUE;
|
|
|
|
foreach($project_templates as $template) {
|
|
foreach($project_questionaires as $item) {
|
|
if ($template['id'] == $item['enquete']) {
|
|
switch($template['id']) {
|
|
case ENQ_WECO_TRDL:
|
|
case ENQ_WECO_WORKPLACE:
|
|
case ENQ_WECO_WORKTIME:
|
|
case ENQ_WECO_NOVOLTAGE:
|
|
case ENQ_WECO_SAFETY:
|
|
case ENQ_SUBSCRIPTION_LIST:
|
|
break;
|
|
default:
|
|
// Script templates
|
|
if ($first) {
|
|
report_data(array_merge($double_report_data, array(value => array("Script templates"), cell_width => array(180,0), ishtml => array(array(type => "bookmark", data => _("Script templates"), parent => 0, bold => 1)), styling_options => array(array('cell' => "fillcolor={rgb 0.78 0.80 0.78}")))));
|
|
|
|
// Clear flag
|
|
$first = FALSE;
|
|
}
|
|
|
|
|
|
$level = explode(' ', _("gebruikers_" . $item['level']));
|
|
$level = $level[0] . " " . $level[1];
|
|
report_data(array_merge($double_report_data, array(value => array($template['titel'], $level), border => array("LBRT","LBRT"))));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Generate report
|
|
return report_generate();
|
|
}
|
|
?>
|