Anda di halaman 1dari 28

TUTORIAL APLIKASI KASIR

TUGAS BESAR PEMROGRAMAN WEB

Oleh :

Kelompok 9

Dwi Octaviani 3311501062


Nindy Surya Agustin 3311501063

PROGRAM STUDI TEKNIK INFORMATIKA


POLITEKNIK NEGERI BATAM
BATAM
2016
Perancangan ER Diagram

Skema relasional tabel

Tabel Pengguna

Nama Field Tipe Keterangan


Id Int(11) Primary Key
Username Varchar(255) -
Password Varchar(255) -

Tabel Barang

Nama Field Tipe Keterangan


Kode_barang Int(11) Primary Key
Nama_barang Varchar(50) -
Harga Float -
Jenis_barang Varchar(20) -

Tabel Transaksi

Nama Field Tipe Keterangan


Kode_transaksi Int(11) Primary Key
Kode_barang Int(11) Foreign Key
Id Varchar(20) Foreign Key
Quantity Int(11) -
Total Int(11) -
Tutorial

1. Download Code Igniter di situs www.codeigniter.com


Kemudian ekstrak file yang sudah di download, ubah nama folder tersebut menjadi
CI_tugasbesar dan letakkan pada folder XAMPP/htdocs

2. Download HTML2PDF di http://html2pdf.fr/en/download . Extract filenya di folder


htdocs - CI_tugasbesar - asset.

3. Aktifkan Web Server XAMPP dan Start pada Module Apache dan Mysql

4. Buat database dengan nama db_kasir dengan tabel-tabel seperti berikut


5. Edit file database.php yang berada di folder
CI_tugasbesar/application/config/database.php menjadi seperti berikut :

6. Tabel Nama File dan Folder yang terletak pada folder Application.
No Nama Folder Nama File

1 models Barang_model.php
Kasir_model.php
Laporan_model.php
Login_model.php

2 controllers barang.php
kasir.php
laporan.php
login.php

3 views Barang_view.php
add_barang_view.php
update_barang_view.php
add_kasir_view.php
kasir_view.php
Login_view.php
Print.php
7. Beri nama kode berikut dengan Barang_model.php dan letakan file sesuai dengan
ketentuan tabel

<?php
//File barang_model.php

class Barang_model extends CI_Model


