Jump to content

Aircraft Enabled [SOLVED]


ukmil

Recommended Posts

Hi, is there anyway to show on my Fleet page if an aircraft is enabled? my knowledge of coding is poor, so would not know where to start. I see in the DB, that there is a '1' against aircaft that are enabled.

So, in my FLEET page, is there a code i can enter which would look at the DB, and if it finds a '1' shows the words 'AVAILABLE', and if it finds a '0' it shows the words 'UNDER MAINTENANCE- UNAVAILABLE'

thanks in advance

Iknow a maintenance script has been requested but this surely is an easy way of doing it.

Link to comment
Share on other sites

ok, since no one helped, I have tried to do this alone. I know NO PHP coding, but managed to get this to work

I use the FLEET TABLE script on this site, and i have managed to get the table to show what I want now :lol:

I added this code into the table

<td><?php If($aircraft->enabled==1){echo "AVAILABLE";} else {echo "UNDER MAINTENANCE";}?></td>

so now on my FLEET page, i get this

fleet.jpg

So my aircraft are now listed as AVAILABLE or UNDER MAINT. This is controlled by the AIRCRAFT ENABLED TICK selection in the aircraft maintenance area

But this is where my skills end

What I would like, is to split the table into two tables.

I would like to show ONLY the available aircraft in the first table., then the UNDER MAINT aircraft in a separate table underneath

I am sure this is possible using some PHP IF/ELSe coding etc but i have no idea how

anyone help?

Link to comment
Share on other sites

no problems, I will post my code later

i have amended it even further, and now have split the table into three sections. The top section shows current flying aircraft, the next section only shows AVAILABLE aircraft, and the lower, all unavailable.

I am learing this PHP stuff every day.

I have also changed the Pilots page, which i will post in another thread, which splits active/inactive crews.

Link to comment
Share on other sites

ok, here is what I did

first, you need the FLEET TABLE code from here

http://forum.phpvms.net/topic/1522-fleet-table/

install that, then replace the code in the Fleet_table.tpl with the one attatched. [backup your original one first, as this one is heavily customised to suit me, and may not suit you]

This code will give you a SPLIT table on your page.

At the top, you will have any aircraft listed as AVAILABLE via the ADMIN menu

underneath, any aircraft you have unticked as enabled. THey will be listed as UNDER MAINT.

it also uses a customised version of the LIVE FLIGHTBOARD here

http://forum.phpvms.net/topic/4650-flightboard/page__view__findpost__p__34526__hl__liveboard__fromsearch__1

it places a smaller version at the top, so you can see any aircraft in use.

post-139-052936700 1309256932_thumb.jpg

fleet_table.zip

Link to comment
Share on other sites

I will also post later, the newset code I am running, which as per the last pic, does not just change the status of the available aircraft when acars data is active, but actually hides it in the list.

However, what I have also done, is changed the ACARS timing from the defauly 720 minutes, to 20 minutes. This is becuase even after you are completed, and filed the Pirep, Acars will still show 'arrived' in the liveboard, and will not place the aircraft back in the list. Changing it to 20 mins, means 20 mins after to file the Pirep, the aircraft will be placed back in the list for use.

Link to comment
Share on other sites

here is my latest revision TPL. this one will remove the aircraft totally from the Availalbe list, if acars data exists against it. As i said though, beware, that for 12 hours after the aircraft has 'arrived' it will remain hidden. I suggest you alter your acars time in the Config

fleet_table.zip

Link to comment
Share on other sites

where i put the </div> in. in my fleet table? or antoher tpl?

i dont know

If it's only doing that on that one page, then place it with all the other </div> at the bottom of the fleet_table.tpl (or however it is named).

Try to add it after this code and see how that works for you.

</tbody>
</table>

So it looks like this...

</tbody>
</table>
</div>

If it doesn't move down, just try adding one at a time so it does, but I think it should only need one.

Link to comment
Share on other sites

Hi

I dont know were i must put in this is my fleet_table

<style type="text/css">
<!--
th {
color: #ff8710;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-weight: bolder;
font-size: 14px;
}
td {
color: #000000;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: normal;
}
-->
</style>
<h1><center><?php echo SITE_NAME?> Fleet Availability</center></h1>
<!-- Fleet Table Version 2.0.- - fleet_table.tpl - By Mitchell W
http://forum.phpvms.net/topic/1522-fleet-table/
CHANGES FROM 1.1:
Added image
Added download
-->
<td align="center">
<h2><center>AIRCRAFT CURRENTLY FLYING</center></h2></td>
<table align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff" style="border:1px solid grey;">
 <tr>
   <th align="center" style="background-color: #006699; width: 3.5%;"> </th>
       <th width="20%" align="center" style="background-color: #006699;">Aircraft</th>
   <th width="5%" align="center" style="background-color: #006699;">Reg</th>
   <th width="18.5%" align="center" style="background-color: #006699;">Status</th>
