my_parent_controller(); Response::handleSessionTimeout("bo"); //load nshow_model $this->load->model('nshow_model'); } /** * Validate and get merged list of Booking,Waiting and Extra people * else if no event schedule ID present show 404 page * * @param integer $eventId * @param integer $eventScheduleID * @return void * access private member */ private function getAttendanceData(int $eventId, int $eventScheduleId) { //Display 404 page if eventschedule ID is not present if (!is_numeric($eventId) || is_null($eventId) && !is_numeric($eventScheduleId) || is_null($eventScheduleId)) { show_404(); } //return combined records return $this->getAttendanceQuery($eventId, $eventScheduleId); } /** * Get data booking, waiting and Extra peoples * * @param integer $eventId * @param integer $eventScheduleID * @return array * access private member */ private function getAttendanceQuery($eventId, $eventScheduleId) : array { //Booking $confirmed = $this->nshow_model->bookList($eventScheduleId); //Waiting $waitlist = $this->nshow_model->waitList($eventScheduleId); //Extra $extra = $this->nshow_model->extraPeople($eventScheduleId); //Combine lists return array_merge($confirmed, $waitlist, $extra); } /** * Check if Waiting, Booking or Extra people * * @param string $type = booking,waiting,extra * @param string $match = match if booking,waiting,extra * @return boolean * access private member */ private function TypeIs(string $type, string $match) : bool { return $type == trim(strtolower($match)); } /** * Compute partial no show * * @param integer $totalPresent * @param integer $totalPlace * @param string $indicator * @return array * access private member */ private function computePartialNoshow(int $totalPresent,int $totalPlace, string $indicator) : array { //holds total partial no show $noShowPartial = []; if ($totalPresent > 0) { if($totalPresent < $totalPlace){ array_push($noShowPartial,$indicator); } } //return noshow computed partial return $noShowPartial; } /** * Display list of statistics by EventId and Event schedule ID * * @param integer $eventId * @param integer $eventScheduleId * @return array * access public member */ public function loadStatistics(int $eventId, int $eventScheduleId) : array { //Iterate data booking list, waiting list and extra peoples foreach ($this->getAttendanceData($eventId, $eventScheduleId) as $key => $datasets) { //Set no of place as totalPlace $this->totalPlace = (int)$datasets->no_of_place; //Set no show type as totalPresent $this->totalPresent = (int)$datasets->no_show_type; //Booking range cells if ($this->TypeIs('booking', $datasets->type)) { $this->AttendusF2[] = $this->totalPlace; $this->AttendusF4 += $this->totalPlace; } //Waiting range cells if ($this->TypeIs('waiting', $datasets->type)) { $this->WaitingListG2[] = $this->totalPlace; $this->WaitingListG4 += $this->totalPlace; } //Count total place $this->countTotalPlace[] = $this->totalPresent ?? 0; //Compute invitees $this->countInvitees[] = ($this->totalPresent - 1) == -1 ? '' : ($this->totalPresent - 1) ; //computes partial no show $this->noShowPartial[] = $this->computePartialNoshow($this->totalPresent,$this->totalPlace,1); //computes total no show $this->noshow[] = $this->totalPresent == 0 ? 1 : ''; } //Display computed ranges output_to_json($this,[ '$TotalAvailablePlace' => $this->nshow_model->getTotalAvailableAndRemainingPlaces($eventId, $eventScheduleId)['total_available_seat'], '$TotalRemainingPlace' => ($this->nshow_model->getTotalAvailableAndRemainingPlaces($eventId, $eventScheduleId)['total_available_seat'] - (count(array_filter($this->countTotalPlace)) + array_sum($this->countInvitees))), '$AttendusF2' => count($this->AttendusF2), '$AttendusF3' => ($this->AttendusF4 - count($this->AttendusF2)), '$AttendusF4' => $this->AttendusF4, '$WaitingListG2' => count($this->WaitingListG2), '$WaitingListG3' => ($this->WaitingListG4 - count($this->WaitingListG2)), '$WaitingListG4' => $this->WaitingListG4, '$PresentsH2' => count(array_filter($this->countTotalPlace)), '$PresentsH3' => array_sum($this->countInvitees), '$PresentsH4' => (count(array_filter($this->countTotalPlace)) + array_sum($this->countInvitees)), '$AbsentsI2' => (count($this->AttendusF2) - count(array_filter($this->countTotalPlace))), '$AbsentsI3' => (($this->AttendusF4 - count($this->AttendusF2)) - array_sum($this->countInvitees)), '$AbsentsI4' => ((count($this->AttendusF2) - count(array_filter($this->countTotalPlace))) + (($this->AttendusF4 - count($this->AttendusF2)) - array_sum($this->countInvitees))), '$NoshowPartial' => count(array_filter($this->noShowPartial)), '$Noshow' => count(array_filter($this->noshow)) ]); } }