<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
*
* http://www.lockon.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Customize\Controller;
use Eccube\Controller\AbstractController;
use Eccube\Entity\Customer;
use Eccube\Event\EccubeEvents;
use Eccube\Event\EventArgs;
use Customize\Form\Type\Front\ExperiencesType;
use Customize\Service\MailService;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class ExperiencesController extends AbstractController
{
/**
* @var MailService
*/
protected $mailService;
/**
* ExperiencesController constructor.
*
* @param MailService $mailService
*/
public function __construct(
MailService $mailService)
{
$this->mailService = $mailService;
}
/**
* お問い合わせ画面.
*
* @Route("/experiences", name="experiences")
* @Template("Experiences/index.twig")
*/
public function index(Request $request)
{
$builder = $this->formFactory->createBuilder(ExperiencesType::class);
// FRONT_CONTACT_INDEX_INITIALIZE
// 今回はイベントを発生させないようにする。
// $event = new EventArgs(
// [
// 'builder' => $builder,
// ],
// $request
// );
// $this->eventDispatcher->dispatch(EccubeEvents::FRONT_CONTACT_INDEX_INITIALIZE, $event);
$form = $builder->getForm();
$form->handleRequest($request);
return [
'form' => $form->createView(),
];
}
/**
* お問い合わせ確認画面.
*
* @Route("/experiences/confirm", name="experiences_confirm")
* @Template("Experiences/confirm.twig")
*/
public function confirm(Request $request)
{
$postData = array();
$postData["entry_type"] = $_POST["entry_type"];
$postData["name"] = $_POST["name"];
$postData["kana"] = $_POST["kana"];
$postData["tel01"] = $_POST["tel01"];
$postData["tel02"] = $_POST["tel02"];
$postData["tel03"] = $_POST["tel03"];
$postData["email"] = $_POST["email"];
return [
'postData' => $postData,
];
}
/**
* お問い合わせ完了画面.
*
* @Route("/experiences/complete", name="experiences_complete")
* @Template("Experiences/complete.twig")
*/
public function complete(Request $request)
{
$postData = array();
$postData["entry_type"] = $_POST["entry_type"];
$postData["name"] = $_POST["name"];
$postData["kana"] = $_POST["kana"];
$postData["tel01"] = $_POST["tel01"];
$postData["tel02"] = $_POST["tel02"];
$postData["tel03"] = $_POST["tel03"];
$postData["email"] = $_POST["email"];
$subject = "こころね農園農業体験申し込み";
$content = "※本メールは自動配信メールです。" . "\r\n";
$content .= "\r\n";
$content .= "┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓" . "\r\n";
$content .= " ※本メールは、" . "\r\n";
$content .= " こころね農園よりお問い合わせされた方に" . "\r\n";
$content .= " お送りしています。" . "\r\n";
$content .= " もしお心当たりが無い場合は、" . "\r\n";
$content .= " その旨info@kokorone-san.com まで" . "\r\n";
$content .= " ご連絡いただければ幸いです。" . "\r\n";
$content .= "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛" . "\r\n";
$content .= $postData["name"] . "様";
$content .= "以下のお問い合わせを受付致しました。" . "\r\n";
$content .= "確認次第ご連絡いたしますので、少々お待ちください。" . "\r\n";
$content .= "お問合せ種別:" . $postData["entry_type"] . "\r\n";
$content .= "お名前:" . $postData["name"] . "\r\n";
$content .= "ふりがな:" . $postData["kana"] . "\r\n";
$content .= "電話番号:" . $postData["tel01"] . "-" . $postData["tel02"] . "-" .$postData["tel03"] . "\r\n";
$content .= "メールアドレス:" . $postData["email"] . "\r\n";
$MailAddress = "uda@beq.co.jp";
mb_language("Japanese");
mb_internal_encoding ("UTF-8");
mb_send_mail($MailAddress,$subject,$content,'FROM:'.$postData["email"]);
$content = mb_convert_encoding( $content, mb_internal_encoding(), "UTF-8" );
$from = mb_convert_encoding( "こころね農園", "JIS", "UTF-8" );
$from = "From:=?ISO-2022-JP?B?" . base64_encode($from) . "?= <$MailAddress>";
mb_send_mail($postData["email"],$subject,$content,$from);
return [
'postData' => $postData,
];
}
}