Jump to content

Random Itineray Builder


Recommended Posts

  • 1 month later...
Posted

hello, is there any way that after the pilot book their ranges, the system block bookings for this pilot? It can happen that a pilot does not like its range and allowing a stay on top of another, and at worst all routes may be booking for a single pilot.

Wait a reply :)

  • 4 weeks later...
  • 5 months later...
Posted

Is it possible to add a couple more drop-downs for Aircraft type (737, 744, etc.) and another for Airline? If it is possible, can you please explain how. :huh:

Posted

This is the whole code that I am trying to get the "Choose Aircraft" menu added to the page. Something I have in there is not coming up right because I just have an empty drop-down box.

<?php
$pilotid = Auth::$userinfo->pilotid;
$last_location = PIREPData::getLastReports($pilotid, 1);
$last_name = OperationsData::getAirportInfo($last_location->arricao);
$userinfo = PilotData::getPilotData($pilotid);

if($last_location->arricao == '') $last_location->arricao = $userinfo->hub;
?>

<table border = "0">
 <tr>
       <th scope="col">Random Itinerary from Current Location</th>
 </tr>
 <tr><form name="randomflights" id="randomflights" action="<?php echo SITE_URL?>/index.php/randomflights/getRandomFlights" method="post">
   <td>Current Location Preselected </td>
     <table>
       <tr>
                       <td width ="25%"><b>Current Location:</b></td>
                       <td width ="75%"><select id="depicao" name="depicao">
                         <option value="<?php echo $last_location->arricao?>"><?php echo $last_location->arricao?> (<?php echo $last_name->name?>)</option>
                       </td>           
               </tr>

                       <tr>
                       <td width ="25%"><b>Aircraft:</b></td>
                       <td width ="75%"><select id="equipment" name="equipment">		
                       <option value="<?php echo $equip->name?>"><?php echo $equip->name?></option>
                       <?php

	if(!$equipment) $equipment = array();
	foreach($equipment as $equip)
	{
		echo '<option value="'.$equip->name.'">'.$equip->name.'</option>';
	}

	?>
                     </td>
</tr>

               <tr>
                       <td width ="25%"><b>Number of Flights:</b></td>
                       <td width ="75%"><select id="count" name="count"> 
                         <option value="1">1</option>                        
                         <option value="5">5</option>
                         <option value="10">10</option>
                         <option value="15">15</option>                                        
                       </select></td>
                       <td><input type="submit" name="submit" value="Find Random Flights"></td>
               </tr>
         </table>              
   </form>
 </tr>
</table>

This is the part I need help with:

<tr>
                       <td width ="25%"><b>Aircraft:</b></td>
                       <td width ="75%"><select id="equipment" name="equipment">		
                       <option value="">Select Equipment<?php echo $equip->name?><?php echo $equip->name?></option>
                       <?php

	if(!$equipment) $equipment = array();
	foreach($equipment as $equip)
	{
		echo '<option value="'.$equip->name.'">'.$equip->name.'</option>';
	}

	?>
                     </td>
</tr>

Guest lorathon
Posted

You will have to fill $equipment with the correct array in the module. You will then need to use this in the search function to filter only those flights with the selected aircraft.

Posted

I got most of that code from the schedule_searchform.tpl and tweaked it to look like (at least how I thought it was supposed to look like) the way you have it when it is searching for its items. I cannot figure out how to code it to search by airframe (EX: All, A320, B737, E45, SF3, etc...)

Guest lorathon
Posted

Version 1.2 released. Same link

http://fs-products.net/PhoenixVA/index.php/downloads

  • If a pilot does not have a flight in yet the starting point will now be that pilots hub.
  • If the script can not find the number of flights selected errors will not be displayed.
  • Pilot able to select equipment to be searched with also. The pilot does NOT need to use this. If the pilot leaves the drop down alone it will search for all airframes.

Posted

Let me see what I can do.

Thank you very much lorathon. I actually had that part coded correctly, I just couldn't figure out what I needed to place in the randomflights.tpl to make it work. I appreciate your help.

Posted

With this code I placed in the randomsearch.tpl

<tr>
		<td width ="25%"><b>Airline: <FONT COLOR="#FF0000">(Optional)</FONT></b></td>
           <td width ="75%"><select id="allAirlines" name="allAirlines">               
            <option value="">Select Airline</option>
           <?php

       if (!$allAirlines) $allAirlines = array();

               foreach($allAirlines as $airline)

           {

               echo '<option value="'.$airline->code.'" '.$sel.'>'.$airline->code.' - '.$airline->name.'</option>';
               }
               ?>
           </td>
       </tr>

