Jump to content
simpilot

TOPPilot beta 1.0

Recommended Posts

TOPPilot beta 1.0

phpVMS module to extract monthly flight statistics for individual pilots from your phpVMS based virtual airline.

Developed by:

simpilot

www.simpilotgroup.com

Developed on:

phpVMS 2.0.874

php 5.2.11

mysql 5.0.51

apache 2.2.11

Included files:

readme.txt

top_flight.sql

TopPilot.php

TpPilotData.class.php

tp_index.tpl

tp_previous.tpl

Install:

-Download the attached package.

-unzip the package and place the files as structured in your root phpVMS install.

-use the top_flights.sql file to create the table needed in your sql database using phpmyadmin or similar.

-after the initial install point your browser to yoursite/index.php/TopPilot/refresh_pilot_stats one time. This will populate the database table with any data available.

-to view the main TopPilot index create a link yoursite/index.php/TopPilot

-everytime a pirep is filed the module will recalculate the pilot stats and update the database

There are three main display functions within the TopPilotData class that you can configure to use in various parts of your site.

Flights flown - TopPilotData::top_pilot_flights($month, $year, 5)
Hours flown -  TopPilotData::top_pilot_hours($month, $year, 5)
Miles flown - TopPilotData::top_pilot_miles($month, $year, 5)

$month should be the two digit month id of the month you want data from – ie 06 = June

$year is the four digit year you are pulling – ie 2010

5 – can be changed to how many records you want returned.

Excluding PIREPS that are not accepted yet.

TopPilot.php line 52.

Uncomment the trailing section and the module will not include unapproved PIREPS. Doing this will cause the module not to display any newly accepted PIREPS in the TopPilot data listings until after another PIREP is filed although you can refresh the stats at anytime using – yoursite/index.php/TopPilot/refresh_pilot_stats

Although this script carries no limits of use a link back to www.simpilotgroup.com would be greatly appreciated!

Have fun!

Hi, I have installed everything, but the current month's statistics are not published, says that I have nothing filed, how I can fix this please?

sorry for the picture in spanish, but my website is in spanish.

post-813-013699100 1288454192_thumb.png

Share this post


Link to post
Share on other sites

Do you have PIREPS filed for the month?

I have a question, the reports is filed is when are approved, or as it is cheap is archived?

and if that's not the way to archive, as it should do please?

Share this post


Link to post
Share on other sites

I have a question, the reports is filed is when are approved, or as it is cheap is archived?

and if that's not the way to archive, as it should do please?

Not exactly sure what you are asking but I think you are asking if the counts are made before or after the PIREP is accepted. The module currently counts all PIREPS that are pending or approved, the instructions and consequences are in the initial post of this thread.

Share this post


Link to post
Share on other sites

http://www.pashairvirtual.co.uk/index.php/TopPilot/get_old_stats?month=10&year=2010

Would it be possible to tell me which file i can put the <div class="mcright"> to align the stats.

thanks

Daniel

I dont know much about the template you are using but you seemed to have solved it back on the 28th of October here -> http://forum.phpvms.net/topic/2225-toppilot-beta-10/page__view__findpost__p__26295

There is also some good css tutorials pointed out by other users eariler in this thread starting here -> http://forum.phpvms.net/topic/2225-toppilot-beta-10/page__view__findpost__p__14916

Share this post


Link to post
Share on other sites

nope that was for the main page. I am talking about the current months. they are messed up and don't know where to put that div tag

thanks

Share this post


Link to post
Share on other sites

Hi. This is a really nice addon, really usefull, congrats!

I saw someone asked to translate months to german. I would like to make the same but translating it to spanish. the code to change it to german was change 'F' to '%B'. Which is the code to translate it to spanish?

Thanks you!!

Share this post


Link to post
Share on other sites

Well I am fine with English though I might consider supporting Spanish in the future. The "german" post says nothing about historical data. Somewhere it is suggested that the 1970 is because there is a PIREP with data set to 0 but I checked my database and there are no PIREP records (no flights have been filed yet).

My TopPilot table is also empty so I don't know at the moment where it gets that December 1969 as start year.

What I have done was to add this to your tp_index.tpl just before the while statement in the last part where it generates the historical data list. I don't know if it is correct because as I said, I have no pireps in my system. I just want to list the past 6 months. Now (dec. 2010) with no PIREPS I only get a single item (December 2010) listed in the historical data section.

// @DEGT Fixed problem with TopPilot returning data from 1969.
$monthsHistoryOffset = 6;	// up to 6 months back
$startyear = $today[year];
if ($today[mon] < $monthsHistoryOffset)
{
   $startyear--;
   $startmonth = 12 - $today[mon];
}

Perhaps it would be nice to make this configurable somewhere in the module. BTW is it the same to use $this->set(x,y) and Template::Set(x,y) ?

Share this post


Link to post
Share on other sites

The module is looking for the first filed pireps and when it does not find one it reverts back to the start of Unix time stamps which is 1/1/70, but with the 20 plus years of php experience you have previously thrown in my face I imagine you understand that. As far as supporting Spanish, that is up to you to modify, once again a veteran of your caliber should be able to accomplish this.

Share this post


Link to post
Share on other sites

The module is looking for the first filed pireps and when it does not find one it reverts back to the start of Unix time stamps which is 1/1/70, but with the 20 plus years of php experience you have previously thrown in my face I imagine you understand that. As far as supporting Spanish, that is up to you to modify, once again a veteran of your caliber should be able to accomplish this.

