AFVA | Mitchell Posted September 21, 2009 Report Share Posted September 21, 2009 G'day, How do I make searching schedules by airlines work? What code do I need? I know basic PHP and do not know much about advanced PHP. I will add it to schedule_searchform.tpl Thanks, Mitchell Williamson Australian Frontier VA Quote Link to comment Share on other sites More sharing options...
Captain_BB Posted September 21, 2009 Report Share Posted September 21, 2009 I'm in the same situation as Mitchell. On my website I offer my pilots several different airlines to choose from and have nearly a thousand flight plans between the different airlines they can choose from. I would also like to know how to program into the "Search Schedules" feature another search option where my pilots can search specifically on the Airline. This would be a great help to my pilots and less time consuming. You're help in this matter with the code to be added would be greatly appreciated. Website: http://westpalmairva.thewestieplace.com/ Thanks in advance..... Quote Link to comment Share on other sites More sharing options...
AFVA | Mitchell Posted September 27, 2009 Author Report Share Posted September 27, 2009 bump ??? Quote Link to comment Share on other sites More sharing options...
Captain_BB Posted September 27, 2009 Report Share Posted September 27, 2009 Hi Mitchell; I guess our problem is not that important. I tried to program it but like you I really do not know enough about PHP to get it to work. Not sure where to go from here. If you get it working could you let me know and I if I can figure it out I will do the same. :- Bruce Quote Link to comment Share on other sites More sharing options...
AFVA | Mitchell Posted September 28, 2009 Author Report Share Posted September 28, 2009 The code I am working on at the moment: <div id="airline"> <p>Select Airline:</p> <p><b>This feature is under construction. Check back soon! AFVA Management. </b></p> <select id="airline" name="airline"> <option value="">Select Airline</option> <?php if(!$airline) $airline = array(); foreach($allairlines as $airline) { echo '<option value="'.$airline->name.'">'.$airline->name.'</option>'; } ?> Trying to get all the airlines to display as an option. Anyone know how to get all the airlines to display as an option?? Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted September 28, 2009 Administrators Report Share Posted September 28, 2009 Sorry, have been crazy busy. What sort of parameters are you looking for? Just the airline? Or additional fields? Quote Link to comment Share on other sites More sharing options...
AFVA | Mitchell Posted September 29, 2009 Author Report Share Posted September 29, 2009 I want to make it so you can search via airline in the drop down menu. So i can search via the airline. It will also help if we can search arr/dep airports as well as aircraft. Thanks Mitch Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted September 29, 2009 Administrators Report Share Posted September 29, 2009 To add a search, basically you modify this: /core/modules/Schedules/Schedules.php, around line 166 is: public function FindFlight() There's a bunch of if statements looking at that search form. So let's assume the field you added was name'd "airline", you'd add: if($this->post->airline!= '') { $routes = SchedulesData::GetSchedulesWithCode($this->post->airline); Template::Set('allroutes', $routes); } Basically you need the Template::Set('allroutes', ...); portion so the template has routes to display. The GetSchedulesWithCode will work with the latest beta. But that's basically how you would build up that search. You can add additional fields/search parameters that way too. The only thing would be is you might need to write some SQL. Quote Link to comment Share on other sites More sharing options...
AFVA | Mitchell Posted October 3, 2009 Author Report Share Posted October 3, 2009 Got a small problem though: The drop-down menu won't display the airlines. The code in schedule_searchform.tpl <div id="airline"> <p>Select Airline:</p> <select id="airline" name="airline"> <option value="">Select Airline</option> <?php if(!$airline) $airline = array(); foreach($allairlines as $airline) { echo '<option value="'.$airline->code.'">'.$airline->name.'</option>'; } ?> </select> <input type="submit" name="submit" value="Find Flights" /> </div> Schedules.php: public function FindFlight() { if($this->post->depicao != '') { Template::Set('allroutes', SchedulesData::GetRoutesWithDeparture($this->post->depicao)); } if($this->post->arricao != '') { Template::Set('allroutes', SchedulesData::GetRoutesWithArrival($this->post->arricao)); } if($this->post->equipment != '') { Template::Set('allroutes', SchedulesData::GetSchedulesByEquip($this->post->equipment)); } if($this->post->distance != '') { if($this->post->type == 'greater') $type = '>'; else $type = '<'; Template::Set('allroutes', SchedulesData::GetSchedulesByDistance($this->post->distance, $type)); } if($this->post->airline!= '') { $routes = SchedulesData::GetSchedulesWithCode($this->post->airline); Template::Set('allroutes', $routes); } Template::Show('schedule_results.tpl'); I want to search using the airlines so that all the airlines appear in the drop down menu. Thanks in advance, Mitch Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted October 3, 2009 Administrators Report Share Posted October 3, 2009 if(!$airline) $airline = array(); foreach($allairlines as $airline) Use: $allairlines = OperationsData::GetAllAirlines(true); foreach($allairlines as $airline) Quote Link to comment Share on other sites More sharing options...
AFVA | Mitchell Posted October 3, 2009 Author Report Share Posted October 3, 2009 "No routes have been found!" When we got 493 routes...... Quote Link to comment Share on other sites More sharing options...
AFVA | Mitchell Posted October 9, 2009 Author Report Share Posted October 9, 2009 bump ??? Bump again........ Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted October 10, 2009 Administrators Report Share Posted October 10, 2009 Sorry, show me your code Quote Link to comment Share on other sites More sharing options...
AFVA | Mitchell Posted October 16, 2009 Author Report Share Posted October 16, 2009 schedules.php: FindFlight section public function FindFlight() { if($this->post->depicao != '') { Template::Set('allroutes', SchedulesData::GetRoutesWithDeparture($this->post->depicao)); } if($this->post->arricao != '') { Template::Set('allroutes', SchedulesData::GetRoutesWithArrival($this->post->arricao)); } if($this->post->equipment != '') { Template::Set('allroutes', SchedulesData::GetSchedulesByEquip($this->post->equipment)); } if($this->post->distance != '') { if($this->post->type == 'greater') $type = '>'; else $type = '<'; Template::Set('allroutes', SchedulesData::GetSchedulesByDistance($this->post->distance, $type)); } if($this->post->airline!= '') { $routes = SchedulesData::GetSchedulesWithCode($this->post->airline); Template::Set('allroutes', $routes); } Template::Show('schedule_results.tpl'); } schedule_searchform.tpl : Airline Search <div id="airline"> <p>Select Airline:</p> <p><b>This feature is under construction. Check back soon! AFVA Management. </b></p> <select id="airline" name="airline"> <option value="">Select Airline</option> <?php $allairlines = OperationsData::GetAllAirlines(true); foreach($allairlines as $airline) { echo '<option value="'.$airline->code.'">'.$airline->name.'</option>'; } ?> </select> <input type="submit" name="submit" value="Find Flights" /> </div> Sorry for the long reply, internet has been down the last couple of days. Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted October 16, 2009 Administrators Report Share Posted October 16, 2009 Try $routes = SchedulesData::GetSchedulesWithCode($this->post->airline, true); Also putting a DB::debug(); after it will show you what the query was. Try that too and post it here. Maybe there's an error Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted October 16, 2009 Administrators Report Share Posted October 16, 2009 Ahh, there's an error with that query. I fixed it, but it'll be in the next commit. Open core/common/scheduledata.class.php search for this line: WHERE s.code''.$code.'' '.$enabled; I think it's around line 242 though, it should be WHERE s.code=''.$code.'' '.$enabled; It's missing the = sign Quote Link to comment Share on other sites More sharing options...
AFVA | Mitchell Posted October 17, 2009 Author Report Share Posted October 17, 2009 Thanks Nabeel! Its up and running ;D Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted October 17, 2009 Administrators Report Share Posted October 17, 2009 Excellent! Quote Link to comment Share on other sites More sharing options...
tj1962 Posted October 20, 2009 Report Share Posted October 20, 2009 Hi Tried to implement this. Foolwed all the code in this thread but got this error. Fatal error: Call to undefined method SchedulesData::GetSchedulesWithCode() in /home/williams/public_html/core/modules/Schedules/Schedules.php on line 183 Any help appreciated TJ Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted October 20, 2009 Administrators Report Share Posted October 20, 2009 That function is part of the latest beta/next version 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.