deploy awal
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
class Auth extends CI_controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('Model_operator');
|
||||
}
|
||||
|
||||
function login()
|
||||
{
|
||||
if (isset($_POST['submit'])) {
|
||||
$username = $this->input->post('username');
|
||||
$password = $this->input->post('password');
|
||||
$hasil = $this->Model_operator->login($username, $password);
|
||||
$foto = $this->Model_operator->ambil_foto($username, $password);
|
||||
if ($hasil == TRUE) {
|
||||
$this->db->where('username', $username);
|
||||
$this->db->update('operator', array('last_login' => date('Y-m-d')));
|
||||
$this->session->set_userdata(array(
|
||||
'id' => $hasil->row()->id_operator,
|
||||
'status_login' => 'oke',
|
||||
'username' => $hasil->row()->username,
|
||||
'nama' => $hasil->row()->nama_operator,
|
||||
'akses' => $hasil->row()->id_akses,
|
||||
'foto' => $foto->foto,
|
||||
));
|
||||
redirect('Dashboard');
|
||||
} else {
|
||||
$this->session->set_flashdata('message_name', 'Username atau Password salah!!');
|
||||
redirect('Auth/login');
|
||||
}
|
||||
} else {
|
||||
$this->load->view('loginbaru');
|
||||
}
|
||||
}
|
||||
|
||||
function logout()
|
||||
{
|
||||
$this->session->sess_destroy();
|
||||
redirect('Auth/login');
|
||||
}
|
||||
|
||||
function form_update(){
|
||||
$this->load->view('form_login');
|
||||
|
||||
|
||||
}
|
||||
public function update_password()
|
||||
{
|
||||
// Pastikan POST request terkirim
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// Ambil data password dari form
|
||||
$password = $this->input->post('password');
|
||||
$confirm_password = $this->input->post('confirm_password');
|
||||
|
||||
// Validasi bahwa kedua password sesuai
|
||||
if ($password == $confirm_password) {
|
||||
// Jika sesuai, update password di database
|
||||
$id_operator = $this->session->userdata('id_operator'); // Sesuaikan dengan session operator Anda
|
||||
$this->db->where('id_operator', $id_operator);
|
||||
$this->db->update('operator', ['password' => md5($password)]);
|
||||
|
||||
// Redirect ke halaman lain atau tampilkan pesan sukses
|
||||
redirect('success_page');
|
||||
} else {
|
||||
// Jika password tidak cocok, tampilkan pesan kesalahan
|
||||
echo "Password and Confirm Password do not match!";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
class Barang extends CI_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
chek_role();
|
||||
$this->load->model('Model_barang');
|
||||
$this->load->model('Model_kategori');
|
||||
// $this->load->model('Model_suplier');
|
||||
}
|
||||
function index()
|
||||
{
|
||||
$data['record'] = $this->Model_barang->tampil_data()->result();
|
||||
$this->template->load('Template/template', 'Barang/lihat_data', $data);
|
||||
$this->load->view('Template/datatables');
|
||||
|
||||
}
|
||||
function post()
|
||||
{
|
||||
if (isset($_POST["submit"])) {
|
||||
$config['upload_path'] = './uploads/';
|
||||
$config['allowed_types'] = 'gif|jpg|png|jpeg';
|
||||
$config['max_size'] = 1024;
|
||||
$config['max_width'] = 6000;
|
||||
$config['max_height'] = 6000;
|
||||
$config['overwrite'] = TRUE;
|
||||
$config['remove_spaces'] = TRUE;
|
||||
$config['encrypt_name'] = TRUE;
|
||||
$this->upload->initialize($config);
|
||||
if (!$this->upload->do_upload('foto')) {
|
||||
$this->session->set_flashdata('message', $this->upload->display_errors());
|
||||
redirect($_SERVER['HTTP_REFERER']);
|
||||
return false;
|
||||
} else {
|
||||
// proses barang
|
||||
$id = $this->input->post('id');
|
||||
$nama = $this->input->post('nama_barang');
|
||||
$suplier = $this->input->post('suplier');
|
||||
$kategori = $this->input->post('kategori');
|
||||
$harga_dot = $this->input->post('harga');
|
||||
$harga = (int) str_replace('.', '', $harga_dot);
|
||||
$harga_beli_with_dot = $this->input->post('harga_beli');
|
||||
|
||||
// Menghapus tanda titik dari nilai
|
||||
$harga_beli = (int) str_replace('.', '', $harga_beli_with_dot);
|
||||
$ukuran = $this->input->post('ukuran');
|
||||
$foto = $this->upload->data('file_name');
|
||||
$data = array(
|
||||
'nama_barang' => $nama,
|
||||
'id_suplier' => $suplier,
|
||||
'id_kategori' => $kategori,
|
||||
'ukuran' => $ukuran,
|
||||
'harga' => $harga,
|
||||
'harga_beli' => $harga_beli,
|
||||
'foto' => $foto,
|
||||
);
|
||||
$this->Model_barang->post($data, $id);
|
||||
$this->session->set_flashdata('message', 'Data Barang berhasil ditambahkan!');
|
||||
redirect('barang');
|
||||
}
|
||||
} else {
|
||||
$id = $this->uri->segment(3);
|
||||
$data['error'] = $this->upload->display_errors();
|
||||
$this->load->model("Model_kategori");
|
||||
$data['kategori'] = $this->Model_kategori->tampilkan_data();
|
||||
$data['suplier'] = $this->Model_kategori->tampilkan_data2();
|
||||
$data['record'] = $this->Model_barang->get_one($id)->row_array();
|
||||
$data['ukuran'] = $this->Model_barang->tampilkan_ukuran()->result();
|
||||
$this->template->load("Template/template", "Barang/form_input", $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function edit()
|
||||
{
|
||||
if (isset($_POST['submit'])) {
|
||||
$config['upload_path'] = './uploads/';
|
||||
$config['allowed_types'] = 'gif|jpg|png|jpeg';
|
||||
$config['max_size'] = 1024;
|
||||
$config['max_width'] = 6000;
|
||||
$config['max_height'] = 6000;
|
||||
$config['overwrite'] = TRUE;
|
||||
$config['remove_spaces'] = TRUE;
|
||||
$config['encrypt_name'] = TRUE;
|
||||
$this->upload->initialize($config);
|
||||
if (!$this->upload->do_upload('foto')) {
|
||||
$this->session->set_flashdata('message', $this->upload->display_errors());
|
||||
redirect($_SERVER['HTTP_REFERER']);
|
||||
return false;
|
||||
} else {
|
||||
$id = $this->input->post('id');
|
||||
$foto = $this->Model_barang->get_one($id)->row_array()['foto'];
|
||||
$path = $this->upload->data('file_path');
|
||||
$uploads = $path . $foto;
|
||||
if (unlink($uploads)) {
|
||||
echo 'deleted successfully';
|
||||
} else {
|
||||
echo 'errors occured';
|
||||
}
|
||||
$nama = $this->input->post('nama_barang');
|
||||
$kategori = $this->input->post('kategori');
|
||||
$harga_dot = $this->input->post('harga');
|
||||
$harga = (int) str_replace('.', '', $harga_dot);
|
||||
$harga_beli_with_dot = $this->input->post('harga_beli');
|
||||
|
||||
// Menghapus tanda titik dari nilai
|
||||
$harga_beli = (int) str_replace('.', '', $harga_beli_with_dot);
|
||||
$ukuran = $this->input->post('ukuran');
|
||||
$foto = $this->upload->data('file_name');
|
||||
$data = array(
|
||||
'nama_barang' => $nama,
|
||||
'id_kategori' => $kategori,
|
||||
'ukuran' => $ukuran,
|
||||
'harga' => $harga,
|
||||
'harga_beli' => $harga_beli,
|
||||
'foto' => $foto,
|
||||
);
|
||||
$this->Model_barang->edit($data, $id);
|
||||
$this->session->set_flashdata('message', 'Data Barang berhasil dirubah!');
|
||||
redirect('barang');
|
||||
}
|
||||
} else {
|
||||
$id = $this->uri->segment(3);
|
||||
$this->load->model('Model_kategori');
|
||||
$data['kategori'] = $this->Model_kategori->tampilkan_data();
|
||||
$data['record'] = $this->Model_barang->get_one($id)->row_array();
|
||||
$data['ukuran'] = $this->Model_barang->tampilkan_ukuran()->result();
|
||||
$this->template->load('Template/template', 'Barang/form_edit', $data);
|
||||
}
|
||||
}
|
||||
function hapus()
|
||||
{
|
||||
$id = $this->uri->segment(3);
|
||||
$this->Model_barang->hapus($id);
|
||||
$this->session->set_flashdata('message', 'Data Barang berhasil dihapus!');
|
||||
redirect('barang');
|
||||
}
|
||||
|
||||
function detail_modal($id)
|
||||
{
|
||||
$id = $this->input->get('id');
|
||||
$data['detail'] = $this->Model_barang->get_detail_modal($id);
|
||||
$this->load->view('Barang/modal_detail', $data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
class Dashboard extends CI_controller
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
chek_session();
|
||||
$this->load->model('Model_dashboard');
|
||||
}
|
||||
|
||||
|
||||
function index()
|
||||
{
|
||||
$data['box'] = $this->box();
|
||||
$data['graph'] = $this->Model_dashboard->graph_stok();
|
||||
$data['kategori'] = $this->Model_dashboard->graph_kategori();
|
||||
$data['laris'] = $this->Model_dashboard->barang_laris();
|
||||
$this->template->load('Template/template', 'Dashboard/lihat_dashboard', $data);
|
||||
// var_dump($this->session->userdata());
|
||||
// die;
|
||||
}
|
||||
|
||||
function form_update(){
|
||||
$this->template->load('Template/template', 'form_update');
|
||||
}
|
||||
public function box()
|
||||
{
|
||||
$box = [
|
||||
[
|
||||
'box' => 'light-blue',
|
||||
'total' => $this->Model_dashboard->total('barang'),
|
||||
'title' => 'Total Barang',
|
||||
'link' => 'Barang',
|
||||
'icon' => 'cubes'
|
||||
],
|
||||
[
|
||||
'box' => 'olive',
|
||||
'total' => $this->Model_dashboard->total('kategori'),
|
||||
'title' => 'Kategori Barang',
|
||||
'link' => 'kategori',
|
||||
'icon' => 'list'
|
||||
],
|
||||
[
|
||||
'box' => 'yellow-active',
|
||||
'total' => $this->Model_dashboard->total_penjualan()->total,
|
||||
'title' => 'Total Penjualan',
|
||||
'link' => 'laporandetail',
|
||||
'icon' => 'shopping-cart'
|
||||
],
|
||||
[
|
||||
'box' => 'red',
|
||||
'total' => $this->Model_dashboard->total_stok()->total,
|
||||
'title' => 'Total Stok Barang',
|
||||
'link' => 'stok',
|
||||
'icon' => 'retweet'
|
||||
],
|
||||
];
|
||||
$info_box = json_decode(json_encode($box), FALSE);
|
||||
return $info_box;
|
||||
}
|
||||
|
||||
public function update_password()
|
||||
{
|
||||
// Pastikan POST request terkirim
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// Ambil data password dari form
|
||||
$password = $this->input->post('password');
|
||||
$confirm_password = $this->input->post('confirm_password');
|
||||
|
||||
// Validasi bahwa kedua password sesuai
|
||||
if ($password == $confirm_password) {
|
||||
// Jika sesuai, update password di database
|
||||
$id_operator = $this->session->userdata('id'); // Sesuaikan dengan session operator Anda
|
||||
$this->db->where('id_operator', $id_operator);
|
||||
$this->db->update('operator', ['password' => md5($password)]);
|
||||
|
||||
// Set pesan alert berhasil
|
||||
$alert_message = array(
|
||||
'class' => 'alert-success',
|
||||
'message' => 'Password Sukses diupdate!'
|
||||
);
|
||||
|
||||
// Set session untuk menampilkan alert
|
||||
$this->session->set_flashdata('alert_message', $alert_message);
|
||||
|
||||
// Redirect ke halaman lain atau tampilkan pesan sukses
|
||||
redirect('dashboard/form_update');
|
||||
} else {
|
||||
// Jika password tidak cocok, set pesan alert gagal
|
||||
$alert_message = array(
|
||||
'class' => 'alert-danger',
|
||||
'message' => 'Password and Confirm Tidak Sama!'
|
||||
);
|
||||
|
||||
// Set session untuk menampilkan alert
|
||||
$this->session->set_flashdata('alert_message', $alert_message);
|
||||
|
||||
// Redirect kembali ke halaman update password
|
||||
redirect('dashboard/form_update');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
class Kategori extends CI_Controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
chek_role();
|
||||
$this->load->model('Model_kategori');
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
$data['record'] = $this->Model_kategori->tampilkan_data();
|
||||
$this->template->load('Template/template', 'Kategori/lihat_data', $data);
|
||||
$this->load->view('Template/datatables');
|
||||
|
||||
}
|
||||
|
||||
function post()
|
||||
{
|
||||
if (isset($_POST['submit'])) {
|
||||
//proses kategori
|
||||
$this->Model_kategori->post();
|
||||
redirect('kategori');
|
||||
} else {
|
||||
$this->template->load('Template/template', 'Kategori/form_input');
|
||||
}
|
||||
}
|
||||
function edit()
|
||||
{
|
||||
if (isset($_POST['submit'])) {
|
||||
//proses kategori
|
||||
$this->Model_kategori->edit();
|
||||
redirect('kategori');
|
||||
} else {
|
||||
$id = $this->uri->segment(3);
|
||||
$data['record'] = $this->Model_kategori->get_one($id)->row_array();
|
||||
$this->template->load('Template/template','Kategori/form_edit', $data);
|
||||
}
|
||||
}
|
||||
|
||||
function hapus()
|
||||
{
|
||||
$td = $this->uri->segment(3);
|
||||
$this->Model_kategori->hapus($td);
|
||||
redirect('kategori');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
class Lapbulanan extends CI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
chek_session();
|
||||
$this->load->model('Model_lapbulanan');
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
$data['tahun'] = $this->uri->segment(3);
|
||||
$thn = $this->uri->segment(3);
|
||||
$data['bulanan'] = $this->Model_lapbulanan->bulanan($thn);
|
||||
$data['cards'] = $this->cards();
|
||||
$this->template->load('Template/template', 'Laporan/lap_bulanan', $data);
|
||||
}
|
||||
|
||||
public function cards()
|
||||
{
|
||||
$data['laris'] = $this->Model_lapbulanan->barang_laris();
|
||||
if ($data['laris'] == FALSE) {
|
||||
$laris = 'kosong';
|
||||
} else {
|
||||
$laris = $data['laris']->nama_barang;
|
||||
}
|
||||
$card = [
|
||||
[
|
||||
'box' => 'green',
|
||||
'total' => 'Rp.' . number_format($this->Model_lapbulanan->income()->gtotal),
|
||||
'title' => 'Pendapatan',
|
||||
'description' => 'Total Pendapatan',
|
||||
'icon' => 'money'
|
||||
],
|
||||
[
|
||||
'box' => 'blue',
|
||||
'total' => $this->Model_lapbulanan->total_penjualan()->total,
|
||||
'title' => 'Barang Terjual',
|
||||
'description' => 'Total Barang Terjual',
|
||||
'icon' => 'shopping-cart'
|
||||
],
|
||||
[
|
||||
'box' => 'yellow-active',
|
||||
'total' => $this->Model_lapbulanan->total_transaksi()->total,
|
||||
'title' => 'Total Penjualan',
|
||||
'description' => 'Total Penjualan',
|
||||
'icon' => 'shopping-basket'
|
||||
],
|
||||
[
|
||||
'box' => 'red',
|
||||
'total' => $laris,
|
||||
'title' => 'Barang Terlaris',
|
||||
'description' => 'Barang Terlaris',
|
||||
'icon' => 'cube'
|
||||
],
|
||||
|
||||
];
|
||||
$info_card = json_decode(json_encode($card), FALSE);
|
||||
return $info_card;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
class Lapharian extends CI_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
chek_session();
|
||||
$this->load->model('Model_lapharian');
|
||||
}
|
||||
|
||||
|
||||
function index($year = NULL, $month = NULL)
|
||||
{
|
||||
$data['calender'] = $this->Model_lapharian->getcalender($year, $month);
|
||||
|
||||
$data['cards'] = $this->cards();
|
||||
$this->template->load('Template/template', 'Laporan/lap_harian', $data);
|
||||
}
|
||||
|
||||
public function cards()
|
||||
{
|
||||
$data['laris'] = $this->Model_lapharian->barang_laris();
|
||||
if ($data['laris'] == FALSE) {
|
||||
$laris = 'kosong';
|
||||
} else {
|
||||
$laris = $this->Model_lapharian->barang_laris()->nama_barang;
|
||||
}
|
||||
$card = [
|
||||
[
|
||||
'box' => 'green',
|
||||
'total' => 'Rp.' . number_format($this->Model_lapharian->income()->gtotal),
|
||||
'title' => 'Pendapatan',
|
||||
'description' => 'Total Pendapatan',
|
||||
'icon' => 'money'
|
||||
],
|
||||
[
|
||||
'box' => 'blue',
|
||||
'total' => $this->Model_lapharian->total_penjualan()->total,
|
||||
'title' => 'Barang Terjual',
|
||||
'description' => 'Total Barang Terjual',
|
||||
'icon' => 'shopping-cart'
|
||||
],
|
||||
[
|
||||
'box' => 'yellow-active',
|
||||
'total' => $this->Model_lapharian->total_transaksi()->total,
|
||||
'title' => 'Total Penjualan',
|
||||
'description' => 'Total Penjualan',
|
||||
'icon' => 'shopping-basket'
|
||||
],
|
||||
[
|
||||
'box' => 'red',
|
||||
'total' => $laris,
|
||||
'title' => 'Barang Terlaris',
|
||||
'description' => 'Barang Terlaris',
|
||||
'icon' => 'cube'
|
||||
],
|
||||
];
|
||||
$info_card = json_decode(json_encode($card), FALSE);
|
||||
return $info_card;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Laporan extends CI_Controller
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
//chek_role();
|
||||
chek_session();
|
||||
$this->load->model('Model_Laporan');
|
||||
}
|
||||
|
||||
|
||||
function index($start = null , $end = null)
|
||||
{
|
||||
if (isset($_POST['search'])) {
|
||||
$start = $this->input->post('start_date');
|
||||
$end = $this->input->post('end_date');
|
||||
$metode = $this->input->post('metode');
|
||||
$data['laporan'] = $this->Model_Laporan->get_range($start,$end,$metode);
|
||||
$data['metode'] = $this->Model_Laporan->get_metode();
|
||||
$this->template->load('Template/template', 'Laporan/lihat_data', $data);
|
||||
$this->load->view('Template/datatables');
|
||||
} else {
|
||||
$data['laporan'] = $this->Model_Laporan->get_data();
|
||||
$data['metode'] = $this->Model_Laporan->get_metode();
|
||||
$this->template->load('Template/template', 'Laporan/lihat_data', $data);
|
||||
$this->load->view('Template/datatables');
|
||||
}
|
||||
}
|
||||
|
||||
function hapus($id)
|
||||
{
|
||||
$this->Model_laporan->hapus_trf($id);
|
||||
$this->Model_laporan->hapus_id($id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Laporandetail extends CI_Controller
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
chek_session();
|
||||
$this->load->model('Model_detail');
|
||||
}
|
||||
|
||||
|
||||
function index($start = null , $end = null)
|
||||
{
|
||||
if (isset($_POST['search'])) {
|
||||
$start = $this->input->post('start_date');
|
||||
$end = $this->input->post('end_date');
|
||||
$metode = $this->input->post('metode');
|
||||
$data['laporan'] = $this->Model_detail->get_range($start,$end,$metode);
|
||||
$data['metode'] = $this->Model_detail->get_metode();
|
||||
$this->template->load('Template/template', 'Laporan/lap_detail', $data);
|
||||
$this->load->view('Template/datatables');
|
||||
}
|
||||
|
||||
elseif (isset($_POST['print'])) {
|
||||
$start = $this->input->post('start_date');
|
||||
$end = $this->input->post('end_date');
|
||||
$metode = $this->input->post('metode');
|
||||
$data['laporan'] = $this->Model_detail->get_range($start,$end,$metode);
|
||||
$data['metode'] = $this->Model_detail->get_metode();
|
||||
$data['start'] = $start;
|
||||
$data['end'] = $end;
|
||||
|
||||
$this->load->view('laporan/printlaporan',$data);
|
||||
}
|
||||
else {
|
||||
$data['laporan'] = $this->Model_detail->get_data();
|
||||
$data['metode'] = $this->Model_detail->get_metode();
|
||||
$this->template->load('Template/template', 'Laporan/lap_detail', $data);
|
||||
$this->load->view('Template/datatables');
|
||||
}
|
||||
}
|
||||
|
||||
public function print_pdf($start = null, $end = null) {
|
||||
// Mengambil data dari model berdasarkan rentang tanggal dan metode yang diberikan
|
||||
$start = $this->input->get('start_date');
|
||||
$end = $this->input->get('end_date');
|
||||
$metode = $this->input->get('metode');
|
||||
$data['laporan'] = $this->Model_detail->get_range($start, $end, $metode);
|
||||
$data['start'] = $start;
|
||||
$data['end'] = $end;
|
||||
|
||||
|
||||
$this->load->view('laporan/printlaporan', $data);
|
||||
}
|
||||
|
||||
|
||||
function hapus($id)
|
||||
{
|
||||
$this->Model_laporan->hapus_trf($id);
|
||||
$this->Model_laporan->hapus_id($id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
class Operator extends CI_Controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
chek_role();
|
||||
$this->load->model('Model_operator');
|
||||
}
|
||||
|
||||
function index()
|
||||
{
|
||||
$data['record'] = $this->Model_operator->tampilkan_data()->result();
|
||||
$this->template->load('Template/template', 'Operator/lihat_data', $data);
|
||||
$this->load->view('Template/datatables');
|
||||
}
|
||||
|
||||
function post()
|
||||
{
|
||||
if (isset($_POST['submit'])) {
|
||||
//proses data
|
||||
$config['upload_path'] = './uploads/operator/';
|
||||
$config['allowed_types'] = 'gif|jpg|png';
|
||||
$config['max_size'] = 1024;
|
||||
$config['max_width'] = 6000;
|
||||
$config['max_height'] = 6000;
|
||||
$config['overwrite'] = TRUE;
|
||||
$config['remove_spaces'] = TRUE;
|
||||
$config['encrypt_name'] = TRUE;
|
||||
$this->upload->initialize($config);
|
||||
if (!$this->upload->do_upload('foto')) {
|
||||
$this->session->set_flashdata('message', $this->upload->display_errors());
|
||||
redirect($_SERVER['HTTP_REFERER']);
|
||||
return false;
|
||||
} else {
|
||||
$data = array('upload_data' => $this->upload->data());
|
||||
$nama = $this->input->post('operator', true);
|
||||
$username = $this->input->post('username', true);
|
||||
$password = $this->input->post('password', true);
|
||||
$akses = $this->input->post('akses', true);
|
||||
$foto = $this->upload->data('file_name');
|
||||
$data = array(
|
||||
'nama_operator' => $nama,
|
||||
'username' => $username,
|
||||
'password' => md5($password),
|
||||
'id_akses' => $akses,
|
||||
'foto' => $foto,
|
||||
|
||||
);
|
||||
$this->db->insert('operator', $data);
|
||||
redirect('operator');
|
||||
}
|
||||
} else {
|
||||
$data['akses'] = $this->Model_operator->getAkses();
|
||||
$data['error'] = $this->upload->display_errors();
|
||||
$this->template->load('Template/template', 'Operator/form_input', $data);
|
||||
}
|
||||
}
|
||||
|
||||
function edit()
|
||||
{
|
||||
if (isset($_POST['submit'])) {
|
||||
//proses operator
|
||||
$config['upload_path'] = './uploads/operator/';
|
||||
$config['allowed_types'] = 'gif|jpg|png';
|
||||
$config['max_size'] = 1024;
|
||||
$config['max_width'] = 6000;
|
||||
$config['max_height'] = 6000;
|
||||
$config['overwrite'] = TRUE;
|
||||
$config['remove_spaces'] = TRUE;
|
||||
$config['encrypt_name'] = TRUE;
|
||||
$this->upload->initialize($config);
|
||||
if (!$this->upload->do_upload('foto')) {
|
||||
$this->session->set_flashdata('message', $this->upload->display_errors());
|
||||
redirect($_SERVER['HTTP_REFERER']);
|
||||
return false;
|
||||
} else {
|
||||
$data = array('upload_data' => $this->upload->data());
|
||||
$nama = $this->input->post('operator', true);
|
||||
$username = $this->input->post('username', true);
|
||||
$akses = $this->input->post('akses', true);
|
||||
$foto = $this->upload->data('file_name');
|
||||
$data = array(
|
||||
'nama_operator' => $nama,
|
||||
'username' => $username,
|
||||
'id_akses' => $akses,
|
||||
'foto' => $foto
|
||||
);
|
||||
$this->Model_operator->edit($data);
|
||||
redirect('operator');
|
||||
}
|
||||
} else {
|
||||
|
||||
$id = $this->uri->segment(3);
|
||||
$data['record'] = $this->Model_operator->get_one($id)->row_array();
|
||||
$data['akses'] = $this->Model_operator->getAkses();
|
||||
$this->template->load('Template/template', 'Operator/form_edit', $data);
|
||||
}
|
||||
}
|
||||
|
||||
function hapus()
|
||||
{
|
||||
$id = $this->uri->segment(3);
|
||||
$this->db->where('id_operator', $id);
|
||||
$this->db->delete('operator');
|
||||
redirect('operator');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
<?php
|
||||
class Penjualan extends CI_Controller
|
||||
{
|
||||
// halaman construct sebagai konstruktor method yang pertama kali akan dipanggil
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
chek_session();
|
||||
$this->load->model('Model_barang');
|
||||
$this->load->model('Model_kategori');
|
||||
$this->load->model('Model_stok');
|
||||
$this->load->model('Model_penjualan');
|
||||
$this->load->library('cart');
|
||||
}
|
||||
// halaman construct sebagai konstruktor method yang pertama kali akan dipanggil
|
||||
|
||||
// sebagai index yang sudah di custom oleh Apllication/config/routes.php
|
||||
function store()
|
||||
{
|
||||
// kondisi jika menekan tombol filter
|
||||
if (isset($_POST['filter'])) {
|
||||
// $this->input->post untuk memproses data dari form $_POST
|
||||
$kategori = $this->input->post('kategori');
|
||||
$ukuran = $this->input->post('ukuran');
|
||||
// ---- $this->input->post untuk memproses data dari form $_POST
|
||||
$total = $this->Model_penjualan->stok_list();
|
||||
// load library pagination(halaman) beserta confignya
|
||||
$this->load->library('pagination');
|
||||
$config['base_url'] = base_url('penjualan/store/'); //halaman utama
|
||||
$config['total_rows'] = $total; //total baris berdasarkan dari databse
|
||||
$config['per_page'] = 0; // set 0 karena masuk kondisi ketika memilih filter "pilih semua"
|
||||
$config['first_link'] = 'First'; // config tombol halaman awal
|
||||
$config['last_link'] = 'Last'; // config tombol halaman akhir
|
||||
$config['next_link'] = 'Next'; // config tombol halaman selanjutnya
|
||||
$config['prev_link'] = 'Prev'; // config tombol halaman sebelumnya
|
||||
$config['full_tag_open'] = '<div class="pagging text-center"><nav><ul class="pagination justify-content-center">';
|
||||
$config['full_tag_close'] = '</ul></nav></div>';
|
||||
$config['num_tag_open'] = '<li class="page-item"><span class="page-link">';
|
||||
$config['num_tag_close'] = '</span></li>';
|
||||
$config['cur_tag_open'] = '<li class="page-item active"><span class="page-link">';
|
||||
$config['cur_tag_close'] = '<span class="sr-only">(current)</span></span></li>';
|
||||
$config['next_tag_open'] = '<li class="page-item"><span class="page-link">';
|
||||
$config['next_tagl_close'] = '<span aria-hidden="true">»</span></span></li>';
|
||||
$config['prev_tag_open'] = '<li class="page-item"><span class="page-link">';
|
||||
$config['prev_tagl_close'] = '</span>Next</li>';
|
||||
$config['first_tag_open'] = '<li class="page-item"><span class="page-link">';
|
||||
$config['first_tagl_close'] = '</span></li>';
|
||||
$config['last_tag_open'] = '<li class="page-item"><span class="page-link">';
|
||||
$config['last_tagl_close'] = '</span></li>';
|
||||
$this->pagination->initialize($config); // setelah config , config tersebut akan di inialisasi, jika tidak config tersebut tidak akan berfungsi
|
||||
$from = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
|
||||
|
||||
//sebuah kumpulan variable yang di satukan menjadi array pada variable $data
|
||||
$data = array(
|
||||
'halaman' => $this->pagination->create_links(),
|
||||
'result' => $this->Model_penjualan->filter_barang($kategori, $ukuran, $config['per_page'], $from),
|
||||
'kategori' => $this->Model_kategori->tampilkan_data(),
|
||||
'ukuran' => $this->Model_barang->tampilkan_ukuran()->result(),
|
||||
'record' => $this->Model_penjualan->tampilkan_data(),
|
||||
);
|
||||
//-----sebuah kumpulan variable yang di satukan menjadi array pada variable $data
|
||||
$this->template->load('Template/template', 'Penjualan/penjualan', $data); //memanggil template dan view dari controller beserta variable $data
|
||||
} else {
|
||||
|
||||
$total = $this->Model_penjualan->stok_list();
|
||||
$this->load->library('pagination');
|
||||
$config['base_url'] = base_url('penjualan/store/');
|
||||
$config['per_page'] = 8;
|
||||
$config['total_rows'] = $total;
|
||||
$config['first_link'] = 'First';
|
||||
$config['last_link'] = 'Last';
|
||||
$config['next_link'] = 'Next';
|
||||
$config['prev_link'] = 'Prev';
|
||||
$config['full_tag_open'] = '<div class="pagging text-center"><nav><ul class="pagination justify-content-center">';
|
||||
$config['full_tag_close'] = '</ul></nav></div>';
|
||||
$config['num_tag_open'] = '<li class="page-item"><span class="page-link">';
|
||||
$config['num_tag_close'] = '</span></li>';
|
||||
$config['cur_tag_open'] = '<li class="page-item active"><span class="page-link">';
|
||||
$config['cur_tag_close'] = '<span class="sr-only">(current)</span></span></li>';
|
||||
$config['next_tag_open'] = '<li class="page-item"><span class="page-link">';
|
||||
$config['next_tagl_close'] = '<span aria-hidden="true">»</span></span></li>';
|
||||
$config['prev_tag_open'] = '<li class="page-item"><span class="page-link">';
|
||||
$config['prev_tagl_close'] = '</span>Next</li>';
|
||||
$config['first_tag_open'] = '<li class="page-item"><span class="page-link">';
|
||||
$config['first_tagl_close'] = '</span></li>';
|
||||
$config['last_tag_open'] = '<li class="page-item"><span class="page-link">';
|
||||
$config['last_tagl_close'] = '</span></li>';
|
||||
$this->pagination->initialize($config);
|
||||
$from = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
|
||||
$data = array(
|
||||
'halaman' => $this->pagination->create_links(),
|
||||
'result' => $this->Model_penjualan->Halaman($config['per_page'], $from),
|
||||
'kategori' => $this->Model_kategori->tampilkan_data(),
|
||||
'ukuran' => $this->Model_barang->tampilkan_ukuran()->result(),
|
||||
'record' => $this->Model_penjualan->tampilkan_data(),
|
||||
);
|
||||
$this->template->load('Template/template', 'Penjualan/penjualan', $data);
|
||||
}
|
||||
}
|
||||
|
||||
function tambah_barang($id, $qty)
|
||||
{
|
||||
$barang = $this->Model_penjualan->lihat_barang($id);
|
||||
if ($barang->row()->jumlah > 350) {
|
||||
$this->session->set_flashdata('message', 'Stok Barang melebihi kapasitas');
|
||||
redirect(base_url('index.php/penjualan'));
|
||||
}
|
||||
elseif ($barang->row()->jumlah < 1) {
|
||||
$this->session->set_flashdata('message', 'Persediaan Barang Habis');
|
||||
redirect(base_url('index.php/penjualan'));
|
||||
}
|
||||
else {
|
||||
$result = $this->Model_penjualan->cart($id);
|
||||
$data = array(
|
||||
'id_barang' => $result->id_barang,
|
||||
'stok_barang' => $result->jumlah_stok,
|
||||
'id' => $result->id_barang,
|
||||
'name' => $result->nama_barang,
|
||||
'qty' => $qty,
|
||||
'price' => $result->harga,
|
||||
'size' => $result->ukuran,
|
||||
'namesize' => $result->nama_ukuran,
|
||||
);
|
||||
$this->cart->insert($data);
|
||||
redirect(base_url('index.php/penjualan'));
|
||||
}
|
||||
}
|
||||
public function get_siswa_by_nis() {
|
||||
$nis = $this->input->post('nis');
|
||||
|
||||
// Misalkan $data_siswa adalah array yang berisi data siswa dari sumber data Anda
|
||||
// Di sini Anda mengambil data sesuai NIS yang dipilih
|
||||
$data_siswa = $this->db->get_where('siswa', array('nis' => $nis))->row_array();
|
||||
|
||||
// Mengirimkan data siswa sebagai JSON
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($data_siswa);
|
||||
}
|
||||
|
||||
function caribarang()
|
||||
{
|
||||
$key = $this->input->get('q');
|
||||
$data = $this->Model_penjualan->hasilcari($key);
|
||||
foreach ($data as $result) {
|
||||
echo '<a href="' . base_url() . 'index.php/penjualan/tambah_barang/' . $result->id_barang . '/1">' . $result->nama_barang . '</a><br />';
|
||||
}
|
||||
}
|
||||
function ubah_qty()
|
||||
{
|
||||
$barang = $this->Model_penjualan->lihat_barang($this->input->post('idbarang'));
|
||||
$permintaan = intval($this->input->post('qty'));
|
||||
$jumlahstok = intval($barang->row()->jumlah);
|
||||
if ($permintaan >= $jumlahstok) {
|
||||
$this->session->set_flashdata('message', 'Jumlah permintaan melebihi stok barang');
|
||||
redirect(base_url('index.php/penjualan'));
|
||||
} else {
|
||||
$data = array(
|
||||
'rowid' => $this->input->post('rowid'),
|
||||
'qty' => $this->input->post('qty')
|
||||
);
|
||||
$this->cart->update($data);
|
||||
redirect(base_url('index.php/penjualan'));
|
||||
}
|
||||
}
|
||||
function hapus_cart($row)
|
||||
{
|
||||
$data = array(
|
||||
'rowid' => $row,
|
||||
'qty' => 0,
|
||||
);
|
||||
$this->cart->update($data);
|
||||
redirect(base_url('index.php/penjualan'));
|
||||
}
|
||||
function cancel()
|
||||
{
|
||||
$this->cart->destroy();
|
||||
redirect(base_url('index.php/penjualan'));
|
||||
}
|
||||
|
||||
function formatNbr($nbr)
|
||||
{
|
||||
if ($nbr == 0 || $nbr == NULL)
|
||||
return "001";
|
||||
else if ($nbr < 10)
|
||||
return "00" . $nbr;
|
||||
elseif ($nbr >= 10 && $nbr < 100)
|
||||
return "0" . $nbr;
|
||||
else
|
||||
return strval($nbr);
|
||||
}
|
||||
|
||||
function transaksi()
|
||||
{
|
||||
$no_trf = $this->Model_penjualan->get_byr($this->input->post('metode'));
|
||||
if ($no_trf->id_byr == 1) {
|
||||
$metode = strtoupper($no_trf->metode);
|
||||
$notrf = substr($metode, 0, 1);
|
||||
} else if ($no_trf->id_byr == 2) {
|
||||
$metode = strtoupper($no_trf->metode);
|
||||
$notrf = substr($metode, 0, 1);
|
||||
} else {
|
||||
$notrf = "0";
|
||||
}
|
||||
$kode = $this->Model_penjualan->get_nourut();
|
||||
$nourut = $this->formatNbr($kode[0]->nomor);
|
||||
$tgl = date('Ymd');
|
||||
$kodeurut = $notrf . $tgl . $nourut;
|
||||
$payment = array(
|
||||
'no_trf' => $kodeurut,
|
||||
'nis_siswa' => $this->input->post('nisn'),
|
||||
'nama_siswa' => $this->input->post('siswa'),
|
||||
'kelas' => $this->input->post('kelas'),
|
||||
'status' => $this->input->post('status'),
|
||||
'totalpure' => $this->input->post('totalpure'),
|
||||
'grand_total ' => $this->input->post('grandtotal'),
|
||||
'diskon' => $this->input->post('diskon'),
|
||||
'bayar' => $this->input->post('bayar'),
|
||||
'kembalian' => $this->input->post('kembalian'),
|
||||
'catatan' => $this->input->post('note'),
|
||||
'tgl_trf' => date('Y-m-d'),
|
||||
'jam_trf' => date('H:i:s'),
|
||||
'id_pembayaran' => $this->input->post('metode'),
|
||||
'no_rek' => $this->input->post('norek'),
|
||||
'atas_nama' => $this->input->post('atas_nama'),
|
||||
'id_bank' => $this->input->post('payments'),
|
||||
'operator' => $this->session->userdata['nama'],
|
||||
);
|
||||
$detail_penjualan = $this->Model_penjualan->tambah_trf($payment);
|
||||
$id_dtlpenjualan = $this->Model_penjualan->get_id($kodeurut);
|
||||
|
||||
$pjl = array();
|
||||
foreach ($this->cart->contents() as $q) {
|
||||
$pjl[] = array(
|
||||
'id_barang' => $q['id_barang'],
|
||||
'stok_barang' => intval($this->Model_penjualan->total_barang($q['id_barang'])->row()->total) - intval($q['qty']),
|
||||
'tanggal_stok' => date('Y-m-d'),
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($this->cart->contents() as $items) {
|
||||
$penjualan[] = array(
|
||||
'id_dtlpen' => $id_dtlpenjualan['id'],
|
||||
'id_barang' => $items['id_barang'],
|
||||
'jumlah_stok' => $items['qty'],
|
||||
'harga_barang' => $items['price'],
|
||||
'sub_total' => $items['subtotal'],
|
||||
);
|
||||
}
|
||||
|
||||
$png = $this->Model_penjualan->pengurangan_stok($pjl);
|
||||
$pjl = $this->Model_penjualan->tambah_pjl($penjualan);
|
||||
if (!$detail_penjualan && !$pjl && !$png) {
|
||||
$this->cart->destroy();
|
||||
$this->session->set_flashdata('message', 'Penjualan Sukses');
|
||||
redirect('penjualan/struk/' . $id_dtlpenjualan['id']);
|
||||
} else {
|
||||
$this->session->set_flashdata('message', 'Ooopss! Penjualan Gagal, Namun Stok Data Berubah!');
|
||||
redirect('penjualan');
|
||||
}
|
||||
}
|
||||
|
||||
function struk($id)
|
||||
{
|
||||
$cek = $this->Model_penjualan->cek_transaksi($this->uri->segment(3));
|
||||
$data = array(
|
||||
'tanggal' => $cek[0]->tgl_trf,
|
||||
'jam' => $cek[0]->jam_trf,
|
||||
'nota' => $cek[0]->no_trf,
|
||||
'operator' => $cek[0]->operator,
|
||||
'pelanggan' => $cek[0]->nama_pelanggan,
|
||||
'total' => $cek[0]->totalpure,
|
||||
'diskon' => $cek[0]->diskon,
|
||||
'grand_total' => $cek[0]->grand_total,
|
||||
'result' => $cek,
|
||||
'metode' => $cek[0]->metode,
|
||||
'bayar' => $cek[0]->bayar,
|
||||
'nis_siswa' => $cek[0]->nis_siswa,
|
||||
'nama_siswa' => $cek[0]->nama_siswa,
|
||||
'status' => $cek[0]->status,
|
||||
'kelas' => $cek[0]->kelas,
|
||||
'kembalian' => $cek[0]->kembalian,
|
||||
'rekening' => $cek[0]->no_rek,
|
||||
'bank' => $cek[0]->nama_bank,
|
||||
'atasnama' => $cek[0]->atas_nama,
|
||||
);
|
||||
$this->template->load('Template/template', 'Penjualan/struk', $data);
|
||||
}
|
||||
|
||||
function detail_modal($id)
|
||||
{
|
||||
$id = $this->input->get('id');
|
||||
$data['detail'] = $this->Model_penjualan->get_detail_modal($id);
|
||||
$this->load->view('Penjualan/modal_detail', $data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
class Siswa extends CI_Controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
chek_role();
|
||||
$this->load->model('Model_barang');
|
||||
$this->load->model('Model_kategori');
|
||||
// $this->load->library('PhpSpreadsheet');
|
||||
}
|
||||
function index()
|
||||
{
|
||||
$data['record'] = $this->db->get("siswa")->result();
|
||||
$this->template->load('Template/template', 'Siswa/lihat_data', $data);
|
||||
$this->load->view('Template/datatables');
|
||||
|
||||
}
|
||||
function post()
|
||||
{
|
||||
if (isset($_POST["submit"])) {
|
||||
|
||||
// proses barang
|
||||
$id = $this->input->post('id');
|
||||
$nama = $this->input->post('nama_siswa');
|
||||
$kelas = $this->input->post('kelas');
|
||||
$nis = $this->input->post('nis');
|
||||
$status = $this->input->post('status');
|
||||
|
||||
$data = array(
|
||||
'nama' => $nama,
|
||||
'kelas' => $kelas,
|
||||
'nis' => $nis,
|
||||
'status' => $status,
|
||||
|
||||
);
|
||||
$this->db->insert("siswa",$data);
|
||||
$this->session->set_flashdata('message', 'Data Siswa berhasil ditambahkan!');
|
||||
redirect('siswa');
|
||||
|
||||
} else {
|
||||
$id = $this->uri->segment(3);
|
||||
$data['error'] = $this->upload->display_errors();
|
||||
$this->load->model("Model_kategori");
|
||||
|
||||
$this->template->load("Template/template", "Siswa/form_input", $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function edit()
|
||||
{
|
||||
if (isset($_POST['submit'])) {
|
||||
$id = $this->input->post('id');
|
||||
$nama = $this->input->post('nama_siswa');
|
||||
$kelas = $this->input->post('kelas');
|
||||
$nis = $this->input->post('nis');
|
||||
$status = $this->input->post('status');
|
||||
$data = array(
|
||||
'nama' => $nama,
|
||||
'kelas' => $kelas,
|
||||
'nis' => $nis,
|
||||
'status' => $status,
|
||||
);
|
||||
$this->Model_barang->editsiswa($data, $id);
|
||||
$this->session->set_flashdata('message', 'Data Barang berhasil dirubah!');
|
||||
redirect('siswa');
|
||||
|
||||
} else {
|
||||
$id = $this->uri->segment(3);
|
||||
$this->load->model('Model_kategori');
|
||||
|
||||
$data['record'] = $this->Model_barang->get_ones($id)->row_array();
|
||||
|
||||
$this->template->load('Template/template', 'Siswa/form_edit', $data);
|
||||
}
|
||||
}
|
||||
function hapus()
|
||||
{
|
||||
$id = $this->uri->segment(3);
|
||||
$this->Model_barang->hapussiswa($id);
|
||||
$this->session->set_flashdata('message', 'Data Siswa berhasil dihapus!');
|
||||
redirect('barang');
|
||||
}
|
||||
|
||||
function detail_modal($id)
|
||||
{
|
||||
$id = $this->input->get('id');
|
||||
$data['detail'] = $this->Model_barang->get_detail_modal($id);
|
||||
$this->load->view('Siswa/modal_detail', $data);
|
||||
}
|
||||
|
||||
|
||||
public function import_excel() {
|
||||
$config['upload_path'] = './uploads/';
|
||||
$config['allowed_types'] = 'xlsx|xls'; // Jenis file yang diizinkan
|
||||
$config['max_size'] = 2048; // Ukuran maksimal file (dalam kilobita)
|
||||
|
||||
$this->upload->initialize($config);
|
||||
|
||||
if (!$this->upload->do_upload('excel_file')) {
|
||||
// Jika upload gagal, tampilkan pesan error
|
||||
$error = $this->upload->display_errors();
|
||||
$this->session->set_flashdata('message', $error);
|
||||
redirect('siswa'); // Redirect kembali ke halaman siswa
|
||||
} else {
|
||||
// Jika upload berhasil, lanjutkan dengan membaca file Excel
|
||||
$file_data = $this->upload->data();
|
||||
$file_path = './uploads/' . $file_data['file_name'];
|
||||
|
||||
|
||||
// Load file Excel
|
||||
$objPHPExcel = IOFactory::load($file_path);
|
||||
|
||||
// Mendapatkan objek worksheet
|
||||
$sheet = $objPHPExcel->getActiveSheet();
|
||||
|
||||
// Mendapatkan jumlah baris di file Excel
|
||||
$highest_row = $sheet->getHighestDataRow();
|
||||
|
||||
// Mulai dari baris kedua (karena baris pertama biasanya adalah header)
|
||||
for ($row = 2; $row <= $highest_row; $row++) {
|
||||
// Ambil nilai dari setiap kolom pada baris saat ini
|
||||
$nama = $sheet->getCellByColumnAndRow(2, $row)->getValue();
|
||||
$kelas = $sheet->getCellByColumnAndRow(3, $row)->getValue();
|
||||
$nis = $sheet->getCellByColumnAndRow(1, $row)->getValue();
|
||||
$status = $sheet->getCellByColumnAndRow(4, $row)->getValue();
|
||||
|
||||
// Simpan data siswa ke dalam database
|
||||
$data = array(
|
||||
'nama' => $nama,
|
||||
'kelas' => $kelas,
|
||||
'nis' => $nis,
|
||||
'status' => $status
|
||||
);
|
||||
$this->db->insert('siswa', $data);
|
||||
}
|
||||
|
||||
// Hapus file Excel yang diunggah
|
||||
unlink($file_path);
|
||||
|
||||
// Set pesan sukses
|
||||
$this->session->set_flashdata('message', 'Data berhasil diimpor dari file Excel.');
|
||||
|
||||
// Redirect kembali ke halaman siswa
|
||||
redirect('siswa');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
class Stok extends CI_Controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('Model_barang');
|
||||
$this->load->model('Model_kategori');
|
||||
$this->load->model('Model_stok');
|
||||
}
|
||||
|
||||
|
||||
function index()
|
||||
{
|
||||
$data['stok'] = $this->Model_stok->tampil_data();
|
||||
$this->template->load('Template/template', 'Stok/lihat_data', $data);
|
||||
$this->load->view('Template/datatables');
|
||||
}
|
||||
|
||||
function post()
|
||||
{
|
||||
if (isset($_POST["submit"])) {
|
||||
$barang = $this->input->post('barang');
|
||||
$stok = $this->Model_stok->get_stok($barang);
|
||||
if ($stok != NULL) {
|
||||
$stok_sebelumnya = $this->Model_stok->get_stok($barang)->stok_barang;
|
||||
$stok_baru = $this->input->post('stok');
|
||||
$hasil = intval($stok_sebelumnya) + intval($stok_baru);
|
||||
if ($hasil >= 325) {
|
||||
$this->session->set_flashdata('message', 'Kapasitas Stok Barang Telah melebihi Batas Maksimum!');
|
||||
redirect('stok');
|
||||
} else {
|
||||
$data = array(
|
||||
'id_barang' => $barang,
|
||||
'stok_barang' => $hasil,
|
||||
'tanggal_stok' => date('Y-m-d')
|
||||
);
|
||||
$this->Model_stok->tambah_stok($barang, $data);
|
||||
redirect('stok');
|
||||
}
|
||||
} else {
|
||||
$stok = $this->input->post('stok');
|
||||
$data = array(
|
||||
'id_barang' => $barang,
|
||||
'stok_barang' => $stok,
|
||||
'tanggal_stok' => date('Y-m-d')
|
||||
);
|
||||
$this->Model_stok->post($data);
|
||||
redirect('stok');
|
||||
}
|
||||
} else {
|
||||
$id = $this->uri->segment(3);
|
||||
$data['barang'] = $this->Model_barang->tampil_dropdown()->result();
|
||||
$this->template->load("Template/template", "Stok/form_input", $data);
|
||||
}
|
||||
}
|
||||
|
||||
function edit()
|
||||
{
|
||||
if (isset($_POST['submit'])) {
|
||||
$id = $this->input->post('id');
|
||||
$barang = $this->input->post('barang');
|
||||
$stok = $this->input->post('stok');
|
||||
if (intval($stok) >= 325) {
|
||||
$this->session->set_flashdata('message', 'Stok Barang Yang Dimasukkan Telah melebihi Batas Maksimum!');
|
||||
redirect('stok');
|
||||
} else {
|
||||
$data = array(
|
||||
'id_barang' => $barang,
|
||||
'stok_barang' => $stok
|
||||
);
|
||||
$this->Model_stok->edit($id, $data);
|
||||
redirect('stok');
|
||||
}
|
||||
} else {
|
||||
$id = $this->uri->segment(3);
|
||||
$data['barang'] = $this->Model_barang->tampil_dropdown()->result();
|
||||
$data['stok'] = $this->Model_stok->get_one($id)->row_array();
|
||||
$this->template->load('Template/template', 'Stok/form_edit', $data);
|
||||
}
|
||||
}
|
||||
|
||||
function hapus()
|
||||
{
|
||||
$id = $this->uri->segment(3);
|
||||
$this->Model_stok->hapus($id);
|
||||
redirect('stok');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
require 'vendor/autoload.php';
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
|
||||
class Suplier extends CI_Controller
|
||||
{
|
||||
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
chek_role();
|
||||
$this->load->model('Model_barang');
|
||||
$this->load->model('Model_kategori');
|
||||
// $this->load->library('PhpSpreadsheet');
|
||||
}
|
||||
function index()
|
||||
{
|
||||
$data['record'] = $this->db->get("suplier")->result();
|
||||
$this->template->load('Template/template', 'Suplier/lihat_data', $data);
|
||||
$this->load->view('Template/datatables');
|
||||
|
||||
}
|
||||
function post()
|
||||
{
|
||||
if (isset($_POST["submit"])) {
|
||||
|
||||
// proses suplier
|
||||
$id = $this->input->post('id');
|
||||
$nama = $this->input->post('nama_perusahaan');
|
||||
$alamat = $this->input->post('alamat');
|
||||
$tlp = $this->input->post('no_tlp');
|
||||
$email = $this->input->post('email');
|
||||
|
||||
$data = array(
|
||||
'nama_perusahaan' => $nama,
|
||||
'alamat' => $alamat,
|
||||
'no_tlp' => $tlp,
|
||||
'email' => $email,
|
||||
|
||||
);
|
||||
$this->db->insert("suplier",$data);
|
||||
$this->session->set_flashdata('message', 'Data Suplier berhasil ditambahkan!');
|
||||
redirect('suplier');
|
||||
|
||||
} else {
|
||||
$id = $this->uri->segment(3);
|
||||
$data['error'] = $this->upload->display_errors();
|
||||
$this->load->model("Model_kategori");
|
||||
|
||||
$this->template->load("Template/template", "Suplier/form_input", $data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function edit()
|
||||
{
|
||||
if (isset($_POST['submit'])) {
|
||||
$id = $this->input->post('id');
|
||||
$nama = $this->input->post('nama_perusahaan');
|
||||
$alamat = $this->input->post('alamat');
|
||||
$tlp = $this->input->post('no_tlp');
|
||||
$email = $this->input->post('email');
|
||||
$data = array(
|
||||
'nama_perusahaan' => $nama,
|
||||
'alamat' => $alamat,
|
||||
'no_tlp' => $tlp,
|
||||
'email' => $email,
|
||||
);
|
||||
$this->Model_barang->editsuplier($data, $id);
|
||||
$this->session->set_flashdata('message', 'Data Suplier berhasil dirubah!');
|
||||
redirect('suplier');
|
||||
|
||||
} else {
|
||||
$id = $this->uri->segment(3);
|
||||
$this->load->model('Model_kategori');
|
||||
$data['record'] = $this->Model_barang->get_ones2($id)->row_array();
|
||||
$this->template->load('Template/template', 'Suplier/form_edit', $data);
|
||||
}
|
||||
}
|
||||
function hapus()
|
||||
{
|
||||
$id = $this->uri->segment(3);
|
||||
$this->Model_barang->hapussuplier($id);
|
||||
$this->session->set_flashdata('message', 'Data Suplier berhasil dihapus!');
|
||||
redirect('suplier');
|
||||
}
|
||||
|
||||
function detail_modal($id)
|
||||
{
|
||||
$id = $this->input->get('id');
|
||||
$data['detail'] = $this->Model_barang->get_detail_modal2($id);
|
||||
$this->load->view('Suplier/modal_detail', $data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title> SELAMAT DATANG DI CV. BILBIL BERKAH SEJAHTERA BANDUNG</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user