Subversion Repositories public

Compare Revisions

Ignore whitespace Rev 3 → Rev 4

/pm/trunk/appt.php
0,0 → 1,481
<?php
/*
Copyright (C) 2003-2004 MJG/04-Inconceivable.org
See file LICENSE for licensing details.
See file VERSION for versioning/author/source details
See file CHANGELOG for changes from version to version
 
Heavily altered by Andreas Theofilu; made it working
with PostgreSQL and made it fit into ProjectManager.
*/
 
// Include configuration data & core functions
require_once('version.inc');
require_once('dbaccess.inc');
require_once('language.inc');
require_once('header.inc');
require_once('helper.inc');
require_once('crypt.inc');
require_once('menu.inc');
require_once('settings.inc');
include("./global_config.inc.php");
 
$func = $_REQUEST['func'];
 
// connect to the database
$CONF['dbConn'] = OpenDB();
// If "del" is set and contains a number > 0 then we have to delete an entry.
if (isset($del) && $del > 0) {
$sqlQuery = "DELETE FROM calendar where ca_num = $del";
 
if (!TQueryDB($CONF['dbConn'], $sqlQuery))
Error("Fehler beim L&ouml;schen eines Kalendereintrags!");
}
 
// If "func" is set we have to check what function we must execute.
if (isset($func)) {
if ($func == "DONE" && isset($id) && $id > 0) { // Set the entry to "done"
$sqlQuery = "UPDATE calendar SET ca_status = 0 WHERE ca_num = $id";
 
if (!TQueryDB($CONF['dbConn'], $sqlQuery))
Error("Fehler beim setzen des Status!");
}
}
 
// Load and display day title and content in fields
if (isset($id)) {
$sqlQuery = "SELECT ca_title, ca_text, ca_num, ca_prnum, ca_task, ca_date, ";
$sqlQuery .= "ca_end, ca_status, ca_writer, ca_minum, ca_priority, mi_nname,";
$sqlQuery .= "mi_vname FROM calendar left join mitarbeiter on mi_num = ca_minum ";
$sqlQuery .= "WHERE ca_num = $id";
$sql_date = 0;
} else {
$sql_date = gmmktime(0, 0, 0, $month, $today, $year);
$sqlQuery = "SELECT ca_title, ca_text, ca_num, ca_prnum, ca_task, ca_date,";
$sqlQuery .= "ca_end, ca_status, ca_writer, ca_minum, ca_priority,";
$sqlQuery .= "mi_nname, mi_vname ";
$sqlQuery .= "FROM calendar left join mitarbeiter on mi_num = ca_minum ";
$sqlQuery .= "WHERE ca_date = $sql_date and ";
$sqlQuery .= "(ca_minum = $unum or ca_minum is null or ca_minum <= 0 or ";
$sqlQuery .= "ca_writer = $unum)";
}
 
if ( $sqlExec = QueryDB($CONF['dbConn'], $sqlQuery) )
{
if ($sqlExec)
$nr = numrowsDB($sqlExec);
else
$nr = 0;
 
if ( $nr > 0 )
{
$data = fetchDB($sqlExec, 0);
 
if ($sql_date == 0) {
$ca_date = $data[5];
$month = gmdate("n", $ca_date);
$today = gmdate("j", $ca_date);
$year = gmdate("Y", $ca_date);
$daylong = gmdate("l",gmmktime(1,1,1,$month,$today,$year));
$monthlong = gmdate("F",gmmktime(1,1,1,$month,$today,$year));
$dayone = gmdate("w",gmmktime(1,1,1,$month,1,$year));
$numdays = gmdate("t",gmmktime(1,1,1,$month,1,$year));
$next_year = $year + 1;
$last_year = $year - 1;
if ($today > $numdays) { $today--; }
$sql_date = $ca_date;
}
 
$ca_title = $data[0];
$ca_text = $data[1];
$ca_num = $data[2];
$ca_prnum = $data[3];
$ca_task = $data[4];
$ca_end = $data[6];
$ca_status = $data[7];
$ca_writer = $data[8];
$ca_minum = $data[9];
$ca_priority = $data[10];
$mi_nname = $data[11];
$mi_vname = $data[12];
 
if (isset($ca_task) && $ca_task > 0) {
$query = "select ta_name from task where ta_num = $ca_task";
$result = QueryDB ($CONF['dbConn'], $query);
 
if (!$result) {
$ta_name = "";
} else {
$data = fetchDB($result, 0);
$ta_name = $data[0];
}
} else
$ta_name = "";
 
$EVENT['title'] = $ca_title;
$EVENT['event'] = stripslashes($ca_text);
$EVENT['html'] = 1;
$EVENT['date'] = $sql_date;
$EVENT['id'] = $ca_num;
$EVENT['task'] = $ta_name;
$EVENT['prnum'] = $ca_prnum;
}
}
 
