{% sw_extends "@Storefront/storefront/page/product-detail/buy-widget-form.html.twig" %}
{% block page_product_detail_buy_form_inner_csrf %}
{{ parent() }}
{% if page.product.available %}
{% set attributesData = null %}
{% if page.product.attributesFromProduct %}
{% set attributesData = page.product.attributesFromProduct %}
{% elseif page.product.attributesFromCategories %}
{% set attributesData = page.product.attributesFromCategories %}
{% elseif page.product.attributesFromProductStream %}
{% set attributesData = page.product.attributesFromProductStream %}
{% endif %}
{% if page.product.dependenciesAttributes %}
{% sw_include '@HuebertAccessoriesDirectly/storefront/page/product-detail/attribute-dependecies.html.twig' %}
{% endif %}
{% if attributesData %}
{% block huebert_upload_modal_container %}
{% sw_include '@Storefront/storefront/page/product-detail/modal/upload.html.twig' %}
{% endblock %}
<div class="row">
<div class="col-12 attributes-container" data-frontend-calculations="true" data-snippets='{
"totalSnippet": "{{ "huebert.detail.totalCalculated"|trans }}",
"currency": "{{ context.currency.symbol }}"
}'>
<input type="hidden" class="language-attribute" value="{{ page.header.activeLanguage.name }}">
{% for attribute in attributesData %}
{% set last = loop.last %}
{% set separatedQuantity = page.separatedQuantity %}
{% if separatedQuantity %}
{% set inputName = "lineItems" %}
{% else %}
{% set inputName = "attributes" %}
{% endif %}
<div class="row {% if attribute.translated.infotext and attribute.infotype == "textbelow" %}info-text-bottom-active{% endif %}">
<div class="{% if attribute.type is same as('textarea') %}col-md-12 {% else %}col-md-6{% endif%} col-12">
{% if attribute.type is same as('dropdown') %}
{% if page.enabledPrices %}
{# WITH PRICES #}
{% if attribute.translated.optionsNameValue.options %}
<label class="form-label" for="{{ attribute.id }}">{{ attribute.translated.name }}
{% if (attribute.infotext or attribute.translated.infotext) and attribute.infotype == "help" %}
<dfn class="hue-tooltip"> {% sw_icon 'help' style {'size':'xs'} %}
<span role="tooltip">{{ attribute.translated.infotext| raw }}</span>
</dfn>
{% endif %}
</label>
<select id="{{ attribute.id }}"
class="custom-select {% if last %}mb-4{% else %}mb-3{% endif %} dropdownValue onValueChange"
{% if separatedQuantity %}
name="lineItems[{{ page.product.id }}][attributes_with_prices][{{ attribute.translated.name }}]"
{% else %}
name="attributes[{{ page.product.id }}][{{ attribute.id }}][attributes_with_prices][{{ attribute.translated.name }}]"
{% endif %}
{% if attribute.required %}required="required"{% endif %}>
<option disabled="disabled" selected="selected" value="">
{{ "huebert.detail.dropdownHint"|trans }}
</option>
{% for option in attribute.translated.optionsNameValue.options %}
<option value="{{ option.name }}--{{ option.value }}">
{{ option.name }}
</option>
{% endfor %}
</select>
{% endif %}
{% else %}
{% if attribute.options %}
<label class="form-label" for="{{ attribute.id }}">{{ attribute.translated.name }}
{% if (attribute.infotext or attribute.translated.infotext) and attribute.infotype == "help" %}
<dfn class="hue-tooltip"> {% sw_icon 'help' style {'size':'xs'} %}
<span role="tooltip">{{ attribute.translated.infotext| raw }}</span>
</dfn>
{% endif %}
</label>
<select id="{{ attribute.id }}"
class="custom-select {% if last %}mb-4{% else %}mb-3{% endif %}"
name="attributes[{{ page.product.id }}][{{ attribute.id }}]"
{% if attribute.required %}required="required"{% endif %}>
<option disabled="disabled" selected="selected" value="">
{{ "huebert.detail.dropdownHint"|trans }}
</option>
{% for option in attribute.options|split(',') %}
<option value="{{ option }}">
{{ option }}
</option>
{% endfor %}
</select>
{% endif %}
{% endif %}
{% elseif attribute.type is same as('single-select') %}
{% if page.enabledPrices %}
{# WITH PRICES #}
{% if attribute.translated.optionsNameValue.options %}
<label class="form-label" for="{{ attribute.id }}">{{ attribute.translated.name }}
{% if (attribute.infotext or attribute.translated.infotext) and attribute.infotype == "help" %}
<dfn class="hue-tooltip"> {% sw_icon 'help' style {'size':'xs'} %}
<span role="tooltip">{{ attribute.translated.infotext| raw }}</span>
</dfn>
{% endif %}
</label>
{% for option in attribute.translated.optionsNameValue.options %}
<div class="custom-control custom-radio {% if loop.last %}mb-3{% else %}mb-1{% endif %}">
<input type="radio"
class="custom-control-input singleValue onValueChange"
id="{{ attribute.id }}_{{ loop.index }}"
{% if separatedQuantity %}
name="lineItems[{{ page.product.id }}][attributes_with_prices][{{ attribute.translated.name }}]"
{% else %}
name="attributes[{{ page.product.id }}][{{ attribute.id }}][attributes_with_prices][{{ attribute.translated.name }}]"
{% endif %}
value="{{ option.name }}--{{ option.value }}"
{% if attribute.required %}required="required"{% endif %}>
<label for="{{ attribute.id }}_{{ loop.index }}" class="custom-control-label">
{{ option.name }}
</label>
</div>
{% endfor %}
{% endif %}
{% else %}
{% if attribute.options %}
<label class="form-label" for="{{ attribute.id }}">{{ attribute.translated.name }}
{% if (attribute.infotext or attribute.translated.infotext) and attribute.infotype == "help" %}
<dfn class="hue-tooltip"> {% sw_icon 'help' style {'size':'xs'} %}
<span role="tooltip">{{ attribute.translated.infotext| raw }}</span>
</dfn>
{% endif %}
</label>
{% for option in attribute.options|split(',') %}
<div class="custom-control custom-radio {% if loop.last %}mb-3{% else %}mb-1{% endif %}">
<input type="radio"
class="custom-control-input"
id="{{ attribute.id }}_{{ loop.index }}"
name="attributes[{{ page.product.id }}][{{ attribute.id }}]"
value="{{ option }}"
{% if attribute.required %}required="required"{% endif %}>
<label for="{{ attribute.id }}_{{ loop.index }}" class="custom-control-label">
{{ option }}
</label>
</div>
{% endfor %}
{% endif %}
{% endif %}
{% elseif attribute.type is same as('multi-select') %}
{% if page.enabledPrices %}
{# WITH PRICES #}
{% if attribute.translated.optionsNameValue.options %}
<label class="form-label" for="{{ attribute.id }}">{{ attribute.translated.name }}
{% if (attribute.infotext or attribute.translated.infotext) and attribute.infotype == "help" %}
<dfn class="hue-tooltip"> {% sw_icon 'help' style {'size':'xs'} %}
<span role="tooltip">{{ attribute.translated.infotext| raw }}</span>
</dfn>
{% endif %}
</label>
{% for option in attribute.translated.optionsNameValue.options %}
<div class="custom-control custom-checkbox {% if loop.last %}mb-3{% else %}mb-1{% endif %}">
<input type="checkbox"
class="custom-control-input multiValue onValueChange"
id="{{ attribute.id }}_{{ loop.index }}"
{% if separatedQuantity %}
name="lineItems[{{ page.product.id }}][attributes_with_prices][{{ attribute.translated.name }}][{{ option.name }}]"
{% else %}
name="attributes[{{ page.product.id }}][{{ attribute.id }}][attributes_with_prices][{{ attribute.translated.name }}][{{ option.name }}]"
{% endif %}
value="{{ option.value }}"
{% if attribute.required %}required="required"{% endif %}>
<label for="{{ attribute.id }}_{{ loop.index }}" class="custom-control-label">
{{ option.name }}
</label>
</div>
{% endfor %}
{% endif %}
{% else %}
{% if attribute.options %}
<label class="form-label" for="{{ attribute.id }}">{{ attribute.translated.name }}
{% if (attribute.infotext or attribute.translated.infotext) and attribute.infotype == "help" %}
<dfn class="hue-tooltip"> {% sw_icon 'help' style {'size':'xs'} %}
<span role="tooltip">{{ attribute.translated.infotext| raw }}</span>
</dfn>
{% endif %}
</label>
{% for option in attribute.options|split(',') %}
<div class="custom-control custom-checkbox {% if loop.last %}mb-3{% else %}mb-1{% endif %}">
<input type="checkbox"
class="custom-control-input"
id="{{ attribute.id }}_{{ loop.index }}"
name="attributes[{{ page.product.id }}][{{ attribute.id }}][]"
value="{{ option }}"
{% if attribute.required %}required="required"{% endif %}>
<label for="{{ attribute.id }}_{{ loop.index }}" class="custom-control-label">
{{ option }}
</label>
</div>
{% endfor %}
{% endif %}
{% endif %}
{% elseif attribute.type is same as('media') %}
<label class="form-label" for="{{ attribute.id }}">{{ attribute.translated.name }}
{% if attribute.infotext and attribute.infotype == "help" %}
<dfn class="hue-tooltip"> {% sw_icon 'help' style {'size':'xs'} %}
<span role="tooltip">{{ attribute.infotext | raw }}</span>
</dfn>
{% endif %}
</label>
<template data-media-upload-plugin data-uplaodUrl="{{ seoUrl('huebert.add.order.attributes.media.upload') }}"></template>
<div style="margin-bottom: 20px;width:300px;">
<input type="file"
id="huebert-add-media-upload_{{ loop.index }}"
class="huebert-add-media-upload_{{ loop.index }} media"
name="huebert-add-media-upload_{{ loop.index }}"
accept="{{ attribute.fileTypes }}"
size = "{{ attribute.mediaMaxSize }}"
{% if attribute.required %}required="required"{% endif %}/>
{% if page.previewImage %}
<img style="display: none;" width="{{ page.imageWidth }}px" class="uploadedImage" src="#" alt="Uploaded image" />
<img style="display: none; margin:7px" width="50px" id="pdf-png" src="/bundles/huebertaddorderattributes/static/PDF_icon.png" alt="Uploaded pdf" >
<span style="display: none; margin:7px" id="file-png" class="icon icon-xl">{% sw_icon 'file' %}</span>
{% endif %}
<span class="huebert-upload-error_{{ loop.index }}" style="display: none; color:red;">
{{ "huebert.detail.uploadImageErr"|trans }}
</span>
<span class="huebert-upload-error_maxsize" style="display: none; color:#7f3535;">
{{ "huebert.detail.uploadImageErrMaxSize"|trans }} {{ attribute.mediaMaxSize }} kB
</span>
<span class="huebert-upload-error-type_{{ loop.index }}" style="display: none; color:red;">
{{ "huebert.detail.uploadImageErrorType"|trans }} {{ attribute.fileTypes }}
</span>
</div>
<input type="hidden" name="_csrf_token_hueber_media_upload"
id="_csrf_token_huebert_media_upload"
value="{{ sw_csrf('huebert.add.order.attributes.media.upload', {"mode":"token"}) }}">
<input type="hidden"
name="attributes[{{ page.product.id }}][{{ attribute.id }}]"
value=""
class="huebert-add-media-upload_mediaId_{{ loop.index }}"
id="{{ attribute.id }}_{{ loop.index }}"/>
<input type="hidden"
name="attributes[{{ page.product.id }}][{{ attribute.id }}][media]"
value=""
class="huebert-add-media-upload_media_id_{{ loop.index }}"
id="{{ attribute.id }}_{{ loop.index }}"/>
{% elseif attribute.type is same as('textarea') %}
<label class="form-label" for="{{ attribute.id }}">{{ attribute.translated.name }}
{% if (attribute.infotext or attribute.translated.infotext) and attribute.infotype == "help" %}
<dfn class="hue-tooltip"> {% sw_icon 'help' style {'size':'xs'} %}
<span role="tooltip">{{ attribute.translated.infotext| raw }}</span>
</dfn>
{% endif %}
</label>
<textarea class="form-control mb-3 hue-textarea" id="{{ attribute.id }}" name="attributes[{{ page.product.id }}][{{ attribute.id }}]"
rows="5" placeholder="{{ attribute.translated.placeholder }}"
{% if attribute.textareaMaxLength and attribute.textareaMaxLength > 0 %} maxlength="{{ attribute.textareaMaxLength }}" data-maxlength="{{ attribute.textareaMaxLength }}"{% endif %}></textarea>
<p id="message-remaining-letters"></p>
{% else %}
<label class="form-label" for="{{ attribute.id }}">{{ attribute.translated.name }}
{% if (attribute.infotext or attribute.translated.infotext) and attribute.infotype == "help" %}
<dfn class="hue-tooltip"> {% sw_icon 'help' style {'size':'xs'} %}
<span role="tooltip">{{ attribute.translated.infotext| raw }}</span>
</dfn>
{% endif %}
</label>
<input
id="{{ attribute.id }}"
type="{{ attribute.type }}"
{% if attribute.type == "number" %}step=".01"{% endif %}
placeholder="{{ attribute.translated.placeholder }}"
aria-label="Custom input for {{ attribute.translated.name }}"
value=""
name="attributes[{{ page.product.id }}][{{ attribute.id }}]"
class="form-control {% if last %}mb-4{% else %}mb-3{% endif %} {% if attribute.type == "text" %} text-validation {{ attribute.maxInputCharacters }}{% endif %}"
{% if attribute.validationpattern %}pattern="{{ attribute.validationpattern }}"{% endif %}
{% if attribute.required %}required="required"{% endif %}
>
{% endif %}
</div>
{% if attribute.translated.infotext and attribute.infotype == "text" %}
<div class="col-6 attribute-infotext">{% sw_icon 'info' style {'size':'xs'} %} {{ attribute.translated.infotext| raw }}</div>
{% endif %}
</div>
{% if attribute.translated.infotext and attribute.infotype == "textbelow" %}
<div class="attribute-infotext">{% sw_icon 'info' style {'size':'xs'} %} {{ attribute.translated.infotext | raw }}</div>
{% endif %}
{% endfor %}
</div>
</div>
{% endif %}
{% endif %}
{% endblock %}