Oleh : Deddy Rusdiansyah,S.Kom Penguatan Daya Saing (PDS) Modul Sistem Informasi Koperasi SIMPAN PINJAM (MySQL, PHP & JQuery) Oleh : Deddy Rusdiansyah,S.Kom
Penguatan Daya Saing (PDS) PIKSI INPUT SERANG 2012
content.php 1 2 3 4 <?php include "inc/inc.koneksi.php"; $mod = $_GET['module']; if ($mod=='home'){ 7 Modul Sistem Informasi Koperasi Deddy Rusdiansyah,S.Kom 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 echo "<h2>Selamat Datang</h2>"; echo "Hai, <b>$_SESSION[namauser] </b> Selamat datang di Sistem Informasi Koperasi"; } elseif ($mod=='jenis'){ include "modul/jenis/jenis.php"; } elseif ($mod=='anggota'){ include "modul/anggota/anggota.php"; } //buatlah form user berdasarkan form anggota elseif ($mod=='simpanan'){ include "modul/simpanan/simpanan.php"; } //buatlah form pengambilan berdasarkan form simpanan elseif ($mod=='pinjaman'){ include "modul/pinjaman/pinjaman.php"; } elseif ($mod=='bayar'){ include "modul/bayar/bayar.php"; } else{ echo "<b>MODUL BELUM ADA ATAU BELUM LENGKAP SILAHKAN BUAT SENDIRI</b>"; } ?>
$sql = mysql_query("SELECT * FROM $table WHERE id_jenis= '$id'"); $row = mysql_num_rows($sql); if ($row>0){ $input = "UPDATE $table SET jenis_simpanan ='$jenis', jumlah ='$jml' WHERE id_jenis= '$id'"; mysql_query($input); echo "<b>Data Sukses diubah</b>"; }else{ $input = "INSERT INTO $table (id_jenis,jenis_simpanan,jumlah) VALUES('$id','$jenis','$jml')"; 15 Modul Sistem Informasi Koperasi Deddy Rusdiansyah,S.Kom 21 22 23 24 mysql_query($input); echo "<b>Data sukses disimpan</b>"; } ?>
hapus.php 1 2 3 4 5 6 7 8 9 10 11 <?php include "../../inc/inc.koneksi.php"; $table = 'jenis_simpan'; $id = $_POST['id']; $sql = mysql_query("SELECT * FROM $table WHERE id_jenis= '$id'"); $row = mysql_num_rows($sql); if ($row>0){ $input = "DELETE FROM $table WHERE id_jenis= '$id'"; mysql_query($input); } ?>
function simpan(){ var no = $("#nomor").val(); var id = $("#identitas").val(); var nama = $("#anggota").val(); var jk = $("#jk").val(); var tempat = $("#tempat").val(); var tgl = $("#tgl").val(); var alamat = $("#alamat").val(); var hp = $("#hp").val();
if(no.length==0){ alert('Maaf, Nomor Anggota tidak boleh kosong'); $("#nomor").focus(); return false(); } if(id.length==0){ alert('Maaf, Nomor Identitas tidak boleh kosong'); $("#identitas").focus(); return false(); } if(nama.length==0){ alert('Maaf, Nama Anggota tidak boleh kosong'); $("#anggota").focus(); return false(); } $.ajax({ type : "POST", url : "modul/anggota/simpan.php", data : "no="+no+ "&id="+id+ "&nama="+nama+ "&jk="+jk+ "&tempat="+tempat+ "&tgl="+tgl+ "&alamat="+alamat+ "&hp="+hp, success : function(data){ $("#tampil_data").load('modul/anggota/tampil_data.php'); $("#form_input").dialog("close"); } }); } $("#cari").click(function(){ var cari = $("#txt_cari").val(); cariData(cari); });
function cariData(e){ var cari = e; $.ajax({ 19 Modul Sistem Informasi Koperasi Deddy Rusdiansyah,S.Kom 88 89 90 91 92 93 94 95 96 type : "GET", url : "modul/anggota/tampil_data.php", data : "cari="+cari, success : function(data){ $("#tampil_data").html(data); } }); } });
$("#jml").keypress(function (data) { if(data.which!=8 && data.which!=0 && (data.which<48 || data.which>57)){ return false; } }); $("#simpan").click(function(){ simpan(); }) function simpan(){ var no = $("#nomor").val(); var tgl = $("#tgl").val(); var jenis = $("#jenis").val(); var jml = $("#jml").val();
if(no.length==0){ alert('Maaf, Nomor Anggota tidak boleh kosong'); $("#nomor").focus(); return false(); } if(tgl.length==0){ alert('Maaf, Tanggal tidak boleh kosong'); $("#tgl").focus(); return false(); } if(jenis.length==0){ alert('Maaf, Jenis Simpanan tidak boleh kosong'); 26 Modul Sistem Informasi Koperasi Deddy Rusdiansyah,S.Kom 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 $("#jenis").focus(); return false(); } if(jml.length==0){ alert('Maaf, Jumlah tidak boleh kosong'); $("#jml").focus(); return false(); }
$.ajax({ type : "POST", url : "modul/simpanan/simpan.php", data : "no="+no+ "&tgl="+tgl+ "&jenis="+jenis+ "&jml="+jml, success : function(data){ //$("#tampil_data1").html(data); $("#tampil_data1").load('modul/simpanan/tampil_data1.php?cari='+no); } }); } $("#baru").click(function(){ var cari =''; $(".input").val(''); $("#nomor").focus(); cariAnggota(cari); cariSimpananAnggota(cari); }) $("#nomor").keyup(function(){ var cari = $("#nomor").val(); cariAnggota(cari); cariSimpananAnggota(cari); }) function cariAnggota(e){ var cari = e; $.ajax({ type : "POST", url : "modul/simpanan/cari_anggota.php", data : "cari="+cari, success : function(data){ $("#info_anggota").html(data); } }); } function cariSimpananAnggota(e){ var cari = e; $.ajax({ type : "GET", url : "modul/simpanan/tampil_data1.php", data : "cari="+cari, success : function(data){ $("#tampil_data1").html(data); } }); 27 Modul Sistem Informasi Koperasi Deddy Rusdiansyah,S.Kom 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 } $("#jenis").change(function(){ var cari = $("#jenis").val(); cariJenis(cari); })
function cariJenis(e){ var cari = e; $.ajax({ type : "POST", url : "modul/simpanan/cari_jenis.php", data : "cari="+cari, dataType: "json", success : function(data){ $("#jml").val(data.jml); } }); }
$("#cari2").click(function(){ var tgl1 = $("#tgl1").val(); var tgl2 = $("#tgl2").val();
if(tgl1.length==0){ alert('Maaf, Tanggal tidak boleh kosong'); $("#tgl1").focus(); return false(); } if(tgl2.length==0){ alert('Maaf, Tanggal tidak boleh kosong'); $("#tgl2").focus(); return false(); }
cariData2(tgl1,tgl2); });
function cariData2(e1,e2){ var tgl1 = e1; var tgl2 = e2;
$.ajax({ type : "POST", url : "modul/simpanan/tampil_data2.php", data : "tgl1="+tgl1+"&tgl2="+tgl2, success : function(data){ $("#tampil_data2").html(data); } }); } $("#cari3").click(function(){ var cari = $("#txt_cari").val(); cariData3(cari); });
28 Modul Sistem Informasi Koperasi Deddy Rusdiansyah,S.Kom 162 163 164 165 166 167 168 169 170 171 172 173 function cariData3(e){ var cari = e; $.ajax({ type : "POST", url : "modul/simpanan/tampil_data3.php", data : "cari="+cari, success : function(data){ $("#tampil_data3").html(data); } }); } });