Exemplo n.º 1
0
 /** @ORM\PostPersist */
 public function PostPersist(Prestation $prestation, LifecycleEventArgs $event)
 {
     $entity = $event->getEntity();
     $entityManager = $event->getEntityManager();
     //Mise a jour du role du photographe
     $status = $prestation->getStatus()->getId();
     $id = $entity->getId();
     $photographer = $entity->getDevis()->getCompany()->getPhotographer()->getId();
     $client = $entity->getClient()->getId();
     switch ($status) {
         case 1:
             //Creation message
             $message = $entity->getReference();
             $model = 1;
             $entityManager->getRepository('MainCommonBundle:Messages\\Message')->createMessagePrestation($id, 2, $model, $client, $photographer, $message);
             break;
         default:
             break;
     }
 }
Exemplo n.º 2
0
 /**
  * Envoi de mail lors de la mise à jour du statut de la prestation
  * 
  * @param  Prestation $Prestation [description]
  * @return [type]                 [description]
  */
 public function prestationUpdateEmail(Prestation $prestation, $comments = null)
 {
     $status = $prestation->getStatus()->getId();
     $photographer = $prestation->getDevis()->getCompany()->getPhotographer();
     $emailPhotographer = $photographer->getEmail();
     $client = $prestation->getClient();
     $emailClient = $client->getEmail();
     $sendToPhotographer = $this->canReceiveEmails($photographer, 1);
     $sendToClient = $this->canReceiveEmails($client, 1);
     $templatePhotographer = null;
     $templateClient = null;
     switch ($status) {
         case 1:
             $templatePhotographer = 'MainCommonBundle:Emails\\Prestations\\Created:to_photographer.html.twig';
             $templateClient = 'MainCommonBundle:Emails\\Prestations\\Created:to_client.html.twig';
             $subjectPhotographer = $this->translator->trans('prestation.created.photographer.subject', array(), 'email');
             $subjectClient = $this->translator->trans('prestation.created.client.subject', array(), 'email');
             break;
         case 2:
             //PHOTOGRAPHER_OK
             $templatePhotographer = 'MainCommonBundle:Emails\\Prestations\\PreApproved:to_photographer.html.twig';
             $templateClient = 'MainCommonBundle:Emails\\Prestations\\PreApproved:to_client.html.twig';
             $subjectPhotographer = $this->translator->trans('prestation.preapproved.photographer.subject', array(), 'email');
             $subjectClient = $this->translator->trans('prestation.preapproved.client.subject', array(), 'email');
             break;
         case 3:
             //Refused-photographer
             $templatePhotographer = 'MainCommonBundle:Emails\\Prestations\\Refused:to_photographer.html.twig';
             $templateClient = 'MainCommonBundle:Emails\\Prestations\\Refused:to_client.html.twig';
             $subjectPhotographer = $this->translator->trans('prestation.refused.photographer.subject', array(), 'email');
             $subjectClient = $this->translator->trans('prestation.refused.client.subject', array(), 'email');
             break;
         case 4:
             //Cancel-Client
             $templatePhotographer = 'MainCommonBundle:Emails\\Prestations\\Abandonned:to_photographer.html.twig';
             $templateClient = 'MainCommonBundle:Emails\\Prestations\\Abandonned:to_client.html.twig';
             $subjectPhotographer = $this->translator->trans('prestation.abandoned.photographer.subject', array(), 'email');
             $subjectClient = $this->translator->trans('prestation.abandoned.client.subject', array(), 'email');
             break;
         case 5:
             //Valide
             $templatePhotographer = 'MainCommonBundle:Emails\\Prestations\\Confirmed:to_photographer.html.twig';
             $templateClient = 'MainCommonBundle:Emails\\Prestations\\Confirmed:to_client.html.twig';
             $subjectPhotographer = $this->translator->trans('prestation.confirmed.photographer.subject', array(), 'email');
             $subjectClient = $this->translator->trans('prestation.confirmed.client.subject', array(), 'email');
             break;
             /*
             case 6:
                 $to = '';
                 $subject = '';
                 $template = '';
                 $body = '';
                 break;
             case 7:
                 $to = '';
                 $subject = '';
                 $template = '';
                 $body = '';
                 break;
             case 8:
                 $to = '';
                 $subject = '';
                 $template = '';
                 $body = '';
                 break;
             */
         /*
         case 6:
             $to = '';
             $subject = '';
             $template = '';
             $body = '';
             break;
         case 7:
             $to = '';
             $subject = '';
             $template = '';
             $body = '';
             break;
         case 8:
             $to = '';
             $subject = '';
             $template = '';
             $body = '';
             break;
         */
         case 9:
             // Annulation photographer
             $templatePhotographer = 'MainCommonBundle:Emails\\Prestations\\Cancel\\Photographer:to_photographer.html.twig';
             $templateClient = 'MainCommonBundle:Emails\\Prestations\\Cancel\\Photographer:to_client.html.twig';
             $subjectPhotographer = $this->translator->trans('prestation.cancel.photographer.tophotographer.subject', array(), 'email');
             $subjectClient = $this->translator->trans('prestation.cancel.photographer.toclient.subject', array(), 'email');
             break;
         case 10:
             // Annulation client
             $templatePhotographer = 'MainCommonBundle:Emails\\Prestations\\Cancel\\Client:to_photographer.html.twig';
             $templateClient = 'MainCommonBundle:Emails\\Prestations\\Cancel\\Client:to_client.html.twig';
             $subjectPhotographer = $this->translator->trans('prestation.cancel.client.tophotographer.subject', array(), 'email');
             $subjectClient = $this->translator->trans('prestation.cancel.client.toclient.subject', array(), 'email');
             break;
         case 11:
             // Litige client
             $templatePhotographer = 'MainCommonBundle:Emails\\Prestations\\Litige\\Client:to_photographer.html.twig';
             $templateClient = 'MainCommonBundle:Emails\\Prestations\\Litige\\Client:to_client.html.twig';
             $subjectPhotographer = $this->translator->trans('prestation.litige.client.tophotographer.subject', array(), 'email');
             $subjectClient = $this->translator->trans('prestation.litige.client.toclient.subject', array(), 'email');
             break;
         case 12:
             // litige photographer
             $templatePhotographer = 'MainCommonBundle:Emails\\Prestations\\Litige\\Photographer:to_photographer.html.twig';
             $templateClient = 'MainCommonBundle:Emails\\Prestations\\Litige\\Photographer:to_client.html.twig';
             $subjectPhotographer = $this->translator->trans('prestation.litige.photographer.tophotographer.subject', array(), 'email');
             $subjectClient = $this->translator->trans('prestation.litige.photographer.toclient.subject', array(), 'email');
             break;
     }
     $from = self::EMAIL;
     if ($templatePhotographer && $sendToPhotographer) {
         $body = $this->templating->render($templatePhotographer, array('prestation' => $prestation, 'base_url' => $this->community));
         $this->sendMessage($from, $emailPhotographer, $subjectPhotographer, $body);
     }
     if ($templateClient && $sendToClient) {
         $body = $this->templating->render($templateClient, array('prestation' => $prestation, 'comments' => $comments, 'base_url' => $this->front));
         $this->sendMessage($from, $emailClient, $subjectClient, $body);
     }
 }
