Jump to content

FrontSchedules - Aircraft Rank


Parkho

Recommended Posts

  • Moderators

Hello All

I have been trying to find a way to implement pilots restrictions on Arcraft into the great Front Schedules add on made by Simpilot. So far, I managed to change the frontscheduledata.class to show me only the schedules with the proper pilot ranking but it shows me one route per pilot meaning if I have 10 pilots it shows me the same route 10 times in the schedules results.

Here is the original code:

<?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/

class FrontSchedulesData extends CodonData
{
   public function findschedules($arricao, $depicao, $airline, $aircraft)   {
       $query = "SELECT phpvms_schedules.*, phpvms_aircraft.name AS aircraft, phpvms_aircraft.registration
               FROM phpvms_schedules, phpvms_aircraft
               WHERE phpvms_schedules.depicao LIKE '$depicao'
               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.registration
               FROM phpvms_schedules, phpvms_aircraft
               WHERE phpvms_schedules.depicao LIKE '$depicao'
               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);
   }

   public function findaircrafttypes() {
       $query = "SELECT DISTINCT icao
               FROM phpvms_aircraft";

       return DB::get_results($query);
   }

   public function findaircraft($aircraft) {
       $query = "SELECT id
               FROM phpvms_aircraft
               WHERE icao='$aircraft'";

       return DB::get_results($query);
   }

   public function findcountries() {
       $query = "SELECT DISTINCT country
               FROM phpvms_airports";

       return DB::get_results($query);
   }

}

And here is the part I changed:

<?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/

class FrontSchedulesData extends CodonData
{
   public function findschedules($arricao, $depicao, $airline, $aircraft)   {
       $query = "SELECT phpvms_schedules.*, phpvms_aircraft.name AS aircraft,phpvms_aircraft.registration,phpvms_pilots.ranklevel //added this
               FROM phpvms_schedules, phpvms_aircraft,phpvms_pilots /added this
               WHERE phpvms_schedules.depicao LIKE '$depicao'
               AND phpvms_schedules.arricao LIKE '$arricao'
               AND phpvms_schedules.code LIKE '$airline'
               AND phpvms_schedules.aircraft LIKE '$aircraft'
               AND phpvms_aircraft.ranklevel<=phpvms_pilots.ranklevel //added this line here
               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.registration,phpvms_pilots.ranklevel //added this
               FROM phpvms_schedules, phpvms_aircraft,phpvms_pilots //added this
               WHERE phpvms_schedules.depicao LIKE '$depicao'
               AND phpvms_schedules.arricao LIKE '$arricao'
               AND phpvms_schedules.code LIKE '$airline'
               AND phpvms_aircraft.ranklevel<=phpvms_pilots.ranklevel  / added this line 
               AND phpvms_aircraft.id LIKE phpvms_schedules.aircraft";

       return DB::get_results($query);
   }

   public function findaircrafttypes() {
       $query = "SELECT DISTINCT icao
               FROM phpvms_aircraft";

       return DB::get_results($query);
   }

   public function findaircraft($aircraft) {
       $query = "SELECT id,phpvms_pilots.ranklevel
               FROM phpvms_aircraft, phpvms_pilots
               WHERE icao='$aircraft'
               AND phpvms_aircraft.ranklevel<=phpvms_pilots.ranklevel";   //Added this.

       return DB::get_results($query);
   }

   public function findcountries() {
       $query = "SELECT DISTINCT country
               FROM phpvms_airports";

       return DB::get_results($query);
   }

}

Now here is the results:

alvand.png

Can anyone tell me where I'm wrong?

Cheers

Link to comment
Share on other sites

  • 3 years later...
  • Members

the query should be

query = "SELECT phpvms_schedules.*, phpvms_aircraft.name AS aircraft,phpvms_aircraft.registration,Auth::$userinfo->ranklevel //added this
						 FROM phpvms_schedules, phpvms_aircraft,phpvms_pilots /added this
						 WHERE phpvms_schedules.depicao LIKE '$depicao'
						 AND phpvms_schedules.arricao LIKE '$arricao'
						 AND phpvms_schedules.code LIKE '$airline'
						 AND phpvms_schedules.aircraft LIKE '$aircraft'
						 AND phpvms_aircraft.ranklevel<=Auth::$userinfo->ranklevel
						 return DB::get_results($query);

Link to comment
Share on other sites

  • 2 months later...

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