Jump to content

Pax Status


Serrador

Recommended Posts

You have to pull it from StatsData.class.php

<p><strong>Passengers Carried: </strong><?php echo StatsData::TotalPaxCarried(); ?></p>

You can do alot with these codes, he is what I have showing:

<p><strong>Total Pilots: <?php echo StatsData::PilotCount(); ?></strong></p>
       <p><strong>Total Flights Flown: </strong><?php echo StatsData::TotalFlights(); ?></p>
       <p><strong>Total Aircraft: </strong><?php echo StatsData::TotalAircraftInFleet(); ?></p>
       <p><strong>Total Hours Flown: </strong><?php echo StatsData::TotalHours(); ?></p>
       <p><strong>Passengers Carried: </strong><?php echo StatsData::TotalPaxCarried(); ?></p>
       <p><strong>Fuel Burned (lbs.): </strong><?php echo StatsData::TotalFuelBurned(); ?></p>
       <p><strong>Miles Flown: </strong><?php echo StatsData::TotalMilesFlown(); ?></p>
       <p><strong>Total Flights Today: </strong><?php echo StatsData::totalflightstoday(); ?></p>

  • Like 1
Link to comment
Share on other sites

That's what I do as well. The only thing missing is the amount of cargo carried, but there does not seem to be any easy way to work that in. :(

I have been doing some searching about this, and still can't seem to find out how people are showing that on their site. It just boggles my mind that I know it is being saved lust like Passengers, but where is it being saved so we can pull it out is the question.

Link to comment
Share on other sites

I found something interesting. It took 198 flights to carry over 2 million passengers:rolleyes: :blink::D I have a nagging suspicion that it is returning the total units, meaning pax and lbs. of cargo. I also haven't found a way to get rid of the decimal amount in fuel burned.

Airline Statistics

Total Pilots: 28

Total Flights Flown: 198

Total Aircraft: 104

Total Hours Flown: 498.37

Passengers Carried: 2297149

Fuel Burned (lbs.): 3157507.1060009

Miles Flown: 213119

Total Flights Today: 0

Total Schedules: 2335

Link to comment
Share on other sites

The same basic code as you posted above. In fact I just duplicated what you posted, this evening and get the same results. I originally had the HTML tied to CSS, rather than using the <STRONG> tags, but I didn't think that was the problem. Since I'm now using the same code you are, I guess I was right. I'm bewildered as to where the stuff to the right of the decimal came from.

I think I've figured out the large number of pax. I suspect it can be traced to cargo a/c accidentally being assigned to pax routes, but I'll have to scour the pireps to find out.

Link to comment
Share on other sites

Yeah, that is definitely weird. If you click my signature, you can see that it doesn't have a decimal on it, so I just don't know. I am strictly using FSPassengers only, not using any ACARS at all, so not sure if that could be the reason.

Link to comment
Share on other sites

  • Administrators

To round the number and remove the decimal use ->

<p><strong>Fuel Burned (lbs.): </strong><?php echo round(StatsData::TotalFuelBurned(), 0); ?></p>

As far as pax count it is pulling the load figure from each PIREP that has a flighttype of "P" ->

