=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 =''; $TDTitStyle =''; // loop to create the column headers for ($i=0;$i'.$VAcolumnNames[$i].''.chr(13); } $TableTitle =''; // loop to create the column headers for ($i=0;$i'.$columnNames[$i].''.chr(13); } $TDListOdd =''; $ListStop ='
'; $TableVA ='
'; // define here background and font colors of $TDListEven =''; // the alternating rows $TRList ='
'; /////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////// THIS IS THE LIST OVERVIEW ////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////// if( (!isset($listflight)) and (!isset($pilotflight)) ) { // ------------------------------ INTRO-TEXT ----------------------------------------------------- // delete or edit as you like ... echo '
'.$PageTitle.'
A demonstration of FsPassenger\'s VA database interface


Airbus A380-800 Swiss International Air Lines flown by Alexander Modica

'; // ------------------------------------------------------------------------------------------------ /////////////////////////////////////// INTRO-TEXT FSP VA ///////////////////////////////////////// /* echo '
WARNING !!! 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: Exporting flight log online to VA (screenshots)

'; echo '

'; */ /////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////// STATISTICS ///////////////////////////////////////// /// Get the total number of flights, total flight time, total passengers & total cargo weight // /////////////////////////////////////////////////////////////////////////////////////////////////// $query = "select count(*) from flights ".$condition; $result=mysql_query($query); if(!$result){echo "SQL Error - ".mysql_error()."
".$query;return;} $NrfFlights=mysql_result($result,0); # total flight time / block time $query= 'SELECT sum( time_to_sec( TotalBlockTime ) ) FROM flights '. $condition; $result= mysql_query( $query ); $zahl= mysql_result( $result, 0 ); $text= give_zeit( $zahl ); # total passengers $query = "SELECT sum(NbrPassengers) FROM flights ".$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' ".$andCondition; $result=mysql_query($query); $TCKG = mysql_result($result,0); $query = "SELECT sum(CargoWeight) FROM flights where right(CargoWeight,3)='lbs' ".$andCondition; $result=mysql_query($query); $TCLB = mysql_result($result,0); $TCW = getWeight($TCKG,$TCLB); // see function at end of script echo '
'.$TDListOdd. "
Virtual Airline Statistics
". "Total flights".$startMsg.": $NrfFlights
Total flight time: $text h
Total passengers carried: $TPC
Total Cargo carried: $TCW
". $ListStop; echo "
"; ////////////////////////////////////////////////////////////////////////////////////////////////// // ------------------------------ COMMENTS ------------------------------------------------------- // delete or edit as you like ... echo '
Click on Pilot Name to show the list of flights. Click on the column headers to sort the data by columns.

'; // ------------------------------------------------------------------------------------------------ // PAGING ///////////////////////////////////////////////////////////////////////////////////////// // // set max page numbers displayed at a time (to avoid line breaks in the paging) $maxPage = 20; $pageStep = 10; $pStart = 0; // preliminary sql-query : $query = "SELECT COUNT(PilotName) as TnF FROM flights GROUP BY PilotName"; if(!$result=mysql_query($query)) { echo "SQL Error - ".mysql_error()."
".$query; return; } /////////////////////////////////////////////////////////////////////////////////////////////////////// $NrfFlights=mysql_num_rows($result); if($NrfFlights==0){echo "No flights to display";return;} $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 = ''.chr(13); $paging_Html .= ''; $paging_Html .= '
Page  '; for ($i=$pageFrom;$i<$pageTo;$i++) { if($i == $thisPage) { $paging_Html .= ''.($i+1).'  '.chr(13); } else { $paging_Html .= ''.($i+1).'  '.chr(13); } } if ($thisPage+1!=$pages) { $paging_Html .= 'next »'; } //Eigenbau von Zurück-Button //} //if ($thisPage-1!=$pages) //{ //$paging_Html .= 'back »'; //} //Ende Eigenbau von Zurück-Button $paging_Html .= ' Displaying Pilots '.($pStart+1).' to '.$pEnd.' of a total '.$NrfFlights.'
'; ////////////////////////////////////////////////////////////////////////////////////////////////////// // main sql-query : $query = "SELECT PilotName, COUNT(PilotName) as TnF, SUM(TIME_TO_SEC(TotalBlockTime)) AS TTotalBlockTime, SUM(NbrPassengers) AS TNbrPassengers, SUM(BonusPoints) AS TBonusPoints, SUM(PenalityPoints) AS TPenalityPoints, SUM(BonusPoints - PenalityPoints) AS TotalPoint FROM flights GROUP BY PilotName ORDER BY $sortColumn LIMIT $pStart,$pageLines"; $result= mysql_query( $query ); $zahl= mysql_result( $result, 0 ); $text= give_zeit( $zahl ); if(!$result=mysql_query($query)) { echo "SQL Error - ".mysql_error()."
".$query; return; } /////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////// LIST TABLE OUTPUT /////////////////////////////////////////////////////////////// echo $paging_Html; echo $ListStart.$TableVA; 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'.$row[[$i]].''.chr(13); } } echo ''; $Line=!$Line; } } else { echo '
There are no flights recorded.'; } echo $ListStop; echo $paging_Html; /////////////////////////////////////////////////////////////////////////////////////////////////////// } if( (!isset($listflight)) and (!isset($pilotflight)) ) return; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if(isset($pilotflight)) { // PAGING ///////////////////////////////////////////////////////////////////////////////////////// // // set max page numbers displayed at a time (to avoid line breaks in the paging) $maxPage = 20; $pageStep = 10; $pStart = 0; //////////////////////////////////////////////////////////////////////////////////////////////////////// $query = "SELECT * FROM flights WHERE PilotName LIKE '%$pilotflight%' "; if(!$result=mysql_query($query)) { echo "SQL Error - ".mysql_error()."
".$query; return; } $NrfFlights=mysql_num_rows($result); if($NrfFlights==0){echo "No flights to display";return;} /////////////////////////////////////////////////////////////////////////////////////////////////////// $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 = ''.chr(13); $paging_Html .= ''; $paging_Html .= '
Page  '; for ($i=$pageFrom;$i<$pageTo;$i++) { if($i == $thisPage) { $paging_Html .= ''.($i+1).'  '.chr(13); } else { $paging_Html .= ''.($i+1).'  '.chr(13); } } if ($thisPage+1!=$pages) { $paging_Html .= 'next »'; } $paging_Html .= ' Displaying Flight '.($pStart+1).' to '.$pEnd.' of a total '.$NrfFlights.'
'; /////////////////////////////////////////////////////////////////////////////////////////////////////// $query = "SELECT * FROM flights WHERE PilotName LIKE '%$pilotflight%' ORDER BY $sortColumn LIMIT $pStart,$pageLines"; if(!$result=mysql_query($query)) { echo "SQL Error - ".mysql_error()."
".$query; return; } ///////////////////// LIST TABLE OUTPUT /////////////////////////////////////////////////////////////// // ------------------------------ INTRO-TEXT ----------------------------------------------------- // delete or edit as you like ... echo '
LogBook of '.$pilotflight.'
A demonstration of FsPassenger\'s VA database interface

