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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user