public function buildForm(FormBuilderInterface $builder, array $options) { $status = array(GlobalAward::STATUS_ACTIVE => 'active', GlobalAward::STATUS_INACTIVE => 'inactive'); $builder->add('type', 'choice', array('choices' => GlobalAwardTypes::getTypes(), 'expanded' => false, 'constraints' => array(new NotBlank()))); $builder->add('name', 'text', array('constraints' => array(new NotBlank()))); $builder->add('awardingBody', new AwardingBodyListType()); $builder->add('country', CountryListType::NAME, array('empty_value' => 'Choose Country')); $builder->add('details', 'textarea'); $builder->add('status', 'choice', array('choices' => $status)); }
public static function groupGlobalAwardPropertiesByType(array $properties) { $awardTypes = GlobalAwardTypes::getTypes(); $globalAwards = \array_flip(GlobalAwardTypes::getTypeKeys()); // initialize holder for awards foreach ($globalAwards as $k => $v) { $globalAwards[$k] = array(); } foreach ($properties as $_property) { $_globalAward = $_property->getValueObject(); $globalAwards[\strtolower($awardTypes[$_globalAward->getType()])][] = $_property; } return $globalAwards; }
/** * Load available global awards of an institution. Used in autocomplete fields * * @param Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function ajaxMedicalCenterGlobalAwardSourceAction(Request $request) { $term = \trim($request->get('term', '')); $type = $request->get('type', null); $types = \array_flip(GlobalAwardTypes::getTypeKeys()); $type = \array_key_exists($type, $types) ? $types[$type] : 0; $output = array(); $options = new QueryOptionBag(); $options->add('globalAward.name', $term); if ($type) { $options->add('globalAward.type', $type); } $awards = $this->getDoctrine()->getRepository('InstitutionBundle:InstitutionMedicalCenterProperty')->getAvailableGlobalAwardsOfInstitutionMedicalCenter($this->institutionMedicalCenter, $options); foreach ($awards as $_award) { $output[] = array('id' => $_award->getId(), 'label' => $_award->getName(), 'awardingBody' => $_award->getAwardingBody()->getName()); } return new Response(\json_encode($output), 200, array('content-type' => 'application/json')); }
/** * @deprecated ? * @param InstitutionMedicalCenter $institutionMedicalCenter */ public function getGroupedMedicalCenterGlobalAwards(InstitutionMedicalCenter $institutionMedicalCenter) { $awardTypes = GlobalAwardTypes::getTypes(); $globalAwards = \array_flip(GlobalAwardTypes::getTypeKeys()); // initialize holder for awards foreach ($globalAwards as $k => $v) { $globalAwards[$k] = array(); } $imcProperties = $this->institutionMedicalCenterPropertyService->getGlobalAwardPropertiesByInstitutionMedicalCenter($institutionMedicalCenter); foreach ($imcProperties as $imcp_arr) { if (!empty($imcp_arr)) { foreach ($imcp_arr as $imcp) { $_globalAward = $imcp->getValueObject(); $globalAwards[\strtolower($awardTypes[$_globalAward->getType()])][] = $imcp; } } } // foreach ($this->getMedicalCenterGlobalAwards($institutionMedicalCenter) as $_globalAward) { // $globalAwards[\strtolower($awardTypes[$_globalAward->getType()])][] = array( // 'global_award' => $_globalAward, // ); // } return $globalAwards; }
public function getGlobalAwardType($type) { return GlobalAwardTypes::getTypeValue($type); }
public function indexAction() { return $this->render('AdminBundle:GlobalAward:index.html.twig', array('global_awards' => $this->filteredResult, 'pager' => $this->pager, 'types' => GlobalAwardTypes::getTypes())); }
/** * * @param Request $request * @return Response * @author acgvelarde */ public function profileAction(Request $request) { $start = \microtime(true); $slug = $request->get('institutionSlug', null); $institutionId = $this->getDoctrine()->getRepository('InstitutionBundle:Institution')->getInstitutionIdBySlug($slug); if (!$institutionId) { throw $this->createNotFoundException('Invalid institution'); } $this->apiInstitutionService = $this->get('services.api.institution'); $this->apiInstitutionMedicalCenterService = $this->get('services.api.institutionMedicalCenter'); $memcacheService = $this->get('services.memcache'); $memcacheKey = FrontendMemcacheKeysHelper::generateInsitutionProfileKey($institutionId); $cachedData = $memcacheService->get($memcacheKey); if (!$cachedData) { $mediaExtensionService = $this->apiInstitutionService->getMediaExtension(); $this->institution = $this->apiInstitutionService->getInstitutionPublicDataById($institutionId); // process common data for both single and multiple center $this->apiInstitutionService->buildGlobalAwards($this->institution)->buildOfferedServices($this->institution)->buildFeaturedMediaSource($this->institution)->buildLogoSource($this->institution)->buildContactDetails($this->institution)->buildExternalSites($this->institution); $isSingleCenterInstitution = $this->apiInstitutionService->isSingleCenterInstitutionType($this->institution['type']); if ($isSingleCenterInstitution) { // build view data for single center institution $this->processSingleCenterInstitution(); } else { // build view data for multiple center institution $this->processMultipleCenterInstitution(); } $this->institution['specializationsList'] = $this->apiInstitutionService->listActiveSpecializations($this->institution['id']); // cache this processed data $memcacheService->set($memcacheKey, $this->institution); } else { $this->institution = $cachedData; $isSingleCenterInstitution = $this->apiInstitutionService->isSingleCenterInstitutionType($this->institution['type']); } $firstMedicalCenter = isset($this->institution['institutionMedicalCenters'][0]) ? $this->institution['institutionMedicalCenters'][0] : null; // set request variables to be used by page meta components $this->getRequest()->attributes->add(array('institution' => $this->institution, 'pageMetaContext' => PageMetaConfiguration::PAGE_TYPE_INSTITUTION, 'pageMetaVariables' => array(PageMetaConfigurationService::ACTIVE_CLINICS_COUNT_VARIABLE => \count($this->institution['institutionMedicalCenters']), PageMetaConfigurationService::SPECIALIZATIONS_COUNT_VARIABLE => \count($this->institution['specializationsList']), PageMetaConfigurationService::SPECIALIZATIONS_LIST_VARIABLE => \implode(', ', \array_slice($this->institution['specializationsList'], 0, 10, true))))); $params = array('institution' => $this->institution, 'isSingleCenterInstitution' => $isSingleCenterInstitution, 'institutionDoctors' => $this->institution['doctors'], 'institutionMedicalCenter' => $firstMedicalCenter, 'form' => $this->createForm(new InstitutionInquiryFormType(), new InstitutionInquiry())->createView(), 'institutionAwards' => $this->institution['globalAwards'], 'institutionServices' => $this->institution['offeredServices'], 'awardTypes' => GlobalAwardTypes::getTypes(), 'photos' => $this->get('services.institution.gallery')->getInstitutionPhotos($this->institution['id'])); $content = $this->render('FrontendBundle:Institution:profile.html.twig', $params); $end = \microtime(true); $diff = $end - $start; //echo "{$diff}s"; exit; $response = $this->setResponseHeaders($content); return $response; }
public function viewGlobalAwardsAction(Request $request) { $form = $this->createForm(new InstitutionGlobalAwardsSelectorFormType()); $repo = $this->getDoctrine()->getRepository('HelperBundle:GlobalAward'); $globalAwards = $repo->findBy(array('status' => GlobalAward::STATUS_ACTIVE)); $propertyService = $this->get('services.institution_property'); $propertyType = $propertyService->getAvailablePropertyType(InstitutionPropertyType::TYPE_GLOBAL_AWARD); $awardTypes = GlobalAwardTypes::getTypes(); $currentGlobalAwards = $this->get('services.institution_property')->getGlobalAwardPropertiesByInstitution($this->institution); $autocompleteSource = $this->get('services.global_award')->getAutocompleteSource(); $editGlobalAwardForm = $this->createForm(new InstitutionGlobalAwardFormType()); return $this->render('AdminBundle:InstitutionGlobalAwards:index.html.twig', array('form' => $form->createView(), 'isSingleCenter' => $this->get('services.institution')->isSingleCenter($this->institution), 'awardsSourceJSON' => \json_encode($autocompleteSource['award']), 'certificatesSourceJSON' => \json_encode($autocompleteSource['certificate']), 'affiliationsSourceJSON' => \json_encode($autocompleteSource['affiliation']), 'accreditationsSourceJSON' => \json_encode($autocompleteSource['accreditation']), 'currentGlobalAwards' => $currentGlobalAwards, 'institution' => $this->institution, 'editGlobalAwardForm' => $editGlobalAwardForm->createView(), 'commonDeleteForm' => $this->createForm(new CommonDeleteFormType())->createView())); }