$params = array(
			'table' => TABLE_PREFIX.'pireps',
			'fields' => 'SUM(`load`) as `total`',
			'where' => array(
				'accepted' => PIREP_ACCEPTED,
				'flighttype' => 'P'
			),

I would check to see if your cargo flights are being recorded with the correct identifier in the flighttype column of the pireps table.

Link to comment
Share on other sites

  • Administrators

How do you do Cargo, instead of Passangers carried?

Add something like this to your statsdata class ->

public static function TotalCargoCarried($airline_code = '')
{
	$key = 'total_cargo_carried';
	if($airline_code != '')
	{
		$key .= '_'.$airline_code;
	}

	$total = CodonCache::read($key);

	if($total === false)
	{
		$params = array(
			'table' => TABLE_PREFIX.'pireps',
			'fields' => 'SUM(`load`) as `total`',
			'where' => array(
				'accepted' => PIREP_ACCEPTED,
				'flighttype' => 'C'
			),
		);

		if(!empty($airline_code))
		{
			$params['where']['code'] = $airline_code;
			$params['group'] = 'code';
		}

		$sql = DB::build_select($params);
		$results = DB::get_results($sql);
		if(!$results)
		{
			$total = 0;
		}
		else
		{
			$total = $results[0]->total;
		}

		CodonCache::write($key, $total, '15minute');
	}

	return $total;
}

And use ->

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

to display it

Link to comment
Share on other sites

Guest lorathon

Sim is correct. Although I would write a new stats class for this so it would not be overwritten in an upgrade. This is what I did. I have a class specifically built for modified standard classes that is full of stuff just like this.

Link to comment
Share on other sites

Add something like this to your statsdata class ->

public static function TotalCargoCarried($airline_code = '')
{
	$key = 'total_cargo_carried';
	if($airline_code != '')
	{
		$key .= '_'.$airline_code;
	}

	$total = CodonCache::read($key);

	if($total === false)
	{
		$params = array(
			'table' => TABLE_PREFIX.'pireps',
			'fields' => 'SUM(`load`) as `total`',
			'where' => array(
				'accepted' => PIREP_ACCEPTED,
				'flighttype' => 'C'
			),
		);

		if(!empty($airline_code))
		{
			$params['where']['code'] = $airline_code;
			$params['group'] = 'code';
		}

		$sql = DB::build_select($params);
		$results = DB::get_results($sql);
		if(!$results)
		{
			$total = 0;
		}
		else
		{
			$total = $results[0]->total;
		}

		CodonCache::write($key, $total, '15minute');
	}

	return $total;
}

And use ->

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

to display it

Thanks for your help, but i got this error when i added this to my site:

Parse error: syntax error, unexpected T_PUBLIC in /home/skygovac/public_html/core/common/StatsData.class.php on line 838

Link to comment
Share on other sites

David, if you placed that code at the very end of StatsData.class.php AFTER HERE:

/**
 * Return the total number of schedules in the system
 *
 * @return int $airline_code Total number
 *
 */
public static function TotalSchedules($airline_code='')
{
	$key = 'total_schedules';
	if($airline_code != '')
	{
		$key .= '_'.$airline_code;
	}

	$total = CodonCache::read($key);

	if($total === false)
	{
		$params = array(
			'table' => TABLE_PREFIX.'schedules',
			'fields' => 'COUNT(`id`) as `total`',
		);

		if(!empty($airline_code))
		{
			$params['where'] = array('code' => $airline_code);
			$params['group'] = 'code';
		}

		$sql = DB::build_select($params);
		$results = DB::get_results($sql);

		if(!$results)
		{
			$total = 0;
		}
		else
		{
			$total = $results[0]->total;
		}

		CodonCache::write($key, $total, '15minute');
	}

	return $total;
}
}        <<<THIS IS THE ONE YOU MOVE

you need to remove the extra } from that code to the very end of the code you just pasted. That's probably why that error is coming up.

Link to comment
Share on other sites

  • 3 months later...
Guest lfreitas1

I solved the problem of Cargo Stats

copy this code between the TotalPaxCarried and PilotCount

the code is:

/**
 * Return the total number of Cargo Carried
 *
 * 
 *
 */
