Jump to content

TOPPilot beta 1.0


simpilot

Recommended Posts

  • 1 month later...

hello,

I have installed phpvms to have many automated, but I have seen that to obtain the best I have to use php and phpmyadmin. In the readme you write "use the file to create the table top_flights.sql needed in your sql database using phpmyadmin or similar." I understand that it is not a course in phpmyadmin but you can tell me the steps to do this, preferably with pictures?

I installed the application without this step and this is the result http://www.tcaf.it/phpvms/index.php/toppilot

So without pirep although flights have been made and accepted pirep

thanks thanks thanks

edit: SOLVED sorry

Link to comment
Share on other sites

  • 1 month later...
  • Administrators

You could try something like this in your data class;

   public function get_monthly_landingrate($month, $year, $howmany) {
       $query = "SELECT * FROM ".TABLE_PREFIX."pireps WHERE MONTH(submitdate) = '$month' AND YEAR(submitdate) = '$year' ORDER BY landingrate DESC LIMIT '$howmany'";

       return DB::get_results($query);
   }

Just wrote this and did not test it you may have to adjust it a little.

Link to comment
Share on other sites

  • Moderators

You could try something like this in your data class;

   public function get_monthly_landingrate($month, $year, $howmany) {
       $query = "SELECT * FROM ".TABLE_PREFIX."pireps WHERE MONTH(submitdate) = '$month' AND YEAR(submitdate) = '$year' ORDER BY landingrate DESC LIMIT '$howmany'";

       return DB::get_results($query);
   }

Just wrote this and did not test it you may have to adjust it a little.

Thank you Simpilot

Is it possible to implement this into TouchdownStats module?

Cheers

  • Like 1
Link to comment
Share on other sites

  • Administrators

You can put it in any of the data class models really, where ever you would like it. If you put it in the touchdowndata.class.php file you can then just call it in your controller or view using;

<?php $variable = TouchdownStatsData::get_monthly_landingrate('month', 'year', 'howmany'); ?>

Then the $variable will be filled with your array to build your table with.

Link to comment
Share on other sites

  • Moderators

You can put it in any of the data class models really, where ever you would like it. If you put it in the touchdowndata.class.php file you can then just call it in your controller or view using;

<?php $variable = TouchdownStatsData::get_monthly_landingrate('month', 'year', 'howmany'); ?>

Then the $variable will be filled with your array to build your table with.

Thanks a lot

I'll give it a try see what happens.

Link to comment
Share on other sites

  • Moderators

Thanks a lot

I'll give it a try see what happens.

Hi Simpilot

ok here is what I did:

1. I added the public function to TouchDownStats.class.data

2. The I changed the code of my table to the following:

<?php
   $stats = TouchdownStatsData::get_monthly_landingrate($month, $year, '2'); <====== Here!
   foreach($stats as $stat)
   {

       $pilot = PilotData::getPilotData($stat->pilotid);
       $aircraft = OperationsData::getAircraftInfo($stat->aircraft);
       echo '<tr>';
       echo '<td align="center">'.$pilot->firstname.' '.$pilot->lastname.'</td>';
       echo '<td align="center">'.$aircraft->name.'</td>';

       echo '<td align="center"><font color="red">'.$stat->landingrate.'   ft/m</font></td>';

       echo '</tr>';

   }
?>

But I get this error:

Warning: Invalid argument supplied for foreach() in /home/alvandai/domains/alvandair.com/public_html/lib/skins/aqua/frontpage_main.tpl on line 204

and the table is empty.

