PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/application/views/performance/performance.php

https://bitbucket.org/nando123/unj-iamperform
PHP | 299 lines | 245 code | 21 blank | 33 comment | 29 complexity | 3d0f78364cfe262be1afaa1c908318da MD5 | raw file
Possible License(s): MIT
  1. <?php
  2. if($kpf){
  3. $data = "";
  4. foreach ($kpf as $key) {
  5. $id_performance = $key->id_performance;
  6. $no_event = $key->master_atlet_nomor_event;
  7. $group = $key->master_group_name;
  8. $jenis = $key->jenis_performance;
  9. $messo = $key->messo;
  10. $date = $key->created_dttm;
  11. $user_id = $key->created_user_id;
  12. $tmpdate = explode(" ", $date);
  13. $dttm = $tmpdate[0];
  14. $catatan = $key->catatan;
  15. $nama = $key->name;
  16. $gambar = $key->gambar;
  17. if($gambar){
  18. $img = "<img alt='$nama' src='$gambar'>";
  19. }else{
  20. $img = "";
  21. }
  22. if($role_type == "KSC" AND $jenis == "Physical" OR $role_type == "CHC" AND $jenis == "Technical" OR $role_type =="PSY" AND $jenis == "Psichology"){
  23. $btnadd = "<a data-backdrop='static' data-toggle='modal' href='".base_url()."index.php/performance/formPerformanceAdd/$jenis/".$id_performance."'><i class='mdi-content-add-box'></i></a>";
  24. }else{
  25. $btnadd = "";
  26. }
  27. if($role_type == "KSC" AND $jenis == "Physical" OR $role_type == "CHC" AND $jenis == "Technical" OR $role_type =="PSY" AND $jenis == "Psichology"){
  28. $btndelete = "<span class='mdi-action-delete' onclick='confirmDelete(\"$id_performance\")'></span>";
  29. }else{
  30. $btndelete = "";
  31. }
  32. $query = $this->db->query("SELECT name as user_nm FROM users WHERE username = '$user_id'");
  33. if($query->num_rows()>0){
  34. $row = $query->row();
  35. $user_nm = $row->user_nm;
  36. }
  37. $sql_phy = " SELECT id_performance_detail as id, id_performance, komponen as komponen,"
  38. . " benchmark as benchmark, goal as goal, current as current"
  39. . " From master_performance_detail where id_performance = '$id_performance'";
  40. $query_phy = $this->db->query($sql_phy);
  41. $table = "";
  42. if($query_phy -> num_rows() > 0){
  43. $result_phy = $query_phy->result();
  44. if($result_phy > 0){
  45. foreach ($result_phy as $item) {
  46. $d_id = $item->id;
  47. $komponen = $item->komponen;
  48. // $messo = $item->benchmark;
  49. $current = $item->goal;
  50. $benchmark = $item->current;
  51. if ($benchmark <= 0) $benchmark = 1;
  52. if ($current <= 0) $current = 1;
  53. // if($role_type == "KSC" AND date("Y-m-d", strtotime($date)) == date("Y-m-d")){
  54. // $btnedit = "<span href='' onclick='showModal(\"$d_id\",\"$komponen\",\"$messo\",\"$current\",\"$benchmark\")'>$item->komponen</span>";
  55. // }else{
  56. $btnedit = "$item->komponen";
  57. // }
  58. // $hasil = ($current/$benchmark)*100;
  59. // $result = number_format($hasil, 2, '.', ' ');
  60. $table .= "<tr><td class='btn-info'><strong>$btnedit</strong></td><td>$item->current</td><td>$item->goal</td></tr>";
  61. }
  62. }
  63. }
  64. $data .= '
  65. <div class="col s12 m6 l6">
  66. <div class="card">
  67. <div class="card-content">
  68. <table class="striped">
  69. <thead>
  70. <tr>
  71. <td colspan="2">'.$jenis.' <span class="text-indigo" id="btnGrafik_'.$id_performance.'">
  72. <span class="mdi-action-assessment" onclick="showGrafik(\''.$id_performance.'\')"></span></span></td>
  73. <td></td><td>'.$btndelete.'</td>
  74. </tr>
  75. </thead>
  76. </table>
  77. <div id="grafik_'.$id_performance.'">
  78. <table class="striped">
  79. <thead>
  80. <tr><th class="indigo white-text" colspan="3">Messo '.$messo.'</th></tr>
  81. <tr>
  82. <th class="indigo white-text" data-field="id">Komponen</th>
  83. <th class="indigo white-text" data-field="price">Benchmark</th>
  84. <th class="indigo white-text" data-field="price">Current</th>
  85. </tr>
  86. </thead>
  87. <tbody>
  88. '.$table.'
  89. <tr><td colspan="4">'.$btnadd.'</td></tr>
  90. </tbody>
  91. </table>
  92. </div>
  93. </div>
  94. <div class="card-action">
  95. <p>Dibuat Pada : '.date('d M Y H:i:s',strtotime($date)).' <br>Dibuat Oleh &nbsp: '.$user_nm.'</p>
  96. <p>Catatan : </p>
  97. <p>'.$catatan.'</p>
  98. </div>
  99. </div>
  100. </div>
  101. ';
  102. }
  103. }else{
  104. $data = "Data Kosong";
  105. }
  106. if($role_type == "KSC"){
  107. $type = "physic";
  108. }
  109. if($role_type == "CHC"){
  110. $type = "technical";
  111. }
  112. if($role_type == "PSY"){
  113. $type = "mental";
  114. }
  115. ?>
  116. <!-- START CONTENT -->
  117. <section id="content">
  118. <div class="container">
  119. <div class="col s12 m12 l6">
  120. <div id="flight-card" class="card">
  121. <div class="card-header sea-games">
  122. <div class="card-title">
  123. <div class="col s5 m5 l5 center-align">
  124. <img src="<?php echo $gambar_atl?>" width="100px" height="100px" class="circle z-depth-1 responsive-img activator">
  125. </div>
  126. <div class="col s5 m5 l5 center-align">
  127. <h5 class="flight-card-title white-text" style="text-shadow: 0px 0px 0px #ffffff;"><b><?php echo $nama_user?></b></h5>
  128. <p class="flight-card-date white-text" style="text-shadow: 0px 0px 0px #ffffff;"><?php echo $group_name ?> - <?php echo $no_event ?></p>
  129. <p class="flight-card-date white-text" style="text-shadow: 0px 0px 0px #ffffff;">Performance Profiling</p>
  130. </div>
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. <div id="card-stats">
  136. <div class="row">
  137. <?php echo $data ?>
  138. <div id="modalData"></div>
  139. </div>
  140. </div>
  141. </div>
  142. <!--end container-->
  143. </section>
  144. <?php if($role_type == "KSC" OR $role_type == "CHC" OR $role_type == "PSY"){?>
  145. <div class="fixed-action-btn" style="bottom: 45px; right: 24px;">
  146. <a class="btn-floating btn-large red" href="<?php echo base_url();?>index.php/performance/ChooseAtlet/data/<?php echo $type ?>">
  147. <i class="large mdi-editor-mode-edit"></i>
  148. </a>
  149. </div>
  150. <?php } ?>
  151. <!-- END CONTENT -->
  152. <script>
  153. function showModal(d_id,komponen,messo,current,benchmark){
  154. $.ajax({
  155. type : 'POST',
  156. url : '<?php echo base_url();?>index.php/performance/showPopUp',
  157. data : {d_id:d_id,komponen:komponen,messo:messo,current:current,benchmark:benchmark},
  158. // dataType: "json",
  159. success: function(data){
  160. // alert(data);
  161. $("#modalData").html(data);
  162. },error: function(xhr, ajaxOptions, thrownError){
  163. alert(xhr.responseText);
  164. }
  165. });
  166. }
  167. function confirmDelete(id_performance){
  168. $.ajax({
  169. type : 'POST',
  170. url : '<?php echo base_url();?>index.php/performance/showDeleteConfirm',
  171. data : {id_performance:id_performance},
  172. // dataType: "json",
  173. success: function(data){
  174. // alert(data);
  175. $("#modalData").html(data);
  176. },error: function(xhr, ajaxOptions, thrownError){
  177. alert(xhr.responseText);
  178. }
  179. });
  180. }
  181. function closeModal(d_id){
  182. var modal = document.getElementById('myModal_'+d_id);
  183. modal.style.display = "none";
  184. }
  185. function showGrafik(id_performance){
  186. // alert(id_performance);
  187. $("#grafik_"+id_performance).html("<div class='progress'><div class='indeterminate'></div></div>");
  188. $("#btnGrafik_"+id_performance).html("<span class='mdi-action-list' onclick='showTable(\""+id_performance+"\")'></span>");
  189. var options = {
  190. colors: ['#FF00B2', '#293696', '#FCFC00', '#DDDF00', '#24CBE5', '#64E572',
  191. '#FF9655', '#FFF263', '#6AF9C4'],
  192. chart: {
  193. polar: true,
  194. type: 'line',
  195. renderTo: 'grafik_'+id_performance,
  196. },
  197. title: {
  198. text: '',
  199. x: -80
  200. },
  201. pane: {
  202. size: '80%'
  203. },
  204. navigation: {
  205. buttonOptions: {
  206. align: "right",
  207. enabled: true,
  208. },
  209. },
  210. xAxis: {
  211. categories: [],
  212. tickmarkPlacement: 'on',
  213. lineWidth: 0
  214. },
  215. yAxis: {
  216. gridLineInterpolation: 'polygon',
  217. lineWidth: 0,
  218. min: 0
  219. },
  220. tooltip: {
  221. shared: true,
  222. pointFormat: '<span style="color:{series.color}">{series.name}: <b>{point.y:,.0f}</b><br/>'
  223. },
  224. // legend: {
  225. // align: 'right',
  226. // verticalAlign: 'top',
  227. // y: 70,
  228. // layout: 'vertical'
  229. // },
  230. series: [{},{}]
  231. // series: [{
  232. // name: 'Achievment',
  233. // data: [10,10,10],
  234. // pointPlacement: 'on'
  235. // }, {
  236. // name: 'Goal',
  237. // data: [10,10,10],
  238. // pointPlacement: 'on'
  239. // },{
  240. // name: 'Messo',
  241. // data: [10,10,10],
  242. // pointPlacement: 'on'
  243. // }]
  244. };
  245. $.ajax({
  246. type : 'POST',
  247. url : '<?php echo base_url();?>index.php/performance/viewGrafik',
  248. data : {id_performance:id_performance},
  249. dataType: "json",
  250. success: function(data){
  251. options.xAxis.categories = data.categories;
  252. options.series[0].name = 'Benchmark';
  253. options.series[0].data = data.benchmark;
  254. options.series[1].name = 'Current';
  255. options.series[1].data = data.current;
  256. var chart = new Highcharts.Chart(options);
  257. },error: function(xhr, ajaxOptions, thrownError){
  258. alert(xhr.responseText);
  259. }
  260. });
  261. }
  262. function showTable(id_performance){
  263. $("#grafik_"+id_performance).html("<div class='progress'><div class='indeterminate'></div></div>");
  264. $("#btnGrafik_"+id_performance).html("<span class='mdi-action-assessment' onclick='showGrafik(\""+id_performance+"\")'></span>");
  265. $.ajax({
  266. type : 'POST',
  267. url : '<?php echo base_url();?>index.php/performance/viewTable',
  268. data : {id_performance:id_performance},
  269. // dataType: "json",
  270. success: function(data){
  271. // alert(data);
  272. $("#grafik_"+id_performance).html(data);
  273. },error: function(xhr, ajaxOptions, thrownError){
  274. alert(xhr.responseText);
  275. }
  276. });
  277. }
  278. </script>