Jump to content

Can I Have A Clean Code Of The Pilot Roster With No Hubs


deactivated

Recommended Posts

Can I Have A Clean Code Of The Pilot Roster With No Hubs

Thanks

Dimtiri

This is what I have:

core>modules>Pilots>pilots.php


<?php
/**
* phpVMS - Virtual Airline Administration Software
* Copyright (c) 2008 Nabeel Shahzad
* For more information, visit www.phpvms.net
*	Forums: http://www.phpvms.net/forum
*	Documentation: http://www.phpvms.net/docs
*
* phpVMS is licenced under the following license:
*   Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
*   View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* @author Nabeel Shahzad
* @copyright Copyright (c) 2008, Nabeel Shahzad
* @link http://www.phpvms.net
* @license http://creativecommons.org/licenses/by-nc-sa/3.0/
*/

class Pilots extends CodonModule
{

public function index()
{
            $this->set('allpilots', PilotData::getAllPilots());
      $this->render('pilots_list.tpl');
        }



public function reports($pilotid='')
{
	if($pilotid == '')
	{
		$this->set('message', 'No pilot specified!');
		$this->render('core_error.tpl');
		return;
	}

	$this->set('pireps', PIREPData::GetAllReportsForPilot($pilotid));
	$this->render('pireps_viewall.tpl');
}


/* Stats stuff for charts */


public function statsdaysdata($pilotid)
{
	$data = PIREPData::getIntervalDataByDays(array('p.pilotid'=>$pilotid), 30);
	$this->create_line_graph('Past 30 days PIREPs', $data);
}

public function statsmonthsdata($pilotid)
{
	$data = PIREPData::getIntervalDataByMonth(array('p.pilotid'=>$pilotid), 3);
	$this->create_line_graph('Monthly Flight Stats', $data);
}

public function statsaircraftdata($pilotid)
{
	$data = StatsData::PilotAircraftFlownCounts($pilotid);
	if(!$data) $data = array();

	include CORE_LIB_PATH.'/php-ofc-library/open-flash-chart.php';

	$d = array();
	foreach($data as $ac)
	{
		OFCharts::add_data_set($ac->aircraft, floatval($ac->hours));
	}

	echo OFCharts::create_pie_graph('Aircraft Flown');
}

protected function create_line_graph($title, $data)
{	
	if(!$data)
	{
		$data = array();
	}

	$bar_values = array();
	$bar_titles = array();
	foreach($data as $val)
	{

		$bar_titles[] = $val->ym;
		$bar_values[] = floatval($val->total);
	}

	OFCharts::add_data_set($bar_titles, $bar_values);
	echo OFCharts::create_area_graph($title);
}

public function RecentFrontPage($count = 5)
{
	$this->set('pilots', PilotData::GetLatestPilots($count));
	$this->render('frontpage_recentpilots.tpl');
}
}

That will get rid of the hubs.

  • Like 5
Link to comment
Share on other sites

  • 2 months later...
  • 3 months later...

Hi Guys,

Just a quick addition to this thread, I was looking for something Similar, however as I am running a Military Sqn System using multiple Airlines, I wanted to List the Rosters for each Airline in Turn.

Heres what I changed in the Pilot.php index method to allow it.

// Get all of our Airlines/Squadrons, and list pilots by Airline or Sqn
	$allairlines = OperationsData::GetAllAirlines();

	if(!$allairlines) $allairlines = array();

	foreach($allairlines as $airline)
	{
		$this->set('title', $airline->name);
		$this->set('code', $airline->code);

		$this->set('allpilots', PilotData::findPilots(array('p.code'=>$airline->code)));

		$this->render('pilots_list.tpl');
	}

	$noairline = PilotData::findPilots(array('p.code'=>''));
	if(!$noairline)
	{
		return;
	}

	$this->set('title', 'Un-Assigned Pilots');
	$this->set('code', '');
	$this->set('allpilots', $noairline);
	$this->render('pilots_list.tpl');

Not sure if its good practice to modify the core classes really, I assume they would be overwritten on update? But its a quick fix for this.

Hopefully this is useful for those looking for a similar way of displaying rosters, Apologies if this has been posted previously.

All the best,

  • Like 1
Link to comment
Share on other sites

  • 2 years later...
  • 2 months later...
  • 2 years later...
On 3/20/2011 at 7:36 AM, James142 said:

This is what I have:

core>modules>Pilots>pilots.php

 


