Jump to content

Rank with numberflight conditions


Recommended Posts

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?

Link to post
Share on other sites

Hello Friend,

When you adciona hours for members, the system does the calculation

automatic.

I suggest you do the exchange of manually patent, for this to be resolved,

Follow the instructions below.

Yoursite.com/ core / app.config and local.config.php

Config::Set('RANKS_AUTOCALCULATE', true);

Change to

Config::Set('RANKS_AUTOCALCULATE', false);

(This will cause the system does not automatically compute the rank for the number of hours since this time to their manual inserting pilots.)

After that possibly you will need to manually change the ranks,

open the administrative site.

Yoursite.com/admin

Then locate the / Pilot & Groups / View All Pilots

Click the option / edit / locate / Current Rank option

And switch to rank the pilot should be, repeat this for all members.

Link to post
Share on other sites

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),

));

}

}

}

Link to post
Share on other sites

The rank system it is based only calculations of hours when you disable means that you will evaluate manuals criteria of rank change according to its charter.

The system does not manage the calculation of ranks by any other means, only sums hours.

The pilot reaches 10 hours of flights to be flown or transferred, the automatic calculation system changes the pilot's rank.

If you keep this manual disabling, you are responsible for doing this manual.

The phpvms that is distributed free of form is how it works now if you want something complex, a system to evaluate the conditions in accordance with its regulation is needed someone to do.

That's another thing, something that we are not addressing here.

You want something based on aircraft restrictions, flight hours.

to be more specific so we can create something according to your requirements.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...