Esempio 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;
 }
Esempio n. 2
0
 public function sendpireps()
 {
     echo '<h3>Sending all PIREPS</h3>';
     $within_timelimit = CronData::check_hoursdiff('update_pireps', CentralData::$limits['update_pireps']);
     if ($within_timelimit == true) {
         echo '<p>You can only export PIREPs every ' . CentralData::$limits['update_pireps'] . ' hours</p>';
         return false;
     }
     $ret = CentralData::send_all_pireps();
     $this->parse_response($ret);
     LogData::addLog(Auth::$userinfo->pilotid, 'vaCentral - PIREPS sent');
 }
Esempio n. 3
0
 public function sendmail()
 {
     $this->checkPermission(EMAIL_PILOTS);
     echo '<h3>Sending email</h3>';
     if ($this->post->subject == '' || trim($this->post->message) == '') {
         $this->set('message', 'You must enter a subject and message!');
         $this->render('core_error.php');
         return;
     }
     if (count($this->post->groups) == 0) {
         $this->set('message', 'You must select groups to send to!');
         $this->render('core_error.php');
         return;
     }
     echo 'Sending email...<br />';
     $pilotarray = array();
     //Begin the nice long assembly of e-mail addresses
     foreach ($this->post->groups as $groupid) {
         if ($groupid == 'all') {
             $all_pilots = PilotData::findPilots(array());
             foreach ($all_pilots as $pilot) {
                 $pilotarray[$pilot->pilotid] = $pilot;
             }
             break;
         } else {
             $tmp = PilotGroups::getUsersInGroup($groupid);
             if (count($tmp) == 0 || !is_array($tmp)) {
                 continue;
             }
             foreach ($tmp as $pilot) {
                 $pilotarray[$pilot->pilotid] = $pilot;
             }
         }
     }
     $subject = DB::escape($this->post->subject);
     $message = stripslashes($this->post->message) . PHP_EOL . PHP_EOL;
     # Do some quick fixing of obvious formatting errors
     $message = str_replace('<br>', '<br />', $message);
     foreach ($pilotarray as $pilot) {
         echo 'Sending for ' . $pilot->firstname . ' ' . $pilot->lastname . '<br />';
         # Variable replacements
         $send_message = str_replace('{PILOT_FNAME}', $pilot->firstname, $message);
         $send_message = str_replace('{PILOT_LNAME}', $pilot->lastname, $send_message);
         $send_message = str_replace('{PILOT_ID}', PilotData::GetPilotCode($pilot->code, $pilot->pilotid), $send_message);
         $send_message = utf8_encode($send_message);
         Util::SendEmail($pilot->email, $subject, $send_message);
     }
     echo 'Complete!';
     LogData::addLog(Auth::$userinfo->pilotid, 'Sent pass mail');
     return;
 }
