Jump to content
Kalo

separate Pilot List per Airline?

Recommended Posts

Hello, if anyone would be able to help me create separate Pilot Lists for each airline it would be much appreciated! I am not very experienced with PHP but thanks to the help of Parkho in a previous thread I setup a pilot list that lists all pilots by hours here: http://www.msflights.net/pilots/phpvms/index.php/pilotlist

We have two airlines, one Commercial and one for General Aviation aircraft, I would like to create separate lists that show pilots by hours for each airline on separate pages. I'm not quite sure if it's possible to show flights/hours for each airline separately especially since we allow pilots to submit pireps for BOTH airlines even though they are signed up for only one.

These are my files for the pilot list so far:

\core\template\pl\pilot_list.tpl: http://pastebin.com/r4yWRUbt

\core\modules\PilotList\PilotList.php: http://pastebin.com/jXmDpVeb

\core\common\PilotListData.class.php: http://pastebin.com/mu2T5gkB

Thanks for any help!

Share this post


Link to post
Share on other sites

Give this a whirl, not tested. Let me know if it's working. ;-)

 

<h3><?php echo $title ;?></h3>
<?php
# Grab the airlines we have in the system.
$airlines = OperationsData::getAllAirlines(true);
# Now let's loop the airlines.
foreach ($airlines as $airline)
{
    $pilots = PilotData::findPilots(['code' => $airline->code]);
    if(!$pilots)
    {
        echo '<tr><td align="center" colspan="5">There are no pilots!</td></tr>';
        return;
    }
    else
    {
?>
<h4><?php echo $airline->name;?></h4>
<table width="100%">
<table id="tabledlist" class="tablesorter">
<thead>
<tr>
    <th>Pilot ID</th>
    <th>Name</th>
    <th>Rank</th>
    <th>Flights</th>
    <th>Hours</th>
</tr>
</thead>
<?php
foreach($pilots as $pilot)
{
?>
<tr>
    <td align="center"><a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>">
            <?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid)?></a>
    </td>
    <td width="1%" nowrap>
        <img src="<?php echo Countries::getCountryImage($pilot->location);?>"
            alt="<?php echo Countries::getCountryName($pilot->location);?>" />

        <?php echo $pilot->firstname.' '.$pilot->lastname?>
    </td>
    <td align="center"><img src="<?php
    $rank = PilotListData::rank($pilot->rank);
    echo $rank->rankimage?>" alt="<?php echo $pilot->rank;?>" /></td>
    <td align="center"><?php echo $pilot->totalflights?></td>
    <td align="center"><?php echo Util::AddTime($pilot->totalhours, $pilot->transferhours); ?></td>
<?php
}
}
?>
</table>
<?php
}
?>

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the help, unfortunately I'm embarrassed to admit I'm not sure exactly where to paste in the airlines code/name. :wacko: I tried a few different spots without success...I'm sure its really simple and I have been starring right at it...but PHP is still like a foreign language to me :(

Share this post


Link to post
Share on other sites

I don't have lib/skins/YOURSKINNAME/pilots_list.php, so I tried replacing my files  \core\template\pl\pilot_list.tpl  and  \core\modules\PilotList\PilotList.php  and got these errors:

Parse error: syntax error, unexpected '[', expecting ')' in /home1/msflight/public_html/pilots/phpvms/core/templates/pl/pilots_list.tpl on line 8
Parse error: syntax error, unexpected '[', expecting ')' in /home1/msflight/public_html/pilots/phpvms/core/modules/PilotList/PilotList.php on line 8

 

Share this post


Link to post
Share on other sites

Ah, you're using the older version, do you have a skin on your website, if so, try lib/skins/YOURSKINNAME/pilots_list.tpl and replace all the content in there. If that file is not there, then try the one in core/templates/pl/pilot_list.tpl which I think is the one Parkho gave you. No need to be embarrassed, it's just like learning another language, you'll get it eventually ;)

And for the error, try replacing this line (on line 8)

$pilots = PilotData::findPilots(['code' => $airline->code]);

With this one

$pilots = PilotData::findPilots(array('code' => $airline->code));

Your PHP version might be very old.

Edited by web541

Share this post


Link to post
Share on other sites

