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

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