Esempio n. 4
0
 private function doPaymentCash(PaymentParams $paymentParams)
 {
     $parameters = array(PayUParameters::ACCOUNT_ID => $this->getAccountID(), PayUParameters::REFERENCE_CODE => $paymentParams->getReference(), PayUParameters::DESCRIPTION => $paymentParams->getDescription(), PayUParameters::VALUE => $paymentParams->getAmount(), PayUParameters::CURRENCY => $paymentParams->getCurrency(), PayUParameters::TAX_VALUE => $paymentParams->getTax(), PayUParameters::TAX_RETURN_BASE => $paymentParams->getTaxBase(), PayUParameters::BUYER_EMAIL => $paymentParams->getBuyerEmail(), PayUParameters::PAYER_NAME => $paymentParams->getPayerName(), PayUParameters::PAYER_DNI => $paymentParams->getPayerDni(), PayUParameters::PAYMENT_METHOD => $paymentParams->getPaymentMethod(), PayUParameters::COUNTRY => $paymentParams->getCountry(), PayUParameters::EXPIRATION_DATE => $paymentParams->getExpirationDate(), PayUParameters::IP_ADDRESS => $paymentParams->getIpAddress());
     $result = array();
     $code = 01;
     $rawResult = '';
     //Action
     try {
         $response = PayUPayments::doAuthorizationAndCapture($parameters);
         $rawResult = $response;
         if ($response) {
             $result['code'] = $code;
             $result['message'] = str_replace('{OPERACION@OPERACION}', 'PayUPayments::doAuthorizationAndCapture', $this->getMessage($code));
             $result['response']['order'] = $response->transactionResponse->orderId;
             $result['response']['transaction'] = $response->transactionResponse->transactionId;
             if ($response->transactionResponse->state == "PENDING") {
                 $status = 05;
                 $result['response']['pendingReason'] = str_replace('{RAZON@RAZON}', $response->transactionResponse->pendingReason, $this->getMessage($status));
                 $result['response']['reference'] = $response->transactionResponse->extraParameters->REFERENCE;
                 $result['response']['urlReceipt'] = '<a class="btn" id="print" href="' . $response->transactionResponse->extraParameters->URL_PAYMENT_RECEIPT_HTML . '" target="_blank">Ver Comprobante</a>';
             }
             if (isset($response->transactionResponse->responseCode)) {
                 $result['response']['responseCode'] = $response->transactionResponse->responseCode;
             }
             $logdata['invoiceid'] = $paymentParams->getReference();
             $logdata['orderid'] = $result['response']['order'];
             $logdata['transaction'] = $result['response']['transaction'];
             $logdata['status'] = $result['response']['state'];
             $logdata['paymentmethod'] = $paymentParams->getPaymentMethod();
             $logdata['message'] = $result['message'];
             $logdata['urlReceipt'] = $result['response']['urlReceipt'];
             $logdata['fecha'] = date("Y-m-d H:i:s");
             $logdata['expiracion'] = $paymentParams->getExpirationDate();
             LogData::saveData($logdata);
         }
     } catch (Exception $e) {
         $code = 00;
         $result['code'] = $code;
         $result['message'] = str_replace('{OPERACION@OPERACION}', 'PayUPayments::doAuthorizationAndCapture', $this->getMessage($code));
         $result['exception'] = $e->getMessage();
     }
     $notificacion = '';
     $notificacion .= "Parametros:\n";
     $notificacion .= json_encode($parameters);
     $notificacion .= "\n\n";
     $notificacion .= "Respuesta:\n";
     $notificacion .= json_encode($result);
     $notificacion .= "\n\n";
     $notificacion .= "Respuesta (RAW):\n";
     $notificacion .= json_encode($rawResult);
     //Result
     return $result;
 }
Esempio n. 5
0
 protected function PIREP_DeleteField()
 {
     $id = DB::escape($this->post->id);
     $ret = PIREPData::DeleteField($id);
     if (DB::errno() != 0) {
         $this->set('message', 'There was an error deleting the field: ' . DB::$err);
         $this->render('core_error.tpl');
     } else {
         LogData::addLog(Auth::$userinfo->pilotid, 'Deleted PIREP field');
         $this->set('message', 'The field was deleted');
         $this->render('core_success.tpl');
     }
 }
Esempio n. 6
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;
 }
Esempio n. 7
0
 protected function delete_schedule_post()
 {
     $schedule = SchedulesData::findSchedules(array('s.id' => $this->post->id));
     SchedulesData::DeleteSchedule($this->post->id);
     $params = array();
     if (DB::errno() != 0) {
         $params['status'] = 'There was an error deleting the schedule';
         $params['error'] = DB::error();
         echo json_encode($params);
         return;
     }
     $params['status'] = 'ok';
     echo json_encode($params);
     LogData::addLog(Auth::$userinfo->pilotid, 'Deleted schedule "' . $schedule->code . $schedule->flightnum . '"');
 }
Esempio n. 8
0
 protected function edit_award_post()
 {
     if ($this->post->name == '' || $this->post->image == '') {
         $this->set('message', 'The name and image must be entered');
         $this->render('core_error.tpl');
         return;
     }
     $ret = AwardsData::EditAward($this->post->awardid, $this->post->name, $this->post->descrip, $this->post->image);
     $this->set('message', 'Award Added!');
     $this->render('core_success.tpl');
     LogData::addLog(Auth::$userinfo->pilotid, 'Edited the award "' . $this->post->name . '"');
 }
