• Tidak ada hasil yang ditemukan

eBook Modul koperasi simpan pinjam denga

N/A
N/A
Protected

Academic year: 2018

Membagikan "eBook Modul koperasi simpan pinjam denga"

Copied!
44
0
0

Teks penuh

(1)

Sistem

(MyS

Oleh :

Pen

Modul

istem Informasi Koperasi

SIMPAN PINJAM

(MySQL, PHP & JQuery)

Oleh : Deddy Rusdiansyah,S.Kom

Penguatan Daya Saing (PDS)

(2)

index.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Login System</title>

<link rel="stylesheet" href="css/style_login.css" type="text/css"/>

<link type="text/css" href="css/excite-bike/jquery-ui-1.8.21.custom.css" rel="stylesheet" /> <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>

<script type="text/javascript" src="js/jquery-ui-1.8.21.custom.min.js"></script> <script type="text/javascript">

$(document).ready(function() { $(".text").val('');

$("#username").focus(); });

function validasi(){

var username = $("#username").val(); var password = $("#password").val(); if (username.length == 0){

alert("Anda belum mengisikan Username."); $("#username").focus();

return false(); }

if (password.length == 0){

alert("Anda belum mengisikan Password."); $("#password").focus();

return false(); }

return true(); }

</script>

<style type="text/css"> .right {

float:right }

button {margin: 0; padding: 0;}

button {margin: 2px; position: relative; padding: 4px 4px 4px 2px; cursor: pointer; float: left; list-style: none;}

button span.ui-icon {float: left; margin: 0 4px;} </style>

</head> <body>

<form name="login" action="cek_login.php" method="POST" onSubmit="return validasi(this)"> <div class="login-inside">

<div class="login-data">

<table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr>

<td>

<div align="center">

<table cellpadding="0" cellspacing="0"> <tr>

<td height="25">Username</td>

(3)

54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77

</tr> <tr>

<td height="26">Password</td>

<td>&nbsp;:&nbsp;<input type="password" class="text" name="password" id="password" /></td> </tr>

<tr>

<td colspan="2"> <div class="right">

<button type="submit" name="submit" class="ui-state-default ui-corner-all" id="icon"> <span class="ui-icon ui-icon-unlocked"></span>Login

</button> </div> </td> </tr> </table> </div> </td> </tr> </table> </div> </div> </form> </body> </html>

style_login.css

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

@charset "utf-8"; /* CSS Document */ body {

background:url(../images/_bg2.jpg); }

.login-inside { width: 400px;

font-family:Verdana, Geneva, sans-serif; font-size:12px;

margin: 0px auto; margin-top: 200px; padding: 10px;

border:2px solid #F30;

/* background-color:#f9f9f9; */

background:url(../images/bg_inside.png); -moz-border-radius: 5px 5px 5px 5px; -webkit-border-radius: 5px 5px 5px 5px; border-radius: 5px 5px 5px 5px;

-moz-box-shadow:0px 0px 4px #aaa; -webkit-box-shadow:0px 0px 4px #aaa; box-shadow:0px 0px 4px #aaa;

}

.login-data {

padding: 40px 0px 25px 0px; color:#F00;

(4)

28 29 30 31 32 33 34 35

} button {

-moz-border-radius: 5px 5px 5px 5px; -webkit-border-radius: 5px 5px 5px 5px; border-radius: 5px 5px 5px 5px;

-moz-box-shadow:0px 0px 4px #aaa; -webkit-box-shadow:0px 0px 4px #aaa; box-shadow:0px 0px 4px #aaa;

}

inc.koneksi.php

1 2 3 4 5 6 7 8

<?php

$server = "localhost"; $username = "root"; $password = "";

$database = "koperasi_pds";

$konek = mysql_connect($server, $username, $password) or die ("Gagal konek ke server MySQL" .mysql_error()); $bukadb = mysql_select_db($database) or die ("Gagal membuka database $database" .mysql_error());

?>

cek_login.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

<?php

include "inc/inc.koneksi.php"; function anti_injection($data){

$filter = mysql_real_escape_string(stripslashes(strip_tags(htmlspecialchars($data,ENT_QUOTES)))); return $filter;

}

$username = anti_injection($_POST[username]); $pass = anti_injection(md5($_POST[password])); if (!ctype_alnum($username) OR !ctype_alnum($pass)){ ?>

<script>

alert('Sekarang loginnya tidak bisa di injeksi lho.'); window.location.href='index.php';

</script> <?php }else{

$login =mysql_query("SELECT * FROM users WHERE user_id='$username' AND password='$pass'"); $ketemu =mysql_num_rows($login);

if ($ketemu > 0){ session_start();

$r = mysql_fetch_array($login); $_SESSION[namauser] = $r[user_id]; $_SESSION[passuser] = $r[password]; header('location:media.php?module=home'); }else{

?> <script>

alert('Maaf, Username atau password salah.'); window.location.href='index.php';

(5)

31 32 33 34

<?php } }

?>

logout.php

1 2 3 4 5

<?php

session_start(); session_destroy();

header('location:index.php'); ?>

media.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

<?php

session_start(); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Sistem Informasi Koperasi Simpan Pinjam</title>

<link rel="stylesheet" href="css/style_content.css" type="text/css"/> <link rel="stylesheet" href="css/style_table.css" type="text/css"/>

<link type="text/css" href="css/excite-bike/jquery-ui-1.8.21.custom.css" rel="stylesheet" /> <script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>

<script type="text/javascript" src="js/jquery-ui-1.8.21.custom.min.js"></script> <!-- untuk menu superfish -->

<link rel="stylesheet" href="css/superfish.css" type="text/css" /> <script type="text/javascript" src="js/superfish.js"></script> <!-- untuk mask -->

<script type="text/javascript" src="js/jquery.maskedinput.js"></script> <script type="text/javascript">

$(document).ready(function(){ $('ul.sf-menu').superfish(); });

</script> </head> <body>

<div class="box"> <div class="border"> <div class="style">

<div class="header"> <span class="title"> <div align="center">

<img src="images/header.jpg" width="840" height="120" /> </div>

</span> </div>

<div class="menu">

(6)

39 40 41 42 43 44 45 46 47 48 49 50 51 52

</div>

<!--awal content --> <div class="content">

<?php include 'content.php'; ?> </div>

<!--akhir content -->

<div class="footer" align="center">

<p>Copyright &copy; PIKSI INPUT SERANG Tahun 2012</p> </div>

</div> </div> </div> </body> </html>

menu.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

<ul class="sf-menu">

<li><a href="?module=home">Home</a></li> <li>

<a href="#">Master</a> <ul>

<li><a href="?module=jenis">Jenis Simpanan</a></li> <li><a href="?module=anggota">Anggota</a></li> <li><a href="?module=users">Users</a></li> </ul>

</li> <li>

<a href="#">Transaksi</a> <ul>

<li><a href="?module=simpanan">Simpanan</a></li> <li><a href="?module=pengambilan">Pengambilan</a></li> <li><a href="?module=pinjaman">Pinjaman</a></li> <li><a href="?module=bayar">Bayar Pinjaman</a></li> </ul>

</li> <li>

<a href="#">Laporan</a> <ul>

<li><a href="?module=lap-anggota">Anggota</a></li> <li><a href="?module=lap-simpanan">Simpanan</a></li> <li><a href="?module=lap-pinjaman">Pinjaman</a></li> </ul>

</li>

<li><a href="logout.php">Keluar</a></li> </ul>

content.php

1 2 3 4

<?php

(7)

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>"; }

?>

style_content.css

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

body {

font-family:Verdana,Arial,sans-serif; font-size:12px;

}

h2,h3{clear:both; text-align:center; font-size:16px;} .box {

width:850px; margin: 0px auto; height:auto; padding:10px;

-moz-border-radius: 5px 5px 5px 5px; -webkit-border-radius: 5px 5px 5px 5px; border-radius: 5px 5px 5px 5px;

-moz-box-shadow:0px 0px 20px #aaa; -webkit-box-shadow:0px 0px 20px #aaa; box-shadow:0px 0px 20spx #aaa;

}

.style {

border: 3px solid #FFFFFF; }

.header {

height: 121px; }

.menu {

height: 33px;

(8)

28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

-moz-border-radius: 5px 5px 5px 5px; -webkit-border-radius: 5px 5px 5px 5px; border-radius: 5px 5px 5px 5px;

-moz-box-shadow:0px 0px 20px #aaa; -webkit-box-shadow:0px 0px 20px #aaa; box-shadow:0px 0px 20spx #aaa;

}

.content {

margin:0px auto; margin-top:10px;

padding:5px 5px 5px 5px; height:auto;

} .footer {

margin-top:10px;

padding:5px 5px 5px 5px; background:#cd152f; color:#fff;

-moz-border-radius: 5px 5px 5px 5px; -webkit-border-radius: 5px 5px 5px 5px; border-radius: 5px 5px 5px 5px;

-moz-box-shadow:0px 0px 20px #aaa; -webkit-box-shadow:0px 0px 20px #aaa; box-shadow:0px 0px 20spx #aaa;

}

style_table.css

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

@charset "utf-8"; /* CSS Document */ #theTable{

background:#BDD2FF; font-size:12px;

border:3px solid #5c9fe9;

-moz-border-radius: 5px 5px 5px 5px; -webkit-border-radius: 5px 5px 5px 5px; border-radius: 5px 5px 5px 5px;

-moz-box-shadow:0px 0px 20px #aaa; -webkit-box-shadow:0px 0px 20px #aaa; box-shadow:0px 0px 20spx #aaa;

}

#theTable th,td { color: #000;

padding-left : 2px; padding-right : 2px; padding-top : 2px; padding-bottom : 2px; }