and some coding placed in the RandomFlights.php (whole code displayed below)

<?php
/*
* phpVMS Module: Random Itinerary Builder
* Coding by Jeffrey Kobus
* www.fs-products.net
* Verion 1.2
* Dated: 03/21/2011
*/


class RandomFlights extends CodonModule
{
public function index()
	{
		Template::Show('randomsearch.tpl');
	}	

public function getRandomFlights()
	{		
		$dep 	= $this->post->depicao;
		$airline = $this->set('allAirlines', $airline);   //This is what I added. I also tried $airline = $this->post->airline;
		$equip 	= $this->post->equipment;
		$count 	= $this->post->count;

		for($i = 0; $i < $count; $i++)
		{					
			$params = array(
     				's.depicao' => $dep,      			
     				's.enabled' => 1
     			);

     			if(!$airline)        // I also added this piece of coding here. I was getting most of the info from a couple of places I searched for in the forum (some was Simpilots)
                   {
                       $airline = '%';
                   }


     			if($equip != "") $params['a.icao'] = $equip;

			$flights = SchedulesData::findSchedules($params);
			if($flights)
			{			
				foreach ($flights as $row)
				{
					$r = rand(0, count($flights));				
					$airline = OperationsData::getAirlineByCode($flights[$r]->code);				
					if($airline->enabled == 0) continue;
					if ($flights[$r]->aircraftlevel > Auth::$userinfo->ranklevel)
					{
						continue;
					}
					else
					{					
						$schedules[$i] = $flights[$r];
						$dep = $flights[$r]->arricao;					
						break;
					}
				}
			}

		}

		Template::Set('schedules', $schedules);
		Template::Set('count', $count);
		Template::Show('randomflights.tpl');					
	}

public function bidAll()
	{			
		$count = $this->post->count;			

		for ($i = 0; $i < $count; $i++)
		{				
			$ret = SchedulesData::addBid($this->post->pilotid, $this->post->schedules[$i]);
			$flight = SchedulesData::getSchedule($this->post->schedules[$i]);				
			if($ret) echo 'Flight - '.$flight->code.$flight->flightnum.' added <br/>';
		}			
		echo 'Finished';		
	}
}
?>

I am still getting nothing in the Dropdown except "SELECT AIRLINE". What the heck am I missing here? I can't figure out what you changed before when you added the Airframe menu. Do I have a typo somewhere, or is there another code I need to place somewhere?

  • 2 months later...
Posted

Version 1.3 released. Same link

http://fs-products.n...x.php/downloads

  • Fixed Equipment Selection
  • Addition of Airline selection

i have installed version 1.3

but my location is LIPQ and i sarch the flyght i have this

51501855.jpg

the second flight is not correct beacuse LIPQ is Airport Arrival not Departure.

The second problem

if click on blook flight, the system blook two flight. If possible blook only one ?

52289413.jpg

Thank's

Guest lorathon
Posted

#1 - The itinerary is correct. The flights are one after another. From one airport to the next and then from that airport onward. This module builds an itinerary.

#2 - If you want 1 then change the form to allow for one flight. It is hard coded for 5,10,15 right now. But 1 should be able to be added.

Guest lorathon
Posted

Go ahead and change the code. It is just the template form that you need to change.

randomsearch.tpl

<?php
$pilotid = Auth::$userinfo->pilotid;
$last_location = PIREPData::getLastReports($pilotid, 1);
$last_name = OperationsData::getAirportInfo($last_location->arricao);
?>

<table border = "0">
 <tr>
<th scope="col">Random Itinerary from Current Location</th>
 </tr>
 <tr><form name="randomflights" id="randomflights" action="<?php echo SITE_URL?>/index.php/randomflights/getRandomFlights" method="post">
   <td>Current Location Preselected </td>
     <table>
       <tr>
		<td width ="25%"><b>Current Location:</b></td>
		<td width ="75%"><select id="depicao" name="depicao">
		  <option value="<?php echo $last_location->arricao?>"><?php echo $last_location->arricao?> (<?php echo $last_name->name?>)</option>
		</td>		
	</tr>
	<tr>
		<td width ="25%"><b>Number of Flights:</b></td>
		<td width ="75%"><select id="count" name="count">
                         <option value="1">1</option>			  
		  <option value="5">5</option>
		  <option value="10">10</option>
		  <option value="15">15</option>			  		
		</select></td>
		<td><input type="submit" name="submit" value="Find Random Flights"></td>
	</tr>
  </table>	  	
   </form>
 </tr>
</table>

  • 3 weeks later...
Posted

Hi Jeff,

I'm having an issue with the Random Itinerary builder.

