APLIKASI E-LIBRARY PADA SDI AL-AZHAR 15 PAMULANG

1 APLIKASI E-LIBRARY PADA SDI AL-AZHAR 15 PAMULANG NINA MARYAMAH PROGRAM STUDI TEKNIK INFORMATIKA FAKULTAS SAINS DAN TEKNOLOGI UNIVERSITAS ISLAM NEGER...
Author:  Ida Sanjaya

100 downloads 1837 Views 1MB Size
"; } elseif( $act == 'update') { $q="UPDATE tbl_buku SET isbn = '$_POST[isbn]', judul_buku = '$_POST[judul_buku]', penerbit = '$_POST[penerbit]', tempat_terbit = '$_POST[tempat_terbit]', pengarang = '$_POST[pengarang]', jum_buku = '$_POST[jum_buku]', jum_halaman = '$_POST[jum_halaman]', tahun_terbit = '$_POST[tahun_terbit]', tanggal = '".date("Y-m-d")."', id_petugas = '$this->adminID' WHERE id_buku = $id"; mysql_query($q) ? $ret=1 : $ret=0; } return $ret; } function tambah_buku($update=false) { $ret = 1; if($update) { /* tambahkan buku ke database */ if($this->cek_empty($_POST)) { return -7; } $isbn=$_POST[isbn]; $jdlBuku= $_POST[judul_buku]; $penerbit= $_POST[penerbit]; $tTerbit = $_POST[tempat_terbit]; $pengarang = $_POST[pengarang]; $jBuku = $_POST[jum_buku]; $jHal = $_POST[jum_hal]; $thnTerbit = $_POST[tahun_terbit]; $q = "INSERT INTO tbl_buku ( isbn, id_petugas, judul_buku, penerbit, tempat_terbit, pengarang, jum_buku, jum_halaman, tahun_terbit, tanggal) VALUES ( '$isbn', '$this->adminID', '$jdlBuku', '$penerbit', '$tTerbit', '$pengarang', '$jBuku', '$jHal', '$thnTerbit','".date("Y-m-d")."')"; mysql_query($q) ? $ret=7: $ret=-7; } else { /* tampilkan form */ $this->show_title_content('tambah-buku.png', "Penambahan Buku", true); echo "
";

161

echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
ISBN";$this>create_input_form("text","isbn");echo "
Judul Buku";$this>create_input_form("text","judul_buku");echo "
Penerbit";$this>create_input_form("text","penerbit");echo "
Tempat terbit";$this>create_input_form("textarea","tempat_terbit");echo "
Pengarang";$this>create_input_form("text","pengarang");echo "
Jumlah Buku";$this>create_input_form("text","jum_buku");echo "
Jumlah Halaman";$this>create_input_form("text","jum_hal");echo "
Tahun Terbit";$this>create_input_form("text","tahun_terbit");echo "
"; echo "

Isi semua kolom !!

"; } return $ret; } function data_booking() { $this->show_title_content('booking-buku.png', 'Data Booking Buku', true); echo "
"; echo ""; echo ""; echo "
id Booking

"; if(isset($_GET[info])) { /* Tampilkan info tentang buku yang dipinjam */ $id=$_GET[info]; $qu = mysql_query("SELECT * FROM tbl_booking where id_booking='$id'"); if(mysql_num_rows($qu)!=1){ echo "

Data booking tidak ada.

"; return; } else { $b=mysql_fetch_array($qu); $qA = mysql_query("SELECT nama_anggota from tbl_anggota where id_anggota='".$b[id_anggota]."'"); $namaA = mysql_result($qA, 0); $now = strtotime(date("Y-m-d")); $batas = strtotime($b[tgl_batas]); if($now > $batas) { $class='warning'; $textInfo = 'Batas waktu telah lewat, tekan hapus untuk menghapus data booking.'; $action='hapus'; $proses='Hapus';

162

} else { $action='proses'; $class='ok'; $textInfo='Tekan tombol proses untuk melanjutkan proses menjadi peminjaman.'; $proses='Proses'; } $qB = mysql_query("SELECT judul_buku FROM tbl_buku where id_buku='".$b[id_buku]."'"); $judulB = mysql_result($qB, 0); echo "

