protected function edit_schedule_post() { if ($this->post->code == '' || $this->post->flightnum == '' || $this->post->deptime == '' || $this->post->arrtime == '' || $this->post->depicao == '' || $this->post->arricao == '') { $this->set('message', 'All of the fields must be filled out'); $this->render('core_error.tpl'); return; } $enabled = $this->post->enabled == 'on' ? true : false; $this->post->route = strtoupper($this->post->route); # Format the flight level $this->post->flightlevel = str_replace(',', '', $this->post->flightlevel); $this->post->flightlevel = str_replace(' ', '', $this->post->flightlevel); # Clear anything invalid out of the route $this->post->route = strtoupper($this->post->route); $this->post->route = str_replace($this->post->depicao, '', $this->post->route); $this->post->route = str_replace($this->post->arricao, '', $this->post->route); $this->post->route = str_replace('SID', '', $this->post->route); $this->post->route = str_replace('STAR', '', $this->post->route); $data = array('code' => $this->post->code, 'flightnum' => $this->post->flightnum, 'depicao' => $this->post->depicao, 'arricao' => $this->post->arricao, 'route' => $this->post->route, 'aircraft' => $this->post->aircraft, 'flightlevel' => $this->post->flightlevel, 'distance' => $this->post->distance, 'deptime' => $this->post->deptime, 'arrtime' => $this->post->arrtime, 'flighttime' => $this->post->flighttime, 'daysofweek' => implode('', $_POST['daysofweek']), 'price' => $this->post->price, 'flighttype' => $this->post->flighttype, 'notes' => $this->post->notes, 'enabled' => $enabled); $val = SchedulesData::editScheduleFields($this->post->id, $data); if (!$val) { $this->set('message', 'There was an error editing the schedule: ' . DB::error()); $this->render('core_error.tpl'); return; } # Parse the route: SchedulesData::getRouteDetails($this->post->id, $this->post->route); $this->set('message', 'The schedule "' . $this->post->code . $this->post->flightnum . '" has been edited'); $this->render('core_success.tpl'); LogData::addLog(Auth::$userinfo->pilotid, 'Edited schedule "' . $this->post->code . $this->post->flightnum . '"'); }
/** * 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()'); }
/** * Operations::edit_schedule_post() * * @return */ protected function edit_schedule_post() { $this->checkPermission(EDIT_SCHEDULES); if ($this->post->code == '' || $this->post->flightnum == '' || $this->post->deptime == '' || $this->post->arrtime == '' || $this->post->depicao == '' || $this->post->arricao == '') { $this->set('message', 'All of the fields must be filled out'); $this->render('core_error.php'); return; } $enabled = $this->post->enabled == 'on' ? true : false; $this->post->route = strtoupper($this->post->route); # Format the flight level $this->post->flightlevel = str_replace(',', '', $this->post->flightlevel); $this->post->flightlevel = str_replace(' ', '', $this->post->flightlevel); # Clear anything invalid out of the route $this->post->route = strtoupper($this->post->route); $this->post->route = str_replace($this->post->depicao, '', $this->post->route); $this->post->route = str_replace($this->post->arricao, '', $this->post->route); $this->post->route = str_replace('SID', '', $this->post->route); $this->post->route = str_replace('STAR', '', $this->post->route); if (is_array($_POST['daysofweek'])) { $daysofweek = implode('', $_POST['daysofweek']); } else { $daysofweek = '0123456'; # default activate for all days } #var_dump($_POST); if (is_array($_POST['week1'])) { $week1 = implode('', $_POST['week1']); } else { $week1 = ''; } if (is_array($_POST['week2'])) { $week2 = implode('', $_POST['week2']); } else { $week2 = ''; } if (is_array($_POST['week3'])) { $week3 = implode('', $_POST['week3']); } else { $week3 = ''; } if (is_array($_POST['week4'])) { $week4 = implode('', $_POST['week4']); } else { $week4 = ''; } $data = array('code' => $this->post->code, 'flightnum' => $this->post->flightnum, 'depicao' => $this->post->depicao, 'arricao' => $this->post->arricao, 'route' => $this->post->route, 'aircraft' => $this->post->aircraft, 'flightlevel' => $this->post->flightlevel, 'distance' => $this->post->distance, 'deptime' => $this->post->deptime, 'arrtime' => $this->post->arrtime, 'flighttime' => $this->post->flighttime, 'daysofweek' => $daysofweek, 'week1' => $week1, 'week2' => $week2, 'week3' => $week3, 'week4' => $week4, 'price' => $this->post->price, 'payforflight' => $this->post->payforflight, 'flighttype' => $this->post->flighttype, 'notes' => $this->post->notes, 'enabled' => $enabled); $val = SchedulesData::editScheduleFields($this->post->id, $data); if (!$val) { $this->set('message', 'There was an error editing the schedule: ' . DB::error()); $this->render('core_error.php'); return; } # Parse the route: SchedulesData::getRouteDetails($this->post->id, $this->post->route); $this->set('message', 'The schedule "' . $this->post->code . $this->post->flightnum . '" has been edited'); $this->render('core_success.php'); LogData::addLog(Auth::$userinfo->pilotid, 'Edited schedule "' . $this->post->code . $this->post->flightnum . '"'); }