Colin Posted August 15, 2012 Report Share Posted August 15, 2012 Hi guys, I'm trying to add the Pireps list to the profile_main.tpl so that a pilot can view his PIREPS and see if they are pending or Approved etc, I've been trying for the past 4 hours to do this and I keep getting errors, any chance someone could help me out please, and if at all possible throw the code my way As always any help appreciated Colin Quote Link to comment Share on other sites More sharing options...
Colin Posted August 15, 2012 Author Report Share Posted August 15, 2012 help please Quote Link to comment Share on other sites More sharing options...
Colin Posted August 15, 2012 Author Report Share Posted August 15, 2012 help please Quote Link to comment Share on other sites More sharing options...
Tom Posted August 15, 2012 Report Share Posted August 15, 2012 help please help please 21 minutes isn't worthy of a bump... Quote Link to comment Share on other sites More sharing options...
Colin Posted August 15, 2012 Author Report Share Posted August 15, 2012 Quote Link to comment Share on other sites More sharing options...
Tom Posted August 15, 2012 Report Share Posted August 15, 2012 You're welcome. And thank you for your pointless spamming, which has evidently greatly increased your success rate, based on the sudden abundance of solutions to your problem. Quote Link to comment Share on other sites More sharing options...
Colin Posted August 15, 2012 Author Report Share Posted August 15, 2012 Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted August 15, 2012 Administrators Report Share Posted August 15, 2012 To use the native function you can add this to your controller function after the initial template call. $this->set('pirep_list', PIREPData::getAllReportsForPilot($Auth::$pilot->pilotid)); $this->render('pireps_viewall.tpl'); Quote Link to comment Share on other sites More sharing options...
Colin Posted August 16, 2012 Author Report Share Posted August 16, 2012 Hi Sim Pilot thanks for your reply, I added the code as you suggested and have made some progress but when I add the PIREPS list table into the profile_main.tpl when displayed on the site it says No reports have been found Where it should list the pilots PIREPS, Is there another code I should be using to display the PIREPS table other than the one already provided in the pireps_viewall.TPL? Many Thanks Quote Link to comment Share on other sites More sharing options...
Jeff Posted August 17, 2012 Report Share Posted August 17, 2012 Colin, Can you paste the code you are placing in the profile_main.tpl so we can see if there is something you might be doing wrong? Quote Link to comment Share on other sites More sharing options...
Colin Posted August 17, 2012 Author Report Share Posted August 17, 2012 Hi Jeff thanks for your reply the code is: <h3>Most Recent PIREP <?php if(isset($descrip)) { echo $descrip; }?> </h3> <table id="tabledlist" class="tablesorter"> <thead> <tr> <th>Flight Number</th> <th>Departure</th> <th>Arrival</th> <th>Status</th> <?php // Only show this column if they're logged in, and the pilot viewing is the // owner/submitter of the PIREPs if(Auth::LoggedIn() && Auth::$userinfo->pilotid == $userinfo->pilotid) { echo '<th>Options</th>'; } ?> </tr> </thead> <tbody> <tr> <td align="center"><a href="<?php echo url('/pireps/view/'.$report->pirepid);?>"><?php echo $report->code . $report->flightnum; ?></a></td> <td align="center"><?php echo $report->depicao; ?></td> <td align="center"><?php echo $report->arricao; ?></td> <td align="center"><?php if($report->accepted == PIREP_ACCEPTED) echo '<div id="success">Accepted</div>'; elseif($report->accepted == PIREP_REJECTED) echo '<div id="error">Rejected</div>'; elseif($report->accepted == PIREP_PENDING) echo '<div id="error">Approval Pending</div>'; elseif($report->accepted == PIREP_INPROGRESS) echo '<div id="error">Flight in Progress</div>'; ?></td> <?php // Only show this column if they're logged in, and the pilot viewing is the // owner/submitter of the PIREPs if(Auth::LoggedIn() && Auth::$userinfo->pilotid == $report->pilotid) { ?> <td align="center"><a href="<?php echo url('/pireps/addcomment?id='.$report->pirepid);?>">Add Comment</a><br /></td> <?php } ?> </tr> </tbody> </table> I've basically just copied and pasted the Pireps_viewall.tpl which hasn't really worked out lol, I came across another thread which has managed to get 1 pirep to show and the No reports have been found has now gone, I'm looking to get at least the pilots last 5 PIREPS to show in the pilot center, I know i'm missing something but not sure what, If you can help I would be much obliged to you. Many Thanks Col Quote Link to comment Share on other sites More sharing options...
Colin Posted August 22, 2012 Author Report Share Posted August 22, 2012 I still haven't managed to get this one solved, any help appreciated Quote Link to comment Share on other sites More sharing options...
mix Posted December 24, 2012 Report Share Posted December 24, 2012 Here is a start, but we need to improve a bit to get some more information. /core/modules/Profile/Profile.php public function lastpireps() { $this->set('userinfo', Auth::$userinfo); $this->set('pireps', PIREPData::getLastReports(Auth::$userinfo->pilotid, 5,'')); $this->render('pireps_last.tpl'); } 1 Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted December 25, 2012 Moderators Report Share Posted December 25, 2012 Colin, If you want to get this done you have to go step by step not just copy some codes from some pages and paste it where you want as it's not gonna work for sure, so first off you will need a variable to search through the PIREPS based on the pilot id then use a foreach loop to get those data out of the DB then you design a table and put the info in it, so here is the code: <?php $pilotid = Auth::$userinfo->pilotid; $reports = PIREPData::getLastReports($pilotid, 5,''); ?> <table width="100%"> <tr> <th>Flight Number</th> <th>Departure</th> <th>Arrival</th> <th>Status</th> <?php if(Auth::LoggedIn() && Auth::$userinfo->pilotid == $userinfo->pilotid) { echo '<th>Options</th>'; } ?> </tr> <?php foreach($reports as $report) { ?> <tr> <td align="center"><a href="<?php echo url('/pireps/view/'.$report->pirepid);?>"><?php echo $report->code . $report->flightnum; ?></a></td> <td align="center"><?php echo $report->depicao; ?></td> <td align="center"><?php echo $report->arricao; ?></td> <td align="center"><?php if($report->accepted == PIREP_ACCEPTED) echo '<div id="success">Accepted</div>'; elseif($report->accepted == PIREP_REJECTED) echo '<div id="error">Rejected</div>'; elseif($report->accepted == PIREP_PENDING) echo '<div id="error">Approval Pending</div>'; elseif($report->accepted == PIREP_INPROGRESS) echo '<div id="error">Flight in Progress</div>'; ?></td> <?php if(Auth::LoggedIn() && Auth::$userinfo->pilotid == $report->pilotid) { ?> <td align="center"><a href="<?php echo url('/pireps/addcomment?id='.$report->pirepid);?>">Add Comment</a><br /></td> <?php } } ?> </tr> </table> Screenshot: Now this will show only last 5 flights. If you want to show more flights change "5" to whatever number you want. 2 Quote Link to comment Share on other sites More sharing options...
Colin Posted January 9, 2013 Author Report Share Posted January 9, 2013 Brilliant thanks guys really appreciated 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.