#theTable th {

background-color:#5c9fe9; color:#FFF;

text-align:center;

(9)

27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47

height:20px; padding-top:5px; }

#theTable td{

border:0px solid #5c9fe9;

font:normal 11px Verdana, Geneva, sans-serif; }

.clickable {

cursor:pointer; }

.stripe1 {

background-color:#ecf2f6; }

.stripe2 {

background-color:#FFF; }

.highlight {

background-color: #ffcc00; font-weight:bold;

}

fungsi_tanggal.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

<?php

function jin_date_sql($date){ $exp = explode('-',$date); if(count($exp) == 3) {

$date = $exp[2].'-'.$exp[1].'-'.$exp[0]; }

return $date; }

function jin_date_str($date){ $exp = explode('-',$date); if(count($exp) == 3) {

$date = $exp[2].'-'.$exp[1].'-'.$exp[0]; }

return $date; }

?>

fungsi_koperasi.php

1 2 3 4 5 6 7 8 9

<?php

function jmlBayar($no) {

$sql = "SELECT sum(angsuran+bunga) as total FROM pinjaman_detail WHERE id_pinjam='$no'"; $data = mysql_fetch_array(mysql_query($sql)); $row = mysql_num_rows(mysql_query($sql)); if ($row>0){

(10)

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

}else{

$hasil = 0; }

return $hasil; }

function sisa($no) {

$sql = "SELECT sum(jumlah_bayar) as total FROM pinjaman_detail WHERE id_pinjam='$no'"; $data = mysql_fetch_array(mysql_query($sql)); $row = mysql_num_rows(mysql_query($sql)); if ($row>0){

$hasil = $data['total']; }else{

$hasil = 0; }

return $hasil; }

?>

MODUL Jenis Simpanan jenis.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

<script language="javascript" src="modul/jenis/ajax.js"></script> <style type="text/css">

button {

margin: 2px; position: relative;

padding: 4px 8px 4px 4px; cursor: pointer;

list-style: none; }

button span.ui-icon { float: left; margin: 0 4px; }

</style> <?php

echo "<div id='dalam_content'> <h2>DAFTAR JENIS SIMPANAN</h2> <div id='menu-tombol'>

<button class='ui-state-default ui-corner-all' id='tambah'> <span class='ui-icon ui-icon-circle-plus'></span>Tambah </button>

</div>

<div id='tampil_data'></div> </div>";

echo "<div id='form_input' title='Tambah/Edit Data'> <table width='100%'>

<tr>

(11)

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

<td width='2%'>:</td>

<td><input type='text' name='id' id='id' size='5' maxlength='5' class='input'></td> </tr>

<tr>

<td>Jenis</td>

<td width='2%'>:</td>

<td><input type='text' name='jenis' id='jenis' size='35' maxlength='35' class='input'></td> </tr>

<tr>

<td>Jumlah</td> <td width='2%'>:</td>

<td><input type='text' name='jml' id='jml' size='15' maxlength='15' class='input'></td> </tr>

</table> </div>"; ?>

ajax.js

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35

// JavaScript Document

$(document).ready(function(){ $(function(){

$('button').hover(

function() { $(this).addClass('ui-state-hover'); }, function() { $(this).removeClass('ui-state-hover'); } );

});

$('#form_input').dialog({ autoOpen: false, show: "blind", hide: "blind", width: 450, modal : true, resizable:false, buttons: {

"Simpan": function() {

//$(this).dialog("close"); simpan();

},

"Batal": function() {

$(this).dialog("close"); }

} });

$("#tampil_data").load('modul/jenis/tampil_data.php'); $('#tambah').click(function(){

$(".input").val('');

$('#form_input').dialog('open'); return false;

});

$("#jml").keypress(function (data) {

(12)

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66

} });

function simpan(){

var id = $("#id").val(); var jenis = $("#jenis").val(); var jml = $("#jml").val();

if(id.length==0){

alert('Maaf, ID tidak boleh kosong'); $("#id").focus();

return false(); }

if(jenis.length==0){

alert('Maaf, Jenis tidak boleh kosong'); $("#jenis").focus();

return false(); }

$.ajax({

type : "POST",

url : "modul/jenis/simpan.php", data : "id="+id+

"&jenis="+jenis+ "&jml="+jml, success : function(data){

$("#tampil_data").load('modul/jenis/tampil_data.php'); $("#form_input").dialog("close");

} }); }

});

tampil_data.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

<script type="text/javascript"> $(function() {

$("#theTable tr:even").addClass("stripe1"); $("#theTable tr:odd").addClass("stripe2");

$("#theTable tr").hover( function() {

$(this).toggleClass("highlight"); },

function() {

$(this).toggleClass("highlight"); }

); });

function editRow(ID){ var id = ID;

var pilih = confirm('Data yang akan mengubah = '+id+ '?'); if (pilih==true) {

$.ajax({

(13)

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75

url : "modul/jenis/cari.php", data : "id="+id,

dataType : "json", success : function(data){

$("#id").val(ID);

$("#jenis").val(data.jenis); $("#jml").val(data.jml);

$('#form_input').dialog('open'); return false;

} }); } }

function deleteRow(ID) { var id = ID;

var pilih = confirm('Data yang akan dihapus = '+id+ '?'); if (pilih==true) {

$.ajax({

type : "POST",

url : "modul/jenis/hapus.php", data : "id="+id,

success : function(data){

$("#tampil_data").load("modul/jenis/tampil_data.php"); }

}); }

} </script> <?php

include '../../inc/inc.koneksi.php';

echo "<table id='theTable' width='100%'> <tr>

<th width='5%'>No</th> <th>ID</th>

<th>Jenis</th> <th>Jumlah</th>

<th width='10%'>Aksi</th> </tr>";

$sql = "SELECT * FROM jenis_simpan ORDER By id_jenis"; $query = mysql_query($sql);

$no=1;

while($rows=mysql_fetch_array($query)){ echo "<tr>

<td align='center'>$no</td>

<td align='center'>$rows[id_jenis]</td> <td>$rows[jenis_simpanan]</td>

<td align='right'>".number_format($rows[jumlah])."</td> <td align='center'>

<a href='javascript:editRow(\"{$rows[id_jenis]}\")'>Edit</a> <a href='javascript:deleteRow(\"{$rows[id_jenis]}\")'>Hapus</a>

(14)

76 77 78 79

$no++; }

echo "</table>"; ?>

cari.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

<?php

include "../../inc/inc.koneksi.php"; $table = 'jenis_simpan';

$id = $_POST['id']; $text = "SELECT *

FROM $table WHERE id_jenis= '$id'"; $sql = mysql_query($text);

$row = mysql_num_rows($sql); if ($row>0){

while ($r=mysql_fetch_array($sql)){

$data['jenis'] = $r[jenis_simpanan]; $data['jml'] = $r[jumlah];

echo json_encode($data); }

}else{

$data['jenis'] = $r[jenis_simpanan]; $data['jml'] = $r[jumlah];

echo json_encode($data); }

?>

simpan.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

<?php

include "../../inc/inc.koneksi.php"; $table ="jenis_simpan";

$id =$_POST[id]; $jenis =$_POST[jenis]; $jml =$_POST[jml];

$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{

(15)

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);

} ?>

