Request: fuel calculation on pilot briefing

Is it possible to add automatic fuel calculations? Those do not have to be extremely accurate but can be used as a general value.

So it goes like that..

if aircraft = MD11 -> Fuelflow x kg/h * hours flighttime + y% extra fuel = required fuel (which should then appear in the briefing)

or something similar

You could probably code that yourself straight into the template

yea i think i know how to customize it or where to place it but not how to write it. my skills in developing are not very good. only in changing. actually, the following code is the first if-operation i have ever written. this is what i think how it maybe could look like. now i need someone who can tell me if this is correct

<?php

if($flighttime < 1.0)

{

if($schedule->aircraft = “MD11”)

{

(4000 / $flighttime) + 3000

}

else if(“$schedule->aircraft” = “B737”)

{

(2000 / $flighttime) + 1500

}

else if(“$schedule->aircraft” = “B747”)

{

(4500 / $flighttime) + 5000

}

else if($flighttime >= 1.0)

{

if($schedule->aircraft = “MD11”)

{

(4000 * $flighttime) + 3000

}

else if(“$schedule->aircraft” = “B737”)

{

(2000 * $flighttime) + 1500

}

else if(“$schedule->aircraft” = “B747”)

{

(4500 * $flighttime) + 5000

}

  }

echo $result

?>

Looking good, will add this aswell if you get it working

Some of our pilots still use 100% fuel, even for short flights so we have some work to do there

The code looks good, but my php is not up there yet, for me to judge it:P

Only my Q is why you use fuelHR / flightHR , should this be multiply insted?

And how to make the math know that flight hours are H:MM insted of 1.5 hr= 1hr 30mins…

But Im cheering for you

1 Like

well i dont think this should be a problem (some database thing)..

about the multiply thing.. i use it only if the hours are more than 1 or 1. otherwise i use / otherwise you get wrong values i think

Oh, i spotted the if for flighttime, then there is no more from me, let me know if it works 8)

I think this will work better for you - corrected some phpsyntax. I am not sure where exactly you are using this but if the variables are not present you are going to get some errors. I am not sure if the template you are using this in will actually provide you with the ‘B747’ etc in the $schedule->aircraft variable, most places it just returns the aircraft id number from the database and you have to call the icao code for it by the id number…

<?php
//you will probably want to make some checks here
//if (!$flighttime)
//        {
//            echo'no flighttime';
//              return;
//          }
//if (!$schedule->aircraft)
//        {
//            echo'no aircraft';
//              return;
//          }

  if($flighttime <= 1.0)
      {
      if($schedule->aircraft=='MD11')
        {
          $result = (4000 / $flighttime) + 3000;
        }
      elseif($schedule->aircraft=='B737')
        {
        $result = (2000 / $flighttime) + 1500;
        }
      elseif($schedule->aircraft=='B747')
        {
        $result = (4500 / $flighttime) + 5000;
        }
  }
  elseif($flighttime >=1.01)
      {
      if($schedule->aircraft=='MD11')
        {
        $result = (4000 * $flighttime) + 3000;
        }
      elseif($schedule->aircraft=='B737')
        {
        $result = (2000 * $flighttime) + 1500;
        }
      elseif($schedule->aircraft=='B747')
        {
        $result = (4500 * $flighttime) + 5000;
        }
else
	{
		//do something here in case a variable is missing ie - echo'invalid information provided';
	}
  }
  echo $result;

?>

I try to integrate this into the pilot briefing page. My goal is, that the pilot can stay on that website to get all required informations about his flights. We want to make as much as possible for the pilots and this would be a nice information.. Not only for the financial situation  ;D

What do you think about replacing $schedules->aircraft with $aircraft->icao ?

Maybe this works.. well i will just try it out but it will take some time for me to integrate it

Ok got it to work, thanks a lot simpilot..  but BEFORE SOMEONE ADDS THIS , I would like to ask anyone who knows php very well to watch over that piece of code. I have that feeling that still something is wrong. There is still that “if statement” about less or more than one hour which is in my eyes now useless but i let it in the script because of my feeling that i did something wrong and i maybe will need it again

Add those lines after any </tr> in your /core/templates/schedule_briefing.tpl ! After that, you have to customize it. In those lines here, I added the names of the aircrafts of my virtual airline. Not everybody has those aircrafts/has different names for those aircrafts or has other aircrafts. You can see those names in the admin panel from phpvms -> Airline Operations -> Add&Edit Fleet -> Name/Type !! this is very important. Then you have to google for the fuelflow of that aircraft. The formula goes like that: $result = fuelflow per/h * (flighttime * 100 / 60) + reserves and taxifuel

        <tr>

