208 lines
5.2 KiB
PHP
208 lines
5.2 KiB
PHP
<?php
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class Action extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('Kueri');
|
|
$this->load->model('LevelModel', 'LevelM');
|
|
$this->load->library(['datatables', 'form_validation']);
|
|
$this->form_validation->set_error_delimiters('', '');
|
|
}
|
|
public function output_json($data, $encode = true)
|
|
{
|
|
if ($encode) $data = json_encode($data);
|
|
$this->output->set_content_type('application/json')->set_output($data);
|
|
}
|
|
public function index()
|
|
{
|
|
$username = $this->session->userdata('username');
|
|
if ($username != null) {
|
|
redirect("Authority");
|
|
}
|
|
$this->load->view('signin');
|
|
}
|
|
public function login()
|
|
{
|
|
$this->load->view('signin');
|
|
}
|
|
public function admin_so()
|
|
{
|
|
$data = array(
|
|
'status_checker' => $this->Kueri->lihat_status()
|
|
);
|
|
$this->load->view('so-center', $data);
|
|
}
|
|
public function table_admin_so()
|
|
{
|
|
$data = array(
|
|
'oper_tek' => $this->Kueri->lihat_ot()
|
|
);
|
|
$this->load->view('table-admin-so', $data);
|
|
}
|
|
public function table_sales_order()
|
|
{
|
|
// $data = array(
|
|
// 'oper_tek' => $this->Kueri->lihat_ot()
|
|
// );
|
|
$this->load->view('table-sales-order');
|
|
}
|
|
// public function my_history()
|
|
// {
|
|
// $ID_USER=$this->session->userdata('ID_USER');
|
|
// $data = array(
|
|
// 'my_so' => $this->Kueri->lihat_soku($ID_USER)
|
|
// );
|
|
// $this->load->view('table-myhistory', $data);
|
|
// }
|
|
public function hapus_so()
|
|
{
|
|
$KODE_SO = $this->input->post('KODE_SO');
|
|
$this->Model_toko->del_so($KODE_SO);
|
|
redirect(base_url("index.php/Action/tables_admin_so"));
|
|
}
|
|
// public function table_account()
|
|
// {
|
|
// $this->load->view('table-account');
|
|
// }
|
|
public function table_pelanggan()
|
|
{
|
|
$this->load->view('table-pelanggan');
|
|
}
|
|
public function table_barang()
|
|
{
|
|
$this->load->view('table-barang');
|
|
}
|
|
public function tambah_so()
|
|
{
|
|
$this->load->view('tambah-so');
|
|
}
|
|
// public function tambah_user()
|
|
// {
|
|
// $this->load->view('tambah-user');
|
|
// }
|
|
public function tambah_barang()
|
|
{
|
|
$this->load->view('tambah-barang');
|
|
}
|
|
public function tambah_pelanggan()
|
|
{
|
|
$this->load->view('tambah-pelanggan');
|
|
}
|
|
public function edit_user()
|
|
{
|
|
$this->load->view('edit-user');
|
|
}
|
|
public function edit_barang()
|
|
{
|
|
$this->load->view('edit-barang');
|
|
}
|
|
// public function edit_pelanggan()
|
|
// {
|
|
// $this->load->view('edit-pelanggan');
|
|
// }
|
|
public function view_so()
|
|
{
|
|
$data = array(
|
|
'status_checker' => $this->Kueri->lihat_status()
|
|
);
|
|
$this->load->view('view-so', $data);
|
|
}
|
|
public function login_action()
|
|
{
|
|
$usernames = $this->session->userdata('username');
|
|
$levels = $this->session->userdata('level');
|
|
if ($usernames != null) {
|
|
redirect('authority');
|
|
}
|
|
////
|
|
$username = $this->input->post('username');
|
|
$password = $this->input->post('password');
|
|
$remember = $this->input->post('rememberme');
|
|
|
|
|
|
$check_un = $this->Kueri->getUn($username);
|
|
$check_login_r = $this->Kueri->getLogin($username, $password)->num_rows();
|
|
// var_dump($check_un);
|
|
|
|
if ($check_un > 0) {
|
|
if ($check_login_r > 0) {
|
|
$datauser = $this->Kueri->getLogin($username, $password)->row_array();
|
|
|
|
$lev = $this->LevelM->getDataLevel($datauser['LEVEL_ID']);
|
|
// $level = 'sdfdsfsdfs';
|
|
if (is_array($lev) || is_object($lev)) {
|
|
foreach ($lev as $key) {
|
|
$level = $key['NAMA_LEVEL'];
|
|
}
|
|
}
|
|
|
|
$sessions = array(
|
|
'id_user' => $datauser['ID_USER'],
|
|
'nama_user' => $datauser['NAMA_USER'],
|
|
'nama_panggilan' => $datauser['NAMA_PANGGILAN'],
|
|
'username' => $datauser['USERNAME'],
|
|
'password' => $datauser['PASSWORD'],
|
|
'level' => $level,
|
|
'status' => $datauser['STATUS']
|
|
);
|
|
if ($remember != null) {
|
|
|
|
setcookie('username', $username, time() + (86400 * 30), "/");
|
|
setcookie('password', $password, time() + (86400 * 30), "/");
|
|
}
|
|
// var_dump($sessionsnya);
|
|
// kill();
|
|
$this->session->set_userdata($sessions);
|
|
redirect('authority');
|
|
} else {
|
|
$this->session->set_flashdata('flash_gagal', 'Password Salah');
|
|
redirect('Action');
|
|
}
|
|
} else {
|
|
$this->session->set_flashdata('flash_gagal', 'Username belum terdaftar');
|
|
redirect('Action');
|
|
}
|
|
|
|
|
|
|
|
// if ($check_login_r > 0) {
|
|
// $datauser = $this->Kueri->getLogin($username, $password)->row_array();
|
|
|
|
// $lev = $this->LevelM->getDataLevel($datauser['LEVEL_ID']);
|
|
// // $level = 'sdfdsfsdfs';
|
|
// if (is_array($lev) || is_object($lev)) {
|
|
// foreach ($lev as $key) {
|
|
// $level = $key['NAMA_LEVEL'];
|
|
// }
|
|
// }
|
|
|
|
// $sessions = array(
|
|
// 'id_user' => $datauser['ID_USER'],
|
|
// 'nama_user' => $datauser['NAMA_USER'],
|
|
// 'nama_panggilan' => $datauser['NAMA_PANGGILAN'],
|
|
// 'username' => $datauser['USERNAME'],
|
|
// 'password' => $datauser['PASSWORD'],
|
|
// 'level' => $level,
|
|
// 'status' => $datauser['STATUS']
|
|
// );
|
|
// // var_dump($sessionsnya);
|
|
// // kill();
|
|
// $this->session->set_userdata($sessions);
|
|
// redirect('authority');
|
|
// } else {
|
|
// $this->session->set_flashdata('flash_gagal', 'Login');
|
|
// redirect('Action');
|
|
// }
|
|
}
|
|
public function logout_action()
|
|
{
|
|
$this->session->sess_destroy();
|
|
setcookie('username', "", time() - 3600);
|
|
setcookie('password', "", time() - 3600);
|
|
redirect('Action');
|
|
}
|
|
}
|