Jump to content

Custom Page


TennShadow

Recommended Posts

I need to create a new page that automatically displays the following information.

Pilot Name Pilot ID Join Date Last Flight

I'd like this sorted by Hub if possible.

Example:

KLAX

Pilot Name Pilot ID Join Date Last Flight

Bob Smith PVA1002 05-05-10 5-15-10

KMIA

Pilot Name Pilot ID Join Date Last Flight

Jane Smith PVA1003 02-05-10 3-15-10

I'd be willing to pay for this if this is too much work.

The reason I need this is I want a page where my Hub Managers can check to see when the last time their pilot flew. I don't want to give them the EDIT_PILOTS group permission so I was thinking this would be the best solution but I don't have a clue on how to do this.

Thanks in advance for your help.

Keith

Link to comment
Share on other sites

  • Administrators

This is part of the module I use for hub managers as I did not want to give them core access as well. I have built my own system for hub managers to change ranks and get pilot information. This page might help you though.

<?php
   $pilots = PilotData::getAllPilots();
           echo '<table width="100%" border="1px">';
           echo '<tr style="font-weight: bold;">';
               echo '<td>Pilot ID</td>';
               echo '<td>Name</td>';
               echo '<td>Rank</td>';
               echo '<td>Total Hours</td>';
               echo '<td>Hub</td>';
               echo '<td>Hire Date</td>';
               echo '<td>Last PIREP</td>';
               echo '<td>email</td>';
               echo '<td>Status</td>';
               echo '</tr>';
           foreach($pilots as $pilot)
           {
               echo '<tr>';
               echo '<td>'.PilotData::getPilotCode($pilot->code, $pilot->pilotid).'</td>';
               echo '<td>'.$pilot->firstname.' '.$pilot->lastname.'</td>';
               echo '<td>';
                   $rank = RanksData::getRankInfo($pilot->rankid);
                   echo $pilot->rank;
               echo '</td>';
               echo '<td>'.$pilot->totalhours.'</td>';
               echo '<td>'.$pilot->hub.'</td>';
               echo '<td align="center">'.date('m/d/Y', strtotime($pilot->joindate)).'</td>';
               if($pilot->lastpirep == 0)
                   {
                       echo '<td align="center" bgcolor="FF6666">No Filights Filed</td>';
                   }
                   else
                   {
                       echo '<td align="center">'.date('m/d/Y', strtotime($pilot->lastpirep)).'</td>';
                   }
               echo '<td>'.$pilot->email.'</td>';
               if($pilot->retired == '0')
               {echo '<td align="center" bgcolor="99ff99">Active</td>';}
               else
               {echo '<td align="center" bgcolor="FF6666">Inactive</td>';}
               echo '</tr>';
           }
          echo '</table>';
?>

If you want the pilot to only see pilots of his own hub add

if($pilot->hub <> Auth::$userinfo->hub)
               {continue;}

between

foreach($pilots as $pilot)
           {

and

echo '<tr>';

B)

  • Like 1
Link to comment
Share on other sites

Thanks Simpilot. That's just what I wanted.

My next question is how do I integrate that into my site? I tried to create a new page but that just messed up the php code. I then added that to a folder and placed it in the Modules directory but it displayed it twice on top of my whole site. laugh.gif

I'm clearly at a loss.

Link to comment
Share on other sites

You can put that right into a template and call that template from wherever with

Template::Show('template-name');

Thanks Nabeel.

That will work if I wanted to integrate that on a page I already have. What I'm looking for it so have that code on its own page where I can put a link to it in my staff menu. I can't use the pages because of the issues it has with PHP code.

Sorry for the trouble. That's why I was willing to pay for this to work. I've tried to figure out PHP and I can't seem to get it.

Link to comment
Share on other sites

  • Administrators

You can create a quick module for that,

in the core/modules folder

Create a folder called 'pilothub', in that 'pilothub.php'

Then in that

:

class pilothub extends CodonModule 
{

  public function index() {

 	Template::Show ('templatefile');
  }
}

Then goto index.php/pilothub

That should do it

  • Like 1
Link to comment
Share on other sites

You can create a quick module for that,

in the core/modules folder

Create a folder called 'pilothub', in that 'pilothub.php'

Then in that

:

class pilothub extends CodonModule 
{

