hjhjhgjgjh Posted October 27, 2009 Report Share Posted October 27, 2009 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 Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted October 27, 2009 Administrators Report Share Posted October 27, 2009 You could probably code that yourself straight into the template Quote Link to comment Share on other sites More sharing options...
hjhjhgjgjh Posted October 27, 2009 Author Report Share Posted October 27, 2009 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 ?> Quote Link to comment Share on other sites More sharing options...
jantorre Posted October 27, 2009 Report Share Posted October 27, 2009 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 Quote Link to comment Share on other sites More sharing options...
hjhjhgjgjh Posted October 27, 2009 Author Report Share Posted October 27, 2009 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 Quote Link to comment Share on other sites More sharing options...
jantorre Posted October 27, 2009 Report Share Posted October 27, 2009 Oh, i spotted the if for flighttime, then there is no more from me, let me know if it works 8) Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted October 28, 2009 Administrators Report Share Posted October 28, 2009 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; ?> Quote Link to comment Share on other sites More sharing options...
hjhjhgjgjh Posted October 28, 2009 Author Report Share Posted October 28, 2009 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 Quote Link to comment Share on other sites More sharing options...
hjhjhgjgjh Posted October 28, 2009 Author Report Share Posted October 28, 2009 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> Quote Link to comment Share on other sites More sharing options...
hjhjhgjgjh Posted October 28, 2009 Author Report Share Posted October 28, 2009 ok i made a lot of changes and will publish the new version tomorrow Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted October 29, 2009 Administrators Report Share Posted October 29, 2009 You should use an editor like netbeans or zend studio which has syntax highlighting and error checking, it'll make your life much easier Quote Link to comment Share on other sites More sharing options...
hjhjhgjgjh Posted October 29, 2009 Author Report Share Posted October 29, 2009 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> Quote Link to comment Share on other sites More sharing options...
James200410 Posted October 29, 2009 Report Share Posted October 29, 2009 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 Quote Link to comment Share on other sites More sharing options...
hjhjhgjgjh Posted October 29, 2009 Author Report Share Posted October 29, 2009 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 Quote Link to comment Share on other sites More sharing options...
hjhjhgjgjh Posted October 29, 2009 Author Report Share Posted October 29, 2009 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? Quote Link to comment Share on other sites More sharing options...
James200410 Posted October 29, 2009 Report Share Posted October 29, 2009 ok thanks will check that now Quote Link to comment Share on other sites More sharing options...
M-Queiroz Posted October 29, 2009 Report Share Posted October 29, 2009 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 Quote Link to comment Share on other sites More sharing options...
hjhjhgjgjh Posted October 29, 2009 Author Report Share Posted October 29, 2009 and if you can do that, do it i cant Quote Link to comment Share on other sites More sharing options...
James200410 Posted October 29, 2009 Report Share Posted October 29, 2009 Thanks Very much tebinu, that worked. Now I got to go and make the fuel data more accurate, lol Thanks again Adam Quote Link to comment Share on other sites More sharing options...
M-Queiroz Posted October 30, 2009 Report Share Posted October 30, 2009 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 Quote Link to comment Share on other sites More sharing options...
James200410 Posted October 30, 2009 Report Share Posted October 30, 2009 I got no idea ... but it looks good ;D Quote Link to comment Share on other sites More sharing options...
hjhjhgjgjh Posted October 30, 2009 Author Report Share Posted October 30, 2009 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 Quote Link to comment Share on other sites More sharing options...
James200410 Posted October 30, 2009 Report Share Posted October 30, 2009 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 Quote Link to comment Share on other sites More sharing options...
M-Queiroz Posted October 31, 2009 Report Share Posted October 31, 2009 as is getting the JA're running MYSQL see 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. Quote Link to comment Share on other sites More sharing options...
hjhjhgjgjh Posted October 31, 2009 Author Report Share Posted October 31, 2009 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. Quote Link to comment Share on other sites More sharing options...
hjhjhgjgjh Posted October 31, 2009 Author Report Share Posted October 31, 2009 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'; } ?> Quote Link to comment Share on other sites More sharing options...
M-Queiroz Posted October 31, 2009 Report Share Posted October 31, 2009 as is getting the JA're running MYSQL see fuel.v1.0.zip Quote Link to comment Share on other sites More sharing options...
M-Queiroz Posted October 31, 2009 Report Share Posted October 31, 2009 then only this cumin to myql to the table to be easier to configure each aircraft i add the aircraft and it puts the fuel to spend hours just by what I now have to do this part are you doing I'm trying here too ok let go and that we will know aogem help us. Quote Link to comment Share on other sites More sharing options...
hjhjhgjgjh Posted October 31, 2009 Author Report Share Posted October 31, 2009 yea i just tried your way but it always shows zero ??? Quote Link to comment Share on other sites More sharing options...
jantorre Posted November 1, 2009 Report Share Posted November 1, 2009 I have not included flighttime in the schedule so I simply made it a value * distance + reserve = fuel . Remember that for short flights, fuel per mile will be higher than for long flights because of climb/cruise time, so you have to balance the number a bit. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.