Initial commit: Kimai TMS

Kimai time management system (PHP 5.6 / MySQL) with custom extensions:
- Budget tracking (ki_budget)
- Change request form (ki_changerequest)
- Invoice generation (ki_invoice)
- Expense tracking (ki_expenses)
- Flexi time (ki_flexitime)
- Export, admin panel, timesheets, tasks, summary

Database: ~900K time entries, 2,000+ users, 439 projects.
Config: includes/autoconf.php — localhost/kimai/kimai
This commit is contained in:
TMS
2026-06-18 21:20:26 +00:00
commit eb299c9131
1099 changed files with 359817 additions and 0 deletions

30
core/checkupdate.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
/**
* This file is part of
* Kimai - Open Source Time Tracking // http://www.kimai.org
* (c) 2006-2009 Kimai-Development-Team
*
* Kimai is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; Version 3, 29 June 2007
*
* Kimai is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kimai; If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Query the Kimai project server for information about a new version.
* The response will simply be passed through.
*/
error_reporting(0);
require('../includes/basics.php');
// check the latest stable version of Kimai on the web
$request = join( '', file('http://versioncheck.kimai.de?revision='.$kga['revision']."&lang=".$kga['language']));
echo strip_tags($request, '<span><a>');
?>

145
core/example.php Normal file
View File

@@ -0,0 +1,145 @@
<?php
$hostname = "localhost";
$username = "kimai";
$password = "kimai";
$dbname = "kimai";
$con = mysqli_connect($hostname, $username, $password, $dbname) or die("<html><script language='JavaScript'>alert('Unable to connect to database! Please try again later.')</script></html>");
//============================================================+
// File name : example_007.php
// Begin : 2008-03-04
// Last Update : 2013-05-14
//
// Description : Example 007 for TCPDF class
// Two independent columns with WriteHTMLCell()
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com LTD
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* Creates an example PDF TEST document using TCPDF
* @package com.tecnick.tcpdf
* @abstract TCPDF - Example: Two independent columns with WriteHTMLCell()
* @author Nicola Asuni
* @since 2008-03-04
*/
// Include the main TCPDF library (search for installation path).
require_once('../extensions/ki_changerequest/templates/tcpdf/tcpdf.php');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 028');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// remove default header/footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(10, PDF_MARGIN_TOP, 10);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
// ---------------------------------------------------------
$pdf->SetDisplayMode('fullpage', 'SinglePage', 'UseNone');
// set font
$pdf->SetFont('times', 'B', 20);
$pdf->AddPage('P', 'A4');
$column_company_name = "<h1>Company Name</h1>";
$query = "select k.knd_name as 'company_name' from kimai15_knd k where k.knd_trash = 0 order by k.knd_name";
$result = mysqli_query($con, $query);
if (mysqli_num_rows($result) != 0) {
while ($row = mysqli_fetch_array($result)) {
$column_company_name .= '<input type="checkbox" value="' . $row['company_name'] . '" name="' . $row['company_name'] . '"' . ">" . $row['company_name'] . "<br/>" . "\n";
}
}
$column_project_name = "<h1>Project Name</h1>";
$query = "select DISTINCT right(p.pct_name,CHAR_LENGTH(p.pct_name) - 8 ) as 'project_name' from kimai15_pct p
where p.pct_trash = 0
order by project_name";
$result = mysqli_query($con, $query);
if (mysqli_num_rows($result) != 0) {
while ($row = mysqli_fetch_array($result)) {
$column_project_name .= '<input type="checkbox" value="' . $row['project_name'] . '" name="' . $row['project_name'] . '"' . ">" . $row['project_name'] . "<br/>" . "\n";
}
}
$column_division_name = "<h1>Divisions</h1>";
$query = "select DISTINCT left(p.pct_name,3) as 'pdivision_name' from kimai15_pct p
where p.pct_trash = 0
order by division_name";
$result = mysqli_query($con, $query);
if (mysqli_num_rows($result) != 0) {
while ($row = mysqli_fetch_array($result)) {
$column_division_name .= '<input type="checkbox" value="' . $row['division_name'] . '" name="' . $row['division_name'] . '"' . ">" . $row['division_name'] . "<br/>" . "\n";
}
}
// writeHTMLCell($w, $h, $x, $y, $html='', $border=0, $ln=0, $fill=0, $reseth=true, $align='', $autopadding=true)
// get current vertical position
$y = $pdf->getY();
// write the first column
$pdf->writeHTMLCell(30, '', '', $y, $column_company_name, 1, 0, 0, false, 'L', true);
// write the second column
$pdf->writeHTMLCell(30, '', '', '', $column_project_name, 1, 0, 0, false, 'L', false);
// write the third column
$pdf->writeHTMLCell(45, '', '', '', $column_division_name, 1, 1, 0, false, 'L', false);
$pdf->AddPage('L', 'A4');
$pdf->writeHTMLCell(45, '', '', '', $column_task_name, 1, 1, 0, false, 'L', true);
$pdf->lastPage();
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_028.pdf', 'I');

515
core/exportsummary.php Normal file
View File

