app/template/default/Product/detail.twig line 1646

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE
  3. Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  4. http://www.ec-cube.co.jp/
  5. For the full copyright and license information, please view the LICENSE
  6. file that was distributed with this source code.
  7. #}
  8. {% extends 'default_frame.twig' %}
  9. {% set body_class = 'product_page' %}
  10. {% block stylesheet %}
  11.     <style>
  12.         .slick-slider {
  13.             margin-bottom: 10px;
  14.             margin-top: -20px;
  15.         }
  16.         .slick-dots {
  17.             position: absolute;
  18.             bottom: -45px;
  19.             display: block;
  20.             width: 100%;
  21.             padding: 0;
  22.             list-style: none;
  23.             text-align: center;
  24.         }
  25.         .slick-dots li {
  26.             position: relative;
  27.             display: inline-block;
  28.             width: 20px;
  29.             height: 20px;
  30.             margin: 0 5px;
  31.             padding: 0;
  32.             cursor: pointer;
  33.         }
  34.         .slick-dots li button {
  35.             font-size: 0;
  36.             line-height: 0;
  37.             display: block;
  38.             width: 20px;
  39.             height: 20px;
  40.             padding: 5px;
  41.             cursor: pointer;
  42.             color: transparent;
  43.             border: 0;
  44.             outline: none;
  45.             background: transparent;
  46.         }
  47.         .slick-dots li button:hover,
  48.         .slick-dots li button:focus {
  49.             outline: none;
  50.         }
  51.         .slick-dots li button:hover:before,
  52.         .slick-dots li button:focus:before {
  53.             opacity: 1;
  54.         }
  55.         .slick-dots li button:before {
  56.             content: " ";
  57.             line-height: 20px;
  58.             position: absolute;
  59.             top: 0;
  60.             left: 0;
  61.             width: 12px;
  62.             height: 12px;
  63.             text-align: center;
  64.             opacity: .25;
  65.             background-color: black;
  66.             border-radius: 50%;
  67.         }
  68.         .slick-dots li.slick-active button:before {
  69.             opacity: .75;
  70.             background-color: black;
  71.         }
  72.         .slick-dots li button.thumbnail img {
  73.             width: 0;
  74.             height: 0;
  75.         }
  76.     </style>
  77.     <link rel="stylesheet" href="/html/user_data/js/style.css">
  78.     <link rel="stylesheet" href="/html/plugins/icheck-bootstrap/icheck-bootstrap.min.css">
  79.     <style>
  80.         /* ============================================
  81.            商品詳細グリッド: 画像50% / 内容50%(均等)
  82.         ============================================ */
  83.         @media (min-width: 768px) {
  84.             body.product_page .ec-grid2 {
  85.                 display: flex;
  86.                 align-items: flex-start;
  87.             }
  88.             body.product_page .ec-grid2 .ec-grid2__cell {
  89.                 width: 50%;
  90.                 flex: 0 0 50%;
  91.                 min-width: 0;
  92.             }
  93.             body.product_page .ec-grid2 .ec-grid2__cell2 {
  94.                 width: 50%;
  95.                 flex: 0 0 50%;
  96.                 min-width: 0;
  97.             }
  98.         }
  99.         /* ============================================
  100.            商品説明欄内のHTMLが画面幅を突き抜けないように
  101.         ============================================ */
  102.         body.product_page .ec-productRole__description {
  103.             min-width: 0;
  104.             overflow-wrap: break-word;
  105.             word-break: break-word;
  106.         }
  107.         body.product_page .ec-productRole__description img,
  108.         body.product_page .ec-productRole__description table,
  109.         body.product_page .ec-productRole__description iframe,
  110.         body.product_page .ec-productRole__description video {
  111.             max-width: 100% !important;
  112.             height: auto;
  113.         }
  114.         body.product_page .ec-productRole__description table {
  115.             display: block;
  116.             overflow-x: auto;
  117.             -webkit-overflow-scrolling: touch;
  118.         }
  119.         /* ============================================
  120.            スマホ用 見積金額 下部固定バー
  121.         ============================================ */
  122.         #sp-mitsumori-bar {
  123.             display: none;
  124.         }
  125.         
  126.         /* ============================================
  127.            商品タイプ選択 共通スタイル
  128.         ============================================ */
  129.         /* セクションラベル */
  130.         .rp-section-label {
  131.             font-size: 14px;
  132.             font-weight: bold;
  133.             color: #333;
  134.             margin-bottom: 10px;
  135.         }
  136.         .rp-section-label span {
  137.             font-weight: normal;
  138.             color: #c00;
  139.         }
  140.         /* ---- 1. 画像付きカード ---- */
  141.         .rp-card-group {
  142.             display: flex;
  143.             flex-wrap: wrap;
  144.             gap: 8px;
  145.             margin-bottom: 4px;
  146.         }
  147.         .rp-card {
  148.             position: relative;
  149.             cursor: pointer;
  150.             width: 110px;
  151.             border: 2px solid #ddd;
  152.             border-radius: 10px;
  153.             overflow: hidden;
  154.             transition: border-color 0.2s, box-shadow 0.2s;
  155.             background: #fff;
  156.         }
  157.         .rp-card:hover {
  158.             border-color: #999;
  159.             box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  160.         }
  161.         .rp-card.is-selected {
  162.             border-color: #1a6fcf;
  163.             box-shadow: 0 2px 10px rgba(26,111,207,0.25);
  164.         }
  165.         .rp-card input[type="radio"] { display: none; }
  166.         .rp-card__image {
  167.             width: 100%;
  168.             aspect-ratio: 1 / 1;
  169.             object-fit: cover;
  170.             display: block;
  171.             background: #f5f5f5;
  172.         }
  173.         .rp-card__placeholder {
  174.             width: 100%;
  175.             aspect-ratio: 1 / 1;
  176.             background: #f0f0f0;
  177.             display: flex;
  178.             align-items: center;
  179.             justify-content: center;
  180.             color: #bbb;
  181.             font-size: 24px;
  182.         }
  183.         .rp-card__name {
  184.             display: block;
  185.             padding: 5px 5px;
  186.             font-size: 11px;
  187.             color: #333;
  188.             text-align: center;
  189.             line-height: 1.4;
  190.             word-break: break-all;
  191.         }
  192.         .rp-card.is-selected .rp-card__name { color: #1a6fcf; font-weight: bold; }
  193.         .rp-card.is-selected::after {
  194.             content: "✓";
  195.             position: absolute;
  196.             top: 3px; right: 6px;
  197.             color: #1a6fcf;
  198.             font-size: 13px;
  199.             font-weight: bold;
  200.         }
  201.         /* ---- 2. ボタン式ラジオ(画像なし・8個以内)---- */
  202.         .rp-btn-group {
  203.             display: flex;
  204.             flex-wrap: wrap;
  205.             gap: 8px;
  206.             margin-bottom: 4px;
  207.             max-width: 100%;
  208.             min-width: 0;
  209.         }
  210.         .rp-btn {
  211.             cursor: pointer;
  212.             padding: 8px 14px;
  213.             border: 2px solid #ddd;
  214.             border-radius: 10px;
  215.             font-size: 13px;
  216.             color: #333;
  217.             background: #fff;
  218.             transition: border-color 0.2s, background 0.2s;
  219.             white-space: nowrap;
  220.             max-width: 100%;
  221.             overflow: hidden;
  222.             text-overflow: ellipsis;
  223.         }
  224.         .rp-btn:hover { border-color: #999; }
  225.         .rp-btn.is-selected {
  226.             border-color: #1a6fcf;
  227.             color: #1a6fcf;
  228.             font-weight: bold;
  229.             background: #f0f6ff;
  230.         }
  231.         .rp-btn input[type="radio"] { display: none; }
  232.         /* ---- ボタン群が3行以上になる場合は1行横スクロール ---- */
  233.         .rp-btn-group.is-scroll,
  234.         .opt-btn-group.is-scroll {
  235.             flex-wrap: nowrap;
  236.             overflow-x: auto;
  237.             overflow-y: hidden;
  238.             -webkit-overflow-scrolling: touch;
  239.             scrollbar-width: thin;
  240.             padding-bottom: 6px;
  241.         }
  242.         .rp-btn-group.is-scroll::-webkit-scrollbar,
  243.         .opt-btn-group.is-scroll::-webkit-scrollbar {
  244.             height: 6px;
  245.         }
  246.         .rp-btn-group.is-scroll::-webkit-scrollbar-thumb,
  247.         .opt-btn-group.is-scroll::-webkit-scrollbar-thumb {
  248.             background: #c0c0c0;
  249.             border-radius: 3px;
  250.         }
  251.         .rp-btn-group.is-scroll > .rp-btn,
  252.         .opt-btn-group.is-scroll > .opt-btn {
  253.             flex: 0 0 auto;
  254.         }
  255.         /* ---- 3. プルダウン(画像なし・9個以上)---- */
  256.         .rp-select-wrap {
  257.             margin-bottom: 4px;
  258.         }
  259.         .rp-select {
  260.             width: 100%;
  261.             max-width: 420px;
  262.             padding: 8px 12px;
  263.             border: 2px solid #ddd;
  264.             border-radius: 10px;
  265.             font-size: 13px;
  266.             color: #333;
  267.             background: #fff;
  268.             appearance: none;
  269.             background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  270.             background-repeat: no-repeat;
  271.             background-position: right 12px center;
  272.             cursor: pointer;
  273.         }
  274.         .rp-select:focus {
  275.             outline: none;
  276.             border-color: #1a6fcf;
  277.         }
  278.         /* ---- オプション選択ボタン(枠線ラジオ)---- */
  279.         .opt-btn-group {
  280.             display: flex;
  281.             flex-wrap: wrap;
  282.             gap: 8px;
  283.             padding: 6px 0;
  284.             max-width: 100%;
  285.             min-width: 0;
  286.         }
  287.         .opt-btn {
  288.             cursor: pointer;
  289.             padding: 7px 14px;
  290.             border: 2px solid #ddd;
  291.             border-radius: 10px;
  292.             font-size: 13px;
  293.             color: #333;
  294.             background: #fff;
  295.             transition: border-color 0.2s, background 0.2s;
  296.             white-space: nowrap;
  297.             max-width: 100%;
  298.             overflow: hidden;
  299.             text-overflow: ellipsis;
  300.         }
  301.         .opt-btn:hover { border-color: #999; }
  302.         .opt-btn.is-selected {
  303.             border-color: #1a6fcf;
  304.             color: #1a6fcf;
  305.             font-weight: bold;
  306.             background: #f0f6ff;
  307.         }
  308.         .opt-btn input[type="radio"] { display: none; }
  309.         /* ============================================
  310.            施工エリア案内
  311.         ============================================ */
  312.         .ec-areaNotice {
  313.             margin: 16px 0;
  314.             padding: 16px 20px;
  315.             background: #f8f9fa;
  316.             border-left: 4px solid #1a6fcf;
  317.             border-radius: 0 8px 8px 0;
  318.         }
  319.         .ec-areaNotice__inner {
  320.             display: flex;
  321.             align-items: flex-start;
  322.             gap: 12px;
  323.         }
  324.         .ec-areaNotice__icon {
  325.             font-size: 22px;
  326.             line-height: 1;
  327.             flex-shrink: 0;
  328.             margin-top: 2px;
  329.         }
  330.         .ec-areaNotice__body {
  331.             flex: 1;
  332.         }
  333.         .ec-areaNotice__title {
  334.             font-size: 13px;
  335.             font-weight: bold;
  336.             color: #1a6fcf;
  337.             margin: 0 0 6px;
  338.         }
  339.         .ec-areaNotice__text {
  340.             font-size: 13px;
  341.             color: #444;
  342.             line-height: 1.7;
  343.             margin: 0;
  344.         }
  345.         .ec-areaNotice__text strong {
  346.             color: #222;
  347.         }
  348.         .ec-areaNotice__link {
  349.             display: inline-block;
  350.             margin-top: 8px;
  351.             font-size: 12px;
  352.             color: #1a6fcf;
  353.             text-decoration: underline;
  354.         }
  355.         .ec-areaNotice__link:hover {
  356.             color: #0d4fa0;
  357.         }
  358.         /* ============================================
  359.            SNSシェア + ブランド名 タイトル行
  360.         ============================================ */
  361.         .ec-productRole__titleRow {
  362.             display: flex;
  363.             align-items: center;
  364.             justify-content: space-between;
  365.             gap: 8px;
  366.             margin-bottom: 4px;
  367.         }
  368.         .ec-productRole__titleRow .ec-headingTitle {
  369.             margin: 0;
  370.             flex: 1;
  371.             font-size: 18px;
  372.         }
  373.         .ec-share-inline {
  374.             display: flex;
  375.             align-items: center;
  376.             gap: 8px;
  377.             flex-shrink: 0;
  378.         }
  379.         @media (max-width: 767px) {
  380.             /* maker_area の float を解除して独立表示 */
  381.             #maker_area {
  382.                 float: none !important;
  383.                 width: auto !important;
  384.                 height: auto !important;
  385.                 display: block;
  386.                 margin-bottom: 4px;
  387.             }
  388.             /* タイトル行: 商品名が全幅を占有しSNSは右寄せ下段 */
  389.             .ec-productRole__titleRow {
  390.                 flex-wrap: wrap;
  391.                 clear: both;
  392.             }
  393.             .ec-productRole__titleRow .ec-headingTitle {
  394.                 flex: 1 1 100%;
  395.                 font-size: 16px;
  396.             }
  397.             .ec-share-inline {
  398.                 flex: 0 0 auto;
  399.                 margin-left: auto;
  400.             }
  401.         }
  402.         .ec-share-inline a {
  403.             display: flex;
  404.             align-items: center;
  405.             justify-content: center;
  406.             width: 32px;
  407.             height: 32px;
  408.             border-radius: 50%;
  409.             font-size: 15px;
  410.             color: #fff;
  411.             text-decoration: none;
  412.             transition: opacity 0.2s;
  413.         }
  414.         .ec-share-inline a:hover { opacity: 0.8; }
  415.         .ec-share-inline .share-twitter  { background: #000; }
  416.         .ec-share-inline .share-facebook { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
  417.         .ec-share-inline .share-line     { background: #06c755; }
  418.         /* description_detail下のシェアブロックはPC/スマホ共通で非表示(タイトル行に移動) */
  419.         .ec-productRole__share { display: none; }
  420.         /* ============================================
  421.            PC用: 現在のお見積り額カード強調
  422.         ============================================ */
  423.         @media (min-width: 768px) {
  424.             .mitsumori-card-pc {
  425.                 border: 2px solid #1a6fcf !important;
  426.                 border-radius: 10px !important;
  427.                 box-shadow: 0 4px 16px rgba(26,111,207,0.18) !important;
  428.                 margin-top: 20px;
  429.                 overflow: hidden;
  430.                 background: linear-gradient(135deg, #1a6fcf, #0d4fa0) !important;
  431.             }
  432.             .mitsumori-card-pc .card-header {
  433.                 background: linear-gradient(135deg, #1a6fcf, #0d4fa0) !important;
  434.                 color: #fff !important;
  435.                 padding: 14px 16px !important;
  436.                 border-bottom: none !important;
  437.             }
  438.             .mitsumori-card-pc .card-title {
  439.                 color: #fff !important;
  440.                 font-size: 15px !important;
  441.                 font-weight: bold !important;
  442.                 margin: 0 !important;
  443.             }
  444.             .mitsumori-card-pc #mitsumori_message {
  445.                 font-size: 22px !important;
  446.                 font-weight: bold !important;
  447.                 color: #fff !important;
  448.             }
  449.             .mitsumori-card-pc .btn-tool {
  450.                 color: #fff !important;
  451.             }
  452.             /* 合計行を大きく強調 */
  453.             .mitsumori-card-pc .nav-item:first-child .nav-link {
  454.                 font-size: 16px !important;
  455.                 font-weight: bold !important;
  456.                 color: #c00 !important;
  457.                 background: #fff8f8 !important;
  458.                 padding: 12px 16px !important;
  459.             }
  460.             .mitsumori-card-pc .nav-item:first-child #mitsumori_goukei {
  461.                 font-size: 20px !important;
  462.                 font-weight: bold !important;
  463.                 color: #c00 !important;
  464.             }
  465.             /* card-body(明細リスト)を白背景に */
  466.             .mitsumori-card-pc .card-body {
  467.                 background: #fff !important;
  468.             }
  469.             .mitsumori-card-pc .card-footer {
  470.                 background: #f8faff !important;
  471.                 border-top: 1px solid #dce8fb !important;
  472.                 padding: 12px 16px !important;
  473.             }
  474.         }
  475.         @media (max-width: 767px) {
  476.             /* スマホでは現在のお見積り額カードの強調スタイルをすべてリセット */
  477.             .mitsumori-card-pc {
  478.                 border: none !important;
  479.                 border-radius: 0 !important;
  480.                 box-shadow: none !important;
  481.                 margin-top: 0 !important;
  482.                 overflow: visible !important;
  483.                 background: none !important;
  484.             }
  485.             .mitsumori-card-pc .card-header {
  486.                 background: none !important;
  487.                 color: inherit !important;
  488.                 padding: inherit !important;
  489.                 border-bottom: inherit !important;
  490.             }
  491.             .mitsumori-card-pc .card-title { color: inherit !important; }
  492.             .mitsumori-card-pc #mitsumori_message { font-size: inherit !important; color: inherit !important; }
  493.             .mitsumori-card-pc .btn-tool { color: inherit !important; }
  494.             /* 折りたたみトグルボタン */
  495.             .btn-mitsumori-toggle {
  496.                 background: none !important;
  497.                 border: 1px solid #aaa !important;
  498.                 border-radius: 4px !important;
  499.                 padding: 2px 8px !important;
  500.                 font-size: 12px !important;
  501.                 color: #333 !important;
  502.                 line-height: 1.4 !important;
  503.             }
  504.             .btn-mitsumori-toggle .toggle-icon {
  505.                 display: inline-block;
  506.                 transition: transform 0.2s;
  507.             }
  508.             /* 展開状態: ▼→▲ */
  509.             .card:not(.collapsed-card) .btn-mitsumori-toggle .toggle-icon::before {
  510.                 content: "▲ 閉じる";
  511.             }
  512.             .card:not(.collapsed-card) .btn-mitsumori-toggle .toggle-icon {
  513.                 display: none;
  514.             }
  515.             .card:not(.collapsed-card) .btn-mitsumori-toggle::after {
  516.                 content: "▲ 閉じる";
  517.                 font-size: 12px;
  518.             }
  519.             .mitsumori-card-pc .nav-item:first-child .nav-link {
  520.                 font-size: inherit !important;
  521.                 color: inherit !important;
  522.                 background: none !important;
  523.                 padding: inherit !important;
  524.             }
  525.             .mitsumori-card-pc .nav-item:first-child #mitsumori_goukei {
  526.                 font-size: inherit !important;
  527.                 color: inherit !important;
  528.             }
  529.             .mitsumori-card-pc .card-footer {
  530.                 background: none !important;
  531.                 border-top: inherit !important;
  532.                 padding: inherit !important;
  533.             }
  534.             /* 横スクロール禁止 */
  535.             body, html {
  536.                 overflow-x: hidden;
  537.                 max-width: 100vw;
  538.             }
  539.             /* ボタンの折り返しを許可(nowrapが原因で横スクロール発生するため) */
  540.             .opt-btn,
  541.             .rp-btn {
  542.                 white-space: normal;
  543.                 word-break: break-all;
  544.             }
  545.             /* エリア案内: スマホでコンパクト */
  546.             .ec-areaNotice {
  547.                 margin: 8px 0;
  548.                 padding: 8px 10px;
  549.                 border-left-width: 3px;
  550.                 cursor: pointer;
  551.             }
  552.             .ec-areaNotice__inner {
  553.                 flex-direction: row;
  554.                 gap: 8px;
  555.                 align-items: flex-start;
  556.             }
  557.             .ec-areaNotice__icon { font-size: 15px; }
  558.             /* タイトル行: 展開トグル */
  559.             .ec-areaNotice__title {
  560.                 font-size: 11px;
  561.                 margin-bottom: 3px;
  562.                 display: flex;
  563.                 justify-content: space-between;
  564.                 align-items: center;
  565.             }
  566.             .ec-areaNotice__title::after {
  567.                 content: "▼";
  568.                 font-size: 9px;
  569.                 color: #888;
  570.                 margin-left: 6px;
  571.                 transition: transform 0.2s;
  572.             }
  573.             .ec-areaNotice.is-open .ec-areaNotice__title::after {
  574.                 transform: rotate(180deg);
  575.             }
  576.             /* 折りたたみ対象: 閉じた状態では非表示 */
  577.             .ec-areaNotice__detail {
  578.                 display: none;
  579.             }
  580.             .ec-areaNotice.is-open .ec-areaNotice__detail {
  581.                 display: block;
  582.             }
  583.             .ec-areaNotice__text { font-size: 11px; line-height: 1.5; }
  584.             .ec-areaNotice__text br { display: none; }
  585.             .ec-areaNotice__link { font-size: 11px; margin-top: 3px; }
  586.             .rp-card { width: calc(33.333% - 6px); min-width: 80px; }
  587.             
  588.             #sp-mitsumori-bar {
  589.                 display: flex;
  590.                 position: fixed;
  591.                 bottom: 0;
  592.                 left: 0;
  593.                 right: 0;
  594.                 z-index: 1000;
  595.                 background: #fff;
  596.                 border-top: 2px solid #e0e0e0;
  597.                 box-shadow: 0 -2px 8px rgba(0,0,0,0.12);
  598.                 align-items: center;
  599.                 padding: 8px 12px;
  600.                 gap: 10px;
  601.             }
  602.             #sp-mitsumori-bar .sp-bar__label {
  603.                 font-size: 11px;
  604.                 color: #666;
  605.                 white-space: nowrap;
  606.             }
  607.             #sp-mitsumori-bar .sp-bar__price {
  608.                 font-size: 18px;
  609.                 font-weight: bold;
  610.                 color: #c00;
  611.                 flex: 1;
  612.             }
  613.             #sp-mitsumori-bar .sp-bar__btn {
  614.                 font-size: 12px;
  615.                 padding: 8px 12px;
  616.                 background: #333;
  617.                 color: #fff;
  618.                 border: none;
  619.                 border-radius: 6px;
  620.                 white-space: nowrap;
  621.                 cursor: pointer;
  622.             }
  623.             /* 下部バーの高さ分ページ下部にpaddingを追加 */
  624.             body {
  625.                 padding-bottom: 64px;
  626.             }
  627.         }
  628.     </style>
  629. {% endblock %}
  630. {% block javascript %}
  631.     <script>
  632.         eccube.classCategories = {{ class_categories_as_json(Product)|raw }};
  633.         // 規格2に選択肢を割り当てる。
  634.         function fnSetClassCategories(form, classcat_id2_selected) {
  635.             var $form = $(form);
  636.             var product_id = $form.find('input[name=product_id]').val();
  637.             var $sele1 = $form.find('select[name=classcategory_id1]');
  638.             var $sele2 = $form.find('select[name=classcategory_id2]');
  639.             eccube.setClassCategories($form, product_id, $sele1, $sele2, classcat_id2_selected);
  640.         }
  641.         {% if form.classcategory_id2 is defined %}
  642.         fnSetClassCategories(
  643.             $('#form1'), {{ form.classcategory_id2.vars.value|json_encode|raw }}
  644.         );
  645.         {% elseif form.classcategory_id1 is defined %}
  646.         eccube.checkStock($('#form1'), {{ Product.id }}, {{ form.classcategory_id1.vars.value|json_encode|raw }}, null);
  647.         {% endif %}
  648.     </script>
  649.     <script>
  650.         $(function() {
  651.             // bfcache無効化
  652.             $(window).bind('pageshow', function(event) {
  653.                 if (event.originalEvent.persisted) {
  654.                     location.reload(true);
  655.                 }
  656.             });
  657.             // Core Web Vital の Cumulative Layout Shift(CLS)対策のため
  658.             // img タグに width, height が付与されている.
  659.             // 630px 未満の画面サイズでは縦横比が壊れるための対策
  660.             // see https://github.com/EC-CUBE/ec-cube/pull/5023
  661.             $('.ec-grid2__cell').hide();
  662.             var removeSize = function () {
  663.                 $('.slide-item').height('');
  664.                 $('.slide-item img')
  665.                     .removeAttr('width')
  666.                     .removeAttr('height')
  667.                     .removeAttr('style');
  668.             };
  669.             var slickInitial = function(slick) {
  670.                 $('.ec-grid2__cell').fadeIn(1500);
  671.                 var baseHeight = $(slick.target).height();
  672.                 var baseWidth = $(slick.target).width();
  673.                 var rate = baseWidth / baseHeight;
  674.                 if(baseHeight * rate < 400){
  675.                     $('.slide-item').height(baseHeight * rate); // 余白を削除する
  676.                 }else{
  677.                     $('.slide-item').height(400); // 余白を削除する
  678.                 }
  679.                 // transform を使用することでCLSの影響を受けないようにする
  680.                 $('.slide-item img')
  681.                     .css(
  682.                         {
  683.                             'transform-origin': 'top left',
  684.                             'transform': 'scaleY(' + rate + ')',
  685.                             'transition': 'transform .1s'
  686.                         }
  687.                     );
  688.                 // 正しいサイズに近くなったら属性を解除する
  689.                 setTimeout(removeSize, 500);
  690.             };
  691.             $('.item_visual').on('init', slickInitial);
  692.             // リサイズ時は CLS の影響を受けないため属性を解除する
  693.             $(window).resize(removeSize);
  694.             $('.item_visual').slick({
  695.                 dots: false,
  696.                 arrows: true,
  697.                 responsive: [{
  698.                     breakpoint: 768,
  699.                     settings: {
  700.                         dots: true,
  701.                         arrows: false
  702.                     }
  703.                 }]
  704.             });
  705.             $('.slideThumb').on('click', function() {
  706.                 var index = $(this).attr('data-index');
  707.                 $('.item_visual').slick('slickGoTo', index, false);
  708.             })
  709.         });
  710.     </script>
  711.     <script>
  712.         $(function() {
  713.             $('.add-cart').on('click', function(event) {
  714.                 {% if form.classcategory_id1 is defined %}
  715.                 // 規格1フォームの必須チェック
  716.                 if ($('#classcategory_id1').val() == '__unselected' || $('#classcategory_id1').val() == '') {
  717.                     $('#classcategory_id1')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  718.                     return true;
  719.                 } else {
  720.                     $('#classcategory_id1')[0].setCustomValidity('');
  721.                 }
  722.                 {% endif %}
  723.                 {% if form.classcategory_id2 is defined %}
  724.                 // 規格2フォームの必須チェック
  725.                 if ($('#classcategory_id2').val() == '__unselected' || $('#classcategory_id2').val() == '') {
  726.                     $('#classcategory_id2')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  727.                     return true;
  728.                 } else {
  729.                     $('#classcategory_id2')[0].setCustomValidity('');
  730.                 }
  731.                 {% endif %}
  732.                 // タイプ2: カート送信直前に set_count を quantity に同期
  733.                 if($('#set_count').length){
  734.                     var _sc = parseInt($('#set_count').val()) || 1;
  735.                     $('#quantity').val(_sc);
  736.                     $('input[name="quantity"]').val(_sc);
  737.                 }
  738.                 // 個数フォームのチェック
  739.                 if ($('#quantity').val() < 1) {
  740.                     $('#quantity')[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  741.                     return true;
  742.                 } else {
  743.                     $('#quantity')[0].setCustomValidity('');
  744.                 }
  745.                 event.preventDefault();
  746.                 $form = $('#form1');
  747.                 $.ajax({
  748.                     url: $form.attr('action'),
  749.                     type: $form.attr('method'),
  750.                     data: $form.serialize(),
  751.                     dataType: 'json',
  752.                     beforeSend: function(xhr, settings) {
  753.                         // Buttonを無効にする
  754.                         $('.add-cart').prop('disabled', true);
  755.                     }
  756.                 }).done(function(data) {
  757.                     // レスポンス内のメッセージをalertで表示
  758.                     $.each(data.messages, function() {
  759.                         $('#ec-modal-header').text(this);
  760.                     });
  761.                     $('.ec-modal').show()
  762.                     // カートブロックを更新する
  763.                     $.ajax({
  764.                         url: "{{ url('block_cart') }}",
  765.                         type: 'GET',
  766.                         dataType: 'html'
  767.                     }).done(function(html) {
  768.                         $('.ec-headerRole__cart').html(html);
  769.                     });
  770.                 }).fail(function(data) {
  771.                     alert('{{ '施工検討リストへの追加に失敗しました。'|trans }}');
  772.                 }).always(function(data) {
  773.                     // Buttonを有効にする
  774.                     $('.add-cart').prop('disabled', false);
  775.                 });
  776.             });
  777.         });
  778.         $('.ec-modal-wrap').on('click', function(e) {
  779.             // モーダル内の処理は外側にバブリングさせない
  780.             e.stopPropagation();
  781.         });
  782.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  783.             $('.ec-modal').hide()
  784.         });
  785.         var pw = "{% if mitsumori_json %}{{ mitsumori_json.pw }}{% endif %}";
  786.         var pd = "{% if mitsumori_json %}{{ mitsumori_json.pd }}{% endif %}";
  787.         var ph = "{% if mitsumori_json %}{{ mitsumori_json.ph }}{% endif %}";
  788.         var pm = "{% if mitsumori_json %}{{ mitsumori_json.pm }}{% endif %}";
  789.         var pc = "{% if mitsumori_json %}{{ mitsumori_json.pc }}{% endif %}";
  790.         var op0 = "{% if mitsumori_json %}{{ mitsumori_json.op[0] }}{% endif %}";
  791.         var op1 = "{% if mitsumori_json %}{{ mitsumori_json.op[1] }}{% endif %}";
  792.         var op2 = "{% if mitsumori_json %}{{ mitsumori_json.op[2] }}{% endif %}";
  793.         var op3 = "{% if mitsumori_json %}{{ mitsumori_json.op[3] }}{% endif %}";
  794.         var op4 = "{% if mitsumori_json %}{{ mitsumori_json.op[4] }}{% endif %}";
  795.         var op5 = "{% if mitsumori_json %}{{ mitsumori_json.op[5] }}{% endif %}";
  796.         var op6 = "{% if mitsumori_json %}{{ mitsumori_json.op[6] }}{% endif %}";
  797.         var op7 = "{% if mitsumori_json %}{{ mitsumori_json.op[7] }}{% endif %}";
  798.         var op8 = "{% if mitsumori_json %}{{ mitsumori_json.op[8] }}{% endif %}";
  799.         var op9 = "{% if mitsumori_json %}{{ mitsumori_json.op[9] }}{% endif %}";
  800.         var op10 = "{% if mitsumori_json %}{{ mitsumori_json.op[10] }}{% endif %}";
  801.         const formatter = new Intl.NumberFormat('ja-JP');
  802.         function mitsumori_simulation(type , value_id){
  803.             var pp = {{ pp|raw }};
  804.             if(type == "pw"){
  805.                 pw = $('#'+value_id).val();
  806.             }
  807.             if(type == "pd"){
  808.                 pd = $('#'+value_id).val();
  809.             }
  810.             if(type == "ph"){
  811.                 ph = $('#'+value_id).val();
  812.             }
  813.             if(type == "pm"){
  814.                 pm = $('#'+value_id).val();
  815.             }
  816.             if(type == "pc"){
  817.                 pc = $('#'+value_id).val();
  818.             }
  819.             if(type == "op0"){ op0 = $('#'+value_id).val(); }
  820.             if(type == "op1"){ op1 = $('#'+value_id).val(); }
  821.             if(type == "op2"){ op2 = $('#'+value_id).val(); }
  822.             if(type == "op3"){ op3 = $('#'+value_id).val(); }
  823.             if(type == "op4"){ op4 = $('#'+value_id).val(); }
  824.             if(type == "op5"){ op5 = $('#'+value_id).val(); }
  825.             if(type == "op6"){ op6 = $('#'+value_id).val(); }
  826.             if(type == "op7"){ op7 = $('#'+value_id).val(); }
  827.             if(type == "op8"){ op8 = $('#'+value_id).val(); }
  828.             if(type == "op9"){ op9 = $('#'+value_id).val(); }
  829.             if(type == "op10"){ op10 = $('#'+value_id).val(); }
  830.             // op系: ボタンの is-selected を選択中のものに付け替え + radio チェック
  831.             if(/^op\d+$/.test(type)) {
  832.                 var $clicked = $('#' + value_id);
  833.                 $clicked.prop('checked', true);
  834.                 var groupName = $clicked.attr('name');
  835.                 $('input[name="' + groupName + '"]').closest('.opt-btn').removeClass('is-selected');
  836.                 $clicked.closest('.opt-btn').addClass('is-selected');
  837.                 // ラベルの選択値テキスト更新
  838.                 var $group = $clicked.closest('.form-group');
  839.                 var $label = $group.find('.rp-section-label');
  840.                 if ($label.length) {
  841.                     var labelText = $label.text().split(':')[0].trim();
  842.                     $label.html(labelText + ': <span>' + $clicked.val() + '</span>');
  843.                 }
  844.             }
  845.             if(pm == ""){
  846.                 $('#mitsumori_message').text("素材を選択してください");
  847.             }
  848.             if(ph == ""){
  849.                 $('#mitsumori_message').text("高さを選択してください");
  850.             }
  851.             if(pd == ""){
  852.                 $('#mitsumori_message').text("奥行きを選択してください");
  853.             }
  854.             if(pw == ""){
  855.                 $('#mitsumori_message').text("幅を選択してください");
  856.             }
  857.             if(pc == ""){
  858.                 $('#mitsumori_message').text("カラーを選択してください");
  859.                 $('#mitsumori_btn').hide();
  860.                 $('#mitsumori_goukei').text("---円");
  861.                 $('#mitsumori_off').text("---円");
  862.                 $('#mitsumori_price').text("---円");
  863.                 $('#maker_price').text("---円");
  864.                 $('#mitsumori_ct').text("---円");
  865.                 $('#mitsumori_option').text("---円");
  866.             }
  867.             if(pw != "" && pd != "" && ph != "" && pm != "" && pc != ""){
  868.                 $('#mitsumori_btn').show();
  869.                 var pp_matched = false;
  870.                 pp.forEach((el) => {
  871.                   if((pw == el.w || pw == "指定なし") && (pd == el.d || pd == "指定なし") && (ph == el.h || ph == "指定なし") && (pm == el.m || pm == "指定なし") && (pc == el.c || pc == "指定なし")){
  872.                     pp_matched = true;
  873.                     if(op0 == "商品購入のみ" || op1 == "商品購入のみ" || op2 == "商品購入のみ" || op3 == "商品購入のみ" || op4 == "商品購入のみ"
  874.                         || op5 == "商品購入のみ" || op6 == "商品購入のみ" || op7 == "商品購入のみ" || op8 == "商品購入のみ" || op9 == "商品購入のみ"){
  875.                           $('#mitsumori_message').text(formatter.format(parseInt(el.price)) + "円");
  876.                           $('#mitsumori_goukei').text(formatter.format(parseInt(el.price)) + "円");
  877.                           $('#mitsumori_off').text(formatter.format(parseInt(el.price) - parseInt(el.maker_price)) + "円");
  878.                           $('#mitsumori_price').text(formatter.format(parseInt(el.price)) + "円");
  879.                           $('#maker_price').text(formatter.format(parseInt(el.maker_price)) + "円");
  880.                           $('#mitsumori_ct').text("0円");
  881.                           $('#mitsumori_option').text("0円");
  882.                           $('#mitsumori_kei').text(formatter.format(parseInt(el.price)) + "円");
  883.                           $('#mitsumori_price_01').text(formatter.format(parseInt(el.price)) + "円");
  884.                           $('#mitsumori_price_02').text(formatter.format(parseInt(el.price)) + "円");
  885.                           $('#mitsumori_ct_01').text("0円");
  886.                           $('#mitsumori_ct_02').text("0円");
  887.                           $('#mitsumori_goukei_02').text(formatter.format(parseInt(el.price)) + "円");
  888.                         mitsumori_goukei = (parseInt(el.price));
  889.                         shoukei = mitsumori_goukei / 1.1;
  890.                         tax = parseInt(mitsumori_goukei - shoukei);
  891.                           $('#mitsumori_shoukei').text(formatter.format(parseInt(shoukei)) + "円");
  892.                           $('#mitsumori_tax').text(formatter.format(parseInt(tax)) + "円");
  893.                     }else{
  894.                           $('#mitsumori_message').text(formatter.format(parseInt(el.price) + parseInt(el.ct)) + "円");
  895.                           $('#mitsumori_goukei').text(formatter.format(parseInt(el.price) + parseInt(el.ct)) + "円");
  896.                           $('#mitsumori_off').text(formatter.format(parseInt(el.price) - parseInt(el.maker_price)) + "円");
  897.                           $('#mitsumori_price').text(formatter.format(parseInt(el.price)) + "円");
  898.                           $('#maker_price').text(formatter.format(parseInt(el.maker_price)) + "円");
  899.                           $('#mitsumori_ct').text(formatter.format(parseInt(el.ct)) + "円");
  900.                           $('#mitsumori_option').text("0円");
  901.                           $('#mitsumori_kei').text(formatter.format(parseInt(el.price) + parseInt(el.ct)) + "円");
  902.                           $('#mitsumori_price_01').text(formatter.format(parseInt(el.price)) + "円");
  903.                           $('#mitsumori_price_02').text(formatter.format(parseInt(el.price)) + "円");
  904.                           $('#mitsumori_ct_01').text(formatter.format(parseInt(el.ct)) + "円");
  905.                           $('#mitsumori_ct_02').text(formatter.format(parseInt(el.ct)) + "円");
  906.                           $('#mitsumori_goukei_02').text(formatter.format(parseInt(el.price) + parseInt(el.ct)) + "円");
  907.                         mitsumori_goukei = (parseInt(el.price) + parseInt(el.ct));
  908.                         shoukei = mitsumori_goukei / 1.1;
  909.                         tax = parseInt(mitsumori_goukei - shoukei);
  910.                           $('#mitsumori_shoukei').text(formatter.format(parseInt(shoukei)) + "円");
  911.                           $('#mitsumori_tax').text(formatter.format(parseInt(tax)) + "円");
  912.                     }
  913.                   }
  914.                 });
  915.                 if (!pp_matched) {
  916.                     $('#mitsumori_message').text("この組み合わせは対応しておりません");
  917.                     $('#mitsumori_btn').hide();
  918.                     $('#mitsumori_goukei').text("---円");
  919.                     $('#mitsumori_off').text("---円");
  920.                     $('#mitsumori_price').text("---円");
  921.                     $('#maker_price').text("---円");
  922.                     $('#mitsumori_ct').text("---円");
  923.                     $('#mitsumori_option').text("---円");
  924.                     $('#mitsumori_kei').text("---円");
  925.                     $('#mitsumori_shoukei').text("---円");
  926.                     $('#mitsumori_tax').text("---円");
  927.                 }    
  928.                 // タイプ5: ステップ・フェンス・面積の現在値を取得
  929.                 if($('input[name=deck_step]:checked').length){ deck_step = $('input[name=deck_step]:checked').val(); }
  930.                 if($('input[name=deck_fence]:checked').length){ deck_fence = $('input[name=deck_fence]:checked').val(); }
  931.                 // タイプ2: 窓サイズ・窓タイプ・ガラスタイプ・セット数
  932.                 var mado_w_val     = $('#mado_w').val()     || '';
  933.                 var mado_h_val     = $('#mado_h').val()     || '';
  934.                 var mado_type_val  = $('input[name=mado_type]:checked').val()  || '';
  935.                 var glass_type_val = $('input[name=glass_type]:checked').val() || '';
  936.                 var set_count_val  = parseInt($('#set_count').val()) || 1;
  937.                 // タイプ3: 台数
  938.                 var daisu_val = parseInt($('#daisu').val()) || 1;
  939.                 // タイプ4・6: 枚数
  940.                 var maisu_val = parseInt($('#maisu').val()) || 1;
  941.                 // タイプ5: 面積
  942.                 var area_val = $('#area').val() || '';
  943.                 // sale_type
  944.                 var sale_type_id = {{ ProductClass.SaleType.id }};
  945.                 var mitsumori_json = { "mitsumori_goukei": $('#mitsumori_goukei').text(),
  946.                                         "mitsumori_goukei_02": $('#mitsumori_goukei_02').text(),
  947.                                         "mitsumori_price": $('#mitsumori_price').text(),
  948.                                         "maker_price": $('#maker_price').text(),
  949.                                         "mitsumori_off": $('#mitsumori_off').text(),
  950.                                         "mitsumori_ct": $('#mitsumori_ct').text(),
  951.                                         "mitsumori_option": $('#mitsumori_option').text(),
  952.                                         "product_id": {{ Product.id }},
  953.                                         "sale_type": sale_type_id,
  954.                                         "pw": pw,
  955.                                         "pd": pd,
  956.                                         "ph": ph,
  957.                                         "pm": pm,
  958.                                         "pc": pc,
  959.                                         "op": [op0,op1,op2,op3,op4,op5,op6,op7,op8,op9,op10],
  960.                                         "mado_w":     mado_w_val,
  961.                                         "mado_h":     mado_h_val,
  962.                                         "mado_type":  mado_type_val,
  963.                                         "glass_type": glass_type_val,
  964.                                         "set_count":  set_count_val,
  965.                                         "daisu":      daisu_val,
  966.                                         "maisu":      maisu_val,
  967.                                         "area":       area_val,
  968.                                         "deck_step":  deck_step,
  969.                                         "deck_fence": deck_fence };
  970.                 $('#mitsumori_json').val(JSON.stringify(mitsumori_json));
  971.                 
  972.             }
  973.             
  974.         }
  975.         {% if color and color|length == 1 %}
  976.             pc = "指定なし";
  977.             {% for cc in color %}{% if cc and cc['name'] %} pc = "{{ cc['name'] }}"; {% endif %}{% endfor %}
  978.         {% endif %}
  979.         {% if p_w and (p_w|length == 1 or p_w|join == "") %}
  980.             pw = "指定なし";
  981.             {% for pw in p_w %}{% if pw %} pw = "{{ pw }}"; {% endif %}{% endfor %}
  982.         {% endif %}
  983.         {% if p_d and (p_d|length == 1 or p_d|join == "") %}
  984.             pd = "指定なし";
  985.             {% for pd in p_d %}{% if pd %} pd = "{{ pd }}"; {% endif %}{% endfor %}
  986.         {% endif %}
  987.         {% if p_h and (p_h|length == 1 or p_h|join == "") %}
  988.             ph = "指定なし";
  989.             {% for ph in p_h %}{% if ph %} ph = "{{ ph }}"; {% endif %}{% endfor %}
  990.         {% endif %}
  991.         {% if p_m and (p_m|length == 1 or p_m|join == "") %}
  992.             pm = "指定なし";
  993.             {% for pm in p_m %}{% if pm %} pm = "{{ pm }}"; {% endif %}{% endfor %}
  994.         {% endif %}
  995.         // ページ読み込み時: タイプ別に quantity の初期値をセット
  996.         (function initQuantityByType(){
  997.             var saleType = {{ ProductClass.SaleType.id }};
  998.             if(saleType == 2 && $('#set_count').length){
  999.                 var _v = parseInt($('#set_count').val()) || 1;
  1000.                 $('#quantity').val(_v);
  1001.                 $('input[name="quantity"]').val(_v);
  1002.             } else if(saleType == 3 && $('#daisu').length){
  1003.                 $('#quantity').val(parseInt($('#daisu').val()) || 1);
  1004.             } else if((saleType == 4 || saleType == 6) && $('#maisu').length){
  1005.                 $('#quantity').val(parseInt($('#maisu').val()) || 1);
  1006.             } else if(saleType == 9 && $('#quantity_only').length){
  1007.                 $('#quantity').val(parseInt($('#quantity_only').val()) || 1);
  1008.             }
  1009.         })();
  1010.         // type → ラベルのプレフィックス文字列
  1011.         var optLabelMap = {pc:'カラー', pw:'幅', pd:'奥行き', ph:'高さ', pm:'素材'};
  1012.         // type → input[name]
  1013.         var optNameMap  = {pc:'color', pw:'pw', pd:'pd', ph:'ph', pm:'pm'};
  1014.         // opt-btn用: 値を直接受け取るラッパー
  1015.         function mitsumori_simulation_val(type, value) {
  1016.             if (type === 'pc') pc = value;
  1017.             if (type === 'pw') pw = value;
  1018.             if (type === 'pd') pd = value;
  1019.             if (type === 'ph') ph = value;
  1020.             if (type === 'pm') pm = value;
  1021.             // is-selected クラスを同グループ内で付け替え
  1022.             var inputName = optNameMap[type];
  1023.             if (inputName) {
  1024.                 var $btns = $('input[name="' + inputName + '"]').closest('.opt-btn');
  1025.                 $btns.removeClass('is-selected');
  1026.                 $btns.filter(function(){
  1027.                     return $(this).find('input').val() === value;
  1028.                 }).addClass('is-selected');
  1029.             }
  1030.             // ラベル行の選択値テキストを更新(例: 「カラー: ブラック」)
  1031.             var labelPrefix = optLabelMap[type];
  1032.             if (labelPrefix) {
  1033.                 // 対象のrp-section-labelを特定(input[name]を含む親を遡る)
  1034.                 var $group = $('input[name="' + inputName + '"]').first().closest('.form-group');
  1035.                 var $label = $group.find('.rp-section-label');
  1036.                 $label.html(labelPrefix + ': <span>' + value + '</span>');
  1037.             }
  1038.             // simulation本体を呼ぶ(value_idは空でOK、グローバル変数を使う)
  1039.             mitsumori_simulation('', '');
  1040.         }
  1041.         mitsumori_simulation("","");
  1042.         // ボタン群: 親幅を超える、または3行以上になる場合は is-scroll で1行横スクロール化
  1043.         function applyBtnGroupScroll() {
  1044.             $('.rp-btn-group, .opt-btn-group').each(function() {
  1045.                 var $group = $(this);
  1046.                 $group.removeClass('is-scroll');
  1047.                 var $items = $group.children();
  1048.                 if ($items.length === 0) return;
  1049.                 var parentWidth = $group.parent().width() || $group.width();
  1050.                 var totalWidth = 0;
  1051.                 var gap = parseInt($group.css('gap'), 10) || 8;
  1052.                 $items.each(function() {
  1053.                     totalWidth += this.offsetWidth + gap;
  1054.                 });
  1055.                 // 単一ボタンが親幅を超える、もしくは合計幅が親幅を超える → 横スクロール化
  1056.                 var anyTooWide = false;
  1057.                 $items.each(function() {
  1058.                     if (this.offsetWidth > parentWidth) { anyTooWide = true; return false; }
  1059.                 });
  1060.                 // 折り返し時の行数も計測
  1061.                 var tops = {};
  1062.                 $items.each(function() { tops[this.offsetTop] = true; });
  1063.                 var rowCount = Object.keys(tops).length;
  1064.                 if (anyTooWide || totalWidth > parentWidth * 2 || rowCount >= 3) {
  1065.                     $group.addClass('is-scroll');
  1066.                 }
  1067.             });
  1068.         }
  1069.         applyBtnGroupScroll();
  1070.         $(window).on('resize', function() {
  1071.             clearTimeout(window._btnScrollTimer);
  1072.             window._btnScrollTimer = setTimeout(applyBtnGroupScroll, 150);
  1073.         });
  1074.         // onload: 見積金額が確定している場合は「工事費込み価格」表示を一致させる
  1075.         (function syncPrice02Display() {
  1076.             var goukeiEl = document.getElementById('mitsumori_goukei');
  1077.             var displayEl = document.getElementById('price02-display');
  1078.             if (!goukeiEl || !displayEl) return;
  1079.             var goukeiText = goukeiEl.textContent.trim();
  1080.             // ---円(未確定)の場合は書き換えない
  1081.             if (goukeiText && goukeiText !== '---円') {
  1082.                 displayEl.textContent = goukeiText;
  1083.             }
  1084.             // 以降の変更にも追従: mitsumori_goukei を監視
  1085.             new MutationObserver(function() {
  1086.                 var text = goukeiEl.textContent.trim();
  1087.                 if (text && text !== '---円') {
  1088.                     displayEl.textContent = text;
  1089.                 }
  1090.             }).observe(goukeiEl, { childList: true, subtree: true, characterData: true });
  1091.         })();
  1092.         function contact_form(product_id){
  1093.             $('#form1').attr('action', '{{ url('contact', {product:Product.id}) }}');
  1094.             $('#form1').submit();
  1095.         }
  1096.         // maisu / madoset は下部の新しい関数定義を使用
  1097.         function heibei(bei){
  1098.             $('#heibei').val(parseInt($('#heibei').val()) + bei);
  1099.             if(parseInt($('#heibei').val()) < 1){ $('#heibei').val(1); }
  1100.             if(parseInt($('#heibei').val()) > 100){ $('#heibei').val(100); }
  1101.             $('#quantity').val($('#heibei').val());
  1102.             mitsumori_simulation('heibei','heibei');
  1103.         }
  1104.         function daisu(dai){
  1105.             $('#daisu').val(parseInt($('#daisu').val()) + dai);
  1106.             if(parseInt($('#daisu').val()) < 1){ $('#daisu').val(1); }
  1107.             if(parseInt($('#daisu').val()) > 10){ $('#daisu').val(10); }
  1108.             $('#quantity').val($('#daisu').val());
  1109.             mitsumori_simulation('daisu','daisu');
  1110.         }
  1111.         function maisu(mai){
  1112.             $('#maisu').val(parseInt($('#maisu').val()) + mai);
  1113.             if(parseInt($('#maisu').val()) < 1){ $('#maisu').val(1); }
  1114.             if(parseInt($('#maisu').val()) > 100){ $('#maisu').val(100); }
  1115.             $('#quantity').val($('#maisu').val());
  1116.             mitsumori_simulation('maisu','maisu');
  1117.         }
  1118.         // タイプ2: セット数プルダウン連動
  1119.         function madosetSelect(val){
  1120.             var v = parseInt(val);
  1121.             if(v < 1) v = 1;
  1122.             if(v > 20) v = 20;
  1123.             // id="quantity" と name="quantity" 両方を確実に書き換え
  1124.             $('#quantity').val(v);
  1125.             $('input[name="quantity"]').val(v);
  1126.             mitsumori_simulation('set','set_count');
  1127.         }
  1128.         // タイプ2: ±ボタン版(後方互換)
  1129.         function madoset(mai){
  1130.             var current = parseInt($('#set_count').val()) || 1;
  1131.             var next = current + mai;
  1132.             if(next < 1) next = 1;
  1133.             if(next > 20) next = 20;
  1134.             $('#set_count').val(next);
  1135.             madosetSelect(next);
  1136.         }
  1137.         // タイプ5: ステップ・フェンス選択値を mitsumori_json に保存するためのグローバル変数
  1138.         var deck_step = "{% if mitsumori_json %}{{ mitsumori_json.deck_step|default('不要') }}{% else %}不要{% endif %}";
  1139.         var deck_fence = "{% if mitsumori_json %}{{ mitsumori_json.deck_fence|default('不要') }}{% else %}不要{% endif %}";
  1140.         // PDF出力: モーダルの mitsumori_json をフォームに同期してから送信
  1141.         function syncPdfJson(){
  1142.             var jsonVal = $('#mitsumori_json').val();
  1143.             $('#pdf_mitsumori_json').val(jsonVal);
  1144.         }
  1145.         // タイプ9: 商品のみ購入
  1146.         function quantityOnly(val){
  1147.             var current = parseInt($('#quantity_only').val()) || 1;
  1148.             var next = current + val;
  1149.             if(next < 1) next = 1;
  1150.             $('#quantity_only').val(next);
  1151.             $('#quantity').val(next);
  1152.         }
  1153.         // ===== スマホ用下部固定バーへの金額同期 =====
  1154.         // mitsumori_message と mitsumori_goukei を監視して下部バーを更新
  1155.         (function() {
  1156.             var msgTarget   = document.getElementById('mitsumori_message');
  1157.             var goukeiTarget = document.getElementById('mitsumori_goukei');
  1158.             var spPrice     = document.getElementById('sp-mitsumori-price');
  1159.             var spBtn       = document.querySelector('#sp-mitsumori-bar .sp-bar__btn');
  1160.             if (!spPrice || !spBtn) return;
  1161.             function syncBar() {
  1162.                 var msg    = msgTarget ? msgTarget.textContent : '';
  1163.                 var goukei = goukeiTarget ? goukeiTarget.textContent : '---円';
  1164.                 // メッセージが「〇〇を選択してください」の場合はメッセージを表示しボタンを非表示
  1165.                 if (msg.indexOf('選択してください') !== -1) {
  1166.                     spPrice.textContent = msg;
  1167.                     spPrice.style.fontSize = '13px';
  1168.                     spPrice.style.color    = '#888';
  1169.                     spBtn.style.display    = 'none';
  1170.                 } else {
  1171.                     // 価格確定時はボタンを表示
  1172.                     spPrice.textContent = goukei;
  1173.                     spPrice.style.fontSize = '18px';
  1174.                     spPrice.style.color    = '#c00';
  1175.                     spBtn.style.display    = 'block';
  1176.                 }
  1177.             }
  1178.             // 初期値を同期
  1179.             syncBar();
  1180.             // mitsumori_message の変化を監視
  1181.             if (msgTarget) {
  1182.                 new MutationObserver(syncBar).observe(
  1183.                     msgTarget, { childList: true, subtree: true, characterData: true }
  1184.                 );
  1185.             }
  1186.             // mitsumori_goukei の変化も監視
  1187.             if (goukeiTarget) {
  1188.                 new MutationObserver(syncBar).observe(
  1189.                     goukeiTarget, { childList: true, subtree: true, characterData: true }
  1190.                 );
  1191.             }
  1192.         })();
  1193.         // ===== 現在のお見積り額: 折りたたみトグルボタンのテキスト切り替え =====
  1194.         (function() {
  1195.             var card = document.querySelector('.mitsumori-card-pc');
  1196.             var btn  = document.querySelector('.btn-mitsumori-toggle .toggle-icon');
  1197.             if (!card || !btn) return;
  1198.             // MutationObserverでcollapsed-cardクラスの変化を監視
  1199.             new MutationObserver(function() {
  1200.                 if (card.classList.contains('collapsed-card')) {
  1201.                     btn.textContent = '▼ 詳細';
  1202.                 } else {
  1203.                     btn.textContent = '▲ 閉じる';
  1204.                 }
  1205.             }).observe(card, { attributes: true, attributeFilter: ['class'] });
  1206.         })();
  1207.         // ===== エリア案内: スマホのみタップで展開 =====
  1208.         (function() {
  1209.             var notice = document.querySelector('.ec-areaNotice');
  1210.             if (!notice) return;
  1211.             notice.addEventListener('click', function(e) {
  1212.                 if (window.innerWidth > 767) return;
  1213.                 // リンククリック時は展開/折りたたみせずリンク遷移
  1214.                 if (e.target.tagName === 'A') return;
  1215.                 notice.classList.toggle('is-open');
  1216.             });
  1217.         })();
  1218.     </script>
  1219.     <script type="application/ld+json">
  1220.     {
  1221.         "@context": "https://schema.org/",
  1222.         "@type": "Product",
  1223.         "name": "{{ Product.name }}",
  1224.         "image": [
  1225.             {% for img in Product.ProductImage %}
  1226.                 "{{ app.request.schemeAndHttpHost }}{{ asset(img, 'save_image') }}"{% if not loop.last %},{% endif %}
  1227.             {% else %}
  1228.                 "{{ app.request.schemeAndHttpHost }}{{ asset(''|no_image_product, 'save_image') }}"
  1229.             {% endfor %}
  1230.         ],
  1231.         "description": "{{ Product.description_list | default(Product.description_detail) | replace({'\n': '', '\r': ''}) | slice(0,300) }}",
  1232.         {% if Product.code_min %}
  1233.         "sku": "{{ Product.code_min }}",
  1234.         {% endif %}
  1235.         "offers": {
  1236.             "@type": "Offer",
  1237.             "url": "{{ url('product_detail', {'id': Product.id}) }}",
  1238.             "priceCurrency": "{{ eccube_config.currency }}",
  1239.             "price": {{ Product.getPrice02IncTaxMin ? Product.getPrice02IncTaxMin : 0}},
  1240.             "availability": "{{ Product.stock_find ? "InStock" : "OutOfStock" }}"
  1241.         }
  1242.     }
  1243.     </script>
  1244. {% endblock %}
  1245. {% block main %}
  1246.     <div class="ec-productRole" style="margin-top:20px;">
  1247.         <div class="ec-grid2">
  1248.             <div class="ec-grid2__cell">
  1249.                 <div class="ec-sliderItemRole">
  1250.                     {# 商品名 + ブランド名 + SNSシェア #}
  1251.                     <div class="ec-productRole__title">
  1252.                         <div class="ec-productRole__titleRow">
  1253.                             <h2 class="ec-headingTitle">{{ Product.name }}</h2>
  1254.                             <div class="ec-share-inline">
  1255.                                 <a href="https://twitter.com/share?url={{ app.request.uri|url_encode }}&text={{ Product.name|url_encode }}"
  1256.                                    class="share-twitter" target="_blank" rel="noreferrer noopener" title="Xでシェア">
  1257.                                     <svg viewBox="0 0 24 24" style="width:15px;height:15px;fill:#fff;"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-4.714-6.231-5.401 6.231H2.74l7.73-8.835L1.254 2.25H8.08l4.254 5.622L18.244 2.25zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>
  1258.                                 </a>
  1259.                                 <a href="https://www.instagram.com/" class="share-facebook" target="_blank" rel="noreferrer noopener" title="Instagram">
  1260.                                     <svg viewBox="0 0 24 24" style="width:15px;height:15px;fill:#fff;"><path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z"/></svg>
  1261.                                 </a>
  1262.                                 <a href="https://social-plugins.line.me/lineit/share?url={{ app.request.uri|url_encode }}"
  1263.                                    class="share-line" target="_blank" rel="noreferrer noopener" title="LINEでシェア">
  1264.                                     <i class="fab fa-line"></i>
  1265.                                 </a>
  1266.                             </div>
  1267.                         </div>
  1268.                     </div>
  1269.                     {% if BaseInfo.option_favorite_product %}
  1270.                      <div style="position:relative;top: 20px;left: 10px;z-index:100;">
  1271.                         {% if is_favorite == false %}
  1272.                         <form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
  1273.                            <button type="submit" id="favorite" class="favorite">&#9825;</button>
  1274.                         </form>
  1275.                         {% else %}
  1276.                         <form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
  1277.                            <button type="submit" id="favorite" class="favorite" style="color:red;">&#9829;</button>
  1278.                         </form>
  1279.                         {% endif %}
  1280.                      </div>
  1281.                     {% endif %}
  1282.                     <div class="item_visual">
  1283.                         {% for ProductImage in Product.ProductImage %}
  1284.                             <div class="slide-item"><img src="{{ asset(ProductImage, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}" width="550" height="550" style="max-height: 400px;"{% if loop.index > 1 %} loading="lazy"{% endif %}></div>
  1285.                         {% else %}
  1286.                             <div class="slide-item"><img src="{{ asset(''|no_image_product, 'save_image') }}" alt="{{ loop.first ? Product.name : '' }}" width="550" height="550" style="max-height: 400px;"></div>
  1287.                         {% endfor %}
  1288.                     </div>
  1289.                     <div class="item_nav">
  1290.                         {% for ProductImage in Product.ProductImage %}
  1291.                             <div class="slideThumb" data-index="{{ loop.index0 }}"><img src="{{ asset(ProductImage, 'save_image') }}" alt="" width="80" height="80" loading="lazy"></div>
  1292.                         {% endfor %}
  1293.                     </div>
  1294.                 </div>
  1295.                     {# ===== 施工エリア案内(見積シミュレーションの下)===== #}
  1296.                     <div class="ec-areaNotice" style="margin-top:16px;margin-right:10px;">
  1297.                         <div class="ec-areaNotice__inner">
  1298.                             <div class="ec-areaNotice__icon">📍</div>
  1299.                             <div class="ec-areaNotice__body">
  1300.                                 <p class="ec-areaNotice__title">施工対応エリアについて</p>
  1301.                                 <div class="ec-areaNotice__detail">
  1302.                                     <p class="ec-areaNotice__text">
  1303.                                         当店の施工サービスは、<strong>山梨県全域</strong>および<br>
  1304.                                         <strong>諏訪エリア(諏訪市・岡谷市・茅野市・諏訪郡)</strong>を対象としております。<br>
  1305.                                         上記エリア外のお客様には、商品のみのご購入が可能でございます。<br>
  1306.                                         ご不明な点がございましたら、お気軽にお問い合わせください。
  1307.                                     </p>
  1308.                                     <a class="ec-areaNotice__link" href="{{ url('contact') }}">エリア外のお客様・ご相談はこちら →</a>
  1309.                                 </div>
  1310.                             </div>
  1311.                         </div>
  1312.                     </div>
  1313.             </div>
  1314.             <div class="ec-grid2__cell2">
  1315.                 <div class="ec-productRole__profile" >
  1316.                     {# 関連カテゴリ #}
  1317.                     {% if Product.ProductCategories is not empty %}
  1318.                         <div class="ec-productRole__category" style="padding:10px 0;">
  1319.                             {% for ProductCategory in Product.ProductCategories %}
  1320.                                 <ul>
  1321.                                     <li>
  1322.                                         {% for Category in ProductCategory.Category.path %}
  1323.                                             <a href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a> {%- if loop.last == false %}
  1324.                                             <span>></span>{% endif -%}
  1325.                                         {% endfor %}
  1326.                                     </li>
  1327.                                 </ul>
  1328.                             {% endfor %}
  1329.                         </div>
  1330.                     {% endif %}
  1331.                     {# 販売価格 #}
  1332.                     <div class="ec-productRole__price">
  1333.                         <span style="color:black;font-size:15px;">工事費込み価格</span>
  1334.                         {% if Product.hasProductClass -%}
  1335.                             {% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
  1336.                                 <div class="ec-price">
  1337.                                     <span id="price02-display" class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }}</span>
  1338.                                     <span class="ec-price__tax">({{ '税込'|trans }})~</span>
  1339.                                 </div>
  1340.                             {% else %}
  1341.                                 <div class="ec-price">
  1342.                                     <span id="price02-display" class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}</span>
  1343.                                     <span class="ec-price__tax">({{ '税込'|trans }})</span>
  1344.                                 </div>
  1345.                             {% endif %}
  1346.                         {% else %}
  1347.                             <div class="ec-price">
  1348.                                 <span id="price02-display" class="ec-price__price">{{ Product.getPrice02IncTaxMin|price }}</span>
  1349.                                     <span class="ec-price__tax">({{ '税込'|trans }})~</span>
  1350.                             </div>
  1351.                         {% endif %}
  1352.                     </div>
  1353.                     {# タグ #}
  1354.                     <ul class="ec-productRole__tags">
  1355.                         {% for Tag in Product.Tags %}
  1356.                             <li class="ec-productRole__tag tag_{{ Tag.id }}">{{ Tag }}</li>
  1357.                         {% endfor %}
  1358.                     </ul>
  1359.                     {# 商品コード #}
  1360.                     {% if Product.code_min is not empty %}
  1361.                         <div class="ec-productRole__code">
  1362.                             {{ '商品コード'|trans }}: <span class="product-code-default">{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</span>
  1363.                         </div>
  1364.                     {% endif %}
  1365.                     <div class="ec-productRole__description">
  1366.                         <div class="ec-rectHeading">
  1367.                             <h4>製品情報</h4>
  1368.                         </div>
  1369.                         {{ Product.sales_infomation|raw|nl2br }}
  1370.                     </div>
  1371.                     <div class="card card-danger" style="clear:both;margin:1px;">
  1372.                       <div class="card-header">
  1373.                         <h3 class="card-title">見積シミュレーション</h3>
  1374.                       </div>
  1375.                       <div class="card-body p-2">
  1376.                         {% set related_image = getProduct_field(Product.id,"related_image") %}
  1377.                         {# related_image は配列: ["1段目画像あり","2段目画像あり","3段目画像あり"] のうち該当するものが格納 #}
  1378.                         {% set img1 = related_image and ("1段目画像あり" in related_image) %}
  1379.                         {% set img2 = related_image and ("2段目画像あり" in related_image) %}
  1380.                         {% set img3 = related_image and ("3段目画像あり" in related_image) %}
  1381.                         {% set img4 = related_image and ("4段目画像あり" in related_image) %}
  1382.                         {% set type1 = getProduct_field(Product.id,"related_name1") %}
  1383.                         {% set type2 = getProduct_field(Product.id,"related_name2") %}
  1384.                         {% set type3 = getProduct_field(Product.id,"related_name3") %}
  1385.                         {% set type4 = getProduct_field(Product.id,"related_name4") %}
  1386.                         {% set hasRelated = (type1 and related_product1 and related_product1|length)
  1387.                                          or (type2 and related_product2 and related_product2|length)
  1388.                                          or (type3 and related_product3 and related_product3|length)
  1389.                                          or (type4 and related_product4 and related_product4|length) %}
  1390.                         {% if hasRelated %}
  1391.                             <div class="row" style="border-bottom:1px solid rgba(0,0,0,.125)"><label class="col-12 col-form-label">この商品のタイプを選択してください。</label></div>
  1392.                         {% endif %}
  1393.                         {# ===== 1段目 ===== #}
  1394.                         {% if type1 and related_product1 and related_product1|length %}
  1395.                         <div class="form-group mt-3 pb-3" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1396.                           <div class="rp-section-label">{{ type1 }}{% if img1 and base_select1 %}: <span>{{ base_select1 }}</span>{% endif %}</div>
  1397.                           {% if img1 %}
  1398.                             {# --- 画像付きカード --- #}
  1399.                             <div class="rp-card-group">
  1400.                               {% for rp_id, rp_name in related_product1 %}
  1401.                                 <label class="rp-card{% if base_select1 == rp_name %} is-selected{% endif %}"
  1402.                                        onclick="location.href='/products/detail/{{ rp_id }}';">
  1403.                                   <input type="radio" name="rp1" value="{{ rp_name }}"
  1404.                                          {% if base_select1 == rp_name %}checked{% endif %}>
  1405.                                   <img class="rp-card__image"
  1406.                                        src="{{ asset('p' ~ rp_id ~ '_cp_1.jpg', 'save_image') }}"
  1407.                                        alt="{{ rp_name }}"
  1408.                                        onerror="this.style.display='none';this.nextElementSibling.style.display='flex';">
  1409.                                   <div class="rp-card__placeholder" style="display:none;">📦</div>
  1410.                                   <span class="rp-card__name">{{ rp_name }}</span>
  1411.                                 </label>
  1412.                               {% endfor %}
  1413.                             </div>
  1414.                           {% else %}
  1415.                             {# --- ボタン式ラジオ --- #}
  1416.                             <div class="rp-btn-group">
  1417.                               {% for rp_id, rp_name in related_product1 %}
  1418.                                 <label class="rp-btn{% if base_select1 == rp_name %} is-selected{% endif %}"
  1419.                                        onclick="location.href='/products/detail/{{ rp_id }}';">
  1420.                                   <input type="radio" name="rp1" value="{{ rp_name }}"
  1421.                                          {% if base_select1 == rp_name %}checked{% endif %}>
  1422.                                   {{ rp_name }}
  1423.                                 </label>
  1424.                               {% endfor %}
  1425.                             </div>
  1426.                           {% endif %}
  1427.                         </div>
  1428.                         {% endif %}
  1429.                         {# ===== 2段目 ===== #}
  1430.                         {% if type2 and related_product2 and related_product2|length %}
  1431.                         <div class="form-group mt-3 pb-3" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1432.                           <div class="rp-section-label">{{ type2 }}{% if img2 and base_select2 %}: <span>{{ base_select2 }}</span>{% endif %}</div>
  1433.                           {% if img2 %}
  1434.                             <div class="rp-card-group">
  1435.                               {% for rp_id, rp_name in related_product2 %}
  1436.                                 <label class="rp-card{% if base_select2 == rp_name %} is-selected{% endif %}"
  1437.                                        onclick="location.href='/products/detail/{{ rp_id }}';">
  1438.                                   <input type="radio" name="rp2" value="{{ rp_name }}"
  1439.                                          {% if base_select2 == rp_name %}checked{% endif %}>
  1440.                                   <img class="rp-card__image"
  1441.                                        src="{{ asset('p' ~ rp_id ~ '_cp_1.jpg', 'save_image') }}"
  1442.                                        alt="{{ rp_name }}"
  1443.                                        onerror="this.style.display='none';this.nextElementSibling.style.display='flex';">
  1444.                                   <div class="rp-card__placeholder" style="display:none;">📦</div>
  1445.                                   <span class="rp-card__name">{{ rp_name }}</span>
  1446.                                 </label>
  1447.                               {% endfor %}
  1448.                             </div>
  1449.                           {% else %}
  1450.                             <div class="rp-btn-group">
  1451.                               {% for rp_id, rp_name in related_product2 %}
  1452.                                 <label class="rp-btn{% if base_select2 == rp_name %} is-selected{% endif %}"
  1453.                                        onclick="location.href='/products/detail/{{ rp_id }}';">
  1454.                                   <input type="radio" name="rp2" value="{{ rp_name }}"
  1455.                                          {% if base_select2 == rp_name %}checked{% endif %}>
  1456.                                   {{ rp_name }}
  1457.                                 </label>
  1458.                               {% endfor %}
  1459.                             </div>
  1460.                           {% endif %}
  1461.                         </div>
  1462.                         {% endif %}
  1463.                         {# ===== 3段目 ===== #}
  1464.                         {% if type3 and related_product3 and related_product3|length %}
  1465.                         <div class="form-group mt-3 pb-3" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1466.                           <div class="rp-section-label">{{ type3 }}{% if img3 and base_select3 %}: <span>{{ base_select3 }}</span>{% endif %}</div>
  1467.                           {% if img3 %}
  1468.                             <div class="rp-card-group">
  1469.                               {% for rp_id, rp_name in related_product3 %}
  1470.                                 <label class="rp-card{% if base_select3 == rp_name %} is-selected{% endif %}"
  1471.                                        onclick="location.href='/products/detail/{{ rp_id }}';">
  1472.                                   <input type="radio" name="rp3" value="{{ rp_name }}"
  1473.                                          {% if base_select3 == rp_name %}checked{% endif %}>
  1474.                                   <img class="rp-card__image"
  1475.                                        src="{{ asset('p' ~ rp_id ~ '_cp_1.jpg', 'save_image') }}"
  1476.                                        alt="{{ rp_name }}"
  1477.                                        onerror="this.style.display='none';this.nextElementSibling.style.display='flex';">
  1478.                                   <div class="rp-card__placeholder" style="display:none;">📦</div>
  1479.                                   <span class="rp-card__name">{{ rp_name }}</span>
  1480.                                 </label>
  1481.                               {% endfor %}
  1482.                             </div>
  1483.                           {% else %}
  1484.                             <div class="rp-btn-group">
  1485.                               {% for rp_id, rp_name in related_product3 %}
  1486.                                 <label class="rp-btn{% if base_select3 == rp_name %} is-selected{% endif %}"
  1487.                                        onclick="location.href='/products/detail/{{ rp_id }}';">
  1488.                                   <input type="radio" name="rp3" value="{{ rp_name }}"
  1489.                                          {% if base_select3 == rp_name %}checked{% endif %}>
  1490.                                   {{ rp_name }}
  1491.                                 </label>
  1492.                               {% endfor %}
  1493.                             </div>
  1494.                           {% endif %}
  1495.                         </div>
  1496.                         {% endif %}
  1497.                         {# ===== 4段目 ===== #}
  1498.                         {% if type4 and related_product4 and related_product4|length %}
  1499.                         <div class="form-group mt-3 pb-3" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1500.                           <div class="rp-section-label">{{ type4 }}{% if img4 and base_select4 %}: <span>{{ base_select4 }}</span>{% endif %}</div>
  1501.                           {% if img4 %}
  1502.                             {# --- 画像付きカード --- #}
  1503.                             <div class="rp-card-group">
  1504.                               {% for rp_id, rp_name in related_product4 %}
  1505.                                 <label class="rp-card{% if base_select4 == rp_name %} is-selected{% endif %}"
  1506.                                        onclick="location.href='/products/detail/{{ rp_id }}';">
  1507.                                   <input type="radio" name="rp4" value="{{ rp_name }}"
  1508.                                          {% if base_select4 == rp_name %}checked{% endif %}>
  1509.                                   <img class="rp-card__image"
  1510.                                        src="{{ asset('p' ~ rp_id ~ '_cp_1.jpg', 'save_image') }}"
  1511.                                        alt="{{ rp_name }}" loading="lazy">
  1512.                                   <span class="rp-card__label">{{ rp_name }}</span>
  1513.                                 </label>
  1514.                               {% endfor %}
  1515.                             </div>
  1516.                           {% else %}
  1517.                             {# --- ボタン式ラジオ --- #}
  1518.                             <div class="rp-btn-group">
  1519.                               {% for rp_id, rp_name in related_product4 %}
  1520.                                 <label class="rp-btn{% if base_select4 == rp_name %} is-selected{% endif %}"
  1521.                                        onclick="location.href='/products/detail/{{ rp_id }}';">
  1522.                                   <input type="radio" name="rp4" value="{{ rp_name }}"
  1523.                                          {% if base_select4 == rp_name %}checked{% endif %}>
  1524.                                   {{ rp_name }}
  1525.                                 </label>
  1526.                               {% endfor %}
  1527.                             </div>
  1528.                           {% endif %}
  1529.                         </div>
  1530.                         {% endif %}
  1531.                         <div class="row" style="border-bottom:1px solid rgba(0,0,0,.125)"><label class="col-12 col-form-label">この商品のオプションを選択してください。</label></div>
  1532.                         {% if color and color|length and ProductClass.SaleType.id != 3 %}
  1533.                         <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1534.                           <div class="rp-section-label">カラー{% if mitsumori_json and mitsumori_json.pc %}: <span>{{ mitsumori_json.pc }}</span>{% endif %}</div>
  1535.                           <div class="opt-btn-group">
  1536.                             {% set idx = 0 %}
  1537.                             {% for cc in color %}{% if cc and cc['name'] %}{% set idx = idx + 1 %}
  1538.                               <label class="opt-btn{% if (mitsumori_json and mitsumori_json.pc == cc['name']) or color|length == 1 %} is-selected{% endif %}"
  1539.                                      onclick="mitsumori_simulation_val('pc', '{{ cc['name']|e('js') }}');">
  1540.                                 <input type="radio" name="color" id="cc_{{ idx }}" value="{{ cc['name'] }}"
  1541.                                        {% if (mitsumori_json and mitsumori_json.pc == cc['name']) or color|length == 1 %}checked{% endif %}>
  1542.                                 {{ cc['name'] }}
  1543.                               </label>
  1544.                             {% endif %}{% endfor %}
  1545.                           </div>
  1546.                         </div>
  1547.                         {% endif %}
  1548.                         {% if p_w and p_w|length and p_w|join != "" %}
  1549.                         <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1550.                           <div class="rp-section-label">幅{% if mitsumori_json and mitsumori_json.pw %}: <span>{{ mitsumori_json.pw }}</span>{% endif %}</div>
  1551.                           <div class="opt-btn-group">
  1552.                             {% set idx = 0 %}
  1553.                             {% for pw in p_w %}{% if pw %}{% set idx = idx + 1 %}
  1554.                               <label class="opt-btn{% if (mitsumori_json and mitsumori_json.pw == pw) or p_w|length == 1 %} is-selected{% endif %}"
  1555.                                      onclick="mitsumori_simulation_val('pw', '{{ pw|e('js') }}');">
  1556.                                 <input type="radio" name="pw" id="pw_{{ idx }}" value="{{ pw }}"
  1557.                                        {% if (mitsumori_json and mitsumori_json.pw == pw) or p_w|length == 1 %}checked{% endif %}>
  1558.                                 {{ pw }}
  1559.                               </label>
  1560.                             {% endif %}{% endfor %}
  1561.                           </div>
  1562.                         </div>
  1563.                         {% endif %}
  1564.                         {% if p_d and p_d|length and p_d|join != "" %}
  1565.                         <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1566.                           <div class="rp-section-label">奥行き{% if mitsumori_json and mitsumori_json.pd %}: <span>{{ mitsumori_json.pd }}</span>{% endif %}</div>
  1567.                           <div class="opt-btn-group">
  1568.                             {% set idx = 0 %}
  1569.                             {% for pd in p_d %}{% if pd %}{% set idx = idx + 1 %}
  1570.                               <label class="opt-btn{% if (mitsumori_json and mitsumori_json.pd == pd) or p_d|length == 1 %} is-selected{% endif %}"
  1571.                                      onclick="mitsumori_simulation_val('pd', '{{ pd|e('js') }}');">
  1572.                                 <input type="radio" name="pd" id="pd_{{ idx }}" value="{{ pd }}"
  1573.                                        {% if (mitsumori_json and mitsumori_json.pd == pd) or p_d|length == 1 %}checked{% endif %}>
  1574.                                 {{ pd }}
  1575.                               </label>
  1576.                             {% endif %}{% endfor %}
  1577.                           </div>
  1578.                         </div>
  1579.                         {% endif %}
  1580.                         {% if p_h and p_h|length and p_h|join != "" %}
  1581.                         <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1582.                           <div class="rp-section-label">高さ{% if mitsumori_json and mitsumori_json.ph %}: <span>{{ mitsumori_json.ph }}</span>{% endif %}</div>
  1583.                           <div class="opt-btn-group">
  1584.                             {% set idx = 0 %}
  1585.                             {% for ph in p_h %}{% if ph %}{% set idx = idx + 1 %}
  1586.                               <label class="opt-btn{% if (mitsumori_json and mitsumori_json.ph == ph) or p_h|length == 1 %} is-selected{% endif %}"
  1587.                                      onclick="mitsumori_simulation_val('ph', '{{ ph|e('js') }}');">
  1588.                                 <input type="radio" name="ph" id="ph_{{ idx }}" value="{{ ph }}"
  1589.                                        {% if (mitsumori_json and mitsumori_json.ph == ph) or p_h|length == 1 %}checked{% endif %}>
  1590.                                 {{ ph }}
  1591.                               </label>
  1592.                             {% endif %}{% endfor %}
  1593.                           </div>
  1594.                         </div>
  1595.                         {% endif %}
  1596.                         {% if p_m and p_m|length and p_m|join != "" %}
  1597.                         <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1598.                           <div class="rp-section-label">素材{% if mitsumori_json and mitsumori_json.pm %}: <span>{{ mitsumori_json.pm }}</span>{% endif %}</div>
  1599.                           <div class="opt-btn-group">
  1600.                             {% set idx = 0 %}
  1601.                             {% for pm in p_m %}{% if pm %}{% set idx = idx + 1 %}
  1602.                               <label class="opt-btn{% if (mitsumori_json and mitsumori_json.pm == pm) or p_m|length == 1 %} is-selected{% endif %}"
  1603.                                      onclick="mitsumori_simulation_val('pm', '{{ pm|e('js') }}');">
  1604.                                 <input type="radio" name="pm" id="pm_{{ idx }}" value="{{ pm }}"
  1605.                                        {% if (mitsumori_json and mitsumori_json.pm == pm) or p_m|length == 1 %}checked{% endif %}>
  1606.                                 {{ pm }}
  1607.                               </label>
  1608.                             {% endif %}{% endfor %}
  1609.                           </div>
  1610.                         </div>
  1611.                         {% endif %}
  1612.                         <!-- 1: 施工見積(通常) → 幅/奥行/高さ/素材/カラーは上部の共通ブロックで表示済み -->
  1613.                         {% if ProductClass.SaleType.id == 1 %}
  1614.                         {% endif %}
  1615.                         <!-- 2: 施工見積(補助金・窓) -->
  1616.                         {% if ProductClass.SaleType.id == 2 %}
  1617.                             {# 窓サイズ(自由入力) #}
  1618.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1619.                               <label class="col-4 col-form-label">窓サイズ</label>
  1620.                               <div class="col-4">
  1621.                                 <div class="input-group">
  1622.                                   <span class="input-group-text">窓幅</span>
  1623.                                   <input type="number" name="mado_w" id="mado_w" class="form-control" value="{{ mitsumori_json.mado_w|default('') }}" placeholder="例: 90" min="1" onchange="mitsumori_simulation('mado_w','mado_w');">
  1624.                                   <span class="input-group-text">cm</span>
  1625.                                 </div>
  1626.                               </div>
  1627.                               <div class="col-4">
  1628.                                 <div class="input-group">
  1629.                                   <span class="input-group-text">窓高さ</span>
  1630.                                   <input type="number" name="mado_h" id="mado_h" class="form-control" value="{{ mitsumori_json.mado_h|default('') }}" placeholder="例: 110" min="1" onchange="mitsumori_simulation('mado_h','mado_h');">
  1631.                                   <span class="input-group-text">cm</span>
  1632.                                 </div>
  1633.                               </div>
  1634.                             </div>
  1635.                             {# 窓タイプ(p_d データから選択肢を生成) #}
  1636.                             {% if p_d and p_d|length and p_d|join != "" %}
  1637.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1638.                               <label class="col-4 col-form-label">窓タイプ</label>
  1639.                               <div class="col-8">
  1640.                                 <div class="form-group clearfix">
  1641.                                 {% set idx = 0 %}
  1642.                                 {% for pd_val in p_d %}
  1643.                                   {% if pd_val %}
  1644.                                   {% set idx = idx + 1 %}
  1645.                                   <div class="icheck-danger d-inline">
  1646.                                     <input type="radio" name="mado_type" id="mado_type_{{ idx }}" value="{{ pd_val }}"
  1647.                                       {% if (mitsumori_json and mitsumori_json.pd == pd_val) or (p_d|length == 1) %}checked{% endif %}
  1648.                                       onclick="mitsumori_simulation('pd','mado_type_{{ idx }}');">
  1649.                                     <label for="mado_type_{{ idx }}">{{ pd_val }}</label>
  1650.                                   </div>
  1651.                                   {% endif %}
  1652.                                 {% endfor %}
  1653.                                 </div>
  1654.                               </div>
  1655.                             </div>
  1656.                             {% endif %}
  1657.                             {# ガラスタイプ(p_m データから選択肢を生成) #}
  1658.                             {% if p_m and p_m|length and p_m|join != "" %}
  1659.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1660.                               <label class="col-4 col-form-label">ガラスタイプ</label>
  1661.                               <div class="col-8">
  1662.                                 <div class="form-group clearfix">
  1663.                                 {% set idx = 0 %}
  1664.                                 {% for pm_val in p_m %}
  1665.                                   {% if pm_val %}
  1666.                                   {% set idx = idx + 1 %}
  1667.                                   <div class="icheck-danger d-inline">
  1668.                                     <input type="radio" name="glass_type" id="glass_type_{{ idx }}" value="{{ pm_val }}"
  1669.                                       {% if (mitsumori_json and mitsumori_json.pm == pm_val) or (p_m|length == 1) %}checked{% endif %}
  1670.                                       onclick="mitsumori_simulation('pm','glass_type_{{ idx }}');">
  1671.                                     <label for="glass_type_{{ idx }}">{{ pm_val }}</label>
  1672.                                   </div>
  1673.                                   {% endif %}
  1674.                                 {% endfor %}
  1675.                                 </div>
  1676.                               </div>
  1677.                             </div>
  1678.                             {% endif %}
  1679.                             {# セット数(プルダウン) → quantity に連動 #}
  1680.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1681.                               <label class="col-4 col-form-label">セット数</label>
  1682.                               <div class="col-8">
  1683.                                 <select name="set_count" id="set_count" class="form-control" onchange="madosetSelect(this.value);">
  1684.                                   {% for i in 1..20 %}
  1685.                                     <option value="{{ i }}" {% if mitsumori_json and mitsumori_json.set_count == i %}selected{% endif %}>{{ i }} セット</option>
  1686.                                   {% endfor %}
  1687.                                 </select>
  1688.                               </div>
  1689.                             </div>
  1690.                         {% endif %}
  1691.                         <!-- 3: 施工見積(物置・ゴミステーション) -->
  1692.                         {% if ProductClass.SaleType.id == 3 %}
  1693.                             {# 幅・奥行き・高さ(p_w/p_d/p_h からラジオボタン生成) #}
  1694.                             {% if p_w and p_w|length and p_w|join != "" %}
  1695.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1696.                               <label class="col-4 col-form-label">幅</label>
  1697.                               <div class="col-8">
  1698.                                 <div class="form-group clearfix">
  1699.                                 {% set idx = 0 %}
  1700.                                 {% for pw_val in p_w %}{% if pw_val %}{% set idx = idx + 1 %}
  1701.                                   <div class="icheck-danger d-inline">
  1702.                                     <input type="radio" name="pw" id="pw3_{{ idx }}" value="{{ pw_val }}"
  1703.                                       {% if (mitsumori_json and mitsumori_json.pw == pw_val) or p_w|length == 1 %}checked{% endif %}
  1704.                                       onclick="mitsumori_simulation('pw','pw3_{{ idx }}');">
  1705.                                     <label for="pw3_{{ idx }}">{{ pw_val }}</label>
  1706.                                   </div>
  1707.                                 {% endif %}{% endfor %}
  1708.                                 </div>
  1709.                               </div>
  1710.                             </div>
  1711.                             {% endif %}
  1712.                             {% if p_d and p_d|length and p_d|join != "" %}
  1713.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1714.                               <label class="col-4 col-form-label">奥行き</label>
  1715.                               <div class="col-8">
  1716.                                 <div class="form-group clearfix">
  1717.                                 {% set idx = 0 %}
  1718.                                 {% for pd_val in p_d %}{% if pd_val %}{% set idx = idx + 1 %}
  1719.                                   <div class="icheck-danger d-inline">
  1720.                                     <input type="radio" name="pd" id="pd3_{{ idx }}" value="{{ pd_val }}"
  1721.                                       {% if (mitsumori_json and mitsumori_json.pd == pd_val) or p_d|length == 1 %}checked{% endif %}
  1722.                                       onclick="mitsumori_simulation('pd','pd3_{{ idx }}');">
  1723.                                     <label for="pd3_{{ idx }}">{{ pd_val }}</label>
  1724.                                   </div>
  1725.                                 {% endif %}{% endfor %}
  1726.                                 </div>
  1727.                               </div>
  1728.                             </div>
  1729.                             {% endif %}
  1730.                             {% if p_h and p_h|length and p_h|join != "" %}
  1731.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1732.                               <label class="col-4 col-form-label">高さ</label>
  1733.                               <div class="col-8">
  1734.                                 <div class="form-group clearfix">
  1735.                                 {% set idx = 0 %}
  1736.                                 {% for ph_val in p_h %}{% if ph_val %}{% set idx = idx + 1 %}
  1737.                                   <div class="icheck-danger d-inline">
  1738.                                     <input type="radio" name="ph" id="ph3_{{ idx }}" value="{{ ph_val }}"
  1739.                                       {% if (mitsumori_json and mitsumori_json.ph == ph_val) or p_h|length == 1 %}checked{% endif %}
  1740.                                       onclick="mitsumori_simulation('ph','ph3_{{ idx }}');">
  1741.                                     <label for="ph3_{{ idx }}">{{ ph_val }}</label>
  1742.                                   </div>
  1743.                                 {% endif %}{% endfor %}
  1744.                                 </div>
  1745.                               </div>
  1746.                             </div>
  1747.                             {% endif %}
  1748.                             {# 棚タイプ(p_m データから選択肢を生成) #}
  1749.                             {% if p_m and p_m|length and p_m|join != "" %}
  1750.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1751.                               <label class="col-4 col-form-label">棚タイプ<br><small class="text-muted">(間仕切り仕様)</small></label>
  1752.                               <div class="col-8">
  1753.                                 <div class="form-group clearfix">
  1754.                                 {% set idx = 0 %}
  1755.                                 {% for pm_val in p_m %}{% if pm_val %}{% set idx = idx + 1 %}
  1756.                                   <div class="icheck-danger d-inline">
  1757.                                     <input type="radio" name="pm" id="pm3_{{ idx }}" value="{{ pm_val }}"
  1758.                                       {% if (mitsumori_json and mitsumori_json.pm == pm_val) or p_m|length == 1 %}checked{% endif %}
  1759.                                       onclick="mitsumori_simulation('pm','pm3_{{ idx }}');">
  1760.                                     <label for="pm3_{{ idx }}">{{ pm_val }}</label>
  1761.                                   </div>
  1762.                                 {% endif %}{% endfor %}
  1763.                                 </div>
  1764.                               </div>
  1765.                             </div>
  1766.                             {% endif %}
  1767.                             {# カラー(共通の color データ使用) #}
  1768.                             {% if color and color|length %}
  1769.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1770.                               <label class="col-4 col-form-label">カラー</label>
  1771.                               <div class="col-8">
  1772.                                 <div class="form-group clearfix">
  1773.                                 {% set idx = 0 %}
  1774.                                 {% for cc in color %}{% if cc and cc['name'] %}{% set idx = idx + 1 %}
  1775.                                   <div class="icheck-danger d-inline">
  1776.                                     <input type="radio" name="color3" id="cc3_{{ idx }}" value="{{ cc['name'] }}"
  1777.                                       {% if (mitsumori_json and mitsumori_json.pc == cc['name']) or color|length == 1 %}checked{% endif %}
  1778.                                       onclick="mitsumori_simulation('pc','cc3_{{ idx }}');">
  1779.                                     <label for="cc3_{{ idx }}">{{ cc['name'] }}</label>
  1780.                                   </div>
  1781.                                 {% endif %}{% endfor %}
  1782.                                 </div>
  1783.                               </div>
  1784.                             </div>
  1785.                             {% endif %}
  1786.                             {# 台数 #}
  1787.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1788.                               <label class="col-4 col-form-label">台数</label>
  1789.                               <div class="col-4">
  1790.                                 <div class="input-group mb-3">
  1791.                                   <input type="number" name="daisu" id="daisu" class="form-control" value="{{ mitsumori_json.daisu|default('1') }}" min="1" max="10" onchange="mitsumori_simulation('daisu','daisu');">
  1792.                                   <span class="input-group-text">台</span>
  1793.                                 </div>
  1794.                               </div>
  1795.                               <div class="col-4">
  1796.                                 <button type="button" class="btn btn-info" onclick="daisu(+1);">+</button>
  1797.                                 <button type="button" class="btn btn-danger" onclick="daisu(-1);">ー</button>
  1798.                               </div>
  1799.                             </div>
  1800.                         {% endif %}
  1801.                         <!-- 4: 施工見積(フェンス・組み立て式) -->
  1802.                         {% if ProductClass.SaleType.id == 4 %}
  1803.                             {# 枚数 #}
  1804.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1805.                               <label class="col-4 col-form-label">枚数</label>
  1806.                               <div class="col-4 mb-3">
  1807.                                 <div class="input-group">
  1808.                                   <input type="number" name="maisu" id="maisu" class="form-control" value="{{ mitsumori_json.maisu|default('3') }}" min="3" max="20" onchange="mitsumori_simulation('maisu','maisu');">
  1809.                                   <span class="input-group-text">枚</span>
  1810.                                 </div>
  1811.                               </div>
  1812.                               <div class="col-4">
  1813.                                 <button type="button" class="btn btn-info" onclick="maisu(+1);">+</button>
  1814.                                 <button type="button" class="btn btn-danger" onclick="maisu(-1);">ー</button>
  1815.                               </div>
  1816.                             </div>
  1817.                         {% endif %}
  1818.                         <!-- 5: 施工見積(ウッドデッキ・タイルデッキ) -->
  1819.                         {% if ProductClass.SaleType.id == 5 %}
  1820.                             {# 施工面積(㎡ 直接入力) #}
  1821.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1822.                               <label class="col-4 col-form-label">施工面積</label>
  1823.                               <div class="col-8">
  1824.                                 <div class="input-group">
  1825.                                   <input type="number" name="area" id="area"
  1826.                                     class="form-control"
  1827.                                     value="{{ mitsumori_json.area|default('') }}"
  1828.                                     placeholder="例: 7.5"
  1829.                                     min="0.1" step="0.1"
  1830.                                     onchange="mitsumori_simulation('area','area');">
  1831.                                   <span class="input-group-text">㎡</span>
  1832.                                 </div>
  1833.                                 <small class="text-muted">幅(cm) × 奥行き(cm) ÷ 10000 = ㎡</small>
  1834.                               </div>
  1835.                             </div>
  1836.                             {# ステップの有無 #}
  1837.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1838.                               <label class="col-4 col-form-label">ステップ</label>
  1839.                               <div class="col-8">
  1840.                                 <div class="form-group clearfix">
  1841.                                   <div class="icheck-danger d-inline">
  1842.                                     <input type="radio" name="deck_step" id="deck_step_yes" value="必要"
  1843.                                       {% if mitsumori_json and mitsumori_json.deck_step == '必要' %}checked{% endif %}
  1844.                                       onclick="mitsumori_simulation('op0','deck_step_yes');">
  1845.                                     <label for="deck_step_yes">必要</label>
  1846.                                   </div>
  1847.                                   <div class="icheck-danger d-inline">
  1848.                                     <input type="radio" name="deck_step" id="deck_step_no" value="不要"
  1849.                                       {% if not mitsumori_json or mitsumori_json.deck_step == '不要' or not mitsumori_json.deck_step %}checked{% endif %}
  1850.                                       onclick="mitsumori_simulation('op0','deck_step_no');">
  1851.                                     <label for="deck_step_no">不要</label>
  1852.                                   </div>
  1853.                                 </div>
  1854.                               </div>
  1855.                             </div>
  1856.                             {# ウッドデッキフェンスの有無 #}
  1857.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1858.                               <label class="col-4 col-form-label">デッキフェンス</label>
  1859.                               <div class="col-8">
  1860.                                 <div class="form-group clearfix">
  1861.                                   <div class="icheck-danger d-inline">
  1862.                                     <input type="radio" name="deck_fence" id="deck_fence_yes" value="必要"
  1863.                                       {% if mitsumori_json and mitsumori_json.deck_fence == '必要' %}checked{% endif %}
  1864.                                       onclick="mitsumori_simulation('op1','deck_fence_yes');">
  1865.                                     <label for="deck_fence_yes">必要</label>
  1866.                                   </div>
  1867.                                   <div class="icheck-danger d-inline">
  1868.                                     <input type="radio" name="deck_fence" id="deck_fence_no" value="不要"
  1869.                                       {% if not mitsumori_json or mitsumori_json.deck_fence == '不要' or not mitsumori_json.deck_fence %}checked{% endif %}
  1870.                                       onclick="mitsumori_simulation('op1','deck_fence_no');">
  1871.                                     <label for="deck_fence_no">不要</label>
  1872.                                   </div>
  1873.                                 </div>
  1874.                               </div>
  1875.                             </div>
  1876.                         {% endif %}
  1877.                         <!-- 6: 施工見積(芝生・枚数・数量買い) -->
  1878.                         {% if ProductClass.SaleType.id == 6 %}
  1879.                             {# 規格(p_m データ → 素材から抽出) #}
  1880.                             {% if p_m and p_m|length and p_m|join != "" %}
  1881.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1882.                               <label class="col-4 col-form-label">規格</label>
  1883.                               <div class="col-8">
  1884.                                 <div class="form-group clearfix">
  1885.                                 {% set idx = 0 %}
  1886.                                 {% for pm_val in p_m %}{% if pm_val %}{% set idx = idx + 1 %}
  1887.                                   <div class="icheck-danger d-inline">
  1888.                                     <input type="radio" name="pm" id="pm6_{{ idx }}" value="{{ pm_val }}"
  1889.                                       {% if (mitsumori_json and mitsumori_json.pm == pm_val) or p_m|length == 1 %}checked{% endif %}
  1890.                                       onclick="mitsumori_simulation('pm','pm6_{{ idx }}');">
  1891.                                     <label for="pm6_{{ idx }}">{{ pm_val }}</label>
  1892.                                   </div>
  1893.                                 {% endif %}{% endfor %}
  1894.                                 </div>
  1895.                               </div>
  1896.                             </div>
  1897.                             {% endif %}
  1898.                             {# 芝の長さ(p_w データ → 幅から抽出) #}
  1899.                             {% if p_w and p_w|length and p_w|join != "" %}
  1900.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1901.                               <label class="col-4 col-form-label">芝の長さ</label>
  1902.                               <div class="col-8">
  1903.                                 <div class="form-group clearfix">
  1904.                                 {% set idx = 0 %}
  1905.                                 {% for pw_val in p_w %}{% if pw_val %}{% set idx = idx + 1 %}
  1906.                                   <div class="icheck-danger d-inline">
  1907.                                     <input type="radio" name="pw" id="pw6_{{ idx }}" value="{{ pw_val }}"
  1908.                                       {% if (mitsumori_json and mitsumori_json.pw == pw_val) or p_w|length == 1 %}checked{% endif %}
  1909.                                       onclick="mitsumori_simulation('pw','pw6_{{ idx }}');">
  1910.                                     <label for="pw6_{{ idx }}">{{ pw_val }}</label>
  1911.                                   </div>
  1912.                                 {% endif %}{% endfor %}
  1913.                                 </div>
  1914.                               </div>
  1915.                             </div>
  1916.                             {% endif %}
  1917.                             {# 施工面積(㎡ 自由入力) #}
  1918.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1919.                               <label class="col-4 col-form-label">施工面積</label>
  1920.                               <div class="col-8">
  1921.                                 <div class="input-group">
  1922.                                   <input type="number" name="area" id="area"
  1923.                                     class="form-control"
  1924.                                     value="{{ mitsumori_json.area|default('') }}"
  1925.                                     placeholder="例: 10.5"
  1926.                                     min="0.1" step="0.1"
  1927.                                     onchange="mitsumori_simulation('area','area');">
  1928.                                   <span class="input-group-text">平米</span>
  1929.                                 </div>
  1930.                               </div>
  1931.                             </div>
  1932.                         {% endif %}
  1933.                         <!-- 9: 商品のみ購入 -->
  1934.                         {% if ProductClass.SaleType.id == 9 %}
  1935.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1936.                               <label class="col-4 col-form-label">数量</label>
  1937.                               <div class="col-4">
  1938.                                 <div class="input-group mb-3">
  1939.                                   <input type="number" name="quantity_only" id="quantity_only" class="form-control" value="1" min="1" onchange="$('#quantity').val(this.value);">
  1940.                                   <span class="input-group-text">個</span>
  1941.                                 </div>
  1942.                               </div>
  1943.                               <div class="col-4">
  1944.                                 <button type="button" class="btn btn-info" onclick="quantityOnly(+1);">+</button>
  1945.                                 <button type="button" class="btn btn-danger" onclick="quantityOnly(-1);">ー</button>
  1946.                               </div>
  1947.                             </div>
  1948.                         {% endif %}
  1949.                         <div class="row" style="border-bottom:1px solid rgba(0,0,0,.125)"><label class="col-12 col-form-label">取り付け工事のご希望に関してお答えください。</label></div>
  1950.                         {% for i in 0..10 %}
  1951.                             {% if op and op|length >= i+1 %}
  1952.                             {% if op[i]['name'] %}
  1953.                             <div class="form-group mt-3 pb-3" style="border-bottom:1px solid rgba(0,0,0,.125)">
  1954.                               <div class="rp-section-label">{{ op[i]['name'] }}{% if mitsumori_json and mitsumori_json.op[i] %}: <span>{{ mitsumori_json.op[i] }}</span>{% endif %}</div>
  1955.                               {% if op[i]['comment'] %}<div class="opt-comment" style="font-size:12px;color:#666;margin:4px 0 6px;">{{ op[i]['comment'] }}</div>{% endif %}
  1956.                               <div class="opt-btn-group">
  1957.                                 <label class="opt-btn{% if mitsumori_json and mitsumori_json.op[i] == op[i]['on'] %} is-selected{% endif %}"
  1958.                                        onclick="mitsumori_simulation('op{{ i }}','op{{ i }}_1');">
  1959.                                   <input type="radio" name="op{{ i }}" id="op{{ i }}_1" value="{{ op[i]['on'] }}" {% if mitsumori_json and mitsumori_json.op[i] == op[i]['on'] %}checked{% endif %}>
  1960.                                   {{ op[i]['on'] }}
  1961.                                 </label>
  1962.                                 <label class="opt-btn{% if mitsumori_json and mitsumori_json.op[i] == op[i]['off'] %} is-selected{% endif %}"
  1963.                                        onclick="mitsumori_simulation('op{{ i }}','op{{ i }}_2');">
  1964.                                   <input type="radio" name="op{{ i }}" id="op{{ i }}_2" value="{{ op[i]['off'] }}" {% if mitsumori_json and mitsumori_json.op[i] == op[i]['off'] %}checked{% endif %}>
  1965.                                   {{ op[i]['off'] }}
  1966.                                 </label>
  1967.                               </div>
  1968.                             </div>
  1969.                             {% endif %}
  1970.                             {% endif %}
  1971.                         {% endfor %}
  1972.                       </div>
  1973.                       <!-- /.card-body -->
  1974.                     </div>
  1975.                     <form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1">
  1976.                         {% if Product.stock_find %}
  1977.                             <div class="ec-productRole__actions">
  1978.                                 {% if form.classcategory_id1 is defined %}
  1979.                                     <div class="ec-select">
  1980.                                         {{ form_row(form.classcategory_id1) }}
  1981.                                         {{ form_errors(form.classcategory_id1) }}
  1982.                                     </div>
  1983.                                     {% if form.classcategory_id2 is defined %}
  1984.                                         <div class="ec-select">
  1985.                                             {{ form_row(form.classcategory_id2) }}
  1986.                                             {{ form_errors(form.classcategory_id2) }}
  1987.                                         </div>
  1988.                                     {% endif %}
  1989.                                 {% endif %}
  1990.                                 <div class="ec-numberInput">
  1991.                                     {{ form_widget(form.quantity, { type: 'hidden' }) }}
  1992.                                     {{ form_errors(form.quantity) }}
  1993.                                 </div>
  1994.                             </div>
  1995.                         {% else %}
  1996.                             <div class="ec-productRole__btn">
  1997.                                 <button type="button" class="ec-blockBtn--action" disabled="disabled">
  1998.                                     {{ 'ただいま品切れ中です。'|trans }}
  1999.                                 </button>
  2000.                             </div>
  2001.                         {% endif %}
  2002.                         <div class="ec-productRole__btn mt-3">
  2003.                            <button type="submit" id="cart_btn" class="ec-blockBtn--action add-cart">施工検討リストに入れる</button>
  2004.                         </div>
  2005.                         {{ form_rest(form) }}
  2006.                     </form>
  2007.                     <div class="ec-modal">
  2008.                         <div class="ec-modal-overlay">
  2009.                             <div class="ec-modal-wrap">
  2010.                                 <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  2011.                                 <div id="ec-modal-header" class="text-center">{{ '施工検討リストに追加しました。'|trans }}</div>
  2012.                                 <div class="ec-modal-box">
  2013.                                     <div class="ec-role">
  2014.                                         <span class="ec-inlineBtn--cancel">{{ '商品検索を続ける'|trans }}</span>
  2015.                                         <a href="{{ url('cart') }}" class="ec-inlineBtn--action">{{ '施工検討リストへ進む'|trans }}</a>
  2016.                                     </div>
  2017.                                 </div>
  2018.                             </div>
  2019.                         </div>
  2020.                     </div>
  2021.                     <div class="ec-productRole__description">{{ Product.description_detail|raw|nl2br }}
  2022.                     </div>
  2023.                     {# SNSシェア #}
  2024.                     <div class="ec-productRole__share">
  2025.                         <ul class="ec-share">
  2026.                             <li class="ec-share__item">
  2027.                                 <a href="https://twitter.com/share?url={{ app.request.uri|url_encode }}&text={{ Product.name|url_encode }}" class="ec-share__link ec-share__link--twitter" target="_blank" rel="noreferrer noopener">
  2028.                                     <i class="fab fa-twitter"></i>
  2029.                                 </a>
  2030.                             </li>
  2031.                             <li class="ec-share__item">
  2032.                                 <a href="https://www.facebook.com/sharer/sharer.php?u={{ app.request.uri|url_encode }}" class="ec-share__link ec-share__link--facebook" target="_blank" rel="noreferrer noopener">
  2033.                                     <i class="fab fa-facebook-f"></i>
  2034.                                 </a>
  2035.                             </li>
  2036.                             <li class="ec-share__item">
  2037.                                 <a href="https://social-plugins.line.me/lineit/share?url={{ app.request.uri|url_encode }}" class="ec-share__link ec-share__link--line" target="_blank" rel="noreferrer noopener">
  2038.                                     <i class="fab fa-line"></i>
  2039.                                 </a>
  2040.                             </li>
  2041.                         </ul>
  2042.                     </div>
  2043.                 </div>
  2044.                 {# ===== スマホ用 見積金額 下部固定バー ===== #}
  2045.                 <div id="sp-mitsumori-bar">
  2046.                     <div>
  2047.                         <div class="sp-bar__label">合計(工事費・税込)</div>
  2048.                         <div class="sp-bar__price" id="sp-mitsumori-price">---円</div>
  2049.                     </div>
  2050.                     <button type="button" class="sp-bar__btn"
  2051.                             onclick="document.getElementById('cart_btn2') && document.getElementById('cart_btn2').click();">
  2052.                         検討リストへ
  2053.                     </button>
  2054.                 </div>
  2055.                 <div class="card col-12 collapsed-card sticky-top float-right mitsumori-card-pc">
  2056.                     <div class="card-header">
  2057.                       <h3 class="card-title">現在のお見積り額</h3>
  2058.                       <div class="card-tools">
  2059.                         <span class="float-left" id="mitsumori_message">395000円</span>
  2060.                         <button type="button" class="btn btn-tool btn-mitsumori-toggle" data-card-widget="collapse" title="詳細を表示">
  2061.                           <span class="toggle-icon">▼ 詳細</span>
  2062.                         </button>
  2063.                       </div>
  2064.                     </div>
  2065.                     <div class="card-body p-0">
  2066.                       <ul class="nav nav-pills flex-column">
  2067.                         <li class="nav-item active">
  2068.                           <a class="nav-link">
  2069.                             <i class="far fa-file-alt"></i> 合計(工事費・税込)
  2070.                             <span class="float-right" id="mitsumori_goukei">395,000円</span>
  2071.                           </a>
  2072.                         </li>
  2073.                         <li class="nav-item active">
  2074.                           <a class="nav-link">
  2075.                             <i class="far fa-file-alt"></i> 商品価格
  2076.                             <span class="float-right" id="mitsumori_price">307,008円</span>
  2077.                           </a>
  2078.                         </li>
  2079.                         <li class="nav-item">
  2080.                           <a class="nav-link">
  2081.                             &nbsp;&nbsp;<i class="far fa-file-alt"></i> カタログ価格
  2082.                             <span class="float-right" id="maker_price">479,700円</span>
  2083.                           </a>
  2084.                         </li>
  2085.                         <li class="nav-item">
  2086.                           <a class="nav-link">
  2087.                             &nbsp;&nbsp;<i class="far fa-file-alt"></i> お値引き
  2088.                             <span class="float-right" id="mitsumori_off">-172,692円</span>
  2089.                           </a>
  2090.                         </li>
  2091.                         <li class="nav-item">
  2092.                           <a class="nav-link">
  2093.                             <i class="far fa-file-alt"></i> 基本工事費
  2094.                             <span class="float-right" id="mitsumori_ct">53,250円</span>
  2095.                           </a>
  2096.                         </li>
  2097.                         <li class="nav-item">
  2098.                           <a class="nav-link">
  2099.                             <i class="far fa-file-alt"></i> 施工オプション
  2100.                             <span class="float-right"id="mitsumori_option">6,297円</span>
  2101.                           </a>
  2102.                         </li>
  2103.                       </ul>
  2104.                     </div>
  2105.                     <div class="card-footer">
  2106.                         <button type="button" id="mitsumori_btn" class="btn btn-info" data-toggle="modal" data-target="#modal-mitsumori">
  2107.                           見積書表示
  2108.                         </button>
  2109.                         <button type="submit" id="cart_btn2" class="btn btn-info add-cart">施工検討リストに入れる</button>
  2110.                     </div>
  2111.                 </div>
  2112.             </div>
  2113.         </div>
  2114.     </div>
  2115.   <div class="modal" id="modal-mitsumori">
  2116.     <div class="modal-dialog modal-mitsumori" style="max-width:1000px">
  2117.       <div class="modal-content">
  2118.         <div class="modal-header">
  2119.           <h4 class="modal-title">お見積書</h4>
  2120.           <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  2121.             <span aria-hidden="true">&times;</span>
  2122.           </button>
  2123.         </div>
  2124.         <div class="modal-body">
  2125.             <div class="invoice p-3 mb-5" style="max-width:1000px; margin:auto;">
  2126.               <!-- title row -->
  2127.               <div class="row">
  2128.                 <div class="col-12">
  2129.                   <h2>概算お見積書 
  2130.                     <small class="float-right" style="font-size:14px;">発行日: 2025/03/14</small>
  2131.                   </h2>
  2132.                 </div>
  2133.                 <!-- /.col -->
  2134.               </div>
  2135.               <!-- info row -->
  2136.               <div class="row invoice-info">
  2137.                 <div class="col-sm-8 invoice-col">
  2138.                   <h3>お客様</h3>
  2139.                   <span>下記の通り、お見積もり申し上げます。</span>
  2140.                   <br />
  2141.                   <br / >
  2142.                   <br />
  2143.                   <h2>お見積金額: <span id="mitsumori_kei">399,080円</span></h2>
  2144.                   <span>
  2145.                     <br/>
  2146.                     <br/>
  2147.                     <br/>
  2148.                     <br/>
  2149.                   </span>
  2150.                 </div>
  2151.                 <div class="col-sm-4 invoice-col">
  2152.                   <p>
  2153.                     <img alt="" src="/html/user_data/js/images/logo.png" style="width: 260px; max-width: 100%; max-height: 10mm;">
  2154.                   </p>
  2155.                   <p>有限会社プラス</p>
  2156.                   <p>〒400-0334</p>
  2157.                   <p>山梨県南アルプス市藤田1450番地2</p>
  2158.                   <p>TEL: 055-284-6480</p>
  2159.                   <img alt="" src="/html/user_data/js/images/seal.svg" style="z-index: 2; position: absolute; width: 21mm; left: 58mm; top: 36mm;">
  2160.                 </div>
  2161.                 <!-- /.col -->
  2162.                 <!-- /.col -->
  2163.               </div>
  2164.               <!-- /.row -->
  2165.               <!-- Table row -->
  2166.               <div class="row">
  2167.                 <div class="col-12 table-responsive">
  2168.                   <table class="table table-striped">
  2169.                     <thead>
  2170.                       <tr>
  2171.                         <th>項目</th>
  2172.                         <th>数量</th>
  2173.                         <th>単位</th>
  2174.                         <th>単価</th>
  2175.                         <th>小計</th>
  2176.                       </tr>
  2177.                     </thead>
  2178.                     <tbody>
  2179.                       <tr>
  2180.                         <td>プレーンルーフ 600タイプ 1台用 単体セット</td>
  2181.                         <td>1</td>
  2182.                         <td>式</td>
  2183.                         <td id="mitsumori_price_01">352,800</td>
  2184.                         <td id="mitsumori_price_02">352,800</td>
  2185.                       </tr>
  2186.                       <tr>
  2187.                         <td>基本工事費</td>
  2188.                         <td>1</td>
  2189.                         <td>式</td>
  2190.                         <td id="mitsumori_ct_01">10,000</td>
  2191.                         <td id="mitsumori_ct_02">10,000</td>
  2192.                       </tr>
  2193.                       <tr>
  2194.                         <td>残土・ガラ処理</td>
  2195.                         <td>1</td>
  2196.                         <td>式</td>
  2197.                         <td>0円</td>
  2198.                         <td></td>
  2199.                       </tr>
  2200.                       <tr>
  2201.                         <td> </td>
  2202.                         <td></td>
  2203.                         <td></td>
  2204.                         <td></td>
  2205.                         <td></td>
  2206.                       </tr>
  2207.                     </tbody>
  2208.                   </table>
  2209.                 </div>
  2210.                 <!-- /.col -->
  2211.               </div>
  2212.               <!-- /.row -->
  2213.               <div class="row">
  2214.                 <!-- accepted payments column -->
  2215.                 <div class="col-6">
  2216.                   <p class="lead">お支払い方法</p>
  2217.                   <p class="text-muted well well-sm shadow-none" style="margin-top: 10px;">銀行振込、クレジットカード決済、PAYPAY決済
  2218.                     <br>銀行振込:山梨中央銀行 白根支店 普通口座 391402
  2219.                     <br>※商品代金と工事代金の総額が金100万円(税込)を超える場合、着手金として代金の半額をご契約後お支払いいただきます。 
  2220.                   </p>
  2221.                 </div>
  2222.                 <!-- /.col -->
  2223.                 <div class="col-6">
  2224.                   <div class="table-responsive">
  2225.                     <table class="table">
  2226.                       <tbody>
  2227.                         <tr>
  2228.                           <th style="width:50%">小計:</th>
  2229.                           <td id="mitsumori_shoukei">362,800</td>
  2230.                         </tr>
  2231.                         <tr>
  2232.                           <th>消費税 (10%)</th>
  2233.                           <td id="mitsumori_tax">36,280</td>
  2234.                         </tr>
  2235.                         <tr>
  2236.                           <th>合計:</th>
  2237.                           <td id="mitsumori_goukei_02">399,080</td>
  2238.                         </tr>
  2239.                       </tbody>
  2240.                     </table>
  2241.                   </div>
  2242.                 </div>
  2243.                 <!-- /.col -->
  2244.               </div>
  2245.               <!-- /.row -->
  2246.             </div>
  2247.         </div>
  2248.         <div class="modal-footer justify-content-between">
  2249.                   {# PDF出力: mitsumori_json を POST して PDF ダウンロード #}
  2250.                   <form method="post" action="{{ url('mitsumori_pdf') }}" target="_blank" id="pdf_download_form">
  2251.                     <input type="hidden" name="_token" value="{{ csrf_token('mitsumori_pdf') }}">
  2252.                     <input type="hidden" name="mitsumori_json" id="pdf_mitsumori_json">
  2253.                     <button type="submit" class="btn btn-primary float-right" style="margin-right: 5px;" onclick="syncPdfJson();">
  2254.                       <i class="fas fa-download"></i>PDF出力
  2255.                     </button>
  2256.                   </form>
  2257.                   <button type="submit" id="cart_btn3" class="btn btn-info add-cart">施工検討リストに入れる</button>
  2258.         </div>
  2259.       </div>
  2260.       <!-- /.modal-content -->
  2261.     </div>
  2262.     <!-- /.modal-dialog -->
  2263.   </div>
  2264.   <!-- /.modal -->
  2265. {% endblock %}