protected function generateEventColumnData($columnIndex) { $columnIndex = (int) $columnIndex; $columnData = array(); $scheduleEventIterator = new ScheduleEventIterator(); $appointmentIterator = new AppointmentIterator(); if (!isset($this->getCurrentDisplayFilter()->columns[$columnIndex])) { throw new Exception(__("Cannot generate column with that index, there is no filter defined for that column Index: ") . $columnIndex); } $this->_session->currentAppointments[$columnIndex] = array(); $filter = $this->getCurrentDisplayFilter(); $filterTimeStart = strtotime($filter->start); $filterTimeEnd = strtotime($filter->end); $paramFilters = $filter->columns[$columnIndex]; if (isset($paramFilters['dateFilter'])) { $filter->date = date('Y-m-d', strtotime($paramFilters['dateFilter'])); } $paramFilters['start'] = $filter->date . ' ' . $filter->start; $paramFilters['end'] = $filter->date . ' ' . $filter->end; $paramFilters['start'] = $filter->date . ' ' . $filter->start; $paramFilters['end'] = $filter->date . ' 23:59:59'; $scheduleEventIterator->setFilter($paramFilters); // we need to get the length of time to create number of rows in the grid $timeLen = ($filterTimeEnd - $filterTimeStart) / 60 / $filter->increment; for ($i = 0; $i <= $timeLen; $i++) { $row = array(); // assign row id as rowNumber and columnIndex $row['id'] = $i . $columnIndex; $row['data'][0] = ''; $columnData[$i] = $row; } $filterToTimeStart = strtotime($paramFilters['start']); $appointmentIterator->setFilter($paramFilters); // hold the temporary data counter $tmpDataCtr = array(); $colMultiplier = 1; $patient = new Patient(); $room = new Room(); $zIndex = 0; foreach ($appointmentIterator as $row) { $startToTime = strtotime($row->start); $endToTime = strtotime($row->end); $tmpStart = date('H:i', $startToTime); $tmpEnd = date('H:i', $endToTime); $timeLen = ($endToTime - $startToTime) / 60 / $filter->increment; $tmpIndex = ($startToTime - $filterToTimeStart) / 60 / $filter->increment; if (!isset($columnData[$tmpIndex])) { break; } $index = $tmpIndex; for ($j = 1; $j <= $timeLen; $j++) { if (!isset($columnData[$index])) { break; } $index++; } $j--; $height = 20 * $j * 1.1; $marginLeft = 8; $multiplier = 1; // generate ranges code inside if ($multiplier === 1) block $incTime = $startToTime; $ranges = array(); for ($ctr = 1; $ctr <= $timeLen; $ctr++) { $ranges[] = date('H:i', $incTime); $incTime = strtotime("+{$filter->increment} minutes", $incTime); } // check for appointment intersection foreach ($tmpDataCtr as $keyCtr => $dataCtr) { if (in_array($tmpStart, $dataCtr['ranges'])) { // merge the ranges if we need to have a nested multiple bookings // uncomment if this is not the case and move the generate ranges to its proper location for code optimization $tmpDataCtr[$keyCtr]['ranges'] = array_merge($dataCtr['ranges'], $ranges); $tmpDataCtr[$keyCtr]['multiplier']++; $multiplier = $tmpDataCtr[$keyCtr]['multiplier']; break; } } if ($multiplier === 1) { $tmpDataCtr[] = array('ranges' => $ranges, 'multiplier' => $multiplier); } else { $marginLeft = ($multiplier - 1) * 250; } if ($multiplier > $colMultiplier) { $colMultiplier = $multiplier; } $patient->setPersonId($row->patientId); $patient->populate(); $person = $patient->person; $room->setRoomId($row->roomId); $room->populate(); $this->_session->currentAppointments[$columnIndex][$row->appointmentId] = $row; $mark = ''; if (strlen($row->appointmentCode) > 0) { $mark = "({$row->appointmentCode})"; } $zIndex++; // where to use room? $columnData[$tmpIndex]['id'] = $row->appointmentId . 'i' . $columnData[$tmpIndex]['id']; $appointmentId = $row->appointmentId; $columnData[$tmpIndex]['data'][0] .= "<div style=\"float:left;position:absolute;margin-top:-11.9px;height:{$height}px;width:230px;overflow:hidden;border:thin solid black;margin-left:{$marginLeft}px;padding-left:2px;background-color:lightgrey;z-index:{$zIndex};\" class=\"dataForeground\" id=\"event{$appointmentId}\" onmouseover=\"expandAppointment({$appointmentId},this);\" onmouseout=\"shrinkAppointment({$appointmentId},this,{$height},{$zIndex});\">{$tmpStart}-{$tmpEnd} <a href=\"\">{$person->last_name}, {$person->first_name} (#{$row->patientId})</a> <div class=\"bottomInner\" id=\"bottomInnerId{$appointmentId}\">{$row->title} {$mark}</div></div>"; $columnData[$tmpIndex]['userdata']['appointmentId'] = $row->appointmentId; } $columnData[0]['userdata']['colMultiplier'] = $colMultiplier; $columnData[0]['userdata']['providerId'] = $paramFilters['providerId']; $roomId = 0; if (isset($paramFilters['roomId'])) { $roomId = $paramFilters['roomId']; } $columnData[0]['userdata']['roomId'] = $roomId; foreach ($scheduleEventIterator as $event) { $x = explode(' ', $event->start); $eventTimeStart = strtotime($x[1]); $x = explode(' ', $event->end); $eventTimeEnd = strtotime($x[1]); // get the starting index $index = ($eventTimeStart - $filterTimeStart) / 60 / $filter->increment; $tmpIndex = $index; $color = $event->provider->color; if ($event->roomId > 0 && strlen($event->room->color) > 0) { $color = $event->room->color; } if (substr($color, 0, 1) != '#') { $color = '#' . $color; } while ($eventTimeStart < $eventTimeEnd) { $eventDateTimeStart = date('Y-m-d H:i:s', $eventTimeStart); $eventTimeStart = strtotime("+{$filter->increment} minutes", $eventTimeStart); $columnData[$tmpIndex]['style'] = 'background-color:' . $color . ';border-color:lightgrey;'; $columnData[$index]['userdata']['title'] = $event->title; $tmpIndex++; } } $ret = array(); $ret['rows'] = $columnData; return $ret; }
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)); }
$description = $database->escapeString($_POST['description']); $hotelId = $database->escapeString($_POST['hotelId']); $room->setRoomName($name); $room->setPrice($price); $room->setPersons($persons); $room->setIsAvailable($isAvailable); if ($isAvailable == 1) { $room->setAvailableUntil($availableUntil); } else { $room->setAvailableUntil("NOT AVAILABLE"); } $room->setDescription($description); $room->setHotelId($hotelId); if (isset($_POST['roomId'])) { $roomId = $database->escapeString($_POST['hotelId']); $room->setRoomId($roomId); $hotel->update($database); } else { $roomId = $room->create($database); } if (count($_FILES) != 0) { $error = 0; $files = array(); $uploaddir = "../images/rooms/large/"; $uploaddirthumb = "../images/rooms/thumb/"; $nameArray = $_FILES['mediaUploads']['name']; $typeArray = $_FILES['mediaUploads']['type']; $tmpNameArray = $_FILES['mediaUploads']['tmp_name']; $errorArray = $_FILES['mediaUploads']['error']; $sizeArray = $_FILES['mediaUploads']['size']; for ($count = 0; $count < count($_FILES['mediaUploads']['name']); $count++) {