Пример #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;
 }
Пример #2
0
 /**
  * Change the status of a PIREP. For the status, use the constants:
  * PIREP_PENDING, PIREP_ACCEPTED, PIREP_REJECTED,PIREP_INPROGRESS
  * 
  * Also handle paying the pilot, and handle PIREP rejection, etc
  * 
  * @param int $pirepid The PIREP ID of status to change
  * @param int $status Use consts: PIREP_PENDING, PIREP_ACCEPTED, PIREP_REJECTED,PIREP_INPROGRESS
  * @return bool
  */
 public static function changePIREPStatus($pirepid, $status)
 {
     # Look up the status of the PIREP of previous
     $pirep_details = PIREPData::getReportDetails($pirepid);
     if (!$pirep_details) {
         return false;
     }
     if ($pirep_details->accepted == $status) {
         return true;
     }
     $ret = self::editPIREPFields($pirepid, array('accepted' => $status));
     # Do something if the PIREP was previously marked as pending
     if ($pirep_details->accepted == PIREP_PENDING) {
         if ($status == PIREP_ACCEPTED) {
             self::calculatePIREPPayment($pirepid);
             SchedulesData::changeFlownCount($pirep_details->code, $pirep_details->flightnum, '+1');
         } elseif ($status == PIREP_REJECTED) {
             // Do nothing, since nothing in the PIREP was actually counted
         }
     } elseif ($pirep_details->accepted == PIREP_ACCEPTED) {
         # If already accepted
         if ($status == PIREP_REJECTED) {
             LedgerData::deletePaymentByPIREP($pirep_details->pirepid);
             PilotData::resetPilotPay($pirep_details->pilotpay);
             SchedulesData::changeFlownCount($pirep_details->code, $pirep_details->flightnum, '-1');
         }
     }
     PilotData::updatePilotStats($pirep_details->pilotid);
     RanksData::calculateUpdatePilotRank($pirep_details->pilotid);
     PilotData::generateSignature($pirep_details->pilotid);
     StatsData::updateTotalHours();
     return $ret;
 }
Пример #3
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();
 }
Пример #4
0
<?php

include dirname(__FILE__) . '/bootstrap.inc.php';
echo '<pre>';
$pilot = PilotData::findPilots(array('p.totalflights > 0'));
$idx = rand(0, count($pilot) - 1);
$pilot = $pilot[$idx];
RanksData::calculateUpdatePilotRank($pilot->pilotid);
Пример #5
0
 /**
  * Change the status of a PIREP. For the status, use the constants:
  * PIREP_PENDING, PIREP_ACCEPTED, PIREP_REJECTED,PIREP_INPROGRESS
  * 
  * Also handle paying the pilot, and handle PIREP rejection, etc
  * 
  * @deprecated Use editPIREPFields instead
  */
 public static function changePIREPStatus($pirepid, $status)
 {
     # Look up the status of the PIREP of previous
     $pirep_details = PIREPData::getReportDetails($pirepid);
     if (!$pirep_details) {
         return false;
     }
     if ($pirep_details->accepted == $status) {
         return true;
     }
     $ret = self::editPIREPFields($pirepid, array('accepted' => $status));
     # Do something if the PIREP was previously marked as pending
     if ($pirep_details->accepted == PIREP_PENDING) {
         if ($status == PIREP_ACCEPTED) {
             # Pay per-schedule
             if (!empty($pirep_details->payforflight)) {
                 $sql = 'UPDATE ' . TABLE_PREFIX . "pilots \n            \t\t\t\tSET totalpay=totalpay+{$pirep_details->payforflight} \n            \t\t\t\tWHERE pilotid={$pirep_details->pilotid}";
                 DB::query($sql);
             } else {
                 # Pay by hour
                 PilotData::updatePilotPay($pirep_details->pilotid, $pirep_details->flighttime, true);
             }
             SchedulesData::changeFlownCount($pirep_details->code, $pirep_details->flightnum, '+1');
         } elseif ($status == PIREP_REJECTED) {
             // Do nothing, since nothing in the PIREP was actually counted
         }
     } elseif ($pirep_details->accepted == PIREP_ACCEPTED) {
         # If already accepted
         if ($status == PIREP_REJECTED) {
             # Subtract their pay for the rejected flight
             if (!empty($pirep_details->payforflight)) {
                 $sql = 'UPDATE ' . TABLE_PREFIX . "pilots \n            \t\t\t\tSET totalpay=totalpay-{$pirep_details->payforflight} \n            \t\t\t\tWHERE pilotid={$pirep_details->pilotid}";
                 DB::query($sql);
             } else {
                 PilotData::updatePilotPay($pirep_details->pilotid, $pirep_details->flighttime, false);
             }
             SchedulesData::changeFlownCount($pirep_details->code, $pirep_details->flightnum, '-1');
         }
     }
     PilotData::updatePilotStats($pirep_details->pilotid);
     RanksData::calculateUpdatePilotRank($pirep_details->pilotid);
     PilotData::generateSignature($pirep_details->pilotid);
     StatsData::updateTotalHours();
     return $ret;
 }