Indeed! only I haven't used PHP in a long long long time (so long I do not wish to remember :-) at a time in my life I left PHP and Unix behind and was lured into the dark waters of .NET and never came back to PHP (or Linux for that matter) until now. Just trying to get my VA up & running asap without having to spend much time coding. Many years ago I used VAdmin but it was poorly coded and incomplete and ended up ditching the project after I had recruited some 5 pilots.

Anyway, thanks for the modules, they have saved me quite some time, otherwise I think I would have simply forgotten about starting a VA again. A time saver indeed. I hope to share some of my simple modules when I get my other site up again (same reasons, I hate coding these days).

Share this post


Link to post
Share on other sites

To include transfer hours in the totals ->

open TopPilotData.class.php

find line 58

$query = "SELECT pilotid, totalhours FROM phpvms_pilots ORDER BY totalhours DESC LIMIT $howmany";

and change to

$query = "SELECT pilotid, totalhours, transferhours FROM phpvms_pilots ORDER BY totalhours DESC LIMIT $howmany";

Hello Dave,

I am busy with this one, but the problem is that it is orderd by totalhours instead of the the total sum of totalhours + transferhours.

How can I change?

Thank you in advange,

Regards,

Cor

Share this post


Link to post
Share on other sites

Something like

$query = "SELECT pilotid, (totalhours + transferhours) AS totalhours FROM phpvms_pilots ORDER BY totalhours DESC LIMIT $howmany";

will work. You can leave the

echo ($row->totalhours + $row->transferhours);

on line 70 of tp_index as

echo $row->totalhours;

because the sql call will already be adding and sorting the hours for you.

Share this post


Link to post
Share on other sites

Hello Dave,

It working almost. It adds the two times but then exactly. I have a total time now of 3540:99 (36:48 + 3514:51) So just a little adjustment needed and i will work like a charme.

Thank you in advange,

regards,

Cor

Share this post


Link to post
Share on other sites

The easiest fix would be to just round the number using number format

echo number_format($row->totalhours);

Or an equation could be written to collapse the tenths to minutes and add an hour to the total etc....

Share this post


Link to post
Share on other sites

Dave,

Found the solution, just used the Util::AddTime command to get the right total time

Regards,

Cor

Share this post


Link to post
Share on other sites

Hi ya Dave. Long time no chit chat man. Hope all is well your way. I really need to fire up MSN one of these days and say hello.

Anyhow, was just curious how 2.0 was looking in the future? I know it has been some time since you posted about it. I figure a few months was time enough to allow a friendly bump on the topic. :D Anyway, like I said, I was just curious is all.

Thanks for all the hard work you have done and do Dave. Much appreciated.

Ray

Share this post


Link to post
Share on other sites

Hey Dave,

Run into a little problem. I get for hours flown a total time of 9.68 ??. What do I need to change.

Tnx,

Regards,

Cor

Share this post


Link to post
Share on other sites

Are you using the Util::AddTime function? I thought that was supposed to change it all to minutes. Looks like it is in tenths to me, or the addition function is off.

Share this post


Link to post
Share on other sites

Hi Dave,

I haven´t change anything in the scripts. Also in the database top_flight it says 9.68. i am in the dark now :rolleyes:

Regards,

Cor

Share this post


Link to post
Share on other sites

Looking at the module the times are added as if they were tenths. It has been a while since I put this one together, looking at my install that must be why I round all the numbers for display. You will have to do some work to intergrate the native add time function into the module, but that would probably clear up the minutes versus tenths issue.

Share this post


Link to post
Share on other sites

I will have a look at it and try to change it. It will be a challenge :rolleyes:

Regards,

Cor

Share this post


Link to post
Share on other sites

Dave,

Found it. I have changed line 60 of toppilot.php into

$totaltime = Util::AddTime($totaltime, $pirep->flighttime);

regards,

Cor

Share this post


Link to post
Share on other sites

Dave, is there a simple way if adding the historical stats in to a dropdown list?

Would look much nicer as the list is starting to get a bit long now,

Cheers.

ut1.png

Share this post


Link to post
Share on other sites

You could replace the table and the php loop with this and it will give you a drop down with a go button;

<script type="text/javascript">
function submitForm() {
var list = document.navList.subMenu;
var page = list.options[ list.selectedIndex ].value;
if (page != "home")
window.location = page;
return false;
}
</script>

<form name="navList" onsubmit="return submitForm();">
<select name="subMenu">
<option value="home">Current Month</option>
<?php
           while ($startyear <= $today[year]):
               {
                   $month_name = date( 'F', mktime(0, 0, 0, $startmonth) );
                   echo '<option value="'.url('/TopPilot/get_old_stats?month='.$startmonth.'&year='.$startyear.'').'">'.$month_name.' - '.$startyear.'</option>';

                   //advance dates
       if ($startmonth == $today[mon] && $startyear == $today[year])
       {
           break;
       }
       if ($startmonth == 12)
       {
           $startyear++;
           $startmonth = 01;
       }
       else
       {
           $startmonth++;
                   }
           }
           endwhile;
           ?>
</select>
<input type="submit" value="Go" />
</form>

An example is at the bottom of the page here -> http://www.virtualaca.net/index.php/TopPilot

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×