</tr>

<?php

$results = ACARSData::GetACARSData();

if (count($results) > 0)
  {
  foreach($results as $flight)
     {

        ?>
     <tr>
         <td></td>
         <td align="center"><?php echo $flight->aircraftname;?></td>
         <td style="font-weight: bolder;"><?php echo $flight->aircraft; ?></td>
         <td align="center"><?php if($flight->phasedetail
   != 'Paused') { echo $flight->phasedetail; }
   else { echo "Cruise"; }?></font></td>
     </tr>
 <?php          
               }
           } else { ?>
               <tr><td width="20%" align="center" colspan="6" style="padding: 5px; font-size: 13px; font-weight: bold; color: #ff961e;">No Aircraft Currently Flying</td></tr>
           <?php
           }
           ?>
</table>
<p></p>
<table border="0">
<thead>  
<tr>
<td align="center">
<table width="100%" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff" style="border:1px solid grey;">

 <tr>
   <th width="10%" align="center" style="background-color: #006699;">Image</th>
   <th width="15%" align="center" style="background-color: #006699;">Type</th>
   <th width="5%" align="center" style="background-color: #006699;">Reg</th>    
   <th width="10%" align="center" style="background-color: #006699;">Hours used</th>
<th width="5%" align="center" style="background-color: #006699;">Flights</th>
   <th width="20.5%" align="center" style="background-color: #006699;">Location</th>
<th width="28.5%" align="center" style="background-color: #006699;">Status</th>
<th width="15.5%" align="center" style="background-color: #006699;">Download Link</th>
</tr>



<tbody>
<?php foreach ($fleet as $aircraft) If($aircraft->enabled==1)
{if($aircraft->registration=="-") { continue; }

?>
<tr>
<td bgcolor="#006699"><img src="<?php echo $aircraft->imagelink; ?>"></td>
<td bgcolor="#006699"><center><font color=#FFFFFF><?php echo $aircraft->name; ?></font></center> </td>
<td bgcolor="#006699" style="font-weight: bolder;"><center><font color=#FFFFFF><?php echo $aircraft->registration; ?></font></center></td>
<td bgcolor="#006699"><center><font color=#FFFFFF><?php echo $aircraft->totaltime; ?></font></center></td>
<td bgcolor="#006699"><center><font color=#FFFFFF><?php echo $aircraft->routesflown; ?></font></center></td><?php
$params = (array('a.registration'=>$aircraft->registration, 'p.accepted'=>PIREP_ACCEPTED));

$pirep = PIREPData::findPIREPS($params);
$current_location2 = $pirep[0]->arrname;
?>
<td bgcolor="#006699" style="font-weight: bolder;"><center><font color=#FFFFFF><?php echo $current_location.''.$current_location2; ?></font></center></td>
<td bgcolor="#006699"><center><font color=#FFFFFF><?php If($aircraft->enabled==1){echo "AVAILABLE";} else {echo "UNDER MAINTENANCE";}?></font></center></td>
<td bgcolor="#006699"><a href="<?php echo $aircraft->downloadlink; ?>"><center><font color=#FFFFFF>Click</font></center></td>
</tr>
<?php } ?>
</table>
<p></p>
<table width="100%" align="center" cellpadding="0" cellspacing="0" bgcolor="#006699" style="border:1px solid grey;">
<th><font color=#FFFFFF>Unavailable Aircrafts</font></th>
</table>
<table border="0">
<p></p>
<p></p>
<thead> 

<tr>
<td align="center">
<table width="100%" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff" style="border:1px solid grey;">
 <tr>
   <th width="10%" align="center" style="background-color: #006699;">Image</th>
   <th width="15%" align="center" style="background-color: #006699;">Type</th>
   <th width="5%" align="center" style="background-color: #006699;">Reg</th>    
   <th width="10%" align="center" style="background-color: #006699;">Hours used</th>
<th width="5%" align="center" style="background-color: #006699;">Sorties</th>
   <th width="20.5%" align="center" style="background-color: #006699;">Location</th>
