Anda di halaman 1dari 44

Modul

Sistem Informasi Koperasi


SIMPAN PINJAM
(MySQL, PHP & JQuery)

Oleh : Deddy Rusdiansyah,S.Kom

Penguatan Daya Saing (PDS)


PIKSI INPUT SERANG
2012

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>
<td>&nbsp;:&nbsp;<input type="text" name="username" class="text" id="username" /></td>
2
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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;
font-weight:bold;
3
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

28 }
29 button {
30
-moz-border-radius: 5px 5px 5px 5px;
31
-webkit-border-radius: 5px 5px 5px 5px;
32
border-radius: 5px 5px 5px 5px;
33
-moz-box-shadow:0px 0px 4px #aaa;
34
-webkit-box-shadow:0px 0px 4px #aaa;
35
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';
</script>
4
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

31
<?php
32
}
33 }
34 ?>

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">
<?php include 'menu.php'; ?>
5
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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
include "inc/inc.koneksi.php";
$mod = $_GET['module'];
if ($mod=='home'){
6
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>";
}
?>

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;
background:#BDD2FF;
font-size:12px;
7
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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;
font:normal 11px Verdana, Geneva, sans-serif;
font-weight:bold;
8
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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){
$hasil
= $data['total'];
9
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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

}else{
$hasil
}
return $hasil;

= 0;

}
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>
<td>ID</td>
10
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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
// JavaScript Document
2
$(document).ready(function(){
3
$(function(){
4
$('button').hover(
5
function() { $(this).addClass('ui-state-hover'); },
6
function() { $(this).removeClass('ui-state-hover'); }
7
);
8
});
9
$('#form_input').dialog({
10
autoOpen: false,
11
show: "blind",
12
hide: "blind",
13
width: 450,
14
modal : true,
15
resizable:false,
16
buttons: {
17
"Simpan": function() {
18
//$(this).dialog("close");
19
simpan();
20
},
21
"Batal": function() {
22
$(this).dialog("close");
23
}
24
}
25
});
26
$("#tampil_data").load('modul/jenis/tampil_data.php');
27
$('#tambah').click(function(){
28
$(".input").val('');
29
$('#form_input').dialog('open');
30
return false;
31
});
32
33
$("#jml").keypress(function (data) {
34
if(data.which!=8 && data.which!=0 && (data.which<48 || data.which>57)){
35
return false;
11
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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
var jenis
var jml

= $("#id").val();
= $("#jenis").val();
= $("#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
<script type="text/javascript">
2
$(function() {
3
$("#theTable tr:even").addClass("stripe1");
4
$("#theTable tr:odd").addClass("stripe2");
5
6
$("#theTable tr").hover(
7
function() {
8
$(this).toggleClass("highlight");
9
},
10
function() {
11
$(this).toggleClass("highlight");
12
}
13
);
14
});
15
function editRow(ID){
16
var id = ID;
17
var pilih = confirm('Data yang akan mengubah = '+id+ '?');
18
if (pilih==true) {
$.ajax({
19
20
type : "POST",
12
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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>
</td>
</tr>";
13
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

76
$no++;
77
}
78 echo "</table>";
79 ?>

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']
$data['jml']

= $r[jenis_simpanan];
= $r[jumlah];

echo json_encode($data);
}
}else{
$data['jenis']
$data['jml']

= $r[jenis_simpanan];
= $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{
$input = "INSERT INTO $table (id_jenis,jenis_simpanan,jumlah)
VALUES('$id','$jenis','$jml')";
14
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);
}
?>

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;
}
#tombol-cari{
float:right;
width:550px;
15
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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>
<td><input type='text' name='tempat' id='tempat' size='30' maxlength='30' class='input'></td>
16
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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
// JavaScript Document
2
$(document).ready(function(){
3
$(function(){
4
$('button').hover(
5
function() { $(this).addClass('ui-state-hover'); },
6
function() { $(this).removeClass('ui-state-hover'); }
7
);
8
});
9
$('#form_input').dialog({
10
autoOpen: false,
11
show: "blind",
12
hide: "blind",
13
width: 550,
modal : true,
14
resizable:false,
15
16
buttons: {
"Simpan": function() {
17
18
//$(this).dialog("close");
19
simpan();
},
20
21
"Batal": function() {
$(this).dialog("close");
22
}
23
24
}
25
});
26
$("#tgl").datepicker({
27
dateFormat:"dd-mm-yy"
28
});
29
$("#tampil_data").load('modul/anggota/tampil_data.php');
30
$('#tambah').click(function(){
31
$(".input").val('');
32
$("#nomor").attr("disabled",false);
17
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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
var id
var nama
var jk
var tempat
var tgl
var alamat
var hp

= $("#nomor").val();
= $("#identitas").val();
= $("#anggota").val();
= $("#jk").val();
= $("#tempat").val();
= $("#tgl").val();
= $("#alamat").val();
= $("#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({
18
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);
}
});
}

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;
var pilih = confirm('Data yang akan dihapus = '+id+ '?');
19
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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++;
}
echo "</table>";
?>

20
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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){
$input = "UPDATE $table SET noidentitas
='$id',
21
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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 {
padding-bottom:10px;
22
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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>
<tr>
23
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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>
</div>
</div>";
?>
24
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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){
alert('Maaf, Jenis Simpanan tidak boleh kosong');
25
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
url
data

: "POST",
: "modul/simpanan/simpan.php",
: "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);
}
});
26
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);
});
27
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);
}
});
}

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

