Exemplo n.º 1
0
 public function savepro()
 {
     if ($this->post->firstname == '' || $this->post->lastname == '') {
         $this->set('message', 'The first or lastname cannot be blank!');
         $this->render('core_error.tpl');
         return;
     }
     $params = array('firstname' => $this->post->firstname, 'lastname' => $this->post->lastname, 'email' => $this->post->email, 'hub' => $this->post->hub, 'retired' => $this->post->retired, 'totalflights' => $this->post->totalflights, 'totalpay' => floatval($this->post->totalpay), 'transferhours' => $this->post->transferhours);
     PilotData::updateProfile($this->post->pilotid, $params);
     PilotData::SaveFields($this->post->pilotid, $_POST);
     /* Don't calculate a pilot's rank if this is set */
     if (Config::Get('RANKS_AUTOCALCULATE') == false) {
         PilotData::changePilotRank($this->post->pilotid, $this->post->rank);
     } else {
         RanksData::calculateUpdatePilotRank($this->post->pilotid);
     }
     StatsData::UpdateTotalHours();
     $this->set('message', 'Profile updated successfully');
     $this->render('core_success.tpl');
     $this->set('pilots', PilotData::getAllPilots());
     $this->render('/pm/pilot_manager.php');
     if ($this->post->resend_email == 'true') {
         $this->post->id = $this->post->pilotid;
         $this->resendemail(false);
     }
     $pilot = PilotData::getPilotData($this->post->pilotid);
     LogData::addLog(Auth::$userinfo->pilotid, 'Updated profile for ' . PilotData::getPilotCode($pilot->code, $pilot->pilotid) . ' ' . $pilot->firstname . ' ' . $pilot->lastname);
     return;
     break;
 }
Exemplo n.º 2
0
    public function testTimesAdded()
    {
        echo '<h3>Checking Times</h3>';
        $sql = 'SELECT `flighttime`
			  FROM ' . TABLE_PREFIX . 'pireps 
			  WHERE `accepted`=' . PIREP_ACCEPTED;
        $results = DB::get_results($sql);
        $this->added_time = 0;
        foreach ($results as $row) {
            $this->added_time = Util::AddTime($this->added_time, $row->flighttime);
        }
        heading('Time added, all PIREPS at once');
        $this->assertNotEqual(0, $this->added_time);
        heading('Time added, pilot by pilot');
        // Now calculate by PIREP
        $allpilots = PilotData::GetAllPilots();
        $total = 0;
        foreach ($allpilots as $pilot) {
            $p_hours = PilotData::getPilotHours($pilot->pilotid);
            $total = Util::AddTime($total, $p_hours);
        }
        $this->assertNotEqual(0, $total);
        heading('Comparing pilot to pilot vs all PIREPS');
        $this->assertEqual($total, $this->added_time);
        heading('Compare to STAT total hours');
        StatsData::UpdateTotalHours();
        $this->assertEqual($total, StatsData::TotalHours());
        echo '<br />';
    }
Exemplo n.º 3
0
    public function testTimesAdded()
    {
        $sql = 'SELECT `flighttime`
			  FROM ' . TABLE_PREFIX . 'pireps 
			  WHERE `accepted`=' . PIREP_ACCEPTED;
        $results = DB::get_results($sql);
        if (!$results) {
            $this->markTestSkipped('No PIREPs to test against');
        }
        $this->added_time = 0;
        foreach ($results as $row) {
            $this->added_time = Util::AddTime($this->added_time, $row->flighttime);
        }
        $this->assertNotEqual(0, $this->added_time);
        // Now calculate by PIREP
        $allpilots = PilotData::GetAllPilots();
        $total = 0;
        foreach ($allpilots as $pilot) {
            $p_hours = PilotData::getPilotHours($pilot->pilotid);
            $total = Util::AddTime($total, $p_hours);
        }
        $this->assertNotEqual(0, $total);
        $this->assertEqual($total, $this->added_time);
        StatsData::UpdateTotalHours();
        $this->assertEqual($total, StatsData::TotalHours());
    }
