diff --git a/Models/Department.php b/Models/Department.php index f099582..86d06d6 100755 --- a/Models/Department.php +++ b/Models/Department.php @@ -145,8 +145,8 @@ class Department implements \JsonSerializable, ArrayableInterface 'status' => $this->status, 'description' => $this->description, 'descriptionRaw' => $this->descriptionRaw, - 'unit' => $this->unit ?? new NullUnit(), - 'parent' => $this->parent ?? new NullDepartment(), + 'unit' => $this->unit, + 'parent' => $this->parent ?? null, ]; } diff --git a/Models/Position.php b/Models/Position.php index 11aa19d..60d9061 100755 --- a/Models/Position.php +++ b/Models/Position.php @@ -143,7 +143,7 @@ class Position implements \JsonSerializable, ArrayableInterface 'description' => $this->description, 'descriptionRaw' => $this->descriptionRaw, 'department' => $this->department ?? new NullDepartment(), - 'parent' => $this->parent ?? new NullPosition(), + 'parent' => $this->parent ?? null, ]; } diff --git a/Models/Unit.php b/Models/Unit.php index d6fab4b..26dc583 100755 --- a/Models/Unit.php +++ b/Models/Unit.php @@ -144,7 +144,7 @@ class Unit implements \JsonSerializable, ArrayableInterface 'status' => $this->status, 'description' => $this->description, 'descriptionRaw' => $this->descriptionRaw, - 'parent' => $this->parent, + 'parent' => $this->parent ?? null, 'image' => $this->image, ]; } diff --git a/Theme/Backend/organigram.tpl.php b/Theme/Backend/organigram.tpl.php index e6c7e82..d197b0b 100755 --- a/Theme/Backend/organigram.tpl.php +++ b/Theme/Backend/organigram.tpl.php @@ -87,8 +87,8 @@ $unitRoot = $unitTree[null][0]['children']; do { ++$toCloseDep; - $parentDep = $parentDep->parent; - $parentDepId = $parentDep->getId(); + $parentDep = $parentDep->parent ?? null; + $parentDepId = $parentDep?->getId() ?? 0; } while ($parentDepId !== 0 && !isset($depTree[$unitId][$parentDepId]['children'][($depTree[$unitId][$parentDepId]['index'] ?? 0) + 1]) );