Location: PHPKode > projects > Dogfood-A Complete Groupware/CRM System > dogfood/calendar/functions01.inc
<?php

// m2.php - PHProjekt Version 3.3
// copyright	  ©  2000-2002 Albrecht Guenther  hide@address.com
// www.phprojekt.com
// Authors: Albrecht Guenther

echo "<script language='Javascript'>\n";
echo "function setMAKEnGo(what){\n";
echo "	  frm = document.create;\n";
echo "	  frm.make.value = what;\n";
echo "	  frm.submit();\n";
echo "}\n";
echo "       function set_warn() {
	     frm = document.create;
	       if (frm.visi.value==2) document.warn.src='img/r.gif';
	       else {document.warn.src='img/t.gif';}
	     }";
echo "</script>";

// edit event: fetch values from database
if ($event_ID) {
	  $result = db_query("select * from ".$DB['current'].".termine where ID = '$event_ID'");
	  $row = db_fetch_row($result);
	  // check permission
	  if (!$row[0] || ($row[1] <> $user_ID && $row[2] <> $user_ID)) {
	  	printf("Are do not have the required permissions to access this section.");
	  	define("_IS_BAD_", "TRUE");
	  }
	  if($user_ID <> $row[1])$read_o = "disabled class=\"inverse\"";
	  if($mode >4) $mode -= 4;
	  // convert values
	  list($year, $month, $day) = explode("-",$row[7]);
	  $event = html_out($row[3]);
	  $note = html_out($row[4]);
	  $anfang = $row[8];
	  $ende = $row[9];
	  $visi = $row[17];
	  $sms_remind = $row[16];// für sms reminder geändert
	  $sms_remind_time = substr($sms_remind,0,strlen($sms_remind)-1);
} else {
	  $event = html_out(stripslashes($event));
	  $note = html_out(stripslashes($note));
}

