コード例 #1
0
 /**
  * Remove institution specialization
  *
  * @param Request $request
  */
 public function ajaxRemoveSpecializationAction(Request $request)
 {
     $institutionSpecialization = $this->getDoctrine()->getRepository('InstitutionBundle:InstitutionSpecialization')->find($request->get('isId', 0));
     if (!$institutionSpecialization) {
         throw $this->createNotFoundException('Invalid instituiton specialization');
     }
     if ($institutionSpecialization->getInstitutionMedicalCenter()->getId() != $this->institutionMedicalCenter->getId()) {
         return new Response("Cannot remove specialization that does not belong to this institution", 401);
     }
     $form = $this->createForm(new CommonDeleteFormType(), $institutionSpecialization);
     if ($request->isMethod('POST')) {
         $form->bind($request);
         if ($form->isValid()) {
             $_id = $institutionSpecialization->getId();
             $em = $this->getDoctrine()->getEntityManager();
             $em->remove($institutionSpecialization);
             $em->flush();
             // 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()));
             $responseContent = array('id' => $_id);
             $response = new Response(\json_encode($responseContent), 200, array('content-type' => 'application/json'));
         } else {
             $response = new Response("Invalid form", 400);
         }
     }
     return $response;
 }
 /**
  * @param InstitutionMedicalCenter $center
  */
 function updateInstitutionMedicalCenterListing(InstitutionMedicalCenter $center)
 {
     $institution = $center->getInstitution();
     $criteria = array('institution' => $institution->getId(), 'institutionMedicalCenter' => $center->getId());
     $recentlyApprovedListing = $this->em->getRepository('AdminBundle:RecentlyApprovedListing')->findOneBy($criteria);
     if ($recentlyApprovedListing) {
         if ($center->getStatus() == InstitutionMedicalCenterStatus::APPROVED) {
             $recentlyApprovedListing->setDateUpdated(new \DateTime());
             $this->em->persist($recentlyApprovedListing);
         } else {
             $this->em->remove($recentlyApprovedListing);
         }
         $this->em->flush();
     } else {
         if ($center->getStatus() == InstitutionMedicalCenterStatus::APPROVED) {
             $recentlyApprovedListingService = new RecentlyApprovedListingService();
             $recentlyApprovedListingService->setEntityManager($this->em);
             $recentlyApprovedListing = new RecentlyApprovedListing();
             $recentlyApprovedListing->setInstitution($institution);
             $recentlyApprovedListing->setInstitutionMedicalCenter($center);
             $recentlyApprovedListing->setDateUpdated(new \DateTime());
             $recentlyApprovedListing->setStatus(1);
             $this->em->persist($recentlyApprovedListing);
             $this->em->flush($recentlyApprovedListing);
         }
     }
 }
コード例 #3
0
 public function preExecute()
 {
     $this->request = $this->getRequest();
     $this->institution = $this->get('services.institution.factory')->findById($this->request->get('institutionId'));
     $this->institutionService = $this->get('services.institution');
     if (!$this->institution) {
         throw $this->createNotFoundException("Invalid institution");
     }
     if ($imcId = $this->getRequest()->get('imcId', 0)) {
         $this->institutionMedicalCenter = $this->get('services.institution_medical_center')->findById($imcId);
         // institution medical center does not belong to institution
         if ($this->institutionMedicalCenter && $this->institutionMedicalCenter->getInstitution()->getId() != $this->institution->getId()) {
             return new Response('Medical center does not belong to institution', 401);
         }
     }
 }
 public function preExecute()
 {
     $this->repository = $this->getDoctrine()->getRepository('InstitutionBundle:InstitutionMedicalCenter');
     $this->service = $this->get('services.institution_medical_center');
     if ($imcId = $this->getRequest()->get('imcId', 0)) {
         $this->institutionMedicalCenter = $this->repository->find($imcId);
         // non-existent medical center group
         if (!$this->institutionMedicalCenter) {
             if ($this->getRequest()->isXmlHttpRequest()) {
                 throw $this->createNotFoundException('Invalid medical center.');
             } else {
                 return $this->_redirectIndexWithFlashMessage('Invalid medical center.', 'error');
             }
         }
         // medical center group does not belong to this institution
         if ($this->institutionMedicalCenter->getInstitution()->getId() != $this->institution->getId()) {
             return $this->_redirectIndexWithFlashMessage('Invalid medical center.', 'error');
         }
     }
 }
 private function migrateClinicLogo(InstitutionMedicalCenter $imc)
 {
     $this->output->write("LOGO of clinic {$imc->getId()}: ");
     $oldDirectory = $this->getWebRootDirectory() . '/' . $imc->getInstitution()->getId();
     if ($media = $imc->getLogo()) {
         $mediaFile = $oldDirectory . '/' . $media->getName();
         if (\file_exists($mediaFile)) {
             $this->doMove($imc->getInstitution(), $media, $this->logoSizes);
             $this->output->write('[OK]');
         } else {
             $this->output->write('[NOT FOUND]');
         }
         $this->output->writeln("");
     } else {
         $this->output->writeln("NO LOGO");
     }
 }
コード例 #6
0
 /**
  * Upload logo for Institution Medical Center
  * @param Request $request
  */
 public function uploadAction(Request $request)
 {
     if ($request->files->get('logo')) {
         $file = $request->files->get('logo');
         $media = $this->get('services.institution.media')->medicalCenterUploadLogo($file, $this->institutionMedicalCenter);
         if ($media->getName()) {
             $src = $this->get('services.institution')->mediaTwigExtension->getInstitutionMediaSrc($media->getName(), ImageSizes::MEDIUM);
             $data['mediaSrc'] = $src;
         }
         $data['status'] = true;
         // 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()));
     }
     return new Response(\json_encode($data), 200, array('content-type' => 'application/json'));
 }
 /**
  * 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;
 }
コード例 #8
0
 function medicalCenterUploadToGallery($file, InstitutionMedicalCenter $medicalCenter, $flushObject = true)
 {
     $result = parent::uploadFile($file);
     if (is_object($result)) {
         $media = $result;
         $sizes = $this->getSizesByType(self::GALLERY_TYPE_IMAGE);
         $this->resize($media, $sizes);
         $gallery = $this->entityManager->getRepository('MediaBundle:Gallery')->findOneByInstitution($medicalCenter->getInstitution()->getId());
         if (!$gallery) {
             $gallery = new Gallery();
             $gallery->addMedia($media);
             $gallery->setInstitution($medicalCenter->getInstitution());
         } else {
             $gallery->addMedia($media);
         }
         $medicalCenter->addMedia($media);
         if ($flushObject) {
             $this->entityManager->persist($gallery);
             $this->entityManager->persist($medicalCenter);
             $this->entityManager->flush();
         }
         return $media;
     }
     return null;
 }