<td colspan=“2” style=“padding: 6px;”>

<?php 

        if($schedule->flighttime <= 1.0)

        {

                      if($schedule->aircraft==‘MD MD-11’)

                        {

                            $result = 8400 * ($schedule->flighttime * 100 / 60) + 3000;

                        }

                        elseif($schedule->aircraft==‘MD DC10’)

                        {

                            $result = 8000 * ($schedule->flighttime * 100 / 60) + 3500;

                        }

elseif($schedule->aircraft==‘MD MD-11F’)

                        {

                            $result = 8400 * ($schedule->flighttime * 100 / 60) + 3000;

                        }

elseif($schedule->aircraft==‘E170’)

                        {

                            $result = 1000 * ($schedule->flighttime * 100 / 60) + 900;

                        }

elseif($schedule->aircraft==‘E190’)

                        {

                            $result = 1200 * ($schedule->flighttime * 100 / 60) + 1000;

                        }

elseif($schedule->aircraft==‘B737-800’)

                        {

                            $result = 3300 * ($schedule->flighttime * 100 / 60) + 1200;

                        }

elseif($schedule->aircraft==‘B737-400’)

                        {

                            $result = 2900 * ($schedule->flighttime * 100 / 60) + 1500;

                        }

elseif($schedule->aircraft==‘B747-200’)

                        {

                            $result = 11364 * ($schedule->flighttime * 100 / 60) + 6000;

                        }

elseif($schedule->aircraft==‘B727-200’)

                        {

                            $result = 4512 * ($schedule->flighttime * 100 / 60) + 1000;

                        }

elseif($schedule->aircraft==‘B747-400’)

                        {

                            $result = 12582 * ($schedule->flighttime * 100 / 60) + 7000;

                        }

elseif($schedule->aircraft==‘B703-200’)

                        {

                            $result = 6690 * ($schedule->flighttime * 100 / 60) + 3000;

                        }

elseif($schedule->aircraft==‘B737-200’)

                        {

                            $result = 1600 * ($schedule->flighttime * 100 / 60) + 1500;

                        }

elseif($schedule->aircraft==‘JS31’)

                        {

                            $result = 234 * ($schedule->flighttime * 100 / 60) + 200;

                        }

elseif($schedule->aircraft==‘DHC7’)

                        {

                            $result = 330 * ($schedule->flighttime * 100 / 60) + 200;

                        }

                      }

                    elseif($schedule->flighttime >= 1.01)

                      {

                        if($schedule->aircraft==‘MD MD-11’)

                        { 

                            $result = 8400 * ($schedule->flighttime * 100 / 60) + 3000;

                        }

                        elseif($schedule->aircraft==‘MD DC-10’)

                        {

                            $result = 8000 * ($schedule->flighttime * 100 / 60) + 3500;

                        }

elseif($schedule->aircraft==‘MD MD-11F’)

                        {

                            $result = 8400 * ($schedule->flighttime * 100 / 60) + 3000;

                        }

elseif($schedule->aircraft==‘E170’)

                        {

                            $result = 1000 * ($schedule->flighttime * 100 / 60) + 900;

                        }

elseif($schedule->aircraft==‘E190’)

                        {

                            $result = 1200 * ($schedule->flighttime * 100 / 60) + 1000;

                        }

elseif($schedule->aircraft==‘B737-800’)

                        {

                            $result = 3300 * ($schedule->flighttime * 100 / 60) + 1200;

                        }

elseif($schedule->aircraft==‘B737-400’)

                        {

                            $result = 2900 * ($schedule->flighttime * 100 / 60) + 1500;

                        }

elseif($schedule->aircraft==‘B747-200’)

                        {

                            $result = 11364 * ($schedule->flighttime * 100 / 60) + 6000;

                        }

elseif($schedule->aircraft==‘B727-200’)

                        {

                            $result = 4512 * ($schedule->flighttime * 100 / 60)  + 1000;

                        }

elseif($schedule->aircraft==‘B747-400’)

                        {

                            $result = 12582 * ($schedule->flighttime * 100 / 60) + 7000;

                        }

elseif($schedule->aircraft==‘B703-200’)

                        {

                            $result = 6690 * ($schedule->flighttime * 100 / 60) + 3000;

                        }

elseif($schedule->aircraft==‘B737-200’)

                        {

                            $result = 1600 * ($schedule->flighttime * 100 / 60) + 1500;

                        }

elseif($schedule->aircraft==‘JS31’)

                        {

                            $result = 234 * ($schedule->flighttime * 100 / 60) + 200;

                        }

elseif($schedule->aircraft==‘DHC7’)

                        {

                            $result = 330 * ($schedule->flighttime * 100 / 60) + 200;

                        }

                      }

                     

                    else

                        {

                            echo’invalid information provided’;

                        }

                 

                  echo round ($result,-2);

                  echo ’ kg’;

               

               

