@@ -256,8 +256,9 @@ public static function setOptions($collection, $value, $label, $group = '')
256256 * @param string $derajat
257257 * @return array nomor, nomor_urut, segmen
258258 */
259- public static function nomor ($ tanggal , $ tahun , $ jenis_naskah_id , $ unit_kerja_id , $ kode_arsip_id , $ derajat )
259+ public static function nomor ($ tanggal , $ jenis_naskah_id , $ unit_kerja_id , $ kode_arsip_id , $ derajat )
260260 {
261+ $ tahun = Carbon::createFromFormat ('Y-m-d ' , $ tanggal ->format ('Y-m-d ' ))->year ;
261262 $ jenis_naskah = JenisNaskah::cache ()->get ('all ' )->where ('id ' , $ jenis_naskah_id )->first ();
262263 $ kode_naskah = KodeNaskah::cache ()->get ('all ' )->where ('id ' , $ jenis_naskah ->kode_naskah_id )->first ();
263264 $ unit_kerja = UnitKerja::cache ()->get ('all ' )->where ('id ' , $ unit_kerja_id )->first ();
@@ -276,8 +277,8 @@ public static function nomor($tanggal, $tahun, $jenis_naskah_id, $unit_kerja_id,
276277 }
277278 $ format = $ jenis_naskah ->format ?? $ kode_naskah ->format ;
278279 $ replaces ['<tahun> ' ] = $ tahun ;
279- $ replaces ['<unit_kerja_id > ' ] = $ unit_kerja ->kode ;
280- $ replaces ['<kode_arsip_id > ' ] = $ kode_arsip ->kode ;
280+ $ replaces ['<kode_unit_kerja > ' ] = $ unit_kerja ->kode ;
281+ $ replaces ['<kode_arsip > ' ] = $ kode_arsip ->kode ;
281282 $ replaces ['<derajat> ' ] = $ derajat ;
282283 $ nomor = strtr ($ format , $ replaces );
283284
@@ -613,4 +614,105 @@ public static function getSbml($tahun, $bulan, $jenis)
613614
614615 return $ nilai ;
615616 }
617+
618+ /**
619+ * Mengubah tanggal ke nama hari.
620+ *
621+ * @param Date $tanggal
622+ * @return string
623+ */
624+ public static function terbilangHari ($ tanggal )
625+ {
626+ $ tanggal = $ tanggal ->format ('Y-m-d ' );
627+ $ hari = ['Senin ' , 'Selasa ' , 'Rabu ' , 'Kamis ' , 'Jumat ' , 'Sabtu ' , 'Minggu ' ];
628+ $ num = date ('N ' , strtotime ($ tanggal ));
629+
630+ return $ hari [$ num - 1 ];
631+ }
632+
633+ /**
634+ * Mengubah bulan ke nama bulan.
635+ *
636+ * @param Int $bulan
637+ * @return string
638+ */
639+ public static function terbilangBulan ($ bulan )
640+ {
641+ return self ::$ bulan [$ bulan ];
642+ }
643+
644+ /**
645+ * Mengubah angka ke rupiah.
646+ *
647+ * @param int|float $angka
648+ * @return string
649+ */
650+ public static function formatRupiah ($ angka )
651+ {
652+ $ hasil = 'Rp. ' .self ::formatUang ($ angka );
653+
654+ return $ hasil ;
655+ }
656+
657+ /**
658+ * Upper case nama tanpa gelar
659+ *
660+ * @param string $nama
661+ * @return string
662+ */
663+ public static function upperNamaTanpaGelar ($ nama )
664+ {
665+ $ hasil = explode (', ' , $ nama )[0 ];
666+
667+ return strtoupper ($ hasil );
668+ }
669+
670+
671+ /**
672+ * Mengubah angka ke format uang.
673+ *
674+ * @param int|float $angka
675+ * @return string
676+ */
677+ public static function formatUang ($ angka )
678+ {
679+ $ hasil = number_format ($ angka , 0 , ', ' , '. ' );
680+
681+ return $ hasil ;
682+ }
683+
684+ /**
685+ * Generate jangka waktu.
686+ *
687+ * @param DateTime $awal
688+ * @param DateTime $akhir
689+ * @return string
690+ */
691+ public static function jangkaWaktuHariKalender ($ awal , $ akhir )
692+ {
693+ $ selisih = ($ awal ->diff ($ akhir ))->format ('%a ' ) + 1 ;
694+
695+ return $ selisih .' ( ' .self ::terbilang ($ selisih ).') Hari Kalender ' ;
696+ }
697+
698+ /**
699+ * Format tampilan spesifikasi.
700+ *
701+ * @param array $spesifikasi
702+ * @return array
703+ */
704+ public static function formatSpek ($ spesifikasi )
705+ {
706+ // $speks= json_decode($spesifikasi,true);
707+ $ spek = collect ($ spesifikasi );
708+ $ spek ->transform (function ($ item , $ index ) {
709+ $ item ['spek_no ' ] = $ index + 1 ;
710+ if (isset ($ item ['spek_harga ' ])) $ item ['spek_harga ' ] = self ::formatRupiah ($ item ['spek_harga ' ]);
711+ if (isset ($ item ['spek_nilai ' ])) $ item ['spek_nilai ' ] = self ::formatRupiah ($ item ['spek_nilai ' ]);
712+ return $ item ;
713+ })->toArray ();
714+ return $ spek ;
715+ }
716+
717+
616718}
0 commit comments