public function ajaxEditGlobalAwardAction() { $globalAward = $this->getDoctrine()->getRepository('HelperBundle:GlobalAward')->find($this->request->get('globalAwardId', 0)); if (!$globalAward) { throw $this->createNotFoundException('Invalid global award'); } $propertyType = $this->get('services.institution_property')->getAvailablePropertyType(InstitutionPropertyType::TYPE_GLOBAL_AWARD); $imcProperty = $this->imcService->getPropertyValue($this->institutionMedicalCenter, $propertyType, $globalAward->getId(), $this->request->get('propertyId', 0)); $imcProperty->setValueObject($globalAward); $editGlobalAwardForm = $this->createForm(new InstitutionGlobalAwardFormType(), $imcProperty); if ($this->request->isMethod('POST')) { $editGlobalAwardForm->bind($this->request); if ($editGlobalAwardForm->isValid()) { $imcProperty = $editGlobalAwardForm->getData(); $em = $this->getDoctrine()->getEntityManager(); $em->persist($imcProperty); $em->flush(); // Invalidate InstitutionMedicalCenterProfile memcache $this->get('services.memcache')->delete(FrontendMemcacheKeysHelper::generateInsitutionMedicalCenterProfileKey($this->institutionMedicalCenter->getId())); $output = array('status' => true, 'extraValue' => $imcProperty->getExtraValue()); $response = new Response(\json_encode($output), 200, array('content-type' => 'application/json')); } else { $response = new Response('Form error', 400); } } return $response; }
public static function toArray(InstitutionInquiry $institutionInquiry) { $data = array('id' => $institutionInquiry->getId(), 'inquirerEmail' => $institutionInquiry->getInquirerEmail(), 'inquirerName' => $institutionInquiry->getInquirerName(), 'dateCreated' => $institutionInquiry->getDateCreated(), 'country' => $institutionInquiry->getCountry(), 'institution' => InstitutionService::institutionToArray($institutionInquiry->getInstitution())); if ($imc = $institutionInquiry->getInstitutionMedicalCenter()) { $data['institutionMedicalCenter'] = InstitutionMedicalCenterService::institutionMedicalCenterToArray($imc); } return $data; }
public function completeProfileOfInstitutionWithSingleCenter(Institution $institution, InstitutionMedicalCenter $institutionMedicalCenter) { // save the institution $this->institutionFactory->save($institution); // set medical center name and description to institution.name and institution.description $institutionMedicalCenter->setName($institution->getName()); $institutionMedicalCenter->setDescription($institution->getDescription() ? $institution->getDescription() : '2'); $institutionMedicalCenter->setInstitution($institution); $institutionMedicalCenter->setAddress($institution->getAddress1()); $institutionMedicalCenter->setCoordinates($institution->getCoordinates()); // save institution medical center as draft $this->institutionMedicalCenterService->saveAsDraft($institutionMedicalCenter); }
/** * Ajax handler for removing a Doctor from InstitutionMedicalCenter * Expected parameters: * - imcId * - doctorId * * @param Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function removeDoctorAction(Request $request) { $result = array('status' => false); $doctor = $this->getDoctrine()->getRepository('DoctorBundle:Doctor')->find($request->get('doctorId', 0)); if (!$doctor) { $result['message'] = 'Invalid Doctor Id.'; } try { $this->institutionMedicalCenter->removeDoctor($doctor); $this->service->save($this->institutionMedicalCenter); $result['status'] = true; $result['message'] = 'Doctor successfully removed from your clinic.'; // Invalidate InstitutionMedicalCenterProfile memcache $this->get('services.memcache')->delete(FrontendMemcacheKeysHelper::generateInsitutionMedicalCenterProfileKey($this->institutionMedicalCenter->getId())); // Invalidate InstitutionProfile memcache $this->get('services.memcache')->delete(FrontendMemcacheKeysHelper::generateInsitutionProfileKey($this->institutionMedicalCenter->getInstitution()->getId())); } catch (\Exception $e) { } return new Response(\json_encode($result), 200, array('content-type' => 'application/json')); }
/** * * @param Mixed <BusinessHour, array> $businessHour * @return */ public function businessHoursToViewData($businessHour) { if ($businessHour instanceof BusinessHour) { $data = array('weekdayBitValue' => $businessHour->getWeekdayBitValue(), 'startTime' => $businessHour->getOpening()->format('h:i A'), 'endTime' => $businessHour->getClosing()->format('h:i A'), 'notes' => $businessHour->getNotes(), 'startTimeDbFormat' => $businessHour->getOpening()->format('h:i'), 'endTimeDbFormat' => $businessHour->getClosing()->format('h:i')); } else { $data = array('weekdayBitValue' => $businessHour['weekdayBitValue'], 'startTime' => $businessHour['opening']->format('h:i A'), 'endTime' => $businessHour['closing']->format('h:i A'), 'notes' => $businessHour['notes'], 'startTimeDbFormat' => $businessHour['opening']->format('h:i'), 'endTimeDbFormat' => $businessHour['closing']->format('h:i')); } $days = $this->institutionMedicalCenterService->extractDaysFromWeekdayBitValue($data['weekdayBitValue']); $daysLabel = ''; if (count($days) > 1) { $currentDay = null; $previousDay = null; $leastDay = null; $groupedWeekdaysLabel = array(); $data['days']['twoLetter'] = array(); foreach ($days as $_day_attr) { $currentDay = $_day_attr; $data['days']['twoLetter'][] = substr($_day_attr['short'], 0, 2); if (null == $previousDay) { $previousDay = $currentDay; $leastDay = $currentDay; } else { if ($currentDay['day'] - $previousDay['day'] > 1) { $groupedWeekdaysLabel[] = $this->_concatenateDays($leastDay, $previousDay); $leastDay = $currentDay; } $previousDay = $currentDay; } } if (null != $leastDay) { $groupedWeekdaysLabel[] = $this->_concatenateDays($leastDay, $previousDay); } $daysLabel = \implode("\n", $groupedWeekdaysLabel); } elseif (count($days) == 1) { $daysLabel = $days[0]['short']; $data['days']['twoLetter'] = array(substr($days[0]['short'], 0, 2)); } $data['daysLabel'] = $daysLabel; return $data; }