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

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.

5 Likes

Thank You Very Much

1 Like

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

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

1 Like

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

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

thanks

1 Like

thanks

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

1 Like

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

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

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.

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,

1 Like

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

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

if i want to make it where i have all my pilots show up like in there airline and not by hub where would i insert the code and how would the code be something simular to

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’);
}
}

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

That’s perfect. thank you

 

Does not work at all

completely no changes made

 

16 minutes ago, AidasP said:

Does not work at all

completely no changes made

 

It does work - you’re doing something wrong.

Where are you uploading this to?

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.

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