Jump to content

TouchdownStats 1.0


simpilot

Recommended Posts

Hey it works !

take a look at this http://www.cargoitaliavirtual.com/index.php/TouchdownStats/top_landings/10

I would like to ask you one last thing if I could,

I would like to have only top five landings and limited monthly and last last thingI would like to limit results of the best from -100 up to -200 if its less than -100 exp: -99 or more -201 I would not like to have them displayed !

Thanks again and best wishes

Link to comment
Share on other sites

I haven't been able to get the Top 5 to call properly yet, but once you get the Top 5 you wont need to show the best from -100 up to -200 since you are already showing

63, -56, -79, -90, and -90

Those will always be showing until someone beats them (except the 63, not sure how that one got on there).

Link to comment
Share on other sites

  • Administrators

Hey it works !

take a look at this http://www.cargoitaliavirtual.com/index.php/TouchdownStats/top_landings/10

I would like to ask you one last thing if I could,

I would like to have only top five landings and limited monthly and last last thingI would like to limit results of the best from -100 up to -200 if its less than -100 exp: -99 or more -201 I would not like to have them displayed !

Thanks again and best wishes

Wait - how did Jeff's code work, I thought you were using the custom PIREP system and table. If that code is working then you must be using the native format and all the other functions will work as they are, no modification is needed.

Link to comment
Share on other sites

  • Administrators

I haven't been able to get the Top 5 to call properly yet, but once you get the Top 5 you wont need to show the best from -100 up to -200 since you are already showing

Those will always be showing until someone beats them (except the 63, not sure how that one got on there).

The use of the limited function is within the first post of this thread.

TouchdownStatsData::get_stats('10')

This will only fill the variable with 10 listings, you can change the 10 to whatever you would like. You can use this in your module that calls the page (prefered) or within the template itself.

or quite simply call the built in page of the module ->

www.yoursite.com/index.php/TouchdownStats/top_landings/10

Link to comment
Share on other sites

Maybe he landed upside down. :huh:

This is how I have mine setup you can look into it.

<?php
   foreach($stats as $stat)
   {
       $pilot = PilotData::getPilotData($stat->pilotid);
       $aircraft = OperationsData::getAircraftInfo($stat->aircraft);
       echo '<tr align="center" valign="middle" bgcolor="#DFF4FF">';
       echo '<td>'.PilotData::getPilotCode($pilot->code, $pilot->pilotid).' - '.$pilot->firstname.' '.$pilot->lastname.'</td>';
       echo '<td>'.$aircraft->fullname.'</td>';
       echo '<td>'.$stat->arricao.'</td>';
       echo '<td>'.$stat->landingrate.'</td>';
       echo '<td>'.date(DATE_FORMAT, strtotime($stat->submitdate)).'</td>';
       echo '</tr>';
   }
?>
</table>
</div>

Jeff

I still didn't make it to make a similar page to yours with only 10 landings !!!!

Could you please tell me in a simple way (because I no almost nothing in coding) how you made your page work like that ?

look at mine http://www.cargoitaliavirtual.com/index.php/TouchdownStats/

thanks Jeff

Link to comment
Share on other sites

  • Administrators

Jeff

I still didn't make it to make a similar page to yours with only 10 landings !!!!

Could you please tell me in a simple way (because I no almost nothing in coding) how you made your page work like that ?

look at mine http://www.cargoitaliavirtual.com/index.php/TouchdownStats/

thanks Jeff

@maiochine

You have me lost at this point :blink: - who's code are you using? What I supplied to you for your custom pirep system or what Jeff gave you, which would be for the native pirep system. The limited number listings will have to be modified for your custom system, but if you are using the native system with the code from Jeff what is built in to the module will work.

Link to comment
Share on other sites

  • Administrators

Hi guys,

Is someone going to have a look if it's possible to get the average touchdown rate per pilot? And per month, year and all time? :-)

Please forigive me if someone is already working on this... :-)

Regards,

Lucas

It is possible to do, I have the module bringing all the data back - you can extend the code to include some more stats and functions if you would like. You can do a print_r to see what is coming back in your tpl file for you to use in your stats equations.