<?php
/**
* phpVMS - Virtual Airline Administration Software
* Copyright (c) 2008 Nabeel Shahzad
* For more information, visit www.phpvms.net
*	Forums: http://www.phpvms.net/forum
*	Documentation: http://www.phpvms.net/docs
*
* phpVMS is licenced under the following license:
*   Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
*   View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* @author Nabeel Shahzad
* @copyright Copyright (c) 2008, Nabeel Shahzad
* @link http://www.phpvms.net
* @license http://creativecommons.org/licenses/by-nc-sa/3.0/
*/

class Pilots extends CodonModule
{

public function index()
{
            $this->set('allpilots', PilotData::getAllPilots());
      $this->render('pilots_list.tpl');
        }



public function reports($pilotid='')
{
	if($pilotid == '')
	{
		$this->set('message', 'No pilot specified!');
		$this->render('core_error.tpl');
		return;
	}

	$this->set('pireps', PIREPData::GetAllReportsForPilot($pilotid));
	$this->render('pireps_viewall.tpl');
}


/* Stats stuff for charts */


public function statsdaysdata($pilotid)
{
	$data = PIREPData::getIntervalDataByDays(array('p.pilotid'=>$pilotid), 30);
	$this->create_line_graph('Past 30 days PIREPs', $data);
}

public function statsmonthsdata($pilotid)
{
	$data = PIREPData::getIntervalDataByMonth(array('p.pilotid'=>$pilotid), 3);
	$this->create_line_graph('Monthly Flight Stats', $data);
}

public function statsaircraftdata($pilotid)
{
	$data = StatsData::PilotAircraftFlownCounts($pilotid);
	if(!$data) $data = array();

	include CORE_LIB_PATH.'/php-ofc-library/open-flash-chart.php';

	$d = array();
	foreach($data as $ac)
	{
		OFCharts::add_data_set($ac->aircraft, floatval($ac->hours));
	}

	echo OFCharts::create_pie_graph('Aircraft Flown');
}

protected function create_line_graph($title, $data)
{	
	if(!$data)
	{
		$data = array();
	}

	$bar_values = array();
	$bar_titles = array();
	foreach($data as $val)
	{

		$bar_titles[] = $val->ym;
		$bar_values[] = floatval($val->total);
	}

	OFCharts::add_data_set($bar_titles, $bar_values);
	echo OFCharts::create_area_graph($title);
}

public function RecentFrontPage($count = 5)
{
	$this->set('pilots', PilotData::GetLatestPilots($count));
	$this->render('frontpage_recentpilots.tpl');
}
}
 

 

That will get rid of the hubs.

 

Im having a bit of a problem. Screenshot: http://prntscr.com/g6m58b

 

Im using PHP version of crewcenter. I've removed all the .tpl's from use. I changed the .tpl sections of the code to .php. See copy below. Can someone please assist me?

==========================================================================================================================================

<?php
/**
* phpVMS - Virtual Airline Administration Software
* Copyright (c) 2008 Nabeel Shahzad
* For more information, visit www.phpvms.net
*    Forums: http://www.phpvms.net/forum
*    Documentation: http://www.phpvms.net/docs
*
* phpVMS is licenced under the following license:
*   Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
*   View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* @author Nabeel Shahzad
* @copyright Copyright (c) 2008, Nabeel Shahzad
* @link http://www.phpvms.net
* @license http://creativecommons.org/licenses/by-nc-sa/3.0/
*/

class Pilots extends CodonModule
{

public function index()
{
            $this->set('allpilots', PilotData::getAllPilots());
      $this->render('pilots_list.php');
        }

public function reports($pilotid='')
{
    if($pilotid == '')
    {
        $this->set('message', 'No pilot specified!');
        $this->render('core_error.php');
        return;
    }

    $this->set('pireps', PIREPData::GetAllReportsForPilot($pilotid));
    $this->render('pireps_viewall.php');
}


/* Stats stuff for charts */


public function statsdaysdata($pilotid)
{
    $data = PIREPData::getIntervalDataByDays(array('p.pilotid'=>$pilotid), 30);
    $this->create_line_graph('Past 30 days PIREPs', $data);
}

public function statsmonthsdata($pilotid)
{
    $data = PIREPData::getIntervalDataByMonth(array('p.pilotid'=>$pilotid), 3);
    $this->create_line_graph('Monthly Flight Stats', $data);
}

public function statsaircraftdata($pilotid)
{
    $data = StatsData::PilotAircraftFlownCounts($pilotid);
    if(!$data) $data = array();

    include CORE_LIB_PATH.'/php-ofc-library/open-flash-chart.php';

    $d = array();
    foreach($data as $ac)
    {
        OFCharts::add_data_set($ac->aircraft, floatval($ac->hours));
    }

    echo OFCharts::create_pie_graph('Aircraft Flown');
}

protected function create_line_graph($title, $data)
{    
    if(!$data)
    {
        $data = array();
    }

    $bar_values = array();
    $bar_titles = array();
    foreach($data as $val)
    {

        $bar_titles[] = $val->ym;
        $bar_values[] = floatval($val->total);
    }

    OFCharts::add_data_set($bar_titles, $bar_values);
    echo OFCharts::create_area_graph($title);
}

public function RecentFrontPage($count = 5)
{
    $this->set('pilots', PilotData::GetLatestPilots($count));
    $this->render('frontpage_recentpilots.php');
}
}

