Location: PHPKode > projects > Silicon Fodder > SiliconFodder/DocumentRoot/diary/settings.php
<? require_once("../common/includes.php"); ?>
<? require_once("../util/general.php"); ?>
<? require_once("../admin/util.php"); ?>
<? require_once("../document/util.php"); ?>
<? ensureUserIsAdmin?>
<?
$mulview = $HTTP_GET_VARS["mulview"];

if($HTTP_GET_VARS["delnotused"] == "true") {
	$mySQL = "DELETE FROM diaryeventtypes WHERE eventId<0";
	gendb_query($mySQL, $myDb) or die(gendb_error());

	header("Location: settings.php?mulview=".$mulview);
	exit;
}
if($HTTP_GET_VARS["addevent"] == "true") {
	$eventName = trim($HTTP_GET_VARS["eventName"]);
	$mySQL = "INSERT INTO diaryeventtypes (eventId, colour, eventName) (SELECT MAX(ABS(eventId))+1, '', '".db_make_safe($eventName)."' FROM diaryeventtypes)";
	gendb_query($mySQL, $myDb) or die(gendb_error());

	header("Location: settings.php?mulview=".$mulview);
	exit;
}
if($HTTP_GET_VARS["flip"] == "true") {
	$eventtypeid = $HTTP_GET_VARS["eventtypeid"];
	$mySQL = "UPDATE diaryeventtypes SET eventId=-eventId WHERE id=".$eventtypeid;
	gendb_query($mySQL, $myDb) or die(gendb_error());

	header("Location: settings.php?mulview=".$mulview);
	exit;
}
if($HTTP_GET_VARS["clear"] == "true") {
	$eventtypeid = $HTTP_GET_VARS["eventtypeid"];
	$mySQL = "UPDATE diaryeventtypes SET colour='' WHERE id=".$eventtypeid;
	gendb_query($mySQL, $myDb) or die(gendb_error());

	header("Location: settings.php?mulview=".$mulview);
	exit;
}
if($HTTP_POST_VARS["posted"] == "1") {
	$mulview = $HTTP_POST_VARS["mulview"];
	$eventcolour = $HTTP_POST_VARS["eventcolour"];
	$eventtypeid = $HTTP_POST_VARS["eventtypeid"];

	$mySQL = "UPDATE diaryeventtypes SET colour='".str_replace("#", "", $eventcolour)."' WHERE id=".$eventtypeid;
	gendb_query($mySQL, $myDb) or die(gendb_error());

	header("Location: settings.php?mulview=".$mulview);
	exit;
}
if($HTTP_POST_VARS["posted"] == "2") {
	$mulview = $HTTP_POST_VARS["mulview"];
	$diaryshowtasks = $HTTP_POST_VARS["diaryshowtasks"];
	
	if($diaryshowtasks == "1") setApplicationObject("diaryshowtasks", "yes");
	else setApplicationObject("diaryshowtasks", "no");

	header("Location: settings.php?mulview=".$mulview);
	exit;
}

if($HTTP_POST_VARS["posted"] == "3") {
        $mulview = $HTTP_POST_VARS["mulview"];
        $appointmentsviauserlist = $HTTP_POST_VARS["appointmentsviauserlist"];

        if($appointmentsviauserlist == "1") setApplicationObject("appointmentsviauserlist", "yes");
        else setApplicationObject("appointmentsviauserlist", "no");

        header("Location: settings.php?mulview=".$mulview);
        exit;
}

?>
<html>
<head>
<? require_once("../common/head.php"); ?>
<script language="javascript">
function _f(_a) {
  var _o='';
  for(var i=0;i<_a.length;i++) {
    _o+='<td width="14" height="14" bgcolor="'+_a[i]+'">';
    _o+='<a href="#" onclick="window.opener.doIt(\''+_a[i]+'\');window.close()">';
    _o+='<IMG SRC="/images/1ptrans.gif" width="14" height="14" border="0" alt="'+_a[i]+'"></a></td>';
  }
  return(_o);
}

