public function testChangePIREPStatus() { # Reject it first $status = PIREPData::ChangePIREPStatus($this->pirep_id, PIREP_REJECTED); $this->assertTrue($status, DB::$error); # Verify status change $this->report_details = PIREPData::GetReportDetails($this->pirep_id); $this->assertEqual($this->report_details->accepted, PIREP_REJECTED); # Change to accepted $status = PIREPData::ChangePIREPStatus($this->pirep_id, PIREP_ACCEPTED); $this->assertTrue($status, DB::$error); # Verify status change $this->report_details = PIREPData::GetReportDetails($this->pirep_id); $this->assertEqual($this->report_details->accepted, PIREP_ACCEPTED); # Verify other changes due to accept echo '<br />'; }
/** * Reject the report, and then send them the comment * that was entered into the report */ protected function reject_pirep_post() { $pirepid = $this->post->pirepid; $comment = $this->post->comment; if ($pirepid == '' || $comment == '') { return; } PIREPData::ChangePIREPStatus($pirepid, PIREP_REJECTED); // 2 is rejected $pirep_details = PIREPData::GetReportDetails($pirepid); // If it was previously accepted, subtract the flight data if (intval($pirep_details->accepted) == PIREP_ACCEPTED) { PilotData::UpdateFlightData($pirep_details->pilotid, -1 * floatval($pirep->flighttime), -1); } //PilotData::UpdatePilotStats($pirep_details->pilotid); RanksData::CalculateUpdatePilotRank($pirep_details->pilotid); PilotData::resetPilotPay($pirep_details->pilotid); StatsData::UpdateTotalHours(); // Send comment for rejection if ($comment != '') { $commenter = Auth::$userinfo->pilotid; // The person logged in commented PIREPData::AddComment($pirepid, $commenter, $comment); // Send them an email $this->set('firstname', $pirep_details->firstname); $this->set('lastname', $pirep_details->lastname); $this->set('pirepid', $pirepid); $message = Template::GetTemplate('email_commentadded.tpl', true); Util::SendEmail($pirep_details->email, 'Comment Added', $message); } LogData::addLog(Auth::$userinfo->pilotid, 'Rejected PIREP #' . $pirepid); # Call the event CodonEvent::Dispatch('pirep_rejected', 'PIREPAdmin', $pirep_details); }
/** * Approve the PIREP, and then update * the pilot's data */ protected function approve_pirep_post() { $pirepid = $this->post->id; if ($pirepid == '') { return; } $pirep_details = PIREPData::getReportDetails($pirepid); $this->set('pirep', $pirep_details); # See if it's already been accepted if (intval($pirep_details->accepted) == PIREP_ACCEPTED) { return; } # Update pilot stats PIREPData::ChangePIREPStatus($pirepid, PIREP_ACCEPTED); // 1 is accepted LogData::addLog(Auth::$userinfo->pilotid, 'Approved PIREP #' . $pirepid); # Call the event CodonEvent::Dispatch('pirep_accepted', 'PIREPAdmin', $pirep_details); }