Modul Anggota

anggota.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

<script language="javascript" src="modul/anggota/ajax.js"></script> <style type="text/css">

button {

margin: 2px; position: relative;

padding: 4px 8px 4px 4px; cursor: pointer;

list-style: none; }

button span.ui-icon { float: left; margin: 0 4px; }

#menu-tombol {

padding-bottom:10px; padding:5px 5px 5px 5px; }

#tombol-tambah{ float:left; width:250px; }

(16)

25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 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

text-align:right; }

#tampil_data{

margin-top:30px; }

</style> <?php

echo "<div id='dalam_content'> <h2>DAFTAR ANGGOTA</h2> <div id='menu-tombol'> <div id='tombol-tambah'>

<button class='ui-state-default ui-corner-all' id='tambah'> <span class='ui-icon ui-icon-circle-plus'></span>Tambah </button>

</div>

<div id='tombol-cari'>

<input type='text' id='txt_cari' size='30'>

<button class='ui-state-default ui-corner-all' id='cari'> <span class='ui-icon ui-icon-search'></span>Cari </button>

</div> </div>

<div id='tampil_data'></div> </div>";

echo "<div id='form_input' title='Tambah/Edit Data'> <table width='100%'>

<tr>

<td>Nomor Anggota</td> <td width='2%'>:</td>

<td><input type='text' name='nomor' id='nomor' size='10' maxlength='10' class='input'></td> </tr>

<tr>

<td>No.Identitas</td> <td width='2%'>:</td>

<td><input type='text' name='identitas' id='identitas' size='20' maxlength='20' class='input'></td> </tr>

<tr>

<td>Nama</td> <td width='2%'>:</td>

<td><input type='text' name='anggota' id='anggota' size='50' maxlength='50' class='input'></td> </tr>

<tr>

<td>Jenis Kelamin</td> <td width='2%'>:</td> <td><select name='jk' id='jk'> <option value=''>-Pilih-</option> <option value='L'>Laki-laki</option> <option value='P'>Perempuan</option> </select>

</td> </tr> <tr>

<td>Tempat Lahir</td> <td width='2%'>:</td>

(17)

80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98

</tr> <tr>

<td>Tanggal Lahir</td> <td width='2%'>:</td>

<td><input type='text' name='tgl' id='tgl' size='12' maxlength='12' class='input'></td> </tr>

<tr>

<td>Alamat</td> <td width='2%'>:</td>

<td><input type='text' name='alamat' id='alamat' size='30' maxlength='30' class='input'></td> </tr>

<tr>

<td>HP</td>

<td width='2%'>:</td>

