Location: PHPKode > projects > Dogfood-A Complete Groupware/CRM System > dogfood/calendar/left.php
<?php
// l.php - PHProjekt Version 3.3
// copyright  ©  2000-2002 Albrecht Guenther  hide@address.com
// www.phprojekt.com
// Authors: Albrecht Guenther, Dieter Fiebelkorn

function get_week_nr($day){
	global $DB, $year, $month;
	$t_stamp = mktime(1,0,0,$month,$day,$year);
	while ($nr < 01){
		if ($t_stamp > 1104101999 and $t_stamp < 1104534000){return 53;}
		if ($t_stamp > 1009666799 and $t_stamp < 1104102000){$t_stamp += 604800;}
		$nr = strftime("%W", $t_stamp);
		$t_stamp -= 86400;
	}
	return $nr;
}

// Time sheet - Arbeitszeiterfassung
if ($timecard) {
  echo "<b>$o_timecard</b> &nbsp;&nbsp;";
  $datum = date("Y-m-d", mktime(date("H")+$timezone,date("i"),date("s"),date("m"),date("d"),date("Y")));
  $time  = date("H:i", mktime(date("H")+$timezone,date("i"),date("s"),date("m"),date("d"),date("Y")));
  echo "<nobr>";
  echo "<a href='".href("index.php?sys_module=timecard&mode=data&action=1")."'><img src='img/a1.gif' alt='$l_text21a' title='$l_text21a' border=0></a>&nbsp;&nbsp;\n";
  echo "<a href='".href("index.php?sys_module=timecard&mode=data&action=2")."'><img src='img/a2.gif' alt='$l_text21b' title='$l_text21b' border=0></a>&nbsp;&nbsp;\n";
  echo "<a href='".href("index.php?sys_module=timecard&mode=data&action=3")."'><img src='img/a3.gif' alt='$l_text21c' title='$l_text21c' border=0></a>&nbsp;&nbsp;\n";
  echo "<a href='".href("index.php?sys_module=timecard&mode=data&action=4")."'><img src='img/a4.gif' alt='$l_text21d' title='$l_text21d' border=0></a>&nbsp;&nbsp;\n";
  $here = "at work ($time): &#13;&#10;";
  $result = db_query("select * from ".$DB['cuurent'].".timecard where datum = '$datum'");
  while ($row = db_fetch_row($result)) {
    if (($row[4] and !$row[5] and !$row[6] and !$row[7]) or ($row[4] and !$row[5] and $row[6] and $row[7])) {
      $result2 = db_query("select nachname from ".$DB['core'].".users where ID = '$row[1]'");
      $row2 = db_fetch_row($result2);
      $here = $here."- $row2[0]  &#13;&#10;";
    }
  }
  echo "&nbsp;&nbsp;&nbsp;<img src=img/b.gif alt='$here' title='$here' width=10>\n</nobr><br>";
  echo "<img src='img/s.gif' width=200 height=1 vspace=3>\n";
}


//1. Form: choose month and year
// create date
$datum = "$year-$month-$day";
// begin form
echo "<form action='".href("index.php")."' method=post name='viewer'>\n";
echo "<table width=200 cellpadding=0 cellspacing=0 border=0>\n";
// button: previous month
echo "<td><input type=button name=previous value =\"<\" ";
echo "onclick=\"javascript:pagemonth(-1, '$sid')\"></td>\n";
// select box for month
echo "<td colspan=5 align=right><select name=month>\n";
for ($a=1; $a<13; $a++) {
  $mo = date("n", mktime(0,0,0,$a,1,$year));
  $name_of_month = $name_month[$mo];
  if ($mo == $month) {echo "<option value=$a selected>$name_of_month\n";}
  else {echo "<option value=$a>$name_of_month\n";}
}
echo "</select>\n";
// find current year
$y = date("Y", mktime(date("H")+$timezone,date("i"),date("s"),date("m"),date("d"),date("Y")));
// select box for the year
echo "<select name=year>&nbsp;\n";
if ($year < $y-2) {echo "<option value=$year selected>$year\n";}
for ($i=$y-2; $i<=$y+5; $i++) {
  if ( $i == $year) {echo "<option value=$i selected>$i\n";}
  else {echo"<option value=$i>$i\n";}
}
if ($year > $y+5) {echo "<option value=$year selected>$year\n";}
echo "</select></td>\n";
echo "<td align=left colspan=1>";
echo "<a href=\"javascript:pagemonth(0, '$sid')\">";
// submit button
echo "<img class=\"image\" src='img/los.gif' border=0 id=tr></a></td>\n";
// button 'next month'
echo "<td><input type=button name=next value =\">\" ";
echo "onclick=\"javascript:pagemonth(1, '$sid')\"></td>\n";
echo "</tr><tr><td colspan=\"8\"><hr size=\"1\" noshade>\n";

