{#
This file is part of EC-CUBE
Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
http://www.ec-cube.co.jp/
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'default_frame.twig' %}
{% set body_class = 'product_page' %}
{% block stylesheet %}
<style>
.slick-slider {
margin-bottom: 10px;
margin-top: -20px;
}
.slick-dots {
position: absolute;
bottom: -45px;
display: block;
width: 100%;
padding: 0;
list-style: none;
text-align: center;
}
.slick-dots li {
position: relative;
display: inline-block;
width: 20px;
height: 20px;
margin: 0 5px;
padding: 0;
cursor: pointer;
}
.slick-dots li button {
font-size: 0;
line-height: 0;
display: block;
width: 20px;
height: 20px;
padding: 5px;
cursor: pointer;
color: transparent;
border: 0;
outline: none;
background: transparent;
}
.slick-dots li button:hover,
.slick-dots li button:focus {
outline: none;
}
.slick-dots li button:hover:before,
.slick-dots li button:focus:before {
opacity: 1;
}
.slick-dots li button:before {
content: " ";
line-height: 20px;
position: absolute;
top: 0;
left: 0;
width: 12px;
height: 12px;
text-align: center;
opacity: .25;
background-color: black;
border-radius: 50%;
}
.slick-dots li.slick-active button:before {
opacity: .75;
background-color: black;
}
.slick-dots li button.thumbnail img {
width: 0;
height: 0;
}
</style>
<link rel="stylesheet" href="/html/user_data/js/style.css">
<link rel="stylesheet" href="/html/plugins/icheck-bootstrap/icheck-bootstrap.min.css">
<style>
/* Show zoom cursor on product images to hint click-to-expand */
.item_visual .slide-item a { display: block; cursor: zoom-in; }
</style>
<style>
/* ============================================
商品詳細グリッド: 画像50% / 内容50%(均等)
============================================ */
@media (min-width: 768px) {
body.product_page .ec-grid2 {
display: flex;
align-items: flex-start;
}
body.product_page .ec-grid2 .ec-grid2__cell {
width: 50%;
flex: 0 0 50%;
min-width: 0;
}
body.product_page .ec-grid2 .ec-grid2__cell2 {
width: 50%;
flex: 0 0 50%;
min-width: 0;
}
}
/* ============================================
商品説明欄内のHTMLが画面幅を突き抜けないように
============================================ */
body.product_page .ec-productRole__description {
min-width: 0;
overflow-wrap: break-word;
word-break: break-word;
}
body.product_page .ec-productRole__description img,
body.product_page .ec-productRole__description table,
body.product_page .ec-productRole__description iframe,
body.product_page .ec-productRole__description video {
max-width: 100% !important;
height: auto;
}
body.product_page .ec-productRole__description table {
display: block;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}
/* ============================================
スマホ用 見積金額 下部固定バー
============================================ */
#sp-mitsumori-bar {
display: none;
}
/* ============================================
商品タイプ選択 共通スタイル
============================================ */
/* セクションラベル */
.rp-section-label {
font-size: 14px;
font-weight: bold;
color: #333;
margin-bottom: 10px;
}
.rp-section-label span {
font-weight: normal;
color: #c00;
}
/* ---- 1. 画像付きカード ---- */
.rp-card-group {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-bottom: 4px;
}
.rp-card {
position: relative;
cursor: pointer;
width: 110px;
border: 2px solid #ddd;
border-radius: 10px;
overflow: hidden;
transition: border-color 0.2s, box-shadow 0.2s;
background: #fff;
}
/* Gate :hover behind real hover-capable pointers. On iOS Safari a
:hover rule that changes appearance makes the first tap apply the
hover state and suppresses the click, so the option chip needed a
second tap to fire its onclick (is-selected + price update). */
@media (hover: hover) and (pointer: fine) {
.rp-card:hover {
border-color: #999;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
}
.rp-card.is-selected {
border-color: #1a6fcf;
box-shadow: 0 2px 10px rgba(26,111,207,0.25);
}
.rp-card input[type="radio"] { display: none; }
.rp-card__image {
width: 100%;
aspect-ratio: 1 / 1;
object-fit: cover;
display: block;
background: #f5f5f5;
}
.rp-card__placeholder {
width: 100%;
aspect-ratio: 1 / 1;
background: #f0f0f0;
display: flex;
align-items: center;
justify-content: center;
color: #bbb;
font-size: 24px;
}
.rp-card__name {
display: block;
padding: 5px 5px;
font-size: 11px;
color: #333;
text-align: center;
line-height: 1.4;
word-break: break-all;
}
.rp-card.is-selected .rp-card__name { color: #1a6fcf; font-weight: bold; }
.rp-card.is-selected::after {
content: "✓";
position: absolute;
top: 3px; right: 6px;
color: #1a6fcf;
font-size: 13px;
font-weight: bold;
}
/* ---- 2. ボタン式ラジオ(画像なし・8個以内)---- */
.rp-btn-group {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-bottom: 4px;
max-width: 100%;
min-width: 0;
}
.rp-btn {
cursor: pointer;
padding: 8px 14px;
border: 2px solid #ddd;
border-radius: 10px;
font-size: 13px;
color: #333;
background: #fff;
transition: border-color 0.2s, background 0.2s;
white-space: nowrap;
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
}
@media (hover: hover) and (pointer: fine) {
.rp-btn:hover { border-color: #999; }
}
.rp-btn.is-selected {
border-color: #1a6fcf;
color: #1a6fcf;
font-weight: bold;
background: #f0f6ff;
}
.rp-btn input[type="radio"] { display: none; }
/* ---- ボタン群が3行以上になる場合は1行横スクロール ---- */
.rp-btn-group.is-scroll,
.opt-btn-group.is-scroll {
flex-wrap: nowrap;
overflow-x: auto;
overflow-y: hidden;
-webkit-overflow-scrolling: touch;
scrollbar-width: thin;
padding-bottom: 6px;
}
.rp-btn-group.is-scroll::-webkit-scrollbar,
.opt-btn-group.is-scroll::-webkit-scrollbar {
height: 6px;
}
.rp-btn-group.is-scroll::-webkit-scrollbar-thumb,
.opt-btn-group.is-scroll::-webkit-scrollbar-thumb {
background: #c0c0c0;
border-radius: 3px;
}
.rp-btn-group.is-scroll > .rp-btn,
.opt-btn-group.is-scroll > .opt-btn {
flex: 0 0 auto;
}
/* ---- 3. プルダウン(画像なし・9個以上)---- */
.rp-select-wrap {
margin-bottom: 4px;
}
.rp-select {
width: 100%;
max-width: 420px;
padding: 8px 12px;
border: 2px solid #ddd;
border-radius: 10px;
font-size: 13px;
color: #333;
background: #fff;
appearance: none;
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");
background-repeat: no-repeat;
background-position: right 12px center;
cursor: pointer;
}
.rp-select:focus {
outline: none;
border-color: #1a6fcf;
}
/* ---- オプション選択ボタン(枠線ラジオ)---- */
.opt-btn-group {
display: flex;
flex-wrap: wrap;
gap: 8px;
padding: 6px 0;
max-width: 100%;
min-width: 0;
}
.opt-btn {
cursor: pointer;
padding: 7px 14px;
border: 2px solid #ddd;
border-radius: 10px;
font-size: 13px;
color: #333;
background: #fff;
transition: border-color 0.2s, background 0.2s;
white-space: nowrap;
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
}
@media (hover: hover) and (pointer: fine) {
.opt-btn:hover { border-color: #999; }
}
.opt-btn.is-selected {
border-color: #1a6fcf;
color: #1a6fcf;
font-weight: bold;
background: #f0f6ff;
}
.opt-btn input[type="radio"] { display: none; }
/* opt-btn with color swatch image. The label still works as a
radio target — clicking the image checks the input. The text
label stays under the image so users can still read the name. */
.opt-btn--with-image {
padding: 4px 6px 6px;
white-space: normal;
text-align: center;
display: inline-flex;
flex-direction: column;
align-items: center;
min-width: 96px;
max-width: 140px;
}
.opt-btn--with-image .opt-btn__img {
display: block;
width: 88px;
height: 66px;
object-fit: cover;
border-radius: 6px;
margin-bottom: 4px;
background: #f5f5f5;
}
.opt-btn--with-image .opt-btn__name {
display: block;
font-size: 11px;
line-height: 1.3;
color: inherit;
}
.opt-btn--with-image.is-selected .opt-btn__img {
outline: 2px solid #1a6fcf;
outline-offset: 1px;
}
/* ============================================
施工エリア案内
============================================ */
.ec-areaNotice {
margin: 16px 0;
padding: 16px 20px;
background: #f8f9fa;
border-left: 4px solid #1a6fcf;
border-radius: 0 8px 8px 0;
}
.ec-areaNotice__inner {
display: flex;
align-items: flex-start;
gap: 12px;
}
.ec-areaNotice__icon {
font-size: 22px;
line-height: 1;
flex-shrink: 0;
margin-top: 2px;
}
.ec-areaNotice__body {
flex: 1;
}
.ec-areaNotice__title {
font-size: 13px;
font-weight: bold;
color: #1a6fcf;
margin: 0 0 6px;
}
.ec-areaNotice__text {
font-size: 13px;
color: #444;
line-height: 1.7;
margin: 0;
}
.ec-areaNotice__text strong {
color: #222;
}
.ec-areaNotice__link {
display: inline-block;
margin-top: 8px;
font-size: 12px;
color: #1a6fcf;
text-decoration: underline;
}
.ec-areaNotice__link:hover {
color: #0d4fa0;
}
/* ============================================
SNSシェア + ブランド名 タイトル行
============================================ */
.ec-productRole__titleRow {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-bottom: 4px;
}
.ec-productRole__titleRow .ec-headingTitle {
margin: 0;
flex: 1;
font-size: 18px;
}
.ec-share-inline {
display: flex;
align-items: center;
gap: 8px;
flex-shrink: 0;
}
@media (max-width: 767px) {
/* maker_area の float を解除して独立表示 */
#maker_area {
float: none !important;
width: auto !important;
height: auto !important;
display: block;
margin-bottom: 4px;
}
/* タイトル行: 商品名が全幅を占有しSNSは右寄せ下段 */
.ec-productRole__titleRow {
flex-wrap: wrap;
clear: both;
}
.ec-productRole__titleRow .ec-headingTitle {
flex: 1 1 100%;
font-size: 16px;
}
.ec-share-inline {
flex: 0 0 auto;
margin-left: auto;
}
}
.ec-share-inline a {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border-radius: 50%;
font-size: 15px;
color: #fff;
text-decoration: none;
transition: opacity 0.2s;
}
.ec-share-inline a:hover { opacity: 0.8; }
.ec-share-inline .share-twitter { background: #000; }
.ec-share-inline .share-facebook { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
.ec-share-inline .share-line { background: #06c755; }
/* description_detail下のシェアブロックはPC/スマホ共通で非表示(タイトル行に移動) */
.ec-productRole__share { display: none; }
/* ============================================
PC用: 現在のお見積り額カード強調
============================================ */
@media (min-width: 768px) {
.mitsumori-card-pc {
border: 2px solid #1a6fcf !important;
border-radius: 10px !important;
box-shadow: 0 4px 16px rgba(26,111,207,0.18) !important;
margin-top: 20px;
overflow: hidden;
background: linear-gradient(135deg, #1a6fcf, #0d4fa0) !important;
}
.mitsumori-card-pc .card-header {
background: linear-gradient(135deg, #1a6fcf, #0d4fa0) !important;
color: #fff !important;
padding: 14px 16px !important;
border-bottom: none !important;
}
.mitsumori-card-pc .card-title {
color: #fff !important;
font-size: 15px !important;
font-weight: bold !important;
margin: 0 !important;
}
.mitsumori-card-pc #mitsumori_message {
font-size: 22px !important;
font-weight: bold !important;
color: #fff !important;
}
.mitsumori-card-pc .btn-tool {
color: #fff !important;
}
/* 合計行を大きく強調 */
.mitsumori-card-pc .nav-item:first-child .nav-link {
font-size: 16px !important;
font-weight: bold !important;
color: #c00 !important;
background: #fff8f8 !important;
padding: 12px 16px !important;
}
.mitsumori-card-pc .nav-item:first-child #mitsumori_goukei {
font-size: 20px !important;
font-weight: bold !important;
color: #c00 !important;
}
/* card-body(明細リスト)を白背景に */
.mitsumori-card-pc .card-body {
background: #fff !important;
}
.mitsumori-card-pc .card-footer {
background: #f8faff !important;
border-top: 1px solid #dce8fb !important;
padding: 12px 16px !important;
}
}
@media (max-width: 767px) {
/* スマホでは現在のお見積り額カードの強調スタイルをすべてリセット */
.mitsumori-card-pc {
border: none !important;
border-radius: 0 !important;
box-shadow: none !important;
margin-top: 0 !important;
overflow: visible !important;
background: none !important;
}
.mitsumori-card-pc .card-header {
background: none !important;
color: inherit !important;
padding: inherit !important;
border-bottom: inherit !important;
}
.mitsumori-card-pc .card-title { color: inherit !important; }
.mitsumori-card-pc #mitsumori_message { font-size: inherit !important; color: inherit !important; }
.mitsumori-card-pc .btn-tool { color: inherit !important; }
/* 折りたたみトグルボタン */
.btn-mitsumori-toggle {
background: none !important;
border: 1px solid #aaa !important;
border-radius: 4px !important;
padding: 2px 8px !important;
font-size: 12px !important;
color: #333 !important;
line-height: 1.4 !important;
}
.btn-mitsumori-toggle .toggle-icon {
display: inline-block;
transition: transform 0.2s;
}
/* 展開状態: ▼→▲ */
.card:not(.collapsed-card) .btn-mitsumori-toggle .toggle-icon::before {
content: "▲ 閉じる";
}
.card:not(.collapsed-card) .btn-mitsumori-toggle .toggle-icon {
display: none;
}
.card:not(.collapsed-card) .btn-mitsumori-toggle::after {
content: "▲ 閉じる";
font-size: 12px;
}
.mitsumori-card-pc .nav-item:first-child .nav-link {
font-size: inherit !important;
color: inherit !important;
background: none !important;
padding: inherit !important;
}
.mitsumori-card-pc .nav-item:first-child #mitsumori_goukei {
font-size: inherit !important;
color: inherit !important;
}
.mitsumori-card-pc .card-footer {
background: none !important;
border-top: inherit !important;
padding: inherit !important;
}
/* 横スクロール禁止 */
body, html {
overflow-x: hidden;
max-width: 100vw;
}
/* ボタンの折り返しを許可(nowrapが原因で横スクロール発生するため) */
.opt-btn,
.rp-btn {
white-space: normal;
word-break: break-all;
}
/* エリア案内: スマホでコンパクト */
.ec-areaNotice {
margin: 8px 0;
padding: 8px 10px;
border-left-width: 3px;
cursor: pointer;
}
.ec-areaNotice__inner {
flex-direction: row;
gap: 8px;
align-items: flex-start;
}
.ec-areaNotice__icon { font-size: 15px; }
/* タイトル行: 展開トグル */
.ec-areaNotice__title {
font-size: 11px;
margin-bottom: 3px;
display: flex;
justify-content: space-between;
align-items: center;
}
.ec-areaNotice__title::after {
content: "▼";
font-size: 9px;
color: #888;
margin-left: 6px;
transition: transform 0.2s;
}
.ec-areaNotice.is-open .ec-areaNotice__title::after {
transform: rotate(180deg);
}
/* 折りたたみ対象: 閉じた状態では非表示 */
.ec-areaNotice__detail {
display: none;
}
.ec-areaNotice.is-open .ec-areaNotice__detail {
display: block;
}
.ec-areaNotice__text { font-size: 11px; line-height: 1.5; }
.ec-areaNotice__text br { display: none; }
.ec-areaNotice__link { font-size: 11px; margin-top: 3px; }
.rp-card { width: calc(33.333% - 6px); min-width: 80px; }
#sp-mitsumori-bar {
display: flex;
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 1000;
background: #fff;
border-top: 2px solid #e0e0e0;
box-shadow: 0 -2px 8px rgba(0,0,0,0.12);
align-items: center;
padding: 8px 12px calc(8px + env(safe-area-inset-bottom)) 12px;
gap: 10px;
}
#sp-mitsumori-bar .sp-bar__label {
font-size: 11px;
color: #666;
white-space: nowrap;
}
#sp-mitsumori-bar .sp-bar__price {
font-size: 18px;
font-weight: bold;
color: #c00;
flex: 1;
}
#sp-mitsumori-bar .sp-bar__btn {
font-size: 12px;
padding: 8px 12px;
background: #333;
color: #fff;
border: none;
border-radius: 6px;
white-space: nowrap;
cursor: pointer;
position: relative;
display: inline-flex;
align-items: center;
gap: 6px;
}
#sp-mitsumori-bar .sp-bar__btn i {
font-size: 14px;
}
#sp-mitsumori-bar .sp-bar__cart-badge {
position: absolute;
top: -6px;
right: -6px;
background: #c00;
color: #fff;
border-radius: 50%;
min-width: 16px;
height: 16px;
font-size: 10px;
line-height: 16px;
padding: 0 4px;
font-weight: bold;
}
#sp-mitsumori-bar .sp-bar__home-btn {
display: inline-flex;
align-items: center;
justify-content: center;
width: 36px;
height: 36px;
border: 1px solid #ccc;
border-radius: 6px;
background: #fff;
color: #333;
text-decoration: none;
cursor: pointer;
}
#sp-mitsumori-bar .sp-bar__home-btn i {
font-size: 16px;
}
#sp-mitsumori-bar .sp-bar__home-btn:hover {
background: #f0f0f0;
}
/* 下部バーの高さ分ページ下部にpaddingを追加 (iOS safe-area 込み) */
body {
padding-bottom: calc(80px + env(safe-area-inset-bottom));
}
}
/* ============================================
カート追加モーダル: 縦並び中央配置
============================================ */
.add-cart-modal__wrap {
text-align: center;
}
.add-cart-modal__header {
font-size: 16px;
margin: 20px 0 24px;
text-align: center;
}
.add-cart-modal__actions {
display: flex;
flex-direction: column;
align-items: center;
gap: 16px;
padding: 0 20px 20px;
}
.add-cart-modal__primary {
display: inline-block;
width: 80%;
max-width: 320px;
padding: 14px 20px;
font-size: 15px;
font-weight: bold;
text-align: center;
background: #d9534f;
color: #fff !important;
border-radius: 6px;
text-decoration: none;
cursor: pointer;
}
.add-cart-modal__primary:hover {
background: #c9302c;
color: #fff !important;
text-decoration: none;
}
.add-cart-modal__secondary {
display: inline-block;
padding: 6px 14px;
font-size: 12px;
color: #666;
border: 1px solid #ccc;
border-radius: 4px;
background: #fff;
cursor: pointer;
}
.add-cart-modal__secondary:hover {
background: #f0f0f0;
color: #333;
}
@media (max-width: 767px) {
.add-cart-modal__actions {
gap: 20px;
}
}
</style>
{% endblock %}
{% block javascript %}
<script>
eccube.classCategories = {{ class_categories_as_json(Product)|raw }};
// 規格2に選択肢を割り当てる。
function fnSetClassCategories(form, classcat_id2_selected) {
var $form = $(form);
var product_id = $form.find('input[name=product_id]').val();
var $sele1 = $form.find('select[name=classcategory_id1]');
var $sele2 = $form.find('select[name=classcategory_id2]');
eccube.setClassCategories($form, product_id, $sele1, $sele2, classcat_id2_selected);
}
{% if form.classcategory_id2 is defined %}
fnSetClassCategories(
$('#form1'), {{ form.classcategory_id2.vars.value|json_encode|raw }}
);
{% elseif form.classcategory_id1 is defined %}
eccube.checkStock($('#form1'), {{ Product.id }}, {{ form.classcategory_id1.vars.value|json_encode|raw }}, null);
{% endif %}
</script>
<script>
$(function() {
// bfcache無効化
$(window).bind('pageshow', function(event) {
if (event.originalEvent.persisted) {
location.reload(true);
}
});
// Core Web Vital の Cumulative Layout Shift(CLS)対策のため
// img タグに width, height が付与されている.
// 630px 未満の画面サイズでは縦横比が壊れるための対策
// see https://github.com/EC-CUBE/ec-cube/pull/5023
$('.ec-grid2__cell').hide();
var removeSize = function () {
$('.slide-item').height('');
$('.slide-item img')
.removeAttr('width')
.removeAttr('height')
.removeAttr('style');
};
var slickInitial = function(slick) {
$('.ec-grid2__cell').fadeIn(1500);
var baseHeight = $(slick.target).height();
var baseWidth = $(slick.target).width();
var rate = baseWidth / baseHeight;
if(baseHeight * rate < 400){
$('.slide-item').height(baseHeight * rate); // 余白を削除する
}else{
$('.slide-item').height(400); // 余白を削除する
}
// transform を使用することでCLSの影響を受けないようにする
$('.slide-item img')
.css(
{
'transform-origin': 'top left',
'transform': 'scaleY(' + rate + ')',
'transition': 'transform .1s'
}
);
// 正しいサイズに近くなったら属性を解除する
setTimeout(removeSize, 500);
};
$('.item_visual').on('init', slickInitial);
// リサイズ時は CLS の影響を受けないため属性を解除する
$(window).resize(removeSize);
$('.item_visual').slick({
dots: false,
arrows: true,
responsive: [{
breakpoint: 768,
settings: {
dots: true,
arrows: false
}
}]
});
$('.slideThumb').on('click', function() {
var index = $(this).attr('data-index');
$('.item_visual').slick('slickGoTo', index, false);
})
});
</script>
<script>
$(function() {
$('.add-cart').on('click', function(event) {
{% if form.classcategory_id1 is defined %}
// 規格1フォームの必須チェック
if ($('#classcategory_id1').val() == '__unselected' || $('#classcategory_id1').val() == '') {
$('#classcategory_id1')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
return true;
} else {
$('#classcategory_id1')[0].setCustomValidity('');
}
{% endif %}
{% if form.classcategory_id2 is defined %}
// 規格2フォームの必須チェック
if ($('#classcategory_id2').val() == '__unselected' || $('#classcategory_id2').val() == '') {
$('#classcategory_id2')[0].setCustomValidity('{{ '項目が選択されていません'|trans }}');
return true;
} else {
$('#classcategory_id2')[0].setCustomValidity('');
}
{% endif %}
// タイプ2: カート送信直前に set_count を quantity に同期
if($('#set_count').length){
var _sc = parseInt($('#set_count').val()) || 1;
$('#quantity').val(_sc);
$('input[name="quantity"]').val(_sc);
}
// 個数フォームのチェック
if ($('#quantity').val() < 1) {
$('#quantity')[0].setCustomValidity('{{ '1以上で入力してください。'|trans }}');
return true;
} else {
$('#quantity')[0].setCustomValidity('');
}
event.preventDefault();
$form = $('#form1');
$.ajax({
url: $form.attr('action'),
type: $form.attr('method'),
data: $form.serialize(),
dataType: 'json',
beforeSend: function(xhr, settings) {
// Buttonを無効にする
$('.add-cart').prop('disabled', true);
}
}).done(function(data) {
// レスポンス内のメッセージをalertで表示
$.each(data.messages, function() {
$('#ec-modal-header').text(this);
});
$('.ec-modal').show()
// カートブロックを更新する
$.ajax({
url: "{{ url('block_cart') }}",
type: 'GET',
dataType: 'html'
}).done(function(html) {
$('.ec-headerRole__cart').html(html);
});
}).fail(function(data) {
alert('{{ 'カートへの追加に失敗しました。'|trans }}');
}).always(function(data) {
// Buttonを有効にする
$('.add-cart').prop('disabled', false);
});
});
});
$('.ec-modal-wrap').on('click', function(e) {
// モーダル内の処理は外側にバブリングさせない
e.stopPropagation();
});
$('.ec-modal-overlay, .ec-modal, .ec-modal-close, .ec-inlineBtn--cancel').on('click', function() {
$('.ec-modal').hide()
});
var pw = "{% if mitsumori_json %}{{ mitsumori_json.pw }}{% endif %}";
var pd = "{% if mitsumori_json %}{{ mitsumori_json.pd }}{% endif %}";
var ph = "{% if mitsumori_json %}{{ mitsumori_json.ph }}{% endif %}";
var pm = "{% if mitsumori_json %}{{ mitsumori_json.pm }}{% endif %}";
var pc = "{% if mitsumori_json %}{{ mitsumori_json.pc }}{% endif %}";
// option1 / option2: カテゴリ別 option 軸 (um: タイプ=subtype, fe: ct_up 等)
var option1 = "{% if mitsumori_json and mitsumori_json.option1 is defined %}{{ mitsumori_json.option1 }}{% endif %}";
var option2 = "{% if mitsumori_json and mitsumori_json.option2 is defined %}{{ mitsumori_json.option2 }}{% endif %}";
var op0 = "{% if mitsumori_json %}{{ mitsumori_json.op[0] }}{% endif %}";
var op1 = "{% if mitsumori_json %}{{ mitsumori_json.op[1] }}{% endif %}";
var op2 = "{% if mitsumori_json %}{{ mitsumori_json.op[2] }}{% endif %}";
var op3 = "{% if mitsumori_json %}{{ mitsumori_json.op[3] }}{% endif %}";
var op4 = "{% if mitsumori_json %}{{ mitsumori_json.op[4] }}{% endif %}";
var op5 = "{% if mitsumori_json %}{{ mitsumori_json.op[5] }}{% endif %}";
var op6 = "{% if mitsumori_json %}{{ mitsumori_json.op[6] }}{% endif %}";
var op7 = "{% if mitsumori_json %}{{ mitsumori_json.op[7] }}{% endif %}";
var op8 = "{% if mitsumori_json %}{{ mitsumori_json.op[8] }}{% endif %}";
var op9 = "{% if mitsumori_json %}{{ mitsumori_json.op[9] }}{% endif %}";
var op10 = "{% if mitsumori_json %}{{ mitsumori_json.op[10] }}{% endif %}";
const formatter = new Intl.NumberFormat('ja-JP');
// ============================================================
// free_area 1 エントリのスキーマ(11 キー固定)
// ============================================================
// w : 幅 (string, 例 "239.9cm" / tf は "1m")
// d : 奥行
// h : 高さ (tf はロール長 "10m")
// m : 素材
// c : カラー
// price : 販売価格 (税抜、amount=1 ベース)
// unit_price : 商品 per-unit 増分 (税抜、AMOUNT_CATEGORIES のみ)
// maker_price : メーカー価格 (税抜)
// ct : 基本工事費 (税抜、amount=1 ベース)
// option1 : fe → ct_up / その他カテゴリ → category-specific
// option2 : um → ct_up / その他カテゴリ → category-specific
//
// ct4 (設置場所) / ct5 (撤去) / ct6 (残土) は option_area 側で扱う.
// ============================================================
// 施工オプション定義(option_area)— 各エントリ {name, comment, on, off, price}
var op_data = {{ op_json|default('[]')|raw }};
// tg カテゴリ用 block 別オプション差額表 (option_item_area).
// 構造: { axis_labels: {F:'床材',front:'前面型',side1:'右側面型',side2:'左側面型'},
// blocks: { 'W_label|D_label': { F:[{idx,label,diff},...], front:[...], side1:[...], side2:[...] }, ... } }
// tg 以外のカテゴリでは空 ({axis_labels:{}, blocks:{}}).
var oi_data = {{ oi_json|default('{"axis_labels":{},"blocks":{}}')|raw }};
// 選択中の tg オプション差額 (axis -> selected choice_idx). ラジオ click で更新される.
var oi_selected = { F: 1, front: 1, side1: 1, side2: 1 };
// sale_type ID(mtb_sale_type の id。本サイトでの意味は次の通り):
// 1 通常 / 2 補助金窓 / 3 物置 / 4 フェンス / 5 デッキ / 6 芝生 / 9 商品のみ
var SALE_TYPE_ID = {{ ProductClass.SaleType.id }};
{# option1 / option2 ラベルをカテゴリ別に決定 (sh=31, rd=43, mo=15) — 以降の UI / JS 両方で使用 #}
{% set option1_label = 'オプション1' %}
{% set option2_label = 'オプション2' %}
{% if Product.ProductCategories is not empty %}
{% for pcat in Product.ProductCategories %}
{% if pcat.category_id == 31 %}{% set option1_label = 'サイズプリセット' %}{% set option2_label = '駆動方式' %}{% endif %}
{% if pcat.category_id == 43 %}{% set option1_label = 'ランマ' %}{% set option2_label = 'タイプ' %}{% endif %}
{% if pcat.category_id == 15 %}{% set option1_label = '棚タイプ' %}{% endif %}
{% if pcat.category_id == 17 %}{% set option1_label = '窓タイプ' %}{% endif %}
{% endfor %}
{% endif %}
// 消費税率(pp.price/pp.ct/op_data.price は scraper が税抜で保存しているため、
// calcGoukei 出口で 1+TAX_RATE を掛けて税込 mitsumori_goukei にする)
var TAX_RATE = 0.10;
function toIncTax(v) { return Math.round(v * (1 + TAX_RATE)); }
/**
* tg 用 block 別オプション差額の集計.
* 現選択 (W, D) から block key を作り、oi_data.blocks[blockKey] を取得.
* 各 axis (F/front/side1/side2) で oi_selected[axis] の choice の diff を合計.
* 戻り値: { total: 差額合計(税抜), items: [{name, label, diff}, ...] }
* block が無い (tg 以外 / 該当 (W,D) が未取得) なら total=0.
*/
function collectOptionItems(curW, curD) {
var result = { total: 0, items: [] };
if (!oi_data || !oi_data.blocks) return result;
var blockKey = (curW || '') + '|' + (curD || '');
var block = oi_data.blocks[blockKey];
if (!block) return result;
var axes = ['F', 'front', 'side1', 'side2'];
for (var i = 0; i < axes.length; i++) {
var axis = axes[i];
var choices = block[axis];
if (!choices || !choices.length) continue;
var idx = oi_selected[axis] || 1;
var pick = null;
for (var j = 0; j < choices.length; j++) {
if (parseInt(choices[j].idx) === parseInt(idx)) { pick = choices[j]; break; }
}
if (!pick) pick = choices[0];
var diff = parseInt(pick.diff) || 0;
result.total += diff;
result.items.push({
name: oi_data.axis_labels[axis] || axis,
label: pick.label,
diff: diff,
});
}
return result;
}
/**
* tg ラジオ群を block 別に DOM へ描画する.
* W/D が確定したら現 block の 4 軸 (F/front/side1/side2) ラジオを #tg-options 要素に出す.
* block が空なら #tg-options を空にする.
*/
function renderOptionItemRadios(curW, curD) {
var $box = $('#tg-options');
if (!$box.length) return;
$box.empty();
if (!oi_data || !oi_data.blocks) return;
var blockKey = (curW || '') + '|' + (curD || '');
var block = oi_data.blocks[blockKey];
if (!block) return;
var axes = ['F', 'front', 'side1', 'side2'];
axes.forEach(function(axis) {
var choices = block[axis];
if (!choices || !choices.length) return;
var axisLabel = (oi_data.axis_labels && oi_data.axis_labels[axis]) || axis;
var $section = $('<div class="form-group tg-axis"></div>');
$section.append('<p class="rp-section-label"><strong>' + axisLabel + '</strong>: <span class="tg-axis-selected"></span></p>');
var $list = $('<div class="tg-choice-list"></div>');
choices.forEach(function(ch, i) {
var inputId = 'tg_' + axis + '_' + ch.idx;
var name = 'tg_' + axis;
var checked = (parseInt(ch.idx) === parseInt(oi_selected[axis] || 1)) ? ' checked' : '';
var diffTxt = ch.diff > 0 ? '+' + formatter.format(ch.diff) + '円' : (ch.diff < 0 ? formatter.format(ch.diff) + '円' : '±0');
$list.append(
'<label class="tg-choice"><input type="radio" name="' + name + '" id="' + inputId + '" value="' + ch.idx + '" data-axis="' + axis + '"' + checked + '> ' +
ch.label + '<span class="tg-diff">(' + diffTxt + ')</span></label>'
);
});
$section.append($list);
$box.append($section);
});
// ラジオ click で oi_selected を更新 → 再計算
$box.off('change.tg').on('change.tg', 'input[type="radio"][data-axis]', function() {
var axis = $(this).data('axis');
oi_selected[axis] = parseInt($(this).val()) || 1;
mitsumori_simulation('refresh', '');
});
updateOptionItemSelectedLabels();
}
function updateOptionItemSelectedLabels() {
$('#tg-options .tg-axis').each(function() {
var $sel = $(this).find('input[type="radio"]:checked');
if (!$sel.length) return;
var label = $sel.parent().contents().filter(function() { return this.nodeType === 3; }).text().trim();
$(this).find('.tg-axis-selected').text(label);
});
}
/**
* 選択中の施工オプションを集計し、ON選択分の price を合計する.
* 戻り値: { total: 合計金額, items: [{name, value, price}, ...] }
*/
function collectOptions() {
var ops = [op0,op1,op2,op3,op4,op5,op6,op7,op8,op9,op10];
var total = 0;
var items = [];
for (var i = 0; i < ops.length; i++) {
if (!op_data[i] || !op_data[i].name) continue;
var sel = ops[i];
if (!sel) continue;
var price = parseInt(op_data[i].price) || 0;
// 「ON」選択時のみ加算(OFF や「不要」「商品購入のみ」は加算しない)
var isOn = (sel === op_data[i].on);
items.push({
name: op_data[i].name,
value: sel,
price: isOn ? price : 0,
on: op_data[i].on,
off: op_data[i].off,
});
if (isOn) total += price;
}
return { total: total, items: items };
}
/**
* free_area 1 エントリ ({w,d,h,m,c,price,unit_price,maker_price,ct,option1,option2})
* から sale_type 別に最終金額を算出する.
*
* 計算式(amount=1 ベース、出口で × 1.10 税込化):
* 1 通常 : price + ct + option_sum
* 2 補助金窓 : price × set_count + (ct + (set_count-1) × option2) + option_sum
* 3 物置 : (price + ct) × daisu + option_sum
* 4 フェンス : price + (maisu-1) × unit_price
* + ct + max(0, maisu-3) × option1
* + option_sum (maisu >= 3)
* 5 デッキ : price + ct + option_sum (area は表示用、計算非関与)
* 6 芝生 : price × ceil(area / (w_m × h_m)) + ct + option_sum
* 9 商品のみ : price のみ(カート quantity 倍で総額)
*
* fe では option1 を ct_up、um では option2 を ct_up として転用.
* tf では w / h にロール幅・長さが格納されており parseLen で数値抽出.
*
* @param {Object} pp free_area の 1 行(matrix エントリ)
* @param {number} optionTotal collectOptions().total
* @param {Object} ctx UI 入力 {set_count, daisu, maisu, area, quantityOnly, ...}
* @returns {Object} {goukei, price, ct, opt, qty} すべて税込整数
*/
function calcGoukei(pp, optionTotal, ctx) {
var basePrice = parseInt(pp.price) || 0;
var baseCt = parseInt(pp.ct) || 0;
var unitPrice = parseInt(pp.unit_price) || 0;
var optSum = optionTotal;
var price = basePrice;
var ct = baseCt;
var qty = 1;
var goukei = 0;
// 「商品購入のみ」選択時は工事費・オプションをゼロにする(任意 sale_type で適用)
var ops = [op0,op1,op2,op3,op4,op5,op6,op7,op8,op9,op10];
var purchaseOnly = ops.some(function(v){ return v === '商品購入のみ'; });
if (purchaseOnly) {
baseCt = 0;
ct = 0;
optSum = 0;
}
switch (SALE_TYPE_ID) {
case 2: { // 補助金・窓 (シンプル表引き方式 2026-05-)
// 2026-05 仕様簡素化: 枚数軸を廃止し、subtype に枚数を内包.
// pp.price / pp.ct は (W, H, ガラス, subtype) の単一価格.
// 複数枚をまとめて買う場合はカート quantity で表現.
qty = 1;
price = basePrice;
ct = baseCt;
goukei = price + ct + optSum;
break;
}
case 3: { // 物置・ゴミステーション
qty = Math.max(1, parseInt(ctx.daisu) || 1);
price = basePrice * qty;
ct = baseCt * qty;
goukei = price + ct + optSum;
break;
}
case 4: { // フェンス・組み立て式(maisu ≥ 3、base_amount = 3)
// scraper は amount=3 を base にしているので pp.price = price(3),
// pp.unit_price = price(4) - price(3).
qty = Math.max(3, parseInt(ctx.maisu) || 3);
price = basePrice + (qty - 3) * unitPrice;
// option1 が ct_up (4枚目以降の増分). 未設定なら ct 固定動作
var ctUp1 = parseInt(pp.option1) || 0;
ct = baseCt + Math.max(0, qty - 3) * ctUp1;
goukei = price + ct + optSum;
break;
}
case 5: { // ウッドデッキ・タイルデッキ
// area は担当者向けの参考値として保持(計算には使わない)
qty = 1;
goukei = basePrice + baseCt + optSum;
price = basePrice;
ct = baseCt;
break;
}
case 6: { // 芝生・人工芝(ロール単位)
// pp.w "1m", pp.h "10m" から数値抽出
var w_m = parseLen(pp.w);
var h_m = parseLen(pp.h);
var rollSize = w_m * h_m;
if (!rollSize || rollSize <= 0) rollSize = 1;
var area = parseFloat(ctx.area) || rollSize;
qty = Math.max(1, Math.ceil(area / rollSize));
price = basePrice * qty;
ct = baseCt;
goukei = price + ct + optSum;
break;
}
case 7: { // 数量買い・基本工事費固定(gf ガーデンファニチャー / st 石材)
qty = Math.max(1, parseInt(ctx.suuryou) || 1);
price = basePrice * qty;
ct = baseCt; // ct は固定(数量に依らない)
goukei = price + ct + optSum;
break;
}
case 9: { // 商品のみ購入
// カート側で quantity × unit price するため goukei は単品価格
qty = parseInt(ctx.quantityOnly) || 1;
price = basePrice;
ct = 0;
optSum = 0;
goukei = price;
break;
}
default: { // 1: 通常(カーポート等、matrix 選択のみ)
qty = 1;
goukei = basePrice + baseCt + optSum;
break;
}
}
// 出口で税込化(pp.price/pp.ct/op_data.price はすべて税抜で保存されている前提)
return {
goukei: toIncTax(goukei),
price: toIncTax(price),
ct: toIncTax(ct),
opt: toIncTax(optSum),
qty: qty,
};
}
/**
* 寸法文字列から「メートル単位の数値」を抽出する.
*
* 単位は m / cm / mm を認識し、いずれも m 単位に正規化して返す.
* 単位が無い場合は m 単位とみなす(旧 tf データ "1m" "10m" との互換).
* 数値が見つからない場合は 0 を返す(呼び出し側で fallback).
*
* 例:
* "1m" → 1
* "100cm" → 1 (2026-06 以降の m → cm 正規化に対応)
* "200cm" → 2
* "5.5m" → 5.5
* "1000mm" → 1
* "" → 0
*/
function parseLen(s) {
if (!s) return 0;
var str = String(s);
var m = str.match(/(\d+(?:\.\d+)?)\s*(mm|cm|m)?/i);
if (!m) return 0;
var n = parseFloat(m[1]);
if (isNaN(n)) return 0;
var unit = (m[2] || 'm').toLowerCase();
if (unit === 'cm') return n / 100;
if (unit === 'mm') return n / 1000;
return n; // 'm' or no unit
}
// pp は autoSelectFirstColor 等からも参照するので global にする
var pp = {{ pp|raw }};
function mitsumori_simulation(type , value_id){
// 価格データ未登録 (pp 行 0 件) の商品は axis 入力に依存せず
// 「価格データ準備中」を表示して終了する.
// (例: scrape 未対象の新規商品 — um のウチリモ 7487/7488 等)
if (!pp || pp.length === 0) {
$('#mitsumori_message').text("価格データ準備中");
$('#mitsumori_btn').hide();
$('#mitsumori_goukei').text("---円");
$('#mitsumori_off').text("---円");
$('#mitsumori_price').text("---円");
$('#maker_price').text("---円");
$('#mitsumori_ct').text("---円");
$('#mitsumori_option').text("---円");
$('#mitsumori_kei').text("---円");
$('#mitsumori_shoukei').text("---円");
$('#mitsumori_tax').text("---円");
return;
}
if(type == "pw"){
pw = $('#'+value_id).val();
}
if(type == "pd"){
pd = $('#'+value_id).val();
}
if(type == "ph"){
ph = $('#'+value_id).val();
}
if(type == "pm"){
pm = $('#'+value_id).val();
}
if(type == "pc"){
pc = $('#'+value_id).val();
}
if(type == "option1"){
option1 = $('#'+value_id).val();
}
if(type == "option2"){
option2 = $('#'+value_id).val();
}
if(type == "op0"){ op0 = $('#'+value_id).val(); }
if(type == "op1"){ op1 = $('#'+value_id).val(); }
if(type == "op2"){ op2 = $('#'+value_id).val(); }
if(type == "op3"){ op3 = $('#'+value_id).val(); }
if(type == "op4"){ op4 = $('#'+value_id).val(); }
if(type == "op5"){ op5 = $('#'+value_id).val(); }
if(type == "op6"){ op6 = $('#'+value_id).val(); }
if(type == "op7"){ op7 = $('#'+value_id).val(); }
if(type == "op8"){ op8 = $('#'+value_id).val(); }
if(type == "op9"){ op9 = $('#'+value_id).val(); }
if(type == "op10"){ op10 = $('#'+value_id).val(); }
// op0 が「商品購入のみ」のとき、他のオプション (op1..op10) を disable 化.
// 価格計算側 (calcGoukei の purchaseOnly 分岐) は既にゼロ化しているが、
// UI で選択可能に見えるとユーザーが混乱するため radio を完全に無効化する.
(function applyPurchaseOnlyUI() {
var isPurchaseOnly = (op0 === '商品購入のみ');
for (var k = 1; k <= 10; k++) {
var $inputs = $('input[name="op' + k + '"]');
if ($inputs.length === 0) continue;
$inputs.prop('disabled', isPurchaseOnly);
var $group = $inputs.first().closest('.form-group');
$group.css({
'opacity': isPurchaseOnly ? '0.4' : '1',
'pointer-events': isPurchaseOnly ? 'none' : 'auto'
});
}
})();
// 全 type 共通: 該当 radio を checked にし、ボタンの is-selected を付け替え + ラベル更新.
// value_id が指定されていて、対応する DOM 要素が opt-btn 配下にあれば適用する.
// (icheck-danger 形式から opt-btn 形式に統一した際、option1/option2/pw/pd/ph/pm/pc 等の
// クリックで is-selected が更新されない不具合があったため、op\d+ 限定の処理を一般化)
if (value_id) {
var $clicked = $('#' + value_id);
if ($clicked.length && $clicked.closest('.opt-btn').length) {
$clicked.prop('checked', true);
var groupName = $clicked.attr('name');
$('input[name="' + groupName + '"]').closest('.opt-btn').removeClass('is-selected');
$clicked.closest('.opt-btn').addClass('is-selected');
var $group = $clicked.closest('.form-group');
var $label = $group.find('.rp-section-label');
if ($label.length) {
var labelText = $label.text().split(':')[0].trim();
$label.html(labelText + ': <span>' + $clicked.val() + '</span>');
}
// op_data の price=0 & 解体/撤去/設置場所 オプションの場合、ON 選択時に「現場調査後に正式お見積もり」文言を表示.
// (twig 側で is_removal_unknown ブロックを描画済み。display 切替のみ JS で行う)
if (/^op\d+$/.test(type)) {
var opIdx = type.replace('op', '');
var opEntry = op_data[parseInt(opIdx)];
if (opEntry) {
var $note = $group.find('.opt-survey-note[data-op-idx="' + opIdx + '"]');
if ($note.length) {
var isOn = ($clicked.val() === opEntry.on);
$note.toggle(isOn);
}
}
// wd (sale_type=5) のステップ / デッキフェンス用の注記もここで切替.
// ステップ → deck_step (op0 だが op_data 範囲外), 必要 選択時に表示.
var radioName = $clicked.attr('name');
if (radioName === 'deck_step') {
$group.find('.opt-survey-note-wd-step').toggle($clicked.val() === '必要');
} else if (radioName === 'deck_fence') {
$group.find('.opt-survey-note-wd-fence').toggle($clicked.val() === '必要');
}
}
}
}
// 必須項目チェックは sale_type 1 系(カーポート/物置/フェンスなど価格マトリクス必要)に限定
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);
// sale_type=3 (物置・ゴミステーション・照明 等) では「素材」を選択肢として扱わない.
// - mo/gs/sy は m が "指定なし" など名目的にしか入っていない
// - sl は m が空のままで matrix に行が来る
// そのため pm の必須チェックを sale_type=3 でスキップする。
var pmRequired = (SALE_TYPE_ID != 3);
if (requireMatrix) {
if(pmRequired && pm == ""){
$('#mitsumori_message').text("素材を選択してください");
}
if(ph == ""){
$('#mitsumori_message').text("高さを選択してください");
}
if(pd == ""){
$('#mitsumori_message').text("奥行きを選択してください");
}
if(pw == ""){
$('#mitsumori_message').text("幅を選択してください");
}
if(pc == ""){
$('#mitsumori_message').text("カラーを選択してください");
$('#mitsumori_btn').hide();
$('#mitsumori_goukei').text("---円");
$('#mitsumori_off').text("---円");
$('#mitsumori_price').text("---円");
$('#maker_price').text("---円");
$('#mitsumori_ct').text("---円");
$('#mitsumori_option').text("---円");
}
}
if(pw != "" && pd != "" && ph != "" && (!pmRequired || pm != "") && pc != ""){
$('#mitsumori_btn').show();
// 入力コンテキスト(sale_type 別パラメータ)
var ctx = {
set_count: parseInt($('#set_count').val()) || 1,
daisu: parseInt($('#daisu').val()) || 1,
maisu: parseInt($('#maisu').val()) || 3,
suuryou: parseInt($('#suuryou').val()) || 1,
area: parseFloat($('#area').val()) || 0,
quantityOnly: parseInt($('#quantity_only').val())|| 1,
mado_w: $('#mado_w').val() || '',
mado_h: $('#mado_h').val() || '',
mado_type: $('input[name=mado_type]:checked').val() || '',
glass_type: $('input[name=glass_type]:checked').val() || '',
deck_step: $('input[name=deck_step]:checked').val() || '',
deck_fence: $('input[name=deck_fence]:checked').val() || '',
};
// 施工オプション集計(残土処理を含む)
var opCalc = collectOptions();
var pp_matched = false;
// 各軸の汎用 axisMatch:
// user 選択 == matrix 値 / user "指定なし" / matrix 値が空
var axisMatch = function(input, value){
return input == value || input == "指定なし" || value === "" || value == null;
};
// 色専用マッチャー: scraper のデータ形式に合わせて拡張する
// 1. 完全一致 / "指定なし" / 値が空 → 真 (axisMatch と同じ)
// 2. matrix 値が "色1/色2/色3" の形 (同価格グループ) → split して user 選択が含まれれば真
// scraper のロジック (scraper_price.py L765-779):
// 全色同価格 → c=""、価格違いグループあり → 各 group を "/" 結合した色名で 1 行
var colorMatch = function(input, value){
if (axisMatch(input, value)) return true;
if (typeof value === 'string' && value.indexOf('/') !== -1 && input) {
var parts = value.split('/');
for (var idx = 0; idx < parts.length; idx++) {
if (parts[idx].trim() === input) return true;
}
}
return false;
};
// 他軸 (w/d/h/m + option1/option2) でマッチする pp 行を抽出.
// option1/option2 は um の subtype 等で使われる. axisMatch は free_area 側が
// 空のとき真を返すので、um 以外のカテゴリ (option 軸を使わない) でも影響なし.
var candidates = pp.filter(function(el){
return axisMatch(pw, el.w) && axisMatch(pd, el.d) && axisMatch(ph, el.h) && axisMatch(pm, el.m)
&& axisMatch(option1, el.option1) && axisMatch(option2, el.option2);
});
var picked = null;
// 優先 1: 色も含めて完全一致 ("色1/色2" 形式の split match を含む)
for (var ii = 0; ii < candidates.length; ii++) {
if (colorMatch(pc, candidates[ii].c)) { picked = candidates[ii]; break; }
}
// 優先 2: 完全一致なし & user の pc が候補のどの c 値にも該当しない (= 命名違い等)
// かつ候補全行で price が一致する場合は、色軸を実質無視して先頭行を採用.
// 例 id=3353: pp.c は "ステンカラー+..." 6種だが price は全て同じなので
// SM(スミ) を選んでも安全に最初の行の価格を返せる.
if (!picked && candidates.length > 0) {
var ppCsInCand = candidates.map(function(r){ return r.c || ''; });
var pcAbsent = (pc !== '' && pc !== '指定なし' && ppCsInCand.indexOf(pc) === -1
&& ppCsInCand.every(function(v){ return v.indexOf('/') === -1 || v.split('/').map(function(s){return s.trim();}).indexOf(pc) === -1; }));
if (pcAbsent) {
var uniqPrices = new Set();
candidates.forEach(function(r){ uniqPrices.add(String(r.price)); });
if (uniqPrices.size === 1) {
// 全候補同価格 → 色軸を wildcard 扱いで OK
picked = candidates[0];
}
// 価格が異なる場合は意図的に picked=null のまま「対応しておりません」.
}
}
pp.forEach((el) => {
if (el === picked) {
pp_matched = true;
// tg block-keyed オプション差額を集計 (tg 以外は total=0)
var oiCalc = collectOptionItems(el.w || '', el.d || '');
// tg ブロックに合わせてラジオを再描画 (tg 以外は no-op)
renderOptionItemRadios(el.w || '', el.d || '');
var calc = calcGoukei(el, opCalc.total, ctx);
var goukei = calc.goukei;
var price = calc.price;
var ct = calc.ct;
var optionSum = calc.opt;
// オプション差額は税抜 → 税込に変換して合計に加算
var oiIncTax = toIncTax(oiCalc.total);
goukei += oiIncTax;
price += oiIncTax; // 差額は本体価格扱いとして mitsumori_price にも加算
// maker_price も scraper が税抜で保存しているため税込に変換
var makerPrice = toIncTax(parseInt(el.maker_price) || 0);
$('#mitsumori_message').text(formatter.format(goukei) + "円");
$('#mitsumori_goukei').text(formatter.format(goukei) + "円");
$('#mitsumori_off').text(formatter.format(price - makerPrice) + "円");
$('#mitsumori_price').text(formatter.format(price) + "円");
$('#maker_price').text(formatter.format(makerPrice) + "円");
$('#mitsumori_ct').text(formatter.format(ct) + "円");
$('#mitsumori_option').text(formatter.format(optionSum) + "円");
$('#mitsumori_kei').text(formatter.format(goukei) + "円");
$('#mitsumori_price_01').text(formatter.format(price) + "円");
$('#mitsumori_price_02').text(formatter.format(price) + "円");
$('#mitsumori_ct_01').text(formatter.format(ct) + "円");
$('#mitsumori_ct_02').text(formatter.format(ct) + "円");
$('#mitsumori_goukei_02').text(formatter.format(goukei) + "円");
var shoukei = goukei / 1.1;
var tax = parseInt(goukei - shoukei);
$('#mitsumori_shoukei').text(formatter.format(parseInt(shoukei)) + "円");
$('#mitsumori_tax').text(formatter.format(tax) + "円");
// PDF 明細用:オプション内訳テーブルを差し込む (施工オプション + tg block オプション)
renderOptionDetailRows(opCalc.items.concat(oiCalc.items.map(function(it){
return { name: it.name, value: it.label, price: it.diff };
})));
}
});
if (!pp_matched) {
$('#mitsumori_message').text("この組み合わせは対応しておりません");
$('#mitsumori_btn').hide();
$('#mitsumori_goukei').text("---円");
$('#mitsumori_off').text("---円");
$('#mitsumori_price').text("---円");
$('#maker_price').text("---円");
$('#mitsumori_ct').text("---円");
$('#mitsumori_option').text("---円");
$('#mitsumori_kei').text("---円");
$('#mitsumori_shoukei').text("---円");
$('#mitsumori_tax').text("---円");
}
// mitsumori_json: バック側に送信する見積データ
var mitsumori_json = { "mitsumori_goukei": $('#mitsumori_goukei').text(),
"mitsumori_goukei_02": $('#mitsumori_goukei_02').text(),
"mitsumori_price": $('#mitsumori_price').text(),
"maker_price": $('#maker_price').text(),
"mitsumori_off": $('#mitsumori_off').text(),
"mitsumori_ct": $('#mitsumori_ct').text(),
"mitsumori_option": $('#mitsumori_option').text(),
"product_id": {{ Product.id }},
"sale_type": SALE_TYPE_ID,
"pw": pw,
"pd": pd,
"ph": ph,
"pm": pm,
"pc": pc,
"op": [op0,op1,op2,op3,op4,op5,op6,op7,op8,op9,op10],
"op_items": opCalc.items,
"mado_w": ctx.mado_w,
"mado_h": ctx.mado_h,
"mado_type": ctx.mado_type,
"glass_type": ctx.glass_type,
"set_count": ctx.set_count,
"daisu": ctx.daisu,
"maisu": ctx.maisu,
"suuryou": ctx.suuryou,
"area": ctx.area,
"deck_step": ctx.deck_step,
"deck_fence": ctx.deck_fence };
$('#mitsumori_json').val(JSON.stringify(mitsumori_json));
}
}
// PDF/モーダル明細の動的差し替え(基本工事費の次にオプション行を追加)
function renderOptionDetailRows(items) {
var $tbody = $('.modal-mitsumori table tbody');
if (!$tbody.length) return;
$tbody.find('tr.opt-row').remove();
var anchorRow = $tbody.find('tr').filter(function(){
return $(this).find('td:first').text().indexOf('残土') !== -1
|| $(this).find('td:first').text().indexOf('基本工事費') !== -1;
}).last();
items.forEach(function(it){
if (!it.name || !it.value) return;
var priceTxt = it.price > 0
? formatter.format(it.price) + '円'
: '0円';
var $tr = $('<tr class="opt-row"></tr>')
.append('<td>' + it.name + ':' + it.value + '</td>')
.append('<td>1</td>')
.append('<td>式</td>')
.append('<td>' + priceTxt + '</td>')
.append('<td>' + (it.price > 0 ? formatter.format(it.price) + '円' : '') + '</td>');
if (anchorRow.length) {
anchorRow.after($tr);
anchorRow = $tr;
} else {
$tbody.append($tr);
}
});
}
// 見積書モーダルを開く直前に、右側「現在のお見積り額」パネルの表示値を
// モーダル内の対応 ID にコピーして金額の食い違いを防ぐ。
// pw/pd/ph/pm が未選択で mitsumori_simulation の full update に到達しない場合でも、
// パネル側の値(HTML 静的初期値 or 直近の simulation 結果)が modal にも反映される。
function syncMitsumoriModalFromPanel() {
var goukeiText = $('#mitsumori_goukei').text();
var priceText = $('#mitsumori_price').text();
var ctText = $('#mitsumori_ct').text();
$('#mitsumori_kei').text(goukeiText);
$('#mitsumori_price_01').text(priceText);
$('#mitsumori_price_02').text(priceText);
$('#mitsumori_ct_01').text(ctText);
$('#mitsumori_ct_02').text(ctText);
$('#mitsumori_goukei_02').text(goukeiText);
// 小計 / 消費税 は税込 goukei から逆算
var num = parseInt(goukeiText.replace(/[^\d-]/g, ''), 10);
if (!isNaN(num) && num > 0) {
var shoukei = Math.round(num / 1.1);
var tax = num - shoukei;
$('#mitsumori_shoukei').text(formatter.format(shoukei) + '円');
$('#mitsumori_tax').text(formatter.format(tax) + '円');
} else {
$('#mitsumori_shoukei').text('---円');
$('#mitsumori_tax').text('---円');
}
}
$(document).on('show.bs.modal', '#modal-mitsumori', function () {
syncMitsumoriModalFromPanel();
});
{# pc の auto-init: pw/pd/ph/pm と同じく p_c(matrix 派生)の length==1 or 全空で「指定なし」化.
search_word(color) が空の「複合色」型商品で pc が空のまま放置されて
「カラーを選択してください」固定になるバグの修正.
search_word に登録された name があれば優先採用. #}
{% if p_c and (p_c|length == 1 or p_c|join == "") %}
pc = "指定なし";
{% for pc_val in p_c %}{% if pc_val %} pc = "{{ pc_val }}"; {% endif %}{% endfor %}
{% if color and color|length == 1 %}
{% for cc in color %}{% if cc and cc['name'] %} pc = "{{ cc['name'] }}"; {% endif %}{% endfor %}
{% endif %}
{% elseif color and color|length == 1 %}
pc = "指定なし";
{% for cc in color %}{% if cc and cc['name'] %} pc = "{{ cc['name'] }}"; {% endif %}{% endfor %}
{% endif %}
{% if p_w and (p_w|length == 1 or p_w|join == "") %}
pw = "指定なし";
{% for pw in p_w %}{% if pw %} pw = "{{ pw }}"; {% endif %}{% endfor %}
{% endif %}
{% if p_d and (p_d|length == 1 or p_d|join == "") %}
pd = "指定なし";
{% for pd in p_d %}{% if pd %} pd = "{{ pd }}"; {% endif %}{% endfor %}
{% endif %}
{% if p_h and (p_h|length == 1 or p_h|join == "") %}
ph = "指定なし";
{% for ph in p_h %}{% if ph %} ph = "{{ ph }}"; {% endif %}{% endfor %}
{% endif %}
{% if p_m and (p_m|length == 1 or p_m|join == "") %}
pm = "指定なし";
{% for pm in p_m %}{% if pm %} pm = "{{ pm }}"; {% endif %}{% endfor %}
{% endif %}
{# p_option1 / p_option2 の auto-init: length==1 or 全空で JS 変数を埋める #}
{% if p_option1 and (p_option1|length == 1 or p_option1|join == "") %}
option1 = "";
{% for opt1 in p_option1 %}{% if opt1 %} option1 = "{{ opt1|e('js') }}"; {% endif %}{% endfor %}
{% endif %}
{% if p_option2 and (p_option2|length == 1 or p_option2|join == "") %}
option2 = "";
{% for opt2 in p_option2 %}{% if opt2 %} option2 = "{{ opt2|e('js') }}"; {% endif %}{% endfor %}
{% endif %}
// カラー radio が複数あるとき初期チェックが無いと「カラーを選択してください」固定になるので、
// 何もチェックされていなければ「最初の radio」を選択する。
// sale_type≠3 は name="color", sale_type=3 は name="color3".
//
// 注意:
// ・search_word(= radio の値)と pp.c(= matrix の色軸)は別の命名体系のケースがある
// (例 id=3353: radio="SM(スミ)" / pp.c="ステンカラー+セピアブラウン")
// ・pp.c に合わせて radio を選ぼうとしても文字列一致しないので無意味。
// ・単純に「先頭の radio」を選ぶ実装に戻し、マッチング側で命名体系違いを吸収する
// (pc が pp.c のどの値にもマッチしないときは色軸を wildcard 扱いにする)。
// ・.rp-section-label のテキストも忘れずに同期する(古い session 値が残ると
// "ステンカラー+セピアブラウン" のような表示と実際の radio が食い違う)。
(function autoSelectFirstColor(){
var groups = ['color', 'color3'];
for (var gi = 0; gi < groups.length; gi++) {
var name = groups[gi];
var nodes = document.querySelectorAll('input[type="radio"][name="' + name + '"]');
if (nodes.length === 0) continue;
var anyChecked = false;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].checked) { anyChecked = true; break; }
}
if (anyChecked) continue;
var target = nodes[0];
target.checked = true;
pc = target.value;
// opt-btn の is-selected を付け替え
var lbl = target.closest('.opt-btn');
if (lbl) {
var sib = lbl.parentNode ? lbl.parentNode.querySelectorAll('.opt-btn') : [];
for (var k = 0; k < sib.length; k++) sib[k].classList.remove('is-selected');
lbl.classList.add('is-selected');
}
// 「カラー: <name>」表示の同期(古い mitsumori_json.pc が残らないように)
var grp = (lbl && lbl.closest('.form-group')) || (target.closest('.form-group'));
if (grp) {
var section = grp.querySelector('.rp-section-label');
if (section) {
var labelHead = section.textContent.split(':')[0].trim();
section.innerHTML = labelHead + ': <span>' + target.value + '</span>';
}
}
}
})();
// option1 / option2 / pw / pd / ph / pm (matrix 軸の radio 群) も同様に
// 「どれもチェックされていなければ先頭を選ぶ」を適用する.
// sale_type=2 の窓タイプ等で「初期表示時に一番初めの選択肢が選択されていない」事象を解消.
(function autoSelectFirstMatrixAxis(){
var axes = [
{ name: 'pw', jsVar: 'pw' },
{ name: 'pd', jsVar: 'pd' },
{ name: 'ph', jsVar: 'ph' },
{ name: 'pm', jsVar: 'pm' },
{ name: 'glass_type', jsVar: 'pm' },
{ name: 'option1', jsVar: 'option1' },
{ name: 'option2', jsVar: 'option2' }
];
for (var ai = 0; ai < axes.length; ai++) {
var ax = axes[ai];
var nodes = document.querySelectorAll('input[type="radio"][name="' + ax.name + '"]');
if (nodes.length === 0) continue;
var anyChecked = false;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].checked) { anyChecked = true; break; }
}
if (anyChecked) continue;
var target = nodes[0];
target.checked = true;
// グローバル JS 変数も埋める
if (ax.jsVar === 'pw') pw = target.value;
else if (ax.jsVar === 'pd') pd = target.value;
else if (ax.jsVar === 'ph') ph = target.value;
else if (ax.jsVar === 'pm') pm = target.value;
else if (ax.jsVar === 'option1') option1 = target.value;
else if (ax.jsVar === 'option2') option2 = target.value;
var lbl = target.closest('.opt-btn');
if (lbl) {
var sib = lbl.parentNode ? lbl.parentNode.querySelectorAll('.opt-btn') : [];
for (var k = 0; k < sib.length; k++) sib[k].classList.remove('is-selected');
lbl.classList.add('is-selected');
}
var grp = (lbl && lbl.closest('.form-group')) || (target.closest('.form-group'));
if (grp) {
var section = grp.querySelector('.rp-section-label');
if (section) {
var labelHead = section.textContent.split(':')[0].trim();
section.innerHTML = labelHead + ': <span>' + target.value + '</span>';
}
}
}
})();
// ページ読み込み時: 見積金額が「合計」になっているため、カート数量は基本1
// sale_type=9(商品のみ購入)だけ通常 EC として数量を引き継ぐ
(function initQuantityByType(){
var saleType = {{ ProductClass.SaleType.id }};
if (saleType == 9 && $('#quantity_only').length) {
$('#quantity').val(parseInt($('#quantity_only').val()) || 1);
} else {
$('#quantity').val(1);
$('input[name="quantity"]').val(1);
}
})();
// type → ラベルのプレフィックス文字列
// option1/option2 のラベルは category 依存 (rd: ランマ/タイプ, sh: サイズプリセット/駆動方式 等).
// PHP から渡された option1_label / option2_label を埋め込み、JS 側でラベル更新に使う.
var optLabelMap = {pc:'カラー', pw:'幅', pd:'奥行き', ph:'高さ', pm:'素材',
option1: '{{ option1_label|default('オプション1')|e('js') }}',
option2: '{{ option2_label|default('オプション2')|e('js') }}'};
// type → input[name]
var optNameMap = {pc:'color', pw:'pw', pd:'pd', ph:'ph', pm:'pm',
option1: 'option1', option2: 'option2'};
// opt-btn用: 値を直接受け取るラッパー
function mitsumori_simulation_val(type, value) {
if (type === 'pc') pc = value;
if (type === 'pw') pw = value;
if (type === 'pd') pd = value;
if (type === 'ph') ph = value;
if (type === 'pm') pm = value;
if (type === 'option1') option1 = value;
if (type === 'option2') option2 = value;
// is-selected クラスを同グループ内で付け替え
var inputName = optNameMap[type];
if (inputName) {
var $btns = $('input[name="' + inputName + '"]').closest('.opt-btn');
$btns.removeClass('is-selected');
$btns.filter(function(){
return $(this).find('input').val() === value;
}).addClass('is-selected');
}
// ラベル行の選択値テキストを更新(例: 「カラー: ブラック」)
var labelPrefix = optLabelMap[type];
if (labelPrefix) {
// 対象のrp-section-labelを特定(input[name]を含む親を遡る)
var $group = $('input[name="' + inputName + '"]').first().closest('.form-group');
var $label = $group.find('.rp-section-label');
$label.html(labelPrefix + ': <span>' + value + '</span>');
}
// simulation本体を呼ぶ(value_idは空でOK、グローバル変数を使う)
mitsumori_simulation('', '');
}
mitsumori_simulation("","");
// ボタン群: 親幅を超える、または3行以上になる場合は is-scroll で1行横スクロール化
function applyBtnGroupScroll() {
$('.rp-btn-group, .opt-btn-group').each(function() {
var $group = $(this);
$group.removeClass('is-scroll');
var $items = $group.children();
if ($items.length === 0) return;
var parentWidth = $group.parent().width() || $group.width();
var totalWidth = 0;
var gap = parseInt($group.css('gap'), 10) || 8;
$items.each(function() {
totalWidth += this.offsetWidth + gap;
});
// 単一ボタンが親幅を超える、もしくは合計幅が親幅を超える → 横スクロール化
var anyTooWide = false;
$items.each(function() {
if (this.offsetWidth > parentWidth) { anyTooWide = true; return false; }
});
// 折り返し時の行数も計測
var tops = {};
$items.each(function() { tops[this.offsetTop] = true; });
var rowCount = Object.keys(tops).length;
if (anyTooWide || totalWidth > parentWidth * 2 || rowCount >= 3) {
$group.addClass('is-scroll');
}
});
}
applyBtnGroupScroll();
$(window).on('resize', function() {
clearTimeout(window._btnScrollTimer);
window._btnScrollTimer = setTimeout(applyBtnGroupScroll, 150);
});
// onload: 見積金額が確定している場合は「工事費込み価格」表示を一致させる
(function syncPrice02Display() {
var goukeiEl = document.getElementById('mitsumori_goukei');
var displayEl = document.getElementById('price02-display');
if (!goukeiEl || !displayEl) return;
var goukeiText = goukeiEl.textContent.trim();
// ---円(未確定)の場合は書き換えない
if (goukeiText && goukeiText !== '---円') {
displayEl.textContent = goukeiText;
}
// 以降の変更にも追従: mitsumori_goukei を監視
new MutationObserver(function() {
var text = goukeiEl.textContent.trim();
if (text && text !== '---円') {
displayEl.textContent = text;
}
}).observe(goukeiEl, { childList: true, subtree: true, characterData: true });
})();
function contact_form(product_id){
$('#form1').attr('action', '{{ url('contact', {product:Product.id}) }}');
$('#form1').submit();
}
// maisu / madoset は下部の新しい関数定義を使用
function heibei(bei){
$('#heibei').val(parseInt($('#heibei').val()) + bei);
if(parseInt($('#heibei').val()) < 1){ $('#heibei').val(1); }
if(parseInt($('#heibei').val()) > 100){ $('#heibei').val(100); }
// goukei に既に枚数を含むため、カート数量は1で固定
$('#quantity').val(1);
mitsumori_simulation('heibei','heibei');
}
function daisu(dai){
$('#daisu').val(parseInt($('#daisu').val()) + dai);
if(parseInt($('#daisu').val()) < 1){ $('#daisu').val(1); }
if(parseInt($('#daisu').val()) > 10){ $('#daisu').val(10); }
$('#quantity').val(1);
mitsumori_simulation('daisu','daisu');
}
// sale_type=7(数量買い・基本工事費固定)用:個数入力
function suuryou(n){
$('#suuryou').val(parseInt($('#suuryou').val()) + n);
if(parseInt($('#suuryou').val()) < 1){ $('#suuryou').val(1); }
if(parseInt($('#suuryou').val()) > 100){ $('#suuryou').val(100); }
$('#quantity').val(1);
mitsumori_simulation('suuryou','suuryou');
}
function maisu(mai){
$('#maisu').val(parseInt($('#maisu').val()) + mai);
// sale_type=4 (フェンス) は3枚未満不可、6 (芝生) は1枚から
var minMai = (SALE_TYPE_ID == 4) ? 3 : 1;
if(parseInt($('#maisu').val()) < minMai){ $('#maisu').val(minMai); }
if(parseInt($('#maisu').val()) > 100){ $('#maisu').val(100); }
$('#quantity').val(1);
mitsumori_simulation('maisu','maisu');
}
// タイプ2: セット数プルダウン連動
function madosetSelect(val){
var v = parseInt(val);
if(v < 1) v = 1;
if(v > 20) v = 20;
$('#set_count').val(v);
$('#quantity').val(1);
$('input[name="quantity"]').val(1);
mitsumori_simulation('set','set_count');
}
// タイプ2: ±ボタン版(後方互換)
function madoset(mai){
var current = parseInt($('#set_count').val()) || 1;
var next = current + mai;
if(next < 1) next = 1;
if(next > 20) next = 20;
$('#set_count').val(next);
madosetSelect(next);
}
// タイプ5: ステップ・フェンス選択値を mitsumori_json に保存するためのグローバル変数
var deck_step = "{% if mitsumori_json and mitsumori_json.deck_step is defined %}{{ mitsumori_json.deck_step|default('不要') }}{% else %}不要{% endif %}";
var deck_fence = "{% if mitsumori_json and mitsumori_json.deck_fence is defined %}{{ mitsumori_json.deck_fence|default('不要') }}{% else %}不要{% endif %}";
// PDF出力: モーダルの mitsumori_json をフォームに同期してから送信
function syncPdfJson(){
var jsonVal = $('#mitsumori_json').val();
$('#pdf_mitsumori_json').val(jsonVal);
}
// タイプ9: 商品のみ購入
function quantityOnly(val){
var current = parseInt($('#quantity_only').val()) || 1;
var next = current + val;
if(next < 1) next = 1;
$('#quantity_only').val(next);
$('#quantity').val(next);
}
// ===== スマホ用下部固定バーへの金額同期 =====
// mitsumori_message と mitsumori_goukei を監視して下部バーを更新
(function() {
var msgTarget = document.getElementById('mitsumori_message');
var goukeiTarget = document.getElementById('mitsumori_goukei');
var spPrice = document.getElementById('sp-mitsumori-price');
var spBtn = document.querySelector('#sp-mitsumori-bar .sp-bar__btn');
if (!spPrice || !spBtn) return;
function syncBar() {
var msg = msgTarget ? msgTarget.textContent : '';
var goukei = goukeiTarget ? goukeiTarget.textContent : '---円';
// メッセージが「〇〇を選択してください」の場合はメッセージを表示しボタンを非表示
if (msg.indexOf('選択してください') !== -1) {
spPrice.textContent = msg;
spPrice.style.fontSize = '13px';
spPrice.style.color = '#888';
spBtn.style.display = 'none';
} else {
// 価格確定時はボタンを表示
spPrice.textContent = goukei;
spPrice.style.fontSize = '18px';
spPrice.style.color = '#c00';
spBtn.style.display = 'block';
}
}
// 初期値を同期
syncBar();
// mitsumori_message の変化を監視
if (msgTarget) {
new MutationObserver(syncBar).observe(
msgTarget, { childList: true, subtree: true, characterData: true }
);
}
// mitsumori_goukei の変化も監視
if (goukeiTarget) {
new MutationObserver(syncBar).observe(
goukeiTarget, { childList: true, subtree: true, characterData: true }
);
}
})();
// ===== 現在のお見積り額: 折りたたみトグルボタンのテキスト切り替え =====
(function() {
var card = document.querySelector('.mitsumori-card-pc');
var btn = document.querySelector('.btn-mitsumori-toggle .toggle-icon');
if (!card || !btn) return;
// MutationObserverでcollapsed-cardクラスの変化を監視
new MutationObserver(function() {
if (card.classList.contains('collapsed-card')) {
btn.textContent = '▼ 詳細';
} else {
btn.textContent = '▲ 閉じる';
}
}).observe(card, { attributes: true, attributeFilter: ['class'] });
})();
// ===== エリア案内: スマホのみタップで展開 =====
(function() {
var notice = document.querySelector('.ec-areaNotice');
if (!notice) return;
notice.addEventListener('click', function(e) {
if (window.innerWidth > 767) return;
// リンククリック時は展開/折りたたみせずリンク遷移
if (e.target.tagName === 'A') return;
notice.classList.toggle('is-open');
});
})();
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Product",
"name": "{{ Product.name }}",
"image": [
{% for img in Product.ProductImage %}
"{{ app.request.schemeAndHttpHost }}{{ asset(img, 'save_image') }}"{% if not loop.last %},{% endif %}
{% else %}
"{{ app.request.schemeAndHttpHost }}{{ asset(''|no_image_product, 'save_image') }}"
{% endfor %}
],
"description": "{{ Product.description_list | default(Product.description_detail) | replace({'\n': '', '\r': ''}) | slice(0,300) }}",
{% if Product.code_min %}
"sku": "{{ Product.code_min }}",
{% endif %}
"offers": {
"@type": "Offer",
"url": "{{ url('product_detail', {'id': Product.id}) }}",
"priceCurrency": "{{ eccube_config.currency }}",
"price": {{ Product.getPrice02IncTaxMin ? Product.getPrice02IncTaxMin : 0}},
"availability": "{{ Product.stock_find ? "InStock" : "OutOfStock" }}"
}
}
</script>
{% endblock %}
{% block main %}
{# option1 / option2 ラベルをカテゴリ別に決定 (sh=31, rd=43, mo=15) - block scope のため main 側でも再定義 #}
{% set option1_label = 'オプション1' %}
{% set option2_label = 'オプション2' %}
{% if Product.ProductCategories is not empty %}
{% for pcat in Product.ProductCategories %}
{% if pcat.category_id == 31 %}{% set option1_label = 'サイズプリセット' %}{% set option2_label = '駆動方式' %}{% endif %}
{% if pcat.category_id == 43 %}{% set option1_label = 'ランマ' %}{% set option2_label = 'タイプ' %}{% endif %}
{% if pcat.category_id == 15 %}{% set option1_label = '棚タイプ' %}{% endif %}
{% if pcat.category_id == 17 %}{% set option1_label = '窓タイプ' %}{% endif %}
{% endfor %}
{% endif %}
<div class="ec-productRole" style="margin-top:20px;">
<div class="ec-grid2">
<div class="ec-grid2__cell">
<div class="ec-sliderItemRole">
{# 商品名 + ブランド名 + SNSシェア #}
<div class="ec-productRole__title">
<div class="ec-productRole__titleRow">
<h2 class="ec-headingTitle">{{ Product.name }}</h2>
<div class="ec-share-inline">
<a href="https://twitter.com/share?url={{ app.request.uri|url_encode }}&text={{ Product.name|url_encode }}"
class="share-twitter" target="_blank" rel="noreferrer noopener" title="Xでシェア">
<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>
</a>
<a href="https://www.instagram.com/" class="share-facebook" target="_blank" rel="noreferrer noopener" title="Instagram">
<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>
</a>
<a href="https://social-plugins.line.me/lineit/share?url={{ app.request.uri|url_encode }}"
class="share-line" target="_blank" rel="noreferrer noopener" title="LINEでシェア">
<i class="fab fa-line"></i>
</a>
</div>
</div>
</div>
{% if BaseInfo.option_favorite_product %}
<div style="position:relative;top: 20px;left: 10px;z-index:100;">
{% if is_favorite == false %}
<form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
<button type="submit" id="favorite" class="favorite">♡</button>
</form>
{% else %}
<form action="{{ url('product_add_favorite', {id:Product.id}) }}" method="post">
<button type="submit" id="favorite" class="favorite" style="color:red;">♥</button>
</form>
{% endif %}
</div>
{% endif %}
<div class="item_visual">
{% for ProductImage in Product.ProductImage %}
<div class="slide-item">
<a class="js-zoom" href="{{ asset(ProductImage, 'save_image') }}" aria-label="{{ loop.first ? Product.name : '' }}">
<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 %}>
</a>
</div>
{% else %}
<div class="slide-item"><img src="{{ asset(''|no_image_product, 'save_image') }}" alt="{{ Product.name }}" width="550" height="550" style="max-height: 400px;"></div>
{% endfor %}
</div>
<div class="item_nav">
{% for ProductImage in Product.ProductImage %}
<div class="slideThumb" data-index="{{ loop.index0 }}"><img src="{{ asset(ProductImage, 'save_image') }}" alt="" width="80" height="80" loading="lazy"></div>
{% endfor %}
</div>
</div>
{# ===== 施工エリア案内(見積シミュレーションの下)===== #}
<div class="ec-areaNotice" style="margin-top:16px;margin-right:10px;">
<div class="ec-areaNotice__inner">
<div class="ec-areaNotice__icon">📍</div>
<div class="ec-areaNotice__body">
<p class="ec-areaNotice__title">施工対応エリアについて</p>
<div class="ec-areaNotice__detail">
<p class="ec-areaNotice__text">
当店の施工サービスは、<strong>山梨県全域</strong>および<br>
<strong>諏訪エリア(諏訪市・岡谷市・茅野市・諏訪郡)</strong>を対象としております。<br>
上記エリア外のお客様には、商品のみのご購入が可能でございます。<br>
ご不明な点がございましたら、お気軽にお問い合わせください。
</p>
<a class="ec-areaNotice__link" href="{{ url('contact') }}">エリア外のお客様・ご相談はこちら →</a>
</div>
</div>
</div>
</div>
</div>
<div class="ec-grid2__cell2">
<div class="ec-productRole__profile" >
{# 関連カテゴリ (DIY=21 / 石材=28 / 照明=44 は非表示要件のため除外) #}
{% set hidden_cat_ids = [21, 28, 44] %}
{% if Product.ProductCategories is not empty %}
<div class="ec-productRole__category" style="padding:10px 0;">
{% for ProductCategory in Product.ProductCategories %}
{% if ProductCategory.Category.id not in hidden_cat_ids %}
<ul>
<li>
{% for Category in ProductCategory.Category.path %}
<a href="{{ url('product_list') }}?category_id={{ Category.id }}">{{ Category.name }}</a> {%- if loop.last == false %}
<span>></span>{% endif -%}
{% endfor %}
</li>
</ul>
{% endif %}
{% endfor %}
</div>
{% endif %}
{# 販売価格 #}
<div class="ec-productRole__price">
<span style="color:black;font-size:15px;">工事費込み価格</span>
{% if Product.hasProductClass -%}
{% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %}
<div class="ec-price">
<span id="price02-display" class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }}</span>
<span class="ec-price__tax">({{ '税込'|trans }})~</span>
</div>
{% else %}
<div class="ec-price">
<span id="price02-display" class="ec-price__price price02-default">{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}</span>
<span class="ec-price__tax">({{ '税込'|trans }})</span>
</div>
{% endif %}
{% else %}
<div class="ec-price">
<span id="price02-display" class="ec-price__price">{{ Product.getPrice02IncTaxMin|price }}</span>
<span class="ec-price__tax">({{ '税込'|trans }})~</span>
</div>
{% endif %}
</div>
{# タグ #}
<ul class="ec-productRole__tags">
{% for Tag in Product.Tags %}
<li class="ec-productRole__tag tag_{{ Tag.id }}">{{ Tag }}</li>
{% endfor %}
</ul>
{# 商品コード #}
{% if Product.code_min is not empty %}
<div class="ec-productRole__code">
{{ '商品コード'|trans }}: <span class="product-code-default">{{ Product.code_min }}{% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}{% endif %}</span>
</div>
{% endif %}
<div class="ec-productRole__description">
<div class="ec-rectHeading">
<h4>製品情報</h4>
</div>
{{ Product.sales_infomation|raw|nl2br }}
</div>
<div class="card card-danger" style="clear:both;margin:1px;">
<div class="card-header">
<h3 class="card-title">見積シミュレーション</h3>
</div>
<div class="card-body p-2">
{% set related_image = getProduct_field(Product.id,"related_image") %}
{# related_image は配列: ["1段目画像あり","2段目画像あり","3段目画像あり"] のうち該当するものが格納 #}
{% set img1 = related_image and ("1段目画像あり" in related_image) %}
{% set img2 = related_image and ("2段目画像あり" in related_image) %}
{% set img3 = related_image and ("3段目画像あり" in related_image) %}
{% set img4 = related_image and ("4段目画像あり" in related_image) %}
{% set type1 = getProduct_field(Product.id,"related_name1") %}
{% set type2 = getProduct_field(Product.id,"related_name2") %}
{% set type3 = getProduct_field(Product.id,"related_name3") %}
{% set type4 = getProduct_field(Product.id,"related_name4") %}
{% set hasRelated = (type1 and related_product1 and related_product1|length)
or (type2 and related_product2 and related_product2|length)
or (type3 and related_product3 and related_product3|length)
or (type4 and related_product4 and related_product4|length) %}
{% if hasRelated %}
<div class="row" style="border-bottom:1px solid rgba(0,0,0,.125)"><label class="col-12 col-form-label">この商品のタイプを選択してください。</label></div>
{% endif %}
{# ===== 1段目 ===== #}
{% if type1 and related_product1 and related_product1|length %}
<div class="form-group mt-3 pb-3" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">{{ type1 }}{% if img1 and base_select1 %}: <span>{{ base_select1 }}</span>{% endif %}</div>
{% if img1 %}
{# --- 画像付きカード --- #}
<div class="rp-card-group">
{% for rp_id, rp_name in related_product1 %}
<label class="rp-card{% if base_select1 == rp_name %} is-selected{% endif %}"
onclick="location.href='/products/detail/{{ rp_id }}';">
<input type="radio" name="rp1" value="{{ rp_name }}"
{% if base_select1 == rp_name %}checked{% endif %}>
<img class="rp-card__image"
src="{{ asset('p' ~ rp_id ~ '_cp_1.jpg', 'save_image') }}"
alt="{{ rp_name }}"
width="120" height="120" loading="lazy"
onerror="this.style.display='none';this.nextElementSibling.style.display='flex';">
<div class="rp-card__placeholder" style="display:none;">📦</div>
<span class="rp-card__name">{{ rp_name }}</span>
</label>
{% endfor %}
</div>
{% else %}
{# --- ボタン式ラジオ --- #}
<div class="rp-btn-group">
{% for rp_id, rp_name in related_product1 %}
<label class="rp-btn{% if base_select1 == rp_name %} is-selected{% endif %}"
onclick="location.href='/products/detail/{{ rp_id }}';">
<input type="radio" name="rp1" value="{{ rp_name }}"
{% if base_select1 == rp_name %}checked{% endif %}>
{{ rp_name }}
</label>
{% endfor %}
</div>
{% endif %}
</div>
{% endif %}
{# ===== 2段目 ===== #}
{% if type2 and related_product2 and related_product2|length %}
<div class="form-group mt-3 pb-3" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">{{ type2 }}{% if img2 and base_select2 %}: <span>{{ base_select2 }}</span>{% endif %}</div>
{% if img2 %}
<div class="rp-card-group">
{% for rp_id, rp_name in related_product2 %}
<label class="rp-card{% if base_select2 == rp_name %} is-selected{% endif %}"
onclick="location.href='/products/detail/{{ rp_id }}';">
<input type="radio" name="rp2" value="{{ rp_name }}"
{% if base_select2 == rp_name %}checked{% endif %}>
<img class="rp-card__image"
src="{{ asset('p' ~ rp_id ~ '_cp_1.jpg', 'save_image') }}"
alt="{{ rp_name }}"
width="120" height="120" loading="lazy"
onerror="this.style.display='none';this.nextElementSibling.style.display='flex';">
<div class="rp-card__placeholder" style="display:none;">📦</div>
<span class="rp-card__name">{{ rp_name }}</span>
</label>
{% endfor %}
</div>
{% else %}
<div class="rp-btn-group">
{% for rp_id, rp_name in related_product2 %}
<label class="rp-btn{% if base_select2 == rp_name %} is-selected{% endif %}"
onclick="location.href='/products/detail/{{ rp_id }}';">
<input type="radio" name="rp2" value="{{ rp_name }}"
{% if base_select2 == rp_name %}checked{% endif %}>
{{ rp_name }}
</label>
{% endfor %}
</div>
{% endif %}
</div>
{% endif %}
{# ===== 3段目 ===== #}
{% if type3 and related_product3 and related_product3|length %}
<div class="form-group mt-3 pb-3" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">{{ type3 }}{% if img3 and base_select3 %}: <span>{{ base_select3 }}</span>{% endif %}</div>
{% if img3 %}
<div class="rp-card-group">
{% for rp_id, rp_name in related_product3 %}
<label class="rp-card{% if base_select3 == rp_name %} is-selected{% endif %}"
onclick="location.href='/products/detail/{{ rp_id }}';">
<input type="radio" name="rp3" value="{{ rp_name }}"
{% if base_select3 == rp_name %}checked{% endif %}>
<img class="rp-card__image"
src="{{ asset('p' ~ rp_id ~ '_cp_1.jpg', 'save_image') }}"
alt="{{ rp_name }}"
width="120" height="120" loading="lazy"
onerror="this.style.display='none';this.nextElementSibling.style.display='flex';">
<div class="rp-card__placeholder" style="display:none;">📦</div>
<span class="rp-card__name">{{ rp_name }}</span>
</label>
{% endfor %}
</div>
{% else %}
<div class="rp-btn-group">
{% for rp_id, rp_name in related_product3 %}
<label class="rp-btn{% if base_select3 == rp_name %} is-selected{% endif %}"
onclick="location.href='/products/detail/{{ rp_id }}';">
<input type="radio" name="rp3" value="{{ rp_name }}"
{% if base_select3 == rp_name %}checked{% endif %}>
{{ rp_name }}
</label>
{% endfor %}
</div>
{% endif %}
</div>
{% endif %}
{# ===== 4段目 ===== #}
{% if type4 and related_product4 and related_product4|length %}
<div class="form-group mt-3 pb-3" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">{{ type4 }}{% if img4 and base_select4 %}: <span>{{ base_select4 }}</span>{% endif %}</div>
{% if img4 %}
{# --- 画像付きカード --- #}
<div class="rp-card-group">
{% for rp_id, rp_name in related_product4 %}
<label class="rp-card{% if base_select4 == rp_name %} is-selected{% endif %}"
onclick="location.href='/products/detail/{{ rp_id }}';">
<input type="radio" name="rp4" value="{{ rp_name }}"
{% if base_select4 == rp_name %}checked{% endif %}>
<img class="rp-card__image"
src="{{ asset('p' ~ rp_id ~ '_cp_1.jpg', 'save_image') }}"
alt="{{ rp_name }}" width="120" height="120" loading="lazy">
<span class="rp-card__label">{{ rp_name }}</span>
</label>
{% endfor %}
</div>
{% else %}
{# --- ボタン式ラジオ --- #}
<div class="rp-btn-group">
{% for rp_id, rp_name in related_product4 %}
<label class="rp-btn{% if base_select4 == rp_name %} is-selected{% endif %}"
onclick="location.href='/products/detail/{{ rp_id }}';">
<input type="radio" name="rp4" value="{{ rp_name }}"
{% if base_select4 == rp_name %}checked{% endif %}>
{{ rp_name }}
</label>
{% endfor %}
</div>
{% endif %}
</div>
{% endif %}
{# ガレージ等で全オプション空のときに見出しのみ表示される事象を回避.
色 / 寸法 / 素材 / option1/2 / op_data いずれかに「描画される」要素がある場合のみ
「この商品のオプションを選択してください。」見出しを表示する.
op_data は cg=9 で「残土」 / gs=27 で「撤去」「残土」を後段ループで
hide するため、単純な op|length > 0 では「見出しだけ残る」事象が
wh / cg の一部商品で発生していた. 描画される entry を事前カウントする. #}
{% set is_gs_h = false %}
{% set is_cg_h = false %}
{% if Product.ProductCategories is not empty %}
{% for pc_h in Product.ProductCategories %}
{% if pc_h.category_id == 27 %}{% set is_gs_h = true %}{% endif %}
{% if pc_h.category_id == 9 %}{% set is_cg_h = true %}{% endif %}
{% endfor %}
{% endif %}
{% set visible_op_count = 0 %}
{% if op and op|length %}
{% for opi in op %}
{% if opi['name'] %}
{% set _hide_h = false %}
{% if is_gs_h and (opi['name'] matches '/撤去/' or opi['name'] matches '/残土/') %}{% set _hide_h = true %}{% endif %}
{% if is_cg_h and opi['name'] matches '/残土/' %}{% set _hide_h = true %}{% endif %}
{% if not _hide_h %}{% set visible_op_count = visible_op_count + 1 %}{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% set has_any_option =
(color and color|length and ProductClass.SaleType.id != 3)
or (p_w and p_w|length and p_w|join != "")
or (p_d and p_d|length and p_d|join != "")
or (p_h and p_h|length and p_h|join != "")
or (p_m and p_m|length and p_m|join != "")
or (p_option1 and p_option1|length and p_option1|join != "")
or (p_option2 and p_option2|length and p_option2|join != "")
or visible_op_count > 0
or ProductClass.SaleType.id in [2, 5, 6, 7, 9]
%}
{% if has_any_option %}
<div class="row" style="border-bottom:1px solid rgba(0,0,0,.125)"><label class="col-12 col-form-label">この商品のオプションを選択してください。</label></div>
{% endif %}
{% if color and color|length and ProductClass.SaleType.id != 3 %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">カラー{% if mitsumori_json and mitsumori_json.pc %}: <span>{{ mitsumori_json.pc }}</span>{% endif %}</div>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for cc in color %}{% if cc and cc['name'] %}{% set idx = idx + 1 %}
{% set has_img = cc['img'] is defined and cc['img'] is not empty %}
<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 %}"
onclick="mitsumori_simulation_val('pc', '{{ cc['name']|e('js') }}');">
<input type="radio" name="color" id="cc_{{ idx }}" value="{{ cc['name'] }}"
{% if (mitsumori_json and mitsumori_json.pc == cc['name']) or color|length == 1 %}checked{% endif %}>
{% if has_img %}
<img src="{{ cc['img'] }}" alt="{{ cc['name'] }}" class="opt-btn__img"
onerror="this.parentNode.classList.remove('opt-btn--with-image'); this.remove();">
<span class="opt-btn__name">{{ cc['name'] }}</span>
{% else %}
{{ cc['name'] }}
{% endif %}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
{% if p_w and p_w|length and p_w|join != "" and ProductClass.SaleType.id != 3 %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">幅{% if mitsumori_json and mitsumori_json.pw %}: <span>{{ mitsumori_json.pw }}</span>{% endif %}</div>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for pw in p_w %}{% if pw %}{% set idx = idx + 1 %}
<label class="opt-btn{% if (mitsumori_json and mitsumori_json.pw == pw) or p_w|length == 1 %} is-selected{% endif %}"
onclick="mitsumori_simulation_val('pw', '{{ pw|e('js') }}');">
<input type="radio" name="pw" id="pw_{{ idx }}" value="{{ pw }}"
{% if (mitsumori_json and mitsumori_json.pw == pw) or p_w|length == 1 %}checked{% endif %}>
{{ pw }}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
{% if p_d and p_d|length and p_d|join != "" and ProductClass.SaleType.id != 3 %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">奥行き{% if mitsumori_json and mitsumori_json.pd %}: <span>{{ mitsumori_json.pd }}</span>{% endif %}</div>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for pd in p_d %}{% if pd %}{% set idx = idx + 1 %}
<label class="opt-btn{% if (mitsumori_json and mitsumori_json.pd == pd) or p_d|length == 1 %} is-selected{% endif %}"
onclick="mitsumori_simulation_val('pd', '{{ pd|e('js') }}');">
<input type="radio" name="pd" id="pd_{{ idx }}" value="{{ pd }}"
{% if (mitsumori_json and mitsumori_json.pd == pd) or p_d|length == 1 %}checked{% endif %}>
{{ pd }}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
{% if p_h and p_h|length and p_h|join != "" and ProductClass.SaleType.id != 3 %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">高さ{% if mitsumori_json and mitsumori_json.ph %}: <span>{{ mitsumori_json.ph }}</span>{% endif %}</div>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for ph in p_h %}{% if ph %}{% set idx = idx + 1 %}
<label class="opt-btn{% if (mitsumori_json and mitsumori_json.ph == ph) or p_h|length == 1 %} is-selected{% endif %}"
onclick="mitsumori_simulation_val('ph', '{{ ph|e('js') }}');">
<input type="radio" name="ph" id="ph_{{ idx }}" value="{{ ph }}"
{% if (mitsumori_json and mitsumori_json.ph == ph) or p_h|length == 1 %}checked{% endif %}>
{{ ph }}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
{% if p_m and p_m|length and p_m|join != "" and ProductClass.SaleType.id != 3 %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">素材{% if mitsumori_json and mitsumori_json.pm %}: <span>{{ mitsumori_json.pm }}</span>{% endif %}</div>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for pm in p_m %}{% if pm %}{% set idx = idx + 1 %}
<label class="opt-btn{% if (mitsumori_json and mitsumori_json.pm == pm) or p_m|length == 1 %} is-selected{% endif %}"
onclick="mitsumori_simulation_val('pm', '{{ pm|e('js') }}');">
<input type="radio" name="pm" id="pm_{{ idx }}" value="{{ pm }}"
{% if (mitsumori_json and mitsumori_json.pm == pm) or p_m|length == 1 %}checked{% endif %}>
{{ pm }}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
{# option1 (sale_type 2 は専用 UI が下にあるため除外 / sale_type 3 は下部ブロックで描画 /
sale_type 4 = fe・ts は option1 が ct_unit_price (枚数増分の工事費単価) で
ユーザー選択肢ではなく計算用の内部値のため radio として表示しない. 値は
上の auto-init (p_option1|length == 1) で JS の option1 変数に埋め込み済み) #}
{% 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 %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<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>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for opt1 in p_option1 %}{% if opt1 %}{% set idx = idx + 1 %}
<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 %}"
onclick="mitsumori_simulation_val('option1', '{{ opt1|e('js') }}');">
<input type="radio" name="option1" id="option1_{{ idx }}" value="{{ opt1 }}"
{% if (mitsumori_json and mitsumori_json.option1 is defined and mitsumori_json.option1 == opt1) or p_option1|length == 1 %}checked{% endif %}>
{{ opt1 }}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
{# option2 #}
{% if p_option2 and p_option2|length and p_option2|join != "" and ProductClass.SaleType.id != 2 and ProductClass.SaleType.id != 3 %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<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>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for opt2 in p_option2 %}{% if opt2 %}{% set idx = idx + 1 %}
<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 %}"
onclick="mitsumori_simulation_val('option2', '{{ opt2|e('js') }}');">
<input type="radio" name="option2" id="option2_{{ idx }}" value="{{ opt2 }}"
{% if (mitsumori_json and mitsumori_json.option2 is defined and mitsumori_json.option2 == opt2) or p_option2|length == 1 %}checked{% endif %}>
{{ opt2 }}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
<!-- 1: 施工見積(通常) → 幅/奥行/高さ/素材/カラーは上部の共通ブロックで表示済み -->
{% if ProductClass.SaleType.id == 1 %}
{% endif %}
<!-- 2: 施工見積(補助金・窓) -->
{% if ProductClass.SaleType.id == 2 %}
{# 窓サイズは右パネルの p_w / p_h ラジオ
(「100cm まで」「150cm まで」…) で選択する仕様.
旧 mado_w / mado_h の自由入力欄は廃止. #}
{# 窓タイプ (option1 = subtype: 引違い 2 枚建 / 4 枚建 / FIX 窓 等) #}
{% if p_option1 and p_option1|length and p_option1|join != "" %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<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>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for opt1_val in p_option1 %}{% if opt1_val %}{% set idx = idx + 1 %}
<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 %}"
onclick="mitsumori_simulation('option1','option1_{{ idx }}');">
<input type="radio" name="option1" id="option1_{{ idx }}" value="{{ opt1_val }}"
{% if (mitsumori_json and mitsumori_json.option1 is defined and mitsumori_json.option1 == opt1_val) or (p_option1|length == 1) %}checked{% endif %}>
{{ opt1_val }}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
{# ガラスタイプ(p_m データから選択肢を生成) #}
{% if p_m and p_m|length and p_m|join != "" %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">ガラスタイプ{% if mitsumori_json and mitsumori_json.pm %}: <span>{{ mitsumori_json.pm }}</span>{% endif %}</div>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for pm_val in p_m %}{% if pm_val %}{% set idx = idx + 1 %}
<label class="opt-btn{% if (mitsumori_json and mitsumori_json.pm == pm_val) or (p_m|length == 1) %} is-selected{% endif %}"
onclick="mitsumori_simulation('pm','glass_type_{{ idx }}');">
<input type="radio" name="glass_type" id="glass_type_{{ idx }}" value="{{ pm_val }}"
{% if (mitsumori_json and mitsumori_json.pm == pm_val) or (p_m|length == 1) %}checked{% endif %}>
{{ pm_val }}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
{# 2026-05 仕様簡素化: 「セット数」入力欄は廃止.
枚数は subtype (引違い 2 枚建 / 4 枚建 等) に内包し、
複数セットはカート quantity で表現する. #}
{% endif %}
<!-- 3: 施工見積(物置・ゴミステーション) -->
{% if ProductClass.SaleType.id == 3 %}
{# 幅・奥行き・高さ(p_w/p_d/p_h からボタン型ラジオ生成) #}
{% if p_w and p_w|length and p_w|join != "" %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">幅{% if mitsumori_json and mitsumori_json.pw %}: <span>{{ mitsumori_json.pw }}</span>{% endif %}</div>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for pw_val in p_w %}{% if pw_val %}{% set idx = idx + 1 %}
<label class="opt-btn{% if (mitsumori_json and mitsumori_json.pw == pw_val) or p_w|length == 1 %} is-selected{% endif %}"
onclick="mitsumori_simulation('pw','pw3_{{ idx }}');">
<input type="radio" name="pw" id="pw3_{{ idx }}" value="{{ pw_val }}"
{% if (mitsumori_json and mitsumori_json.pw == pw_val) or p_w|length == 1 %}checked{% endif %}>
{{ pw_val }}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
{% if p_d and p_d|length and p_d|join != "" %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">奥行き{% if mitsumori_json and mitsumori_json.pd %}: <span>{{ mitsumori_json.pd }}</span>{% endif %}</div>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for pd_val in p_d %}{% if pd_val %}{% set idx = idx + 1 %}
<label class="opt-btn{% if (mitsumori_json and mitsumori_json.pd == pd_val) or p_d|length == 1 %} is-selected{% endif %}"
onclick="mitsumori_simulation('pd','pd3_{{ idx }}');">
<input type="radio" name="pd" id="pd3_{{ idx }}" value="{{ pd_val }}"
{% if (mitsumori_json and mitsumori_json.pd == pd_val) or p_d|length == 1 %}checked{% endif %}>
{{ pd_val }}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
{% if p_h and p_h|length and p_h|join != "" %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">高さ{% if mitsumori_json and mitsumori_json.ph %}: <span>{{ mitsumori_json.ph }}</span>{% endif %}</div>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for ph_val in p_h %}{% if ph_val %}{% set idx = idx + 1 %}
<label class="opt-btn{% if (mitsumori_json and mitsumori_json.ph == ph_val) or p_h|length == 1 %} is-selected{% endif %}"
onclick="mitsumori_simulation('ph','ph3_{{ idx }}');">
<input type="radio" name="ph" id="ph3_{{ idx }}" value="{{ ph_val }}"
{% if (mitsumori_json and mitsumori_json.ph == ph_val) or p_h|length == 1 %}checked{% endif %}>
{{ ph_val }}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
{# 棚タイプ(p_m データから選択肢を生成) #}
{% if p_m and p_m|length and p_m|join != "" %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">棚タイプ <small class="text-muted">(間仕切り仕様)</small>{% if mitsumori_json and mitsumori_json.pm %}: <span>{{ mitsumori_json.pm }}</span>{% endif %}</div>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for pm_val in p_m %}{% if pm_val %}{% set idx = idx + 1 %}
<label class="opt-btn{% if (mitsumori_json and mitsumori_json.pm == pm_val) or p_m|length == 1 %} is-selected{% endif %}"
onclick="mitsumori_simulation('pm','pm3_{{ idx }}');">
<input type="radio" name="pm" id="pm3_{{ idx }}" value="{{ pm_val }}"
{% if (mitsumori_json and mitsumori_json.pm == pm_val) or p_m|length == 1 %}checked{% endif %}>
{{ pm_val }}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
{# option1 (mo の 棚タイプ 等、p_option1 データから選択肢を生成) #}
{% if p_option1 and p_option1|length and p_option1|join != "" %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<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>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for opt1_val in p_option1 %}{% if opt1_val %}{% set idx = idx + 1 %}
<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 %}"
onclick="mitsumori_simulation('option1','option1_3_{{ idx }}');">
<input type="radio" name="option1" id="option1_3_{{ idx }}" value="{{ opt1_val }}"
{% if (mitsumori_json and mitsumori_json.option1 is defined and mitsumori_json.option1 == opt1_val) or p_option1|length == 1 %}checked{% endif %}>
{{ opt1_val }}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
{# カラー(共通の color データ使用) #}
{% if color and color|length %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">カラー{% if mitsumori_json and mitsumori_json.pc %}: <span>{{ mitsumori_json.pc }}</span>{% endif %}</div>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for cc in color %}{% if cc and cc['name'] %}{% set idx = idx + 1 %}
<label class="opt-btn{% if (mitsumori_json and mitsumori_json.pc == cc['name']) or color|length == 1 %} is-selected{% endif %}"
onclick="mitsumori_simulation('pc','cc3_{{ idx }}');">
<input type="radio" name="color3" id="cc3_{{ idx }}" value="{{ cc['name'] }}"
{% if (mitsumori_json and mitsumori_json.pc == cc['name']) or color|length == 1 %}checked{% endif %}>
{{ cc['name'] }}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
{# 台数 #}
<div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<label class="col-4 col-form-label">台数</label>
<div class="col-4">
<div class="input-group mb-3">
<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');">
<span class="input-group-text">台</span>
</div>
</div>
<div class="col-4">
<button type="button" class="btn btn-info" onclick="daisu(+1);">+</button>
<button type="button" class="btn btn-danger" onclick="daisu(-1);">ー</button>
</div>
</div>
{% endif %}
<!-- 4: 施工見積(フェンス・組み立て式) -->
{% if ProductClass.SaleType.id == 4 %}
{# 枚数 #}
<div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<label class="col-4 col-form-label">枚数</label>
<div class="col-4 mb-3">
<div class="input-group">
<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');">
<span class="input-group-text">枚</span>
</div>
</div>
<div class="col-4">
<button type="button" class="btn btn-info" onclick="maisu(+1);">+</button>
<button type="button" class="btn btn-danger" onclick="maisu(-1);">ー</button>
</div>
</div>
{% endif %}
<!-- 5: 施工見積(ウッドデッキ・タイルデッキ) -->
{% if ProductClass.SaleType.id == 5 %}
{# ステップの有無 #}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">ステップ</div>
<div class="opt-btn-group">
{% set step_yes_checked = (mitsumori_json and mitsumori_json.deck_step is defined and mitsumori_json.deck_step == '必要') %}
{% 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) %}
<label class="opt-btn{% if step_yes_checked %} is-selected{% endif %}"
onclick="mitsumori_simulation('op0','deck_step_yes');">
<input type="radio" name="deck_step" id="deck_step_yes" value="必要"
{% if step_yes_checked %}checked{% endif %}>
必要
</label>
<label class="opt-btn{% if step_no_checked %} is-selected{% endif %}"
onclick="mitsumori_simulation('op0','deck_step_no');">
<input type="radio" name="deck_step" id="deck_step_no" value="不要"
{% if step_no_checked %}checked{% endif %}>
不要
</label>
</div>
<div class="opt-survey-note-wd-step" style="font-size:12px;color:#c00;margin-top:6px;{% if not step_yes_checked %}display:none;{% endif %}">
※ 現場調査後に正式お見積もりさせていただきます。
</div>
</div>
{# ウッドデッキフェンスの有無 #}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">デッキフェンス</div>
<div class="opt-btn-group">
{% set fence_yes_checked = (mitsumori_json and mitsumori_json.deck_fence is defined and mitsumori_json.deck_fence == '必要') %}
{% 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) %}
<label class="opt-btn{% if fence_yes_checked %} is-selected{% endif %}"
onclick="mitsumori_simulation('op1','deck_fence_yes');">
<input type="radio" name="deck_fence" id="deck_fence_yes" value="必要"
{% if fence_yes_checked %}checked{% endif %}>
必要
</label>
<label class="opt-btn{% if fence_no_checked %} is-selected{% endif %}"
onclick="mitsumori_simulation('op1','deck_fence_no');">
<input type="radio" name="deck_fence" id="deck_fence_no" value="不要"
{% if fence_no_checked %}checked{% endif %}>
不要
</label>
</div>
<div class="opt-survey-note-wd-fence" style="font-size:12px;color:#c00;margin-top:6px;{% if not fence_yes_checked %}display:none;{% endif %}">
※ 現場調査後に正式お見積もりさせていただきます。
</div>
</div>
{% endif %}
<!-- 6: 施工見積(芝生・枚数・数量買い) -->
{% if ProductClass.SaleType.id == 6 %}
{# 規格(p_m データ → 素材から抽出) #}
{% if p_m and p_m|length and p_m|join != "" %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">規格{% if mitsumori_json and mitsumori_json.pm %}: <span>{{ mitsumori_json.pm }}</span>{% endif %}</div>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for pm_val in p_m %}{% if pm_val %}{% set idx = idx + 1 %}
<label class="opt-btn{% if (mitsumori_json and mitsumori_json.pm == pm_val) or p_m|length == 1 %} is-selected{% endif %}"
onclick="mitsumori_simulation('pm','pm6_{{ idx }}');">
<input type="radio" name="pm" id="pm6_{{ idx }}" value="{{ pm_val }}"
{% if (mitsumori_json and mitsumori_json.pm == pm_val) or p_m|length == 1 %}checked{% endif %}>
{{ pm_val }}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
{# 芝の長さ(p_w データ → 幅から抽出) #}
{% if p_w and p_w|length and p_w|join != "" %}
<div class="form-group mt-3 pb-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">芝の長さ{% if mitsumori_json and mitsumori_json.pw %}: <span>{{ mitsumori_json.pw }}</span>{% endif %}</div>
<div class="opt-btn-group">
{% set idx = 0 %}
{% for pw_val in p_w %}{% if pw_val %}{% set idx = idx + 1 %}
<label class="opt-btn{% if (mitsumori_json and mitsumori_json.pw == pw_val) or p_w|length == 1 %} is-selected{% endif %}"
onclick="mitsumori_simulation('pw','pw6_{{ idx }}');">
<input type="radio" name="pw" id="pw6_{{ idx }}" value="{{ pw_val }}"
{% if (mitsumori_json and mitsumori_json.pw == pw_val) or p_w|length == 1 %}checked{% endif %}>
{{ pw_val }}
</label>
{% endif %}{% endfor %}
</div>
</div>
{% endif %}
{# 施工面積(㎡ 自由入力) #}
<div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<label class="col-4 col-form-label">施工面積</label>
<div class="col-8">
<div class="input-group">
<input type="number" name="area" id="area"
class="form-control"
value="{{ mitsumori_json.area|default('') }}"
placeholder="例: 10.5"
min="0.1" step="0.1"
onchange="mitsumori_simulation('area','area');">
<span class="input-group-text">平米</span>
</div>
</div>
</div>
{% endif %}
<!-- 7: 施工見積(数量買い・基本工事費固定) -->
{% if ProductClass.SaleType.id == 7 %}
{# 個数(物置の daisu と同形式、単位は「個」) #}
<div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<label class="col-4 col-form-label">個数</label>
<div class="col-4">
<div class="input-group mb-3">
<input type="number" name="suuryou" id="suuryou" class="form-control"
value="{{ mitsumori_json.suuryou|default('1') }}" min="1" max="100"
onchange="mitsumori_simulation('suuryou','suuryou');">
<span class="input-group-text">個</span>
</div>
</div>
<div class="col-4">
<button type="button" class="btn btn-info" onclick="suuryou(+1);">+</button>
<button type="button" class="btn btn-danger" onclick="suuryou(-1);">ー</button>
</div>
</div>
{% endif %}
<!-- 9: 商品のみ購入 -->
{% if ProductClass.SaleType.id == 9 %}
<div class="form-group row mt-2" style="border-bottom:1px solid rgba(0,0,0,.125)">
<label class="col-4 col-form-label">数量</label>
<div class="col-4">
<div class="input-group mb-3">
<input type="number" name="quantity_only" id="quantity_only" class="form-control" value="1" min="1" onchange="$('#quantity').val(this.value);">
<span class="input-group-text">個</span>
</div>
</div>
<div class="col-4">
<button type="button" class="btn btn-info" onclick="quantityOnly(+1);">+</button>
<button type="button" class="btn btn-danger" onclick="quantityOnly(-1);">ー</button>
</div>
</div>
{% endif %}
<div class="row" style="border-bottom:1px solid rgba(0,0,0,.125)"><label class="col-12 col-form-label">取り付け工事のご希望に関してお答えください。</label></div>
{# gs (ゴミステーション, category id=27) では「撤去対応」「残土・ガラ処理」は ex-shop に存在しないため非表示
cg (カーゲート, category id=9) では「残土・ガラ処理」分は撤去金額側に内包済みのため非表示
(撤去オプション自体は残す) #}
{% set is_gs = false %}
{% set is_cg = false %}
{% if Product.ProductCategories is not empty %}
{% for ProductCategory in Product.ProductCategories %}
{% if ProductCategory.category_id == 27 %}{% set is_gs = true %}{% endif %}
{% if ProductCategory.category_id == 9 %}{% set is_cg = true %}{% endif %}
{% endfor %}
{% endif %}
{% for i in 0..10 %}
{% if op and op|length >= i+1 %}
{% if op[i]['name'] %}
{% set hide_opt = false %}
{% if is_gs and (op[i]['name'] matches '/撤去/' or op[i]['name'] matches '/残土/') %}
{% set hide_opt = true %}
{% endif %}
{% if is_cg and op[i]['name'] matches '/残土/' %}
{% set hide_opt = true %}
{% endif %}
{% if not hide_opt %}
{# price=0 で「解体」「撤去」「設置場所」(wd 等で API 差額未提供) を含むオプションは
選択時に「現場調査後に正式お見積もり」文言を出す. #}
{% set is_removal_unknown = (op[i]['price']|default(0) == 0 or op[i]['price']|default('0') == '0')
and (op[i]['name'] matches '/解体/' or op[i]['name'] matches '/撤去/' or op[i]['name'] matches '/設置場所/') %}
<div class="form-group mt-3 pb-3" style="border-bottom:1px solid rgba(0,0,0,.125)">
<div class="rp-section-label">{{ op[i]['name'] }}{% if mitsumori_json and mitsumori_json.op[i] %}: <span>{{ mitsumori_json.op[i] }}</span>{% endif %}</div>
{% if op[i]['comment'] %}<div class="opt-comment" style="font-size:12px;color:#666;margin:4px 0 6px;">{{ op[i]['comment'] }}</div>{% endif %}
<div class="opt-btn-group">
<label class="opt-btn{% if mitsumori_json and mitsumori_json.op[i] == op[i]['on'] %} is-selected{% endif %}"
onclick="mitsumori_simulation('op{{ i }}','op{{ i }}_1');">
<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 %}>
{{ op[i]['on'] }}
</label>
<label class="opt-btn{% if mitsumori_json and mitsumori_json.op[i] == op[i]['off'] %} is-selected{% endif %}"
onclick="mitsumori_simulation('op{{ i }}','op{{ i }}_2');">
<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 %}>
{{ op[i]['off'] }}
</label>
</div>
{% if is_removal_unknown %}
<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 %}">
※ 現場調査後に正式お見積もりさせていただきます。
</div>
{% endif %}
</div>
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
</div>
<!-- /.card-body -->
</div>
<form action="{{ url('product_add_cart', {id:Product.id}) }}" method="post" id="form1" name="form1">
{% if Product.stock_find %}
<div class="ec-productRole__actions">
{% if form.classcategory_id1 is defined %}
<div class="ec-select">
{{ form_row(form.classcategory_id1) }}
{{ form_errors(form.classcategory_id1) }}
</div>
{% if form.classcategory_id2 is defined %}
<div class="ec-select">
{{ form_row(form.classcategory_id2) }}
{{ form_errors(form.classcategory_id2) }}
</div>
{% endif %}
{% endif %}
<div class="ec-numberInput">
{{ form_widget(form.quantity, { type: 'hidden' }) }}
{{ form_errors(form.quantity) }}
</div>
</div>
{% else %}
<div class="ec-productRole__btn">
<button type="button" class="ec-blockBtn--action" disabled="disabled">
{{ 'ただいま品切れ中です。'|trans }}
</button>
</div>
{% endif %}
<div class="ec-productRole__btn mt-3">
<button type="submit" id="cart_btn" class="ec-blockBtn--action add-cart">カートに入れる</button>
</div>
{{ form_rest(form) }}
</form>
<div class="ec-modal add-cart-modal">
<div class="ec-modal-overlay">
<div class="ec-modal-wrap add-cart-modal__wrap">
<span class="ec-modal-close"><span class="ec-icon"><img src="{{ asset('assets/icon/cross-dark.svg') }}" alt=""/></span></span>
<div id="ec-modal-header" class="text-center add-cart-modal__header">{{ 'カートに追加しました。'|trans }}</div>
<div class="ec-modal-box add-cart-modal__box">
<div class="ec-role add-cart-modal__actions">
<a href="{{ url('cart') }}" class="ec-inlineBtn--action add-cart-modal__primary">{{ 'カートに進む'|trans }}</a>
<span class="ec-inlineBtn--cancel add-cart-modal__secondary">{{ '商品検索を続ける'|trans }}</span>
</div>
</div>
</div>
</div>
</div>
<div class="ec-productRole__description">{{ Product.description_detail|raw|nl2br }}
</div>
{# SNSシェア #}
<div class="ec-productRole__share">
<ul class="ec-share">
<li class="ec-share__item">
<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">
<i class="fab fa-twitter"></i>
</a>
</li>
<li class="ec-share__item">
<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">
<i class="fab fa-facebook-f"></i>
</a>
</li>
<li class="ec-share__item">
<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">
<i class="fab fa-line"></i>
</a>
</li>
</ul>
</div>
</div>
{# ===== スマホ用 見積金額 下部固定バー ===== #}
<div id="sp-mitsumori-bar">
<div>
<div class="sp-bar__label">合計(工事費・税込)</div>
<div class="sp-bar__price" id="sp-mitsumori-price">---円</div>
</div>
<button type="button" class="sp-bar__btn"
onclick="document.getElementById('cart_btn2') && document.getElementById('cart_btn2').click();">
<i class="fas fa-shopping-cart"></i>
<span class="sp-bar__btn-label">検討リストへ</span>
{% set spTotalQty = get_carts_total_quantity() %}
{% if spTotalQty > 0 %}
<span class="sp-bar__cart-badge">{{ spTotalQty|number_format }}</span>
{% endif %}
</button>
<a href="{{ url('homepage') }}" class="sp-bar__home-btn" title="トップページへ">
<i class="fas fa-home"></i>
</a>
</div>
{# tg カテゴリ用: block 別オプション差額ラジオ (W/D 確定後に JS が動的描画) #}
<div id="tg-options" class="tg-options-container col-12"></div>
<div class="card col-12 collapsed-card sticky-top float-right mitsumori-card-pc">
<div class="card-header">
<h3 class="card-title">現在のお見積り額</h3>
<div class="card-tools">
<span class="float-left" id="mitsumori_message">395000円</span>
<button type="button" class="btn btn-tool btn-mitsumori-toggle" data-card-widget="collapse" title="詳細を表示">
<span class="toggle-icon">▼ 詳細</span>
</button>
</div>
</div>
<div class="card-body p-0">
<ul class="nav nav-pills flex-column">
<li class="nav-item active">
<a class="nav-link">
<i class="far fa-file-alt"></i> 合計(工事費・税込)
<span class="float-right" id="mitsumori_goukei">395,000円</span>
</a>
</li>
<li class="nav-item active">
<a class="nav-link">
<i class="far fa-file-alt"></i> 商品価格
<span class="float-right" id="mitsumori_price">307,008円</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link">
<i class="far fa-file-alt"></i> カタログ価格
<span class="float-right" id="maker_price">479,700円</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link">
<i class="far fa-file-alt"></i> お値引き
<span class="float-right" id="mitsumori_off">-172,692円</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link">
<i class="far fa-file-alt"></i> 基本工事費
<span class="float-right" id="mitsumori_ct">53,250円</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link">
<i class="far fa-file-alt"></i> 施工オプション
<span class="float-right"id="mitsumori_option">6,297円</span>
</a>
</li>
</ul>
</div>
<div class="card-footer">
<button type="button" id="mitsumori_btn" class="btn btn-info" data-toggle="modal" data-target="#modal-mitsumori">
見積書表示
</button>
<button type="submit" id="cart_btn2" class="btn btn-info add-cart">カートに入れる</button>
</div>
</div>
</div>
</div>
</div>
<div class="modal" id="modal-mitsumori">
<div class="modal-dialog modal-mitsumori" style="max-width:1000px">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">お見積書</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="invoice p-3 mb-5" style="max-width:1000px; margin:auto;">
<!-- title row -->
<div class="row">
<div class="col-12">
<h2>概算お見積書
<small class="float-right" style="font-size:14px;">発行日: 2025/03/14</small>
</h2>
</div>
<!-- /.col -->
</div>
<!-- info row -->
<div class="row invoice-info">
<div class="col-sm-8 invoice-col">
<h3>お客様</h3>
<span>下記の通り、お見積もり申し上げます。</span>
<br />
<br / >
<br />
<h2>お見積金額: <span id="mitsumori_kei">399,080円</span></h2>
<span>
<br/>
<br/>
<br/>
<br/>
</span>
</div>
<div class="col-sm-4 invoice-col">
<p>
<img alt="" src="/html/user_data/js/images/logo.png" style="width: 260px; max-width: 100%; max-height: 10mm;">
</p>
<p>有限会社プラス</p>
<p>〒400-0334</p>
<p>山梨県南アルプス市藤田1450番地2</p>
<p>TEL: 055-284-6480</p>
<img alt="" src="/html/user_data/js/images/seal.svg" style="z-index: 2; position: absolute; width: 21mm; left: 58mm; top: 36mm;">
</div>
<!-- /.col -->
<!-- /.col -->
</div>
<!-- /.row -->
<!-- Table row -->
<div class="row">
<div class="col-12 table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>項目</th>
<th>数量</th>
<th>単位</th>
<th>単価</th>
<th>小計</th>
</tr>
</thead>
<tbody>
<tr>
<td id="mitsumori_item_name">{{ Product.name }}</td>
<td>1</td>
<td>式</td>
<td id="mitsumori_price_01">352,800</td>
<td id="mitsumori_price_02">352,800</td>
</tr>
<tr>
<td>基本工事費</td>
<td>1</td>
<td>式</td>
<td id="mitsumori_ct_01">10,000</td>
<td id="mitsumori_ct_02">10,000</td>
</tr>
<tr>
<td>残土・ガラ処理</td>
<td>1</td>
<td>式</td>
<td>0円</td>
<td></td>
</tr>
<tr>
<td> </td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
<div class="row">
<!-- accepted payments column -->
<div class="col-6">
<p class="lead">お支払い方法</p>
<p class="text-muted well well-sm shadow-none" style="margin-top: 10px;">銀行振込、クレジットカード決済、PAYPAY決済
<br>銀行振込:山梨中央銀行 白根支店 普通口座 391402
<br>※商品代金と工事代金の総額が金100万円(税込)を超える場合、着手金として代金の半額をご契約後お支払いいただきます。
</p>
</div>
<!-- /.col -->
<div class="col-6">
<div class="table-responsive">
<table class="table">
<tbody>
<tr>
<th style="width:50%">小計:</th>
<td id="mitsumori_shoukei">362,800</td>
</tr>
<tr>
<th>消費税 (10%)</th>
<td id="mitsumori_tax">36,280</td>
</tr>
<tr>
<th>合計:</th>
<td id="mitsumori_goukei_02">399,080</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</div>
</div>
<div class="modal-footer justify-content-between">
{# PDF出力: mitsumori_json を POST して PDF ダウンロード #}
<form method="post" action="{{ url('mitsumori_pdf') }}" target="_blank" id="pdf_download_form">
<input type="hidden" name="_token" value="{{ csrf_token('mitsumori_pdf') }}">
<input type="hidden" name="mitsumori_json" id="pdf_mitsumori_json">
<button type="submit" class="btn btn-primary float-right" style="margin-right: 5px;" onclick="syncPdfJson();">
<i class="fas fa-download"></i>PDF出力
</button>
</form>
<button type="submit" id="cart_btn3" class="btn btn-info add-cart">カートに入れる</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<!-- Image zoom modal: custom lightweight lightbox (no CDN dependency) -->
<div id="img-modal" role="dialog" aria-modal="true" aria-label="画像拡大">
<button id="img-modal__close" aria-label="閉じる">×</button>
<button id="img-modal__prev" aria-label="前の画像">❮</button>
<img id="img-modal__img" src="" alt="">
<button id="img-modal__next" aria-label="次の画像">❯</button>
</div>
<style>
#img-modal {
display: none;
position: fixed;
inset: 0;
z-index: 9999;
background: rgba(0,0,0,0.88);
align-items: center;
justify-content: center;
cursor: zoom-out;
}
#img-modal.is-open { display: flex; }
#img-modal__img {
max-width: 92vw;
max-height: 88vh;
object-fit: contain;
border-radius: 4px;
cursor: default;
user-select: none;
touch-action: pinch-zoom;
display: block;
}
#img-modal__close {
position: absolute;
top: 14px;
right: 18px;
font-size: 38px;
color: #fff;
cursor: pointer;
background: none;
border: none;
padding: 0;
line-height: 1;
z-index: 1;
opacity: 0.85;
}
#img-modal__close:hover { opacity: 1; }
#img-modal__prev,
#img-modal__next {
position: absolute;
top: 50%;
transform: translateY(-50%);
font-size: 36px;
color: #fff;
cursor: pointer;
background: rgba(0,0,0,0.32);
border: none;
padding: 10px 16px;
line-height: 1;
border-radius: 6px;
z-index: 1;
opacity: 0.8;
user-select: none;
}
#img-modal__prev:hover, #img-modal__next:hover { opacity: 1; }
#img-modal__prev { left: 12px; }
#img-modal__next { right: 12px; }
@media (max-width: 767px) {
#img-modal__prev, #img-modal__next { font-size: 28px; padding: 8px 12px; }
}
</style>
<script>
(function(){
var images = [];
var current = 0;
// Collect original (non-cloned) slide images at click time.
// After Slick init, slides are wrapped in .slick-slide; clones have .slick-cloned.
function collectImages() {
images = [];
var $slides = $('.item_visual .slick-slide:not(.slick-cloned)');
if (!$slides.length) {
// Slick not yet initialized (fallback)
$slides = $('.item_visual .slide-item');
}
$slides.each(function() {
var $a = $(this).find('a.js-zoom');
if ($a.length) {
images.push({ src: $a.attr('href'), alt: $a.find('img').attr('alt') || '' });
}
});
}
function showImage(idx) {
current = ((idx % images.length) + images.length) % images.length;
$('#img-modal__img').attr({ src: images[current].src, alt: images[current].alt });
}
function openModal(href) {
collectImages();
if (!images.length) return;
var idx = 0;
for (var i = 0; i < images.length; i++) {
if (images[i].src === href) { idx = i; break; }
}
showImage(idx);
$('#img-modal').addClass('is-open');
$('body').css('overflow', 'hidden');
}
function closeModal() {
$('#img-modal').removeClass('is-open');
$('body').css('overflow', '');
}
// Click handler: works for both original and Slick-cloned anchors
$(document).on('click', '.item_visual a.js-zoom', function(e) {
e.preventDefault();
openModal($(this).attr('href'));
});
// Close on backdrop click
$('#img-modal').on('click', function(e) {
if (e.target === this) closeModal();
});
$('#img-modal__close').on('click', closeModal);
$('#img-modal__prev').on('click', function(e) { e.stopPropagation(); showImage(current - 1); });
$('#img-modal__next').on('click', function(e) { e.stopPropagation(); showImage(current + 1); });
// Keyboard navigation
$(document).on('keydown', function(e) {
if (!$('#img-modal').hasClass('is-open')) return;
if (e.key === 'Escape') closeModal();
if (e.key === 'ArrowLeft') showImage(current - 1);
if (e.key === 'ArrowRight') showImage(current + 1);
});
// Touch swipe (horizontal only)
var _tx = 0;
var $modal = document.getElementById('img-modal');
$modal.addEventListener('touchstart', function(e) {
_tx = e.changedTouches[0].clientX;
}, { passive: true });
$modal.addEventListener('touchend', function(e) {
var dx = e.changedTouches[0].clientX - _tx;
if (Math.abs(dx) > 48) {
dx < 0 ? showImage(current + 1) : showImage(current - 1);
}
}, { passive: true });
})();
</script>
{% endblock %}