public static function TotalCargoCarried($airline_code = '')
       {
               $key = 'total_cargo_carried';
               if($airline_code != '')
               {
                       $key .= '_'.$airline_code;
               }

               $total = CodonCache::read($key);

               if($total === false)
               {
                       $params = array(
                               'table' => TABLE_PREFIX.'pireps',
                               'fields' => 'SUM(`load`) as `total`',
                               'where' => array(
                                       'accepted' => PIREP_ACCEPTED,
                                       'flighttype' => 'C'
                               ),
                       );

                       if(!empty($airline_code))
                       {
                               $params['where']['code'] = $airline_code;
                               $params['group'] = 'code';
                       }

                       $sql = DB::build_select($params);
                       $results = DB::get_results($sql);
                       if(!$results)
                       {
                               $total = 0;
                       }
                       else
                       {
                               $total = $results[0]->total;
                       }

                       CodonCache::write($key, $total, '15minute');
               }

               return $total;
       }

Like this:

/* These contributed by simpilot from phpVMS forums
 */

/**
* Get the total number of pilots
*/
public static function PilotCount($airline_code='')
{
	$key = 'pilot_count';
	if($airline_code != '')
	{
		$key .= '_'.$airline_code;
	}

	$total = CodonCache::read($key);

	if($total === false)
	{
		$params = array(
			'table' => TABLE_PREFIX.'pilots',
			'fields' => 'COUNT(*) as `total`',
		);

		if(!empty($airline_code))
		{
			$params['where']['code'] = $airline_code;
			$params['group'] = 'code';
		}

		$sql = DB::build_select($params);
		$results = DB::get_results($sql);
		if(!$results)
		{
			$total = 0;
		}
		else
		{
			$total = $results[0]->total;
		}

		CodonCache::write($key, $total, '15minute');
	}

	return $total;
}

/**
 * Return the total number of Cargo Carried
 *
 * 
 *
 */
public static function TotalCargoCarried($airline_code = '')
       {
               $key = 'total_cargo_carried';
               if($airline_code != '')
               {
                       $key .= '_'.$airline_code;
               }

               $total = CodonCache::read($key);

               if($total === false)
               {
                       $params = array(
                               'table' => TABLE_PREFIX.'pireps',
                               'fields' => 'SUM(`load`) as `total`',
                               'where' => array(
                                       'accepted' => PIREP_ACCEPTED,
                                       'flighttype' => 'C'
                               ),
                       );

                       if(!empty($airline_code))
                       {
                               $params['where']['code'] = $airline_code;
                               $params['group'] = 'code';
                       }

                       $sql = DB::build_select($params);
                       $results = DB::get_results($sql);
                       if(!$results)
                       {
                               $total = 0;
                       }
                       else
                       {
                               $total = $results[0]->total;
                       }

                       CodonCache::write($key, $total, '15minute');
               }

               return $total;
       }

/**
 * Return the total number of passengers carried
 *
 * @return mixed This is the return value description
 *
 */
public static function TotalPaxCarried($airline_code = '')
{
	$key = 'total_pax_carried';
	if($airline_code != '')
	{
		$key .= '_'.$airline_code;
	}

	$total = CodonCache::read($key);

	if($total === false)
	{
		$params = array(
			'table' => TABLE_PREFIX.'pireps',
			'fields' => 'SUM(`load`) as `total`',
			'where' => array(
				'accepted' => PIREP_ACCEPTED,
				'flighttype' => 'P'
			),
		);

		if(!empty($airline_code))
		{
			$params['where']['code'] = $airline_code;
			$params['group'] = 'code';
		}

		$sql = DB::build_select($params);
		$results = DB::get_results($sql);
		if(!$results)
		{
			$total = 0;
		}
		else
		{
			$total = $results[0]->total;
		}

		CodonCache::write($key, $total, '15minute');
	}

	return $total;
}

if you want to have my full file statsdata.class.php, in this Attachments

Portuguese:

Eu Resolvi o problema do Cargo Stats

copie esse codigo entre o TotalPaxCarried e PilotCount

o codigo é:

/**
 * Return the total number of Cargo Carried
 *
 * 
 *
 */