Link to comment
Share on other sites

Try this

<?php
/**
* phpVMS - Virtual Airline Administration Software
* Copyright (c) 2008 Nabeel Shahzad
* For more information, visit www.phpvms.net
*    Forums: http://www.phpvms.net/forum
*    Documentation: http://www.phpvms.net/docs
*
* phpVMS is licenced under the following license:
*   Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
*   View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
*
* @author Nabeel Shahzad
* @copyright Copyright (c) 2008, Nabeel Shahzad
* @link http://www.phpvms.net
* @license http://creativecommons.org/licenses/by-nc-sa/3.0/
*/
class Pilots extends CodonModule
{
  public function index()
  {
      $this->set('allpilots', PilotData::getAllPilots());
	  $this->set('pilot_list', PilotData::getAllPilots());
      $this->render('pilots_list.php');
  }

  public function reports($pilotid='')
  {
      if($pilotid == '')
      {
          $this->set('message', 'No pilot specified!');
          $this->render('core_error.php');
          return;
      }

      $this->set('pireps', PIREPData::GetAllReportsForPilot($pilotid));
      $this->render('pireps_viewall.php');
  }


  /* Stats stuff for charts */


  public function statsdaysdata($pilotid)
  {
      $data = PIREPData::getIntervalDataByDays(array('p.pilotid'=>$pilotid), 30);
      $this->create_line_graph('Past 30 days PIREPs', $data);
  }

  public function statsmonthsdata($pilotid)
  {
      $data = PIREPData::getIntervalDataByMonth(array('p.pilotid'=>$pilotid), 3);
      $this->create_line_graph('Monthly Flight Stats', $data);
  }

  public function statsaircraftdata($pilotid)
  {
      $data = StatsData::PilotAircraftFlownCounts($pilotid);
      if(!$data) $data = array();

      include CORE_LIB_PATH.'/php-ofc-library/open-flash-chart.php';

      $d = array();
      foreach($data as $ac)
      {
          OFCharts::add_data_set($ac->aircraft, floatval($ac->hours));
      }

      echo OFCharts::create_pie_graph('Aircraft Flown');
  }

  protected function create_line_graph($title, $data)
  {    
      if(!$data)
      {
          $data = array();
      }

      $bar_values = array();
      $bar_titles = array();
      foreach($data as $val)
      {

          $bar_titles[] = $val->ym;
          $bar_values[] = floatval($val->total);
      }

      OFCharts::add_data_set($bar_titles, $bar_values);
      echo OFCharts::create_area_graph($title);
  }

  public function RecentFrontPage($count = 5)
  {
      $this->set('pilots', PilotData::GetLatestPilots($count));
      $this->render('frontpage_recentpilots.php');
  }
}

Make sure the templates you are using match up with this repo

Link to comment
Share on other sites

  • 4 months later...
20 minutes ago, AidasP said:

Does not work at all

completely no changes made

 

Note that the coding above works using phpvms 5.5 and runing php version 5.6 on my server. That's my config at least.

 

Also r you using the .tpl or .php version of the crewcenter. That will change the formatting as shown above.

Link to comment
Share on other sites

1 hour ago, Shadesb181 said:

Note that the coding above works using phpvms 5.5 and runing php version 5.6 on my server. That's my config at least.

 

Also r you using the .tpl or .php version of the crewcenter. That will change the formatting as shown above.