{

function __construct()
{
parent::__construct();
}

function getAllBarang()
{
$this->db->select("*");
$this->db->from("barang");

return $this->db->get();
}

function getBarang($kode)
{
$this->db->where('kode_barang', $kode);
$this->db->select("*");
$this->db->from("barang");

return $this->db->get();
}

function addBarang($data)
{
$this->db->insert('barang', $data);
}

function updatebarang($data, $condition)


{
$this->db->where($condition);
$this->db->update('barang', $data);

function deleteBarang($kode)
{
$this->db->where('kode_barang', $kode);
$this->db->delete('barang');
}
}

8. Beri nama kode berikut dengan barang.php dan letakan file sesuai dengan ketentuan
tabel

<?php if ( ! defined('BASEPATH')) exit('No direct script access


allowed');

class Barang extends CI_Controller


{
function __construct()
{
parent::__construct();
$this->load->model("Barang_model");
}

public function index()


{
$data['listBarang'] = $this-
>Barang_model->getAllBarang();
$this->load->view('barang_view',
$data);
}

public function addBarang()


{
$this->load->view('add_barang_view');
}

public function addBarangDb()


{
$data = array('nama_barang' =>
$this->input->post('nama_barang'),'harga' => $this->input-
>post('harga'),
'jenis_barang' => $this->input-
>post('jenis_barang'));
$this->Barang_model-
>addBarang($data);
redirect('barang');
}

public function updateBarang($kode_barang)


{
$data['barang'] = $this->Barang_model-
>getBarang($kode_barang);
$this->load->view('update_barang_view',
$data);
}

public function updateBarangDb()


{
$data = array('nama_barang' => $this-
>input->post('nama_barang'),'harga' => $this->input->post('harga'),
'jenis_barang' => $this->input-
>post('jenis_barang'));
$condition['kode_barang'] = $this-
>input->post('kode_barang');
$this->Barang_model-
>updateBarang($data, $condition);
redirect('barang');
}

public function deleteBarangDb($kode_barang)


{
$this->Barang_model-
>deleteBarang($kode_barang);
redirect('barang');
}
}
9. Beri nama kode berikut dengan barang_view.php dan letakan file sesuai dengan
ketentuan tabel

<!-- File barang_view.php -->


<html>
<head>
<title>LIHAT BARANG</title>
<style type="text/css">
body{
width: 80%;
margin: 20px auto;
background:black;
}
.container{
width: 100%;
margin: 30px auto;
}

/*bagian header*/
.header{
background: #DCDCDC;
padding: 2px 10px;
text-align: center;
font:100% Freestyle Script;
font-size:20px;
color: #665039;
}
/*akhir header*/

.clear{
clear: both;
}

.nav{
height: 500px;
}
/*bagian sidebar*/
.container .nav .sidebar{
background: #222;
float: left;
width: 25%;
height: 500px;
}

/*akhir sidebar*/

.container .nav .content{


background: #F5F5DC;
float: left;
height: 500px;
width: 75%;
font:100% Tekton Pro;
}

.footer{
padding: 2px 10px;
background: #DCDCDC;
font:100% Chaparral Pro Light;
color: #665039;
}
a:link, a:visited {
display: block;
width: 75%;
font-weight: #F0FFFF;
color: gold;
background-color:#2F4F4F ;
text-align: center;
padding: 10px;
text-decoration: none;
text-transform: uppercase;
}

a:hover, a:active {
background-color: black;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>Aplikasi Kasir</h1>
</div>
<div class="nav">
<div class="sidebar">
<br>
<ul style="list-style-type:none">
<p><li><a href="<?= base_url()
?>index.php/barang/addBarang">TAMBAH BARANG</a></li>
<p><li><a href="<?= base_url()
?>index.php/kasir">LIHAT TRANSAKSI</a></li>
<p><li><a href="<?= base_url()
?>index.php/kasir/addkasir">TRANSAKSI BARU</a></li>
<p><li><a href="<?= base_url()
?>index.php/login/logout">LOGOUT</a></li>

</ul>
</div>
<?php

$jumlahBarang = $listBarang->num_rows();
?>

<?php
if($jumlahBarang > 0){
?>
<div class="content">
<center><h3>Data Barang</h3></center>
<center>
<table width="550" border="1" align ="center"
>
<thead>
<tr bgcolor="#DCDCDC">
<th> No.</th>
<th>Kode Barang</th>
<th>Nama Barang</th>
<th>Harga</th>
<th>Stok</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
foreach ($listBarang-
>result() as $row) {
?>
<tr>
<td><?= $i++ ?></td>
<td><?= $row->kode_barang
?></td>
<td><?= $row->nama_barang
?></td>
<td><?= $row->harga ?></td>
<td><?= $row-
>jenis_barang?></td>
<td>
<a href="<?=
base_url() ?>index.php/barang/updateBarang/<?= $row->kode_barang
?>">Update</a>
<a href="<?=
base_url() ?>index.php/barang/deleteBarangDb/<?= $row->kode_barang
?>">Delete</a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</center>
<?php
}
?>
</div>
<div class="clear"></div>
<div class="footer">
<marquee><b>Tugas Besar Pemrograman Web by Dwi
Octaviani & Nindy Surya Agustin</marquee></font>
</div>
</div>
</body>
</html>

10. Beri nama kode berikut dengan add_barang_view.php dan letakan file sesuai dengan
ketentuan tabel

<!-- File add_barang_view.php -->


<html>
<head>
<title>Tambah Data Barang</title>
<style type="text/css">

body{
width: 80%;
margin: 20px auto;
background:black;
}
.container{
width: 90%;
margin: 30px auto;
}

/*bagian header*/
.header{
background: #DCDCDC;
padding: 2px 10px;
text-align: center;
font:100% Freestyle Script;
font-size:20px;
color: #665039;
}
/*akhir header*/

.clear{
clear: both;
}

.nav{
height: 500px;
}
/*bagian sidebar*/
.container .nav .sidebar{
background: #222;
float: left;
width: 25%;
height: 500px;
}

/*akhir sidebar*/

.container .nav .content{


background: #F5F5DC;
float: left;
height: 500px;
width: 75%;
font:100% Tekton Pro;
}

.footer{
padding: 2px 10px;
background: #DCDCDC;
font:100% Chaparral Pro Light;
color: #665039;
}

a:link, a:visited {
display: block;
width: 75%;
font-weight: #F0FFFF;
color: gold;
background-color:#2F4F4F ;
text-align: center;
padding: 10px;
text-decoration: none;
text-transform: uppercase;
}
a:hover, a:active {
background-color: black;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>Aplikasi Kasir</h1>
</div>

<div class="nav">
<div class="sidebar">
<br>
<ul style="list-style-type:none">
<p><li><a href="<?=
base_url() ?>index.php/barang">LIHAT BARANG</a></li>
<p><li><a href="<?=
base_url() ?>index.php/kasir">LIHAT TRANSAKSI</a></li>
<p><li><a href="<?=
base_url() ?>index.php/kasir/addkasir">TRANSAKSI BARU</a></li>
<p><li><a href="<?=
base_url() ?>index.php/login/logout">LOGOUT</a></li>

</ul>
</div>

<div class="content">
<br>
<br>
<br>
<table width="550" border="1" align
="center" >
<form method="post" action="<?= base_url()
?>index.php/barang/addBarangDb">
<tr>
<td height="40"
align="center" bgcolor="#ebf185"><font color="black">
<b>Tambah
Barang</b></font></td>
</tr>
<tr>
<td
bgcolor="#f6fbe0"><table width="550" border="0" align="center"
cellpadding="10" cellspacing="8">
</tr>
<tr>
<td width="163">Nama Barang </td>

<td width="400"><input
type="text" placeholder="nama barang" name="nama_barang"
size="40"/></td>
</tr>
<tr>
<td width="163">Harga (Rp)</td>
<td width="400"><input
type="text" placeholder= "harga" name="harga" size="20"/></td>
</tr>
<tr>
<td height="50">Jenis
Barang</td>
<td>:
<select
name="jenis_barang">
<option
value="">Pilih Jenis</option>
<option
value="Makanan">Makanan</option>
<option
value="Minuman">Minuman</option>
<option
value="Snack">Snack</option>
</select>
</td>
</tr>
<tr>
<td>
<center><input
type="submit" value="Simpan barang" /></center>
</form>
</td>
</tr>
</table></table>
</div></div>

<div class="clear"></div>
<div class="footer">
<marquee><b>Tugas Besar Pemrograman Web
by Dwi Octaviani & Nindy Surya Agustin</marquee></font>
</div>
</div>
</body>
</html>

11. Beri nama kode berikut dengan update_barang_view.php dan letakan file sesuai
dengan ketentuan tabel

<!-- File update_barang_view.php -->


<html>
<head>
<title>Ubah Data Barang</title>
<style type="text/css">

body{
width: 80%;
margin: 20px auto;
background:black;
}
.container{
width: 90%;
margin: 30px auto;
}

/*bagian header*/
.header{
background: #DCDCDC;
padding: 2px 10px;
text-align: center;
font:100% Freestyle Script;
font-size:20px;
color: #665039;
}
/*akhir header*/

.clear{
clear: both;
}

.nav{
height: 500px;
}
/*bagian sidebar*/
.container .nav .sidebar{
background: #222;
float: left;
width: 25%;
height: 500px;
}

/*akhir sidebar*/

.container .nav .content{


background: #F5F5DC;
float: left;
height: 500px;
width: 75%;
font:100% Tekton Pro;
}

.footer{
padding: 2px 10px;
background: #DCDCDC;
font:100% Chaparral Pro Light;
color: #665039;
}

a:link, a:visited {
display: block;
width: 75%;
font-weight: #F0FFFF;
color: gold;
background-color:#2F4F4F ;
text-align: center;
padding: 10px;
text-decoration: none;
text-transform: uppercase;
}

a:hover, a:active {
background-color: black;
}
</style>
<body>
<div class="container">
<div class="header">
<h1>Aplikasi Kasir</h1>
</div>

<div class="nav">
<div class="sidebar">
<br>
<ul style="list-style-type:none">
<p><li><a href="<?= base_url()
?>index.php/barang/addBarang">TAMBAH BARANG</a></li>
<p><li><a href="<?= base_url()
?>index.php/barang">LIHAT BARANG</a></li>
<p><li><a href="<?= base_url()
?>index.php/kasir">LIHAT TRANSAKSI</a></li>
<p><li><a href="<?= base_url()
?>index.php/kasir/addkasir">TRANSAKSI BARU</a></li>
<p><li><a href="<?= base_url()
?>index.php/login/logout">LOGOUT</a></li>

</ul>
</div>
<div class="content">
<br>
<br>
<br>
<table width="500" border="1" align ="center" >
<?php
foreach($barang->result() as $detail){
?>
<form method="post" action="<?= base_url()
?>index.php/barang/updateBarangDb">
<tr>
<td height="40" align="center"
bgcolor="#ebf185"><font color="black">
<b>Ubah Data Barang</b></font></td>
</tr>
<tr>
<td bgcolor="#f6fbe0"><table
width="452" border="0" align="center" cellpadding="10"
cellspacing="8">
<tr>
<input type="hidden" value="<?php echo $detail-
>kode_barang; ?>" name="kode_barang" />
<tr>
<td width="163">Nama Barang </td>
<td width="400"><input type="text"
placeholder="Nama Barang" name="nama_barang" value="<?php echo
$detail->nama_barang; ?>" /></td>
</tr>
<tr>
<td width="163">Harga (Rp)</td>
<td width="400"><input type="text"
placeholder="harga" name="harga" value="<?php echo $detail->harga;
?>" /></td>
</tr>
<tr>
<td width="163">Jenis</td>
<td width="400"><input type="text"
placeholder="jenis_barang" name="jenis_barang" value="<?php echo
$detail->jenis_barang; ?>" /></td>
</tr>
<tr>
<td>
<center><input type="submit" value="Ubah Data"
/></center>
</form></td></tr>
</table></table>
</div></div>
<?php
}
?>
<div class="clear"></div>
<div class="footer">
<marquee><b>Tugas Besar Pemrograman Web by Dwi
Octaviani & Nindy Surya Agustin</marquee></font>
</div>
</div>
</body>
</html>

12. Beri nama kode berikut dengan Login_Model.php dan letakan file sesuai dengan
ketentuan tabel

<?php

class Login_model extends CI_Model{


function cek_login($table,$where){
return $this->db->get_where($table,$where);
}
}

13. Beri nama kode berikut dengan Login.php dan letakan file sesuai dengan ketentuan
tabel

<?php

class Login extends CI_Controller{

function __construct(){
parent::__construct();
$this->load->model('Login_model');

function index(){
$this->load->view('Login_view');
}

function aksi_login(){
$username = $this->input->post('username');
$password = $this->input->post('password');
$where = array(
'username' => $username,
'password' => md5($password)
);
$cek = $this->Login_model->cek_login("pengguna",$where)-
>num_rows();
if($cek > 0){

$data_session = array(
'id' => $id,
'nama' => $username,
'status' => "login"
);

$this->session->set_userdata($data_session);

redirect(base_url("index.php/kasir/addKasir"));

}else{
echo "Username dan password salah !";
?> <a href="<?php echo base_url('index.php/login');
?>">Kembali</a> <?php
}
}

function logout(){
$this->session->sess_destroy();
redirect(base_url('index.php/login'));
}
} ?>

14. Beri nama kode berikut dengan Login_view.php dan letakan file sesuai dengan
ketentuan tabel

<!DOCTYPE html>
<html>
<head>
<title>Login User</title>
<style type="text/css">
body{
width: 80%;
margin: 20px auto;
background:black;
}
.container{
width: 90%;
margin: 30px auto;
}

/*bagian header*/
.header{
background: #DCDCDC;
padding: 2px 10px;
text-align: center;
font:100% Freestyle Script;
font-size:20px;
color: #665039;
}
/*akhir header*/

.clear{
clear: both;
}

.nav{
height: 500px;
}
/*bagian sidebar*/
.container .nav .sidebar{
background: #222;
float: left;
width: 25%;
height: 500px;
}

/*akhir sidebar*/

.container .nav .content{


background: #F5F5DC;
float: left;
height: 500px;
width: 100%;
font:100% Tekton Pro;
}

.footer{
padding: 2px 10px;
background: #DCDCDC;
font:100% Chaparral Pro Light;
color: #665039;
}

a:link, a:visited {
display: block;
width: 75%;
font-weight: #F0FFFF;
color: gold;
background-color:#2F4F4F ;
text-align: center;
padding: 10px;
text-decoration: none;
text-transform: uppercase;
}

a:hover, a:active {
background-color: black;
}
.boxmodel{
background: white;
border: 5px solid;
height: 250px;
margin: 40px;
padding: 15px;
width: 450px;
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>Aplikasi Kasir</h1>
</div>
<div class="nav">
<div class="content">
<br>
<br>
<br>
<table width="350" border="1" align ="center" >
<form name='login' action="<?php echo
base_url('index.php/login/aksi_login'); ?>" method='post'>
<tr>
<td height="40" align="center"
bgcolor="#ebf185"><font color="black">
<H2><b>LOGIN</b></H2></font></td>
</tr>
<tr>
<td bgcolor="#f6fbe0"><table width="350" border="0"
align="center" cellpadding="10" cellspacing="10">
<tr>
<td width="163"><b>Username</td>
<td width="400"><input align='center' type='text'
name='username' placeholder="Username" size="20"/></td>
</tr>
<tr>
<td width="163"><b>Password</td>
<td width="400"><input align='center' type='password'
name='password' placeholder="Password" /></td>
</tr>
<tr>
<td colspan="3">
<center><input align='center' type='submit' name='submit'
value="LOGIN" /></center>
</form>
</td>
</tr>
</table></table>
</div></div>
<div class="clear"></div>
<div class="footer">
<marquee><b>Tugas Besar Pemrograman Web by
Dwi Octaviani & Nindy Surya Agustin</marquee></font>
</div>
</div>
</body>
</html>

15. Beri nama kode berikut dengan Kasir_model.php dan letakan file sesuai dengan
ketentuan tabel

<?php if ( ! defined('BASEPATH')) exit('No direct script access


allowed');
class Kasir_model extends CI_Model{

public function __construct()


{
parent::__construct();
}

function getAllKasir()
{
$this->db->select("*");
$this->db->from("transaksi");
return $this->db->get();
}

function addKasir($data)
{
$this->db->insert('transaksi', $data);
}

function deleteTransaksi($kode)
{
$this->db->where('kode_transaksi', $kode);
$this->db->delete('transaksi');
}

16. Beri nama kode berikut dengan Kasir.php dan letakan file sesuai dengan ketentuan
tabel

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class kasir extends CI_Controller {

function __construct()
{
parent::__construct();
$this->load->model("Kasir_model");
}

public function index()


{
$data['listKasir'] = $this->Kasir_model->getAllKasir();
$this->load->view('kasir_view', $data);
}

public function addKasir()


{
$this->load->view('add_kasir_view');
}

public function addKasirDb()


{
$data = array('kode_barang' => $this->input-
>post('kode_barang'),'quantity' => $this->input->post('quantity'),
'total' => $this->input->post('total'),'id' =>
$this->input->post('nama_kasir'));
$this->Kasir_model->addKasir($data);
redirect('kasir');
}

public function deleteTransaksiDb($kode_transaksi)


{
$this->Kasir_model->deleteTransaksi($kode_transaksi);
redirect('kasir');
}
}
17. Beri nama kode berikut dengan add_kasir_view.php dan letakan file sesuai dengan
ketentuan tabel

<!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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>APLIKASI KASIR</title>
<link rel="stylesheet" type="text/css"
href="ss.css">
<link rel="stylesheet" href="css/font-
awesome.min.css"/>
<style type="text/css">
body{
width: 80%;
margin: 20px auto;
background:black;
}
.container{
width: 100%;
margin: 30px auto;
}

/*bagian header*/
.header{
background: #DCDCDC;
padding: 2px 10px;
text-align: center;
font:100% Freestyle Script;
font-size:20px;
color: #665039;
}
/*akhir header*/

.clear{
clear: both;
}

.nav{
height: 500px;
}
/*bagian sidebar*/
.container .nav .sidebar{
background: #222;
float: left;
width: 25%;
height: 500px;
}

/*akhir sidebar*/

.container .nav .content{


background: #F5F5DC;
float: left;
height: 500px;
width: 75%;
font:100% Tekton Pro;
}

.footer{
padding: 2px 10px;
background: #DCDCDC;
font:100% Chaparral Pro Light;
color: #665039;
}

a:link, a:visited {
display: block;
width: 75%;
font-weight: #F0FFFF;
color: gold;
background-color:#2F4F4F ;
text-align: center;
padding: 10px;
text-decoration: none;
text-transform: uppercase;
}

a:hover, a:active {
background-color: black;
}
</style>
</head>

<script>
function barang() {
var harga =
document.getElementById('harga').value;
var quantity =
document.getElementById('quantity').value;
var total = (parseInt(harga * quantity));
if (!isNaN(total)) {
document.getElementById('total').value =
total;
}
}

function showkembali() {
var txt3NumberValue =
document.getElementById('total').value;
var txt4NumberValue =
document.getElementById('totalbayar').value;
var result1 = (parseInt(txt4NumberValue -
txt3NumberValue));
if (!isNaN(result1)) {
document.getElementById('kembali').value =
result1;
}
}
</script>

<body>
<div class="container">
<div class="header">
<h1>Aplikasi Kasir</h1>
</div>
<div class="nav">
<div class="sidebar">
<br>
<ul style="list-style-type:none">
<p><li><a href="<?= base_url()
?>index.php/barang/addBarang">TAMBAH BARANG</a></li>
<p><li><a href="<?= base_url()
?>index.php/kasir">LIHAT TRANSAKSI</a></li>
<p><li><a href="<?= base_url()
?>index.php/barang">LIHAT BARANG</a></li>
<p><li><a href="<?= base_url()
?>index.php/login/logout">LOGOUT</a></li>

</ul>
</div>
<div class="content">
<br>
<br>
<form method="post" action="<?= base_url()
?>index.php/kasir/addKasirDb">
<table width="750" border="1" align="center"><br>
<tr>
<td height="40" align="center"
bgcolor="#ebf185"><font color="black">
<b>Tambah Transaksi</b></font></td>
</tr>
<tr>
<td bgcolor="#f6fbe0"><table
width="750" border="0" align="center" bgcolor="#ebf185"
cellpadding="3" cellspacing="8">
<tr>
<td width="163">Nama Barang </td>
<td width="150"><select name="kode_barang2" >
<option>---- Nama Barang----
</option>
<?php
mysql_connect("localhost",
"root", "");
mysql_select_db("db_kasir");
$sql = mysql_query("SELECT * FROM
barang ORDER BY kode_barang ASC");
if(mysql_num_rows($sql) != 0){
while($data =
mysql_fetch_assoc($sql)){
echo
'<option>'.$data['kode_barang'].'-'.$data['nama_barang'].'-
'.$data['harga'].'</option>';

}
}
?>
</select></td>
<td width="163">TOTAL (Rp) :</td>
</tr>
<tr>
<td width="163">Kode Barang</td>
<td width="400">
<?php
// Koneksi
mysql_select_db("db_kasir");
$result = mysql_query("select * from
barang");
$jsArray = "var sms = new Array();\n";
echo '<select name="kode_barang"
id="kode_barang" onchange="document.getElementById(\'harga\').value
= sms[this.value]">';
echo '<option>-------</option>';
while ($row = mysql_fetch_array($result)) {
echo '<option value="' .
$row['kode_barang'] . '">' . $row['kode_barang'] . '</option>';
$jsArray .= "sms['" .
$row['kode_barang'] . "'] = '" . addslashes($row['harga']) .
"';\n";
}
echo '</select>';
?>
</td>
<td width="400"><input name="total"
type="text" id="total" size="20" onkeyup="showkembali();" /></td>
</tr>
<tr>
<td width="163">Harga (Rp)</td>
<td width="400">
<input name="harga" type="text" id="harga"
size="20" onkeyup="barang();" readonly >
<script type="text/javascript">
<?php echo $jsArray; ?>
</script>
</td>
<td width="163">BAYAR (Rp) :</td>
</tr>
<tr>
<td width="163">Quantity</td>
<td width="400"><input name="quantity"
type="text" id="quantity" size="20" onkeyup="barang();"/></td>
<td width="400"><input name="txtnama"
type="text" id="totalbayar" size="20"
onkeyup="showkembali();"/></td>
</tr>
<tr>
<td width="163"></td>
<td width="400"></td>
<td width="163">KEMBALI (Rp) :</td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input name="tblIsi" type="submit"
id="tblIsi" value="Selesai" /></td>
<td width="400"><input name="txtharga"
type="text" id="kembali" size="20" /></td>
</tr>
</table>
<tr>
<td height="40" align="center"
bgcolor="#ebf185">
<font color="black">
<b>User Login : </b></font>
<input name="nama_kasir" type="text"
value="<?php echo $this->session->userdata("nama"); ?>"
id="nama_kasir"/></td>
</tr>
</table>
</div>

<div class="clear"></div>
<div class="footer">
<marquee><b>Tugas Besar Pemrograman Web by Dwi
Octaviani & Nindy Surya Agustin</marquee></font>
</div>
</div>
</body>
</html>

18. Beri nama kode berikut dengan kasir_view.php dan letakan file sesuai dengan
ketentuan tabel

<!-- File barang_view.php -->


<html>
<head>
<title>APLIKASI KASIR</title>
<style type="text/css">
body{
width: 80%;
margin: 20px auto;
background:black;
}
.container{
width: 100%;
margin: 30px auto;
}

/*bagian header*/
.header{
background: #DCDCDC;
padding: 2px 10px;
text-align: center;
font:100% Freestyle Script;
font-size:20px;
color: #665039;
}
/*akhir header*/

.clear{
clear: both;
}

.nav{
height: 500px;
}
/*bagian sidebar*/
.container .nav .sidebar{
background: #222;
float: left;
width: 25%;
height: 500px;
}

/*akhir sidebar*/

.container .nav .content{


background: #F5F5DC;
float: left;
height: 500px;
width: 75%;
font:100% Tekton Pro;
}

.footer{
padding: 2px 10px;
background: #DCDCDC;
font:100% Chaparral Pro Light;
color: #665039;
}

a:link, a:visited {
display: block;
width: 75%;
font-weight: #F0FFFF;
color: gold;
background-color:#2F4F4F ;
text-align: center;
padding: 10px;
text-decoration: none;
text-transform: uppercase;
}

a:hover, a:active {
background-color: black;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>APLIKASI KASIR</h1>
</div>
<div class="nav">
<div class="sidebar">
<br>
<ul style="list-style-type:none">
<p><li><a href="<?= base_url()
?>index.php/barang/addBarang">TAMBAH BARANG</a></li>
<p><li><a href="<?= base_url()
?>index.php/barang">LIHAT BARANG</a></li>
<p><li><a href="<?= base_url()
?>index.php/kasir/addkasir">TRANSAKSI BARU</a></li>
<p><li><a href="<?= base_url()
?>index.php/kasir">LIHAT TRANSAKSI</a></li>
<p><li><a href="<?= base_url()
?>index.php/login/logout">LOGOUT</a></li>

</ul>
</div>
<?php

$jumlahKasir = $listKasir->num_rows();
//$listProducts berasal dari data yang dilempar
dari controller, yaitu $data['listProducts']. num_rows()
//digunakan untuk menghitung jumlah baris yang
dimiliki ketika kita melakukan select dari database
?>
<?php
if($jumlahKasir > 0){ //Apabila data produk yang
ada didalam database lebih dari 0 maka baru ditampilkan
?>

<!-- Kalau ada datanya, maka kita akan tampilkan dalam


table -->
<div class="content">
<center><h1>Data Transaksi</h1></center>
<center>
<table border="1">
<thead>
<tr bgcolor="#DCDCDC">
<th> No.</th>
<th>Kode Transaksi</th>
<th>Kode Barang</th>
<th>Quantity</th>
<th>Total</th>
<th>ID kasir</th>
<th>Action</th>
</tr>

</thead>
<tbody>
<?php
//Kita akan melakukan
looping sesuai dengan data yang dimiliki
$i = 1; //nantinya akan
digunakan untuk pengisian Nomor
foreach ($listKasir-
>result() as $row) {
?>
<tr>
<td><?= $i++ ?></td>
<td><?= $row-
>kode_transaksi ?></td> <!-- karena berbentuk objek, maka kita
menggunakan panah (->) untuk menujukkan field yang ada di database
-->
<td><?= $row->kode_barang
?></td>
<td><?= $row->quantity
?></td>
<td><?= $row->total ?></td>
<!-- karena berbentuk objek, maka kita menggunakan panah (->) untuk
menujukkan field yang ada di database -->
<td><?= $row->id
?></td>
<td>
<a href="<?=
base_url() ?>index.php/kasir/deleteTransaksiDb/<?= $row-
>kode_transaksi ?>">Delete</a>
</td>
</tr>

<?php
}
?>
</tbody>
</table>
</center>
<?php
}
?>
<br>
<br>
<center>
<table border="0">
<tr>
<a href="<?= base_url()
?>index.php/laporan/cetak">Cetak Laporan Transaksi</a>
<tr>
</table>
</div>
<div class="clear"></div>
<div class="footer">
<font color="#000080">
<marquee>Tugas Besar Pemrograman Web by Dwi
Octaviani & Nindy Surya Agustin</marquee></font>
</div>
</div>
</body>
</html>

19. Beri nama kode berikut dengan laporan.php dan letakan file sesuai dengan ketentuan
tabel

<?php if ( ! defined('BASEPATH')) exit('No direct script access


allowed');

class laporan extends CI_Controller {

public function __construct(){


parent::__construct();

$this->load->model('laporan_model');
}

public function index(){


$data['transaksi'] = $this->laporan_model->view_row();
$this->load->view('preview', $data);
}

public function cetak(){


ob_start();
$data['transaksi'] = $this->laporan_model->view_row();
$this->load->view('print', $data);
$html = ob_get_contents();
ob_end_clean();

require_once('./assets/html2pdf/html2pdf.class.php');
$pdf = new HTML2PDF('L','A4','en');
$pdf->WriteHTML($html);
$pdf->Output('Laporan Transaksi.pdf', 'D');
}
}
20. Beri nama kode berikut dengan laporan_model.php dan letakan file sesuai dengan
ketentuan tabel

<?php if ( ! defined('BASEPATH')) exit('No direct script access


allowed');

class laporan_Model extends CI_Model {


public function view(){
return $this->db->get('transaksi')->result();
}

public function view_row(){


return $this->db->get('transaksi')->result();
}
}

21. Beri nama kode berikut dengan print.php dan letakan file sesuai dengan ketentuan
tabel

<html>
<head>
<title>Cetak PDF</title>
</head>
<body>
<h1 style="text-align: center;">Laporan Transaksi</h1>
<?php echo "Tanggal : ".date('d-m-Y'); ?>

<table align=center border="1" width="100%">


<tr align=center bgcolor="#7e7c7c">
<th align=center width=100 scope="col">Kode
Transaksi</th>
<th align=center width=100 scope="col">Kode Barang</th>
<th align=center width=100 scope="col">Quantity</th>
<th align=center width=100 scope="col">Total</th>
<th align=center width=100 scope="col">ID</th>
</tr>
<?php
if( ! empty($transaksi)){
$no = 1;
foreach($transaksi as $row){
echo "<tr align=center>";
echo "<td>".$row->kode_transaksi."</td>";
echo "<td>".$row->kode_barang."</td>";
echo "<td>".$row->quantity."</td>";
echo "<td>".$row->total."</td>";
echo "<td>".$row->id."</td>";
echo "</tr>";
$no++;
}
}
?>
</table>
</body>
</html>

Anda mungkin juga menyukai