/** * * @param unknown $devis * @param unknown $town * @param unknown $day * @param unknown $address * @param unknown $startTime * @param unknown $message * @return boolean */ public function create($devis, $town, $day, $address, $startTime, $duration, $message) { $client = $this->getCurrentUser(); $town = $this->em->getRepository('MainCommonBundle:Geo\\Town')->findOneById($town); $address = $address; $status = $this->em->getRepository('MainCommonBundle:Status\\PrestationStatus')->findOneById(self::PRESTATION_ENCOURS); $devisPrice = $this->em->getRepository('MainCommonBundle:Photographers\\DevisPrices')->findOneBy(array('devis' => $devis->getId(), 'duration' => $duration)); $duration = $devisPrice->getDuration(); $price = $devisPrice->getPrice(); $start = str_replace('/', '-', $day) . ' ' . $startTime . ':00'; $startTime = new \DateTime($start); $commission = $this->serviceCommissionPrestation->generateCommission($devis); $prestation = new Prestation(); $prestation->setReference($this->reference->generateReference()); $prestation->setDevis($devis); $prestation->setRappel($devis->getPresentation()); $prestation->setClient($client); $prestation->setTown($town); $prestation->setPrice($price); $prestation->setAddress($address); $prestation->setStartTime($startTime); $prestation->setDuration($duration); $prestation->setStatus($status); $prestation->setCommission($commission); try { $this->em->persist($prestation); $this->CreateMessage($prestation, $client, $devis->getCompany()->getPhotographer(), 1, $message); $this->em->flush(); $this->mailer->prestationUpdateEmail($prestation); $this->notification->createPrestationNotification($prestation); return $prestation; } catch (\Exception $e) { $this->session->errorFlashMessage(); $this->logger->error($e->getMessage()); return false; } }