Jump to content

Recommended Posts

Posted (edited)

On recent flights on the first page, it should show the name of the plane in which the Pirep was archived, instead it shows the number 1
Here is the code I'm using:

<?php
$pilotid = Auth::$userinfo->pilotid;
$reports = PIREPData::getLastReports($pilotid, 5,'');
?>

<table class="table table-striped mt30" cellspacing="0" width="100%" height="30" border="1" bordercolor="#FFFFFF">
<tr>
<th bgcolor="#dd4b39"><font color="#ffffff">Flight Number</font></th>
<th bgcolor="#dd4b39"><font color="#ffffff">Aircraft</font></th>
<th bgcolor="#dd4b39"><font color="#ffffff">Departure</font></th>
<th bgcolor="#dd4b39"><font color="#ffffff">Arrival</font></th>
<th bgcolor="#dd4b39"><font color="#ffffff">Flight Time</font></th>
<th bgcolor="#dd4b39"><font color="#ffffff">Landing rate</font></th>
<th bgcolor="#dd4b39"><font color="#ffffff">Date</font></th>
<th bgcolor="#dd4b39"><font color="#ffffff">Status</font></th>

</tr>
<?php

if($reports)
foreach($reports as $report)
{
?>
<tr>
<td><a href="<?php echo url('/pireps/view/'.$report->pirepid);?>"><?php echo $report->code . $report->flightnum; ?></a></td>
<td><?php echo $report->aircraft;?></td>
<td><?php echo $report->depicao; ?></td>
<td><?php echo $report->arricao; ?></td>
<td><?php echo $report->flighttime; ?></td>
<td><?php echo $report->landingrate; ?>&nbsp;ft/min</td>
<td><?php echo date(DATE_FORMAT, strtotime($report->submitdate)); ?></td>
<td><?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>
</tr>
</table>

Other problem. if a pilot did not fly, how to insert "no report"?

Thanks for a possible reply

01.jpg

 

 

Edited by gio1961
Posted (edited)

Try this! Just edit the button class to your own if you don't have Bootstrap 4.

 

<?php
$count = 10;
$pireps = PIREPData::getRecentReportsByCount($count);
?>
<table class="table table-striped mt30" width="100%" cellspacing="0">
    <tr>
        <th>Flight</th>
        <th>Departure</th>
        <th>Arrival</th>
        <th>Aircraft</th>
        <th>Duration</th>
        <th>Landing</th>
        <th>Status</th>
	</tr>
<?php
if(count($pireps) > 0)
{
  foreach ($pireps as $pirep)
  {
    $pilotinfo = PilotData::getPilotData($pirep->pilotid);
    $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid);
    $acrid = OperationsData::getAircraftByReg($pirep->registration);

    echo '<tr>';
    echo '<td><a href="'.SITE_URL.'/index.php/pireps/viewreport/'.$pirep->pirepid.'">'.$pirep->code.$pirep->flightnum.'</a></td>';
    echo '<td>'.$pirep->depicao.'</td>';
    echo '<td>'.$pirep->arricao.'</td>';
    echo '<td>'.$pirep->aircraft.'</td>';
    echo '<td>'.$pirep->flighttime.'</td>';
    echo '<td>'.$pirep->landingrate.' ft/m</td>';

if($pirep->accepted == PIREP_ACCEPTED)

echo '<td><button type="button" class="btn btn-outline btn-success btn-xs mb-2">Flight Approved</button></td>';

                                elseif($pirep->accepted == PIREP_REJECTED)

echo '<td><button type="button" class="btn btn-outline btn-danger btn-xs mb-2">Flight Rejected</button></td>';

                                elseif($pirep->accepted == PIREP_PENDING)

echo '<td><button type="button" class="btn btn-outline btn-primary btn-xs mb-2">Approval Pending</button></td>';

                                elseif($pirep->accepted == PIREP_INPROGRESS)

echo '<td><button type="button" class="btn btn-outline btn-primary btn-xs mb-2">On Progress</button></td>';
    echo '</tr>';
  }
}
else
{
    echo '<tr><td>There are no recent flights!</td></tr>';
}
?>
</tbody>
</table>
<div class="clear"></div>
<div class="clear"></div>

 