public static function TotalCargoCarried($airline_code = '')
       {
               $key = 'total_cargo_carried';
               if($airline_code != '')
               {
                       $key .= '_'.$airline_code;
               }

               $total = CodonCache::read($key);

               if($total === false)
               {
                       $params = array(
                               'table' => TABLE_PREFIX.'pireps',
                               'fields' => 'SUM(`load`) as `total`',
                               'where' => array(
                                       'accepted' => PIREP_ACCEPTED,
                                       'flighttype' => 'C'
                               ),
                       );

                       if(!empty($airline_code))
                       {
                               $params['where']['code'] = $airline_code;
                               $params['group'] = 'code';
                       }

                       $sql = DB::build_select($params);
                       $results = DB::get_results($sql);
                       if(!$results)
                       {
                               $total = 0;
                       }
                       else
                       {
                               $total = $results[0]->total;
                       }

                       CodonCache::write($key, $total, '15minute');
               }

               return $total;
       }

ficara assim:

/* These contributed by simpilot from phpVMS forums
 */

/**
* Get the total number of pilots
*/
public static function PilotCount($airline_code='')
{
	$key = 'pilot_count';
	if($airline_code != '')
	{
		$key .= '_'.$airline_code;
	}

	$total = CodonCache::read($key);

	if($total === false)
	{
		$params = array(
			'table' => TABLE_PREFIX.'pilots',
			'fields' => 'COUNT(*) as `total`',
		);

		if(!empty($airline_code))
		{
			$params['where']['code'] = $airline_code;
			$params['group'] = 'code';
		}

		$sql = DB::build_select($params);
		$results = DB::get_results($sql);
		if(!$results)
		{
			$total = 0;
		}
		else
		{
			$total = $results[0]->total;
		}

		CodonCache::write($key, $total, '15minute');
	}

	return $total;
}

/**
 * Return the total number of Cargo Carried
 *
 * 
 *
 */
public static function TotalCargoCarried($airline_code = '')
       {
               $key = 'total_cargo_carried';
               if($airline_code != '')
               {
                       $key .= '_'.$airline_code;
               }

               $total = CodonCache::read($key);

               if($total === false)
               {
                       $params = array(
                               'table' => TABLE_PREFIX.'pireps',
                               'fields' => 'SUM(`load`) as `total`',
                               'where' => array(
                                       'accepted' => PIREP_ACCEPTED,
                                       'flighttype' => 'C'
                               ),
                       );

                       if(!empty($airline_code))
                       {
                               $params['where']['code'] = $airline_code;
                               $params['group'] = 'code';
                       }

                       $sql = DB::build_select($params);
                       $results = DB::get_results($sql);
                       if(!$results)
                       {
                               $total = 0;
                       }
                       else
                       {
                               $total = $results[0]->total;
                       }

                       CodonCache::write($key, $total, '15minute');
               }

               return $total;
       }

/**
 * Return the total number of passengers carried
 *
 * @return mixed This is the return value description
 *
 */
public static function TotalPaxCarried($airline_code = '')
{
	$key = 'total_pax_carried';
	if($airline_code != '')
	{
		$key .= '_'.$airline_code;
	}

	$total = CodonCache::read($key);

	if($total === false)
	{
		$params = array(
			'table' => TABLE_PREFIX.'pireps',
			'fields' => 'SUM(`load`) as `total`',
			'where' => array(
				'accepted' => PIREP_ACCEPTED,
				'flighttype' => 'P'
			),
		);

		if(!empty($airline_code))
		{
			$params['where']['code'] = $airline_code;
			$params['group'] = 'code';
		}

		$sql = DB::build_select($params);
		$results = DB::get_results($sql);
		if(!$results)
		{
			$total = 0;
		}
		else
		{
			$total = $results[0]->total;
		}

		CodonCache::write($key, $total, '15minute');
	}

	return $total;
}

Se você quiserem o meu arquivo completo statsdata.class.php esta no Attachments

StatsData.class.php

Link to comment
Share on other sites

  • 3 weeks later...

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