Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Html time export #21

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions htmltimetable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
function starthtmldocument($handle){
fwrite($handle,
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
');
fwrite($handle, css());
fwrite($handle, '
</head>
<body>');
}

$classes=null;

function starthtmltable($handle,$columns){
global $classes;

fwrite($handle, ' <table>');
fwrite($handle, ' <tr>');
$classes=array();
foreach ($columns as $column){
$class=strtolower(str_replace(" ", "_", $column));
$classes[]=$class;
fwrite($handle, ' <th class="'.$class.'">'.$column.'</th>');
}

fwrite($handle, ' </tr>');
}

$odd_row=true;

function addtohtmltable($handle,$columns){
global $odd_row, $classes;
if ($odd_row){
fwrite($handle, ' <tr class="odd">');
} else fwrite($handle, ' <tr class="even">');
$odd_row=!$odd_row;

for ($index=0; $index<count($columns);$index++){
fwrite($handle, ' <td class="'.$classes[$index].'">'.$columns[$index].'</td>');
}

fwrite($handle, ' </tr>');

}

function closehtmltable($handle){
fwrite($handle, ' </table>');
}

function closehtmldocument($handle){
fwrite($handle, ' </body>');
fwrite($handle, '</html>');
}

function css(){
return '<style type="text/css">
*{ font-size: 11px; }
.stunden{ max-width: 40px; overflow: hidden; }
.begonnen, .beendet{ max-width: 40px; overflow: hidden; }
.odd{ background-color: #ddd; }
table{ border-collapse:collapse }
td{ border: 1px solid black; }
</style>';
}
1 change: 1 addition & 0 deletions language/de/lng.conf
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ deleted = gelöscht
desktop = Arbeitsplatz
edited = bearbeitet
excelexport = Excel
htmlexport = HTML
export = Export
favicon = Favoriten-Icon
general = Allgemein
Expand Down
1 change: 1 addition & 0 deletions language/en/lng.conf
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ deleted = deleted
desktop = Desktop
edited = edited
excelexport = Excel
htmlexport = HTML
export = Export
favicon = Favicon
general = General
Expand Down
37 changes: 37 additions & 0 deletions managetimetracker.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
require("init.php");
require('htmltimetable.php');
// check if the user is logged in
if (!isset($_SESSION["userid"])) {
$template->assign("loginerror", 0);
Expand Down Expand Up @@ -181,6 +182,42 @@
echo "ok";
}
}
} elseif ($action == "projecthtml") {
if (!chkproject($userid, $id)) {
$errtxt = $langfile["notyourproject"];
$noperm = $langfile["accessdenied"];
$template->assign("errortext", "$errtxt<br>$noperm");
$template->assign("mode", "error");
$template->display("error.tpl");
die();
}
$htmlfile = fopen(CL_ROOT . "/files/" . CL_CONFIG . "/ics/timetrack-$id.html", "w");

$line = array($struser, $strtask, $strcomment, $strday, $strstarted, $strended, $strhours);
starthtmldocument($htmlfile);
starthtmltable($htmlfile, $line);

if (!empty($start) and !empty($end)) {
$track = $tracker->getProjectTrack($id, $usr, $taski, $start, $end, 1000);
} else {
$track = $tracker->getProjectTrack($id, $usr , $taski, 0, 0, 1000);
}

if (!empty($track)) {
foreach($track as $tra) {
$hrs = round($tra["hours"], 2);
$hrs = str_replace(".", ",", $hrs);
$myArr = array($tra["uname"], $tra["tname"], $tra["comment"], $tra["daystring"], $tra["startstring"], $tra["endstring"], $hrs);
addtohtmltable($htmlfile, $myArr);
}
}

closehtmltable($htmlfile);
closehtmldocument($htmlfile);

fclose($htmlfile);
$loc = $url . "files/" . CL_CONFIG . "/ics/timetrack-$id.html";
header("Location: $loc");
} elseif ($action == "projectxls") {
if (!chkproject($userid, $id)) {
$errtxt = $langfile["notyourproject"];
Expand Down
Binary file modified templates/standard/theme/spring/images/export-headline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions templates/standard/theme/standard/css/style_main.css
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,14 @@ td.message ul {
background-position: -69px -31px;
}

.export-main a.html {
background-position: 0 0;
}

.export-main a.html:hover {
background-position: 0 -31px;
}

.export-main a.vcardmale {
width: 28px;
background-position: -32px 0;
Expand Down
5 changes: 3 additions & 2 deletions templates/standard/tracker_project.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
</div>
<div class="export-main">
<a class="export"><span>{#export#}</span></a>
<div class="export-in" style="width:46px;left: -46px;"> {*at one item*}
<div class="export-in" style="width:69px;left: -69px;"> {*at one item*}
<a class="html" target="_blank" href="managetimetracker.php?action=projecthtml&amp;id={$project.ID}{if $start != "" and $end != ""}&amp;start={$start}&amp;end={$end}{/if}{if $usr > 0}&amp;usr={$usr}{/if}{if $task > 0}&amp;task={$task}{/if}{if $fproject|default > 0}&amp;project={$fproject|default}{/if}"><span>{#htmlexport#}</span></a>
<a class="pdf" href="managetimetracker.php?action=projectpdf&amp;id={$project.ID}{if $start != "" and $end != ""}&amp;start={$start}&amp;end={$end}{/if}{if $usr > 0}&amp;usr={$usr}{/if}{if $task > 0}&amp;task={$task}{/if}{if $fproject|default > 0}&amp;project={$fproject|default}{/if}"><span>{#pdfexport#}</span></a>
<a class="excel" href="managetimetracker.php?action=projectxls&amp;id={$project.ID}{if $start != "" and $end != ""}&amp;start={$start}&amp;end={$end}{/if}{if $usr > 0}&amp;usr={$usr}{/if}{if $task > 0}&amp;task={$task}{/if}{if $fproject|default > 0}&amp;project={$fproject|default}{/if}"><span>{#excelexport#}</span></a>
</div>
Expand Down Expand Up @@ -157,4 +158,4 @@
</div> {*content-left END*}

{include file="sidebar-a.tpl"}
{include file="footer.tpl"}
{include file="footer.tpl"}