Exemplo n.º 3
0
 public function createPrestationNotification(Prestation $prestation)
 {
     $status = $prestation->getStatus()->getId();
     $photographer = $prestation->getDevis()->getCompany()->getPhotographer();
     $client = $prestation->getClient();
     switch ($status) {
         case 1:
             $to = $photographer;
             $subject = self::PRESTATION_CREEE;
             break;
         case 2:
             //PHOTOGRAPHER_OK
             $to = $client;
             $subject = self::PHOTOGRAPHER_OK;
             break;
         case 3:
             //Cancel-photographer
             $to = $client;
             $subject = self::PHOTOGRAPHER_KO;
             break;
         case 4:
             //Cancel-Client
             $to = $photographer;
             $subject = self::CLIENT_KO;
             break;
         case 5:
             //Valide
             $to = $photographer;
             $subject = self::PRESTATION_OK;
             break;
         case 6:
             $to = $photographer;
             $subject = self::OLD_PRESTATION;
             break;
         case 7:
             $to = $photographer;
             $subject = self::PHOTOS_DELIVERED;
             break;
         case 8:
             $to = $photographer;
             $subject = self::CLOSED_PRESTATION;
             break;
         case 9:
             $to = $client;
             $subject = self::CANCELED_PHOTOGRAPHER;
             break;
         case 10:
             $to = $photographer;
             $subject = self::CANCELED_CLIENT;
             break;
         case 11:
             $to = $photographer;
             $subject = self::LITIGE_CLIENT;
             break;
         case 12:
             $to = $client;
             $subject = self::LITIGE_PHOTOGRAPHER;
             break;
     }
     $notification = new Notification();
     $notification->setType(1);
     $notification->setPrestation($prestation);
     $notification->setContent($subject);
     $notification->setReceiver($to);
     try {
         $this->em->persist($notification);
         $this->em->flush();
     } catch (\Exception $e) {
         $this->session->errorFlashMessage();
         $this->logger->error($e->getMessage());
     }
 }
