Jump to content
phpVMS Forums

Pilot Stats on front page


Recommended Posts

I'm trying to get the pilots stats to show on my front page, i have added the following code to frontpage_main.php but it's not pulling the data.

 

<ul class="list-group">
              <li class="list-group-item"><span class="badge"><?php echo $userinfo->totalflights?></span>Total Flights</li>
              <li class="list-group-item"><span class="badge badge-default"><?php echo $userinfo->totalhours; ?></span>Total Hours</li>
              <li class="list-group-item"><span class="badge badge-primary"><?php echo $userinfo->transferhours?></span>Transfer Hours</li>
              <li class="list-group-item"><span class="badge badge-success"><?php echo FinanceData::FormatMoney($userinfo->totalpay) ?></span>Pay</li>
              <li class="list-group-item"><span class="badge badge-warning"><?php echo $nextrank->rank?></span>Next Rank</li>
              <li class="list-group-item"><span class="badge badge-warning"><?php echo ($nextrank->minhours - $pilot_hours)?></span>Hrs until Next Rank</li>
            </ul>   

 

 

Untitled.png

Link to post
Share on other sites
16 hours ago, mattsmith said:

I'm trying to get the pilots stats to show on my front page, i have added the following code to frontpage_main.php but it's not pulling the data.

 

<ul class="list-group">
              <li class="list-group-item"><span class="badge"><?php echo $userinfo->totalflights?></span>Total Flights</li>
              <li class="list-group-item"><span class="badge badge-default"><?php echo $userinfo->totalhours; ?></span>Total Hours</li>
              <li class="list-group-item"><span class="badge badge-primary"><?php echo $userinfo->transferhours?></span>Transfer Hours</li>
              <li class="list-group-item"><span class="badge badge-success"><?php echo FinanceData::FormatMoney($userinfo->totalpay) ?></span>Pay</li>
              <li class="list-group-item"><span class="badge badge-warning"><?php echo $nextrank->rank?></span>Next Rank</li>
              <li class="list-group-item"><span class="badge badge-warning"><?php echo ($nextrank->minhours - $pilot_hours)?></span>Hrs until Next Rank</li>
            </ul>   

 

 

Untitled.png

The best option is put these information in profile_main.

You should edit the core/modules/Frontpage/Frontpage.php

replace with 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/ * @package module_frontpage
 */

class Frontpage extends CodonModule
{
	public $title = 'Welcome';
	
	public function index()
	{
		$this->set('usersonline', StatsData::UsersOnline());
		$this->set('guestsonline', StatsData::GuestsOnline());
		$this->set('pilotcode', PilotData::getPilotCode($pilot->code, $pilot->pilotid));
		$this->set('report', PIREPData::getLastReports($pilot->pilotid));
		$this->set('nextrank', RanksData::getNextRank($totalhours));
		$this->set('allawards', AwardsData::getPilotAwards($pilot->pilotid));
		$this->set('userinfo', $pilot);
        $this->set('pilot', $pilot);
		$this->set('pilot_hours', $totalhours);
		$this->render('frontpage_main.tpl');
	}
}

 

Edited by ProSkyDesign
Link to post
Share on other sites

In general, I do not agree with anything that has to do with editing the core files of a phpVMS website when you can avoid it. Also, I do not know if the above changes are going to work.

The part of code you are using does not show data because the $userinfo variable has not been populated. Instead of "$userinfo->totalhours", you can use  "Auth::$userinfo->totalhours" which should populate the $userinfo variable correctly. After that you can make use of the functions shown in the part of code "ProSkyDesign" shown. For example:

<li class="list-group-item"><span class="badge badge-primary"><?php echo Auth::$userinfo->transferhours; ?></span>Transfer Hours</li>
<li class="list-group-item"><span class="badge badge-success"><?php echo FinanceData::FormatMoney(Auth::$userinfo->totalpay); ?></span>Pay</li>

You can do the same with the rest of the data you want to show in the frontpage of your website. :)

Link to post
Share on other sites
  • 2 weeks later...
On 5/22/2017 at 4:51 PM, mattsmith said:

I'm trying to get the pilots stats to show on my front page, i have added the following code to frontpage_main.php but it's not pulling the data.

 

<ul class="list-group">
              <li class="list-group-item"><span class="badge"><?php echo $userinfo->totalflights?></span>Total Flights</li>
              <li class="list-group-item"><span class="badge badge-default"><?php echo $userinfo->totalhours; ?></span>Total Hours</li>
              <li class="list-group-item"><span class="badge badge-primary"><?php echo $userinfo->transferhours?></span>Transfer Hours</li>
              <li class="list-group-item"><span class="badge badge-success"><?php echo FinanceData::FormatMoney($userinfo->totalpay) ?></span>Pay</li>
              <li class="list-group-item"><span class="badge badge-warning"><?php echo $nextrank->rank?></span>Next Rank</li>
              <li class="list-group-item"><span class="badge badge-warning"><?php echo ($nextrank->minhours - $pilot_hours)?></span>Hrs until Next Rank</li>
            </ul>   

 

 

Untitled.png

I have created a module called "Statistics". You can look at the demo at my website.

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