<td><input type='text' name='hp' id='hp' size='20' maxlength='20' class='input'></td> </tr>

</table> </div>"; ?>

ajax.js

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

// JavaScript Document

$(document).ready(function(){ $(function(){

$('button').hover(

function() { $(this).addClass('ui-state-hover'); }, function() { $(this).removeClass('ui-state-hover'); } );

});

$('#form_input').dialog({ autoOpen: false, show: "blind", hide: "blind", width: 550, modal : true, resizable:false, buttons: {

"Simpan": function() {

//$(this).dialog("close"); simpan();

},

"Batal": function() {

$(this).dialog("close"); }

} });

$("#tgl").datepicker({

dateFormat:"dd-mm-yy" });

$("#tampil_data").load('modul/anggota/tampil_data.php'); $('#tambah').click(function(){

$(".input").val('');

(18)

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 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

$("#nomor").focus();

$('#form_input').dialog('open'); return false;

});

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);

});

(19)

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); }

}); }

});

tampil_data.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

<script type="text/javascript"> $(function() {

$("#theTable tr:even").addClass("stripe1"); $("#theTable tr:odd").addClass("stripe2"); $("#theTable tr").hover(

function() {

$(this).toggleClass("highlight"); },

function() {

$(this).toggleClass("highlight"); }

); });

function editRow(ID){ var id = ID;

var pilih = confirm('Data yang akan mengubah = '+id+ '?'); if (pilih==true) {

$.ajax({

type : "POST",

url : "modul/anggota/cari.php", data : "id="+id,

dataType : "json", success : function(data){

$("#nomor").val(ID); $("#identitas").val(data.id); $("#anggota").val(data.nama); $("#jk").val(data.jk);

$("#tempat").val(data.tempat); $("#tgl").val(data.tgl);

$("#alamat").val(data.alamat); $("#hp").val(data.hp);

$("#nomor").attr("disabled",true); $('#form_input').dialog('open'); return false;

} }); } }

function deleteRow(ID) { var id = ID;

(20)

43 44 45 46 47 48 49 50 51 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

if (pilih==true) { $.ajax({

type : "POST",

url : "modul/anggota/hapus.php", data : "id="+id,

success : function(data){

$("#tampil_data").load("modul/anggota/tampil_data.php"); }

}); }

}

</script> <?php

include '../../inc/inc.koneksi.php';

$cari = $_GET['cari'];

$where = " WHERE noanggota LIKE '%$cari%' OR namaanggota LIKE '%$cari%'";

echo "<table id='theTable' width='100%'> <tr>

<th width='5%'>No</th> <th>Nomor</th>

<th>Nama</th> <th>L/P</th> <th>HP</th>

<th width='10%'>Aksi</th> </tr>";

$sql = "SELECT *

FROM anggota $where

ORDER BY noanggota"; $query = mysql_query($sql);

$no=1;

while($rows=mysql_fetch_array($query)){ echo "<tr>

<td align='center'>$no</td>

<td align='center'>$rows[noanggota]</td> <td>$rows[namaanggota]</td>

<td align='center'>$rows[jk]</td> <td >$rows[hp]</td>

<td align='center'>

<a href='javascript:editRow(\"{$rows[noanggota]}\")'>Edit</a> <a href='javascript:deleteRow(\"{$rows[noanggota]}\")'>Hapus</a>

</td> </tr>"; $no++;

}

(21)

cari.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

<?php

include "../../inc/inc.koneksi.php"; include "../../inc/fungsi_tanggal.php"; $table = 'anggota';

$id = $_POST['id'];

$text = "SELECT * FROM $table WHERE noanggota= '$id'"; $sql = mysql_query($text);

$row = mysql_num_rows($sql); if ($row>0){

while ($r=mysql_fetch_array($sql)){ $data['id'] = $r[noidentitas]; $data['nama'] = $r[namaanggota]; $data['jk'] = $r[jk];

$data['tempat']= $r[tempat_lahir];

$data['tgl'] = jin_date_str($r[tgl_lahir]); $data['alamat'] = $r[alamat];

$data['hp'] = $r[hp]; echo json_encode($data); }

}else{

$data['id'] = ''; $data['nama'] = ''; $data['jk'] = ''; $data['tempat']= ''; $data['tgl'] = ''; $data['alamat'] = ''; $data['hp'] = ''; echo json_encode($data); }

?>

simpan.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

<?php

include "../../inc/inc.koneksi.php"; include "../../inc/fungsi_tanggal.php"; $table ="anggota";

$no =$_POST[no]; $id =$_POST[id]; $nama =$_POST[nama]; $jk =$_POST[jk]; $tempat =$_POST[tempat];

$tgl =jin_date_sql($_POST[tgl]); $alamat =$_POST[alamat];

$hp =$_POST[hp]; $pwd =md5('koperasi'); $sql = mysql_query("SELECT *

FROM $table

WHERE noanggota= '$no'"); $row = mysql_num_rows($sql);

if ($row>0){

(22)

20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

namaanggota ='$nama', jk ='$jk', tempat_lahir ='$tempat', tgl_lahir ='$tgl', alamat ='$alamat',

hp ='$hp'

WHERE noanggota= '$no'"; mysql_query($input);

echo "<b>Data Sukses diubah</b>"; }else{

$input = "INSERT INTO $table

(noanggota,noidentitas,namaanggota,jk,tempat_lahir,tgl_lahir,alamat,hp,pwd)

VALUES('$no','$id','$nama','$jk','$tempat','$tgl','$alamat','$hp','$pwd')"; 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 = 'anggota';

$id = $_POST['id'];

$sql = mysql_query("SELECT * FROM $table WHERE noanggota= '$id'"); $row = mysql_num_rows($sql);

if ($row>0){

$input = "DELETE FROM $table WHERE noanggota= '$id'"; mysql_query($input);

} ?>

MODUL Simpanan

simpanan.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

<script language="javascript" src="modul/simpanan/ajax.js"></script> <style type="text/css">

button {

margin: 2px; position: relative;

padding: 4px 8px 4px 4px; cursor: pointer;

list-style: none; }

button span.ui-icon { float: left; margin: 0 4px; }

#menu-tombol {

(23)

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70

padding:5px 5px 5px 5px; margin-bottom:20px; }

#tombol-tambah{ float:left; width:250px; }

#tombol-cari{ float:right; width:500px; text-align:right; }

#tampil_data2,#tampil_data3{ margin-top:30px; }

#info_anggota{

position:absolute;

padding:5px 5px 5px 5px; background-color:#FFF; width:450px;

border:3px solid #5c9fe9;

-moz-border-radius: 5px 5px 5px 5px; -webkit-border-radius: 5px 5px 5px 5px; border-radius: 5px 5px 5px 5px;

-moz-box-shadow:0px 0px 20px #aaa; -webkit-box-shadow:0px 0px 20px #aaa; box-shadow:0px 0px 20spx #aaa;

z-index:200px; float:right; left:350px; }

