new feature for suhu kuda
This commit is contained in:
parent
1755105af1
commit
d5fd300b6a
@ -18,8 +18,11 @@ class Department extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
//$rows = $this->model->findAll();
|
$filter = [
|
||||||
$rows = $this->model->getDepartments();
|
'DepartmentCode' => $this->request->getVar('DepartmentCode'),
|
||||||
|
'DepartmentName' => $this->request->getVar('DepartmentName'),
|
||||||
|
];
|
||||||
|
$rows = $this->model->getDepartments($filter);
|
||||||
|
|
||||||
if (empty($rows)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||||
|
|||||||
@ -18,7 +18,11 @@ class Workstation extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
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)) {
|
if (empty($rows)) {
|
||||||
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
return $this->respond([ 'status' => 'success', 'message' => "no Data.", 'data' => [] ], 200);
|
||||||
|
|||||||
@ -35,7 +35,7 @@ class Organization extends Migration {
|
|||||||
'WorkstationName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
'WorkstationName' => ['type' => 'varchar', 'constraint'=> 150, 'null'=> true],
|
||||||
'Type' => ['type' => 'tinyint', 'null'=> true],
|
'Type' => ['type' => 'tinyint', 'null'=> true],
|
||||||
'LinkTo' => ['type' => 'int', 'null'=> true],
|
'LinkTo' => ['type' => 'int', 'null'=> true],
|
||||||
'Enable' => ['type' => 'bit', 'null'=> true],
|
'Enable' => ['type' => 'int', 'null'=> true],
|
||||||
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
'CreateDate' => ['type'=>'DATETIME', 'null' => true],
|
||||||
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
'EndDate' => ['type'=>'DATETIME', 'null' => true]
|
||||||
]);
|
]);
|
||||||
|
|||||||
@ -13,11 +13,19 @@ class DepartmentModel extends BaseModel {
|
|||||||
protected $useSoftDeletes = true;
|
protected $useSoftDeletes = true;
|
||||||
protected $deletedField = 'EndDate';
|
protected $deletedField = 'EndDate';
|
||||||
|
|
||||||
public function getDepartments() {
|
public function getDepartments($filter = []) {
|
||||||
$rows = $this->select('department.*, discipline.DisciplineCode, discipline.DisciplineName, site.SiteCode, site.SiteName')
|
$this->select('department.*, discipline.DisciplineCode, discipline.DisciplineName, site.SiteCode, site.SiteName')
|
||||||
->join('discipline', 'discipline.DisciplineID=department.DisciplineID', 'left')
|
->join('discipline', 'discipline.DisciplineID=department.DisciplineID', 'left')
|
||||||
->join('site', 'department.SiteID=site.SiteID', 'left')
|
->join('site', 'department.SiteID=site.SiteID', 'left');
|
||||||
->findAll();
|
|
||||||
|
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;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,23 +14,27 @@ class WorkstationModel extends BaseModel {
|
|||||||
protected $useSoftDeletes = true;
|
protected $useSoftDeletes = true;
|
||||||
protected $deletedField = 'EndDate';
|
protected $deletedField = 'EndDate';
|
||||||
|
|
||||||
public function getWorkstations() {
|
public function getWorkstations($filter = []) {
|
||||||
$rows = $this->select('workstation.*, department.DepartmentName, wst1.WorkstationName as LinkToName')
|
$this->select('workstation.*, department.DepartmentName, wst1.WorkstationName as LinkToName')
|
||||||
->join('workstation wst1', 'workstation.LinkTo=wst1.WorkstationID', 'left')
|
->join('workstation wst1', 'workstation.LinkTo=wst1.WorkstationID', 'left')
|
||||||
->join('department', 'department.DepartmentID=workstation.DepartmentID', 'left')
|
->join('department', 'department.DepartmentID=workstation.DepartmentID', 'left');
|
||||||
->findAll();
|
|
||||||
|
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;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWorkstation($WorkstationID) {
|
public function getWorkstation($WorkstationID) {
|
||||||
$rows = $this->select("workstation.*, department.DepartmentName, wst1.WorkstationName as LinkToName,
|
$rows = $this->select("workstation.*, department.DepartmentName, wst1.WorkstationName as LinkToName,enable.VDesc as EnableName, wstype.VDesc as TypeName")
|
||||||
CASE
|
|
||||||
WHEN workstation.Enable = 1 THEN 'Enabled'
|
|
||||||
ELSE 'Disabled'
|
|
||||||
END AS EnableText, valueset.VValue as TypeName")
|
|
||||||
->join('workstation wst1', 'workstation.LinkTo=wst1.WorkstationID', 'left')
|
->join('workstation wst1', 'workstation.LinkTo=wst1.WorkstationID', 'left')
|
||||||
->join('department', 'department.DepartmentID=workstation.DepartmentID', '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)
|
->where('workstation.WorkstationID', $WorkstationID)
|
||||||
->findAll();
|
->findAll();
|
||||||
return $rows;
|
return $rows;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user