public function render_institution_suggestions(Institution $institution)
 {
     $suggestions = array();
     $isSingleCenter = $this->institutionService->isSingleCenter($institution);
     $label = $isSingleCenter ? 'clinic' : 'hospital';
     if (!$isSingleCenter && !$institution->getInstitutionMedicalCenters()) {
         $suggestions[] = array('description' => '<span class="span1"><i class="icon-medkit icon-2x hca-red pull-left"></i></span>You currently have no centers for your ' . $label . ' yet.');
     }
     if ($isSingleCenter) {
         $medicalCenter = $this->institutionService->getFirstMedicalCenter($institution);
         if (!$medicalCenter->getDoctors()->count()) {
             $suggestions[] = array('description' => '<span class="span1"><i class="icon-user-md icon-2x hca-red pull-left"></i></span>You currently dont have doctors for your ' . $label . ' yet.');
         }
     }
     if (!$institution->getDescription()) {
         $suggestions[] = array('description' => '<span class="span1"><i class="icon-file icon-2x hca-red pull-left"></i></span>You currently have no <b>description</b> for your ' . $label . ' yet.');
     }
     if (!$institution->getLogo()) {
         if ($institution->getPayingClient()) {
             $suggestions[] = array('description' => '<span class="span1"><i class="icon-h-sign icon-2x hca-red pull-left"></i></span> You have not yet added a <b>logo</b>. Upload it today and help patients make an instant brand connection between your clinic and the treatments you offer.');
         } else {
             $suggestions[] = array('description' => '<span class="span1"><i class="icon-h-sign icon-2x hca-red pull-left"></i></span>Upgrade your listing today and have your <b>logo</b> show on your ' . ($isSingleCenter ? 'clinic page' : 'clinic pages') . '. ');
         }
     }
     if (!$institution->getFeaturedMedia()) {
         if ($institution->getPayingClient()) {
             $suggestions[] = array('description' => '<span class="span1"><i class="icon-picture icon-2x hca-red pull-left"></i></span>You have not yet uploaded your <b>cover photo</b>. Make use of this space to add a large image to establish your brand and reputation.');
         } else {
             $suggestions[] = array('description' => '<span class="span1"><i class="icon-picture icon-2x hca-red pull-left"></i></span>Upgrade your listing today and have a <b>cover photo</b> show on your ' . ($isSingleCenter ? 'clinic page' : 'clinic pages') . '. Making use of this space to add a large image helps in establishing your brand and reputation.');
         }
     }
     if ($this->institutionGalleryService->institutionHasPhotos($institution->getId())) {
         if ($institution->getPayingClient()) {
             $suggestions[] = array('description' => '<span class="span1"><i class="icon-film icon-2x hca-red pull-left"></i></span>You have not yet uploaded <b>photos or videos</b>. Beautiful photos and videos help give users a more complete image of your ' . $label . ', and makes decisions easier and more likely.');
         } else {
             $suggestions[] = array('description' => '<span class="span1"><i class="icon-film icon-2x hca-red pull-left"></i></span>Upgrade your listing today to add <b>photos and videos</b>. Beautiful photos and videos help give users a more complete image of your ' . $label . ', and makes decisions easier and more likely.');
         }
     }
     if (!$institution->getContactDetails()->count()) {
         $suggestions[] = array('description' => '<span class="span1"><i class="icon-phone icon-2x hca-red pull-left"></i></span>You currently have no <b>contact details</b> for your ' . $label . ' yet.');
     }
     if (!$institution->getSocialMediaSites()) {
         $suggestions[] = array('description' => '<span class="span1"><i class="icon-group icon-2x hca-red pull-left"></i></span>You currently have no <b>social media sites</b> for your ' . $label . ' yet.');
     }
     if (!$this->institutionService->getAllGlobalAwards($institution)) {
         $suggestions[] = array('description' => '<span class="span1"><i class="icon-asterisk icon-2x hca-red pull-left"></i></span>You have not yet listed any <b>awards, certifications, affiliations or accreditations</b>. List your certifications and accreditations to help show that your clinics adhere to international standards of quality; list your awards and affiliations to show you are recognized by peers in your industry. ');
     }
     return $suggestions;
 }
 /**
  * DEPRECATED ??? - Note added by: Adelbert
  *   
  * Load tabbed contents of an institution
  *   
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function loadMultipleCenterInstitutionTabbedContentsAction()
 {
     $output = array();
     $parameters = array('institution' => $this->institution);
     $content = $this->request->get('content', null);
     switch ($content) {
         case 'services':
             $ancillaryServicesData = array('globalList' => $this->get('services.helper.ancillary_service')->getActiveAncillaryServices(), 'currentAncillaryData' => array(), 'selected' => array());
             foreach ($this->get('services.institution_property')->getInstitutionByPropertyType($this->institution, InstitutionPropertyType::TYPE_ANCILLIARY_SERVICE) as $_selectedService) {
                 $ancillaryServicesData['currentAncillaryData'][] = array('id' => $_selectedService->getId(), 'value' => $_selectedService->getValue());
                 $ancillaryServicesData['selected'][] = $_selectedService->getValue();
             }
             $parameters['services'] = $ancillaryServicesData;
             $output['services'] = array('html' => $this->renderView('InstitutionBundle:Widgets:tabbedContent.institutionServices.html.twig', $parameters));
             break;
         case 'awards':
             $form = $this->createForm(new InstitutionGlobalAwardsSelectorFormType());
             //$currentGlobalAwards = $this->institutionService->getGroupedGlobalAwardsByType($this->institution);
             $currentGlobalAwards = $this->get('services.institution_property')->getGlobalAwardPropertiesByInstitution($this->institution);
             $autocompleteSource = $this->get('services.global_award')->getAutocompleteSource();
             $editGlobalAwardForm = $this->createForm(new InstitutionGlobalAwardFormType());
             $parameters['form'] = $form->createView();
             $parameters['editGlobalAwardForm'] = $editGlobalAwardForm->createView();
             $parameters['isSingleCenter'] = $this->institutionService->isSingleCenter($this->institution);
             $parameters['awardsSourceJSON'] = \json_encode($autocompleteSource['award']);
             $parameters['certificatesSourceJSON'] = \json_encode($autocompleteSource['certificate']);
             $parameters['affiliationsSourceJSON'] = \json_encode($autocompleteSource['affiliation']);
             $parameters['accreditationsSourceJSON'] = \json_encode($autocompleteSource['accreditation']);
             $parameters['currentGlobalAwards'] = $currentGlobalAwards;
             $parameters['institution'] = $this->institution;
             $parameters['commonDeleteForm'] = $this->createForm(new CommonDeleteFormType())->createView();
             $output['awards'] = array('html' => '');
     }
     return new Response(\json_encode($output), 200, array('content-type' => 'application/json'));
 }
 /**
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function setupInstitutionMedicalCenterAction(Request $request)
 {
     $error_message = false;
     if ($this->institutionService->isSingleCenter($this->institution)) {
         // this is not part of the sign up flow of  single center institution
         throw $this->createNotFoundException();
     }
     $this->currentSignUpStep = $this->signUpService->getMultipleCenterSignUpStepByRoute($request->attributes->get('_route'));
     // TODO: check current sign up status
     // We don't assume that there is a medical center instance here already since this is also where we redirect from multiple center institution sign up
     if (!$this->institutionMedicalCenter instanceof InstitutionMedicalCenter) {
         $this->institutionMedicalCenter = new InstitutionMedicalCenter();
         $this->institutionMedicalCenter->setInstitution($this->institution);
     }
     $this->get('services.contact_detail')->initializeContactDetails($this->institutionMedicalCenter, array(ContactDetailTypes::PHONE), $this->institution->getCountry());
     $form = $this->createForm(new InstitutionMedicalCenterFormType($this->institution), $this->institutionMedicalCenter, array(InstitutionMedicalCenterFormType::OPTION_BUBBLE_ALL_ERRORS => false));
     if ($this->request->isMethod('POST')) {
         $formRequestData = $request->get($form->getName());
         if ((bool) $request->get('isSameAddress')) {
             $formRequestData['address'] = json_decode($this->institution->getAddress1(), true);
             $this->institutionMedicalCenter->setAddressHint($this->institution->getAddressHint());
             $this->institutionMedicalCenter->setCoordinates($this->institution->getCoordinates());
         }
         $form->bind($formRequestData);
         if ($form->isValid()) {
             $this->institutionMedicalCenter = $form->getData();
             $institutionMedicalCenterService = $this->get('services.institution_medical_center');
             $this->get('services.contact_detail')->removeInvalidContactDetails($this->institutionMedicalCenter);
             $institutionMedicalCenterService->clearBusinessHours($this->institutionMedicalCenter);
             foreach ($this->institutionMedicalCenter->getBusinessHours() as $_hour) {
                 $_hour->setInstitutionMedicalCenter($this->institutionMedicalCenter);
             }
             $institutionMedicalCenterService->saveAsDraft($this->institutionMedicalCenter);
             // update sign up step status of institution
             $this->_updateInstitutionSignUpStepStatus($this->currentSignUpStep, true);
             // redirect to next step
             $nextStepRoute = $this->signUpService->getMultipleCenterSignUpNextStep($this->currentSignUpStep)->getRoute();
             // TODO: Update this when we have formulated a strategy for our events system
             // We can't use InstitutionBundleEvents; we don't know the consequences of the event firing up other listeners.
             $this->get('event_dispatcher')->dispatch(MailerBundleEvents::NOTIFICATIONS_CLINIC_CREATED, new GenericEvent($this->institutionMedicalCenter, array('userEmail' => $request->getSession()->get('userEmail'))));
             return $this->redirect($this->generateUrl($nextStepRoute, array('imcId' => $this->institutionMedicalCenter->getId())));
         }
         $form_errors = $this->get('validator')->validate($form);
         if ($form_errors) {
             $error_message = 'We need you to correct some of your input. Please check the fields in red.';
         }
     }
     return $this->render('InstitutionBundle:SignUp:setupInstitutionMedicalCenter.html.twig', array('form' => $form->createView(), 'institution' => $this->institution, 'institutionMedicalCenter' => $this->institutionMedicalCenter, 'error_message' => $error_message));
 }