Jump to content

Request: fuel calculation on pilot briefing


hjhjhgjgjh

Recommended Posts

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

?>

Link to comment
Share on other sites

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 :D

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

  • Like 1
Link to comment
Share on other sites

  • Administrators

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;

?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>

fuel.png

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

okay the 4512 (well changes for every aircraft) is the fuel flow per hour. you have to check the internet to get accurate date for every aircraft. then, flighttime multiplied with 100 / 60 to get everything in minutes (because you have values like 1.5 which is not 1,5 hours... its 1 hours 50 minutes and so on...) than, those + 1000 (again depending on the aircraft) is the "extrafuel" or reserves or whatever you will call it ;)

for the fuel flow, i just took values for aircrafts on FL300 so you really have to change those if you have something like an ATR or jetstream in your fleet as they will never reach that level. I am the whole time flying with those calculations and those are at least working very well for me. I will make an update soon, so it will automatically write the config from the aircrafts in your fleet list,.. also i will use more accurate data from burn tables and so on but thats future.. i am not a professional web developer and so i need to find out how to do that first.

and @ James200410:

be carefull.. you cant just replace those kg with lbs and thats it, you have to change the fuel flow than to lbs/h ;)

Link to comment
Share on other sites

and @ James200410:

be carefull.. you cant just replace those kg with lbs and thats it, you have to change the fuel flow than to lbs/h ;)

lol thanks mate, I understand, its not on the live site, I need to go and set it up for my particular fleet, I was just amazed that I got it to work as Im not real good with all this php stuff ;D

Thanks again and looking forward to your future updates.

Regards

Adam

Link to comment
Share on other sites

as is getting the JA're running MYSQL

see

  tbsc000.jpg

tbsc001.jpg

now is that I will break your head to make it work

help

        <td><?php

        if($schedule->flighttime == 0)

            {

            echo 'no fuel data available';

            }

        elseif($schedule->flighttime <= 1.0)

                  {

                      if <?php "{$schedule->aircraft}"; ?>')

                        {

                            $result =  <?php "{$schedule->aircraft==$aircraft->fuelh}"; ?> * ($schedule->flighttime * 100 / 60) +  <?php "{$schedule->aircraft==$aircraft->fuelr}"; ?>;

                        }

                      }

                    elseif($schedule->flighttime >= 1.01)

                      {

                       

                  elseif($schedule->aircraft=='<?php "{$schedule->aircraft}"; ?>')

                        {

                            $result = <?php "{$schedule->aircraft==$aircraft->fuelh}"; ?> * ($schedule->flighttime * 100 / 60) +  <?php "{$schedule->aircraft==$aircraft->fuelr}"; ?>;

                        }

                    }

                   

                    else

                        {

                            echo'invalid information provided';

                        }

                  if($schedule->flighttime > 0)

                  {

                  echo round ($result,-2);

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

                  }

             

       

      ?></td>

how do I get data from mysql this aircraft.

Link to comment
Share on other sites

CAUTION!!! DO NOT USE THE SYSTEM UNTIL I SAY SO

i made a big mistake which i try to solve at the moment. before i start, i will write some modul soon so its easier to change everything but i am not done yet. here is the mistake

my calculation in that system goes like that: "Fuelflow * time + reserves" The mistake is in the time. I am calculating with HH.MM which means if you have 2 hours 40 minutes, it will automatically calculate 2.4 and not 2,666667 hours.

Here is the new code i made. First i added this line

        $ftinhours = explode(":", "$schedule->flighttime");

behind the first row of that fuel calculation so it looks like that

<?

$ftinhours = explode(".", "$schedule->flighttime");

...

then the calculation has to look like that:

$result = 8000 * $ftinhours[0] + 8000 * ($ftinhours[1] * 100 / 60) + 3000;

in my case, i took the MD11 which has a fuel flow of 8000kg per hour. the flight was 2 hours and 40 minutes and i put in reserves of 3000 so this is what the calculation looks like:

8000 * 2 + 8000 *(40 * 100 / 60 ) + 3000

but this doesnt work correctly.. what do i do wrong :S

---------------

edit: okay i think i will start from the beginning and try to write something like a clean code with modules and stuff. it will be done within the next 48 hours.  ;)

Link to comment
Share on other sites

okay thats what i have so far. i removed the whole code and now i added one line to the table phpvms_aircraft which is called "fuelflow" here is the code but still, something is wrong cause it always shows 0 in the calculation. (i filled the mysql table with 3000 all the row down)

<?php

        $flighttime = explode(".", "$schedule->flighttime");

        $flightminutes1 = $flighttime[1] / 60;

        $fuelhours0 = $fuelflow * $flighttime[0];

        $fuelminutes = $fuelflow * $flightminutes1;

        $fuelflow="SELECT fuelflow FROM aircraft WHERE id $aircraft-schedule";

        $result = $fuelhours + $fuelminutes;

            if($schedule->flighttime == 0)

            {

                echo 'no fuel data available';

            }

            else

            {

                echo round ($result,-2);

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

            }

?>

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