(I am using the latest official phpvms release, but I am only on php5.3 since it does not work on later versions (I coudln't get the phpvms forks to work with 5.5+))

thanks, mine is only located in /core/templates/pl. I replaced that file completely and got the error, then tried your fix on line 8 which made the page load properly but broke the previous functionality I had setup (showing top 100 pilots from most to least hours)(it would now load all 800 pilots by pilot ID).

It did show both airlines on the page but for the second airline it only showed pilots that were registered with that second airline. I was hoping it would be possible to list a pilot in both airline lists since they can submit pireps to each airline even though they can only register for one airline at a time(sorry that sounds confusing:blink:). Basically I wanted to know if its possible to show Pilot X who registered with Airline A to appear in BOTH pilot lists for Airline A and B even though he is only registered to Airline A (because he submitted pireps to both Airlines).

I am trying to set this up because we will have a commercial airline and a general aviation airline, but I want to keep the pilot list of hours separate since as you can imagine commercial pilots rack up way more hours then general aviation pilots. We are pretty casual so I wanted a pilot who is registered in the commercial airline to also be able to submit pireps for the general aviation airline, and show up in both pilot lists for each airline.

Thanks for all the help, I have to call it a night, so I will check back in tomorrow.

Share this post


Link to post
Share on other sites
2 hours ago, Kalo said:

Basically I wanted to know if its possible to show Pilot X who registered with Airline A to appear in BOTH pilot lists for Airline A and B even though he is only registered to Airline A (because he submitted pireps to both Airlines).

I don't think that's doable since the given variable has to be the airline code and since the pilot is registered only with one airline. Another approach would be to loop through the PIREPS and pull out the pilots who submitted the PIREP. In that case you won't be able to show all your pilots cause some of them are registered but never submitted any reports.

Edited by Parkho
  • Like 1

Share this post


Link to post
Share on other sites
10 hours ago, Parkho said:

Another approach would be to loop through the PIREPS and pull out the pilots who submitted the PIREP. In that case you won't be able to show all your pilots cause some of them are registered but never submitted any reports.

Would this only work for specific PIREPS you list or could you pull all PIREPS from that airline?

Share this post


Link to post
Share on other sites
On 1/25/2017 at 7:35 PM, Kyle said:

Give this a whirl, not tested. Let me know if it's working. 😉

 


<h3><?php echo $title ;?></h3>
<?php
# Grab the airlines we have in the system.
$airlines = OperationsData::getAllAirlines(true);
# Now let's loop the airlines.
foreach ($airlines as $airline)
{
    $pilots = PilotData::findPilots(['code' => $airline->code]);
    if(!$pilots)
    {
        echo '<tr><td align="center" colspan="5">There are no pilots!</td></tr>';
        return;
    }
    else
    {
?>
<h4><?php echo $airline->name;?></h4>
<table width="100%">
<table id="tabledlist" class="tablesorter">
<thead>
<tr>
    <th>Pilot ID</th>
    <th>Name</th>
    <th>Rank</th>
    <th>Flights</th>
    <th>Hours</th>
</tr>
</thead>
<?php
foreach($pilots as $pilot)
{
?>
<tr>
    <td align="center"><a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>">
            <?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid)?></a>
    </td>
    <td width="1%" nowrap>
        <img src="<?php echo Countries::getCountryImage($pilot->location);?>"
            alt="<?php echo Countries::getCountryName($pilot->location);?>" />

        <?php echo $pilot->firstname.' '.$pilot->lastname?>
    </td>
    <td align="center"><img src="<?php
    $rank = PilotListData::rank($pilot->rank);
    echo $rank->rankimage?>" alt="<?php echo $pilot->rank;?>" /></td>
    <td align="center"><?php echo $pilot->totalflights?></td>
    <td align="center"><?php echo Util::AddTime($pilot->totalhours, $pilot->transferhours); ?></td>
<?php
}
}
?>
</table>
<?php
}
?>

 

Hello guys, help if possible.
How to display the list of pilots only of a specific company, es code "RAD".

$pilots = PilotData::findPilots(['code' => $airline->code]);


Thanks for a possible reply

Edited by gio1961

Share this post


Link to post
Share on other sites

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