Jump to content

Add Pireps to Pilot Main Profile


Colin

Recommended Posts

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 :wub:

Colin

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 4 months later...

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');
}

  • Like 1
Link to comment
Share on other sites

  • Moderators

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:

pirep.png

Now this will show only last 5 flights. If you want to show more flights change "5" to whatever number you want. :D

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

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