public function newAction() { $colIndex = $this->_getParam('colIndex'); $sessionFilters = $this->_calendarSession->filter; if (!isset($sessionFilters->columns[$colIndex])) { $msg = __('Cannot generate column with that index, there is no filter defined for that column Index: ') . $colIndex; throw new Exception($msg); } $column = $sessionFilters->columns[$colIndex]; $providerId = (int) $column['providerId']; $this->view->providerId = $providerId; $headerText = ''; if ($providerId > 0) { $provider = new Provider(); $provider->setPersonId($providerId); $provider->populate(); $headerText = $provider->displayName; } $roomId = 0; if (isset($column['roomId'])) { $roomId = $column['roomId']; } $this->view->roomId = $roomId; if ($roomId > 0) { $room = new Room(); $room->id = $roomId; $room->populate(); $headerText .= ' -> ' . $room->name; } if (isset($column['dateFilter'])) { $headerText .= " ({$column['dateFilter']})"; } $this->view->headerText = $headerText; $templates = array('' => ''); $templates['tpl1'] = 'Provider 1 Template'; $templates['tpl2'] = 'Provider 2 Template'; $templates['tpl3'] = 'Provider 3 Template'; $this->view->templates = $templates; // $this->_calendarSession->filter; calendar filter $this->render('new'); }
protected function _generateEventColumnData(array $filters) { // filters assume to be sanitized $appointment = new Appointment(); $appointment->providerId = $filters['providerId']; $appointment->roomId = $filters['roomId']; $appointment->start = $filters['dateFilter'] . ' ' . self::FILTER_TIME_START; $appointment->end = $filters['dateFilter'] . ' ' . self::FILTER_TIME_END; $startTime = strtotime($appointment->start); $endTime = strtotime($appointment->end); // we need to get the length of time to create number of rows in the grid $timeLen = ($endTime - $startTime) / 60 / self::FILTER_MINUTES_INTERVAL; // NOTE: height is 22px for xp, default 20px // prepopulate return data $columnData = array(); //$maps = array(); $start = $startTime; $end = $endTime; $ctr = 0; while ($start <= $end) { $map = array(); $map['start'] = $start; $start = strtotime('+' . self::FILTER_MINUTES_INTERVAL . ' minutes', $start); $map['end'] = $start; //$maps[$ctr] = $map; $row = array(); // assign row id as rowNumber and columnIndex $columnData[$ctr] = array('id' => $ctr + 1, 'data' => array(''), 'map' => $map); $ctr++; } $columnDataCtr = count($columnData); $data = array('apps' => array(), 'events' => array()); $mapIndex = 0; $apps = array(); foreach ($appointment->getIter() as $app) { $start = strtotime($app->start); for ($i = $mapIndex; $i < $columnDataCtr; $i++) { $map = $columnData[$mapIndex]['map']; $mapIndex = $i; if ($start >= $map['start'] && $start <= $map['end']) { if (!isset($data['apps'][$i])) { $data['apps'][$i] = array(); } $data['apps'][$i][] = $app; break; } } } $mapIndex = 0; $events = array(); trigger_error('looping schedule event started'); $scheduleEvent = new ScheduleEvent(); $db = Zend_Registry::get('dbAdapter'); $sqlSelect = $db->select()->from('scheduleEvents')->where('providerId = ?', $appointment->providerId)->where('roomId = ?', $appointment->roomId)->where('start >= ?', $appointment->start)->where('end <= ?', $appointment->end)->where('start <= end')->order('start ASC'); $stmt = $db->query($sqlSelect); $stmt->setFetchMode(Zend_Db::FETCH_ASSOC); while ($row = $stmt->fetch()) { $event = new ScheduleEvent(); $event->populateWithArray($row); $start = strtotime($event->start); for ($i = $mapIndex; $i < $columnDataCtr; $i++) { $map = $columnData[$i]['map']; $mapIndex = $i; if ($start >= $map['start'] && $start <= $map['end']) { if (!isset($data['events'][$i])) { $data['events'][$i] = array(); } $data['events'][$i] = $event; break; } } } trigger_error('looping schedule event ended'); $colMultiplier = 1; $zIndex = 0; foreach ($data['apps'] as $index => $apps) { $ctr = count($apps); $columnData[$index]['userdata']['ctr'] = $ctr; if ($ctr > $colMultiplier) { $colMultiplier = $ctr; } for ($i = 0; $i < $ctr; $i++) { $app = $apps[$i]; $this->_populateAppointmentRow($app, $columnData, $index, $i, $ctr); } } $header = "{$filters['dateFilter']}<br>"; $title = $filters['dateFilter']; // temporarily set the header as providerId $providerId = (int) $filters['providerId']; $roomId = (int) $filters['roomId']; if ($providerId > 0) { $provider = new Provider(); $provider->setPersonId($providerId); $provider->populate(); $name = $provider->optionName; // we simply replace the comma with its html equivalent (,) because this may cause not to render the header $header .= str_replace(',', ',', $name); $title .= ' -> ' . $name; } if ($roomId > 0) { $room = new Room(); $room->id = $roomId; $room->populate(); if ($providerId > 0) { $header .= '<br>'; } $header .= $room->name; $title .= ' -> ' . $room->name; } $buildings = array(); foreach ($data['events'] as $index => $event) { $this->_populateScheduleEventRow($event, $columnData, $index); $buildingId = (int) $event->buildingId; $building = new Building(); $building->buildingId = $buildingId; $building->populate(); $buildings[$buildingId] = $building->displayName; } $eventBuilding = implode(', ', $buildings); $header .= '<br>(' . $eventBuilding . ')'; $title .= ' -> (' . $eventBuilding . ')'; $header = '<label title="' . $title . '">' . $header . '</label>'; for ($i = 0; $i < $columnDataCtr; $i++) { unset($columnData[$i]['map']); } $columnData[0]['userdata']['colMultiplier'] = $colMultiplier; $columnData[0]['userdata']['providerId'] = $appointment->providerId; $columnData[0]['userdata']['roomId'] = $appointment->roomId; $columnData[0]['userdata']['date'] = $filters['dateFilter']; return array('header' => $header, 'events' => array('rows' => $columnData)); }
public function listHistoryAction() { $personId = (int) $this->_getParam('personId'); $future = (int) $this->_getParam('future'); $rows = array(); $appointmentTemplate = new AppointmentTemplate(); $reasons = $appointmentTemplate->getAppointmentReasons(); $iterator = new AppointmentIterator(null, false); $filters = array('patientId' => $personId); if ($future) { $filters['start'] = date('Y-m-d'); } $iterator->setFilters($filters); foreach ($iterator as $app) { $personId = (int) $app->patientId; $appointmentId = (int) $app->appointmentId; $providerId = (int) $app->providerId; $roomId = (int) $app->roomId; list($dateStart, $timeStart) = explode(' ', $app->start); list($dateEnd, $timeEnd) = explode(' ', $app->end); $providerName = ''; if ($providerId > 0) { $provider = new Provider(); $provider->setPersonId($providerId); $provider->populate(); $providerName = $provider->displayName; } $roomName = ''; if ($roomId > 0) { $room = new Room(); $room->setRoomId($roomId); $room->populate(); $roomName = $room->displayName; } $routing = new Routing(); $routing->personId = $personId; $routing->appointmentId = $appointmentId; $routing->providerId = $providerId; $routing->roomId = $roomId; $routing->populateByAppointments(); $station = $routing->stationId; $reason = $app->reason; $appointmentReason = isset($reasons[$reason]) ? $reasons[$reason]['name'] : ''; $row = array(); $row['id'] = $appointmentId; $row['data'] = array(); $row['data'][] = $dateStart; $row['data'][] = $timeStart . ' - ' . $timeEnd; $row['data'][] = $providerName; $row['data'][] = $app->title; $row['data'][] = $roomName; $row['data'][] = $appointmentReason; $row['data'][] = $app->appointmentCode; $row['data'][] = $routing->stationId; $rows[] = $row; } $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $json->direct(array('rows' => $rows)); }
protected function _generateColumnHeader(array $column) { $data = array(); $data['header'] = "{$column['dateFilter']}<br>"; $title = $column['dateFilter']; // temporarily set the header as providerId $providerId = $column['providerId']; $roomId = 0; if (isset($column['roomId'])) { $roomId = $column['roomId']; } if ($providerId > 0) { $provider = new Provider(); $provider->setPersonId($providerId); $provider->populate(); $name = $provider->last_name . ', ' . $provider->first_name; // we simply replace the comma with its html equivalent (,) because this may cause not to render the header $data['header'] .= str_replace(',', ',', $name); $title .= ' -> ' . $name; } if ($roomId > 0) { $room = new Room(); $room->id = $roomId; $room->populate(); if ($providerId > 0) { //$data['header'] .= '<br>'; $data['header'] .= ' - '; } $data['header'] .= $room->name; $title .= ' -> ' . $room->name; } $data['header'] = '<label title="' . $title . '">' . $data['header'] . '</label>'; return $data; }