Jump to content

Recommended Posts

Posted

Not rocket science to do I guess, just need to do some simple work with a few variables:

current hours/no of hours required * 100. I guess you can then put it in a progress bar or something if you really wanted to.

Not got time right now, but I'll do a quick version for you in the morning if you want.

Jon

  • 2 years later...
Posted

I want to have a progress bar for each pilot to next rank!

Like this:

http://screencast.com/t/HYPoTYLP4az

How do I accomplish this? I have the % Complete code for Live Flights like this:

http://screencast.com/t/nE0bLsOCF

Thanks for your help!

Hey,

I am writed something for you. I'm sure it's working with bootstrap progress bar. You can try another progress bar styles. Remember to change <div class="here">

Preview: http://i.hizliresim.com/b5kQ4Z.jpg

<?php
// Code by Alp Yeni
$percentage = ($pilot_hours/$nextrank->minhours) * 100; //Calculate percentage to next rank.
$round = round($percentage); // Round percentage because xxx.x% is not good for CSS.
echo '<div class="progress">'; // Create progress bar
echo "<div class='progress-bar' role='progressbar' aria-valuenow='60' aria-valuemin='0' aria-valuemax='100' style='width: ", $round, "%'></div>"; // Progress bar inner
echo '<span class="sr-only">' .$round. '% Complete</span>'; // Progress bar percentage
echo '</div>'; //close inner
echo '</div>'; // Close percentage bar
?>

For more bootstrap progress-bar styles: http://getbootstrap....nents/#progress

Thanks!

Posted

Alright, I am a little bit confused, actually really confused. I think I have part of it working but I am unsure if it is percentage to next rank or final rank (which wouldn't make since, as i want it to be to next rank in line for the pilot). A few things I am going to try to explain, I hope.

Here is the code from above:

<?php
// Code by Alp Yeni
$percentage = ($pilot_hours/$nextrank->minhours) * 100; //Calculate percentage to next rank.
$round = round($percentage); // Round percentage because xxx.x% is not good for CSS.
echo '<div class="progress">'; // Create progress bar
echo "<div class='progress-bar' role='progressbar' aria-valuenow='60' aria-valuemin='0' aria-valuemax='100' style='width: ", $round, "%'></div>"; // Progress bar inner
echo '<span class="sr-only">' .$round. '% Complete</span>'; // Progress bar percentage
echo '</div>'; //close inner
echo '</div>'; // Close percentage bar
?>

Than I used my acarsmap.tpl styling in my style sheet, and adjusted it for his code:

.progress {
 border: 1px solid #000000;
 border-radius: 5px;
 width: 150px; 
 margin: 0px 0px 0px 0px; 
 padding: 1px; 
 float: middle; 
 background: #f2f2f2;
}

.progress-bar {
 background-color: #FF0000; 
 height: 10px;
 vertical-align:right;
}

It appears to be working but I am not completely sure. Here are some example screen shots:

http://screencast.com/t/VOb4gils2sOL

http://screencast.com/t/qLGqSvmsX

And than me as admin which I gave myself the max hours to get me to the highest rank as a test, and I get this error because i am at the max rank:

http://screencast.com/t/yURELrCZH

And of course a pilot that is a new hire it states 0% which is kinda confusing to me as shouldn't it state a percentage to next rank.

New pilot no hours:

http://screencast.com/t/neT0yhbY

Also want it to state you have whatever % to next rank and show the rank in words, whatever the next rank is!

Posted

I really think the current code could be done better, as it is now showing the % required in total. To better explain, here is an example. Think of a rank structure like this:

Rank1 = 0-10h

Rank2 = 10-20h

Rank3 = 20-30h

If I have 15h now, I am 50% on my way to the next rank, Rank3. Correct? (20-10=10h, 15-10=5h, and 5 is a half of 10) But, judging by your code, it would tell me I am 15/20*100 = 75% on my way to the rank.

I mean, both ways are technically correct, but I think my way of thinking is a bit better :)

<?php
$get_rank_information = RanksData::getRankName(Auth::$userinfo->rank);
$current_mh = $get_rank_information->minhours;
$difference = $nextrank->minhours - $current_mh; //hours between 2 ranks
$hours_in_rank = $pilot_hours - $get_rank_information->minhours;
$percent = round(((100 * $hours_in_rank)/$difference));
?>

And you'll probably need to place this in RanksData.class.php

public static function getRankName($rank)
{
$rank = DB::escape($rank);
$sql = "SELECT * FROM phpvms_ranks WHERE rank='$rank'";
return DB::get_row($sql);
}

In the end, I might be wrong, really late here...if that's the case, I'll just edit this in the morning not to confuse people

Posted

Yeah your right what I have is not working right. What I originally wanted was the "You have 87 hours left until your promotion to Second Officer" to show a progress bar, not the percentage thing I ended up with :)

Posted

I have this in the profile main file:

<div class="progress">

<div class="progress-bar">

<div style="width: $pilothours-$nextrank->minhours </div>

</div>

</div>

and this in the css:

.progress {

border: 1px solid #000000;

border-radius: 5px;

width: 300px;

margin: 0px 0px 0px 350px;

padding: 1px 1px 1px 25px;

float: middle;

background: #f2f2f2;

}

.progress-bar {

background-color: #FF0000;

height: 10px;

vertical-align:right;

}

http://screencast.com/t/AMPGjba4II

Notice it is set to 50 hours so the progress bar should be half way and starting from the left not the right!

It showing a progress bar but it is backwards and does not change when I change the pilot hours. And alignment in my css needs work which I know, but I can't get it to work right :)

Thanks for your help. I appreciate it!

Posted

Really late here, and I am very tired. Just taken a rough look at this, and spotted one obvious error for now.

Instead of

<div style="width: $pilothours-$nextrank->minhours </div>

Try

<div style="width: <?php echo round($pilothours-$nextrank->minhours); ?>%"></div>

if there is anything else that is making an issue, I'll try and help out tomorrow :)

  • 1 month later...
  • Moderators
Posted

A good atlernative way (if you can't do it using css etc) would be to create different images with the progress bar loading and call them based on a specific percentage. For example, if the pilot is on the 50%, you will call the "progress/50.png" etc.

Posted

I have the progress bar working for percentage to rank, what I don't know how to do is the complete range of ranks, from the beginning rank to the ending rank and showing a progress bar as pilots go through the entire rank range (or whatever rank they receive and stop at) to the last rank.

I have this and its working properly, as far as the correct percentage to next rank:

It's 100 hours to the next rank so the test pilot is at 27% (or 27 hours) of 100 and has 73% (or 73 hours) of 100 to the next rank. And it works.

http://screencast.com/t/8NDkNJxc49p

Thanks everyone for your help!

  • Like 1

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...