Location: PHPKode > projects > Dogfood-A Complete Groupware/CRM System > dogfood/calendar/right.php
<?php
// r.php - PHProjekt Version 3.3
// copyright  ©  2000-2002 Albrecht Guenther  hide@address.com
// www.phprojekt.com
// Author: Albrecht Guenther

// TODO list
// delete todo
if ($action == "todo_del") {

  // check permission
  $result = db_query("select von from ".$DB['core'].".todo where ID = '$ID'");
  $row = db_fetch_row($result);
  if ($row[0] == 0) { die("no entry found."); }
  if ($row[0] <> $user_ID) { die("You are not allowed to do this!"); }
  // delete record from db
  $result = db_query("delete from ".$DB['core'].".todo where ID = '$ID'");
}

// create todo
elseif ($action == "todo_anl") {
  if ($komu) {
    $result = db_query("select kurz from ".$DB['core'].".users where ID = '$user_ID'");
    $row = db_fetch_row($result);
    if ($komu <> $user_ID) { $text="[".$row[0]."] ".$text; }
    $result = db_query("insert into ".$DB['core'].".todo values($dbIDnull,'$komu','$text',null,null,null)");
  }
  else $result = db_query("insert into ".$DB['core'].".todo values($dbIDnull,'$user_ID','$text',null,null,null)");
}

// update status of project
if ($statuschange) {
  if (!ereg("(^[0-9]*$)",$status) or $status<0 or $status>100) echo "<b>$r_status</b>";
  else $result = db_query("update ".$DB['current'].".projekte set status='$status', statuseintrag='$heute' where ID='$ID'");
}

// POLLS: insert vote
if ($votum_ID) {

  // make sure the user hasn't already voted
  $result = db_query("select fertig, an from ".$DB['current'].".votum where ID = '$votum_ID'");
  $row = db_fetch_row($result);
  if (!ereg("\"$user_kurz\"",$row[0])) {

    // radiobutton?
    if ($radiopoll) {
      $result = db_query("update ".$DB['current'].".votum set $radiopoll=$radiopoll + 1 where ID = '$votum_ID'");
      $stimme = 1;
    }
    // checkboxes?
    else {
      if ($zahl1) {$result = db_query("update ".$DB['current'].".votum set zahl1=zahl1 + 1 where ID = '$votum_ID'");$stimme = 1;}
      if ($zahl2) {$result = db_query("update ".$DB['current'].".votum set zahl2=zahl2 + 1 where ID = '$votum_ID'");$stimme = 1;}
      if ($zahl3) {$result = db_query("update ".$DB['current'].".votum set zahl3=zahl3 + 1 where ID = '$votum_ID'");$stimme = 1;}
    }
    //no vote at all?
    if ($stimme == 0) { $result = db_query("update ".$DB['current'].".votum set kein=kein + 1 where ID = '$votum_ID'"); }

    // update list of users already voted
    $result = db_query("select fertig from ".$DB['current'].".votum where ID = '$votum_ID'");
    $row = db_fetch_row($result);
    $pers = unserialize($row[0]);
    $pers[] = $user_kurz;
    $fertig = serialize($pers);
    $result = db_query("update ".$DB['current'].".votum set fertig='$fertig' where ID = '$votum_ID'");
  } // close bracket from if query, whether the user already has been voted
}


// ****************
//start html output
// ****************
echo "<script language='JavaScript' src='lib/chkform.js'></script>\n";

// helpdesk
if ($rts) {
	add_select("cl_help", "ID");
  echo "<form action='".href("index.php?sys_module=helpdesk")."' method='post' name='cl_help'>\n";
  echo "<input type=hidden name='mode' value='forms'>\n";
  echo "<input type=hidden name='mode_index' value='forms'>\n";
  echo "<table cellspacing=0 cellpadding=1 width=200><td>\n";
  echo "<tr><td><a href='index.php?sys_module=help&file=helpdesk'><b>$o_rts</b></a></td>\n";
  // link to list
  echo "<td align=right><a href='".href("index.php?sys_module=calendar&mode=rts&step=m_q")."'>$r_bmlist</a></td></tr>\n";
  // form for assigned requests
  echo "<tr><td width=175><select name=ID>\n";
  $where = "(assigned = '$user_kurz'";
  if ($groups) $where .= " or assigned = '$user_group'";
  $where.=") ";
  $result = db_query("select ID,name,priority from ".$DB['current'].".helpdesk_tickets where $where and status = '1' order by priority desc");
  while ($row = db_fetch_row($result)) {
    $text = substr($row[1],0,26);
    echo "<option value='$row[0]'>$text\n";
  }
  echo "</select></td>\n";
  // submit button
  echo "<td align=right><input type=image class=\"image\" src='img/los.gif' border=0 id=tr></td></tr><tr><td>\n";
  echo "</tr></table>";
  echo "<img class=\"image\" src='img/s.gif' width=200 height=1 vspace=2 border=0></form>\n";
}

