Jump to content

Jakes

Members
  • Posts

    72
  • Joined

  • Last visited

Everything posted by Jakes

  1. Ok, my question now is this: in the code below the Aircraft registration is retrieved from the pirep, but the database must write to the ID. now how is the ID coupled to the registration here? Even if you have the pirep read by ID as well, how does the Pirep ID which is $aircraft->id connect to the ID in suppose to write to the DB here: private function updateAircraft($id, $cond) { the entire code: <?php class Aircraft_Condition extends CodonModule { public function __construct() { CodonEvent::addListener('Aircraft_Condition'); } public function EventListener($eventinfo) { if($eventinfo[0] == 'pirep_filed') { $pirepinfo = $eventinfo[2]; $aircraft = OperationsData::getAircraftByReg($pirepinfo->registration); if($pirepinfo->landingrate < -100 && $pirepinfo->landingrate > -500) $cond = $aircraft->cond -20; else $cond = 100; $update = $this->updateAircraft($aircraft->id, $cond); } } private function updateAircraft($id, $cond) { $sql = 'UPDATE '.TABLE_PREFIX."aircraft SET `cond` = '$cond' WHERE `id` = '$id'"; $res = DB::query($sql); if(DB::errno() != 0) return false; CodonCache::delete('all_aircraft'); CodonCache::delete('all_aircraft_enabled'); CodonCache::delete('all_aircraft_search'); CodonCache::delete('all_aircraft_search_enabled'); return true; } }
  2. Hi thomas, this is not the calculation for the condition as in the 'cond' value, but it is the conditions used when calculating the prize of a new plane. You will see there is also a condition for used planes etc.
  3. Thanks Jeffrey, for your help! I have tested it, with no luck though, and that gave me second thoughts on the event it is based on, named Pirep_filed. Why I am saying this is, when will the condition be updated? when the pilot press the file pirep button, or when it is approved? Secondly, IF it is updated when the pirep is filed, then, with approval, I guess the condition is updated again? so basically two scripts updating the same condition. So I am back to square 1... Where is the initial code that update the condition....
  4. I have tried a different approach: I figured if you can have a command like this: if (DB::errno() != 0) return false; CodonCache::delete('all_aircraft'); you could maybe use it the other way around? Like OperationsData::update('cond'); So here is what I have UNTESTED I have set the condition to write to a value of 50 just for testing purposes. I also decided to go with Aircraft Reg rather than ID. Is that wise? <?php /** * phpVMS - Virtual Airline Administration Software * Copyright (c) 2008 Nabeel Shahzad * For more information, visit www.phpvms.net * Forums: http://www.phpvms.net/forum * Documentation: http://www.phpvms.net/docs * * phpVMS is licenced under the following license: * Creative Commons Attribution Non-commercial Share Alike (by-nc-sa) * View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/ * */ class Aircraft_Condition extends CodonModule { public function __index() { CodonEvent::addListener('Aircraft_Condition'); } public function EventListener($eventinfo) { if($eventinfo[0] == 'pirep_filed') { $pirepinfo = $eventinfo[2]; } } public static function editAircraft($data) { //Retrieve the aircraft info based on the aircraft id stored in the pirep row $data['registration'] = OperationsData::getAircraftByReg($pirepinfo->registration) if ($pirepinfo->landingrate > -1 && $pirepinfo->landingrate <-2000) { $data('cond') = 50; } $res = DB::query($sql); OperationsData::update('cond'); if (DB::errno() != 0) return false; CodonCache::delete('all_aircraft'); CodonCache::delete('all_aircraft_enabled'); CodonCache::delete('all_aircraft_search'); CodonCache::delete('all_aircraft_search_enabled'); return true; } }}
  5. Just going over everything, and wanted to make sure, is this statement correct (I know the figures are insane, but just for testing purposes) //Figure out the $cond that needs to be placed into the if($pirepinfo->landingrate > -1 && $pirepinfo->landingrate <-2000) $cond = $aircraft->cond -20; Shouldn't it be: //Figure out the $cond that needs to be placed into the if($pirepinfo->landingrate > -1)&& ($pirepinfo->landingrate <-2000) $cond = $aircraft->cond -20;
  6. Ok, I have this so far, without any error, but it does not overwrite the condition. what did i miss? Is there more to do than just add the module? <?php /** * phpVMS - Virtual Airline Administration Software * Copyright (c) 2008 Nabeel Shahzad * For more information, visit www.phpvms.net * Forums: http://www.phpvms.net/forum * Documentation: http://www.phpvms.net/docs * * phpVMS is licenced under the following license: * Creative Commons Attribution Non-commercial Share Alike (by-nc-sa) * View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/ * */ class Aircraft_Condition extends CodonModule { public function __index() { CodonEvent::addListener('Aircraft_Condition'); } public function EventListener($eventinfo) { if($eventinfo[0] == 'pirep_filed') $pirepinfo = $eventinfo[2]; //Retrieve the aircraft info based on the aircraft id stored in the pirep row $aircraft = OperationsData::getAircraftByReg($pirepinfo->registration); //Figure out the $cond that needs to be placed into the if($pirepinfo->landingrate > -100 && $pirepinfo->landingrate <-500) $cond = $aircraft->cond -20; //update the 'cond' column using the aircraft id for row identification $update = OperationsData::editAircraft(array('id'=>$pirepinfo->aircraftid, 'cond'=>$cond)); } }
  7. Hi Thomas, Thanks for the response. I found the culprit. the if($eventinfo[0] == 'pirep_filed') was without the last bracket ok, so no more error, but I have run a test or two, and it does not update the 'cond' value. Maybe I must have the codon module to listen for event before pirep is filed? here is the code as it is now: <?php /** * phpVMS - Virtual Airline Administration Software * Copyright (c) 2008 Nabeel Shahzad * For more information, visit www.phpvms.net * Forums: http://www.phpvms.net/forum * Documentation: http://www.phpvms.net/docs * * phpVMS is licenced under the following license: * Creative Commons Attribution Non-commercial Share Alike (by-nc-sa) * View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/ * */ class Aircraft_Condition extends CodonModule { public function __index() { CodonEvent::addListener('Aircraft_Condition'); } public function EventListener($eventinfo) { if($eventinfo[0] == 'pirep_filed') //Retrieve the aircraft info based on the aircraft id stored in the pirep row $aircraft = OperationsData::getAircraftInfo($pirepinfo->aircraftid); //Figure out the $cond that needs to be placed into the if($pirepinfo->landingrate > -200 && $pirepinfo->landingrate <-500) $cond = $aircraft->cond -20; //update the 'cond' column using the aircraft id for row identification $update = OperationsData::editAircraft(array('id'=>$pirepinfo->aircraftid, 'cond'=>$cond)); } } As soon as the basic condition work, i will add more conditions based on landing rates
  8. I guess it is on the right track, but I get the following error: Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in /home/jdsarcco/public_html/uvsaaf/core/modules/Aircraft_Condition/Aircraft_Condition.php on line 21
  9. Ok I guess it is better to add it's own independent listner. I am following these documentation and trying to compile an independend module: This is what I have: class Aircraft_Condition extends CodonModule { CodonEvent::addListener('Aircraft_Condition'); } public function EventListener($eventinfo) { if($eventinfo[0] == 'pirep_filed' { $pirepinfo = $eventinfo[1]; if($pirepinfo->landingrate > -200 && $pirepinfo->landingrate <-500); return DB::get_row('SELECT cond FROM ' . TABLE_PREFIX . 'aircraft WHERE `id`=' . $AircraftID); $cond = $cond -20 } } Not working though. I wish I knew more about coding
  10. At the moment I am trying to add it to the core/modules/KACARS_Free/kACARS_Free.php module. Is there a better place to add it to?
  11. Thanks for the response, gents, first, Well, manual pireps does not have a landing rate (although I am sure it could file a default of foe example -150) But even if the code is added there, I guess it is basically the same? The values I have entered is not exact, it must be played around to get the set that works the best. Tanks for the input! Ok, so now I have this: public function updateCondition() $Landing = $xml->$xml->pirep->landing, $AircraftID =>$xml->liveupdate->registration, { return DB::get_row('SELECT cond FROM ' . TABLE_PREFIX . 'aircraft WHERE `id`=' . $AircraftID); } } if( $landing > -200 && $landing < -300 ){ $cond = $cond -7 } else if ( $landing > -300 && $landing < -400 ){ $cond = $cond -15 } else if ( $landing > -400 && $landing < -500 ){ $cond = $cond -30 } else if ( $landing > -500 ){ $cond = $cond -50 } The idea is to get the landing rate from the pirep instead of the DB, as it could not be filed yet
  12. Hi there, I have installed the Step 1 Aircraft buying Mod Version 0.91, and in the database, Under Aircraft, it added a table named 'cond' for aircraft condition. Is there a way that when filing a pirep with kACARS, it reads the current condition of the aircraft, and based on the landing rate, it write a new condition to the table? The idea is with a landing with a rate between -200 and -300 to subtract 7% from the condition. From -300 to -400 to subtract 15% from the condition and -400 to -500 subtract 30%. any landing harder than -500 subtract 50%. I was thinking of the core/modules/KACARS_Free/kACARS_Free.php module, maybe it can be write into that? my own UNSUCCESFULL and incomplete attempt so far: //START ADD CONDITION TO LANDING RATE $selsql = "SELECT cond FROM MySQLaircraft where aircraftID=$ac"; $result = mysql_query($selsql); $no_record = mysql_num_rows($result); if($no_record > 0) while($row = mysql_fetch_array($result)) { echo '<tr><td>'.$row['cond'].'</td></tr>'; } if( $landing > -200 && $landing < -300 ) { $cond = $cond -7% } else if ( $landing > -300 && $landing < -400 ) { $cond = $cond -15% } else if ( $landing > -400 && $landing < -500 ) { $cond = $cond -30% } else if ( $landing > -500 ) { $cond = $cond -50% } // END ADD CONDITION TO LANDING RATE Any help perhaps?
  13. Yes, but somewhere there is a code that calculate the aircraft useage. With this installation there is a table added named "cond" for aircraft condition. And after installation, and all the aircraft are brought, the conditions are not all 100%. Some of my aircraft are 95% even. So where is that condition calculated?
  14. Hi Jacques, I am trying to figure out how the condition is calculated in the first place, but cannot find the file containing that info. will see what I can do Cheers, Jakes
  15. Hi there, Thanks for a great modification! What are the conditions used to calculate the aircraft condition? and in what file is it coded? Best regards Jakes
  16. Jakes

    Flowchart

    Hi there, Is there a way to make a page with a flowchart I can use for indicating Line of command? Best regards,
  17. Hi there, in the local_config.php there is the option to automatically set users inactive if not active. Mine is set for true -60 days. However, it does not set any pilot inactive at all. My code as it is now: # After how long to mark a pilot inactive, in days Config::Set('PILOT_AUTO_RETIRE', true); Config::Set('PILOT_INACTIVE_TIME', 60); If someone can maybe direct me to the solution for this, i will appreciate it! Best Regards,
  18. Solved the problem was in the navigation.tpl file in my ObsessBlueskin. To fix it: Find: if(Auth::UserInGroup('Administrators')) replace with: if(PilotGroups::group_has_perm(Auth::$usergroups, ACCESS_ADMIN))
  19. Hi there, I have created a new group named Commanding Officers, and I gave the following access: ACCESS_ADMIN MODERATE_PIREP The idea is to have the group have acces to approve pireps, but nothing else. I also have a test account added to the group, but the admin page is not showing up at all. Do I miss some settings perhaps? Have a look at http://www.uvsaaf.fsworld.co.za/index.php Best regards, Jakes
  20. Jakes

    VAForum 2

    Thank you for the quick response. I am learning still
  21. Jakes

    VAForum 2

    Hi there, I have spend an hour searching for the file to edit to add this snippet on to my web page. If it is not too much of an effort, can you please indicate which file to edit?
  22. Got it, installed, and working great, Thank you! Only thing I try to figuer out is how to notify of new posts, in any form
  23. Hi there, I want to download and install this mod, but the attachment are unavailable. Can someone maybe help me out?
  24. Ok, I have added the code you provided to /core/common/TouchdownStatsData.class.php, and then, I get the following error: What do I miss? When I enter a statistic value for example 10, it work perfect, but with an airline code, I also get this error. Link to first 10 stats: http://uvsaaf.fsworld.co.za/index.php/TouchdownStats/top_landings/10'>http://uvsaaf.fsworld.co.za/index.php/TouchdownStats/top_landings/10 Link to error: http://uvsaaf.fsworld.co.za/index.php/TouchdownStats/top_landings/ I guess this should work when placing the airline code instead? here are some of the airlines (Squadrons) we operate: CEF Central Flying School Langebaaan CFS 85 Combat Flying School FFS 44 Squadron FTS 15 Squadron HFS 87 Helicopter Flying School Thank you, Jakes
×
×
  • Create New...