templates/CatalogueVue/_modal_edit.html.twig line 1

Open in your IDE?
  1. {# templates/catalogue/_modal_edit.html.twig #}
  2. <style>
  3. .ce-section {
  4. font-size: 11px; font-weight: 700; text-transform: uppercase;
  5. letter-spacing: .06em; color: #6c757d;
  6. margin: 14px 0 8px; padding-bottom: 4px;
  7. border-bottom: 1px solid #e9ecef;
  8. }
  9. .ce-label {
  10. font-size: 10px; font-weight: 700; color: #495057;
  11. text-transform: uppercase; letter-spacing: .04em;
  12. margin-bottom: 2px; display: block;
  13. }
  14. .ce-prix-calc {
  15. background: #e7f1ff; border: 1px solid #b8daff;
  16. border-radius: 6px; padding: 8px 12px;
  17. font-size: 12px; color: #004085; font-weight: 600;
  18. margin-bottom: 10px;
  19. }
  20. .ce-badge-translate {
  21. font-size: 10px; background: #d4edda; color: #155724;
  22. border: 1px solid #c3e6cb; border-radius: 20px;
  23. padding: 2px 8px; margin-left: 6px; font-weight: 600;
  24. }
  25. /* Uniformiser les champs du form Symfony */
  26. #ceForm .form-group { margin-bottom: 8px; }
  27. #ceForm label { font-size: 10px; font-weight: 700; color: #495057;
  28. text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
  29. #ceForm .form-control { font-size: 13px; height: calc(1.5em + .5rem + 2px); padding: .25rem .5rem; }
  30. #ceForm select.form-control { height: calc(1.5em + .5rem + 2px); }
  31. #ceForm textarea.form-control { height: auto; }
  32. </style>
  33. {# ── Info traduction ── #}
  34. <div class="alert alert-info py-2 px-3 mb-2" style="font-size:12px">
  35. <i class="fas fa-language mr-1"></i>
  36. <strong>{{ 'article.edit_modal.info_banner_bold'|trans }}</strong>
  37. {{ 'article.edit_modal.info_banner_text'|trans }}
  38. <span class="ce-badge-translate">{{ 'article.edit_modal.ai_badge'|trans }}</span>
  39. </div>
  40. {{ form_start(form, {'attr': {'id': 'ceForm'}}) }}
  41. {# ── Section : Informations principales ── #}
  42. <div class="ce-section"><i class="fas fa-tag mr-1"></i> {{ 'article.edit_modal.section_main_info'|trans }}</div>
  43. <div class="form-row">
  44. <div class="col-12 form-group">
  45. {{ form_label(form.designation, 'article.edit_modal.label_designation'|trans) }}
  46. {{ form_widget(form.designation, {'attr': {'class': 'form-control form-control-sm'}}) }}
  47. </div>
  48. </div>
  49. <div class="form-row">
  50. <div class="col-12 form-group">
  51. {{ form_label(form.description, 'article.edit_modal.label_description'|trans) }}
  52. {{ form_widget(form.description, {'attr': {'class': 'form-control form-control-sm', 'rows': '2'}}) }}
  53. </div>
  54. </div>
  55. <div class="form-row">
  56. <div class="col-md-4 form-group">
  57. {{ form_label(form.typeArticle, 'article.edit_modal.label_type_article'|trans) }}
  58. {{ form_widget(form.typeArticle, {'attr': {'class': 'form-control form-control-sm'}}) }}
  59. </div>
  60. <div class="col-md-4 form-group">
  61. {{ form_label(form.unite, 'article.edit_modal.label_unite'|trans) }}
  62. {{ form_widget(form.unite, {'attr': {'class': 'form-control form-control-sm'}}) }}
  63. </div>
  64. <div class="col-md-4 form-group">
  65. {{ form_label(form.codeArticle, 'article.edit_modal.label_code_article'|trans) }}
  66. {{ form_widget(form.codeArticle, {'attr': {'class': 'form-control form-control-sm'}}) }}
  67. </div>
  68. </div>
  69. {# ── Section : Catégories ── #}
  70. <div class="ce-section"><i class="fas fa-folder mr-1"></i> {{ 'article.edit_modal.section_categories'|trans }}</div>
  71. <div class="form-row">
  72. <div class="col-md-6 form-group">
  73. {{ form_label(form.categorycatalogue, 'article.edit_modal.label_categorie'|trans) }}
  74. {{ form_widget(form.categorycatalogue, {'attr': {'class': 'form-control form-control-sm'}}) }}
  75. </div>
  76. <div class="col-md-6 form-group">
  77. {{ form_label(form.sousCategoryCatalogue, 'article.edit_modal.label_sous_categorie'|trans) }}
  78. {{ form_widget(form.sousCategoryCatalogue, {'attr': {'class': 'form-control form-control-sm'}}) }}
  79. </div>
  80. </div>
  81. {# ── Section : Asset ── #}
  82. <div class="ce-section"><i class="fas fa-laptop mr-1"></i> {{ 'article.edit_modal.section_asset'|trans }}</div>
  83. <div class="form-row">
  84. <div class="col-md-6 form-group">
  85. {{ form_label(form.assetCodeFamille, 'article.edit_modal.label_famille_asset'|trans) }}
  86. {{ form_widget(form.assetCodeFamille, {'attr': {'class': 'form-control form-control-sm', 'id': 'ce_famille'}}) }}
  87. </div>
  88. <div class="col-md-6 form-group">
  89. {{ form_label(form.assetCodeCategory, 'article.edit_modal.label_categorie_asset'|trans) }}
  90. {{ form_widget(form.assetCodeCategory, {'attr': {'class': 'form-control form-control-sm', 'id': 'ce_category'}}) }}
  91. </div>
  92. </div>
  93. {# ── Section : Prix ── #}
  94. <div class="ce-section"><i class="fas fa-money-bill-wave mr-1"></i> {{ 'article.edit_modal.section_prix'|trans }}</div>
  95. <div class="ce-prix-calc">
  96. <i class="fas fa-calculator mr-1"></i>
  97. {{ 'article.edit_modal.prix_ht_calc'|trans }} <strong id="ce-ht-display">{{ catalogue.prixHT }}</strong> {{ 'article.edit_modal.currency'|trans }}
  98. &nbsp;|&nbsp;
  99. {{ 'article.edit_modal.taxe_calc'|trans }} <strong id="ce-taxe-display">{{ catalogue.taxe ?? 0 }}</strong>%
  100. &nbsp;|&nbsp;
  101. {{ 'article.edit_modal.prix_ttc_calc'|trans }} <strong id="ce-ttc-display">{{ catalogue.prix }}</strong> {{ 'article.edit_modal.currency'|trans }}
  102. </div>
  103. <div class="form-row">
  104. <div class="col-md-6 form-group">
  105. <label class="ce-label">{{ 'article.edit_modal.label_prix_ht'|trans }}</label>
  106. <input type="number" name="form[prixHT]" id="ce-prixHT"
  107. class="form-control form-control-sm"
  108. value="{{ catalogue.prixHT }}"
  109. step="0.01" min="0"
  110. oninput="ceCalcPrix()">
  111. </div>
  112. <div class="col-md-6 form-group">
  113. <label class="ce-label">{{ 'article.edit_modal.label_taxe'|trans }}</label>
  114. <select name="form[taxe]" id="ce-taxe"
  115. class="form-control form-control-sm"
  116. onchange="ceCalcPrix()">
  117. {% for tax in ['0', '10', '18', '19.25', '20'] %}
  118. <option value="{{ tax }}"
  119. {{ catalogue.taxe == tax ? 'selected' : '' }}>
  120. {{ tax }}%
  121. </option>
  122. {% endfor %}
  123. </select>
  124. </div>
  125. </div>
  126. {# ── Section : MRP & Stock ── #}
  127. <div class="ce-section"><i class="fas fa-boxes mr-1"></i> {{ 'article.edit_modal.section_stock_mrp'|trans }}</div>
  128. <div class="form-row">
  129. <div class="col-md-4 form-group">
  130. {{ form_label(form.typeMRP, 'article.edit_modal.label_type_mrp'|trans) }}
  131. {{ form_widget(form.typeMRP, {'attr': {'class': 'form-control form-control-sm'}}) }}
  132. </div>
  133. <div class="col-md-4 form-group">
  134. <label class="ce-label">{{ 'article.edit_modal.label_stock_min'|trans }}</label>
  135. <input type="number" name="form[minStock]"
  136. class="form-control form-control-sm"
  137. value="{{ catalogue.minStock }}" min="0">
  138. </div>
  139. <div class="col-md-4 form-group">
  140. <label class="ce-label">{{ 'article.edit_modal.label_stock_max'|trans }}</label>
  141. <input type="number" name="form[maxStock]"
  142. class="form-control form-control-sm"
  143. value="{{ catalogue.maxStock }}" min="0">
  144. </div>
  145. <div class="col-md-4 form-group">
  146. <label class="ce-label">{{ 'article.edit_modal.label_stock_securite'|trans }}</label>
  147. <input type="number" name="form[stockSecurite]"
  148. class="form-control form-control-sm"
  149. value="{{ catalogue.stockSecurite }}" min="0">
  150. </div>
  151. <div class="col-md-4 form-group">
  152. <label class="ce-label">{{ 'article.edit_modal.label_delai_fournisseur'|trans }}</label>
  153. <input type="number" name="form[supplierLeadTime]"
  154. class="form-control form-control-sm"
  155. value="{{ catalogue.supplierLeadTime }}" min="0">
  156. </div>
  157. <div class="col-md-4 form-group">
  158. <label class="ce-label">{{ 'article.edit_modal.label_delai_approvisionnement'|trans }}</label>
  159. <input type="number" name="form[procurementLeadTime]"
  160. class="form-control form-control-sm"
  161. value="{{ catalogue.procurementLeadTime }}" min="0">
  162. </div>
  163. <div class="col-md-4 form-group">
  164. <label class="ce-label">{{ 'article.edit_modal.label_consommation_mensuelle'|trans }}</label>
  165. <input type="number" name="form[monthlyConsumption]"
  166. class="form-control form-control-sm"
  167. value="{{ catalogue.monthlyConsumption }}" min="0">
  168. </div>
  169. </div>
  170. {# ── Boutons ── #}
  171. <div class="d-flex justify-content-end mt-3" style="gap:8px">
  172. <button type="button" class="btn btn-sm btn-secondary"
  173. data-dismiss="modal">
  174. <i class="fas fa-times mr-1"></i> {{ 'action.annuler'|trans }}
  175. </button>
  176. <button type="submit" class="btn btn-sm btn-primary" id="ce-submit-btn">
  177. <i class="fas fa-save mr-1"></i> {{ 'article.edit_modal.btn_save_translate'|trans }}
  178. </button>
  179. </div>
  180. {{ form_end(form) }}
  181. <script>
  182. function ceCalcPrix() {
  183. const ht = parseFloat(document.getElementById('ce-prixHT').value) || 0;
  184. const taxe = parseFloat(document.getElementById('ce-taxe').value) || 0;
  185. const ttc = ht * (1 + taxe / 100);
  186. document.getElementById('ce-ht-display').textContent = Math.round(ht).toLocaleString('fr-FR');
  187. document.getElementById('ce-taxe-display').textContent = taxe;
  188. document.getElementById('ce-ttc-display').textContent = Math.round(ttc).toLocaleString('fr-FR');
  189. }
  190. document.getElementById('ce_famille')?.addEventListener('change', function() {
  191. const familleId = this.value;
  192. const catSelect = document.getElementById('ce_category');
  193. if (!catSelect) return;
  194. catSelect.innerHTML = '<option>{{ 'article.edit_modal.js_loading_categories'|trans|e('js') }}</option>';
  195. if (!familleId) {
  196. catSelect.innerHTML = '<option value="">{{ 'article.edit_modal.js_choose_category_asset'|trans|e('js') }}</option>';
  197. return;
  198. }
  199. fetch('/api/asset-categories?famille=' + familleId)
  200. .then(r => r.json())
  201. .then(data => {
  202. catSelect.innerHTML = '<option value="">{{ 'article.edit_modal.js_choose_category_asset'|trans|e('js') }}</option>';
  203. data.forEach(c => {
  204. catSelect.innerHTML += `<option value="${c.id}">${c.libele} - ${c.nomequip}</option>`;
  205. });
  206. })
  207. .catch(() => {
  208. catSelect.innerHTML = '<option value="">{{ 'catalogue.modal.load_error'|trans|e('js') }}</option>';
  209. });
  210. });
  211. ceCalcPrix();
  212. </script>