// Script updated 1/11/05 by Ian : modified createEditRecord on clients request.
function SectionLink($sName, $sId, $sPreCode = "
", $sPostCode = "", $bMarkActive = 1, $sActiveClass = "active") {
$sClassCode = "";
if (($GLOBALS["sPage"] == $sId) && ($bMarkActive)) {
$sClassCode = " class=\"".$sActiveClass."\"";
}
return $sPreCode."".$sName."".$sPostCode;
}
//////////////////////////////
// create login record
//
// takes the user id
// creates a record in the login table
function createLogin($id, $username, $password) {
$dateTime = date("Y-m-d H:i:s");
$year = date("Y");
$month = date("m");
$day = date("d");
$sql = "insert into logins set
username = '$username',
password = '$password',
logged_in = '$dateTime',
player_id = '$id',
day = '$day',
month = '$month',
year = '$year'
";
mysql_query($sql) or die("SQL Insert Error".mysql_error());
return mysql_insert_id();
}
function createLogout($id) {
$dateTime = date("Y-m-d H:i:s");
$sql = "update logins set logged_out = '$dateTime' where id = '$id'";
mysql_query($sql) or die("SQL Update Error".mysql_error());
}
//////////////////////////////
// create edit record
//
// takes the user id, house id, development id
// creates a record in the edits table
function createEdit() {
}
//////////////////////////////
// date formatting
// takes a mysql date
// returns a date formatted as dd/mm/yy
function format_date($date) {
$date = substr($date,8,2)."/".substr($date,5,2)."/".substr($date,2,2);
return $date;
}
// takes mysql date and time
// returns date formatted as dd/mm/yyyy and time as hh:mm:ss
function format_datetime($datetime) {
$datetime = substr($datetime,8,2)."/".substr($datetime,5,2)."/".substr($datetime,0,4)." ".substr($datetime,11,8);
return $datetime;
}
//////////////////////////////
// last editor
// takes the sheet that was edited and the person who was doing it
// updates an edits table
function lastEditedBy($sheet,$pid,$devid,$hid) {
$date = date("Y-m-d");
$time = date("H:i:s");
$sql = "select name from players where id = '$pid'";
$result = mysql_query($sql) or die("SQL Select Error: ".mysql_error());
$row = mysql_fetch_row($result);
$person = addslashes($row[0]);
$sql = "update edits set date = '$date', time = '$time', person = '$person', development_id = '$devid', house_id = '$hid' where sheet = '$sheet'";
mysql_query($sql) or die("SQL Update Error".mysql_error());
}
//////////////////////////////
// edits
// record who edited what and when
function createEditRecord($devid,$hid,$pid, $updated_fields=""){
// Edited 1/11/05 by ian : added new db field updated_fields
$date = date("Y-m-d");
$time = date("H:i:s");
$sql = "select name from players where id = '$pid'";
$result = mysql_query($sql) or die("SQL Select Error: ".mysql_error());
$row = mysql_fetch_row($result);
$person = addslashes($row[0]);
$sql = "insert into edits_record set date = '$date', time = '$time', person_id = '$pid', development_id = '$devid', house_id = '$hid', updated_fields='$updated_fields'";
mysql_query($sql) or die("SQL Insert Error: ".mysql_error());
}
//////////////////////////////
// date selection
$year = date('Y');
if ($year === '2005') $ys1 = "selected";
else if($year==='2006')$ys2 = "selected";
else if($year==='2007')$ys3 = "selected";
else if($year==='2008')$ys4 = "selected";
else if($year==='2009')$ys5 = "selected";
else if($year==='2010')$ys6 = "selected";
else if($year==='2011')$ys7 = "selected";
else if($year==='2012')$ys8 = "selected";
$yearoption = "
";
$month = date('m');
if($month=='01')$mo1 = "selected";
else if($month=='02')$mo2 = "selected";
else if($month=='03')$mo3 = "selected";
else if($month=='04')$mo4 = "selected";
else if($month=='05')$mo5 = "selected";
else if($month=='06')$mo6 = "selected";
else if($month=='07')$mo7 = "selected";
else if($month=='08')$mo8 = "selected";
else if($month=='09')$mo9 = "selected";
else if($month=='10')$mo10 = "selected";
else if($month=='11')$mo11 = "selected";
else if($month=='12')$mo12 = "selected";
$monthoption = "
";
$day = date('d');
if($day=='01')$da1 = "selected";
else if($day=='02')$da2 = "selected";
else if($day=='03')$da3 = "selected";
else if($day=='04')$da4 = "selected";
else if($day=='05')$da5 = "selected";
else if($day=='06')$da6 = "selected";
else if($day=='07')$da7 = "selected";
else if($day=='08')$da8 = "selected";
else if($day=='09')$da9 = "selected";
else if($day=='10')$da10 = "selected";
else if($day=='11')$da11 = "selected";
else if($day=='12')$da12 = "selected";
else if($day=='13')$da13 = "selected";
else if($day=='14')$da14 = "selected";
else if($day=='15')$da15 = "selected";
else if($day=='16')$da16 = "selected";
else if($day=='17')$da17 = "selected";
else if($day=='18')$da18 = "selected";
else if($day=='19')$da19 = "selected";
else if($day=='20')$da20 = "selected";
else if($day=='21')$da21 = "selected";
else if($day=='22')$da22 = "selected";
else if($day=='23')$da23 = "selected";
else if($day=='24')$da24 = "selected";
else if($day=='25')$da25 = "selected";
else if($day=='26')$da26 = "selected";
else if($day=='27')$da27 = "selected";
else if($day=='28')$da28 = "selected";
else if($day=='29')$da29 = "selected";
else if($day=='30')$da30 = "selected";
else if($day=='31')$da31 = "selected";
$dayoption = "
";
?>
Dunboy Construction Administration System