@@ -0,0 +1,515 @@
<?php
$hostname = "localhost";
$username = "kimai";
$password = "kimai";
$dbname = "kimai";
$dbport = "3306";
$conn = mysqli_connect($hostname, $username, $password, $dbname, $dbport) or die("<html><script language='JavaScript'>alert('Unable to connect to database! Please try again later.'),history.go(-1)</script></html>");
$file="demo.xls";
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$file");
$in = $_POST['in'];
$out = $_POST['out'];
$usrname = $_POST['usrname'];
$date_string = '';
$fromdate = gmdate("Y-m-d", $in);
$todate = gmdate("Y-m-d", $out);
$date = $todate;
$date1 = str_replace('-', '/', $date);
$todate = date('Y-m-d', strtotime($date1 . "+1 days"));
$date = $fromdate;
$date1 = str_replace('-', '/', $date);
$fromdate = date('Y-m-d', strtotime($date1 . "+1 days"));
$sql = "select u.reported_div from kimai15_usr u where u.usr_name = '$usrname'";
$result = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_assoc($result)) {
$selected_division = $row['reported_div'];
}
mysqli_query($con, "SET SESSION sql_mode = 'TRADITIONAL'");
?>
<h1>Time Analysis for <?php echo $selected_division ?> division(s) </h1>
<h2><?php echo $fromdate . " - " . gmdate("Y-m-d", $out); ?></h2>
<legend>Project Chart</legend>
<?php
try {
if ($selected_division == "ALL") {
$wheresub = "";
$where = "";
} else {
$wheresub = " and usr.usr_div = '$selected_division' ";
$where = " and u.usr_div = '$selected_division' ";
}
$con = new PDO("mysql:host=$hostname;dbname=$dbname", "$username", "$password");
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = "SELECT un.name,un.division,
b.Billable,
nb.Non_Billable as 'Non-billable',
up.Unproductive,
(case when th.Total_Hours is null then 0.00 else th.Total_Hours end) as 'Total Hours',
(5 * (DATEDIFF('$todate', '$fromdate') DIV 7) + MID('0123455501234445012333450122234501101234000123450', 7 * WEEKDAY('$fromdate') + WEEKDAY('$todate') + 1, 1)) * 8.5 as 'Core Working Hours',
round((((case when th.Total_Hours is null then 0.00 else th.Total_Hours end))-((5 * (DATEDIFF('$todate', '$fromdate') DIV 7) + MID('0123455501234445012333450122234501101234000123450', 7 * WEEKDAY('$fromdate') + WEEKDAY('$todate') + 1, 1)) * 8.5)),2) as 'Difference'
FROM
(select u.usr_alias as 'Name', u.usr_div as 'Division'
from kimai15_zef e
inner join kimai15_usr u on e.zef_usrID=u.usr_ID
inner join kimai15_pct p on e.zef_pctID=p.pct_ID
where
u.usr_active = 1
$where
group by u.usr_name) un
LEFT JOIN
(SELECT usr.usr_alias, (case when (round(sum(zef.zef_time) / 3600,2)) is null then 0 else (round(sum(zef.zef_time) / 3600,2)) end) as Total_Hours
FROM kimai15_zef zef
INNER JOIN kimai15_usr usr on zef.zef_usrID = usr.usr_ID
inner join kimai15_pct pct on zef.zef_pctID=pct.pct_ID
WHERE zef.zef_in > UNIX_TIMESTAMP(DATE_FORMAT('$fromdate','%Y-%m-%d'))
and zef.zef_in < UNIX_TIMESTAMP(DATE_FORMAT('$todate','%Y-%m-%d')) group by usr.usr_name) th
ON (un.name=th.usr_alias)
LEFT JOIN
(SELECT usr.usr_alias, round(sum(zef.zef_time) / 3600,2) as Billable FROM kimai15_zef zef
INNER JOIN kimai15_usr usr on zef.zef_usrID = usr.usr_ID
INNER JOIN kimai15_pct pct on zef.zef_pctID=pct.pct_ID
WHERE pct.pct_billable = 0
and zef.zef_in > UNIX_TIMESTAMP(DATE_FORMAT('$fromdate','%Y-%m-%d'))
and zef.zef_in < UNIX_TIMESTAMP(DATE_FORMAT('$todate','%Y-%m-%d')) group by usr.usr_name) b
ON (un.name=b.usr_alias)
LEFT JOIN
(SELECT usr.usr_alias, round(sum(zef.zef_time) / 3600,2) AS Non_Billable FROM kimai15_zef zef
INNER JOIN kimai15_usr usr on zef.zef_usrID = usr.usr_ID
INNER JOIN kimai15_pct pct on zef.zef_pctID=pct.pct_ID
WHERE pct.pct_billable = 1
and zef.zef_in > UNIX_TIMESTAMP(DATE_FORMAT('$fromdate','%Y-%m-%d'))
and zef.zef_in < UNIX_TIMESTAMP(DATE_FORMAT('$todate','%Y-%m-%d')) group by usr.usr_name) nb
ON (un.name=nb.usr_alias)
LEFT JOIN
(SELECT usr.usr_alias, round(sum(zef.zef_time) / 3600,2) AS Unproductive FROM kimai15_zef zef
INNER JOIN kimai15_usr usr on zef.zef_usrID = usr.usr_ID
INNER JOIN kimai15_pct pct on zef.zef_pctID=pct.pct_ID
WHERE pct.pct_billable = 2
and zef.zef_in > UNIX_TIMESTAMP(DATE_FORMAT('$fromdate','%Y-%m-%d'))
and zef.zef_in < UNIX_TIMESTAMP(DATE_FORMAT('$todate','%Y-%m-%d')) group by usr.usr_name) up
ON (un.name=up.usr_alias)";
//echo $query;
echo '<table id="myTable" border="1" cellpadding="3" cellspacing="0">';
$result = $con->query($query);
//return only the first row (we only need field names)
$row = $result->fetch(PDO::FETCH_ASSOC);
echo " <tr> \n";
foreach ($row as $field => $value) {
echo " <th>$field</th> \n";
} // end foreach
echo " </tr> \n";
//second query gets the data
$data = $con->query($query);
$data->setFetchMode(PDO::FETCH_ASSOC);
foreach ($data as $row) {
echo " <tr> \n";
foreach ($row as $name => $value) {
echo " <td>$value</td> \n";
} // end field loop
echo " </tr> \n";
} // end record loop
echo "</table> \n";
} catch (PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
} // end try
?>
<br/>
<br/>
<legend>Total Hours by Billable Projects</legend>
<table class="mytable" border="1px" style="margin: 10px; width: 99%; font-size: 9px">
<thead class="myth">
<tr class="myth">
<th class="myth">Company Name</th>
<th class="myth">Project Name</th>
<?php
$sqlyu = "select u.usr_name as 'name', u.usr_alias as 'alias' from kimai15_zef e
inner join kimai15_usr u on e.zef_usrID=u.usr_ID
inner join kimai15_pct p on e.zef_pctID=p.pct_ID
where
e.zef_in > UNIX_TIMESTAMP(DATE_FORMAT('$fromdate','%Y-%m-%d')) and
e.zef_in < UNIX_TIMESTAMP(DATE_FORMAT('$todate','%Y-%m-%d'))
and p.pct_billable = 0
$where
group by u.usr_name
";
$resultyu = mysqli_query($conn, $sqlyu);
while ($rowyu = mysqli_fetch_array($resultyu)) {
$nameyu = $rowyu['name'];
$aliasyu = $rowyu['alias'];
echo "<th class='myth'>$aliasyu</th>";
$namesyu[] = $nameyu;
}
?>
<th class="myth">TOTAL</th>
</tr>
</thead>
<?php
$sqlyu = "select k.knd_name as companyname, p.pct_name as project, ROUND(SUM(e.zef_time) / 3600, 2) as project_total from kimai15_zef e
join kimai15_usr u on e.zef_usrID=u.usr_ID
inner join kimai15_pct p on e.zef_pctID=p.pct_ID
inner join kimai15_knd k on p.pct_kndID=k.knd_ID
where
e.zef_in > UNIX_TIMESTAMP(DATE_FORMAT('$fromdate','%Y-%m-%d')) and
e.zef_in < UNIX_TIMESTAMP(DATE_FORMAT('$todate','%Y-%m-%d'))
and p.pct_billable = 0
$where
group by p.pct_name
";
$resultyu = mysqli_query($conn, $sqlyu);
$totalforreportyu = 0;
while ($rowyu = mysqli_fetch_array($resultyu)) {
$projecttotalyu = $rowyu['project_total'];
$projectyu = $rowyu['project'];
$companynameyu = $rowyu['companyname'];
echo "<tr><td class='mytd'>$companynameyu</td><td class='mytd'>$projectyu</td>";
foreach ($namesyu as $nameyu) {
$sqlayu = "select ROUND(SUM(e.zef_time) / 3600, 2) as 'totaltime'
from kimai15_zef e
inner join kimai15_usr u on e.zef_usrID=u.usr_ID
inner join kimai15_pct p on e.zef_pctID=p.pct_ID
where
e.zef_in > UNIX_TIMESTAMP(DATE_FORMAT('$fromdate','%Y-%m-%d')) and
e.zef_in < UNIX_TIMESTAMP(DATE_FORMAT('$todate','%Y-%m-%d'))
and p.pct_name = '$projectyu'
and u.usr_name = '$nameyu'
and p.pct_billable = 0
$where
group by p.pct_name";
$result1yu = mysqli_query($conn, $sqlayu);
$totalyu = 0;
if (mysqli_num_rows($result1yu) != 0) {
while ($rowyu = mysqli_fetch_array($result1yu)) {
$timeyu = $rowyu['totaltime'];
echo "<td>$timeyu</td>";
}
} else {
echo "<td></td>";
}
}
echo "<td>$projecttotalyu</td>";
echo "</tr>";
$totalforreportyu = $totalforreportyu + $projecttotalyu;
}
?>
<tr>
<td>TOTAL</td><td></td>
<?php
foreach ($namesyu as $nameyu) {
$sqlyu = "select u.usr_alias as name, ROUND(SUM(e.zef_time) / 3600, 2) as 'totaltime'
from kimai15_zef e
inner join kimai15_usr u on e.zef_usrID=u.usr_ID
inner join kimai15_pct p on e.zef_pctID=p.pct_ID
where
e.zef_in > UNIX_TIMESTAMP(DATE_FORMAT('$fromdate','%Y-%m-%d')) and
e.zef_in < UNIX_TIMESTAMP(DATE_FORMAT('$todate','%Y-%m-%d'))
and u.usr_name = '$nameyu'
and p.pct_billable = 0
$where
group by u.usr_name";
$resultyu = mysqli_query($conn, $sqlyu);
while ($rowyu = mysqli_fetch_array($resultyu)) {
$timeyu = $rowyu['totaltime'];
echo "<td>$timeyu</td>";
}
}
echo "<td>$totalforreportyu</td>";
?>
</tr>
</table>
<br/>
<legend>Total Hours by Non-billable Projects</legend>
<table class="mytable" border="1px" style="margin: 10px; width: 99%; font-size: 9px">
<thead class="myth">
<tr class="myth">
<th class="myth">Company Name</th>
<th class="myth">Project Name</th>
<?php
$sql = "select u.usr_name as 'name', u.usr_alias as 'alias' from kimai15_zef e
inner join kimai15_usr u on e.zef_usrID=u.usr_ID
inner join kimai15_pct p on e.zef_pctID=p.pct_ID
where
e.zef_in > UNIX_TIMESTAMP(DATE_FORMAT('$fromdate','%Y-%m-%d')) and
e.zef_in < UNIX_TIMESTAMP(DATE_FORMAT('$todate','%Y-%m-%d'))
and p.pct_billable = 1
$where
group by u.usr_name
";
$result = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_array($result)) {
$name = $row['name'];
$alias = $row['alias'];
echo "<th class='myth'>$alias</th>";
$names[] = $name;
}
?>
<th class="myth">TOTAL</th>
</tr>
</thead>
<?php
$sql = "select k.knd_name as companyname, p.pct_name as project, ROUND(SUM(e.zef_time) / 3600, 2) as project_total from kimai15_zef e
inner join kimai15_usr u on e.zef_usrID=u.usr_ID
inner join kimai15_pct p on e.zef_pctID=p.pct_ID
inner join kimai15_knd k on p.pct_kndID=k.knd_ID
where
e.zef_in > UNIX_TIMESTAMP(DATE_FORMAT('$fromdate','%Y-%m-%d')) and
e.zef_in < UNIX_TIMESTAMP(DATE_FORMAT('$todate','%Y-%m-%d'))
and p.pct_billable = 1
$where
group by p.pct_name
";
$result = mysqli_query($conn, $sql);
$totalforreport = 0;
while ($row = mysqli_fetch_array($result)) {
$projecttotal = $row['project_total'];
$project = $row['project'];
$companyname = $row['companyname'];
echo "<tr><td class='mytd'>$companyname</td><td class='mytd'>$project</td>";
foreach ($names as $name) {
$sqla = "select ROUND(SUM(e.zef_time) / 3600, 2) as 'totaltime'
from kimai15_zef e
inner join kimai15_usr u on e.zef_usrID=u.usr_ID
inner join kimai15_pct p on e.zef_pctID=p.pct_ID
where
e.zef_in > UNIX_TIMESTAMP(DATE_FORMAT('$fromdate','%Y-%m-%d')) and
e.zef_in < UNIX_TIMESTAMP(DATE_FORMAT('$todate','%Y-%m-%d'))
and p.pct_name = '$project'
and u.usr_name = '$name'
and p.pct_billable = 1
$where
group by p.pct_name";
$result1 = mysqli_query($conn, $sqla);
$total = 0;
if (mysqli_num_rows($result1) != 0) {
while ($row = mysqli_fetch_array($result1)) {
$time = $row['totaltime'];
echo "<td>$time</td>";
}
} else {
echo "<td></td>";
}
}
echo "<td>$projecttotal</td>";
echo "</tr>";
$totalforreport = $totalforreport + $projecttotal;
}
?>
<tr>
<td>TOTAL</td><td></td>
<?php
foreach ($names as $name) {
$sql = "select u.usr_alias as name, ROUND(SUM(e.zef_time) / 3600, 2) as 'totaltime'
from kimai15_zef e
inner join kimai15_usr u on e.zef_usrID=u.usr_ID
inner join kimai15_pct p on e.zef_pctID=p.pct_ID
where
e.zef_in > UNIX_TIMESTAMP(DATE_FORMAT('$fromdate','%Y-%m-%d')) and
e.zef_in < UNIX_TIMESTAMP(DATE_FORMAT('$todate','%Y-%m-%d'))
and u.usr_name = '$name'
and p.pct_billable = 1
$where
group by u.usr_name";
$result = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_array($result)) {
$time = $row['totaltime'];
echo "<td>$time</td>";
}
}
echo "<td>$totalforreport</td>";
?>
</tr>
</table>
<br/>
<legend>Total Hours by Unproductive Projects</legend>
<table class="mytable" border="1px" style="margin: 10px; width: 99%; font-size: 9px">
<thead class="myth">
<tr class="myth">
<th class="myth">Company Name</th>
<th class="myth">Project Name</th>
<?php
$sqlui = "select u.usr_name as 'name', u.usr_alias as 'alias' from kimai15_zef e
inner join kimai15_usr u on e.zef_usrID=u.usr_ID
inner join kimai15_pct p on e.zef_pctID=p.pct_ID
where
e.zef_in > UNIX_TIMESTAMP(DATE_FORMAT('$fromdate','%Y-%m-%d')) and
e.zef_in < UNIX_TIMESTAMP(DATE_FORMAT('$todate','%Y-%m-%d'))
and p.pct_billable = 2
$where
group by u.usr_name
";
$resultui = mysqli_query($conn, $sqlui);
while ($rowui = mysqli_fetch_array($resultui)) {
$nameui = $rowui['name'];
$aliasui = $rowui['alias'];
echo "<th class='myth'>$aliasui</th>";
$namesui[] = $nameui;
}
?>
<th class="myth">TOTAL</th>
</tr>
</thead>
<?php
$sqlui = "select k.knd_name as companyname ,p.pct_name as project, ROUND(SUM(e.zef_time) / 3600, 2) as project_total from kimai15_zef e
inner join kimai15_usr u on e.zef_usrID=u.usr_ID
inner join kimai15_pct p on e.zef_pctID=p.pct_ID
inner join kimai15_knd k on p.pct_kndID=k.knd_ID
where
e.zef_in > UNIX_TIMESTAMP(DATE_FORMAT('$fromdate','%Y-%m-%d')) and
e.zef_in < UNIX_TIMESTAMP(DATE_FORMAT('$todate','%Y-%m-%d'))
and p.pct_billable = 2
$where
group by p.pct_name
";
$resultui = mysqli_query($conn, $sqlui);
$totalforreportui = 0;
while ($rowui = mysqli_fetch_array($resultui)) {
$projecttotalui = $rowui['project_total'];
$projectui = $rowui['project'];
$companynameui = $rowui['companyname'];
echo "<tr><td class='mytd'>$companynameui</td><td class='mytd'>$projectui</td>";
foreach ($namesui as $nameui) {
$sqlaui = "select ROUND(SUM(e.zef_time) / 3600, 2) as 'totaltime'
from kimai15_zef e
inner join kimai15_usr u on e.zef_usrID=u.usr_ID
inner join kimai15_pct p on e.zef_pctID=p.pct_ID
where
e.zef_in > UNIX_TIMESTAMP(DATE_FORMAT('$fromdate','%Y-%m-%d')) and
e.zef_in < UNIX_TIMESTAMP(DATE_FORMAT('$todate','%Y-%m-%d'))
and p.pct_name = '$projectui'
and u.usr_name = '$nameui'
and p.pct_billable = 2
$where
group by p.pct_name";
$result1ui = mysqli_query($conn, $sqlaui);
$totalui = 0;
if (mysqli_num_rows($result1ui) != 0) {
while ($rowui = mysqli_fetch_array($result1ui)) {
$timeui = $rowui['totaltime'];
echo "<td>$timeui</td>";
}
} else {
echo "<td></td>";
}
}
echo "<td>$projecttotalui</td>";
echo "</tr>";
$totalforreportui = $totalforreportui + $projecttotalui;
}
?>
<tr>
<td>TOTAL</td><td></td>
<?php
foreach ($namesui as $nameui) {
$sqlui = "select u.usr_alias as name, ROUND(SUM(e.zef_time) / 3600, 2) as 'totaltime'
from kimai15_zef e
inner join kimai15_usr u on e.zef_usrID=u.usr_ID
inner join kimai15_pct p on e.zef_pctID=p.pct_ID
where
e.zef_in > UNIX_TIMESTAMP(DATE_FORMAT('$fromdate','%Y-%m-%d')) and
e.zef_in < UNIX_TIMESTAMP(DATE_FORMAT('$todate','%Y-%m-%d'))
and u.usr_name = '$nameui'
and p.pct_billable = 2
$where
group by u.usr_name";
$resultui = mysqli_query($conn, $sqlui);
while ($rowui = mysqli_fetch_array($resultui)) {
$timeui = $rowui['totaltime'];
echo "<td>$timeui</td>";
}
}
echo "<td>$totalforreportui</td>";
?>
</tr>
</table>
</div>
</div>

