Jump to content

VastatsData.class.php


simpilot

Recommended Posts

  • Administrators

Hello everyone,

I am in process of finishng up a new class for phpVMS that details statistics for your VA. I have attached a screenie from my development server with the stats that are built so far. Anyone have any suggestions for anything else you think a VA would like to have stats for?

Total - Flights, Pilots, and Hours are already built into the phpVMS app. The rest come out of the new class I am building.

Capture2.jpg

Link to comment
Share on other sites

  • Administrators

Test Release.... Tested with beta 741

Place the VastatsData.class.php in your core/common folder and run the sql file within the database that phpVMS is using.

Functions already built into phpVMS by Nabeel  :)

<?php echo StatsData::PilotCount(); ?>
<?php echo StatsData::TotalFlights(); ?>
<?php echo StatsData::TotalHours(); ?>

Additional functions available through VastatsData.class

<?php VastatsData::totalflightstoday(); ?>
<?php VastatsData::totalpaxcarried(); ?>
<?php VastatsData::totalfuelburned(); ?>
<?php VastatsData::totalmilesflown(); ?>
<?php VastatsData::totalaircraftinfleet(); ?>
<?php VastatsData::totalschedules(); ?>
<?php VastatsData::totalnewsitems(); ?>
<?php VastatsData::pagecounter(); ?>
<?php VastatsData::usersonline(); ?>

The next phpVMS release is to use sessions so the users online will be better served through that function when it comes available.

Post any issues or if you need help, please avoid pm's as there may be others that have the same problem and can be helped by an open post  ;)

I also have to say Thank You to Nabeel -> The phpVMS system is well written and fun to work with!

Have Fun and GO FLY!

Vastats.zip

Link to comment
Share on other sites

  • Administrators

Hi again, is there a way to put in a stats page the top routes flown and the top aircraft uesd by the pilots?

These two functions are built into the existing StatsData.class in phpvms. You can use ->

StatsData::TopRoutes(1)
StatsData::AircraftUsage(5)

The number behind each one determines how many records you want returned.  ;)

Link to comment
Share on other sites

  • Administrators

mmmm, it does not work for me...  :-

i get

<?php StatsData::AircraftUsage(5); ?>

and it does not work...

did i made anything wrong?

That is returning an array of data which you then need to convert and display however you would like on your site. I use a module where for the case 'stats' I declare,

case 'stats':

Template::Set('toproutes', StatsData::TopRoutes(1));
Template::Set('topaircraft', StatsData::AircraftUsage(5));
Template::Show('stats_operations.tpl');

Then in my stats_operations.tpl to display the data I want to see for top aircraft ->

<?php
if(!$topaircraft)
{
echo 'No Top Aircraft';
return;
}
foreach($topaircraft as $topa)
{
?>
<tr>
<td align="center"><?php echo $topa->aircraft; ?></ td>
<td align="center"><?php echo $topa->registration; ?></ td>
</tr>
<?php 
}
?>  

and for top routes ->

<?php
if(!$toproutes)
{
echo 'No Top Routes Exist';
return;
}
foreach($toproutes as $report)
{
?>
<tr>
<td align="center"><?php echo $report->code; ?><?php echo $report->flightnum; ?></td>
<td align="center"><?php echo $report->depicao; ?></td>
<td align="center"><?php echo $report->arricao; ?></td>
<td align="center"><?php echo $report->distance; ?></td>
</tr>
<?php 
}
?>  

These pieces you need to build into your app and display in your template the way you would like to see it.  ;)

Link to comment
Share on other sites

  • Administrators

I've attached the latest StatsData (haven't commited it yet). You can see some of the changes I made (mainly using the SUM() function, and using a column name on counts instead of * which is faster)

I'll implement the pilots online, once that's completed.

Great job, thanks!

StatsData.class.zip

Link to comment
Share on other sites

  • Administrators

How to I run the .sql file? Also, when I do so, can I just copy theses lines into my code to get the stats?

<?php echo StatsData::PilotCount(); ?>

<?php echo StatsData::TotalFlights(); ?>

<?php echo StatsData::TotalHours(); ?>

These three stats were built by Nabeel and are already in the app, you would not have to run the sql file to use those. If you want to use the other commands you would have to use the sql file and update your db using phpmyadmin. The vastats options will be included in future release I believe.

Link to comment
Share on other sites

  • Administrators

Get into the phpmyadmin for your db and select the database that your trying to modify. Select the sql tab and paste the sql query into the window. Hit go. You should then get a message that the query executed sucsessfully. Done.

The commands that are at the beginning of this thread can just be pasted into your site where you want them to appear and then echo the data to get the number.

Link to comment
Share on other sites

  • Administrators

I'm sorry but how exactly can I access phpmyadmin? I found a website called www.phpmyadmin.net, but even if that's where to go, I don't know what to do from there.

My VA's website is http://www.swava.net.

Do you have access to the cpanel(or something similar) for your site? You should have phpmyadmin as an option from there in the database section. If you do not have access to the backend of the site you will have to write a quick script to insert it through a php file or the like. How did you originally set up your database, you, or someone had to have access to some sort of a database manager.

Link to comment
Share on other sites

That is returning an array of data which you then need to convert and display however you would like on your site. I use a module where for the case 'stats' I declare,

case 'stats':

Template::Set('toproutes', StatsData::TopRoutes(1));
Template::Set('topaircraft', StatsData::AircraftUsage(5));
Template::Show('stats_operations.tpl');

Then in my stats_operations.tpl to display the data I want to see for top aircraft ->

<?php
if(!$topaircraft)
{
echo 'No Top Aircraft';
return;
}
foreach($topaircraft as $topa)
{
?>
<tr>
<td align="center"><?php echo $topa->aircraft; ?></ td>
<td align="center"><?php echo $topa->registration; ?></ td>
</tr>
<?php 
}
?>  

and for top routes ->

<?php
if(!$toproutes)
{
echo 'No Top Routes Exist';
return;
}
foreach($toproutes as $report)
{
?>
<tr>
<td align="center"><?php echo $report->code; ?><?php echo $report->flightnum; ?></td>
<td align="center"><?php echo $report->depicao; ?></td>
<td align="center"><?php echo $report->arricao; ?></td>
<td align="center"><?php echo $report->distance; ?></td>
</tr>
<?php 
}
?>  

These pieces you need to build into your app and display in your template the way you would like to see it.  ;)

hello again,

could you pls explain how to create this module... I think first i have to create a module and put somehow:

case 'stats':
            
   Template::Set('toproutes', StatsData::TopRoutes(1));
   Template::Set('topaircraft', StatsData::AircraftUsage(5));
   Template::Show('stats_operations.tpl');

and then add to stats_operations.tpl

<?php
if(!$toproutes)
{
   echo 'No Top Routes Exist';
   return;
}
foreach($toproutes as $report)
{
?>
<tr>
   <td align="center"><?php echo $report->code; ?><?php echo $report->flightnum; ?></td>
   <td align="center"><?php echo $report->depicao; ?></td>
   <td align="center"><?php echo $report->arricao; ?></td>
   <td align="center"><?php echo $report->distance; ?></td>
</tr>
<?php 
}
?> 

for top routes for example.

I think i have all mess up !

sorry  :-[

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