Jump to content

Automatic Fuel Calculation


hjhjhgjgjh

Recommended Posts

Here is what I used for the passenger flight reference:

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

<td>Required Fuel</td>

<td>Type of Flight</td>

</tr>

<tr>

<td width="50%" >

<?php Template::Show('fuel.tpl'); ?>

</td>

<td width="50%" ><?php if($schedule->flighttype=='P')

{

echo 'Passenger <b>(P)</b>';

}

?>

</td>

I assume you could just add "elseif" statements for Charter or Cargo, or whatever.

Link to comment
Share on other sites

Here is what I used for the passenger flight reference:

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

<td>Required Fuel</td>

<td>Type of Flight</td>

</tr>

<tr>

<td width="50%" >

<?php Template::Show('fuel.tpl'); ?>

</td>

<td width="50%" ><?php if($schedule->flighttype=='P')

{

echo 'Passenger <b>(P)</b>';

}

?>

</td>

I assume you could just add "elseif" statements for Charter or Cargo, or whatever.

Thank you for posting that, i finally got it too work!!!!!!!! :D

Link to comment
Share on other sites

  • 3 weeks later...

well nice mod but i can't make it to work ;(

Parse error: syntax error, unexpected '=' in /home/greeceai/public_html/fss/core/templates/fuel.tpl on line 6

		<?php
               /**
	*Fuelflow Table
	*/

       $fuelflowB737-400 = 2800 ;
       $fuelflowB737-700 = 2900 ;
       $fuelflowB737-600 = 2600 ;
       $fuelflowATR 72-500 = 0760 ;
       $fuelflowE145 = 0810 ;

       /**
	*Reserves Table
	*/

       $reservesB737-400 = 3000;
       $reservesB737-700 = 3000;
       $reservesB737-600 = 3000;
       $reservesATR 72-500 = 2500;
       $reservesE145 = 1800;

       if($schedule->aircraft == 'B737-700')
       {
           $fuelflow = $fuelflowB737;
           $reserves = $reservesB737;

       }
        elseif($schedule->aircraft == 'B737-400')
        {
        	$fuelflow = $fuelflowB734;
           $reserves = $reservesB734;

        }
        elseif($schedule->aircraft == 'B737-600')
        {
        	$fuelflow = $fuelflowB736;
           $reserves = $reservesB736;

        }
        elseif($schedule->aircraft == 'ATR 72-500')
        {
        	$fuelflow = $fuelflowATR ;
           $reserves = $reservesATR ;

        }
        elseif($schedule->aircraft == 'E145')
        {
        	$fuelflow = $fuelflowE145;
           $reserves = $reservesE145;

        }

       $fltime = explode(".", $schedule->flighttime);
	$flmin = $fltime[1] / 60;
       $flhou = $fltime[0];
       $fuelhours = $fuelflow * $flhou;
       $fuelminutes1 = $fuelflow * $flmin;
       $fuelminutes = $fuelminutes1 * 1;
       $result = $fuelhours + $fuelminutes;
       $mrreserves = 600;
       $lrreserves = 1500;
       $mr = $mrreserves + $reserves;
       $lr = $lrreserves + $reserves;
       $mlf = $fuelflow * 0.45;

           if($fuelflow == '0')
           	{
               	echo 'no fuel data available (no a/c fuelflow data)';
               }
          	elseif($schedule->flighttime == '0')
               {
                       echo '<b>'.'no aircraft performance data available <br />(missing flight duration)'.'</b>';
               }
   	    elseif($schedule->flighttime >='0.00001')
           			{
                       if($result == '0')
                       {
         	              echo '<b>'.'no aircraft performance data available'.'</b>';
                       }
                       else
               		{

                         if($schedule->distance <= '501')
                           {
                           	$result1 = $result + $reserves + $mlf;
                               echo '<b>Total: </b>';
                               echo round ($result1,-2);
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($result1 * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo '<hr>';
                               echo 'Trip: ';
                               echo round ($result,-2);
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($result * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo 'Taxi + Reserves: ';
                               echo $reserves;
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($reserves * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo 'Minimum Landing: ';
                               echo $mlf;
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($mlf * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo '<hr>';
                               echo '<font color="#FF0000">Caution</font>: Please doublecheck calculation before use !';                                  
                           }
                       		elseif($schedule->distance <= '1601')
                           {
                               $result3 = $result + $mrreserves + $reserves + $mlf;
                               echo '<b>Total: </b>';
                               echo round ($result3,-1);
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($result3 * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo '<hr>';
                               echo 'Trip: ';
                               echo round ($result,-1);
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($result * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo 'Taxi + Reserves: ';
                               echo $mr;
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($mr * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo 'Minimum Landing: ';
                               echo $mlf;
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.$mlf * 2.2.'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo '<hr>';
                               echo '<font color="#FF0000">Caution</font>: Please doublecheck calculation before use !';     

                           }
                       		elseif($schedule->distance >= '1602')
                           {
                               $result4 = $result + $lrreserves + $reserves + $mlf;
                               echo '<b>Total: </b>';
                               echo round ($result4,-1);
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($result4 * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo '<hr>';
                               echo 'Trip: ';
                               echo round ($result,-1);
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($result * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo 'Taxi + Reserves: ';
                               echo $lr;
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($lr * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo 'Minimum Landing: ';
                               echo $mlf;
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($mlf * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo '<hr>';
                               echo '<font color="#FF0000">Caution</font>: Please doublecheck calculation before use !'; 
                           }
               		}
               	}

       	        else
                   {
                       echo 'fail';
                   }

		?>

Link to comment
Share on other sites

i see at least one mistake

$reservesATR 72-500 = 2500;

you cannot write variables with spaces in it. also i would recommend you to avoid using "-" in variables if possible

"no aircraft performance data available" only comes when the script cannot recognize your aircraft or there is no aircraft in the file which has the same code

Link to comment
Share on other sites

i see at least one mistake

$reservesATR 72-500 = 2500;

you cannot write variables with spaces in it. also i would recommend you to avoid using "-" in variables if possible

Copy already corrected (also in admin center to avoid conflick)

"no aircraft performance data available" only comes when the script cannot recognize your aircraft or there is no aircraft in the file which has the same code

yes but my flight have an aircraft... here my new fuel.tpl:

		<?php
               /**
	*Fuelflow Table
	*/

       $fuelflowB737400 = 2800 ;
       $fuelflowB737700 = 2900 ;
       $fuelflowB737600 = 2600 ;
       $fuelflowATR72500 = 0760 ;
       $fuelflowE145 = 0810 ;

       /**
	*Reserves Table
	*/

       $reservesB737400 = 3000;
       $reservesB737700 = 3000;
       $reservesB737600 = 3000;
       $reservesATR72500 = 2500;
       $reservesE145 = 1800;

       if($schedule->aircraft == 'B737700')
       {
           $fuelflow = $fuelflowB737;
           $reserves = $reservesB737;

       }
        else if($schedule->aircraft == 'B737400')
        {
        	$fuelflow = $fuelflowB734;
           $reserves = $reservesB734;

        }
        else if($schedule->aircraft == 'B737600')
        {
        	$fuelflow = $fuelflowB736;
           $reserves = $reservesB736;

        }
        else if($schedule->aircraft == 'ATR72500')
        {
        	$fuelflow = $fuelflowATR ;
           $reserves = $reservesATR ;

        }
        else if($schedule->aircraft == 'E145')
        {
        	$fuelflow = $fuelflowE145;
           $reserves = $reservesE145;

        }

       $fltime = explode(".", $schedule->flighttime);
	$flmin = $fltime[1] / 60;
       $flhou = $fltime[0];
       $fuelhours = $fuelflow * $flhou;
       $fuelminutes1 = $fuelflow * $flmin;
       $fuelminutes = $fuelminutes1 * 1;
       $result = $fuelhours + $fuelminutes;
       $mrreserves = 600;
       $lrreserves = 1500;
       $mr = $mrreserves + $reserves;
       $lr = $lrreserves + $reserves;
       $mlf = $fuelflow * 0.45;

           if($fuelflow == '0')
           	{
               	echo 'no fuel data available (no a/c fuelflow data)';
               }
          	else if($schedule->flighttime == '0')
               {
                       echo '<b>'.'no aircraft performance data available <br />(missing flight duration)'.'</b>';
               }
   	    else if($schedule->flighttime >='0.00001')
           			{
                       if($result == '0')
                       {
         	              echo '<b>'.'no aircraft performance data available'.'</b>';
                       }
                       else
               		{

                         if($schedule->distance <= '501')
                           {
                           	$result1 = $result + $reserves + $mlf;
                               echo '<b>Total: </b>';
                               echo round ($result1,-2);
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($result1 * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo '<hr>';
                               echo 'Trip: ';
                               echo round ($result,-2);
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($result * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo 'Taxi + Reserves: ';
                               echo $reserves;
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($reserves * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo 'Minimum Landing: ';
                               echo $mlf;
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($mlf * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo '<hr>';
                               echo '<font color="#FF0000">Caution</font>: Please doublecheck calculation before use !';                                  
                           }
                       		else if($schedule->distance <= '1601')
                           {
                               $result3 = $result + $mrreserves + $reserves + $mlf;
                               echo '<b>Total: </b>';
                               echo round ($result3,-1);
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($result3 * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo '<hr>';
                               echo 'Trip: ';
                               echo round ($result,-1);
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($result * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo 'Taxi + Reserves: ';
                               echo $mr;
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($mr * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo 'Minimum Landing: ';
                               echo $mlf;
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.$mlf * 2.2.'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo '<hr>';
                               echo '<font color="#FF0000">Caution</font>: Please doublecheck calculation before use !';     

                           }
                       		else if($schedule->distance >= '1602')
                           {
                               $result4 = $result + $lrreserves + $reserves + $mlf;
                               echo '<b>Total: </b>';
                               echo round ($result4,-1);
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($result4 * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo '<hr>';
                               echo 'Trip: ';
                               echo round ($result,-1);
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($result * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo 'Taxi + Reserves: ';
                               echo $lr;
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($lr * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo 'Minimum Landing: ';
                               echo $mlf;
                               echo ' kg';
                               echo ' - ';
                               echo '<b>'.round ($mlf * 2.2,-1).'</b>';
                               echo ' lbs';
                               echo '<br>';
                               echo '<hr>';
                               echo '<font color="#FF0000">Caution</font>: Please doublecheck calculation before use !'; 
                           }
               		}
               	}

       	        else
                   {
                       echo 'fail';
                   }

		?>

Link to comment
Share on other sites

if($schedule->aircraft == 'B737700')

{

$fuelflow = $fuelflowB737; <-

$reserves = $reservesB737; <- those both variables have to be changed as well for example this one would be $reservesB737700

}

also do not add leading zero´s like you have here:

$fuelflowATR72500 = 0760 ;

$fuelflowE145 = 0810 ;

Link to comment
Share on other sites

if($schedule->aircraft == 'B737700')

{

$fuelflow = $fuelflowB737; <-

$reserves = $reservesB737; <- those both variables have to be changed as well for example this one would be $reservesB737700

}

also do not add leading zero´s like you have here:

$fuelflowATR72500 = 0760 ;

$fuelflowE145 = 0810 ;

Thank you so much!!!! Working Fine! realy good add on!

Regards Dimitris

p.s. keep up the good work

Link to comment
Share on other sites

I am getting the "no aircraft performance data available" on mine. But it works 100% for the main airline. The other 2 airlines under the same site have different codes and scedules etc., but they get the error. Everything pulls from the same sql database, so not sure why this happens, or how to fix it?!

Link to comment
Share on other sites

I am getting the "no aircraft performance data available" on mine. But it works 100% for the main airline. The other 2 airlines under the same site have different codes and scedules etc., but they get the error. Everything pulls from the same sql database, so not sure why this happens, or how to fix it?!

hmm check all your variables and check the names of the aircrafts. maybe there is something wrong because it should always work, no matter how much airlines you have there

Link to comment
Share on other sites

No, no spaces. The only thing I can think of, sort of, is that, when I added the new aircraft to the sql database, they start at ID#1 obviously for the first one, then when it gets to the newer aircraft, it jumps from ID#111 to ID#148 and again from ID#155 to ID#195. Now, I didn't think that would matter. I basically left room between the VA's for future aircraft additions(that's just my way). :) But, maybe that is causing odd happennings?!?

Link to comment
Share on other sites

First off, my database is not phpvms_aircraft, it is cpc_aircraft(phpvms_ is replaced with cpc_ in all the databases). Keep in mind everything else works great. If I assign a different aircraft ID# to the schedule, then it works fine. It just seems to be the ones associated with a different airline code. All schedules fall under cpc_schedules. That includes 3 airlines (CPC, EPA and WDA). All aircraft fall under cpc_aircraft (includes the same CPC, EPA and WDA aircraft). So it seems the other schedules that have the EPA and WDA airlines have an issue.

sql.jpg

fuel.jpg

Link to comment
Share on other sites

What do you want a screenshot of, exactly??? Do you want me to show the whole fuel.tpl?

Here is the error I get:

'no aircraft performance data available'

Only see just that error here:

elseif($schedule->flighttime >='0.00001')

{

if($result == '0')

{

echo '<b>'.'no aircraft performance data available'.'</b>';

Link to comment
Share on other sites

Ok, it is ONLY the B732, on the "EPA" company, that does not show fuel. I missed the HS748 in the fuel.tpl, so that is fine now, but it is that B732 that is weird. But for whatever reason. it shows the fuel details for the B732, except EPA's?! I have checked the database and it is basically the same details. I am probably just missing something obvious.

Link to comment
Share on other sites

  • 8 months later...

Ok, it is ONLY the B732, on the "EPA" company, that does not show fuel. I missed the HS748 in the fuel.tpl, so that is fine now, but it is that B732 that is weird. But for whatever reason. it shows the fuel details for the B732, except EPA's?! I have checked the database and it is basically the same details. I am probably just missing something obvious.

After I tweaked my aircraft naming, it worked great for me, tyvm :)

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 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...