</style> <?php

echo "<div id='dalam_content'>

<h2>DAFTAR SIMPANAN ANGGOTA</h2> <div id='tabs'>

<ul>

<li><a href='#tabs-1'>Simpanan</a></li> <li><a href='#tabs-2'>Pertanggal</a></li> <li><a href='#tabs-3'>Daftar</a></li> </ul>

<div id='tabs-1'>

<div id='info_anggota'></div> <table width='100%'>

<tr>

<td width='15%'>Nomor Anggota</td> <td width='2%'>:</td>

<td><input type='text' id='nomor' size='15' class='input'></td> </tr>

<tr>

<td width='15%'>Tanggal</td> <td width='2%'>:</td>

<td><input type='tgl' id='tgl' size='12' class='input'></td> </tr>

(24)

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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125

<td width='15%'>Jenis Simpanan</td> <td width='2%'>:</td>

<td><select name='jenis' id='jenis' class='input'> <option value=''>-Pilih-</option>";

$sql = "SELECT * FROM jenis_simpan"; $query = mysql_query($sql);

while($rows=mysql_fetch_array($query)){

echo "<option value='$rows[id_jenis]'>$rows[id_jenis] - $rows[jenis_simpanan]</option>"; }

echo "</select> </td>

</tr> <tr>

<td width='15%'>Jumlah</td> <td width='2%'>:</td>

<td><input type='text' name='jml' id='jml' size='15' class='input'></td> </tr>

<tr>

<td colspan='3' align='center'>

<button class='ui-state-default ui-corner-all' id='simpan'> <span class='ui-icon ui-icon-disk'></span>Simpan </button>

<button class='ui-state-default ui-corner-all' id='baru'> <span class='ui-icon ui-icon-document'></span>Baru </button>

</td> </tr> </table>

<div id='tampil_data1'></div> </div>

<div id='tabs-2'>

<div id='menu-tombol'> <div id='tombol-cari'>

Tanggal <input type='text' id='tgl1' size='12'> s/d <input type='text' id='tgl2' size='12'> <button class='ui-state-default ui-corner-all' id='cari2'>

<span class='ui-icon ui-icon-search'></span>Cari </button>

</div> </div>

<div id='tampil_data2'></div> </div>

<div id='tabs-3'>

<div id='menu-tombol'> <div id='tombol-cari'>

<input type='text' id='txt_cari' size='30'>

<button class='ui-state-default ui-corner-all' id='cari3'> <span class='ui-icon ui-icon-search'></span>Cari </button>

</div> </div>

<div id='tampil_data3'></div> </div>

(25)

ajax.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

// JavaScript Document

$(document).ready(function(){ $(function(){

$('button').hover(

function() { $(this).addClass('ui-state-hover'); }, function() { $(this).removeClass('ui-state-hover'); } );

});

$("#nomor").keyup(function(e){ var isi = $(e.target).val();

$(e.target).val(isi.toUpperCase()); });

$('#tabs').tabs();

$("#tgl").datepicker({

dateFormat:"dd-mm-yy" });

$("#tgl1").datepicker({

dateFormat:"dd-mm-yy" });

$("#tgl2").datepicker({

dateFormat:"dd-mm-yy" });

$("#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){

(26)

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)

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)

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); }

}); }

});

cari_anggota.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

<?php

include "../../inc/inc.koneksi.php"; include "../../inc/fungsi_tanggal.php";

$table = 'anggota'; $id = $_POST['cari']; $text = "SELECT *

FROM $table WHERE noanggota= '$id'"; $sql = mysql_query($text);

