Jump to content
deactivated

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

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

Share this post


Link to post
Share on other sites

That actually worked out real nice. Thanks for the share. +1

Hey West Jet, can you give him a +1 for sharing please?

  • Like 1

Share this post


Link to post
Share on other sites

That actually worked out real nice. Thanks for the share. +1

Hey West Jet, can you give him a +1 for sharing please?

rolleyes.gif thanks :P

  • Like 1

Share this post


Link to post
Share on other sites

rolleyes.gif thanks :P

Not a problem. Thank you. I was meaing to do that for a while but never did until I saw this post.

  • Like 1

Share this post


Link to post
Share on other sites

well.. it worked for me on another site but now im getting the error:

Notice: The template file "/home/ualvirtu/public_html//core/templates/Pilots_list.tpl" doesn't exist in /home/ualvirtu/public_html/core/classes/TemplateSet.class.php on line 248

Share this post


Link to post
Share on other sites

well.. it worked for me on another site but now im getting the error:

Do you have the file Pilots_list.tpl in your core/templates file? That error code is telling you that it can't find the Pilots_list.tpl file..

Share this post


Link to post
Share on other sites

Download phpvms again, go to the core>templates folder, find the pilots_list.tpl file and upload it again, and that should fix that problem. If not run the checkinstall.php maybe something is corrupted.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Nice Add! I agree it's a good idea to have those if you are running a military operations!

Share this post


Link to post
Share on other sites

I apologize for opening this old topic, but as I found it a very useful topic, I thought I would debug it. Fixed 2 errors, one with the pilots_list.tpl being Pilots_list.tpl thus rendering and error, and another with it screwing with the recent pilot function.

http://pastebin.com/yFejJA7e

Share this post


Link to post
Share on other sites
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');
}
}

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
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..

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Ok well you need to stop calling it crew center as people will automatically think you are using the crewcenter that many of us use. 

Why are you making these edits (ie file location)?

What phpVMS version are you using?

you can easily grab the default php file you need from a github repo

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×