Jump to content

[SOLVED] Remove select airports from schedules_searchform.tpl


AGuyFawkesMask

Recommended Posts

Good evening, everyone--and happy holidays! I'm unsure whether or not this is the appropriate section to ask whether or not anyone developed a solution for this yet, but I'm not exactly asking for support. This is just a question.

Has anyone ever written a script that excludes certain airports from showing up in the depapttab, arrapttab dropdown menus on their schedules_searchform.tpl?

This would be useful to me because I have certain airports right now in my phpvms_airports table that were previously used during temporary "charter" activities. Today, we no longer utilize them in our day-to-day operation.

Here's what I originally came up with:

<div id="depapttab">
<p>Select your departure airport:</p>
<select id="depicao" name="depicao">
<option value="">Select All</option>
<?php
$exclude = array(13, 18, 19, 22);
if(!$depairports) $depairports = array();
foreach($depairports as $airport) {
if(!in_array($depairports->id, $exclude)) {
 echo '<option value="'.$airport->icao.'">'.$airport->icao.' - '.$airport->name.'</option>';
}
}
?>
</select>
<input type="submit" name="submit" value="Find Flights" />
</div>

Unfortunately, none of this worked though.

Any insight? I have a feeling it might be connected to modules/Schedules.php, but I'm unsure.

Thanks in advance for the assistance.

Link to comment
Share on other sites

  • Moderators

if you think you won't use those airports ever again, then you'll have to do two things to remove them for good:

1. Delete the airports from your DB totally.

2. Delete all schedules you have created for those airports

* You can either use the admin center for this or your DB.

But if you want them to be there just in case for future use then you're gonna have to write some code and say if $airport->name == "LLLL", continue here is an example:

foreach($depairports as $airport) {
{
  if($airport->icao == "ABCD")
      {
        continue;
      }
  echo '<option value="'.$airport->icao.'">'.$airport->icao.' - '.$airport->name.'</option>';
}

Now "ABCD" is the ICAO of the airport you want to exclude. :D

  • Like 1
Link to comment
Share on other sites

That's a good idea, parkho, but I actually solved the issue myself! Have a look:

<div id="depapttab">
 <p>Select your departure airport:</p>
 <select id="depicao" name="depicao">
 <option value="">Select All</option>
 <?php
 $exclude = array(13, 18, 19, 22); // Airport IDs found in phpVMS_airports not to be included in the dropdown menu
 if(!$depairports) $depairports = array();
  foreach($depairports as $airport) {
   if(!in_array($airport->id, $exclude)) { // Exclude values in the above array from the dropdown menu
 echo '<option value="'.$airport->icao.'">'.$airport->icao.' - '.$airport->name.'</option>';
   }
  }
 ?>
 </select>
 <input type="submit" name="submit" value="Find Flights" />
</div>

It was really just a small error that I failed to catch. I was using...

if(!in_array($depairports->id, $exclude))

...instead of...

if(!in_array($airport->id, $exclude))

What a silly mistake! :lol: Anyway, all fixed now. Hopefully this can be of benefit to some other users. (I think I tagged the right search words.)

Thanks for the suggestion, though. And have a good holiday!

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