ln-asm Posted June 27, 2013 Report Share Posted June 27, 2013 Hello everybody! I've tried to search for this, but I can't seem to find anything...I'm just wondering, what exactly is updated in the database when accepting a PIREP? What I have so far: - PIREP status set to 1 (accepted) - Added hours to pilot's account - Added number of flights to pilot's account but is there anything else than this? Also: is there anyone who knows where I can find the SQL query for pending PIREPs? Thank you very much for your replies! Anders Quote Link to comment Share on other sites More sharing options...
Members Vangelis Posted June 27, 2013 Members Report Share Posted June 27, 2013 I dont know what you want to do but, when you or your acars software send a pirep then a function with the name filepirep is executed This function is located in PIREPData.class https://github.com/nshahzad/phpVMS/blob/master/core/common/PIREPData.class.php And starts from line 547 till line 837 the sql statement is located in line 748 Quote Link to comment Share on other sites More sharing options...
ln-asm Posted June 27, 2013 Author Report Share Posted June 27, 2013 I was actually thinking more of what happens when you hit the "Accept"-button for pending PIREPs in the administration center, not how the PIREP itself it filed. But it looks like there could be something in this file anyway, I'll try to figure out something! But yeah, if anyone knows exactly which tables and what columns are updated in the database when you accept a PIREP, that'd be highly appreciated Anders Quote Link to comment Share on other sites More sharing options...
Members Vangelis Posted June 27, 2013 Members Report Share Posted June 27, 2013 Ok my bad. This is the Pirepadmin module in admin section https://github.com/n.../PIREPAdmin.php in line 298 is function approve_pirep_post where if you put side by side the pirepdata.class you will be able to see what is happening For example protected function approve_pirep_post() { $pirepid = $this->post->id; if($pirepid == '') return; $pirep_details = PIREPData::GetReportDetails($pirepid); # See if it's already been accepted if(intval($pirep_details->accepted) == PIREP_ACCEPTED) return; # Update pilot stats SchedulesData::IncrementFlownCount($pirep_details->code, $pirep_details->flightnum); -------------------------------------------------------------------------------------------------------------------------------- public static function IncrementFlownCount($code, $flightnum) /located in schedulesData.class.php { $schedid = intval($schedid); $code = strtoupper($code); $flightnum = strtoupper($flightnum); $sql = 'UPDATE '.TABLE_PREFIX."schedules SET timesflown=timesflown+1 WHERE code='{$code}' AND flightnum='{$flightnum}'"; $res = DB::query($sql); if(DB::errno() != 0) return false; return true; } -------------------------------------------------------------------------------------------------------------------------------- PIREPData::ChangePIREPStatus($pirepid, PIREP_ACCEPTED); // 1 is accepted -------------------------------------------------------------------------------------------------------------------------------- public static function ChangePIREPStatus($pirepid, $status)// located in PIREPData.class.php { return self::editPIREPFields($pirepid, array('accepted' => $status)); } with public static function editPIREPFields($pirepid, $fields) { if(!is_array($fields)) { return false; } $sql = "UPDATE `".TABLE_PREFIX."pireps` SET "; $sql .= DB::build_update($fields); $sql .= ' WHERE `pirepid`='.$pirepid; $res = DB::query($sql); if(DB::errno() != 0) { return false; } return true; } ------------------------------------------------------------------------------------------------------------------------------------------------------------------- PilotData::UpdateFlightData($pirep_details->pilotid, $pirep_details->flighttime, 1); PilotData::UpdatePilotPay($pirep_details->pilotid, $pirep_details->flighttime); RanksData::CalculateUpdatePilotRank($pirep_details->pilotid); PilotData::GenerateSignature($pirep_details->pilotid); StatsData::UpdateTotalHours(); LogData::addLog(Auth::$userinfo->pilotid, 'Approved PIREP #'.$pirepid); # Call the event CodonEvent::Dispatch('pirep_accepted', 'PIREPAdmin', $pirep_details); } end etc In a summary when you click on accept pirep these functions are executed $pirep_details = PIREPData::GetReportDetails($pirepid); # Update pilot stats SchedulesData::IncrementFlownCount($pirep_details->code, $pirep_details->flightnum); PIREPData::ChangePIREPStatus($pirepid, PIREP_ACCEPTED); // 1 is accepted PilotData::UpdateFlightData($pirep_details->pilotid, $pirep_details->flighttime, 1); PilotData::UpdatePilotPay($pirep_details->pilotid, $pirep_details->flighttime); RanksData::CalculateUpdatePilotRank($pirep_details->pilotid); PilotData::GenerateSignature($pirep_details->pilotid); StatsData::UpdateTotalHours(); LogData::addLog(Auth::$userinfo->pilotid, 'Approved PIREP #'.$pirepid); # Call the event CodonEvent::Dispatch('pirep_accepted', 'PIREPAdmin', $pirep_details); I hope i have solved your questions if not here we are if you want tomorrow i can make a post with the sql queries only Quote Link to comment Share on other sites More sharing options...
OA01 Posted June 28, 2013 Report Share Posted June 28, 2013 You might want to look at the DB directly, via PHP-Admin. If you look at the PIREP table it will give you a better visualisation of what gets updated. Of course, as you can see from what Vangelis has shown you, other tables get populated also, such as PIREP comments etc. At least it's easier to see than staring at code! Quote Link to comment Share on other sites More sharing options...
Members Vangelis Posted June 28, 2013 Members Report Share Posted June 28, 2013 When i was writing the post after that geek squad came and slaped me in the face 1 Quote Link to comment Share on other sites More sharing options...
ln-asm Posted June 29, 2013 Author Report Share Posted June 29, 2013 Thank you very much guys! Really appreciated I will look into this the upcoming days, and then we'll see if I can figure this out hehe Anders 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.