gio1961 Posted June 2, 2019 Report Share Posted June 2, 2019 (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; ?> 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 Edited June 6, 2019 by gio1961 Quote Link to comment Share on other sites More sharing options...
flyalaska Posted June 4, 2019 Report Share Posted June 4, 2019 Try taking off the <?php right above the if($report->accepted == PIREP_ACCEPTED) Quote Link to comment Share on other sites More sharing options...
gio1961 Posted June 4, 2019 Author Report Share Posted June 4, 2019 3 hours ago, flyalaska said: Try taking off the <?php right above the if($report->accepted == PIREP_ACCEPTED) Thanks, unfortunately it doesn't work Quote Link to comment Share on other sites More sharing options...
flyalaska Posted June 5, 2019 Report Share Posted June 5, 2019 (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 June 5, 2019 by flyalaska Quote Link to comment Share on other sites More sharing options...
gio1961 Posted June 5, 2019 Author Report Share Posted June 5, 2019 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 Quote Link to comment Share on other sites More sharing options...
flyalaska Posted June 6, 2019 Report Share Posted June 6, 2019 Are you referring to last flights per pilot? Quote Link to comment Share on other sites More sharing options...
gio1961 Posted June 6, 2019 Author Report Share Posted June 6, 2019 (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" Edited June 6, 2019 by gio1961 Quote Link to comment Share on other sites More sharing options...
flyalaska Posted June 6, 2019 Report Share Posted June 6, 2019 Try this <?php echo $pirep->aircraft . " ($pirep->registration)"; ?> Quote Link to comment Share on other sites More sharing options...
gio1961 Posted June 6, 2019 Author Report Share Posted June 6, 2019 9 minutes ago, flyalaska said: Try this <?php echo $pirep->aircraft . " ($pirep->registration)"; ?> unfortunately it does not work. Thanks anyway Quote Link to comment Share on other sites More sharing options...
flyalaska Posted June 6, 2019 Report Share Posted June 6, 2019 Weird, that came off my site. That is what I am using. Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted June 6, 2019 Administrators Report Share Posted June 6, 2019 (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 June 6, 2019 by ProAvia Quote Link to comment Share on other sites More sharing options...
gio1961 Posted June 6, 2019 Author Report Share Posted June 6, 2019 (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; ?> 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 I'm using version 5.5.2. I tried all the codes posted, nothing to do. Thank you all Edited June 6, 2019 by gio1961 Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted June 6, 2019 Administrators Report Share Posted June 6, 2019 (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 June 6, 2019 by ProAvia Quote Link to comment Share on other sites More sharing options...
flyalaska Posted June 7, 2019 Report Share Posted June 7, 2019 (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. Edited June 7, 2019 by flyalaska Quote Link to comment Share on other sites More sharing options...
gio1961 Posted June 7, 2019 Author Report Share Posted June 7, 2019 "$ report" and "$ reports" refers to the pirep table in the database. The skin used is CrewCenter. I got the code from here: https://forum.phpvms.net/topic/7789-add-pireps-to-pilot-main-profile/ Quote Link to comment Share on other sites More sharing options...
Administrators ProAvia Posted June 7, 2019 Administrators Report Share Posted June 7, 2019 (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 June 7, 2019 by ProAvia Quote Link to comment Share on other sites More sharing options...
flyalaska Posted June 7, 2019 Report Share Posted June 7, 2019 The code you got from that link was posted in 2012, Most likely outdated, perhaps the reason for your issues. Quote Link to comment Share on other sites More sharing options...
gio1961 Posted June 7, 2019 Author Report Share Posted June 7, 2019 Ok, thanks to everyone Quote Link to comment Share on other sites More sharing options...
gio1961 Posted July 6, 2019 Author Report Share Posted July 6, 2019 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; ?> 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> 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.