38 lines
1.4 KiB
PHP
38 lines
1.4 KiB
PHP
<?php
|
|
namespace App\Models\Organization;
|
|
use App\Models\BaseModel;
|
|
|
|
class WorkstationModel extends BaseModel {
|
|
protected $table = 'workstation';
|
|
protected $primaryKey = 'WorkstationID';
|
|
protected $allowedFields = ['DepartmentID', 'WorkstationCode', 'WorkstationName', 'Type', 'LinkTo', 'Enable',
|
|
'EquipmentID', 'CreateDate', 'EndDate'];
|
|
|
|
protected $useTimestamps = true;
|
|
protected $createdField = 'CreateDate';
|
|
protected $updatedField = '';
|
|
protected $useSoftDeletes = true;
|
|
protected $deletedField = 'EndDate';
|
|
|
|
public function getWorkstations() {
|
|
$rows = $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();
|
|
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")
|
|
->join('workstation wst1', 'workstation.LinkTo=wst1.WorkstationID', 'left')
|
|
->join('department', 'department.DepartmentID=workstation.DepartmentID', 'left')
|
|
->where('workstation.WorkstationID', $WorkstationID)
|
|
->findAll();
|
|
return $rows;
|
|
}
|
|
}
|