Пример #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);
     // 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);
 }
Пример #2
0
 /**
  * Add a payment for a PIREP.
  * 
  * @param int $pirepid PIREP ID
  * @return
  */
 public static function calculatePIREPPayment($pirepid)
 {
     $pirep = DB::get_row('SELECT `pirepid`, `pilotid`, 
                 `flighttime_stamp`, `pilotpay`, 
             `paytype`, `flighttype`, `accepted`
         FROM `' . TABLE_PREFIX . 'pireps`
         WHERE `pirepid`=' . $pirepid);
     if ($pirep->accepted == PIREP_REJECTED) {
         return false;
     }
     if ($pirep->paytype == PILOT_PAY_HOURLY) {
         # Price out per-hour?
         $peices = explode(':', $pirep->flighttime_stamp);
         $minutes = $peices[0] * 60 + $peices[1];
         $amount = $minutes * ($pirep->pilotpay / 60);
     } elseif ($pirep->paytype == PILOT_PAY_SCHEDULE) {
         $amount = $pirep->pilotpay;
     }
     $params = array('pirepid' => $pirepid, 'pilotid' => $pirep->pilotid, 'paysource' => PAYSOURCE_PIREP, 'paytype' => $pirep->paytype, 'amount' => $amount);
     $entry = LedgerData::getPaymentByPIREP($pirepid);
     if (!$entry) {
         LedgerData::addPayment($params);
     } else {
         LedgerData::editPayment($entry->id, $params);
     }
     PilotData::resetPilotPay($pirep->pilotid);
     return $amount;
 }
Пример #3
0
 public function resetpilotpay()
 {
     echo '<h3>Resetting Pilot Pay</h3>';
     $allpilots = PilotData::GetAllPilots();
     foreach ($allpilots as $p) {
         $total = PilotData::resetPilotPay($p->pilotid);
         echo "{$p->firstname} {$p->lastname} - total \$ {$total}<br />";
     }
     echo 'Done';
     LogData::addLog(Auth::$userinfo->pilotid, 'Reset pilot pay');
 }
Пример #4
0
 /**
  * LedgerData::deletePayment()
  * 
  * @param mixed $pirep_id
  * @return void
  */
 public static function deletePaymentByPIREP($pirepid)
 {
     $payment = self::getPaymentByPIREP($pirepid);
     $ret = DB::query('DELETE FROM `' . TABLE_PREFIX . 'ledger`
          WHERE `pirepid`=' . $pirepid);
     PilotData::resetPilotPay($payment->pilotid);
     return $ret;
 }