//begin outer table structure
echo "<table align='center' border=\"0\" cellpadding=\"4\" cellspacing=\"4\" width=\"528\">
<tr>
<td>
<table class=\"input\" width=\"311\">
<tr>
<td bgcolor=\"white\" valign=\"middle\" align=\"center\"><b>$daylong, $monthlong $today, $year</b></td>
</tr>
</table>
</td>
<td valign=\"middle\" align=\"center\">
<table class=\"input\" width=\"100%\">
<tr>
<td valign=\"middle\" align=\"center\"><a href=\"appt.php?year=$last_year&today=$today&month=$month&header=1&menu=0\" onmouseover=\"document.calb2.src='" . $CONF['url_images'] . "/ltab2over.gif'\" onmouseout=\"document.calb2.src='" . $CONF['url_images'] . "/ltab2.gif'\"><img src=\"" . $CONF['url_images'] . "/ltab2.gif\" border=\"0\" name=\"calb2\"></a></td><td>&nbsp;</td>
<td valign=\"middle\" align=\"center\"><b>$year</b></td>
<td>&nbsp;</td><td valign=\"middle\" align=\"center\"><a href=\"appt.php?year=$next_year&today=$today&month=$month&header=1&menu=0\" onmouseover=\"document.calb1.src='" . $CONF['url_images'] . "/rtab2over.gif'\" onmouseout=\"document.calb1.src='" . $CONF['url_images'] . "/rtab2.gif'\"><img src=\"" . $CONF['url_images'] . "/rtab2.gif\" border=\"0\" name=\"calb1\"></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign=\"top\">";
$hi = 425;
 
if (isset($ca_prnum) || isset($ca_task) || isset($ca_minum) || isset($ca_status)) {
echo " <table class=\"input\" width=\"100%\">";
echo " <tr><td class=\"cellbg\" valign=\"top\" width=\"40%\">Status:</td>";
 
if ($ca_status > 0)
$st = "<font color=\"#a00000\">Offen</font>";
else
$st = "<font color=\"#00a000\">Erledigt</font>";
 
$hi -= 20;
echo " <td class=\"cellbg\" valign=\"top\" width=\"65%\"><b>$st</b></td></tr>\n";
 
if (isset($ca_prnum)) {
echo " <tr><td class=\"cellbg\" valign=\"top\" width=\"35%\">Projektnummer:</td>
<td class=\"cellbg\" valign=\"top\" width=\"65%\"><b>" . $EVENT['prnum'] . "</b></td></tr>\n";
$hi -= 20;
}
 
if (isset($ca_task)) {
echo " <tr><td class=\"cellbg\" valign=\"top\" width=\"35%\">Taskname:</td>
<td class=\"cellbg\" valign=\"top\" width=\"65%\">" . $EVENT['task'] . "</td></tr>\n";
$hi -= 20;
}
 
if (isset($ca_minum)) {
echo " <tr><td class=\"cellbg\" valign=\"top\" width=\"35%\">F&uuml;r Mitarbeiter:</td>
<td class=\"cellbg\" valign=\"top\" width=\"65%\">$mi_nname $mi_vname</td></tr>\n";
$hi -= 20;
}
 
if (isset($ca_end)) {
echo " <tr><td class=\"cellbg\" valign=\"top\" width=\"40%\">Erledigt bis:</td>";
echo " <td class=\"cellbg\" valign=\"top\" width=\"65%\"><b>" . gmdate($dtformatshort, $ca_end) . "</b></td></tr>\n";
$hi -= 20;
}
 
echo " <tr><td class=\"cellbg\" valign=\"top\" width=\"40%\">Priorit&auml;t:</td>";
 
switch($ca_priority) {
case 0: $prio = "Niedrig"; break;
case 1: $prio = "Normal"; break;
case 2: $prio = "Hoch"; break;
default: $prio = "Niedrig";
}
 
echo " <td class=\"cellbg\" valign=\"top\" width=\"65%\">$prio</td></tr>\n";
 
echo " </table><br>";
}
 