// show Todo list and form
if ($todo) {
  echo "<form action='".href("index.php?sys_module=calendar")."' method='post' name=frm onSubmit=\"return chkForm('frm','text','$opt_bm4!')\">\n";
  echo "<input type=hidden name='action' value='todo_anl'>\n";
  echo "<input type=hidden name=year value='$year'>\n";
  echo "<input type=hidden name=month value='$month'>\n";
  echo "<input type=hidden name=day value='$day'>\n";
  echo "<table cellspacing=0 cellpadding=1 border=0 width=200><td>\n";
  echo "<tr><td><a href='index.php?sys_module=help&file=todo'><b>$r_todolist</b></a></td></tr>\n";
  echo "<tr><td width=175>\n";
  if (ereg("c",$user_access)){
    echo "<input type=text name=text size=12 maxlength=35> ";
    echo "<select name=komu size=1>\n";
    echo "<option value=$user_ID>$user_kurz\n";
    // select statement for groups
    $result2 = db_query("select ID from ".$DB['core'].".users where ID <> '$user_ID'");
    // loop over the users of this group
    while ($row2 = db_fetch_row($result2)) {
      $result = db_query("select ID,kurz from ".$DB['core'].".users where ID = '$row2[0]' order by kurz");
      while ($row = db_fetch_row($result)) echo "<option value=$row[0]>$row[1]\n";
    }
    echo "</select>";
  }
  else { echo "<input type=text name=text size=21 maxlength=35>"; }
  echo "</td>\n";
  // submit button
  echo "<td align=right><input type=image class=\"image\" src='img/los.gif' border=0 id=tr></td></tr><tr><td>\n";
  // display all entries in a list with the delete button
  $result = db_query("select * from ".$DB['core'].".todo where von = '$user_ID' order by remark");
  while ($row = db_fetch_row($result)) {
    $text = html_out($row[2]);
    echo "<a href='".href("index.php?sys_module=calendar&action=todo_del&ID=$row[0]&year=$year&month=$month&day=$day")."'>\n";
    echo "<img src='img/r.gif' alt='$r_tododel' title='$r_tododel' border=0 width=7></a>&nbsp;".urldecode($text)."<br>\n";
  }
  echo "</td></tr></table>";
  echo "<img src='img/s.gif' width=200 height=1 vspace=2 border=0></form>\n";
}

// Notizen/notes
if ($notes) {
  $record = 0;
  echo "<form action='".href("index.php?sys_module=notes")."' method=post>\n";
  echo "<input type=hidden name=aendern value='aendern'>";
  echo "<table cellspacing=0 cellpadding=0  border=0 width=200>\n";
  echo "<tr><td><a href='index.php?sys_module=help&file=notes'><b>$r_notes1</b></a></td></tr>\n";
  echo "<tr><td width=175><select name=ID>\n";
  // query for all personal notes, limit to the last 25
  $result = db_query("select note_id,name,changed from ".$DB['current'].".notes where von = '$user_ID' order by changes desc");
  while ($row = db_fetch_row($result) and $record < 26) {
    $row[1] = html_out($row[1]);
    echo "<option value=$row[0]>$row[1]\n";
    $record++;
  }
  echo "</select></td><td align=right>&nbsp;<input type=image class=\"image\" src='img/los.gif' border=0 id=tr></td></tr></table>";
  echo "<img src='img/s.gif' width=200 height=1 vspace=2 border=0></form>\n";
}

// Lesezeichen/Bookmarks
if ($lesezeichen) {
  $record = 0;
  printf("<script language=\"javascript\">\n\tfunction view_book() {\n\t\tif(document.bk_list.book_marks[document.bk_list.book_marks.selectedIndex]) window.open(document.bk_list.book_marks[document.bk_list.book_marks.selectedIndex].value, \"bmark_viewer\"); else alert(\"You must make a valid selection.\");\n\t}\n</script>");
  echo "<form action=\"javascript:view_book();\" method=post name=\"bk_list\">\n";
  echo "<table cellspacing=0 cellpadding=0 width=200>\n";
  echo "<tr><td><a href='index.php?sys_module=helpindex.php?sys_module=help&file==bookmark'><b>$r_bmtitle</b></a></td>\n";
  echo "<td align=right><nobr><a href='".href("index.php?sys_module=bookmarks&mode=forms&neu=1")."'>$new</a> | \n"; // Edit
  echo "<a href='".href("index.php?sys_module=bookmarks&mode=view")."'>$r_bmlist</a></nobr></td></tr>\n";    // list
  echo "<tr><td width=150><select name=\"book_marks\">\n";
  // query for all bookmarks of this group, limit to the last 25
  $result = db_query("select url,title,datum from ".$DB['current'].".bookmarks where $sql_user_group order by datum desc");
  while ($row = db_fetch_row($result) and $record < 26) {
    $row[1] = html_out($row[1]);
    echo "<option value=$row[0]>$row[1]\n";
    $record++;
  }
  echo "</select></td><td align=right>&nbsp;<input type=image class=\"image\" src='img/los.gif' border=0 id=tr></td></tr></table>\n";
  echo "<img src='img/s.gif' width=200 height=1 vspace=2 border=0></form>\n";
}

