app/Customize/Twig/Extension/ServiceExtension.php line 1126

Open in your IDE?
  1. <?php
  2. /**
  3.  * @version EC=CUBE4
  4.  * @copyright 株式会社 翔 kakeru.co.jp
  5.  * @author
  6.  * 2021年11月29日作成
  7.  *
  8.  * app\Customize\Twig\Extension\ServiceExtension.php
  9.  *
  10.  * TWIGからサービスの呼び出し
  11.  *
  12.  *
  13.  *
  14.  *                             C= C= C= ┌(;・_・)┘トコトコ
  15.  ******************************************************/
  16. namespace Customize\Twig\Extension;
  17. use Customize\Entity\CacheTrait;
  18. use Customize\Service\FavoriteService;
  19. use Customize\Service\GoodsPriceService;
  20. use Customize\Service\Google\ReCaptchaService;
  21. use Customize\Service\InventoryMatrixService;
  22. use Customize\Service\OrderService;
  23. use Customize\Service\Payment\PaymentService;
  24. use Customize\Service\SampleService;
  25. use DOMNamedNodeMap;
  26. use DOMNode;
  27. use Eccube\Entity\CartItem;
  28. use Eccube\Entity\OrderItem;
  29. use Eccube\Repository\ClassCategoryRepository;
  30. use Eccube\Repository\ProductRepository;
  31. use Lm\Engine\EC\Entity\GoodsWithRelated;
  32. use Lm\Engine\EC\Entity\Item\Item;
  33. use Lm\Engine\EC\Entity\OrderHeaderExtended;
  34. use Lm\Engine\InventoryMatrix\InventoryMatrix;
  35. use Lm\Engine\Zaiko\Yoyaku;
  36. use Lm\Entity\Goods;
  37. use Lm\Entity\OrderHeader;
  38. use Lm\Service\Cache\CacheService;
  39. use Lm\Util\Date;
  40. use Detection\MobileDetect as MobileDetector;
  41. use Symfony\Component\DependencyInjection\ContainerInterface;
  42. use Symfony\Component\DomCrawler\Crawler;
  43. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  44. use Symfony\Component\HttpFoundation\RequestStack;
  45. use Twig\Extension\AbstractExtension;
  46. use Twig\TwigFunction;
  47. use Twig\TwigFilter;
  48. use Twig\Environment as Twig;
  49. use Customize\Service\LmHelper;
  50. use Customize\Service\CustomerService;
  51. use Customize\Service\CommonService;
  52. use Eccube\Repository\ProductClassRepository;
  53. use Eccube\Repository\OrderRepository;
  54. use Eccube\Repository\Master\PrefRepository;
  55. use Eccube\Repository\Master\JobRepository;
  56. use Lm\Service\Db\SqlService;
  57. use Lm\Engine\NoukiKeisan\NoukiKeisan as NoukiEngine;
  58. use Customize\Service\CatalogService;
  59. use Customize\Service\CartService;
  60. use Customize\Service\GoodsService;
  61. use Customize\Service\MetaTagService;
  62. use Customize\Service\EstimateCharacterizer;
  63. use Eccube\Repository\Master\OrderItemTypeRepository;
  64. use Customize\Converter\OrderConverter;
  65. use Customize\Service\OrderHelper;
  66. use Customize\Service\AutoLoadService;
  67. use Customize\Service\MobileDetector as LmMobileDetector;
  68. use Lm\Engine\SokujitsuHassou\SokujitsuHassou;
  69. use Twig\TwigTest;
  70. use Customize\Converter\ProductConverter;
  71. class ServiceExtension extends AbstractExtension
  72. {
  73.     use CacheTrait;
  74.     const Cache1 'EstimateProductClassIds';
  75.     const MetatagTwig 'Common/MetaTags.twig';
  76.     const BreadCrumTwig 'Common/BreadCrumb.twig';
  77.     const EstimateTwig 'Common/Estimate.twig';
  78.     const ExclusionTwig 'Cart/Parts/Exclusion.twig';
  79.     const CartAddLineTwig 'Cart/Parts/Responsive/AddLine.twig';
  80.     const ShoppingEstimate 'Shopping/Parts/Estimate.twig';
  81.     const MobileShoppingEstimate 'Common/MobileEstimate.twig';
  82.     const MailEstimate 'Mail/Parts/Estimate.twig';
  83.     const JWeek = ['日''月''火''水''木''金''土'];
  84.     /**
  85.      * @var Container
  86.      */
  87.     protected $Container;
  88.     protected $Session;
  89.     protected $RequestStack;
  90.     protected $LmHelper;
  91.     protected $CustomerService;
  92.     protected $CommonService;
  93.     protected $PrefRepository;
  94.     protected $JobRepository;
  95.     protected $Router;
  96.     protected $Request;
  97.     protected $CatalogService;
  98.     protected $CartService;
  99.     protected $CatalogValue;
  100.     protected $GoodsService;
  101.     protected $Twig;
  102.     /**
  103.      * @var ProductRepository
  104.      */
  105.     private $ProductRepository;
  106.     protected $ProductClassRepository;
  107.     protected $Bank;
  108.     protected $CacheService;
  109.     protected $MetaTagService;
  110.     protected $EstimateCharacterizer;
  111.     protected $OrderItemTypeRepository;
  112.     protected $PaymentDetails = [];
  113.     protected $EstimateOptions = [];
  114.     protected $OrderConverter;
  115.     protected $OrderRepository;
  116.     protected $EstimateType;
  117.     protected $AutoLoadService;
  118.     protected $CartSortFlg;
  119.     /**
  120.      * @var MobileDetector
  121.      */
  122.     private $mobileDetector;
  123.     /**
  124.      * @var LmMobileDetector
  125.      */
  126.     private $LmMobileDetector;
  127.     /**
  128.      * @var FavoriteService
  129.      */
  130.     private $FavoriteService;
  131.     /**
  132.      * @var SampleService
  133.      */
  134.     private $SampleService;
  135.     /**
  136.      * @var OrderService
  137.      */
  138.     private $OrderService;
  139.     private $paymentService;
  140.     private $reCaptchaService;
  141.     private $productConverter;
  142.     public function __construct(ContainerInterface      $Container,
  143.                                 SessionInterface        $Session,
  144.                                 RequestStack            $RequestStack,
  145.                                 LmHelper                $LmHelper,
  146.                                 CustomerService         $CustomerService,
  147.                                 CommonService           $CommonService,
  148.                                 PrefRepository          $PrefRepository,
  149.                                 JobRepository           $JobRepository,
  150.                                 CatalogService          $CatalogService,
  151.                                 CartService             $CartService,
  152.                                 GoodsService            $GoodsService,
  153.                                 Twig                    $Twig,
  154.                                 ProductRepository       $productRepository,
  155.                                 ProductClassRepository  $ProductClassRepository,
  156.                                 ClassCategoryRepository $ClassCategoryRepository,
  157.                                 CacheService            $CacheService,
  158.                                 MetaTagService          $MetaTagService,
  159.                                 EstimateCharacterizer   $EstimateCharacterizer,
  160.                                 OrderItemTypeRepository $OrderItemTypeRepository,
  161.                                 OrderService            $orderService,
  162.                                 OrderConverter          $OrderConverter,
  163.                                 OrderRepository         $OrderRepository,
  164.                                 GoodsPriceService       $GoodsPriceService,
  165.                                 AutoLoadService         $AutoLoadService,
  166.                                 MobileDetector          $mobileDetector,
  167.                                 LmMobileDetector        $LmMobileDetector,
  168.                                 FavoriteService         $FavoriteService,
  169.                                 SampleService           $SampleService,
  170.                                 PaymentService          $paymentService,
  171.                                 InventoryMatrixService  $inventoryMatrixService,
  172.                                 ReCaptchaService        $reCaptchaService,
  173.                                 ProductConverter        $productConverter
  174.     )
  175.     {
  176.         $this->Container $Container;
  177.         $this->Session $Session;
  178.         $this->RequestStack $RequestStack;
  179.         $this->LmHelper $LmHelper;
  180.         $this->CustomerService $CustomerService;
  181.         $this->CommonService $CommonService;
  182.         $this->PrefRepository $PrefRepository;
  183.         $this->JobRepository $JobRepository;
  184.         $this->Router $Container->get('router');
  185.         $this->Request $RequestStack->getCurrentRequest();
  186.         $this->CatalogService $CatalogService;
  187.         $this->CartService $CartService;
  188.         $this->GoodsService $GoodsService;
  189.         $this->Twig $Twig;
  190.         $this->ProductRepository $productRepository;
  191.         $this->ProductClassRepository $ProductClassRepository;
  192.         $this->ClassCategoryRepository $ClassCategoryRepository;
  193.         $this->CacheService $CacheService;
  194.         $this->MetaTagService $MetaTagService;
  195.         $this->EstimateCharacterizer $EstimateCharacterizer;
  196.         $this->OrderItemTypeRepository $OrderItemTypeRepository;
  197.         $this->OrderService $orderService;
  198.         $this->OrderConverter $OrderConverter;
  199.         $this->OrderRepository $OrderRepository;
  200.         $this->GoodsPriceService $GoodsPriceService;
  201.         $this->AutoLoadService $AutoLoadService;
  202.         $this->mobileDetector $mobileDetector;
  203.         $this->LmMobileDetector $LmMobileDetector;
  204.         $this->FavoriteService $FavoriteService;
  205.         $this->SampleService $SampleService;
  206.         $this->paymentService $paymentService;
  207.         $this->inventoryMatrixService $inventoryMatrixService;
  208.         $this->reCaptchaService $reCaptchaService;
  209.         $this->productConverter $productConverter;
  210.     }
  211.     public function getFunctions()
  212.     {
  213.         return [
  214.             new TwigFunction('Service', function ($Service) {
  215.                 return new $Service($this->Container$this->RequestStack);
  216.             }, ['pre_escape' => 'html''is_safe' => ['html']]),
  217.             new TwigFunction('LmCssList', [$this'GetLmCssList']),
  218.             new TwigFunction('LmCartType', [$this'GetLmCartType']),
  219.             new TwigFunction('FristLogin', [$this'GetFirstLogin']),
  220.             new TwigFunction('AmazonLogin', [$this'GetAmazonLogin']),
  221.             new TwigFunction('GetPrefs', [$this'GetPrefs']),
  222.             new TwigFunction('GetLmCuatomer', [$this'GetLmCuatomer']),
  223.             new TwigFunction('GetJob', [$this'GetJob']),
  224.             new TwigFunction('GetPrivacy3', [$this'GetPrivacy3']),
  225.             new TwigFunction('OlToken', [$this'GetOlToken']),
  226.             new TwigFunction('RequestLmOrderOption', [$this->CommonService'RequestLmOrderOption']),
  227.             new TwigFunction('Survey', [$this->CommonService'SetSurvey']),
  228.             new TwigFunction('SurveyData', [$this->CommonService'SetSurveyData']),
  229.             new TwigFunction('RequestUri', [$this'GetRequestUri']),
  230.             new TwigFunction('CouponData', [$this'GetCouponData']),
  231.             new TwigFunction('InitiarizeLmOrederOption', [$this'SetInitiarizeLmOrederOption']),
  232.             new TwigFunction('DiscountName', [$this'SetDiscountName']),
  233.             new TwigFunction('SetReceipt', [$this'SetReceipt']),
  234.             new TwigFunction('Receipt', [$this'GetReceipt']),
  235.             new TwigFunction('LmOptionName', [$this'GetLmOptionName']),
  236.             new TwigFunction('CatalogLimit', [$this->CatalogService'GetLimit']),
  237.             new TwigFunction('CatalogLimitMessage', [$this'CatalogLimitMessage']),
  238.             new TwigFunction('CatalogValidation', [$this->CatalogService'CatalogValidation']),
  239.             new TwigFunction('CatalogChecked', [$this'GetCatalogChecked']),
  240.             new TwigFunction('ShoppingTitle', [$this'SetShoppingTitle']),
  241.             new TwigFunction('ShoppingConfirmBtn', [$this'ShoppingConfirmBtn']),
  242.             new TwigFunction('GetCatalogViews', [$this'GetCatalogViews']),
  243.             new TwigFunction('GetSampleCatalogs', [$this->CatalogService'GetSampleCatalogs']),
  244.             new TwigFunction('CartSumImage', [$this'GetCartSumImage']),
  245.             new TwigFunction('GoodsMainImage', [$this'GetGoodsMainImage']),
  246.             new TwigFunction('CartItemPullDown', [$this'GetCartItemPullDown']),
  247.             new TwigFunction('LoadStockLabel', [$this'getStockLabel']),
  248.             new TwigFunction('CartItemSizePullDown', [$this'GetCartItemSizePullDown']),
  249.             new TwigFunction('CartItemColorPullDown', [$this'GetCartItemColorPullDown']),
  250.             new TwigFunction('lm_tax', [$this'GetLmTax']),
  251.             new TwigFunction('Caet_item_stock', [$this'GetCartItmeStock']),
  252.             new TwigFunction('CartItemSameDayShippingFlg', [$this'GetCartItemSameDayShippingFlg']),
  253.             new TwigFunction('CartItemStockNumber', [$this'GetCartItemStockNumber']),
  254.             new TwigFunction('GetConfig', [$this'GetConfig']),
  255.             new TwigFunction('GetCartNextBtnText', [$this'GetCartNextBtnText']),
  256.             new TwigFunction('GetCartBackBtnText', [$this'GetCartBackBtnText']),
  257.             new TwigFunction('GetShoppingNextBtnText', [$this'GetShoppingNextBtnText']),
  258.             new TwigFunction('GetShoppingBackBtnText', [$this'GetShoppingBackBtnText']),
  259.             new TwigFunction('GetLmOrderOption', [$this'GetLmOrderOption']),
  260.             new TwigFunction('Bank', [$this'GetBank']),
  261.             new TwigFunction('JunctionMode', [$this->CommonService'GetJunctionMode']),
  262.             new TwigFunction('CartHybridBtn', [$this'SetCartHybridBtn']),
  263.             new TwigFunction('CartHybridBtnByCartItem', [$this'ShowCartHybridBtnByCartItem']),
  264.             new TwigFunction('ShowOrderItem', [$this'SetShowOrderItem']),
  265.             new TwigFunction('ExclusionControl', [$this'SetExclusionControl']),
  266.             new TwigFunction('SetMetaTags', [$this'SetMetaTags']),
  267.             new TwigFunction('HeaderH1', [$this'SetHeaderH1']),
  268.             new TwigFunction('SetBreadCrumb', [$this'SetBreadCrumb']),
  269.             new TwigFunction('EstimateCharaCart', [$this'SetEstimateCharaCart']),
  270.             new TwigFunction('ItemType', [$this'GetItemType']),
  271.             new TwigFunction('isSliderEnabled', [$this'isSliderEnabled']),
  272.             new TwigFunction('PaymentDetails', [$this'GetPaymentDetails']),
  273.             new TwigFunction('SetEstimateOptions', [$this'SetEstimateOptions']),
  274.             new TwigFunction('GetEstimateOption', [$this'GetEstimateOption']),
  275.             new TwigFunction('ShowEstimateOptions', [$this'ShowEstimateOptions']),
  276.             new TwigFunction('ShowEstimateMobileOptions', [$this'ShowEstimateMobileOptions']),
  277.             new TwigFunction('ShowEstimateOptionsMail', [$this'ShowEstimateOptionsMail']),
  278.             new TwigFunction('ZeusCardDatas', [$this'GetZeusCardDatas']),
  279.             new TwigFunction('ZeusCardError', [$this'GetZeusCardError']),
  280.             new TwigFunction('EstimateType', [$this'GetEstimateType']),
  281.             new TwigFunction('GetCustomerBangou', [$this'GetCustomerBangou']),
  282.             new TwigFunction('NariKawariSession', [$this->AutoLoadService'GetNariKawariSession']),
  283.             new TwigFunction('NariKawariFormData', [$this->AutoLoadService'GetNariKawariFormData']),
  284.             new TwigFunction('GetCatalogNoukiSchedule', [$this'getCatalogNoukiSchedule']),
  285.             new TwigFunction('CartSortFlg', [$this'GetCartSortFlg']),
  286.             new TwigFunction('CartAddLine', [$this'GetCartAddLine']),
  287.             new TwigFunction('PageType', [$this'getPageType']),
  288.             new TwigFunction('isMobile', [$this'isMobile']),
  289.             new TwigFunction('wannaSeePc', [$this'wannaSeePc']),
  290.             new TwigFunction('CartBackBtn', [$this'GetCartBackBtn']),
  291.             new TwigFunction('WithGetParams', [$this'WithGetParams']),
  292.             new TwigFunction('PageWithGetParams', [$this'PageWithGetParams']),
  293.             new TwigFunction('ShowSendScheduleDate', [$this'showSendScheduleDate']),
  294.             new TwigFunction('ShowSendScheduleMessage', [$this'showSendScheduleMessage']),
  295.             new TwigFunction('GetCategoryImageUrlById', [$this'getCategoryImageUrlById']),
  296.             new TwigFunction('EigyoubiCalendar', [$this->CommonService'EigyoubiCalendar']),
  297.             new TwigFunction('GetOrderPaymentId', [$this'getOrderPaymentId']),
  298.             new TwigFunction('GetShippingAddr03', [$this->CustomerService'getShippingAddr03']),
  299.             new TwigFunction('GetLandMarkCustomerInfo', [$this->CustomerService'GetLandMarkCustomerId']),
  300.             new TwigFunction('CalculateTotalQuantityForOrder', [$this->CommonService'calculateTotalQuantityForOrder']),
  301.             new TwigFunction('getMessageForPayment', [$this->paymentService'getMessage']),
  302.             new TwigFunction('GetFavoriteFlashMessage', [$this->FavoriteService'getFavoriteFlashMessage']),
  303.             new TwigFunction('GetFavoriteFlashGoods', [$this->FavoriteService'getFavoriteFlashGoods']),
  304.             new TwigFunction('FileUploadNotice', [$this'showFileSizeUpload']),
  305.             new TwigFunction('GetSampleLimitError', [$this->SampleService'getSampleLimitError']),
  306.             new TwigFunction('formatDataToJson', [$this'formatDataToJson']),
  307.             new TwigFunction('getCurrentBreadcrumb', [$this'getCurrentBreadcrumb']),
  308.             new TwigFunction('getCartSessionName', [$this'getCartSessionName']),
  309.             new TwigFunction('groupItemsHasSameProductId', [$this'groupItemsHasSameProductId']),
  310.             new TwigFunction('getColorRGBCode', [$this'getColorRGBCode']),
  311.             new TwigFunction('formatDate', [$this'formatDate']),
  312.             new TwigFunction('formatMonthAndDay', [$this'formatMonthAndDay']),
  313.             new TwigFunction('getToTraceParent', function () {
  314.                 return $this->RequestStack->getCurrentRequest()->attributes->get('toTraceParent');
  315.             }),
  316.             new TwigFunction('getTrackId', function () {
  317.                 return $this->RequestStack->getCurrentRequest()->attributes->get('toTrackId');
  318.             }),
  319.             new TwigFunction('getInventoryMatrix', [$this'getInventoryMatrixData']),
  320.             new TwigFunction('shouldProcessReCaptcha', [$this->reCaptchaService'shouldProcessReCaptcha']),
  321.             new TwigFunction('showYoyakuFlag', [$this'showYoyakuFlag']),
  322.             new TwigFunction('showSokujitsuHassouBannerIfSo', [$this'showSokujitsuHassouBannerIfSo']),
  323.         ];
  324.     }
  325.     /**
  326.      * Get inventory matrix via cache
  327.      *
  328.      * @param GoodsWithRelated $goods
  329.      * @param $color
  330.      * @param $size
  331.      * @return mixed|null
  332.      * @throws \Psr\Cache\InvalidArgumentException
  333.      */
  334.     public function getInventoryMatrixData(GoodsWithRelated $goods, &$color null, &$size null)
  335.     {
  336.         $cacheKey $this->LmHelper->getCacheKey("getInventoryMatrixData", [$goods$color$size]);
  337.         $id $goods->getGoodsId();
  338.         $stock $this->GoodsService->getGoodsStock($id1); // value of stock is not should cache
  339.         return $this->getCacheByKey($cacheKey, function () use ($goods$color$size$stock$id) {
  340.             // JAN情報(=product_class id)
  341.             list($jan$janColor) = $this->productConverter->getGoodsJanById($id);
  342.             // 色情報
  343.             $color $this->GoodsService->getGoodsColorSelectSql($id);
  344.             // サイズ情報
  345.             $size $this->GoodsService->getGoodsSizeListById($id);
  346.             // 商品即日情報
  347.             $sokujitsu $this->GoodsService->getGoodsSameDayShipping($id1);
  348.             // 商品在庫情報
  349.             // 商品予約情報
  350.             $yoyaku $this->GoodsService->getGoodsReservation($id1);
  351.             // 商品入荷予定日情報
  352.             $yoteibi $this->GoodsService->getGoodsStockDate($id1);
  353.             // カートマトリックス用のデータ生成
  354.             $matrixData = [];
  355.             $matrixData_cnt = [];
  356.             $line 0;
  357.             $sizeMax = ($this->LmMobileDetector->isMobile() ? 999 8);
  358.             $max 0;
  359.             foreach ($color as $v1) {
  360.                 $line++;
  361.                 $line2 0;
  362.                 $no 1;
  363.                 foreach ($size as $v2) {
  364.                     if ($line2 % ($sizeMax) === 0) {
  365.                         $no++;
  366.                     } else {
  367.                         $max $line2 % ($sizeMax);
  368.                     }
  369.                     $tmpYoteibi NULL;
  370.                     if (!empty($yoteibi[$v1["gcl_id"]][$v2["gp_id"]]) and $sokujitsu[$v1["gcl_id"]][$v2["gp_id"]] <= SokujitsuHassou::FLG_NONE) {
  371.                         $tmpYoteibi date("n月j日"strtotime($yoteibi[$v1["gcl_id"]][$v2["gp_id"]]));
  372.                     }
  373.                     $matrixData_cnt[$no] = $max;
  374.                     $matrixData[$no][$line][$line2] = [
  375.                         'line' => $line,
  376.                         'product_id' => $jan[$v1["gcl_id"]][$v2["gp_id"]],
  377.                         'shiire_color' => $janColor[$v1["gcl_id"]][$v2["gp_id"]],
  378.                         'color' => $v1,
  379.                         'size' => $v2,
  380.                         'stock' => $stock[$v1["gcl_id"]][$v2["gp_id"]],
  381.                         'yoyaku' => $yoyaku[$v1["gcl_id"]][$v2["gp_id"]],
  382.                         'yoteibi' => $tmpYoteibi,
  383.                         'sokujitsu' => $sokujitsu[$v1["gcl_id"]][$v2["gp_id"]],
  384.                     ];
  385.                     $line2++;
  386.                 }
  387.             }
  388.             return $matrixData;
  389.         });
  390.     }
  391.     public function getFilters()
  392.     {
  393.         return [
  394.             new TwigFilter('Base', [$this'BaseInfo']),
  395.             new TwigFilter('LmPrice', [$this'GetLmPrice']),
  396.             new TwigFilter('FormatPrice', [$this'FormatPrice']),
  397.             new TwigFilter('phone', [$this'SetPhone']),
  398.             new TwigFilter('post', [$this'SetPost']),
  399.             new TwigFilter('jweek', [$this'SetJWeek']),
  400.             new TwigFilter('AjaxPrice', [$this->GoodsPriceService'embedGoodsPrice']),
  401.             new TwigFilter('OrderId', [$this->LmHelper'convertOrderToOrderId']),
  402.             new TwigFilter('InventoryMatrix', [$this'showInventoryMatrix']),
  403.             new TwigFilter('LmWebTeika', [$this'filterLmWebTeika']),
  404.             new TwigFilter('LmWebPrice', [$this'filterLmWebPrice']),
  405.         ];
  406.     }
  407.     public function getTests()
  408.     {
  409.         return [
  410.             new TwigTest('numeric''is_numeric'),
  411.         ];
  412.     }
  413.     /**
  414.      * Master Job をゲットする
  415.      *
  416.      * @return obj Job
  417.      */
  418.     public function GetPrefs()
  419.     {
  420.         return $this->PrefRepository->finsBy([], ['sort_no' => 'asc']);
  421.     }
  422.     public function GetJob()
  423.     {
  424.         return $this->JobRepository->findBy([], ['sort_no' => 'asc']);
  425.     }
  426.     /**
  427.      * TWIG に LMカートタイプを返す
  428.      *   cart_type:
  429.      * 1 -- 購入(加工なし)
  430.      * 2 -- 購入(加工あり(加工なしとの混在含む))
  431.      * 3 -- 貸出サンプル
  432.      * 4 -- カタログ請求
  433.      */
  434.     public function GetLmCartType()
  435.     {
  436.         return $this->LmHelper->getCartType();
  437.     }
  438.     /**
  439.      * 初回ログイン
  440.      *
  441.      */
  442.     public function GetFirstLogin()
  443.     {
  444.         $Flg $this->CustomerService->GetFirstLoginFlg();
  445.         $this->CustomerService->SetFirstLoginFlg(null);
  446.         return $Flg;
  447.     }
  448.     public function GetLmCuatomer($Eail)
  449.     {
  450.         if (!$Lmcustomer $this->CustomerService->GetLandMarkCustomerEmail($Eail)) {
  451.             $Columns $this->CommonService->GetYaml('LmCustomer.yaml');
  452.             foreach ($Columns as $Column) {
  453.                 switch ($Column) {
  454.                     case 'address03':
  455.                         $Lmcustomer['customer_address3'] = '';
  456.                         break;
  457.                     case 'fax_number':
  458.                         $Lmcustomer['customer_fax'] = '';
  459.                         break;
  460.                     default:
  461.                         $Lmcustomer[$Column] = '';
  462.                         break;
  463.                 }
  464.             }
  465.         };
  466.         return $Lmcustomer;
  467.     }
  468.     /**
  469.      * アマゾンログイン
  470.      *
  471.      */
  472.     public function GetAmazonLogin()
  473.     {
  474.         return $this->CustomerService->GetAmazonLoginFlg();
  475.     }
  476.     /**
  477.      *  LMプライバシーポリシーの取得
  478.      *
  479.      * @return string admin_privacy3
  480.      */
  481.     public function GetPrivacy3()
  482.     {
  483.         $Sql = new SqlService;
  484.         $Data $Sql->Table('admin_table')
  485.             ->Find();
  486.         return $Data['admin_privacy3'] ?? '';
  487.     }
  488.     /**
  489.      * オリジナルトークンを返す
  490.      * @param string $Cd
  491.      * @param string $name 'token'
  492.      *
  493.      * @return string $Token
  494.      */
  495.     public function GetOlToken($Cd$Name 'token')
  496.     {
  497.         return $this->CommonService->ResetToken($Cd$Name);
  498.     }
  499.     /**
  500.      * クーポンの値引き時 リダイレクト先URIを返す
  501.      *
  502.      */
  503.     public function GetRequestUri()
  504.     {
  505.         return $this->Request->server->get('REQUEST_URI');
  506.     }
  507.     /**
  508.      * クーポンのData
  509.      *
  510.      */
  511.     public function GetCouponData()
  512.     {
  513.         return $this->CommonService->GetLmOrderOption(CommonService::Lm_Option_Coupon);
  514.     }
  515.     /**
  516.      * 領収書
  517.      *
  518.      */
  519.     public function SetReceipt($CompanyName$Name$Write)
  520.     {
  521.         $Receipt $this->CommonService->GetLmOrderOption(CommonService::Lm_Option_Receipt);
  522.         $Re $Receipt;
  523.         $Re['flg'] = [''''];
  524.         if (!$Receipt) {
  525.             $Re['name'] = $CompanyName $CompanyName $Name;
  526.             $Re['flg'][0] = 'checked="checked"';
  527.             $Re['write'] = $Write;
  528.             $Re['comment'] = '';
  529.         } else {
  530.             $Re['flg'][$Receipt['flg']] = 'checked="checked"';
  531.         }
  532.         return $Re;
  533.     }
  534.     public function GetReceipt()
  535.     {
  536.         if (!$Receipt $this->CommonService->GetLmOrderOption(CommonService::Lm_Option_Receipt)) {
  537.             return false;
  538.         }
  539.         return $Receipt['flg'] == false $Receipt;
  540.     }
  541.     public function GetLmOptionName($Name null)
  542.     {
  543.         switch ($Name) {
  544.             case 'catalog':
  545.                 $Re CommonService::Lm_Option_Catalog;
  546.                 break;
  547.             case 'receipt';
  548.             default:
  549.                 $Re CommonService::Lm_Option_Receipt;
  550.                 break;
  551.         }
  552.         return $Re;
  553.     }
  554.     /**
  555.      * LMOrderPption 初期化
  556.      *
  557.      */
  558.     public function SetInitiarizeLmOrederOption($OrderId)
  559.     {
  560.         $this->CommonService->SetInitiarizeLmOrederOption($OrderId);
  561.     }
  562.     public function SetShoppingTitle($Message$Num)
  563.     {
  564.         $Message trans($Message);
  565.         if (is_null($Num)) {
  566.             return $Message;
  567.         }
  568.         return $this->LmHelper->getCartType() <= CartService::CartTypeEstimate $Num '.' $Message $Message;
  569.     }
  570.     /**
  571.      * 確認気年のボタン
  572.      *
  573.      * @return string
  574.      */
  575.     public function ShoppingConfirmBtn()
  576.     {
  577.         $Message 'front.shopping.checkout';
  578.         switch ($this->LmHelper->getCartType()) {
  579.             case CartService::CartTypeCatalog:
  580.                 $Message 'front.Shopping_Button04';
  581.                 break;
  582.             case CartService::CartTypeNormal:
  583.             default:
  584.                 break;
  585.         }
  586.         return $Message;
  587.     }
  588.     public function GetCatalogChecked($Id$Name null)
  589.     {
  590.         $Checked = ['''checked="checked"'];
  591.         if ('Open' == $Name) {
  592.             $OpenCtalog $this->CommonService->GetLmOrderOption('OpenCatalog');
  593.             if (is_null($OpenCtalog) && $Id == 0) {
  594.                 return $Checked[1];
  595.             }
  596.             return $Id == $OpenCtalog $Checked[1] : $Checked[0];
  597.         }
  598.         if (!$this->CatalogValue) {
  599.             if ($Value $this->CommonService->GetLmOrderOption(CommonService::Lm_Option_Catalog)) {
  600.                 $this->CatalogValue array_flip($Value);
  601.             }
  602.         }
  603.         if (isset($this->CatalogValue[$Id])) {
  604.             return $Checked[1];
  605.         }
  606.         return $Checked[0];
  607.     }
  608.     public function GetLmOrderOption($name)
  609.     {
  610.         return $this->CommonService->GetLmOrderOption($name);
  611.     }
  612.     /**
  613.      * LMOrderPption クーポン
  614.      * ショッピング 表示
  615.      *
  616.      * @return string $name
  617.      */
  618.     public function SetDiscountName()
  619.     {
  620.         return $this->CommonService->GetLmOrderOption(CommonService::Lm_Option_Coupon) ? 'クーポン' trans('common.discount');
  621.     }
  622.     /**
  623.      * カタログの札数メッセージ
  624.      *
  625.      * @param int num
  626.      *
  627.      * @return string メッセージ
  628.      */
  629.     public function CatalogLimitMessage($Num)
  630.     {
  631.         return str_replace('@@'$Numtrans('front.cart_catalog.message09'));
  632.     }
  633.     public function CatalogValidation()
  634.     {
  635.         if (CartService::CartTypeCatalog != $this->CartService->getCartType()) {
  636.             return false;
  637.         }
  638.         return $this->CatalogService->CatalogValidation();
  639.     }
  640.     public function GetCatalogViews()
  641.     {
  642.         return $this->CatalogService->GetView();
  643.     }
  644.     /**
  645.      * カートにて サムネイルのURLを生成する
  646.      *
  647.      */
  648.     public function GetCartSumImage($ProductId)
  649.     {
  650.         $Dir substr($ProductId, -1);
  651.         return "/goods.img/{$Dir}/{$ProductId}/main_sum.jpg";
  652.     }
  653.     /**
  654.      * カートにて サムネイルのURLを生成する
  655.      *
  656.      */
  657.     public function GetGoodsMainImage($ProductId)
  658.     {
  659.         $Dir substr($ProductId, -1);
  660.         return "/goods.img/{$Dir}/{$ProductId}/main.jpg";
  661.     }
  662.     /**
  663.      * LMの価格に対して 税込価格を返す
  664.      *
  665.      */
  666.     public function GetLmTax($ProductClassId)
  667.     {
  668.         $ProductClass $this->ProductClassRepository->find($ProductClassId);
  669.         return $ProductClass->getPrice02IncTax();
  670.     }
  671.     /**
  672.      * LM在庫数を返す
  673.      *
  674.      * 0 ・・・ 在庫なし
  675.      * 1以上 ・・・ 在庫あり
  676.      * # null ・・・ 99(入荷予定)
  677.      * #  *   ・・・ 999
  678.      *`@param int ClassId
  679.      *
  680.      * @return string 在庫数
  681.      */
  682.     public function GetCartItmeStock($ProductClass)
  683.     {
  684.         $ClassId $ProductClass->getId();
  685.         $Stock $this->GoodsService->getValidationStock($ClassId);
  686.         $Re '';
  687.         switch (true) {
  688.             case is_null($Stock):
  689.                 $Re trans('front.cart_item.title10');
  690.                 break;
  691.             case $Stock == 0:
  692.                 $Re trans('front.cart_item.title11');;
  693.                 break;
  694.             default:
  695.                 $Text $this->CommonService->GetConfig('ESTIMATE_TEXT');
  696.                 $Re $Text['Text23'] . number_format($Stock) . $Text['Text04'];
  697.                 break;
  698.         }
  699.         return $Re;
  700.     }
  701.     public function GetCartItemSameDayShippingFlg($ProductClass$quantity null)
  702.     {
  703.         $result $this->GoodsService->getGoodsSameDayShipping($ProductClass->getProduct()->getId(), 0$ProductClass->getId(), nullnull$quantity);
  704.         return $result;
  705.     }
  706.     public function GetCartItemStockNumber($productClass$sameShippingFlg)
  707.     {
  708.         $stock $this->GoodsService->getGoodsStock(nullfalse$productClass->getId());
  709.         if ($sameShippingFlg SokujitsuHassou::FLG_NONE) {
  710.             return $stock['stock_sokujitsu'];
  711.         } else {
  712.             return $stock['stock_total'];
  713.         }
  714.     }
  715.     public function GetCartNextBtnText()
  716.     {
  717.         switch ($this->GetLmCartType()) {
  718.             case CartService::CartTypeSample:
  719.                 return 'サンプル申込の手続きへ';
  720.             case CartService::CartTypeNormal:
  721.             case CartService::CartTypeEstimate:
  722.             default:
  723.                 return '次へ(レジへ進む)';
  724.         }
  725.     }
  726.     public function GetCartBackBtnText()
  727.     {
  728.         switch ($this->GetLmCartType()) {
  729.             case CartService::CartTypeSample:
  730.                 return '他にもサンプル申込商品を選ぶ';
  731.             case CartService::CartTypeNormal:
  732.             case CartService::CartTypeEstimate:
  733.             default:
  734.                 return '買い物を続ける';
  735.         }
  736.     }
  737.     public function GetShoppingNextBtnText()
  738.     {
  739.         switch ($this->GetLmCartType()) {
  740.             case CartService::CartTypeSample:
  741.                 return '同意して次へ';
  742.             case CartService::CartTypeCatalog:
  743.                 return '送信する';
  744.             case CartService::CartTypeNormal:
  745.             case CartService::CartTypeEstimate:
  746.             default:
  747.                 return '確認画面に進む';
  748.         }
  749.     }
  750.     public function GetShoppingBackBtnText()
  751.     {
  752.         switch ($this->GetLmCartType()) {
  753.             case CartService::CartTypeCatalog:
  754.                 return '入力画面に戻る';
  755.             case CartService::CartTypeNormal:
  756.             case CartService::CartTypeEstimate:
  757.             case CartService::CartTypeSample:
  758.             default:
  759.                 return 'カートに戻る';
  760.         }
  761.     }
  762.     public function GetConfig($key)
  763.     {
  764.         return $this->LmHelper->getConfig($key);
  765.     }
  766.     public function getColorRGBCode($productId)
  767.     {
  768.         $colors = [];
  769.         $goodColors $this->GoodsService->getGoodsColorSelectSql($productId);
  770.         if (is_array($goodColors) && count($goodColors) > 0) {
  771.             foreach ($goodColors as $goodColor) {
  772.                 if (!$goodColor['color_name']) {
  773.                     continue;
  774.                 }
  775.                 $id $this->LmHelper->convGclIdToClassCategory1Id($goodColor['gcl_id']);
  776.                 $colors[$id] = $goodColor['color_rgb'];
  777.             }
  778.         }
  779.         return $colors;
  780.     }
  781.     public function GetCartItemColorPullDown($ItemId$ProductId$classCategory1Id$EstimateId$EmptyOptionAsFirst false)
  782.     {
  783.         //
  784.         $Type 'color';
  785.         //
  786.         $Data = [];
  787.         $Value null;
  788.         $Id 0;
  789.         //
  790.         $kbn 1;
  791.         if ($classCategory1Id) {
  792.             $ClassCategory1 $this->ClassCategoryRepository->find($classCategory1Id);
  793.             $Value $ClassCategory1->getId();
  794.             $ClassName $ClassCategory1->getClassName();
  795.             $kbn $ClassName->getId();
  796.         }
  797.         foreach ($this->GoodsService->getGoodsColorSelectSql($ProductId) as $Val) {
  798.             if (!$Val['color_name']) {
  799.                 continue;
  800.             }
  801.             $Id $this->LmHelper->convGclIdToClassCategory1Id($Val['gcl_id']);
  802.             $Selected = !$EmptyOptionAsFirst && $Value == $Id 'selected="selected"' '';
  803.             $Rgb 'data-rgb=#' $Val['color_rgb'];
  804.             $Data[$Id] = [
  805.                 'name' => $Val['color_name'],
  806.                 'Selected' => $Selected,
  807.                 'disabled' => '',
  808.                 'Data' => $Rgb
  809.             ];
  810.         };
  811.         //
  812.         return $this->GetCartItemPullDown($ItemId$ProductId$Type$Data$Value$EstimateId$EmptyOptionAsFirst);
  813.     }
  814.     public function GetCartItemSizePullDown($ItemId$ProductId$classCategory2Id$classCategory1Id$EstimateId$EmptyOptionAsFirst false)
  815.     {
  816.         //
  817.         $Type 'size';
  818.         //
  819.         $Data = [];
  820.         $Value null;
  821.         $Id 0;
  822.         //
  823.         $kbn 2;
  824.         if ($classCategory2Id) {
  825.             $ClassCategory2 $this->ClassCategoryRepository->find($classCategory2Id);
  826.             $Value $ClassCategory2->getId();
  827.             $ClassName $ClassCategory2->getClassName();
  828.             $kbn $ClassName->getId();
  829.         }
  830.         if ($classCategory1Id) {
  831.             //
  832.             $ClassCategory1 $this->ClassCategoryRepository->find($classCategory1Id);
  833.             $sizeList $this->GoodsService->getGoodsSizeListWithStockInfoByClassCategory1($ClassCategory1);
  834.         } else {
  835.             $sizeList $this->GoodsService->getGoodsSizeListById($ProductId);
  836.         }
  837.         foreach ($sizeList as $Val) {
  838.             if (!$Val['size_name']) {
  839.                 continue;
  840.             }
  841.             $Id $this->LmHelper->convGpIdToClassCategory2Id($Val['gp_id']);
  842.             $Selected = !$EmptyOptionAsFirst && $Value == $Id 'selected="selected"' '';
  843.             $disabled = (isset($Val['disabled']) && $Val['disabled'] === 1) ? 'disabled' '';
  844.             $Data[$Id] = [
  845.                 'name' => $Val['size_name'],
  846.                 'Selected' => $Selected,
  847.                 'disabled' => $disabled,
  848.                 'Data' => ''
  849.             ];
  850.         };
  851.         //
  852.         return $this->GetCartItemPullDown($ItemId$ProductId$Type$Data$Value$EstimateId$EmptyOptionAsFirst);
  853.     }
  854.     public function GetCartItemPullDown($ItemId$ProductId$Type$ItemDatas$Value$EstimateId$EmptyOptionAsFirst false)
  855.     {
  856.         //
  857.         $Re = [
  858.             'ItemId' => $ItemId,
  859.             'ProductId' => $ProductId,
  860.             'Type' => $Type,
  861.             'ItemDatas' => $ItemDatas,
  862.             'Value' => $Value,
  863.             'EstimateId' => $EstimateId,
  864.             'EmptyOptionAsFirst' => $EmptyOptionAsFirst
  865.         ];
  866.         //
  867.         return $this->Twig->render('Cart/Parts/PullDown.twig'$Re);
  868.     }
  869.     public function getStockLabel($ProductId$ClassCategory1Id$ClassCategory2Id)
  870.     {
  871.         //
  872.         $context = [
  873.             'ProductClass' => $this->ProductClassRepository->findOneBy([
  874.                 'Product' => $ProductId,
  875.                 'ClassCategory1' => $ClassCategory1Id,
  876.                 'ClassCategory2' => $ClassCategory2Id,
  877.             ]),
  878.         ];
  879.         //
  880.         return $this->Twig->render('Cart/Parts/StockLabel.twig'$context);
  881.     }
  882.     public function GetBank($Name$Bancode '')
  883.     {
  884.         if (!$this->Bank) {
  885.             $Banks $this->CommonService->GetYaml('Bank.yaml');
  886.             if ($Bancode) {
  887.                 $this->Bank $Banks[1];
  888.                 $this->Bank['account'] = $Bancode;
  889.             } else {
  890.                 $this->Bank $Banks[0];
  891.             }
  892.         }
  893.         return $this->Bank[$Name];
  894.     }
  895.     /**
  896.      * ハイブリッドボタンの設置
  897.      * 1 サンプルは出力しない
  898.      * 2 加工できない商品は出力しない
  899.      * 3 分割対応  2022/10/20
  900.      */
  901.     public function SetCartHybridBtn($ProductId$EstimateId$ItemId$btnName null)
  902.     {
  903.         #1
  904.         if ($this->CartService->getCartType() >= CartService::CartTypeSample) {
  905.             return;
  906.         }
  907.         #2
  908.         if (!$Type GoodsService::getEnableEstimateTypeById($ProductId)) {
  909.             return;
  910.         }
  911.         #3
  912.         if (CartService::CartTypeEstimate == $this->CartService->GetCartType() &&
  913.             $this->CommonService->GetConfig('BunkaruFlg') == false) {
  914.             $this->EstimateType $this->EstimateType ?? $this->CartService->GetEstimateType();
  915.         }
  916.         if (is_numeric($ItemId)) {
  917.             $Itemids $ItemId;
  918.         } else {
  919.             $Ids = [];
  920.             foreach ($ItemId as $Item) {
  921.                 if ($Item->getEstimateId() != $EstimateId) {
  922.                     continue;
  923.                 }
  924.                 $productItemId $Item->getProductClass()->getProduct()->getId();
  925.                 if (!GoodsService::getEnableEstimateTypeById($productItemId)) {
  926.                     continue;
  927.                 }
  928.                 $Ids[] = $Item->getId();
  929.             }
  930.             $Itemids implode(','$Ids);
  931.         }
  932.         $Re = [
  933.             'ItemIds' => $Itemids,
  934.             'Name' => $btnName ?? trans('front.cart_item_button04_' $Type),
  935.             'EstimateId' => $EstimateId,
  936.             'Type' => $ProductId,
  937.         ];
  938.         return $this->Twig->render('Cart/Parts/CartHybridBtn.twig'$Re);
  939.     }
  940.     /**
  941.      * @param CartItem $CartItem
  942.      * @return string
  943.      */
  944.     public function ShowCartHybridBtnByCartItem(CartItem $CartItem)
  945.     {
  946.         //
  947.         $ProductId $CartItem->getProductClass()->getProduct()->getId();
  948.         $EstimateId $CartItem->getEstimateId();
  949.         // TODO: 旧・セット品番への対応
  950.         // // $ItemId = array_filter(is_array($CartItems = $CartItem->getCart()->getCartItems()) ? $CartItems : $CartItems->toArray(), function ($CartItem) {
  951.         // //     /**
  952.         // //      * @var CartItem $CartItem
  953.         // //      */
  954.         // //     return !$this->CartService->isProductNoOptions($CartItem->getProductClass()->getProduct()->getId());
  955.         // // });
  956.         $ItemId $CartItem->getCart()->getCartItems();
  957.         $btnName $CartItem->isSusoage() ? '裾上げ内容の変更' '加工内容の変更';
  958.         //
  959.         return $this->SetCartHybridBtn($ProductId$EstimateId$ItemId$btnName);
  960.     }
  961.     public function SetShowOrderItem($Order$Type)
  962.     {
  963.         $Item null;
  964.         foreach ($Order->getOrderItems() as $OrderItem) {
  965.             $OrderItemType $OrderItem->getOrderItemType();
  966.             if ($Type == $OrderItemType->getId()) {
  967.                 $Item $OrderItem;
  968.             }
  969.         };
  970.         if (!$Item) {
  971.             return '';
  972.         }
  973.         $Re = [
  974.             'Item' => $Item,
  975.             'Type' => $Item->getOrderItemType(),
  976.         ];
  977.         return $this->Twig->render('Shopping/Parts/OrderItem.twig'$Re);
  978.     }
  979.     /**
  980.      * カート排他制御
  981.      *
  982.      */
  983.     public function SetExclusionControl()
  984.     {
  985.         $Type '';
  986.         if (!$Type $this->Session->get(CartService::Session_ExclusionControlFlg)) {
  987.             return;
  988.         };
  989.         #2022/10/22 リピート注文特殊処理 Cartエラーで返せない
  990.         switch ($Type) {
  991.             case CartService::RepeatError01:
  992.                 $Messages[] = trans('front.Cart.Repeat_message01');
  993.                 break;
  994.             case CartService::RepeatError02:
  995.                 $Messages[] = trans('front.ExclusionControl.message04');
  996.                 break;
  997.             case CartService::RepeatError03:
  998.                 $Messages[] = trans('front.ExclusionControl.message05');
  999.                 break;
  1000.             default:
  1001.                 for ($i 1$i <= 2$i++) {
  1002.                     $Messages[] = $this->CommonService->SetExclusionControl($Type$i);
  1003.                 }
  1004.                 break;
  1005.         }
  1006.         $this->Session->set(CartService::Session_ExclusionControlFlgnull);
  1007.         return $this->Twig->render(self::ExclusionTwig,
  1008.             [
  1009.                 'Messages' => $Messages,
  1010.             ]);
  1011.     }
  1012.     public function SetMetaTags($Datas)
  1013.     {
  1014.         $Key array_key_first($Datas);
  1015.         $Data $Datas[$Key] ?? null;
  1016.         switch (true) {
  1017.             case $Key === 'item':
  1018.                 $this->MetaTagService->SetItem($Datas[$Key]);
  1019.                 $Image $this->LmHelper->getGoodsImageUrl($Data['goods_id'], 'main.jpg');
  1020.                 $this->MetaTagService->SetOpgs(4$Image);
  1021.                 break;
  1022.             case $Key === 'SubCategory':
  1023.             case $Key === 'Category':
  1024.                 $this->MetaTagService->SetCategory($Datas[$Key]);
  1025.                 $this->MetaTagService->SetOpgs();
  1026.                 break;
  1027.             case $Key === 'message':
  1028.                 $this->MetaTagService->SetMessage($Datas[$Key]);
  1029.                 $this->MetaTagService->SetOpgs();
  1030.                 break;
  1031.             case $Key === 'review':
  1032.                 $this->MetaTagService->SetReview($Datas[$Key]);
  1033.                 $this->MetaTagService->SetOpgs(4);
  1034.                 break;
  1035.             case $Key === 0:
  1036.                 $this->MetaTagService->SetMetaTags($Data); //
  1037.                 break;
  1038.             default:
  1039.                 $this->MetaTagService->SetMetaPages(); //
  1040.                 break;
  1041.         }
  1042.         return $this->Twig->render(self::MetatagTwig, [
  1043.             'Title' => $this->MetaTagService->GetTitle(),
  1044.             'MetaTags' => $this->MetaTagService->GetMetaTags(),
  1045.             'Opgs' => $this->MetaTagService->GetOpgs(),
  1046.             'UrlName' => $this->Request->get('_route'),
  1047.         ]);
  1048.     }
  1049.     public function SetHeaderH1()
  1050.     {
  1051.         return $this->MetaTagService->GetHeaderH1();
  1052.     }
  1053.     /**
  1054.      * パンクズを一括管理する
  1055.      * @param $BreadCrumbs  string | array none 非表示
  1056.      * 1 第一因子を TOPページとする 固定
  1057.      * 2 BreadCrumbsのKEYを1にすると 最後に ページ名を追加します
  1058.      * 3 配列の内容は、KEYが href' 'label' になります
  1059.      */
  1060.     public function SetBreadCrumb($BreadCrumbs)
  1061.     {
  1062.         $Type $BreadCrumbs[0] ?? null;
  1063.         if (!is_array($Type) && $Type == 'none') {
  1064.             return;
  1065.         }
  1066.         $this->getBreadCrumb('homepage');
  1067.         $Re[] = $this->getBreadCrumb('homepage');
  1068.         #第一因子 (0)
  1069.         $UrlName $this->Request->get('_route');
  1070.         if (count($BreadCrumbs) > 0) {
  1071.             foreach ($BreadCrumbs as $Key => $BreadCrumb) {
  1072.                 $BC['label'] = $BreadCrumb['label'] ?? '';
  1073.                 $BC['href'] = $BreadCrumb['href'] ?? '';
  1074.                 switch (array_key_first($BreadCrumbs)) {
  1075.                     case 1:
  1076.                         $Re[] = $BC;
  1077.                         $Re[] = $this->getBreadCrumb($UrlName);
  1078.                         break;
  1079.                     default:
  1080.                         $Re[] = $BC;
  1081.                 }
  1082.             }
  1083.         } else {
  1084.             $Re[] = $this->getBreadCrumb($UrlName);
  1085.         }
  1086.         return $this->Twig->render(self::BreadCrumTwig, [
  1087.             'BreadCrumbs' => $Re,
  1088.         ]);
  1089.     }
  1090.     protected function getBreadCrumb($UrlName)
  1091.     {
  1092.         $Name $this->CommonService->GetPagename($UrlName);
  1093.         switch ($UrlName) {
  1094.             case 'cart':
  1095.                 if ($this->LmHelper->getCartType() == 4) {
  1096.                     $MetaTags $this->CommonService->GetYaml(CommonService::MetaTagData);
  1097.                     $Name $MetaTags['catalog']['PageName'];
  1098.                 }
  1099.                 break;
  1100.             case 'shopping_login':
  1101.                 $Name "ログイン";
  1102.                 break;
  1103.             default:
  1104.                 break;
  1105.         }
  1106.         try {
  1107.             return [
  1108.                 'href' => $this->Router->generate($UrlName) ?? '',
  1109.                 'label' => $this->LmHelper->display_text($Name)
  1110.             ];
  1111.         } catch (\Exception $e) {
  1112.             return $this->getBreadCrumb('homepage');
  1113.         }
  1114.     }
  1115.     public function getCurrentBreadcrumb()
  1116.     {
  1117.         $Re[] = $this->getBreadCrumb('homepage');
  1118.         $UrlName $this->Request->get('_route');
  1119.         $Re[] = $this->getBreadCrumb($UrlName);
  1120.         return $Re;
  1121.     }
  1122.     /**
  1123.      * 見積もりシミュレーション文字化
  1124.      *
  1125.      */
  1126.     public function SetEstimateCharaCart($CartKey$EstimateId$Options$isDisplayOnSp false)
  1127.     {
  1128.         if (!$Option $Options[$CartKey][$EstimateId] ?? null) {
  1129.             return;
  1130.         }
  1131.         if ($isDisplayOnSp) {
  1132.             return $this->Twig->render('Common/EstimateMobile.twig', [
  1133.                 'Prints' => $Option['print'] ?? [],
  1134.                 'Susoage' => $Option['susoage'] ?? '',
  1135.                 'Lot' => $Option['lot'] ?? null,
  1136.             ]);
  1137.         }
  1138.         return $this->Twig->render(self::EstimateTwig, [
  1139.             'Prints' => $Option['print'] ?? [],
  1140.             'Susoage' => $Option['susoage'] ?? '',
  1141.             'Lot' => $Option['lot'] ?? null,
  1142.         ]);
  1143.     }
  1144.     public function GetItemType($Id$Flg null)
  1145.     {
  1146.         $ItemType $this->OrderItemTypeRepository->find($Id);
  1147.         return $ItemType->getName();
  1148.     }
  1149.     public function GetPaymentDetails($Param$Items)
  1150.     {
  1151.         foreach ($Items as $Item) {
  1152.             $Type $Item->getOrderItemTypeId();
  1153.             if ($Type == $Param) {
  1154.                 return $Item->getPrice();
  1155.             }
  1156.         }
  1157.         return null;
  1158.     }
  1159.     /**
  1160.      * @param OrderItem[] $Items
  1161.      * @return void
  1162.      */
  1163.     public function SetEstimateOptions($Items)
  1164.     {
  1165.         $this->EstimateOptions = [];
  1166.         $EstimetIds = [];
  1167.         $Options = [];
  1168.         $I null;
  1169.         $Num 1;
  1170.         $ItemCount 0;
  1171.         foreach ($Items as $Item) {
  1172.             $ProductClass $Item->getProductClass();
  1173.             $Product $ProductClass->getProduct();
  1174.             $EstimetIds[$Product->getId()][$Item->getEstimateId()] = $Item->getId();
  1175.             $Options[$Item->getId()] = $Item->getOptions();
  1176.             $L $Product->getId() . '-' $Item->getEstimateId();
  1177.             if ($I != $L) {
  1178.                 $this->CartSortFlg[$Product->getId()][$Item->getEstimateId()]['h'] = $Item->getId();
  1179.                 $this->CartSortFlg[$Product->getId()][$Item->getEstimateId()]['n'] = $Num;
  1180.                 $Num++;
  1181.                 $ItemCount 0;
  1182.             }
  1183.             $I $L;
  1184.             $ItemCount++;
  1185.             $this->CartSortFlg[$Product->getId()][$Item->getEstimateId()]['f'] = $Item->getId();
  1186.             $this->CartSortFlg[$Product->getId()][$Item->getEstimateId()]['ItemCount'] = $ItemCount;
  1187.         }
  1188.         foreach ($EstimetIds as $ProductId) {
  1189.             foreach ($ProductId as $Id) {
  1190.                 $this->EstimateOptions[$Id] = $Options[$Id];
  1191.             }
  1192.         }
  1193.     }
  1194.     public function GetEstimateOption($Id$Page 'Shopping')
  1195.     {
  1196.         if (!$Options $this->EstimateOptions[$Id] ?? null) {
  1197.             return;
  1198.         }
  1199.         $this->EstimateCharacterizer->EstimateCharacterIzation($Options, [], $Page);
  1200.         $EstimateOption $this->EstimateCharacterizer->GetCharacters();
  1201.         return [
  1202.             'print' => $EstimateOption['print'] ?? [],
  1203.             'susoage' => $EstimateOption['susoage'] ?? '',
  1204.             'lot' => $EstimateOption['lot'] ?? null,
  1205.         ];
  1206.     }
  1207.     public function ShowEstimateOptions($Id)
  1208.     {
  1209.         if (!$OpipnData $this->EstimateOptions[$Id] ?? null) {
  1210.             return;
  1211.         }
  1212.         $this->EstimateCharacterizer->EstimateCharacterIzation($OpipnData, [], 'Shopping');
  1213.         $Option $this->EstimateCharacterizer->GetCharacters();
  1214.         return $this->Twig->render(self::ShoppingEstimate, [
  1215.             'Prints' => $Option['print'] ?? [],
  1216.             'Susoage' => $Option['susoage'] ?? '',
  1217.             'Lot' => $Option['lot'] ?? null,
  1218.         ]);
  1219.     }
  1220.     public function ShowEstimateMobileOptions($item)
  1221.     {
  1222.         if (!$optionData $this->EstimateOptions[$item->getId()] ?? null) {
  1223.             return;
  1224.         }
  1225.         $this->EstimateCharacterizer->EstimateCharacterIzation($optionData, [], 'Shopping');
  1226.         $Option $this->EstimateCharacterizer->GetCharacters();
  1227.         return $this->Twig->render(self::MobileShoppingEstimate, [
  1228.             'orderItem' => $item,
  1229.             'Prints' => $Option['print'] ?? [],
  1230.             'Susoage' => $Option['susoage'] ?? '',
  1231.             'Lot' => $Option['lot'] ?? null,
  1232.             'ProductClass' => $item->getProductClass(),
  1233.         ]);
  1234.     }
  1235.     public function ShowEstimateOptionsMail($Id$SubTotal)
  1236.     {
  1237.         if (!isset($this->EstimateOptions[$Id])) {
  1238.             return;
  1239.         }
  1240.         if (!$OptionData $this->EstimateOptions[$Id]) {
  1241.             '注文別合計:' number_format($SubTotal) . '円';
  1242.         }
  1243.         $this->EstimateCharacterizer->EstimateCharacterIzation($OptionData, [], 'Shopping');
  1244.         $Option $this->EstimateCharacterizer->GetCharacters();
  1245.         return $this->Twig->render(self::MailEstimate, [
  1246.             'Prints' => $Option['print'] ?? [],
  1247.             'Susoage' => $Option['susoage'] ?? '',
  1248.             'Lot' => $Option['lot'] ?? null,
  1249.             'kakouhi' => $Option['total'] ?? 0,
  1250.             'OptionSubTotal' => ($Option['total'] ?? 0) + ($Option['lot']['total'] ?? 0) + ($Option['product_total'] ?? 0),
  1251.         ]);
  1252.     }
  1253.     public function GetCartSortFlg($Item$Flg 'h')
  1254.     {
  1255.         $ProductClass $Item->getProductClass();
  1256.         $Product $ProductClass->getProduct();
  1257.         $ProductId $Product->getId();
  1258.         $EstimateId $Item->getEstimateId();
  1259.         $ItemId $Item->getId();
  1260.         switch ($Flg) {
  1261.             case 'f' :
  1262.                 return $this->CartSortFlg[$ProductId][$EstimateId][$Flg] == $ItemId true false;
  1263.                 break;
  1264.             case 'n':
  1265.                 return $this->CartSortFlg[$ProductId][$EstimateId][$Flg];
  1266.                 break;
  1267.             case 'ItemCount':
  1268.                 return $this->CartSortFlg[$ProductId][$EstimateId][$Flg];
  1269.             case 'h':
  1270.             default:
  1271.                 return $this->CartSortFlg[$ProductId][$EstimateId][$Flg] == $ItemId true false;
  1272.                 break;
  1273.         }
  1274.     }
  1275.     public function GetZeusCardDatas($Name$Order)
  1276.     {
  1277.         $Value '';
  1278.         switch ($Name) {
  1279.             case 'money':
  1280.                 $Value $this->OrderService->calculateCreditTotal($Order);
  1281.                 break;
  1282.             case 'sendid':
  1283.                 $Customer $Order->getCustomer();
  1284.                 $LmCustomer $this->CustomerService->GetLandMarkCustomerId($Customer->getLmCustomerId(), true);
  1285.                 $Value $LmCustomer['customer_bangou'];
  1286.                 break;
  1287.             case 'sendpoint':
  1288.                 $Value $Order->getZeusRequestData();
  1289.                 break;
  1290.             case 'telno':
  1291.                 $Value $Order->getPhoneNumber();
  1292.                 break;
  1293.             case 'email':
  1294.                 $Value $Order->getEmail();
  1295.                 break;
  1296.         }
  1297.         return $Value;
  1298.     }
  1299.     /**
  1300.      * ZeusCardError
  1301.      * カードエラーの場合表示する
  1302.      *
  1303.      */
  1304.     public function GetZeusCardError()
  1305.     {
  1306.         $CardError false;
  1307.         if ($OrderId $this->Session->get(OrderHelper::SESSION_ORDER_ID)) {
  1308.             $Order $this->OrderRepository->find($OrderId);
  1309.             $Paymenr $Order->getPayment();
  1310.             if ($this->CommonService->GetConfig('ZEUS_CARD_PAYMAET_ID') == $Paymenr->getId()) {
  1311.                 $CardError $Order->getLmOrderId();
  1312.             }
  1313.             $this->Session->get(OrderHelper::SESSION_ORDER_IDnull);
  1314.         }
  1315.         return $CardError;
  1316.     }
  1317.     public function GetEstimateType()
  1318.     {
  1319.         if ($this->CommonService->getConfig('BunkaruFlg')) {
  1320.             return 0;
  1321.         }
  1322.         switch ($this->CartService->GetCartType()) {
  1323.             case CartService::CartTypeEstimate:
  1324.                 return $this->CartService->getEstimateType();
  1325.                 break;
  1326.             case CartService::CartTypeNormal:
  1327.             default:
  1328.                 return 0;
  1329.                 break;
  1330.         }
  1331.     }
  1332.     public function GetCartAddLine($CartItem)
  1333.     {
  1334.         $Item $this->GetCartItemData($CartItem);
  1335.         $lineItemId $Item['EstimateId'] . '-' $Item['ProductId'];
  1336.         return $this->Twig->render(self::CartAddLineTwig, [
  1337.             'num' => $this->GetCartSortFlg($CartItem'n'),
  1338.             'ItemId' => $CartItem->getId(),
  1339.             'ProductId' => $Item['ProductId'],
  1340.             'ProductClass' => $Item['ProductClass'],
  1341.             'ClassCategory1Id' => $Item['ClassCategory1Id'],
  1342.             'ClassCategory2Id' => $Item['ClassCategory2Id'],
  1343.             'EstimateId' => $Item['EstimateId'],
  1344.             'lineItemId' => $lineItemId,
  1345.         ]);
  1346.     }
  1347.     protected function GetCartItemData($CartItem)
  1348.     {
  1349.         $ProductClass $CartItem->getProductClass();
  1350.         $Product $ProductClass->getProduct();
  1351.         $ClassCategory1 is_null($ProductClass) ? null $ProductClass->getClassCategory1();
  1352.         $ClassCategory1Id is_null($ClassCategory1) ? null $ClassCategory1->getId();
  1353.         $ClassCategory2 is_null($ProductClass) ? null $ProductClass->getClassCategory2();
  1354.         $ClassCategory2Id is_null($ClassCategory2) ? null $ClassCategory2->getId();
  1355.         return [
  1356.             'ProductClass' => $ProductClass,
  1357.             'Product' => $Product,
  1358.             'ProductId' => $Product->getId(),
  1359.             'ClassCategory1Id' => $ClassCategory1Id,
  1360.             'ClassCategory2Id' => $ClassCategory2Id,
  1361.             'EstimateId' => $CartItem->getEstimateId(),
  1362.         ];
  1363.     }
  1364.     public function GetCartBackBtn()
  1365.     {
  1366.         return $this->LmHelper->getBackUrl();
  1367.     }
  1368.     /********************************************************************************************************************* */
  1369.     /**
  1370.      * メッセージのbaseinfo config Messegeを 変換する
  1371.      * 例 
  1372.      *  {{BaseInfo.shop_name}}
  1373.      *  {{Config.Payment_Charge_free}}
  1374.      *  {{message.common.ResetPassward_messeg02}} or {{trans.common.ResetPassward_messeg02}}
  1375.      */
  1376.     public function BaseInfo($Text)
  1377.     {
  1378.         //     return $Text;
  1379.         return $this->CommonService->BaseInfo($Text);
  1380.     }
  1381.     /**
  1382.      * LMのプライス出力フォーマット
  1383.      * @param int $Price
  1384.      * @param string|false $yen
  1385.      */
  1386.     public function GetLmPrice($Price$yen '円')
  1387.     {
  1388.         if (!is_numeric($Price)) {
  1389.             return $Price;
  1390.         }
  1391.         if ($yen === false) {
  1392.             $yen '';
  1393.         }
  1394.         return number_format($Price) . $yen;
  1395.     }
  1396.     public function FormatPrice($Price)
  1397.     {
  1398.         if (!is_numeric($Price)) {
  1399.             return $Price;
  1400.         }
  1401.         return number_format($Price) . '<span class="prices-unit">円</span>';
  1402.     }
  1403.     /**
  1404.      * LMのプライス出力フォーマット
  1405.      *
  1406.      */
  1407.     public function SetPhone($Phone)
  1408.     {
  1409.         return $this->CommonService->GetPhoneNumber($Phonefalse);
  1410.     }
  1411.     public function SetPost($Post)
  1412.     {
  1413.         $Post str_replace('-'''$Post);
  1414.         if (strlen($Post) < 7) {
  1415.             return $Post;
  1416.         }
  1417.         return substr($Post03) . '-' substr($Post34);
  1418.     }
  1419.     public function SetJWeek($Da)
  1420.     {
  1421.         return \Lm\Util\Date::weekDay($Da\Lm\Util\Date::COUNTRY_JP);
  1422.     }
  1423.     public function GetLmCssList()
  1424.     {
  1425.         //
  1426.         $context = [];
  1427.         //
  1428.         $cssConfig $this->CommonService->GetConfig('Css');
  1429.         $cssRoot $cssConfig['Root'];
  1430.         $cssIndex $cssConfig['CssList'];
  1431.         $cssList = [];
  1432.         //
  1433.         $deviceType strtolower($this->CommonService->GetDevice(false$this->LmMobileDetector));
  1434.         //
  1435.         $pageTypeConfig $this->LmHelper->getPageType();
  1436.         $pageType $pageTypeConfig['type'];
  1437.         //
  1438.         $cssList array_merge($cssList$cssIndex[$deviceType]['common']);
  1439.         $cssList array_merge($cssList$cssIndex[$deviceType][$pageType]);
  1440.         //
  1441.         foreach ($cssList as $css) {
  1442.             $context['CssList'][] = [
  1443.                 'href' => "{$cssRoot}/{$deviceType}/{$css}",
  1444.             ];
  1445.         }
  1446.         //
  1447.         return $this->Twig->render('Common/CssList.twig'$context);
  1448.     }
  1449.     public function isSliderEnabled()
  1450.     {
  1451.         return $this->LmHelper->filterSliderEnabled();
  1452.     }
  1453.     public function GetCustomerBangou($lmCustomerId)
  1454.     {
  1455.         //
  1456.         $result = (new SqlService())
  1457.             ->Select('customer_bangou')
  1458.             ->Table('customer_table')
  1459.             ->Set('customer_id'$lmCustomerId)
  1460.             ->Find();
  1461.         //
  1462.         $customerBangou $result['customer_bangou'];
  1463.         //
  1464.         return $customerBangou;
  1465.     }
  1466.     public function getCatalogNoukiSchedule()
  1467.     {
  1468.         //
  1469.         return (new NoukiEngine())
  1470.             ->getCatalogSendDate();
  1471.     }
  1472.     public function getPageType()
  1473.     {
  1474.         return $this->LmHelper->getPageType();
  1475.     }
  1476.     /**
  1477.      * @param bool|false $strict
  1478.      * @return bool
  1479.      */
  1480.     public function isMobile($strict false)
  1481.     {
  1482.         if ($strict) {
  1483.             return $this->mobileDetector->isMobile();
  1484.         } else {
  1485.             return $this->LmMobileDetector->isMobile();
  1486.         }
  1487.     }
  1488.     /**
  1489.      * @return bool
  1490.      */
  1491.     public function wannaSeePc()
  1492.     {
  1493.         return !$this->isMobile() && $this->isMobile(true);
  1494.     }
  1495.     /**
  1496.      * @param array $paramsAdd
  1497.      * @param array $params
  1498.      * @return string
  1499.      */
  1500.     public function WithGetParams($paramsAdd$params = [])
  1501.     {
  1502.         if (is_array($params) && count($params) === 0) {
  1503.             $params $this->Request->query->all();
  1504.         }
  1505.         $params array_merge($params$paramsAdd);
  1506.         $result http_build_query($params);
  1507.         return $result;
  1508.     }
  1509.     /**
  1510.      * @param int $page
  1511.      * @return string
  1512.      */
  1513.     public function PageWithGetParams($page)
  1514.     {
  1515.         return $this->WithGetParams([
  1516.             'page' => $page,
  1517.         ]);
  1518.     }
  1519.     /**
  1520.      * @param OrderHeader|array|int $order
  1521.      * @return string|null
  1522.      * @throws \Exception
  1523.      */
  1524.     public function showSendScheduleDate($order)
  1525.     {
  1526.         try {
  1527.             /**
  1528.              * @var OrderHeader $orderHeader
  1529.              */
  1530.             if ($orderHeader OrderHeader::factory($order)) {
  1531.                 //
  1532.                 return NoukiEngine::showSendScheduleByOrder($orderHeader);
  1533.             } else {
  1534.                 //
  1535.                 return null;
  1536.             }
  1537.         } catch (\Exception $e) {
  1538.             //
  1539.             if (is_string($order)) {
  1540.                 //
  1541.                 if (Date::validate($order'Y/m/d')) {
  1542.                     //
  1543.                     return NoukiEngine::showSendSchedule($order);
  1544.                 } else {
  1545.                     //
  1546.                     return $order;
  1547.                 }
  1548.             } else {
  1549.                 //
  1550.                 throw new \Exception('お届け予定日の計算処理に失敗しました'0$e);
  1551.             }
  1552.         }
  1553.     }
  1554.     /**
  1555.      * @param OrderHeader|array|int $order
  1556.      * @return string
  1557.      * @throws \Exception
  1558.      */
  1559.     public function showSendScheduleMessage($order)
  1560.     {
  1561.         //
  1562.         $orderHeader OrderHeader::factory($order);
  1563.         //
  1564.         return $this->Twig->render('Common/SendScheduleDate.twig', [
  1565.             'orderHeader' => $orderHeader,
  1566.             'isMobile' => $this->isMobile(),
  1567.             'sendSchedule' => $this->showSendScheduleDate($order),
  1568.             'paymentAtobarai' => [OrderHeader::PAYMENT_TYPE_ATOBARAIOrderHeader::PAYMENT_TYPE_ATOBARAI_MONTHLY],
  1569.         ]);
  1570.     }
  1571.     public function getOrderPaymentId($Order)
  1572.     {
  1573.         return !empty($Order->getPayment()) ? $Order->getPayment()->getId() : null;
  1574.     }
  1575.     public function getCategoryImageUrlById($categoryId)
  1576.     {
  1577.         return "/category_images/{$categoryId}.webp";
  1578.     }
  1579.     public function showFileSizeUpload($name 'default')
  1580.     {
  1581.         //
  1582.         $config $this->CommonService->GetConfig('FILE_UPLOAD');
  1583.         //
  1584.         if (!isset($config[$name])) {
  1585.             //
  1586.             throw new \Exception('Config name specified is invalid.');
  1587.         }
  1588.         //
  1589.         $FileUploadConfig $config[$name];
  1590.         //
  1591.         return $this->Twig->render('Common/FileUploadNotice.twig', [
  1592.             'FileUploadConfig' => $FileUploadConfig,
  1593.         ]);
  1594.     }
  1595.     public function showInventoryMatrix(GoodsWithRelated $goods)
  1596.     {
  1597.         //
  1598.         $id $goods->getGoodsId();
  1599.         $data $this->GoodsService->getGoodsById($id);
  1600.         $Product $this->ProductRepository->find($id);
  1601.         // $matrixData = $this->inventoryMatrixService->getInventoryMatrixData($goods, $color, $size);
  1602.         $inventoryMatrix = (new InventoryMatrix())
  1603.             ->getMatrixStock($goodsfalse$color$size)
  1604.         ;
  1605.         $colorCnt count($color);
  1606.         $sizeCnt count($size);
  1607.         $SellingColor $this->GoodsService->getSellingColorSql($idcount($color));
  1608.         $isShowMatrixButtonAbove = (($colorCnt * (intval(($sizeCnt 1) / 6) + 1)) >= 10);
  1609.         //
  1610.         return $this->Twig->render('Item/matrix.twig', [
  1611.             'isShowMatrixButtonAbove' => $isShowMatrixButtonAbove,
  1612.             'data' => $data,
  1613.             'goods' => $goods,
  1614.             // 'matrixData' => $matrixData,
  1615.             'Product' => $Product,
  1616.             'SellingColor' => $SellingColor,
  1617.             'inventoryMatrix' => $inventoryMatrix,
  1618.         ]);
  1619.     }
  1620.     /**
  1621.      * Handle format Object or array to json
  1622.      *
  1623.      * @param $data
  1624.      * @return string|null
  1625.      */
  1626.     public function formatDataToJson($data)
  1627.     {
  1628.         if (empty($data)) {
  1629.             return null;
  1630.         }
  1631.         return json_encode($dataJSON_UNESCAPED_UNICODE JSON_UNESCAPED_SLASHES);
  1632.     }
  1633.     public function getCartSessionName($key)
  1634.     {
  1635.         switch ($key) {
  1636.             case 'GROUP_1_NORMAL':
  1637.                 return '通常注文';
  1638.             case 'GROUP_2_RESERVATION':
  1639.                 return '予約注文';
  1640.             case 'GROUP_3_KYOUEI':
  1641.                 return 'メーカー「共栄-KYOEI」';
  1642.             default:
  1643.                 return '商品一覧';
  1644.         }
  1645.     }
  1646.     public function groupItemsHasSameProductId($items)
  1647.     {
  1648.         $result = [];
  1649.         foreach ($items as $item) {
  1650.             $productId $item->getProduct()->getId();
  1651.             if (!isset($result[$productId])) {
  1652.                 $result[$productId] = [];
  1653.             }
  1654.             $result[$productId][] = $item;
  1655.         }
  1656.         return $result;
  1657.     }
  1658.     /**
  1659.      * Get format date. Example: 2023/09/15 -> 2023年9月15日(金)
  1660.      *
  1661.      * @param string $date
  1662.      * @return string
  1663.      */
  1664.     public function formatDate(string $datebool $showDay true)
  1665.     {
  1666.         if (!empty($date) && strtotime($date) !== false) {
  1667.             $weekdays = [
  1668.                 => '月',
  1669.                 => '火',
  1670.                 => '水',
  1671.                 => '木',
  1672.                 => '金',
  1673.                 => '土',
  1674.                 => '日'
  1675.             ];
  1676.             $dateString date('Y年n月j日'strtotime($date));
  1677.             if ($showDay == false) {
  1678.                 return $dateString;
  1679.             }
  1680.             $dayOfWeek date('N'strtotime($date));
  1681.             $day $weekdays[$dayOfWeek];
  1682.             return $dateString '(' $day ')';
  1683.         }
  1684.         return $date;
  1685.     }
  1686.     public function formatMonthAndDay(string $datebool $showDay true$format "n/j")
  1687.     {
  1688.         if (!empty($date) && strtotime($date) !== false) {
  1689.             $weekdays = [
  1690.                 => '月',
  1691.                 => '火',
  1692.                 => '水',
  1693.                 => '木',
  1694.                 => '金',
  1695.                 => '土',
  1696.                 => '日'
  1697.             ];
  1698.             $dateString date($formatstrtotime($date));
  1699.             if ($showDay == false) {
  1700.                 return $dateString;
  1701.             }
  1702.             $dayOfWeek date('N'strtotime($date));
  1703.             $day $weekdays[$dayOfWeek];
  1704.             return $dateString '(' $day ')' ' 頃';
  1705.         }
  1706.         return $date;
  1707.     }
  1708.     public function getDayOfWeek(string $date)
  1709.     {
  1710.         if (!empty($date) && strtotime($date) !== false) {
  1711.             $weekdays = [
  1712.                 => '月',
  1713.                 => '火',
  1714.                 => '水',
  1715.                 => '木',
  1716.                 => '金',
  1717.                 => '土',
  1718.                 => '日'
  1719.             ];
  1720.             $dayOfWeek date('N'strtotime($date));
  1721.             return $weekdays[$dayOfWeek];
  1722.         }
  1723.         return null;
  1724.     }
  1725.     /**
  1726.      * @param int $goodsId
  1727.      * @param int $janId
  1728.      * @return string
  1729.      */
  1730.     public function showYoyakuFlag($goodsId$janId)
  1731.     {
  1732.         //
  1733.         return Yoyaku::check($goodsIdfalse$janId) ? '(予約)' null;
  1734.     }
  1735.     /**
  1736.      * @param Item|Goods|int
  1737.      * @return string
  1738.      */
  1739.     public function filterLmWebTeika($item) {
  1740.         /**
  1741.          * @var Item $Item
  1742.          */
  1743.         $item Item::factory($item);
  1744.         //
  1745.         return $this->Twig->render('Common/LmWebPrice.twig', [
  1746.             'minPrice' => $item->getMinTeika(),
  1747.             'maxPrice' => $item->getMaxTeika(),
  1748.         ]);
  1749.     }
  1750.     /**
  1751.      * @param Item|Goods|int
  1752.      * @return string
  1753.      */
  1754.     public function filterLmWebPrice($item) {
  1755.         /**
  1756.          * @var Item $Item
  1757.          */
  1758.         $item Item::factory($item);
  1759.         //
  1760.         return $this->Twig->render('Common/LmWebPrice.twig', [
  1761.             'minPrice' => $item->getMinPrice(),
  1762.             'maxPrice' => $item->getMaxPrice(),
  1763.         ]);
  1764.     }
  1765.     /**
  1766.      * @param Goods $goods
  1767.      * @return string
  1768.      */
  1769.     public function showSokujitsuHassouBannerIfSo(Goods $goods)
  1770.     {
  1771.         /**
  1772.          * @var GoodsWithRelated $goods
  1773.          */
  1774.         $goods GoodsWithRelated::factory($goods);
  1775.         //
  1776.         return $this->Twig->render('Common/SokujitsuHassouBanner.twig', [
  1777.             'goods' => $goods,
  1778.         ]);
  1779.     }
  1780. }