Hey guys, I have a new project that I want to do. I noticed the boarding pass does this thing where is gets a random gate, how can I make it randomly select the specific gate at an airport?
For example, I have 14 gates at Las Vegas, and 11 gates at San Jose. If a pilot views the boarding pass I want it to randomly select one of the gate numbers I put in for Vegas.
Then I plan on taking this method and putting it in my flight dispatch for pilots.
So, how would I go about doing this? Would if be possible to write something like if $airport = KLAS select gates x - x or something of the sort?
Hey guys, I have a new project that I want to do. I noticed the boarding pass does this thing where is gets a random gate, how can I make it randomly select the specific gate at an airport?
For example, I have 14 gates at Las Vegas, and 11 gates at San Jose. If a pilot views the boarding pass I want it to randomly select one of the gate numbers I put in for Vegas.
Then I plan on taking this method and putting it in my flight dispatch for pilots.
So, how would I go about doing this? Would if be possible to write something like if $airport = KLAS select gates x - x or something of the sort?
That PHP there where it gets the date, you can do:
<?php
if($schedule->depicao == 'KLAS') {
echo chr(rand(65, 68)); // Gate letter between A and C
echo rand(10, 22); // Random gate letter between 10 and 22
} elseif($schedule->depicao == 'KJFK') {
echo chr(rand(66, 70)); // Gate letter between B and E
echo rand(110, 120); // Random gate letter between 110 to 120
}
I got this working perfectly for two of my airports KBOS and KSFO but I want to have accurate gates and terminals for each city we serve all 18. I researched for a couple hours yesterday and accurately copied the terminals and gates from the airport sites on the web. So…I copied the if…else statement and just pasted it after the first statement. Works great!! Also, some of my airports only have numbered gates like PHNL. You can see that instead of letters, I substituted the ASCII code for a dash “-” I am so proud of this since I don’t know spit about php coding. There are 2 problems I have encountered maybe Nabeel can help. When you generate a boarding pass it picks the gate correctly at random from my specs in the template, BUT when you push the print view it generates a NEW gate. The first three if/else pairs generate gates then every other one just comes up blank. Help please.
if($schedule->depicao == ‘KBOS’) {
echo chr(rand(69, 69)); // Gate letter between E and E
echo rand(2, 8); // Random gate letter between 2 and 8
} elseif($schedule->depicao == ‘KSFO’) {
echo chr(rand(65, 65)); // Gate letter between A and A
echo rand(1, 12); // Random gate letter between 1 to 12
}
if($schedule->depicao == ‘PHNL’) {
echo chr(rand(45, 45)); // No gate letter just a dash
echo rand(14, 14); // Gate letter 14
} elseif($schedule->depicao == ‘KMIA’) {
echo chr(rand(69, 69)); // Gate letter between E and E
echo rand(2, 12); // Random gate letter between 2 to 12
Nabeel, could you please take a look at my post above and let me know if this is able to support multiple gate selections like 18 of them or am I overextending this. thank you
Thank you, I figured it was something like that which is why I asked Nabeel who wrote it to take a look. I think that more people might like to use this like I am to get their aircraft to load at the actual terminals with the proper gates for all their flights (unless you have 300 flights or something).