Link to comment
Share on other sites

@maiochine

You have me lost at this point :blink: - who's code are you using? What I supplied to you for your custom pirep system or what Jeff gave you, which would be for the native pirep system. The limited number listings will have to be modified for your custom system, but if you are using the native system with the code from Jeff what is built in to the module will work.

Hey Big Boss ! :D

I'm using the codes you gave me

<?php 
   foreach($stats as $stat) 
   { 
       echo '<tr>'; 
       echo '<td>'.$stat->PilotName.'</td>'; 
       echo '<td>'.$stat->AircraftName.'</td>'; 
       echo '<td>'.$stat->ArrivalIcaoName.'</td>'; 
       echo '<td>'.$stat->TouchDownVertSpeedFt.'</td>'; 
       echo '<td>'.$stat->datestamp.'</td>'; 
               echo '</tr>'; 
   } 
?> 

this code worked perfectly :) I only need to know hoe to limit the stats for monthly stats and top 5 and Im aaaaaaaaaaaaaaaaal done ;)

Tanks again Simpilot

Link to comment
Share on other sites

These are the codes I have in their entirety:

TouchdownStats.php (located in public_html/core/modules/TouchdownStats/TouchdownStats.php)

<?php
//simpilotgroup addon module for phpVMS virtual airline system
//
//simpilotgroup addon modules are licenced under the following license:
//Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
//To view full license text visit http://creativecommons.org/licenses/by-nc-sa/3.0/
//
//@author David Clark (simpilot)
//@copyright Copyright (c) 2009-2010, David Clark
//@license http://creativecommons.org/licenses/by-nc-sa/3.0/

class TouchdownStats extends CodonModule {

   public function index() {
       $this->set('stats', TouchdownStatsData::get_all_stats('10'));
       $this->show('touchdownstats/touchdownstats_index.tpl');
   }

   public function top_landings($howmany)  {
       $this->set('stats', TouchdownStatsData::get_stats($howmany));
       $this->show('touchdownstats/touchdownstats_index.tpl');
   }
}

touchdownstats_index.tpl (located in public_html/core/templates/touchdownstats/touchdownstats_index.tpl)

<div class="mcright">
<?php
//simpilotgroup addon module for phpVMS virtual airline system
//
//simpilotgroup addon modules are licenced under the following license:
//Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
//To view full license text visit http://creativecommons.org/licenses/by-nc-sa/3.0/
//
//@author David Clark (simpilot)
//@copyright Copyright (c) 2009-2010, David Clark
//@license http://creativecommons.org/licenses/by-nc-sa/3.0/
?>
<table width="100%" border="1" bordercolor="#FFFFFF" class="tablesorter" id="tabledlist">
<tr align="center" valign="middle" bgcolor="#0079B2">
       <td>Pilot</td>
       <td>Aircraft</td>
       <td>Arrival Field</td>
       <td>Landing Rate</td>
       <td>Date Flown</td>
   </tr>
<?php
   foreach($stats as $stat)
   {
       $pilot = PilotData::getPilotData($stat->pilotid);
       $aircraft = OperationsData::getAircraftInfo($stat->aircraft);
       echo '<tr align="center" valign="middle" bgcolor="#DFF4FF">';
       echo '<td>'.PilotData::getPilotCode($pilot->code, $pilot->pilotid).' - '.$pilot->firstname.' '.$pilot->lastname.'</td>';
       echo '<td>'.$aircraft->fullname.'</td>';
       echo '<td>'.$stat->arricao.'</td>';
       echo '<td>'.$stat->landingrate.'</td>';
       echo '<td>'.date(DATE_FORMAT, strtotime($stat->submitdate)).'</td>';
       echo '</tr>';
   }
?>
</table>
</div>

Now just link to it. I use: http://www.oneworldvs.net/index.php/TouchdownStats/top_landings/10

Link to comment
Share on other sites

It is possible to do, I have the module bringing all the data back - you can extend the code to include some more stats and functions if you would like. You can do a print_r to see what is coming back in your tpl file for you to use in your stats equations.

