pos-gis/resources/views/export/xlsx_cetak_formula.blade.php
2024-10-07 13:13:42 +07:00

455 lines
14 KiB
PHP

@php
$d_kcp = collect(\DB::select("SELECT definition FROM user_unit_kerja where id = ".Auth::user()->unit_kerja))->first();
$penugasan = $persiapan;
if ($penugasan == "semua") {
$t_mulai = date('Y-m-d',strtotime($t_mulai));
$t_selesai = date('Y-m-d',strtotime($t_selesai));
$filter_penugasan = "";
}else{
$date_penugasan = collect(\DB::select("SELECT audit_tittle, ma.start_date, ma.end_date FROM master_audit_job maj
join master_audit_plan ma on ma.id = maj.audit_plan_id
where maj.id = ".$penugasan))->first();
$t_mulai = $date_penugasan->start_date;
$t_selesai = $date_penugasan->end_date;
$filter_penugasan = " and audit_job_id = ".$penugasan;
}
@endphp
<table>
<tr>
<td></td>
</tr>
<tr>
<td colspan="13">Penilaian Pengendalian Intern Unit Kerja</td>
</tr>
<tr>
<td colspan="13">{{$d_kcp->definition}}</td>
</tr>
<tr>
<td></td>
<td colspan="4"></td>
</tr>
<tr>
<td></td>
<td>Unit Kerja </td>
<td>: {{$d_kcp->definition}}</td>
</tr>
<tr>
<td></td>
<td>Wilayah </td>
<td>: </td>
</tr>
<tr>
<td></td>
<td>Tanggal Audit </td>
<td>: {{date('d-m-Y',strtotime($t_mulai))}} s.d. {{date('d-m-Y',strtotime($t_selesai))}}</td>
</tr>
</table>
<br>
<table>
<thead>
<tr>
<th rowspan="2">NO</th>
<th rowspan="2">FAKTOR PENILAIAN</th>
<th rowspan="2">1=Diaudit, 0= Tidak diaudit</th>
<th colspan="8">BOBOT RISIKO</th>
<th rowspan="2">SKOR KETIDAKTAAN</th>
<th rowspan="2">SKOR</th>
</tr>
<tr>
<th>R0-1</th>
<th>R0-2</th>
<th>R0-3</th>
<th>R0-4</th>
<th>R1-1</th>
<th>R1-2</th>
<th>R1-3</th>
<th>R1-4</th>
</tr>
<tr>
@for ($i = 1; $i <= 13; $i++)
<td>({{$i}})</td>
@endfor
</tr>
</thead>
@php
$d_sebab = \DB::select("SELECT * FROM reff_aspek order by code");
foreach ($d_sebab as $key => $ds) {
$count_sebab[$ds->code] = 0;
}
@endphp
@php
$t_mulai = date('Y-m-d',strtotime($t_mulai));
$t_selesai = date('Y-m-d',strtotime($t_selesai));
$d_bidang = \DB::select("SELECT DISTINCT ON (rsca.definition ) rsca.definition as bidang,rsca.id as kode_bidang,ri.bidang_ics
FROM master_audit_finding maf
join reff_sub_class_audit rsca on rsca.id = maf.id_program
join reff_ics ri on ri.id = maf.ics where finding_date >= '".$t_mulai."' and finding_date <= '".$t_selesai."'".$filter_penugasan);
$d_jum_p_loss = collect(\DB::select("SELECT sum(value_loss::int) as jum
FROM master_audit_finding maf
join reff_sub_class_audit rsca on rsca.id = maf.id_program
join reff_ics ri on ri.id = maf.ics
join reff_aspek ra on ra.id = maf.jenis_sebab
where loss = 'p' and finding_date >= '".$t_mulai."' and finding_date <= '".$t_selesai."'".$filter_penugasan))->first();
$d_jum_r_loss = collect(\DB::select("SELECT sum(value_loss::int) as jum
FROM master_audit_finding maf
join reff_sub_class_audit rsca on rsca.id = maf.id_program
join reff_ics ri on ri.id = maf.ics
join reff_aspek ra on ra.id = maf.jenis_sebab
where loss = 'r' and finding_date >= '".$t_mulai."' and finding_date <= '".$t_selesai."'".$filter_penugasan))->first();
$d_init_bobot = \DB::select("SELECT DISTINCT ON (bobot.nama) rsca.definition as bidang,rsca.id as kode_bidang,ri.bidang_ics,bobot.*
FROM master_audit_finding maf
join reff_sub_class_audit rsca on rsca.id = maf.id_program
join reff_ics ri on ri.id = maf.ics
join bobot on bobot.id = rsca.id_bobot
where finding_date >= '".$t_mulai."' and finding_date <= '".$t_selesai."'".$filter_penugasan);
$kc1 = 10;$kc2 = 2;$kc3 = 15;$kc4 = 13;
$kc5 = 3;$kc6 = 8;$kc7 = 6;$kc8 = 4;
@endphp
@if (count($d_bidang) != 0 )
<tbody>
{{-- BOBOT BIDANG --}}
@foreach ($d_init_bobot as $dib)
<tr>
<td></td>
<td>{{ $dib->nama }}</td>
<td></td>
<td>{{$dib->r01}}</td>
<td>{{$dib->r02}}</td>
<td>{{$dib->r03}}</td>
<td>{{$dib->r04}}</td>
<td>{{$dib->r11}}</td>
<td>{{$dib->r12}}</td>
<td>{{$dib->r13}}</td>
<td>{{$dib->r14}}</td>
</tr>
@endforeach
<tr>
<td></td>
<td></td>
<td></td>
<td colspan="8">JUMLAH TEMUAN</td>
<td></td>
<td></td>
</tr>
@php
$tr1=0;$tr2=0;$tr3=0;$tr4=0;
$tr5=0;$tr6=0;$tr7=0;$tr8=0;
$t_sk=0;$t_s=0;
$no = 1;
@endphp
@foreach($d_bidang as $db)
@php
$r1 = 0;$r2 = 0;$r3 = 0;$r4 = 0;
$r5 = 0;$r6 = 0;$r7 = 0;$r8 = 0;
@endphp
{{-- DATA BIDANG ISC --}}
@php
$d_isc = \DB::select("SELECT DISTINCT ON(bidang_ics) rsca.definition as bidang,ri.id as id_bidang_ics
FROM master_audit_finding maf
join reff_sub_class_audit rsca on rsca.id = maf.id_program
join reff_ics ri on ri.id = maf.ics
where rsca.id = '".$db->kode_bidang."' and finding_date >= '".$t_mulai."' and finding_date <= '".$t_selesai."' ".$filter_penugasan);
@endphp
@foreach ($d_isc as $di)
{{-- DATA --}}
@php
$data = \DB::select("SELECT maf.* ,rsca.id as kode_bidang,rsca.definition as bidang,ri.bidang_ics, ra.code as sebab_code
FROM master_audit_finding maf
join reff_sub_class_audit rsca on rsca.id = maf.id_program
join reff_ics ri on ri.id = maf.ics
join reff_aspek ra on ra.id = maf.jenis_sebab
where ri.id = '".$di->id_bidang_ics."' and finding_date >= '".$t_mulai."' and finding_date <= '".$t_selesai."'".$filter_penugasan);
@endphp
@foreach ($data as $d)
@php
$data_bobot = collect(\DB::select("select *
from reff_sub_class_audit rsca
join bobot on bobot.id = rsca.id_bobot
where rsca.id = ".$d->kode_bidang))->first();
($d->index_scoring_id == 1) ? $r1++:$r1;
($d->index_scoring_id == 2) ? $r2++:$r2;
($d->index_scoring_id == 3) ? $r3++:$r3;
($d->index_scoring_id == 4) ? $r4++:$r4;
($d->index_scoring_id == 5) ? $r5++:$r5;
($d->index_scoring_id == 6) ? $r6++:$r6;
($d->index_scoring_id == 7) ? $r7++:$r7;
($d->index_scoring_id == 8) ? $r8++:$r8;
$count_sebab[$d->sebab_code]++;
// $tr1 += $r1;
// $tr2 += $r2;
$total_per_row_stt = ($r1*$data_bobot->r01)+($r2*$data_bobot->r02)+($r3*$data_bobot->r03)+($r4*$data_bobot->r04)+
($r5*$data_bobot->r11)+($r6*$data_bobot->r12)+($r7*$data_bobot->r13)+($r8*$data_bobot->r14);
$total_per_row_skor = (1 / (count($data)+1) )*$total_per_row_stt;
@endphp
@endforeach
{{-- END DATA --}}
@endforeach
{{-- END BIDANG ISC --}}
@php
$tr1 += $r1;
$tr2 += $r2;
$tr3 += $r3;
$tr4 += $r4;
$tr5 += $r5;
$tr6 += $r6;
$tr7 += $r7;
$tr8 += $r8;
$t_sk += $total_per_row_stt;
$t_s += $total_per_row_skor;
@endphp
<tr>
<td>{{$no}}</td>
<td>{{ $db->bidang }}</td>
<td>1</td>
<td>{{$r1}}</td>
<td>{{$r2}}</td>
<td>{{$r3}}</td>
<td>{{$r4}}</td>
<td>{{$r5}}</td>
<td>{{$r6}}</td>
<td>{{$r7}}</td>
<td>{{$r8}}</td>
<td>{{$total_per_row_stt}}</td> {{-- SKOR TIDAK TAAT --}}
<td>{{$total_per_row_skor}}</td> {{-- SKOR --}}
</tr>
@php
$no++;
@endphp
@endforeach
<tr>
<td></td>
<td>Total</td>
<td>{{$no-1}}</td>
<td>{{$tr1}}</td>
<td>{{$tr2}}</td>
<td>{{$tr3}}</td>
<td>{{$tr4}}</td>
<td>{{$tr5}}</td>
<td>{{$tr6}}</td>
<td>{{$tr7}}</td>
<td>{{$tr8}}</td>
<td>{{$t_sk}}</td> {{-- SKOR TIDAK TAAT --}}
<td>{{$t_s}}</td> {{-- SKOR --}}
</tr>
</tbody>
</table>
@php
$spredikat = round((-8*log($t_s+1)+100),2);
if ( $spredikat<=50) {
$pred = "Tidak Baik";
}
elseif ($spredikat<=60) {
$pred = "Hampir Baik";
}
elseif ($spredikat<=70) {
$pred = "Baik -";
}
elseif ($spredikat<=80) {
$pred = "Baik +";
}
elseif ($spredikat<=90) {
$pred = "Lebih Baik";
}
elseif ($spredikat>90) {
$pred = "Sangat Baik";
}
@endphp
<table>
<tr><td colspan="15"></td></tr>
<tr>
<td colspan="11">SKOR PREDIKAT</td>
<td colspan="2">{{ $spredikat }}</td>
</tr>
<tr>
<td colspan="15"></td>
</tr>
<tr>
<td colspan="11">PREDIKAT</td>
<td colspan="2">{{$pred}}</td>
</tr>
<tr>
<td colspan="15"></td>
</tr>
@php
$max_sebab = max($count_sebab);
$c_sebab = 0;
@endphp
@foreach ($d_sebab as $ds_count)
@if ($count_sebab[$ds_count->code] == $max_sebab)
@php
$c_sebab++;
@endphp
@endif
@endforeach
@php
// dd($c_sebab);
if ($c_sebab == 1) {
$cc = 1;
}else {
$cc = 0;
}
@endphp
@foreach ($d_sebab as $k_sebab => $ds_table)
@if ($count_sebab[$ds_table->code] == $max_sebab)
<tr>
@if ($k_sebab == $cc)
<td colspan="2" rowspan="{{$c_sebab}}">Penyebab Kesalahan Terbesar</td>
@endif
<td colspan="4">
{{$ds_table->definition}}
</td>
@if ($k_sebab == $cc)
<td colspan="4" rowspan="{{$c_sebab}}">Dengan Jumlah</td>
<td colspan="3" rowspan="{{$c_sebab}}">{{$max_sebab}} Temuan</td>
@endif
</tr>
@endif
@endforeach
<tr>
<td colspan="15"></td>
</tr>
<tr>
<td colspan="12">JUMLAH POTENSIAL LOSS</td>
<td>{{$d_jum_p_loss->jum}}</td>
</tr>
<tr>
<td colspan="12">% probability of loss event*</td>
<td>0</td>
</tr>
<tr>
<td colspan="12">JUMLAH RIIL LOSS</td>
<td>{{$d_jum_r_loss->jum}}</td>
</tr>
<tr>
<td colspan="15"></td>
</tr>
<tr>
<td colspan="11">PENGURANG NILAI:</td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="11">1. KASUS/PELANGGARAN BERAT/FRAUD DGN NILAI KERUGIAN:</td>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="11">- T1. Fraud/Realized Loss Rp1,- sampai dengan 0,03% dari modal disetor (setara Rp1,- s.d Rp100 juta)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td colspan="11"> - T2. Fraud/Realized Loss lebih besar dari 0.03% sampai dengan 0.06% modal disetor (setara >Rp100 juta s.d Rp200 juta)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td colspan="11">- T3. Fraud/Realized Loss lebih besar dari 0.05% sampai dengan 0.14% modal disetor (setara >Rp200 juta s.d Rp500 juta)</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td colspan="11">- T4. Fraud/Realized Loss lebih besar dari 0.14% modal disetor sampai dengan seterusnya (>Rp500 juta).</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td colspan="11">2. TEMUAN BERULANG DPI (JUMLAH TEMUAN BERULANG X 0.25).</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td colspan="11">3. TEMUAN TIDAK DITINDAKLANJUTI </td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td colspan="11">SKOR AKHIR </td>
<td></td>
<td>{{$spredikat}}</td>
</tr>
<tr>
<td colspan="11">PREDIKAT </td>
<td></td>
<td>{{$pred}}</td>
</tr>
</table>
@endif