Info booking buku


"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo "
» Id Booking

$b[id_booking]

» Judul Buku

". parse($judulB,31,31)."

» Nama Siswa

". parse($namaA,31,31)."

» Tanggal di booking

$b[tgl_booking]

» Batas Booking

$b[tgl_batas]


"; echo "
"; echo "


"; echo "

$textInfo

"; } } elseif(isset( $_POST[cari])) { /* Cari data booking */ $key=$_POST[q]; $sql = mysql_query("SELECT id_booking from tbl_booking where id_booking='$key'"); if(mysql_num_rows($sql) <1) { echo "

Data booking dengan id \"$key\" tidak ada.

"; return; } else { echo "<script type='text/javascript'> setTimeout(window.location='?act=booking&info=".mysql_result($sql, 0)."', 100); "; } } elseif(isset( $_GET[proses])) { /* proses data booking menjadi pinjam */ if($_POST[proses] == 'Proses') { $qBooking=false; $delBooking = "DELETE FROM tbl_booking where id_booking='$_POST[id_bo]'"; $addPinjam = "INSERT INTO tbl_pinjam(id_pinjam, id_anggota, id_buku, tgl_pinjam, tgl_batas) VALUES (

163

'$_POST[id_bo]', '$_POST[id_a]', '$_POST[id_bu]', '".date("Y-md")."', '".date("Y-m-d",strtotime(date("Y-m-d")) + (86400 * 5))."')"; $qPinjam = mysql_query( $addPinjam) ? true : false; if($qPinjam) { $qBooking = mysql_query( $delBooking) ? true : false; if($qBooking) { echo "

Data Berhasil di proses

"; } } else{ echo "

Data Gagal di proses

"; } } else { /* batalkan booking */ $qDelB = false; $delBooking = "DELETE FROM tbl_booking where id_booking='$_POST[id_bo]'"; $qDelB = mysql_query($delBooking); if($qDelB) { echo "

Booking telah dibatalkan.

"; } else { echo "

Booking gagal dihapus.

"; } } } else { $halaman = isset($_GET[hal]) ? $_GET[hal] : 0; $batas = 10; $mulai=($halaman*$batas); echo "
"; $q = "SELECT * FROM tbl_booking ORDER BY id_booking DESC limit $mulai,$batas"; echo ' '; $buku = mysql_query($q); while($b=mysql_fetch_array($buku)) { (($tmp2++)%2) == 0 ? $c="style='background:#B6D6EC'" : $c="style='background:#CFD3D5'"; echo ""; echo ""; } echo "
id bookingid anggotaid buku tgl bookingtgl batasinfo
$b[id_booking]$b[id_anggota]$b[id_buku] $b[tgl_booking]$b[tgl_batas]
"; echo "