if(!defined("_IS_BAD_")) {
	// form: create, modify and delete event
	echo "<center><table cellspacing=1 cellpadding=0 border=0>\n";
	echo "<colgroup><col width=25%><col width=30%><col width=25%><col width=20%></colgroup>\n";

	// if ID is given, show 'change event', otherwise show	  'create and delete event'
	if ($event_ID) $pagetitle = "$r_proj2 $admin_text7"; else $pagetitle = $m2_text1;
	// title and link to help page
	echo "<tr><td align=center colspan=4><b><a href='$doc/create.html' target=_blank>$pagetitle</a></b><br><br></td></tr>\n ";
	// form with day, begin & end, event & note
	echo "<form action='".href("index.php?sys_module=calendar")."' method=post name='create'>\n ";
	echo "<input type=hidden name='no_r' value='$no_r'>\n";
	echo "<input type='hidden' name='all' value='$all'>\n";
	echo "<input type=hidden name='up' value='$up'>\n";
	echo "<input type=hidden name='sort' value='$sort'>\n";
	echo "<input type=hidden name='page' value='$page'>\n";
	echo "<input type=hidden name='perpage' value='$perpage'>\n";
	echo "<input type=hidden name='filter' value='$filter'>\n";
	echo "<input type=hidden name='keyword' value='$keyword'>\n";
	echo "<input type=hidden name='mode' value='$mode'>\n";
	echo "<input type='hidden' name='year' value='$year'>\n";
	echo "<input type='hidden' name='var1' value='1'>\n";	  // variable for javascript

	// date
	echo "<tr><td width=80>$forum_text9:</td>\n";
	echo "<td colspan=3>$l_text6: <input type='text' name='day' size='2' maxlength='2' value='$day' $read_o>.\n";
	echo "<input type='text' name='month' size='2' maxlength='2' value='$month' $read_o>.$year\n";

	// begin
	echo "<br>$l_text7:<input type='text' name='anfang' value='$anfang' size='5' maxlength='5' $read_o>\n";
// end
	echo "&nbsp;&nbsp;$l_text8:<input type='text' name='ende' size='5' value='$ende' maxlength='5' $read_o></td></tr>\n";
	echo "<tr><td>$l_text9:</td><td colspan=3><input type='text' name='event' value='$event' size='36' maxlength='128' $read_o></td></tr>\n";
	echo "<tr><td>Note:</td><td colspan=3><input type='text' name='note' value='$note' size='36' maxlength='128' $read_o></td></tr>\n";

	// visibility of this event
	if(!eregi("n",$user_access)){
		echo"<tr><td>$m2_text5</td>";
		echo "<td colspan=3 valign='top'><select name='visi' onChange='set_warn()' $read_o>\n";
		echo "<option value='0'"; if($visi==0)echo" selected"; echo ">$m2_text2\n";
		echo "<option value='1'"; if($visi==1)echo" selected"; echo ">$m2_text3\n";
		echo "<option value='2'"; if($visi==2)echo" selected"; echo ">$m2_text4</select>\n";
		$dotcol =($visi==2)?('r'):('t');
		echo"&nbsp;<img name='warn' src='img/$dotcol.gif' width='10' height='10' border='0'></td></tr>";
		echo "<tr></td colspan=4><img src='img/s.gif' width=325 height=1></td></tr>\n";   // line
	}

	// show resources
	if ($ressourcen) {
		echo "<tr><td>$inst_text18</td>";
		echo "<td colspan=3><select name=ressource $read_o><option value=''>\n";
		$result2 = db_query("select ID, name from ".$DB['current'].".ressourcen");
		while ($row2 = db_fetch_row($result2)) {
			echo "<option value=$row2[0]";
			if ($row2[0] == $row[10]) { echo " selected"; }
			echo ">$row2[1]\n";
		}
		echo "</select></td>\n";
	}
	echo "</tr><tr>\n";

	// select contact (only if module is active an nolink option is not active)
	if ($adressen and !$contacts_nolink) {
		echo "<td>$o_adresses</td><td colspan=3><select name=contact $read_o><option value=''>\n";
		$result2 = db_query("select ID,vorname,nachname from ".$DB['core'].".contacts where (von = '$user_ID' or acc like 'a') and $sql_user_group order by nachname");
		while ($row2 = db_fetch_row($result2)) {
		echo "<option value=$row2[0]";
		if ($row2[0] == $row[12]) { echo " selected"; }
			echo ">$row2[2], $row2[1]\n";
		}
		echo "</select></td></tr><tr>\n";
	}

	// select project
	if($projekte) {
		echo "<td>$l_text11</td><td colspan=3><select name=project $read_o><option value=''>\n";
		// prepare query for function
		$query = "where $sql_user_group";
		// call function to show all required elemts in a tree structure in the select box
		show_elements_of_tree("projekte","name",$query,"personen"," order by name",$row[5],"parent",0);
		echo "</select></td>\n";
	}

	echo "</tr><tr>\n";

	// comment field
	echo "<tr><td>$admin_text71</td><td colspan=3><textarea rows=6 cols=32 name='remark' $read_o>$row[13]</textarea>\n</td></tr>";

	//sms / email reminder
	if ($sms_remind_service and ($user_smsnr or $user_email)) {
		$sms_remind_cb = ""; $email_remind_cb = "";$sms_none = "selected";
		$sms_lenght = strlen($sms_remind);
		$sms_last = $sms_lenght - 1;
		$remind_type = substr($sms_remind,$sms_last,"1");
		if ($remind_type=="1") $sms_remind_cb = "selected";$sms_none="";
		if ($remind_type=="2") $email_remind_cb = "selected";$sms_none="";
		//hier muß noch für kein reminder was rein
		echo "<tr><td colspan=4><img src='img/s.gif' width=325 height=1></td></tr>\n";   // line
		echo "<tr><td>Reminder</td>";
		echo "<td><input type='text' name='sms_remind' size='3' value='$sms_remind_time' maxlength='3' $read_o> min</td>";
		echo "<td>";
		echo "<select name=\"smslist\" size=\"1\">";
		echo "<option>---</option>";
		if ($user_smsnr) echo "<option $sms_remind_cb>sms</option> >";
		if ($user_email) echo "<option $email_remind_cb>email</option> >";
		echo "</td><td>";
		echo "</td></tr>";
	}

	// display only if it's a new event
	if (!$event_ID) {
		echo "<tr><td colspan=4><img src='img/s.gif' width=325 height=1></td></tr>\n";   // line

		// repeating events
		echo "<tr><td>$m1_text42:</td>\n";
		echo "<td colspan=3><select name='serie'>\n";
		echo "<option value=''>$l_text13\n";
		echo "<option value='tag'>$l_text14\n";
		echo "<option value='woche'>$l_text15\n";
		echo "<option value='monat'>$l_text16\n";
		echo "<option value='jahr'>$l_text17\n";
		echo "</select>\n";
		echo "$l_text18:<input type='text' name='endday' size='2' maxlength='2'>.\n";
		echo "<input type='text' name='endmonth' size='2' maxlength='2'>.\n";
		echo "<input type='text' name='endyear' size='4' maxlength='4'></td></tr>\n";

		// create group events
		if ( ereg("c",$user_access)) {
			echo "<tr><td colspan=4><img src='img/s.gif' width=325 height=1></td></tr>\n";   // line
			echo "<tr><td>$l_text24</td>\n";
			echo "<td colspan=3><select name=persev[] multiple size=3>\n";
			// fetch users from this actual group
			// loop over all users
			if ($user_group) $result = db_query("select * from ".$DB['core'].".users where gruppe = '$user_group' order by kurz"); else $result = db_query("select * from ".$DB['core'].".users order by kurz");
			while ($row = db_fetch_row($result)) {
				echo "<option value=$row[3]";
				if(eregi($row[3],$spers)) echo " selected";
				echo ">$row[3]\n";
			}
			echo "</select>\n";
			// profile box
			if ($profile) {
			echo "$l_text25: <select name=gruev>\n <option value>\n";
			$result = db_query("select * from ".$DB['current'].".profile where von = '$user_ID'");
			while ($row = db_fetch_row($result)) {
				echo "<option value=$row[0]";
				if($gru==$row[0])echo " selected";
				echo">$row[2]\n";}
				echo "</select>\n";
			}
			echo "</td></tr>";
		}

		echo "<tr><td colspan=4><img src='img/s.gif' width=325 height=1></td></tr>\n";   // line

		// create button
		echo "<tr><td>&nbsp;</td><td>\n";
		echo "<input type=hidden name='make' value='create'>\n";
		echo "<input type='submit' class=\"button\" value='$l_text19'>\n";
	} else { // update button
		echo "<tr><td>&nbsp;</td><td>\n";
		echo "<input type=hidden name='make' value='update'>\n";
		echo "<input type=hidden name='event_ID' value='$event_ID'>\n";
		if($read_o) echo"&nbsp;\n";
		else echo "<input type='submit' class=\"button\" value='$admin_text7'>\n";
	}
	
	// delete button
	echo "</td><td><input type='button' class=\"button\" value='$l_text20' onclick=\"javascript:setMAKEnGo('delete');\"></td>\n";
	echo "</form></td>\n";


	// back button
	echo "<td>&nbsp;&nbsp;<a href=\"javascript:".($mode==3?"setMAKEnGo('')":"history.back()")."\">$back</a></td>";
	echo "</table></center>";
}
?>
Return current item: Dogfood-A Complete Groupware/CRM System