$row = mysql_num_rows($sql); if ($row>0){

$r=mysql_fetch_array($sql); if ($r[jk]=='L'){

$sex = 'Laki-laki'; }else{

$sex = 'Perempuan'; }

echo "<table> <tr>

<td>Nama</td>

<td>: $r[namaanggota]</td> </tr>

<tr>

<td>Jenis Kelamin</td> <td>: $sex</td>

</tr> <tr>

<td>Tempat, Tgl Lahir</td>

<td>: $r[tempat_lahir], ".jin_date_str($r[tgl_lahir])."</td> </tr>

<tr>

<td>Alamat</td> <td>: $r[alamat]</td> </tr>

</table>"; }

(29)

cari_jenis.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

<?php

include "../../inc/inc.koneksi.php"; $table = 'jenis_simpan';

$id = $_POST['cari']; $text = "SELECT *

FROM $table WHERE id_jenis= '$id'"; $sql = mysql_query($text);

$row = mysql_num_rows($sql); if ($row>0){

while ($r=mysql_fetch_array($sql)){

$data['jml'] = $r[jumlah]; echo json_encode($data);

} }else{

$data['jml'] = ''; echo json_encode($data); }

?>

tampil_data1.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

<script type="text/javascript"> $(function() {

$("#theTable tr:even").addClass("stripe1"); $("#theTable tr:odd").addClass("stripe2");

$("#theTable tr").hover( function() {

$(this).toggleClass("highlight"); },

function() {

$(this).toggleClass("highlight"); }

); });

function deleteRow(ID) { var id = ID;

var cari = $("#nomor").val();

var pilih = confirm('Data yang akan dihapus = '+id+ '?'); if (pilih==true) {

$.ajax({

type : "POST",

url : "modul/simpanan/hapus.php", data : "id="+id,

success : function(data){

$("#tampil_data1").load("modul/simpanan/tampil_data1.php?cari="+cari); }

}); }

}

(30)

32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

include '../../inc/inc.koneksi.php'; include '../../inc/fungsi_tanggal.php'; $cari = $_GET['cari'];

$where = " WHERE noanggota='$cari'"; echo "<table id='theTable' width='100%'>

<tr>

<th width='5%'>No</th> <th>Tanggal</th> <th>Simpanan</th> <th>Jumlah</th> <th>Hapus</th> </tr>";

$sql = "SELECT a.*,b.jenis_simpanan FROM simpanan as a JOIN jenis_simpan as b ON a.id_jenis=b.id_jenis $where

ORDER BY a.id_simpanan DESC"; $query = mysql_query($sql);

$no=1;

while($rows=mysql_fetch_array($query)){ echo "<tr>

<td align='center'>$no</td>

<td align='center'>".jin_date_str($rows[tgl])."</td> <td>$rows[jenis_simpanan]</td>

<td align='right'>".number_format($rows[jumlah])."</td> <td align='center'>

<a href='javascript:deleteRow(\"{$rows[id_simpanan]}\")'>Hapus</a>

</td> </tr>"; $no++;

$gtotal = $gtotal+$rows[jumlah]; }

echo " <tr>

<td colspan='3' align='center'>Total</td>

<td align='right'><b>".number_format($gtotal)."</b></td> </table>";

?>

tampil_data2.php

1 2 3 4 5 6 7 8 9 10 11

<script type="text/javascript"> $(function() {

$("#theTable.dua tr:even").addClass("stripe1"); $("#theTable.dua tr:odd").addClass("stripe2");

$("#theTable.dua tr").hover( function() {

$(this).toggleClass("highlight"); },

function() {

(31)

12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

} ); }); </script> <?php

include '../../inc/inc.koneksi.php'; include '../../inc/fungsi_tanggal.php'; $tgl1 = jin_date_sql($_POST['tgl1']); $tgl2 = jin_date_sql($_POST['tgl2']);

$where = " WHERE tgl BETWEEN '$tgl1' AND '$tgl2'"; echo "<table id='theTable' class='dua' width='100%'>

<tr>

<th width='5%'>No</th> <th>Tanggal</th> <th>No Anggota</th> <th>Anggota</th> <th>L/P</th> <th>Simpanan</th> <th>Jumlah</th> </tr>";

$sql = "SELECT a.*,b.jenis_simpanan,c.namaanggota,c.jk FROM simpanan as a

JOIN jenis_simpan as b JOIN anggota as c

ON a.id_jenis=b.id_jenis AND a.noanggota=c.noanggota $where

ORDER BY a.id_simpanan DESC"; $query = mysql_query($sql);

$no=1;

while($rows=mysql_fetch_array($query)){ echo "<tr>

<td align='center'>$no</td>

<td align='center'>".jin_date_str($rows[tgl])."</td> <td align='center'>$rows[noanggota]</td>

<td>$rows[namaanggota]</td> <td align='center'>$rows[jk]</td> <td>$rows[jenis_simpanan]</td>

<td align='right'>".number_format($rows[jumlah])."</td> </tr>";

$no++; }

echo "</table>"; ?>

tampil_data3.php

1 2 3 4 5 6 7 8

<script type="text/javascript"> $(function() {

$("#theTable.tiga tr:even").addClass("stripe1"); $("#theTable.tiga tr:odd").addClass("stripe2");

$("#theTable.tiga tr").hover( function() {

(32)

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46

},

function() {

$(this).toggleClass("highlight"); }

); }); </script> <?php

include '../../inc/inc.koneksi.php'; $cari = $_POST['cari'];

$where = " WHERE noanggota LIKE '%$cari%' OR namaanggota LIKE '%$cari%'"; echo "<table id='theTable' class='tiga' width='100%'>

<tr>

<th width='5%'>No</th> <th>Nomor</th>

<th>Nama</th> <th>L/P</th> <th>Total</th> </tr>";

$sql = "SELECT a.noanggota,a.namaanggota,a.jk,

(SELECT sum(jumlah) FROM simpanan WHERE noanggota=a.noanggota) as total FROM anggota as a

$where

ORDER BY noanggota"; $query = mysql_query($sql);

$no=1;

while($rows=mysql_fetch_array($query)){ echo "<tr>

<td align='center'>$no</td>

<td align='center'>$rows[noanggota]</td> <td>$rows[namaanggota]</td>

<td align='center'>$rows[jk]</td>

<td align='right'>".number_format($rows[total])."</td> </tr>";

$no++; }

echo "</table>"; ?>

simpan.php

1 2 3 4 5 6 7 8 9 10 11 12 13

<?php

session_start();

include "../../inc/inc.koneksi.php"; include "../../inc/fungsi_tanggal.php"; $table ="simpanan";

$tgl =jin_date_sql($_POST[tgl]); $no =$_POST[no]; $jenis =$_POST[jenis]; $jml =$_POST[jml];

$userid = $_SESSION[namauser];

(33)

14 15

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 = 'simpanan';

$id = $_POST['id'];

$sql = mysql_query("SELECT * FROM $table WHERE id_simpanan= '$id'"); $row = mysql_num_rows($sql);

if ($row>0){

$input = "DELETE FROM $table WHERE id_simpanan= '$id'"; mysql_query($input);

} ?>

MODUL Pinjaman

pinjaman.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

<script language="javascript" src="modul/pinjaman/ajax.js"></script> <style type="text/css">

button {

margin: 2px; position: relative;

padding: 4px 8px 4px 4px; cursor: pointer;

list-style: none; }

button span.ui-icon { float: left; margin: 0 4px; }

#menu-tombol1 {

padding-bottom:10px; padding:5px 5px 5px 5px; margin-bottom:20px; }

#tombol-tambah{ float:left; width:250px; }

#tombol-cari{ float:right; width:500px; text-align:right; }

#tampil_data2,#tampil_data3{ margin-top:30px; }

#info_anggota{

(34)

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 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

padding:5px 5px 5px 5px; background-color:#FFF; width:450px;

border:3px solid #5c9fe9;

-moz-border-radius: 5px 5px 5px 5px; -webkit-border-radius: 5px 5px 5px 5px; border-radius: 5px 5px 5px 5px;

-moz-box-shadow:0px 0px 20px #aaa; -webkit-box-shadow:0px 0px 20px #aaa; box-shadow:0px 0px 20spx #aaa;

z-index:200px; float:right; left:350px; }

</style> <?php

echo "<div id='dalam_content'>

<h2>DAFTAR PINJAMAN ANGGOTA</h2> <div id='tabs'>

<ul>

<li><a href='#tabs-1'>Pinjaman</a></li> <li><a href='#tabs-2'>Ketentuan</a></li> </ul>

<div id='tabs-1'> <div id='form_isian'>

<div id='info_anggota'></div> <table width='100%'>

<tr>

<td width='15%'>No.Pinjaman</td> <td width='2%'>:</td>

<td><input type='text' id='no' size='15' disabled></td> </tr>

<tr>

<td width='15%'>Nomor Anggota</td> <td width='2%'>:</td>

<td><input type='text' id='nomor' size='15' class='input'></td> </tr>

<tr>

