pilot roster

HI

Now pilot roster show pilots by Hub , I want show pilots by Airline .

I try to change pilot.php , but just show Airlines Name nad Code . “There are no pilots!”

$allairlines = OperationsData::getAllAirlines($onlyenabled=false);

	if(!$allairlines) $allairline = array();

	foreach($allairlines as $airline)
	{
		$this->set('title', $airline->name);
		$this->set('code', $airline->code);

		$this->set('allpilots', PilotData::findPilots(array('p.code'=>$airline->code)));

		$this->render('pilots_list.tpl');
	}

	$noairlines = PilotData::findPilots(array('p.code'=>''));
	if(!$noairline)
	{
		return;
	}

	$this->set('title', 'No Airlines');
	$this->set('code', '');
	$this->set('allpilots', $noairlines);
	$this->render('pilots_list.tpl');
}

Tnx

Instead of getAirlineByID() try getAllAirlines(). What is it outputting right now?

And:

$noAirline = PilotData::findPilots(array(‘p.Airline’=>‘’));

You want p.code => ‘airline code’, since that’s how their airline is store

please check below code :

$allairlines = OperationsData::getAllAirlines();

	if(!$allairlines) $allairline = array();

	foreach($allairlines as $airline)
	{
		$this->set('title', $airline->name);
		$this->set('code', $airline->code);

		$this->set('allpilots', PilotData::findPilots(array('p.Airline'=>$airline->code)));

		$this->render('pilots_list.tpl');
	}

	$noAirline = PilotData::findPilots(array('p.Airline'=>''));
	if(!$noairline)
	{
		return;
	}

	$this->set('title', 'No Airlines');
	$this->set('code', '');
	$this->set('allpilots', $noairlines);
	$this->render('pilots_list.tpl');
}

and just show Airline name .

Do p.airline (it might be case senstive).

What’s in your template? And what’s it showing now?

HI

thank You nabel for help!

still show Airlines name in Pilot roster .

KLM :

there are no pilot .

{
	// Get all of our hubs, and list pilots by hub
	$allairlines = OperationsData::getAllAirlines();

	if(!$allairlines) $allairline = array();

	foreach($allairlines as $airline)
	{
		$this->set('title', $airline->name);
		$this->set('code', $airline->code);

		$this->set('allpilots', PilotData::findPilots(array('p.airline'=>$airline->code)));

		$this->render('pilots_list.tpl');
	}

	$noAirline = PilotData::findPilots(array('p.airline'=>''));
	if(!$noairline)
	{
		return;
	}

	$this->set('title', 'No Airlines');
	$this->set('code', '');
	$this->set('allpilots', $noairlines);
	$this->render('pilots_list.tpl');
}

After

$this->set(‘allpilots’, PilotData::findPilots(array(‘p.airline’=>$airline->code)));

put a DB::debug(), and show what that says

it doesn’t work .

Parse error: syntax error, unexpected T_VARIABLE in /home/XXX/public_html/data4/core/modules/Pilots/Pilots.php on line 36

{
	$allairlines = OperationsData::getAllAirlines();

	if(!$allairlines) $allairline = array();

	foreach($allairlines as $airline)
	{
		$this->set('title', $airline->name);
		$this->set('code', $airline->code);

		$this->set('allpilots', PilotData::findPilots(array('p.airline'=>$airline->code)));
                DB::debug()				
		$this->render('pilots_list.tpl');
	}

	$noAirline = PilotData::findPilots(array('p.airline'=>''));
	if(!$noairline)
	{
		return;
	}

	$this->set('title', 'No Airlines');
	$this->set('code', '');
	$this->set('allpilots', $noairlines);
	$this->render('pilots_list.tpl');
}

You forgot the semi colon at the end of the DB::debug(); line

Log : Caller: DB::write_debug->DB::query

