public function renderPeople() { $ISmembers = $this->skautIS->org->PersonAllExport(array("ID_Unit" => 25634)); $this->template->person = []; $this->template->validMembers = []; $this->template->validISmembers = []; $this->template->invalidISmembers = []; $reg_numbers = []; foreach ($ISmembers as $ISmember) { $reg = $ISmember->RegistrationNumber; $member = $this->registrations->getBy(['registration_number' => $reg]); if ($member) { $this->template->person[] = $ISmember; $this->template->validMembers[] = $member; $this->template->validISmembers[] = $ISmember; $reg_numbers[] = $reg; } else { $this->template->invalidISmembers[] = $ISmember; } } if (count($this->template->validISmembers) === count($this->template->validMembers)) { $this->template->validSize = count($this->template->validISmembers); } else { $this->error('Došlo k chybě při komunikaci s IS skautem.', \Nette\Http\IResponse::S500_INTERNAL_SERVER_ERROR); } $this->template->invalidMembers = $this->registrations->findAll()->where('registration_number NOT ? OR registration_number IS NULL', $reg_numbers); }