Jump to content

kenny

Members
  • Posts

    23
  • Joined

  • Last visited

Posts posted by kenny

  1. Hi man!

    I wanted to know if you can also pay for free flights or charter . Now if a pilot makes a flight by checking the " charter flight" option in the ACARS , it is not paid and are not even calculated fuel costs . I wish I could also pay those who make free flights , perhaps by calculating a percentage less than the full pay ...

    Thanks

  2. Mmm... i'm not sure what do you mean... sorry.

    I copy my rankdataclass with my modify.

    <?php

    /**

    * phpVMS - Virtual Airline Administration Software

    * Copyright © 2008 Nabeel Shahzad

    * For more information, visit www.phpvms.net

    * Forums: http://www.phpvms.net/forum'>http://www.phpvms.net/forum

    * Documentation: http://www.phpvms.net/docs'>http://www.phpvms.net/docs

    *

    * phpVMS is licenced under the following license:

    * Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)

    * View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/

    *

    * @author Nabeel Shahzad

    * @copyright Copyright © 2008, Nabeel Shahzad

    * @link http://www.phpvms.net

    * @license http://creativecommons.org/licenses/by-nc-sa/3.0/

    */

    class RanksData extends CodonData {

    static $lasterror;

    /**

    * Return information about the rank, given the ID

    */

    public static function getRankInfo($rankid) {

    $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'ranks

    WHERE rankid=' . $rankid;

    return DB::get_row($sql);

    }

    public static function getRankByName($name) {

    $sql = 'SELECT *

    FROM `' . TABLE_PREFIX . "ranks`

    WHERE `rank`='{$name}'";

    return DB::get_row($sql);

    }

    /**

    * Returns all the ranks, and the total number of pilots

    * on each rank

    */

    public static function getAllRanks() {

    $allranks = CodonCache::read('all_ranks');

    if ($allranks === false) {

    $sql = 'SELECT r.*,

    (SELECT COUNT(*) FROM ' . TABLE_PREFIX .'pilots WHERE rank=r.rank) as totalpilots

    FROM ' . TABLE_PREFIX . 'ranks r

    ORDER BY r.minhours ASC';

    $allranks = DB::get_results($sql);

    CodonCache::write('all_ranks', $allranks, 'long');

    }

    return $allranks;

    }

    public static function getRankImage($rank) {

    $sql = 'SELECT `rankimage` FROM ' . TABLE_PREFIX . 'ranks WHERE rank="' . $rank .

    '"';

    return DB::get_var($sql);

    }

    /**

    * Get the level the passed rank is in the list

    */

    public static function getRankLevel($rankid) {

    if ($rankid == 0) {

    return 0;

    }

    $all_ranks = self::getAllRanks();

    $i = 0;

    foreach ($all_ranks as $rank) {

    $i++;

    if ($rank->rankid == $rankid) {

    return $i;

    }

    }

    return 0;

    }

    /**

    * Give the number of hours and flights, return the next rank

    */

    public static function getNextRank($hours, $flights) {

    $sql = "SELECT * FROM " . TABLE_PREFIX . "ranks

    WHERE MinHours<=$hours AND MinFlights<=$flights ORDER BY MinHours DESC LIMIT 1";

    return DB::get_row($sql);

    }

    /**

    * Add a ranking. This will automatically call

    * CalculatePilotRanks() at the end

    */

    public static function addRank($title, $minhours, $minflighs, $imageurl, $payrate) {

    $minhours = intval($minhours);

    $minflights = intval($minflights);

    $payrate = floatval($payrate);

    $sql = "INSERT INTO " . TABLE_PREFIX .

    "ranks (rank, rankimage, minhours, minflights, payrate)

    VALUES('$title', '$imageurl', '$minhours', '$minflights', $payrate)";

    $ret = DB::query($sql);

    if (DB::$errno == 1062) {

    self::$lasterror = 'This already exists';

    return false;

    }

    CodonCache::delete('all_ranks');

    self::calculatePilotRanks();

    return true;

    }

    /**

    * Update a certain rank

    */

    public static function updateRank($rankid, $title, $minhours, $minflights, $imageurl, $payrate) {

    $minhours = intval($minhours);

    $minflights = intval($minflights);

    $payrate = floatval($payrate);

    $sql = "UPDATE " . TABLE_PREFIX . "ranks

    SET rank='$title', rankimage='$imageurl', minhours='$minhours', minflights='$minflights', payrate=$payrate

    WHERE rankid=$rankid";

    $res = DB::query($sql);

    if (DB::errno() != 0) return false;

    CodonCache::delete('all_ranks');

    self::calculatePilotRanks();

    return true;

    }

    /**

    * Delete a rank, and then recalculate

    */

    public static function deleteRank($rankid) {

    $sql = 'DELETE FROM ' . TABLE_PREFIX . 'ranks WHERE rankid=' . $rankid;

    DB::query($sql);

    if (DB::errno() != 0) return false;

    CodonCache::delete('all_ranks');

    self::CalculatePilotRanks();

    return true;

    }

    /**

    * Go through each pilot, check their hours, and see where they

    * stand in the rankings. If they are above the minimum hours

    * for that rank level, then make $last_rank that text. At the

    * end, update that

    */

    public static function calculatePilotRanks() {

    /* Don't calculate a pilot's rank if this is set */

    if (Config::Get('RANKS_AUTOCALCULATE') === false) {

    return;

    }

    $ranks_list = self::getAllRanks();

    $pilots = PilotData::getAllPilots();

    if (count($pilots) == 0 || !is_array($pilots)) {

    return;

    }

    foreach ($pilots as $pilot) {

    self::calculateUpdatePilotRank($pilot->pilotid, $ranks_list);

    }

    }

    public static function calculateUpdatePilotRank($pilotid, $ranks_list = null) {

    /* Don't calculate a pilot's rank if this is set */

    if (Config::Get('RANKS_AUTOCALCULATE') == false) {

    return;

    }

    if($ranks_list === null) {

    $ranks_list = self::getAllRanks();

    }

    $pilotid = intval($pilotid);

    $pilot = PilotData::getPilotData($pilotid);

    $pilothours = $pilot->totalhours;

    $pilotflights = $pilot->totalflights;

    if (Config::Get('TRANSFER_HOURS_IN_RANKS') == true) {

    $pilothours += $pilot->transferhours;

    }

    $i = 0;

    foreach ($ranks_list as $rank) {

    $i++;

    if ($pilothours >= intval($rank->minhours)) {

    $rank_level = $i;

    $last_rank = $rank->rank;

    $last_rankid = $rank->rankid;

    }

    }

    $update = array(

    'rankid' => $last_rankid,

    'rank' => $last_rank,

    'ranklevel' => $rank_level,

    );

    PilotData::updateProfile($pilot->pilotid, $update);

    if($pilot->rank != $last_rank) {

    $message = Lang::get('activity.pilot.promotion');

    $message = str_replace('$rank', $last_rank, $message);

    # Add it to the activity feed

    ActivityData::addActivity(array(

    'pilotid' => $pilotid,

    'type' => ACTIVITY_PROMOTION,

    'refid' => $pilotid,

    'message' => htmlentities($message),

    ));

    }

    }

    }

  3. Hello guys, I need a little help.

    I wish the ranks were awarded not only based on the hours but also the number of flights made.

    I was able to bring up the function in the admin panel and make it work. The table in the database is updated correctly, but if I add the hours to a pilot with the "transert hours" the rank is increased even if there isn't a number of required flights.

    Can anyone help me?

  4. Hi man, i would like to have a pilot roser without Hub separations. I would like a single list.

    I have insert this code in Pilots.php, but i have this error in roster page: Warning: Invalid argument supplied for foreach() in /home/hfrjgrdn/sites/phpvms/core/templates/pilots_list.php on line 33.

    Can you help me?

  5. Hi sir, i have install your version of phpvms, but i have a problem with Captcha. In a registration form, when click on register, i see this error:

    Fatal error: Class 'ReCaptcha' not found in /home/hfrjgrdn/sites/dfyvanet/phpvms/core/modules/Registration/Registration.php on line 178

    Can you help me please?

  6. to all with the error try the following in your commen change the husstransfer class the part for the get all requests to the following $sql = "SELECT h.pilotid, p.firstname, p.lastname, p.email, p.hub, h.hub_initial, h.hub_req, h.date_submitted, h.reason, h.status FROM ".TABLE_PREFIX."hubtransfer h LEFT JOIN ".TABLE_PREFIX."pilots p ON p.pilotid = h.pilotid";

    $ret = DB::get_results($sql);

    return $ret;

    this fixzd mine thanks to the help of manuel from crazy creatives

    can you copy your code in "HubTransfertData.class.php" from line 51 to exd of modify?

    Thanks

×
×
  • Create New...