Exemplo n.º 4
0
 protected function edit_pirep_post()
 {
     if ($this->post->code == '' || $this->post->flightnum == '' || $this->post->depicao == '' || $this->post->arricao == '' || $this->post->aircraft == '' || $this->post->flighttime == '') {
         $this->set('message', 'You must fill out all of the required fields!');
         $this->render('core_error.tpl');
         return false;
     }
     $pirepInfo = PIREPData::getReportDetails($this->post_action->pirepid);
     if (!$pirepInfo) {
         $this->set('message', 'Invalid PIREP!');
         $this->render('core_error.tpl');
         return false;
     }
     $this->post->fuelused = str_replace(' ', '', $this->post->fuelused);
     $this->post->fuelused = str_replace(',', '', $this->post->fuelused);
     $fuelcost = $this->post->fuelused * $this->post->fuelunitcost;
     # form the fields to submit
     $data = array('pirepid' => $this->post->pirepid, 'code' => $this->post->code, 'flightnum' => $this->post->flightnum, 'leg' => $this->post->leg, 'depicao' => $this->post->depicao, 'arricao' => $this->post->arricao, 'aircraft' => $this->post->aircraft, 'flighttime' => $this->post->flighttime, 'load' => $this->post->load, 'price' => $this->post->price, 'pilotpay' => $this->post->pilotpay, 'fuelused' => $this->post->fuelused, 'fuelunitcost' => $this->post->fuelunitcost, 'fuelprice' => $fuelcost, 'expenses' => $this->post->expenses);
     if (!PIREPData::UpdateFlightReport($this->post->pirepid, $data)) {
         $this->set('message', 'There was an error editing your PIREP');
         $this->render('core_error.tpl');
         return false;
     }
     PIREPData::SaveFields($this->post->pirepid, $_POST);
     //Accept or reject?
     $this->post->id = $this->post->pirepid;
     $submit = strtolower($this->post->submit_pirep);
     // Add a comment
     if (trim($this->post->comment) != '' && $submit != 'reject pirep') {
         PIREPData::AddComment($this->post->pirepid, Auth::$userinfo->pilotid, $this->post->comment);
     }
     if ($submit == 'accept pirep') {
         $this->approve_pirep_post();
     } elseif ($submit == 'reject pirep') {
         $this->reject_pirep_post();
     }
     StatsData::UpdateTotalHours();
     # Update a pilot's stats
     PilotData::updatePilotStats($pirepInfo->pilotid);
     LogData::addLog(Auth::$userinfo->pilotid, 'Edited PIREP #' . $this->post->id);
     return true;
 }
Exemplo n.º 5
0
 /**
  * Maintenance::resethours()
  * 
  * @return
  */
 public function resethours()
 {
     CodonModule::checkPermission(MAINTENANCE);
     echo '<h3>Updating Total Hours Count</h3>';
     $total = 0;
     echo '<p>Calculating hours for all pilots: <br />';
     $allpilots = PilotData::GetAllPilots();
     foreach ($allpilots as $pilot) {
         $hours = PilotData::UpdateFlightHours($pilot->pilotid);
         $total = Util::AddTime($total, $hours);
         echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid) . " - found {$hours} flight hours for number <br />";
     }
     echo "Pilots have a total of <strong>{$total} hours</strong><br /><br />";
     echo "<strong>Now counting from PIREPS</strong><br />";
     StatsData::UpdateTotalHours();
     echo 'Found ' . StatsData::TotalHours() . ' total hours, updated<br /></p>';
     LogData::addLog(Auth::$userinfo->pilotid, 'Reset hours');
 }
