function cleanText($text)
{
    //This text file is not utf, its iso so we have to decode/encode
    $text = safe_utf8_decode($text);
    $trade = array('�' => 'a', '�' => 'a', '�' => 'a', '�' => 'a', '�' => 'a', '�' => 'A', '�' => 'A', '�' => 'A', '�' => 'A', '�' => 'A', '�' => 'e', '�' => 'e', '�' => 'e', '�' => 'e', '�' => 'E', '�' => 'E', '�' => 'E', '�' => 'E', '�' => 'i', '�' => 'i', '�' => 'i', '�' => 'i', '�' => 'I', '�' => 'I', '�' => 'I', '�' => 'I', '�' => 'o', '�' => 'o', '�' => 'o', '�' => 'o', '�' => 'o', '�' => 'O', '�' => 'O', '�' => 'O', '�' => 'O', '�' => 'O', '�' => 'u', '�' => 'u', '�' => 'u', '�' => 'u', '�' => 'U', '�' => 'U', '�' => 'U', '�' => 'U', '�' => 'N', '�' => 'n');
    $text = strtr($text, $trade);
    $text = utf8_encode($text);
    return $text;
}
Example #2
0
 $pdf->ezSetCmMargins(1, 2, 1.5, 1.5);
 $pdf->selectFont("{$font_dir}/Helvetica.afm");
 $pdf->ezText(safe_utf8_decode(dPgetConfig('company_name')), 12);
 $date = new CDate();
 $pdf->ezText("\n" . $date->format($df), 8);
 $pdf->selectFont("{$font_dir}/Helvetica-Bold.afm");
 $pdf->ezText("\n" . safe_utf8_decode($AppUI->_('Task Log Report')), 12);
 $pdf->ezText(safe_utf8_decode($pname), 15);
 if ($log_all) {
     $pdf->ezText("All task log entries", 9);
 } else {
     $pdf->ezText("Task log entries from " . $start_date->format($df) . ' to ' . $end_date->format($df), 9);
 }
 $pdf->ezText("\n\n");
 $title = 'Task Logs';
 $pdfheaders = array(safe_utf8_decode($AppUI->_('Created by')), safe_utf8_decode($AppUI->_('Summary')), safe_utf8_decode($AppUI->_('Description')), safe_utf8_decode($AppUI->_('Date')), safe_utf8_decode($AppUI->_('Hours')), safe_utf8_decode($AppUI->_('Cost Code')));
 $options = array('showLines' => 0, 'fontSize' => 12, 'rowGap' => 2, 'colGap' => 5, 'xPos' => 50, 'xOrientation' => 'right', 'width' => 500);
 $pdfheaderdata[] = array('', '', '', '', '', '');
 $pdf->ezTable($pdfheaderdata, $pdfheaders, $title, $options);
 $options['col_options'] = array(2 => array('width' => 250), 3 => array('width' => 55), 4 => array('width' => 30), 5 => array('width' => 30));
 $options['showHeadings'] = 0;
 $options['showLines'] = 1;
 $options['fontSize'] = 8;
 $pdf->ezTable($pdfdata, '', '', $options);
 if ($fp = fopen($temp_dir . '/temp' . $AppUI->user_id . '.pdf', 'wb')) {
     fwrite($fp, $pdf->ezOutput());
     fclose($fp);
     echo '<a href="' . DP_BASE_URL . '/files/temp/temp' . $AppUI->user_id . '.pdf" target="pdf">';
     echo $AppUI->_("View PDF File");
     echo "</a>";
 } else {
Example #3
0
    foreach ($task_list as $tid) {
        $resources[$tid] = array();
    }
    $q->clear();
    $q->addQuery('a.*, b.resource_name');
    $q->addTable('resource_tasks', 'a');
    $q->leftJoin('resources', 'b', 'a.resource_id = b.resource_id');
    $q->addWhere('a.task_id in (' . implode(',', $task_list) . ')');
    $res = $q->exec();
    if (!$res) {
        $AppUI->setMsg(db_error(), UI_MSG_ERROR);
        $AppUI->redirect();
    }
    while ($row = db_fetch_assoc($res)) {
        $resources[$row['task_id']][$row['resource_id']] = safe_utf8_decode($row['resource_name']) . " [" . $row['percent_allocated'] . "%]";
    }
}
// Build the data columns
foreach ($tasks as $task_id => $detail) {
    $row =& $pdfdata[];
    $row[] = safe_utf8_decode($detail['task_name']);
    $row[] = safe_utf8_decode($detail['user_username']);
    $row[] = implode("\n", $assigned_users[$task_id]);
    if ($hasResources) {
        $row[] = implode("\n", $resources[$task_id]);
    }
    $end_date = new CDate($detail['task_end_date']);
    $row[] = $end_date->format($df);
}
$pdf->ezTable($pdfdata, $columns, $title, $options);
$pdf->ezStream();
Example #4
0
function showcompany($company, $restricted = false)
{
    global $AppUI, $allpdfdata, $log_start_date, $log_end_date, $log_all;
    /* $sql="
            SELECT
                    billingcode_id,
                    billingcode_name,
                    billingcode_value
            FROM billingcode
            WHERE company_id=$company
            ORDER BY billingcode_name ASC
            ";
                                                                                                                      
            $company_billingcodes=NULL;
            $ptrc=db_exec($sql);
            $nums=db_num_rows($ptrc);
            echo db_error();
                                                                                                                             
            for ($x=0; $x < $nums; $x++) {
                    $row=db_fetch_assoc($ptrc);
                    $company_billingcodes[$row['billingcode_id']]=$row['billingcode_name'];
            }
    */
    $q = new DBQuery();
    $q->addTable('projects');
    $q->addQuery('project_id, project_name');
    $q->addWhere('project_company = ' . $company);
    $projects = $q->loadHashList();
    $q->addTable('companies');
    $q->addQuery('company_name');
    $q->addWhere('company_id = ' . $company);
    $company_name = $q->loadResult();
    $table = '<h2>Company: ' . $company_name . '</h2>
        <table cellspacing="1" cellpadding="4" border="0" class="tbl">';
    $project_row = '
        <tr>
                <th>' . $AppUI->_('Project') . '</th>';
    $pdfth[] = $AppUI->_('Project');
    /*		if (isset($company_billingcodes))
    	                foreach ($company_billingcodes as $code)
    			{
            	                $project_row .= '<th>' . $code . ' ' . $AppUI->_('Hours') . '</th>';
    				$pdfth[] = $code;
    			}
      */
    $project_row .= '<th>' . $AppUI->_('Total') . '</th></tr>';
    $pdfth[] = $AppUI->_('Total');
    $pdfdata[] = $pdfth;
    $hours = 0.0;
    $table .= $project_row;
    foreach ($projects as $project => $name) {
        $pdfproject = array();
        $pdfproject[] = safe_utf8_decode($name);
        $project_hours = 0;
        $project_row = "<tr><td>{$name}</td>";
        $q->addTable('projects', 'prj');
        $q->addTable('tasks', 't');
        $q->addTable('task_log', 'tl');
        $q->addQuery('task_log_costcode, sum(task_log_hours) as hours');
        $where = 'project_id = ' . $project;
        if ($log_start_date != 0 && !$log_all) {
            $where .= " AND task_log_date >= {$log_start_date}";
        }
        if ($log_end_date != 0 && !$log_all) {
            $where .= " AND task_log_date <= {$log_end_date}";
        }
        if ($restricted) {
            $where .= " AND task_log_creator = '" . $AppUI->user_id . "'";
        }
        $where .= ' AND project_id = task_project' . ' AND task_id = task_log_task';
        $q->addWhere($where);
        $q->addGroup('project_id');
        //task_log_costcode
        $task_logs = $q->loadHashList();
        /*		if (isset($company_billingcodes))
        		foreach ($company_billingcodes as $code => $name)
        		{
        			if (isset($task_logs[$code]))
        			{
        				$value = sprintf("%.2f", $task_logs[$code]);
        				$project_row .= '<td>' . $value . '</td>';
        				$project_hours += $task_logs[$code];
        				$pdfproject[] = $value;
        			}
        			else
        			{
        				$project_row .= '<td>&nbsp;</td>';
        				$pdfproject[] = 0;
        			}
        		}
        */
        foreach ($task_logs as $task_log) {
            $project_hours += $task_log;
        }
        $project_row .= '<td>' . round($project_hours, 2) . '</td></tr>';
        $pdfproject[] = round($project_hours, 2);
        $hours += $project_hours;
        if ($project_hours > 0) {
            $table .= $project_row;
            $pdfdata[] = $pdfproject;
        }
    }
    if ($hours > 0) {
        $allpdfdata[$company_name] = $pdfdata;
        echo $table;
        echo '<tr><td>Total</td><td>' . round($hours, 2) . '</td></tr></table>';
    }
    return $hours;
}
Example #5
0
if (is_array($tasks)) {
    $nameUser = '';
    foreach ($tasks as $t) {
        if ($nameUser != $t['user_name']) {
            $row++;
            $barTmp = new GanttBar($row++, array($t['user_name'], '', '', ' '), '0', '0;', 0.6);
            $barTmp->title->SetFont(FF_CUSTOM, FS_NORMAL, 8);
            $barTmp->title->SetColor('#' . $t['project_color_identifier']);
            $barTmp->SetFillColor('#' . $t['project_color_identifier']);
            if (is_file(TTF_DIR . 'FreeSansBold.ttf')) {
                $barTmp->title->SetFont(FF_CUSTOM, FF_BOLD);
            }
            $graph2->Add($barTmp);
        }
        if ($locale_char_set == 'utf-8' && function_exists('safe_utf8_decode')) {
            $name = mb_strlen(safe_utf8_decode($t['task_name'])) > 25 ? mb_substr(safe_utf8_decode($t['task_name']), 0, 22) . '...' : safe_utf8_decode($t['task_name']);
            $nameUser = $t['user_name'];
        } else {
            //while using charset different than UTF-8 we need not to use utf8_deocde
            $name = mb_strlen($t['task_name']) > 25 ? mb_substr($t['task_name'], 0, 22) . '...' : $t['task_name'];
            $nameUser = $t['user_name'];
        }
        //using new jpGraph determines using Date object instead of string
        $start = $t['task_start_date'] > '0000-00-00 00:00:00' ? $t['task_start_date'] : date('Y-m-d H:i:s');
        $end_date = $t['task_end_date'];
        $actual_end = $t['task_end_date'] ? $t['task_end_date'] : ' ';
        $end_date = new CDate($end_date);
        //$end->addDays(0);
        $end = $end_date->getDate();
        $start = new CDate($start);
        //$start->addDays(0);
Example #6
0
/**
 * Need to use safe_utf8_decode because eZPDF doesn't understand UTF8, only Latin1
 */
function collate_pdf_task($depth, $task)
{
    global $project_id, $pdfdata, $df;
    $spacer = '';
    for ($i = 1; $i < $depth; $i++) {
        $spacer .= '  ';
    }
    $data = array();
    if ($project_id == 0) {
        $data[] = safe_utf8_decode($task['project_name']);
    }
    $data[] = $spacer . safe_utf8_decode($task['task_name']);
    $data[] = safe_utf8_decode($task['task_description']);
    $data[] = safe_utf8_decode($task['users']);
    $data[] = safe_utf8_decode($task['start_date'] != ' ' ? $task['start_date']->format($df) : ' ');
    $data[] = safe_utf8_decode($task['end_date'] != ' ' ? $task['end_date']->format($df) : ' ');
    $data[] = safe_utf8_decode($task['task_percent_complete'] . '%');
    $pdfdata[] = $data;
    unset($data);
}
Example #7
0
     $level = 0;
 }
 $name = $a['task_name'];
 if ($locale_char_set == 'utf-8' && function_exists('safe_utf8_decode')) {
     $name = safe_utf8_decode($name);
 }
 $name = mb_strlen($name) > 34 ? mb_substr($name, 0, 33) . '.' : $name;
 $name = str_repeat(' ', $level) . $name;
 if ($caller == 'todo') {
     $pname = $a['project_name'];
     if ($locale_char_set == 'utf-8') {
         if (function_exists('mb_substr')) {
             $pname = mb_strlen($pname) > 14 ? mb_substr($pname, 0, 5) . '...' . mb_substr($pname, -5, 5) : $pname;
         } else {
             if (function_exists('safe_utf8_decode')) {
                 $pname = safe_utf8_decode($pname);
             }
         }
     } else {
         $pname = mb_strlen($pname) > 14 ? mb_substr($pname, 0, 5) . '...' . mb_substr($pname, -5, 5) : $pname;
     }
 }
 //using new jpGraph determines using Date object instead of string
 $start_date = new CDate($a['task_start_date']);
 $end_date = new CDate($a['task_end_date']);
 $start = $start_date->getDate();
 $end = $end_date->getDate();
 $progress = $a['task_percent_complete'] + 0;
 if ($progress > 100) {
     $progress = 100;
 } else {
Example #8
0
        $graph->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HWEEK);
        $graph->scale->week->SetStyle(WEEKSTYLE_WNBR);
    }
}
$row = 0;
if (!is_array($projects) || sizeof($projects) == 0) {
    $d = new CDate();
    $bar = new GanttBar($row++, array(' ' . $AppUI->_('No projects found'), ' ', ' ', ' '), $d->getDate(), $d->getDate(), ' ', 0.6);
    $bar->title->SetFont(FF_CUSTOM, FS_NORMAL, 8);
    $bar->title->SetColor('red');
    $graph->Add($bar);
}
if (is_array($projects)) {
    foreach ($projects as $p) {
        if ($locale_char_set == 'utf-8' && function_exists('safe_utf8_decode')) {
            $name = mb_strlen(safe_utf8_decode($p['project_name'])) > 25 ? mb_substr(safe_utf8_decode($p['project_name']), 0, 22) . '...' : safe_utf8_decode($p['project_name']);
        } else {
            //while using charset different than UTF-8 we need not to use utf8_deocde
            $name = mb_strlen($p['project_name']) > 25 ? mb_substr($p['project_name'], 0, 22) . '...' : $p['project_name'];
        }
        //using new jpGraph determines using Date object instead of string
        $start = $p['project_start_date'] > '0000-00-00 00:00:00' ? $p['project_start_date'] : date('Y-m-d H:i:s');
        $end_date = $p['project_end_date'] > '0000-00-00 00:00:00' ? $p['project_end_date'] : date('Y-m-d H:i:s', time());
        $end_date = new CDate($end_date);
        //$end->addDays(0);
        $end = $end_date->getDate();
        $start = new CDate($start);
        //$start->addDays(0);
        $start = $start->getDate();
        $progress = $p['project_percent_complete'] + 0;
        $caption = '';
function cleanText($text)
{
    $text = safe_utf8_decode($text);
    return $text;
}