app/Customize/Controller/custumEventController.php line 269

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 custumEventController 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("/plan/2024sakura", name="sakura2024", methods={"GET"})
  55.     * @Template("Plan/2024sakura.twig")
  56.     */
  57.     public function sakura2024()
  58.     {
  59.         try {
  60.             $this->session->set('sakura2004'"set");
  61.             //----------------------------------
  62.             //ここから下はカレンダー 
  63.             //----------------------------------
  64.             // サービスオブジェクトを作成
  65.             $client = new Google_Client();
  66.             // サービスアカウント作成時にダウンロードしたjsonファイル
  67.             $aimJsonPath './ornate-axiom-406706-fd999b268a9d.json';
  68.             // サービスオブジェクトを作成
  69.             $client = new Google_Client();
  70.             // このアプリケーション名
  71.             $client->setApplicationName('カレンダー操作テスト イベントの取得');
  72.             // ※ 注意ポイント: 権限の指定
  73.             // 予定を取得する時は Google_Service_Calendar::CALENDAR_READONLY
  74.             // 予定を追加する時は Google_Service_Calendar::CALENDAR_EVENTS
  75.             $client->setScopes(Google_Service_Calendar::CALENDAR_READONLY);
  76.             // ユーザーアカウントのjsonを指定
  77.             $client->setAuthConfig($aimJsonPath);
  78.             // サービスオブジェクトの用意
  79.             $service = new Google_Service_Calendar($client);
  80.             // カレンダーID 2024桜イベントのカレンダー設定
  81.             $calendarId 'f815c4cba3a22813d3bda95af18688b85cdbca97bd25e4c4e5bfb3fbd289d8e3@group.calendar.google.com';
  82.             // 取得時の詳細設定
  83.             // 日付を最短
  84.             $optParams = array(
  85.                 'orderBy' => 'startTime',
  86.                 'singleEvents' => true,
  87.                 'timeMax' => date('2024-04-08\T00:00:00\Z'),
  88.             );
  89.             $results $service->events->listEvents($calendarId$optParams);
  90.             //書式設定
  91.             foreach( $results->getItems() as $event) {
  92.                 for($i=date('Ymd'strtotime$event->start->dateTime)); $i<=date('Ymd'strtotime($event->end->dateTime)); $i++){
  93.                     $tmp=date('Y/m/d'strtotime($i));
  94.                     $res[$tmp][date('H',strtotime($event->start->dateTime))] = date('H',strtotime($event->start->dateTime));
  95.                 }
  96.             }
  97.             //カレンダー開始日を設定
  98.             //+3 hourは、3時間前に時間判定するため
  99.             $today date('Y/m/d',strtotime('+3 hour'));
  100.             $startDate '2024/03/20';
  101.             if( $today $startDate ) {
  102.                 $startDate=$today;
  103.             }
  104.             //返却値
  105.             return [
  106.                 'reserveInfo' => $res,
  107.                 'startdate' => $startDate,
  108.                 'nowdate' => date('Y/m/d',strtotime('+3 hour')),
  109.                 'nowtime' => date('Hi',strtotime('+3 hour')),
  110.                 'nextdate' => date('Y/m/d',strtotime('+1 day +3 hour')),
  111.                 'next2date' => date('Y/m/d',strtotime('+2 day +3 hour')),
  112.             ];
  113.         } catch (\Exception $e) {
  114. //            log_error('getFavorites Exception: ',  $e->getMessage());
  115.             return [
  116.                 'testtest' => $e->getMessage(),
  117.             ];
  118.         }
  119.     }
  120.     /**
  121.      * @Route("/plan/2024sakura/reserved", name="2024sakura_reserved", methods={"POST"})
  122.      * @Template("Plan/2024sakura_reserved.twig")
  123.      */
  124.     public function sakura2024_reserved()
  125.     {
  126.         try {
  127.             log_info('2024sakura_reserved 開始');
  128. //             if(!$this->session->get('sakura2004')) {
  129. //                 return $this->redirectToRoute('homepage');
  130. //             }
  131.             // カレンダーID
  132.             $calendarId 'f815c4cba3a22813d3bda95af18688b85cdbca97bd25e4c4e5bfb3fbd289d8e3@group.calendar.google.com';
  133.             $aimJsonPath './ornate-axiom-406706-fd999b268a9d.json';
  134.     
  135.             if($calendarId) {
  136.                 // サービスオブジェクトを作成
  137.                 $client = new Google_Client();
  138.                 // このアプリケーション名
  139.                 $client->setApplicationName('カレンダー操作テスト イベントの取得');
  140.                 log_info('2024sakura_reserved 開始1');
  141.                 // ※ 注意ポイント: 権限の指定
  142.                 // 予定を取得する時は Google_Service_Calendar::CALENDAR_READONLY
  143.                 // 予定を追加する時は Google_Service_Calendar::CALENDAR_EVENTS
  144.                 $client->setScopes(Google_Service_Calendar::CALENDAR_EVENTS);
  145.                 log_info('2024sakura_reserved 開始2');
  146.                 // ユーザーアカウントのjsonを指定
  147.                 $client->setAuthConfig($aimJsonPath);
  148.                 log_info('2024sakura_reserved 開始3');
  149.                 // サービスオブジェクトの用意
  150.                 $service = new Google_Service_Calendar($client);
  151.                 //日付と時間に分割
  152.                 $year substr($_POST['request'], 04);
  153.                 $month substr($_POST['request'], 42);
  154.                 $day substr($_POST['request'], 62);
  155.                 $hour substr($_POST['request'], 82);
  156.                 $minute substr($_POST['request'], 102);
  157.                 $start_datetime = new Carbon(sprintf("%s-%s-%s %s:%s:00"$year$month$day$hour$minute));
  158.                 $end_datetime = new Carbon(sprintf("%s-%s-%s %s:%s:00"$year$month$day$hour$minute));
  159.                 $end_datetime->addHour(2);    //2時間後を設定
  160.                 
  161.                 log_info('2024sakura_reserved 開始4');
  162.                 $description "name:".$_POST['name'];
  163.                 log_info('2024sakura_reserved 開始5-1');
  164.                 $description .= "<br>Country:".$_POST['country'];
  165.                 log_info('2024sakura_reserved 開始5-2');
  166.                 $description .= "<br>mail:".$_POST['email'];
  167.                 log_info('2024sakura_reserved 開始5-3');
  168.                 $description .= "<br>tel:".$_POST['telcode'].' '.$_POST['tel'];
  169.                 log_info('2024sakura_reserved 開始5-4');
  170.                 $description .= "<br>参加人数:".$_POST['participants'];
  171.                 log_info('2024sakura_reserved 開始5-5');
  172.                 log_info('2024sakura_reserved 開始5-6');
  173.                 $description .= "<br>Transfer Option:".$_POST['transfer'];
  174.                 log_info('2024sakura_reserved 開始5-7');
  175.                 if (isset($_POST['pickup'])) {
  176.                 $description .= "<br>pickup:".$_POST['pickup'];
  177.                 } else {
  178.                     $_POST['pickup']='';
  179.                 }
  180.                 log_info('2024sakura_reserved 開始5-8');
  181.                 $description .= "<br>コメント:".$_POST['message'];
  182.                 log_info('2024sakura_reserved 開始6');
  183.                 $event = new Google_Service_Calendar_Event(array(
  184.                     'summary' => "2024 SAKURA name:".$_POST['name'],
  185.                     'start' => array(
  186.                         'dateTime' => $start_datetime,
  187.                         'timeZone' => 'Asia/Tokyo',
  188.                     ),
  189.                     'end' => array(
  190.                         'dateTime' => $end_datetime,
  191.                         'timeZone' => 'Asia/Tokyo',
  192.                     ),
  193.                     'description' => $description,
  194.                 ));
  195.                 log_info('2024sakura_reserved 開始7');
  196.                 $event $service->events->insert($calendarId$event);
  197.                 log_info('2024sakura_reserved 開始8');
  198.             }
  199.             //
  200. //            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');
  201.             //メール送信、17は「dtb_mail_template」のID
  202.             $this->mailService->sendReserveRequest($_POST,17);
  203.             $this->session->remove('sakura2004');
  204.             log_info('2024sakura_reserved 終了');
  205.             return [
  206.             ];
  207.         } catch (\Exception $e) {
  208.             log_info('2024sakura_reserved Exception');
  209.             return [
  210.                 'testtest' => $e->getMessage(),
  211.             ];
  212.         }
  213.     }
  214.     /**
  215.     * @Route("/plan/limited", name="limited", methods={"GET"})
  216.     * @Template("Plan/limited.twig")
  217.     */
  218.     public function limited()
  219.     {
  220.         try {
  221.             $this->session->set('limited'"set");
  222.             //----------------------------------
  223.             //ここから下はカレンダー 
  224.             //----------------------------------
  225.             // サービスオブジェクトを作成
  226.             $client = new Google_Client();
  227.             // サービスアカウント作成時にダウンロードしたjsonファイル
  228.             $aimJsonPath './ornate-axiom-406706-fd999b268a9d.json';
  229.             // サービスオブジェクトを作成
  230.             $client = new Google_Client();
  231.             // このアプリケーション名
  232.             $client->setApplicationName('カレンダー操作テスト イベントの取得');
  233.             // ※ 注意ポイント: 権限の指定
  234.             // 予定を取得する時は Google_Service_Calendar::CALENDAR_READONLY
  235.             // 予定を追加する時は Google_Service_Calendar::CALENDAR_EVENTS
  236.             $client->setScopes(Google_Service_Calendar::CALENDAR_READONLY);
  237.             // ユーザーアカウントのjsonを指定
  238.             $client->setAuthConfig($aimJsonPath);
  239.             // サービスオブジェクトの用意
  240.             $service = new Google_Service_Calendar($client);
  241.             // カレンダーID 2024桜イベントのカレンダー設定
  242.             $calendarId 'cd71e0a784b8b714563997b9e6ddafab3fd57ee1f4f9e543a15861610afb9a22@group.calendar.google.com';
  243.             // 取得時の詳細設定
  244.             // 日付を最短
  245.             $optParams = array(
  246.                 'orderBy' => 'startTime',
  247.                 'singleEvents' => true,
  248.                 'timeMax' => date('c',strtotime("+3 month")),    //3か月分
  249.             );
  250.             $results $service->events->listEvents($calendarId$optParams);
  251.             //書式設定
  252.             $res['calendar']=true;
  253.             foreach( $results->getItems() as $event) {
  254.                 for($i=date('Ymd'strtotime$event->start->dateTime)); $i<=date('Ymd'strtotime($event->end->dateTime)); $i++){
  255.                     $year substr($i0,4);
  256.                     $month substr($i4,2);
  257.                     $day substr($i6,2);
  258.                     if(checkdate $month $day $year )) {
  259.                         $tmp=date('Y-m-d'strtotime($i));
  260.                         $res[$tmp] = $tmp;
  261.                     }
  262.                 }
  263.             }
  264.             //返却値
  265.             return [
  266.                 'events' => json_encode($res),
  267.                 'calendar_start_date' => date('Y-m-d'strtotime('+2 day')),
  268.             ];
  269.         } catch (\Exception $e) {
  270. //            log_error('getFavorites Exception: ',  $e->getMessage());
  271.             return [
  272.                 'testtest' => $e->getMessage(),
  273.                 'events' => json_encode($res),
  274.             ];
  275.         }
  276.     }
  277.     /**
  278.      * @Route("/plan/limited/reserved", name="limited_reserved", methods={"POST"})
  279.      * @Template("Plan/limited_reserved.twig")
  280.      */
  281.     public function limited_reserved()
  282.     {
  283.         try {
  284.             log_info('limited_reserved 開始');
  285. //             if(!$this->session->get('limited')) {
  286. //                 return $this->redirectToRoute('homepage');
  287. //             }
  288.             // カレンダーID
  289.             $calendarId "cd71e0a784b8b714563997b9e6ddafab3fd57ee1f4f9e543a15861610afb9a22@group.calendar.google.com";
  290.             $aimJsonPath './ornate-axiom-406706-fd999b268a9d.json';
  291.     
  292.             if($calendarId) {
  293.                 // サービスオブジェクトを作成
  294.                 $client = new Google_Client();
  295.                 // このアプリケーション名
  296.                 $client->setApplicationName('カレンダー操作テスト イベントの取得');
  297.                 // ※ 注意ポイント: 権限の指定
  298.                 // 予定を取得する時は Google_Service_Calendar::CALENDAR_READONLY
  299.                 // 予定を追加する時は Google_Service_Calendar::CALENDAR_EVENTS
  300.                 $client->setScopes(Google_Service_Calendar::CALENDAR_EVENTS);
  301.                 // ユーザーアカウントのjsonを指定
  302.                 $client->setAuthConfig($aimJsonPath);
  303.                 // サービスオブジェクトの用意
  304.                 $service = new Google_Service_Calendar($client);
  305.                 
  306.                 log_info('limited_reserved 開始4');
  307.                 $description "date:".$_POST['startdate'];
  308.                 $description .= "<br>name:".$_POST['name'];
  309.                 $description .= "<br>Country:".$_POST['country'];
  310.                 $description .= "<br>mail:".$_POST['email'];
  311.                 $description .= "<br>tel:".$_POST['telcode'].' '.$_POST['tel'];
  312.                 $description .= "<br>参加人数:".$_POST['participants'];
  313.                 $description .= "<br>pickup:".$_POST['pickup'];
  314.                 $description .= "<br>コメント:".$_POST['message'];
  315.                 $start_datetime = new Carbon($_POST['startdate']." 13:00:00");
  316.                 $end_datetime = new Carbon($_POST['startdate']." 20:00:00");
  317.                 $event = new Google_Service_Calendar_Event(array(
  318.                     'summary' => "Limited - name:".$_POST['name'],
  319.                     'start' => array(
  320.                         'dateTime' => $start_datetime,
  321.                         'timeZone' => 'Asia/Tokyo',
  322.                     ),
  323.                     'end' => array(
  324.                         'dateTime' => $end_datetime,
  325.                         'timeZone' => 'Asia/Tokyo',
  326.                     ),
  327.                     'description' => $description,
  328.                 ));
  329.                 log_info('limited_reserved $start_datetime:'.$start_datetime);
  330.                 log_info('limited_reserved $end_datetime:'.$end_datetime);
  331.                 log_info('limited_reserved $description:'.$description);
  332.                 log_info('limited_reserved 開始7');
  333.                 $event $service->events->insert($calendarId$event);
  334.                 log_info('limited_reserved 開始8');
  335.             }
  336.             //
  337.             //メール送信、24は「dtb_mail_template」のID
  338.             $this->mailService->sendReserveRequest($_POST,24);
  339.             $this->session->remove('limited');
  340.             log_info('limited_reserved 終了');
  341.             return [
  342.                 'testtest' => '',
  343.             ];
  344.         } catch (\Exception $e) {
  345.             log_info('limited_reserved Exception');
  346.             return [
  347.                 'testtest' => $e->getMessage(),
  348.             ];
  349.         }
  350.     }
  351.     /**
  352.     * @Route("/plan/fireworks", name="fireworks", methods={"GET"})
  353.     * @Template("Plan/fireworks.twig")
  354.     */
  355.     public function fireworks()
  356.     {
  357.         try {
  358.             $this->session->set('limited'"set");
  359.             //返却値
  360.             return [
  361.             ];
  362.         } catch (\Exception $e) {
  363. //            log_error('getFavorites Exception: ',  $e->getMessage());
  364.             return [
  365.                 'testtest' => $e->getMessage(),
  366.                 'events' => json_encode($res),
  367.             ];
  368.         }
  369.     }
  370.     /**
  371.      * @Route("/plan/fireworks/reserved", name="fireworks_reserved", methods={"POST"})
  372.      * @Template("Plan/fireworks_reserved.twig")
  373.      */
  374.     public function fireworks_reserved()
  375.     {
  376.         try {
  377.             log_info('fireworks_reserved 開始');
  378.              if(!$this->session->get('limited')) {
  379.                  return $this->redirectToRoute('homepage');
  380.              }
  381.             //メール送信、24は「dtb_mail_template」のID
  382.             $this->mailService->sendReserveRequest($_POST,25);
  383.             $this->session->remove('limited');
  384.             log_info('limited_reserved 終了');
  385.             return [
  386.                 'testtest' => '',
  387.             ];
  388.         } catch (\Exception $e) {
  389.             log_info('limited_reserved Exception');
  390.             return [
  391.                 'testtest' => $e->getMessage(),
  392.             ];
  393.         }
  394.     }
  395.     /**
  396.     * @Route("/plan/cruisefireworks", name="cruisefireworks", methods={"GET"})
  397.     * @Template("Plan/cruisefireworks.twig")
  398.     */
  399.     public function cruisefireworks()
  400.     {
  401.         try {
  402.             $this->session->set('limited'"set");
  403.             //返却値
  404.             return [
  405.             ];
  406.         } catch (\Exception $e) {
  407. //            log_error('getFavorites Exception: ',  $e->getMessage());
  408.             return [
  409.                 'testtest' => $e->getMessage(),
  410.                 'events' => json_encode($res),
  411.             ];
  412.         }
  413.     }
  414.     /**
  415.      * @Route("/plan/cruisefireworks/reserved", name="cruisefireworks_reserved", methods={"POST"})
  416.      * @Template("Plan/cruisefireworks_reserved.twig")
  417.      */
  418.     public function cruisefireworks_reserved()
  419.     {
  420.         try {
  421.             log_info('cruisefireworks_reserved 開始');
  422.              if(!$this->session->get('limited')) {
  423.                  return $this->redirectToRoute('homepage');
  424.              }
  425.             //メール送信、24は「dtb_mail_template」のID
  426.             $this->mailService->sendReserveRequest($_POST,25);
  427.             $this->session->remove('limited');
  428.             log_info('limited_reserved 終了');
  429.             return [
  430.                 'testtest' => '',
  431.             ];
  432.         } catch (\Exception $e) {
  433.             log_info('limited_reserved Exception');
  434.             return [
  435.                 'testtest' => $e->getMessage(),
  436.             ];
  437.         }
  438.     }
  439.     /**
  440.     * @Route("/plan/carlimited", name="carlimited", methods={"GET"})
  441.     * @Template("Plan/carlimited.twig")
  442.     */
  443.     public function carlimited()
  444.     {
  445.         try {
  446.             $this->session->set('limited'"set");
  447.             //返却値
  448.             return [
  449.             ];
  450.         } catch (\Exception $e) {
  451. //            log_error('getFavorites Exception: ',  $e->getMessage());
  452.             return [
  453.                 'testtest' => $e->getMessage(),
  454.                 'events' => json_encode($res),
  455.             ];
  456.         }
  457.     }
  458.     /**
  459.      * @Route("/plan/carlimited/reserved", name="carlimited_reserved", methods={"POST"})
  460.      * @Template("Plan/carlimited_reserved.twig")
  461.      */
  462.     public function carlimited_reserved()
  463.     {
  464.         try {
  465.             log_info('carlimited_reserved 開始');
  466.              if(!$this->session->get('limited')) {
  467.                  return $this->redirectToRoute('homepage');
  468.              }
  469.             //メール送信、28は「dtb_mail_template」のID
  470.             $this->mailService->sendReserveRequest($_POST,28);
  471.             $this->session->remove('limited');
  472.             log_info('carlimited_reserved 終了');
  473.             return [
  474.                 'testtest' => '',
  475.             ];
  476.         } catch (\Exception $e) {
  477.             log_info($e);
  478.             log_info('carlimited_reserved Exception');
  479.             return [
  480.                 'testtest' => $e->getMessage(),
  481.             ];
  482.         }
  483.     }
  484. }