new feature for suhu kuda

This commit is contained in:
mahdahar 2025-12-02 09:29:42 +07:00
parent 1755105af1
commit d5fd300b6a
5 changed files with 37 additions and 18 deletions

View File

@ -18,8 +18,11 @@ class Department extends BaseController {
}
public function index() {
//$rows = $this->model->findAll();
$rows = $this->model->getDepartments();
$filter = [
'DepartmentCode' => $this->request->getVar('DepartmentCode'),
'DepartmentName' => $this->request->getVar('DepartmentName'),
];
$rows = $this->model->getDepartments($filter);
if (empty($rows)) {
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);

View File

@ -18,7 +18,11 @@ class Workstation extends BaseController {
}
public function index() {
$rows = $this->model->getWorkstations();
$filter = [
'WorkstationCode' => $this->request->getVar('WorkstationCode'),
'WorkstationName' => $this->request->getVar('WorkstationName'),
];
$rows = $this->model->getWorkstations($filter);
if (empty($rows)) {
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);

View File

@ -35,7 +35,7 @@ class Organization extends Migration {
'WorkstationName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
'Type' => ['type' => 'tinyint', 'null'=> true],
'LinkTo' => ['type' => 'int', 'null'=> true],
'Enable' => ['type' => 'bit', 'null'=> true],
'Enable' => ['type' => 'int', 'null'=> true],
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
'EndDate' => ['type'=>'DATETIME', 'null' => true]
]);

View File

@ -13,11 +13,19 @@ class DepartmentModel extends BaseModel {
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
public function getDepartments() {
$rows = $this->select('department.*, discipline.DisciplineCode, discipline.DisciplineName, site.SiteCode, site.SiteName')
public function getDepartments($filter = []) {
$this->select('department.*, discipline.DisciplineCode, discipline.DisciplineName, site.SiteCode, site.SiteName')
->join('discipline', 'discipline.DisciplineID=department.DisciplineID', 'left')
->join('site', 'department.SiteID=site.SiteID', 'left')
->findAll();
->join('site', 'department.SiteID=site.SiteID', 'left');
if (!empty($filter['DepartmentCode'])) {
$this->like('department.DepartmentCode', $filter['DepartmentCode'], 'both');
}
if (!empty($filter['DepartmentName'])) {
$this->like('department.DepartmentName', $filter['DepartmentName'], 'both');
}
$rows = $this->findAll();
return $rows;
}

View File

@ -14,23 +14,27 @@ class WorkstationModel extends BaseModel {
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
public function getWorkstations() {
$rows = $this->select('workstation.*, department.DepartmentName, wst1.WorkstationName as LinkToName')
public function getWorkstations($filter = []) {
$this->select('workstation.*, department.DepartmentName, wst1.WorkstationName as LinkToName')
->join('workstation wst1', 'workstation.LinkTo=wst1.WorkstationID', 'left')
->join('department', 'department.DepartmentID=workstation.DepartmentID', 'left')
->findAll();
->join('department', 'department.DepartmentID=workstation.DepartmentID', 'left');
if (!empty($filter['WorkstationCode'])) {
$this->like('workstation.WorkstationCode', $filter['WorkstationCode'], 'both');
}
if (!empty($filter['WorkstationName'])) {
$this->like('workstation.WorkstationName', $filter['WorkstationName'], 'both');
}
$rows = $this->findAll();
return $rows;
}
public function getWorkstation($WorkstationID) {
$rows = $this->select("workstation.*, department.DepartmentName, wst1.WorkstationName as LinkToName,
CASE
WHEN workstation.Enable = 1 THEN 'Enabled'
ELSE 'Disabled'
END AS EnableText, valueset.VValue as TypeName")
$rows = $this->select("workstation.*, department.DepartmentName, wst1.WorkstationName as LinkToName,enable.VDesc as EnableName, wstype.VDesc as TypeName")
->join('workstation wst1', 'workstation.LinkTo=wst1.WorkstationID', 'left')
->join('department', 'department.DepartmentID=workstation.DepartmentID', 'left')
->join('valueset', 'valueset.VID=workstation.Type', 'left')
->join('valueset wstype', 'wstype.VID=workstation.Type', 'left')
->join('valueset enable', 'enable.VID=workstation.Enable', 'left')
->where('workstation.WorkstationID', $WorkstationID)
->findAll();
return $rows;