14-02-2011, 06:35 PM
Hy guys
I have the problem that i cant find the background colour of this Php script
could you help me
i think I have tried out every background colour
but i think you guys had better eyes to see what background colour it is
thanks to you
I have the problem that i cant find the background colour of this Php script
could you help me
Quote:<?php
/* GLOBAL PARAMETERS FOR FsPlistflight.php */
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// the following arrays list the columns and the corresponding database field-names showing up in the table //
// you can add more columns/fields or remove those you don't wish to display or sort them in a different way //
// Note: the two arrays must have the same number of values; values must be separated by comma //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
$tableColumns = 'Flight Nr,Date,Company,Pilot,From,To,PAX,Type,Time,Result,Bonus,Penalty';
$dataFields = 'FlightId,FlightDate,CompanyName,PilotName,DepartureIcaoName,ArrivalIcaoName,NbrPassengers,
AircraftType,TotalBlockTime,FlightResult,BonusPoints,PenalityPoints';
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// GLOBAL PARAMETERS CHANGE THESE AS YOU LIKE //////////////////////////////////////
$pageLines = 50; // sets the number of rows displayed on
each page
$tableWidth = '800'; // width of the main table - change according to number
of columns
$defaultSort = 'datestamp desc'; // default sorting column if no other option is selected
// you
can set this to 'FlightDate', 'CompanyName' or whatever you like,
//
add 'desc' to sort the data in descending order
# colors
$oddColor = '#D5E4FD'; // 1st background color of alternating table
rows
$evenColor = '#fcf9e4'; // 2nd background color of alternating table rows
$linkColor = '#000099'; // font color for linked items (in this case just "FlightId")
# misc data formats
$dateFormat = 0; // sets the default YYYY-MM-DD format for
the Flight Date
$dateSeparator = '-'; // you can set it to '1' to use DD.MM.YYYY instead
// you
can also change the separator character (e.g. '.')
# Headline on top of page
$PageTitle ="RUPPRECHTER JOHANNES";
# set a start date (referring to upload-date) for the records to be displayed, starting with that date
# this is optional, leave it empty (default) to display all records in the database
$startDate = ''; // if not empty, the date must be entered in
a given format
// (YYYY-
MM-DD) and it has to be valid - ex.: '2005-05-30'
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////NEEDED STUFF USUALLY YOU WILL NOT NEED TO CHANGE THIS///////////////////////////////////
define("FSP", 1);
# setting.php contains MySQL database settings and other settings; it contains also the FSP UNIT SETTING
require("FsPadmin/setting.php");
# common.php do the connection to MySQL the value $databaseconnexion is set to true if the connection is okay
require("FsPadmin/common.php");
// the value "$databaseconnexion" is set to true in common.php if the connexion is ok
if($databaseconnexion==FALSE){echo "Error - unable to connect to mySQL database;";return;}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// get the header-variables GET / POST
$listflight = $_GET['listflight']; // ID of a single selected flight
$s = $_GET['s']; // sorting option (column)
$d = $_GET['d']; // sorting direction
(ASCENDING or DESCENDING)
$p = $_GET['p']; // actual page to display
// create the arrays for the column names and database fields from config.php
$columnNames = explode(",",$tableColumns);
$dbFieldNames = explode(",",$dataFields);
for($i=0;$i<count($dbFieldNames);$i++) {
$dbFieldNames[$i] = trim($dbFieldNames[$i]);
}
// set the sql condition for start date selected, if any
$condition = '';
$andCondition = '';
if($startDate != '')
{
$startMsg = ' since '.$startDate;
$startDate .= ' 00:00:00';
$condition = "where datestamp>=str_to_date('".$startDate."','%Y-%m-%d %H:%i:%s')";
$andCondition = "and datestamp>=str_to_date('".$startDate."','%Y-%m-%d %H:%i:%s')";
}
// avoid invalid options for $d
if ($d!=1) $d=0;
// SORTING ////////////////////////////////////////////////////////////////////////////////////////////////////
if($s=="")
{
$sortColumn = $defaultSort;
} else {
$sortColumn = $s;
if($d==1) $sortColumn .= ' desc';
$sortOptions[$sortColumn] = !$sortOptions[$sortColumn];
if($sortColumn!='id desc' && $sortColumn!='id')
{
$sortColumn .= ', id desc';
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////// EDIT THE TABLE DESIGN HERE //////////////////////////////////////////////////////////////
$ListStart ='<table width="'.$tableWidth.'" cellspacing="1" cellpadding="2" align="center" style="font: normal 11px/14px Arial,sans-
serif;padding:2px 7px 2px 7px">';
$TDTitStyle ='<td nowrap style="background-color:#5F7EEB;color:white;padding:2px 5px 2px 5px">';
$TableTitle ='<tr>';
// loop to create the column headers
for ($i=0;$i<count($dbFieldNames);$i++)
{
$TableTitle .= $TDTitStyle.
' <a href="?action=va&s='.$dbFieldNames[$i].'&d='.$sortOptions[$dbFieldNames[$i]].'&p='.$p.'"
style="text-decoration:none;color:white">'.$columnNames[$i].'</a></td>'.chr(13);
}
$TDListOdd ='<td nowrap style="background-color:#D5E4FD;color:black;padding-left:5px">'; // define here background and
font colors of
$TDListEven ='<td nowrap style="background-color:#7CADDE;color:black;padding-left:5px">'; // the alternating rows
$TRList ='<tr>';
$ListStop ='</table>';
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////// THIS IS THE LIST OVERVIEW //////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(!isset($listflight))
{
// ------------------------------ INTRO-TEXT -----------------------------------------------------
// delete or edit as you like ...
echo '<table align="center" border="0"><tr><td>
<span style="font: bold 18px/24px Arial,sans-serif">
'.$PageTitle.'
</span><br>
<span style="font: bold 11px/16px Arial,sans-serif">
A demonstration of FsPassenger\'s VA database interface
</span>
</td></tr></table><br>';
// ------------------------------------------------------------------------------------------------
/////////////////////////////////////// INTRO-TEXT FSP VA /////////////////////////////////////////
/*
echo '<table align="center" width="500" cellspacing="2" cellpadding="2" border="0" style="font:normal 12px/16px
Arial,sans-serif"><tr><td>
<strong>WARNING !!!</strong> This shows only the abilities of FsP to export and record data in a SQL
database,
I don\'t have time yet to make a nice page so the data are displayed "right out of the box".
See this topic in the forum about export features:
<a href="http://www.fspassengers.com/forum/showthread.php?tid=149">Exporting flight log
online to VA</a> (screenshots)
</td></tr></table><br>';
echo '<div align="center"><img src="http://www.fspassengers.com/images/vademo.jpg" alt="" border="0"></div><br>';
*/
///////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////// STATISTICS /////////////////////////////////////////
/// Get the total number of flights, total flight time, total passengers & total cargo weight //
///////////////////////////////////////////////////////////////////////////////////////////////////
$query = "select count(*) from flights WHERE UserName = 'Rupprechter Johannes' ".$condition;
$result=mysql_query($query);
if(!$result){echo "SQL Error - ".mysql_error()."<br>".$query;return;}
$NrfFlights=mysql_result($result,0);
# total flight time / block time
$query = "SELECT sec_to_time(sum(time_to_sec(TotalBlockTime))) FROM flights WHERE UserName = 'Rupprechter
Johannes' ".$condition;
$result=mysql_query($query);
$TFT = number_format(mysql_result($result,0));
# total passengers
$query = "SELECT sum(NbrPassengers) FROM flights WHERE UserName = 'Rupprechter Johannes' ".$condition;
$result=mysql_query($query);
$TPC = number_format(mysql_result($result,0));
# total cargo weight // there might be units of lbs as well as kg in one database
// therefor each sum has to be read
separately.
// we compute the total weight in one unit
first and
// display both units in the stats
$query = "SELECT sum(CargoWeight) FROM flights where right(CargoWeight,2)='kg' AND UserName = 'Rupprechter
Johannes' ".$andCondition;
$result=mysql_query($query);
$TCKG = mysql_result($result,0);
$query = "SELECT sum(CargoWeight) FROM flights where right(CargoWeight,3)='lbs' AND UserName = 'Rupprechter
Johannes' ".$andCondition;
$result=mysql_query($query);
$TCLB = mysql_result($result,0);
$TCW = getWeight($TCKG,$TCLB); // see function at end of script
echo '<br><table width="300" cellspacing="1" cellpadding="2" align="center" style="font: normal 11px/14px Arial,sans-
serif;padding:7px 7px 7px 7px">'.$TDListOdd.
"<div align=\"center\"><strong><u>Johannes Statistic</u></strong><br>".
"Total flights".$startMsg.": $NrfFlights<br>
Total flight time: $TFT h<br>
Total passengers carried: $TPC<br>
Total Cargo carried: $TCW</div>".
$ListStop;
echo "<br>";
//////////////////////////////////////////////////////////////////////////////////////////////////
// ------------------------------ COMMENTS -------------------------------------------------------
// delete or edit as you like ...
echo '<table align="center" width="'.$tableWidth.'" cellspacing="2" cellpadding="2" border="0" style="font:normal
12px/16px Arial,sans-serif;color:#444444">
<tr><td>Click on Flight-Nr to show the details of one flight. Click on the column headers to sort the
data by columns.</td>
</tr></table><br>';
// ------------------------------------------------------------------------------------------------
// PAGING /////////////////////////////////////////////////////////////////////////////////////////
//
// set max page numbers displayed at a time (to avoid line breaks in the paging)
$maxPage = 20;
$pageStep = 10;
$pStart = 0;
if ($NrfFlights>0)
{
$pages = ceil($NrfFlights/$pageLines);
if(isset($p) && $p<=$pages) {$thisPage=$p;} else {$thisPage=0;}
$pStart = $thisPage*$pageLines;
$pEnd = $pStart+$pageLines;
if($pEnd>$NrfFlights) $pEnd=$NrfFlights;
// reduce the nbr of pages displayed at a time
if($pages > $maxPage)
{
$pageFrom = $thisPage-$pageStep;
if($pageFrom < 0) $pageFrom = 0;
$pageTo = $pageFrom+$maxPage;
if($pageTo > $pages) $pageTo = $pages;
}
else
{
$pageTo = $pages;
}
// create the HTML for the paging
$paging_Html = '<table width="'.$tableWidth.'" align="center"
style="font:normal 12px/14px Arial,sans-serif;background-
color:white"><tr>'.chr(13);
$paging_Html .= '<td valign="top" style="padding:4px 0px 4px 4px">Page ';
for ($i=$pageFrom;$i<$pageTo;$i++)
{
if($i == $thisPage)
{
$paging_Html .= '<span style="font-weight:bold">'.($i+1).'</span> '.chr(13);
} else {
$paging_Html .= '<a href="?action=va&s='.$s.'&d='.$d.'&p='.$i.'" style="color:'.$linkColor.'">'.
($i+1).'</a> '.chr(13);
}
}
if ($thisPage+1!=$pages)
{
$paging_Html .= '<a href="?action=va&s='.$s.'&d='.$d.'&p='.($thisPage+1).'"
style="color:'.$linkColor.'">next »</a>';
}
$paging_Html .= '</td><td valign="top" align="right" style="padding:4px 4px 4px 0px"">
Displaying Flight '.($pStart+1).' to '.$pEnd.' of a
total '.$NrfFlights.'</td>';
$paging_Html .= '</tr></table>';
// main sql-query :
$query = "SELECT * FROM flights WHERE UserName = 'Rupprechter Johannes' ".$condition." ORDER BY
$sortColumn LIMIT $pStart,$pageLines";
if(!$result=mysql_query($query))
{
// if any invalid sort parameters are transmitted, the sorting defaults to 'id'
$query = "SELECT * FROM flights ".$condition." ORDER BY $defaultSort LIMIT $pStart,$pageLines";
if(!$result=mysql_query($query))
{
echo "SQL Error - ".mysql_error()."<br>".$query;
return;
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////// LIST TABLE OUTPUT ///////////////////////////////////////////////////////////////
echo $paging_Html;
echo $ListStart.$TableTitle;
if ($NrfFlights>0) {
$Line=0;
// loop to display all rows
while ($row = mysql_fetch_assoc($result))
{
echo $TRList;
// loop to display all columns using function "makeTD()"
for($i=0;$i<count($dbFieldNames);$i++)
{
if ($dbFieldNames[$i]=='FlightId')
{
echo makeTD($row[$dbFieldNames[$i]],$dbFieldNames[$i],$Line,$row['id']);
// this TD is linked by FlightId
} else {
echo makeTD($row[$dbFieldNames[$i]],$dbFieldNames[$i],$Line);
}
}
echo '</tr>';
$Line=!$Line;
}
}
else
{
echo '<tr><td colspan="'.count($dbFieldNames).'" align="center"><br>There are no flights recorded.</td></tr>';
}
echo $ListStop;
echo $paging_Html;
///////////////////////////////////////////////////////////////////////////////////////////////////////
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if(!isset($listflight))return;
///////////////////// THIS IS THE SINGLE FLIGHT OUTPUT ///////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$query = "SELECT * FROM flights WHERE id=$listflight";
$result=mysql_query($query);
if(!$result){echo "SQL Error - ".mysql_error();return;}
$NrfFlights=mysql_num_rows($result);
if($NrfFlights==0){echo "No flights to display";return;}
$Line=0;
$row = mysql_fetch_assoc($result);
echo '<table width="600" border="1" cellspacing="0" cellpadding="2" align="center"
style="background-color: #D5E4FD; font: normal 11px/14px Arial,sans-serif">';
echo '<tr><td colspan="2" align="center" style="background-color: #7CADDE;"><strong>Company: </strong>'.$row
["CompanyName"].' <strong>Flight Id: </strong>'.$row
["FlightId"].' <strong>Flight Date:</strong> '.$row
["FlightDate"].' <strong>Pilot:</strong> '.$row["PilotName"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>Aircraft Name:</strong></td><td>'.$row["AircraftName"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>Aircraft Type:</strong></td><td>'.$row["AircraftType"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>Departure:</strong></td><td>'.$row["DepartureIcaoName"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>Arrival:</strong></td><td>'.$row["ArrivalIcaoName"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>Departure Time:</strong></td><td>'.$row["DepartureLocalHour"]." (".$row
["DepartureGmtHour"]." GMT)</td></tr>";
echo '<tr><td style="width: 120px;"><strong>Arrival Time:</strong></td><td>'.$row["ArrivalLocalHour"]." (".$row
["ArrivalGmtHour"]." GMT)<br></td></tr>";
echo '<tr><td style="width: 120px;"><strong>Passengers:</strong></td><td>'.$row["NbrPassengers"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>Cargo:</strong></td><td>'.$row["CargoWeight"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>Flight Result:</strong></td><td>'.$row["FlightResult"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>Take-Off Weight:</strong></td><td>'.$row["StartAircraftWeight"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>Landing Weight:</strong></td><td>'.$row["EndAircraftWeight"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>Take-Off fuel:</strong></td><td>'.$row["StartFuelQuantity"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>Landing Fuel:</strong></td><td>'.$row["EndFuelQuantity"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>TotalBlockTime:</strong></td><td>'.$row["TotalBlockTime"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>TotalBlockTimeNight:</strong></td><td>'.$row["TotalBlockTimeNight"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>TotalAirbornTime:</strong></td><td>'.$row["TotalAirbornTime"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>TotalTimeOnGround:</strong></td><td>'.$row["TotalTimeOnGround"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>MaxAltitude:</strong></td><td>'.$row["MaxAltitude"]."</td></tr>";
if($row["CruiseTimeStopSec"]>0)
{
echo '<tr><td style="width: 120px;"><strong>CruiseSpeed:</strong></td><td>'.$row["CruiseSpeed"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>CruiseMachSpeed:</strong></td><td>'.$row
["CruiseMachSpeed"]."</td></tr>";
}
if($row["LandingSpeed"]>0)
{
echo '<tr><td style="width: 120px;"><strong>LandingSpeed:</strong></td><td>'.$row["LandingSpeed"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>LandingPitch:</strong></td><td>'.$row["LandingPitch"]."°</td></tr>";
}
echo '<tr><td style="width: 120px;"><strong>TouchDownVertSpeedFt:</strong></td><td>'.$row["TouchDownVertSpeedFt"]."
ft/mn</td></tr>";
echo '<tr><td style="width: 120px;"><strong>CaptainSentMayday:</strong></td><td>'.$row["CaptainSentMayday"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>CrashFlag:</strong></td><td>'.$row["CrashFlag"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>PassengersOpinion:</strong></td><td>'.$row["PassengersOpinion"]."%
</td></tr>";
echo '<tr><td style="width: 120px;"><strong>PassengersOpinionText:</strong></td><td>-'.$row["PassengersOpinionText"]."
</td></tr>";
echo '<tr><td style="width: 120px;"><strong>FailureText:</strong></td><td>-'.$row["FailureText"]."</td></tr>";
echo '<tr><td style="width: 120px;"><strong>CasualtiesText:</strong></td><td>-'.$row["CasualtiesText"]." </td></tr>";
echo '<tr><td style="width: 120px;"><strong>Pilot Bonus:</strong></td><td>'.$row["BonusPoints"]." </td></tr>";
echo '<tr><td style="width: 120px;"><strong>PilotBonusText:</strong></td><td>-'.$row["PilotBonusText"]." </td></tr>";
echo '<tr><td style="width: 120px;"><strong>Pilot Penality:</strong></td><td>'.$row["PenalityPoints"]." </td></tr>";
echo '<tr><td style="width: 120px;"><strong>PilotPenalityText:</strong></td><td>-'.$row["PilotPenalityText"]." </td></tr>";
echo '<tr><td colspan=2 align="center" style="padding:5px 0px 5px 0px;font-weight:bold"><a href="javascript:history.back
()">« back</a></td>';
echo '</table>';
echo '<br><br>';
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*******************************************************************************************************************/
// Functions
/*******************************************************************************************************************/
// this function generates the HTML for one cell (TD) in a table row
function makeTD($data,$fieldName,$evenodd,$rowID=-1)
{ global $linkColor;
global $evenColor;
global $oddColor;
global $dateFormat;
global $dateSeparator;
// set alternating background-colors
if($evenodd==1) {$bgColor = $evenColor;} else {$bgColor = $oddColor;}
// automatic right-align for numeric values
if(is_numeric($data) && $fieldName!='FlightId') {$tdalign = 'align="right" ';} else {$tdalign = '';}
// reformat the FlightDate from YYYY-MM-DD to DD-MM-YYYY (only if the global parameter is set to '1')
if($dateFormat == 1 && $fieldName == 'FlightDate' && strlen($data) == 10) {
$data = reDate($data,$dateSeparator);
}
// short departure/arrival ICAO names (delete the following line to show long names)
if(strstr($fieldName,'IcaoName')) $data=substr($data,0,4);
// link through Flight-ID?
if($rowID>-1) $data = '<a href="?listflight='.$rowID.'" style="color:'.$linkColor.'">'.$data.'</a>';
// return the HTML
$tdList = '<td nowrap '.$tdalign.'style="background-color:'.$bgColor.';padding:1px 5px 1px 5px">'.$data.'</td>'.chr(13);
return $tdList;
}
// this function takes the accumulated kg and lbs weights,
// puts them together and returns the total cargo in both units
function getWeight($kg,$lb)
{
$LBtoKG = 0.4535924;
$totalKG = $kg+($lb*$LBtoKG);
$totalLB = $totalKG/$LBtoKG;
$cwStr = number_format($totalKG,0).' kg / '.number_format($totalLB,0).' lbs';
return $cwStr;
}
// changes the format of a given date from YYYY-MM-DD to DD-MM-YYYY
// the second parameter defines the separator used
function reDate($dt,$sep) {
$nDate = "";
if(strstr($dt,'-')) {
$tmpArr = explode("-",$dt);
for($i=count($tmpArr)-1;$i>=0;$i--) {
$nDate .= $tmpArr[$i].$sep;
}
$nDate = substr($nDate,0,strlen($nDate)-1);
}
return $nDate;
}
// this adds two hours of FsP and returns them in hour format
// ( 12:30:45 + 02:05:06 = 14:35:51 for example)
// --- not used in this script ---
function AddTime($Time1,$Time2)
{
$timea=explode(":",$Time1);
$timeb=explode(":",$Time2);
$secondes=($timea[0]+$timeb[0])*3600;
$secondes+=($timea[1]+$timeb[1])*60;
$secondes+=$timea[2]+$timeb[2];
$hours = floor($secondes / 3600);
$minute = floor(($secondes - ($hours * 3600)) / 60);
$secconde = $secondes - ($hours * 3600) - ($minute * 60);
return sprintf("%02d:%02d:%02d", $hours, $minute, $secconde);
}
?>
i think I have tried out every background colour
but i think you guys had better eyes to see what background colour it is
thanks to you