示例#1
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;
 }
示例#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
 /**
  * Add a  User
  * 
  * $data = array(
  * 'firstname' => '',
  * 'lastname' => '',
  * 'email' => '',
  * 'password' => '',
  * 'code' => '',
  * 'location' => '',
  * 'hub' => '',
  * 'confirm' => false);
  */
 public static function addUser($data)
 {
     /*$data = array(
       'firstname' => '',
       'lastname' => '',
       'email' => '',
       'password' => '',
       'code' => '',
       'location' => '',
       'hub' => '',
       'confirm' => false);*/
     $exists = self::CheckUserEmail($data['email']);
     if (is_object($exists)) {
         self::$error = 'Email already exists';
         return false;
     }
     //Set the password, add some salt
     $salt = md5(date('His'));
     $password = md5($data['password'] . $salt);
     //Stuff it into here, the confirmation email will use it.
     self::$salt = $salt;
     $code = DB::escape(strtoupper($data['code']));
     $firstname = DB::escape(ucwords($data['firstname']));
     $lastname = DB::escape(ucwords($data['lastname']));
     $location = DB::escape(strtoupper($data['location']));
     //Add this stuff in
     if ($data['confirm'] === true) {
         $confirm = 1;
     } else {
         $confirm = 0;
     }
     $sql = "INSERT INTO " . TABLE_PREFIX . "pilots (firstname, lastname, email,\n\t\t\t\t\tcode, location, hub, password, salt, confirmed, joindate, lastip)\n\t\t\t\t  VALUES (\n                    '{$firstname}', '{$lastname}', '{$data['email']}', '{$code}',\n\t\t\t\t\t'{$location}', '{$data['hub']}', '{$password}', \n                    '{$salt}', {$confirm}, NOW(), \n                    '{$_SERVER['REMOTE_ADDR']}'\n                    )";
     $res = DB::query($sql);
     if (DB::errno() != 0) {
         if (DB::errno() == 1062) {
             self::$error = 'This email address is already registered';
             return false;
         }
         self::$error = DB::error();
         return false;
     }
     //Grab the new pilotid, we need it to insert those "custom fields"
     $pilotid = DB::$insert_id;
     RanksData::CalculateUpdatePilotRank($pilotid);
     PilotData::generateSignature($pilotid);
     /* Add them to the default group */
     $defaultGroup = SettingsData::getSettingValue('DEFAULT_GROUP');
     PilotGroups::addUsertoGroup($pilotid, $defaultGroup);
     // For later
     self::$pilotid = $pilotid;
     //Get customs fields
     $fields = self::getCustomFields();
     if (count($fields) > 0) {
         foreach ($fields as $field) {
             $value = Vars::POST($field->fieldname);
             $value = DB::escape($value);
             if ($value != '') {
                 $sql = "INSERT INTO `" . TABLE_PREFIX . "fieldvalues` (fieldid, pilotid, value)\n    \t\t\t\t\t\t\tVALUES ({$field->fieldid}, {$pilotid}, '{$value}')";
                 DB::query($sql);
             }
         }
     }
     $pilotdata = PilotData::getPilotData($pilotid);
     /* Add this into the activity feed */
     $message = Lang::get('activity.new.pilot');
     foreach ($pilotdata as $key => $value) {
         $message = str_replace('$' . $key, $value, $message);
     }
     # Add it to the activity feed
     ActivityData::addActivity(array('pilotid' => $pilotid, 'type' => ACTIVITY_NEW_PILOT, 'refid' => $pilotid, 'message' => htmlentities($message)));
     return true;
 }