project done before
This commit is contained in:
116
application/controllers/Home.php
Normal file
116
application/controllers/Home.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Home extends CI_Controller {
|
||||
|
||||
// var $table = $this->mhome->;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->load->helper('form');
|
||||
// $this->load->library('form_validation');
|
||||
|
||||
$this->load->model('model');
|
||||
$this->load->model('m_tabel_ss');
|
||||
$admin = $this->session->userdata('admin');
|
||||
if ($admin == '' || $admin == null || $admin != 'admin') {
|
||||
$this->session->set_flashdata('error', 'Sila Login Terlebih Dahulu');
|
||||
redirect('/login');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
// print_r('sini halaman Login');
|
||||
$main['header'] = "Halaman Utama";
|
||||
|
||||
if ($this->input->post('proses') == "edit") {
|
||||
// print_r('sini edit');
|
||||
$data = $this->model->serialize($this->input->post('data'));
|
||||
// print_r($data);
|
||||
$this->model->update('tb_list_barang',array('id' => $this->input->post('id')),$data);
|
||||
// print_r($this->input->post('id'));
|
||||
if($this->db->affected_rows() > 0){
|
||||
// print_r('Ada Perubahan');
|
||||
$this->session->set_flashdata('success', 'Detail Barang Behasil Terupdate');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->session->set_flashdata('success', 'Detail Barang Tetap Sama Seperti Sebelumnya');
|
||||
// print_r('tiada Perubahan');
|
||||
}
|
||||
}
|
||||
elseif ($this->input->post('proses') == "cari_data") {
|
||||
// print_r("sini datanya");
|
||||
$id = $this->input->post('id');
|
||||
$cek_data = $this->model->tampil_data_where('tb_list_barang',array('id' => $id))->result();
|
||||
// print_r(count($cek_data));
|
||||
print_r(json_encode($cek_data[0]));
|
||||
}
|
||||
elseif ($this->input->post('proses') == "tables") {
|
||||
$list = $this->m_tabel_ss->get_datatables(array('a.nama','a.harga'),array(null, 'a.nama','a.harga',null),array('a.nama' => 'asc'),"tb_list_barang a",null,null);
|
||||
$data = array();
|
||||
$no = $_POST['start'];
|
||||
foreach ($list as $field) {
|
||||
$no++;
|
||||
$row = array();
|
||||
// $ket = str_replace("\r\n",'+', $field->ket);
|
||||
$row[] = $no;
|
||||
$row[] = $field->nama;
|
||||
$row[] = "Rp .". number_format($field->harga);
|
||||
// $row[] = $field->waktu;
|
||||
$row[] = '<center><a data-toggle="modal" data-id="'.$field->id.'" title="Lihat Detail Barang" class="lihat_informasi btn btn-primary btn-sm nc-icon nc-zoom-split" href="#lihat_informasi" id="klik_'.$field->id.'"></a></center>';
|
||||
$data[] = $row;
|
||||
}
|
||||
|
||||
$output = array(
|
||||
"draw" => $_POST['draw'],
|
||||
"recordsTotal" => $this->m_tabel_ss->count_all("tb_list_barang a",null,null),
|
||||
"recordsFiltered" => $this->m_tabel_ss->count_filtered(array('a.nama','a.harga'),array(null, 'a.nama','a.harga',null),array('a.nama' => 'asc'),"tb_list_barang a",null,null),
|
||||
"data" => $data,
|
||||
);
|
||||
//output dalam format JSON
|
||||
echo json_encode($output);
|
||||
}
|
||||
elseif ($this->input->post('proses') == 'tambah') {
|
||||
$data = $this->model->serialize($this->input->post('data'));
|
||||
$cek_data = $this->model->tampil_data_where('tb_list_barang',array('id' => $data['id']))->result();
|
||||
if (count($cek_data) > 0) {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var myhtml = document.createElement("div");
|
||||
myhtml.innerHTML = "Barcode sudah terdaftar dalam sistem sebelumnya dengan Nama Barang <br><b><?=$cek_data[0]->nama?></b><br>Sila cek di list barang";
|
||||
swal({
|
||||
title: "Barcode Sudah Terdaftar",
|
||||
content: myhtml,
|
||||
icon: "warning",
|
||||
showLoaderOnConfirm: true,
|
||||
})
|
||||
|
||||
reset();
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->model->insert('tb_list_barang',$data);
|
||||
$this->session->set_flashdata('success', 'Barang dengan nama\n '.$data['nama'].'\n berhasil ditambahkan ke dalam daftar barang');
|
||||
print_r("<script>location.reload()</script>");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$main['count'] = count($this->model->tampil_data_keseluruhan('tb_list_barang')->result());
|
||||
$this->load->view('login/index',$main);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function logout() {
|
||||
$this->session->unset_userdata('admin');
|
||||
redirect('login');
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
44
application/controllers/Login.php
Normal file
44
application/controllers/Login.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Login extends CI_Controller {
|
||||
|
||||
// var $table = $this->mhome->;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->load->helper('form');
|
||||
// $this->load->library('form_validation');
|
||||
|
||||
$this->load->model('model');
|
||||
// $this->load->model('m_tabel_ss');
|
||||
|
||||
}
|
||||
|
||||
function index() {
|
||||
// print_r('sini login');
|
||||
|
||||
if ($this->input->post('button_login')) {
|
||||
// print_r('jalankan login');
|
||||
$username = $this->input->post('username');
|
||||
$password = $this->input->post('password');
|
||||
if ($username == 'admin' && $password == 'admin') {
|
||||
$this->session->set_flashdata('success', 'Selamat Kembali Admin');
|
||||
$this->session->set_userdata('admin', 'admin');
|
||||
redirect('/home');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->session->set_flashdata('error', 'Username dan Password salah');
|
||||
redirect('/login');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->load->view('login/login');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
123
application/controllers/User.php
Normal file
123
application/controllers/User.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class User extends CI_Controller {
|
||||
|
||||
// var $table = $this->mhome->;
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// $this->load->helper('form');
|
||||
// $this->load->library('form_validation');
|
||||
|
||||
$this->load->model('model');
|
||||
$this->load->model('m_tabel_ss');
|
||||
|
||||
}
|
||||
|
||||
function index() {
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
// if ($this->input->post('proses') == 'coba2') {
|
||||
// // print_r($this->input->post('img_data'));
|
||||
// define('UPLOAD_DIR', 'images/');
|
||||
// $image_parts = explode(";base64,", $_POST['img_data']);
|
||||
// $image_type_aux = explode("image/", $image_parts[0]);
|
||||
// $image_type = $image_type_aux[0];
|
||||
// $image_base64 = base64_decode($image_parts[0]);
|
||||
// $file = UPLOAD_DIR . 'heheh.jpg';
|
||||
// file_put_contents($file, $image_base64);
|
||||
// }
|
||||
if ($this->input->post('proses') == "cari") {
|
||||
$cari_data = $this->model->tampil_data_where('tb_list_barang',array('id' => $this->input->post('id')))->result();
|
||||
if (count($cari_data) > 0 ) {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
if ($("#list_beli").val() == '' || $("#list_beli").val() == null || $("#list_beli").val() == undefined) {
|
||||
$("#id_barang").val("<?=$cari_data[0]->id?>");
|
||||
$("#nama").html("<?=$cari_data[0]->nama?>");
|
||||
$("#nama_barang").val("<?=$cari_data[0]->nama?>");
|
||||
$("#harga_barang").val("<?=$cari_data[0]->harga?>");
|
||||
$("#harga").html("Rp. <?=number_format($cari_data[0]->harga)?>");
|
||||
$("#total").html("Masukkan Jumlah Pembelian");
|
||||
$("#interactive").attr('style','display : none');
|
||||
$("#button_listing").attr('style','display : block');
|
||||
Quagga.stop();
|
||||
$("#div_jumlah").attr('style','display : block');
|
||||
$("#jumlah_pembelian").focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#id_barang").val("<?=$cari_data[0]->id?>");
|
||||
// console.log($("#id_barang").val())
|
||||
var array_list = JSON.parse($("#list_beli").val());
|
||||
var cek = 0
|
||||
// var key,value;
|
||||
// for (var [key, value] of Object.entries(array_list)) {
|
||||
// // console.log(value.id);
|
||||
// if (value.id == $("#id_barang").val()) {
|
||||
// cek = 1;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// Object.keys(array_list).forEach(function (key) {
|
||||
// console.log(array_list[key].id)
|
||||
// if (array_list[key].id == $("#id_barang").val()) {
|
||||
// cek = 1;
|
||||
// break;
|
||||
// }
|
||||
// });
|
||||
|
||||
for (var i = 0; i < array_list.length; ++i) {
|
||||
// console.log(array_list[i].id)
|
||||
if (array_list[i].id == $("#id_barang").val()) {
|
||||
cek = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cek == 1) {
|
||||
swal({
|
||||
text: "Barang Yang Discan Sudah Ada Dalam List Pembelian",
|
||||
icon: "info",
|
||||
buttons: false,
|
||||
timer : 2000
|
||||
});
|
||||
reset()
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#id_barang").val("<?=$cari_data[0]->id?>");
|
||||
$("#nama").html("<?=$cari_data[0]->nama?>");
|
||||
$("#nama_barang").val("<?=$cari_data[0]->nama?>");
|
||||
$("#harga_barang").val("<?=$cari_data[0]->harga?>");
|
||||
$("#harga").html("Rp. <?=number_format($cari_data[0]->harga)?>");
|
||||
$("#total").html("Masukkan Jumlah Pembelian");
|
||||
$("#interactive").attr('style','display : none');
|
||||
$("#button_listing").attr('style','display : block');
|
||||
Quagga.stop();
|
||||
$("#div_jumlah").attr('style','display : block');
|
||||
$("#jumlah_pembelian").focus();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
swal({
|
||||
text: "Barcode Yang Discan Tiada Dalam Sistem",
|
||||
icon: "warning",
|
||||
buttons: false,
|
||||
timer : 2000
|
||||
})
|
||||
App.init()
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
25
application/controllers/Welcome.php
Normal file
25
application/controllers/Welcome.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Welcome extends CI_Controller {
|
||||
|
||||
/**
|
||||
* Index Page for this controller.
|
||||
*
|
||||
* Maps to the following URL
|
||||
* http://example.com/index.php/welcome
|
||||
* - or -
|
||||
* http://example.com/index.php/welcome/index
|
||||
* - or -
|
||||
* Since this controller is set as the default controller in
|
||||
* config/routes.php, it's displayed at http://example.com/
|
||||
*
|
||||
* So any other public methods not prefixed with an underscore will
|
||||
* map to /index.php/welcome/<method_name>
|
||||
* @see https://codeigniter.com/user_guide/general/urls.html
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('welcome_message');
|
||||
}
|
||||
}
|
||||
11
application/controllers/index.html
Normal file
11
application/controllers/index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user