echo " <table class=\"input\" width=\"100%\" height=\"$hi\">
<tr>
<td class=\"cellbg\" valign=\"top\">";
 
 
/* Show event text if there is an event */
if ( isset($EVENT['id']) )
{
echo "<div class=\"eventheading\">" . $EVENT['title'] . "</div>\n";
echo "<div class='navbar'></div><br />\n";
echo wordwrap($EVENT['event'], 60, "<br>");
}
else
{
echo "<div align='center' class='eventheading_noevent'>&nbsp;Keine Eintr&auml;ge f&uuml;r diesen Tag!&nbsp;</div>\n";
}
 
echo "</td></tr></table>";
echo "<br><center>";
 
echo "<table border=0 cellspacing=3 cellpadding=3><tr>\n";
echo "<td>";
ButtonLink("Neuer Termin", "calentry.php", "year=$year&today=$today&month=$month&header=1&menu=0");
echo "</td>";
// echo "<td><a href='calentry.php?year=$year&today=$today&month=$month&header=1&menu=0'>";
// echo "<img src=\"image/button_calentnew.png\" border=0 alt=\"Neuer Eintrag\"></a></td>\n";
$num_button = 1;
 
if ($ca_status && ($ca_minum == $unum || $rstufe == 1)) {
echo "<td>";
ButtonLink("Erledigt", "appt.php", "year=$year&today=$today&month=$month&id=$ca_num&func=DONE&header=1&menu=0");
echo "</td>";
// echo "<td><a href='appt.php?year=$year&today=$today&month=$month&id=$ca_num&func=DONE&header=1&menu=0'>";
// echo "<img src=\"image/button_calfin.png\" border=0 alt=\"Task erledigt\"></a></td>\n";
$num_button++;
}
 
if ($ca_status && ((isset($ca_writer) && $ca_writer == $unum) || $rstufe == 1)) {
if (($num_button % 3) == 0)
echo "</tr><tr>\n";
 
$tdate = gmdate($dtformatshort, $ca_date);
$tend = gmdate($dtformatshort, $ca_end);
echo "<td>";
ButtonLink("Editieren", "calentry.php",
"ca_num=$ca_num&ca_prnum=$ca_prnum&ca_task=$ca_task&" .
"ca_minum=$ca_minum&ca_date=$tdate&ca_priority=$ca_priority&" .
"ca_end=$tend&ca_title=$ca_title&ca_text=" . urlencode($ca_text) .
"&func=edit&header=1&menu=0");
echo "</td>";
// echo "<td><a href=\"calentry.php?ca_num=$ca_num&ca_prnum=$ca_prnum";
// echo "&ca_task=$ca_task&ca_minum=$ca_minum&ca_date=$tdate&ca_priority=$ca_priority";
// echo "&ca_end=$tend&ca_title=$ca_title&ca_text=$ca_text&func=edit&header=1&menu=0\">";
// echo "<img src=\"image/button_edit.png\" border=0 alt=\"Eintrag editieren\"></a></td>\n";
$num_button++;
}
 