It doesn't often build the correct number of flights as selected. I will put in 5 flights and it might show 3 (or something different)

The only changes to the template is adding the option to select 1 or 3 flights and deleting the 15 flight option.

I have plenty of schedules that would allow the continuity of the legs.

Any ideas?

Guest lorathon
Posted

Not sure. Check the module. There is a rank limit, maybe that is a stopping the build.

Posted

Hmmmm. The ranks appear to be correct.

I've recently imported a number of airports - perhaps that has affected things?

I've also just noticed some of the route distances are off after recalculating - not sure if that would have an impact.

Posted

There may be a couple of things you can check to see if they are conflicting your searches.

1. See if there are actually flights out of all your destinations.

2. Make sure that the Days of Operations aren't conflicting with it, since you might have flights that aren't scheduled to fly that day, so it can't continue the search.

Posted

There may be a couple of things you can check to see if they are conflicting your searches.

1. See if there are actually flights out of all your destinations.

2. Make sure that the Days of Operations aren't conflicting with it, since you might have flights that aren't scheduled to fly that day, so it can't continue the search.

Thanks for the suggestions. Checked to make I had them covered - had one airport without a departure leg and a couple of routes that didn't fly everyday. Changed those but still no luck :(

  • 2 months later...
Posted

hello jeff

I tried changing the option "get current location" with "select departure airport" but when I click on "find random flights" can not find any flight, although there are flights

these are the changes I made in core/templates/randomsearch.tpl

view line 11 and line 28 to 44

<?php
/*
* phpVMS Module: Random Itinerary Builder
* Coding by Jeffrey Kobus
* www.fs-products.net
* Verion 1.3
* Dated: 03/22/2011
*/

$pilotid = Auth::$userinfo->pilotid;
$airports = OperationsData::GetAllAirports(); 
$equipment = OperationsData::GetAllAircraftSearchList(true);
$airlines = OperationsData::getAllAirlines(true);
?>

<table border = "0">
 <tr>
<th scope="col">
<font color=red>Random Itinerary Builder</th>
 </tr>
 <tr><form name="randomflights" id="randomflights" action="<?php echo SITE_URL?>/index.php/randomflights/getRandomFlights" method="post">
<td><font color=yellow>Current Location Preselected </td>
 	<table>
   	<tr>
 	<td width ="25%"><b><font color=red>Select departure airport:</b></td>
		<td width ="75%"><select id="airport" name="airport">
<option value="">Select airport</option>

<?php 
if(!$airports) $airports = array();

foreach ($airports as $airport) 
{

     	echo '<option value="'.$airport->icao.'">'.$airport->icao.' - ' . $airport->name.' </option>';
}

?>



		</td>		
	</tr>
	<tr>
		<td width ="25%"><b><font color=red>Airline:</b></td>
       	<td width ="75%"><select id="airline" name="airline">       		
       		<option value="">Select Airline</option>
       	<?php
           	if(!$airlines) $airlines = array();
           	foreach($airlines as $airline)
           	{
echo '<option value="'.$airline->code.'">'.$airline->name.'</option>';
           	}
       	?>
       	</td>
   	</tr>
	<tr>
		<td width ="25%"><b><font color=red>Aircraft:</b></td>
       	<td width ="75%"><select id="equipment" name="equipment">       		
       		<option value="">All Aircraft</option>
       	<?php
           	if(!$equipment) $equipment = array();
           	foreach($equipment as $equip)
           	{
                   	echo '<option value="'.$equip->icao.'">'.$equip->name.'</option>';
           	}
       	?>
       	</td>
   	</tr>
	<tr>
		<td width ="25%"><b><font color=red>Number of Flights:</b></td>
		<td width ="75%"><select id="count" name="count">		  	
	  	<option value="5">5</option>
	  	<option value="10">10</option>
	  	<option value="15">15</option>		  			
		</select></td>
		<td><input type="submit" name="submit" value="Find Random Flights"></td>
	</tr>
 	</table>  		
</form>
 </tr>
</table>

I miss some changes?

Thanks for the help

Best regards

Mattia

  • 3 months later...
Posted

I've been looking at the code and was wondering how I can change that it doesn't only look at the current location, but looks for those flights with a defined "destination airport".

Let's say I'm at KORD, and I want to fly to Lukla in the hymalaya's.

It knows my current location and I enter the ICAO for lukla. Then the script should look for connection flights that get me to Lukla. no matter how many legs it takes. If a flight is missing, it should create a connnecting charter flight.

  • 1 month later...
Posted

Hi Jeff,

I did get the question if it possible to put a choice in distance. Becuase sometimes people don`t want to

do longhauls.

Regards,

Cor

  • Like 1

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