'; // ------------------------------------------------------------------------------------------------ // ------------------------------ COMMENTS ------------------------------------------------------- // delete or edit as you like ... echo '
Click on Flight-Nr to show the details of one flight. Click on the column headers to sort the data by columns.

'; // ------------------------------------------------------------------------------------------------ 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'; $Line=!$Line; } } else { echo '
There are no flights recorded.'; } echo $ListStop; echo $paging_Html; echo '
« return to pilots list
'; } if(isset($pilotflight))return; ///////////////////// THIS IS THE SINGLE FLIGHT OUTPUT /////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if(isset($listflight)) { $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 ''; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; if($row["CruiseTimeStopSec"]>0) { echo '"; echo '"; } if($row["LandingSpeed"]>0) { echo '"; echo '"; } echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo '"; echo ''; echo '
Company: '.$row["CompanyName"].'    Flight Id: '.$row["FlightId"].'    Flight Date: '.$row["FlightDate"].'    Pilot: '.$row["PilotName"]."
Aircraft Name:'.$row["AircraftName"]."
Aircraft Type:'.$row["AircraftType"]."
Departure:'.$row["DepartureIcaoName"]."
Arrival:'.$row["ArrivalIcaoName"]."
Departure Time:'.$row["DepartureLocalHour"]." (".$row["DepartureGmtHour"]." GMT)
Arrival Time:'.$row["ArrivalLocalHour"]." (".$row["ArrivalGmtHour"]." GMT)
Passengers:'.$row["NbrPassengers"]."
Cargo:'.$row["CargoWeight"]."
Flight Result:'.$row["FlightResult"]."
Take-Off Weight:'.$row["StartAircraftWeight"]."
Landing Weight:'.$row["EndAircraftWeight"]."
Take-Off fuel:'.$row["StartFuelQuantity"]."
Landing Fuel:'.$row["EndFuelQuantity"]."
TotalBlockTime:'.$row["TotalBlockTime"]."
TotalBlockTimeNight:'.$row["TotalBlockTimeNight"]."
TotalAirbornTime:'.$row["TotalAirbornTime"]."
TotalTimeOnGround:'.$row["TotalTimeOnGround"]."
MaxAltitude:'.$row["MaxAltitude"]."
CruiseSpeed:'.$row["CruiseSpeed"]."
CruiseMachSpeed:'.$row["CruiseMachSpeed"]."
LandingSpeed:'.$row["LandingSpeed"]."
LandingPitch:'.$row["LandingPitch"]."°
TouchDownVertSpeedFt:'.$row["TouchDownVertSpeedFt"]." ft/mn
CaptainSentMayday:'.$row["CaptainSentMayday"]."
CrashFlag:'.$row["CrashFlag"]."
PassengersOpinion:'.$row["PassengersOpinion"]."%
PassengersOpinionText:-'.$row["PassengersOpinionText"]."
FailureText:-'.$row["FailureText"]."
CasualtiesText:-'.$row["CasualtiesText"]."
Pilot Bonus:'.$row["BonusPoints"]."
PilotBonusText:-'.$row["PilotBonusText"]."
Pilot Penality:'.$row["PenalityPoints"]."
PilotPenalityText:-'.$row["PilotPenalityText"]."
« back
'; echo '

'; } if(isset($listflight))return; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /*******************************************************************************************************************/ // 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 = ''.$data.''; // return the HTML $tdList = ''.$data.''.chr(13); return $tdList; } function makeTD1($data,$fieldName,$evenodd,$rowID=-1) { global $linkColor; global $evenColor; global $oddColor; // set alternating background-colors if($evenodd==1) {$bgColor = $evenColor;} else {$bgColor = $oddColor;} // automatic right-align exlude PilotName field if($fieldName!='PilotName') {$tdalign = 'align="right" ';} else {$tdalign = '';} // link through PilotName Flight List if($rowID>-1) $data = ''.$data.''; // return the HTML $tdList = ''.$data.''.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); } ?>