app/Customize/Controller/custumPageController.php line 780

Open in your IDE?
  1. <?php
  2. namespace Customize\Controller;
  3. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  4. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Doctrine\ORM\Query\ResultSetMapping;
  7. /* add */
  8. use Eccube\Controller\AbstractController;
  9. use Eccube\Entity\Product;
  10. use Eccube\Repository\CustomerRepository;
  11. use Eccube\Common\EccubeConfig;
  12. use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
  13. use Eccube\Service\MailService;
  14. use Eccube\Service\TeikiService;
  15. /* add2 reminde */
  16. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  17. use Eccube\Form\Type\Front\ForgotType;
  18. use Eccube\Form\Type\Front\PasswordResetType;
  19. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  20. use Eccube\Form\Type\SearchProductType;
  21. use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
  22. use Symfony\Component\HttpFoundation\Request;
  23. use Eccube\Form\Type\AddCartType;
  24. use Eccube\Event\EventArgs;
  25. use Eccube\Event\EccubeEvents;
  26. use Eccube\Repository\BaseInfoRepository;
  27. use Google_Client;
  28. use Google_Service_Calendar;
  29. use Google_Service_Calendar_Event;
  30. use Eccube\Form\Type\Front\PhotoType;
  31. use Carbon\Carbon;
  32. class custumPageController extends AbstractController
  33. {
  34.     protected $BaseInfo;
  35.     protected $customerRepository;
  36.     protected $mailService;
  37.     /**
  38.      * SamplePageController constructor.
  39.      * @param \Eccube\Repository\BaseInfoRepository $baseInfoRepository
  40.      * @param \Eccube\Repository\CustomerRepository $customerRepository
  41.      * @param \Eccube\Service\MailService $mailService
  42.      */
  43.     public function __construct(
  44.         \Eccube\Repository\BaseInfoRepository $baseInfoRepository,
  45.         \Eccube\Repository\CustomerRepository $customerRepository,
  46.         \Eccube\Service\MailService $mailService,
  47.         )
  48.     {
  49.         $this->BaseInfo $baseInfoRepository->get();
  50.         $this->customerRepository $customerRepository;
  51.         $this->mailService $mailService;
  52.     }
  53.     /**
  54.     * @Route("/products", name="product", methods={"GET"})
  55.     * @Template("Product/index.twig")
  56.     */
  57.     public function product()
  58.     {
  59.         try {
  60.     
  61.             //DBコネクション
  62.             $conn $this->entityManager->getConnection();
  63.             //お気に入り情報
  64.             $query =<<<__LONG_STRRING__
  65.                 SELECT dtb_product.id,dtb_product.name,    t2.file_name,dtb_product.item14,dtb_product.item19,dtb_product.item22, dtb_product.search_word,dtb_product.item16 FROM dtb_product
  66.                 left join (select product_id, file_name  from dtb_product_image where (product_id, sort_no ) in (select  product_id ,min(sort_no) as price from dtb_product_image group by product_id)) t2 on dtb_product.id =t2.product_id
  67.             __LONG_STRRING__;
  68.             //SQL実行
  69. //            $stmt = $conn->prepare($query);
  70.             $stmt $conn->query($query);
  71.             $rows $stmt->fetchAll();
  72.             $products=[];
  73.             foreach($rows as $val) {
  74.                 $products[$val['id']]=$val;
  75.             }
  76.             //返却値
  77.             return [
  78.                 'products' => $products,
  79.             ];
  80.         } catch (\Exception $e) {
  81. //            log_error('getFavorites Exception: ',  $e->getMessage());
  82.             return [
  83.                 'testtest' => $e->getMessage(),
  84.             ];
  85.         }
  86.     }
  87.     /**
  88.     * @Route("/photo", name="photo", methods={"GET"})
  89.     * @Template("Photo/index.twig")
  90.     */
  91.     public function photo()
  92.     {
  93.         try {
  94.             //DBコネクション
  95.             $conn $this->entityManager->getConnection();
  96.             //お気に入り情報
  97.             $query =<<<__LONG_STRRING__
  98.                 SELECT dtb_product.id,dtb_product.name,    t2.file_name, dtb_product.item13, dtb_product.item14 FROM dtb_product
  99.                 left join (select product_id, file_name  ,min(sort_no)  from dtb_product_image group by product_id) t2 on dtb_product.id =t2.product_id
  100.             __LONG_STRRING__;
  101.             //SQL実行
  102.             $stmt $conn->query($query);
  103.             $rows $stmt->fetchAll();
  104.             $products=[];
  105.             foreach($rows as $val) {
  106.                 $products[$val['id']]=$val;
  107.             }
  108.             //返却値
  109.             $timemin=2;
  110.             return [
  111.                 'products' => $products,
  112.                 'calendar_start_date' => date('Y-m-d'strtotime('+'.$timemin.'day')),
  113.                 'calendar_end_date' => date('Y-m-d'strtotime('+3 month')),
  114.             ];
  115.         } catch (\Exception $e) {
  116.             return [
  117.                 'testtest' => $e->getMessage(),
  118.             ];
  119.         }
  120.     }
  121.     /**
  122.      * @Route("/photo/reserved", name="photo_reserved", methods={"POST"})
  123.      * @Template("Photo/reserved.twig")
  124.      */
  125.     public function photoReserved()
  126.     {
  127.         try {
  128.             // カレンダーID
  129.             $calendarId $_POST['calendarId'];
  130.             $aimJsonPath './ornate-axiom-406706-fd999b268a9d.json';
  131.             // サービスオブジェクトを作成
  132.             $client = new Google_Client();
  133.             // このアプリケーション名
  134.             $client->setApplicationName('カレンダー操作テスト イベントの取得');
  135.             // ※ 注意ポイント: 権限の指定
  136.             // 予定を取得する時は Google_Service_Calendar::CALENDAR_READONLY
  137.             // 予定を追加する時は Google_Service_Calendar::CALENDAR_EVENTS
  138.             $client->setScopes(Google_Service_Calendar::CALENDAR_EVENTS);
  139.             // ユーザーアカウントのjsonを指定
  140.             $client->setAuthConfig($aimJsonPath);
  141.             // サービスオブジェクトの用意
  142.             $service = new Google_Service_Calendar($client);
  143.             $start_datetime = new Carbon($_POST['date'].' '.$_POST['starttime']);
  144.             $end_datetime = new Carbon($_POST['date'].' '.$_POST['starttime']);
  145.             $end_datetime->addHour(2);
  146.             $shootinglocation=$_POST['shootinglocation'];
  147.             if(!$shootinglocation) {
  148.                 $shootinglocation=$_POST['shootinglocationname'];
  149.             }
  150.             $description "日時:".$_POST['date'].' '.$_POST['starttime'];
  151.             $description .= "<br>name:".$_POST['name'];
  152.             $description .= "<br>Country:".$_POST['country'];
  153.             $description .= "<br>mail:".$_POST['email'];
  154.             $description .= "<br>tel:".$_POST['tel'];
  155.             $description .= "<br>参加人数:".$_POST['participants'];
  156.             $description .= "<br>集合場所:".$_POST['pickup'];
  157.             $description .= "<br>撮影場所:".$shootinglocation;
  158.             $description .= "<br>体験運転:".$_POST['experience'];
  159.             $description .= "<br>コメント:".$_POST['message'];
  160.             $event = new Google_Service_Calendar_Event(array(
  161.                 'summary' => "name:".$_POST['name'],
  162.                 'start' => array(
  163.                     'dateTime' => $start_datetime,
  164.                     'timeZone' => 'Asia/Tokyo',
  165.                 ),
  166.                 'end' => array(
  167.                     'dateTime' => $end_datetime,
  168.                     'timeZone' => 'Asia/Tokyo',
  169.                 ),
  170.                 'description' => $description,
  171.             ));
  172.             $event $service->events->insert($calendarId$event);
  173.             $this->mailService->sendReserveRequest($_POST,10);
  174.             return [
  175.             ];
  176.         } catch (\Exception $e) {
  177.             return [
  178.                 'testtest' => $e->getMessage(),
  179.             ];
  180.         }
  181.     }
  182.     /**
  183.      * 商品詳細画面.
  184.      *
  185.      * @Route("/photo/detail/{id}", name="photo_detail", methods={"GET"}, requirements={"id" = "\d+"})
  186.      * @Template("Photo/detail.twig")
  187.      * @ParamConverter("Photo", options={"repository_method" = "findWithSortedClassCategories"})
  188.      *
  189.      * @param Request $request
  190.      * @param Product $Product
  191.      *
  192.      * @return array
  193.      */
  194.     public function detail(Request $requestProduct $Product)
  195.     {
  196.         if (!$this->checkVisibility($Product)) {
  197.             throw new NotFoundHttpException();
  198.         }
  199.         //----------------------------------
  200.         //ここから下はカレンダー 
  201.         //----------------------------------
  202.         // サービスオブジェクトを作成
  203.         $client = new Google_Client();
  204.         // サービスアカウント作成時にダウンロードしたjsonファイル
  205.         $aimJsonPath './ornate-axiom-406706-fd999b268a9d.json';
  206.         // サービスオブジェクトを作成
  207.         $client = new Google_Client();
  208.         // このアプリケーション名
  209.         $client->setApplicationName('カレンダー操作テスト イベントの取得');
  210.         // ※ 注意ポイント: 権限の指定
  211.         // 予定を取得する時は Google_Service_Calendar::CALENDAR_READONLY
  212.         // 予定を追加する時は Google_Service_Calendar::CALENDAR_EVENTS
  213.         $client->setScopes(Google_Service_Calendar::CALENDAR_READONLY);
  214.         // ユーザーアカウントのjsonを指定
  215.         $client->setAuthConfig($aimJsonPath);
  216.         // サービスオブジェクトの用意
  217.         $service = new Google_Service_Calendar($client);
  218.         // カレンダーID
  219.         // 商品マスタから取得
  220.         $calendarId '4f27c24687328a69f1c56a92418269c0eec7b0cbf324dfebdd66b1468b16e540@group.calendar.google.com';
  221.         if($Product->getItem13()) {
  222.             $calendarId $Product->getItem13();
  223.         }
  224.         // 取得時の詳細設定
  225.         // 日付を最短
  226.         $timemin=1;
  227.         if($Product->getItem15()) {
  228.             $timemin=$Product->getItem15()-1;
  229.         }
  230.         $optParams = array(
  231.             'orderBy' => 'startTime',
  232.             'singleEvents' => true,
  233.             'timeMax' => date('c',strtotime("+3 month")),    //3か月分
  234.             'timeMin' => date('c'strtotime('+'.$timemin.' day')),    //1週間後から
  235.         );
  236.         $results $service->events->listEvents($calendarId$optParams);
  237.         //書式設定
  238.         $res=[];
  239.         foreach( $results->getItems() as $event) {
  240. //            $tDate=date('Y-m-d',strtotime($start = $event->start->dateTime));
  241. //            $tDate=date('Y-m-d',strtotime($start = $event->end->dateTime));
  242.             for($i=date('Ymd'strtotime$event->start->dateTime)); $i<=date('Ymd'strtotime($event->end->dateTime)); $i++){
  243.                 $year substr($i0,4);
  244.                 $month substr($i4,2);
  245.                 $day substr($i6,2);
  246.                 if(checkdate $month $day $year )) {
  247.                     $tmp=date('Y-m-d'strtotime($i));
  248.                     $res[$tmp] = $tmp;
  249.                 }
  250.             }
  251. //            $res[$tDate][]=date('H',strtotime($start = $event->start->dateTime));
  252. //            $res[$tDate][]=date('H',strtotime($start = $event->end->dateTime));
  253.         }
  254.         //フロントカレンダー用に+1日する。
  255.         $timemin+=1;
  256.         return [
  257.             'title' => $Product->getName(),
  258.             'subtitle' => $Product->getName(),
  259.             'Product' => $Product,
  260.             'events' => json_encode($res),
  261.             'calendar_start_date' => date('Y-m-d'strtotime('+'.$timemin.'day')),
  262.         ];
  263.     }
  264.     /**
  265.     * @Route("/drive", name="drive", methods={"GET"})
  266.     * @Template("Drive/index.twig")
  267.     */
  268.     public function drive()
  269.     {
  270.         try {
  271.             //DBコネクション
  272.             $conn $this->entityManager->getConnection();
  273.             //お気に入り情報
  274.             $query =<<<__LONG_STRRING__
  275.                 SELECT dtb_product.id,dtb_product.name,    t2.file_name, dtb_product.item13, dtb_product.item14, dtb_product.search_word FROM dtb_product
  276.                 left join (select product_id, file_name  from dtb_product_image where (product_id, sort_no ) in (select  product_id ,min(sort_no) as price from dtb_product_image group by product_id)) t2 on dtb_product.id =t2.product_id
  277.             __LONG_STRRING__;
  278.             //SQL実行
  279.             $stmt $conn->query($query);
  280.             $rows $stmt->fetchAll();
  281.             $products=[];
  282.             foreach($rows as $val) {
  283.                 $products[$val['id']]=$val;
  284.             }
  285.             //返却値
  286.             $timemin=2;
  287.             return [
  288.                 'products' => $products,
  289.                 'calendar_start_date' => date('Y-m-d'strtotime('+'.$timemin.'day')),
  290.                 'calendar_end_date' => date('Y-m-d'strtotime('+3 month')),
  291.             ];
  292.         } catch (\Exception $e) {
  293.             return [
  294.                 'testtest' => $e->getMessage(),
  295.             ];
  296.         }
  297.     }
  298.     /**
  299.      * @Route("/drive/reserved", name="drive_reserved", methods={"POST"})
  300.      * @Template("Drive/reserved.twig")
  301.      */
  302.     public function driveReserved()
  303.     {
  304.         try {
  305.             // カレンダーID
  306.             $calendarId $_POST['calendarId'];
  307.             $aimJsonPath './ornate-axiom-406706-fd999b268a9d.json';
  308.             if($calendarId) {
  309.                 // サービスオブジェクトを作成
  310.                 $client = new Google_Client();
  311.                 // このアプリケーション名
  312.                 $client->setApplicationName('カレンダー操作テスト イベントの取得');
  313.                 // ※ 注意ポイント: 権限の指定
  314.                 // 予定を取得する時は Google_Service_Calendar::CALENDAR_READONLY
  315.                 // 予定を追加する時は Google_Service_Calendar::CALENDAR_EVENTS
  316.                 $client->setScopes(Google_Service_Calendar::CALENDAR_EVENTS);
  317.                 // ユーザーアカウントのjsonを指定
  318.                 $client->setAuthConfig($aimJsonPath);
  319.                 // サービスオブジェクトの用意
  320.                 $service = new Google_Service_Calendar($client);
  321.                 $start_datetime = new Carbon($_POST['date'].' '.$_POST['starttime']);
  322.                 $end_datetime = new Carbon($_POST['date'].' '.$_POST['starttime']);
  323.                 $end_datetime->addHour($_POST['time']);
  324.                 $shootinglocation=$_POST['shootinglocation'];
  325.                 if(!$shootinglocation) {
  326.                     $shootinglocation=$_POST['shootinglocationname'];
  327.                 }
  328.                 
  329.                 log_info('driveReserved 開始1-1');
  330.                 $description "日時:".$_POST['date'].' '.$_POST['starttime'];
  331.                 $description "Car Experience time:".$_POST['time'];
  332.                 $description .= "<br>name:".$_POST['name'];
  333.                 $description .= "<br>Country:".$_POST['country'];
  334.                 log_info('driveReserved 開始1-2');
  335.                 $description .= "<br>mail:".$_POST['email'];
  336.                 $description .= "<br>tel:".$_POST['tel'];
  337.                 $description .= "<br>参加人数:".$_POST['participants'];
  338.                 $description .= "<br>集合場所:".$_POST['pickup'];
  339.                 log_info('driveReserved 開始1-3');
  340.                 $description .= "<br>Desired Prefix Menu:".$shootinglocation;
  341.                 $description .= "<br>Photo Shoot Option by photographer:".$_POST['option'];
  342.                 $description .= "<br>コメント:".$_POST['message'];
  343.                 log_info('driveReserved 開始1-4');
  344.                 $event = new Google_Service_Calendar_Event(array(
  345.                     'summary' => "name:".$_POST['name'],
  346.                     'start' => array(
  347.                         'dateTime' => $start_datetime,
  348.                         'timeZone' => 'Asia/Tokyo',
  349.                     ),
  350.                     'end' => array(
  351.                         'dateTime' => $end_datetime,
  352.                         'timeZone' => 'Asia/Tokyo',
  353.                     ),
  354.                     'description' => $description,
  355.                 ));
  356.                 log_info('driveReserved 開始1-5');
  357.                 $event $service->events->insert($calendarId$event);
  358.             }
  359.             //メール送信、12は「dtb_mail_template」のID
  360.             log_info('driveReserved 開始2-1');
  361.             $this->mailService->sendReserveRequest($_POST,12);
  362.             return [
  363.             ];
  364.         } catch (\Exception $e) {
  365.             log_info('driveReserved Exception');
  366.             return [
  367.                 'testtest' => $e->getMessage(),
  368.             ];
  369.         }
  370.     }
  371.     /**
  372.      * 商品詳細画面.
  373.      *
  374.      * @Route("/drive/detail/{id}", name="drive_detail", methods={"GET"}, requirements={"id" = "\d+"})
  375.      * @Template("Drive/detail.twig")
  376.      * @ParamConverter("Drive", options={"repository_method" = "findWithSortedClassCategories"})
  377.      *
  378.      * @param Request $request
  379.      * @param Product $Product
  380.      *
  381.      * @return array
  382.      */
  383.     public function driveDetail(Request $requestProduct $Product)
  384.     {
  385.         if (!$this->checkVisibility($Product)) {
  386.             throw new NotFoundHttpException();
  387.         }
  388.         //----------------------------------
  389.         //ここから下はカレンダー 
  390.         //----------------------------------
  391.         // サービスオブジェクトを作成
  392.         $client = new Google_Client();
  393.         // サービスアカウント作成時にダウンロードしたjsonファイル
  394.         $aimJsonPath './ornate-axiom-406706-fd999b268a9d.json';
  395.         // サービスオブジェクトを作成
  396.         $client = new Google_Client();
  397.         // このアプリケーション名
  398.         $client->setApplicationName('カレンダー操作テスト イベントの取得');
  399.         // ※ 注意ポイント: 権限の指定
  400.         // 予定を取得する時は Google_Service_Calendar::CALENDAR_READONLY
  401.         // 予定を追加する時は Google_Service_Calendar::CALENDAR_EVENTS
  402.         $client->setScopes(Google_Service_Calendar::CALENDAR_READONLY);
  403.         // ユーザーアカウントのjsonを指定
  404.         $client->setAuthConfig($aimJsonPath);
  405.         // サービスオブジェクトの用意
  406.         $service = new Google_Service_Calendar($client);
  407.         // カレンダーID
  408.         // 商品マスタから取得
  409.         $calendarId '4f27c24687328a69f1c56a92418269c0eec7b0cbf324dfebdd66b1468b16e540@group.calendar.google.com';
  410.         if($Product->getItem13()) {
  411.             $calendarId $Product->getItem13();
  412.         }
  413.         // 取得時の詳細設定
  414.         // 日付を最短
  415.         $timemin=1;
  416.         if($Product->getItem15()) {
  417.             $timemin=$Product->getItem15()-1;
  418.         }
  419.         $optParams = array(
  420.             'orderBy' => 'startTime',
  421.             'singleEvents' => true,
  422.             'timeMax' => date('c',strtotime("+3 month")),
  423.         );
  424.         $results $service->events->listEvents($calendarId$optParams);
  425.         //書式設定
  426.         $res=[];
  427.         foreach( $results->getItems() as $event) {
  428. //            $tDate=date('Y-m-d',strtotime($start = $event->start->dateTime));
  429. //            $tDate=date('Y-m-d',strtotime($start = $event->end->dateTime));
  430.             for($i=date('Ymd'strtotime$event->start->dateTime)); $i<=date('Ymd'strtotime($event->end->dateTime)); $i++){
  431.                 $year substr($i0,4);
  432.                 $month substr($i4,2);
  433.                 $day substr($i6,2);
  434.                 if(checkdate $month $day $year )) {
  435.                     $tmp=date('Y-m-d'strtotime($i));
  436.                     $res[$tmp] = $tmp;
  437.                 }
  438.             }
  439. //            $res[$tDate][]=date('H',strtotime($start = $event->start->dateTime));
  440. //            $res[$tDate][]=date('H',strtotime($start = $event->end->dateTime));
  441.         }
  442.         //フロントカレンダー用に+1日する。
  443.         $timemin+=1;
  444.         return [
  445.             'title' => $Product->getName(),
  446.             'subtitle' => $Product->getName(),
  447.             'Product' => $Product,
  448.             'events' => json_encode($res),
  449.             'calendar_start_date' => date('Y-m-d'strtotime('+'.$timemin.'day')),
  450.         ];
  451.     }
  452.     /**
  453.     * @Route("/rental", name="rental", methods={"GET"})
  454.     * @Template("Rental/index.twig")
  455.     */
  456.     public function rental()
  457.     {
  458.         try {
  459.             //DBコネクション
  460.             $conn $this->entityManager->getConnection();
  461.             //お気に入り情報
  462.             $query =<<<__LONG_STRRING__
  463.                 SELECT dtb_product.id,dtb_product.name,    t2.file_name, dtb_product.item11, dtb_product.item13, dtb_product.item14, dtb_product.item18, dtb_product.item17, dtb_product.item16, dtb_product.item19,dtb_product.item22,t3.category_id,dtb_product.search_word FROM dtb_product
  464.                 left join (select product_id, file_name  from dtb_product_image where (product_id, sort_no ) in (select  product_id ,min(sort_no) as price from dtb_product_image group by product_id)) t2 on dtb_product.id =t2.product_id
  465.                 left join (select product_id, category_id  from dtb_product_category where category_id=8 or category_id=9 or category_id=10 or category_id=16 ) t3 on dtb_product.id =t3.product_id
  466.             __LONG_STRRING__;
  467.             //SQL実行
  468.             $stmt $conn->query($query);
  469.             $rows $stmt->fetchAll();
  470.             $products=[];
  471.             foreach($rows as $val) {
  472.                 $products[$val['id']]=$val;
  473.             }
  474.             //返却値
  475.             $timemin=2;
  476.             return [
  477.                 'products' => $products,
  478.                 'calendar_start_date' => date('Y-m-d'strtotime('+'.$timemin.'day')),
  479.                 'calendar_end_date' => date('Y-m-d'strtotime('+3 month')),
  480.             ];
  481.         } catch (\Exception $e) {
  482.             return [
  483.                 'testtest' => $e->getMessage(),
  484.             ];
  485.         }
  486.     }
  487.     /**
  488.      * @Route("/rental/reserved", name="rental_reserved", methods={"POST"})
  489.      * @Template("Rental/reserved.twig")
  490.      */
  491.     public function rentalReserved()
  492.     {
  493.         try {
  494.             log_info('rentalReserved 開始');
  495.              if(!$this->session->get('rental.car')) {
  496.                  return $this->redirectToRoute('homepage');
  497.              }
  498.             // カレンダーID
  499.             $calendarId $_POST['calendarId'];
  500.             $aimJsonPath './ornate-axiom-406706-fd999b268a9d.json';
  501.     
  502.             if($calendarId) {
  503.                 // サービスオブジェクトを作成
  504.                 $client = new Google_Client();
  505.                 // このアプリケーション名
  506.                 $client->setApplicationName('カレンダー操作テスト イベントの取得');
  507.                 log_info('rentalReserved 開始1');
  508.                 // ※ 注意ポイント: 権限の指定
  509.                 // 予定を取得する時は Google_Service_Calendar::CALENDAR_READONLY
  510.                 // 予定を追加する時は Google_Service_Calendar::CALENDAR_EVENTS
  511.                 $client->setScopes(Google_Service_Calendar::CALENDAR_EVENTS);
  512.                 log_info('rentalReserved 開始2');
  513.                 // ユーザーアカウントのjsonを指定
  514.                 $client->setAuthConfig($aimJsonPath);
  515.                 log_info('rentalReserved 開始3');
  516.                 // サービスオブジェクトの用意
  517.                 $service = new Google_Service_Calendar($client);
  518.                 $start_datetime = new Carbon($_POST['startdate'].' '.$_POST['starttime']);
  519.                 $end_datetime = new Carbon($_POST['enddate'].' '.$_POST['endtime']);
  520.                 
  521.                 log_info('rentalReserved 開始4');
  522.                 log_info('rentalReserved 開始5');
  523.                 $description "Type:".$_POST['type'];
  524.                 $description .= "<br>Rental Dates:".$_POST['startdate'].$_POST['starttime']."-".$_POST['enddate'].$_POST['endtime'];
  525. if(!$_POST['supercarflg']) {
  526.                 $description .= "<br>Destination:".$_POST['destination_name']." ".$_POST['otherkm']."km";
  527. }
  528.                 $description .= "<br>estimates:".$_POST['estimate'];
  529.                 $description .= "<br>";
  530.                 $description .= "<br>name:".$_POST['name'];
  531.                 $description .= "<br>Country:".$_POST['country'];
  532.                 $description .= "<br>age:".$_POST['age'];
  533.                 $description .= "<br>International driving permit(IDP):".$_POST['idp'];
  534.                 $description .= "<br>mail:".$_POST['email'];
  535.                 $description .= "<br>tel:".$_POST['telcode'].' '.$_POST['tel'];
  536.                 $description .= "<br>集合場所:".$_POST['pickup'];
  537.                 $description .= "<br>降車場所:".$_POST['dropoff'];
  538.                 $description .= "<br>Lead Car Option:".$_POST['option'];
  539.                 $description .= "<br>参加人数:".$_POST['participants'];
  540.                 $description .= "<br>コメント:".$_POST['message'];
  541.                 log_info('rentalReserved 開始6');
  542.                 $event = new Google_Service_Calendar_Event(array(
  543.                     'summary' => $_POST['carname'].':'.$_POST['name'],
  544.                     'start' => array(
  545.                         'dateTime' => $start_datetime,
  546.                         'timeZone' => 'Asia/Tokyo',
  547.                     ),
  548.                     'end' => array(
  549.                         'dateTime' => $end_datetime,
  550.                         'timeZone' => 'Asia/Tokyo',
  551.                     ),
  552.                     'description' => $description,
  553.                 ));
  554.                 log_info('rentalReserved 開始7');
  555.                 $event $service->events->insert($calendarId$event);
  556.                 log_info('rentalReserved 開始8');
  557.             }
  558.             //
  559. //            INSERT INTO dtb_order(name01, email, phone_number, subtotal, tax, total, payment_total, payment_method, create_date, update_date, order_date, currency_code, add_point, use_point, order_status_id, discriminator_type) VALUES ('TEST', 'yell.616@gmail.com', '0000000000', '160000', '0', '160000', '160000', '代金引換', now(), now(), now(), 'JPY', '0', '0', '1', 'order');
  560.             //メール送信、11は「dtb_mail_template」のID
  561.             $this->mailService->sendReserveRequest($_POST,11);
  562.             $this->session->remove('rental.car');
  563.             log_info('rentalReserved 終了');
  564.             return [
  565.             ];
  566.         } catch (\Exception $e) {
  567.             log_info('rentalReserved Exception');
  568.             return [
  569.                 'testtest' => $e->getMessage(),
  570.             ];
  571.         }
  572.     }
  573.     /**
  574.      * @Route("/rental/comfirm", name="rental_comfirm", methods={"POST"})
  575.      * @Template("Rental/comfirm.twig")
  576.      */
  577.     public function rentalConfirm()
  578.     {
  579.         $this->session->set('rental.car'$_POST);
  580.         try {
  581.             // カレンダーID
  582.             return [
  583.             'post'=>$_POST,
  584.             ];
  585.         } catch (\Exception $e) {
  586.             log_info('rentalReserved Exception');
  587.             return [
  588.                 'testtest' => $e->getMessage(),
  589.             ];
  590.         }
  591.     }
  592.     /**
  593.      * 商品詳細画面.
  594.      *
  595.      * @Route("/rental/detail/{id}", name="rental_detail", methods={"GET"}, requirements={"id" = "\d+"})
  596.      * @Template("Rental/detail.twig")
  597.      * @ParamConverter("Rental", options={"repository_method" = "findWithSortedClassCategories"})
  598.      *
  599.      * @param Request $request
  600.      * @param Product $Product
  601.      *
  602.      * @return array
  603.      */
  604.     public function rentalDetail(Request $requestProduct $Product)
  605.     {
  606.         if (!$this->checkVisibility($Product)) {
  607.             throw new NotFoundHttpException();
  608.         }
  609.         //----------------------------------
  610.         //ここから下はカレンダー 
  611.         //----------------------------------
  612.         // サービスオブジェクトを作成
  613.         $client = new Google_Client();
  614.         // サービスアカウント作成時にダウンロードしたjsonファイル
  615.         $aimJsonPath './ornate-axiom-406706-fd999b268a9d.json';
  616.         // サービスオブジェクトを作成
  617.         $client = new Google_Client();
  618.         // このアプリケーション名
  619.         $client->setApplicationName('カレンダー操作テスト イベントの取得');
  620.         // ※ 注意ポイント: 権限の指定
  621.         // 予定を取得する時は Google_Service_Calendar::CALENDAR_READONLY
  622.         // 予定を追加する時は Google_Service_Calendar::CALENDAR_EVENTS
  623.         $client->setScopes(Google_Service_Calendar::CALENDAR_READONLY);
  624.         // ユーザーアカウントのjsonを指定
  625.         $client->setAuthConfig($aimJsonPath);
  626.         // サービスオブジェクトの用意
  627.         $service = new Google_Service_Calendar($client);
  628.         // カレンダーID
  629.         // 商品マスタから取得
  630.         $calendarId '';
  631.         if($Product->getItem13()) {
  632.             $calendarId $Product->getItem13();
  633.         }
  634.         // 取得時の詳細設定
  635.         // 日付を最短
  636.         $res['calendar']=false;
  637.         $timemin=1;
  638.         if($calendarId) {
  639.             $res['calendar']=true;
  640.             if($Product->getItem15()) {
  641.                 $timemin=$Product->getItem15()-1;
  642.             }
  643.             $optParams = array(
  644.                 'orderBy' => 'startTime',
  645.                 'singleEvents' => true,
  646.                 'timeMax' => date('c',strtotime("+3 month")),    //3か月分
  647.             );
  648.             $results $service->events->listEvents($calendarId$optParams);
  649.             //書式設定
  650.             foreach( $results->getItems() as $event) {
  651.     //            $tDate=date('Y-m-d',strtotime($start = $event->start->dateTime));
  652.     //            $tDate=date('Y-m-d',strtotime($start = $event->end->dateTime));
  653.                 for($i=date('Ymd'strtotime$event->start->dateTime)); $i<=date('Ymd'strtotime($event->end->dateTime)); $i++){
  654.                     $year substr($i0,4);
  655.                     $month substr($i4,2);
  656.                     $day substr($i6,2);
  657.                     if(checkdate $month $day $year )) {
  658.                         $tmp=date('Y-m-d'strtotime($i));
  659.                         $res[$tmp] = $tmp;
  660.                     }
  661.                 }
  662.     //            $res[$tDate][]=date('H',strtotime($start = $event->start->dateTime));
  663.     //            $res[$tDate][]=date('H',strtotime($start = $event->end->dateTime));
  664.             }
  665.         }
  666.         
  667.         //フロントカレンダー用に+1日する。
  668.         $timemin+=1;
  669.         return [
  670.             'title' => $Product->getName(),
  671.             'subtitle' => $Product->getName(),
  672.             'Product' => $Product,
  673.             'events' => json_encode($res),
  674.             'calendar_start_date' => date('Y-m-d'strtotime('+'.$timemin.'day')),
  675.         ];
  676.     }
  677.     /**
  678.     * @Route("/help/company", name="help_company", methods={"GET"})
  679.     * @Template("Help/company.twig")
  680.     */
  681.     public function company() 
  682.     {
  683.         return [];
  684.     }
  685.     /**
  686.     * @Route("/help/club", name="help_club", methods={"GET"})
  687.     * @Template("Help/club.twig")
  688.     */
  689.     public function club()
  690.     {
  691.         return [];
  692.     }
  693.     /**
  694.     * @Route("/plan/case01", name="plan_case01", methods={"GET"})
  695.     * @Template("Plan/case01.twig")
  696.     */
  697.     public function case01()
  698.     {
  699.         return [];
  700.     }
  701.     /**
  702.     * @Route("/plan/case02", name="plan_case02", methods={"GET"})
  703.     * @Template("Plan/case02.twig")
  704.     */
  705.     public function case02()
  706.     {
  707.         return [];
  708.     }
  709.     /**
  710.     * @Route("/plan/case03", name="plan_case03", methods={"GET"})
  711.     * @Template("Plan/case03.twig")
  712.     */
  713.     public function case03(){ return []; }
  714.     /**
  715.     * @Route("/plan/case04", name="plan_case04", methods={"GET"})
  716.     * @Template("Plan/case04.twig")
  717.     */
  718.     public function case04(){ return []; }
  719.     /**
  720.      * @Method("GET")
  721.      * @Route("/plan/{id}", name="plan_detail", methods={"GET"}))
  722.      * @Template("Plan/detail.twig")
  723.      */
  724.     public function planMethod($id)
  725.     { 
  726.         require_once('../../wpsite/wp-load.php');
  727.         $post get_post($id);
  728.         $array = array(
  729.             "id" => $post->ID,
  730.             "title" => get_field('title_en',$post->ID),
  731.             "main_img" => get_field('main_img',$post->ID)['url'],
  732.             "sp_main_img" => get_field('sp_main_img',$post->ID)['url'],
  733.             "detail_title" => get_field('detail_title_en',$post->ID),
  734.             "list_text" => get_field('list_text_en',$post->ID),
  735.             "main_text" => get_field('main_text_en',$post->ID),
  736.             "css" => get_field('css',$post->ID),
  737.         );
  738.         
  739.         for($i=1$i <= 11$i++) {
  740.             $array['img_'.$i] = get_field('img_'.$i$post->ID);
  741.             $array['title_'.$i] = get_field('title_'.$i.'_en'$post->ID);
  742.             $array['text_'.$i] = get_field('text_'.$i.'_en'$post->ID);
  743.         }
  744.         return [
  745.             'WpPosts' => $array,
  746.         ];
  747.     }
  748.     /**
  749.      * @Method("GET")
  750.      * @Route("/news/{id}", name="news_detail", methods={"GET"}))
  751.      * @Template("News/detail.twig")
  752.      */
  753.     public function newsMethod($id)
  754.     { 
  755.         require_once('../../wpsite/wp-load.php');
  756.         $post get_post($id);
  757.         
  758.         //明細行取得
  759.         $array = array(
  760.             "id" => $post->ID,
  761.             "title" => get_field('title_en',$post->ID),
  762.             "detail_title" => get_field('detail_title_en',$post->ID),
  763.             "main_img" => get_field('main_img',$post->ID)['url'],
  764.             "main_text" => get_field('main_text_en',$post->ID),
  765.         );
  766.         //明細行取得
  767.         for($i=1$i <= 10$i++) {
  768.             $array['img_'.$i] = get_field('img_'.$i$post->ID);
  769.             $array['img_desc_'.$i] = get_field('img_desc_'.$i.'_en'$post->ID);
  770.             $array['title_'.$i] = get_field('title_'.$i.'_en'$post->ID);
  771.             $array['text_'.$i] = get_field('text_'.$i.'_en'$post->ID);
  772.         }
  773.         return [
  774.             'WpPosts' => $array,
  775.         ];
  776.     }
  777.     /**
  778.     * @Route("/payment", name="payment", methods={"GET"})
  779.     * @Template("Payment/index.twig")
  780.     */
  781.     public function payment()
  782.     {
  783.         return [];
  784.     }
  785.     /**
  786.     * @Route("/experience", name="experience", methods={"GET"})
  787.     * @Template("Experience/index.twig")
  788.     */
  789.     public function experience()
  790.     {
  791.         return [];
  792.     }
  793.     /**
  794.     * @Route("/service", name="service", methods={"GET"})
  795.     * @Template("Service/index.twig")
  796.     */
  797.     public function service()
  798.     {
  799.         return [];
  800.     }
  801.     /**
  802.      * 閲覧可能な商品かどうかを判定
  803.      *
  804.      * @param Product $Product
  805.      *
  806.      * @return boolean 閲覧可能な場合はtrue
  807.      */
  808.     protected function checkVisibility(Product $Product)
  809.     {
  810.         $is_admin $this->session->has('_security_admin');
  811.         // 管理ユーザの場合はステータスやオプションにかかわらず閲覧可能.
  812.         if (!$is_admin) {
  813.             // 在庫なし商品の非表示オプションが有効な場合.
  814.             // if ($this->BaseInfo->isOptionNostockHidden()) {
  815.             //     if (!$Product->getStockFind()) {
  816.             //         return false;
  817.             //     }
  818.             // }
  819.             // 公開ステータスでない商品は表示しない.
  820.             if ($Product->getStatus()->getId() !== constant('Eccube\\Entity\\Master\\ProductStatus::DISPLAY_SHOW')) {
  821.                 return false;
  822.             }
  823.         }
  824.         return true;
  825.     }
  826.     /**
  827.     * @Route("/ebike/spots", name="ebike_spots", methods={"GET"})
  828.     * @Template("Ebike/spots.twig")
  829.     */
  830.     public function ebikespots()
  831.     {
  832.         return [];
  833.     }
  834.     /**
  835.      * 商品詳細画面.
  836.      *
  837.      * @Route("/ebike/{id}", name="ebike_detail", methods={"GET"}, requirements={"id" = "\d+"})
  838.      * @Template("Ebike/detail.twig")
  839.      * @ParamConverter("Ebike", options={"repository_method" = "findWithSortedClassCategories"})
  840.      *
  841.      * @param Request $request
  842.      * @param Product $Product
  843.      *
  844.      * @return array
  845.      */
  846.     public function ebike(Request $requestProduct $Product)
  847.     {
  848.         $this->session->set('rental.ebike'"set");
  849.         if (!$this->checkVisibility($Product)) {
  850.             throw new NotFoundHttpException();
  851.         }
  852.         //----------------------------------
  853.         //ここから下はカレンダー 
  854.         //----------------------------------
  855.         // サービスオブジェクトを作成
  856.         $client = new Google_Client();
  857.         // サービスアカウント作成時にダウンロードしたjsonファイル
  858.         $aimJsonPath './ornate-axiom-406706-fd999b268a9d.json';
  859.         // サービスオブジェクトを作成
  860.         $client = new Google_Client();
  861.         // このアプリケーション名
  862.         $client->setApplicationName('カレンダー操作テスト イベントの取得');
  863.         // ※ 注意ポイント: 権限の指定
  864.         // 予定を取得する時は Google_Service_Calendar::CALENDAR_READONLY
  865.         // 予定を追加する時は Google_Service_Calendar::CALENDAR_EVENTS
  866.         $client->setScopes(Google_Service_Calendar::CALENDAR_READONLY);
  867.         // ユーザーアカウントのjsonを指定
  868.         $client->setAuthConfig($aimJsonPath);
  869.         // サービスオブジェクトの用意
  870.         $service = new Google_Service_Calendar($client);
  871.         // カレンダーID
  872.         // 商品マスタから取得
  873.         $calendarId '';
  874.         if($Product->getItem13()) {
  875.             $calendarId $Product->getItem13();
  876.         }
  877.         // 取得時の詳細設定
  878.         // 日付を最短
  879.         $res['calendar']=false;
  880.         $tmp4=[];
  881.         $timemin=1;
  882.         if($calendarId) {
  883.             $res['calendar']=true;
  884.             if($Product->getItem15()) {
  885.                 $timemin=$Product->getItem15()-1;
  886.             }
  887.             $optParams = array(
  888.                 'orderBy' => 'startTime',
  889.                 'singleEvents' => true,
  890.                 'timeMax' => date('c',strtotime("+3 month")),    //3か月分
  891.             );
  892.             $results $service->events->listEvents($calendarId$optParams);
  893.             //書式設定
  894.             foreach( $results->getItems() as $event) {
  895.                 
  896.                 for($i=date('Ymd'strtotime$event->start->dateTime)); $i<=date('Ymd'strtotime($event->end->dateTime)); $i++){
  897.                     $year substr($i0,4);
  898.                     $month substr($i4,2);
  899.                     $day substr($i6,2);
  900.                     if(checkdate $month $day $year )) {
  901.                         //日付が正しい
  902.                         $tmp=date('Y-m-d'strtotime($i));
  903.                         
  904.                         $cnt=0;
  905.                         if(array_key_exists($tmp,$res)) {
  906.                             //日付の配列にデータがある場合、件数を取得
  907.                             $cnt=$res[$tmp];
  908.                         }
  909.                         $res[$tmp] = $cnt+(int)$event->location;
  910.                     }
  911.                 }
  912.             }
  913.         }
  914.         
  915.         //フロントカレンダー用に+1日する。
  916.         $timemin+=1;
  917.         return [
  918.             'title' => $Product->getName(),
  919.             'subtitle' => $Product->getName(),
  920.             'Product' => $Product,
  921.             'events' => json_encode($res),
  922.             'calendar_start_date' => date('Y-m-d'strtotime('+'.$timemin.'day')),
  923.         ];
  924.     }
  925.     /**
  926.      * @Route("/ebike/reserved", name="ebike_reserved", methods={"POST"})
  927.      * @Template("Ebike/reserved.twig")
  928.      */
  929.     public function ebikeReserved()
  930.     {
  931.         try {
  932.              if(!$this->session->get('rental.ebike')) {
  933.                  return $this->redirectToRoute('homepage');
  934.              }
  935.             log_info('ebikeReserved 開始');
  936.             // カレンダーID
  937.             $calendarId $_POST['calendarId'];
  938.             $aimJsonPath './ornate-axiom-406706-fd999b268a9d.json';
  939.             if($calendarId) {
  940.                 // サービスオブジェクトを作成
  941.                 $client = new Google_Client();
  942.                 // このアプリケーション名
  943.                 $client->setApplicationName('カレンダー操作テスト イベントの取得');
  944.                 log_info('ebikeReserved 開始1');
  945.                 // ※ 注意ポイント: 権限の指定
  946.                 // 予定を取得する時は Google_Service_Calendar::CALENDAR_READONLY
  947.                 // 予定を追加する時は Google_Service_Calendar::CALENDAR_EVENTS
  948.                 $client->setScopes(Google_Service_Calendar::CALENDAR_EVENTS);
  949.                 log_info('ebikeReserved 開始2');
  950.                 // ユーザーアカウントのjsonを指定
  951.                 $client->setAuthConfig($aimJsonPath);
  952.                 log_info('ebikeReserved 開始3');
  953.                 // サービスオブジェクトの用意
  954.                 $service = new Google_Service_Calendar($client);
  955.                 $start_datetime = new Carbon($_POST['date'].' '.$_POST['starttime']);
  956.                 $end_datetime = new Carbon($_POST['date'].' '.$_POST['starttime']);
  957.                 
  958.                 $time=$_POST['time'];
  959.                 if($_POST['time']) {
  960.                     $end_datetime->addHour($time);
  961.                     $time.=' hours';
  962.                 }
  963.                 log_info('ebikeReserved 開始4');
  964.                 $description "日時:".$_POST['date'].' '.$_POST['starttime'];
  965.                 $description .= "<br>レンタル時間:".$_POST['time'];
  966.                 $description .= "<br>units:".$_POST['units'];
  967.                 $description .= "<br>name:".$_POST['name'];
  968.                 $description .= "<br>Country:".$_POST['country'];
  969.                 $description .= "<br>mail:".$_POST['email'];
  970.                 $description .= "<br>tel:".$_POST['tel'];
  971.                 $description .= "<br>コメント:".$_POST['message'];
  972.                 log_info('ebikeReserved 開始5');
  973.                 
  974.                 //カレンダー設定
  975.                 $event = new Google_Service_Calendar_Event(array(
  976.                     'summary' => "name:".$_POST['name'],
  977.                     'start' => array(
  978.                         'dateTime' => $start_datetime,
  979.                         'timeZone' => 'Asia/Tokyo',
  980.                     ),
  981.                     'end' => array(
  982.                         'dateTime' => $end_datetime,
  983.                         'timeZone' => 'Asia/Tokyo',
  984.                     ),
  985.                     'description' => $description,
  986.                     'location' => $_POST['units'],
  987.                 ));
  988.                 log_info('ebikeReserved 開始6');
  989.                 $event $service->events->insert($calendarId$event);
  990.                 log_info('ebikeReserved 開始7');
  991.             }
  992.             //
  993. //            INSERT INTO dtb_order(name01, email, phone_number, subtotal, tax, total, payment_total, payment_method, create_date, update_date, order_date, currency_code, add_point, use_point, order_status_id, discriminator_type) VALUES ('TEST', 'yell.616@gmail.com', '0000000000', '160000', '0', '160000', '160000', '代金引換', now(), now(), now(), 'JPY', '0', '0', '1', 'order');
  994.             //メール送信、15は「dtb_mail_template」のID
  995.             $this->mailService->sendReserveRequest($_POST,15);
  996.             $this->session->remove('rental.ebike');
  997.             log_info('rentalReserved 終了');
  998.             return [
  999.             ];
  1000.         } catch (\Exception $e) {
  1001.             log_info('rentalReserved Exception');
  1002.             return [
  1003.                 'testtest' => $e->getMessage(),
  1004.             ];
  1005.         }
  1006.     }
  1007.     /**
  1008.     * @Route("/helicopter", name="helicopter", methods={"GET"})
  1009.     * @Template("Helicopter/index.twig")
  1010.     */
  1011.     public function helicopter()
  1012.     {
  1013.         return [];
  1014.     }
  1015.     /**
  1016.      * 商品詳細画面.
  1017.      *
  1018.      * @Route("/helicopter/detail/{id}", name="helicopter_detail", methods={"GET"}, requirements={"id" = "\d+"})
  1019.      * @Template("Helicopter/detail.twig")
  1020.      * @ParamConverter("Helicopter", options={"repository_method" = "findWithSortedClassCategories"})
  1021.      *
  1022.      * @param Request $request
  1023.      * @param Product $Product
  1024.      *
  1025.      * @return array
  1026.      */
  1027.     public function helicopterDetail(Request $requestProduct $Product)
  1028.     {
  1029.         $this->session->set('rental.helicopter'"set");
  1030.         
  1031.         if (!$this->checkVisibility($Product)) {
  1032.             throw new NotFoundHttpException();
  1033.         }
  1034.         $res=[];
  1035.         return [
  1036.             'title' => $Product->getName(),
  1037.             'subtitle' => $Product->getName(),
  1038.             'events' => json_encode($res),
  1039.             'Product' => $Product,
  1040.             'calendar_start_date' => date('Y-m-d'strtotime('+1day')),
  1041.         ];
  1042.     }
  1043.     /**
  1044.      * @Route("/helicopter/reserved", name="helicopter_reserved", methods={"POST"})
  1045.      * @Template("Helicopter/reserved.twig")
  1046.      */
  1047.     public function helicopterReserved()
  1048.     {
  1049.         try {
  1050.              if(!$this->session->get('rental.helicopter')) {
  1051.                  return $this->redirectToRoute('homepage');
  1052.              }
  1053.             //メール送信、19は「dtb_mail_template」のID
  1054.             log_info('helicopterReserved 開始2-1');
  1055.             $this->mailService->sendReserveRequest($_POST,19);
  1056.             $this->session->remove('rental.helicopter');
  1057.             log_info('helicopterReserved 終了');
  1058.             return [
  1059.             ];
  1060.         } catch (\Exception $e) {
  1061.             log_info('helicopter Reserved Exception');
  1062.             return [
  1063.                 'testtest' => $e->getMessage(),
  1064.             ];
  1065.         }
  1066.     }
  1067.     /**
  1068.     * @Route("/fuji", name="fuji", methods={"GET"})
  1069.     * @Template("Fuji/index.twig")
  1070.     */
  1071.     public function fuji()
  1072.     {
  1073.         return [];
  1074.     }
  1075.     /**
  1076.     * @Route("/fuji/service01", name="fuji_service01", methods={"GET"})
  1077.     * @Template("Fuji/service01.twig")
  1078.     */
  1079.     public function fuji_service01()
  1080.     {
  1081.         return [];
  1082.     }
  1083.     /**
  1084.     * @Route("/fuji/service02", name="fuji_service02", methods={"GET"})
  1085.     * @Template("Fuji/service02.twig")
  1086.     */
  1087.     public function fuji_service02()
  1088.     {
  1089.         return [];
  1090.     }
  1091.     /**
  1092.     * @Route("/fuji/service03", name="fuji_service03", methods={"GET"})
  1093.     * @Template("Fuji/service03.twig")
  1094.     */
  1095.     public function fuji_service03()
  1096.     {
  1097.         return [];
  1098.     }
  1099.     /**
  1100.     * @Route("/fuji/service04", name="fuji_service04", methods={"GET"})
  1101.     * @Template("Fuji/service04.twig")
  1102.     */
  1103.     public function fuji_service04()
  1104.     {
  1105.         return [];
  1106.     }
  1107.     /**
  1108.     * @Route("/fuji/service05", name="fuji_service05", methods={"GET"})
  1109.     * @Template("Fuji/service05.twig")
  1110.     */
  1111.     public function fuji_service05()
  1112.     {
  1113.         return [];
  1114.     }
  1115.     /**
  1116.      * @Route("/fuji/reserved/{id}", name="fuji_reserved", methods={"GET"})
  1117.      * @Template("Fuji/reserved.twig")
  1118.      */
  1119.     public function fujiReserved($id)
  1120.     {
  1121.         try {
  1122.             $this->session->set('rental.fuji'"set");
  1123.             return [
  1124.                 'id' => $id,
  1125.             ];
  1126.         } catch (\Exception $e) {
  1127.             log_info('helicopter Reserved Exception');
  1128.              return $this->redirectToRoute('homepage');
  1129.         }
  1130.     }
  1131.     /**
  1132.      * @Route("/fuji/complete", name="fuji_complete", methods={"POST"})
  1133.      * @Template("Fuji/complete.twig")
  1134.      */
  1135.     public function fujiComplete()
  1136.     {
  1137.         try {
  1138.              if(!$this->session->get('rental.fuji')) {
  1139.                  return $this->redirectToRoute('homepage');
  1140.              }
  1141.             //メール送信、29は「dtb_mail_template」のID
  1142.             log_info('Fuji Reserved  開始2-1');
  1143.             $this->mailService->sendReserveRequest($_POST,29);
  1144.             $this->session->remove('rental.fuji');
  1145.             log_info('Fuji Reserved 終了');
  1146.             return [
  1147.                 'posts' => $_POST,
  1148.             ];
  1149.         } catch (\Exception $e) {
  1150.             log_info('Fuji Reserved Exception');
  1151. //            var_dump($e->getMessage());
  1152.             return [
  1153.                 'posts' => $_POST,
  1154.                 'testtest' => $e->getMessage(),
  1155.             ];
  1156.         }
  1157.     }
  1158.     /**
  1159.     * @Route("/summer", name="summer", methods={"GET"})
  1160.     * @Template("Summer/index.twig")
  1161.     */
  1162.     public function summer()
  1163.     {
  1164.         return [];
  1165.     }
  1166.     /**
  1167.     * @Route("/autumn", name="autumn", methods={"GET"})
  1168.     * @Template("Autumn/index.twig")
  1169.     */
  1170.     public function autumn()
  1171.     {
  1172.         return [];
  1173.     }
  1174.     /**
  1175.      * @Route("/autumn/reserved/{id}", name="autumn_reserved", methods={"GET"})
  1176.      * @Template("Autumn/reserved.twig")
  1177.      */
  1178.     public function autumnReserved($id)
  1179.     {
  1180.         try {
  1181.             $this->session->set('rental.autumn'"set");
  1182.             return [
  1183.                 'id' => $id,
  1184.             ];
  1185.         } catch (\Exception $e) {
  1186.             log_info('helicopter Reserved Exception');
  1187.              return $this->redirectToRoute('homepage');
  1188.         }
  1189.     }
  1190.     /**
  1191.      * @Route("/autumn/complete", name="autumn_complete", methods={"POST"})
  1192.      * @Template("Autumn/complete.twig")
  1193.      */
  1194.     public function autumnComplete()
  1195.     {
  1196.         try {
  1197.              if(!$this->session->get('rental.autumn')) {
  1198.                  return $this->redirectToRoute('homepage');
  1199.              }
  1200.             //メール送信、27は「dtb_mail_template」のID
  1201.             log_info('Cruise Reserved  開始2-1');
  1202.             $this->mailService->sendReserveRequest($_POST,27);
  1203.             $this->session->remove('rental.autumn');
  1204.             log_info('Cruise Reserved 終了');
  1205.             return [
  1206.             ];
  1207.         } catch (\Exception $e) {
  1208.             log_info('Autumn Reserved Exception');
  1209. //            var_dump($e->getMessage());
  1210.             return [
  1211.                 'testtest' => $e->getMessage(),
  1212.             ];
  1213.         }
  1214.     }
  1215.     /**
  1216.      * 商品詳細画面.
  1217.      *
  1218.      * @Route("/summer/detail/{id}", name="summer_detail", methods={"GET"}, requirements={"id" = "\d+"})
  1219.      * @Template("Summer/detail.twig")
  1220.      * @ParamConverter("Summer", options={"repository_method" = "findWithSortedClassCategories"})
  1221.      *
  1222.      * @param Request $request
  1223.      * @param Product $Product
  1224.      *
  1225.      * @return array
  1226.      */
  1227.     public function summerDetail(Request $requestProduct $Product)
  1228.     {
  1229.         $this->session->set('rental.helicopter'"set");
  1230.         
  1231.         if (!$this->checkVisibility($Product)) {
  1232.             throw new NotFoundHttpException();
  1233.         }
  1234.         $res=[];
  1235.         return [
  1236.             'title' => $Product->getName(),
  1237.             'subtitle' => $Product->getName(),
  1238.             'events' => json_encode($res),
  1239.             'Product' => $Product,
  1240.             'calendar_start_date' => date('Y-m-d'strtotime('+1day')),
  1241.         ];
  1242.     }
  1243.     /**
  1244.      * @Route("/summer/reserved", name="summer_reserved", methods={"POST"})
  1245.      * @Template("Summer/reserved.twig")
  1246.      */
  1247.     public function summerReserved()
  1248.     {
  1249.         try {
  1250.              if(!$this->session->get('rental.summer')) {
  1251.                  return $this->redirectToRoute('homepage');
  1252.              }
  1253.             //メール送信、19は「dtb_mail_template」のID
  1254.             log_info('SummerReserved 開始2-1');
  1255.             $this->mailService->sendReserveRequest($_POST,19);
  1256.             $this->session->remove('rental.summer');
  1257.             log_info('SummerReserved 終了');
  1258.             return [
  1259.             ];
  1260.         } catch (\Exception $e) {
  1261.             log_info('Summer Reserved Exception');
  1262.             return [
  1263.                 'testtest' => $e->getMessage(),
  1264.             ];
  1265.         }
  1266.     }
  1267.     /**
  1268.     * @Route("/cruise", name="cruise", methods={"GET"})
  1269.     * @Template("Cruise/index.twig")
  1270.     */
  1271.     public function cruise()
  1272.     {
  1273.         return [];
  1274.     }
  1275.     /**
  1276.      * 商品詳細画面.
  1277.      *
  1278.      * @Method("GET")
  1279.      * @Route("/cruise/{id}", name="cruise_detail", methods={"GET"})
  1280.      * @Template("Cruise/detail.twig")
  1281.      */
  1282.     public function cruiseDetail($id)
  1283.     {
  1284.         
  1285.         $this->session->set('rental.cruise'"set");
  1286. //        if($id == 'tokyo')
  1287.         $res=[];
  1288.         return [
  1289.             'id' => $id,
  1290.         ];
  1291.     }
  1292.     /**
  1293.      * @Route("/cruise/reserved/{id}", name="cruise_reserved", methods={"GET"})
  1294.      * @Template("Cruise/reserved.twig")
  1295.      */
  1296.     public function cruiseReserved($id)
  1297.     {
  1298.         try {
  1299.             $title="";
  1300.             if($id==1) {
  1301.                 $title="RIVER CRUISE";
  1302.             } else if($id==2) {
  1303.                 $title="TOKYO BAY CRUISE";
  1304.             } else if($id==3) {
  1305.                 $title="YOKOHAMA BAY SUNSET CRUISE";
  1306.             } else if($id==4) {
  1307.                 $title="CHIBA / MIURA RESORT CRUISE";
  1308.             } else if($id==5) {
  1309.                 $title="CHIBA RESORT CRUISE";
  1310.             } else  {
  1311.                  return $this->redirectToRoute('homepage');
  1312.             }
  1313.             return [
  1314.                 'id' => $id,
  1315.                 'title' => $title,
  1316.             ];
  1317.         } catch (\Exception $e) {
  1318.             log_info('helicopter Reserved Exception');
  1319.             return [
  1320.                 'testtest' => $e->getMessage(),
  1321.             ];
  1322.         }
  1323.     }
  1324.     /**
  1325.      * @Route("/cruise/complete", name="cruise_complete", methods={"POST"})
  1326.      * @Template("Cruise/complete.twig")
  1327.      */
  1328.     public function cruiseComplete()
  1329.     {
  1330.         try {
  1331.              if(!$this->session->get('rental.cruise')) {
  1332.                  return $this->redirectToRoute('homepage');
  1333.              }
  1334.             //メール送信、26は「dtb_mail_template」のID
  1335.             log_info('Cruise Reserved  開始2-1');
  1336.             $this->mailService->sendReserveRequest($_POST,26);
  1337.             $this->session->remove('rental.cruise');
  1338.             log_info('Cruise Reserved 終了');
  1339.             return [
  1340.             ];
  1341.         } catch (\Exception $e) {
  1342.             log_info('Cruise Reserved Exception');
  1343. //            var_dump($e->getMessage());
  1344.             return [
  1345.                 'testtest' => $e->getMessage(),
  1346.             ];
  1347.         }
  1348.     }
  1349. }