Jump to content

Recommended Posts

Posted

Hi, This problem is because you don't have flights.

Kind Regards.

i have flight with pirep accept, but the situation not change :(

maybe the table will only work with the new flights in pending ? I feel :P

Posted

@fsx, does the db table have anything in the landing rate column?

Hello Simpilot, I am the person who commissioned the work redesign (tcaf) :D

As you can see I have canceled flights and pirep, but if you need a flight and I can show you the result

  • 1 month later...
Posted

Hi all,

Keep getting this error all uploaded to correct files not sure what to do any help will be appreciated I am using kACARS so I know the landing rate is there.

here is the error

Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\lib\skins\detachable\frontpage_main.tpl on line 33

I can link to the landing rates when I use http://www.angelairva.co.uk/index.php/Touchdownstats

But I just can not get it to show on the Frontpage.

here is the code I am putting on my Frontpage.TPL

<?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="1px">
   <tr>
       <td>Pilot</td>
       <td>Aircraft</td>
       <td>Arrival Field</td>
       <td>Landing Rate</td>
       <td>Date Posted</td>
   </tr>
<?php
   foreach($stats as $stat)
   {
       $pilot = PilotData::getPilotData($stat->pilotid);
       $aircraft = OperationsData::getAircraftInfo($stat->aircraft);
       echo '<tr>';
       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></p>

Thanks in advance

Scott

  • Administrators
Posted

How are you including it on your frontpage?

something like

<?php MainController::run('touchdownstats', 'index'); ?>

should be all you need if the data is there.

Posted

How are you including it on your frontpage?

something like

<?php MainController::run('touchdownstats', 'index'); ?>

should be all you need if the data is there.

Damn that was quick Dave!!! :D

Will give it a try

Thanks again

Scott

  • 2 weeks later...
Posted

Hi there,

I have Helicopters, as well as Aircraft in my fleet, and the fixed wing pilots are sarting to omplain that the Heli guys is unfair with landing rates.

Is there a way I can seperate the landing rate stats for each aircraft, OR maybe each Airline at least?

Thanks very much!

Jakes

  • Administrators
Posted

The easiest thing to to do would be seperate them by airline if you have that in place already.

You could add a function to the model like:

public function get_airline_stats($airline) {
       $query = "SELECT * FROM `".TABLE_PREFIX."pireps`
                   WHERE landingrate < '0'
                   AND code = '$airline'
                   ORDER BY landingrate DESC";

       return DB::get_results($query);
   }

Posted

Ok, I have added the code you provided to /core/common/TouchdownStatsData.class.php, and then, I get the following error:

Warning: Invalid argument supplied for foreach() in /home/jdsarcco/public_html/uvsaaf/core/templates/touchdownstats/touchdownstats_index.tpl on line 21

What do I miss?

When I enter a statistic value for example 10, it work perfect, but with an airline code, I also get this error.

Link to first 10 stats: http://uvsaaf.fsworld.co.za/index.php/TouchdownStats/top_landings/10'>http://uvsaaf.fsworld.co.za/index.php/TouchdownStats/top_landings/10

Link to error: http://uvsaaf.fsworld.co.za/index.php/TouchdownStats/top_landings/

I guess this should work when placing the airline code instead? here are some of the airlines (Squadrons) we operate:

CEF Central Flying School Langebaaan

CFS 85 Combat Flying School

FFS 44 Squadron

FTS 15 Squadron

HFS 87 Helicopter Flying School

Thank you,

Jakes

  • Administrators
Posted

Can you post your controller and data class to paste bucket so I can see what it is trying to do. I think you are just not assigning the variable in the controller function, not sure though.

  • 2 weeks later...
  • Moderators
Posted

You could add a couple new functions to the module and data class

Maybe something like this in your module file

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

And something like this in your data class

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

       return DB::get_results($query);
   }

Hi Simpilot

Is it possible to change the code to find the lowest or highest between the landing rates and show them as the best and the worst on daily PIREPS?

Thanks

  • Administrators
Posted

You can use the above referenced function and just ask for 1 return, that would give you the worst, then add a WHERE DAY(submitdate) = DAY(NOW()) or something like that into the function to granb the worst from that day. You will have to code for the reality of no data at all being found as well to avoid a foreach loop error.

Posted

I keep getting the error:

Invalid argument supplied for foreach() in C:\xampp\htdocs\vms\core\common\TouchdownStatsData.class.php on line 44

When I try to call the average landing rate of the pilot.

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

is the code I have in the TouchdownStatsData.class

and

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

I am using in the template.

I can get the average ailine rate fine....just not the pilot rate.

I am stumped.

(line 44 is the second foreach call

  • Moderators
Posted

You can use the above referenced function and just ask for 1 return, that would give you the worst, then add a WHERE DAY(submitdate) = DAY(NOW()) or something like that into the function to granb the worst from that day. You will have to code for the reality of no data at all being found as well to avoid a foreach loop error.

Hello Simpilot

Just wanted to thank you for this and let you know that I managed the coding and it's now working like a charm. Here is my site for reference : www.alvandair.com

Thanks again

Cheers

  • Moderators
Posted

Dave sorry if this has been covered already i got to page 7 and it was nearly there but not quite.

What im after is to display the top xx pilots in average landing rate order, so Pilot name, Average landing rate, limited to 10.

I have all their averages listed on my pilots list ok but just want a table with the top 10 pilots sorted with the best average landing rate.

Cheers.

  • Administrators
Posted

How about something like this Mark;

Add to TouchdownstataData.class.php

  function get_averages($howmany) {

       $avg = array();

       $pilots = PilotData::findPilots(array('retired' => '0'));

       foreach($pilots as $pilot)
           {
               $query = "SELECT AVG(landingrate) as average, pilotid FROM ".TABLE_PREFIX."pireps WHERE landingrate < '0' AND pilotid='$pilot->pilotid'";
               $result = DB::get_row($query);
               if($result->pilotid != '')
               {$avg[] = $result;}
           }

       rsort($avg);

       return array_slice($avg, '0', $howmany);
   }

Add to TouchdownStats.php

   function averages($howmany)   {
       $this->set('stats', TouchdownStatsData::get_averages($howmany));
       $this->show('touchdownstats/touchdownstats_averages.tpl');
   }

Add a new template in core/templates/touchdownstats called touchdownstats_averages.tpl

<h3>Best Average Landing Rate</h3>
<?php
if($stats)
{
   echo '<table>';
   echo '<tr>';
   echo '<th>Landing Rate</th>';
   echo '<th>Pilot</th>';
   echo '</tr>';
       foreach($stats as $stat)
       {
           $pilot = PilotData::getPilotData($stat->pilotid);
           echo '<tr>';
           echo '<td>'.round($stat->average, 1).'</td>';
           echo '<td>'.PilotData::getPilotCode($pilot->code, $pilot->pilotid).' - '.$pilot->firstname.' '.$pilot->lastname.'</td>';
           echo '</tr>';
       }
   echo '</table>';
}
else
{
   echo 'No Stats Available';
}
?>

Then call it by url and pass how many records you want as the last element

http://www.yoursite.com/index.php/touchdownstats/averages/10

or within another template

<?php MainController::run('touchdownstats', 'averages', '10'); ?>

  • Moderators
Posted

My error, I put the template in the wrong folder :)

All i want to do now is count and display the number of flights for each pilot and im there :)

I have tried the usual $userinfo but cant get it to display anything, would i need to update the query?

  • Administrators
Posted

Try changing the query to;

$query = "SELECT AVG(landingrate) as average, SUM(*) as flights, pilotid FROM ".TABLE_PREFIX."pireps WHERE landingrate < '0' AND pilotid='$pilot->pilotid'";

And you should get the number of flights back with the array;

$stat->flights

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