js.blade.php 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <script src="http://code.highcharts.com/highcharts.js"></script>
  2. <script src="http://code.highcharts.com/maps/modules/map.js"></script>
  3. <script src="http://code.highcharts.com/maps/modules/exporting.js"></script>
  4. <script src="http://code.highcharts.com/mapdata/countries/us/us-all.js"></script>
  5. <script>
  6. Highcharts.chart('inspeksi-kegiatan', {
  7. chart: {
  8. type: 'bar'
  9. },
  10. title:false,
  11. <?php
  12. $upt = \App\Model\Setting\UPT::select('office_name','office_id')->distinct()->get();
  13. ?>
  14. xAxis: {
  15. categories: [
  16. @foreach($upt as $key => $value)
  17. '{{$value->office_name}}',
  18. @endforeach
  19. ],
  20. title: {
  21. text: null
  22. }
  23. },
  24. yAxis: {
  25. min: 0,
  26. title: {
  27. text: 'Capaian Kegiatan Inspeksi',
  28. align: 'high'
  29. },
  30. labels: {
  31. overflow: 'justify'
  32. }
  33. },
  34. tooltip: {
  35. valueSuffix: 'Kegiatan'
  36. },
  37. plotOptions: {
  38. bar: {
  39. dataLabels: {
  40. enabled: true
  41. }
  42. }
  43. },
  44. legend: {
  45. layout: 'vertical',
  46. align: 'right',
  47. verticalAlign: 'top',
  48. x: -40,
  49. y: 80,
  50. floating: true,
  51. borderWidth: 1,
  52. backgroundColor:
  53. Highcharts.defaultOptions.legend.backgroundColor || '#000',
  54. shadow: true
  55. },
  56. credits: {
  57. enabled: false
  58. },
  59. series: [
  60. {
  61. name: 'Total Kegiatan Inspeksi',
  62. data: [
  63. @foreach($upt as $key => $value)
  64. {{\App\Model\Inspeksi\Inspeksi::where('kode_upt',$value->office_id)->count()}},
  65. @endforeach
  66. ]
  67. },
  68. ]
  69. });
  70. </script>
  71. <script>
  72. Highcharts.chart('inspeksi-capaian-total', {
  73. chart: {
  74. type: 'bar'
  75. },
  76. title:false,
  77. xAxis: {
  78. categories: [
  79. 'Jumlah Kegiatan',
  80. 'Capaian Hasil Inspeksi',
  81. ],
  82. title: {
  83. text: null
  84. }
  85. },
  86. yAxis: {
  87. min: 0,
  88. title: {
  89. text: 'Capaian Total',
  90. align: 'high'
  91. },
  92. labels: {
  93. overflow: 'justify'
  94. }
  95. },
  96. tooltip: {
  97. valueSuffix: '%'
  98. },
  99. plotOptions: {
  100. bar: {
  101. dataLabels: {
  102. enabled: true
  103. }
  104. }
  105. },
  106. legend: {
  107. layout: 'vertical',
  108. align: 'right',
  109. verticalAlign: 'top',
  110. x: -40,
  111. y: 80,
  112. floating: true,
  113. borderWidth: 1,
  114. backgroundColor:
  115. Highcharts.defaultOptions.legend.backgroundColor || '#000',
  116. shadow: true
  117. },
  118. credits: {
  119. enabled: false
  120. },
  121. series: [
  122. {
  123. name: 'Berdasarkan Capaian Hasil',
  124. data: [
  125. <?php
  126. $jumlahdata = \App\Model\Inspeksi\Inspeksi::count();
  127. ?>
  128. {{$jumlahdata}},
  129. {{number_format($capaian, 2)}},
  130. ]
  131. },
  132. ]
  133. });
  134. </script>
  135. <script>
  136. Highcharts.chart('inspeksi-hasil', {
  137. chart: {
  138. type: 'bar'
  139. },
  140. title:false,
  141. <?php
  142. $upt = \App\Model\Setting\UPT::select('office_name','office_id')->distinct()->get();
  143. ?>
  144. xAxis: {
  145. categories: [
  146. @foreach($upt as $key => $value)
  147. '{{$value->office_name}}',
  148. @endforeach
  149. ],
  150. title: {
  151. text: null
  152. }
  153. },
  154. yAxis: {
  155. min: 0,
  156. title: {
  157. text: 'Capaian Hasil Inspeksi',
  158. align: 'high'
  159. },
  160. labels: {
  161. overflow: 'justify'
  162. }
  163. },
  164. tooltip: {
  165. valueSuffix: '%'
  166. },
  167. plotOptions: {
  168. bar: {
  169. dataLabels: {
  170. enabled: true
  171. }
  172. }
  173. },
  174. legend: {
  175. layout: 'vertical',
  176. align: 'right',
  177. verticalAlign: 'top',
  178. x: -40,
  179. y: 80,
  180. floating: true,
  181. borderWidth: 1,
  182. backgroundColor:
  183. Highcharts.defaultOptions.legend.backgroundColor || '#000',
  184. shadow: true
  185. },
  186. credits: {
  187. enabled: false
  188. },
  189. series: [
  190. {
  191. name: 'Berdasarkan Capaian Hasil',
  192. data: [
  193. @foreach($upt as $key => $value)
  194. <?php
  195. $date = \App\Model\Inspeksi\Inspeksi::select('tanggal_lapor')->where('kode_upt',$value->office_id)->orderBy('tanggal_lapor','desc')->first();
  196. $time=strtotime($date->tanggal_lapor);
  197. $month=date("m",$time);
  198. $year=date("Y",$time);
  199. $hi_sesuai_isr = \App\Model\Inspeksi\Inspeksi::where('status',1)->whereMonth('tanggal_lapor',$month)->whereYear('tanggal_lapor',$year)->where('kode_upt',$value->office_id)->sum('hi_sesuai_isr');
  200. $tl_sesuai_isr = \App\Model\Inspeksi\Inspeksi::where('status',1)->whereMonth('tanggal_lapor',$month)->whereYear('tanggal_lapor',$year)->where('kode_upt',$value->office_id)->sum('tl_sesuai_isr');
  201. $data_sampling = \App\Model\Inspeksi\Inspeksi::where('status',1)->whereMonth('tanggal_lapor',$month)->whereYear('tanggal_lapor',$year)->where('kode_upt',$value->office_id)->sum('data_sampling');
  202. if($data_sampling == 0){
  203. $capaian = 0;
  204. }else{
  205. $capaian = ( $hi_sesuai_isr + $tl_sesuai_isr ) / ($data_sampling) * 100;
  206. }
  207. if ($capaian >= 100) {
  208. $capaian = 100;
  209. }
  210. ?>
  211. {{number_format($capaian, 2)}},
  212. @endforeach
  213. ]
  214. },
  215. ]
  216. });
  217. </script>
  218. <?php
  219. $getUptName = \App\Model\Setting\UPT::where('office_id',Auth::user()->upt)->select('office_name')->distinct()->value('office_name');
  220. $getStatus = \App\Model\Privillage\Role::where('id',Auth::user()->role_id)->value('akses');
  221. ?>
  222. @if($getStatus != 'administator')
  223. <script>
  224. Highcharts.chart('inspeksi-kegiatan-operator', {
  225. chart: {
  226. type: 'bar'
  227. },
  228. title:false,
  229. xAxis: {
  230. categories: [
  231. '{{$getUptName}}',
  232. ],
  233. title: {
  234. text: null
  235. }
  236. },
  237. yAxis: {
  238. min: 0,
  239. title: {
  240. text: 'Capaian Kegiatan Inspeksi',
  241. align: 'high'
  242. },
  243. labels: {
  244. overflow: 'justify'
  245. }
  246. },
  247. tooltip: {
  248. valueSuffix: 'Kegiatan'
  249. },
  250. plotOptions: {
  251. bar: {
  252. dataLabels: {
  253. enabled: true
  254. }
  255. }
  256. },
  257. legend: {
  258. layout: 'vertical',
  259. align: 'right',
  260. verticalAlign: 'top',
  261. x: -40,
  262. y: 80,
  263. floating: true,
  264. borderWidth: 1,
  265. backgroundColor:
  266. Highcharts.defaultOptions.legend.backgroundColor || '#000',
  267. shadow: true
  268. },
  269. credits: {
  270. enabled: false
  271. },
  272. series: [
  273. {
  274. name: 'Total Kegiatan Inspeksi',
  275. data: [
  276. {{\App\Model\Inspeksi\Inspeksi::where('kode_upt',Auth::user()->upt)->count()}},
  277. ]
  278. },
  279. ]
  280. });
  281. </script>
  282. <script>
  283. Highcharts.chart('inspeksi-hasil-operator', {
  284. chart: {
  285. type: 'bar'
  286. },
  287. title:false,
  288. xAxis: {
  289. categories: [
  290. '{{$getUptName}}',
  291. ],
  292. title: {
  293. text: null
  294. }
  295. },
  296. yAxis: {
  297. min: 0,
  298. title: {
  299. text: 'Capaian Hasil Inspeksi',
  300. align: 'high'
  301. },
  302. labels: {
  303. overflow: 'justify'
  304. }
  305. },
  306. tooltip: {
  307. valueSuffix: '%'
  308. },
  309. plotOptions: {
  310. bar: {
  311. dataLabels: {
  312. enabled: true
  313. }
  314. }
  315. },
  316. legend: {
  317. layout: 'vertical',
  318. align: 'right',
  319. verticalAlign: 'top',
  320. x: -40,
  321. y: 80,
  322. floating: true,
  323. borderWidth: 1,
  324. backgroundColor:
  325. Highcharts.defaultOptions.legend.backgroundColor || '#000',
  326. shadow: true
  327. },
  328. credits: {
  329. enabled: false
  330. },
  331. series: [
  332. {
  333. name: 'Berdasarkan Capaian Hasil',
  334. data: [
  335. <?php
  336. $date = \App\Model\Inspeksi\Inspeksi::select('tanggal_lapor')->where('kode_upt',Auth::user()->upt)->orderBy('tanggal_lapor','desc')->first();
  337. if($date != null && $date != ""){
  338. $time=strtotime($date->tanggal_lapor);
  339. $month=date("m",$time);
  340. $year=date("Y",$time);
  341. $hi_sesuai_isr = \App\Model\Inspeksi\Inspeksi::where('status',1)->whereMonth('tanggal_lapor',$month)->whereYear('tanggal_lapor',$year)->where('kode_upt',Auth::user()->upt)->sum('hi_sesuai_isr');
  342. $tl_sesuai_isr = \App\Model\Inspeksi\Inspeksi::where('status',1)->whereMonth('tanggal_lapor',$month)->whereYear('tanggal_lapor',$year)->where('kode_upt',Auth::user()->upt)->sum('tl_sesuai_isr');
  343. $data_sampling = \App\Model\Inspeksi\Inspeksi::where('status',1)->whereMonth('tanggal_lapor',$month)->whereYear('tanggal_lapor',$year)->where('kode_upt',Auth::user()->upt)->sum('data_sampling');
  344. if($data_sampling == 0){
  345. $calculationData = 0;
  346. }else{
  347. $calculationData = ( $hi_sesuai_isr + $tl_sesuai_isr ) / ($data_sampling) * 100;
  348. }
  349. if ($calculationData >= 100) {
  350. $calculationData = 100;
  351. }
  352. }else{
  353. $calculationData = 0;
  354. }
  355. ?>
  356. {{number_format($calculationData, 2)}},
  357. ]
  358. },
  359. ]
  360. });
  361. </script>
  362. @endif
  363. <script type="text/javascript">
  364. var map = am4core.create("chartdiv", am4maps.MapChart);
  365. </script>
  366. <script type="text/javascript">
  367. $('form#inspeksi-save').submit(function(event) {
  368. var data_sampling = parseInt($('#data_sampling').val());
  369. var hi_sesuai_isr = parseInt($('#hi_sesuai_isr').val());
  370. var hi_proses_isr = parseInt($('#hi_proses_isr').val());
  371. var hi_tidak_aktif = parseInt($('#hi_tidak_aktif').val());
  372. var hi_tidak_sesuai_isr = parseInt($('#hi_tidak_sesuai_isr').val());
  373. var jumlah_hi = parseInt(hi_sesuai_isr + hi_proses_isr + hi_tidak_aktif + hi_tidak_sesuai_isr);
  374. if (jumlah_hi > data_sampling) {
  375. $("#data_sampling").addClass("is-invalid");
  376. $("#data_sampling").focus();
  377. return false;
  378. }
  379. else {
  380. $("#data_sampling").removeClass("is-invalid");
  381. return true;
  382. }
  383. });
  384. $('#data_sampling').keydown(function(event) {
  385. $("#data_sampling").removeClass("is-invalid");
  386. });
  387. </script>