Exemplo n.º 4
0
 /**
  * 
  * @param unknown $id
  * @param unknown $slug
  * @return boolean
  */
 public function updatePrestation(Prestation $prestation, $slug)
 {
     switch ($slug) {
         case 2:
             if ($prestation->getStatus()->getId() == self::PRESTATION_ENCOURS) {
                 $status = $this->em->getRepository('MainCommonBundle:Status\\PrestationStatus')->findOneById(self::PHOTOGRAPHER_OK);
                 $flashMessage = 'flash.message.prestation.status.pre_approved';
             }
             break;
         case 3:
             //Cancel-photographer
             if ($prestation->getStatus()->getId() == self::PRESTATION_ENCOURS || $prestation->getStatus()->getId() == self::PHOTOGRAPHER_OK) {
                 $status = $this->em->getRepository('MainCommonBundle:Status\\PrestationStatus')->findOneById(self::PHOTOGRAPHER_KO);
                 $flashMessage = 'flash.message.prestation.status.index';
             }
             break;
         case 4:
             //Cancel-Client
             if ($prestation->getStatus()->getId() == self::PRESTATION_ENCOURS || $prestation->getStatus()->getId() == self::PHOTOGRAPHER_OK) {
                 $status = $this->em->getRepository('MainCommonBundle:Status\\PrestationStatus')->findOneById(self::CLIENT_KO);
                 $flashMessage = 'flash.message.prestation.status.index';
             }
             break;
         case 5:
             //Valide
             if ($prestation->getStatus()->getId() == self::PHOTOGRAPHER_OK) {
                 $status = $this->em->getRepository('MainCommonBundle:Status\\PrestationStatus')->findOneById(self::PRESTATION_OK);
                 $flashMessage = 'flash.message.prestation.status.index';
             }
             break;
         case 6:
             if ($prestation->getStatus()->getId() == self::PRESTATION_OK) {
                 $status = $this->em->getRepository('MainCommonBundle:Status\\PrestationStatus')->findOneById(self::OLD_PRESTATION);
                 $flashMessage = 'flash.message.prestation.status.index';
             }
             break;
         case 7:
             if ($prestation->getStatus()->getId() == self::OLD_PRESTATION) {
                 $status = $this->em->getRepository('MainCommonBundle:Status\\PrestationStatus')->findOneById(self::PHOTOS_DELIVERED);
                 $flashMessage = 'flash.message.prestation.status.index';
             }
             break;
         case 8:
             if ($prestation->getStatus()->getId() == self::PHOTOS_DELIVERED || $prestation->getStatus()->getId() == self::LITIGE_PHOTOGRAPHER || $prestation->getStatus()->getId() == self::LITIGE_CLIENT || $prestation->getStatus()->getId() == self::CANCELED_CLIENT || $prestation->getStatus()->getId() == self::CANCELED_PHOTOGRAPHER) {
                 $status = $this->em->getRepository('MainCommonBundle:Status\\PrestationStatus')->findOneById(self::CLOSED_PRESTATION);
                 $flashMessage = 'flash.message.prestation.status.index';
             }
             break;
     }
     $prestation->setStatus($status);
     $prestation->setUpdatedAt(new \DateTime('now'));
     try {
         $this->em->flush();
         //Envoi du mail
         $this->mailer->prestationUpdateEmail($prestation);
         $this->notification->createPrestationNotification($prestation);
         $this->session->successFlashMessage($flashMessage);
         return true;
     } catch (\Exception $e) {
         $this->session->errorFlashMessage();
         $this->logger->error($e->getMessage());
         return false;
     }
 }
Exemplo n.º 5
0
 /**
  * [get description]
  * @param  Prestation $prestation [description]
  * @return [type]                 [description]
  */
 public function get(Prestation $prestation)
 {
     return $this->repository->findOneByPrestation($prestation->getId());
 }