28
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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);
}
});
}
}
</script>
<?php
29
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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
<script type="text/javascript">
2
$(function() {
3
$("#theTable.dua tr:even").addClass("stripe1");
4
$("#theTable.dua tr:odd").addClass("stripe2");
5
6
$("#theTable.dua tr").hover(
7
function() {
8
$(this).toggleClass("highlight");
9
},
10
function() {
11
$(this).toggleClass("highlight");
30
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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() {
$(this).toggleClass("highlight");
31
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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];
$input = "INSERT INTO $table (tgl,noanggota,id_jenis,jumlah,user_id)
VALUES('$tgl','$no','$jenis','$jml','$userid')";
mysql_query($input);
32
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

14 echo "<b>Data sukses disimpan</b>";


15 ?>

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{
position:absolute;
33
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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>
<td width='15%'>Bunga</td>
34
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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>
</div>
</div>
</div>";
?>

35
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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();
$("#tampil_data1").load('modul/pinjaman/tampil_data_cicilan.php?cari='+no);
36
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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);
}
});
37
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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);
}
});
}
$("#jenis").change(function(){
var cari = $("#jenis").val();
38
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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";
$sql
= mysql_query($text);
$row = mysql_num_rows($sql);
39
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

9
if ($row>0){
10
$r=mysql_fetch_array($sql);
11
$noakhir
= (int) substr($r[noakhir], 2, 4);
12
$noakhir++;
13
$no = 'P'. sprintf("%04s",$noakhir);
14
$data['no']
= $no;
15
echo json_encode($data);
16 }else{
17
$data['no']
= 'P0001';
18
echo json_encode($data);
19 }
20 ?>
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>";
}
?>
40
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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>
<th>Jumlah <br>Bayar</th>
<th>Jumlah <br>Cicilan</th>
41
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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 echo "
91
92
93
94
95 ?>

<th>Sisa</th>
<th>Hapus</th>
</tr>";
= "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>
$sql

</td>
</tr>";
$no++;
$gtotal = $gtotal+$rows[jumlah];
}
<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() {
$(this).toggleClass("highlight");
},
42
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

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
54
55
56
57
58
59
60
61
62
63
64

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);
}
});
}
}
</script>
<?php
include '../../inc/inc.koneksi.php';
include '../../inc/fungsi_tanggal.php';
$cari = $_GET['cari'];
$where = " WHERE id_pinjam='$cari'";
echo "<table id='theTable' width='100%'>
<tr>
<th width='5%'>No</th>
<th>Cicilan Ke</th>
<th>Angsuran</th>
<th>Bunga</th>
<th>Total</th>
</tr>";
$sql
= "SELECT *
FROM pinjaman_detail
$where
ORDER BY id_pinjam,cicilan";
$query = mysql_query($sql);
$no=1;
while($rows=mysql_fetch_array($query)){
$jumlah = $rows[angsuran]+ $rows[bunga];
echo "<tr>
<td align='center'>$no</td>
<td align='center'>$rows[cicilan]</td>
<td align='right'>".number_format($rows[angsuran])."</td>
<td align='right'>".number_format($rows[bunga])."</td>
<td align='right'>".number_format($jumlah)."</td>
</tr>";
$no++;
$gtotal = $gtotal+$jumlah;
}
echo "<tr>
<td colspan='4' align='center'>Total</td>
<td align='right'><b>".number_format($gtotal)."</b></td>
43
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

65
</table>";
66 ?>
Simpan_header.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

<?php
session_start();
include "../../inc/inc.koneksi.php";
include "../../inc/fungsi_tanggal.php";
$table ="pinjaman_header";
$tgl
=jin_date_sql($_POST[tgl]);
$no
=$_POST[no];
$nomor=$_POST[nomor];
$lama =$_POST[lama];
$jml =$_POST[jml];
$bunga =$_POST[bunga];
$userid = $_SESSION[namauser];
$input = "INSERT INTO $table (id_pinjam,tgl,noanggota,jumlah,lama,bunga,user_id)
VALUES('$no','$tgl','$nomor','$jml','$lama','$bunga','$userid')";
mysql_query($input);
echo "<b>Data sukses disimpan</b>";
?>

Simpan_detail.php
1
<?php
2
include "../../inc/inc.koneksi.php";
3
$table
="pinjaman_detail";
4
$no
=$_POST[no];
5
$cicilan=$_POST[i];
6
$angsuran
=$_POST[angsuran];
7
$bunga
=$_POST[t_bunga];
8
$input = "INSERT INTO $table (id_pinjam,cicilan,angsuran,bunga)
9
VALUES('$no','$cicilan','$angsuran','$bunga')";
10 mysql_query($input);
11 echo "<b>Data sukses disimpan</b>";
12 ?>
hapus.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14

<?php
include "../../inc/inc.koneksi.php";
$tableH
= 'pinjaman_header';
$tableD
= 'pinjaman_detail';
$id
= $_POST['id'];
$sql = mysql_query("SELECT * FROM $tableH WHERE id_pinjam= '$id'");
$row = mysql_num_rows($sql);
if ($row>0){
$input = "DELETE FROM $tableD WHERE id_pinjam= '$id'";
mysql_query($input);
$input = "DELETE FROM $tableH WHERE id_pinjam= '$id'";
mysql_query($input);
}
?>

44
Modul Sistem Informasi Koperasi
Deddy Rusdiansyah,S.Kom

Anda mungkin juga menyukai