<th width="28.5%" align="center" style="background-color: #006699;">Status</th>
<th width="15.5%" align="center" style="background-color: #006699;">Download Link</th>
</tr>
<?php foreach ($fleet as $aircraft) If($aircraft->enabled==0)
{
?>
<tr>
<td bgcolor="#006699"><img src="<?php echo $aircraft->imagelink; ?>"></td>
<td bgcolor="#006699"><center><font color=#FFFFFF><?php echo $aircraft->name; ?></font></center> </td>
<td bgcolor="#006699" style="font-weight: bolder;"><center><font color=#FFFFFF><?php echo $aircraft->registration; ?></font></center></td>
<td bgcolor="#006699"><center><font color=#FFFFFF><?php echo $aircraft->totaltime; ?></font></center></td>
<td bgcolor="#006699"><center><font color=#FFFFFF><?php echo $aircraft->routesflown; ?></font></center></td>
<?php
$params = (array('a.registration'=>$aircraft->registration, 'p.accepted'=>PIREP_ACCEPTED));

$pirep = PIREPData::findPIREPS($params);
$current_location2 = $pirep[0]->arrname;
?>
<td bgcolor="#006699" style="font-weight: bolder;"><center><font color=#FFFFFF><?php echo $current_location.''.$current_location2; ?></font></center></td>
<td bgcolor="#006699"><center><font color=#FF0000><?php If($aircraft->enabled==1){echo "AVAILABLE";} else {echo "UNDER MAINTENANCE";}?></font></center></td>
<td bgcolor="#006699"><a href="<?php echo $aircraft->downloadlink; ?>"><center><font color=#FFFFFF>Click</font></center></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<br />

Link to comment
Share on other sites

ok, found a problem with my code, told you I was never that good at this

the part in the AVAILABLE list, which either hides, or places 'in use' against it has an error

it only works on one aircraft. So if you only have one aircraft in flight, it works, which is how tested it

BUT, if you have multiple aircraft, the code only seems to pick on the last aircraft listed in the IN FLIGHT table, and uses that data in the AVAILABLE table. sO no matter how many aircraft are flying, you will only ever see one hidden, or listed as in use

does any coder know where I have gone wrong, and a way to fix it?

I suspect it is this

if($flight->aircraft==$aircraft->registration){continue;}

since the first bit of code in the tpl, takes each aircraft in turn , and puts it in the IN FLIGHLT board, the one aircraft 'left in memory' when it moves into the top table, is the one it hides

how can i force the table to check every aircraft in the acars data?

Link to comment
Share on other sites

If it's only doing that on that one page, then place it with all the other </div> at the bottom of the fleet_table.tpl (or however it is named).

Try to add it after this code and see how that works for you.

</tbody>
</table>

So it looks like this...

</tbody>
</table>
</div>

If it doesn't move down, just try adding one at a time so it does, but I think it should only need one.

Hi it doesnt work. Any Idea here is my code again

<style type="text/css">
<!--
th {
color: #ff8710;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-weight: bolder;
font-size: 14px;
}
td {
color: #000000;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: normal;
}
-->
</style>
<h1><center><?php echo SITE_NAME?> Fleet Availability</center></h1>
<!-- Fleet Table Version 2.0.- - fleet_table.tpl - By Mitchell W
http://forum.phpvms.net/topic/1522-fleet-table/
CHANGES FROM 1.1:
Added image
Added download
-->
<td align="center">
<h2><center>AIRCRAFT CURRENTLY FLYING</center></h2></td>
<table align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff" style="border:1px solid grey;">
 <tr>
   <th align="center" style="background-color: #006699; width: 3.5%;"> </th>
       <th width="20%" align="center" style="background-color: #006699;">Aircraft</th>
   <th width="5%" align="center" style="background-color: #006699;">Reg</th>
   <th width="18.5%" align="center" style="background-color: #006699;">Status</th>
</tr>

<?php

$results = ACARSData::GetACARSData();

if (count($results) > 0)
  {
  foreach($results as $flight)
     {

        ?>
     <tr>
         <td></td>
         <td align="center"><?php echo $flight->aircraftname;?></td>
         <td style="font-weight: bolder;"><?php echo $flight->aircraft; ?></td>
         <td align="center"><?php if($flight->phasedetail
   != 'Paused') { echo $flight->phasedetail; }
   else { echo "Cruise"; }?></font></td>
     </tr>
 <?php          
               }
           } else { ?>
               <tr><td width="20%" align="center" colspan="6" style="padding: 5px; font-size: 13px; font-weight: bold; color: #ff961e;">No Aircraft Currently Flying</td></tr>
           <?php
           }
           ?>
</table>
<p></p>
<table border="0">
<thead>  
<tr>
<td align="center">
<table width="100%" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff" style="border:1px solid grey;">

 <tr>
   <th width="10%" align="center" style="background-color: #006699;">Image</th>
   <th width="15%" align="center" style="background-color: #006699;">Type</th>
   <th width="5%" align="center" style="background-color: #006699;">Reg</th>    
   <th width="10%" align="center" style="background-color: #006699;">Hours used</th>
<th width="5%" align="center" style="background-color: #006699;">Flights</th>
   <th width="20.5%" align="center" style="background-color: #006699;">Location</th>
<th width="28.5%" align="center" style="background-color: #006699;">Status</th>
<th width="15.5%" align="center" style="background-color: #006699;">Download Link</th>
</tr>



<tbody>
<?php foreach ($fleet as $aircraft) If($aircraft->enabled==1)
{if($aircraft->registration=="-") { continue; }

?>
<tr>
<td bgcolor="#006699"><img src="<?php echo $aircraft->imagelink; ?>"></td>
<td bgcolor="#006699"><center><font color=#FFFFFF><?php echo $aircraft->name; ?></font></center> </td>
<td bgcolor="#006699" style="font-weight: bolder;"><center><font color=#FFFFFF><?php echo $aircraft->registration; ?></font></center></td>
<td bgcolor="#006699"><center><font color=#FFFFFF><?php echo $aircraft->totaltime; ?></font></center></td>
<td bgcolor="#006699"><center><font color=#FFFFFF><?php echo $aircraft->routesflown; ?></font></center></td><?php
$params = (array('a.registration'=>$aircraft->registration, 'p.accepted'=>PIREP_ACCEPTED));

$pirep = PIREPData::findPIREPS($params);
$current_location2 = $pirep[0]->arrname;
?>
<td bgcolor="#006699" style="font-weight: bolder;"><center><font color=#FFFFFF><?php echo $current_location.''.$current_location2; ?></font></center></td>
<td bgcolor="#006699"><center><font color=#FFFFFF><?php If($aircraft->enabled==1){echo "AVAILABLE";} else {echo "UNDER MAINTENANCE";}?></font></center></td>
<td bgcolor="#006699"><a href="<?php echo $aircraft->downloadlink; ?>"><center><font color=#FFFFFF>Click</font></center></td>
</tr>
<?php } ?>
</table>
<p></p>
<table width="100%" align="center" cellpadding="0" cellspacing="0" bgcolor="#006699" style="border:1px solid grey;">
<th><font color=#FFFFFF>Unavailable Aircrafts</font></th>
</table>
<table border="0">
<p></p>
<thead> 

<tr>
<td align="center">
<table width="100%" align="center" cellpadding="0" cellspacing="0" bgcolor="#ffffff" style="border:1px solid grey;">
 <tr>
   <th width="10%" align="center" style="background-color: #006699;">Image</th>
   <th width="15%" align="center" style="background-color: #006699;">Type</th>
   <th width="5%" align="center" style="background-color: #006699;">Reg</th>    
   <th width="10%" align="center" style="background-color: #006699;">Hours used</th>
<th width="5%" align="center" style="background-color: #006699;">Sorties</th>
   <th width="20.5%" align="center" style="background-color: #006699;">Location</th>
<th width="28.5%" align="center" style="background-color: #006699;">Status</th>
<th width="15.5%" align="center" style="background-color: #006699;">Download Link</th>
</tr>
<?php foreach ($fleet as $aircraft) If($aircraft->enabled==0)
{
?>
<tr>
<td bgcolor="#006699"><img src="<?php echo $aircraft->imagelink; ?>"></td>
<td bgcolor="#006699"><center><font color=#FFFFFF><?php echo $aircraft->name; ?></font></center> </td>
<td bgcolor="#006699" style="font-weight: bolder;"><center><font color=#FFFFFF><?php echo $aircraft->registration; ?></font></center></td>
<td bgcolor="#006699"><center><font color=#FFFFFF><?php echo $aircraft->totaltime; ?></font></center></td>
<td bgcolor="#006699"><center><font color=#FFFFFF><?php echo $aircraft->routesflown; ?></font></center></td>
<?php
$params = (array('a.registration'=>$aircraft->registration, 'p.accepted'=>PIREP_ACCEPTED));

$pirep = PIREPData::findPIREPS($params);
$current_location2 = $pirep[0]->arrname;
?>
<td bgcolor="#006699" style="font-weight: bolder;"><center><font color=#FFFFFF><?php echo $current_location.''.$current_location2; ?></font></center></td>
<td bgcolor="#006699"><center><font color=#FF0000><?php If($aircraft->enabled==1){echo "AVAILABLE";} else {echo "UNDER MAINTENANCE";}?></font></center></td>
<td bgcolor="#006699"><a href="<?php echo $aircraft->downloadlink; ?>"><center><font color=#FFFFFF>Click</font></center></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<br />

Link to comment
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...