예제 #1
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $inquiry1 = new Inquiry();
     $inquiry1->setName('フランツ・クサーヴァー・モーツァルト');
     $inquiry1->setEmail('*****@*****.**');
     $inquiry1->setTel('000-1111-2222');
     $inquiry1->setType(0);
     $inquiry1->setContent('私の作った曲を演奏していただけませんか?');
     $inquiry1->setProcessStatus(1);
     $inquiry1->setProcessMemo('返信済');
     $manager->persist($inquiry1);
     $inquiry2 = new Inquiry();
     $inquiry2->setName('ニコロ・パガニーニ');
     $inquiry2->setEmail('*****@*****.**');
     $inquiry2->setTel('012-1111-3333');
     $inquiry2->setType(1);
     $inquiry2->setContent('バイオリンパートの奏者として応募したいのですが、選考はいつ行っていますか?私は今月末頃なら東京に滞在しています。');
     $inquiry2->setProcessStatus(0);
     $manager->persist($inquiry2);
     $inquiry3 = new Inquiry();
     $inquiry3->setName('ニコロ・パガニーニ3');
     $inquiry3->setEmail('*****@*****.**');
     $inquiry3->setTel('012-1111-4444');
     $inquiry3->setType(1);
     $inquiry3->setContent('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
     $inquiry3->setProcessStatus(0);
     $manager->persist($inquiry3);
     $manager->flush();
 }
 /**
  * @test
  */
 public function CSVが正しく作られること()
 {
     $inquiry1 = new Inquiry();
     $inquiry1->setId(1);
     $inquiry1->setName('テストあいうえお');
     $inquiry1->setEmail('*****@*****.**');
     $inquiry2 = new Inquiry();
     $inquiry2->setId(2);
     $inquiry2->setName('テストかきくけこ');
     $inquiry2->setEmail('*****@*****.**');
     $inquiryCollection = new ArrayCollection([$inquiry1, $inquiry2]);
     $this->inquiryRepository->expects($this->once())->method('findAllByKeyword')->willReturn($inquiryCollection);
     $result = $this->SUT->build('テスト');
     $expected = "1,テストあいうえお,aiu@example.com\r\n" . "2,テストかきくけこ,keko@example.com\r\n";
     $this->assertThat($result, $this->equalTo($expected));
 }
예제 #3
0
 /**
  * @Route("/booking/inquiry/{id}/{dateFrom}/{dateTo}", name="booking-inquiry")
  */
 public function inquiryAction(Request $request, $id, $dateFrom, $dateTo)
 {
     $loggedIn = $this->get('security.context')->isGranted('IS_AUTHENTICATED_REMEMBERED');
     // user logged in
     $eq = $this->getDoctrineRepo('AppBundle:Equipment')->find($id);
     // init/calculate inquiry details
     //<editor-fold>
     $from = DateTime::createFromFormat('Y-m-d\\TH:i+', $dateFrom);
     $to = DateTime::createFromFormat('Y-m-d\\TH:i+', $dateTo);
     $days = $to->diff($from)->days;
     $price = ($days + 1) * $eq->getPrice();
     $inquiry = array('from' => $from, 'to' => $to, 'days' => $days, 'price' => $price, 'whereabouts' => $eq->getWhereaboutsAsString());
     //</editor-fold>
     // build form
     //<editor-fold>
     $url = $this->generateUrl('booking-inquiry', array('id' => $id, 'dateFrom' => $dateFrom, 'dateTo' => $dateTo));
     $builder = $this->createFormBuilder()->setAction($url);
     if (!$loggedIn) {
         $builder->add('name', 'text', array('attr' => array('max-length' => 128), 'constraints' => array(new NotBlank(), new Length(array('max' => 128)))))->add('email', 'email', array('attr' => array('max-length' => 128), 'constraints' => array(new NotBlank(), new Length(array('max' => 128)), new Email(array('checkHost' => true)))));
     }
     $builder->add('message', 'textarea', array('constraints' => array(new NotBlank())));
     $form = $builder->getForm();
     //</editor-fold>
     $form->handleRequest($request);
     if ($form->isValid()) {
         $data = $form->getData();
         $inq = new Inquiry();
         // map fields & save
         //<editor-fold>
         $inq->setEquipment($eq);
         if (!$loggedIn) {
             $inq->setName($data['name']);
             $inq->setEmail($data['email']);
         } else {
             $inq->setUser($this->getUser());
         }
         $inq->setMessage($data['message']);
         $inq->setFromAt($inquiry['from']);
         $inq->setToAt($inquiry['to']);
         $inq->setPrice($inquiry['price']);
         $inq->setDeposit($eq->getDeposit());
         $inq->setPriceBuy($eq->getPriceBuy());
         // TODO: filter out any contact data from the message (phone, email)
         $em = $this->getDoctrine()->getManager();
         $em->persist($inq);
         $em->flush();
         //</editor-fold>
         // send email
         //<editor-fold>
         // prepare params
         $provider = $eq->getUser();
         $url = $request->getSchemeAndHttpHost() . $this->generateUrl('booking-response', array('id' => $inq->getId()));
         $from = array($this->getParameter('mailer_fromemail') => $this->getParameter('mailer_fromname'));
         $emailHtml = $this->renderView('Emails/inquiry.html.twig', array('mailer_image_url_prefix' => $this->getParameter('mailer_image_url_prefix'), 'provider' => $provider, 'inquiry' => $inq, 'equipment' => $eq, 'url' => $url));
         $message = Swift_Message::newInstance()->setSubject('Du hast soeben eine Anfrage erhalten')->setFrom($from)->setTo($provider->getEmail())->setBody($emailHtml, 'text/html');
         $this->get('mailer')->send($message);
         //</editor-fold>
         return new JsonResponse(array('status' => 'ok'));
     }
     return $this->render('booking/inquiry.html.twig', array('loggedIn' => $loggedIn, 'inquiry' => $inquiry, 'form' => $form->createView(), 'equipment' => $eq));
 }