app/Customize/Controller/ExperiencesController.php line 74

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of EC-CUBE
  4.  *
  5.  * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
  6.  *
  7.  * http://www.lockon.co.jp/
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Customize\Controller;
  13. use Eccube\Controller\AbstractController;
  14. use Eccube\Entity\Customer;
  15. use Eccube\Event\EccubeEvents;
  16. use Eccube\Event\EventArgs;
  17. use Customize\Form\Type\Front\ExperiencesType;
  18. use Customize\Service\MailService;
  19. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  20. use Symfony\Component\HttpFoundation\Request;
  21. use Symfony\Component\Routing\Annotation\Route;
  22. class ExperiencesController extends AbstractController
  23. {
  24.     /**
  25.      * @var MailService
  26.      */
  27.     protected $mailService;
  28.     /**
  29.      * ExperiencesController constructor.
  30.      *
  31.      * @param MailService $mailService
  32.      */
  33.     public function __construct(
  34.         MailService $mailService)
  35.     {
  36.         $this->mailService $mailService;
  37.     }
  38.     /**
  39.      * お問い合わせ画面.
  40.      *
  41.      * @Route("/experiences", name="experiences")
  42.      * @Template("Experiences/index.twig")
  43.      */
  44.     public function index(Request $request)
  45.     {
  46.         $builder $this->formFactory->createBuilder(ExperiencesType::class);
  47.         // FRONT_CONTACT_INDEX_INITIALIZE
  48.         // 今回はイベントを発生させないようにする。
  49.         // $event = new EventArgs(
  50.         //     [
  51.         //         'builder' => $builder,
  52.         //     ],
  53.         //     $request
  54.         // );
  55.         // $this->eventDispatcher->dispatch(EccubeEvents::FRONT_CONTACT_INDEX_INITIALIZE, $event);
  56.         $form $builder->getForm();
  57.         $form->handleRequest($request);
  58.         return [
  59.             'form' => $form->createView(),
  60.         ];
  61.     }
  62.     /**
  63.      * お問い合わせ確認画面.
  64.      *
  65.      * @Route("/experiences/confirm", name="experiences_confirm")
  66.      * @Template("Experiences/confirm.twig")
  67.      */
  68.     public function confirm(Request $request)
  69.     {
  70.         $postData = array();
  71.         $postData["entry_type"] = $_POST["entry_type"];
  72.         $postData["name"] = $_POST["name"];
  73.         $postData["kana"] = $_POST["kana"];
  74.         $postData["tel01"] = $_POST["tel01"];
  75.         $postData["tel02"] = $_POST["tel02"];
  76.         $postData["tel03"] = $_POST["tel03"];
  77.         $postData["email"] = $_POST["email"];
  78.         return [
  79.             'postData' => $postData,
  80.         ];
  81.     }
  82.     /**
  83.      * お問い合わせ完了画面.
  84.      *
  85.      * @Route("/experiences/complete", name="experiences_complete")
  86.      * @Template("Experiences/complete.twig")
  87.      */
  88.     public function complete(Request $request)
  89.     {
  90.         $postData = array();
  91.         $postData["entry_type"] = $_POST["entry_type"];
  92.         $postData["name"] = $_POST["name"];
  93.         $postData["kana"] = $_POST["kana"];
  94.         $postData["tel01"] = $_POST["tel01"];
  95.         $postData["tel02"] = $_POST["tel02"];
  96.         $postData["tel03"] = $_POST["tel03"];
  97.         $postData["email"] = $_POST["email"];
  98.         $subject "こころね農園農業体験申し込み";
  99.         $content "※本メールは自動配信メールです。" "\r\n";
  100.         $content .= "\r\n";
  101.         $content .= "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓" "\r\n";
  102.         $content .= " ※本メールは、" "\r\n";
  103.         $content .= " こころね農園よりお問い合わせされた方に" "\r\n";
  104.         $content .= " お送りしています。" "\r\n";
  105.         $content .= " もしお心当たりが無い場合は、" "\r\n";
  106.         $content .= " その旨info@kokorone-san.com まで" "\r\n";
  107.         $content .= " ご連絡いただければ幸いです。" "\r\n";
  108.         $content .= "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛" "\r\n";
  109.         $content .= $postData["name"] .  "様";
  110.         $content .= "以下のお問い合わせを受付致しました。" "\r\n";
  111.         $content .= "確認次第ご連絡いたしますので、少々お待ちください。" "\r\n";
  112.         $content .= "お問合せ種別:" $postData["entry_type"] . "\r\n";
  113.         $content .= "お名前:" $postData["name"] . "\r\n";
  114.         $content .= "ふりがな:" $postData["kana"] . "\r\n";
  115.         $content .= "電話番号:" $postData["tel01"] . "-" $postData["tel02"] . "-" .$postData["tel03"]    . "\r\n";
  116.         $content .= "メールアドレス:" $postData["email"] . "\r\n";
  117.         $MailAddress "uda@beq.co.jp";
  118.         mb_language("Japanese");
  119.         mb_internal_encoding ("UTF-8");
  120.         mb_send_mail($MailAddress,$subject,$content,'FROM:'.$postData["email"]);
  121.         $content mb_convert_encoding$contentmb_internal_encoding(), "UTF-8" );
  122.         $from mb_convert_encoding"こころね農園""JIS""UTF-8" );
  123.         $from "From:=?ISO-2022-JP?B?" base64_encode($from) . "?= <$MailAddress>";
  124.         mb_send_mail($postData["email"],$subject,$content,$from);
  125.         return [
  126.             'postData' => $postData,
  127.         ];
  128.     }
  129. }