wait..............................................................I am using default 'Crew Center', well at least the one i made with bootstrap, the thing is, that (yes my version is 5.5.x, of phpvms), that the Module Pilots, is acting like its not even existing there, i can delete everything, i can keep everything, i can edit stuff, it just ignores my changes, i am really annoyed with the hubs, just like sitting here trying to fix it for like 2h30min, so yeah..

Link to comment
Share on other sites

Just now, AidasP said:

wait..............................................................I am using default 'Crew Center', well at least the one i made with bootstrap, the thing is, that (yes my version is 5.5.x, of phpvms), that the Module Pilots, is acting like its not even existing there, i can delete everything, i can keep everything, i can edit stuff, it just ignores my changes, i am really annoyed with the hubs, just like sitting here trying to fix it for like 2h30min, so yeah..

oh and yeah i move them to my skin folder, or edit it directly, still no luck

Link to comment
Share on other sites

Noo... I dont user the CrewCenter, i told that before, im using my own, which i made with bootstrap, any1 can give me a code with pilots list, without hubs, and with bootstrap would be appreciated a lot!

i mean with bootstrap - bootstrap table

Edited by AidasP
Link to comment
Share on other sites

For phpvms 5.5.x, go into core/modules/Pilots/Pilot.php and find this

	public function index()
	{
		// Get all of our hubs, and list pilots by hub
		$allhubs = OperationsData::GetAllHubs();
		
		if(!$allhubs) $allhubs = array();
		
		foreach($allhubs as $hub)
		{
			$this->set('title', $hub->name);
			$this->set('icao', $hub->icao);
			
            $pilot_list = PilotData::findPilots(array('p.hub'=>$hub->icao));
			$this->set('allpilots', $pilot_list); # deprecated
            $this->set('pilot_list', $pilot_list);
								
			$this->render('pilots_list.tpl');
		}
		
		$nohub = PilotData::findPilots(array('p.hub'=>''));
		if(!$nohub) {
			return;
		}
		
		$this->set('title', 'No Hub');
		$this->set('icao', '');
		$this->set('allpilots', $nohub); # deprecated
        $this->set('pilot_list', $nohub);
		$this->render('pilots_list.tpl');
	}

And replace it with this

	public function index()
	{
		$allpilots = PilotData::getAllPilots();
		$this->set('allpilots', $allpilots); # deprecated
        $this->set('pilot_list', $allpilots);
		$this->render('pilots_list.tpl');
	}

Provided you haven't heavily modified the pilots_list.tpl/.php file, it should work.

NOTE: This takes into account the nature of the post, to give a pilots list of every pilot in the database and order them by pilot id not by hub.

If you want the default then do what shakamonkey88 said and go to the github repo and download the default file again.

Edited by web541
Link to comment
Share on other sites

  • 1 month later...
On 12/19/2017 at 11:27 PM, web541 said:

For phpvms 5.5.x, go into core/modules/Pilots/Pilot.php and find this


	public function index()
	{
		// Get all of our hubs, and list pilots by hub
		$allhubs = OperationsData::GetAllHubs();
		
		if(!$allhubs) $allhubs = array();
		
		foreach($allhubs as $hub)
		{
			$this->set('title', $hub->name);
			$this->set('icao', $hub->icao);
			
            $pilot_list = PilotData::findPilots(array('p.hub'=>$hub->icao));
			$this->set('allpilots', $pilot_list); # deprecated
            $this->set('pilot_list', $pilot_list);
								
			$this->render('pilots_list.tpl');
		}
		
		$nohub = PilotData::findPilots(array('p.hub'=>''));
		if(!$nohub) {
			return;
		}
		
		$this->set('title', 'No Hub');
		$this->set('icao', '');
		$this->set('allpilots', $nohub); # deprecated
        $this->set('pilot_list', $nohub);
		$this->render('pilots_list.tpl');
	}

And replace it with this


	public function index()
	{
		$allpilots = PilotData::getAllPilots();
		$this->set('allpilots', $allpilots); # deprecated
        $this->set('pilot_list', $allpilots);
		$this->render('pilots_list.tpl');
	}

Provided you haven't heavily modified the pilots_list.tpl/.php file, it should work.

NOTE: This takes into account the nature of the post, to give a pilots list of every pilot in the database and order them by pilot id not by hub.

If you want the default then do what shakamonkey88 said and go to the github repo and download the default file again.

Okay, thanks! Sorry for late reply. But that really helps.

 

      Aidas

  • Like 1
Link to comment
Share on other sites

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