Hallo! Selamat Datang di Marketplace produk digital, Freelancer terbaik di indonesia (65345 Members, 764 Products, 5083 Topic, 12753 Comments)

Butuh karyawan baru? atau seorang Web Developer (Part-time/Freelance/Full-time), cari disini : Members Area Jobs!

IF pada kasus Billing PDAM tidak bekerja

Dibuat
Login Terakhir 22 Hari lalu,
Telah Dilihat 1673 Kali
joko ahmadi Mengatakan : Sultan Account
  1. Assalamualaikum Warahmatullahi Wabarakatuh... mas Robby dan Mas Buchori dan teman2 PHPMU mohon bantuan koreksi dari script ini (tarif PDAM jika <10 m3 harga mengikuti 10m3 kalau diatas 10 maka 10x tarif1 dan sisanya di hitung tarif ke 2 ) pada line 186
  2.  
  3. var jumlah2 = $("#jumlah2");
  4.  
  5. if ((parseInt(total) - 10 ) >=0 <=10 );
  6.  
  7. {
  8. ((parseInt(total) - 10 ) * parseInt(tarif2));
  9. } 0
  10. if ((parseInt(total) - 10 ) <0);
  11. { 0;
  12. }
  13. else{
  14. 10 * parseInt(tarif2);
  15. }
  16.  
  17.  
  18.  
  19.  
  20. $("#jumlah2 ").val(jumlah2 );
  21.  
  22.  
  23.  
  24. script full
  25.  
  26. <?php
  27. include "inc/koneksi.php";
  28.  
  29. include "inc/kode.php";
  30.  
  31. ?>
  32.  
  33. <div class="panel panel-info">
  34. <div class="panel-heading">
  35. <b>Tambah Pemakaian</b>
  36. </div>
  37. <div class="panel-body">
  38. <div class="row">
  39. <div class="col-md-12">
  40. <form method="POST" enctype="multipart/form-data">
  41.  
  42. <div class="form-group">
  43. <label>ID Pemakaian</label>
  44. <input class="form-control" type="text" name="id_pakai" value="<?php echo $format; ?>" />
  45. </div>
  46.  
  47. <div class="form-group">
  48. <label>Pelanggan</label>
  49. <select name="id_pelanggan" id="id_pelanggan" class="form-control" required>
  50. <option value=""></option>
  51. <?php
  52. // ambil data dari database
  53. $query = "select * from tb_pelanggan where status='Aktif'";
  54. $hasil = mysqli_query($koneksi, $query);
  55. while ($row = mysqli_fetch_array($hasil)) {
  56. ?>
  57. <option value="<?php echo $row['id_pelanggan'] ?>"><?php echo $row['id_pelanggan'] ?>| <?php echo $row['nama_pelanggan'] ?></option>
  58. <?php
  59. }
  60. ?>
  61. </select>
  62. </div>
  63.  
  64. <div class="form-group">
  65. <label>Bulan</label>
  66. <select name="id_bulan" id="id_bulan" class="form-control" required>
  67. <option value="">-- Pilih Bulan --</option>
  68. <?php
  69. // ambil data dari database
  70. $query = "select * from tb_bulan order by id_bulan asc";
  71. $hasil = mysqli_query($koneksi, $query);
  72. while ($row = mysqli_fetch_array($hasil)) {
  73. ?>
  74. <option value="<?php echo $row['id_bulan'] ?>"> <?php echo $row['nama_bulan'] ?></option>
  75. <?php
  76. }
  77. ?>
  78. </select>
  79. </div>
  80.  
  81. <div class="form-group">
  82. <label>Tahun</label>
  83. <input type="number" class="form-control" min="2021" max="2030" name="tahun" value="2021" placeholder="Masukkan tahun"/>
  84. </div>
  85.  
  86. <div class="form-group">
  87. <label>Meteran Bulan Lalu</label>
  88. <input type="text" name="awal" id="awal" class="form-control" placeholder="0" readonly="">
  89. </div>
  90.  
  91. <div class="form-group">
  92. <label>Meteran Bulan Ini</label>
  93. <input type="text" name="akhir" id="akhir" class="form-control" placeholder="Meteran bulan ini">
  94. </div>
  95.  
  96. <div class="form-group mb-0">
  97. <label>Pemakaian (Bulan Ini - Bulan lalu)</label>
  98. <input type="text" name="total" id="total" class="form-control" placeholder="Pemakaian bulan ini" readonly="" >
  99. </div>
  100.  
  101. <div class="form-group mb-0">
  102. <?php $sql_cek = "select l.tarif1, l.tarif2, l.tarif3 from tb_layanan l inner join tb_pelanggan p where l.id_layanan=p.id_layanan";
  103. $query_cek = mysqli_query($koneksi, $sql_cek);
  104. $data_cek = mysqli_fetch_array($query_cek,MYSQLI_BOTH);
  105. ?>
  106. <input type="text" class="form-control" name="tarif1" id="tarif1" value="<?php echo $data_cek['tarif1']; ?>" readonly=""/>
  107. <input type="text" class="form-control" name="tarif2" id="tarif2" value="<?php echo $data_cek['tarif2']; ?>" readonly=""/>
  108. <input type="text" class="form-control" name="tarif3" id="tarif3" value="<?php echo $data_cek['tarif3']; ?>" readonly=""/>
  109. </div>
  110.  
  111. <div class="form-group mb-0">
  112. <input type="hidden" name="harga" id="harga" class="form-control" readonly="">
  113. </div>
  114.  
  115. <div class="form-group mb-0">
  116. <input type="text" name="jumlah1" id="jumlah1" class="form-control" readonly="">
  117. </div>
  118. <div class="form-group mb-0">
  119. <input type="text " name="jumlah2" id="jumlah2" class="form-control" readonly="">
  120. </div>
  121.  
  122. <div class="form-group mb-0">
  123. <input type="text" name="jumlah3" id="jumlah3" class="form-control" readonly="">
  124. </div>
  125.  
  126. <div>
  127. <input type="submit" name="Simpan" value="Simpan" class="btn btn-success" >
  128.  
  129. </div>
  130. </div>
  131. </form>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136.  
  137. <?php
  138. if (isset ($_POST['Simpan'])){
  139. //mulai proses simpan data
  140. $sql_simpan = "INSERT INTO tb_pakai (id_pakai, id_pelanggan, bulan, tahun, awal, akhir, pakai) VALUES (
  141. '".$_POST['id_pakai']."',
  142. '".$_POST['id_pelanggan']."',
  143. '".$_POST['id_bulan']."',
  144. '".$_POST['tahun']."',
  145. '".$_POST['awal']."',
  146. '".$_POST['akhir']."',
  147. '".$_POST['total']."');";
  148. $sql_simpan .= "INSERT INTO tb_tagihan (id_pakai, tagihan) VALUES (
  149. '".$_POST['id_pakai']."',
  150. '".$_POST['harga']."')";
  151. $query_simpan = mysqli_multi_query($koneksi, $sql_simpan);
  152.  
  153. mysqli_close($koneksi);
  154.  
  155. if ($query_simpan)
  156. {
  157. echo "<script>
  158. Swal.fire({title: 'Simpan Berhasil',text: '',icon: 'success',confirmButtonText: 'OK'
  159. }).then((result) => {
  160. if (result.value) {
  161. window.location = 'r1.php?halaman=pakai_tampil';
  162. }})</script>";
  163. }else{
  164. echo "<script>
  165. Swal.fire({title: 'Simpan Gagal',text: '',icon: 'error',confirmButtonText: 'OK'
  166. }).then((result) => {
  167. if (result.value) {
  168. window.location = 'r1.php?halaman=pakai_tambah';
  169. }})</script>";
  170. }
  171. //selesai proses simpan data
  172. }
  173.  
  174.  
  175. ?>
  176.  
  177. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
  178. <script>
  179. $(document).ready(function(){
  180. $('#id_pelanggan').change(function(){
  181. var id_pelanggan = $(this).val();
  182. $.ajax({
  183. url:"super/pakai/proses-ajax.php",
  184. method:"POST",
  185. data:{id_pelanggan:id_pelanggan},
  186. success:function(data){
  187. $('#awal').val(data);
  188. }
  189. });
  190. });
  191. });
  192. </script>
  193.  
  194. <script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
  195. <script type="text/javascript">
  196. $(document).ready(function() {
  197. $("#akhir, #awal").keyup(function() {
  198. var awal = $("#awal").val() || 0;
  199. var akhir = $("#akhir").val();
  200. var total = parseInt(akhir) - parseInt(awal) ;
  201. $("#total").val(total);
  202.  
  203. var tarif1 = $("#tarif1").val();
  204. var tarif2 = $("#tarif2").val();
  205. var tarif3 = $("#tarif3").val();
  206.  
  207. var jumlah1 = 10 * parseInt(tarif1);
  208. $("#jumlah1").val(jumlah1);
  209.  
  210.  
  211. var jumlah2 = $("#jumlah2");
  212.  
  213. if ((parseInt(total) - 10 ) >=0 <=10 );
  214.  
  215. {
  216. ((parseInt(total) - 10 ) * parseInt(tarif2));
  217. } 0
  218. if ((parseInt(total) - 10 ) <0);
  219. { 0;
  220. }
  221. else{
  222. 10 * parseInt(tarif2);
  223. }
  224.  
  225.  
  226.  
  227.  
  228. $("#jumlah2 ").val(jumlah2 );
  229.  
  230. //var jumlah2 = parseInt(total2) * parseInt(tarif2);
  231. // $("#jumlah2").val(jumlah2);
  232.  
  233.  
  234.  
  235. var jumlah3 = (parseInt(total) - 20) * parseInt(tarif3);
  236. $("#jumlah3").val(jumlah3);
  237.  
  238.  
  239. var harga = parseInt(jumlah1) + parseInt(jumlah2);
  240. $("#harga").val(harga);
  241.  
  242. });
  243. });
  244. </script>
Maaf, Untuk Memberikan Komentar Anda Harus Login !!!