public function showAgenda() { $model = new Slot(); $exist = Agenda::find()->where(['agendaID' => $this->agendaID])->one(); $permAgendaID = Agenda::find()->where(['owner' => $exist['owner'], 'type' => 'perm'])->one(); $tempSlotIDs = array(); if ($exist['type'] == 'temp') { $tempSlotIDs = $model->getIDs($this->agendaID); } $permSlotIDs = $model->getIDs($permAgendaID['agendaID']); $permindex = 0; $tempindex = 0; $agendforShow = array(); $index = 0; while ($permindex < sizeof($permSlotIDs) && $tempindex < sizeof($tempSlotIDs)) { if ($tempSlotIDs[$tempindex]['slotnum'] == $permSlotIDs[$permindex]['slotnum']) { $agendforShow[$index]['slotID'] = $tempSlotIDs[$tempindex]['slotID']; $agendforShow[$index]['maxBookers'] = $tempSlotIDs[$tempindex]['numberOfBookers']; $agendforShow[$index]['content'] = $tempSlotIDs[$tempindex]['content']; $count = Book::find()->where(['slotID' => $agendforShow[$index]['slotID'], 'date' => $exist['lastUpdate']])->count(); $agendforShow[$index]['bookCount'] = $count; $tempindex++; $index++; } else { $agendforShow[$index]['slotID'] = $permSlotIDs[$permindex]['slotID']; $agendforShow[$index]['maxBookers'] = $permSlotIDs[$permindex]['numberOfBookers']; $agendforShow[$index]['content'] = $permSlotIDs[$permindex]['content']; $count = Book::find()->where(['slotID' => $agendforShow[$index]['slotID'], 'date' => $exist['lastUpdate']])->count(); $agendforShow[$index]['bookCount'] = $count; $index++; } $permindex++; } while ($tempindex < sizeof($tempSlotIDs)) { $agendforShow[$index]['slotID'] = $tempSlotIDs[$tempindex]['slotID']; $agendforShow[$index]['maxBookers'] = $tempSlotIDs[$tempindex]['numberOfBookers']; $agendforShow[$index]['content'] = $tempSlotIDs[$tempindex]['content']; $count = Book::find()->where(['slotID' => $agendforShow[$index]['slotID'], 'date' => $exist['lastUpdate']])->count(); $agendforShow[$index]['bookCount'] = $count; $tempindex++; $index++; } while ($permindex < sizeof($permSlotIDs)) { $agendforShow[$index]['slotID'] = $permSlotIDs[$permindex]['slotID']; $agendforShow[$index]['maxBookers'] = $permSlotIDs[$permindex]['numberOfBookers']; $agendforShow[$index]['content'] = $permSlotIDs[$permindex]['content']; $count = Book::find()->where(['slotID' => $agendforShow[$index]['slotID'], 'date' => $exist['lastUpdate']])->count(); $agendforShow[$index]['bookCount'] = $count; $permindex++; $index++; } return $agendforShow; }