if (isset($ca_num) && $ca_num > 0 && $ca_status == 0 && ($ca_writer == $unum || $rstufe == 1)) {
if (($num_button % 3) == 0)
echo "</tr><tr>\n";
 
echo "<td>";
ButtonLink("Eintrag L&ouml;schen", "appt.php", "year=$year&today=$today&month=$month&del=$ca_num&header=1&menu=0");
echo "</td>";
// echo "<td><a href='appt.php?year=$year&today=$today&month=$month&del=$ca_num&header=1&menu=0'>";
// echo "<img src=\"image/button_calentdel.png\" border=0 alt=\"Eintrag L&ouml;schen\"></a></td>\n";
$num_button++;
}
 
echo "</tr></table>\n";
echo "</center>";
echo " <td valign=\"top\">
 
<table class=\"input\" width=\"250\">
<tr>
<td valign=\"middle\" align=\"center\" onClick=\"window.location='appt.php?year=$year&today=1&month=1&header=1&menu=0';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"appt.php?year=$year&today=1&month=1&header=1&menu=0\" class=\"normal\">Jan</a> </td>
<td valign=\"middle\" align=\"center\" onClick=\"window.location='appt.php?year=$year&today=1&month=2&header=1&menu=0';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"appt.php?year=$year&today=1&month=2&header=1&menu=0\" class=\"normal\">Feb</a> </td>
<td valign=\"middle\" align=\"center\" onClick=\"window.location='appt.php?year=$year&today=1&month=3&header=1&menu=0';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"appt.php?year=$year&today=1&month=3&header=1&menu=0\" class=\"normal\">M&auml;r</a> </td>
<td valign=\"middle\" align=\"center\" onClick=\"window.location='appt.php?year=$year&today=1&month=4&header=1&menu=0';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"appt.php?year=$year&today=1&month=4&header=1&menu=0\" class=\"normal\">Apr</a> </td>
<td valign=\"middle\" align=\"center\" onClick=\"window.location='appt.php?year=$year&today=1&month=5&header=1&menu=0';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"appt.php?year=$year&today=1&month=5&header=1&menu=0\" class=\"normal\">Mai</a> </td>
<td valign=\"middle\" align=\"center\" onClick=\"window.location='appt.php?year=$year&today=1&month=6&header=1&menu=0';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"appt.php?year=$year&today=1&month=6&header=1&menu=0\" class=\"normal\">Jun</a> </td>
</tr>
<tr>
<td valign=\"middle\" align=\"center\" onClick=\"window.location='appt.php?year=$year&today=1&month=7&header=1&menu=0';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"appt.php?year=$year&today=1&month=7&header=1&menu=0\" class=\"normal\">Jul</a> </td>
<td valign=\"middle\" align=\"center\" onClick=\"window.location='appt.php?year=$year&today=1&month=8&header=1&menu=0';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"appt.php?year=$year&today=1&month=8&header=1&menu=0\" class=\"normal\">Aug</a> </td>
<td valign=\"middle\" align=\"center\" onClick=\"window.location='appt.php?year=$year&today=1&month=9&header=1&menu=0';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"appt.php?year=$year&today=1&month=9&header=1&menu=0\" class=\"normal\">Sep</a> </td>
<td valign=\"middle\" align=\"center\" onClick=\"window.location='appt.php?year=$year&today=1&month=10&header=1&menu=0';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"appt.php?year=$year&today=1&month=10&header=1&menu=0\" class=\"normal\">Okt</a> </td>
<td valign=\"middle\" align=\"center\" onClick=\"window.location='appt.php?year=$year&today=1&month=11&header=1&menu=0';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"appt.php?year=$year&today=1&month=11&header=1&menu=0\" class=\"normal\">Nov</a> </td>
<td valign=\"middle\" align=\"center\" onClick=\"window.location='appt.php?year=$year&today=1&month=12&header=1&menu=0';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"> <a href=\"appt.php?year=$year&today=1&month=12&header=1&menu=0\" class=\"normal\">Dez</a> </td>
</tr>
</table><br />\n";
 
 
//display name of month
echo "<table class=\"input\" width=\"250\">\n<tr>\n";
echo "<td class=\"cellbg\" colspan=\"7\" valign=\"middle\" align=\"center\"><font class=\"regheading\"><b>" . gmdate("F",gmmktime(1,1,1,$month,1,$year)) . "</b></font>\n</td>\n";
echo "</tr>\n<tr>\n";
 
 
//display day names
foreach($alldays as $value) {
echo "<td class=\"cellbg\" valign=\"middle\" align=\"center\" width=\"10%\"><font class=\"normaltext\" size=\"1\"><b>$value</b></font></td>\n";
}
echo "</tr>\n<tr>\n";
 
 
//display blank days as nbsp's
for ($i = 0; $i < $dayone; $i++) {
echo "<td class=\"cellbg\" valign=\"middle\" align=\"center\"><font class=\"normaltext\" size=\"1\">&nbsp;</font></td>\n";
}
 
 
//display days
for ($zz = 1; $zz <= $numdays; $zz++) {
if ($i >= 7) {
print("</tr>\n<tr>\n"); $i=0;
}
 
//check current day for an event
$result_found = 0;
 
if ($zz == $today) { //mark todays cell regardless
echo "<td valign=\"middle\" align=\"center\" onClick=\"window.location='appt.php?year=$year&today=$zz&month=$month&header=1&menu=0';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='celltoday'\" class=\"celltoday\"><a href=\"appt.php?year=$year&today=$zz&month=$month&header=1&menu=0\" class=\"today\">$zz</a></font></td>\n";
$result_found = 1;
}
 
if ($result_found != 1) {//search for event on this day and mark cell if title not empty
$sql_currentday = gmmktime(0, 0, 0, $month, $zz, $year);
$eventQuery = "SELECT distinct ca_title, ca_date ";
$eventQuery .= "FROM calendar ";
$eventQuery .= "WHERE ca_date = '$sql_currentday'";
 
if ($rstufe != 1) {
$eventQuery .= " and (ca_minum = $unum or ca_minum is null ";
$eventQuery .= "or ca_writer = $unum)";
}
 
$eventExec = QueryDB($CONF['dbConn'], $eventQuery);
$nr = numrowsDB($eventExec);
$j = 0;
$old_date = 0;
 
while($j < $nr) {
$data = fetchDB($eventExec, $j);
$row['title'] = $data[0];
$row['date'] = $data[1];
 
if (strlen($row["title"]) > 0 && $row['date'] != $old_date) {
echo "<td valign=\"middle\" align=\"center\" onClick=\"window.location='";
echo "appt.php?year=$year&today=$zz&month=$month&header=1&menu=0';";
echo "\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellevent'";
echo "\" class=\"cellevent\"><a href=\"appt.php";
echo "?year=$year&today=$zz&month=$month&header=1&menu=0\" class=\"normal\">$zz</a></td>\n";
$result_found = 1;
}
 
$old_date = $row['date'];
$j++;
}
}
 
if ($result_found != 1) {//show default cell style for day
echo "<td valign=\"middle\" align=\"center\" onClick=\"window.location='appt.php?year=$year&today=$zz&month=$month&header=1&menu=0';\" onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\"><a href=\"appt.php?year=$year&today=$zz&month=$month&header=1&menu=0\" class=\"normal\">$zz</a></td>\n";
}
 
$i++; $result_found = 0;
}
 