230
core/floaters.php Normal file
View File

@@ -0,0 +1,230 @@
<?php
/**
* This file is part of
* Kimai - Open Source Time Tracking // http://www.kimai.org
* (c) 2006-2009 Kimai-Development-Team
*
* Kimai is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; Version 3, 29 June 2007
*
* Kimai is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kimai; If not, see <http://www.gnu.org/licenses/>.
*/
/**
* =============================
* = Floating Window Generator =
* =============================
*
* Called via AJAX from the Kimai user interface. Depending on $axAction
* some HTML will be returned, which will then be shown in a floater.
*/
// insert KSPI
$isCoreProcessor = 1;
$dir_templates = "templates/floaters/"; // folder of the template files
require("../includes/kspi.php");
switch ($axAction) {
/**
* Display the credits floater. The copyright will automatically be
* set from 2006 to the current year.
*/
case 'credits':
$tpl->assign('devtimespan', '2006-'.date('y'));
$tpl->display("credits.tpl");
break;
/**
* Display the timesheet floater.
*/
case 'printTimesheet':
$sel = makeSelectBox("tpl", "name");
$tpl->assign('sel_tpl_names', $sel[0]);
$tpl->assign('sel_tpl_IDs', $sel[1]);
$sel = get_arr_tpl("name");
$tpl->assign('tpl_template', $sel);
$tpl->assign('usr_usr_ID', $kga['usr']['usr_ID']);
//var_dump($data);
$tpl->display("timesheet.tpl");
break;
/**
* Display the credits floater. The copyright will automatically be
* set from 2006 to the current year.
*/
case 'securityWarning':
if ($axValue == 'installer') {
$tpl->display("security_warning.tpl");
}
break;
/**
* Display the preferences dialog.
*/
case 'prefs':
if (isset($kga['customer'])) die();
$tpl->assign('skins', ls("../skins"));
$tpl->assign('langs', langs());
$tpl->assign('timezones', timezoneList());
$tpl->assign('usr', $kga['usr']);
$tpl->assign('rate', get_rate($kga['usr']['usr_ID'],NULL,NULL));
$tpl->display("preferences.tpl");
break;
/**
* Display the dialog to add or edit a customer.
*/
case 'add_edit_knd':
if (isset($kga['customer']) || $kga['usr']['usr_sts']==2) die();
if ($id) {
// Edit mode. Fill the dialog with the data of the customer.
$data = knd_get_data($id);
if ($data) {
$tpl->assign('knd_name' , $data['knd_name' ]);
$tpl->assign('knd_comment' , $data['knd_comment' ]);
$tpl->assign('knd_password' , $data['knd_password']);
$tpl->assign('knd_company' , $data['knd_company' ]);
$tpl->assign('knd_vat' , $data['knd_vat' ]);
$tpl->assign('knd_contact' , $data['knd_contact' ]);
$tpl->assign('knd_street' , $data['knd_street' ]);
$tpl->assign('knd_zipcode' , $data['knd_zipcode' ]);
$tpl->assign('knd_city' , $data['knd_city' ]);
$tpl->assign('knd_tel' , $data['knd_tel' ]);
$tpl->assign('knd_fax' , $data['knd_fax' ]);
$tpl->assign('knd_mobile' , $data['knd_mobile' ]);
$tpl->assign('knd_mail' , $data['knd_mail' ]);
$tpl->assign('knd_homepage' , $data['knd_homepage']);
$tpl->assign('knd_visible' , $data['knd_visible' ]);
$tpl->assign('knd_filter' , $data['knd_filter' ]);
$tpl->assign('grp_selection', knd_get_grps($id));
$tpl->assign('id', $id);
}
}
// create the <select> element for the groups
$sel = makeSelectBox("grp",$kga['usr']['usr_grp']);
$tpl->assign('sel_grp_names', $sel[0]);
$tpl->assign('sel_grp_IDs', $sel[1]);
// A new customer is assigned to the group of the current user by default.
if (!$id) {
$grp_selection[]=$kga['usr']['usr_grp'];
$tpl->assign('grp_selection', $grp_selection);
$tpl->assign('id', 0);
}
$tpl->display("add_edit_knd.tpl");
break;
/**
* Display the dialog to add or edit a project.
*/
case 'add_edit_pct':
if (isset($kga['customer']) || $kga['usr']['usr_sts']==2) die();
if ($id) {
$data = pct_get_data($id);
if ($data) {
$tpl->assign('pct_name' , $data['pct_name' ]);
$tpl->assign('pct_comment' , $data['pct_comment' ]);
$tpl->assign('pct_visible' , $data['pct_visible' ]);
$tpl->assign('pct_internal' , $data['pct_internal' ]);
$tpl->assign('pct_filter' , $data['pct_filter' ]);
$tpl->assign('pct_budget' , $data['pct_budget' ]);
$tpl->assign('knd_selection' , $data['pct_kndID' ]);
$tpl->assign('evt_selection' , pct_get_evts($id) );
$tpl->assign('pct_default_rate', $data['pct_default_rate']);
$tpl->assign('pct_my_rate' , $data['pct_my_rate' ]);
$tpl->assign('grp_selection', pct_get_grps($id));
$tpl->assign('id', $id);
}
}
// Create a <select> element to chosse the customer.
$sel = makeSelectBox("knd",$kga['usr']['usr_grp'],isset($data)?$data['pct_kndID']:null);
$tpl->assign('sel_knd_names', $sel[0]);
$tpl->assign('sel_knd_IDs', $sel[1]);
// Create a <select> element to chosse the events.
$sel = makeSelectBox("evt",$kga['usr']['usr_grp']);
$tpl->assign('sel_evt_names', $sel[0]);
$tpl->assign('sel_evt_IDs', $sel[1]);
// Create a <select> element to chosse the groups.
$sel = makeSelectBox("grp",$kga['usr']['usr_grp']);
$tpl->assign('sel_grp_names', $sel[0]);
$tpl->assign('sel_grp_IDs', $sel[1]);
// Set defaults for a new project.
if (!$id) {
$grp_selection[]=$kga['usr']['usr_grp'];
$tpl->assign('grp_selection', $grp_selection);
$tpl->assign('knd_selection', null);
$tpl->assign('id', 0);
}
$tpl->display("add_edit_pct.tpl");
break;
/**
* Display the dialog to add or edit an event.
*/
case 'add_edit_evt':
if (isset($kga['customer']) || $kga['usr']['usr_sts']==2) die();
if ($id) {
$data = evt_get_data($id);
if ($data) {
$tpl->assign('evt_name' , $data['evt_name' ]);
$tpl->assign('evt_comment' , $data['evt_comment' ]);
$tpl->assign('evt_visible' , $data['evt_visible' ]);
$tpl->assign('evt_filter' , $data['evt_filter' ]);
$tpl->assign('evt_default_rate', $data['evt_default_rate']);
$tpl->assign('evt_my_rate' , $data['evt_my_rate' ]);
$tpl->assign('grp_selection', evt_get_grps($id));
$tpl->assign('pct_selection', evt_get_pcts($id));
$tpl->assign('id', $id);
}
}
// Create a <select> element to chosse the groups.
$sel = makeSelectBox("grp",$kga['usr']['usr_grp']);
$tpl->assign('sel_grp_names', $sel[0]);
$tpl->assign('sel_grp_IDs', $sel[1]);
// Create a <select> element to chosse the projects.
$sel = makeSelectBox("pct",$kga['usr']['usr_grp']);
$tpl->assign('sel_pct_names', $sel[0]);
$tpl->assign('sel_pct_IDs', $sel[1]);
// Set defaults for a new project.
if (!$id) {
$grp_selection[]=$kga['usr']['usr_grp'];
$tpl->assign('grp_selection', $grp_selection);
$tpl->assign('id', 0);
}
$tpl->display("add_edit_evt.tpl");
break;
}
?>

