Guest User

Untitled

a guest
Jun 17th, 2014
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 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. // Get all of our hubs, and list pilots by hub
  25. $allhubs = OperationsData::GetAllHubs();
  26.  
  27. if(!$allhubs) $allhubs = array();
  28.  
  29. foreach($allhubs as $hub)
  30. {
  31.  
  32. $this->set('icao', $hub->icao);
  33.  
  34. $this->set('allpilots', PilotData::findPilots(array('p.hub'=>$hub->icao)));
  35.  
  36. $this->render('pilots_list.tpl');
  37. }
  38.  
  39. $nohub = PilotData::findPilots(array('p.hub'=>''));
  40. if(!$nohub)
  41. {
  42. return;
  43. }
  44.  
  45. $this->set('title', 'No Hub');
  46. $this->set('icao', '');
  47. $this->set('allpilots', $nohub);
  48. $this->render('pilots_list.tpl');
  49. }
  50.  
  51. public function reports($pilotid='')
  52. {
  53. if($pilotid == '')
  54. {
  55. $this->set('message', 'No pilot specified!');
  56. $this->render('core_error.tpl');
  57. return;
  58. }
  59.  
  60. $this->set('pireps', PIREPData::GetAllReportsForPilot($pilotid));
  61. $this->render('pireps_viewall.tpl');
  62. }
  63.  
  64.  
  65. /* Stats stuff for charts */
  66.  
  67.  
  68. public function statsdaysdata($pilotid)
  69. {
  70. $data = PIREPData::getIntervalDataByDays(array('p.pilotid'=>$pilotid), 30);
  71. $this->create_line_graph('Past 30 days PIREPs', $data);
  72. }
  73.  
  74. public function statsmonthsdata($pilotid)
  75. {
  76. $data = PIREPData::getIntervalDataByMonth(array('p.pilotid'=>$pilotid), 3);
  77. $this->create_line_graph('Monthly Flight Stats', $data);
  78. }
  79.  
  80. public function statsaircraftdata($pilotid)
  81. {
  82. $data = StatsData::PilotAircraftFlownCounts($pilotid);
  83. if(!$data) $data = array();
  84.  
  85. include CORE_LIB_PATH.'/php-ofc-library/open-flash-chart.php';
  86.  
  87. $d = array();
  88. foreach($data as $ac)
  89. {
  90. OFCharts::add_data_set($ac->aircraft, floatval($ac->hours));
  91. }
  92.  
  93. echo OFCharts::create_pie_graph('Aircraft Flown');
  94. }
  95.  
  96. protected function create_line_graph($title, $data)
  97. {
  98. if(!$data)
  99. {
  100. $data = array();
  101. }
  102.  
  103. $bar_values = array();
  104. $bar_titles = array();
  105. foreach($data as $val)
  106. {
  107.  
  108. $bar_titles[] = $val->ym;
  109. $bar_values[] = floatval($val->total);
  110. }
  111.  
  112. OFCharts::add_data_set($bar_titles, $bar_values);
  113. echo OFCharts::create_area_graph($title);
  114. }
  115.  
  116. public function RecentFrontPage($count = 5)
  117. {
  118. $this->set('pilots', PilotData::GetLatestPilots($count));
  119. $this->render('frontpage_recentpilots.tpl');
  120. }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment