update gán lịch trình cho nhân viên

This commit is contained in:
2020-10-14 14:00:01 +07:00
parent 620dfc75c2
commit ed061f5994
16 changed files with 2626 additions and 100 deletions

View File

@@ -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;
}
}