I don't know where I'm doing it wrong! :(

Link to comment
Share on other sites

  • Moderators

Are you passing the month and year to the $month and $year variables?

If so, are there any PIREPS with landing rates for the month and year you are passing?

Well I just added the function to the Class and called it in my .tpl, does it mean that I have to assign the month and the year in the module?

Link to comment
Share on other sites

  • Moderators

As an example i display then using the current month in php so,

Template Code

      <h3>Top 10 Landings for <?php echo date("F Y");?></h3> 
<?php MainController::Run('TouchdownStats', 'top_landing_this_month'); ?><br />

Module code

//added By Mark Grant 03-02-2011
public function get_stats_by_cur_month () {
       $query =  "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`
              WHERE landingrate < '0' 
		AND MONTH(submitdate)=MONTH(now())
		AND YEAR(submitdate)=YEAR(now())
		ORDER BY landingrate DESC
		LIMIT 10";

return DB::get_results($query);
   }

Link to comment
Share on other sites

  • 2 weeks later...

Hello All...

I searched the forum for a reply...guess i was not able to find it...

I get the following error:

Warning: Invalid argument supplied for foreach() in ..../public_html/PIREP/core/templates/tp_index.tpl

when i go to ..../PIREP/index.php/TopPilot

Any suggestions much appreciated

Thank you

Link to comment
Share on other sites

It could be a couple of things.

- Did you rn the function to populate the table with data initially?

- Are any of your pireps recorded using an ACARS client? It will not calculate manual PIREPs.

Thank you for your reply...

I guess since i am not using this php for FG, i am not using ACARS, It is more of manual PIREPs. As such i guess that is why it did not work.

Thank you for your replies

http://www.cresdernixrof.com/PIREP

cheers

Link to comment
Share on other sites

  • 2 weeks later...

G'day Simpilot,

I can't get this module to populate the table withing my database, im using phpvms v2.1.934

When i go to (mysite Qantas VA)/index.php/TopPilot/refresh_pilot_stats, it just shoes a blank page, i seen that this was initially created for 2.0.874, is that the reason it isn't working?

If that's the case, how's v2.0 coming along :D

Cheers

Tylor

Link to comment
Share on other sites

G'day Simpilot,

Ok i found the problem, i have custom database names, so i needed to redirect it to them, now i am having trouble displaying info, i want to display the top 5 pilots with the greatest number of hours for a month

i have this, but am sure the syntax is wrong

<?php echo TopPilotData::top_pilot_flights(08, 2011, 5) ?>

my other question. Is it possible to have automatically start display statistics for the previous month, so i don't have to go in and change it every month, i am aiming of showing the previous month's stats.

Thanks

Tylor

Link to comment
Share on other sites

  • 4 weeks later...
  • Administrators

bump please someone kindly respond to my error that i am receiving.

This has been addressed a number of times in this thread.

Some possibilities include;

Did you run the script to populate the table as in the directions?

Do you have any PIREPS recorded in the database?

Did you install the new mysql table in your database?

Link to comment
Share on other sites

This has been addressed a number of times in this thread.

Some possibilities include;

Did you run the script to populate the table as in the directions?

Do you have any PIREPS recorded in the database?

Did you install the new mysql table in your database?

1. YES

2. YES

3. YES

But my phpvms sql has a different prefix

Link to comment
Share on other sites

  • Moderators

Then if that is the problem you will need to edit the following to your prefix, Core Common TopPilotData.class.php

Look at the top and change, FROM phpvms_pireps to your prefix or for a universal fix,

FROM `" . TABLE_PREFIX .

<?php
//by:simpilot
//www.simpilotgroup.com
class TopPilotData extends CodonData $query = "SELECT * FROM phpvms_pireps
{
   public function get_monthly_stats($month, $year) {
       $query = "SELECT * FROM phpvms_pireps WHERE MONTH(submitdate) = '$month' AND YEAR(submitdate) = '$year'";

       return DB::get_results($query);
   }

   public function record_stats($pilot_id, $totalflights, $totaltime, $totalmiles, $startmonth, $startyear) {
       $query = "INSERT INTO top_flights (pilot_id, flights, hours, miles, month, year)
               VALUES('$pilot_id', '$totalflights', '$totaltime', '$totalmiles', '$startmonth', '$startyear')";

       DB::query($query);
   }

   public function clear_table()   {
       $query = "TRUNCATE TABLE top_flights";

       DB::query($query);
   }

   public function top_pilot_flights($month, $year, $howmany)    {
       $query = "SELECT * FROM top_flights WHERE month='$month' AND year='$year' ORDER BY flights DESC LIMIT $howmany";

       return DB::get_results($query);
   }

   public function top_pilot_hours($month, $year, $howmany)    {
       $query = "SELECT * FROM top_flights WHERE month='$month' AND year='$year' ORDER BY hours DESC LIMIT $howmany";

       return DB::get_results($query);
   }

   public function top_pilot_miles($month, $year, $howmany)    {
       $query = "SELECT * FROM top_flights WHERE month='$month' AND year='$year' ORDER BY miles DESC LIMIT $howmany";

       return DB::get_results($query);
   }

   public function alltime_flights ($howmany)  {
       $query = "SELECT pilotid, totalflights FROM phpvms_pilots ORDER BY totalflights DESC LIMIT $howmany";

       return DB::get_results($query);
   }

   public function alltime_hours ($howmany)  {
       $query = "SELECT pilotid, totalhours FROM phpvms_pilots ORDER BY totalhours DESC LIMIT $howmany";

       return DB::get_results($query);
   }
}

Link to comment
Share on other sites

  • Administrators

Still getin the same error!

Did you try to populate the database again after changing the table prefix? If so, is there anything in the new top_pilots table? If there is, do a print_r or var_dump in the template for the variable and see what comes out. That will show if there is any data available and guide you on where to look for the problem.

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...