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

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.         /* Show zoom cursor on product images to hint click-to-expand */
  81.         .item_visual .slide-item a { display: block; cursor: zoom-in; }
  82.     </style>
  83.     <style>
  84.         /* ============================================
  85.            商品詳細グリッド: 画像50% / 内容50%(均等)
  86.         ============================================ */
  87.         @media (min-width: 768px) {
  88.             body.product_page .ec-grid2 {
  89.                 display: flex;
  90.                 align-items: flex-start;
  91.             }
  92.             body.product_page .ec-grid2 .ec-grid2__cell {
  93.                 width: 50%;
  94.                 flex: 0 0 50%;
  95.                 min-width: 0;
  96.             }
  97.             body.product_page .ec-grid2 .ec-grid2__cell2 {
  98.                 width: 50%;
  99.                 flex: 0 0 50%;
  100.                 min-width: 0;
  101.             }
  102.         }
  103.         /* ============================================
  104.            商品説明欄内のHTMLが画面幅を突き抜けないように
  105.         ============================================ */
  106.         body.product_page .ec-productRole__description {
  107.             min-width: 0;
  108.             overflow-wrap: break-word;
  109.             word-break: break-word;
  110.         }
  111.         body.product_page .ec-productRole__description img,
  112.         body.product_page .ec-productRole__description table,
  113.         body.product_page .ec-productRole__description iframe,
  114.         body.product_page .ec-productRole__description video {
  115.             max-width: 100% !important;
  116.             height: auto;
  117.         }
  118.         body.product_page .ec-productRole__description table {
  119.             display: block;
  120.             overflow-x: auto;
  121.             -webkit-overflow-scrolling: touch;
  122.         }
  123.         /* ============================================
  124.            スマホ用 見積金額 下部固定バー
  125.         ============================================ */
  126.         #sp-mitsumori-bar {
  127.             display: none;
  128.         }
  129.         
  130.         /* ============================================
  131.            商品タイプ選択 共通スタイル
  132.         ============================================ */
  133.         /* セクションラベル */
  134.         .rp-section-label {
  135.             font-size: 14px;
  136.             font-weight: bold;
  137.             color: #333;
  138.             margin-bottom: 10px;
  139.         }
  140.         .rp-section-label span {
  141.             font-weight: normal;
  142.             color: #c00;
  143.         }
  144.         /* ---- 1. 画像付きカード ---- */
  145.         .rp-card-group {
  146.             display: flex;
  147.             flex-wrap: wrap;
  148.             gap: 8px;
  149.             margin-bottom: 4px;
  150.         }
  151.         .rp-card {
  152.             position: relative;
  153.             cursor: pointer;
  154.             width: 110px;
  155.             border: 2px solid #ddd;
  156.             border-radius: 10px;
  157.             overflow: hidden;
  158.             transition: border-color 0.2s, box-shadow 0.2s;
  159.             background: #fff;
  160.         }
  161.         /* Gate :hover behind real hover-capable pointers. On iOS Safari a
  162.            :hover rule that changes appearance makes the first tap apply the
  163.            hover state and suppresses the click, so the option chip needed a
  164.            second tap to fire its onclick (is-selected + price update). */
  165.         @media (hover: hover) and (pointer: fine) {
  166.             .rp-card:hover {
  167.                 border-color: #999;
  168.                 box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  169.             }
  170.         }
  171.         .rp-card.is-selected {
  172.             border-color: #1a6fcf;
  173.             box-shadow: 0 2px 10px rgba(26,111,207,0.25);
  174.         }
  175.         .rp-card input[type="radio"] { display: none; }
  176.         .rp-card__image {
  177.             width: 100%;
  178.             aspect-ratio: 1 / 1;
  179.             object-fit: cover;
  180.             display: block;
  181.             background: #f5f5f5;
  182.         }
  183.         .rp-card__placeholder {
  184.             width: 100%;
  185.             aspect-ratio: 1 / 1;
  186.             background: #f0f0f0;
  187.             display: flex;
  188.             align-items: center;
  189.             justify-content: center;
  190.             color: #bbb;
  191.             font-size: 24px;
  192.         }
  193.         .rp-card__name {
  194.             display: block;
  195.             padding: 5px 5px;
  196.             font-size: 11px;
  197.             color: #333;
  198.             text-align: center;
  199.             line-height: 1.4;
  200.             word-break: break-all;
  201.         }
  202.         .rp-card.is-selected .rp-card__name { color: #1a6fcf; font-weight: bold; }
  203.         .rp-card.is-selected::after {
  204.             content: "✓";
  205.             position: absolute;
  206.             top: 3px; right: 6px;
  207.             color: #1a6fcf;
  208.             font-size: 13px;
  209.             font-weight: bold;
  210.         }
  211.         /* ---- 2. ボタン式ラジオ(画像なし・8個以内)---- */
  212.         .rp-btn-group {
  213.             display: flex;
  214.             flex-wrap: wrap;
  215.             gap: 8px;
  216.             margin-bottom: 4px;
  217.             max-width: 100%;
  218.             min-width: 0;
  219.         }
  220.         .rp-btn {
  221.             cursor: pointer;
  222.             padding: 8px 14px;
  223.             border: 2px solid #ddd;
  224.             border-radius: 10px;
  225.             font-size: 13px;
  226.             color: #333;
  227.             background: #fff;
  228.             transition: border-color 0.2s, background 0.2s;
  229.             white-space: nowrap;
  230.             max-width: 100%;
  231.             overflow: hidden;
  232.             text-overflow: ellipsis;
  233.         }
  234.         @media (hover: hover) and (pointer: fine) {
  235.             .rp-btn:hover { border-color: #999; }
  236.         }
  237.         .rp-btn.is-selected {
  238.             border-color: #1a6fcf;
  239.             color: #1a6fcf;
  240.             font-weight: bold;
  241.             background: #f0f6ff;
  242.         }
  243.         .rp-btn input[type="radio"] { display: none; }
  244.         /* ---- ボタン群が3行以上になる場合は1行横スクロール ---- */
  245.         .rp-btn-group.is-scroll,
  246.         .opt-btn-group.is-scroll {
  247.             flex-wrap: nowrap;
  248.             overflow-x: auto;
  249.             overflow-y: hidden;
  250.             -webkit-overflow-scrolling: touch;
  251.             scrollbar-width: thin;
  252.             padding-bottom: 6px;
  253.         }
  254.         .rp-btn-group.is-scroll::-webkit-scrollbar,
  255.         .opt-btn-group.is-scroll::-webkit-scrollbar {
  256.             height: 6px;
  257.         }
  258.         .rp-btn-group.is-scroll::-webkit-scrollbar-thumb,
  259.         .opt-btn-group.is-scroll::-webkit-scrollbar-thumb {
  260.             background: #c0c0c0;
  261.             border-radius: 3px;
  262.         }
  263.         .rp-btn-group.is-scroll > .rp-btn,
  264.         .opt-btn-group.is-scroll > .opt-btn {
  265.             flex: 0 0 auto;
  266.         }
  267.         /* ---- 3. プルダウン(画像なし・9個以上)---- */
  268.         .rp-select-wrap {
  269.             margin-bottom: 4px;
  270.         }
  271.         .rp-select {
  272.             width: 100%;
  273.             max-width: 420px;
  274.             padding: 8px 12px;
  275.             border: 2px solid #ddd;
  276.             border-radius: 10px;
  277.             font-size: 13px;
  278.             color: #333;
  279.             background: #fff;
  280.             appearance: none;
  281.             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");
  282.             background-repeat: no-repeat;
  283.             background-position: right 12px center;
  284.             cursor: pointer;
  285.         }
  286.         .rp-select:focus {
  287.             outline: none;
  288.             border-color: #1a6fcf;
  289.         }
  290.         /* ---- オプション選択ボタン(枠線ラジオ)---- */
  291.         .opt-btn-group {
  292.             display: flex;
  293.             flex-wrap: wrap;
  294.             gap: 8px;
  295.             padding: 6px 0;
  296.             max-width: 100%;
  297.             min-width: 0;
  298.         }
  299.         .opt-btn {
  300.             cursor: pointer;
  301.             padding: 7px 14px;
  302.             border: 2px solid #ddd;
  303.             border-radius: 10px;
  304.             font-size: 13px;
  305.             color: #333;
  306.             background: #fff;
  307.             transition: border-color 0.2s, background 0.2s;
  308.             white-space: nowrap;
  309.             max-width: 100%;
  310.             overflow: hidden;
  311.             text-overflow: ellipsis;
  312.         }
  313.         @media (hover: hover) and (pointer: fine) {
  314.             .opt-btn:hover { border-color: #999; }
  315.         }
  316.         .opt-btn.is-selected {
  317.             border-color: #1a6fcf;
  318.             color: #1a6fcf;
  319.             font-weight: bold;
  320.             background: #f0f6ff;
  321.         }
  322.         .opt-btn input[type="radio"] { display: none; }
  323.         /* opt-btn with color swatch image. The label still works as a
  324.            radio target — clicking the image checks the input. The text
  325.            label stays under the image so users can still read the name. */
  326.         .opt-btn--with-image {
  327.             padding: 4px 6px 6px;
  328.             white-space: normal;
  329.             text-align: center;
  330.             display: inline-flex;
  331.             flex-direction: column;
  332.             align-items: center;
  333.             min-width: 96px;
  334.             max-width: 140px;
  335.         }
  336.         .opt-btn--with-image .opt-btn__img {
  337.             display: block;
  338.             width: 88px;
  339.             height: 66px;
  340.             object-fit: cover;
  341.             border-radius: 6px;
  342.             margin-bottom: 4px;
  343.             background: #f5f5f5;
  344.         }
  345.         .opt-btn--with-image .opt-btn__name {
  346.             display: block;
  347.             font-size: 11px;
  348.             line-height: 1.3;
  349.             color: inherit;
  350.         }
  351.         .opt-btn--with-image.is-selected .opt-btn__img {
  352.             outline: 2px solid #1a6fcf;
  353.             outline-offset: 1px;
  354.         }
  355.         /* ============================================
  356.            施工エリア案内
  357.         ============================================ */
  358.         .ec-areaNotice {
  359.             margin: 16px 0;
  360.             padding: 16px 20px;
  361.             background: #f8f9fa;
  362.             border-left: 4px solid #1a6fcf;
  363.             border-radius: 0 8px 8px 0;
  364.         }
  365.         .ec-areaNotice__inner {
  366.             display: flex;
  367.             align-items: flex-start;
  368.             gap: 12px;
  369.         }
  370.         .ec-areaNotice__icon {
  371.             font-size: 22px;
  372.             line-height: 1;
  373.             flex-shrink: 0;
  374.             margin-top: 2px;
  375.         }
  376.         .ec-areaNotice__body {
  377.             flex: 1;
  378.         }
  379.         .ec-areaNotice__title {
  380.             font-size: 13px;
  381.             font-weight: bold;
  382.             color: #1a6fcf;
  383.             margin: 0 0 6px;
  384.         }
  385.         .ec-areaNotice__text {
  386.             font-size: 13px;
  387.             color: #444;
  388.             line-height: 1.7;
  389.             margin: 0;
  390.         }
  391.         .ec-areaNotice__text strong {
  392.             color: #222;
  393.         }
  394.         .ec-areaNotice__link {
  395.             display: inline-block;
  396.             margin-top: 8px;
  397.             font-size: 12px;
  398.             color: #1a6fcf;
  399.             text-decoration: underline;
  400.         }
  401.         .ec-areaNotice__link:hover {
  402.             color: #0d4fa0;
  403.         }
  404.         /* ============================================
  405.            SNSシェア + ブランド名 タイトル行
  406.         ============================================ */
  407.         .ec-productRole__titleRow {
  408.             display: flex;
  409.             align-items: center;
  410.             justify-content: space-between;
  411.             gap: 8px;
  412.             margin-bottom: 4px;
  413.         }
  414.         .ec-productRole__titleRow .ec-headingTitle {
  415.             margin: 0;
  416.             flex: 1;
  417.             font-size: 18px;
  418.         }
  419.         .ec-share-inline {
  420.             display: flex;
  421.             align-items: center;
  422.             gap: 8px;
  423.             flex-shrink: 0;
  424.         }
  425.         @media (max-width: 767px) {
  426.             /* maker_area の float を解除して独立表示 */
  427.             #maker_area {
  428.                 float: none !important;
  429.                 width: auto !important;
  430.                 height: auto !important;
  431.                 display: block;
  432.                 margin-bottom: 4px;
  433.             }
  434.             /* タイトル行: 商品名が全幅を占有しSNSは右寄せ下段 */
  435.             .ec-productRole__titleRow {
  436.                 flex-wrap: wrap;
  437.                 clear: both;
  438.             }
  439.             .ec-productRole__titleRow .ec-headingTitle {
  440.                 flex: 1 1 100%;
  441.                 font-size: 16px;
  442.             }
  443.             .ec-share-inline {
  444.                 flex: 0 0 auto;
  445.                 margin-left: auto;
  446.             }
  447.         }
  448.         .ec-share-inline a {
  449.             display: flex;
  450.             align-items: center;
  451.             justify-content: center;
  452.             width: 32px;
  453.             height: 32px;
  454.             border-radius: 50%;
  455.             font-size: 15px;
  456.             color: #fff;
  457.             text-decoration: none;
  458.             transition: opacity 0.2s;
  459.         }
  460.         .ec-share-inline a:hover { opacity: 0.8; }
  461.         .ec-share-inline .share-twitter  { background: #000; }
  462.         .ec-share-inline .share-facebook { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
  463.         .ec-share-inline .share-line     { background: #06c755; }
  464.         /* description_detail下のシェアブロックはPC/スマホ共通で非表示(タイトル行に移動) */
  465.         .ec-productRole__share { display: none; }
  466.         /* ============================================
  467.            PC用: 現在のお見積り額カード強調
  468.         ============================================ */
  469.         @media (min-width: 768px) {
  470.             .mitsumori-card-pc {
  471.                 border: 2px solid #1a6fcf !important;
  472.                 border-radius: 10px !important;
  473.                 box-shadow: 0 4px 16px rgba(26,111,207,0.18) !important;
  474.                 margin-top: 20px;
  475.                 overflow: hidden;
  476.                 background: linear-gradient(135deg, #1a6fcf, #0d4fa0) !important;
  477.             }
  478.             .mitsumori-card-pc .card-header {
  479.                 background: linear-gradient(135deg, #1a6fcf, #0d4fa0) !important;
  480.                 color: #fff !important;
  481.                 padding: 14px 16px !important;
  482.                 border-bottom: none !important;
  483.             }
  484.             .mitsumori-card-pc .card-title {
  485.                 color: #fff !important;
  486.                 font-size: 15px !important;
  487.                 font-weight: bold !important;
  488.                 margin: 0 !important;
  489.             }
  490.             .mitsumori-card-pc #mitsumori_message {
  491.                 font-size: 22px !important;
  492.                 font-weight: bold !important;
  493.                 color: #fff !important;
  494.             }
  495.             .mitsumori-card-pc .btn-tool {
  496.                 color: #fff !important;
  497.             }
  498.             /* 合計行を大きく強調 */
  499.             .mitsumori-card-pc .nav-item:first-child .nav-link {
  500.                 font-size: 16px !important;
  501.                 font-weight: bold !important;
  502.                 color: #c00 !important;
  503.                 background: #fff8f8 !important;
  504.                 padding: 12px 16px !important;
  505.             }
  506.             .mitsumori-card-pc .nav-item:first-child #mitsumori_goukei {
  507.                 font-size: 20px !important;
  508.                 font-weight: bold !important;
  509.                 color: #c00 !important;
  510.             }
  511.             /* card-body(明細リスト)を白背景に */
  512.             .mitsumori-card-pc .card-body {
  513.                 background: #fff !important;
  514.             }
  515.             .mitsumori-card-pc .card-footer {
  516.                 background: #f8faff !important;
  517.                 border-top: 1px solid #dce8fb !important;
  518.                 padding: 12px 16px !important;
  519.             }
  520.         }
  521.         @media (max-width: 767px) {
  522.             /* スマホでは現在のお見積り額カードの強調スタイルをすべてリセット */
  523.             .mitsumori-card-pc {
  524.                 border: none !important;
  525.                 border-radius: 0 !important;
  526.                 box-shadow: none !important;
  527.                 margin-top: 0 !important;
  528.                 overflow: visible !important;
  529.                 background: none !important;
  530.             }
  531.             .mitsumori-card-pc .card-header {
  532.                 background: none !important;
  533.                 color: inherit !important;
  534.                 padding: inherit !important;
  535.                 border-bottom: inherit !important;
  536.             }
  537.             .mitsumori-card-pc .card-title { color: inherit !important; }
  538.             .mitsumori-card-pc #mitsumori_message { font-size: inherit !important; color: inherit !important; }
  539.             .mitsumori-card-pc .btn-tool { color: inherit !important; }
  540.             /* 折りたたみトグルボタン */
  541.             .btn-mitsumori-toggle {
  542.                 background: none !important;
  543.                 border: 1px solid #aaa !important;
  544.                 border-radius: 4px !important;
  545.                 padding: 2px 8px !important;
  546.                 font-size: 12px !important;
  547.                 color: #333 !important;
  548.                 line-height: 1.4 !important;
  549.             }
  550.             .btn-mitsumori-toggle .toggle-icon {
  551.                 display: inline-block;
  552.                 transition: transform 0.2s;
  553.             }
  554.             /* 展開状態: ▼→▲ */
  555.             .card:not(.collapsed-card) .btn-mitsumori-toggle .toggle-icon::before {
  556.                 content: "▲ 閉じる";
  557.             }
  558.             .card:not(.collapsed-card) .btn-mitsumori-toggle .toggle-icon {
  559.                 display: none;
  560.             }
  561.             .card:not(.collapsed-card) .btn-mitsumori-toggle::after {
  562.                 content: "▲ 閉じる";
  563.                 font-size: 12px;
  564.             }
  565.             .mitsumori-card-pc .nav-item:first-child .nav-link {
  566.                 font-size: inherit !important;
  567.                 color: inherit !important;
  568.                 background: none !important;
  569.                 padding: inherit !important;
  570.             }
  571.             .mitsumori-card-pc .nav-item:first-child #mitsumori_goukei {
  572.                 font-size: inherit !important;
  573.                 color: inherit !important;
  574.             }
  575.             .mitsumori-card-pc .card-footer {
  576.                 background: none !important;
  577.                 border-top: inherit !important;
  578.                 padding: inherit !important;
  579.             }
  580.             /* 横スクロール禁止 */
  581.             body, html {
  582.                 overflow-x: hidden;
  583.                 max-width: 100vw;
  584.             }
  585.             /* ボタンの折り返しを許可(nowrapが原因で横スクロール発生するため) */
  586.             .opt-btn,
  587.             .rp-btn {
  588.                 white-space: normal;
  589.                 word-break: break-all;
  590.             }
  591.             /* エリア案内: スマホでコンパクト */
  592.             .ec-areaNotice {
  593.                 margin: 8px 0;
  594.                 padding: 8px 10px;
  595.                 border-left-width: 3px;
  596.                 cursor: pointer;
  597.             }
  598.             .ec-areaNotice__inner {
  599.                 flex-direction: row;
  600.                 gap: 8px;
  601.                 align-items: flex-start;
  602.             }
  603.             .ec-areaNotice__icon { font-size: 15px; }
  604.             /* タイトル行: 展開トグル */
  605.             .ec-areaNotice__title {
  606.                 font-size: 11px;
  607.                 margin-bottom: 3px;
  608.                 display: flex;
  609.                 justify-content: space-between;
  610.                 align-items: center;
  611.             }
  612.             .ec-areaNotice__title::after {
  613.                 content: "▼";
  614.                 font-size: 9px;
  615.                 color: #888;
  616.                 margin-left: 6px;
  617.                 transition: transform 0.2s;
  618.             }
  619.             .ec-areaNotice.is-open .ec-areaNotice__title::after {
  620.                 transform: rotate(180deg);
  621.             }
  622.             /* 折りたたみ対象: 閉じた状態では非表示 */
  623.             .ec-areaNotice__detail {
  624.                 display: none;
  625.             }
  626.             .ec-areaNotice.is-open .ec-areaNotice__detail {
  627.                 display: block;
  628.             }
  629.             .ec-areaNotice__text { font-size: 11px; line-height: 1.5; }
  630.             .ec-areaNotice__text br { display: none; }
  631.             .ec-areaNotice__link { font-size: 11px; margin-top: 3px; }
  632.             .rp-card { width: calc(33.333% - 6px); min-width: 80px; }
  633.             
  634.             #sp-mitsumori-bar {
  635.                 display: flex;
  636.                 position: fixed;
  637.                 bottom: 0;
  638.                 left: 0;
  639.                 right: 0;
  640.                 z-index: 1000;
  641.                 background: #fff;
  642.                 border-top: 2px solid #e0e0e0;
  643.                 box-shadow: 0 -2px 8px rgba(0,0,0,0.12);
  644.                 align-items: center;
  645.                 padding: 8px 12px calc(8px + env(safe-area-inset-bottom)) 12px;
  646.                 gap: 10px;
  647.             }
  648.             #sp-mitsumori-bar .sp-bar__label {
  649.                 font-size: 11px;
  650.                 color: #666;
  651.                 white-space: nowrap;
  652.             }
  653.             #sp-mitsumori-bar .sp-bar__price {
  654.                 font-size: 18px;
  655.                 font-weight: bold;
  656.                 color: #c00;
  657.                 flex: 1;
  658.             }
  659.             #sp-mitsumori-bar .sp-bar__btn {
  660.                 font-size: 12px;
  661.                 padding: 8px 12px;
  662.                 background: #333;
  663.                 color: #fff;
  664.                 border: none;
  665.                 border-radius: 6px;
  666.                 white-space: nowrap;
  667.                 cursor: pointer;
  668.                 position: relative;
  669.                 display: inline-flex;
  670.                 align-items: center;
  671.                 gap: 6px;
  672.             }
  673.             #sp-mitsumori-bar .sp-bar__btn i {
  674.                 font-size: 14px;
  675.             }
  676.             #sp-mitsumori-bar .sp-bar__cart-badge {
  677.                 position: absolute;
  678.                 top: -6px;
  679.                 right: -6px;
  680.                 background: #c00;
  681.                 color: #fff;
  682.                 border-radius: 50%;
  683.                 min-width: 16px;
  684.                 height: 16px;
  685.                 font-size: 10px;
  686.                 line-height: 16px;
  687.                 padding: 0 4px;
  688.                 font-weight: bold;
  689.             }
  690.             #sp-mitsumori-bar .sp-bar__home-btn {
  691.                 display: inline-flex;
  692.                 align-items: center;
  693.                 justify-content: center;
  694.                 width: 36px;
  695.                 height: 36px;
  696.                 border: 1px solid #ccc;
  697.                 border-radius: 6px;
  698.                 background: #fff;
  699.                 color: #333;
  700.                 text-decoration: none;
  701.                 cursor: pointer;
  702.             }
  703.             #sp-mitsumori-bar .sp-bar__home-btn i {
  704.                 font-size: 16px;
  705.             }
  706.             #sp-mitsumori-bar .sp-bar__home-btn:hover {
  707.                 background: #f0f0f0;
  708.             }
  709.             /* 下部バーの高さ分ページ下部にpaddingを追加 (iOS safe-area 込み) */
  710.             body {
  711.                 padding-bottom: calc(80px + env(safe-area-inset-bottom));
  712.             }
  713.         }
  714.         /* ============================================
  715.            カート追加モーダル: 縦並び中央配置
  716.         ============================================ */
  717.         .add-cart-modal__wrap {
  718.             text-align: center;
  719.         }
  720.         .add-cart-modal__header {
  721.             font-size: 16px;
  722.             margin: 20px 0 24px;
  723.             text-align: center;
  724.         }
  725.         .add-cart-modal__actions {
  726.             display: flex;
  727.             flex-direction: column;
  728.             align-items: center;
  729.             gap: 16px;
  730.             padding: 0 20px 20px;
  731.         }
  732.         .add-cart-modal__primary {
  733.             display: inline-block;
  734.             width: 80%;
  735.             max-width: 320px;
  736.             padding: 14px 20px;
  737.             font-size: 15px;
  738.             font-weight: bold;
  739.             text-align: center;
  740.             background: #d9534f;
  741.             color: #fff !important;
  742.             border-radius: 6px;
  743.             text-decoration: none;
  744.             cursor: pointer;
  745.         }
  746.         .add-cart-modal__primary:hover {
  747.             background: #c9302c;
  748.             color: #fff !important;
  749.             text-decoration: none;
  750.         }
  751.         .add-cart-modal__secondary {
  752.             display: inline-block;
  753.             padding: 6px 14px;
  754.             font-size: 12px;
  755.             color: #666;
  756.             border: 1px solid #ccc;
  757.             border-radius: 4px;
  758.             background: #fff;
  759.             cursor: pointer;
  760.         }
  761.         .add-cart-modal__secondary:hover {
  762.             background: #f0f0f0;
  763.             color: #333;
  764.         }
  765.         @media (max-width: 767px) {
  766.             .add-cart-modal__actions {
  767.                 gap: 20px;
  768.             }
  769.         }
  770.     </style>
  771. {% endblock %}
  772. {% block javascript %}
  773.     <script>
  774.         eccube.classCategories = {{ class_categories_as_json(Product)|raw }};
  775.         // 規格2に選択肢を割り当てる。
  776.         function fnSetClassCategories(form, classcat_id2_selected) {
  777.             var $form = $(form);
  778.             var product_id = $form.find('input[name=product_id]').val();
  779.             var $sele1 = $form.find('select[name=classcategory_id1]');
  780.             var $sele2 = $form.find('select[name=classcategory_id2]');
  781.             eccube.setClassCategories($form, product_id, $sele1, $sele2, classcat_id2_selected);
  782.         }
  783.         {% if form.classcategory_id2 is defined %}
  784.         fnSetClassCategories(
  785.             $('#form1'), {{ form.classcategory_id2.vars.value|json_encode|raw }}
  786.         );
  787.         {% elseif form.classcategory_id1 is defined %}
  788.         eccube.checkStock($('#form1'), {{ Product.id }}, {{ form.classcategory_id1.vars.value|json_encode|raw }}, null);
  789.         {% endif %}
  790.     </script>
  791.     <script>
  792.         $(function() {
  793.             // bfcache無効化
  794.             $(window).bind('pageshow', function(event) {
  795.                 if (event.originalEvent.persisted) {
  796.                     location.reload(true);
  797.                 }
  798.             });
  799.             // Core Web Vital の Cumulative Layout Shift(CLS)対策のため
  800.             // img タグに width, height が付与されている.
  801.             // 630px 未満の画面サイズでは縦横比が壊れるための対策
  802.             // see https://github.com/EC-CUBE/ec-cube/pull/5023
  803.             $('.ec-grid2__cell').hide();
  804.             var removeSize = function () {
  805.                 $('.slide-item').height('');
  806.                 $('.slide-item img')
  807.                     .removeAttr('width')
  808.                     .removeAttr('height')
  809.                     .removeAttr('style');
  810.             };
  811.             var slickInitial = function(slick) {
  812.                 $('.ec-grid2__cell').fadeIn(1500);
  813.                 var baseHeight = $(slick.target).height();
  814.                 var baseWidth = $(slick.target).width();
  815.                 var rate = baseWidth / baseHeight;
  816.                 if(baseHeight * rate < 400){
  817.                     $('.slide-item').height(baseHeight * rate); // 余白を削除する
  818.                 }else{
  819.                     $('.slide-item').height(400); // 余白を削除する
  820.                 }
  821.                 // transform を使用することでCLSの影響を受けないようにする
  822.                 $('.slide-item img')
  823.                     .css(
  824.                         {
  825.                             'transform-origin': 'top left',
  826.                             'transform': 'scaleY(' + rate + ')',
  827.                             'transition': 'transform .1s'
  828.                         }
  829.                     );
  830.                 // 正しいサイズに近くなったら属性を解除する
  831.                 setTimeout(removeSize, 500);
  832.             };
  833.             $('.item_visual').on('init', slickInitial);
  834.             // リサイズ時は CLS の影響を受けないため属性を解除する
  835.             $(window).resize(removeSize);
  836.             $('.item_visual').slick({
  837.                 dots: false,
  838.                 arrows: true,
  839.                 responsive: [{
  840.                     breakpoint: 768,
  841.                     settings: {
  842.                         dots: true,
  843.                         arrows: false
  844.                     }
  845.                 }]
  846.             });
  847.             $('.slideThumb').on('click', function() {
  848.                 var index = $(this).attr('data-index');
  849.                 $('.item_visual').slick('slickGoTo', index, false);
  850.             })
  851.         });
  852.     </script>
  853.     <script>
  854.         $(function() {
  855.             $('.add-cart').on('click', function(event) {
  856.                 {% if form.classcategory_id1 is defined %}
  857.                 // 規格1フォームの必須チェック
  858.                 if ($('#classcategory_id1').val() == '__unselected' || $('#classcategory_id1').val() == '') {
  859.                     $('#classcategory_id1')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  860.                     return true;
  861.                 } else {
  862.                     $('#classcategory_id1')[0].setCustomValidity('');
  863.                 }
  864.                 {% endif %}
  865.                 {% if form.classcategory_id2 is defined %}
  866.                 // 規格2フォームの必須チェック
  867.                 if ($('#classcategory_id2').val() == '__unselected' || $('#classcategory_id2').val() == '') {
  868.                     $('#classcategory_id2')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
  869.                     return true;
  870.                 } else {
  871.                     $('#classcategory_id2')[0].setCustomValidity('');
  872.                 }
  873.                 {% endif %}
  874.                 // タイプ2: カート送信直前に set_count を quantity に同期
  875.                 if($('#set_count').length){
  876.                     var _sc = parseInt($('#set_count').val()) || 1;
  877.                     $('#quantity').val(_sc);
  878.                     $('input[name="quantity"]').val(_sc);
  879.                 }
  880.                 // 個数フォームのチェック
  881.                 if ($('#quantity').val() < 1) {
  882.                     $('#quantity')[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
  883.                     return true;
  884.                 } else {
  885.                     $('#quantity')[0].setCustomValidity('');
  886.                 }
  887.                 event.preventDefault();
  888.                 $form = $('#form1');
  889.                 $.ajax({
  890.                     url: $form.attr('action'),
  891.                     type: $form.attr('method'),
  892.                     data: $form.serialize(),
  893.                     dataType: 'json',
  894.                     beforeSend: function(xhr, settings) {
  895.                         // Buttonを無効にする
  896.                         $('.add-cart').prop('disabled', true);
  897.                     }
  898.                 }).done(function(data) {
  899.                     // レスポンス内のメッセージをalertで表示
  900.                     $.each(data.messages, function() {
  901.                         $('#ec-modal-header').text(this);
  902.                     });
  903.                     $('.ec-modal').show()
  904.                     // カートブロックを更新する
  905.                     $.ajax({
  906.                         url: "{{ url('block_cart') }}",
  907.                         type: 'GET',
  908.                         dataType: 'html'
  909.                     }).done(function(html) {
  910.                         $('.ec-headerRole__cart').html(html);
  911.                     });
  912.                 }).fail(function(data) {
  913.                     alert('{{ 'カートへの追加に失敗しました。'|trans }}');
  914.                 }).always(function(data) {
  915.                     // Buttonを有効にする
  916.                     $('.add-cart').prop('disabled', false);
  917.                 });
  918.             });
  919.         });
  920.         $('.ec-modal-wrap').on('click', function(e) {
  921.             // モーダル内の処理は外側にバブリングさせない
  922.             e.stopPropagation();
  923.         });
  924.         $('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
  925.             $('.ec-modal').hide()
  926.         });
  927.         var pw = "{% if mitsumori_json %}{{ mitsumori_json.pw }}{% endif %}";
  928.         var pd = "{% if mitsumori_json %}{{ mitsumori_json.pd }}{% endif %}";
  929.         var ph = "{% if mitsumori_json %}{{ mitsumori_json.ph }}{% endif %}";
  930.         var pm = "{% if mitsumori_json %}{{ mitsumori_json.pm }}{% endif %}";
  931.         var pc = "{% if mitsumori_json %}{{ mitsumori_json.pc }}{% endif %}";
  932.         // option1 / option2: カテゴリ別 option 軸 (um: タイプ=subtype, fe: ct_up 等)
  933.         var option1 = "{% if mitsumori_json and mitsumori_json.option1 is defined %}{{ mitsumori_json.option1 }}{% endif %}";
  934.         var option2 = "{% if mitsumori_json and mitsumori_json.option2 is defined %}{{ mitsumori_json.option2 }}{% endif %}";
  935.         var op0 = "{% if mitsumori_json %}{{ mitsumori_json.op[0] }}{% endif %}";
  936.         var op1 = "{% if mitsumori_json %}{{ mitsumori_json.op[1] }}{% endif %}";
  937.         var op2 = "{% if mitsumori_json %}{{ mitsumori_json.op[2] }}{% endif %}";
  938.         var op3 = "{% if mitsumori_json %}{{ mitsumori_json.op[3] }}{% endif %}";
  939.         var op4 = "{% if mitsumori_json %}{{ mitsumori_json.op[4] }}{% endif %}";
  940.         var op5 = "{% if mitsumori_json %}{{ mitsumori_json.op[5] }}{% endif %}";
  941.         var op6 = "{% if mitsumori_json %}{{ mitsumori_json.op[6] }}{% endif %}";
  942.         var op7 = "{% if mitsumori_json %}{{ mitsumori_json.op[7] }}{% endif %}";
  943.         var op8 = "{% if mitsumori_json %}{{ mitsumori_json.op[8] }}{% endif %}";
  944.         var op9 = "{% if mitsumori_json %}{{ mitsumori_json.op[9] }}{% endif %}";
  945.         var op10 = "{% if mitsumori_json %}{{ mitsumori_json.op[10] }}{% endif %}";
  946.         const formatter = new Intl.NumberFormat('ja-JP');
  947.         // ============================================================
  948.         //  free_area 1 エントリのスキーマ(11 キー固定)
  949.         // ============================================================
  950.         //   w           : 幅 (string, 例 "239.9cm" / tf は "1m")
  951.         //   d           : 奥行
  952.         //   h           : 高さ (tf はロール長 "10m")
  953.         //   m           : 素材
  954.         //   c           : カラー
  955.         //   price       : 販売価格 (税抜、amount=1 ベース)
  956.         //   unit_price  : 商品 per-unit 増分 (税抜、AMOUNT_CATEGORIES のみ)
  957.         //   maker_price : メーカー価格 (税抜)
  958.         //   ct          : 基本工事費 (税抜、amount=1 ベース)
  959.         //   option1     : fe → ct_up / その他カテゴリ → category-specific
  960.         //   option2     : um → ct_up / その他カテゴリ → category-specific
  961.         //
  962.         //  ct4 (設置場所) / ct5 (撤去) / ct6 (残土) は option_area 側で扱う.
  963.         // ============================================================
  964.         // 施工オプション定義(option_area)— 各エントリ {name, comment, on, off, price}
  965.         var op_data = {{ op_json|default('[]')|raw }};
  966.         // tg カテゴリ用 block 別オプション差額表 (option_item_area).
  967.         //   構造: { axis_labels: {F:'床材',front:'前面型',side1:'右側面型',side2:'左側面型'},
  968.         //           blocks: { 'W_label|D_label': { F:[{idx,label,diff},...], front:[...], side1:[...], side2:[...] }, ... } }
  969.         // tg 以外のカテゴリでは空 ({axis_labels:{}, blocks:{}}).
  970.         var oi_data = {{ oi_json|default('{"axis_labels":{},"blocks":{}}')|raw }};
  971.         // 選択中の tg オプション差額 (axis -> selected choice_idx). ラジオ click で更新される.
  972.         var oi_selected = { F: 1, front: 1, side1: 1, side2: 1 };
  973.         // sale_type ID(mtb_sale_type の id。本サイトでの意味は次の通り):
  974.         //   1 通常 / 2 補助金窓 / 3 物置 / 4 フェンス / 5 デッキ / 6 芝生 / 9 商品のみ
  975.         var SALE_TYPE_ID = {{ ProductClass.SaleType.id }};
  976.         {# option1 / option2 ラベルをカテゴリ別に決定 (sh=31, rd=43, mo=15) — 以降の UI / JS 両方で使用 #}
  977.         {% set option1_label = 'オプション1' %}
  978.         {% set option2_label = 'オプション2' %}
  979.         {% if Product.ProductCategories is not empty %}
  980.             {% for pcat in Product.ProductCategories %}
  981.                 {% if pcat.category_id == 31 %}{% set option1_label = 'サイズプリセット' %}{% set option2_label = '駆動方式' %}{% endif %}
  982.                 {% if pcat.category_id == 43 %}{% set option1_label = 'ランマ' %}{% set option2_label = 'タイプ' %}{% endif %}
  983.                 {% if pcat.category_id == 15 %}{% set option1_label = '棚タイプ' %}{% endif %}
  984.                 {% if pcat.category_id == 17 %}{% set option1_label = '窓タイプ' %}{% endif %}
  985.             {% endfor %}
  986.         {% endif %}
  987.         // 消費税率(pp.price/pp.ct/op_data.price は scraper が税抜で保存しているため、
  988.         // calcGoukei 出口で 1+TAX_RATE を掛けて税込 mitsumori_goukei にする)
  989.         var TAX_RATE = 0.10;
  990.         function toIncTax(v) { return Math.round(v * (1 + TAX_RATE)); }
  991.         /**
  992.          * tg 用 block 別オプション差額の集計.
  993.          *   現選択 (W, D) から block key を作り、oi_data.blocks[blockKey] を取得.
  994.          *   各 axis (F/front/side1/side2) で oi_selected[axis] の choice の diff を合計.
  995.          * 戻り値: { total: 差額合計(税抜), items: [{name, label, diff}, ...] }
  996.          *   block が無い (tg 以外 / 該当 (W,D) が未取得) なら total=0.
  997.          */
  998.         function collectOptionItems(curW, curD) {
  999.             var result = { total: 0, items: [] };
  1000.             if (!oi_data || !oi_data.blocks) return result;
  1001.             var blockKey = (curW || '') + '|' + (curD || '');
  1002.             var block = oi_data.blocks[blockKey];
  1003.             if (!block) return result;
  1004.             var axes = ['F', 'front', 'side1', 'side2'];
  1005.             for (var i = 0; i < axes.length; i++) {
  1006.                 var axis = axes[i];
  1007.                 var choices = block[axis];
  1008.                 if (!choices || !choices.length) continue;
  1009.                 var idx = oi_selected[axis] || 1;
  1010.                 var pick = null;
  1011.                 for (var j = 0; j < choices.length; j++) {
  1012.                     if (parseInt(choices[j].idx) === parseInt(idx)) { pick = choices[j]; break; }
  1013.                 }
  1014.                 if (!pick) pick = choices[0];
  1015.                 var diff = parseInt(pick.diff) || 0;
  1016.                 result.total += diff;
  1017.                 result.items.push({
  1018.                     name:  oi_data.axis_labels[axis] || axis,
  1019.                     label: pick.label,
  1020.                     diff:  diff,
  1021.                 });
  1022.             }
  1023.             return result;
  1024.         }
  1025.         /**
  1026.          * tg ラジオ群を block 別に DOM へ描画する.
  1027.          *   W/D が確定したら現 block の 4 軸 (F/front/side1/side2) ラジオを #tg-options 要素に出す.
  1028.          *   block が空なら #tg-options を空にする.
  1029.          */
  1030.         function renderOptionItemRadios(curW, curD) {
  1031.             var $box = $('#tg-options');
  1032.             if (!$box.length) return;
  1033.             $box.empty();
  1034.             if (!oi_data || !oi_data.blocks) return;
  1035.             var blockKey = (curW || '') + '|' + (curD || '');
  1036.             var block = oi_data.blocks[blockKey];
  1037.             if (!block) return;
  1038.             var axes = ['F', 'front', 'side1', 'side2'];
  1039.             axes.forEach(function(axis) {
  1040.                 var choices = block[axis];
  1041.                 if (!choices || !choices.length) return;
  1042.                 var axisLabel = (oi_data.axis_labels && oi_data.axis_labels[axis]) || axis;
  1043.                 var $section = $('<div class="form-group tg-axis"></div>');
  1044.                 $section.append('<p class="rp-section-label"><strong>' + axisLabel + '</strong>: <span class="tg-axis-selected"></span></p>');
  1045.                 var $list = $('<div class="tg-choice-list"></div>');
  1046.                 choices.forEach(function(ch, i) {
  1047.                     var inputId = 'tg_' + axis + '_' + ch.idx;
  1048.                     var name = 'tg_' + axis;
  1049.                     var checked = (parseInt(ch.idx) === parseInt(oi_selected[axis] || 1)) ? ' checked' : '';
  1050.                     var diffTxt = ch.diff > 0 ? '+' + formatter.format(ch.diff) + '円' : (ch.diff < 0 ? formatter.format(ch.diff) + '円' : '±0');
  1051.                     $list.append(
  1052.                         '<label class="tg-choice"><input type="radio" name="' + name + '" id="' + inputId + '" value="' + ch.idx + '" data-axis="' + axis + '"' + checked + '> ' +
  1053.                         ch.label + '<span class="tg-diff">(' + diffTxt + ')</span></label>'
  1054.                     );
  1055.                 });
  1056.                 $section.append($list);
  1057.                 $box.append($section);
  1058.             });
  1059.             // ラジオ click で oi_selected を更新 → 再計算
  1060.             $box.off('change.tg').on('change.tg', 'input[type="radio"][data-axis]', function() {
  1061.                 var axis = $(this).data('axis');
  1062.                 oi_selected[axis] = parseInt($(this).val()) || 1;
  1063.                 mitsumori_simulation('refresh', '');
  1064.             });
  1065.             updateOptionItemSelectedLabels();
  1066.         }
  1067.         function updateOptionItemSelectedLabels() {
  1068.             $('#tg-options .tg-axis').each(function() {
  1069.                 var $sel = $(this).find('input[type="radio"]:checked');
  1070.                 if (!$sel.length) return;
  1071.                 var label = $sel.parent().contents().filter(function() { return this.nodeType === 3; }).text().trim();
  1072.                 $(this).find('.tg-axis-selected').text(label);
  1073.             });
  1074.         }
  1075.         /**
  1076.          * 選択中の施工オプションを集計し、ON選択分の price を合計する.
  1077.          * 戻り値: { total: 合計金額, items: [{name, value, price}, ...] }
  1078.          */
  1079.         function collectOptions() {
  1080.             var ops = [op0,op1,op2,op3,op4,op5,op6,op7,op8,op9,op10];
  1081.             var total = 0;
  1082.             var items = [];
  1083.             for (var i = 0; i < ops.length; i++) {
  1084.                 if (!op_data[i] || !op_data[i].name) continue;
  1085.                 var sel = ops[i];
  1086.                 if (!sel) continue;
  1087.                 var price = parseInt(op_data[i].price) || 0;
  1088.                 // 「ON」選択時のみ加算(OFF や「不要」「商品購入のみ」は加算しない)
  1089.                 var isOn = (sel === op_data[i].on);
  1090.                 items.push({
  1091.                     name:  op_data[i].name,
  1092.                     value: sel,
  1093.                     price: isOn ? price : 0,
  1094.                     on:    op_data[i].on,
  1095.                     off:   op_data[i].off,
  1096.                 });
  1097.                 if (isOn) total += price;
  1098.             }
  1099.             return { total: total, items: items };
  1100.         }
  1101.         /**
  1102.          * free_area 1 エントリ ({w,d,h,m,c,price,unit_price,maker_price,ct,option1,option2})
  1103.          * から sale_type 別に最終金額を算出する.
  1104.          *
  1105.          * 計算式(amount=1 ベース、出口で × 1.10 税込化):
  1106.          *   1 通常        : price + ct + option_sum
  1107.          *   2 補助金窓    : price × set_count + (ct + (set_count-1) × option2) + option_sum
  1108.          *   3 物置        : (price + ct) × daisu + option_sum
  1109.          *   4 フェンス    : price + (maisu-1) × unit_price
  1110.          *                  + ct + max(0, maisu-3) × option1
  1111.          *                  + option_sum   (maisu >= 3)
  1112.          *   5 デッキ      : price + ct + option_sum   (area は表示用、計算非関与)
  1113.          *   6 芝生        : price × ceil(area / (w_m × h_m)) + ct + option_sum
  1114.          *   9 商品のみ    : price のみ(カート quantity 倍で総額)
  1115.          *
  1116.          * fe では option1 を ct_up、um では option2 を ct_up として転用.
  1117.          * tf では w / h にロール幅・長さが格納されており parseLen で数値抽出.
  1118.          *
  1119.          * @param {Object} pp  free_area の 1 行(matrix エントリ)
  1120.          * @param {number} optionTotal  collectOptions().total
  1121.          * @param {Object} ctx  UI 入力 {set_count, daisu, maisu, area, quantityOnly, ...}
  1122.          * @returns {Object} {goukei, price, ct, opt, qty}  すべて税込整数
  1123.          */
  1124.         function calcGoukei(pp, optionTotal, ctx) {
  1125.             var basePrice  = parseInt(pp.price)       || 0;
  1126.             var baseCt     = parseInt(pp.ct)          || 0;
  1127.             var unitPrice  = parseInt(pp.unit_price)  || 0;
  1128.             var optSum     = optionTotal;
  1129.             var price      = basePrice;
  1130.             var ct         = baseCt;
  1131.             var qty        = 1;
  1132.             var goukei     = 0;
  1133.             // 「商品購入のみ」選択時は工事費・オプションをゼロにする(任意 sale_type で適用)
  1134.             var ops = [op0,op1,op2,op3,op4,op5,op6,op7,op8,op9,op10];
  1135.             var purchaseOnly = ops.some(function(v){ return v === '商品購入のみ'; });
  1136.             if (purchaseOnly) {
  1137.                 baseCt = 0;
  1138.                 ct     = 0;
  1139.                 optSum = 0;
  1140.             }
  1141.             switch (SALE_TYPE_ID) {
  1142.                 case 2: {  // 補助金・窓 (シンプル表引き方式 2026-05-)
  1143.                     // 2026-05 仕様簡素化: 枚数軸を廃止し、subtype に枚数を内包.
  1144.                     // pp.price / pp.ct は (W, H, ガラス, subtype) の単一価格.
  1145.                     // 複数枚をまとめて買う場合はカート quantity で表現.
  1146.                     qty    = 1;
  1147.                     price  = basePrice;
  1148.                     ct     = baseCt;
  1149.                     goukei = price + ct + optSum;
  1150.                     break;
  1151.                 }
  1152.                 case 3: {  // 物置・ゴミステーション
  1153.                     qty   = Math.max(1, parseInt(ctx.daisu) || 1);
  1154.                     price = basePrice * qty;
  1155.                     ct    = baseCt * qty;
  1156.                     goukei = price + ct + optSum;
  1157.                     break;
  1158.                 }
  1159.                 case 4: {  // フェンス・組み立て式(maisu ≥ 3、base_amount = 3)
  1160.                     // scraper は amount=3 を base にしているので pp.price = price(3),
  1161.                     // pp.unit_price = price(4) - price(3).
  1162.                     qty   = Math.max(3, parseInt(ctx.maisu) || 3);
  1163.                     price = basePrice + (qty - 3) * unitPrice;
  1164.                     // option1 が ct_up (4枚目以降の増分). 未設定なら ct 固定動作
  1165.                     var ctUp1 = parseInt(pp.option1) || 0;
  1166.                     ct = baseCt + Math.max(0, qty - 3) * ctUp1;
  1167.                     goukei = price + ct + optSum;
  1168.                     break;
  1169.                 }
  1170.                 case 5: {  // ウッドデッキ・タイルデッキ
  1171.                     // area は担当者向けの参考値として保持(計算には使わない)
  1172.                     qty    = 1;
  1173.                     goukei = basePrice + baseCt + optSum;
  1174.                     price  = basePrice;
  1175.                     ct     = baseCt;
  1176.                     break;
  1177.                 }
  1178.                 case 6: {  // 芝生・人工芝(ロール単位)
  1179.                     // pp.w "1m", pp.h "10m" から数値抽出
  1180.                     var w_m = parseLen(pp.w);
  1181.                     var h_m = parseLen(pp.h);
  1182.                     var rollSize = w_m * h_m;
  1183.                     if (!rollSize || rollSize <= 0) rollSize = 1;
  1184.                     var area  = parseFloat(ctx.area) || rollSize;
  1185.                     qty    = Math.max(1, Math.ceil(area / rollSize));
  1186.                     price  = basePrice * qty;
  1187.                     ct     = baseCt;
  1188.                     goukei = price + ct + optSum;
  1189.                     break;
  1190.                 }
  1191.                 case 7: {  // 数量買い・基本工事費固定(gf ガーデンファニチャー / st 石材)
  1192.                     qty    = Math.max(1, parseInt(ctx.suuryou) || 1);
  1193.                     price  = basePrice * qty;
  1194.                     ct     = baseCt;                 // ct は固定(数量に依らない)
  1195.                     goukei = price + ct + optSum;
  1196.                     break;
  1197.                 }
  1198.                 case 9: {  // 商品のみ購入
  1199.                     // カート側で quantity × unit price するため goukei は単品価格
  1200.                     qty    = parseInt(ctx.quantityOnly) || 1;
  1201.                     price  = basePrice;
  1202.                     ct     = 0;
  1203.                     optSum = 0;
  1204.                     goukei = price;
  1205.                     break;
  1206.                 }
  1207.                 default: {  // 1: 通常(カーポート等、matrix 選択のみ)
  1208.                     qty    = 1;
  1209.                     goukei = basePrice + baseCt + optSum;
  1210.                     break;
  1211.                 }
  1212.             }
  1213.             // 出口で税込化(pp.price/pp.ct/op_data.price はすべて税抜で保存されている前提)
  1214.             return {
  1215.                 goukei: toIncTax(goukei),
  1216.                 price:  toIncTax(price),
  1217.                 ct:     toIncTax(ct),
  1218.                 opt:    toIncTax(optSum),
  1219.                 qty:    qty,
  1220.             };
  1221.         }
  1222.         /**
  1223.          * 寸法文字列から「メートル単位の数値」を抽出する.
  1224.          *
  1225.          * 単位は m / cm / mm を認識し、いずれも m 単位に正規化して返す.
  1226.          * 単位が無い場合は m 単位とみなす(旧 tf データ "1m" "10m" との互換).
  1227.          * 数値が見つからない場合は 0 を返す(呼び出し側で fallback).
  1228.          *
  1229.          * 例:
  1230.          *   "1m"     → 1
  1231.          *   "100cm"  → 1   (2026-06 以降の m → cm 正規化に対応)
  1232.          *   "200cm"  → 2
  1233.          *   "5.5m"   → 5.5
  1234.          *   "1000mm" → 1
  1235.          *   ""       → 0
  1236.          */
  1237.         function parseLen(s) {
  1238.             if (!s) return 0;
  1239.             var str = String(s);
  1240.             var m = str.match(/(\d+(?:\.\d+)?)\s*(mm|cm|m)?/i);
  1241.             if (!m) return 0;
  1242.             var n = parseFloat(m[1]);
  1243.             if (isNaN(n)) return 0;
  1244.             var unit = (m[2] || 'm').toLowerCase();
  1245.             if (unit === 'cm') return n / 100;
  1246.             if (unit === 'mm') return n / 1000;
  1247.             return n;  // 'm' or no unit
  1248.         }
  1249.         // pp は autoSelectFirstColor 等からも参照するので global にする
  1250.         var pp = {{ pp|raw }};
  1251.         function mitsumori_simulation(type , value_id){
  1252.             // 価格データ未登録 (pp 行 0 件) の商品は axis 入力に依存せず
  1253.             // 「価格データ準備中」を表示して終了する.
  1254.             // (例: scrape 未対象の新規商品 — um のウチリモ 7487/7488 等)
  1255.             if (!pp || pp.length === 0) {
  1256.                 $('#mitsumori_message').text("価格データ準備中");
  1257.                 $('#mitsumori_btn').hide();
  1258.                 $('#mitsumori_goukei').text("---円");
  1259.                 $('#mitsumori_off').text("---円");
  1260.                 $('#mitsumori_price').text("---円");
  1261.                 $('#maker_price').text("---円");
  1262.                 $('#mitsumori_ct').text("---円");
  1263.                 $('#mitsumori_option').text("---円");
  1264.                 $('#mitsumori_kei').text("---円");
  1265.                 $('#mitsumori_shoukei').text("---円");
  1266.                 $('#mitsumori_tax').text("---円");
  1267.                 return;
  1268.             }
  1269.             if(type == "pw"){
  1270.                 pw = $('#'+value_id).val();
  1271.             }
  1272.             if(type == "pd"){
  1273.                 pd = $('#'+value_id).val();
  1274.             }
  1275.             if(type == "ph"){
  1276.                 ph = $('#'+value_id).val();
  1277.             }
  1278.             if(type == "pm"){
  1279.                 pm = $('#'+value_id).val();
  1280.             }
  1281.             if(type == "pc"){
  1282.                 pc = $('#'+value_id).val();
  1283.             }
  1284.             if(type == "option1"){
  1285.                 option1 = $('#'+value_id).val();
  1286.             }
  1287.             if(type == "option2"){
  1288.                 option2 = $('#'+value_id).val();
  1289.             }
  1290.             if(type == "op0"){ op0 = $('#'+value_id).val(); }
  1291.             if(type == "op1"){ op1 = $('#'+value_id).val(); }
  1292.             if(type == "op2"){ op2 = $('#'+value_id).val(); }
  1293.             if(type == "op3"){ op3 = $('#'+value_id).val(); }
  1294.             if(type == "op4"){ op4 = $('#'+value_id).val(); }
  1295.             if(type == "op5"){ op5 = $('#'+value_id).val(); }
  1296.             if(type == "op6"){ op6 = $('#'+value_id).val(); }
  1297.             if(type == "op7"){ op7 = $('#'+value_id).val(); }
  1298.             if(type == "op8"){ op8 = $('#'+value_id).val(); }
  1299.             if(type == "op9"){ op9 = $('#'+value_id).val(); }
  1300.             if(type == "op10"){ op10 = $('#'+value_id).val(); }
  1301.             // op0 が「商品購入のみ」のとき、他のオプション (op1..op10) を disable 化.
  1302.             // 価格計算側 (calcGoukei の purchaseOnly 分岐) は既にゼロ化しているが、
  1303.             // UI で選択可能に見えるとユーザーが混乱するため radio を完全に無効化する.
  1304.             (function applyPurchaseOnlyUI() {
  1305.                 var isPurchaseOnly = (op0 === '商品購入のみ');
  1306.                 for (var k = 1; k <= 10; k++) {
  1307.                     var $inputs = $('input[name="op' + k + '"]');
  1308.                     if ($inputs.length === 0) continue;
  1309.                     $inputs.prop('disabled', isPurchaseOnly);
  1310.                     var $group = $inputs.first().closest('.form-group');
  1311.                     $group.css({
  1312.                         'opacity':        isPurchaseOnly ? '0.4'  : '1',
  1313.                         'pointer-events': isPurchaseOnly ? 'none' : 'auto'
  1314.                     });
  1315.                 }
  1316.             })();
  1317.             // 全 type 共通: 該当 radio を checked にし、ボタンの is-selected を付け替え + ラベル更新.
  1318.             //   value_id が指定されていて、対応する DOM 要素が opt-btn 配下にあれば適用する.
  1319.             //   (icheck-danger 形式から opt-btn 形式に統一した際、option1/option2/pw/pd/ph/pm/pc 等の
  1320.             //    クリックで is-selected が更新されない不具合があったため、op\d+ 限定の処理を一般化)
  1321.             if (value_id) {
  1322.                 var $clicked = $('#' + value_id);
  1323.                 if ($clicked.length && $clicked.closest('.opt-btn').length) {
  1324.                     $clicked.prop('checked', true);
  1325.                     var groupName = $clicked.attr('name');
  1326.                     $('input[name="' + groupName + '"]').closest('.opt-btn').removeClass('is-selected');
  1327.                     $clicked.closest('.opt-btn').addClass('is-selected');
  1328.                     var $group = $clicked.closest('.form-group');
  1329.                     var $label = $group.find('.rp-section-label');
  1330.                     if ($label.length) {
  1331.                         var labelText = $label.text().split(':')[0].trim();
  1332.                         $label.html(labelText + ': <span>' + $clicked.val() + '</span>');
  1333.                     }
  1334.                     // op_data の price=0 & 解体/撤去/設置場所 オプションの場合、ON 選択時に「現場調査後に正式お見積もり」文言を表示.
  1335.                     //   (twig 側で is_removal_unknown ブロックを描画済み。display 切替のみ JS で行う)
  1336.                     if (/^op\d+$/.test(type)) {
  1337.                         var opIdx = type.replace('op', '');
  1338.                         var opEntry = op_data[parseInt(opIdx)];
  1339.                         if (opEntry) {
  1340.                             var $note = $group.find('.opt-survey-note[data-op-idx="' + opIdx + '"]');
  1341.                             if ($note.length) {
  1342.                                 var isOn = ($clicked.val() === opEntry.on);
  1343.                                 $note.toggle(isOn);
  1344.                             }
  1345.                         }
  1346.                         // wd (sale_type=5) のステップ / デッキフェンス用の注記もここで切替.
  1347.                         //   ステップ → deck_step (op0 だが op_data 範囲外), 必要 選択時に表示.
  1348.                         var radioName = $clicked.attr('name');
  1349.                         if (radioName === 'deck_step') {
  1350.                             $group.find('.opt-survey-note-wd-step').toggle($clicked.val() === '必要');
  1351.                         } else if (radioName === 'deck_fence') {
  1352.                             $group.find('.opt-survey-note-wd-fence').toggle($clicked.val() === '必要');
  1353.                         }
  1354.                     }
  1355.                 }
  1356.             }
  1357.             // 必須項目チェックは sale_type 1 系(カーポート/物置/フェンスなど価格マトリクス必要)に限定
  1358.             var requireMatrix = (SALE_TYPE_ID == 1 || SALE_TYPE_ID == 2 || SALE_TYPE_ID == 3 || SALE_TYPE_ID == 4 || SALE_TYPE_ID == 5 || SALE_TYPE_ID == 6 || SALE_TYPE_ID == 7 || SALE_TYPE_ID == 9);
  1359.             // sale_type=3 (物置・ゴミステーション・照明 等) では「素材」を選択肢として扱わない.
  1360.             //   - mo/gs/sy は m が "指定なし" など名目的にしか入っていない
  1361.             //   - sl は m が空のままで matrix に行が来る
  1362.             //   そのため pm の必須チェックを sale_type=3 でスキップする。
  1363.             var pmRequired = (SALE_TYPE_ID != 3);
  1364.             if (requireMatrix) {
  1365.                 if(pmRequired && pm == ""){
  1366.                     $('#mitsumori_message').text("素材を選択してください");
  1367.                 }
  1368.                 if(ph == ""){
  1369.                     $('#mitsumori_message').text("高さを選択してください");
  1370.                 }
  1371.                 if(pd == ""){
  1372.                     $('#mitsumori_message').text("奥行きを選択してください");
  1373.                 }
  1374.                 if(pw == ""){
  1375.                     $('#mitsumori_message').text("幅を選択してください");
  1376.                 }
  1377.                 if(pc == ""){
  1378.                     $('#mitsumori_message').text("カラーを選択してください");
  1379.                     $('#mitsumori_btn').hide();
  1380.                     $('#mitsumori_goukei').text("---円");
  1381.                     $('#mitsumori_off').text("---円");
  1382.                     $('#mitsumori_price').text("---円");
  1383.                     $('#maker_price').text("---円");
  1384.                     $('#mitsumori_ct').text("---円");
  1385.                     $('#mitsumori_option').text("---円");
  1386.                 }
  1387.             }
  1388.             if(pw != "" && pd != "" && ph != "" && (!pmRequired || pm != "") && pc != ""){
  1389.                 $('#mitsumori_btn').show();
  1390.                 // 入力コンテキスト(sale_type 別パラメータ)
  1391.                 var ctx = {
  1392.                     set_count:    parseInt($('#set_count').val())    || 1,
  1393.                     daisu:        parseInt($('#daisu').val())        || 1,
  1394.                     maisu:        parseInt($('#maisu').val())        || 3,
  1395.                     suuryou:      parseInt($('#suuryou').val())      || 1,
  1396.                     area:         parseFloat($('#area').val())       || 0,
  1397.                     quantityOnly: parseInt($('#quantity_only').val())|| 1,
  1398.                     mado_w:       $('#mado_w').val() || '',
  1399.                     mado_h:       $('#mado_h').val() || '',
  1400.                     mado_type:    $('input[name=mado_type]:checked').val()  || '',
  1401.                     glass_type:   $('input[name=glass_type]:checked').val() || '',
  1402.                     deck_step:    $('input[name=deck_step]:checked').val()  || '',
  1403.                     deck_fence:   $('input[name=deck_fence]:checked').val() || '',
  1404.                 };
  1405.                 // 施工オプション集計(残土処理を含む)
  1406.                 var opCalc = collectOptions();
  1407.                 var pp_matched = false;
  1408.                 // 各軸の汎用 axisMatch:
  1409.                 //   user 選択 == matrix 値 / user "指定なし" / matrix 値が空
  1410.                 var axisMatch = function(input, value){
  1411.                     return input == value || input == "指定なし" || value === "" || value == null;
  1412.                 };
  1413.                 // 色専用マッチャー: scraper のデータ形式に合わせて拡張する
  1414.                 //   1. 完全一致 / "指定なし" / 値が空 → 真 (axisMatch と同じ)
  1415.                 //   2. matrix 値が "色1/色2/色3" の形 (同価格グループ) → split して user 選択が含まれれば真
  1416.                 // scraper のロジック (scraper_price.py L765-779):
  1417.                 //   全色同価格 → c=""、価格違いグループあり → 各 group を "/" 結合した色名で 1 行
  1418.                 var colorMatch = function(input, value){
  1419.                     if (axisMatch(input, value)) return true;
  1420.                     if (typeof value === 'string' && value.indexOf('/') !== -1 && input) {
  1421.                         var parts = value.split('/');
  1422.                         for (var idx = 0; idx < parts.length; idx++) {
  1423.                             if (parts[idx].trim() === input) return true;
  1424.                         }
  1425.                     }
  1426.                     return false;
  1427.                 };
  1428.                 // 他軸 (w/d/h/m + option1/option2) でマッチする pp 行を抽出.
  1429.                 // option1/option2 は um の subtype 等で使われる. axisMatch は free_area 側が
  1430.                 // 空のとき真を返すので、um 以外のカテゴリ (option 軸を使わない) でも影響なし.
  1431.                 var candidates = pp.filter(function(el){
  1432.                     return axisMatch(pw, el.w) && axisMatch(pd, el.d) && axisMatch(ph, el.h) && axisMatch(pm, el.m)
  1433.                         && axisMatch(option1, el.option1) && axisMatch(option2, el.option2);
  1434.                 });
  1435.                 var picked = null;
  1436.                 // 優先 1: 色も含めて完全一致 ("色1/色2" 形式の split match を含む)
  1437.                 for (var ii = 0; ii < candidates.length; ii++) {
  1438.                     if (colorMatch(pc, candidates[ii].c)) { picked = candidates[ii]; break; }
  1439.                 }
  1440.                 // 優先 2: 完全一致なし & user の pc が候補のどの c 値にも該当しない (= 命名違い等)
  1441.                 //   かつ候補全行で price が一致する場合は、色軸を実質無視して先頭行を採用.
  1442.                 //   例 id=3353: pp.c は "ステンカラー+..." 6種だが price は全て同じなので
  1443.                 //     SM(スミ) を選んでも安全に最初の行の価格を返せる.
  1444.                 if (!picked && candidates.length > 0) {
  1445.                     var ppCsInCand = candidates.map(function(r){ return r.c || ''; });
  1446.                     var pcAbsent = (pc !== '' && pc !== '指定なし' && ppCsInCand.indexOf(pc) === -1
  1447.                                     && ppCsInCand.every(function(v){ return v.indexOf('/') === -1 || v.split('/').map(function(s){return s.trim();}).indexOf(pc) === -1; }));
  1448.                     if (pcAbsent) {
  1449.                         var uniqPrices = new Set();
  1450.                         candidates.forEach(function(r){ uniqPrices.add(String(r.price)); });
  1451.                         if (uniqPrices.size === 1) {
  1452.                             // 全候補同価格 → 色軸を wildcard 扱いで OK
  1453.                             picked = candidates[0];
  1454.                         }
  1455.                         // 価格が異なる場合は意図的に picked=null のまま「対応しておりません」.
  1456.                     }
  1457.                 }
  1458.                 pp.forEach((el) => {
  1459.                   if (el === picked) {
  1460.                     pp_matched = true;
  1461.                     // tg block-keyed オプション差額を集計 (tg 以外は total=0)
  1462.                     var oiCalc = collectOptionItems(el.w || '', el.d || '');
  1463.                     // tg ブロックに合わせてラジオを再描画 (tg 以外は no-op)
  1464.                     renderOptionItemRadios(el.w || '', el.d || '');
  1465.                     var calc       = calcGoukei(el, opCalc.total, ctx);
  1466.                     var goukei     = calc.goukei;
  1467.                     var price      = calc.price;
  1468.                     var ct         = calc.ct;
  1469.                     var optionSum  = calc.opt;
  1470.                     // オプション差額は税抜 → 税込に変換して合計に加算
  1471.                     var oiIncTax   = toIncTax(oiCalc.total);
  1472.                     goukei += oiIncTax;
  1473.                     price  += oiIncTax;  // 差額は本体価格扱いとして mitsumori_price にも加算
  1474.                     // maker_price も scraper が税抜で保存しているため税込に変換
  1475.                 var makerPrice = toIncTax(parseInt(el.maker_price) || 0);
  1476.                     $('#mitsumori_message').text(formatter.format(goukei) + "円");
  1477.                     $('#mitsumori_goukei').text(formatter.format(goukei) + "円");
  1478.                     $('#mitsumori_off').text(formatter.format(price - makerPrice) + "円");
  1479.                     $('#mitsumori_price').text(formatter.format(price) + "円");
  1480.                     $('#maker_price').text(formatter.format(makerPrice) + "円");
  1481.                     $('#mitsumori_ct').text(formatter.format(ct) + "円");
  1482.                     $('#mitsumori_option').text(formatter.format(optionSum) + "円");
  1483.                     $('#mitsumori_kei').text(formatter.format(goukei) + "円");
  1484.                     $('#mitsumori_price_01').text(formatter.format(price) + "円");
  1485.                     $('#mitsumori_price_02').text(formatter.format(price) + "円");
  1486.                     $('#mitsumori_ct_01').text(formatter.format(ct) + "円");
  1487.                     $('#mitsumori_ct_02').text(formatter.format(ct) + "円");
  1488.                     $('#mitsumori_goukei_02').text(formatter.format(goukei) + "円");
  1489.                     var shoukei = goukei / 1.1;
  1490.                     var tax     = parseInt(goukei - shoukei);
  1491.                     $('#mitsumori_shoukei').text(formatter.format(parseInt(shoukei)) + "円");
  1492.                     $('#mitsumori_tax').text(formatter.format(tax) + "円");
  1493.                     // PDF 明細用:オプション内訳テーブルを差し込む (施工オプション + tg block オプション)
  1494.                     renderOptionDetailRows(opCalc.items.concat(oiCalc.items.map(function(it){
  1495.                         return { name: it.name, value: it.label, price: it.diff };
  1496.                     })));
  1497.                   }
  1498.                 });
  1499.                 if (!pp_matched) {
  1500.                     $('#mitsumori_message').text("この組み合わせは対応しておりません");
  1501.                     $('#mitsumori_btn').hide();
  1502.                     $('#mitsumori_goukei').text("---円");
  1503.                     $('#mitsumori_off').text("---円");
  1504.                     $('#mitsumori_price').text("---円");
  1505.                     $('#maker_price').text("---円");
  1506.                     $('#mitsumori_ct').text("---円");
  1507.                     $('#mitsumori_option').text("---円");
  1508.                     $('#mitsumori_kei').text("---円");
  1509.                     $('#mitsumori_shoukei').text("---円");
  1510.                     $('#mitsumori_tax').text("---円");
  1511.                 }
  1512.                 // mitsumori_json: バック側に送信する見積データ
  1513.                 var mitsumori_json = { "mitsumori_goukei": $('#mitsumori_goukei').text(),
  1514.                                         "mitsumori_goukei_02": $('#mitsumori_goukei_02').text(),
  1515.                                         "mitsumori_price": $('#mitsumori_price').text(),
  1516.                                         "maker_price": $('#maker_price').text(),
  1517.                                         "mitsumori_off": $('#mitsumori_off').text(),
  1518.                                         "mitsumori_ct": $('#mitsumori_ct').text(),
  1519.                                         "mitsumori_option": $('#mitsumori_option').text(),
  1520.                                         "product_id": {{ Product.id }},
  1521.                                         "sale_type": SALE_TYPE_ID,
  1522.                                         "pw": pw,
  1523.                                         "pd": pd,
  1524.                                         "ph": ph,
  1525.                                         "pm": pm,
  1526.                                         "pc": pc,
  1527.                                         "op": [op0,op1,op2,op3,op4,op5,op6,op7,op8,op9,op10],
  1528.                                         "op_items": opCalc.items,
  1529.                                         "mado_w":     ctx.mado_w,
  1530.                                         "mado_h":     ctx.mado_h,
  1531.                                         "mado_type":  ctx.mado_type,
  1532.                                         "glass_type": ctx.glass_type,
  1533.                                         "set_count":  ctx.set_count,
  1534.                                         "daisu":      ctx.daisu,
  1535.                                         "maisu":      ctx.maisu,
  1536.                                         "suuryou":    ctx.suuryou,
  1537.                                         "area":       ctx.area,
  1538.                                         "deck_step":  ctx.deck_step,
  1539.                                         "deck_fence": ctx.deck_fence };
  1540.                 $('#mitsumori_json').val(JSON.stringify(mitsumori_json));
  1541.             }
  1542.         }
  1543.         // PDF/モーダル明細の動的差し替え(基本工事費の次にオプション行を追加)
  1544.         function renderOptionDetailRows(items) {
  1545.             var $tbody = $('.modal-mitsumori table tbody');
  1546.             if (!$tbody.length) return;
  1547.             $tbody.find('tr.opt-row').remove();
  1548.             var anchorRow = $tbody.find('tr').filter(function(){
  1549.                 return $(this).find('td:first').text().indexOf('残土') !== -1
  1550.                     || $(this).find('td:first').text().indexOf('基本工事費') !== -1;
  1551.             }).last();
  1552.             items.forEach(function(it){
  1553.                 if (!it.name || !it.value) return;
  1554.                 var priceTxt = it.price > 0
  1555.                     ? formatter.format(it.price) + '円'
  1556.                     : '0円';
  1557.                 var $tr = $('<tr class="opt-row"></tr>')
  1558.                     .append('<td>' + it.name + ':' + it.value + '</td>')
  1559.                     .append('<td>1</td>')
  1560.                     .append('<td>式</td>')
  1561.                     .append('<td>' + priceTxt + '</td>')
  1562.                     .append('<td>' + (it.price > 0 ? formatter.format(it.price) + '円' : '') + '</td>');
  1563.                 if (anchorRow.length) {
  1564.                     anchorRow.after($tr);
  1565.                     anchorRow = $tr;
  1566.                 } else {
  1567.                     $tbody.append($tr);
  1568.                 }
  1569.             });
  1570.         }
  1571.         // 見積書モーダルを開く直前に、右側「現在のお見積り額」パネルの表示値を
  1572.         // モーダル内の対応 ID にコピーして金額の食い違いを防ぐ。
  1573.         // pw/pd/ph/pm が未選択で mitsumori_simulation の full update に到達しない場合でも、
  1574.         // パネル側の値(HTML 静的初期値 or 直近の simulation 結果)が modal にも反映される。
  1575.         function syncMitsumoriModalFromPanel() {
  1576.             var goukeiText = $('#mitsumori_goukei').text();
  1577.             var priceText  = $('#mitsumori_price').text();
  1578.             var ctText     = $('#mitsumori_ct').text();
  1579.             $('#mitsumori_kei').text(goukeiText);
  1580.             $('#mitsumori_price_01').text(priceText);
  1581.             $('#mitsumori_price_02').text(priceText);
  1582.             $('#mitsumori_ct_01').text(ctText);
  1583.             $('#mitsumori_ct_02').text(ctText);
  1584.             $('#mitsumori_goukei_02').text(goukeiText);
  1585.             // 小計 / 消費税 は税込 goukei から逆算
  1586.             var num = parseInt(goukeiText.replace(/[^\d-]/g, ''), 10);
  1587.             if (!isNaN(num) && num > 0) {
  1588.                 var shoukei = Math.round(num / 1.1);
  1589.                 var tax     = num - shoukei;
  1590.                 $('#mitsumori_shoukei').text(formatter.format(shoukei) + '円');
  1591.                 $('#mitsumori_tax').text(formatter.format(tax) + '円');
  1592.             } else {
  1593.                 $('#mitsumori_shoukei').text('---円');
  1594.                 $('#mitsumori_tax').text('---円');
  1595.             }
  1596.         }
  1597.         $(document).on('show.bs.modal', '#modal-mitsumori', function () {
  1598.             syncMitsumoriModalFromPanel();
  1599.         });
  1600.         {# pc の auto-init: pw/pd/ph/pm と同じく p_c(matrix 派生)の length==1 or 全空で「指定なし」化.
  1601.            search_word(color) が空の「複合色」型商品で pc が空のまま放置されて
  1602.            「カラーを選択してください」固定になるバグの修正.
  1603.            search_word に登録された name があれば優先採用. #}
  1604.         {% if p_c and (p_c|length == 1 or p_c|join == "") %}
  1605.             pc = "指定なし";
  1606.             {% for pc_val in p_c %}{% if pc_val %} pc = "{{ pc_val }}"; {% endif %}{% endfor %}
  1607.             {% if color and color|length == 1 %}
  1608.                 {% for cc in color %}{% if cc and cc['name'] %} pc = "{{ cc['name'] }}"; {% endif %}{% endfor %}
  1609.             {% endif %}
  1610.         {% elseif color and color|length == 1 %}
  1611.             pc = "指定なし";
  1612.             {% for cc in color %}{% if cc and cc['name'] %} pc = "{{ cc['name'] }}"; {% endif %}{% endfor %}
  1613.         {% endif %}
  1614.         {% if p_w and (p_w|length == 1 or p_w|join == "") %}
  1615.             pw = "指定なし";
  1616.             {% for pw in p_w %}{% if pw %} pw = "{{ pw }}"; {% endif %}{% endfor %}
  1617.         {% endif %}
  1618.         {% if p_d and (p_d|length == 1 or p_d|join == "") %}
  1619.             pd = "指定なし";
  1620.             {% for pd in p_d %}{% if pd %} pd = "{{ pd }}"; {% endif %}{% endfor %}
  1621.         {% endif %}
  1622.         {% if p_h and (p_h|length == 1 or p_h|join == "") %}
  1623.             ph = "指定なし";
  1624.             {% for ph in p_h %}{% if ph %} ph = "{{ ph }}"; {% endif %}{% endfor %}
  1625.         {% endif %}
  1626.         {% if p_m and (p_m|length == 1 or p_m|join == "") %}
  1627.             pm = "指定なし";
  1628.             {% for pm in p_m %}{% if pm %} pm = "{{ pm }}"; {% endif %}{% endfor %}
  1629.         {% endif %}
  1630.         {# p_option1 / p_option2 の auto-init: length==1 or 全空で JS 変数を埋める #}
  1631.         {% if p_option1 and (p_option1|length == 1 or p_option1|join == "") %}
  1632.             option1 = "";
  1633.             {% for opt1 in p_option1 %}{% if opt1 %} option1 = "{{ opt1|e('js') }}"; {% endif %}{% endfor %}
  1634.         {% endif %}
  1635.         {% if p_option2 and (p_option2|length == 1 or p_option2|join == "") %}
  1636.             option2 = "";
  1637.             {% for opt2 in p_option2 %}{% if opt2 %} option2 = "{{ opt2|e('js') }}"; {% endif %}{% endfor %}
  1638.         {% endif %}
  1639.         // カラー radio が複数あるとき初期チェックが無いと「カラーを選択してください」固定になるので、
  1640.         // 何もチェックされていなければ「最初の radio」を選択する。
  1641.         // sale_type≠3 は name="color", sale_type=3 は name="color3".
  1642.         //
  1643.         // 注意:
  1644.         //   ・search_word(= radio の値)と pp.c(= matrix の色軸)は別の命名体系のケースがある
  1645.         //     (例 id=3353: radio="SM(スミ)" / pp.c="ステンカラー+セピアブラウン")
  1646.         //   ・pp.c に合わせて radio を選ぼうとしても文字列一致しないので無意味。
  1647.         //   ・単純に「先頭の radio」を選ぶ実装に戻し、マッチング側で命名体系違いを吸収する
  1648.         //     (pc が pp.c のどの値にもマッチしないときは色軸を wildcard 扱いにする)。
  1649.         //   ・.rp-section-label のテキストも忘れずに同期する(古い session 値が残ると
  1650.         //     "ステンカラー+セピアブラウン" のような表示と実際の radio が食い違う)。
  1651.         (function autoSelectFirstColor(){
  1652.             var groups = ['color', 'color3'];
  1653.             for (var gi = 0; gi < groups.length; gi++) {
  1654.                 var name = groups[gi];
  1655.                 var nodes = document.querySelectorAll('input[type="radio"][name="' + name + '"]');
  1656.                 if (nodes.length === 0) continue;
  1657.                 var anyChecked = false;
  1658.                 for (var i = 0; i < nodes.length; i++) {
  1659.                     if (nodes[i].checked) { anyChecked = true; break; }
  1660.                 }
  1661.                 if (anyChecked) continue;
  1662.                 var target = nodes[0];
  1663.                 target.checked = true;
  1664.                 pc = target.value;
  1665.                 // opt-btn の is-selected を付け替え
  1666.                 var lbl = target.closest('.opt-btn');
  1667.                 if (lbl) {
  1668.                     var sib = lbl.parentNode ? lbl.parentNode.querySelectorAll('.opt-btn') : [];
  1669.                     for (var k = 0; k < sib.length; k++) sib[k].classList.remove('is-selected');
  1670.                     lbl.classList.add('is-selected');
  1671.                 }
  1672.                 // 「カラー: <name>」表示の同期(古い mitsumori_json.pc が残らないように)
  1673.                 var grp = (lbl && lbl.closest('.form-group')) || (target.closest('.form-group'));
  1674.                 if (grp) {
  1675.                     var section = grp.querySelector('.rp-section-label');
  1676.                     if (section) {
  1677.                         var labelHead = section.textContent.split(':')[0].trim();
  1678.                         section.innerHTML = labelHead + ': <span>' + target.value + '</span>';
  1679.                     }
  1680.                 }
  1681.             }
  1682.         })();
  1683.         // option1 / option2 / pw / pd / ph / pm (matrix 軸の radio 群) も同様に
  1684.         // 「どれもチェックされていなければ先頭を選ぶ」を適用する.
  1685.         //   sale_type=2 の窓タイプ等で「初期表示時に一番初めの選択肢が選択されていない」事象を解消.
  1686.         (function autoSelectFirstMatrixAxis(){
  1687.             var axes = [
  1688.                 { name: 'pw',      jsVar: 'pw' },
  1689.                 { name: 'pd',      jsVar: 'pd' },
  1690.                 { name: 'ph',      jsVar: 'ph' },
  1691.                 { name: 'pm',      jsVar: 'pm' },
  1692.                 { name: 'glass_type', jsVar: 'pm' },
  1693.                 { name: 'option1', jsVar: 'option1' },
  1694.                 { name: 'option2', jsVar: 'option2' }
  1695.             ];
  1696.             for (var ai = 0; ai < axes.length; ai++) {
  1697.                 var ax = axes[ai];
  1698.                 var nodes = document.querySelectorAll('input[type="radio"][name="' + ax.name + '"]');
  1699.                 if (nodes.length === 0) continue;
  1700.                 var anyChecked = false;
  1701.                 for (var i = 0; i < nodes.length; i++) {
  1702.                     if (nodes[i].checked) { anyChecked = true; break; }
  1703.                 }
  1704.                 if (anyChecked) continue;
  1705.                 var target = nodes[0];
  1706.                 target.checked = true;
  1707.                 // グローバル JS 変数も埋める
  1708.                 if (ax.jsVar === 'pw') pw = target.value;
  1709.                 else if (ax.jsVar === 'pd') pd = target.value;
  1710.                 else if (ax.jsVar === 'ph') ph = target.value;
  1711.                 else if (ax.jsVar === 'pm') pm = target.value;
  1712.                 else if (ax.jsVar === 'option1') option1 = target.value;
  1713.                 else if (ax.jsVar === 'option2') option2 = target.value;
  1714.                 var lbl = target.closest('.opt-btn');
  1715.                 if (lbl) {
  1716.                     var sib = lbl.parentNode ? lbl.parentNode.querySelectorAll('.opt-btn') : [];
  1717.                     for (var k = 0; k < sib.length; k++) sib[k].classList.remove('is-selected');
  1718.                     lbl.classList.add('is-selected');
  1719.                 }
  1720.                 var grp = (lbl && lbl.closest('.form-group')) || (target.closest('.form-group'));
  1721.                 if (grp) {
  1722.                     var section = grp.querySelector('.rp-section-label');
  1723.                     if (section) {
  1724.                         var labelHead = section.textContent.split(':')[0].trim();
  1725.                         section.innerHTML = labelHead + ': <span>' + target.value + '</span>';
  1726.                     }
  1727.                 }
  1728.             }
  1729.         })();
  1730.         // ページ読み込み時: 見積金額が「合計」になっているため、カート数量は基本1
  1731.         // sale_type=9(商品のみ購入)だけ通常 EC として数量を引き継ぐ
  1732.         (function initQuantityByType(){
  1733.             var saleType = {{ ProductClass.SaleType.id }};
  1734.             if (saleType == 9 && $('#quantity_only').length) {
  1735.                 $('#quantity').val(parseInt($('#quantity_only').val()) || 1);
  1736.             } else {
  1737.                 $('#quantity').val(1);
  1738.                 $('input[name="quantity"]').val(1);
  1739.             }
  1740.         })();
  1741.         // type → ラベルのプレフィックス文字列
  1742.         // option1/option2 のラベルは category 依存 (rd: ランマ/タイプ, sh: サイズプリセット/駆動方式 等).
  1743.         // PHP から渡された option1_label / option2_label を埋め込み、JS 側でラベル更新に使う.
  1744.         var optLabelMap = {pc:'カラー', pw:'幅', pd:'奥行き', ph:'高さ', pm:'素材',
  1745.                            option1: '{{ option1_label|default('オプション1')|e('js') }}',
  1746.                            option2: '{{ option2_label|default('オプション2')|e('js') }}'};
  1747.         // type → input[name]
  1748.         var optNameMap  = {pc:'color', pw:'pw', pd:'pd', ph:'ph', pm:'pm',
  1749.                            option1: 'option1', option2: 'option2'};
  1750.         // opt-btn用: 値を直接受け取るラッパー
  1751.         function mitsumori_simulation_val(type, value) {
  1752.             if (type === 'pc') pc = value;
  1753.             if (type === 'pw') pw = value;
  1754.             if (type === 'pd') pd = value;
  1755.             if (type === 'ph') ph = value;
  1756.             if (type === 'pm') pm = value;
  1757.             if (type === 'option1') option1 = value;
  1758.             if (type === 'option2') option2 = value;
  1759.             // is-selected クラスを同グループ内で付け替え
  1760.             var inputName = optNameMap[type];
  1761.             if (inputName) {
  1762.                 var $btns = $('input[name="' + inputName + '"]').closest('.opt-btn');
  1763.                 $btns.removeClass('is-selected');
  1764.                 $btns.filter(function(){
  1765.                     return $(this).find('input').val() === value;
  1766.                 }).addClass('is-selected');
  1767.             }
  1768.             // ラベル行の選択値テキストを更新(例: 「カラー: ブラック」)
  1769.             var labelPrefix = optLabelMap[type];
  1770.             if (labelPrefix) {
  1771.                 // 対象のrp-section-labelを特定(input[name]を含む親を遡る)
  1772.                 var $group = $('input[name="' + inputName + '"]').first().closest('.form-group');
  1773.                 var $label = $group.find('.rp-section-label');
  1774.                 $label.html(labelPrefix + ': <span>' + value + '</span>');
  1775.             }
  1776.             // simulation本体を呼ぶ(value_idは空でOK、グローバル変数を使う)
  1777.             mitsumori_simulation('', '');
  1778.         }
  1779.         mitsumori_simulation("","");
  1780.         // ボタン群: 親幅を超える、または3行以上になる場合は is-scroll で1行横スクロール化
  1781.         function applyBtnGroupScroll() {
  1782.             $('.rp-btn-group, .opt-btn-group').each(function() {
  1783.                 var $group = $(this);
  1784.                 $group.removeClass('is-scroll');
  1785.                 var $items = $group.children();
  1786.                 if ($items.length === 0) return;
  1787.                 var parentWidth = $group.parent().width() || $group.width();
  1788.                 var totalWidth = 0;
  1789.                 var gap = parseInt($group.css('gap'), 10) || 8;
  1790.                 $items.each(function() {
  1791.                     totalWidth += this.offsetWidth + gap;
  1792.                 });
  1793.                 // 単一ボタンが親幅を超える、もしくは合計幅が親幅を超える → 横スクロール化
  1794.                 var anyTooWide = false;
  1795.                 $items.each(function() {
  1796.                     if (this.offsetWidth > parentWidth) { anyTooWide = true; return false; }
  1797.                 });
  1798.                 // 折り返し時の行数も計測
  1799.                 var tops = {};
  1800.                 $items.each(function() { tops[this.offsetTop] = true; });
  1801.                 var rowCount = Object.keys(tops).length;
  1802.                 if (anyTooWide || totalWidth > parentWidth * 2 || rowCount >= 3) {
  1803.                     $group.addClass('is-scroll');
  1804.                 }
  1805.             });
  1806.         }
  1807.         applyBtnGroupScroll();
  1808.         $(window).on('resize', function() {
  1809.             clearTimeout(window._btnScrollTimer);
  1810.             window._btnScrollTimer = setTimeout(applyBtnGroupScroll, 150);
  1811.         });
  1812.         // onload: 見積金額が確定している場合は「工事費込み価格」表示を一致させる
  1813.         (function syncPrice02Display() {
  1814.             var goukeiEl = document.getElementById('mitsumori_goukei');
  1815.             var displayEl = document.getElementById('price02-display');
  1816.             if (!goukeiEl || !displayEl) return;
  1817.             var goukeiText = goukeiEl.textContent.trim();
  1818.             // ---円(未確定)の場合は書き換えない
  1819.             if (goukeiText && goukeiText !== '---円') {
  1820.                 displayEl.textContent = goukeiText;
  1821.             }
  1822.             // 以降の変更にも追従: mitsumori_goukei を監視
  1823.             new MutationObserver(function() {
  1824.                 var text = goukeiEl.textContent.trim();
  1825.                 if (text && text !== '---円') {
  1826.                     displayEl.textContent = text;
  1827.                 }
  1828.             }).observe(goukeiEl, { childList: true, subtree: true, characterData: true });
  1829.         })();
  1830.         function contact_form(product_id){
  1831.             $('#form1').attr('action', '{{ url('contact', {product:Product.id}) }}');
  1832.             $('#form1').submit();
  1833.         }
  1834.         // maisu / madoset は下部の新しい関数定義を使用
  1835.         function heibei(bei){
  1836.             $('#heibei').val(parseInt($('#heibei').val()) + bei);
  1837.             if(parseInt($('#heibei').val()) < 1){ $('#heibei').val(1); }
  1838.             if(parseInt($('#heibei').val()) > 100){ $('#heibei').val(100); }
  1839.             // goukei に既に枚数を含むため、カート数量は1で固定
  1840.             $('#quantity').val(1);
  1841.             mitsumori_simulation('heibei','heibei');
  1842.         }
  1843.         function daisu(dai){
  1844.             $('#daisu').val(parseInt($('#daisu').val()) + dai);
  1845.             if(parseInt($('#daisu').val()) < 1){ $('#daisu').val(1); }
  1846.             if(parseInt($('#daisu').val()) > 10){ $('#daisu').val(10); }
  1847.             $('#quantity').val(1);
  1848.             mitsumori_simulation('daisu','daisu');
  1849.         }
  1850.         // sale_type=7(数量買い・基本工事費固定)用:個数入力
  1851.         function suuryou(n){
  1852.             $('#suuryou').val(parseInt($('#suuryou').val()) + n);
  1853.             if(parseInt($('#suuryou').val()) < 1){ $('#suuryou').val(1); }
  1854.             if(parseInt($('#suuryou').val()) > 100){ $('#suuryou').val(100); }
  1855.             $('#quantity').val(1);
  1856.             mitsumori_simulation('suuryou','suuryou');
  1857.         }
  1858.         function maisu(mai){
  1859.             $('#maisu').val(parseInt($('#maisu').val()) + mai);
  1860.             // sale_type=4 (フェンス) は3枚未満不可、6 (芝生) は1枚から
  1861.             var minMai = (SALE_TYPE_ID == 4) ? 3 : 1;
  1862.             if(parseInt($('#maisu').val()) < minMai){ $('#maisu').val(minMai); }
  1863.             if(parseInt($('#maisu').val()) > 100){ $('#maisu').val(100); }
  1864.             $('#quantity').val(1);
  1865.             mitsumori_simulation('maisu','maisu');
  1866.         }
  1867.         // タイプ2: セット数プルダウン連動
  1868.         function madosetSelect(val){
  1869.             var v = parseInt(val);
  1870.             if(v < 1) v = 1;
  1871.             if(v > 20) v = 20;
  1872.             $('#set_count').val(v);
  1873.             $('#quantity').val(1);
  1874.             $('input[name="quantity"]').val(1);
  1875.             mitsumori_simulation('set','set_count');
  1876.         }
  1877.         // タイプ2: ±ボタン版(後方互換)
  1878.         function madoset(mai){
  1879.             var current = parseInt($('#set_count').val()) || 1;
  1880.             var next = current + mai;
  1881.             if(next < 1) next = 1;
  1882.             if(next > 20) next = 20;
  1883.             $('#set_count').val(next);
  1884.             madosetSelect(next);
  1885.         }
  1886.         // タイプ5: ステップ・フェンス選択値を mitsumori_json に保存するためのグローバル変数
  1887.         var deck_step = "{% if mitsumori_json and mitsumori_json.deck_step is defined %}{{ mitsumori_json.deck_step|default('不要') }}{% else %}不要{% endif %}";
  1888.         var deck_fence = "{% if mitsumori_json and mitsumori_json.deck_fence is defined %}{{ mitsumori_json.deck_fence|default('不要') }}{% else %}不要{% endif %}";
  1889.         // PDF出力: モーダルの mitsumori_json をフォームに同期してから送信
  1890.         function syncPdfJson(){
  1891.             var jsonVal = $('#mitsumori_json').val();
  1892.             $('#pdf_mitsumori_json').val(jsonVal);
  1893.         }
  1894.         // タイプ9: 商品のみ購入
  1895.         function quantityOnly(val){
  1896.             var current = parseInt($('#quantity_only').val()) || 1;
  1897.             var next = current + val;
  1898.             if(next < 1) next = 1;
  1899.             $('#quantity_only').val(next);
  1900.             $('#quantity').val(next);
  1901.         }
  1902.         // ===== スマホ用下部固定バーへの金額同期 =====
  1903.         // mitsumori_message と mitsumori_goukei を監視して下部バーを更新
  1904.         (function() {
  1905.             var msgTarget   = document.getElementById('mitsumori_message');
  1906.             var goukeiTarget = document.getElementById('mitsumori_goukei');
  1907.             var spPrice     = document.getElementById('sp-mitsumori-price');
  1908.             var spBtn       = document.querySelector('#sp-mitsumori-bar .sp-bar__btn');
  1909.             if (!spPrice || !spBtn) return;
  1910.             function syncBar() {
  1911.                 var msg    = msgTarget ? msgTarget.textContent : '';
  1912.                 var goukei = goukeiTarget ? goukeiTarget.textContent : '---円';
  1913.                 // メッセージが「〇〇を選択してください」の場合はメッセージを表示しボタンを非表示
  1914.                 if (msg.indexOf('選択してください') !== -1) {
  1915.                     spPrice.textContent = msg;
  1916.                     spPrice.style.fontSize = '13px';
  1917.                     spPrice.style.color    = '#888';
  1918.                     spBtn.style.display    = 'none';
  1919.                 } else {
  1920.                     // 価格確定時はボタンを表示
  1921.                     spPrice.textContent = goukei;
  1922.                     spPrice.style.fontSize = '18px';
  1923.                     spPrice.style.color    = '#c00';
  1924.                     spBtn.style.display    = 'block';
  1925.                 }
  1926.             }
  1927.             // 初期値を同期
  1928.             syncBar();
  1929.             // mitsumori_message の変化を監視
  1930.             if (msgTarget) {
  1931.                 new MutationObserver(syncBar).observe(
  1932.                     msgTarget, { childList: true, subtree: true, characterData: true }
  1933.                 );
  1934.             }
  1935.             // mitsumori_goukei の変化も監視
  1936.             if (goukeiTarget) {
  1937.                 new MutationObserver(syncBar).observe(
  1938.                     goukeiTarget, { childList: true, subtree: true, characterData: true }
  1939.                 );
  1940.             }
  1941.         })();
  1942.         // ===== 現在のお見積り額: 折りたたみトグルボタンのテキスト切り替え =====
  1943.         (function() {
  1944.             var card = document.querySelector('.mitsumori-card-pc');
  1945.             var btn  = document.querySelector('.btn-mitsumori-toggle .toggle-icon');
  1946.             if (!card || !btn) return;
  1947.             // MutationObserverでcollapsed-cardクラスの変化を監視
  1948.             new MutationObserver(function() {
  1949.                 if (card.classList.contains('collapsed-card')) {
  1950.                     btn.textContent = '▼ 詳細';
  1951.                 } else {
  1952.                     btn.textContent = '▲ 閉じる';
  1953.                 }
  1954.             }).observe(card, { attributes: true, attributeFilter: ['class'] });
  1955.         })();
  1956.         // ===== エリア案内: スマホのみタップで展開 =====
  1957.         (function() {
  1958.             var notice = document.querySelector('.ec-areaNotice');
  1959.             if (!notice) return;
  1960.             notice.addEventListener('click', function(e) {
  1961.                 if (window.innerWidth > 767) return;
  1962.                 // リンククリック時は展開/折りたたみせずリンク遷移
  1963.                 if (e.target.tagName === 'A') return;
  1964.                 notice.classList.toggle('is-open');
  1965.             });
  1966.         })();
  1967.     </script>
  1968.     <script type="application/ld+json">
  1969.     {
  1970.         "@context": "https://schema.org/",
  1971.         "@type": "Product",
  1972.         "name": "{{ Product.name }}",
  1973.         "image": [
  1974.             {% for img in Product.ProductImage %}
  1975.                 "{{ app.request.schemeAndHttpHost }}{{ asset(img, 'save_image') }}"{% if not loop.last %},{% endif %}
  1976.             {% else %}
  1977.                 "{{ app.request.schemeAndHttpHost }}{{ asset(''|no_image_product, 'save_image') }}"
  1978.             {% endfor %}
  1979.         ],
  1980.         "description": "{{ Product.description_list | default(Product.description_detail) | replace({'\n': '', '\r': ''}) | slice(0,300) }}",
  1981.         {% if Product.code_min %}
  1982.         "sku": "{{ Product.code_min }}",
  1983.         {% endif %}
  1984.         "offers": {
  1985.             "@type": "Offer",
  1986.             "url": "{{ url('product_detail', {'id': Product.id}) }}",
  1987.             "priceCurrency": "{{ eccube_config.currency }}",
  1988.             "price": {{ Product.getPrice02IncTaxMin ? Product.getPrice02IncTaxMin : 0}},
  1989.             "availability": "{{ Product.stock_find ? "InStock" : "OutOfStock" }}"
  1990.         }
  1991.     }
  1992.     </script>
  1993. {% endblock %}
  1994. {% block main %}
  1995.     {# option1 / option2 ラベルをカテゴリ別に決定 (sh=31, rd=43, mo=15) - block scope のため main 側でも再定義 #}
  1996.     {% set option1_label = 'オプション1' %}
  1997.     {% set option2_label = 'オプション2' %}
  1998.     {% if Product.ProductCategories is not empty %}
  1999.         {% for pcat in Product.ProductCategories %}
  2000.             {% if pcat.category_id == 31 %}{% set option1_label = 'サイズプリセット' %}{% set option2_label = '駆動方式' %}{% endif %}
  2001.             {% if pcat.category_id == 43 %}{% set option1_label = 'ランマ' %}{% set option2_label = 'タイプ' %}{% endif %}
  2002.             {% if pcat.category_id == 15 %}{% set option1_label = '棚タイプ' %}{% endif %}
  2003.             {% if pcat.category_id == 17 %}{% set option1_label = '窓タイプ' %}{% endif %}
  2004.         {% endfor %}
  2005.     {% endif %}
  2006.     <div class="ec-productRole" style="margin-top:20px;">
  2007.         <div class="ec-grid2">
  2008.             <div class="ec-grid2__cell">
  2009.                 <div class="ec-sliderItemRole">
  2010.                     {# 商品名 + ブランド名 + SNSシェア #}
  2011.                     <div class="ec-productRole__title">
  2012.                         <div class="ec-productRole__titleRow">
  2013.                             <h2 class="ec-headingTitle">{{ Product.name }}</h2>
  2014.                             <div class="ec-share-inline">
  2015.                                 <a href="https://twitter.com/share?url={{ app.request.uri|url_encode }}&text={{ Product.name|url_encode }}"
  2016.                                    class="share-twitter" target="_blank" rel="noreferrer noopener" title="Xでシェア">
  2017.                                     <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>
  2018.                                 </a>
  2019.                                 <a href="https://www.instagram.com/" class="share-facebook" target="_blank" rel="noreferrer noopener" title="Instagram">
  2020.                                     <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>
  2021.                                 </a>
  2022.                                 <a href="https://social-plugins.line.me/lineit/share?url={{ app.request.uri|url_encode }}"
  2023.                                    class="share-line" target="_blank" rel="noreferrer noopener" title="LINEでシェア">
  2024.                                     <i class="fab fa-line"></i>
  2025.                                 </a>
  2026.                             </div>
  2027.                         </div>
  2028.                     </div>
  2029.                     {% if BaseInfo.option_favorite_product %}
  2030.                      <div style="position:relative;top: 20px;left: 10px;z-index:100;">
  2031.                         {% if is_favorite == false %}
  2032.                         <form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
  2033.                            <button type="submit" id="favorite" class="favorite">&#9825;</button>
  2034.                         </form>
  2035.                         {% else %}
  2036.                         <form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
  2037.                            <button type="submit" id="favorite" class="favorite" style="color:red;">&#9829;</button>
  2038.                         </form>
  2039.                         {% endif %}
  2040.                      </div>
  2041.                     {% endif %}
  2042.                     <div class="item_visual">
  2043.                         {% for ProductImage in Product.ProductImage %}
  2044.                             <div class="slide-item">
  2045.                                 <a class="js-zoom" href="{{ asset(ProductImage, 'save_image') }}" aria-label="{{ loop.first ? Product.name : '' }}">
  2046.                                     <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 %}>
  2047.                                 </a>
  2048.                             </div>
  2049.                         {% else %}
  2050.                             <div class="slide-item"><img src="{{ asset(''|no_image_product, 'save_image') }}" alt="{{ Product.name }}" width="550" height="550" style="max-height: 400px;"></div>
  2051.                         {% endfor %}
  2052.                     </div>
  2053.                     <div class="item_nav">
  2054.                         {% for ProductImage in Product.ProductImage %}
  2055.                             <div class="slideThumb" data-index="{{ loop.index0 }}"><img src="{{ asset(ProductImage, 'save_image') }}" alt="" width="80" height="80" loading="lazy"></div>
  2056.                         {% endfor %}
  2057.                     </div>
  2058.                 </div>
  2059.                     {# ===== 施工エリア案内(見積シミュレーションの下)===== #}
  2060.                     <div class="ec-areaNotice" style="margin-top:16px;margin-right:10px;">
  2061.                         <div class="ec-areaNotice__inner">
  2062.                             <div class="ec-areaNotice__icon">📍</div>
  2063.                             <div class="ec-areaNotice__body">
  2064.                                 <p class="ec-areaNotice__title">施工対応エリアについて</p>
  2065.                                 <div class="ec-areaNotice__detail">
  2066.                                     <p class="ec-areaNotice__text">
  2067.                                         当店の施工サービスは、<strong>山梨県全域</strong>および<br>
  2068.                                         <strong>諏訪エリア(諏訪市・岡谷市・茅野市・諏訪郡)</strong>を対象としております。<br>
  2069.                                         上記エリア外のお客様には、商品のみのご購入が可能でございます。<br>
  2070.                                         ご不明な点がございましたら、お気軽にお問い合わせください。
  2071.                                     </p>
  2072.                                     <a class="ec-areaNotice__link" href="{{ url('contact') }}">エリア外のお客様・ご相談はこちら →</a>
  2073.                                 </div>
  2074.                             </div>
  2075.                         </div>
  2076.                     </div>
  2077.             </div>
  2078.             <div class="ec-grid2__cell2">
  2079.                 <div class="ec-productRole__profile" >
  2080.                     {# 関連カテゴリ (DIY=21 / 石材=28 / 照明=44 は非表示要件のため除外) #}
  2081.                     {% set hidden_cat_ids = [21, 28, 44] %}
  2082.                     {% if Product.ProductCategories is not empty %}
  2083.                         <div class="ec-productRole__category" style="padding:10px 0;">
  2084.                             {% for ProductCategory in Product.ProductCategories %}
  2085.                                 {% if ProductCategory.Category.id not in hidden_cat_ids %}
  2086.                                 <ul>
  2087.                                     <li>
  2088.                                         {% for Category in ProductCategory.Category.path %}
  2089.                                             <a href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a> {%- if loop.last == false %}
  2090.                                             <span>></span>{% endif -%}
  2091.                                         {% endfor %}
  2092.                                     </li>
  2093.                                 </ul>
  2094.                                 {% endif %}
  2095.                             {% endfor %}
  2096.                         </div>
  2097.                     {% endif %}
  2098.                     {# 販売価格 #}
  2099.                     <div class="ec-productRole__price">
  2100.                         <span style="color:black;font-size:15px;">工事費込み価格</span>
  2101.                         {% if Product.hasProductClass -%}
  2102.                             {% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
  2103.                                 <div class="ec-price">
  2104.                                     <span id="price02-display" class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }}</span>
  2105.                                     <span class="ec-price__tax">({{ '税込'|trans }})~</span>
  2106.                                 </div>
  2107.                             {% else %}
  2108.                                 <div class="ec-price">
  2109.                                     <span id="price02-display" class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}</span>
  2110.                                     <span class="ec-price__tax">({{ '税込'|trans }})</span>
  2111.                                 </div>
  2112.                             {% endif %}
  2113.                         {% else %}
  2114.                             <div class="ec-price">
  2115.                                 <span id="price02-display" class="ec-price__price">{{ Product.getPrice02IncTaxMin|price }}</span>
  2116.                                     <span class="ec-price__tax">({{ '税込'|trans }})~</span>
  2117.                             </div>
  2118.                         {% endif %}
  2119.                     </div>
  2120.                     {# タグ #}
  2121.                     <ul class="ec-productRole__tags">
  2122.                         {% for Tag in Product.Tags %}
  2123.                             <li class="ec-productRole__tag tag_{{ Tag.id }}">{{ Tag }}</li>
  2124.                         {% endfor %}
  2125.                     </ul>
  2126.                     {# 商品コード #}
  2127.                     {% if Product.code_min is not empty %}
  2128.                         <div class="ec-productRole__code">
  2129.                             {{ '商品コード'|trans }}: <span class="product-code-default">{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</span>
  2130.                         </div>
  2131.                     {% endif %}
  2132.                     <div class="ec-productRole__description">
  2133.                         <div class="ec-rectHeading">
  2134.                             <h4>製品情報</h4>
  2135.                         </div>
  2136.                         {{ Product.sales_infomation|raw|nl2br }}
  2137.                     </div>
  2138.                     <div class="card card-danger" style="clear:both;margin:1px;">
  2139.                       <div class="card-header">
  2140.                         <h3 class="card-title">見積シミュレーション</h3>
  2141.                       </div>
  2142.                       <div class="card-body p-2">
  2143.                         {% set related_image = getProduct_field(Product.id,"related_image") %}
  2144.                         {# related_image は配列: ["1段目画像あり","2段目画像あり","3段目画像あり"] のうち該当するものが格納 #}
  2145.                         {% set img1 = related_image and ("1段目画像あり" in related_image) %}
  2146.                         {% set img2 = related_image and ("2段目画像あり" in related_image) %}
  2147.                         {% set img3 = related_image and ("3段目画像あり" in related_image) %}
  2148.                         {% set img4 = related_image and ("4段目画像あり" in related_image) %}
  2149.                         {% set type1 = getProduct_field(Product.id,"related_name1") %}
  2150.                         {% set type2 = getProduct_field(Product.id,"related_name2") %}
  2151.                         {% set type3 = getProduct_field(Product.id,"related_name3") %}
  2152.                         {% set type4 = getProduct_field(Product.id,"related_name4") %}
  2153.                         {% set hasRelated = (type1 and related_product1 and related_product1|length)
  2154.                                          or (type2 and related_product2 and related_product2|length)
  2155.                                          or (type3 and related_product3 and related_product3|length)
  2156.                                          or (type4 and related_product4 and related_product4|length) %}
  2157.                         {% if hasRelated %}
  2158.                             <div class="row" style="border-bottom:1px solid rgba(0,0,0,.125)"><label class="col-12 col-form-label">この商品のタイプを選択してください。</label></div>
  2159.                         {% endif %}
  2160.                         {# ===== 1段目 ===== #}
  2161.                         {% if type1 and related_product1 and related_product1|length %}
  2162.                         <div class="form-group mt-3 pb-3" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2163.                           <div class="rp-section-label">{{ type1 }}{% if img1 and base_select1 %}: <span>{{ base_select1 }}</span>{% endif %}</div>
  2164.                           {% if img1 %}
  2165.                             {# --- 画像付きカード --- #}
  2166.                             <div class="rp-card-group">
  2167.                               {% for rp_id, rp_name in related_product1 %}
  2168.                                 <label class="rp-card{% if base_select1 == rp_name %} is-selected{% endif %}"
  2169.                                        onclick="location.href='/products/detail/{{ rp_id }}';">
  2170.                                   <input type="radio" name="rp1" value="{{ rp_name }}"
  2171.                                          {% if base_select1 == rp_name %}checked{% endif %}>
  2172.                                   <img class="rp-card__image"
  2173.                                        src="{{ asset('p' ~ rp_id ~ '_cp_1.jpg', 'save_image') }}"
  2174.                                        alt="{{ rp_name }}"
  2175.                                        width="120" height="120" loading="lazy"
  2176.                                        onerror="this.style.display='none';this.nextElementSibling.style.display='flex';">
  2177.                                   <div class="rp-card__placeholder" style="display:none;">📦</div>
  2178.                                   <span class="rp-card__name">{{ rp_name }}</span>
  2179.                                 </label>
  2180.                               {% endfor %}
  2181.                             </div>
  2182.                           {% else %}
  2183.                             {# --- ボタン式ラジオ --- #}
  2184.                             <div class="rp-btn-group">
  2185.                               {% for rp_id, rp_name in related_product1 %}
  2186.                                 <label class="rp-btn{% if base_select1 == rp_name %} is-selected{% endif %}"
  2187.                                        onclick="location.href='/products/detail/{{ rp_id }}';">
  2188.                                   <input type="radio" name="rp1" value="{{ rp_name }}"
  2189.                                          {% if base_select1 == rp_name %}checked{% endif %}>
  2190.                                   {{ rp_name }}
  2191.                                 </label>
  2192.                               {% endfor %}
  2193.                             </div>
  2194.                           {% endif %}
  2195.                         </div>
  2196.                         {% endif %}
  2197.                         {# ===== 2段目 ===== #}
  2198.                         {% if type2 and related_product2 and related_product2|length %}
  2199.                         <div class="form-group mt-3 pb-3" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2200.                           <div class="rp-section-label">{{ type2 }}{% if img2 and base_select2 %}: <span>{{ base_select2 }}</span>{% endif %}</div>
  2201.                           {% if img2 %}
  2202.                             <div class="rp-card-group">
  2203.                               {% for rp_id, rp_name in related_product2 %}
  2204.                                 <label class="rp-card{% if base_select2 == rp_name %} is-selected{% endif %}"
  2205.                                        onclick="location.href='/products/detail/{{ rp_id }}';">
  2206.                                   <input type="radio" name="rp2" value="{{ rp_name }}"
  2207.                                          {% if base_select2 == rp_name %}checked{% endif %}>
  2208.                                   <img class="rp-card__image"
  2209.                                        src="{{ asset('p' ~ rp_id ~ '_cp_1.jpg', 'save_image') }}"
  2210.                                        alt="{{ rp_name }}"
  2211.                                        width="120" height="120" loading="lazy"
  2212.                                        onerror="this.style.display='none';this.nextElementSibling.style.display='flex';">
  2213.                                   <div class="rp-card__placeholder" style="display:none;">📦</div>
  2214.                                   <span class="rp-card__name">{{ rp_name }}</span>
  2215.                                 </label>
  2216.                               {% endfor %}
  2217.                             </div>
  2218.                           {% else %}
  2219.                             <div class="rp-btn-group">
  2220.                               {% for rp_id, rp_name in related_product2 %}
  2221.                                 <label class="rp-btn{% if base_select2 == rp_name %} is-selected{% endif %}"
  2222.                                        onclick="location.href='/products/detail/{{ rp_id }}';">
  2223.                                   <input type="radio" name="rp2" value="{{ rp_name }}"
  2224.                                          {% if base_select2 == rp_name %}checked{% endif %}>
  2225.                                   {{ rp_name }}
  2226.                                 </label>
  2227.                               {% endfor %}
  2228.                             </div>
  2229.                           {% endif %}
  2230.                         </div>
  2231.                         {% endif %}
  2232.                         {# ===== 3段目 ===== #}
  2233.                         {% if type3 and related_product3 and related_product3|length %}
  2234.                         <div class="form-group mt-3 pb-3" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2235.                           <div class="rp-section-label">{{ type3 }}{% if img3 and base_select3 %}: <span>{{ base_select3 }}</span>{% endif %}</div>
  2236.                           {% if img3 %}
  2237.                             <div class="rp-card-group">
  2238.                               {% for rp_id, rp_name in related_product3 %}
  2239.                                 <label class="rp-card{% if base_select3 == rp_name %} is-selected{% endif %}"
  2240.                                        onclick="location.href='/products/detail/{{ rp_id }}';">
  2241.                                   <input type="radio" name="rp3" value="{{ rp_name }}"
  2242.                                          {% if base_select3 == rp_name %}checked{% endif %}>
  2243.                                   <img class="rp-card__image"
  2244.                                        src="{{ asset('p' ~ rp_id ~ '_cp_1.jpg', 'save_image') }}"
  2245.                                        alt="{{ rp_name }}"
  2246.                                        width="120" height="120" loading="lazy"
  2247.                                        onerror="this.style.display='none';this.nextElementSibling.style.display='flex';">
  2248.                                   <div class="rp-card__placeholder" style="display:none;">📦</div>
  2249.                                   <span class="rp-card__name">{{ rp_name }}</span>
  2250.                                 </label>
  2251.                               {% endfor %}
  2252.                             </div>
  2253.                           {% else %}
  2254.                             <div class="rp-btn-group">
  2255.                               {% for rp_id, rp_name in related_product3 %}
  2256.                                 <label class="rp-btn{% if base_select3 == rp_name %} is-selected{% endif %}"
  2257.                                        onclick="location.href='/products/detail/{{ rp_id }}';">
  2258.                                   <input type="radio" name="rp3" value="{{ rp_name }}"
  2259.                                          {% if base_select3 == rp_name %}checked{% endif %}>
  2260.                                   {{ rp_name }}
  2261.                                 </label>
  2262.                               {% endfor %}
  2263.                             </div>
  2264.                           {% endif %}
  2265.                         </div>
  2266.                         {% endif %}
  2267.                         {# ===== 4段目 ===== #}
  2268.                         {% if type4 and related_product4 and related_product4|length %}
  2269.                         <div class="form-group mt-3 pb-3" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2270.                           <div class="rp-section-label">{{ type4 }}{% if img4 and base_select4 %}: <span>{{ base_select4 }}</span>{% endif %}</div>
  2271.                           {% if img4 %}
  2272.                             {# --- 画像付きカード --- #}
  2273.                             <div class="rp-card-group">
  2274.                               {% for rp_id, rp_name in related_product4 %}
  2275.                                 <label class="rp-card{% if base_select4 == rp_name %} is-selected{% endif %}"
  2276.                                        onclick="location.href='/products/detail/{{ rp_id }}';">
  2277.                                   <input type="radio" name="rp4" value="{{ rp_name }}"
  2278.                                          {% if base_select4 == rp_name %}checked{% endif %}>
  2279.                                   <img class="rp-card__image"
  2280.                                        src="{{ asset('p' ~ rp_id ~ '_cp_1.jpg', 'save_image') }}"
  2281.                                        alt="{{ rp_name }}" width="120" height="120" loading="lazy">
  2282.                                   <span class="rp-card__label">{{ rp_name }}</span>
  2283.                                 </label>
  2284.                               {% endfor %}
  2285.                             </div>
  2286.                           {% else %}
  2287.                             {# --- ボタン式ラジオ --- #}
  2288.                             <div class="rp-btn-group">
  2289.                               {% for rp_id, rp_name in related_product4 %}
  2290.                                 <label class="rp-btn{% if base_select4 == rp_name %} is-selected{% endif %}"
  2291.                                        onclick="location.href='/products/detail/{{ rp_id }}';">
  2292.                                   <input type="radio" name="rp4" value="{{ rp_name }}"
  2293.                                          {% if base_select4 == rp_name %}checked{% endif %}>
  2294.                                   {{ rp_name }}
  2295.                                 </label>
  2296.                               {% endfor %}
  2297.                             </div>
  2298.                           {% endif %}
  2299.                         </div>
  2300.                         {% endif %}
  2301.                         {# ガレージ等で全オプション空のときに見出しのみ表示される事象を回避.
  2302.                            色 / 寸法 / 素材 / option1/2 / op_data いずれかに「描画される」要素がある場合のみ
  2303.                            「この商品のオプションを選択してください。」見出しを表示する.
  2304.                            op_data は cg=9 で「残土」 / gs=27 で「撤去」「残土」を後段ループで
  2305.                            hide するため、単純な op|length > 0 では「見出しだけ残る」事象が
  2306.                            wh / cg の一部商品で発生していた. 描画される entry を事前カウントする. #}
  2307.                         {% set is_gs_h = false %}
  2308.                         {% set is_cg_h = false %}
  2309.                         {% if Product.ProductCategories is not empty %}
  2310.                             {% for pc_h in Product.ProductCategories %}
  2311.                                 {% if pc_h.category_id == 27 %}{% set is_gs_h = true %}{% endif %}
  2312.                                 {% if pc_h.category_id == 9  %}{% set is_cg_h = true %}{% endif %}
  2313.                             {% endfor %}
  2314.                         {% endif %}
  2315.                         {% set visible_op_count = 0 %}
  2316.                         {% if op and op|length %}
  2317.                             {% for opi in op %}
  2318.                                 {% if opi['name'] %}
  2319.                                     {% set _hide_h = false %}
  2320.                                     {% if is_gs_h and (opi['name'] matches '/撤去/' or opi['name'] matches '/残土/') %}{% set _hide_h = true %}{% endif %}
  2321.                                     {% if is_cg_h and opi['name'] matches '/残土/' %}{% set _hide_h = true %}{% endif %}
  2322.                                     {% if not _hide_h %}{% set visible_op_count = visible_op_count + 1 %}{% endif %}
  2323.                                 {% endif %}
  2324.                             {% endfor %}
  2325.                         {% endif %}
  2326.                         {% set has_any_option =
  2327.                             (color and color|length and ProductClass.SaleType.id != 3)
  2328.                             or (p_w and p_w|length and p_w|join != "")
  2329.                             or (p_d and p_d|length and p_d|join != "")
  2330.                             or (p_h and p_h|length and p_h|join != "")
  2331.                             or (p_m and p_m|length and p_m|join != "")
  2332.                             or (p_option1 and p_option1|length and p_option1|join != "")
  2333.                             or (p_option2 and p_option2|length and p_option2|join != "")
  2334.                             or visible_op_count > 0
  2335.                             or ProductClass.SaleType.id in [2, 5, 6, 7, 9]
  2336.                         %}
  2337.                         {% if has_any_option %}
  2338.                         <div class="row" style="border-bottom:1px solid rgba(0,0,0,.125)"><label class="col-12 col-form-label">この商品のオプションを選択してください。</label></div>
  2339.                         {% endif %}
  2340.                         {% if color and color|length and ProductClass.SaleType.id != 3 %}
  2341.                         <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2342.                           <div class="rp-section-label">カラー{% if mitsumori_json and mitsumori_json.pc %}: <span>{{ mitsumori_json.pc }}</span>{% endif %}</div>
  2343.                           <div class="opt-btn-group">
  2344.                             {% set idx = 0 %}
  2345.                             {% for cc in color %}{% if cc and cc['name'] %}{% set idx = idx + 1 %}
  2346.                               {% set has_img = cc['img'] is defined and cc['img'] is not empty %}
  2347.                               <label class="opt-btn{% if has_img %} opt-btn--with-image{% endif %}{% if (mitsumori_json and mitsumori_json.pc == cc['name']) or color|length == 1 %} is-selected{% endif %}"
  2348.                                      onclick="mitsumori_simulation_val('pc', '{{ cc['name']|e('js') }}');">
  2349.                                 <input type="radio" name="color" id="cc_{{ idx }}" value="{{ cc['name'] }}"
  2350.                                        {% if (mitsumori_json and mitsumori_json.pc == cc['name']) or color|length == 1 %}checked{% endif %}>
  2351.                                 {% if has_img %}
  2352.                                   <img src="{{ cc['img'] }}" alt="{{ cc['name'] }}" class="opt-btn__img"
  2353.                                        onerror="this.parentNode.classList.remove('opt-btn--with-image'); this.remove();">
  2354.                                   <span class="opt-btn__name">{{ cc['name'] }}</span>
  2355.                                 {% else %}
  2356.                                   {{ cc['name'] }}
  2357.                                 {% endif %}
  2358.                               </label>
  2359.                             {% endif %}{% endfor %}
  2360.                           </div>
  2361.                         </div>
  2362.                         {% endif %}
  2363.                         {% if p_w and p_w|length and p_w|join != "" and ProductClass.SaleType.id != 3 %}
  2364.                         <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2365.                           <div class="rp-section-label">幅{% if mitsumori_json and mitsumori_json.pw %}: <span>{{ mitsumori_json.pw }}</span>{% endif %}</div>
  2366.                           <div class="opt-btn-group">
  2367.                             {% set idx = 0 %}
  2368.                             {% for pw in p_w %}{% if pw %}{% set idx = idx + 1 %}
  2369.                               <label class="opt-btn{% if (mitsumori_json and mitsumori_json.pw == pw) or p_w|length == 1 %} is-selected{% endif %}"
  2370.                                      onclick="mitsumori_simulation_val('pw', '{{ pw|e('js') }}');">
  2371.                                 <input type="radio" name="pw" id="pw_{{ idx }}" value="{{ pw }}"
  2372.                                        {% if (mitsumori_json and mitsumori_json.pw == pw) or p_w|length == 1 %}checked{% endif %}>
  2373.                                 {{ pw }}
  2374.                               </label>
  2375.                             {% endif %}{% endfor %}
  2376.                           </div>
  2377.                         </div>
  2378.                         {% endif %}
  2379.                         {% if p_d and p_d|length and p_d|join != "" and ProductClass.SaleType.id != 3 %}
  2380.                         <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2381.                           <div class="rp-section-label">奥行き{% if mitsumori_json and mitsumori_json.pd %}: <span>{{ mitsumori_json.pd }}</span>{% endif %}</div>
  2382.                           <div class="opt-btn-group">
  2383.                             {% set idx = 0 %}
  2384.                             {% for pd in p_d %}{% if pd %}{% set idx = idx + 1 %}
  2385.                               <label class="opt-btn{% if (mitsumori_json and mitsumori_json.pd == pd) or p_d|length == 1 %} is-selected{% endif %}"
  2386.                                      onclick="mitsumori_simulation_val('pd', '{{ pd|e('js') }}');">
  2387.                                 <input type="radio" name="pd" id="pd_{{ idx }}" value="{{ pd }}"
  2388.                                        {% if (mitsumori_json and mitsumori_json.pd == pd) or p_d|length == 1 %}checked{% endif %}>
  2389.                                 {{ pd }}
  2390.                               </label>
  2391.                             {% endif %}{% endfor %}
  2392.                           </div>
  2393.                         </div>
  2394.                         {% endif %}
  2395.                         {% if p_h and p_h|length and p_h|join != "" and ProductClass.SaleType.id != 3 %}
  2396.                         <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2397.                           <div class="rp-section-label">高さ{% if mitsumori_json and mitsumori_json.ph %}: <span>{{ mitsumori_json.ph }}</span>{% endif %}</div>
  2398.                           <div class="opt-btn-group">
  2399.                             {% set idx = 0 %}
  2400.                             {% for ph in p_h %}{% if ph %}{% set idx = idx + 1 %}
  2401.                               <label class="opt-btn{% if (mitsumori_json and mitsumori_json.ph == ph) or p_h|length == 1 %} is-selected{% endif %}"
  2402.                                      onclick="mitsumori_simulation_val('ph', '{{ ph|e('js') }}');">
  2403.                                 <input type="radio" name="ph" id="ph_{{ idx }}" value="{{ ph }}"
  2404.                                        {% if (mitsumori_json and mitsumori_json.ph == ph) or p_h|length == 1 %}checked{% endif %}>
  2405.                                 {{ ph }}
  2406.                               </label>
  2407.                             {% endif %}{% endfor %}
  2408.                           </div>
  2409.                         </div>
  2410.                         {% endif %}
  2411.                         {% if p_m and p_m|length and p_m|join != "" and ProductClass.SaleType.id != 3 %}
  2412.                         <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2413.                           <div class="rp-section-label">素材{% if mitsumori_json and mitsumori_json.pm %}: <span>{{ mitsumori_json.pm }}</span>{% endif %}</div>
  2414.                           <div class="opt-btn-group">
  2415.                             {% set idx = 0 %}
  2416.                             {% for pm in p_m %}{% if pm %}{% set idx = idx + 1 %}
  2417.                               <label class="opt-btn{% if (mitsumori_json and mitsumori_json.pm == pm) or p_m|length == 1 %} is-selected{% endif %}"
  2418.                                      onclick="mitsumori_simulation_val('pm', '{{ pm|e('js') }}');">
  2419.                                 <input type="radio" name="pm" id="pm_{{ idx }}" value="{{ pm }}"
  2420.                                        {% if (mitsumori_json and mitsumori_json.pm == pm) or p_m|length == 1 %}checked{% endif %}>
  2421.                                 {{ pm }}
  2422.                               </label>
  2423.                             {% endif %}{% endfor %}
  2424.                           </div>
  2425.                         </div>
  2426.                         {% endif %}
  2427.                         {# option1 (sale_type 2 は専用 UI が下にあるため除外 / sale_type 3 は下部ブロックで描画 /
  2428.                            sale_type 4 = fe・ts は option1 が ct_unit_price (枚数増分の工事費単価) で
  2429.                            ユーザー選択肢ではなく計算用の内部値のため radio として表示しない. 値は
  2430.                            上の auto-init (p_option1|length == 1) で JS の option1 変数に埋め込み済み) #}
  2431.                         {% if p_option1 and p_option1|length and p_option1|join != "" and ProductClass.SaleType.id != 2 and ProductClass.SaleType.id != 3 and ProductClass.SaleType.id != 4 %}
  2432.                         <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2433.                           <div class="rp-section-label">{{ option1_label }}{% if mitsumori_json and mitsumori_json.option1 is defined and mitsumori_json.option1 %}: <span>{{ mitsumori_json.option1 }}</span>{% endif %}</div>
  2434.                           <div class="opt-btn-group">
  2435.                             {% set idx = 0 %}
  2436.                             {% for opt1 in p_option1 %}{% if opt1 %}{% set idx = idx + 1 %}
  2437.                               <label class="opt-btn{% if (mitsumori_json and mitsumori_json.option1 is defined and mitsumori_json.option1 == opt1) or p_option1|length == 1 %} is-selected{% endif %}"
  2438.                                      onclick="mitsumori_simulation_val('option1', '{{ opt1|e('js') }}');">
  2439.                                 <input type="radio" name="option1" id="option1_{{ idx }}" value="{{ opt1 }}"
  2440.                                        {% if (mitsumori_json and mitsumori_json.option1 is defined and mitsumori_json.option1 == opt1) or p_option1|length == 1 %}checked{% endif %}>
  2441.                                 {{ opt1 }}
  2442.                               </label>
  2443.                             {% endif %}{% endfor %}
  2444.                           </div>
  2445.                         </div>
  2446.                         {% endif %}
  2447.                         {# option2 #}
  2448.                         {% if p_option2 and p_option2|length and p_option2|join != "" and ProductClass.SaleType.id != 2 and ProductClass.SaleType.id != 3 %}
  2449.                         <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2450.                           <div class="rp-section-label">{{ option2_label }}{% if mitsumori_json and mitsumori_json.option2 is defined and mitsumori_json.option2 %}: <span>{{ mitsumori_json.option2 }}</span>{% endif %}</div>
  2451.                           <div class="opt-btn-group">
  2452.                             {% set idx = 0 %}
  2453.                             {% for opt2 in p_option2 %}{% if opt2 %}{% set idx = idx + 1 %}
  2454.                               <label class="opt-btn{% if (mitsumori_json and mitsumori_json.option2 is defined and mitsumori_json.option2 == opt2) or p_option2|length == 1 %} is-selected{% endif %}"
  2455.                                      onclick="mitsumori_simulation_val('option2', '{{ opt2|e('js') }}');">
  2456.                                 <input type="radio" name="option2" id="option2_{{ idx }}" value="{{ opt2 }}"
  2457.                                        {% if (mitsumori_json and mitsumori_json.option2 is defined and mitsumori_json.option2 == opt2) or p_option2|length == 1 %}checked{% endif %}>
  2458.                                 {{ opt2 }}
  2459.                               </label>
  2460.                             {% endif %}{% endfor %}
  2461.                           </div>
  2462.                         </div>
  2463.                         {% endif %}
  2464.                         <!-- 1: 施工見積(通常) → 幅/奥行/高さ/素材/カラーは上部の共通ブロックで表示済み -->
  2465.                         {% if ProductClass.SaleType.id == 1 %}
  2466.                         {% endif %}
  2467.                         <!-- 2: 施工見積(補助金・窓) -->
  2468.                         {% if ProductClass.SaleType.id == 2 %}
  2469.                             {# 窓サイズは右パネルの p_w / p_h ラジオ
  2470.                                (「100cm まで」「150cm まで」…) で選択する仕様.
  2471.                                旧 mado_w / mado_h の自由入力欄は廃止. #}
  2472.                             {# 窓タイプ (option1 = subtype: 引違い 2 枚建 / 4 枚建 / FIX 窓 等) #}
  2473.                             {% if p_option1 and p_option1|length and p_option1|join != "" %}
  2474.                             <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2475.                               <div class="rp-section-label">窓タイプ{% if mitsumori_json and mitsumori_json.option1 is defined and mitsumori_json.option1 %}: <span>{{ mitsumori_json.option1 }}</span>{% endif %}</div>
  2476.                               <div class="opt-btn-group">
  2477.                                 {% set idx = 0 %}
  2478.                                 {% for opt1_val in p_option1 %}{% if opt1_val %}{% set idx = idx + 1 %}
  2479.                                   <label class="opt-btn{% if (mitsumori_json and mitsumori_json.option1 is defined and mitsumori_json.option1 == opt1_val) or (p_option1|length == 1) %} is-selected{% endif %}"
  2480.                                          onclick="mitsumori_simulation('option1','option1_{{ idx }}');">
  2481.                                     <input type="radio" name="option1" id="option1_{{ idx }}" value="{{ opt1_val }}"
  2482.                                            {% if (mitsumori_json and mitsumori_json.option1 is defined and mitsumori_json.option1 == opt1_val) or (p_option1|length == 1) %}checked{% endif %}>
  2483.                                     {{ opt1_val }}
  2484.                                   </label>
  2485.                                 {% endif %}{% endfor %}
  2486.                               </div>
  2487.                             </div>
  2488.                             {% endif %}
  2489.                             {# ガラスタイプ(p_m データから選択肢を生成) #}
  2490.                             {% if p_m and p_m|length and p_m|join != "" %}
  2491.                             <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2492.                               <div class="rp-section-label">ガラスタイプ{% if mitsumori_json and mitsumori_json.pm %}: <span>{{ mitsumori_json.pm }}</span>{% endif %}</div>
  2493.                               <div class="opt-btn-group">
  2494.                                 {% set idx = 0 %}
  2495.                                 {% for pm_val in p_m %}{% if pm_val %}{% set idx = idx + 1 %}
  2496.                                   <label class="opt-btn{% if (mitsumori_json and mitsumori_json.pm == pm_val) or (p_m|length == 1) %} is-selected{% endif %}"
  2497.                                          onclick="mitsumori_simulation('pm','glass_type_{{ idx }}');">
  2498.                                     <input type="radio" name="glass_type" id="glass_type_{{ idx }}" value="{{ pm_val }}"
  2499.                                            {% if (mitsumori_json and mitsumori_json.pm == pm_val) or (p_m|length == 1) %}checked{% endif %}>
  2500.                                     {{ pm_val }}
  2501.                                   </label>
  2502.                                 {% endif %}{% endfor %}
  2503.                               </div>
  2504.                             </div>
  2505.                             {% endif %}
  2506.                             {# 2026-05 仕様簡素化: 「セット数」入力欄は廃止.
  2507.                                枚数は subtype (引違い 2 枚建 / 4 枚建 等) に内包し、
  2508.                                複数セットはカート quantity で表現する. #}
  2509.                         {% endif %}
  2510.                         <!-- 3: 施工見積(物置・ゴミステーション) -->
  2511.                         {% if ProductClass.SaleType.id == 3 %}
  2512.                             {# 幅・奥行き・高さ(p_w/p_d/p_h からボタン型ラジオ生成) #}
  2513.                             {% if p_w and p_w|length and p_w|join != "" %}
  2514.                             <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2515.                               <div class="rp-section-label">幅{% if mitsumori_json and mitsumori_json.pw %}: <span>{{ mitsumori_json.pw }}</span>{% endif %}</div>
  2516.                               <div class="opt-btn-group">
  2517.                                 {% set idx = 0 %}
  2518.                                 {% for pw_val in p_w %}{% if pw_val %}{% set idx = idx + 1 %}
  2519.                                   <label class="opt-btn{% if (mitsumori_json and mitsumori_json.pw == pw_val) or p_w|length == 1 %} is-selected{% endif %}"
  2520.                                          onclick="mitsumori_simulation('pw','pw3_{{ idx }}');">
  2521.                                     <input type="radio" name="pw" id="pw3_{{ idx }}" value="{{ pw_val }}"
  2522.                                            {% if (mitsumori_json and mitsumori_json.pw == pw_val) or p_w|length == 1 %}checked{% endif %}>
  2523.                                     {{ pw_val }}
  2524.                                   </label>
  2525.                                 {% endif %}{% endfor %}
  2526.                               </div>
  2527.                             </div>
  2528.                             {% endif %}
  2529.                             {% if p_d and p_d|length and p_d|join != "" %}
  2530.                             <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2531.                               <div class="rp-section-label">奥行き{% if mitsumori_json and mitsumori_json.pd %}: <span>{{ mitsumori_json.pd }}</span>{% endif %}</div>
  2532.                               <div class="opt-btn-group">
  2533.                                 {% set idx = 0 %}
  2534.                                 {% for pd_val in p_d %}{% if pd_val %}{% set idx = idx + 1 %}
  2535.                                   <label class="opt-btn{% if (mitsumori_json and mitsumori_json.pd == pd_val) or p_d|length == 1 %} is-selected{% endif %}"
  2536.                                          onclick="mitsumori_simulation('pd','pd3_{{ idx }}');">
  2537.                                     <input type="radio" name="pd" id="pd3_{{ idx }}" value="{{ pd_val }}"
  2538.                                            {% if (mitsumori_json and mitsumori_json.pd == pd_val) or p_d|length == 1 %}checked{% endif %}>
  2539.                                     {{ pd_val }}
  2540.                                   </label>
  2541.                                 {% endif %}{% endfor %}
  2542.                               </div>
  2543.                             </div>
  2544.                             {% endif %}
  2545.                             {% if p_h and p_h|length and p_h|join != "" %}
  2546.                             <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2547.                               <div class="rp-section-label">高さ{% if mitsumori_json and mitsumori_json.ph %}: <span>{{ mitsumori_json.ph }}</span>{% endif %}</div>
  2548.                               <div class="opt-btn-group">
  2549.                                 {% set idx = 0 %}
  2550.                                 {% for ph_val in p_h %}{% if ph_val %}{% set idx = idx + 1 %}
  2551.                                   <label class="opt-btn{% if (mitsumori_json and mitsumori_json.ph == ph_val) or p_h|length == 1 %} is-selected{% endif %}"
  2552.                                          onclick="mitsumori_simulation('ph','ph3_{{ idx }}');">
  2553.                                     <input type="radio" name="ph" id="ph3_{{ idx }}" value="{{ ph_val }}"
  2554.                                            {% if (mitsumori_json and mitsumori_json.ph == ph_val) or p_h|length == 1 %}checked{% endif %}>
  2555.                                     {{ ph_val }}
  2556.                                   </label>
  2557.                                 {% endif %}{% endfor %}
  2558.                               </div>
  2559.                             </div>
  2560.                             {% endif %}
  2561.                             {# 棚タイプ(p_m データから選択肢を生成) #}
  2562.                             {% if p_m and p_m|length and p_m|join != "" %}
  2563.                             <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2564.                               <div class="rp-section-label">棚タイプ <small class="text-muted">(間仕切り仕様)</small>{% if mitsumori_json and mitsumori_json.pm %}: <span>{{ mitsumori_json.pm }}</span>{% endif %}</div>
  2565.                               <div class="opt-btn-group">
  2566.                                 {% set idx = 0 %}
  2567.                                 {% for pm_val in p_m %}{% if pm_val %}{% set idx = idx + 1 %}
  2568.                                   <label class="opt-btn{% if (mitsumori_json and mitsumori_json.pm == pm_val) or p_m|length == 1 %} is-selected{% endif %}"
  2569.                                          onclick="mitsumori_simulation('pm','pm3_{{ idx }}');">
  2570.                                     <input type="radio" name="pm" id="pm3_{{ idx }}" value="{{ pm_val }}"
  2571.                                            {% if (mitsumori_json and mitsumori_json.pm == pm_val) or p_m|length == 1 %}checked{% endif %}>
  2572.                                     {{ pm_val }}
  2573.                                   </label>
  2574.                                 {% endif %}{% endfor %}
  2575.                               </div>
  2576.                             </div>
  2577.                             {% endif %}
  2578.                             {# option1 (mo の 棚タイプ 等、p_option1 データから選択肢を生成) #}
  2579.                             {% if p_option1 and p_option1|length and p_option1|join != "" %}
  2580.                             <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2581.                               <div class="rp-section-label">{{ option1_label }}{% if mitsumori_json and mitsumori_json.option1 is defined and mitsumori_json.option1 %}: <span>{{ mitsumori_json.option1 }}</span>{% endif %}</div>
  2582.                               <div class="opt-btn-group">
  2583.                                 {% set idx = 0 %}
  2584.                                 {% for opt1_val in p_option1 %}{% if opt1_val %}{% set idx = idx + 1 %}
  2585.                                   <label class="opt-btn{% if (mitsumori_json and mitsumori_json.option1 is defined and mitsumori_json.option1 == opt1_val) or p_option1|length == 1 %} is-selected{% endif %}"
  2586.                                          onclick="mitsumori_simulation('option1','option1_3_{{ idx }}');">
  2587.                                     <input type="radio" name="option1" id="option1_3_{{ idx }}" value="{{ opt1_val }}"
  2588.                                            {% if (mitsumori_json and mitsumori_json.option1 is defined and mitsumori_json.option1 == opt1_val) or p_option1|length == 1 %}checked{% endif %}>
  2589.                                     {{ opt1_val }}
  2590.                                   </label>
  2591.                                 {% endif %}{% endfor %}
  2592.                               </div>
  2593.                             </div>
  2594.                             {% endif %}
  2595.                             {# カラー(共通の color データ使用) #}
  2596.                             {% if color and color|length %}
  2597.                             <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2598.                               <div class="rp-section-label">カラー{% if mitsumori_json and mitsumori_json.pc %}: <span>{{ mitsumori_json.pc }}</span>{% endif %}</div>
  2599.                               <div class="opt-btn-group">
  2600.                                 {% set idx = 0 %}
  2601.                                 {% for cc in color %}{% if cc and cc['name'] %}{% set idx = idx + 1 %}
  2602.                                   <label class="opt-btn{% if (mitsumori_json and mitsumori_json.pc == cc['name']) or color|length == 1 %} is-selected{% endif %}"
  2603.                                          onclick="mitsumori_simulation('pc','cc3_{{ idx }}');">
  2604.                                     <input type="radio" name="color3" id="cc3_{{ idx }}" value="{{ cc['name'] }}"
  2605.                                            {% if (mitsumori_json and mitsumori_json.pc == cc['name']) or color|length == 1 %}checked{% endif %}>
  2606.                                     {{ cc['name'] }}
  2607.                                   </label>
  2608.                                 {% endif %}{% endfor %}
  2609.                               </div>
  2610.                             </div>
  2611.                             {% endif %}
  2612.                             {# 台数 #}
  2613.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2614.                               <label class="col-4 col-form-label">台数</label>
  2615.                               <div class="col-4">
  2616.                                 <div class="input-group mb-3">
  2617.                                   <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');">
  2618.                                   <span class="input-group-text">台</span>
  2619.                                 </div>
  2620.                               </div>
  2621.                               <div class="col-4">
  2622.                                 <button type="button" class="btn btn-info" onclick="daisu(+1);">+</button>
  2623.                                 <button type="button" class="btn btn-danger" onclick="daisu(-1);">ー</button>
  2624.                               </div>
  2625.                             </div>
  2626.                         {% endif %}
  2627.                         <!-- 4: 施工見積(フェンス・組み立て式) -->
  2628.                         {% if ProductClass.SaleType.id == 4 %}
  2629.                             {# 枚数 #}
  2630.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2631.                               <label class="col-4 col-form-label">枚数</label>
  2632.                               <div class="col-4 mb-3">
  2633.                                 <div class="input-group">
  2634.                                   <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');">
  2635.                                   <span class="input-group-text">枚</span>
  2636.                                 </div>
  2637.                               </div>
  2638.                               <div class="col-4">
  2639.                                 <button type="button" class="btn btn-info" onclick="maisu(+1);">+</button>
  2640.                                 <button type="button" class="btn btn-danger" onclick="maisu(-1);">ー</button>
  2641.                               </div>
  2642.                             </div>
  2643.                         {% endif %}
  2644.                         <!-- 5: 施工見積(ウッドデッキ・タイルデッキ) -->
  2645.                         {% if ProductClass.SaleType.id == 5 %}
  2646.                             {# ステップの有無 #}
  2647.                             <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2648.                               <div class="rp-section-label">ステップ</div>
  2649.                               <div class="opt-btn-group">
  2650.                                 {% set step_yes_checked = (mitsumori_json and mitsumori_json.deck_step is defined and mitsumori_json.deck_step == '必要') %}
  2651.                                 {% set step_no_checked = (not mitsumori_json or mitsumori_json.deck_step is not defined or mitsumori_json.deck_step == '不要' or not mitsumori_json.deck_step) %}
  2652.                                 <label class="opt-btn{% if step_yes_checked %} is-selected{% endif %}"
  2653.                                        onclick="mitsumori_simulation('op0','deck_step_yes');">
  2654.                                   <input type="radio" name="deck_step" id="deck_step_yes" value="必要"
  2655.                                          {% if step_yes_checked %}checked{% endif %}>
  2656.                                   必要
  2657.                                 </label>
  2658.                                 <label class="opt-btn{% if step_no_checked %} is-selected{% endif %}"
  2659.                                        onclick="mitsumori_simulation('op0','deck_step_no');">
  2660.                                   <input type="radio" name="deck_step" id="deck_step_no" value="不要"
  2661.                                          {% if step_no_checked %}checked{% endif %}>
  2662.                                   不要
  2663.                                 </label>
  2664.                               </div>
  2665.                               <div class="opt-survey-note-wd-step" style="font-size:12px;color:#c00;margin-top:6px;{% if not step_yes_checked %}display:none;{% endif %}">
  2666.                                 ※ 現場調査後に正式お見積もりさせていただきます。
  2667.                               </div>
  2668.                             </div>
  2669.                             {# ウッドデッキフェンスの有無 #}
  2670.                             <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2671.                               <div class="rp-section-label">デッキフェンス</div>
  2672.                               <div class="opt-btn-group">
  2673.                                 {% set fence_yes_checked = (mitsumori_json and mitsumori_json.deck_fence is defined and mitsumori_json.deck_fence == '必要') %}
  2674.                                 {% set fence_no_checked = (not mitsumori_json or mitsumori_json.deck_fence is not defined or mitsumori_json.deck_fence == '不要' or not mitsumori_json.deck_fence) %}
  2675.                                 <label class="opt-btn{% if fence_yes_checked %} is-selected{% endif %}"
  2676.                                        onclick="mitsumori_simulation('op1','deck_fence_yes');">
  2677.                                   <input type="radio" name="deck_fence" id="deck_fence_yes" value="必要"
  2678.                                          {% if fence_yes_checked %}checked{% endif %}>
  2679.                                   必要
  2680.                                 </label>
  2681.                                 <label class="opt-btn{% if fence_no_checked %} is-selected{% endif %}"
  2682.                                        onclick="mitsumori_simulation('op1','deck_fence_no');">
  2683.                                   <input type="radio" name="deck_fence" id="deck_fence_no" value="不要"
  2684.                                          {% if fence_no_checked %}checked{% endif %}>
  2685.                                   不要
  2686.                                 </label>
  2687.                               </div>
  2688.                               <div class="opt-survey-note-wd-fence" style="font-size:12px;color:#c00;margin-top:6px;{% if not fence_yes_checked %}display:none;{% endif %}">
  2689.                                 ※ 現場調査後に正式お見積もりさせていただきます。
  2690.                               </div>
  2691.                             </div>
  2692.                         {% endif %}
  2693.                         <!-- 6: 施工見積(芝生・枚数・数量買い) -->
  2694.                         {% if ProductClass.SaleType.id == 6 %}
  2695.                             {# 規格(p_m データ → 素材から抽出) #}
  2696.                             {% if p_m and p_m|length and p_m|join != "" %}
  2697.                             <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2698.                               <div class="rp-section-label">規格{% if mitsumori_json and mitsumori_json.pm %}: <span>{{ mitsumori_json.pm }}</span>{% endif %}</div>
  2699.                               <div class="opt-btn-group">
  2700.                                 {% set idx = 0 %}
  2701.                                 {% for pm_val in p_m %}{% if pm_val %}{% set idx = idx + 1 %}
  2702.                                   <label class="opt-btn{% if (mitsumori_json and mitsumori_json.pm == pm_val) or p_m|length == 1 %} is-selected{% endif %}"
  2703.                                          onclick="mitsumori_simulation('pm','pm6_{{ idx }}');">
  2704.                                     <input type="radio" name="pm" id="pm6_{{ idx }}" value="{{ pm_val }}"
  2705.                                            {% if (mitsumori_json and mitsumori_json.pm == pm_val) or p_m|length == 1 %}checked{% endif %}>
  2706.                                     {{ pm_val }}
  2707.                                   </label>
  2708.                                 {% endif %}{% endfor %}
  2709.                               </div>
  2710.                             </div>
  2711.                             {% endif %}
  2712.                             {# 芝の長さ(p_w データ → 幅から抽出) #}
  2713.                             {% if p_w and p_w|length and p_w|join != "" %}
  2714.                             <div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2715.                               <div class="rp-section-label">芝の長さ{% if mitsumori_json and mitsumori_json.pw %}: <span>{{ mitsumori_json.pw }}</span>{% endif %}</div>
  2716.                               <div class="opt-btn-group">
  2717.                                 {% set idx = 0 %}
  2718.                                 {% for pw_val in p_w %}{% if pw_val %}{% set idx = idx + 1 %}
  2719.                                   <label class="opt-btn{% if (mitsumori_json and mitsumori_json.pw == pw_val) or p_w|length == 1 %} is-selected{% endif %}"
  2720.                                          onclick="mitsumori_simulation('pw','pw6_{{ idx }}');">
  2721.                                     <input type="radio" name="pw" id="pw6_{{ idx }}" value="{{ pw_val }}"
  2722.                                            {% if (mitsumori_json and mitsumori_json.pw == pw_val) or p_w|length == 1 %}checked{% endif %}>
  2723.                                     {{ pw_val }}
  2724.                                   </label>
  2725.                                 {% endif %}{% endfor %}
  2726.                               </div>
  2727.                             </div>
  2728.                             {% endif %}
  2729.                             {# 施工面積(㎡ 自由入力) #}
  2730.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2731.                               <label class="col-4 col-form-label">施工面積</label>
  2732.                               <div class="col-8">
  2733.                                 <div class="input-group">
  2734.                                   <input type="number" name="area" id="area"
  2735.                                     class="form-control"
  2736.                                     value="{{ mitsumori_json.area|default('') }}"
  2737.                                     placeholder="例: 10.5"
  2738.                                     min="0.1" step="0.1"
  2739.                                     onchange="mitsumori_simulation('area','area');">
  2740.                                   <span class="input-group-text">平米</span>
  2741.                                 </div>
  2742.                               </div>
  2743.                             </div>
  2744.                         {% endif %}
  2745.                         <!-- 7: 施工見積(数量買い・基本工事費固定) -->
  2746.                         {% if ProductClass.SaleType.id == 7 %}
  2747.                             {# 個数(物置の daisu と同形式、単位は「個」) #}
  2748.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2749.                               <label class="col-4 col-form-label">個数</label>
  2750.                               <div class="col-4">
  2751.                                 <div class="input-group mb-3">
  2752.                                   <input type="number" name="suuryou" id="suuryou" class="form-control"
  2753.                                     value="{{ mitsumori_json.suuryou|default('1') }}" min="1" max="100"
  2754.                                     onchange="mitsumori_simulation('suuryou','suuryou');">
  2755.                                   <span class="input-group-text">個</span>
  2756.                                 </div>
  2757.                               </div>
  2758.                               <div class="col-4">
  2759.                                 <button type="button" class="btn btn-info" onclick="suuryou(+1);">+</button>
  2760.                                 <button type="button" class="btn btn-danger" onclick="suuryou(-1);">ー</button>
  2761.                               </div>
  2762.                             </div>
  2763.                         {% endif %}
  2764.                         <!-- 9: 商品のみ購入 -->
  2765.                         {% if ProductClass.SaleType.id == 9 %}
  2766.                             <div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2767.                               <label class="col-4 col-form-label">数量</label>
  2768.                               <div class="col-4">
  2769.                                 <div class="input-group mb-3">
  2770.                                   <input type="number" name="quantity_only" id="quantity_only" class="form-control" value="1" min="1" onchange="$('#quantity').val(this.value);">
  2771.                                   <span class="input-group-text">個</span>
  2772.                                 </div>
  2773.                               </div>
  2774.                               <div class="col-4">
  2775.                                 <button type="button" class="btn btn-info" onclick="quantityOnly(+1);">+</button>
  2776.                                 <button type="button" class="btn btn-danger" onclick="quantityOnly(-1);">ー</button>
  2777.                               </div>
  2778.                             </div>
  2779.                         {% endif %}
  2780.                         <div class="row" style="border-bottom:1px solid rgba(0,0,0,.125)"><label class="col-12 col-form-label">取り付け工事のご希望に関してお答えください。</label></div>
  2781.                         {# gs (ゴミステーション, category id=27) では「撤去対応」「残土・ガラ処理」は ex-shop に存在しないため非表示
  2782.                            cg (カーゲート, category id=9) では「残土・ガラ処理」分は撤去金額側に内包済みのため非表示
  2783.                            (撤去オプション自体は残す) #}
  2784.                         {% set is_gs = false %}
  2785.                         {% set is_cg = false %}
  2786.                         {% if Product.ProductCategories is not empty %}
  2787.                             {% for ProductCategory in Product.ProductCategories %}
  2788.                                 {% if ProductCategory.category_id == 27 %}{% set is_gs = true %}{% endif %}
  2789.                                 {% if ProductCategory.category_id == 9 %}{% set is_cg = true %}{% endif %}
  2790.                             {% endfor %}
  2791.                         {% endif %}
  2792.                         {% for i in 0..10 %}
  2793.                             {% if op and op|length >= i+1 %}
  2794.                             {% if op[i]['name'] %}
  2795.                             {% set hide_opt = false %}
  2796.                             {% if is_gs and (op[i]['name'] matches '/撤去/' or op[i]['name'] matches '/残土/') %}
  2797.                                 {% set hide_opt = true %}
  2798.                             {% endif %}
  2799.                             {% if is_cg and op[i]['name'] matches '/残土/' %}
  2800.                                 {% set hide_opt = true %}
  2801.                             {% endif %}
  2802.                             {% if not hide_opt %}
  2803.                             {# price=0 で「解体」「撤去」「設置場所」(wd 等で API 差額未提供) を含むオプションは
  2804.                                選択時に「現場調査後に正式お見積もり」文言を出す. #}
  2805.                             {% set is_removal_unknown = (op[i]['price']|default(0) == 0 or op[i]['price']|default('0') == '0')
  2806.                                                           and (op[i]['name'] matches '/解体/' or op[i]['name'] matches '/撤去/' or op[i]['name'] matches '/設置場所/') %}
  2807.                             <div class="form-group mt-3 pb-3" style="border-bottom:1px solid rgba(0,0,0,.125)">
  2808.                               <div class="rp-section-label">{{ op[i]['name'] }}{% if mitsumori_json and mitsumori_json.op[i] %}: <span>{{ mitsumori_json.op[i] }}</span>{% endif %}</div>
  2809.                               {% if op[i]['comment'] %}<div class="opt-comment" style="font-size:12px;color:#666;margin:4px 0 6px;">{{ op[i]['comment'] }}</div>{% endif %}
  2810.                               <div class="opt-btn-group">
  2811.                                 <label class="opt-btn{% if mitsumori_json and mitsumori_json.op[i] == op[i]['on'] %} is-selected{% endif %}"
  2812.                                        onclick="mitsumori_simulation('op{{ i }}','op{{ i }}_1');">
  2813.                                   <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 %}>
  2814.                                   {{ op[i]['on'] }}
  2815.                                 </label>
  2816.                                 <label class="opt-btn{% if mitsumori_json and mitsumori_json.op[i] == op[i]['off'] %} is-selected{% endif %}"
  2817.                                        onclick="mitsumori_simulation('op{{ i }}','op{{ i }}_2');">
  2818.                                   <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 %}>
  2819.                                   {{ op[i]['off'] }}
  2820.                                 </label>
  2821.                               </div>
  2822.                               {% if is_removal_unknown %}
  2823.                               <div class="opt-survey-note" data-op-idx="{{ i }}" style="font-size:12px;color:#c00;margin-top:6px;{% if not (mitsumori_json and mitsumori_json.op[i] == op[i]['on']) %}display:none;{% endif %}">
  2824.                                 ※ 現場調査後に正式お見積もりさせていただきます。
  2825.                               </div>
  2826.                               {% endif %}
  2827.                             </div>
  2828.                             {% endif %}
  2829.                             {% endif %}
  2830.                             {% endif %}
  2831.                         {% endfor %}
  2832.                       </div>
  2833.                       <!-- /.card-body -->
  2834.                     </div>
  2835.                     <form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1">
  2836.                         {% if Product.stock_find %}
  2837.                             <div class="ec-productRole__actions">
  2838.                                 {% if form.classcategory_id1 is defined %}
  2839.                                     <div class="ec-select">
  2840.                                         {{ form_row(form.classcategory_id1) }}
  2841.                                         {{ form_errors(form.classcategory_id1) }}
  2842.                                     </div>
  2843.                                     {% if form.classcategory_id2 is defined %}
  2844.                                         <div class="ec-select">
  2845.                                             {{ form_row(form.classcategory_id2) }}
  2846.                                             {{ form_errors(form.classcategory_id2) }}
  2847.                                         </div>
  2848.                                     {% endif %}
  2849.                                 {% endif %}
  2850.                                 <div class="ec-numberInput">
  2851.                                     {{ form_widget(form.quantity, { type: 'hidden' }) }}
  2852.                                     {{ form_errors(form.quantity) }}
  2853.                                 </div>
  2854.                             </div>
  2855.                         {% else %}
  2856.                             <div class="ec-productRole__btn">
  2857.                                 <button type="button" class="ec-blockBtn--action" disabled="disabled">
  2858.                                     {{ 'ただいま品切れ中です。'|trans }}
  2859.                                 </button>
  2860.                             </div>
  2861.                         {% endif %}
  2862.                         <div class="ec-productRole__btn mt-3">
  2863.                            <button type="submit" id="cart_btn" class="ec-blockBtn--action add-cart">カートに入れる</button>
  2864.                         </div>
  2865.                         {{ form_rest(form) }}
  2866.                     </form>
  2867.                     <div class="ec-modal add-cart-modal">
  2868.                         <div class="ec-modal-overlay">
  2869.                             <div class="ec-modal-wrap add-cart-modal__wrap">
  2870.                                 <span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
  2871.                                 <div id="ec-modal-header" class="text-center add-cart-modal__header">{{ 'カートに追加しました。'|trans }}</div>
  2872.                                 <div class="ec-modal-box add-cart-modal__box">
  2873.                                     <div class="ec-role add-cart-modal__actions">
  2874.                                         <a href="{{ url('cart') }}" class="ec-inlineBtn--action add-cart-modal__primary">{{ 'カートに進む'|trans }}</a>
  2875.                                         <span class="ec-inlineBtn--cancel add-cart-modal__secondary">{{ '商品検索を続ける'|trans }}</span>
  2876.                                     </div>
  2877.                                 </div>
  2878.                             </div>
  2879.                         </div>
  2880.                     </div>
  2881.                     <div class="ec-productRole__description">{{ Product.description_detail|raw|nl2br }}
  2882.                     </div>
  2883.                     {# SNSシェア #}
  2884.                     <div class="ec-productRole__share">
  2885.                         <ul class="ec-share">
  2886.                             <li class="ec-share__item">
  2887.                                 <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">
  2888.                                     <i class="fab fa-twitter"></i>
  2889.                                 </a>
  2890.                             </li>
  2891.                             <li class="ec-share__item">
  2892.                                 <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">
  2893.                                     <i class="fab fa-facebook-f"></i>
  2894.                                 </a>
  2895.                             </li>
  2896.                             <li class="ec-share__item">
  2897.                                 <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">
  2898.                                     <i class="fab fa-line"></i>
  2899.                                 </a>
  2900.                             </li>
  2901.                         </ul>
  2902.                     </div>
  2903.                 </div>
  2904.                 {# ===== スマホ用 見積金額 下部固定バー ===== #}
  2905.                 <div id="sp-mitsumori-bar">
  2906.                     <div>
  2907.                         <div class="sp-bar__label">合計(工事費・税込)</div>
  2908.                         <div class="sp-bar__price" id="sp-mitsumori-price">---円</div>
  2909.                     </div>
  2910.                     <button type="button" class="sp-bar__btn"
  2911.                             onclick="document.getElementById('cart_btn2') && document.getElementById('cart_btn2').click();">
  2912.                         <i class="fas fa-shopping-cart"></i>
  2913.                         <span class="sp-bar__btn-label">検討リストへ</span>
  2914.                         {% set spTotalQty = get_carts_total_quantity() %}
  2915.                         {% if spTotalQty > 0 %}
  2916.                             <span class="sp-bar__cart-badge">{{ spTotalQty|number_format }}</span>
  2917.                         {% endif %}
  2918.                     </button>
  2919.                     <a href="{{ url('homepage') }}" class="sp-bar__home-btn" title="トップページへ">
  2920.                         <i class="fas fa-home"></i>
  2921.                     </a>
  2922.                 </div>
  2923.                 {# tg カテゴリ用: block 別オプション差額ラジオ (W/D 確定後に JS が動的描画) #}
  2924.                 <div id="tg-options" class="tg-options-container col-12"></div>
  2925.                 <div class="card col-12 collapsed-card sticky-top float-right mitsumori-card-pc">
  2926.                     <div class="card-header">
  2927.                       <h3 class="card-title">現在のお見積り額</h3>
  2928.                       <div class="card-tools">
  2929.                         <span class="float-left" id="mitsumori_message">395000円</span>
  2930.                         <button type="button" class="btn btn-tool btn-mitsumori-toggle" data-card-widget="collapse" title="詳細を表示">
  2931.                           <span class="toggle-icon">▼ 詳細</span>
  2932.                         </button>
  2933.                       </div>
  2934.                     </div>
  2935.                     <div class="card-body p-0">
  2936.                       <ul class="nav nav-pills flex-column">
  2937.                         <li class="nav-item active">
  2938.                           <a class="nav-link">
  2939.                             <i class="far fa-file-alt"></i> 合計(工事費・税込)
  2940.                             <span class="float-right" id="mitsumori_goukei">395,000円</span>
  2941.                           </a>
  2942.                         </li>
  2943.                         <li class="nav-item active">
  2944.                           <a class="nav-link">
  2945.                             <i class="far fa-file-alt"></i> 商品価格
  2946.                             <span class="float-right" id="mitsumori_price">307,008円</span>
  2947.                           </a>
  2948.                         </li>
  2949.                         <li class="nav-item">
  2950.                           <a class="nav-link">
  2951.                             &nbsp;&nbsp;<i class="far fa-file-alt"></i> カタログ価格
  2952.                             <span class="float-right" id="maker_price">479,700円</span>
  2953.                           </a>
  2954.                         </li>
  2955.                         <li class="nav-item">
  2956.                           <a class="nav-link">
  2957.                             &nbsp;&nbsp;<i class="far fa-file-alt"></i> お値引き
  2958.                             <span class="float-right" id="mitsumori_off">-172,692円</span>
  2959.                           </a>
  2960.                         </li>
  2961.                         <li class="nav-item">
  2962.                           <a class="nav-link">
  2963.                             <i class="far fa-file-alt"></i> 基本工事費
  2964.                             <span class="float-right" id="mitsumori_ct">53,250円</span>
  2965.                           </a>
  2966.                         </li>
  2967.                         <li class="nav-item">
  2968.                           <a class="nav-link">
  2969.                             <i class="far fa-file-alt"></i> 施工オプション
  2970.                             <span class="float-right"id="mitsumori_option">6,297円</span>
  2971.                           </a>
  2972.                         </li>
  2973.                       </ul>
  2974.                     </div>
  2975.                     <div class="card-footer">
  2976.                         <button type="button" id="mitsumori_btn" class="btn btn-info" data-toggle="modal" data-target="#modal-mitsumori">
  2977.                           見積書表示
  2978.                         </button>
  2979.                         <button type="submit" id="cart_btn2" class="btn btn-info add-cart">カートに入れる</button>
  2980.                     </div>
  2981.                 </div>
  2982.             </div>
  2983.         </div>
  2984.     </div>
  2985.   <div class="modal" id="modal-mitsumori">
  2986.     <div class="modal-dialog modal-mitsumori" style="max-width:1000px">
  2987.       <div class="modal-content">
  2988.         <div class="modal-header">
  2989.           <h4 class="modal-title">お見積書</h4>
  2990.           <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  2991.             <span aria-hidden="true">&times;</span>
  2992.           </button>
  2993.         </div>
  2994.         <div class="modal-body">
  2995.             <div class="invoice p-3 mb-5" style="max-width:1000px; margin:auto;">
  2996.               <!-- title row -->
  2997.               <div class="row">
  2998.                 <div class="col-12">
  2999.                   <h2>概算お見積書 
  3000.                     <small class="float-right" style="font-size:14px;">発行日: 2025/03/14</small>
  3001.                   </h2>
  3002.                 </div>
  3003.                 <!-- /.col -->
  3004.               </div>
  3005.               <!-- info row -->
  3006.               <div class="row invoice-info">
  3007.                 <div class="col-sm-8 invoice-col">
  3008.                   <h3>お客様</h3>
  3009.                   <span>下記の通り、お見積もり申し上げます。</span>
  3010.                   <br />
  3011.                   <br / >
  3012.                   <br />
  3013.                   <h2>お見積金額: <span id="mitsumori_kei">399,080円</span></h2>
  3014.                   <span>
  3015.                     <br/>
  3016.                     <br/>
  3017.                     <br/>
  3018.                     <br/>
  3019.                   </span>
  3020.                 </div>
  3021.                 <div class="col-sm-4 invoice-col">
  3022.                   <p>
  3023.                     <img alt="" src="/html/user_data/js/images/logo.png" style="width: 260px; max-width: 100%; max-height: 10mm;">
  3024.                   </p>
  3025.                   <p>有限会社プラス</p>
  3026.                   <p>〒400-0334</p>
  3027.                   <p>山梨県南アルプス市藤田1450番地2</p>
  3028.                   <p>TEL: 055-284-6480</p>
  3029.                   <img alt="" src="/html/user_data/js/images/seal.svg" style="z-index: 2; position: absolute; width: 21mm; left: 58mm; top: 36mm;">
  3030.                 </div>
  3031.                 <!-- /.col -->
  3032.                 <!-- /.col -->
  3033.               </div>
  3034.               <!-- /.row -->
  3035.               <!-- Table row -->
  3036.               <div class="row">
  3037.                 <div class="col-12 table-responsive">
  3038.                   <table class="table table-striped">
  3039.                     <thead>
  3040.                       <tr>
  3041.                         <th>項目</th>
  3042.                         <th>数量</th>
  3043.                         <th>単位</th>
  3044.                         <th>単価</th>
  3045.                         <th>小計</th>
  3046.                       </tr>
  3047.                     </thead>
  3048.                     <tbody>
  3049.                       <tr>
  3050.                         <td id="mitsumori_item_name">{{ Product.name }}</td>
  3051.                         <td>1</td>
  3052.                         <td>式</td>
  3053.                         <td id="mitsumori_price_01">352,800</td>
  3054.                         <td id="mitsumori_price_02">352,800</td>
  3055.                       </tr>
  3056.                       <tr>
  3057.                         <td>基本工事費</td>
  3058.                         <td>1</td>
  3059.                         <td>式</td>
  3060.                         <td id="mitsumori_ct_01">10,000</td>
  3061.                         <td id="mitsumori_ct_02">10,000</td>
  3062.                       </tr>
  3063.                       <tr>
  3064.                         <td>残土・ガラ処理</td>
  3065.                         <td>1</td>
  3066.                         <td>式</td>
  3067.                         <td>0円</td>
  3068.                         <td></td>
  3069.                       </tr>
  3070.                       <tr>
  3071.                         <td> </td>
  3072.                         <td></td>
  3073.                         <td></td>
  3074.                         <td></td>
  3075.                         <td></td>
  3076.                       </tr>
  3077.                     </tbody>
  3078.                   </table>
  3079.                 </div>
  3080.                 <!-- /.col -->
  3081.               </div>
  3082.               <!-- /.row -->
  3083.               <div class="row">
  3084.                 <!-- accepted payments column -->
  3085.                 <div class="col-6">
  3086.                   <p class="lead">お支払い方法</p>
  3087.                   <p class="text-muted well well-sm shadow-none" style="margin-top: 10px;">銀行振込、クレジットカード決済、PAYPAY決済
  3088.                     <br>銀行振込:山梨中央銀行 白根支店 普通口座 391402
  3089.                     <br>※商品代金と工事代金の総額が金100万円(税込)を超える場合、着手金として代金の半額をご契約後お支払いいただきます。 
  3090.                   </p>
  3091.                 </div>
  3092.                 <!-- /.col -->
  3093.                 <div class="col-6">
  3094.                   <div class="table-responsive">
  3095.                     <table class="table">
  3096.                       <tbody>
  3097.                         <tr>
  3098.                           <th style="width:50%">小計:</th>
  3099.                           <td id="mitsumori_shoukei">362,800</td>
  3100.                         </tr>
  3101.                         <tr>
  3102.                           <th>消費税 (10%)</th>
  3103.                           <td id="mitsumori_tax">36,280</td>
  3104.                         </tr>
  3105.                         <tr>
  3106.                           <th>合計:</th>
  3107.                           <td id="mitsumori_goukei_02">399,080</td>
  3108.                         </tr>
  3109.                       </tbody>
  3110.                     </table>
  3111.                   </div>
  3112.                 </div>
  3113.                 <!-- /.col -->
  3114.               </div>
  3115.               <!-- /.row -->
  3116.             </div>
  3117.         </div>
  3118.         <div class="modal-footer justify-content-between">
  3119.                   {# PDF出力: mitsumori_json を POST して PDF ダウンロード #}
  3120.                   <form method="post" action="{{ url('mitsumori_pdf') }}" target="_blank" id="pdf_download_form">
  3121.                     <input type="hidden" name="_token" value="{{ csrf_token('mitsumori_pdf') }}">
  3122.                     <input type="hidden" name="mitsumori_json" id="pdf_mitsumori_json">
  3123.                     <button type="submit" class="btn btn-primary float-right" style="margin-right: 5px;" onclick="syncPdfJson();">
  3124.                       <i class="fas fa-download"></i>PDF出力
  3125.                     </button>
  3126.                   </form>
  3127.                   <button type="submit" id="cart_btn3" class="btn btn-info add-cart">カートに入れる</button>
  3128.         </div>
  3129.       </div>
  3130.       <!-- /.modal-content -->
  3131.     </div>
  3132.     <!-- /.modal-dialog -->
  3133.   </div>
  3134.   <!-- /.modal -->
  3135.     <!-- Image zoom modal: custom lightweight lightbox (no CDN dependency) -->
  3136.     <div id="img-modal" role="dialog" aria-modal="true" aria-label="画像拡大">
  3137.         <button id="img-modal__close" aria-label="閉じる">&times;</button>
  3138.         <button id="img-modal__prev" aria-label="前の画像">&#10094;</button>
  3139.         <img id="img-modal__img" src="" alt="">
  3140.         <button id="img-modal__next" aria-label="次の画像">&#10095;</button>
  3141.     </div>
  3142.     <style>
  3143.     #img-modal {
  3144.         display: none;
  3145.         position: fixed;
  3146.         inset: 0;
  3147.         z-index: 9999;
  3148.         background: rgba(0,0,0,0.88);
  3149.         align-items: center;
  3150.         justify-content: center;
  3151.         cursor: zoom-out;
  3152.     }
  3153.     #img-modal.is-open { display: flex; }
  3154.     #img-modal__img {
  3155.         max-width: 92vw;
  3156.         max-height: 88vh;
  3157.         object-fit: contain;
  3158.         border-radius: 4px;
  3159.         cursor: default;
  3160.         user-select: none;
  3161.         touch-action: pinch-zoom;
  3162.         display: block;
  3163.     }
  3164.     #img-modal__close {
  3165.         position: absolute;
  3166.         top: 14px;
  3167.         right: 18px;
  3168.         font-size: 38px;
  3169.         color: #fff;
  3170.         cursor: pointer;
  3171.         background: none;
  3172.         border: none;
  3173.         padding: 0;
  3174.         line-height: 1;
  3175.         z-index: 1;
  3176.         opacity: 0.85;
  3177.     }
  3178.     #img-modal__close:hover { opacity: 1; }
  3179.     #img-modal__prev,
  3180.     #img-modal__next {
  3181.         position: absolute;
  3182.         top: 50%;
  3183.         transform: translateY(-50%);
  3184.         font-size: 36px;
  3185.         color: #fff;
  3186.         cursor: pointer;
  3187.         background: rgba(0,0,0,0.32);
  3188.         border: none;
  3189.         padding: 10px 16px;
  3190.         line-height: 1;
  3191.         border-radius: 6px;
  3192.         z-index: 1;
  3193.         opacity: 0.8;
  3194.         user-select: none;
  3195.     }
  3196.     #img-modal__prev:hover, #img-modal__next:hover { opacity: 1; }
  3197.     #img-modal__prev { left: 12px; }
  3198.     #img-modal__next { right: 12px; }
  3199.     @media (max-width: 767px) {
  3200.         #img-modal__prev, #img-modal__next { font-size: 28px; padding: 8px 12px; }
  3201.     }
  3202.     </style>
  3203.     <script>
  3204.     (function(){
  3205.         var images = [];
  3206.         var current = 0;
  3207.         // Collect original (non-cloned) slide images at click time.
  3208.         // After Slick init, slides are wrapped in .slick-slide; clones have .slick-cloned.
  3209.         function collectImages() {
  3210.             images = [];
  3211.             var $slides = $('.item_visual .slick-slide:not(.slick-cloned)');
  3212.             if (!$slides.length) {
  3213.                 // Slick not yet initialized (fallback)
  3214.                 $slides = $('.item_visual .slide-item');
  3215.             }
  3216.             $slides.each(function() {
  3217.                 var $a = $(this).find('a.js-zoom');
  3218.                 if ($a.length) {
  3219.                     images.push({ src: $a.attr('href'), alt: $a.find('img').attr('alt') || '' });
  3220.                 }
  3221.             });
  3222.         }
  3223.         function showImage(idx) {
  3224.             current = ((idx % images.length) + images.length) % images.length;
  3225.             $('#img-modal__img').attr({ src: images[current].src, alt: images[current].alt });
  3226.         }
  3227.         function openModal(href) {
  3228.             collectImages();
  3229.             if (!images.length) return;
  3230.             var idx = 0;
  3231.             for (var i = 0; i < images.length; i++) {
  3232.                 if (images[i].src === href) { idx = i; break; }
  3233.             }
  3234.             showImage(idx);
  3235.             $('#img-modal').addClass('is-open');
  3236.             $('body').css('overflow', 'hidden');
  3237.         }
  3238.         function closeModal() {
  3239.             $('#img-modal').removeClass('is-open');
  3240.             $('body').css('overflow', '');
  3241.         }
  3242.         // Click handler: works for both original and Slick-cloned anchors
  3243.         $(document).on('click', '.item_visual a.js-zoom', function(e) {
  3244.             e.preventDefault();
  3245.             openModal($(this).attr('href'));
  3246.         });
  3247.         // Close on backdrop click
  3248.         $('#img-modal').on('click', function(e) {
  3249.             if (e.target === this) closeModal();
  3250.         });
  3251.         $('#img-modal__close').on('click', closeModal);
  3252.         $('#img-modal__prev').on('click', function(e) { e.stopPropagation(); showImage(current - 1); });
  3253.         $('#img-modal__next').on('click', function(e) { e.stopPropagation(); showImage(current + 1); });
  3254.         // Keyboard navigation
  3255.         $(document).on('keydown', function(e) {
  3256.             if (!$('#img-modal').hasClass('is-open')) return;
  3257.             if (e.key === 'Escape') closeModal();
  3258.             if (e.key === 'ArrowLeft') showImage(current - 1);
  3259.             if (e.key === 'ArrowRight') showImage(current + 1);
  3260.         });
  3261.         // Touch swipe (horizontal only)
  3262.         var _tx = 0;
  3263.         var $modal = document.getElementById('img-modal');
  3264.         $modal.addEventListener('touchstart', function(e) {
  3265.             _tx = e.changedTouches[0].clientX;
  3266.         }, { passive: true });
  3267.         $modal.addEventListener('touchend', function(e) {
  3268.             var dx = e.changedTouches[0].clientX - _tx;
  3269.             if (Math.abs(dx) > 48) {
  3270.                 dx < 0 ? showImage(current + 1) : showImage(current - 1);
  3271.             }
  3272.         }, { passive: true });
  3273.     })();
  3274.     </script>
  3275. {% endblock %}