Update besar apk finance

This commit is contained in:
Wian Drs
2026-09-11 16:03:00 +07:00
parent d42483b350
commit 4ef15c22ae
897 changed files with 98056 additions and 15979 deletions
+38 -21
View File
@@ -1,7 +1,7 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Users extends CI_Controller {
class Users extends MY_Admin_Controller {
public function __construct()
{
@@ -35,15 +35,17 @@ class Users extends CI_Controller {
{
$this->db->select('
users.id,
users.username,
users.nama,
roles.nama_role
users.username,
users.nama,
roles.nama_role,
employees.full_name AS employee_name
');
$this->db->from('users');
$this->db->join('roles', 'roles.id = users.role_id', 'left');
$this->db->from('users');
$this->db->join('roles', 'roles.id = users.role_id', 'left');
$this->db->join('k_employees employees','employees.id=users.employee_id','left');
$column_order = ['users.id', 'users.username', 'users.nama', 'roles.nama_role'];
$column_search = ['users.username', 'users.nama', 'roles.nama_role'];
$column_order = ['users.id', 'users.username', 'users.nama', 'roles.nama_role','employees.full_name'];
$column_search = ['users.username', 'users.nama', 'roles.nama_role','employees.full_name'];
$order = ['users.id' => 'DESC'];
$search_value = $this->input->post('search')['value'] ?? '';
@@ -99,8 +101,9 @@ class Users extends CI_Controller {
$row->id,
$row->username,
$row->nama,
$row->nama_role,
$action
$row->nama_role,
$row->employee_name ?: '-',
$action
];
}
@@ -109,14 +112,16 @@ class Users extends CI_Controller {
private function _count_filtered($search_value)
{
$this->db->from('users');
$this->db->join('roles', 'roles.id = users.role_id', 'left');
$this->db->from('users');
$this->db->join('roles', 'roles.id = users.role_id', 'left');
$this->db->join('k_employees employees','employees.id=users.employee_id','left');
if (!empty($search_value)) {
$this->db->group_start();
$this->db->like('users.username', $search_value);
$this->db->or_like('users.nama', $search_value);
$this->db->or_like('roles.nama_role', $search_value);
$this->db->or_like('roles.nama_role', $search_value);
$this->db->or_like('employees.full_name', $search_value);
$this->db->group_end();
}
@@ -141,11 +146,12 @@ class Users extends CI_Controller {
return;
}
$data = [
$data = [
'username' => $this->input->post('username'),
'nama' => $this->input->post('nama'),
'role_id' => $this->input->post('role_id'),
'password' => password_hash($this->input->post('password'), PASSWORD_DEFAULT)
'password' => password_hash($this->input->post('password'), PASSWORD_DEFAULT),
'employee_id' => $this->validatedEmployeeId($this->input->post('employee_id'))
];
$this->dm->setTable('users')->insert($data);
@@ -206,10 +212,11 @@ class Users extends CI_Controller {
return;
}
$data = [
$data = [
'username' => $this->input->post('username'),
'nama' => $this->input->post('nama'),
'role_id' => $this->input->post('role_id')
'role_id' => $this->input->post('role_id'),
'employee_id' => $this->validatedEmployeeId($this->input->post('employee_id'))
];
if (!empty($this->input->post('password'))) {
@@ -254,10 +261,20 @@ class Users extends CI_Controller {
// =========================
// GET ROLES
// =========================
public function get_role()
public function get_role()
{
$roles = $this->db->get('roles')->result();
$roles = $this->db->where('is_active',1)->order_by('nama_role','ASC')->get('roles')->result();
echo json_encode($roles);
}
}
}
public function get_employee()
{
return json_response(true,'Daftar karyawan.',array('data'=>$this->db->select('id,employee_code,full_name')->where(array('company_id'=>(int)$this->companycontext->id(),'is_active'=>1))->order_by('full_name')->get('k_employees')->result()));
}
private function validatedEmployeeId($value)
{
$id=(int)$value;if($id<1)return null;$row=$this->db->select('id')->where(array('id'=>$id,'company_id'=>(int)$this->companycontext->id(),'is_active'=>1))->get('k_employees')->row();return$row?$id:null;
}
}