Exemplo n.º 6
0
 public function viewpilots()
 {
     /* This function is called for *ANYTHING* in that popup box
        
        Preset all of the template items in this function and
        call them in the subsequent templates
        
        Confusing at first, but easier than loading each tab
        independently via AJAX. Though may be an option later
        on, but can certainly be done by a plugin (Add another
        tab through AJAX). The hook is available for whoever
        wants to use it
        */
     switch ($this->post->action) {
         case 'changepassword':
             $this->ChangePassword();
             return;
             break;
         case 'deletepilot':
             $pilotid = $this->post->pilotid;
             $pilotinfo = PilotData::getPilotData($pilotid);
             PilotData::DeletePilot($pilotid);
             CodonEvent::Dispatch('pilot_deleted', 'PilotAdmin', $pilot);
             $this->set('message', Lang::gs('pilot.deleted'));
             $this->render('core_success.tpl');
             LogData::addLog(Auth::$userinfo->pilotid, 'Deleted pilot ' . PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid) . ' ' . $pilotinfo->firstname . ' ' . $pilotinfo->lastname);
             break;
             /* These are reloaded into the #pilotgroups ID
                so the entire groups list is refreshed
                */
         /* These are reloaded into the #pilotgroups ID
            so the entire groups list is refreshed
            */
         case 'addgroup':
             $this->AddPilotToGroup();
             $this->SetGroupsData($this->post->pilotid);
             $this->render('pilots_groups.tpl');
             return;
             break;
         case 'removegroup':
             $this->RemovePilotGroup();
             $this->SetGroupsData($this->post->pilotid);
             $this->render('pilots_groups.tpl');
             return;
             break;
         case 'saveprofile':
             if ($this->post->firstname == '' || $this->post->lastname == '') {
                 $this->set('message', 'The first or lastname cannot be blank!');
                 $this->render('core_error.tpl');
                 return;
             }
             if (intval($this->post->retired) == 1) {
                 $retired = true;
             } else {
                 $retired = false;
             }
             $params = array('code' => $this->post->code, 'firstname' => $this->post->firstname, 'lastname' => $this->post->lastname, 'email' => $this->post->email, 'location' => $this->post->location, 'hub' => $this->post->hub, 'retired' => $retired, 'totalhours' => $this->post->totalhours, 'totalflights' => $this->post->totalflights, 'totalpay' => floatval($this->post->totalpay), 'payadjust' => floatval($this->post->payadjust), 'transferhours' => $this->post->transferhours, 'comment' => $this->post->comment);
             PilotData::updateProfile($this->post->pilotid, $params);
             PilotData::SaveFields($this->post->pilotid, $_POST);
             /* Don't calculate a pilot's rank if this is set */
             if (Config::Get('RANKS_AUTOCALCULATE') == false) {
                 PilotData::changePilotRank($this->post->pilotid, $this->post->rank);
             } else {
                 RanksData::calculateUpdatePilotRank($this->post->pilotid);
             }
             StatsData::UpdateTotalHours();
             $this->set('message', 'Profile updated successfully');
             $this->render('core_success.tpl');
             $pilot = PilotData::getPilotData($this->post->pilotid);
             LogData::addLog(Auth::$userinfo->pilotid, 'Updated profile for ' . PilotData::getPilotCode($pilot->code, $pilot->pilotid) . ' ' . $pilot->firstname . ' ' . $pilot->lastname);
             return;
             break;
     }
     if ($this->get->action == 'viewoptions') {
         $this->ViewPilotDetails();
         return;
     }
     $this->ShowPilotsList();
 }
Exemplo n.º 7
0
    $sql = 'SELECT * 
					FROM ' . TABLE_PREFIX . "settings\n\t\t\t\t\tWHERE name='TOTAL_HOURS'";
    $res = DB::get_row($sql);
    if (!$res) {
        $sql = "INSERT INTO `phpvms_settings` (`friendlyname`, `name`, `value`,`descrip`,`core`)\n\t\t\tVALUES ('Total Hours', 'TOTAL_HOURS', '', 'These are the total hours your VA has flown', '0')";
        DB::query($sql);
    }
    echo '<strong>Updating hours</strong><br />';
    $allpilots = PilotData::GetAllPilots();
    foreach ($allpilots as $pilot) {
        $hours = PilotData::UpdateFlightHours($pilot->pilotid);
        $total = Util::AddTime($total, $hours);
    }
    echo "Pilots have a total of <strong>{$total} hours</strong><br /><br />";
    echo "<strong>Updating PIREPS  Hours</strong><br />";
    StatsData::UpdateTotalHours();
    echo 'Found ' . StatsData::TotalHours() . ' total hours, updated<br />';
}
if ($version < 20854) {
    Installer::add_to_config('USERS_ONLINE_TIME', 20, 'The StatsData::UserOnline() function - how many minutes to check');
    Installer::sql_file_update(SITE_ROOT . '/install/update_854.sql');
}
Installer::sql_file_update(SITE_ROOT . '/install/update.sql');
OperationsData::updateAircraftRankLevels();
/* Add them to the default group */
$allpilots = PilotData::GetAllPilots();
foreach ($allpilots as $pilot) {
    PilotGroups::AddUsertoGroup($pilot->pilotid, DEFAULT_GROUP);
}
/* Update expenses */
//FinanceData::updateAllExpenses();