// list of actual projects
if ($projekte) {
  $result = db_query("select * from ".$DB['current'].".projekte where (personen like '%\"$user_kurz\"%' or chef = '$user_kurz')
                     and (kategorie = '3' or kategorie = '0' or kategorie is null) order by wichtung desc");
  echo "<table cellspacing=0 cellpadding=1 width=200><tr>\n";
  echo "<td colspan=2><a href='index.php?sys_module=help&file=projects'><b>$r_projtitle</b></td>\n";
  echo "<td align=right><a href='".href("index.php?sys_module=projects")."'>$r_bmlist</a></td></tr>\n";
  echo "<tr><td>$r_proj1:</td><td>$r_proj2:</td><td>$r_proj3:</td></tr>\n";
  while ($row = db_fetch_row($result)) {
    if (!$datum) { $datum = $year."-".$month."-".$day; }
    if ($row[7] <= $datum and $row[2] >= $datum) {
      //change class
      if (($i/2) == round($i/2)) { $class = "inverse"; $i++; } else { $class="main"; $i++; }
      // name of the project
      echo "<tr class=\"".$class."\"><td>".html_out($row[1])."</td>\n";
      // show deadline
      echo "<td width=70>$row[2]</td>\n";
      echo"<form action='".href("index.php?sys_module=calendar")."' method=post>\n";
      echo "<input type=hidden name=ID value=$row[0]>\n";
      echo "<input type=hidden name=statuschange value=1>\n";
      echo "<input type=hidden name=datum value=$datum>";
      echo "<input type='hidden' name='change_status' value='1'>\n";
      echo "<td valign=top align=right>";
      if ($row[9] == $user_kurz) { echo "<input type=text name=status value='$row[5]' size=3 onBlur='this.form.submit()'>%"; }
      else { echo "$row[5]%</td>\n"; }
      echo "</form></tr>\n";
    }
  }
  echo "</table>";
}
echo "<img src='img/s.gif' width=200 height=1 vspace=2 border=0></form>";

// Start Polls
	echo "<table cellspacing=0 cellpadding=1 border=0 width=200>\n";
	echo "<tr><td><a href='index.php?sys_module=help&file=votes'><b>$r_votetitle</b></a></td>";
	echo "<td align=right><a href='".href("index.php?sys_module=votum")."'>$r_votelist</a>\n</td></tr>\n";
	// fewtch all votes from the database
	$result = db_query("select * from ".$DB['current'].".votum");
	while($row = db_fetch_row($result)) {
		if($row[5] == "") $row[5] = "null";
		if($row[6] == "") $row[6] = "null";
		// have a look whether the user is 1. participant of this poll but not 2. already answered this poll :-)
		if(preg_match("/(\"$user_kurz\")/", $row[5])&&!preg_match("/(\"$user_kurz\")/", $row[6])) {
			$day = substr($row[1],6,2);
			$month = substr($row[1],4,2);
			// begin form to vote
			echo "<tr><td colspan=2><form action='".href("index.php?sys_module=calendar")."' action='post'>\n";
			echo "<input type='hidden' name='votum_ID' value='$row[0]'>\n";
			echo "<input type=hidden name=datum value=$datum>";
			// fetch author from user table
			$result2 = db_query("select nachname from ".$DB['core'].".users where ID = '$row[2]'");
			$row2 = db_fetch_row($result2);
			// display poll
			echo "<img src='img/b.gif' alt='$r_vote1 $month-$day von $row2[0]' title='$r_vote1 $month-$day von $row2[0]' width=7 border=0> ".html_out($row[3])."<br>\n";
			// is it a poll where you can vote 1. alternatively (-> radio button)
			if($row[4] == 'r') {
				// scan all three available option fields
				for($i=7; $i<=9; $i++) if($row[$i]) echo "<input type='radio' name='radiopoll' value='zahl".($i-6)."'>".html_out($row[$i])."<br>\n";
			} else {
				// scan all three available option fields
				for ($i=7; $i<=9; $i++) if(!$row[$i]) echo "<input type='checkbox' name='zahl".($i-6)."' value='yes'>".html_out($row[$i])."<br>\n";
			}
			echo "<input type=image class=\"image\" src='img/los.gif' border=0 id='tr'></form></td></tr>\n";
		}
	}
	echo "</table>";
// End Polls
?>
Return current item: Dogfood-A Complete Groupware/CRM System