Edited by flyalaska
Posted
2 hours ago, flyalaska said:

Try this! Just edit the button class to your own if you don't have Bootstrap 4.

 


<?php
$count = 10;
$pireps = PIREPData::getRecentReportsByCount($count);
?>
<table class="table table-striped mt30" width="100%" cellspacing="0">
    <tr>
        <th>Flight</th>
        <th>Departure</th>
        <th>Arrival</th>
        <th>Aircraft</th>
        <th>Duration</th>
        <th>Landing</th>
        <th>Status</th>
	</tr>
<?php
if(count($pireps) > 0)
{
  foreach ($pireps as $pirep)
  {
    $pilotinfo = PilotData::getPilotData($pirep->pilotid);
    $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid);
    $acrid = OperationsData::getAircraftByReg($pirep->registration);

    echo '<tr>';
    echo '<td><a href="'.SITE_URL.'/index.php/pireps/viewreport/'.$pirep->pirepid.'">'.$pirep->code.$pirep->flightnum.'</a></td>';
    echo '<td>'.$pirep->depicao.'</td>';
    echo '<td>'.$pirep->arricao.'</td>';
    echo '<td>'.$pirep->aircraft.'</td>';
    echo '<td>'.$pirep->flighttime.'</td>';
    echo '<td>'.$pirep->landingrate.' ft/m</td>';

if($pirep->accepted == PIREP_ACCEPTED)

echo '<td><button type="button" class="btn btn-outline btn-success btn-xs mb-2">Flight Approved</button></td>';

                                elseif($pirep->accepted == PIREP_REJECTED)

echo '<td><button type="button" class="btn btn-outline btn-danger btn-xs mb-2">Flight Rejected</button></td>';

                                elseif($pirep->accepted == PIREP_PENDING)

echo '<td><button type="button" class="btn btn-outline btn-primary btn-xs mb-2">Approval Pending</button></td>';

                                elseif($pirep->accepted == PIREP_INPROGRESS)

echo '<td><button type="button" class="btn btn-outline btn-primary btn-xs mb-2">On Progress</button></td>';
    echo '</tr>';
  }
}
else
{
    echo '<tr><td>There are no recent flights!</td></tr>';
}
?>
</tbody>
</table>
<div class="clear"></div>
<div class="clear"></div>

 

Thank you for answering. The code you posted refers to the pilot reports and not the "MY" last flights. The code I posted refers to this.
Sincerely

Posted (edited)
8 hours ago, flyalaska said:

Are you referring to last flights per pilot?

Yes, I'm referring to the pilot last flights

As you can see from the image posted, instead of the name of the plane there is number "1"

01.jpg

Edited by gio1961
  • Administrators
Posted (edited)

I'm guessing you are using phpVMS 2.1.x or 5.0 and not 5.5.2

Try this - change

<td><?php echo $report->aircraft;?></td>

to show aircraft registration

<td><?php echo $report->aircraft . "(report->registration)";?></td>

or to show aircraft ICAO

<td><?php echo $report->aircraft . "(report->icao)";?></td>

Edited by ProAvia
Posted (edited)

<table class="table table-striped mt30" cellspacing="0" width="100%" height="30" border="1" bordercolor="#FFFFFF">

<tr>

<th bgcolor="#dd4b39"><font color="#ffffff">Flight Number</font></th>

<th bgcolor="#dd4b39"><font color="#ffffff">Aircraft</font></th>

<th bgcolor="#dd4b39"><font color="#ffffff">Departure</font></th>

<th bgcolor="#dd4b39"><font color="#ffffff">Arrival</font></th>

<th bgcolor="#dd4b39"><font color="#ffffff">Flight Time</font></th>

<th bgcolor="#dd4b39"><font color="#ffffff">Landing rate</font></th>

<th bgcolor="#dd4b39"><font color="#ffffff">Date</font></th>

<th bgcolor="#dd4b39"><font color="#ffffff">Status</font></th>

</tr>

<?php

if($reports)

foreach($reports as $report)

