faraz
January 29, 2010, 4:22pm
1
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
nabeel
January 29, 2010, 7:35pm
2
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
faraz
January 29, 2010, 7:41pm
3
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 .
nabeel
January 29, 2010, 7:54pm
4
Do p.airline (it might be case senstive).
What’s in your template? And what’s it showing now?
faraz
January 29, 2010, 8:00pm
5
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');
}
nabeel
January 29, 2010, 8:01pm
6
After
$this->set(‘allpilots’, PilotData::findPilots(array(‘p.airline’=>$airline->code)));
put a DB::debug(), and show what that says
faraz
January 29, 2010, 8:11pm
7
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');
}
nabeel
January 29, 2010, 10:37pm
8
You forgot the semi colon at the end of the DB::debug(); line
faraz
January 29, 2010, 10:49pm
9
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');
}
nabeel
January 29, 2010, 11:59pm
10
Look on that page, it will show what’s returned there
faraz
January 30, 2010, 6:47pm
11
sorry
I don’t understand . what do you mean ?
faraz
February 2, 2010, 3:48pm
12
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');
}
nabeel
February 2, 2010, 4:25pm
13
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
faraz
February 2, 2010, 4:39pm
14
Please see below link : (pilot roster output )
and for Debug , you need Log ?
Tnx
faraz
February 4, 2010, 3:21pm
15
Does anyone have any idea how i would do this?
nabeel
February 4, 2010, 3:32pm
16
After
$allairlines = OperationsData::getAllAirlines();
Put a DB::debug(); and post the output
faraz
February 4, 2010, 4:05pm
17
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
nabeel
February 4, 2010, 11:13pm
18
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
faraz
February 4, 2010, 11:42pm
19
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));