502
core/kimai.php Normal file
View File

@@ -0,0 +1,502 @@
<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
/**
* This file is part of
* Kimai - Open Source Time Tracking // http://www.kimai.org
* (c) 2006-2009 Kimai-Development-Team
*
* Kimai is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; Version 3, 29 June 2007
*
* Kimai is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kimai; If not, see <http://www.gnu.org/licenses/>.
*/
if ($_POST['changebillable_submit']) {
foreach ($_POST as $key => $value) {
$con = new PDO('mysql:host=localhost;dbname=kimai', "kimai", "kimai");
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if ($key == "changebillable_submit") {
} else {
$sql = "UPDATE kimai15_pct SET `pct_billable`=$value WHERE `pct_ID`=$key;";
$result = $con->query($sql);
}
}
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
header('Location: ' . $actual_link);
}
// =============================
// = Smarty (initialize class) =
// =============================
require_once('../libraries/smarty/Smarty.class.php');
$tpl = new Smarty();
$tpl->template_dir = '../templates/';
$tpl->compile_dir = '../compile/';
// prevent IE from caching the response
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Access-Control-Allow-Origin: *');
// ==================================
// = implementing standard includes =
// ==================================
include('../includes/basics.php');
$usr = checkUser();
if ($_POST['selected_division']) {
$selected_division = $_POST['selected_division'];
$usrname = $usr['usr_name'];
$con = mysqli_connect("localhost", "kimai", "kimai", "kimai");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = "UPDATE kimai15_usr SET `reported_div`='$selected_division' WHERE `usr_name`='$usrname';";
mysqli_query($con, $sql);
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
header('Location: ' . $actual_link);
}
// Jedes neue update schreibt seine Versionsnummer in die Datenbank.
// Beim nächsten Update kommt dann in der Datei /includes/var.php die neue V-Nr. mit.
// der updater.php weiss dann welche Aenderungen an der Datenbank vorgenommen werden muessen.
checkDBversion("..");
$tpl->assign('browser', get_agent());
// =========================================
// = PARSE EXTENSION CONFIGS (ext_configs) =
// =========================================
if ($handle = opendir('../extensions/')) {
chdir("../extensions/");
$ext_configs = array();
$css_extension_files = array();
$js_extension_files = array();
$extensions = array();
$tab_change_trigger = array();
$tss_hooks = array();
$rec_hooks = array();
$stp_hooks = array();
$chu_hooks = array();
$chk_hooks = array();
$chp_hooks = array();
$che_hooks = array();
$lft_hooks = array(); // list filter hooks
$rsz_hooks = array(); // resize hooks
$timeouts = array();
while (false !== ($file = readdir($handle))) {
if (is_dir($file) AND ( $file != ".") AND ( $file != "..") AND ( substr($file, 0) != ".") AND ( substr($file, 0, 1) != "#")) {
if (file_exists($file . '/config.ini')) {
$settings = parse_ini_file($file . '/config.ini');
// Check if user has the correct rank to use this extension
if (isset($kga['usr']))
switch ($kga['usr']['usr_sts']) {
case 0:
if ($settings['ADMIN_ALLOWED'] == "1") {
$extensions[] = $settings;
}
break;
case 1:
if ($settings['GROUP_LEADER_ALLOWED'] == "1") {
$extensions[] = $settings;
}
break;
case 2:
if ($settings['USER_ALLOWED'] == "1") {
$extensions[] = $settings;
}
break;
} else if ($settings['CUSTOMER_ALLOWED'] == "1")
$extensions[] = $settings;
foreach ($settings as $key => $value) {
// add CSS files
if ($key == 'CSS_INCLUDE_FILES') {
if (is_array($value)) {
foreach ($value as $subvalue) {
if (!in_array($subvalue, $css_extension_files)) {
$css_extension_files[] = $subvalue;
}
}
} else {
if (!in_array($value, $css_extension_files)) {
$css_extension_files[] = $value;
}
}
}
// add JavaScript files
if ($key == 'JS_INCLUDE_FILES') {
if (is_array($value)) {
foreach ($value as $subvalue) {
if (!in_array($subvalue, $js_extension_files)) {
$js_extension_files[] = $subvalue;
}
}
} else {
if (!in_array($value, $js_extension_files)) {
$js_extension_files[] = $value;
}
}
}
// read trigger function for tab change
if ($key == 'TAB_CHANGE_TRIGGER') {
$tab_change_trigger[] = $value;
}
// read hook triggers
if ($key == 'TIMESPACE_CHANGE_TRIGGER') {
$tss_hooks[] = $value;
}
if ($key == 'BUZZER_RECORD_TRIGGER') {
$rec_hooks[] = $value;
}
if ($key == 'BUZZER_STOP_TRIGGER') {
$stp_hooks[] = $value;
}
if ($key == 'CHANGE_USR_TRIGGER') {
$chu_hooks[] = $value;
}
if ($key == 'CHANGE_KND_TRIGGER') {
$chk_hooks[] = $value;
}
if ($key == 'CHANGE_PCT_TRIGGER') {
$chp_hooks[] = $value;
}
if ($key == 'CHANGE_EVT_TRIGGER') {
$che_hooks[] = $value;
}
if ($key == 'LIST_FILTER_TRIGGER') {
$lft_hooks[] = $value;
}
if ($key == 'RESIZE_TRIGGER') {
$rsz_hooks[] = $value;
}
// add Timeout clearing
if ($key == 'REG_TIMEOUTS') {
if (is_array($value)) {
foreach ($value as $subvalue) {
if (!in_array($subvalue, $timeouts)) {
$timeouts[] = $subvalue;
}
}
} else {
if (!in_array($value, $timeouts)) {
$timeouts[] = $value;
}
}
}
}
}
}
}
closedir($handle);
}
// ============================================
// = initialize currently displayed timespace =
// ============================================
$timespace = get_timespace();
$in = $timespace[0];
$out = $timespace[1];
// ===============================================
// = get time for the probably running stopwatch =
// ===============================================
$current_timer = array();
if (isset($kga['customer'])) {
$current_timer['all'] = 0;
$current_timer['hour'] = 0;
$current_timer['min'] = 0;
$current_timer['sec'] = 0;
} else
$current_timer = get_current_timer();
// =======================================
// = Display date and time in the header =
// =======================================
$wd = $kga['lang']['weekdays_short'][date("w", time())];
$dp_start = 0;
if ($kga['calender_start'] != "")
$dp_start = $kga['calender_start'];
else if (isset($kga['usr']))
$dp_start = date("d/m/Y", getjointime($kga['usr']['usr_ID']));
$dp_today = date("d/m/Y", time());
$tpl->assign('dp_start', $dp_start);
$tpl->assign('dp_today', $dp_today);
if (isset($kga['customer']))
$tpl->assign('total', formatDuration(get_zef_time($in, $out, null, array($kga['customer']['knd_ID']))));
else
$tpl->assign('total', formatDuration(get_zef_time($in, $out, $kga['usr']['usr_ID'])));
// ===========================
// = DatePicker localization =
// ===========================
$localized_DatePicker = "";
$tpl->assign('weekdays_array', sprintf("['%s','%s','%s','%s','%s','%s','%s']\n"
, $kga['lang']['weekdays'][0], $kga['lang']['weekdays'][1], $kga['lang']['weekdays'][2], $kga['lang']['weekdays'][3], $kga['lang']['weekdays'][4], $kga['lang']['weekdays'][5], $kga['lang']['weekdays'][6]));
$tpl->assign('weekdays_short_array', sprintf("['%s','%s','%s','%s','%s','%s','%s']\n"
, $kga['lang']['weekdays_short'][0], $kga['lang']['weekdays_short'][1], $kga['lang']['weekdays_short'][2], $kga['lang']['weekdays_short'][3], $kga['lang']['weekdays_short'][4], $kga['lang']['weekdays_short'][5], $kga['lang']['weekdays_short'][6]));
$tpl->assign('months_array', sprintf("['%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s']\n", $kga['lang']['months'][0], $kga['lang']['months'][1], $kga['lang']['months'][2], $kga['lang']['months'][3], $kga['lang']['months'][4], $kga['lang']['months'][5], $kga['lang']['months'][6], $kga['lang']['months'][7], $kga['lang']['months'][8], $kga['lang']['months'][9], $kga['lang']['months'][10], $kga['lang']['months'][11]));
$tpl->assign('months_short_array', sprintf("['%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s']", $kga['lang']['months_short'][0], $kga['lang']['months_short'][1], $kga['lang']['months_short'][2], $kga['lang']['months_short'][3], $kga['lang']['months_short'][4], $kga['lang']['months_short'][5], $kga['lang']['months_short'][6], $kga['lang']['months_short'][7], $kga['lang']['months_short'][8], $kga['lang']['months_short'][9], $kga['lang']['months_short'][10], $kga['lang']['months_short'][11]));
// ==============================
// = assign smarty placeholders =
// ==============================
$tpl->assign('current_timer_hour', $current_timer['hour']);
$tpl->assign('current_timer_min', $current_timer['min']);
$tpl->assign('current_timer_sec', $current_timer['sec']);
$tpl->assign('current_timer_start', $current_timer['all'] ? $current_timer['all'] : time());
$tpl->assign('current_time', time());
$tpl->assign('timespace_in', $in);
$tpl->assign('timespace_out', $out);
$tpl->assign('kga', $kga);
$tpl->assign('extensions', $extensions);
$tpl->assign('css_extension_files', $css_extension_files);
$tpl->assign('js_extension_files', $js_extension_files);
if (isset($kga['usr']))
$tpl->assign('recstate', get_rec_state($kga['usr']['usr_ID']));
else
$tpl->assign('recstate', 0);
$tpl->assign('lang_checkUsername', $kga['lang']['checkUsername']);
$tpl->assign('lang_checkGroupname', $kga['lang']['checkGroupname']);
$knd_data = array('knd_ID' => false, 'knd_name' => '');
$pct_data = array('pct_ID' => false, 'pct_name' => '');
$evt_data = array('evt_ID' => false, 'evt_name' => '');
if (!isset($kga['customer'])) {
//$lastZefRecord = zef_get_data(false);
$last_pct = pct_get_data($kga['usr']['lastProject']);
$last_evt = evt_get_data($kga['usr']['lastEvent']);
if (!$last_pct['pct_trash']) {
$pct_data = $last_pct;
$knd_data = knd_get_data($last_pct['pct_kndID']);
}
if (!$last_evt['evt_trash'])
$evt_data = $last_evt;
}
$tpl->assign('knd_data', $knd_data);
$tpl->assign('pct_data', $pct_data);
$tpl->assign('evt_data', $evt_data);
// =========================================
// = INCLUDE EXTENSION PHP FILE =
// =========================================
$extDir = WEBROOT . 'extensions';
if ($handle = opendir($extDir)) {
chdir($extDir);
$ext_configs = array();
while (false !== ($file = readdir($handle))) {
if (is_dir($file) AND ( $file != ".") AND ( $file != "..") AND ( substr($file, 0) != ".") AND ( substr($file, 0, 1) != "#")) {
if ($subhandle = opendir($extDir . DIRECTORY_SEPARATOR . $file)) {
while (false !== ($phpfile = readdir($subhandle))) {
if ($phpfile == "kimai_include.php") {
require_once($extDir . DIRECTORY_SEPARATOR . $file . DIRECTORY_SEPARATOR . $phpfile);
}
}
closedir($subhandle);
}
}
}
closedir($handle);
}
// =======================
// = display user table =
// =======================
if (isset($kga['customer']))
$arr_usr = array();
else
$arr_usr = get_arr_watchable_users($kga['usr']['usr_ID']);
if (count($arr_usr) > 0) {
$tpl->assign('arr_usr', $arr_usr);
} else {
$tpl->assign('arr_usr', '0');
}
$tpl->assign('usr_display', $tpl->fetch("lists/usr.tpl"));
// ==========================
// = display customer table =
// ========================
if (isset($kga['customer']))
$arr_knd = array(array(
'knd_ID' => $kga['customer']['knd_ID'],
'knd_name' => $kga['customer']['knd_name'],
'knd_visible' => $kga['customer']['knd_visible']));
else
$arr_knd = get_arr_knd($kga['usr']['usr_grp']);
if (count($arr_knd) > 0) {
$tpl->assign('arr_knd', $arr_knd);
} else {
$tpl->assign('arr_knd', '0');
}
$tpl->assign('knd_display', $tpl->fetch("lists/knd.tpl"));
// =========================
// = display project table =
// =========================
if (isset($kga['customer']))
$arr_pct = get_arr_pct_by_knd("all", $kga['customer']['knd_ID']);
else
$arr_pct = get_arr_pct($kga['usr']['usr_grp']);
if (count($arr_pct) > 0) {
$tpl->assign('arr_pct', $arr_pct);
} else {
$tpl->assign('arr_pct', '0');
}
$tpl->assign('pct_display', $tpl->fetch("lists/pct.tpl"));
// ========================
// = display events table =
// ========================
if (isset($kga['customer']))
$arr_evt = get_arr_evt_by_knd($kga['customer']['knd_ID']);
else if ($pct_data['pct_ID'])
$arr_evt = get_arr_evt_by_pct($kga['usr']['usr_grp'], $pct_data['pct_ID']);
else
$arr_evt = get_arr_evt($kga['usr']['usr_grp']);
if (count($arr_evt) > 0) {
$tpl->assign('arr_evt', $arr_evt);
} else {
$tpl->assign('arr_evt', '0');
}
$tpl->assign('evt_display', $tpl->fetch("lists/evt.tpl"));
if (isset($kga['usr']))
$tpl->assign('showInstallWarning', $kga['usr']['usr_sts'] == 0 && file_exists(WEBROOT . 'installer'));
else
$tpl->assign('showInstallWarning', false);
// ========================
// = BUILD HOOK FUNCTIONS =
// ========================
$hook_tss = "";
if (is_array($tss_hooks)) {
foreach ($tss_hooks as $hook) {
$hook_tss .= $hook;
}
}
$hook_bzzRec = "";
if (is_array($rec_hooks)) {
foreach ($rec_hooks as $hook) {
$hook_bzzRec .= $hook;
}
}
$hook_bzzStp = "";
if (is_array($stp_hooks)) {
foreach ($stp_hooks as $hook) {
$hook_bzzStp .= $hook;
}
}
$hook_chgUsr = "";
if (is_array($chu_hooks)) {
foreach ($chu_hooks as $hook) {
$hook_chgUsr .= $hook;
}
}
$hook_chgKnd = "";
if (is_array($chk_hooks)) {
foreach ($chk_hooks as $hook) {
$hook_chgKnd .= $hook;
}
}
$hook_chgPct = "";
if (is_array($chp_hooks)) {
foreach ($chp_hooks as $hook) {
$hook_chgPct .= $hook;
}
}
$hook_chgEvt = "";
if (is_array($che_hooks)) {
foreach ($che_hooks as $hook) {
$hook_chgEvt .= $hook;
}
}
$hook_filter = "";
if (is_array($lft_hooks)) {
foreach ($lft_hooks as $hook) {
$hook_filter .= $hook;
}
}
$hook_resize = "";
if (is_array($rsz_hooks)) {
foreach ($rsz_hooks as $hook) {
$hook_resize .= $hook;
}
}
$tpl->assign('hook_tss', $hook_tss);
$tpl->assign('hook_bzzRec', $hook_bzzRec);
$tpl->assign('hook_bzzStp', $hook_bzzStp);
$tpl->assign('hook_chgUsr', $hook_chgUsr);
$tpl->assign('hook_chgKnd', $hook_chgKnd);
$tpl->assign('hook_chgPct', $hook_chgPct);
$tpl->assign('hook_chgEvt', $hook_chgEvt);
$tpl->assign('hook_filter', $hook_filter);
$tpl->assign('hook_resize', $hook_resize);
$timeoutlist = "";
foreach ($timeouts as $timeout) {
$timeoutlist .= "kill_timeout('" . $timeout . "');";
}
$tpl->assign('timeoutlist', $timeoutlist);
$tpl->display('core/main.tpl');
?>