var _o='';
_o+='<HTML><HEAD><TITLE>Color Chart</TITLE></HEAD>';
_o+='<body onload="window.focus()" onblur="window.focus()" bgcolor="#334455" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0">';
_o+='<table border="1" bgcolor="#888888" cellpadding="0" cellspacing="0">';
_o+='<!-- RED --><tr>';
var _a$=new Array("#ffeeee","#ffcccc","#ffaaaa","#ff8888","#ff6666","#ff4444","#ff2222","#ff0000","#ee0000","#cc0000","#aa0000","#880000","#770000","#660000","#550000","#440000","#330000");
_o+=_f(_a$);
_o+='</tr><!-- GREEN --><tr>';
var _b$=new Array("#eeffee","#ccffcc","#aaffaa","#88ff88","#66ff66","#44ff44","#22ff22","#00ff00","#00ee00","#00cc00","#00aa00","#008800","#007700","#006600","#005500","#004400","#003300");
_o+=_f(_b$);
_o+='</tr><!-- BLUE --><tr>';
var _c$=new Array("#eeeeff","#ccccff","#aaaaff","#8888ff","#6666ff","#4444ff","#2222ff","#0000ff","#0000ee","#0000cc","#0000aa","#000088","#000077","#000066","#000055","#000044","#000033");
_o+=_f(_c$);
_o+='</tr><!-- YELLOW --><tr>';
var _d$=new Array("#ffffee","#ffffcc","#ffffaa","#ffff88","#ffff66","#ffff44","#ffff22","#ffff00","#eeee00","#cccc00","#aaaa00","#888800","#777700","#666600","#555500","#444400","#333300");
_o+=_f(_d$);
_o+='</tr><!-- PURPLE --><tr>';
var _e$=new Array("#ffeeff","#ffccff","#ffaaff","#ff88ff","#ff66ff","#ff44ff","#ff22ff","#ff00ff","#ee00ee","#cc00cc","#aa00aa","#880088","#770077","#660066","#550055","#440044","#330033");
_o+=_f(_e$);
_o+='</tr><!-- ORANGE --><tr>';
var _f$=new Array("#ffddd0","#ffe0aa","#ffdd88","#ffcc77","#ffbb66","#ffaa55","#ffaa44","#ff9944","#ff8833","#ff7722","#ff6622","#ee5522","#dd4411","#cc3300","#aa2200","#882200","#662200");
_o+=_f(_f$);
_o+='</tr><!-- CYAN --><tr>';
var _g$=new Array("#eeffff","#ccffff","#aaffff","#88ffff","#66ffff","#44ffff","#22ffff","#00ffff","#00eeee","#00cccc","#00aaaa","#008888","#007777","#006666","#005555","#004444","#003333");
_o+=_f(_g$);
_o+='</tr><!-- GRAY --><tr>';
var _h$=new Array("#ffffff","#eeeeee","#dddddd","#cccccc","#bbbbbb","#aaaaaa","#a0a0a0","#999999","#888888","#777777","#666666","#555555","#444444","#333333","#222222","#111111","#000000");
_o+=_f(_h$);
_o+='</tr></table></BODY></HTML>';

var win= null;

function NewWindow(fieldId) {
	document.frm.eventtypeid.value=fieldId;
	// Opens the Color Chart Popup
	win2=window.open('','colorPop','height=130,width=274,top=150,left=100,scrollbars=no,resizable=no');
	win2.document.open();
	win2.document.write(_o);
	win2.document.close();
}
function doIt(color) {
	document.frm.eventcolour.value = color;
	document.frm.submit();
}

function addEvent() {
	var eventName = prompt('Please enter the new event name', '');
	if(eventName != '' && eventName != null) {
		self.location = 'settings.php?mulview=<?=$mulview?>&addevent=true&eventName=' + escape(eventName);
	}
}
function delEventsNotUsed() {
	if(confirm('Are you sure you want to delete unused diary events from the system?')) {
		self.location = 'settings.php?mulview=<?=$mulview?>&delnotused=true';
	}
}
</script>
</head>

<body>
<?
if(isPda()) {
	pdaHeader("Diary Settings", "index.php", true, "Settings");
} else {
	dispHeader("Diary Settings");
}
?>
Use this page to add new event-types to the diary, and to alter the colour highlighting used.
<br><br>

<form name="frm" method="post" action="settings.php">
<table width="500">
<tr><th>Event-type</th><th>Colour</th><th>Use on site?</th></tr>
<?
$mySQL = "SELECT * FROM diaryeventtypes ORDER BY id";
$rows = gendb_query($mySQL, $myDb) or die(gendb_error());
while($row = gendb_fetch_assoc($rows)) {
	$showOnSite = ($row["eventId"] > 0);

	echo "<tr>";
	echo "<td>".$row["eventName"]."</td>";
	echo "<td style=\"padding:5px;height:20px;background-color:#".$row["colour"]."\">background colour - <a href=\"javascript:NewWindow(".$row["id"].")\">[change]</a> <a href=\"settings.php?clear=true&eventtypeid=".$row["id"]."\">[clear]</a></td>";
	echo "<td align=\"center\"><input type=\"checkbox\"".($showOnSite ? " checked" : "")." onClick=\"self.location='settings.php?flip=true&eventtypeid=".$row["id"]."'\"></td>";
	echo "</tr>";
}
gendb_free_result($rows);
?>
</table>
<br>
<?=gen_button("btnAdd", "addEvent()", "", "", "&nbsp;Add&nbsp;new&nbsp;event&nbsp;")?>
<br><br>
<?=gen_button("btnDel", "delEventsNotUsed()", "", "", "&nbsp;Delete&nbsp;unused&nbsp;events&nbsp;from&nbsp;system&nbsp;")?><!--<br><i style="font-size:12px">note - if there are current diary events that are linked to a type that is not<br>used on the site, then that information will be lost</i>-->
<br><br><hr><br>
Show tasks on the diary? <input type="checkbox" name="diaryshowtasks" value="1" <? if(getApplicationObject("diaryshowtasks") == "yes") echo " checked"; ?>> <a href="#" onClick="document.frm.posted.value='2';document.frm.submit();return false;" class="liteButton">Update</a>
<br><br><hr><br>
<? if(isSuperUser()) { ?>
Appointments go via internal user list, rather than straight to diary? <input type="checkbox" name="appointmentsviauserlist" value="1" <? if(getApplicationObject("appointmentsviauserlist") == "yes") echo " checked"; ?>> <a href="#" onClick="document.frm.posted.value='3';document.frm.submit();return false;" class="liteButton">Update</a>
<br><br><hr><br>
<? } ?>
<?=gen_button("btnBack", "self.location='index.php?mulview=".$mulview."'", "", "", "Back to diary")?>
<input type="hidden" name="posted" value="1">
<input type="hidden" name="eventtypeid" value="">
<input type="hidden" name="eventcolour" value="">
<input type="hidden" name="mulview" value="<?=$mulview?>">
</form>

</body>
</html>
<? require_once("../common/incFinal.php"); ?>
Return current item: Silicon Fodder