{% extends '@kohinos/block/block_collapse.html.twig' %}

{% block blocktitle %}
	<i class="fa fa-user-tie mr-4"></i> {{'Professionnel'|trans}}
{% endblock blocktitle %}
{% block blocksubtitle %}
{% endblock blocksubtitle %}


{% block blockcontent %}
	{% set form = getPrestataireInfosForm(app.user) %}

	{# Use macro as a template : macro for a prestataire product family entry in the form collection #}
	{% import _self as formMacros %}
	{% macro printPrestataireProductFamilyForm(prestataireProductFamilyForm, formName = "") %}
		<div class="presta-products-family">
			<div class="presta-products-family-fields">
				<div class="form-group presta-products-family-form-group">
					{{ form_label(prestataireProductFamilyForm.productFamily) }} 
					{{ form_widget(prestataireProductFamilyForm.productFamily) }}
				</div>
				<div class="form-group presta-products-family-form-group">
					{{ form_label(prestataireProductFamilyForm.products) }}
					{{ form_widget(prestataireProductFamilyForm.products) }}
				</div>
				<div class="presta-products-family-duplicate-warning">{{'Cette famille de produits est déjà renseignée.'|trans}}</div>
			</div>
			<a href="#" class="presta-products-family-delete">
				<i
					class="fa fa-times delete-icon"
					id="formPrestataireInfos_prestataireProductFamilies_{{ formName == '' ? '__name__' : formName }}_delete"
				></i>
			</a>
		</div>
	{% endmacro %}

	{{form_start(form)}}
		{{ form_row(form.raison) }}
		{{ form_row(form.statut) }}
		{% if getCurrentPrestataire().rubriques|length > 0%}
			<div class="form-group">
				<label>Rubriques :</label>
				{% for rubrique in getCurrentPrestataire().rubriques %}
					<input disabled="disabled" class='form-control' value='{{rubrique.name}}' />
				{% endfor %}
			</div>
		{% endif %}
		{{ form_row(form.siret) }}
		{{ form_row(form.bic) }}
		{{ form_row(form.iban) }}
		{{ form_row(form.responsable) }}
		{{ form_row(form.metier) }}
		{{ form_row(form.horaires) }}
		{{ form_row(form.web) }}
		{% if form.reconversionFrequency is defined %}
			{{ form_row(form.reconversionFrequency) }}
		{% endif %}
		<hr/>
		{{ form_row(form.media) }}
		{{ form_row(form.description) }}
		<hr/>
		<h3>Adresses</h3>
		<div class="geolocs" data-prototype="<div class='card p-2 mb-2 border-primary'>{{ form_widget(form.geolocs.vars.prototype)|e('html_attr') }}</div>">
			{% for geoloc in form.geolocs %}
				<div class='card p-2 mb-2 border-primary'>
					{{ form_row(geoloc) }}
				</div>
			{% endfor %}
		</div>
		<hr/>
		{{ form_row(form.newcaissiers) }}
		<hr/>
		{% if form.prestataireProductFamilies is defined %}
			<h4>{{ form_label(form.prestataireProductFamilies) }}</h4>
			{{ form_errors(form.prestataireProductFamilies) }}

			<div 
				class="presta-products-families-list"
				data-index="{{ form.prestataireProductFamilies|length > 0 ? form.prestataireProductFamilies|last.vars.name + 1 : 0 }}"
    			data-prototype="{{ formMacros.printPrestataireProductFamilyForm(form.prestataireProductFamilies.vars.prototype)|e('html_attr') }}"
			>
				{% for prestataireProductFamilyForm in form.prestataireProductFamilies %}
					{{ formMacros.printPrestataireProductFamilyForm(prestataireProductFamilyForm, prestataireProductFamilyForm.vars.name) }}
				{% endfor %}
				{% do form.prestataireProductFamilies.setRendered() %}
			</div>

			<button 
				type="button"
				id="add-prestataire-products-family"
				class="btn-primary btn"
				data-collection-holder-class="presta-products-families-list"
			>
				<i class="fa fa-plus"></i>
			</button>
			<hr/>
		{% endif %}
		{{ form_row(form.acceptemlc) }}

		{% if form.ccasOk is defined %}
			{{ form_row(form.ccasOk) }}
		{% endif %}

		{{ form_row(form.save) }}
	{{form_end(form)}}
{% endblock blockcontent %}