// show links for list view of events and resources
echo "<tr><td colspan=4>";
if ($ressourcen) {echo "<a href='".href("index.php?sys_module=calendar&mode=3&make=ress&no_r=$no_r")."'><i>$l_text1</i></a>"; }
echo "&nbsp;&nbsp;</td>";
echo "<td colspan=4 align=right><a href='".href("index.php?sys_module=calendar&mode=3&make=termin&no_r=$no_r")."'><i>$l_text2</i></a></td></tr>";

// show all days of a month
// name of week days
for ($i=0; $i<7; $i++) {
	echo "<td id=cal width=25>$name_day2[$i]</td>";
}
echo "<td id=cal>&nbsp;</td>";
echo "</tr><tr>";

//first week, still in last month?
if (date("w", mktime(0,0,0,$month,1,$year)) == 0) $da = -6; elseif (date("w", mktime(0,0,0,$month,1,$year))!=1) $da = - date("w", mktime(0,0,0,$month,1,$year)) +1; else $da = 1;

// set week number for the first time
  $week_nr = get_week_nr($da+1);

// show days of the previous month
if(!date("w", mktime(0,0,0,$month,1,$year))) {
	$start = 7;
} else $start = date("w", mktime(0,0,0,$month,1,$year));

for ($a = ($start-2); $a>=0; $a--) {
	$d = date("t", mktime(0,0,0,$month,0,$year)) - $a;
	echo"<td align=\"center\">$d</td>\n";
}

// show days of the actual month
for ($d=1; $d <= date("t", mktime(0,0,0,($month+1),0,$year)); $d++) {
	// fetch events
	$datum2 = date("Y-m-d",mktime(0,0,0,$month,$d,$year));
	$result3 = db_query("select ID from ".$DB['current'].".termine where datum like '$datum2' and an='$user_ID'");
	$row3 = db_fetch_row($result3);
	// today = red
	if ($month===date("m") AND $year==date("Y") AND $d==date("d")) $d1 = " style=\"color:#FF0000; font-weight:bold;\""; elseif ($row3[0] > 0) $d1=" style=\"color:#000000; font-weight:bold;\""; else $d1="";

	// day link
	printf("<td align=\"center\"><a href=\"javascript:dayweek(1, %d, %d, %d, '%s');\"%s>%d</a></td>", $year, $month, $d, $sid, $d1, $d);
	if (date("w", mktime(0,0,0,$month,$d,$year)) == 0 && date("t", mktime(0,0,0,($month+1),0,$year)) > $d )  {
		echo "</tr><tr>\n";
		// set values to show week number
		$da = $d + 1;
		$week_nr = get_week_nr($da);
	}
}

// show days of the next month
if (date("w", mktime(0,0,0,$month+1,1,$year)) <> 1) {
  $d=1;
  while (date("w", mktime(0,0,0,($month+1),$d,$year)) <> 1) {
    echo"<td align=\"center\">$d</td>\n";
    $d++;
  }
}
echo "</tr></table>\n";