259
core/pdf.php Normal file
View File

@@ -0,0 +1,259 @@
<?php
$hostname = "localhost";
$username = "kimai";
$password = "kimai";
$dbname = "kimai";
$dbport = "3306";
$con = mysqli_connect($hostname, $username, $password, $dbname, $dbport) or die("<html><script language='JavaScript'>alert('Unable to connect to database! Please try again later.')</script></html>");
//============================================================+
// File name : example_010.php
// Begin : 2008-03-04
// Last Update : 2013-05-14
//
// Description : Example 010 for TCPDF class
// Text on multiple columns
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com LTD
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* Creates an example PDF TEST document using TCPDF
* @package com.tecnick.tcpdf
* @abstract TCPDF - Example: Text on multiple columns
* @author Nicola Asuni
* @since 2008-03-04
*/
// Include the main TCPDF library (search for installation path).
require_once('../extensions/ki_changerequest/templates/tcpdf/tcpdf.php');
/**
* Extend TCPDF to work with multiple columns
*/
class MC_TCPDF extends TCPDF {
/**
* Print chapter
* @param $num (int) chapter number
* @param $title (string) chapter title
* @param $file (string) name of the file containing the chapter body
* @param $mode (boolean) if true the chapter body is in HTML, otherwise in simple text.
* @public
*/
public function PrintChapter($num, $title, $file, $mode=false) {
// disable existing columns
$this->resetColumns();
// print chapter title
$this->ChapterTitle($num, $title);
// set columns
$this->setEqualColumns(4,57);
// print chapter body
$this->ChapterBody($file, $mode);
}
/**
* Set chapter title
* @param $num (int) chapter number
* @param $title (string) chapter title
* @public
*/
public function ChapterTitle($num, $title, $width=60) {
$this->SetFont('helvetica', '', 14);
$this->SetFillColor(200, 220, 255);
$this->Cell($width, 6, $title, 0, 1, '', 1);
$this->Ln(4);
}
/**
* Print chapter body
* @param $file (string) name of the file containing the chapter body
* @param $mode (boolean) if true the chapter body is in HTML, otherwise in simple text.
* @public
*/
public function ChapterBody($file, $mode=false) {
$this->selectColumn();
// get esternal file content
$content = $file;
// set font
$this->SetFont('times', '', 9);
$this->SetTextColor(50, 50, 50);
// print content
if ($mode) {
// ------ HTML MODE ------
$this->writeHTML($content, true, false, true, false, 'J');
} else {
// ------ TEXT MODE ------
$this->Write(0, $content, '', 0, 'J', true, 0, false, true, 0);
}
$this->Ln();
}
} // end of extended class
// ---------------------------------------------------------
// EXAMPLE
// ---------------------------------------------------------
// create new PDF document
$pdf = new MC_TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 010');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
$header_logo = 'alteram_logo.png';
// set default header data
$pdf->SetHeaderData($header_logo, PDF_HEADER_LOGO_WIDTH, 'Time Sheet Management', 'Change Request Form');
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
//GET COMPANIES FROM DATABASE
$column_company_name = "";
$query = "select k.knd_name as 'company_name' from kimai15_knd k where k.knd_trash = 0 order by k.knd_name";
$result = mysqli_query($con, $query);
if (mysqli_num_rows($result) != 0) {
while ($row = mysqli_fetch_array($result)) {
$column_company_name .= '<input type="checkbox" padding="10" value="' . $row['company_name'] . '" name="' . $row['company_name'] . '"' . ">" . $row['company_name'] . "<br/>" . "\n";
}
}
//GET PROJECTS FROM DATABASE
$column_project_name = "";
$query = "select DISTINCT right(p.pct_name,CHAR_LENGTH(p.pct_name) - 5 ) as 'project_name' from kimai15_pct p
where p.pct_trash = 0
order by project_name";
$result = mysqli_query($con, $query);
if (mysqli_num_rows($result) != 0) {
while ($row = mysqli_fetch_array($result)) {
$column_project_name .= '<input type="checkbox" value="' . $row['project_name'] . '" name="' . $row['project_name'] . '"' . ">" . $row['project_name'] . "<br/>" . "\n";
}
}
//GET DIVISIONS FROM DATABASE
$column_division_name = "";
$query = "select DISTINCT left(p.pct_name,3) as 'division_name' from kimai15_pct p
where p.pct_trash = 0
order by division_name";
$result = mysqli_query($con, $query);
if (mysqli_num_rows($result) != 0) {
while ($row = mysqli_fetch_array($result)) {
$column_division_name .= '<input type="checkbox" value="' . $row['division_name'] . '" name="' . $row['division_name'] . '"' . ">" . $row['division_name'] . "<br/>" . "\n";
}
}
//GET TASKS FROM DB
$column_task_name = "";
$query = "select e.evt_name as 'task_name' from kimai15_evt e
where e.evt_trash = 0
order by task_name";
$result = mysqli_query($con, $query);
if (mysqli_num_rows($result) != 0) {
while ($row = mysqli_fetch_array($result)) {
$column_task_name .= '<input type="checkbox" value="' . $row['task_name'] . '" name="' . $row['task_name'] . '"' . ">" . $row['task_name'] . "<br/>" . "\n";
}
}
// ADD PAGE
$pdf->AddPage('P');
//ADD FORM
$pdf->setFormDefaultProp(array('lineWidth'=>1, 'borderStyle'=>'solid', 'fillColor'=>array(255, 255, 200), 'strokeColor'=>array(255, 128, 128)));
$pdf->SetFont('helvetica', '', 12);
// First name
$pdf->Cell(35, 5, 'First name:');
$pdf->TextField('firstname', 50, 5);
$pdf->Ln(10);
// Last name
$pdf->Cell(35, 5, 'Last name:');
$pdf->TextField('lastname', 50, 5);
$pdf->Ln(10);
$pdf->writeHTMLCell(51, 7, 49, 25, '', 1, 0, 0, false, 'L', true);
$pdf->writeHTMLCell(51, 7, 49, 35, '', 1, 0, 0, false, 'L', true);
$pdf->Ln(10);
//ADD First Column
//$pdf->resetColumns();
$pdf->setEqualColumns(3, 57, 0);
$pdf->selectColumn();
$pdf->ChapterTitle(0,"Company Name", 60);
$pdf->ChapterBody($column_company_name, true);
//Second Column
$pdf->resetColumns();
$pdf->setEqualColumns(3, 57, 45);
$pdf->selectColumn(1);
$pdf->ChapterTitle(0,"Project Name",60);
$pdf->ChapterBody($column_project_name, true);
//Third Column
$pdf->resetColumns();
$pdf->setEqualColumns(3, 57, 45);
$pdf->selectColumn(2);
$pdf->ChapterTitle(0,"Division", 60);
$pdf->ChapterBody($column_division_name, true);
// ADD PAGE
$pdf->AddPage('L');
// PRINT SECOND CHAPTER
$pdf->PrintChapter(2, 'Task List', $column_task_name, true);
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_010.pdf', 'I');
//============================================================+
// END OF FILE
//============================================================+

