private function _getEditMedicalCenterCalloutView()
 {
     $calloutParams = array('{CENTER_NAME}' => $this->institutionMedicalCenter->getName(), '{ADD_CLINIC_URL}' => $this->generateUrl('institution_medicalCenter_add'));
     $calloutMessage = $this->get('services.institution.callouts')->get('success_edit_center', $calloutParams);
     $calloutView = $this->renderView('InstitutionBundle:Widgets:callout.html.twig', array('callout' => $calloutMessage));
     return $calloutView;
 }
 /**
  * Create a PageMetaConfiguration for clinic page
  * 
  * @param InstitutionMedicalCenter $institutionMedicalCenter
  * @return \HealthCareAbroad\HelperBundle\Entity\PageMetaConfiguration
  */
 public function buildForInstitutionMedicalCenterPage(InstitutionMedicalCenter $institutionMedicalCenter)
 {
     $institution = $institutionMedicalCenter->getInstitution();
     $location = ($institution->getCity() ? $institution->getCity() . ', ' : '') . $institution->getCountry();
     $metaConfig = new PageMetaConfiguration();
     $metaConfig->setTitle("{$institutionMedicalCenter->getName()} - {$institution->getName()} {$location} - " . $this->siteName);
     $metaConfig->setDescription("{$institutionMedicalCenter->getName()} at {$institution->getName()} offers treatments in {" . PageMetaConfigurationService::SPECIALIZATIONS_LIST_VARIABLE . "} in {$location}. Get details at " . $this->siteName);
     $metaConfig->setKeywords("{$institution->getName()}, {$institutionMedicalCenter->getName()}, {$location}, {" . PageMetaConfigurationService::SPECIALIZATIONS_LIST_VARIABLE . "}, medical tourism, Doctor, Dentist");
     $metaConfig->setPageType(PageMetaConfiguration::PAGE_TYPE_INSTITUTION_MEDICAL_CENTER);
     return $metaConfig;
 }
 public static function institutionMedicalCenterToArray(InstitutionMedicalCenter $institutionMedicalCenter)
 {
     $data = array('id' => $institutionMedicalCenter->getId(), 'name' => $institutionMedicalCenter->getName());
     return $data;
 }
 /**
  * Ajax handler for updating institution medical center by field
  * @param Request $request
  * @author acgvelarde
  */
 public function ajaxUpdateByFieldAction(Request $request)
 {
     $output = array();
     $propertyService = $this->get('services.institution_medical_center_property');
     if (true) {
         try {
             $formVariables = $request->get(InstitutionMedicalCenterFormType::NAME);
             unset($formVariables['_token']);
             $removedFields = \array_diff(InstitutionMedicalCenterFormType::getFieldNames(), array_keys($formVariables));
             $this->get('services.contact_detail')->initializeContactDetails($this->institutionMedicalCenter, array(ContactDetailTypes::PHONE));
             $form = $this->createForm(new InstitutionMedicalCenterFormType($this->institution), $this->institutionMedicalCenter, array(InstitutionMedicalCenterFormType::OPTION_BUBBLE_ALL_ERRORS => false, InstitutionMedicalCenterFormType::OPTION_REMOVED_FIELDS => $removedFields));
             $form->bind($request);
             if ($form->isValid()) {
                 $institutionMedicalCenterService = $this->get('services.institution_medical_center');
                 $this->get('services.contact_detail')->removeInvalidContactDetails($this->institutionMedicalCenter);
                 $responseContent = array();
                 if (isset($formVariables['businessHours'])) {
                     $institutionMedicalCenterService->clearBusinessHours($this->institutionMedicalCenter);
                     foreach ($this->institutionMedicalCenter->getBusinessHours() as $hour) {
                         $hour->setInstitutionMedicalCenter($this->institutionMedicalCenter);
                     }
                     $institutionMedicalCenterService->save($this->institutionMedicalCenter);
                     $responseContent = array('businessHours' => $formVariables['businessHours']);
                 } elseif (isset($form['services'])) {
                     $propertyService->addPropertyForInstitutionMedicalCenterByType($this->institution, $form['services']->getData(), InstitutionPropertyType::TYPE_ANCILLIARY_SERVICE, $this->institutionMedicalCenter);
                     $responseContent = array('services' => $form['services']);
                 } elseif ($awardType = $request->get('awardTypeKey')) {
                     $awardsData = isset($form['awards']) ? $form['awards']->getData() : array();
                     $propertyService->addPropertyForInstitutionMedicalCenterByType($this->institution, $awardsData, InstitutionPropertyType::TYPE_GLOBAL_AWARD, $this->institutionMedicalCenter);
                     $globalAwards = $propertyService->getGlobalAwardPropertiesByInstitutionMedicalCenter($this->institutionMedicalCenter);
                     $responseContent['awardsType'] = $awardType;
                     $responseContent['awardsHtml'] = $this->renderView('InstitutionBundle:Widgets/Profile:globalAwards.html.twig', array('eachAward' => array('list' => $globalAwards[$awardType]), 'type' => $awardType . 's', 'toggleBtnId' => 'clinic-edit-' . $awardType . 's-btn'));
                 } else {
                     $institutionMedicalCenterService->save($this->institutionMedicalCenter);
                     if ($this->isSingleCenter) {
                         // also update the instituion name and description
                         $this->institution->setName($this->institutionMedicalCenter->getName());
                         $this->institution->setDescription($this->institutionMedicalCenter->getDescription());
                         $this->get('services.institution.factory')->save($this->institution);
                     }
                     if (isset($formVariables['address'])) {
                         $formVariables['stringAddress'] = $this->get('services.institutionMedicalCenter.twig.extension')->getCompleteAddressAsString($this->institutionMedicalCenter);
                     }
                     if (isset($formVariables['contactDetails'])) {
                         $formVariables['contactDetails'] = $this->get('services.contact_detail')->getContactDetailsStringValue($this->institutionMedicalCenter->getContactDetails());
                     }
                     $responseContent = array('institutionMedicalCenter' => $formVariables);
                 }
                 // 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()));
                 $response = new Response(\json_encode($responseContent), 200, array('content-type' => 'application/json'));
             } else {
                 $errors = array();
                 foreach ($form->getChildren() as $field) {
                     if (\count($eachErrors = $field->getErrors())) {
                         $errors[] = array('field' => $field->getName(), 'error' => $eachErrors[0]->getMessageTemplate());
                     }
                 }
                 $response = new Response(\json_encode(array('errors' => $errors)), 400, array('content-type' => 'application/json'));
             }
         } catch (\Exception $e) {
             return new Response($e->getMessage(), 500);
         }
     }
     return $response;
 }