[Pemprograman Berbasis KK] ETS
Nitama Nurlingga Yotifa
05111740000059
Link web : Disini [ADMIN email : nitama@gmail.com, password : 1234 | KARYAWAN email : yotifa@gmail.com, password : 1234]
05111740000059
Evaluasi Tengah Semester
Sistem Informasi Pencatatan Transaksi Penjualan pada Kasir (POS)
- Deskripsi Sistem Sistem ini merupakan sebuah sistem informasi yang diperuntukkan untuk melakukan pencatatan transaksi pada kasir suatu cafe yang menjual minuman kopi.
- Fitur Fitur yang terdapat pada sistem ini yaitu :
- Login admin dan karyawan Sebelum memasuki halaman home, user akan diarahkan pada halaman login. Login karyawan dan admin pada halaman yang sama.
- Halaman home Halaman home merupakan halaman utama/dashboard. Ketika user berhasil login secara otomatis akan diarahkan ke halaman ini.
- Registrasi akun karyawan Fitur registrasi akun karyawan hanya tersedia untuk user admin. Pada halaman ini terdapat form untuk membuat akun.
- Halaman penjualan Halaman penjualan merupakan halaman yang digunakan untuk mencatat transaksi. Pada halaman ini terdapat list gambar menu, nama menu, dan harga. Jika akan melakukan pembelian dapat mengisi jumlah item yang akan dibeli kemudia klik bayar untuk meneruskan transaksi.
- Halaman laporan Halaman ini berisi list item yang terjual beserta informasi detilnya.
- Database
- Dokumentasi Souce Code
- View
- Templates auth_header.php
- Admin
- Karyawan index.php
- Auth blocked.php
- Penjualan index.php
- Laporan index.php
Halaman login untuk karyawan dan admin |
Masukkan email (nitama@gmail.com) dan password (1234) untuk login akun karyawan |
Masukkan email (yotifa@gmail.com) dan password (1234) untuk login akun admin |
Halaman home untuk karyawan. |
Halaman home untuk admin. Perbedaan dengan halaman milik karyawan terapat pada menu sidebar |
Halaman register yang berisi formulir untuk membuat akun karyawan oleh admin |
Data yang diisikan harus sesuai |
Halaman penjualan dapat diakses oleh karyawan dan admin |
Masukkan jumlah item yang akan dibeli. Lalu klik add untuk menambahkan |
Kemudian item akan muncul di kiri besera rinciannya. Selanjutnya bisa tambahkan item lain yang akan dibeli |
Untuk menghapus dapat klik button remove jika ingin menghapus satuan atau klik clear cart untuk menghapus semua. Untuk melanjutkan transaksi dapat klik button bayar |
Halaman laporan berisi item yang terjual beserta rinciannya |
- Berikut ini adalah database dari sistem ini :
Daftar tabel yang digunakna |
Tabel detil transaksi |
Tabel user menu |
Tabel transaksi |
Tabel product |
Tabel user |
Tabel menu |
Tabel sub menu |
Tabel user role |
1: <!DOCTYPE html>
2: <html lang="en">
3: <head>
4: <meta charset="utf-8">
5: <meta http-equiv="X-UA-Compatible" content="IE=edge">
6: <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7: <meta name="description" content="">
8: <meta name="author" content="">
9: <title>
10: <?= $title; ?>
11: </title>
12: <!-- Custom fonts for this template-->
13: <link href="<?= base_url('assets/'); ?>vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
14: <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
15: <!-- Custom styles for this template-->
16: <link href="<?= base_url('assets/'); ?>css/sb-admin-2.min.css" rel="stylesheet">
17: </head>
18: <body class="bg-gradient-secondary">
auth_footer.php
1: <!-- Bootstrap core JavaScript-->
2: <script src="<?= base_url('assets/'); ?>vendor/jquery/jquery.min.js"></script>
3: <script src="<?= base_url('assets/'); ?>vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
4: <!-- Core plugin JavaScript-->
5: <script src="<?= base_url('assets/'); ?>vendor/jquery-easing/jquery.easing.min.js"></script>
6: <!-- Custom scripts for all pages-->
7: <script src="<?= base_url('assets/'); ?>js/sb-admin-2.min.js"></script>
8: </body>
9: </html>
header.php
1: <!DOCTYPE html>
2: <html lang="en">
3: <head>
4: <meta charset="utf-8">
5: <meta http-equiv="X-UA-Compatible" content="IE=edge">
6: <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7: <meta name="description" content="">
8: <meta name="author" content="">
9: <title><?= $title; ?></title>
10: <!-- Custom fonts for this template-->
11: <link href="<?= base_url('assets/'); ?>vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
12: <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
13: <!-- Custom styles for this template-->
14: <link href="<?= base_url('assets/'); ?>css/sb-admin-2.min.css" rel="stylesheet">
15: </head>
16: <body id="page-top">
17: <!-- Page Wrapper -->
18: <div id="wrapper">
1: <!-- Content Wrapper -->
2: <div id="content-wrapper" class="d-flex flex-column">
3: <!-- Main Content -->
4: <div id="content">
5: <!-- Topbar -->
6: <nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">
7: <!-- Sidebar Toggle (Topbar) -->
8: <button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
9: <i class="fa fa-bars"></i>
10: </button>
11: <!-- Topbar Navbar -->
12: <ul class="navbar-nav ml-auto">
13: <div class="topbar-divider d-none d-sm-block"></div>
14: <!-- Nav Item - User Information -->
15: <li class="nav-item dropdown no-arrow">
16: <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
17: <span class="mr-2 d-none d-lg-inline text-gray-600 small"><?= $user['name'] ?></span>
18: <img class="img-profile rounded-circle" src="<?= base_url('assets/img/profile/' . $user['image']); ?>">
19: </a>
20: <!-- Dropdown - User Information -->
21: <div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="userDropdown">
22: <a class="dropdown-item" href="#">
23: <i class="fas fa-user fa-sm fa-fw mr-2 text-gray-400"></i>
24: Profile
25: </a>
26: <div class="dropdown-divider"></div>
27: <a class="dropdown-item" href="<?= base_url('auth/logout'); ?>" data-toggle="modal" data-target="#logoutModal">
28: <i class="fas fa-sign-out-alt fa-sm fa-fw mr-2 text-gray-400"></i>
29: Logout
30: </a>
31: </div>
32: </li>
33: </ul>
34: </nav>
35: <!-- End of Topbar -->
1: <!-- Sidebar -->
2: <ul class="navbar-nav bg-gradient-info sidebar sidebar-dark accordion" id="accordionSidebar">
3: <!-- Sidebar - Brand -->
4: <a class="sidebar-brand d-flex align-items-center justify-content-center" href="index.html">
5: <div class="sidebar-brand-icon rotate-n-15">
6: <i class="fas fa-mug-hot"></i>
7: </div>
8: <!-- <div class="sidebar-brand-text mx-3">Nama Toko <sup>2</sup></div> -->
9: <div class="sidebar-brand-text mx-3">St*rBucks</div>
10: </a>
11: <!-- Divider -->
12: <hr class="sidebar-divider my-0">
13: <!-- QUERY MENU -->
14: <?php
15: $role_id = $this->session->userdata('role_id');
16: $queryMenu = "SELECT `user_menu`.`id`, `menu`
17: FROM `user_menu` JOIN `user_access_menu`
18: ON `user_menu`.`id` = `user_access_menu`.`menu_id`
19: WHERE `user_access_menu`.`role_id` = $role_id
20: ORDER BY `user_access_menu`.`menu_id` ASC
21: ";
22: $menu = $this->db->query($queryMenu)->result_array();
23: ?>
24: <!-- LOOPING MENU -->
25: <?php foreach ($menu as $m) : ?>
26: <!-- Heading -->
27: <div class="sidebar-heading">
28: <?= $m['menu']; ?>
29: </div>
30: <!-- SIAPKAN SUB MENU SESUAI MENU -->
31: <?php
32: $menuId = $m['id'];
33: $querySubMenu = "SELECT *
34: FROM `user_sub_menu` JOIN `user_menu`
35: ON `user_sub_menu`.`menu_id` = `user_menu`.`id`
36: WHERE `user_sub_menu`.`menu_id` = $menuId
37: AND `user_sub_menu`.`is_active` = 1
38: ";
39: $subMenu = $this->db->query($querySubMenu)->result_array();
40: ?>
41: <?php foreach ($subMenu as $sm) : ?>
42: <!-- Nav Item - Dashboard -->
43: <li class="nav-item">
44: <?php if ($sm['title'] == 'Home') : ?>
45: <?php if ($role_id == 1) : ?>
46: <a class="nav-link" href="admin">
47: <?php else : ?>
48: <a class="nav-link" href="<?= base_url($sm['url']); ?>">
49: <?php endif; ?>
50: <?php else : ?>
51: <a class="nav-link" href="<?= base_url($sm['url']); ?>">
52: <?php endif; ?>
53: <i class="<?= $sm['icon']; ?>"></i>
54: <span><?= $sm['title']; ?></span></a>
55: </li>
56: <?php endforeach; ?>
57: <?php endforeach; ?>
58: <!-- Divider -->
59: <hr class="sidebar-divider d-none d-md-block">
60: <!-- Sidebar Toggler (Sidebar) -->
61: <div class="text-center d-none d-md-inline">
62: <button class="rounded-circle border-0" id="sidebarToggle"></button>
63: </div>
64: </ul>
65: <!-- End of Sidebar -->
1: <!-- Footer -->
2: <footer class="sticky-footer bg-white">
3: <div class="container my-auto">
4: <div class="copyright text-center my-auto">
5: <span>Copyright © St*rbuck Coffee Company <?= date('Y'); ?></span>
6: </div>
7: </div>
8: </footer>
9: <!-- End of Footer -->
10: </div>
11: <!-- End of Content Wrapper -->
12: </div>
13: <!-- End of Page Wrapper -->
14: <!-- Scroll to Top Button-->
15: <a class="scroll-to-top rounded" href="#page-top">
16: <i class="fas fa-angle-up"></i>
17: </a>
18: <!-- Logout Modal-->
19: <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
20: <div class="modal-dialog" role="document">
21: <div class="modal-content">
22: <div class="modal-header">
23: <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
24: <button class="close" type="button" data-dismiss="modal" aria-label="Close">
25: <span aria-hidden="true">×</span>
26: </button>
27: </div>
28: <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
29: <div class="modal-footer">
30: <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
31: <a class="btn btn-primary" href="<?= base_url('auth/logout'); ?>">Logout</a>
32: </div>
33: </div>
34: </div>
35: </div>
36: <!-- Bootstrap core JavaScript-->
37: <script src="<?= base_url('assets/'); ?>vendor/jquery/jquery.min.js"></script>
38: <script src="<?= base_url('assets/'); ?>vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
39: <!-- Core plugin JavaScript-->
40: <script src="<?= base_url('assets/'); ?>vendor/jquery-easing/jquery.easing.min.js"></script>
41: <!-- Custom scripts for all pages-->
42: <script src="<?= base_url('assets/'); ?>js/sb-admin-2.min.js"></script>
43: </body>
44: </html>
- script.php
1: <script>
2: $(document).ready(function() {
3: $('.add_cart').click(function() {
4: var id = $(this).data("productid");
5: var name = $(this).data("productname");
6: var price = $(this).data("price");
7: var quantity = $('#' + id).val();
8: if (quantity != '' && quantity > 0) {
9: $.ajax({
10: url: "<?php echo base_url(); ?>penjualan/add",
11: method: "POST",
12: data: {
13: id: id,
14: name: name,
15: price: price,
16: quantity: quantity
17: },
18: success: function(data) {
19: alert("Product Added into Cart");
20: $('#cart_details').html(data);
21: $('#' + product_id).val('');
22: }
23: });
24: } else {
25: alert("Please Enter quantity");
26: }
27: });
28: $('#cart_details').load("<?php echo base_url(); ?>penjualan/load");
29: $(document).on('click', '.remove_inventory', function() {
30: var row_id = $(this).attr("id");
31: if (confirm("Are you sure you want to remove this?")) {
32: $.ajax({
33: url: "<?php echo base_url(); ?>penjualan/remove",
34: method: "POST",
35: data: {
36: row_id: row_id
37: },
38: success: function(data) {
39: alert("Product removed from Cart");
40: $('#cart_details').html(data);
41: }
42: });
43: } else {
44: return false;
45: }
46: });
47: $(document).on('click', '#clear_cart', function() {
48: if (confirm("Are you sure you want to clear cart?")) {
49: $.ajax({
50: url: "<?php echo base_url(); ?>penjualan/clear",
51: success: function(data) {
52: alert("Your cart has been clear...");
53: $('#cart_details').html(data);
54: }
55: });
56: } else {
57: return false;
58: }
59: });
60: $(document).on('click', '.bayar', function() {
61: $.ajax({
62: url: "<?php echo base_url(); ?>penjualan/bayar",
63: success: function(data) {
64: alert("Your cart has been clear...");
65: $('#cart_details').html(data);
66: }
67: });
68: });
69: });
70: </script>
1: <!-- Begin Page Content -->
2: <div class="container-fluid home">
3: <!-- Page Heading -->
4: <div class="card bg-dark text-white">
5: <img class=" card-img" src="assets/img/background/bg.png" alt="Card image">
6: <div class="card-img-overlay">
7: <h1 class="card-title display-2 text-white text-center invisible"><?= $title ?></h1>
8: <p class="card-text display-4 text-center">Welcome <?= $user['name'] ?></p><br>
9: <p class="card-text display-5 text-center"><em>-People say <strong>money</strong> can't buy <strong>happiness</strong>. They Lie! Money buys <strong>coffee</strong>, coffee makes me <strong>happy</strong>-</em></p>
10: </div>
11: </div>
12: <!-- /.container-fluid -->
13: </div>
14: <!-- End of Main Content -->
1: <!-- Begin Page Content -->
2: <div class="container-fluid home">
3: <!-- Page Heading -->
4: <div class="card bg-dark text-white">
5: <img class=" card-img" src="assets/img/background/bg.png" alt="Card image">
6: <div class="card-img-overlay">
7: <h1 class="card-title display-2 text-white text-center invisible"><?= $title ?></h1>
8: <p class="card-text display-4 text-center">Welcome <?= $user['name'] ?></p><br>
9: <p class="card-text display-5 text-center"><em>-People say <strong>money</strong> can't buy <strong>happiness</strong>. They Lie! Money buys <strong>coffee</strong>, coffee makes me <strong>happy</strong>-</em></p>
10: </div>
11: </div>
12: <!-- /.container-fluid -->
13: </div>
14: <!-- End of Main Content -->
1: <!DOCTYPE html>
2: <html lang="en">
3: <head>
4: <meta charset="utf-8">
5: <meta http-equiv="X-UA-Compatible" content="IE=edge">
6: <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7: <meta name="description" content="">
8: <meta name="author" content="">
9: <title>Access Blocked</title>
10: <!-- Custom fonts for this template-->
11: <link href="<?= base_url('assets/'); ?>vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
12: <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
13: <!-- Custom styles for this template-->
14: <link href="<?= base_url('assets/'); ?>css/sb-admin-2.min.css" rel="stylesheet">
15: </head>
16: <body id="page-top">
17: <!-- Page Wrapper -->
18: <div id="wrapper">
19: <!-- Content Wrapper -->
20: <div id="content-wrapper" class="d-flex flex-column">
21: <!-- Main Content -->
22: <div id="content">
23: <!-- Begin Page Content -->
24: <div class="container-fluid mt-5">
25: <!-- 404 Error Text -->
26: <div class="text-center">
27: <div class="error mx-auto" data-text="403">403</div>
28: <p class="lead text-gray-800 mb-5">Access Forbidden</p>
29: <p class="text-gray-500 mb-0">It looks like you found a glitch in the matrix...</p>
30: <a href="<?= base_url('karyawan') ?>">← Back to Dashboard</a>
31: </div>
32: </div>
33: <!-- /.container-fluid -->
34: </div>
35: <!-- End of Main Content -->
36: </div>
37: <!-- End of Content Wrapper -->
38: </div>
39: <!-- End of Page Wrapper -->
40: <!-- Scroll to Top Button-->
41: <a class="scroll-to-top rounded" href="#page-top">
42: <i class="fas fa-angle-up"></i>
43: </a>
44: <!-- Logout Modal-->
45: <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
46: <div class="modal-dialog" role="document">
47: <div class="modal-content">
48: <div class="modal-header">
49: <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
50: <button class="close" type="button" data-dismiss="modal" aria-label="Close">
51: <span aria-hidden="true">×</span>
52: </button>
53: </div>
54: <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
55: <div class="modal-footer">
56: <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
57: <a class="btn btn-primary" href="login.html">Logout</a>
58: </div>
59: </div>
60: </div>
61: </div>
62: <!-- Bootstrap core JavaScript-->
63: <script src="<?= base_url('assets/'); ?>vendor/jquery/jquery.min.js"></script>
64: <script src="<?= base_url('assets/'); ?>vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
65: <!-- Core plugin JavaScript-->
66: <script src="<?= base_url('assets/'); ?>vendor/jquery-easing/jquery.easing.min.js"></script>
67: <!-- Custom scripts for all pages-->
68: <script src="<?= base_url('assets/'); ?>js/sb-admin-2.min.js"></script>
69: </body>
70: </html>
login.php
1: <div class="container">
2: <!-- Outer Row -->
3: <div class="row justify-content-center">
4: <div class="col-lg-7">
5: <div class="card o-hidden border-0 shadow-lg my-5">
6: <div class="card-body p-0">
7: <!-- Nested Row within Card Body -->
8: <div class="row">
9: <div class="col-lg">
10: <div class="p-5">
11: <div class="text-center">
12: <h1 class="h4 text-gray-900 mb-4">Login Page</h1>
13: </div>
14: <?= $this->session->flashdata('message') ?>
15: <form class="user" method="post" action="<?= base_url('auth') ?>">
16: <div class="form-group">
17: <input type="text" class="form-control form-control-user" id="email" name="email" placeholder="Enter Email Address..." value="<?= set_value('email') ?>">
18: <?= form_error('email', '<small class="text-danger pl-3">', '</small>'); ?>
19: </div>
20: <div class="form-group">
21: <input type="password" class="form-control form-control-user" id="password" name="password" placeholder="Password">
22: <?= form_error('password', '<small class="text-danger pl-3">', '</small>'); ?>
23: </div>
24: <button type="submit" class="btn btn-info btn-user btn-block">
25: Login
26: </button>
27: </form>
28: <hr>
29: </div>
30: </div>
31: </div>
32: </div>
33: </div>
34: </div>
35: </div>
36: </div>
register.php
1: <div class="container">
2: <div class="card o-hidden border-0 shadow-lg my-5 col-lg-7 mx-auto">
3: <div class="card-body p-0">
4: <!-- Nested Row within Card Body -->
5: <div class="row">
6: <div class="col-lg">
7: <div class="p-5">
8: <div class="text-center">
9: <h1 class="h4 text-gray-900 mb-4">Create an Account!</h1>
10: </div>
11: <form class="user" method="post" action="<?= base_url('auth/registration') ?>">
12: <div class="form-group">
13: <input type="text" class="form-control form-control-user" id="name" name="name" placeholder="full name" value="<?= set_value('name') ?>">
14: <?= form_error('name', '<small class="text-danger pl-3">', '</small>'); ?>
15: </div>
16: <div class="form-group">
17: <input type="text" class="form-control form-control-user" id="email" name="email" placeholder="Email Address" value="<?= set_value('email') ?>">
18: <?= form_error('email', '<small class="text-danger pl-3">', '</small>'); ?>
19: </div>
20: <div class="form-group row">
21: <div class="col-sm-6 mb-3 mb-sm-0">
22: <input type="password" class="form-control form-control-user" id="password1" name="password1" placeholder="Password">
23: <?= form_error('password1', '<small class="text-danger pl-3">', '</small>'); ?>
24: </div>
25: <div class="col-sm-6">
26: <input type="password" class="form-control form-control-user" id="password2" name="password2" placeholder="Repeat Password">
27: </div>
28: </div>
29: <button type="submit" class="btn btn-info btn-user btn-block">
30: Register Account
31: </button>
32: </form>
33: <hr>
34: <div class="text-center">
35: <a class="small" href="<?= base_url('admin') ?>">Back</a>
36: </div>
37: </div>
38: </div>
39: </div>
40: </div>
41: </div>
42: </div>
1: <!-- Begin Page Content -->
2: <div class="container-fluid home">
3: <div class="container">
4: <div class="row">
5: <div class="col-md-7">
6: <div class="row">
7: <?php foreach ($product as $row) : ?>
8: <div class="col-sm-4">
9: <img class="card-img-top" src="<?= base_url('assets/img/product/' . $row->image); ?>" alt="Card image cap">
10: <div class="card-body">
11: <h6 class="card-title"><?= $row->name ?></h6>
12: <p class="card-title">Rp.<?= $row->price ?></p>
13: <?= '
14: <input type="text" name="quantity" class="form-control quantity" id="' . $row->id . '" /><br />
15: <button type="button" name="add_cart" class="btn btn-success add_cart" data-productname="' . $row->name . '" data-price="' . $row->price . '" data-productid="' . $row->id . '" />Add</button>' ?>
16: </div>
17: </div>
18: <?php endforeach; ?>
19: </div>
20: </div>
21: <div class="col-md-5">
22: <div id="cart_details">
23: <h3 class="text-center">Pesanan kosong</h3>
24: </div>
25: </div>
26: </div>
27: </div>
28: </div>
29: <!-- End of Main Content -->
1: <!-- Begin Page Content -->
2: <div class="container-fluid">
3: <!-- Page Heading -->
4: <h1 class="h3 mb-4 text-gray-800"><?= $title ?></h1>
5: <div class="row">
6: <div class="col-lg-11">
7: <table class="table table-hover">
8: <thead>
9: <tr>
10: <th scope="col">ID Transaksi</th>
11: <th scope="col">Menu</th>
12: <th scope="col">Harga</th>
13: <th scope="col">Jumlah</th>
14: <th scope="col">Total</th>
15: <th scope="col">Tanggal</th>
16: </tr>
17: </thead>
18: <tbody>
19: <?php
20: $queryT = "SELECT *
21: FROM `transaksi`
22: ";
23: $transaksi = $this->db->query($queryT)->result_array();
24: ?>
25: <?php foreach ($transaksi as $baris) : ?>
26: <?php
27: $id_transaksi = $baris['id'];
28: $queryTransaksi = "SELECT *
29: FROM `detil_transaksi`
30: WHERE `detil_transaksi`.`id_transaksi` = $id_transaksi
31: ";
32: $detil_transaksi = $this->db->query($queryTransaksi)->result_array();
33: ?>
34: <?php foreach ($detil_transaksi as $row) : ?>
35: <tr>
36: <td><?= $row['id_transaksi']; ?></td>
37: <td><?= $row['name']; ?></td>
38: <td><?= $row['price']; ?></td>
39: <td><?= $row['quantity']; ?></td>
40: <td><?= 'Rp. ' . $row['price'] * $row['quantity']; ?></td>
41: <td><?= date('d F Y', $baris['date']); ?></td>
42: </tr>
43: <?php endforeach; ?>
44: <?php endforeach; ?>
45: </tbody>
46: </table>
47: </div>
48: </div>
49: </div>
50: <!-- /.container-fluid -->
51: </div>
52: <!-- End of Main Content -->
- Controller
1: <?php
2: defined('BASEPATH') or exit('No direct script access allowed');
3: class Auth extends CI_Controller
4: {
5: public function __construct()
6: {
7: // untuk memanggil method contructor di CI_Controller
8: parent::__construct();
9: $this->load->library('form_validation');
10: }
11: public function index()
12: {
13: $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
14: $this->form_validation->set_rules('password', 'Password', 'trim|required');
15: if ($this->form_validation->run() == false) {
16: $data['title'] = 'Login';
17: $this->load->view('templates/auth_header', $data);
18: $this->load->view('auth/login');
19: $this->load->view('templates/auth_footer');
20: } else {
21: //Validasi sukses
22: $this->_login(); //_ untuk menandakan private hanya untuk kelas ini saja
23: }
24: }
25: private function _login()
26: {
27: $email = $this->input->post('email');
28: $password = $this->input->post('password');
29: $user = $this->db->get_where('user', ['email' => $email])->row_array(); //baca : select * dari tael user where email == $email
30: if ($user) {
31: // jika user aktif
32: if ($user['is_active'] == 1) {
33: if (password_verify($password, $user['password'])) {
34: $data = [
35: 'email' => $user['email'],
36: 'role_id' => $user['role_id']
37: ];
38: $this->session->set_userdata($data);
39: if ($user['role_id'] == 1) {
40: redirect('admin');
41: } else {
42: redirect('karyawan');
43: }
44: } else {
45: $this->session->set_flashdata('message', '<div class="alert alert-danger" role="alert"> Wrong password</div>');
46: redirect('auth');
47: }
48: } else {
49: $this->session->set_flashdata('message', '<div class="alert alert-danger" role="alert"> This email has been not activated! </div>');
50: redirect('auth');
51: }
52: } else {
53: $this->session->set_flashdata('message', '<div class="alert alert-danger" role="alert"> Email is not registered! </div>');
54: redirect('auth');
55: }
56: }
57: public function registration()
58: {
59: $this->form_validation->set_rules('name', 'Name', 'required|trim'); //trim agar jika menyisakan spasi di depan atau dibelakang akan dihapus agar tidak tersimpan di db
60: $this->form_validation->set_rules('email', 'Email', 'required|trim|valid_email|is_unique[user.email]');
61: $this->form_validation->set_rules('password1', 'Password', 'required|trim|min_length[3]|matches[password2]', [
62: 'matches' => 'password dont match',
63: 'min_length' => 'Password too short!'
64: ]); //trim agar jika menyisakan spasi di depan atau dibelakang akan dihapus agar tidak tersimpan di db
65: $this->form_validation->set_rules('password2', 'Password', 'required|trim|matches[password1]'); //trim agar jika menyisakan spasi di depan atau dibelakang akan dihapus agar tidak tersimpan di db
66: if ($this->form_validation->run() == false) {
67: $data['title'] = 'Registration';
68: $this->load->view('templates/auth_header', $data);
69: $this->load->view('auth/registration');
70: $this->load->view('templates/auth_footer');
71: } else {
72: $data = [
73: 'name' => htmlspecialchars($this->input->post('name', true)),
74: 'email' => htmlspecialchars($this->input->post('email', true)),
75: 'image' => 'default.png',
76: 'password' => password_hash($this->input->post('password1'), PASSWORD_DEFAULT),
77: 'role_id' => 2,
78: 'is_active' => 1,
79: 'date_created' => time()
80: ];
81: $this->db->insert('user', $data);
82: $this->session->set_flashdata('message', '<div class="alert alert-success" role="alert"> Congratulation! Your account has been created. Please login. </div>');
83: redirect('admin');
84: }
85: }
86: public function logout()
87: {
88: $this->session->unset_userdata('email');
89: $this->session->unset_userdata('role_id');
90: $this->session->set_flashdata('message', '<div class="alert alert-success" role="alert"> You have been logout. </div>');
91: redirect('auth');
92: }
93: public function blocked()
94: {
95: $this->load->view('auth/blocked');
96: }
97: }
- Admin.php
1: <?php
2: defined('BASEPATH') or exit('No direct script access allowed');
3: class Admin extends CI_Controller
4: {
5: public function __construct()
6: {
7: parent::__construct();
8: is_logged_in();
9: }
10: public function index()
11: {
12: $data['title'] = 'Home';
13: $data['user'] = $this->db->get_where('user', ['email' => $this->session->userdata('email')])->row_array();
14: $this->load->view('templates/header', $data);
15: $this->load->view('templates/sidebar', $data);
16: $this->load->view('templates/topbar', $data);
17: $this->load->view('Admin/index', $data);
18: $this->load->view('templates/footer');
19: }
20: }
- Karyawan.php
1: <?php
2: defined('BASEPATH') or exit('No direct script access allowed');
3: class Karyawan extends CI_Controller
4: {
5: public function __construct()
6: {
7: parent::__construct();
8: is_logged_in();
9: }
10: public function index()
11: {
12: $data['title'] = 'Home';
13: $data['user'] = $this->db->get_where('user', ['email' => $this->session->userdata('email')])->row_array();
14: $this->load->view('templates/header', $data);
15: $this->load->view('templates/sidebar', $data);
16: $this->load->view('templates/topbar', $data);
17: $this->load->view('karyawan/index', $data);
18: $this->load->view('templates/footer');
19: }
20: }
- Penjualan.php
1: <?php
2: defined('BASEPATH') or exit('No direct script access allowed');
3: class Penjualan extends CI_Controller
4: {
5: public function index()
6: {
7: $this->load->model('penjualan_model');
8: $product['product'] = $this->penjualan_model->fetch_all();
9: $data['title'] = 'Penjualan';
10: $data['user'] = $this->db->get_where('user', ['email' => $this->session->userdata('email')])->row_array();
11: $this->load->view('templates/header', $data);
12: $this->load->view('templates/sidebar', $data);
13: $this->load->view('templates/topbar', $data);
14: $this->load->view('Penjualan/index', $product);
15: $this->load->view('templates/footer');
16: $this->load->view('templates/script');
17: }
18: public function add()
19: {
20: $this->load->library("cart");
21: $data = array(
22: "id" => $_POST["id"],
23: "name" => $_POST["name"],
24: "qty" => $_POST["quantity"],
25: "price" => $_POST["price"]
26: );
27: $this->cart->insert($data); //return rowid
28: echo $this->view();
29: }
30: function load()
31: {
32: echo $this->view();
33: }
34: function remove()
35: {
36: $this->load->library("cart");
37: $row_id = $_POST["row_id"];
38: $data = array(
39: 'rowid' => $row_id,
40: 'qty' => 0
41: );
42: $this->cart->update($data);
43: echo $this->view();
44: }
45: function clear()
46: {
47: $this->load->library("cart");
48: $this->cart->destroy();
49: echo $this->view();
50: }
51: function view()
52: {
53: $this->load->library("cart");
54: $output = '';
55: $output .= '
56: <h3>Daftar Pesanan</h3><br />
57: <div class="table-responsive">
58: <div align="right">
59: <button type="button" id="clear_cart" class="btn btn-warning">Clear Cart</button>
60: </div>
61: <br />
62: <table class="table table-bordered">
63: <tr>
64: <th width="40%">Name</th>
65: <th width="15%">Quantity</th>
66: <th width="15%">Price</th>
67: <th width="15%">Total</th>
68: <th width="15%">Action</th>
69: </tr>
70: ';
71: $count = 0;
72: foreach ($this->cart->contents() as $items) {
73: $count++;
74: $output .= '
75: <tr>
76: <td>' . $items["name"] . '
77: <td>' . $items["qty"] . '
78: <td>' . $items["price"] . '
79: <td>' . $items["subtotal"] . '
80: <td><button type="button" name="remove" class="btn btn-danger btn-xs remove_inventory" id="' . $items["rowid"] . '">Remove</button></td>
81: </tr>
82: ';
83: }
84: $output .= '
85: <tr>
86: <td colspan="4" align="right">Total</td>
87: <td>' . $this->cart->total() . '
88: </tr>
89: </table>
90: <div align="right">
91: <button type="submit" class="btn btn-success bayar">Bayar</button>
92: </div>
93: </div>
94: ';
95: if ($count == 0) {
96: $output = '<h3 align="center">Pesanan kosong</h3>';
97: }
98: return $output;
99: }
100: function bayar()
101: {
102: $this->load->library("cart");
103: $data_transaksi = [
104: 'date' => time()
105: ];
106: $this->db->insert('transaksi', $data_transaksi);
107: $maxid = 0;
108: $row = $this->db->query('SELECT MAX(id) AS `maxid` FROM `transaksi`')->row();
109: if ($row) {
110: $maxid = $row->maxid;
111: }
112: foreach ($this->cart->contents() as $items) {
113: $data = array(
114: 'id_transaksi' => $maxid,
115: 'name' => $items['name'],
116: 'price' => $items['price'],
117: 'quantity' => $items['qty']
118: );
119: $this->db->insert('detil_transaksi', $data);
120: }
121: $this->cart->destroy();
122: echo $this->view();
123: }
124: }
1: <?php
2: defined('BASEPATH') or exit('No direct script access allowed');
3: class Laporan extends CI_Controller
4: {
5: public function index()
6: {
7: $data['title'] = 'Laporan Penjualan';
8: $data['user'] = $this->db->get_where('user', ['email' => $this->session->userdata('email')])->row_array();
9: $this->load->view('templates/header', $data);
10: $this->load->view('templates/sidebar', $data);
11: $this->load->view('templates/topbar', $data);
12: $this->load->view('Laporan/index', $data);
13: $this->load->view('templates/footer');
14: $this->load->view('templates/script');
15: }
16: }
- Model
- Helpers
- Penjualan_model.php
1: <?php
2: class Penjualan_model extends CI_Model
3: {
4: function fetch_all()
5: {
6: $query = $this->db->get('product');
7: return $query->result();
8: }
9: }
1: <?php
2: class Penjualan_model extends CI_Model
3: {
4: function fetch_all()
5: {
6: $query = $this->db->get('product');
7: return $query->result();
8: }
9: }
Link web : Disini [ADMIN email : nitama@gmail.com, password : 1234 | KARYAWAN email : yotifa@gmail.com, password : 1234]
Komentar
Posting Komentar