tgycgijoes Posted April 23, 2012 Report Share Posted April 23, 2012 this is my modified schedule boarding pass. tpl It seems I have learned JUST enough php to screw it up. Can someone fluent in php please tell me why "I have an unscheduled end in line 111 the last line of this code. I have gone over it over and over and can't see an error but it worked till I changed one of the if icao gate schedules because I was not getting the proper selected gates just weird three digit random numbers. It DID work properly and then I added two airports, there were too many and now it doesn't work. Thank you. <?php # This will only show this message if it's not a popup window # Ends on line 13-15 if(!isset($_GET['newwindow'])) { ?> <h3>Requirements for Online Checkin</h3> <p>To proceed through Security Checkpoint, you will need a government-issued photo ID and either a Boarding Pass or Security Document. Customers under 18 years of age are not required to show government-issued photo ID.</p> <p><a href="#" onclick="window.open('<?php echo actionurl('/schedules/boardingpass/'.$schedule->id.'?newwindow');?>'); return false;">Open in new window for printing</a></p> <?php } ?> <style> /* Some integrated styles here, for the popup */ .boardingpass { font-family: Tahoma, Verdana; font-size: 14px; } .boardingpass h3 { background: none; padding-left: 3px; padding-bottom: 2px; } .boardingpass .thickline { background: #333; height: 2px; } </style> <table width="90%" class="boardingpass"> <tr> <td width="1%"><img src="<?php echo SITE_URL?>/lib/images/barcode.png" /></td> <td align="left"><h3><?php echo SITE_NAME;?></h3></td> </tr> <tr> <td colspan="2"><h3>Boarding Pass</h3></td> </tr> <tr class="thickline"> <td colspan="2"></td> </tr> <tr> <td valign="top"> <table class="boardingpass"> <tr> <td> <strong>Date:</strong> <br /> <strong>Name: </strong> <br /> <strong>Frequent Flier Number: </strong> <br /> <strong>Boarding Pass Number:</strong> </td> <td> <?php echo date('Y-m-d'); ?><br /> <?php echo Auth::$userinfo->firstname.' '.Auth::$userinfo->lastname?><br /> <?php echo Auth::$userinfo->code.strtoupper(substr(md5(Auth::$userinfo->pilotid), 0, 6))?><br /> <?php echo $schedule->bidid; ?><br /> </td> </tr> </td> <td valign="top"> <strong>Gate:</strong> <?php # We are gonna get a random gate if($schedule->depicao == 'PHOG'){ echo chr(rand(45, 45)); // No gate letter just a dash echo rand(9, 16); // Random gate letter between 9 and 16 }elseif($schedule->depicao == 'PHNY'){ echo chr(rand(45, 45)); // No gate letter echo rand(1, 4); // Random gate letter between 1 to 4} if($schedule->depicao == 'PHNL'){ echo chr(rand(45, 45)); // No gate letter echo rand(71, 80); // Random gate letter between 71 and 80 }elseif($schedule->depicao == 'PHKO') {echo chr(rand(45, 45)); // No gate letter echo rand(6, 10); // Random gate letter between 6 to 10} if($schedule->depicao == 'PHJH') echo chr(rand(45, 45)); // No gate letter echo rand(1, 3); // Random gate letter between 1 to 3 }elseif($schedule->depicao == 'PHMK'){ echo chr(rand(45, 45)); // No gate letter echo rand(1, 3); // Random gate letter between 1 to 3} ?> <?php # Generate a hash from the bid id, and get the first 6 characters # That'll be used for our confirmation number, and upper-case them echo strtoupper(substr(md5($schedule->bidid), 0, 6)); ?> </td> <tr class="thickline"> <td colspan="2"></td> </tr> <tr> <td valign="top"> <strong>Flight: </strong><?php echo $schedule->code.$schedule->flightnum?><br /> <strong>Depart: </strong><?php echo $schedule->deptime; ?><br /> <strong>Arrive: </strong><?php echo $schedule->arrtime;?><br /> </td> <td valign="top"> <strong>Aircraft: </strong><?php echo $schedule->aircraft?> <br /> <?php echo "$schedule->depname ($schedule->depicao)";?><br /> <?php echo "$schedule->arrname ($schedule->arricao)"; ?><br /> </td> </tr> </table> Quote Link to comment Share on other sites More sharing options...
Tom Posted April 23, 2012 Report Share Posted April 23, 2012 <?php # This will only show this message if it's not a popup window # Ends on line 13-15 if(!isset($_GET['newwindow'])) { ?> <h3>Requirements for Online Checkin</h3> <p>To proceed through Security Checkpoint, you will need a government-issued photo ID and either a Boarding Pass or Security Document. Customers under 18 years of age are not required to show government-issued photo ID.</p> <p><a href="#" onclick="window.open('<?php echo actionurl('/schedules/boardingpass/'.$schedule->id.'?newwindow');?>'); return false;">Open in new window for printing</a></p> <?php } ?> <style> /* Some integrated styles here, for the popup */ .boardingpass { font-family: Tahoma, Verdana; font-size: 14px; } .boardingpass h3 { background: none; padding-left: 3px; padding-bottom: 2px; } .boardingpass .thickline { background: #333; height: 2px; } </style> <table width="90%" class="boardingpass"> <tr> <td width="1%"><img src="<?php echo SITE_URL?>/lib/images/barcode.png" /></td> <td align="left"><h3><?php echo SITE_NAME;?></h3></td> </tr> <tr> <td colspan="2"><h3>Boarding Pass</h3></td> </tr> <tr class="thickline"> <td colspan="2"></td> </tr> <tr> <td valign="top"> <table class="boardingpass"> <tr> <td> <strong>Date:</strong> <br /> <strong>Name: </strong> <br /> <strong>Frequent Flier Number: </strong> <br /> <strong>Boarding Pass Number:</strong> </td> <td> <?php echo date('Y-m-d'); ?><br /> <?php echo Auth::$userinfo->firstname.' '.Auth::$userinfo->lastname?><br /> <?php echo Auth::$userinfo->code.strtoupper(substr(md5(Auth::$userinfo->pilotid), 0, 6))?><br /> <?php echo $schedule->bidid; ?><br /> </td> </tr> </td> <td valign="top"> <strong>Gate:</strong> <?php # We are gonna get a random gate if($schedule->depicao == 'PHOG'){ echo chr(rand(45, 45)); // No gate letter just a dash echo rand(9, 16); // Random gate letter between 9 and 16 } elseif($schedule->depicao == 'PHNY'){ echo chr(rand(45, 45)); // No gate letter echo rand(1, 4); // Random gate letter between 1 to 4 } elseif($schedule->depicao == 'PHNL'){ echo chr(rand(45, 45)); // No gate letter echo rand(71, 80); // Random gate letter between 71 and 80 } elseif($schedule->depicao == 'PHKO'){ echo chr(rand(45, 45)); // No gate letter echo rand(6, 10); // Random gate letter between 6 to 10 } elseif($schedule->depicao == 'PHJH'){ // There was an opening brace missing here echo chr(rand(45, 45)); // No gate letter echo rand(1, 3); // Random gate letter between 1 to 3 } elseif($schedule->depicao == 'PHMK'){ echo chr(rand(45, 45)); // No gate letter echo rand(1, 3); // Random gate letter between 1 to 3 } # Generate a hash from the bid id, and get the first 6 characters # That'll be used for our confirmation number, and upper-case them echo strtoupper(substr(md5($schedule->bidid), 0, 6)); ?> </td> <tr class="thickline"> <td colspan="2"></td> </tr> <tr> <td valign="top"> <strong>Flight: </strong><?php echo $schedule->code.$schedule->flightnum?><br /> <strong>Depart: </strong><?php echo $schedule->deptime; ?><br /> <strong>Arrive: </strong><?php echo $schedule->arrtime;?><br /> </td> <td valign="top"> <strong>Aircraft: </strong><?php echo $schedule->aircraft?> <br /> <?php echo "$schedule->depname ($schedule->depicao)";?><br /> <?php echo "$schedule->arrname ($schedule->arricao)"; ?><br /> </td> </tr> </table> That should work. A better way: <?php # This will only show this message if it's not a popup window # Ends on line 13-15 if(!isset($_GET['newwindow'])) { ?> <h3>Requirements for Online Checkin</h3> <p>To proceed through Security Checkpoint, you will need a government-issued photo ID and either a Boarding Pass or Security Document. Customers under 18 years of age are not required to show government-issued photo ID.</p> <p><a href="#" onclick="window.open('<?php echo actionurl('/schedules/boardingpass/'.$schedule->id.'?newwindow');?>'); return false;">Open in new window for printing</a></p> <?php } ?> <style> /* Some integrated styles here, for the popup */ .boardingpass { font-family: Tahoma, Verdana; font-size: 14px; } .boardingpass h3 { background: none; padding-left: 3px; padding-bottom: 2px; } .boardingpass .thickline { background: #333; height: 2px; } </style> <table width="90%" class="boardingpass"> <tr> <td width="1%"><img src="<?php echo SITE_URL?>/lib/images/barcode.png" /></td> <td align="left"><h3><?php echo SITE_NAME;?></h3></td> </tr> <tr> <td colspan="2"><h3>Boarding Pass</h3></td> </tr> <tr class="thickline"> <td colspan="2"></td> </tr> <tr> <td valign="top"> <table class="boardingpass"> <tr> <td> <strong>Date:</strong> <br /> <strong>Name: </strong> <br /> <strong>Frequent Flier Number: </strong> <br /> <strong>Boarding Pass Number:</strong> </td> <td> <?php echo date('Y-m-d'); ?><br /> <?php echo Auth::$userinfo->firstname.' '.Auth::$userinfo->lastname?><br /> <?php echo Auth::$userinfo->code.strtoupper(substr(md5(Auth::$userinfo->pilotid), 0, 6))?><br /> <?php echo $schedule->bidid; ?><br /> </td> </tr> </td> <td valign="top"> <strong>Gate:</strong> <?php # We are gonna get a random gate switch($schedule->depicao){ case 'PHOG': echo chr(rand(45, 45)); // No gate letter just a dash echo rand(9, 16); // Random gate letter between 9 and 16 break; case 'PHNY': echo chr(rand(45, 45)); // No gate letter echo rand(1, 4); // Random gate letter between 1 to 4 break; case 'PHNL': echo chr(rand(45, 45)); // No gate letter echo rand(71, 80); // Random gate letter between 71 and 80 break; case 'PHKO': echo chr(rand(45, 45)); // No gate letter echo rand(6, 10); // Random gate letter between 6 to 10 break; case 'PHJH': echo chr(rand(45, 45)); // No gate letter echo rand(1, 3); // Random gate letter between 1 to 3 break; case 'PHMK': echo chr(rand(45, 45)); // No gate letter echo rand(1, 3); // Random gate letter between 1 to 3 break; default: // Optionally include another set of echos just in case it's none of the above. if not remove these lines } # Generate a hash from the bid id, and get the first 6 characters # That'll be used for our confirmation number, and upper-case them echo strtoupper(substr(md5($schedule->bidid), 0, 6)); ?> </td> <tr class="thickline"> <td colspan="2"></td> </tr> <tr> <td valign="top"> <strong>Flight: </strong><?php echo $schedule->code.$schedule->flightnum?><br /> <strong>Depart: </strong><?php echo $schedule->deptime; ?><br /> <strong>Arrive: </strong><?php echo $schedule->arrtime;?><br /> </td> <td valign="top"> <strong>Aircraft: </strong><?php echo $schedule->aircraft?> <br /> <?php echo "$schedule->depname ($schedule->depicao)";?><br /> <?php echo "$schedule->arrname ($schedule->arricao)"; ?><br /> </td> </tr> </table> Quote Link to comment Share on other sites More sharing options...
tgycgijoes Posted April 23, 2012 Author Report Share Posted April 23, 2012 Tom, thanks for the help and right away. This fixed the problem of display and took away the error, but the proper gates are not displaying on the boarding pass. Instead I get random series of numbers like: 13E4DA3B for PHOG or 3167909 for PHMK ??? When I used my way above on another website, I could only use it for 4 airports when I tried to use it for 18 and asked for gate number help, someone told me that was probably how Nabeel programmed the original though he gave us the mod in another topic but for just 2 airports for someone else. Thoughts? I did notice that the first two numbers in this series IS the gate so I programmed a space after the gate number until we figure out what the other six numbers/letters come from. They are NOT in the other website with the original code but they only work for four airports and then go "squirrely". I am going to go back and try your mod of else...else and see if I can get ALL 18 of my airports programmed to select the real gates. Richard Quote Link to comment Share on other sites More sharing options...
tgycgijoes Posted April 24, 2012 Author Report Share Posted April 24, 2012 Tom, this is fantastic!! I have just finished entering 21 different airports with the exact gates for each one entered so that the boarding pass can select the "real" gates at each airport. If it works for 21 I am sure it will work for any amount.\ of airports if you are interested in programming them. Thanks to both you and Nabeel. Nabeel for the original mod and you for the finessing of it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.