Beispiel #1
0
 /**
  * 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);
     // 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);
 }
Beispiel #2
0
 /**
  * SchedulePIREPTest::testPIREPRejected()
  * 
  * @return void
  */
 public function testPIREPRejected()
 {
     $this->resetPilot();
     $sched = $this->findSchedule();
     Config::Set('PIREP_CHECK_DUPLICATE', false);
     Config::Set('EMAIL_SEND_PIREP', false);
     # Update this schedule to only pay per-hour
     SchedulesData::editScheduleFields($sched->id, array('payforflight' => 0));
     $sched = $this->findSchedule();
     $this->assertEquals(0, $sched->payforflight, 'Pay per-flight set to 0');
     $pirep_test = array('pilotid' => $this->samplePilotID, 'code' => $sched->code, 'flightnum' => $sched->flightnum, 'route' => $sched->route, 'depicao' => $sched->depicao, 'arricao' => $sched->arricao, 'aircraft' => $sched->aircraft, 'flighttime' => $sched->flighttime, 'submitdate' => 'NOW()', 'fuelused' => 6000, 'source' => 'unittest', 'comment' => 'Test Flight');
     # Update Pilot Pay to be set to zero
     PilotData::updateProfile($this->samplePilotID, array('totalpay' => 0));
     $pilot_data = PilotData::getPilotData($this->samplePilotID);
     $this->assertEquals($pilot_data->totalpay, 0, 'Reset Pilot Pay to 0');
     # File the flight report
     $pirepid = PIREPData::fileReport($pirep_test);
     $this->assertGreaterThan(0, $pirepid, PIREPData::$lasterror);
     $pirepdata = PIREPData::findPIREPS(array('p.pirepid' => $pirepid));
     $this->assertGreaterThan(0, count($pirepdata), 'No PIREPs returned');
     # Work on one...
     $pirepdata = $pirepdata[0];
     # Verify the little bits of this PIREP....
     $this->assertEquals(PILOT_PAY_HOURLY, $pirepdata->paytype, 'PIREP Pay Type');
     $this->assertEquals($pilot_data->payrate, $pirepdata->pilotpay, 'PIREP Pay Amount');
     # Check the pilot pay
     $pilot_data = PilotData::getPilotData($this->samplePilotID);
     $this->assertEquals(0, $pilot_data->totalpay, 'Check pilot pay after PIREP FILE');
     # Reject the PIREP and then check the pilot pay
     $status = PIREPData::changePIREPStatus($pirepdata->pirepid, PIREP_REJECTED);
     $pirepdata = PIREPData::findPIREPS(array('p.pirepid' => $pirepid));
     $this->assertEquals(PIREP_REJECTED, $pirepdata[0]->accepted, 'changePIREPStatus to ACCEPTED');
     $pirepdata = $pirepdata[0];
     # Check the schedule flown count:
     $post_accept = $this->findSchedule();
     $this->assertEquals($sched->timesflown, $post_accept->timesflown, "Schedule increment count");
     $post_pilot_data = PilotData::getPilotData($this->samplePilotID);
     $this->assertEquals(0, $post_pilot_data->totalpay, 'Check pilot pay after PIREP REJECT');
     $this->assertEquals($pilot_data->totalflights, $post_pilot_data->totalflights, 'Total Flights');
     # Delete the PIREP
     PIREPData::deletePIREP($pirepid);
     # Verify delete
     $data = PIREPData::findPIREPS(array('p.pirepid' => $pirepid));
     $this->assertEmpty($data, 'PIREPDdata::deletePIREP()');
 }
Beispiel #3
0
<?php

include dirname(__FILE__) . '/bootstrap.inc.php';
echo '<pre>';
$sql = 'UPDATE `' . TABLE_PREFIX . 'pireps` SET `accepted`=' . PIREP_PENDING . ' WHERE `pirepid`=2';
DB::query($sql);
PIREPData::changePIREPStatus(2, PIREP_ACCEPTED);
var_dump(LedgerData::getPaymentByPIREP(2));