OK. i'll see if i can get this thing working. If i have it working, i'll post it here :-)

Thanks guys

Lucas

Link to comment
Share on other sites

OK. i am officially lost now.

I want to show the average landing rate per pilot. Now i have created this query that is very basic and simple but it shows what i need.

It's this:

SELECT (phpvms_pilots.firstname), (phpvms_pilots.lastname) AS Name, avg(phpvms_pireps.landingrate) AS Average_Landingrate

FROM phpvms_pilots

INNER JOIN phpvms_pireps ON phpvms_pireps.pilotid = phpvms_pilots.pilotid

GROUP BY phpvms_pilots.pilotid

ORDER BY phpvms_pireps.landingrate DESC

i was looking at the simpilot module but i really am lost and i don't even know where to start getting different data.

Is it possible to execute the query above? how can i do that?

thanks in advance.. again, :-)

Lucas

Link to comment
Share on other sites

  • Administrators

@maiochine

To use the limit with your database table you will need to change the function within TouchdownStats.php ->

This ->

public function get_stats($howmany) {
       $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`
                   WHERE landingrate < '0'
                   ORDER BY landingrate DESC
                   LIMIT $howmany";

       return DB::get_results($query);
   }

Needs to change to ->

public function get_stats($howmany) {
       $query = "SELECT * FROM flights
                   WHERE TouchDownVertSpeedFt < '0'
                   ORDER BY TouchDownVertSpeedFt DESC
                   LIMIT $howmany";

       return DB::get_results($query);
   }

Link to comment
Share on other sites

  • Administrators

OK. i am officially lost now.

I want to show the average landing rate per pilot. Now i have created this query that is very basic and simple but it shows what i need.

It's this:

SELECT (phpvms_pilots.firstname), (phpvms_pilots.lastname) AS Name, avg(phpvms_pireps.landingrate) AS Average_Landingrate

FROM phpvms_pilots

INNER JOIN phpvms_pireps ON phpvms_pireps.pilotid = phpvms_pilots.pilotid

GROUP BY phpvms_pilots.pilotid

ORDER BY phpvms_pireps.landingrate DESC

i was looking at the simpilot module but i really am lost and i don't even know where to start getting different data.

Is it possible to execute the query above? how can i do that?

thanks in advance.. again, :-)

Lucas

Add this to TouchdownstatsData ->

public function pilot_stats($pilotid)   {
       $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`
                   WHERE landingrate < '0'
                   AND pilotid = '$pilotid'
                   ORDER BY landingrate DESC";

       return DB::get_results($query);
   }

   public function pilot_average($pilotid) {
       $stats = self::pilot_stats($pilotid);
       $total = 0;
       $count = 0;

       foreach ($stats as $stat)
           {
           $total = $total + $stat->landingrate;
           $count++;
       }
       $average = $total / $count;

       return $average;
   }

   public function airline_average() {
       $stats = self::get_all_stats();
       $total = 0;
       $count = 0;

       foreach ($stats as $stat)
           {
           $total = $total + $stat->landingrate;
           $count++;
       }
       $average = $total / $count;

       return $average;
   }

Then where you want to show a pilots average do ->

<?php echo 'Pilot average landing rate '.TouchdownStatsData::pilot_average('pilot#'); ?>

and replace pilot# with the database id for the pilot you want to show the stat for - ie in pilot_public_profile it would be $userinfo->pilotid

or for the VA's average ->

<?php echo 'VA average landing rate '.TouchdownStatsData::airline_average(); ?>

Link to comment
Share on other sites

@JEFF

I tried your script but still didn't manage to get only TOP TEN look at the result !!!

http://www.cargoitaliavirtual.com/index.php/TouchdownStats/top_landings/10

I tried your .tpl code but it doesn't work so Im using this code now