258
core/pdf1.php Normal file
View File

@@ -0,0 +1,258 @@
<?php
$hostname = "localhost";
$username = "kimai";
$password = "kimai";
$dbname = "kimai";
$con = mysqli_connect($hostname, $username, $password, $dbname) or die("<html><script language='JavaScript'>alert('Unable to connect to database! Please try again later.')</script></html>");
//============================================================+
// File name : example_010.php
// Begin : 2008-03-04
// Last Update : 2013-05-14
//
// Description : Example 010 for TCPDF class
// Text on multiple columns
//
// Author: Nicola Asuni
//
// (c) Copyright:
// Nicola Asuni
// Tecnick.com LTD
// www.tecnick.com
// info@tecnick.com
//============================================================+
/**
* Creates an example PDF TEST document using TCPDF
* @package com.tecnick.tcpdf
* @abstract TCPDF - Example: Text on multiple columns
* @author Nicola Asuni
* @since 2008-03-04
*/
// Include the main TCPDF library (search for installation path).
require_once('../extensions/ki_changerequest/templates/tcpdf/tcpdf.php');
/**
* Extend TCPDF to work with multiple columns
*/
class MC_TCPDF extends TCPDF {
/**
* Print chapter
* @param $num (int) chapter number
* @param $title (string) chapter title
* @param $file (string) name of the file containing the chapter body
* @param $mode (boolean) if true the chapter body is in HTML, otherwise in simple text.
* @public
*/
public function PrintChapter($num, $title, $file, $mode=false) {
// disable existing columns
$this->resetColumns();
// print chapter title
$this->ChapterTitle($num, $title);
// set columns
$this->setEqualColumns(4,57);
// print chapter body
$this->ChapterBody($file, $mode);
}
/**
* Set chapter title
* @param $num (int) chapter number
* @param $title (string) chapter title
* @public
*/
public function ChapterTitle($num, $title, $width) {
$this->SetFont('helvetica', '', 14);
$this->SetFillColor(200, 220, 255);
$this->Cell($width, 6, $title, 0, 1, '', 1);
$this->Ln(4);
}
/**
* Print chapter body
* @param $file (string) name of the file containing the chapter body
* @param $mode (boolean) if true the chapter body is in HTML, otherwise in simple text.
* @public
*/
public function ChapterBody($file, $mode=false) {
$this->selectColumn();
// get esternal file content
$content = $file;
// set font
$this->SetFont('times', '', 9);
$this->SetTextColor(50, 50, 50);
// print content
if ($mode) {
// ------ HTML MODE ------
$this->writeHTML($content, true, false, true, false, 'J');
} else {
// ------ TEXT MODE ------
$this->Write(0, $content, '', 0, 'J', true, 0, false, true, 0);
}
$this->Ln();
}
} // end of extended class
// ---------------------------------------------------------
// EXAMPLE
// ---------------------------------------------------------
// create new PDF document
$pdf = new MC_TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 010');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
$header_logo = 'alteram_logo.png';
// set default header data
$pdf->SetHeaderData($header_logo, PDF_HEADER_LOGO_WIDTH, 'Time Sheet Management', 'Change Request Form');
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
//GET COMPANIES FROM DATABASE
$column_company_name = "";
$query = "select k.knd_name as 'company_name' from kimai15_knd k where k.knd_trash = 0 order by k.knd_name";
$result = mysqli_query($con, $query);
if (mysqli_num_rows($result) != 0) {
while ($row = mysqli_fetch_array($result)) {
$column_company_name .= '<input type="checkbox" value="' . $row['company_name'] . '" name="' . $row['company_name'] . '"' . ">" . $row['company_name'] . "<br/>" . "\n";
}
}
//GET PROJECTS FROM DATABASE
$column_project_name = "";
$query = "select DISTINCT right(p.pct_name,CHAR_LENGTH(p.pct_name) - 8 ) as 'project_name' from kimai15_pct p
where p.pct_trash = 0
order by project_name";
$result = mysqli_query($con, $query);
if (mysqli_num_rows($result) != 0) {
while ($row = mysqli_fetch_array($result)) {
$column_project_name .= '<input type="checkbox" value="' . $row['project_name'] . '" name="' . $row['project_name'] . '"' . ">" . $row['project_name'] . "<br/>" . "\n";
}
}
//GET DIVISIONS FROM DATABASE
$column_division_name = "";
$query = "select DISTINCT left(p.pct_name,3) as 'division_name' from kimai15_pct p
where p.pct_trash = 0
order by division_name";
$result = mysqli_query($con, $query);
if (mysqli_num_rows($result) != 0) {
while ($row = mysqli_fetch_array($result)) {
$column_division_name .= '<input type="checkbox" value="' . $row['division_name'] . '" name="' . $row['division_name'] . '"' . ">" . $row['division_name'] . "<br/>" . "\n";
}
}
//GET TASKS FROM DB
$column_task_name = "";
$query = "select e.evt_name as 'task_name' from kimai15_evt e
where e.evt_trash = 0
order by task_name";
$result = mysqli_query($con, $query);
if (mysqli_num_rows($result) != 0) {
while ($row = mysqli_fetch_array($result)) {
$column_task_name .= '<input type="checkbox" value="' . $row['task_name'] . '" name="' . $row['task_name'] . '"' . ">" . $row['task_name'] . "<br/>" . "\n";
}
}
// ADD PAGE
$pdf->AddPage('P');
//ADD FORM
$pdf->setFormDefaultProp(array('lineWidth'=>1, 'borderStyle'=>'solid', 'fillColor'=>array(255, 255, 200), 'strokeColor'=>array(255, 128, 128)));
$pdf->SetFont('helvetica', '', 12);
// First name
$pdf->Cell(35, 5, 'First name:');
$pdf->TextField('firstname', 50, 5);
$pdf->Ln(10);
// Last name
$pdf->Cell(35, 5, 'Last name:');
$pdf->TextField('lastname', 50, 5);
$pdf->Ln(10);
$pdf->writeHTMLCell(51, 7, 49, 25, '', 1, 0, 0, false, 'L', true);
$pdf->writeHTMLCell(51, 7, 49, 35, '', 1, 0, 0, false, 'L', true);
$pdf->Ln(10);
//ADD First Column
//$pdf->resetColumns();
$pdf->setEqualColumns(3, 57, 0);
$pdf->selectColumn();
$pdf->ChapterTitle(0,"Company Name", 60);
$pdf->ChapterBody($column_company_name, true);
//Second Column
$pdf->resetColumns();
$pdf->setEqualColumns(3, 57, 45);
$pdf->selectColumn(1);
$pdf->ChapterTitle(0,"Project Name",60);
$pdf->ChapterBody($column_project_name, true);
//Third Column
$pdf->resetColumns();
$pdf->setEqualColumns(3, 57, 45);
$pdf->selectColumn(2);
$pdf->ChapterTitle(0,"Division", 60);
$pdf->ChapterBody($column_division_name, true);
// ADD PAGE
$pdf->AddPage('L');
// PRINT SECOND CHAPTER
$pdf->PrintChapter(2, 'Task List', $column_task_name, true);
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('example_010.pdf', 'I');
//============================================================+
// END OF FILE
//============================================================+

