Jump to content

Live Fuel Problem work around


Guest lorathon

Recommended Posts

Guest lorathon

Since the live fuel server stopped allowing phpVMS users to access the live fuel I have been seeing too many flights with a zero for fuel price. I am assuming this was due to the copy that Nabeel put up for the live lookup. I still wanted to use the live lookup ( I dont like the idea of all of the airports having the same fuel price) so I just looked for a work around.

What I wanted was to be able to poll the live fuel server, if there was a price there then use it. If not then use the default. The problem became that sometimes a zero was sent back. The script would then run the fuel calc with zero as the fuel price. So I dug in and worked out a way to accomplish what I wanted.

Bare in mind that this modification is too a class file that will be overwritten during and upgrade.

core/common/FuelData.class.php


public static function getFuelPrice($apt_icao)
{		
	$price = false;
	$aptinfo = OperationsData::GetAirportInfo($apt_icao);

	// Live pricing enabled, and the airport is set to '0' for a live price
	if(Config::Get('FUEL_GET_LIVE_PRICE') == true && ($aptinfo->fuelprice == '0' || $aptinfo->fuelprice == ''))
	{
		$price = self::get_cached_price($apt_icao);

		if(!$price)
		{				
			$price = self::get_from_server($apt_icao);	

			if(!is_bool($price))
			{
				if($price != '0' && $price != '')      //This checks if the return is a zero or blank if it is not then it returns the good price
				{
					return $price; // Returns the JetA price
				}
			}
		}		
		else
		{
			if($price->jeta != '0' && $price->jeta != '')  //Same as above
			{
				return $price->jeta;
			}
		}
	}

	/* Live price stuff above failed or was "off" */                
	if($aptinfo->fuelprice == '' || $aptinfo->fuelprice == 0)
		return Config::Get('FUEL_DEFAULT_PRICE');
	else
		return $aptinfo->fuelprice;
}


Link to comment
Share on other sites

but i thouth the live feulpricing wan't working annymore

Nabeel says and I quote

I've changed the API to refer to the last updated fuel price, so they may be off (they were updated last week).

That means that the last fuel update that he was able to capture is the current one in use. So with this work around it should give prices the way that should be as of when that last update was made to the API. Now the fuel prices are going to be old as dust now, but at least all airports will not have the same fuel prices and should get no $0.00 fuel prices. That has been a major problem that I have been running in to lately.

Link to comment
Share on other sites

  • Moderators

Nabeel says and I quote

That means that the last fuel update that he was able to capture is the current one in use. So with this work around it should give prices the way that should be as of when that last update was made to the API. Now the fuel prices are going to be old as dust now, but at least all airports will not have the same fuel prices and should get no $0.00 fuel prices. That has been a major problem that I have been running in to lately.

t(hanks ray

will see iff its getting the last prices :-)

Link to comment
Share on other sites

Well, if you go to each airport you added and click look up or what ever it is, all it does is say

Live price check:

Waiting for ICAO change...

Now I just need to go back and try a couple flights from a few of those 0$ fuel price airports and see if this cleared up that problem for me.

Link to comment
Share on other sites

  • 7 months later...

Nope. Not the whole thing.

A quick tip to doing this kind of thing is take a close look at the opening line of code, and then look at the closing line of code. Find the two corresponding lines in your php file and replace it from start line to end line.

Link to comment
Share on other sites

  • 10 months later...
  • 7 months later...

We could also use at least as a reference this mundi index

http://www.indexmund...modity=jet-fuel

maybe some kind of feed can be used from here and added to the phpVMS (I'm not a coder, just saying)

note

he price is FOB (freight on board) for U.S. Gulf Coast, so to have a fair estimate, some extra shipping and handling costs should be added for the destination airport

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