<?php
//simpilotgroup addon module for phpVMS virtual airline system
//
//simpilotgroup addon modules are licenced under the following license:
//Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
//To view full license text visit http://creativecommons.org/licenses/by-nc-sa/3.0/
//
//@author David Clark (simpilot)
//@copyright Copyright (c) 2009-2010, David Clark
//@license http://creativecommons.org/licenses/by-nc-sa/3.0/
?>
<table width="100%" border="1" bordercolor="#FFFFFF" class="tablesorter" id="tabledlist">
<tr align="center" valign="middle" bgcolor="#0079B2">

       <td>Pilot</td>
       <td>Aircraft</td>
       <td>Arrival Field</td>
       <td>Landing Rate</td>
       <td>Date Posted</td>
   </tr>
<?php 
   foreach($stats as $stat) 
   { 
       echo '<tr>'; 
       echo '<td>'.$stat->PilotName.'</td>'; 
       echo '<td>'.$stat->AircraftName.'</td>'; 
       echo '<td>'.$stat->ArrivalIcaoName.'</td>'; 
       echo '<td>'.$stat->TouchDownVertSpeedFt.'</td>'; 
       echo '<td>'.$stat->datestamp.'</td>'; 
               echo '</tr>'; 
   } 
?> 
</table>

would you please help me out with this ... im trying to make a table similare to the one below please could you tell me how to do that ? I'm not a professional coder, of course the blured area contain Pilot Name date of lfight and departure/destination :(

statstable.jpg

Link to comment
Share on other sites

So this is my touchdownstats file:

<?php

//simpilotgroup addon module for phpVMS virtual airline system

//

//simpilotgroup addon modules are licenced under the following license:

//Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)

//To view full license text visit http://creativecommons.org/licenses/by-nc-sa/3.0/

//

//@author David Clark (simpilot)

//@copyright Copyright © 2009-2010, David Clark

//@license http://creativecommons.org/licenses/by-nc-sa/3.0/

