{# templates/catalogue/_modal_edit.html.twig #}
<style>
.ce-section {
font-size: 11px; font-weight: 700; text-transform: uppercase;
letter-spacing: .06em; color: #6c757d;
margin: 14px 0 8px; padding-bottom: 4px;
border-bottom: 1px solid #e9ecef;
}
.ce-label {
font-size: 10px; font-weight: 700; color: #495057;
text-transform: uppercase; letter-spacing: .04em;
margin-bottom: 2px; display: block;
}
.ce-prix-calc {
background: #e7f1ff; border: 1px solid #b8daff;
border-radius: 6px; padding: 8px 12px;
font-size: 12px; color: #004085; font-weight: 600;
margin-bottom: 10px;
}
.ce-badge-translate {
font-size: 10px; background: #d4edda; color: #155724;
border: 1px solid #c3e6cb; border-radius: 20px;
padding: 2px 8px; margin-left: 6px; font-weight: 600;
}
/* Uniformiser les champs du form Symfony */
#ceForm .form-group { margin-bottom: 8px; }
#ceForm label { font-size: 10px; font-weight: 700; color: #495057;
text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
#ceForm .form-control { font-size: 13px; height: calc(1.5em + .5rem + 2px); padding: .25rem .5rem; }
#ceForm select.form-control { height: calc(1.5em + .5rem + 2px); }
#ceForm textarea.form-control { height: auto; }
</style>
{# ── Info traduction ── #}
<div class="alert alert-info py-2 px-3 mb-2" style="font-size:12px">
<i class="fas fa-language mr-1"></i>
<strong>{{ 'article.edit_modal.info_banner_bold'|trans }}</strong>
{{ 'article.edit_modal.info_banner_text'|trans }}
<span class="ce-badge-translate">{{ 'article.edit_modal.ai_badge'|trans }}</span>
</div>
{{ form_start(form, {'attr': {'id': 'ceForm'}}) }}
{# ── Section : Informations principales ── #}
<div class="ce-section"><i class="fas fa-tag mr-1"></i> {{ 'article.edit_modal.section_main_info'|trans }}</div>
<div class="form-row">
<div class="col-12 form-group">
{{ form_label(form.designation, 'article.edit_modal.label_designation'|trans) }}
{{ form_widget(form.designation, {'attr': {'class': 'form-control form-control-sm'}}) }}
</div>
</div>
<div class="form-row">
<div class="col-12 form-group">
{{ form_label(form.description, 'article.edit_modal.label_description'|trans) }}
{{ form_widget(form.description, {'attr': {'class': 'form-control form-control-sm', 'rows': '2'}}) }}
</div>
</div>
<div class="form-row">
<div class="col-md-4 form-group">
{{ form_label(form.typeArticle, 'article.edit_modal.label_type_article'|trans) }}
{{ form_widget(form.typeArticle, {'attr': {'class': 'form-control form-control-sm'}}) }}
</div>
<div class="col-md-4 form-group">
{{ form_label(form.unite, 'article.edit_modal.label_unite'|trans) }}
{{ form_widget(form.unite, {'attr': {'class': 'form-control form-control-sm'}}) }}
</div>
<div class="col-md-4 form-group">
{{ form_label(form.codeArticle, 'article.edit_modal.label_code_article'|trans) }}
{{ form_widget(form.codeArticle, {'attr': {'class': 'form-control form-control-sm'}}) }}
</div>
</div>
{# ── Section : Catégories ── #}
<div class="ce-section"><i class="fas fa-folder mr-1"></i> {{ 'article.edit_modal.section_categories'|trans }}</div>
<div class="form-row">
<div class="col-md-6 form-group">
{{ form_label(form.categorycatalogue, 'article.edit_modal.label_categorie'|trans) }}
{{ form_widget(form.categorycatalogue, {'attr': {'class': 'form-control form-control-sm'}}) }}
</div>
<div class="col-md-6 form-group">
{{ form_label(form.sousCategoryCatalogue, 'article.edit_modal.label_sous_categorie'|trans) }}
{{ form_widget(form.sousCategoryCatalogue, {'attr': {'class': 'form-control form-control-sm'}}) }}
</div>
</div>
{# ── Section : Asset ── #}
<div class="ce-section"><i class="fas fa-laptop mr-1"></i> {{ 'article.edit_modal.section_asset'|trans }}</div>
<div class="form-row">
<div class="col-md-6 form-group">
{{ form_label(form.assetCodeFamille, 'article.edit_modal.label_famille_asset'|trans) }}
{{ form_widget(form.assetCodeFamille, {'attr': {'class': 'form-control form-control-sm', 'id': 'ce_famille'}}) }}
</div>
<div class="col-md-6 form-group">
{{ form_label(form.assetCodeCategory, 'article.edit_modal.label_categorie_asset'|trans) }}
{{ form_widget(form.assetCodeCategory, {'attr': {'class': 'form-control form-control-sm', 'id': 'ce_category'}}) }}
</div>
</div>
{# ── Section : Prix ── #}
<div class="ce-section"><i class="fas fa-money-bill-wave mr-1"></i> {{ 'article.edit_modal.section_prix'|trans }}</div>
<div class="ce-prix-calc">
<i class="fas fa-calculator mr-1"></i>
{{ 'article.edit_modal.prix_ht_calc'|trans }} <strong id="ce-ht-display">{{ catalogue.prixHT }}</strong> {{ 'article.edit_modal.currency'|trans }}
|
{{ 'article.edit_modal.taxe_calc'|trans }} <strong id="ce-taxe-display">{{ catalogue.taxe ?? 0 }}</strong>%
|
{{ 'article.edit_modal.prix_ttc_calc'|trans }} <strong id="ce-ttc-display">{{ catalogue.prix }}</strong> {{ 'article.edit_modal.currency'|trans }}
</div>
<div class="form-row">
<div class="col-md-6 form-group">
<label class="ce-label">{{ 'article.edit_modal.label_prix_ht'|trans }}</label>
<input type="number" name="form[prixHT]" id="ce-prixHT"
class="form-control form-control-sm"
value="{{ catalogue.prixHT }}"
step="0.01" min="0"
oninput="ceCalcPrix()">
</div>
<div class="col-md-6 form-group">
<label class="ce-label">{{ 'article.edit_modal.label_taxe'|trans }}</label>
<select name="form[taxe]" id="ce-taxe"
class="form-control form-control-sm"
onchange="ceCalcPrix()">
{% for tax in ['0', '10', '18', '19.25', '20'] %}
<option value="{{ tax }}"
{{ catalogue.taxe == tax ? 'selected' : '' }}>
{{ tax }}%
</option>
{% endfor %}
</select>
</div>
</div>
{# ── Section : MRP & Stock ── #}
<div class="ce-section"><i class="fas fa-boxes mr-1"></i> {{ 'article.edit_modal.section_stock_mrp'|trans }}</div>
<div class="form-row">
<div class="col-md-4 form-group">
{{ form_label(form.typeMRP, 'article.edit_modal.label_type_mrp'|trans) }}
{{ form_widget(form.typeMRP, {'attr': {'class': 'form-control form-control-sm'}}) }}
</div>
<div class="col-md-4 form-group">
<label class="ce-label">{{ 'article.edit_modal.label_stock_min'|trans }}</label>
<input type="number" name="form[minStock]"
class="form-control form-control-sm"
value="{{ catalogue.minStock }}" min="0">
</div>
<div class="col-md-4 form-group">
<label class="ce-label">{{ 'article.edit_modal.label_stock_max'|trans }}</label>
<input type="number" name="form[maxStock]"
class="form-control form-control-sm"
value="{{ catalogue.maxStock }}" min="0">
</div>
<div class="col-md-4 form-group">
<label class="ce-label">{{ 'article.edit_modal.label_stock_securite'|trans }}</label>
<input type="number" name="form[stockSecurite]"
class="form-control form-control-sm"
value="{{ catalogue.stockSecurite }}" min="0">
</div>
<div class="col-md-4 form-group">
<label class="ce-label">{{ 'article.edit_modal.label_delai_fournisseur'|trans }}</label>
<input type="number" name="form[supplierLeadTime]"
class="form-control form-control-sm"
value="{{ catalogue.supplierLeadTime }}" min="0">
</div>
<div class="col-md-4 form-group">
<label class="ce-label">{{ 'article.edit_modal.label_delai_approvisionnement'|trans }}</label>
<input type="number" name="form[procurementLeadTime]"
class="form-control form-control-sm"
value="{{ catalogue.procurementLeadTime }}" min="0">
</div>
<div class="col-md-4 form-group">
<label class="ce-label">{{ 'article.edit_modal.label_consommation_mensuelle'|trans }}</label>
<input type="number" name="form[monthlyConsumption]"
class="form-control form-control-sm"
value="{{ catalogue.monthlyConsumption }}" min="0">
</div>
</div>
{# ── Boutons ── #}
<div class="d-flex justify-content-end mt-3" style="gap:8px">
<button type="button" class="btn btn-sm btn-secondary"
data-dismiss="modal">
<i class="fas fa-times mr-1"></i> {{ 'action.annuler'|trans }}
</button>
<button type="submit" class="btn btn-sm btn-primary" id="ce-submit-btn">
<i class="fas fa-save mr-1"></i> {{ 'article.edit_modal.btn_save_translate'|trans }}
</button>
</div>
{{ form_end(form) }}
<script>
function ceCalcPrix() {
const ht = parseFloat(document.getElementById('ce-prixHT').value) || 0;
const taxe = parseFloat(document.getElementById('ce-taxe').value) || 0;
const ttc = ht * (1 + taxe / 100);
document.getElementById('ce-ht-display').textContent = Math.round(ht).toLocaleString('fr-FR');
document.getElementById('ce-taxe-display').textContent = taxe;
document.getElementById('ce-ttc-display').textContent = Math.round(ttc).toLocaleString('fr-FR');
}
document.getElementById('ce_famille')?.addEventListener('change', function() {
const familleId = this.value;
const catSelect = document.getElementById('ce_category');
if (!catSelect) return;
catSelect.innerHTML = '<option>{{ 'article.edit_modal.js_loading_categories'|trans|e('js') }}</option>';
if (!familleId) {
catSelect.innerHTML = '<option value="">{{ 'article.edit_modal.js_choose_category_asset'|trans|e('js') }}</option>';
return;
}
fetch('/api/asset-categories?famille=' + familleId)
.then(r => r.json())
.then(data => {
catSelect.innerHTML = '<option value="">{{ 'article.edit_modal.js_choose_category_asset'|trans|e('js') }}</option>';
data.forEach(c => {
catSelect.innerHTML += `<option value="${c.id}">${c.libele} - ${c.nomequip}</option>`;
});
})
.catch(() => {
catSelect.innerHTML = '<option value="">{{ 'catalogue.modal.load_error'|trans|e('js') }}</option>';
});
});
ceCalcPrix();
</script>