phpVMS

phpVMS Admin Dashboard Fixes

By 24 November 2020No Comments

As you may have noticed, when you access your phpVMS admin dashboard the line graph and latest news never loads in. According to a blog post by VirtualAirlines.EU, the graph based on shockwave flash, was hacked a few years ago. The phpVMS news hasn’t worked for years and no longer pulls any news data from phpVMS itself.

However there are a few work arounds to get the graph showing on the main admin page, along with a few other features.

Navigate to /admin/modules/dashboard/dashboard.php and locate $this->render. This can be round around line 41.

Replace the code with the following so it looks as follows:

if (is_array(PIREPData::getReportsByExportStatus(false)) || PIREPData::getReportsByExportStatus(false) instanceof Countable) {
$this->set('unexported_count', count(PIREPData::getReportsByExportStatus(false)));
$this->set('pireps', PIREPData::getIntervalDataByDays(array(), 30));
$this->set('allbids', SchedulesData::getAllBids());
}
$this->render('dashboard.php');
}

If you have the gallery module and want to show pending submissions then you can also include the following to the above:

$this->set('screenshots', ScreenshotsData::getscreenshots_toapprove());

Now that this has been added in, close and save the file. Now navigate to /admin/templates/dashboard.tpl or php. Around line 36, After the } add the following code:

Template::Show('pilots_viewallbids.tpl');
Template::Show('screenshots_approval.tpl');

If you use the php version, you should change .tpl to .php

Now that you have inserted that part of code, save the file and scroll down to the bottom where it states this line

Don’t need to change anything below this here.

Delete the entire <script> block and replace with the following:

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
  google.charts.load('current', {'packages':['corechart']});
  google.charts.setOnLoadCallback(drawChart);

  function drawChart() {
    var data = google.visualization.arrayToDataTable([
      ['Day', 'Pireps'],
	<?php
	$counter=0;
	$total=0;
	$len = count($pireps);
	foreach($pireps as $row)
	{
		echo "['".date('j M',$row->timestamp)."',".$row->total."]";
		$total=$total+$row->total;
		if ($counter<$len-1)
		{ 	echo ","; }
		$counter++;	
	}		
	?>
    ]);

    var options = {
      title: '',
      legend: { position: 'none' }
    };

    var chart = new google.visualization.LineChart(document.getElementById('reportcounts'));

    chart.draw(data, options);
  }

You can now save the changes made and head to your admin panel. There you should see something similar to this

As you can see the graph is now displaying. In this instace we don’t use the gallery call function.

 

We hope you enjoy this little work around fix. Take care and stay safe all!

Leave a Reply