class TouchdownStatsData extends CodonData {

public function pilot_stats($pilotid) {

$query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`

WHERE landingrate < '0'

AND pilotid = '$pilotid'

ORDER BY landingrate DESC";

return DB::get_results($query);

}

public function pilot_average($pilotid) {

$stats = self::pilot_stats($pilotid);

$total = 0;

$count = 0;

foreach ($stats as $stat)

{

$total = $total + $stat->landingrate;

$count++;

}

$average = $total / $count;

return $average;

}

public function airline_average() {

$stats = self::get_all_stats();

$total = 0;

$count = 0;

foreach ($stats as $stat)

{

$total = $total + $stat->landingrate;

$count++;

}

$average = $total / $count;

return $average;

}

public function get_all_stats() {

$query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`

WHERE landingrate < '0'

ORDER BY landingrate DESC";

return DB::get_results($query);

}

public function get_stats($howmany) {

$query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`

WHERE landingrate < '0'

ORDER BY landingrate DESC

LIMIT $howmany";

return DB::get_results($query);

}

}

and the error message that i get is:

Warning: Invalid argument supplied for foreach() in /home/seriousa/public_html/core/common/TouchdownStatsData.class.php on line 28

Warning: Division by zero in /home/seriousa/public_html/core/common/TouchdownStatsData.class.php on line 33

Pilot average landing rate 2

any idea's on this issue?

Thanks again guys!

Lucas

Link to comment
Share on other sites

  • Administrators

@MrAmsterdam

Without a link it is hard to tell, but my guess is that you are not passing a pilot id to the function so it does not know what to look for in the database and is returning an empty variable.

Read my post here -> http://forum.phpvms.net/topic/2989-touchdownstats-10/page__view__findpost__p__21572 for this additional code and make sure you are calling the data as specified, I imagine the label 'pilot#' has not been replaced with a variable.

Link to comment
Share on other sites

Hi,

I used this:

<?php echo 'Pilot average landing rate '.round(TouchdownStatsData::pilot_average('1'), 2); ?>

and then i get the error message. Maybe you can have a look at http://serious-airlines.com/index.php/pages/averagelandingrate

there is the error message.

I can't seem to understand where i am messing stuff up... :-(

Sorry for being a pain in the a$$

Lucas

Link to comment
Share on other sites

  • Moderators

@JEFF

I tried your script but still didn't manage to get only TOP TEN look at the result !!!

http://www.cargoitaliavirtual.com/index.php/TouchdownStats/top_landings/10

I tried your .tpl code but it doesn't work so Im using this code now

<?php
//simpilotgroup addon module for phpVMS virtual airline system
//
//simpilotgroup addon modules are licenced under the following license:
//Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
//To view full license text visit http://creativecommons.org/licenses/by-nc-sa/3.0/
//
//@author David Clark (simpilot)
//@copyright Copyright (c) 2009-2010, David Clark
//@license http://creativecommons.org/licenses/by-nc-sa/3.0/
?>
<table width="100%" border="1" bordercolor="#FFFFFF" class="tablesorter" id="tabledlist">
<tr align="center" valign="middle" bgcolor="#0079B2">

       <td>Pilot</td>
       <td>Aircraft</td>
       <td>Arrival Field</td>
       <td>Landing Rate</td>
       <td>Date Posted</td>
   </tr>
<?php 
   foreach($stats as $stat) 
   { 
       echo '<tr>'; 
       echo '<td>'.$stat->PilotName.'</td>'; 
       echo '<td>'.$stat->AircraftName.'</td>'; 
       echo '<td>'.$stat->ArrivalIcaoName.'</td>'; 
       echo '<td>'.$stat->TouchDownVertSpeedFt.'</td>'; 
       echo '<td>'.$stat->datestamp.'</td>'; 
               echo '</tr>'; 
   } 
?> 
</table>

would you please help me out with this ... im trying to make a table similare to the one below please could you tell me how to do that ? I'm not a professional coder, of course the blured area contain Pilot Name date of lfight and departure/destination :(

statstable.jpg

Looks like you got that from thomsonvirtual :)

Link to comment
Share on other sites

  • Administrators

Hi,

I used this:

<?php echo 'Pilot average landing rate '.round(TouchdownStatsData::pilot_average('1'), 2); ?>

and then i get the error message. Maybe you can have a look at http://serious-airlines.com/index.php/pages/averagelandingrate

there is the error message.

I can't seem to understand where i am messing stuff up... :-(

Sorry for being a pain in the a$$

Lucas

Check your pilots table to see if there is actually a pilot with pilotid 1 - Do you have an offset set or something? - This code works on my development site, my va, and all the other va's that have installed it. Try using pilot id 2.

Link to comment
Share on other sites

Check your pilots table to see if there is actually a pilot with pilotid 1 - Do you have an offset set or something? - This code works on my development site, my va, and all the other va's that have installed it. Try using pilot id 2.

Simpilot,

No, as far as i know i have a standard installation with a skin installed. i can't recall doing anything really special...

when i go into the sql database and run this query i get a result back...

select * from phpvms_pilots WHERE pilotid = 1;

i get the name of the pilot that is using pilotid nr 1. (it's me :-) )

Regards,

Lucas

Link to comment
Share on other sites

@JEFF

Here's my TouchdownStats.php

<?php
//simpilotgroup addon module for phpVMS virtual airline system
//
//simpilotgroup addon modules are licenced under the following license:
//Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
//To view full license text visit http://creativecommons.org/licenses/by-nc-sa/3.0/
//
//@author David Clark (simpilot)
//@copyright Copyright (c) 2009-2010, David Clark
//@license http://creativecommons.org/licenses/by-nc-sa/3.0/

class TouchdownStats extends CodonModule {

   public function index() {
       $this->set('stats', TouchdownStatsData::get_all_stats('10'));
       $this->show('touchdownstats/touchdownstats_index.tpl');
   }

   public function top_landings($howmany)  {
       $this->set('stats', TouchdownStatsData::get_stats($howmany));
       $this->show('touchdownstats/touchdownstats_index.tpl');
   }
}

If there's anything else please tell me !

Link to comment
Share on other sites

Just so you know, through trial and error, I used this code on on the header.tpl to reflect the VA's average stats to 2 decimal places. Thanks Jeff for all your help. Not sure if this is the 'clean' way of doing it, but:

<strong>Avg Landing Rate: </strong><?php echo ''.round(TouchdownStatsData::airline_average('airline'), 2); ?>

vastats.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...