$create_emptys = 7 - (($dayone + $numdays) % 7);
if ($create_emptys == 7) { $create_emptys = 0; }
 
//display blank remaining cells
if ($create_emptys != 0) {
echo "<td class=\"cellbg\" valign=\"middle\" align=\"center\" colspan=\"$create_emptys\"><font class=\"normaltext\"> </font></td>\n";
}
 
echo "</tr>\n";
echo "</table><br />\n";
 
 
//weekly display
echo "<table class=\"input\" width=\"250\">\n<tr>\n";
echo "<td valign=\"middle\" align=\"center\" class=\"cellbg\"><font class=\"regheading\"><b>Die ganze Woche</b></font></td></tr>\n";
 
 
for ($i = $today; $i <= ($today + 6); $i++)
{
//determine if days rollover into next month
$current_day = $i;
$current_year = $year;
$current_month = $month;
 
if ($i > $numdays)
{
$current_day = ($i - $numdays);
$current_month = $month + 1;
 
if ($current_month > 12)
{
$current_month = 1; $current_year = $year + 1;
}
}
 
$dayname = gmdate("l",gmmktime(1,1,1,$current_month,$current_day,$current_year));
$sql_currentday = gmmktime(0, 0, 0, $current_month, $current_day, $current_year);
$eventQuery = "SELECT ca_title, ca_num ";
$eventQuery .= "FROM calendar ";
$eventQuery .= "WHERE ca_date = '$sql_currentday'";
 
if ($rstufe != 1) {
$eventQuery .= " and (ca_minum = $unum or ca_minum is null ";
$eventQuery .= "or ca_writer = $unum)";
}
 
$eventExec = QueryDB($CONF['dbConn'], $eventQuery);
 
if ( $eventExec )
{
$j=0;
$nr = numrowsDB($eventExec);
 
while($j < $nr)
{
$data = fetchDB($eventExec, $j);
$row['title'] = $data[0];
$row['id'] = $data[1];
 
if (strlen($row["title"]) > 0)
{
$this_days_title[$j] = stripslashes($row["title"]);
$this_days_title[$j] = htmlspecialchars($this_days_title[$j]);
$this_id[$j] = $row['id'];
}
 
$j++;
}
 
if ( $j==0 )
{
$this_days_title[0] = "";
}
}
 
// echo "<tr onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\" height=\"30\">
// <td valign=\"top\" onClick=\"window.location='" .$_SERVER['PHP_SELF']. "?year=$current_year&today=$current_day&month=$current_month&header=$header';\"><a href=\"".$_SERVER['PHP_SELF']."?year=$current_year&today=$current_day&month=$current_month&header=$header\" class=\"normal\">$dayname - $current_day</a><br />\n";
echo "<tr onMouseOver=\"this.className='cellover'\"; onMouseOut=\"this.className='cellbg'\" class=\"cellbg\" height=\"30\">
<td valign=\"top\"><a href=\"appt.php?year=$current_year&today=$current_day&month=$current_month&header=1&menu=0\" class=\"normal\">$dayname - $current_day</a><br />\n";
 
 
//display day title if exists
$a = 0;
 
if ($nr > 0)
echo "<font class=\"eventtitle\">";
 
while ($a <= $j) {
if ( strlen($this_days_title[$a]) > 0 ) {
echo "<a href=\"appt.php?today=$current_day&month=$current_month&year=$current_year&id=";
echo $this_id[$a] . "&header=1&menu=0\">" . $this_days_title[$a] . "</a><br>\n";
}
 
$a++;
}
 
if ($nr > 0)
echo "</font>\n";
 
echo "</td></tr>\n";
$this_days_title = "";
}
echo "</table>\n";
 
echo "<center><a href=\"appt.php?header=1&menu=0\" class=\"normal\">Heutiger Tag</a></center>";
 
 
//end outer table
echo "</td>
</tr>
</table>\n";
 
require('footer.inc');
?>