"; echo "
    Halaman
  • "; $total=mysql_num_rows(mysql_query("SELECT * FROM tbl_booking")); $page=ceil($total/$batas);

    164

    $tmp=1; while($tmp<= $page) { if($tmp==($halaman+1)) { echo "
  • $tmp
  • "; } else { echo "
  • $tmp
  • "; } $tmp++; } echo "
"; } } function data_pinjam() { $this->show_title_content('pinjam-buku.png', 'Data Peminjaman Buku', true); echo "
"; echo ""; echo ""; echo "
id Pinjam

"; if(isset($_GET[info])) { /* Tampilkan info tentang buku yang dipinjam */ $id=$_GET[info]; $qu = mysql_query("SELECT * FROM tbl_pinjam where id_pinjam='$id'"); if(mysql_num_rows($qu)!=1){ echo "

Data peminjaman tidak ada.

"; return; } else { $b=mysql_fetch_array($qu); $namaP = mysql_result(mysql_query("SELECT nama_anggota from tbl_anggota where id_anggota='".$b[id_anggota]."'"), 0); $judulB = mysql_result(mysql_query("SELECT judul_buku FROM tbl_buku where id_buku='".$b[id_buku]."'"), 0); $pinjam = strtotime($b[tgl_pinjam]); $now = strtotime(date("Y-m-d")); $batas = $pinjam + (86400 *5); /* 5 hari */ $bedaH = ($now - $batas)/86400; $diDenda = $bedaH > 0 ? true : false; if($diDenda) { $class='warning'; $textInfo = "Pengembalian terlambat $bedaH hari, tekan tombol proses untuk melanjutkan"; $status="Terlambat"; $denda = $bedaH * 100; } else { $class='ok'; $textInfo='Tekan tombol proses untuk melanjutkan proses pengembalian buku.'; $status = "OK";

165

$denda = 0; } echo "

Info Peminjaman buku


"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
» Id Pinjam

$b[id_pinjam]

» Judul Buku

". parse($judulB,31,31)."

» Nama Siswa

". parse($namaP,31,31)."

» Tanggal di pinjam

$b[tgl_pinjam]

» Tanggal sekarang

".date("Y-md")."

» Status

$status

» Denda

Rp. $denda


"; echo "
"; echo "


"; echo "

$textInfo

"; } } elseif(isset( $_POST[cari])) { /* Cari data pinjam */ $key=$_POST[q]; $sql = mysql_query("SELECT id_pinjam from tbl_pinjam where id_pinjam='$key'"); if(mysql_num_rows($sql) <1) { echo "

Data peminjaman dengan id \"$key\" tidak ada.

"; return; } else { echo "<script type='text/javascript'> setTimeout(window.location='?act=pinjam&info=".mysql_result($sql, 0)."', 100); "; } } elseif(isset( $_GET[proses])) { /* proses pengembalian buku */ if($_POST[proses] == 'Proses') { $idPinjam = $_POST[id_p]; $idAnggota = $_POST[id_a]; $idBuku = $_POST[id_b]; $denda = $_POST[denda]; $tglPinjam = $_POST[tglP]; $jum_buku = mysql_result(mysql_query("SELECT jum_buku from tbl_buku where id_buku='$idBuku'"), 0); $delPinjam = "DELETE FROM tbl_pinjam where id_pinjam='$idPinjam'";

166

$addKembali = "INSERT INTO tbl_kembali(id_anggota, id_buku, tgl_pinjam, tgl_kembali, denda) VALUES ( '$idAnggota', '$idBuku', '$tglPinjam', '".date("Y-m-d")."', $denda)"; $addBuku = "UPDATE tbl_buku SET jum_buku = ".($jum_buku+1)." WHERE id_buku ='$idBuku'"; $bigQuery=false; if(mysql_query( $delPinjam)) { if(mysql_query( $addKembali)){ if(mysql_query( $addBuku)) { $bigQuery = true; } } } if($bigQuery){ echo "

Data Berhasil di proses

"; } else{ echo "

Data Gagal di proses

"; } } else {} } else { $halaman = isset($_GET[hal]) ? $_GET[hal] : 0; $batas = 10; $mulai=($halaman*$batas); echo "
"; $q = "SELECT * FROM tbl_pinjam ORDER BY id_pinjam DESC limit $mulai,$batas"; echo ' '; $buku = mysql_query($q); while($b=mysql_fetch_array($buku)) { (($tmp2++)%2) == 0 ? $c="style='background:#B6D6EC'" : $c="style='background:#CFD3D5'"; $bKembali = date("Y-m-d",strtotime($b[tgl_pinjam]) + (86400 * 5)); echo ""; echo ""; } echo "
id pinjamid anggotaid bukutgl pinjamtgl batasinfo
$b[id_pinjam]$b[id_anggota]$b[id_buku] $b[tgl_pinjam]$bKembali
"; echo "

"; echo "
    Halaman
  • "; $total=mysql_num_rows(mysql_query("SELECT * FROM tbl_pinjam")); $page=ceil($total/$batas); $tmp=1; while($tmp<= $page) {

    167

    if($tmp==($halaman+1)) { echo "
  • $tmp
  • "; } else { echo "
  • $tmp
  • "; } $tmp++; } echo "
"; } } function data_siswa() { $this->show_title_content('data-siswa.png', 'Data Siswa', true); echo "
"; echo ""; echo ""; echo "
id Siswa

"; if(isset($_GET[info])) { /* Tampilkan info siswa */ $id=$_GET[info]; $qu = mysql_query("SELECT * FROM tbl_anggota where id_anggota='$id'"); if(mysql_num_rows($qu)!=1){ echo "

Data siswa tidak ada.

"; return; } else { $b=mysql_fetch_array($qu); $jmlBooking = mysql_result( mysql_query("SELECT count(id_buku) FROM tbl_booking WHERE id_anggota='$b[id_anggota]'"), 0); $jmlPinjam = mysql_result( mysql_query("SELECT count(id_buku) FROM tbl_pinjam WHERE id_anggota='$b[id_anggota]'"), 0); $jmlKembali = mysql_result( mysql_query("SELECT count(id_buku) FROM tbl_kembali WHERE id_anggota='$b[id_anggota]'"), 0); $idKelas = mysql_result( mysql_query("SELECT lokal_kelas from tbl_kelas WHERE id_kelas='$b[id_kelas]'"), 0); echo "

Informasi Siswa


"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
» Nis

$b[id_anggota]

» Nama Siswa

". parse($b[nama_anggota],31,31)."

» Kelas

$b[id_kelas] ( $idKelas )

» Angkatan

$b[angkatan]

» Jenis Kelamin

$b[gender] ( ";

168

echo $b[gender]=='L' ? "Laki-laki" : "Perempuan";echo " )

» Tempat TTL

". parse($b[tempat_lahir],21,21).", $b[tgl_lahir]

» Alamat

". parse($b[alamat],31,31)."

» Kodepos

$b[kodepos]

» No telp

$b[telp_anggota]

» Email

$b[email]

"; echo "
Info Buku
Buku yang dibooking:$jmlBooking buah
Buku yang sedang dipinjam:$jmlPinjam buah
Buku yang telah dikembalikan:$jmlKembali buah
"; echo "
"; echo "
"; } } elseif(isset( $_POST[cari])) { /* Cari data pinjam */ $key=$_POST[q]; $sql = mysql_query("SELECT id_anggota from tbl_anggota where id_anggota='$key'"); if(mysql_num_rows($sql) <1) { echo "

Data siswa id \"$key\" tidak ada.

"; return; } else { echo "<script type='text/javascript'> setTimeout(window.location='?act=siswa&info=".mysql_result($sql, 0)."', 100); "; } } elseif(isset( $_GET[edit])) { /* proses pengembalian buku */ $id = $_GET[edit]; $sql = mysql_query( "SELECT * FROM tbl_anggota where id_anggota='$id'"); if(mysql_num_rows($sql) <1) { echo "

Data siswa id \"$id\" tidak ada.

"; return; }

169

if($_POST[proses] == 'Proses') { /* proses data yang telah diedit */ $idAnggota = $_POST[id_a]; $idKelas = $_POST[kelas_a]; $namaA = $_POST[nama_a]; $kelasA = $_POST[kelas_b]; $angkatanA = $_POST[angkatan_a]; $genderA = $_POST[gender]; $tLahir = $_POST[t_lahir]; $tglLahir = $_POST[tgl_lahir]; $alamatA = $_POST[alamat]; $nTelp = $_POST[n_telp]; $email = $_POST[email]; $kPos = $_POST[k_pos]; $pwd = $_POST[pwd]; $sqlU = "UPDATE tbl_anggota SET nama_anggota='$namaA', id_kelas='$idKelas',angkatan = '$angkatanA', gender='$genderA', tempat_lahir='$tLahir', tgl_lahir='$tglLahir', alamat='$alamatA', telp_anggota='$nTelp', kodepos='$kPos', email='$email' "; if(!empty($pwd)) { $sqlU .= ",kata_sandi='".md5($pwd)."' " ;}

$sqlU .= " WHERE id_anggota='$idAnggota'";

if(mysql_query( $sqlU)) { echo "

Data Berhasil di proses

"; } else{ echo "

Data Gagal di proses

"; } echo $sqlU; } else { /* tampilkan edit */ $b = mysql_fetch_array($sql); echo "
"; echo ""; echo ""; echo "
Nama Siswa"; $this->create_input_form('text', 'nama_a',$b[nama_anggota]); echo "
Kelas"; $this->create_input_form('text', 'kelas_a',$b[id_kelas]); echo "
Angkatan"; $this->create_input_form('text', 'angkatan_a',$b[angkatan]); echo "
Jenis Kelamin"; $b[gender]=='L' ? $l='checked' : $w='checked'; echo "Laki-lakiPerempuan"; echo "
Tempat Lahir"; $this->create_input_form('text', 't_lahir', $b[tempat_lahir]); echo "
Tanggal Lahir"; $this->create_input_form('text','tgl_lahir',$b[tgl_lahir]);

170

echo "
No Telp"; $this->create_input_form('text','n_telp', $b[telp_anggota]); echo "
Alamat"; $this->create_input_form('textarea', 'alamat', $b[alamat]); echo "
Kode Pos"; $this->create_input_form('text', 'k_pos', $b[kodepos]); echo "
Email"; $this->create_input_form('text', 'email', $b[email]); echo "
Password"; $this->create_input_form('text', 'pwd', ""); echo "
"; echo ""; echo ""; echo "

"; echo '

Jika tidak ingin mengganti password, biarkan field password kosong.

'; } } elseif(isset( $_GET[hapus])) { /* Hapus data */ $id = $_GET[hapus]; $sqlH = "DELETE FROM tbl_anggota where id_anggota='$id'"; if(mysql_query($sqlH)) { echo "

Data Berhasil di hapus

"; } else { echo "

Data Gagal di hapus

"; } } else { $halaman = isset($_GET[hal]) ? $_GET[hal] : 0; $batas = 10; $mulai=($halaman*$batas); echo "
"; $q = "SELECT * FROM tbl_anggota ORDER BY id_anggota DESC limit $mulai,$batas"; echo ' '; $siswa = mysql_query($q); while($b=mysql_fetch_array($siswa)) { (($tmp2++)%2) == 0 ? $c="style='background:#B6D6EC'" : $c="style='background:#CFD3D5'"; echo ""; echo ""; } echo "
id siswanama siswaid kelas j kelaminangkatanemailinfo
$b[id_anggota]".parse($b[nama_anggota], 25, 25)."$b[id_kelas] $b[gender]$b[angkatan]".parse($b[email], 25, 25)."
"; echo "

";

171

echo "
    Halaman
  • "; $total=mysql_num_rows(mysql_query("SELECT * FROM tbl_anggota")); $page=ceil($total/$batas); $tmp=1; while($tmp<= $page) { if($tmp==($halaman+1)) { echo "
  • $tmp
  • "; } else { echo "
  • $tmp
  • "; } $tmp++; } echo "
"; } } } class var var var var

User extends Html { $status; $name; $id; $titleTable;

function User() { $this->status = $_SESSION['Level']; $this->nama = $_SESSION['Name']; $this->id = $_SESSION['theID']; } function cek_session() { $ret=true; if( $this->status != md5(2)) { $ret=false; } return $ret;

} function show_order_book() { $q="select count(id_booking) from tbl_booking where id_anggota='".$this->id."'"; $q2="select count(id_pinjam) from tbl_pinjam where id_anggota='".$this->id."'"; $t=mysql_result(mysql_query($q), 0); $t2=mysql_result(mysql_query($q2), 0); echo ""; echo "
⇒ Buku dibooking= <strong>$t buah.
⇒ Buku dipinjam= <strong>$t2 buah.
"; } function data_booking() { $dicari = false; $infoText="Tidak ada bookingan buku";

172

$q = "select * from tbl_booking where id_anggota='".$this>id."'"; $this->show_title_content('booking-buku.png', 'Data Booking Buku', true); echo "
"; echo ""; echo ""; echo "
id Booking

"; if(isset($_POST[cari])) { $q .= " && id_booking='".$_POST[q]."'"; $dicari=true;} $x = mysql_query($q); if(mysql_num_rows($x) <1) { if($dicari) {$infoText="Tidak ada buku yang dibooking berdasarkan kata kunci \"$_POST[q]\""; } echo "

$infoText

"; return; } if($dicari) { $b=mysql_fetch_array($x); echo "<script type='text/javascript'> setTimeout(window.location='?act=view&booking=$b[id_booking]', 2000); "; exit; } echo '
'; while($b=mysql_fetch_array($x)) { (($tmp2++)%2) == 0 ? $c="style='background:#B6D6EC'" : $c="style='background:#CFD3D5'"; echo " "; } echo "
id bookingid buku tgl bookingtgl batasinfo
$b[id_booking] $b[id_buku] $b[tgl_booking] $b[tgl_batas]"; echo "
"; echo "
"; } function data_pinjam() { $dicari = false; $infoText = "Tidak Ada buku yang dipinjam"; $q = "select * from tbl_pinjam where id_anggota='".$this>id."'";

173

$this->show_title_content('booking-buku.png', 'Data Peminjaman Buku', true); echo "
"; echo ""; echo ""; echo "
id Pinjam

"; if(isset($_POST[cari])) { $q .= " && id_pinjam='".$_POST[q]."'"; $dicari=true;} $x = mysql_query($q); if(mysql_num_rows($x) <1) { if($dicari) { $infoText="Tidak ada buku yang dipinjam berdasarkan kata kunci \"$_POST[q]\""; } echo "

$infoText

"; return; } if($dicari) { $b=mysql_fetch_array($x); echo "<script type='text/javascript'> setTimeout(window.location='?act=view&pinjam=$b[id_pinjam]', 2000); "; exit; } echo '
'; while($b=mysql_fetch_array($x)) { (($tmp2++)%2) == 0 ? $c="style='background:#B6D6EC'" : $c="style='background:#CFD3D5'"; echo " "; } echo "
id pinjamid buku tgl pinjamtgl batasinfo
$b[id_pinjam] $b[id_buku] $b[tgl_pinjam] $b[tgl_batas]"; echo "
"; echo "
"; } function form_cari() { $this->show_title_content("data-cari.png", "Pencarian Buku"); $this->search_book($this->status); } function view_book() { if(isset($_GET[pinjam])) { /* info peminjaman buku */ $idPinjam = $_GET[pinjam];

174

$sqlP = "SELECT * FROM tbl_pinjam WHERE id_anggota = '$this>id' AND id_pinjam='$idPinjam'"; $q = mysql_query($sqlP); if(mysql_num_rows($q) != 1) { echo "

Data Pinjam dengan id = \"$idPinjam\", tidak ada

"; return; } $Q = mysql_fetch_array($q); $sqlB = "select * from tbl_buku where id_buku='$Q[id_buku]'"; $B = mysql_fetch_array(mysql_query($sqlB)); $tPinjam = strtotime($Q[tgl_pinjam]); $now = strtotime(date("Y-m-d")); $batas = $tPinjam + (86400 *5); /* 5 hari */ $bedaH = ($now - $batas)/86400; $diDenda = $bedaH > 0 ? true : false; if($diDenda) { $class='warning'; $textInfo = "Peminjaman telah melewati batas waktu, harap segera mengembalikan buku ke perpustakaan"; $status="Terlambat"; $denda = $bedaH * 100; } else { $class='ok'; $textInfo='Buku sedang dipinjam, harap merawat buku dengan baik.'; $status = "AKTIF"; $denda = 0; } echo "

Info Peminjaman buku


"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
» Id Pinjam

$Q[id_pinjam]

» Judul Buku

" . parse($B[judul_buku],31,31) . "

» Tanggal di pinjam

$Q[tgl_pinjam]

» Tanggal Batas

$Q[tgl_batas]

» Tanggal sekarang

".date("Y-md")."

» Status

$status

» Denda

Rp. $denda


"; echo "
"; echo "

"; echo "

$textInfo

";

175

} elseif(isset($_GET[booking])) { /* info booking buku */ $idBooking = $_GET[booking]; if(isset($_GET[Cancel])) { mysql_query("DELETE FROM tbl_booking where id_booking='$idBooking'"); echo "

Data booking dengan id \"$idBooking\" telah dihapus

"; echo ""; return; } $sqlP = "SELECT * FROM tbl_booking WHERE id_anggota = '$this->id' AND id_booking='$idBooking'"; $q = mysql_query($sqlP); if(mysql_num_rows($q) != 1) { echo "

Data Booking dengan id = \"$idBooking\", tidak ada

"; return; } $Q = mysql_fetch_array($q); $sqlB = "select * from tbl_buku where id_buku='$Q[id_buku]'"; $B = mysql_fetch_array(mysql_query($sqlB)); $tPinjam = strtotime($Q[tgl_booking]); $now = strtotime(date("Y-m-d")); $batas = strtotime($Q[tgl_batas]); $bedaH = ($now - $batas)/86400; $diDenda = $bedaH > 0 ? true : false; if($diDenda) { $class='warning'; $textInfo = "Booking buku telah melewati batas waktu, id tidak dapat digunakan lagi."; $status="Tidak Aktif"; } else { $class='ok'; $textInfo='Booking masih berlaku, harap segera menukar id ini dengan buku yang dibooking.'; $status = "AKTIF"; } echo "

Info Booking buku


"; echo ""; echo ""; echo ""; echo ""; echo ""; echo "";

176

echo ""; echo "
» Id Booking

$idBooking

» Judul Buku

" . parse($B[judul_buku],31,31) . "

» Tanggal di booking

$Q[tgl_booking]

» Tanggal Batas

$Q[tgl_batas]

» Tanggal sekarang

".date("Y-md")."

» Status

$status


"; echo "

"; echo "

$textInfo

"; } elseif(isset($_GET[buku])) { /* info buku */ $idBuku = $_GET[buku]; $sqlP = "SELECT * FROM tbl_buku WHERE id_buku='$idBuku'"; $q = mysql_query($sqlP); if(mysql_num_rows($q) != 1) { echo "

Buku dengan id = \"$idBuku\", tidak ada

"; return; } $Q = mysql_fetch_array($q); $Q[jum_buku] < 1 ? $kosong=true : $kosong=false; if(isset($_GET[bookNow]) and !$kosong) { $haveId=false; $val = $Q[jum_buku] - 1; $now = date("Y-m-d"); $batas = date("Y-m-d",strtotime($now) + (86400 * 2)); while(!$haveId){ $newId = mt_rand(1,1000); $x = mysql_query("SELECT id_booking FROM tbl_booking WHERE id_booking='$newId'"); if(mysql_num_rows($x)<1) { $haveId=true; } } mysql_query("UPDATE tbl_buku SET jum_buku='$val' WHERE id_buku='$idBuku'"); mysql_query("INSERT INTO tbl_booking (id_booking, id_anggota, id_buku, tgl_booking, tgl_batas) VALUES ('$newId', '$this->id', '$idBuku', '$now', '$batas')"); $B = mysql_fetch_array(mysql_query("SELECT * FROM tbl_booking WHERE id_booking='$newId'")); echo "

Booking Buku Berhasil


"; echo ""; echo ""; echo ""; echo ""; echo "
";

177

echo "
» Id Booking

$B[id_booking]

» Id Buku

$B[id_buku]

» Tanggal Pinjam

$B[tgl_booking]

» Tanggal Batas

$B[tgl_batas]


"; echo "

Booking buku berhasil, harap mengambil buku dengan memberikan nomor id diatas.

"; return; } if($kosong) { $class='warning'; $textInfo = "Stok buku sedang kosong, anda tidak dapat melakukan booking."; $status="Kosong"; } else { $class='ok'; $textInfo='Buku tersedia silahkan tekan Booking untuk melakukan pembookingan.'; $status = "Tersedia"; } echo "

Info Buku


"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "" ; echo ""; echo ""; echo ""; echo ""; echo "
» Id Buku

$idBuku

» Isbn

$Q[isbn]

» Judul Buku

" . parse($Q[judul_buku],31,31) . "

» Penerbit

". parse($Q[penerbit],31,31) . "

» Tempat Terbit

" . parse($Q[tempat_terbit],31,31) . "

» Pengarang

".parse($Q[pengarang],31,31)."

» Jumlah Buku

$Q[jum_buku]

» Jumlah Halaman

$Q[jum_halaman]

» Tahun Terbit

$Q[tahun_terbit]

» Status

$status


"; if(!$kosong) { echo ""; } echo "
"; echo "

";

178

}

echo "

$textInfo

";

}

} ?>

Logout

179