  public function index() {

 	Template::Show ('templatefile');
  }
}

Then goto index.php/pilothub

That should do it

Thanks Nabeel, that worked!

I was actually a lot closer to figuring it out than I thought. I checked out your module directions and I was only missing the "Template::Show ("templatefile");

Maybe I should give myself a little more credit in the programing arena.

Thanks again to both Simpilot and Nabeel for this.

Keith

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Hi Nabeel,

Is there a way to have a folder under the modules folder where we can store all these so called custom folders. By way of example, /core/modules/mymodules/module1/module1.php and so on. I get an error when I try and do it like this, something along the lines of module not found...

It would be helpful not to clutter the modules folder with all these custom folders.

Thanks

Mark

Link to comment
Share on other sites

  • Administrators

What I do to keep the modules to a minimum is create one module with multiple functions for custom pages.

For example create a custom module "ContentPages.php"

and within it create functions for each page you want

class ContentPages extends CodonModule  
{ 

  public function index() { 

       $this->show('index.tpl'); 
  } 

  public function pilots() { 

       $this->show('pilots.tpl'); 
  } 

  public function aboutus() { 

       $this->show('aboutus.tpl'); 
  } 


}

Then just create your link to the new page -> www.mysite.com/index.php/ContentPages/function you want to use.

This way you will only have one module and folder and you can add as many functions (pages) to it as you need.

Link to comment
Share on other sites

  • 1 year later...

I know this is digging up an old thread, but I have made some changes to the code.

<?php

$pilots = PilotData::getAllPilots();


       	echo '<table width="100%" border="1px">';

       	echo '<tr style="font-weight: bold;">';
           	echo '<td>Pilot ID</td>';
           	echo '<td>Name</td>';
           	echo '<td>Rank</td>';
           	echo '<td>Total Hours</td>';
           	echo '<td>Hub</td>';
           	echo '<td>Hire Date</td>';
           	echo '<td>Last PIREP</td>';
           	echo '<td>email</td>';
           	echo '<td>Status</td>';
           	echo '</tr>';

       	foreach($pilots as $pilot)
       	{
			if($pilot->hub <> Auth::$userinfo->hub)
           	{continue;}
			$furl = url('/airports/get_airport?icao='.$pilot->hub);
			$profile = PilotData::getPilotCode($pilot->code, $pilot->pilotid);
           	$image = $pilot->rankimage;
           	echo '<tr>';
           	echo '<td><a href="http://yoururl/index.php/profile/view/'.$profile.'">'.$profile.'</a></td>';
           	echo '<td>'.$pilot->firstname.' '.$pilot->lastname.'</td>';
           	echo '<td>';
               	$rank = RanksData::getRankInfo($pilot->rankid);
               	echo '<img src="'.$image.'" alt="'.$pilot->rank.'" />';
           	echo '</td>';
           	echo '<td>'.$pilot->totalhours.'</td>';
           	echo '<td><a href="'.$furl.'">'.$pilot->hub.'</a></td>';
           	echo '<td align="center">'.date('m/d/Y', strtotime($pilot->joindate)).'</td>';
           	if($pilot->lastpirep == 0)
               	{
                   	echo '<td align="center" bgcolor="FF6666">No Filights Filed</td>';
               	}
               	else
               	{
                   	echo '<td align="center">'.date('m/d/Y', strtotime($pilot->lastpirep)).'</td>';
               	}
			if(!Auth::LoggedIn())
{
           	echo '<td>You are not Logged in!</td>';
}
else{

			echo '<td><a href="mailto:'.$pilot->email.'" title="Email">'.$pilot->email.'</td>';
}
           	if($pilot->retired == '0')
           	{echo '<td align="center" bgcolor="99ff99">Active</td>';}
           	else
           	{echo '<td align="center" bgcolor="FF6666">Inactive</td>';}
           	echo '</tr>';
       	}

  		echo '</table>';

?>

I have made it so that the rank image shows, you can click on the pilot ID and go to their profile, their email only shows for registered users who are logged in, added the code to allow you to click on the hub airport ICAO and get the details(only works if you have the module for that installed), I also made the email clickable, so you can send an email to each pilot easier then you could have before. All credit goes to Simpilot for the code. I do not take credit for any of it.

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