public function index()
{
	$allairlines = OperationsData::getAllAirlines();

	if(!$allairlines) $allairline = array();

	foreach($allairlines as $airline)
	{
		$this->set('title', $airline->name);
		$this->set('code', $airline->code);

		$this->set('allpilots', PilotData::findPilots(array('p.airline'=>$airline->code)));
                        DB::debug(); 				
		$this->render('pilots_list.tpl');
	}

	$noAirline = PilotData::findPilots(array('p.airline'=>''));
	if(!$noairline)
	{
		return;
	}

	$this->set('title', 'No Airlines');
	$this->set('code', '');
	$this->set('allpilots', $noairlines);
	$this->render('pilots_list.tpl');
}

Look on that page, it will show what’s returned there

sorry

I don’t understand . what do you mean ?

still show Airlines Name and show There are no pilots!

pilots_list.tpl

<h3><?php echo $title.'-'.$code?></h3>

<thead>
<table border="0.5" width="100%"><tr>
<tr>
<th bgcolor=#F2F2F2>Pilot ID</th>
<th bgcolor=#F2F2F2>Name</th>
<th bgcolor=#F2F2F2>Rank</th>
        <th bgcolor=#F2F2F2>Last Active</th>
        <th bgcolor=#F2F2F2>Location</th>
        <th bgcolor=#F2F2F2>IVAO VID</th>
        
</thead>
<tbody>
<?php
foreach($roster as $pilot)
{
/* 
	To include a custom field, use the following example:

	<td>
		<?php echo PilotData::GetFieldValue($pilot->pilotid, 'VATSIM ID'); ?>
	</td>

	For instance, if you added a field called "IVAO Callsign":

		echo PilotData::GetFieldValue($pilot->pilotid, 'IVAO Callsign');		
 */
?>
<tr>
<td bgcolor=#FFFFFF width=10% height=5 align=center><font face=Tahoma color=#7E7E7E size=2><a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>">
		<?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid)?></a>
</td>

	<td bgcolor=#FFFFFF width=20% height=5 align=center>

	<?php echo $pilot->firstname.' '.$pilot->lastname?> (<?php echo PilotData::getFieldValue($pilot->pilotid,'VA Rank'); ?>)
</td>
<td bgcolor=#FFFFFF width=10% height=5 align=center><font face=Tahoma color=#7E7E7E size=2><img src="<?php echo $pilot->rankimage?>" alt="<?php echo $pilot->rank;?>" /></td>
</td>
<td bgcolor=#FFFFFF width=10% height=5 align=center><font face=Tahoma color=#7E7E7E size=2><?php echo $pilot->lastlogin?></td>

<td bgcolor=#FFFFFF width=5% height=5 align=center><font face=Tahoma color=#7E7E7E size=2><?php
$last_location = PIREPData::getLastReports($pilot->pilotid, 1, PIREP_ACCEPTED);
if(!$last_location)
echo $pilot->hub;

else

echo $last_location->arricao ;
?>

</td>
<td bgcolor=#FFFFFF width=5% height=5 align=center><font face=Tahoma color=#7E7E7E size=2><?php $fieldvalue = PilotData :: getFieldValue ( $pilot-> pilotid , 'IVAO VID' );
if( $fieldvalue != '' )
{
echo '<a href="http://www.ivao.aero/members/person/details.asp?ID='. $fieldvalue . '" target="_blank"><img src="http://status.ivao.aero/R/'.$fieldvalue.'.png" width="150" height="30" border="0" alt="IVAO VID"/></a>' ;
}
?>
</td>
</td>
<?php
}
?>
</tbody>
</table>

and pilot.php

public function index()
  {
      $allairlines = OperationsData::getAllAirlines();
      
      if(!$allairlines) $allairline = array();
      
      foreach($allairlines as $airline)
      {
        $this->set('title', $airline->name);
        $this->set('code', $airline->code);
         
        $this->set('allpilots', PilotData::findPilots(array('p.airline'=>$airline->code)));
                        DB::debug();             
        $this->render('pilots_list.tpl');
      }
      
      $noAirline = PilotData::findPilots(array('p.airline'=>''));
      if(!$noairline)
      {
        return;
      }
      
      $this->set('title', 'No Airlines');
      $this->set('code', '');
      $this->set('allpilots', $noairlines);
      $this->render('pilots_list.tpl');
  }

