update gán lịch trình cho nhân viên
This commit is contained in:
@@ -112,4 +112,27 @@ class Department extends \yii\db\ActiveRecord {
|
||||
return ["status" => true, "description" => ""];
|
||||
}
|
||||
|
||||
public function getChilds() {
|
||||
return $this->find()->andWhere(['pid' => $this->code])->all();
|
||||
}
|
||||
|
||||
public function getCountStaff() {
|
||||
$childs = $this->childs;
|
||||
$totals = 0;
|
||||
foreach ($childs as $key => $value) {
|
||||
$totals += $value->countStaff;
|
||||
}
|
||||
$totals += Staff::find()->andWhere(['department_id' => $this->code])->count();
|
||||
return $totals;
|
||||
}
|
||||
|
||||
public function departmentChilds($id, &$childs = []) {
|
||||
$childs[] = $id;
|
||||
$ls = $this->find()->andWhere(['pid' => $id])->all();
|
||||
foreach ($ls as $key => $value) {
|
||||
$this->departmentChilds($value->code, $childs);
|
||||
}
|
||||
return $childs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -117,4 +117,13 @@ class Device extends \yii\db\ActiveRecord {
|
||||
return $results;
|
||||
}
|
||||
|
||||
public static function deviceArray() {
|
||||
$lists = self::find()->all();
|
||||
$results = [];
|
||||
foreach ($lists as $key => $value) {
|
||||
$results[$value->id] = $value->name;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -150,4 +150,13 @@ class Schedule extends \yii\db\ActiveRecord {
|
||||
return hexdec("0" . $front . "0" . $back);
|
||||
}
|
||||
|
||||
public static function scheduleArray() {
|
||||
$lists = self::find()->all();
|
||||
$results = [];
|
||||
foreach ($lists as $key => $value) {
|
||||
$results[$value->id] = $value->name;
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ use Yii;
|
||||
* @property int $modified_at
|
||||
* @property int $card_register_time
|
||||
* @property int $schedule_id
|
||||
* @property string $door_access
|
||||
*/
|
||||
class Staff extends \yii\db\ActiveRecord {
|
||||
|
||||
@@ -39,7 +40,7 @@ class Staff extends \yii\db\ActiveRecord {
|
||||
return [
|
||||
[['code', 'name', 'gender'], 'required'],
|
||||
[['code', 'card_number', 'department_id', 'birthday', 'date_in', 'created_at', 'modified_at', 'card_register_time', 'schedule_id'], 'integer'],
|
||||
[['address'], 'string'],
|
||||
[['address', 'door_access'], 'string'],
|
||||
[['name', 'email'], 'string', 'max' => 100],
|
||||
[['gender'], 'string', 'max' => 10],
|
||||
[['phone'], 'string', 'max' => 20],
|
||||
@@ -121,4 +122,15 @@ class Staff extends \yii\db\ActiveRecord {
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function getDoors() {
|
||||
$doors = [];
|
||||
if ($this->door_access) {
|
||||
$ls = json_decode($this->door_access, true);
|
||||
foreach ($ls as $key => $value) {
|
||||
$doors[] = Door::findOne($value)->name;
|
||||
}
|
||||
}
|
||||
return implode(", ", $doors);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user