TennShadow Posted May 22, 2010 Report Posted May 22, 2010 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 Quote
Administrators simpilot Posted May 22, 2010 Administrators Report Posted May 22, 2010 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>'; 1 Quote
Administrators Nabeel Posted May 22, 2010 Administrators Report Posted May 22, 2010 The default pilots list sorts by hub, would that help? You can remove columns in the template Quote
TennShadow Posted May 23, 2010 Author Report Posted May 23, 2010 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. I'm clearly at a loss. Quote
Administrators Nabeel Posted May 23, 2010 Administrators Report Posted May 23, 2010 You can put that right into a template and call that template from wherever with Template::Show('template-name'); Quote
TennShadow Posted May 23, 2010 Author Report Posted May 23, 2010 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. Quote
Administrators Nabeel Posted May 23, 2010 Administrators Report Posted May 23, 2010 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 1 Quote
TennShadow Posted May 24, 2010 Author Report Posted May 24, 2010 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 1 Quote
Administrators Nabeel Posted May 24, 2010 Administrators Report Posted May 24, 2010 Once you get the hang of it, it ain't so bad! Quote
saapilot Posted June 28, 2010 Report Posted June 28, 2010 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 Quote
Administrators simpilot Posted June 28, 2010 Administrators Report Posted June 28, 2010 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. Quote
saapilot Posted June 28, 2010 Report Posted June 28, 2010 Many thanks for your valued input once again.... Mark Quote
Administrators Nabeel Posted June 28, 2010 Administrators Report Posted June 28, 2010 Yep, simpilot's suggestion is the way to go. Housing subfolders would be a huge change to the core Quote
Strider Posted August 20, 2011 Report Posted August 20, 2011 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. 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.