You never posted the output of what happens when you goto that page. Does any debug text show up? If not then it’s not reaching that code, and you have to see why

Please see below link : (pilot roster output )

and for Debug , you need Log ?

Tnx

Does anyone have any idea how i would do this?

After

$allairlines = OperationsData::getAllAirlines();

Put a DB::debug(); and post the output

I added DB::debug(); .

public function index()
{
	$allairlines = OperationsData::getAllAirlines();
	DB::debug(); 
	if(!$allairlines) $allairline = array();

	foreach($allairlines as $airline)
	{
		$this->set('title', $airline->name);
		$this->set('code', $airline->code);

		$this->set('allpilots', PilotData::findPilots(array('p.airline'=>$airline->code)));
                        				
		$this->render('pilots_list.tpl');

}

	$noAirline = PilotData::findPilots(array('p.airline'=>''));
	if(!$noairline)
	{
		return;
	}

	$this->set('title', 'No Airlines');
	$this->set('code', '');
	$this->set('allpilots', $noairlines);
	$this->render('pilots_list.tpl');


}

and pilots_list

<h3><?php echo $title.'-'.$code?></h3>



<thead>
<table border="0.5" width="100%"><tr>
<tr>
<th bgcolor=#F2F2F2>Pilot ID</th>
<th bgcolor=#F2F2F2>Name</th>
<th bgcolor=#F2F2F2>Rank</th>
        <th bgcolor=#F2F2F2>Location</th>
        <th bgcolor=#F2F2F2>IVAO VID</th>
        
</thead>
<tbody>
<?php
foreach($roster as $pilot)
{
/* 
	To include a custom field, use the following example:

	<td>
		<?php echo PilotData::GetFieldValue($pilot->pilotid, 'VATSIM ID'); ?>
	</td>

	For instance, if you added a field called "IVAO Callsign":

		echo PilotData::GetFieldValue($pilot->pilotid, 'IVAO Callsign');		
 */
?>
<tr>
<td bgcolor=#FFFFFF width=10% height=5 align=center><font face=Tahoma color=#7E7E7E size=2><a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>">
		<?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid)?></a>
</td>

	<td bgcolor=#FFFFFF width=20% height=5 align=center>

	<?php echo $pilot->firstname.' '.$pilot->lastname?> (<?php echo PilotData::getFieldValue($pilot->pilotid,'VA Rank'); ?>)
</td>
<td bgcolor=#FFFFFF width=10% height=5 align=center><font face=Tahoma color=#7E7E7E size=2><img src="<?php echo $pilot->rankimage?>" alt="<?php echo $pilot->rank;?>" /></td>
</td>

?>
<td bgcolor=#FFFFFF width=5% height=5 align=center><font face=Tahoma color=#7E7E7E size=2><?php
$last_location = PIREPData::getLastReports($pilot->pilotid, 1, PIREP_ACCEPTED);
if(!$last_location)
echo $pilot->hub;

else

echo $last_location->arricao ;
?>

</td>
<td bgcolor=#FFFFFF width=5% height=5 align=center><font face=Tahoma color=#7E7E7E size=2><?php $fieldvalue = PilotData :: getFieldValue ( $pilot-> pilotid , 'IVAO VID' );
if( $fieldvalue != '' )
{
echo '<a href="http://www.ivao.aero/members/person/details.asp?ID='. $fieldvalue . '" target="_blank"><img src="http://status.ivao.aero/R/'.$fieldvalue.'.png" width="150" height="30" border="0" alt="IVAO VID"/></a>' ;
}
?>
</td>
</td>
<?php
}
?>
</tbody>
</table>

and still show " There are no pilots!" , where can I found output for Debug ?

Tnx

It should be showing on the page. If it’s not, then you are either looking in the wrong place or haven’t called it

HI

are you sure this code is correct ?

'p.airline'

and also I try ‘p.code’ , but those are not working . 

and I think below link doesn’t exist in PilotData :

PilotData::findPilots(array('p.airline'=>$airline->codes));

Yes I said back here:

It’s p.code.

And it should be

$airline->code

Not codes