{

?>

<tr>

<td><a href="<?php echo url('/pireps/view/'.$report->pirepid);?>"><?php echo $report->code . $report->flightnum; ?></a></td>

<td><?php echo $report->aircraft . " ($report->registration)"; ?></td>

<td><?php echo $report->depicao;?>
 <br />
<?php $departname = OperationsData::getAirportInfo($report->depicao);
$depairport = substr($departname->name,0,18);?><?php echo $depairport;?>

</td>

<td><?php echo $report->arricao;?>
<br />
<?php  $arrivename = OperationsData::getAirportInfo($report->arricao);
$arrairport = substr($arrivename->name,0,18);?><?php echo $arrairport;?>

</td>

<td><?php echo $report->flighttime; ?></td>

<td><?php echo $report->landingrate; ?>&nbsp;ft/min</td>

<td><?php echo date(DATE_FORMAT, strtotime($report->submitdate)); ?></td>

<td><?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>

</tr>

</table>

table pireps

000.jpg

I'm using version 5.5.2. I tried all the codes posted, nothing to do. Thank you all

Edited by gio1961
  • Administrators
Posted (edited)

I think "$report" and "$reports" are referencing the PIREP table in the database. And the PIREP table only shows the aircraft ID number. You need to find a way to reference that aircraft ID number and then call the aircraft table into the mix. Then the aircraft ID can reference the aircraft type, registration or whatever else the aircraft table provides for that specific aircraft ID.

What skin are you using? What is the name of the file for the code you posted?

Edited by ProAvia
Posted (edited)

I pasted your original code on my site. With the exception of the table being full screen(easy fix) , your code works on my site as it should.

pireps.png

 

Edited by flyalaska
  • Administrators
Posted (edited)

Try this... in your last code above, copy the contents and do the following

Change all occurrances of $reports to $pirep_list and all occurrances of $report to $pirep

My phpVMS 5.5.2 has those changes and works fine. Or as flyalaska said, the original code you posted works on his site. Maybe it's an issue with your skin.

Is this the pireps_viewall.php file? Is it in your CrewCenter skin folder or in core/templates?

Edited by ProAvia
  • 4 weeks later...
Posted

I solved Thanks also "Parkho" I found a post on the forum:

I added "OperationsData.class.php":

public static function GetAircraftById($id)
{
$sql="SELECT * FROM phpvms_aircraft WHERE id='$id' ";
return DB::get_row($sql);
}

Code:

<?php

$pilotid = Auth::$userinfo->pilotid;
$reports = PIREPData::getLastReports($pilotid, 5,'');

?>

*****

<h4>My Latest 5 Flights</h4>
 

<table id="tabledlist" class="tablesorter table table-hover" ellspacing="0" width="100%">
<tr>
<th>Flight Number</th>
<th>Aircraft</th>
<th>Departure</th>
<th>Arrival</th>
<th>Flight Time</th>
<th>Landing rate</th>
<th>Date</th>
<th>Status</th>
</tr>

<?php

if($reports)

foreach($reports as $report)

{

?>

<tr>

<td><a href="<?php echo url('/pireps/view/'.$report->pirepid);?>"><?php echo $report->code . $report->flightnum; ?></a></td>

<td><?php
$aircraft = OperationsData::getAircraftById($report->aircraft);
echo $aircraft->fullname;
echo " ( ";
echo $aircraft->registration;
echo " ) ";
?>


</td>

<td><?php echo $report->depicao;?>

</td>

<td><?php echo $report->arricao;?>

</td>

<td><?php echo $report->flighttime; ?></td>

<td><?php echo $report->landingrate; ?>&nbsp;ft/min</td>

<td><?php echo date(DATE_FORMAT, strtotime($report->submitdate)); ?></td>

<td><?php

if($report->accepted == PIREP_ACCEPTED)

echo '<span class="label label-success"><font color="#fff">Accepted</font></span>';

elseif($report->accepted == PIREP_REJECTED)

echo '<span class="label label-danger"><font color="#fff">Rejected</font></span>';

elseif($report->accepted == PIREP_PENDING)

echo '<span class="label label-warning"><font color="#000">Approval Pending</font></span>';

elseif($report->accepted == PIREP_INPROGRESS)

echo '<span class="label label-warning"><font color="#000">Flight in Progress</font></span>';

}

?>
</td>
</tr>
</table>

 

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