<td width='15%'>Tanggal</td> <td width='2%'>:</td>

<td><input type='tgl' id='tgl' size='12' class='input'></td> </tr>

<tr>

<td width='15%'>Lama Pinjaman</td> <td width='2%'>:</td>

<td><select name='lama' id='lama' class='input'> <option value=''>-Pilih-</option>

<option value='6'>6 Bulan</option> <option value='12'>12 Bulan</option> <option value='24'>24 Bulan</option> </select>

</td> </tr> <tr>

(35)

88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 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

<td width='2%'>:</td>

<td><input type='text' name='bunga' id='bunga' size='5' class='input'> %</td> </tr>

<tr>

<td width='15%'>Jumlah</td> <td width='2%'>:</td>

<td><input type='text' name='jml' id='jml' size='15' class='input'></td> </tr>

<tr>

<td colspan='3' align='center'>

<button class='ui-state-default ui-corner-all' id='simpan'> <span class='ui-icon ui-icon-disk'></span>Simpan </button>

<button class='ui-state-default ui-corner-all' id='tutup'> <span class='ui-icon ui-icon-circle-close'></span>Tutup </button>

</td> </tr> </table> </div>

<div id='menu-tombol1'> <div id='tombol-tambah'>

<button class='ui-state-default ui-corner-all' id='tambah'> <span class='ui-icon ui-icon-circle-plus'></span>Tambah </button>

</div>

<div id='tombol-cari'>

Tanggal <input type='text' id='tgl1' size='10'> s/d <input type='text' id='tgl2' size='10'> <button class='ui-state-default ui-corner-all' id='cari2'>

<span class='ui-icon ui-icon-search'></span>Cari </button>

</div> </div>

<div id='tampil_data1'></div> </div>

<div id='tabs-2'> <p>Ketentuan :</p>

<p>Setiap Anggota meminjam harus memenuhi persyaratan sebagai berikut</p> <ol>

<li>Foto Copy KTP Suami/Istri</li>

<li>Tidak Memiliki Tunggakan Sebelumnya</li> </ol>

(36)

ajax.js

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

// JavaScript Document