?>

</td>

</tr>

ok i made a lot of changes and will publish the new version tomorrow

You should use an editor like netbeans or zend studio which has syntax highlighting and error checking, it’ll make your life much easier

i used dreamweaver but will get netbeans,.. thanks for that hint

here the last update for this script.. (read the instruction above how to get it to work)

    <tr>

<td width=“50%” >

<?php

        if($schedule->flighttime == 0)

        {

            echo ‘no fuel data available’;

            } 

        elseif($schedule->flighttime <= 1.0)

        {

                      if($schedule->aircraft==‘MD MD-11’)

                        {

                            $result = 8400 * ($schedule->flighttime * 100 / 60) + 3000;

                        }

                        elseif($schedule->aircraft==‘MD DC10’)

                        {

                            $result = 8000 * ($schedule->flighttime * 100 / 60) + 3500;

                        }

elseif($schedule->aircraft==‘MD MD-11F’)

                        {

                            $result = 8400 * ($schedule->flighttime * 100 / 60) + 3000;

                        }

elseif($schedule->aircraft==‘E170’)

                        {

                            $result = 1000 * ($schedule->flighttime * 100 / 60) + 900;

                        }

elseif($schedule->aircraft==‘E190’)

                        {

                            $result = 1200 * ($schedule->flighttime * 100 / 60) + 1000;

                        }

elseif($schedule->aircraft==‘B737-800’)

                        {

                            $result = 3300 * ($schedule->flighttime * 100 / 60) + 1200;

                        }

elseif($schedule->aircraft==‘B737-400’)

                        {

                            $result = 2900 * ($schedule->flighttime * 100 / 60) + 1500;

                        }

elseif($schedule->aircraft==‘B747-200’)

                        {

                            $result = 11364 * ($schedule->flighttime * 100 / 60) + 6000;

                        }

                        elseif($schedule->aircraft==‘B747-200F’)

                        {

                            $result = 11364 * ($schedule->flighttime * 100 / 60) + 6000;

                        }

                        elseif($schedule->aircraft==‘B747-400F’)

                        {

                            $result = 11364 * ($schedule->flighttime * 100 / 60) + 6000;

                        }

elseif($schedule->aircraft==‘B727-200’)

                        {

                            $result = 4512 * ($schedule->flighttime * 100 / 60) + 1000;

                        }

elseif($schedule->aircraft==‘B747-400’)

                        {

                            $result = 12582 * ($schedule->flighttime * 100 / 60) + 7000;

                        }

elseif($schedule->aircraft==‘B703-200’)

                        {

                            $result = 6690 * ($schedule->flighttime * 100 / 60) + 3000;

                        }

elseif($schedule->aircraft==‘B737-200’)

                        {

                            $result = 1600 * ($schedule->flighttime * 100 / 60) + 1500;

                        }

elseif($schedule->aircraft==‘JS31’)

                        {

                            $result = 234 * ($schedule->flighttime * 100 / 60) + 200;

                        }

elseif($schedule->aircraft==‘DHC7’)

                        {

                            $result = 330 * ($schedule->flighttime * 100 / 60) + 200;

                        }

                      }

                    elseif($schedule->flighttime >= 1.01)

                      {

                        if($schedule->aircraft==‘MD MD-11’)

                        { 

                            $result = 8400 * ($schedule->flighttime * 100 / 60) + 3000;

                        }

                        elseif($schedule->aircraft==‘MD DC-10’)

                        {

                            $result = 8000 * ($schedule->flighttime * 100 / 60) + 3500;

                        }

elseif($schedule->aircraft==‘MD MD-11F’)

                        {

                            $result = 8400 * ($schedule->flighttime * 100 / 60) + 3000;

                        }

elseif($schedule->aircraft==‘E170’)

                        {

                            $result = 1000 * ($schedule->flighttime * 100 / 60) + 900;

                        }

elseif($schedule->aircraft==‘E190’)

                        {

                            $result = 1200 * ($schedule->flighttime * 100 / 60) + 1000;

                        }

elseif($schedule->aircraft==‘B737-800’)

                        {

                            $result = 3300 * ($schedule->flighttime * 100 / 60) + 1200;

                        }

elseif($schedule->aircraft==‘B737-400’)

                        {

                            $result = 2900 * ($schedule->flighttime * 100 / 60) + 1500;

                        }

elseif($schedule->aircraft==‘B747-200’)

                        {

                            $result = 11364 * ($schedule->flighttime * 100 / 60) + 6000;

                        }

                        elseif($schedule->aircraft==‘B747-200F’)

                        {

                            $result = 11364 * ($schedule->flighttime * 100 / 60) + 6000;

                        }

                        elseif($schedule->aircraft==‘B747-400F’)

                        {

                            $result = 11364 * ($schedule->flighttime * 100 / 60) + 6000;

                        }

elseif($schedule->aircraft==‘B727-200’)

                        {

                            $result = 4512 * ($schedule->flighttime * 100 / 60)  + 1000;

                        }

elseif($schedule->aircraft==‘B747-400’)

                        {

                            $result = 12582 * ($schedule->flighttime * 100 / 60) + 7000;

                        }

elseif($schedule->aircraft==‘B703-200’)

                        {

                            $result = 6690 * ($schedule->flighttime * 100 / 60) + 3000;

                        }

elseif($schedule->aircraft==‘B737-200’)

                        {

                            $result = 1600 * ($schedule->flighttime * 100 / 60) + 1500;

                        }

elseif($schedule->aircraft==‘JS31’)

                        {

                            $result = 234 * ($schedule->flighttime * 100 / 60) + 200;

                        }

elseif($schedule->aircraft==‘DHC7’)

                        {

                            $result = 330 * ($schedule->flighttime * 100 / 60) + 200;

                        }

                      }

                     

                    else

                        {

                            echo’invalid information provided’;

                        }

                  if($schedule->flighttime > 0)

                  {

                  echo round ($result,-2);

                  echo ’ kg - this includes fuel for taxi and reserves’;

                }

               

