Jump to content

Recommended Posts

Posted

Hi. You should read through the various pages in this thread. There is a way to make it show only the last X amount of months stats. I don't recall what page it is on though. I know for a fact it works. I use it on my site. ;)

Posted

Warning: Invalid argument supplied for foreach() in /home1/akariyou/public_html/aivirtual/core/templates/tp_index.tpl on line 24

Warning: Invalid argument supplied for foreach() in /home1/akariyou/public_html/aivirtual/core/templates/tp_index.tpl on line 42

What is this?.. please help me!

  • 1 month later...
Posted

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

  • 1 month later...
  • Administrators
Posted

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.

  • Moderators
Posted
  On 8/16/2011 at 1:03 PM, simpilot said:

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
  • Administrators
Posted

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.

  • Moderators
Posted
  On 8/17/2011 at 1:39 AM, simpilot said:

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.

  • Moderators
Posted
  On 8/17/2011 at 1:57 PM, parkho said:

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! :(

  • Administrators
Posted

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?

  • Moderators
Posted
  On 8/17/2011 at 10:09 PM, simpilot said:

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?

  • Moderators
Posted
  On 8/20/2011 at 7:32 PM, simpilot said:

When you call it in your template, you will need to assign data to the $month and $year variable -> ie '8', '2011'

Ok thanks I'll see what i can do. ;)

  • Moderators
Posted

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);
   }

  • 2 weeks later...
Posted

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

  • Administrators
Posted

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.

Posted
  On 9/1/2011 at 2:22 AM, simpilot said:

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

  • 2 weeks later...
Posted

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

  • Administrators
Posted

All you should get when you refresh the stats is a blank page, all it is doing is populating the database. When you go back to the top pilot index the data should be showing as long as their are ACARS submitted PIREPs in the database.

Posted

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

  • 4 weeks later...
Posted

getting this error

Warning: Invalid argument supplied for foreach() in /****/*****/*******/******/core/templates/tp_index.tpl on line 24

Warning: Invalid argument supplied for foreach() in /****/*****/*******/******/core/templates/tp_index.tpl on line 41

  • Administrators
Posted
  On 10/11/2011 at 11:13 AM, PIAS2011 said:

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?

Posted
  On 10/11/2011 at 11:23 AM, simpilot said:

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

  • Moderators
Posted

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);
   }
}

  • Administrators
Posted
  On 10/11/2011 at 6:23 PM, PIAS2011 said:

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.

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.

×
×
  • Create New...