Advertisement
sigitsuryono25

Etc

Mar 26th, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.48 KB | None | 0 0
  1.  
  2. application/x-httpd-php Etc.php ( PHP script text )
  3. <?php
  4.  
  5. /*
  6. * To change this license header, choose License Headers in Project Properties.
  7. * To change this template file, choose Tools | Templates
  8. * and open the template in the editor.
  9. */
  10.  
  11. /**
  12. * Description of Etc
  13. *
  14. * @author windows8.1
  15. */
  16. class Etc extends CI_Model {
  17.  
  18. //put your code here
  19. function tarif($tipe) {
  20. $query = $this->db->query("select tarif from tarif where tipe='$tipe'");
  21. $data = $query->rows();
  22. return $data->tarif;
  23. }
  24.  
  25. function charge_mishop() {
  26. $query = $this->db->query("select tarif from tarif where tipe='charge'");
  27. $data = $query->rows();
  28. return $data->tarif;
  29. }
  30.  
  31.  
  32. function add_date($tgl){
  33. $date = date_create($tgl);
  34. date_add($date, date_interval_create_from_date_string('3 days'));
  35. return date_format($date, 'd-m-Y');
  36. }
  37.  
  38.  
  39. public function rp($angka) {
  40. $rupiah = number_format($angka, 0, ',', '.');
  41. return 'Rp ' . $rupiah;
  42. }
  43.  
  44. public function rps($angka) {
  45. $rupiah = number_format($angka, 0, ',', '.');
  46. return $rupiah;
  47. }
  48.  
  49. function bulan($tgl) {
  50. $bulan = substr($tgl, 5, 2);
  51. Switch ($bulan) {
  52. case 1 : $bulan = "Januari";
  53. Break;
  54. case 2 : $bulan = "Februari";
  55. Break;
  56. case 3 : $bulan = "Maret";
  57. Break;
  58. case 4 : $bulan = "April";
  59. Break;
  60. case 5 : $bulan = "Mei";
  61. Break;
  62. case 6 : $bulan = "Juni";
  63. Break;
  64. case 7 : $bulan = "Juli";
  65. Break;
  66. case 8 : $bulan = "Agustus";
  67. Break;
  68. case 9 : $bulan = "September";
  69. Break;
  70. case 10 : $bulan = "Oktober";
  71. Break;
  72. case 11 : $bulan = "November";
  73. Break;
  74. case 12 : $bulan = "Desember";
  75. Break;
  76. }
  77. return $bulan;
  78. }
  79.  
  80. function tgl($tgl) {
  81. $hari = substr($tgl, 8, 2);
  82. $tahun = substr($tgl, 0, 4);
  83. $nama_bulan = $this->bulan($tgl);
  84. $tgl_oke = $hari . ' ' . $nama_bulan . ' ' . $tahun;
  85. return $tgl_oke;
  86. }
  87.  
  88. function prov() {
  89. $query = $this->db->query("Select * from provinces");
  90. return $query->result();
  91. }
  92.  
  93. function kab($id) {
  94. $query = $this->db->query("Select * from regencies where province_id='$id'");
  95. return $query->result();
  96. }
  97.  
  98. public function terbilang($angka) {
  99.  
  100. $angka = (float) $angka;
  101. $bilangan = array('', 'Satu', 'Dua', 'Tiga', 'Empat', 'Lima', 'Enam', 'Tujuh', 'Delapan', 'Sembilan', 'Sepuluh', 'Sebelas');
  102.  
  103. if ($angka < 12) {
  104. return $bilangan[$angka];
  105. } else if ($angka < 20) {
  106. return $bilangan[$angka - 10] . ' Belas';
  107. } else if ($angka < 100) {
  108. $hasil_bagi = (int) ($angka / 10);
  109. $hasil_mod = $angka % 10;
  110. return trim(sprintf('%s Puluh %s', $bilangan[$hasil_bagi], $bilangan[$hasil_mod]));
  111. } else if ($angka < 200) {
  112. return sprintf('Seratus %s', $this->terbilang($angka - 100));
  113. } else if ($angka < 1000) {
  114. $hasil_bagi = (int) ($angka / 100);
  115. $hasil_mod = $angka % 100;
  116. return trim(sprintf('%s Ratus %s', $bilangan[$hasil_bagi], $this->terbilang($hasil_mod)));
  117. } else if ($angka < 2000) {
  118. return trim(sprintf('Seribu %s', $this->terbilang($angka - 1000)));
  119. } else if ($angka < 1000000) {
  120. $hasil_bagi = (int) ($angka / 1000);
  121. $hasil_mod = $angka % 1000;
  122. return sprintf('%s Ribu %s', $this->terbilang($hasil_bagi), $this->terbilang($hasil_mod));
  123. } else if ($angka < 1000000000) {
  124. $hasil_bagi = (int) ($angka / 1000000);
  125. $hasil_mod = $angka % 1000000;
  126. return trim(sprintf('%s Juta %s', $this->terbilang($hasil_bagi), $this->terbilang($hasil_mod)));
  127. } else if ($angka < 1000000000000) {
  128. $hasil_bagi = (int) ($angka / 1000000000);
  129. $hasil_mod = fmod($angka, 1000000000);
  130. return trim(sprintf('%s Milyar %s', $this->terbilang($hasil_bagi), $this->terbilang($hasil_mod)));
  131. } else if ($angka < 1000000000000000) {
  132. $hasil_bagi = $angka / 1000000000000;
  133. $hasil_mod = fmod($angka, 1000000000000);
  134. return trim(sprintf('%s Triliun %s', $this->terbilang($hasil_bagi), $this->terbilang($hasil_mod)));
  135. } else {
  136. return 'Data Salah';
  137. }
  138. }
  139.  
  140. function gen_uuid() {
  141. return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
  142. // 32 bits for "time_low"
  143. mt_rand(0, 0xffff), mt_rand(0, 0xffff),
  144. // 16 bits for "time_mid"
  145. mt_rand(0, 0xffff),
  146. // 16 bits for "time_hi_and_version",
  147. // four most significant bits holds version number 4
  148. mt_rand(0, 0x0fff) | 0x4000,
  149. // 16 bits, 8 bits for "clk_seq_hi_res",
  150. // 8 bits for "clk_seq_low",
  151. // two most significant bits holds zero and one for variant DCE1.1
  152. mt_rand(0, 0x3fff) | 0x8000,
  153. // 48 bits for "node"
  154. mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
  155. );
  156. }
  157.  
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement