stuartpb Posted June 9, 2011 Report Posted June 9, 2011 That code I posted in SimPilot's FrontSchedule search thread, for the "your location" to appear in the departure select field proved problematic, as it was setting everyone's location the same as mine. Not sure why, but it was.Anyway, I've managed to sort it out now. I've posted here because I've modified two files: The airport_search.tpl file from the FrontSchedule Addon (located in your core/templates folder when you have installed the addon.) The default schedule_results.tpl that is shipped with phpVMS First up, replace the code shown below from Simpilot's airport_search.tpl with the code underneath that. airport_search.tpl - Original code: <td>Select A Departure Airfield</td> <td> <select class="search" name="depicao"> <option value="">All</option> <?php foreach ($airports as $airport) {echo '<option value="'.$airport->icao.'">'.$airport->icao.' - '.$airport->name.'</option>';} ?> </select> </td> </tr> Replace with: <td>Select A Departure Airfield</td> <td> <select class="search" name="depicao"> <option value="">All</option> <?php if (Auth::LoggedIn()) {?> <?php $reports = PIREPData::getLastReports(Auth::$userinfo->pilotid, 1, PIREP_ACCEPTED); if(is_object($reports)) {echo '<option value="'.$reports->arricao.'">Your current location ('.$reports->arricao.')</option>';} elseif(!$reports) {echo '<option value="'.Auth::$userinfo->hub.'">Your current location ('.Auth::$userinfo->hub.')</option>';}}?> <?php foreach ($airports as $airport) { echo '<option value="'.$airport->icao.'">'.$airport->icao.' - '.$airport->name.'</option>'; }?> </select> </td> </tr> Just to explain exactly what this does again, when a pilot is searching for flights, they can choose the "Your Current Location ()" option from the departure airport search field. Then the results will display flights from either the hub your pilot is located at if they've never flown yet, or if they've filed a pirep and it's been accepted - their last arrival airport. I done this because in my VA, pilots must fly flights in logical order, they can only book flights from the airport they last arrived at. This little amendment to Simpilot's great addon provides pilots with an easy way to find the flights they are eligible to fly. I've made some mods to the schedule_results.tpl file too, so that the add to bid link is removed if the pilot is not located at an airport, their rank is too low for the aircraft and also if the flight is not operating on the day. Original schedule_results.tpl - Delete the following from this file: /* Uncomment this code if you want only schedules which are from the last PIREP that pilot filed */ /*if(Auth::LoggedIn()) { $search = array( 'p.pilotid' => Auth::$userinfo->pilotid, 'p.accepted' => PIREP_ACCEPTED ); $reports = PIREPData::findPIREPS($search, 1); // return only one if(is_object($reports)) { # IF the arrival airport doesn't match the departure airport if($reports->arricao != $route->depicao) { continue; } } }*/ /* Skip over a route if it's not for this day of week Left this here, so it can be omitted if your VA doesn't use this. Comment out these two lines if you don't want to. */ /* Check if a 7 is being used for Sunday, since PHP thinks 0 is Sunday */ $route->daysofweek = str_replace('7', '0', $route->daysofweek); if(strpos($route->daysofweek, date('w')) === false) continue; /* END DAY OF WEEK CHECK */ /* This will skip over a schedule if it's been bid on This only runs if the below setting is enabled If you don't want it to skip, then comment out this code below by adding // in front of each line until the END DISABLE SCHEDULE comment below If you do that, and want to show some text when it's been bid on, see the comment below */ if(Config::Get('DISABLE_SCHED_ON_BID') == true && $route->bidid != 0) { continue; } /* END DISABLE SCHEDULE ON BID */ /* Skip any schedules which have aircraft that the pilot is not rated to fly (according to RANK), only skip them if they are logged in. */ if(Config::Get('RESTRICT_AIRCRAFT_RANKS') === true && Auth::LoggedIn()) { /* This means the aircraft rank level is higher than what the pilot's ranklevel, so just do "continue" and move onto the next route in the list */ if($route->aircraftlevel > Auth::$userinfo->ranklevel) { continue; } } Then replace the following code: <td nowrap> <a href="<?php echo url('/schedules/details/'.$route->id);?>">View Details</a><br /> <a href="<?php echo url('/schedules/brief/'.$route->id);?>">Pilot Brief</a><br /> <?php # Don't allow overlapping bids and a bid exists if(Config::Get('DISABLE_SCHED_ON_BID') == true && $route->bidid != 0) { ?> <a id="<?php echo $route->id; ?>" class="addbid" href="<?php echo actionurl('/schedules/addbid');?>">Add to Bid</a> <?php } else { if(Auth::LoggedIn()) { ?> <a id="<?php echo $route->id; ?>" class="addbid" href="<?php echo url('/schedules/addbid');?>">Add to Bid</a> <?php } } ?> </td> With this code: <td nowrap> <?php if(!Auth::LoggedIn()) {echo 'Restricted Access';} else {?> <a href="<?php echo url('/schedules/brief/'.$route->id);?>">Pilot Brief</a><br/> <?php if(Auth::LoggedIn()) { if(Config::Get('RESTRICT_AIRCRAFT_RANKS') === true && Auth::LoggedIn()) { if($route->ranklevel > Auth::$userinfo->rankid) { continue; } } $route->daysofweek = str_replace('7', '0', $route->daysofweek); if(strpos($route->daysofweek, date('w')) === false) continue; if(Auth::LoggedIn()) { $search = array( 'p.pilotid' => Auth::$userinfo->pilotid, 'p.accepted' => PIREP_ACCEPTED ); $reports = PIREPData::getLastReports(Auth::$userinfo->pilotid, 1, PIREP_ACCEPTED); if(is_object($reports)) { # IF the arrival airport doesn't match the departure airport if($reports->arricao != $route->depicao) { continue; } } if(!$reports) { if (Auth::$userinfo->hub != $route->depicao) { continue; } } } ?> <a id="<?php echo $route->id; ?>" class="addbid" href="<?php echo url('/schedules/addbid');?>"><strong>Book Flight</strong></a> <?php }?> </td> EDIT: If you want to use the aircraft rank restriction, you MUST ensure this option is set to true in the core/app.config.php file, as below: # Pilot pilots to only fly aircraft they're ranked to Config::Set('RESTRICT_AIRCRAFT_RANKS', true); Now, when you or your pilots view the schedule results page, any flights for which you do not have the appropriate rank, is not being operated on the day, or you are not located at the dept airport will not show the add to bid link. Also, if people view the site who are not logged in, they will not see either the pilot brief link or the add to bid. I chose to do this as I wanted only registered members to see detailed flight information. I wanted my pilots to be able to see all the schedules the VA runs, but not be able to book them if any of the restrictions apply. That way they can plan ahead for their flights, by viewing all the schedules. Combined with the airport_search hack, it works really well (in my opinion anyways ) If you try this yourself, BACK UP THE ORIGINAL FILES!!! I can't support this hack, as I only just figured out how to get it working myself. There may be an easier way, if so and anyone knows it, please do share. Cheers, Stuart PS: The original addon by Simpilot can be found here: http://forum.phpvms.net/topic/2197-schedule-search-airline-aircraft-arrival-departure/ Also, I take absolutely no credit for the fantastic module SimPilot wrote, I've simply modified a few lines on one file. Quote
stuartpb Posted June 12, 2011 Author Report Posted June 12, 2011 Has anyone else tried this yet? Any success? Quote
Jon Posted June 12, 2011 Report Posted June 12, 2011 Hi Stuart, I'll have a go with it on my development site tommorrow. Might use it in my new site Regards Jon Quote
Ahmad Posted June 12, 2011 Report Posted June 12, 2011 Count me in guys thanks Simpilot & Stuart for a such wonderful changes........... i will check it on my test website and get back with the result soon Regards Ahmad Quote
Mark J Posted June 13, 2011 Report Posted June 13, 2011 not working for me... heres my airport_search.tpl file <?php $lastreport = PIREPData::GetLastReports(Auth::$userinfo, 1); if(!$lastreport) {$location = Auth::$userinfo->hub; } else {$location = $lastreport->arricao;} ?> <?php //simpilotgroup addon module for phpVMS virtual airline system // //simpilotgroup addon modules are licenced under the following license: //Creative Commons Attribution Non-commercial Share Alike (by-nc-sa) //To view full icense text visit http://creativecommons.org/licenses/by-nc-sa/3.0/ // //@author David Clark (simpilot) //@copyright Copyright (c) 2009-2010, David Clark //@license http://creativecommons.org/licenses/by-nc-sa/3.0/ ?> <h4>Schedule Search</h4> <form action="<?php echo url('/FrontSchedules');?>" method="post" enctype="multipart/form-data"> <table width="100%" cellpadding="10px"> <tr> <td>Select An Airline</td> <td> <select class="search" name="airline"> <option value="">All</option> <?php foreach ($airlines as $airline) {echo '<option value="'.$airline->code.'">'.$airline->name.'</option>';} ?> </select> </td> </tr> <tr> <td>Select An Aircraft Type</td> <td> <select class="search" name="aircraft"> <option value="">All</option> <?php foreach ($aircrafts as $aircraft) {echo '<option value="'.$aircraft->icao.'">'.$aircraft->icao.'</option>';} ?> </select> </td> </tr> <td>Select A Departure Airfield</td> <td> <select class="search" name="depicao"> <option value="">All</option> <?php $reports = PIREPData::getLastReports(Auth::$userinfo->pilotid, 1, PIREP_ACCEPTED); if(is_object($reports)) { echo '<option value="'.$reports->arricao.'">Your current location ('.$reports->arricao.')</option>'; } elseif(!$reports) { echo '<option value="'.Auth::$userinfo->hub.'">Your current location ('.Auth::$userinfo->hub.')</option>'; }?> <?php foreach ($airports as $airport) { echo '<option value="'.$airport->icao.'">'.$airport->icao.' - '.$airport->name.'</option>'; }?> </select> </td> </tr> <tr> <td>Select An Arrival Airfield</td> <td> <select class="search" name="arricao"> <option value="">All</option> <?php foreach ($airports as $airport) {echo '<option value="'.$airport->icao.'">'.$airport->icao.' - '.$airport->name.'</option>';} ?> </select> </td> </tr> <tr> <td colspan="2"> <input type="hidden" name="action" value="findflight" /> <input type="submit" name="submit" value="Search For A Flight" /> </td> </tr> </table> </form> <br /> <a href="<?php echo url('Schedules'); ?>">View All Today's Flights</a> 1 Quote
stuartpb Posted June 13, 2011 Author Report Posted June 13, 2011 not working for me... heres my airport_search.tpl file <?php $lastreport = PIREPData::GetLastReports(Auth::$userinfo, 1); if(!$lastreport) {$location = Auth::$userinfo->hub; } else {$location = $lastreport->arricao;} ?> <?php //simpilotgroup addon module for phpVMS virtual airline system // //simpilotgroup addon modules are licenced under the following license: //Creative Commons Attribution Non-commercial Share Alike (by-nc-sa) //To view full icense text visit http://creativecommons.org/licenses/by-nc-sa/3.0/ // //@author David Clark (simpilot) //@copyright Copyright © 2009-2010, David Clark //@license http://creativecommons.org/licenses/by-nc-sa/3.0/ ?> <h4>Schedule Search</h4> <form action="<?php echo url('/FrontSchedules');?>" method="post" enctype="multipart/form-data"> <table width="100%" cellpadding="10px"> <tr> <td>Select An Airline</td> <td> <select class="search" name="airline"> <option value="">All</option> <?php foreach ($airlines as $airline) {echo '<option value="'.$airline->code.'">'.$airline->name.'</option>';} ?> </select> </td> </tr> <tr> <td>Select An Aircraft Type</td> <td> <select class="search" name="aircraft"> <option value="">All</option> <?php foreach ($aircrafts as $aircraft) {echo '<option value="'.$aircraft->icao.'">'.$aircraft->icao.'</option>';} ?> </select> </td> </tr> <tr> <!--Missed A TR Here--> <td>Select A Departure Airfield</td> <td> <select class="search" name="depicao"> <option value="">All</option> <?php $reports = PIREPData::getLastReports(Auth::$userinfo->pilotid, 1, PIREP_ACCEPTED); if(is_object($reports)) { echo '<option value="'.$reports->arricao.'">Your current location ('.$reports->arricao.')</option>'; } elseif(!$reports) { echo '<option value="'.Auth::$userinfo->hub.'">Your current location ('.Auth::$userinfo->hub.')</option>'; }?> <?php foreach ($airports as $airport) { echo '<option value="'.$airport->icao.'">'.$airport->icao.' - '.$airport->name.'</option>'; }?> </select> </td> </tr> <tr> <td>Select An Arrival Airfield</td> <td> <select class="search" name="arricao"> <option value="">All</option> <?php foreach ($airports as $airport) {echo '<option value="'.$airport->icao.'">'.$airport->icao.' - '.$airport->name.'</option>';} ?> </select> </td> </tr> What's happening when you try to use the code? I've marked a <tr> that you missed out, but the code is the same as mine, and it works on my site. Quote
Mark J Posted June 13, 2011 Report Posted June 13, 2011 heres the website. it is just acting like the simpilot addon. 1 Quote
stuartpb Posted June 13, 2011 Author Report Posted June 13, 2011 heres the website. it is just acting like the simpilot addon. Are you sure you have overwritten the airport_search.tpl file with the amended one? Looking at the html output for that page, there have been no modifications made to the file. Quote
Mark J Posted June 13, 2011 Report Posted June 13, 2011 im almost positive! i know im new at this but im pretty sure.. is there something else that could be wrong? Quote
Mark J Posted June 13, 2011 Report Posted June 13, 2011 [*]The airport_search.tpl file from the FrontSchedule Module. this is in the templates folder not the frontschedule module folder correct? Quote
stuartpb Posted June 13, 2011 Author Report Posted June 13, 2011 im almost positive! i know im new at this but im pretty sure.. is there something else that could be wrong? Try making a backup of the airport_search.tpl file, and then in the working copy you've been using to make the amendments delete the departure airport bit of code from the opening <tr> to the closing </tr>, then upload that to the server. If the departure airport part is missing then we are on the same page If not, then check your chosen skin folder to make sure there isn't an airport_search.tpl file in there. It's hard for me to guess where the problem is without seeing how your site is laid out on the server. If anyone wants to jump in feel free Quote
stuartpb Posted June 13, 2011 Author Report Posted June 13, 2011 this is in the templates folder not the frontschedule module folder correct? Yes that's right. When I said the FrontSchedule module, I meant the downloaded files from SimPilot's addon. The airport_search.tpl goes in the core/templates folder, not in the core/modules/FrontShedules folder. Apologies for the confusion there. Quote
Mark J Posted June 13, 2011 Report Posted June 13, 2011 haha wow.. I feel like an idiot! I had a copy of the airportsearch.tpl file in the skins and even though i was editing the one in the templates on it messed it up. So not the Current Location is showing up, but is there a way to make it to where it's automatically selected? Because at the moment its just a choice. Quote
stuartpb Posted June 13, 2011 Author Report Posted June 13, 2011 I see the current location showing now, is it working? EDIT scratch that seen your post above. Yes you can make it so that there is no choice: 1: You can either make it so the current location appears first in the list, 2: Or you can remove the other options from the list so that only the current location one shows. 1: Just move the <option value="">All</option> below the php for the current location. 2: Delete the following: <option value="">All</option> <?php foreach ($airports as $airport) { echo '<option value="'.$airport->icao.'">'.$airport->icao.' - '.$airport->name.'</option>';} ?> Quote
Mark J Posted June 13, 2011 Report Posted June 13, 2011 Alright thanks! Works great! Thanks for being patient too.. really new to this Quote
stuartpb Posted June 13, 2011 Author Report Posted June 13, 2011 No worries, glad to have helped Quote
stuartpb Posted June 13, 2011 Author Report Posted June 13, 2011 I've made another little modification, which removes the "your current location()" if a user is not logged in. <?php if (Auth::LoggedIn()) {?> <?php $reports = PIREPData::getLastReports(Auth::$userinfo->pilotid, 1, PIREP_ACCEPTED); if(is_object($reports)) {echo '<option value="'.$reports->arricao.'">Your current location ('.$reports->arricao.')</option>';} elseif(!$reports) {echo '<option value="'.Auth::$userinfo->hub.'">Your current location ('.Auth::$userinfo->hub.')</option>';}}?> Changed the original post to reflect this. Quote
Moderators mark1million Posted June 13, 2011 Moderators Report Posted June 13, 2011 Stuart, How do you get the grouped listing i just copied the echo '<optgroup label="'.$airport->country.'">'; and as expected because its in the loop before each field the country is displayed, is there another modification somewhere? Quote
stuartpb Posted June 13, 2011 Author Report Posted June 13, 2011 Stuart, How do you get the grouped listing i just copied the echo '<optgroup label="'.$airport->country.'">'; and as expected because its in the loop before each field the country is displayed, is there another modification somewhere? Sorry mate, I meant to delete the echo '<optgroup label="'.$airport->country.'">'; part from the code before I posted. Quote
stuartpb Posted June 13, 2011 Author Report Posted June 13, 2011 I've received a few requests by private message to support this modification, and as I said in the initial post, I cannot support it further than telling you how I managed to get it working on my site. If it doesn't work on your site, you would be better off asking someone who is more skilled than me. I've listed all the changes I can remember making, so if it isn't working for you, accept my apologies but there isn't a whole lot I can do to help. Quote
Moderators mark1million Posted June 13, 2011 Moderators Report Posted June 13, 2011 Stuart, i like the country listing and grouped together which is good, if you every want to share the code then you can always get me on pm Quote
stuartpb Posted June 13, 2011 Author Report Posted June 13, 2011 Stuart, i like the country listing and grouped together which is good, if you every want to share the code then you can always get me on pm PM on it's way in a mo, and no I'm not going to share this code to everyone. I reckon I've shared enough tbh. Quote
Moderators mark1million Posted June 13, 2011 Moderators Report Posted June 13, 2011 That you have mate, just got to say you have a cracking site there, I would even go as far to say the best layout and graphics i have ever seen for a phpVMS site Quote
Jeff Posted June 14, 2011 Report Posted June 14, 2011 Stuart, is there a missing code that restricts outranked routes by aircraft? I don't see the code in what you posted. The only thing I see is # Pilot pilots to only fly aircraft they're ranked toConfig::Set('RESTRICT_AIRCRAFT_RANKS', true); which I have been using from the start (which still doesn't work). Everything is changed accordingly as you described, and working correctly, but it is still showing "ADD TO BID" on flights which contain aircraft which members are not ranked for. Quote
stuartpb Posted June 14, 2011 Author Report Posted June 14, 2011 Stuart, is there a missing code that restricts outranked routes by aircraft? I don't see the code in what you posted. The only thing I see is which I have been using from the start (which still doesn't work). Everything is changed accordingly as you described, and working correctly, but it is still showing "ADD TO BID" on flights which contain aircraft which members are not ranked for. I've scoured all the files I can remember changing, and some I couldn't remember changing, and I think I've figured out why it isn't working for you guys. You need to add this to the queries in the FrontScheduleData.class: phpvms_aircraft.ranklevel Like so: public function findschedules($arricao, $depicao, $airline, $aircraft) { $query = "SELECT phpvms_schedules.*, phpvms_aircraft.name AS aircraft, phpvms_aircraft.ranklevel, phpvms_aircraft.registration FROM phpvms_schedules, phpvms_aircraft WHERE phpvms_schedules.depicao LIKE '$depicao' AND phpvms_schedules.enabled=1 AND phpvms_schedules.arricao LIKE '$arricao' AND phpvms_schedules.code LIKE '$airline' AND phpvms_schedules.aircraft LIKE '$aircraft' AND phpvms_aircraft.id LIKE '$aircraft'"; return DB::get_results($query); } public function findschedule($arricao, $depicao, $airline) { $query = "SELECT phpvms_schedules.*, phpvms_aircraft.name AS aircraft, phpvms_aircraft.ranklevel, phpvms_aircraft.registration FROM phpvms_schedules, phpvms_aircraft WHERE phpvms_schedules.depicao LIKE '$depicao' AND phpvms_schedules.enabled=1 AND phpvms_schedules.arricao LIKE '$arricao' AND phpvms_schedules.code LIKE '$airline' AND phpvms_aircraft.id LIKE phpvms_schedules.aircraft"; return DB::get_results($query); } If that doesn't work I honestly can't remember any other changes. Quote
Jeff Posted June 15, 2011 Report Posted June 15, 2011 nope, unfortunately that didn't fix it either. Thanks anyways Quote
stuartpb Posted June 15, 2011 Author Report Posted June 15, 2011 nope, unfortunately that didn't fix it either. Thanks anyways I'll go through the files when I have more time over the next day or two, I'm up to my armpits in jobs to do at the moment. Obviously there's something I've forgotten but I really can't remember. Quote
ukmil Posted July 3, 2011 Report Posted July 3, 2011 I just tried your code, only in the schedule_results page, and it gave me this Parse error: syntax error, unexpected $end in /home1/ukmilorg/public_html/vms/core/templates/schedule_results.tpl on line 100 this is my page, which i probably did something incorrect <?phpif(!$allroutes) { echo '<p align="center">No routes have been found!</p>'; return; } ?> <table id="tabledlist" class="tablesorter"> <thead> <tr> <th>Flight Info</th> <th>Options</th> </tr> </thead> <tbody> <?php foreach($allroutes as $route) { /* THIS BEGINS ONE TABLE ROW */ ?> <tr> <td> <a href="<?php echo url('/schedules/details/'.$route->id);?>"><?php echo $route->code . $route->flightnum?> <?php echo '('.$route->depicao.' - '.$route->arricao.')'?> </a> <br /> <strong>Departure: </strong><?php echo $route->deptime;?> <strong>Arrival: </strong><?php echo $route->arrtime;?><br /> <strong>Equipment: </strong><?php echo $route->aircraft; ?> (<?php echo $route->registration;?>) <strong>Distance: </strong><?php echo $route->distance . Config::Get('UNITS');?> <br /> <strong>Days Flown: </strong><?php echo Util::GetDaysCompact($route->daysofweek); ?><br /> <?php echo ($route->route=='') ? '' : '<strong>Route: </strong>'.$route->route.'<br />' ?> <?php echo ($route->notes=='') ? '' : '<strong>Notes: </strong>'.html_entity_decode($route->notes).'<br />' ?> <?php # Note: this will only show if the above code to # skip the schedule is commented out if($route->bidid != 0) { echo 'This route has been bid on'; } ?> </td> <td nowrap> <?php if(!Auth::LoggedIn()) {echo 'Restricted Access';} else {?> <a href="<?php echo url('/schedules/brief/'.$route->id);?>">Pilot Brief</a><br/> <?php if(Auth::LoggedIn()) { if(Config::Get('RESTRICT_AIRCRAFT_RANKS') === true && Auth::LoggedIn()) { if($route->ranklevel > Auth::$userinfo->rankid) { continue; } } $route->daysofweek = str_replace('7', '0', $route->daysofweek); if(strpos($route->daysofweek, date('w')) === false) continue; if(Auth::LoggedIn()) { $search = array( 'p.pilotid' => Auth::$userinfo->pilotid, 'p.accepted' => PIREP_ACCEPTED ); $reports = PIREPData::getLastReports(Auth::$userinfo->pilotid, 1, PIREP_ACCEPTED); if(is_object($reports)) { # IF the arrival airport doesn't match the departure airport if($reports->arricao != $route->depicao) { continue; } } if(!$reports) { if (Auth::$userinfo->hub != $route->depicao) { continue; } } } ?> <a id="<?php echo $route->id; ?>" class="addbid" href="<?php echo url('/schedules/addbid');?>"><strong>Book Flight</strong></a> <?php }?> </td> </tr> <?php /* END OF ONE TABLE ROW */ } ?> </tbody> </table> <hr> Quote
stuartpb Posted July 3, 2011 Author Report Posted July 3, 2011 On the last part of your code: <?php /* END OF ONE TABLE ROW */ } ?> </tbody> </table> <hr> add a } like so: <?php /* END OF ONE TABLE ROW */ }} ?> </tbody> </table> </div> Hopefully that should work. Quote
ukmil Posted July 3, 2011 Report Posted July 3, 2011 Yip, that did it, thanks Now, i think i will need to work out, how to add the current pilots location to the Pilots roster, like I have with my Fleet page for the aircraft. Quote
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.