Esempio n. 9
0
 public function processExpense()
 {
     if ($this->post->name == '' || $this->post->cost == '') {
         $this->set('message', 'Name and cost must be entered');
         $this->render('core_error.tpl');
         return;
     }
     if (!is_numeric($this->post->cost)) {
         $this->set('message', 'Cost must be a numeric amount, no symbols');
         $this->render('core_error.tpl');
         return;
     }
     if ($this->post->action == 'addexpense') {
         # Make sure it doesn't exist
         if (FinanceData::GetExpenseByName($this->post->name)) {
             $this->set('message', 'Expense already exists!');
             $this->render('core_error.tpl');
             return;
         }
         $ret = FinanceData::AddExpense($this->post->name, $this->post->cost, $this->post->type);
         $this->set('message', 'The expense "' . $this->post->name . '" has been added');
         FinanceData::setExpensesforMonth(time());
         LogData::addLog(Auth::$userinfo->pilotid, 'Added expense "' . $this->post->name . '"');
     } elseif ($this->post->action == 'editexpense') {
         $ret = FinanceData::EditExpense($this->post->id, $this->post->name, $this->post->cost, $this->post->type);
         $this->set('message', 'The expense "' . $this->post->name . '" has been edited');
         FinanceData::setExpensesforMonth(time());
         LogData::addLog(Auth::$userinfo->pilotid, 'Edited expense "' . $this->post->name . '"');
     }
     if (!$ret) {
         $this->set('message', 'Error: ' . DB::error());
         $this->render('core_error.tpl');
         return;
     }
     $this->render('core_success.tpl');
 }
Esempio n. 10
0
 public function index()
 {
     $params = array();
     $this->set('all_logs', LogData::findLogs($params));
     $this->render('logs_index.tpl');
 }
Esempio n. 11
0
    /**
     * Maintenance::resetpireproute()
     * 
     * @return
     */
    public function resetpireproute()
    {
        CodonModule::checkPermission(MAINTENANCE);
        echo '<h3>Reset cached PIREP routes</h3> 
				Resetting... <br />';
        PIREPData::deleteAllRouteDetails();
        echo 'Completed!';
        LogData::addLog(Auth::$userinfo->pilotid, 'Reset cached pirep route details');
    }
Esempio n. 12
0
    public function resetpireproute()
    {
        echo '<h3>Reset cached PIREP routes</h3> 
				Resetting... <br />';
        PIREPData::deleteAllRouteDetails();
        echo 'Completed!';
        LogData::addLog(Auth::$userinfo->pilotid, 'Reset cached pirep route details');
    }
Esempio n. 13
0
 protected function DeleteNewsItem()
 {
     $this->checkPermission(EDIT_NEWS);
     if (!SiteData::DeleteItem($this->post->id)) {
         $this->set('message', Lang::gs('news.delete.error'));
         $this->render('core_error.php');
         return;
     }
     $this->set('message', Lang::gs('news.item.deleted'));
     $this->render('core_success.php');
     LogData::addLog(Auth::$userinfo->pilotid, 'Deleted news ' . $this->post->id);
 }
Esempio n. 14
0
 protected function AddAward()
 {
     if ($this->post->awardid == '' || $this->post->pilotid == '') {
         return;
     }
     # Check if they already have this award
     $award = AwardsData::GetPilotAward($this->post->pilotid, $this->post->awardid);
     if ($award) {
         $this->set('message', Lang::gs('award.exists'));
         $this->render('core_error.tpl');
         return;
     }
     AwardsData::AddAwardToPilot($this->post->pilotid, $this->post->awardid);
     $pilot = PilotData::getPilotData($this->post->pilotid);
     LogData::addLog(Auth::$userinfo->pilotid, 'Added and award to ' . PilotData::getPilotCode($pilot->code, $pilot->pilotid) . ' - ' . $pilot->firstname . ' ' . $pilot->lastname);
 }