$(document).ready(function(){ $(function(){

$('button').hover(

function() { $(this).addClass('ui-state-hover'); }, function() { $(this).removeClass('ui-state-hover'); } );

});

$("#nomor").keyup(function(e){ var isi = $(e.target).val();

$(e.target).val(isi.toUpperCase()); });

$('#tabs').tabs(); $("#tgl").datepicker({

dateFormat:"dd-mm-yy" });

$("#tgl1").datepicker({

dateFormat:"dd-mm-yy" });

$("#tgl2").datepicker({

dateFormat:"dd-mm-yy" });

$("#jml").keypress(function (data) {

if(data.which!=8 && data.which!=0 && (data.which<48 || data.which>57)){ return false;

} });

$("#bunga").keypress(function (data) {

if(data.which!=8 && data.which!=0 && (data.which<48 || data.which>57)){ return false;

} });

$("#form_isian").hide();

$("#tampil_data1").load('modul/pinjaman/tampil_data1.php'); function buatNomor(){

var no = '0001'; $.ajax({

type : "POST",

url : "modul/pinjaman/cari_nomor.php", data : "no="+no,

dataType : "json", success : function(data){

$("#no").val(data.no); }

}); }

$("#tambah").click(function(){ $("#form_isian").show(); $("#menu-tombol1").hide(); $("#nomor").focus();

buatNomor();

var no = $("#no").val();

(37)

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 107 108

})

$("#simpan").click(function(){ simpanHeader(); })

function simpanHeader(){

var no = $("#no").val(); var nomor = $("#nomor").val(); var tgl = $("#tgl").val(); var lama = $("#lama").val(); var jml = $("#jml").val(); var bunga = $("#bunga").val(); if(no.length==0){

alert('Maaf, Nomor Anggota tidak boleh kosong'); $("#no").focus();

return false(); }

if(nomor.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(lama.length==0){

alert('Maaf, Lama Pinjaman tidak boleh kosong'); $("#lama").focus();

return false(); }

if(jml.length==0){

alert('Maaf, Jumlah tidak boleh kosong'); $("#jml").focus();

return false(); }

if(bunga.length==0){

alert('Maaf, Bunga tidak boleh kosong'); $("#bunga").focus();

return false(); }

$.ajax({

type : "POST",

url : "modul/pinjaman/simpan_header.php", data : "no="+no+

"&nomor="+nomor+ "&tgl="+tgl+

"&lama="+lama+ "&bunga="+bunga+ "&jml="+jml, success : function(data){

simpanDetail();

$("#tampil_data1").load('modul/pinjaman/tampil_data_cicilan.php?cari='+no); }

(38)

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 162 163

}

function simpanDetail(){

var no = $("#no").val(); var lama = $("#lama").val(); var jml = $("#jml").val(); var bunga = $("#bunga").val();

var angsuran = parseInt(jml)/parseInt(lama);

var t_bunga = (parseInt(angsuran)*parseInt(bunga))/100; for (var i = 1; i <= lama ; ++i) {

$.ajax({

type : "POST",

url : "modul/pinjaman/simpan_detail.php", data : "no="+no+

"&i="+i+

"&angsuran="+angsuran+ "&t_bunga="+t_bunga, success : function(data){

} }); } }

$("#tutup").click(function(){ $(".input").val(''); $("#form_isian").hide(); $("#menu-tombol1").show();

$("#tampil_data1").load('modul/pinjaman/tampil_data1.php'); })

$("#nomor").keyup(function(){ var cari = $("#nomor").val(); cariAnggota(cari);

})

function cariAnggota(e){ var cari = e; $.ajax({

type : "POST",

url : "modul/pinjaman/cari_anggota.php", data : "cari="+cari,

success : function(data){

$("#info_anggota").html(data); }

}); }

function cariSimpananAnggota(e){ var cari = e;

$.ajax({

type : "GET",

url : "modul/pinjaman/tampil_data1.php", data : "cari="+cari,

success : function(data){

$("#tampil_data1").html(data); }

}); }

(39)

164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206

cariJenis(cari); })

function cariJenis(e){ var cari = e; $.ajax({

type : "POST",

url : "modul/pinjaman/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/pinjaman/tampil_data2.php", data : "tgl1="+tgl1+"&tgl2="+tgl2,

success : function(data){

$("#tampil_data2").html(data); }

}); }

});

cari_nomor.php

1 2 3 4 5 6 7 8

<?php

include "../../inc/inc.koneksi.php"; include "../../inc/fungsi_tanggal.php"; $table = 'pinjaman_header';

$text = "SELECT max(id_pinjam) as noakhir FROM $table";

(40)

9 10 11 12 13 14 15 16 17 18 19 20

if ($row>0){

$r=mysql_fetch_array($sql);

$noakhir = (int) substr($r[noakhir], 2, 4); $noakhir++;

$no = 'P'. sprintf("%04s",$noakhir); $data['no'] = $no; echo json_encode($data); }else{

$data['no'] = 'P0001'; echo json_encode($data);

} ?>

cari_anggota.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

<?php

include "../../inc/inc.koneksi.php"; include "../../inc/fungsi_tanggal.php"; $table = 'anggota';

$id = $_POST['cari']; $text = "SELECT *

FROM $table WHERE noanggota= '$id'"; $sql = mysql_query($text);

$row = mysql_num_rows($sql); if ($row>0){

$r=mysql_fetch_array($sql); if ($r[jk]=='L'){

$sex = 'Laki-laki'; }else{

$sex = 'Perempuan'; }

echo "<table> <tr>

<td>No Identitas</td> <td>: $r[noidentitas]</td> </tr>

<tr>

<td>Nama</td>

<td>: $r[namaanggota]</td> </tr>

<tr>

<td>Jenis Kelamin</td> <td>: $sex</td>

</tr> <tr>

<td>Tempat, Tgl Lahir</td>

<td>: $r[tempat_lahir], ".jin_date_str($r[tgl_lahir])."</td> </tr>

<tr>

<td>Alamat</td> <td>: $r[alamat]</td> </tr>

</table>"; }

(41)

Tampil_data1.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

<script type="text/javascript"> $(function() {

$("#theTable.satu tr:even").addClass("stripe1"); $("#theTable.satu tr:odd").addClass("stripe2");

$("#theTable.satu tr").hover( function() {

$(this).toggleClass("highlight"); },

function() {

$(this).toggleClass("highlight"); }

); });

function deleteRow(ID) { var id = ID;

var pilih = confirm('Data yang akan dihapus = '+id+ '?'); if (pilih==true) {

$.ajax({

type : "POST",

url : "modul/pinjaman/hapus.php", data : "id="+id,

success : function(data){

$("#tampil_data1").load("modul/pinjaman/tampil_data1.php"); }

}); }

}

</script> <?php

include '../../inc/inc.koneksi.php'; include '../../inc/fungsi_tanggal.php'; include '../../inc/fungsi_koperasi.php'; $tgl1 = $_POST['tgl1'];

$tgl2 = $_POST['tgl2']; if(!empty($tgl1)) {

$where = " WHERE tgl BETWEEN '$tgl1' AND '$tgl2'"; }else{

$where =""; }

echo "<table id='theTable' class='satu' width='100%'> <tr>

<th width='5%'>No</th> <th>Nomor</th>

<th>Tanggal</th> <th>No.Anggota</th> <th>Nama</th> <th>L/P</th> <th>Lama</th> <th>Jumlah</th> <th>Bunga</th>

(42)

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

<th>Sisa</th> <th>Hapus</th> </tr>";

$sql = "SELECT a.*,b.namaanggota,b.jk

FROM pinjaman_header as a JOIN anggota as b

ON a.noanggota=b.noanggota $where

ORDER BY a.id_pinjam DESC"; $query = mysql_query($sql);

$no=1;

while($rows=mysql_fetch_array($query)){ $jml_bayar= jmlBayar($rows[id_pinjam]); $jml_cicilan = sisa($rows[id_pinjam]); $sisa = $jml_bayar - $jml_cicilan; echo "<tr>

<td align='center'>$no</td> <td>$rows[id_pinjam]</td>

<td align='center'>".jin_date_str($rows[tgl])."</td> <td align='center'>$rows[noanggota]</td>

<td>$rows[namaanggota]</td> <td align='center'>$rows[jk]</td> <td align='center'>$rows[lama]</td>

<td align='right'>".number_format($rows[jumlah])."</td> <td align='center'>$rows[bunga]</td>

<td align='center'>".number_format($jml_bayar)."</td> <td align='center'>".number_format($jml_cicilan)."</td> <td align='center'>".number_format($sisa)."</td> <td align='center'>

<a href='javascript:deleteRow(\"{$rows[id_pinjam]}\")'>Hapus</a>

</td> </tr>"; $no++;

$gtotal = $gtotal+$rows[jumlah]; }

echo " <tr>

<td colspan='7' align='center'>Total</td>

<td align='right'><b>".number_format($gtotal)."</b></td> </table>";

?>

Tampil_data_cicilan.php

1 2 3 4 5 6 7 8 9

<script type="text/javascript"> $(function() {

$("#theTable tr:even").addClass("stripe1"); $("#theTable tr:odd").addClass("stripe2");

$("#theTable tr").hover( function() {

Referensi

Dokumen terkait

Tesis berjudul (dalam bahasa Indonesia) : ”Analisis Pengaruh Budaya Organisasi dan Kepemimpinan Pengelolaan Koperasi Simpan Pinjam/Unit Simpan Koperasi terhadap

Perubahan mendasar yang dilakukan pada sistem informasi transaksi tahunan yang baru ini adalah pada input data yang dilakukan dengan komputerisasi, manajemen

Pasal 11 peraturan menteri diatas menyatakan jika Kelengkapan legalitas yang terdiri dari Akta Pendirian Koperasi, Anggaran Dasar, perubahan pengesahan Anggaran Dasar bagi

Koperasi Simpan Pinjam juga bertujuan untuk memberi kesempatan kepada anggotanya untuk memperoleh pinjaman dengan mudah dan dengan bunga ringan dan berusaha untuk mencegah para

Pembahasan Untuk mengatasi masalah kurangnya komunikasi antara para anggota koperasi dengan unit koperasi, dapat diselesaikan dengan pemecahan masalah yaitu mengadakan program

Koperasi adalah salah satu penggerak roda perekonomian rakyat yang ada di Indonesia yang berdasarkan asas kekeluargaan dengan tujuan untuk meningkatkan kesejahteraan anggota pada

Gambaran Keseluruhan Koperasi saat ini yang sudah merubah anggaran dasarnya menjadi koperasi syariah adalah sebagai berikut: Tabel 5 Data Koperasi yang Legalitasnya sudah Syariah per

Pengujian Black Box Data Anggota Kasus dan Hasil Pengujian data benar Skenario Realisasi Pengujian Hasil Input semua kebutuhan data yang valid Sistem akan menyimpa n data