?>

</td>

It shows up but I can’t get it to work unfortunately  :-[

Here is what I have;

</tr>

<!-- Aircraft Fuel Estimate –>

<tr style=“background-color: #333; color: #FFF;”>

<td colspan=“2”>Estimated Fuel Required</td>

</tr>

<tr>

<td colspan=“2”>

      <?php

        if($schedule->flighttime <= 1.0)

                  {

                      if($schedule->aircraft==‘B60’)

                        {

                            $result = 800 * ($schedule->flighttime * 100 / 60) + 200;

                        }

                  elseif($schedule->aircraft==‘B738’)

                        {

                            $result = 8000 * ($schedule->flighttime * 100 / 60) + 3500;

                        }

                  elseif($schedule->aircraft==‘PA31T’)

                        {

                            $result = 800 * ($schedule->flighttime * 100 / 60) + 200;

                        }

                  elseif($schedule->aircraft==‘B744’)

                        {

                            $result = 1000 * ($schedule->flighttime * 100 / 60) + 900;

                        }

                      }

                   

                    else

                        {

                            echo ‘Estimated fuel is currently unavailable >>’;

                        }

                  if($schedule->flighttime > 0)

                  {

                  echo round ($result,-2);

                  echo ’ lbs - NOTE fuel for taxi and reserves inclusive’;

                  }

?>

      </td>

  </tr>

Can anyone see what is wrong ?

I have double checked the type/names of the aircraft.

Thanks in advance.

Adam

looks correct for me. please check if you inserted the flighttimes for every flight in the format “H.MM” and then please check if you really choosed the aircraft names and not icao codes

no, i see your mistake. you forgot that there is another “if” in the middle of the code

elseif($schedule->flighttime >= 1.01)

you only have

if($schedule->flighttime <= 1.0)

but what happens when the flighttime is over 1 hour?

ok thanks will check that now

and by creating a module with a table in mysql and placed a form for the data code would be smaller and easier to add new aircraft

and if you can do that, do it i cant

Thanks Very much tebinu, that worked.

Now I got to go and make the fuel data more accurate, lol

Thanks again

Adam

What is the value $ result = 4512

and

What is the value $ result $ calendar-> flighttime * 100 / 60) + 1000, so that each serves and how the calculation is done