Jump to content

Last Flight?


freshJet

Recommended Posts

Does anyone know the code for this? I have seen one before, however it was for the public profile. I've got it working too, but I want it now on the Pilot Centre, so when the pilot views the pilot centre, it says how long it's been since their last flight, for example:

Your last flight was 3 days ago.

That way, they know whether they are in danger of being marked inactive or not. I remember Virtual Norwegian had it when I flew for them...

  • Like 1
Link to comment
Share on other sites

<?php
		if ($userinfo->lastpirep == '0000-00-00 00:00:00') {
			echo 'You have not flown any flights yet!';
		}
		else {
			$datebefore1 = substr($userinfo->lastpirep, 0, 10);
			$datetoday2 = date("Y-m-d");
			$datebefore3 = strtotime($datebefore1);
			$datetoday4 = strtotime($datetoday2);
			$newdate = $datetoday4-$datebefore3;
			$lastpirep = floor($newdate/(60*60*24));
			echo 'Your last flight was ';
				if ($lastpirep == 0) { echo 'today'; }
				else if ($lastpirep == 1) { echo 'yesterday'; }
				else {
					echo $lastpirep . ' day(s) ago';
				}
			}			?>

This will show: Your last flight was X day(s) ago

But this one below will show: Your last flight was [X] day(s) ago. You have [X] days left until you are marked as retired (UPDATED VERSION)

<?php $totaldays = Config::Get('PILOT_INACTIVE_TIME');


                       {
               ?>
<?php
                       if ($userinfo->lastpirep == '0000-00-00 00:00:00') {
                               echo 'You have not flown any flights yet!';
                       }
                       else {
                               $datebefore1 = substr($userinfo->lastpirep, 0, 10);
                               $datetoday2 = date("Y-m-d");
                               $datebefore3 = strtotime($datebefore1);
                               $datetoday4 = strtotime($datetoday2);
                               $newdate = $datetoday4-$datebefore3;
                               $lastpirep = floor($newdate/(60*60*24));
                               $daysleft = $totaldays-$lastpirep;
                               echo 'Your last flight was ';
                                       if ($lastpirep == 0) { echo 'today'; }
                                       else if ($lastpirep == 1) { echo 'yesterday'; }
                                       else {
                                               echo $lastpirep . ' day(s) ago.';
                                       }
                                       echo '&nbspYou have ';
                                       if ($daysleft == 0) { echo 'You have being marked as a retired pilot!'; }
                                       else {
                                               echo $daysleft . '&nbspdays left until you are marked as retired';
                                       }


                       }
                       ?><?php 
 }  ?>

  • Like 2
Link to comment
Share on other sites

Hold on, if you are using the second code, you should replace it with this:

<?php $totaldays = Config::Get('PILOT_INACTIVE_TIME');


                       {
               ?>
<?php
		if ($userinfo->lastpirep == '0000-00-00 00:00:00') {
			echo 'You have not flown any flights yet!';
		}
		else {
			$datebefore1 = substr($userinfo->lastpirep, 0, 10);
			$datetoday2 = date("Y-m-d");
			$datebefore3 = strtotime($datebefore1);
			$datetoday4 = strtotime($datetoday2);
			$newdate = $datetoday4-$datebefore3;
			$lastpirep = floor($newdate/(60*60*24));
			$daysleft = $totaldays-$lastpirep;
			echo 'Your last flight was ';
				if ($lastpirep == 0) { echo 'today'; }
				else if ($lastpirep == 1) { echo 'yesterday'; }
				else {
					echo $lastpirep . ' day(s) ago.';
				}
				echo '&nbspYou have ';
				if ($daysleft == 0) { echo 'You have being marked as a retired pilot!'; }
				else {
					echo $daysleft . '&nbspdays left until you are marked as retired';
				}


		}
		?><?php 
 }
 ?>

Otherwise it will show: You have -[X] (a minus number) days left until you are marked as a retired pilot when they are retired.

If you are using the first code however, this doesn't matter

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

You can use the same code that is above and it should still show the same information. But you might want to change the text like: "You have being marked as a retired pilot!" to "this pilot has being marked as a retired pilot!" etc..

Example:

<?php $totaldays = Config::Get('PILOT_INACTIVE_TIME');


                       {
               ?>
<?php
                       if ($userinfo->lastpirep == '0000-00-00 00:00:00') {
                               echo 'This pilot hasn't not flown any flights yet!';
                       }
                       else {
                               $datebefore1 = substr($userinfo->lastpirep, 0, 10);
                               $datetoday2 = date("Y-m-d");
                               $datebefore3 = strtotime($datebefore1);
                               $datetoday4 = strtotime($datetoday2);
                               $newdate = $datetoday4-$datebefore3;
                               $lastpirep = floor($newdate/(60*60*24));
                               $daysleft = $totaldays-$lastpirep;
                               echo 'Last flight was ';
                                       if ($lastpirep == 0) { echo 'today'; }
                                       else if ($lastpirep == 1) { echo 'yesterday'; }
                                       else {
                                               echo $lastpirep . ' day(s) ago.';
                                       }
                                       echo '&nbspYou have ';
                                       if ($daysleft == 0) { echo 'This pilot has being marked as a retired pilot!'; }
                                       else {
                                               echo $daysleft . '&nbspdays left until they are marked as retired';
                                       }


                       }
                       ?><?php 
 }
 ?>

I have tried the above code on localhost, and it worked fine

Link to comment
Share on other sites

  • 2 months later...
  • 3 months later...

Hi All,

Like this code snippet and this is what I have so far:

<?php
                       if ($userinfo->lastpirep == '0000-00-00 00:00:00') {
                               echo 'You have not flown any flights yet!';
                       }
                       else {
                               $datebefore1 = substr($userinfo->lastpirep, 0, 10);
                               $datetoday2 = date("Y-m-d");
                               $datebefore3 = strtotime($datebefore1);
                               $datetoday4 = strtotime($datetoday2);
                               $newdate = $datetoday4-$datebefore3;
                               $lastpirep = floor($newdate/(60*60*24));
                               $daysleft = $totaldays-$lastpirep;
                               echo '<center><b>Your last flight was</b> ';
                                       if ($lastpirep == 0) { echo '<b>today</b>'; }
                                       else if ($lastpirep == 1) { echo 'yesterday'; }
                                       else {
                                               echo $lastpirep . ' day(s) ago.';
                                       }
                                       echo ' <b>You have</b> ';
                                       if ($daysleft == 0) { echo '<b>You have being marked as a retired pilot!</b>'; }
                                       else {
                                               echo $daysleft . '<b>&nbspdays left until you are marked as retired</b></center>';
                                       }


                       }
                       ?>

What I want to do is show the number of days in bold red. So it would read like "Your last flight was today You have 90 days left until you are marked as retired". So when a pilot is in their Profile it will stick out some. This is actually the very first line in the profile. So they will see it as soon as they go to their profile page.

I have messed with the code a good bit but unable to get what I am looking for. Your help would be greatly appreciated.

Link to comment
Share on other sites

Create a class in your CSS file like so:

.redBold {     
color: red;    
font-weight: bold;
}

Now in the above code, change Line 22 from:

echo $daysleft . ' days left until you are marked as retired';

to:

echo "<span class="redBold\">".$daysleft."</span>" . '<b> days left until you are marked as retired!</b>';

  • Like 1
Link to comment
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...