freshJet Posted June 12, 2011 Report Share Posted June 12, 2011 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... 1 Quote Link to comment Share on other sites More sharing options...
freshJet Posted June 13, 2011 Author Report Share Posted June 13, 2011 bump 1 Quote Link to comment Share on other sites More sharing options...
James142 Posted June 13, 2011 Report Share Posted June 13, 2011 <?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 ' You have '; if ($daysleft == 0) { echo 'You have being marked as a retired pilot!'; } else { echo $daysleft . ' days left until you are marked as retired'; } } ?><?php } ?> 2 Quote Link to comment Share on other sites More sharing options...
freshJet Posted June 14, 2011 Author Report Share Posted June 14, 2011 Genius James, cheers ! 1 Quote Link to comment Share on other sites More sharing options...
James142 Posted June 14, 2011 Report Share Posted June 14, 2011 Genius James, cheers ! Quote Link to comment Share on other sites More sharing options...
James142 Posted June 14, 2011 Report Share Posted June 14, 2011 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 ' You have '; if ($daysleft == 0) { echo 'You have being marked as a retired pilot!'; } else { echo $daysleft . ' days 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 1 Quote Link to comment Share on other sites More sharing options...
freshJet Posted June 14, 2011 Author Report Share Posted June 14, 2011 Yeah I'm using the first one. Quote Link to comment Share on other sites More sharing options...
lorlandi Posted July 10, 2011 Report Share Posted July 10, 2011 Hi, a little question about this code, if i want to show the same information but in the pilot list for each pilot. Is correct...... i must to change $userinfo->lastpirep by $pilot->lastpirep or change other parts of the code. Thanks Quote Link to comment Share on other sites More sharing options...
James142 Posted July 10, 2011 Report Share Posted July 10, 2011 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 ' You have '; if ($daysleft == 0) { echo 'This pilot has being marked as a retired pilot!'; } else { echo $daysleft . ' days left until they are marked as retired'; } } ?><?php } ?> I have tried the above code on localhost, and it worked fine Quote Link to comment Share on other sites More sharing options...
lorlandi Posted July 10, 2011 Report Share Posted July 10, 2011 Ok many thanks for the help. Regards Quote Link to comment Share on other sites More sharing options...
AUZ Posted September 19, 2011 Report Share Posted September 19, 2011 Sorry, but I keep getting this displayed; Your last flight was 15235 day(s) ago Even after I submitted a manual pirep. Any ideas ? and thanks for the code, looks great! Just wish I could get it to work. Quote Link to comment Share on other sites More sharing options...
James142 Posted September 19, 2011 Report Share Posted September 19, 2011 Hmm thats odd. Was the PIREP accepted? Quote Link to comment Share on other sites More sharing options...
AUZ Posted September 20, 2011 Report Share Posted September 20, 2011 Yes, Pirep was accepted and I fly everyday almost, I could understand it saying maybe 3-4 days ago but no 15235 days ago lol I can't really see why its not working correctly Quote Link to comment Share on other sites More sharing options...
ATAvCEO Posted January 10, 2012 Report Share Posted January 10, 2012 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> days 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. Quote Link to comment Share on other sites More sharing options...
tutmeister Posted January 11, 2012 Report Share Posted January 11, 2012 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>'; 1 Quote Link to comment Share on other sites More sharing options...
ATAvCEO Posted January 11, 2012 Report Share Posted January 11, 2012 tutmeister, Thank you very much works like a charm. Quote Link to comment Share on other sites More sharing options...
tutmeister Posted January 11, 2012 Report Share Posted January 11, 2012 tutmeister, Thank you very much works like a charm. You're welcome. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.