Advertisement
Guest User

Untitled

a guest
Jun 17th, 2014
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. <?php
  2. /**
  3. * phpVMS - Virtual Airline Administration Software
  4. * Copyright (c) 2008 Nabeel Shahzad
  5. * For more information, visit www.phpvms.net
  6. * Forums: http://www.phpvms.net/forum
  7. * Documentation: http://www.phpvms.net/docs
  8. *
  9. * phpVMS is licenced under the following license:
  10. * Creative Commons Attribution Non-commercial Share Alike (by-nc-sa)
  11. * View license.txt in the root, or visit http://creativecommons.org/licenses/by-nc-sa/3.0/
  12. *
  13. * @author Nabeel Shahzad
  14. * @copyright Copyright (c) 2008, Nabeel Shahzad
  15. * @link http://www.phpvms.net
  16. * @license http://creativecommons.org/licenses/by-nc-sa/3.0/
  17. */
  18.  
  19. class Pilots extends CodonModule
  20. {
  21.  
  22. public function index()
  23. {
  24. $this->set('allpilots', PilotData::getAllpilots());
  25. $this->render('pilots_list.tpl');
  26. }
  27.  
  28.  
  29.  
  30. public function reports($pilotid='')
  31. {
  32. if($pilotid == '')
  33. {
  34. $this->set('message', 'No Pilot specified!');
  35. $this->render('core_error.tpl');
  36. return;
  37. }
  38.  
  39. $this->set('pireps', PIREPData::GetAllReportsForPilot($pilotid));
  40. $this->render('pireps_viewall.tpl');
  41. }
  42.  
  43.  
  44. /* Stats stuff for charts */
  45.  
  46.  
  47. public function statsdaysdata($pilotid)
  48. {
  49. $data = PIREPData::getIntervalDataByDays(array('p.pilotid'=>$pilotid), 30);
  50. $this->create_line_graph('Past 30 days PIREPs', $data);
  51. }
  52.  
  53. public function statsmonthsdata($pilotid)
  54. {
  55. $data = PIREPData::getIntervalDataByMonth(array('p.pilotid'=>$pilotid), 3);
  56. $this->create_line_graph('Monthly Flight Stats', $data);
  57. }
  58.  
  59. public function statsaircraftdata($pilotid)
  60. {
  61. $data = StatsData::PilotAircraftFlownCounts($pilotid);
  62. if(!$data) $data = array();
  63.  
  64. include CORE_LIB_PATH.'/php-ofc-library/open-flash-chart.php';
  65.  
  66. $d = array();
  67. foreach($data as $ac)
  68. {
  69. OFCharts::add_data_set($ac->aircraft, floatval($ac->hours));
  70. }
  71.  
  72. echo OFCharts::create_pie_graph('Aircraft Flown');
  73. }
  74.  
  75. protected function create_line_graph($title, $data)
  76. {
  77. if(!$data)
  78. {
  79. $data = array();
  80. }
  81.  
  82. $bar_values = array();
  83. $bar_titles = array();
  84. foreach($data as $val)
  85. {
  86.  
  87. $bar_titles[] = $val->ym;
  88. $bar_values[] = floatval($val->total);
  89. }
  90.  
  91. OFCharts::add_data_set($bar_titles, $bar_values);
  92. echo OFCharts::create_area_graph($title);
  93. }
  94.  
  95. public function RecentFrontPage($count = 5)
  96. {
  97. $this->set('pilots', PilotData::GetLatestPilots($count));
  98. $this->render('frontpage_recentpilots.tpl');
  99. }
  100.  
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement