DashboardController.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <?php
  2. namespace App\Http\Controllers\Core;
  3. use App\Http\Controllers\Controller;
  4. use Illuminate\Support\Facades\Crypt;
  5. use Illuminate\Http\Request;
  6. use App\Model\Privillage\Role;
  7. use App\Model\Inspeksi\Inspeksi;
  8. use Auth;
  9. use Session;
  10. use App\Model\UPTSModel;
  11. use Yajra\DataTables\Facades\DataTables;
  12. class DashboardController extends Controller
  13. {
  14. public function __construct()
  15. {
  16. $this->middleware('auth');
  17. }
  18. public function index(){
  19. $year = date('Y');
  20. if (Role::where('id',Auth::user()->role_id)->value('akses') == 'administrator') {
  21. //SPP
  22. $rt_paid = \App\Model\SPP\RincianTagihan::where('status','paid')->where('status_izin','Perpanjangan')->where('bi_type',8)->whereYear('bi_begin',$year)->count();
  23. $total_rt = \App\Model\SPP\RincianTagihan::where('status_izin','Perpanjangan')->whereYear('bi_begin',$year)->count();
  24. if ($total_rt == 0) {
  25. $rt_presentation = 0;
  26. }else{
  27. $rt_presentation = $rt_paid / $total_rt * 100;
  28. }
  29. $st_paid = \App\Model\SPP\StatusTagihan::where('status','paid')->where('status_izin','Perpanjangan')->whereYear('bi_create_date',$year)->count();
  30. $total_st = \App\Model\SPP\StatusTagihan::where('status_izin','Perpanjangan')->whereYear('bi_create_date',$year)->count();
  31. if ($total_st == 0) {
  32. $st_presentation = 0;
  33. }else{
  34. $st_presentation = $st_paid / $total_st * 100;
  35. }
  36. //Loket Pelayanan
  37. $open = \App\Model\Service\LoketPengaduan::where('active',1)->where('tujuan',1)->count();
  38. $reopen = \App\Model\Service\LoketPengaduan::where('active',3)->where('tujuan',1)->count();
  39. $fixOpen = $open + $reopen;
  40. $closed = \App\Model\Service\LoketPengaduan::where('active',0)->where('tujuan',1)->count();
  41. $totalpengaduan = \App\Model\Service\LoketPengaduan::where('tujuan',1)->count();
  42. if ($closed <= 0) {
  43. $loketpengaduanpercent = 0;
  44. }else{
  45. $loketpengaduanpercent = $closed / $totalpengaduan * 100;
  46. }
  47. //SosialisasiBimtek
  48. $terealisasi = \App\Model\SosialisasiBimtek\MonevSosialisasi::whereNotNull('id_rensos')->count();
  49. $blm = \App\Model\SosialisasiBimtek\RencanaSosialisasi::count();
  50. if ($blm == 0) {
  51. $total_sosialisasi = 0;
  52. }else{
  53. $total_sosialisasi = $terealisasi / $blm * 100;
  54. if($total_sosialisasi >= 100){
  55. $total_sosialisasi = 100;
  56. }
  57. }
  58. //UNAR
  59. $total_unar = \App\Model\Service\Unar::where('full_cat',1)->count();
  60. $tahun_sekarang = date('Y');
  61. $rencana_unar = \App\RencanaUnar::where('tahun',$tahun_sekarang)->value('jumlah');
  62. $getUptUnar = \App\Model\Setting\UPT::distinct('office_id')->count();
  63. $rencana_unar_fix = $rencana_unar * $getUptUnar;
  64. if ($rencana_unar_fix == 0) {
  65. $unarpercent = 0;
  66. }elseif($total_unar >= $rencana_unar){
  67. $unarpercent = 100;
  68. }
  69. else{
  70. $unarpercent = $total_unar / $rencana_unar_fix * 100;
  71. }
  72. //Penanganan Piutang
  73. $petang_psbdt = \App\Model\Service\PenangananPiutang::where('tahapan_pengurusan','PSBDT')->count();
  74. $petang_lunas = \App\Model\Service\PenangananPiutang::where('tahapan_pengurusan','Lunas (SPPNL)')->count();
  75. $petang_pengembalian = \App\Model\Service\PenangananPiutang::where('tahapan_pengurusan','Pengembalian')->count();
  76. $petang_pembatalan = \App\Model\Service\PenangananPiutang::where('tahapan_pengurusan','Pembatalan')->count();
  77. $petang_data = \App\Model\Service\PenangananPiutang::count();
  78. if ($petang_data <= 0) {
  79. $petang = 0;
  80. }else{
  81. $petang = ($petang_psbdt + $petang_lunas + $petang_pengembalian + $petang_pembatalan) / ($petang_data) * 100;
  82. }
  83. //Inspeksi
  84. $date = Inspeksi::select('tanggal_lapor')->where('status',1)->orderBy('tanggal_lapor','desc')->first();
  85. if (!$date) {
  86. $month=date("m");
  87. $year=date("Y");
  88. }else{
  89. $time=strtotime($date->tanggal_lapor);
  90. $month=date("m",$time);
  91. $year=date("Y",$time);
  92. }
  93. $hi_sesuai_isr = Inspeksi::where('status',1)->whereMonth('tanggal_lapor',$month)->whereYear('tanggal_lapor',$year)->sum('hi_sesuai_isr');
  94. $tl_sesuai_isr = Inspeksi::where('status',1)->whereMonth('tanggal_lapor',$month)->whereYear('tanggal_lapor',$year)->sum('tl_sesuai_isr');
  95. $data_sampling = Inspeksi::where('status',1)->whereMonth('tanggal_lapor',$month)->whereYear('tanggal_lapor',$year)->sum('data_sampling');
  96. if($data_sampling == 0){
  97. $total_inspeksi = 0;
  98. }else{
  99. $total_inspeksi = ( $hi_sesuai_isr + $tl_sesuai_isr ) / ($data_sampling) * 100;
  100. }
  101. if ($total_inspeksi >= 100) {
  102. $total_inspeksi = 100;
  103. }
  104. }else{
  105. //SPP
  106. $getUptName = \App\Model\Setting\UPT::where('office_id',Auth::user()->upt)->select('office_name')->distinct()->value('office_name');
  107. $rt_paid = \App\Model\SPP\RincianTagihan::where('status','paid')->where('status_izin','Perpanjangan')->where('upt',$getUptName)->where('bi_type',8)->whereYear('bi_begin',$year)->count();
  108. $total_rt = \App\Model\SPP\RincianTagihan::where('status_izin','Perpanjangan')->whereYear('bi_begin',$year)->where('upt',$getUptName)->count();
  109. if ($total_rt == 0) {
  110. $rt_presentation = 0;
  111. }else{
  112. $rt_presentation = $rt_paid / $total_rt * 100;
  113. }
  114. $st_paid = \App\Model\SPP\StatusTagihan::where('status_izin','Perpanjangan')->where('status','paid')->whereYear('bi_create_date',$year)->where('upt',$getUptName)->count();
  115. $total_st = \App\Model\SPP\StatusTagihan::where('status_izin','Perpanjangan')->whereYear('bi_create_date',$year)->where('upt',$getUptName)->count();
  116. if ($total_st == 0) {
  117. $st_presentation = 0;
  118. }else{
  119. $st_presentation = $st_paid / $total_st * 100;
  120. }
  121. //Loket Pelayanan
  122. $open = \App\Model\Service\LoketPengaduan::where('active',1)->where('tujuan',1)->where('kode_upt',Auth::user()->upt)->count();
  123. $reopen = \App\Model\Service\LoketPengaduan::where('active',3)->where('tujuan',1)->where('kode_upt',Auth::user()->upt)->count();
  124. $fixOpen = $open + $reopen;
  125. $closed = \App\Model\Service\LoketPengaduan::where('active',0)->where('tujuan',1)->where('kode_upt',Auth::user()->upt)->count();
  126. $totalpengaduan = \App\Model\Service\LoketPengaduan::where('tujuan',1)->where('kode_upt',Auth::user()->upt)->count();
  127. if ($closed <= 0) {
  128. $loketpengaduanpercent = 0;
  129. }else{
  130. $loketpengaduanpercent = $closed / $totalpengaduan * 100;
  131. }
  132. //SosialisasiBimtek
  133. $terealisasi = \App\Model\SosialisasiBimtek\MonevSosialisasi::whereNotNull('id_rensos')->where('kode_upt',Auth::user()->upt)->count();
  134. $blm = \App\Model\SosialisasiBimtek\RencanaSosialisasi::where('kode_upt',Auth::user()->upt)->count();
  135. if ($blm == 0) {
  136. $total_sosialisasi = 0;
  137. }else{
  138. $total_sosialisasi = $terealisasi / $blm * 100;
  139. if($total_sosialisasi >= 100){
  140. $total_sosialisasi = 100;
  141. }
  142. }
  143. //UNAR
  144. $total_unar = \App\Model\Service\Unar::where('full_cat',1)->where('kode_upt',Auth::user()->upt)->count();
  145. $tahun_sekarang = date('Y');
  146. $rencana_unar = \App\RencanaUnar::where('tahun',$tahun_sekarang)->value('jumlah');
  147. $getUptUnar = \App\Model\Setting\UPT::where('office_id',Auth::user()->upt)->distinct('office_id')->count();
  148. $rencana_unar_fix = $rencana_unar * $getUptUnar;
  149. if ($rencana_unar_fix == 0) {
  150. $unarpercent = 0;
  151. }elseif($total_unar >= $rencana_unar){
  152. $unarpercent = 100;
  153. }
  154. else{
  155. $unarpercent = $total_unar / $rencana_unar_fix * 100;
  156. }
  157. //Inspeksi
  158. $date = Inspeksi::select('tanggal_lapor')->where('kode_upt',Auth::user()->upt)->orderBy('tanggal_lapor','desc')->first();
  159. $time=strtotime($date->tanggal_lapor);
  160. $month=date("m",$time);
  161. $year=date("Y",$time);
  162. $hi_sesuai_isr = Inspeksi::where('status',1)->where('kode_upt',Auth::user()->upt)->whereMonth('tanggal_lapor',$month)->whereYear('tanggal_lapor',$year)->sum('hi_sesuai_isr');
  163. $tl_sesuai_isr = Inspeksi::where('status',1)->where('kode_upt',Auth::user()->upt)->whereMonth('tanggal_lapor',$month)->whereYear('tanggal_lapor',$year)->sum('tl_sesuai_isr');
  164. $data_sampling = Inspeksi::where('status',1)->where('kode_upt',Auth::user()->upt)->whereMonth('tanggal_lapor',$month)->whereYear('tanggal_lapor',$year)->sum('data_sampling');
  165. if($data_sampling == 0){
  166. $total_inspeksi = 0;
  167. }else{
  168. $total_inspeksi = ( $hi_sesuai_isr + $tl_sesuai_isr ) / ($data_sampling) * 100;
  169. }
  170. if ($total_inspeksi >= 100) {
  171. $total_inspeksi = 100;
  172. }
  173. // $jumlahdata = \App\Model\Inspeksi\Inspeksi::where('kode_upt',Auth::user()->upt)->count();
  174. // $capaian = \App\Model\Inspeksi\Inspeksi::where('kode_upt',Auth::user()->upt)->where('status',1)->sum('capaian_valid');
  175. // if ($capaian == 0) {
  176. // $total_inspeksi = 0;
  177. // }else{
  178. // $total_inspeksi = $capaian / $jumlahdata;
  179. // }
  180. // $data_sampling = Inspeksi::where('kode_upt',Auth::user()->upt)->where('status',1)->sum('data_sampling');
  181. // $hi_sesuai_isr = Inspeksi::where('kode_upt',Auth::user()->upt)->where('status',1)->sum('hi_sesuai_isr');
  182. // $tl_sesuai_isr = Inspeksi::where('kode_upt',Auth::user()->upt)->where('status',1)->sum('tl_sesuai_isr');
  183. // $capaian = \App\Model\Inspeksi\Inspeksi::where('status',1)->sum('capaian_valid');
  184. // if($data_sampling == 0)
  185. // $total_inspeksi = 0;
  186. // else{
  187. // $total_inspeksi = ( $hi_sesuai_isr + $tl_sesuai_isr ) / ($data_sampling) * 100;
  188. // }
  189. //Penanganan Piutang
  190. $petang_psbdt = \App\Model\Service\PenangananPiutang::where('tahapan_pengurusan','PSBDT')->where('kode_upt',Auth::user()->upt)->count();
  191. $petang_lunas = \App\Model\Service\PenangananPiutang::where('tahapan_pengurusan','Lunas (SPPNL)')->where('kode_upt',Auth::user()->upt)->count();
  192. $petang_pengembalian = \App\Model\Service\PenangananPiutang::where('tahapan_pengurusan','Pengembalian')->where('kode_upt',Auth::user()->upt)->count();
  193. $petang_pembatalan = \App\Model\Service\PenangananPiutang::where('tahapan_pengurusan','Pembatalan')->where('kode_upt',Auth::user()->upt)->count();
  194. $petang_data = \App\Model\Service\PenangananPiutang::where('kode_upt',Auth::user()->upt)->count();
  195. if ($petang_data <= 0) {
  196. $petang = 0;
  197. }else{
  198. $petang = ($petang_psbdt + $petang_lunas + $petang_pengembalian + $petang_pembatalan) / ($petang_data) * 100;
  199. }
  200. }
  201. $id_bulan = 'Dashboard ' . date('Y');
  202. return view('welcome',compact('loketpengaduanpercent','total_sosialisasi','unarpercent','total_inspeksi','id_bulan','petang','rt_presentation','st_presentation'));
  203. }
  204. public function searchByMonth(Request $request){
  205. $years = date('Y');
  206. if ($request->id_bulan == 1) {
  207. $bulan = 12;
  208. $year = $years - 1;
  209. }
  210. else{
  211. $bulan = $request->id_bulan - 1;
  212. $year = $years;
  213. }
  214. if (Role::where('id',Auth::user()->role_id)->value('akses') == 'administrator') {
  215. //SPP
  216. $rt_paid = \App\Model\SPP\RincianTagihan::where('status','paid')->where('status_izin','Perpanjangan')->where('bi_type',8)->whereMonth('bi_begin',$bulan)->whereYear('bi_begin',$year)->count();
  217. $total_rt = \App\Model\SPP\RincianTagihan::where('status_izin','Perpanjangan')->whereMonth('bi_begin',$bulan)->whereYear('bi_begin',$year)->count();
  218. if ($total_rt == 0) {
  219. $rt_presentation = 0;
  220. }else{
  221. $rt_presentation = $rt_paid / $total_rt * 100;
  222. }
  223. $st_paid = \App\Model\SPP\StatusTagihan::where('status','paid')->where('status_izin','Perpanjangan')->whereMonth('bi_create_date',$bulan)->whereYear('bi_create_date',$year)->count();
  224. $total_st = \App\Model\SPP\StatusTagihan::where('status_izin','Perpanjangan')->whereMonth('bi_create_date',$bulan)->whereYear('bi_create_date',$year)->count();
  225. if ($total_st == 0) {
  226. $st_presentation = 0;
  227. }else{
  228. $st_presentation = $st_paid / $total_st * 100;
  229. }
  230. //Loket Pelayanan
  231. $open = \App\Model\Service\LoketPengaduan::where('active',1)->whereMonth('tanggal_pelayanan',$request->id_bulan)->whereYear('tanggal_pelayanan',$year)->where('tujuan',1)->count();
  232. $reopen = \App\Model\Service\LoketPengaduan::where('active',3)->whereMonth('tanggal_pelayanan',$request->id_bulan)->where('tujuan',1)->whereYear('tanggal_pelayanan',$year)->count();
  233. $fixOpen = $open + $reopen;
  234. $closed = \App\Model\Service\LoketPengaduan::where('active',0)->whereMonth('tanggal_pelayanan',$request->id_bulan)->whereYear('tanggal_pelayanan',$year)->where('tujuan',1)->count();
  235. $totalpengaduan = \App\Model\Service\LoketPengaduan::where('tujuan',1)->whereMonth('tanggal_pelayanan',$request->id_bulan)->whereYear('tanggal_pelayanan',$year)->count();
  236. if ($closed <= 0) {
  237. $loketpengaduanpercent = 0;
  238. }else{
  239. $loketpengaduanpercent = $closed / $totalpengaduan * 100;
  240. }
  241. //SosialisasiBimtek
  242. $terealisasi = \App\Model\SosialisasiBimtek\MonevSosialisasi::whereNotNull('id_rensos')->whereMonth('tanggal_pelaksanaan',$request->id_bulan)->whereYear('tanggal_pelaksanaan',$year)->count();
  243. $blm = \App\Model\SosialisasiBimtek\RencanaSosialisasi::whereMonth('tanggal_pelaksanaan',$request->id_bulan)->whereYear('tanggal_pelaksanaan',$year)->count();
  244. if ($blm == 0) {
  245. $total_sosialisasi = 0;
  246. }else{
  247. $total_sosialisasi = $terealisasi / $blm * 100;
  248. }
  249. //UNAR
  250. $total_unar = \App\Model\Service\Unar::where('full_cat',1)->whereMonth('tanggal_ujian',$request->id_bulan)->whereYear('tanggal_ujian',$year)->count();
  251. $tahun_sekarang = date('Y');
  252. $rencana_unar = \App\RencanaUnar::where('tahun',$tahun_sekarang)->value('jumlah');
  253. if ($rencana_unar == 0) {
  254. $unarpercent = 0;
  255. }elseif($total_unar >= $rencana_unar){
  256. $unarpercent = 100;
  257. }
  258. else{
  259. $unarpercent = $total_unar / $rencana_unar * 100;
  260. }
  261. //Penanganan Piutang
  262. $petang_psbdt = \App\Model\Service\PenangananPiutang::where('tahapan_pengurusan','PSBDT')->whereMonth('tanggal',$request->id_bulan)->whereYear('tanggal',$year)->count();
  263. $petang_lunas = \App\Model\Service\PenangananPiutang::where('tahapan_pengurusan','Lunas (SPPNL)')->whereMonth('tanggal',$request->id_bulan)->whereYear('tanggal',$year)->count();
  264. $petang_data = \App\Model\Service\PenangananPiutang::where('kode_upt',Auth::user()->upt)->whereMonth('tanggal',$request->id_bulan)->whereYear('tanggal',$year)->count();
  265. if ($petang_data <= 0) {
  266. $petang = 0;
  267. }else{
  268. $petang = ($petang_psbdt + $petang_lunas ) / ($petang_data) * 100;
  269. }
  270. //Inspeksi
  271. $jumlahdata = \App\Model\Inspeksi\Inspeksi::whereMonth('tanggal_lapor',$request->id_bulan)->whereYear('tanggal_lapor',$year)->count();
  272. $capaian = \App\Model\Inspeksi\Inspeksi::where('status',1)->whereMonth('tanggal_lapor',$request->id_bulan)->whereYear('tanggal_lapor',$year)->sum('capaian_valid');
  273. if ($capaian == 0) {
  274. $total_inspeksi = 0;
  275. }else{
  276. $total_inspeksi = $capaian / $jumlahdata;
  277. }
  278. }else{
  279. //SPP
  280. $getUptName = \App\Model\Setting\UPT::where('office_id',Auth::user()->upt)->select('office_name')->distinct()->value('office_name');
  281. $rt_paid = \App\Model\SPP\RincianTagihan::where('status','paid')->where('status_izin','Perpanjangan')->where('upt',$getUptName)->where('bi_type',8)->whereMonth('bi_begin',$bulan)->whereYear('bi_begin',$year)->count();
  282. $total_rt = \App\Model\SPP\RincianTagihan::where('status_izin','Perpanjangan')->where('upt',$getUptName)->whereMonth('bi_begin',$bulan)->whereYear('bi_begin',$year)->count();
  283. if ($total_rt == 0) {
  284. $rt_presentation = 0;
  285. }else{
  286. $rt_presentation = $rt_paid / $total_rt * 100;
  287. }
  288. $st_paid = \App\Model\SPP\StatusTagihan::where('status','paid')->where('status_izin','Perpanjangan')->where('upt',$getUptName)->whereMonth('bi_create_date',$bulan)->whereYear('bi_create_date',$year)->count();
  289. $total_st = \App\Model\SPP\StatusTagihan::where('status_izin','Perpanjangan')->where('upt',$getUptName)->whereMonth('bi_create_date',$bulan)->whereYear('bi_create_date',$year)->count();
  290. if ($total_st == 0) {
  291. $st_presentation = 0;
  292. }else{
  293. $st_presentation = $st_paid / $total_st * 100;
  294. }
  295. //Loket Pelayanan
  296. $open = \App\Model\Service\LoketPengaduan::where('active',1)->whereMonth('tanggal_pelayanan',$request->id_bulan)->whereYear('tanggal_pelayanan',$year)->where('tujuan',1)->where('kode_upt',Auth::user()->upt)->count();
  297. $reopen = \App\Model\Service\LoketPengaduan::where('active',3)->whereMonth('tanggal_pelayanan',$request->id_bulan)->whereYear('tanggal_pelayanan',$year)->where('tujuan',1)->where('kode_upt',Auth::user()->upt)->count();
  298. $fixOpen = $open + $reopen;
  299. $closed = \App\Model\Service\LoketPengaduan::where('active',0)->whereMonth('tanggal_pelayanan',$request->id_bulan)->whereYear('tanggal_pelayanan',$year)->where('tujuan',1)->where('kode_upt',Auth::user()->upt)->count();
  300. $totalpengaduan = \App\Model\Service\LoketPengaduan::where('tujuan',1)->whereMonth('tanggal_pelayanan',$request->id_bulan)->whereYear('tanggal_pelayanan',$year)->where('kode_upt',Auth::user()->upt)->count();
  301. if ($closed <= 0) {
  302. $loketpengaduanpercent = 0;
  303. }else{
  304. $loketpengaduanpercent = $closed / $totalpengaduan * 100;
  305. }
  306. //SosialisasiBimtek
  307. $terealisasi = \App\Model\SosialisasiBimtek\MonevSosialisasi::whereNotNull('id_rensos')->whereMonth('tanggal_pelaksanaan',$request->id_bulan)->whereYear('tanggal_pelaksanaan',$year)->where('kode_upt',Auth::user()->upt)->count();
  308. $blm = \App\Model\SosialisasiBimtek\RencanaSosialisasi::where('kode_upt',Auth::user()->upt)->whereMonth('tanggal_pelaksanaan',$request->id_bulan)->whereYear('tanggal_pelaksanaan',$year)->count();
  309. if ($blm == 0) {
  310. $total_sosialisasi = 0;
  311. }else{
  312. $total_sosialisasi = $terealisasi / $blm * 100;
  313. }
  314. //UNAR
  315. $total_unar = \App\Model\Service\Unar::where('full_cat',1)->whereMonth('tanggal_ujian',$request->id_bulan)->whereYear('tanggal_ujian',$year)->where('kode_upt',Auth::user()->upt)->count();
  316. $tahun_sekarang = date('Y');
  317. $rencana_unar = \App\RencanaUnar::where('tahun',$tahun_sekarang)->value('jumlah');
  318. if ($rencana_unar == 0) {
  319. $unarpercent = 0;
  320. }elseif($total_unar >= $rencana_unar){
  321. $unarpercent = 100;
  322. }
  323. else{
  324. $unarpercent = $total_unar / $rencana_unar * 100;
  325. }
  326. //Inspeksi
  327. $jumlahdata = \App\Model\Inspeksi\Inspeksi::where('kode_upt',Auth::user()->upt)->whereMonth('tanggal_lapor',$request->id_bulan)->whereYear('tanggal_lapor',$year)->count();
  328. $capaian = \App\Model\Inspeksi\Inspeksi::where('kode_upt',Auth::user()->upt)->where('status',1)->whereMonth('tanggal_lapor',$request->id_bulan)->whereYear('tanggal_lapor',$year)->sum('capaian_valid');
  329. if ($capaian == 0) {
  330. $total_inspeksi = 0;
  331. }else{
  332. $total_inspeksi = $capaian / $jumlahdata;
  333. }
  334. //Penanagnan Piutang
  335. $petang_psbdt = \App\Model\Service\PenangananPiutang::where('tahapan_pengurusan','PSBDT')->whereMonth('tanggal',$request->id_bulan)->whereYear('tanggal',$year)->where('kode_upt',Auth::user()->upt)->count();
  336. $petang_lunas = \App\Model\Service\PenangananPiutang::where('tahapan_pengurusan','Lunas (SPPNL)')->whereMonth('tanggal',$request->id_bulan)->whereYear('tanggal',$year)->where('kode_upt',Auth::user()->upt)->count();
  337. $petang_data = \App\Model\Service\PenangananPiutang::where('kode_upt',Auth::user()->upt)->whereMonth('tanggal',$request->id_bulan)->whereYear('tanggal',$year)->count();
  338. if ($petang_data <= 0) {
  339. $petang = 0;
  340. }else{
  341. $petang = ($petang_psbdt + $petang_lunas ) / ($petang_data) * 100;
  342. }
  343. }
  344. $id_bulan = 'Dashboard Bulan ' . \App\Model\Date\ListMonth::where('id_bulan',$request->id_bulan)->value('nama') . ' ' . date('Y');
  345. return view('welcome',compact('loketpengaduanpercent','total_sosialisasi','unarpercent','total_inspeksi','id_bulan','petang','rt_presentation','st_presentation'));
  346. }
  347. public function ubah_password(){
  348. return view('dev.core.password');
  349. }
  350. public function post_password(Request $request){
  351. $password = \App\User::find(Auth::user()->id);
  352. $password->password = bcrypt($request->kata_sandi);
  353. $password->save();
  354. Session::flash('info', 'Kata Sandi');
  355. Session::flash('colors', 'green');
  356. Session::flash('icons', 'fas fa-clipboard-check');
  357. Session::flash('alert', 'Berhasil Mengubah Kata Sandi, Silahkan Login Ulang!');
  358. return redirect(route('logout'));
  359. }
  360. public function surveyLink(){
  361. return view('dev.helpers.survey');
  362. }
  363. public function postSurveyLink(Request $request){
  364. $link = \App\SurveyLink::where('id',1)->update([
  365. 'link' => $request->link
  366. ]);
  367. Session::flash('info', 'Survey Link');
  368. Session::flash('colors', 'green');
  369. Session::flash('icons', 'fas fa-clipboard-check');
  370. Session::flash('alert', 'Berhasil Mengubah Link');
  371. return redirect()->back();
  372. }
  373. public function getUpts(){
  374. $upts = new UPTSModel();
  375. $data = $upts->getData();
  376. return DataTables::of($data)->make(true);
  377. }
  378. public function newDashboard(){
  379. return view('new-dashboard');
  380. }
  381. }