340
core/processor.php Normal file
View File

@@ -0,0 +1,340 @@
<?php
/**
* This file is part of
* Kimai - Open Source Time Tracking // http://www.kimai.org
* (c) 2006-2009 Kimai-Development-Team
*
* Kimai is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; Version 3, 29 June 2007
*
* Kimai is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kimai; If not, see <http://www.gnu.org/licenses/>.
*/
/**
* ==================
* = Core Processor =
* ==================
*
* Called via AJAX from the Kimai user interface. Depending on $axAction
* actions are performed, e.g. editing preferences or returning a list
* of customers.
*/
// insert KSPI
$isCoreProcessor = 1;
$dir_templates = "templates/core/";
require("../includes/kspi.php");
switch ($axAction) {
/**
* Append a new entry to the logfile.
*/
case 'logfile':
logfile("JavaScript: " . $axValue);
break;
/**
* Remember which project and event the user has selected for
* the quick recording via the buzzer.
*/
case 'saveBuzzerPreselection':
if (!isset($kga['usr'])) return;
$data= array();
if (isset($_REQUEST['project']))
$data['lastProject'] = $_REQUEST['project'];
if (isset($_REQUEST['event']))
$data['lastEvent'] = $_REQUEST['event'];
usr_edit($kga['usr']['usr_ID'],$data);
break;
/**
* Store the user preferences entered in the preferences dialog.
*/
case 'editPrefs':
if (isset($kga['customer'])) die();
$preferences['skin'] = $_REQUEST['skin'];
$preferences['autoselection'] = isset($_REQUEST['autoselection'])?1:0;
$preferences['quickdelete'] = $_REQUEST['quickdelete'];
$preferences['rowlimit'] = $_REQUEST['rowlimit'];
$preferences['lang'] = $_REQUEST['lang'];
$preferences['flip_pct_display'] = isset($_REQUEST['flip_pct_display'])?1:0;
$preferences['pct_comment_flag'] = isset($_REQUEST['pct_comment_flag'])?1:0;
$preferences['showIDs'] = isset($_REQUEST['showIDs'])?1:0;
$preferences['noFading'] = isset($_REQUEST['noFading'])?1:0;
$preferences['user_list_hidden'] = isset($_REQUEST['user_list_hidden'])?1:0;
$preferences['hideClearedEntries'] = isset($_REQUEST['hideClearedEntries'])?1:0;
$preferences['sublistAnnotations'] = $_REQUEST['sublistAnnotations'];
usr_set_preferences($preferences,'ui.');
usr_set_preferences(array('timezone'=>$_REQUEST['timezone']));
$rate = str_replace($kga['conf']['decimalSeparator'],'.',$_REQUEST['rate']);
if (is_numeric($rate))
save_rate($kga['usr']['usr_ID'],null,NULL,$rate);
else
remove_rate($kga['usr']['usr_ID'],null,NULL);
// If the password field is empty don't overwrite the old password.
if ($_REQUEST['pw'] != "") {
$usr_data['pw'] = md5($kga['password_salt'].$_REQUEST['pw'].$kga['password_salt']);
usr_edit($kga['usr']['usr_ID'], $usr_data);
}
break;
/**
* When the user changes the timespace it is stored in the database so
* it can be restored, when the user reloads the page.
*/
case 'setTimespace':
if (!isset($kga['usr'])) die();
$timespace = explode('|',$axValue);
$timespace_in = explode('-',$timespace[0]);
$timespace_in = (int)mktime(0,0,0,$timespace_in[0],$timespace_in[1],$timespace_in[2]);
if ($timespace_in < 950000000) $timespace_in = $in;
$timespace_out = explode('-',$timespace[1]);
$timespace_out = (int)mktime(23,59,59,$timespace_out[0],$timespace_out[1],$timespace_out[2]);
if ($timespace_out < 950000000) $timespace_out = $out;
save_timespace($timespace_in,$timespace_out,$kga['usr']['usr_ID']);
break;
/**
* The user started the recording of an event via the buzzer. If this method
* is called while another recording is running the first one will be stopped.
*/
case 'startRecord':
if (isset($kga['customer'])) die();
if (get_rec_state($kga['usr']['usr_ID'])) {
stopRecorder();
}
$IDs = explode('|',$axValue);
startRecorder($IDs[0],$IDs[1],$id);
echo 1;
break;
/**
* Stop the running recording.
*/
case 'stopRecord':
stopRecorder();
echo 1;
break;
/**
* Return a list of users. Customers are not shown any users. The
* type of the current user decides which users are shown to him.
* See get_arr_watchable_users.
*/
case 'reload_usr':
if (isset($kga['customer']))
$arr_usr = array();
else
$arr_usr = get_arr_watchable_users($kga['usr']['usr_ID']);
if (count($arr_usr)>0) {
$tpl->assign('arr_usr', $arr_usr);
} else {
$tpl->assign('arr_usr', 0);
}
$tpl->display("../lists/usr.tpl");
break;
/**
* Return a list of customers. A customer can only see himself.
*/
case 'reload_knd':
if (isset($kga['customer']))
$arr_knd = array(array(
'knd_ID'=>$kga['customer']['knd_ID'],
'knd_name'=>$kga['customer']['knd_name'],
'knd_visible'=>$kga['customer']['knd_visible']));
else
$arr_knd = get_arr_knd($kga['usr']['usr_grp']);
if (count($arr_knd)>0) {
$tpl->assign('arr_knd', $arr_knd);
} else {
$tpl->assign('arr_knd', 0);
}
$tpl->display("../lists/knd.tpl");
break;
/**
* Return a list of projects. Customers are only shown their projects.
*/
case 'reload_pct':
if (isset($kga['customer']))
$arr_pct = get_arr_pct_by_knd("all",$kga['customer']['knd_ID']);
else
$arr_pct = get_arr_pct($kga['usr']['usr_grp']);
if (count($arr_pct)>0) {
$tpl->assign('arr_pct', $arr_pct);
} else {
$tpl->assign('arr_pct', 0);
}
$tpl->display("../lists/pct.tpl");
break;
/**
* Return a list of tasks. Customers are only shown tasks which are
* used for them. If a project is set as filter via the pct parameter
* only tasks for that project are shown.
*/
case 'reload_evt':
if (isset($kga['customer']))
$arr_evt = get_arr_evt_by_knd($kga['customer']['knd_ID']);
else if (isset($_REQUEST['pct']))
$arr_evt = get_arr_evt_by_pct($kga['usr']['usr_grp'],
$_REQUEST['pct']);
else
$arr_evt = get_arr_evt($kga['usr']['usr_grp']);
if (count($arr_evt)>0) {
$tpl->assign('arr_evt', $arr_evt);
} else {
$tpl->assign('arr_evt', 0);
}
$tpl->display("../lists/evt.tpl");
break;
/**
* Add a new customer, project or event. This is a core function as it's
* used at least by the admin panel and the timesheet extension.
*/
case 'add_edit_KndPctEvt':
if(isset($kga['customer']) || $kga['usr']['usr_sts']==2) die(); // only admins and grpleaders can do this ...
switch($axValue) {
/**
* add or edit a customer
*/
case "knd":
if (count($_REQUEST['knd_grp']) == 0) die(); // no group would mean it is never accessable
$data['knd_name'] = $_REQUEST['knd_name'];
$data['knd_comment'] = $_REQUEST['knd_comment'];
$data['knd_company'] = $_REQUEST['knd_company'];
$data['knd_vat'] = $_REQUEST['knd_vat'];
$data['knd_contact'] = $_REQUEST['knd_contact'];
$data['knd_street'] = $_REQUEST['knd_street'];
$data['knd_zipcode'] = $_REQUEST['knd_zipcode'];
$data['knd_city'] = $_REQUEST['knd_city'];
$data['knd_tel'] = $_REQUEST['knd_tel'];
$data['knd_fax'] = $_REQUEST['knd_fax'];
$data['knd_mobile'] = $_REQUEST['knd_mobile'];
$data['knd_mail'] = $_REQUEST['knd_mail'];
$data['knd_homepage'] = $_REQUEST['knd_homepage'];
$data['knd_visible'] = $_REQUEST['knd_visible'];
$data['knd_filter'] = $_REQUEST['knd_filter'];
// If password field is empty dont overwrite the password.
if ($_REQUEST['knd_password'] != "") {
$data['knd_password'] = md5($kga['password_salt'].$_REQUEST['knd_password'].$kga['password_salt']);
}
// add or update the customer
if (!$id) {
$id = knd_create($data);
} else {
knd_edit($id, $data);
}
// set the customer group mappings
$grp_array = $_REQUEST['knd_grp'];
assign_knd2grps($id, $grp_array);
break;
/**
* add or edit a project
*/
case "pct":
if (count($_REQUEST['pct_grp']) == 0) die(); // no group would mean it is never accessable
$data['pct_name'] = $_REQUEST['pct_name'];
$data['pct_kndID'] = $_REQUEST['pct_kndID'];
$data['pct_comment'] = $_REQUEST['pct_comment'];
$data['pct_visible'] = isset($_REQUEST['pct_visible'])?1:0;
$data['pct_internal'] = isset($_REQUEST['pct_internal'])?1:0;
$data['pct_filter'] = $_REQUEST['pct_filter'];
$data['pct_budget'] =
str_replace($kga['conf']['decimalSeparator'],'.',$_REQUEST['pct_budget']);
$data['pct_default_rate'] =
str_replace($kga['conf']['decimalSeparator'],'.',$_REQUEST['pct_default_rate']);
$data['pct_my_rate'] =
str_replace($kga['conf']['decimalSeparator'],'.',$_REQUEST['pct_my_rate']);
// add or update the project
if (!$id) {
$id = pct_create($data);
} else {
pct_edit($id, $data);
}
// set the project group mappings
if (isset($_REQUEST['pct_grp']))
assign_pct2grps($id, $_REQUEST['pct_grp']);
if (isset($_REQUEST['pct_evt']))
assign_pct2evts($id, $_REQUEST['pct_evt']);
break;
/**
* add or edit a task
*/
case "evt":
if (count($_REQUEST['evt_grp']) == 0) die(); // no group would mean it is never accessable
$data['evt_name'] = $_REQUEST['evt_name'];
$data['evt_comment'] = $_REQUEST['evt_comment'];
$data['evt_visible'] = $_REQUEST['evt_visible'];
$data['evt_filter'] = $_REQUEST['evt_filter'];
$data['evt_default_rate'] =
str_replace($kga['conf']['decimalSeparator'],'.',$_REQUEST['evt_default_rate']);
$data['evt_my_rate'] =
str_replace($kga['conf']['decimalSeparator'],'.',$_REQUEST['evt_my_rate']);
// add or update the project
if (!$id) {
$id = evt_create($data);
} else {
evt_edit($id, $data);
}
// set the task group and task project mappings
if (isset($_REQUEST['evt_grp']))
assign_evt2grps($id, $_REQUEST['evt_grp']);
else
assign_evt2grps($id, array());
if (isset($_REQUEST['evt_pct']))
assign_evt2pcts($id, $_REQUEST['evt_pct']);
else
assign_evt2pcts($id, array());
break;
}
break;
}
?>