// ************
// Profiles
if ($profile) {
  echo "<table width=200 cellpadding=2 cellspacing=0>\n";
  echo "<tr align=right><td><a href='index.php?sys_module=help&file=groups'><b>Group View</b></a>\n";
  if ($view) {
   $args="?sys_module=calendar&year=$year&month=$month&day=$day&view=0&no_r=$no_r";
   echo "<a href='".href("index.php$args")."'>";
  }
  else { echo "<a href='".href("index.php?sys_module&year=$year&month=$month&day=$day&view=1&no_r=$no_r")."'>"; }
  echo "<img src='img/".($view?"close":"open").".gif' border=0></a></td></tr></table>\n";
  if ($view) {
    $result = db_query("select acc from $DB['core'].users where ID = '$user_ID' and acc not like '%u%'");
    $row = db_fetch_row($result);
    $mygru=$gru;
    $mypers=unserialize(stripslashes($spers));
    if ($profile or $row[0]) {
      if ($day <= 0) { $day = 1; }
      echo "<table cellpadding=0 cellspacing=0 width=200>";
      // manual selection
      if ($user_group) {$result = db_query("select * from ".$DB['core'].".users where gruppe=$user_group and (acc like '%y%' or acc like '%v%' or ID = $user_ID) order by kurz");}
      else {$result = db_query("select * from ".$DB['core'].".users where acc like '%y%' or acc like '%v%' or ID = $user_ID order by kurz");}
      echo "<tr><td rowspan=3><select name=pers multiple size=5>\n";
      // db query for group system

      $pers_length=0;
      while ($row = db_fetch_row($result)) {
        echo "<option value=$row[3]";
        for ($a = 0; $a < count($mypers); $a++) { if ( $row[3] == $mypers[$a] ) { echo " selected"; }}
        echo ">$row[3]\n";
        $pers_length++;
      }
      echo "</select>&nbsp;</td>\n";
      echo "<td>$l_text25</td>\n";
      echo "<input type=hidden name=pers_length value=$pers_length>";
      echo "<td><select name=gru>\n <option value>\n";
      if ($ressourcen) {
        if ($mygru == "ress") { echo "<option value='ress' selected>$l_text4\n"; }
        else  {echo "<option value='ress'>$l_text4\n"; }
        echo "<option value>-----\n";
      }
      $result = db_query("select * from ".$DB['core'].".profile where von = '$user_ID' order by bezeichnung");
      while ($row = db_fetch_row($result)) {
        if ($mygru == $row[0]) {
          $row[2] = html_out($row[2]);
          echo "<option value=$row[0] selected>$row[2]\n";
        }
        else {echo "<option value=$row[0]>$row[2]\n";}
      }
      echo "</select></td>";
      echo "<tr><td>$l_text30</td><td><select name=axis>\n";
      echo "<option value=v".($axis!='h'&&$axis!='x'?" selected":"").">$l_text30a\n";
      echo "<option value=h".($axis=='h'?" selected":"").">$l_text30b\n";
      echo "<option value=x".($axis=='x'?" selected":"").">$l_text30c\n</select></td></tr>";
      if (!isset($dist)) { $dist = 0; }
      echo "<tr><td>$l_text31</td><td><select name=dist>\n";
      for ($i = 0; $i < count($l_text31a); $i++) {
        echo "<option value=$l_text31b[$i]";
        if ($dist == $l_text31b[$i]) { echo " selected"; }
        echo ">$l_text31a[$i]\n";
      }
      echo "</select></td></tr></table>\n";
    }
  }
}
echo "<input type=hidden name=day value=$day>";
echo "<input type=hidden name=view value=$view>";
echo "<input type=hidden name=no_r value=$no_r>";
echo "</form>\n";

// separation bar
echo "<img src='img/s.gif' width=200 height=1 vspace=4>\n";

// *******************************
//Form: create and delete event
echo "<form action='".href("index.php?sys_module=calendar")."' method=post name='new_event'>\n ";
echo "<table cellspacing=0 cellpadding=0 border=0 width=200>\n";
echo "<tr><td align=center colspan=6><b><a href='index.php?sys_module=help&file=create'>$l_text5</a></b></td></tr>\n ";
// variable for javascript
echo "<input type='hidden' name='var1' value='1'>\n";
echo "<input type=hidden name='make' value='create'>\n";
echo "<input type=hidden name=mode value=1>\n";
echo "<input type=hidden name=year value=$year>\n";
echo "<input type=hidden name=month value=$month>\n";
// input boxesfor day, start and end time
echo "<tr><td>Day:</td><td><input type='text' name='day' value='$day' size='2' maxlength='2' value='$day'></td>\n";
echo "<td>From: </td><td><input type='text' name='anfang' size='5' maxlength='5'></td>\n";
echo "<td>To: </td><td><input type='text' name='ende' size='5' maxlength='5'></td></tr>\n";
// text and note of the event
echo "<tr><td>Title:</td><td colspan=5><input type='text' name='event' size='26' maxlength='128'></td></tr>\n";
echo "<tr><td>Note:</td><td colspan=5><input type='text' name='note' size='26' maxlength='128'></td></tr>\n";
// submit button - create event
echo "<tr><td>&nbsp;</td><td colspan=3><input class=\"button\" type=submit value='Create' border=0></td>\n";
// link for extended event
echo "<td colspan=3>[ <a href=\"javascript:document.new_event.action='index.php?sys_module=calendar&mode=2';document.new_event.submit();\">Advanced</a> ]</td></tr>\n";
echo "</table><img src='img/s.gif' width=200 height=1 vspace=3>\n";
echo "</form>\n";

// register schedule variables
// reg_sess_vars(array("gru","spers","axis","view","dist","no_r","isRess","u_r_ID",""));
?>
Return current item: Dogfood-A Complete Groupware/CRM System