選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

macros.html.twig 9.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. {% macro startCard(col, zone = "default", card ='primary', fullWidth = false ) %}
  2. {% if col > 0 %}
  3. <div class="col-{{ col }}">{% endif %}
  4. <div class="card card-{{ card }}">
  5. <div class="card-header">
  6. <h3 class="card-title">
  7. {% set label = "group."~zone %}
  8. {{ label|trans({}, 'lcshop')|raw }}
  9. </h3>
  10. </div>
  11. <div class="card-body {{ fullWidth == true ? 'p-0' : 'row' }}">
  12. {% endmacro startCard %}
  13. {% macro cardOverlay(attr) %}
  14. </div>
  15. <div v-if="{{ attr }}==true" class="overlay">
  16. <i class="fas fa-2x fa-sync-alt"></i>
  17. </div>
  18. {% endmacro cardOverlay %}
  19. {% macro endCard(noCol = false) %}
  20. </div>
  21. </div>
  22. {% if noCol == false %}</div>{% endif %}
  23. {% endmacro endCard %}
  24. {% macro productField(colspan, field, fieldName, fieldDisplay = false, displaySuffix="",attr="") %}
  25. {% if fieldDisplay == false %}{% set fieldDisplay = fieldName %}{% endif %}
  26. <td {{ attr|raw }} colspan="{{ colspan }}" class="{{ fieldName }}">
  27. <div class="value" v-show="{{ fieldName }}Inherited == false" v-on:click="{{ fieldName }}Inherited = true">
  28. <div v-if="{{ fieldName }}">
  29. {% verbatim %}{{ {% endverbatim %}{{ fieldDisplay }} {% verbatim %}}}{% endverbatim %}{{ displaySuffix }}
  30. </div>
  31. <div v-else class="inherited">
  32. {% verbatim %}{{ productFamily.{% endverbatim %}{{ fieldDisplay }} {% verbatim %}}}{% endverbatim %}{{ displaySuffix }}
  33. </div>
  34. </div>
  35. <div v-show="{{ fieldName }}Inherited == true">
  36. {{ form_widget(field, {'attr' : {'v-model' : fieldName , 'v-on:focusout': fieldName~'Inherited = false', '@change' : fieldName~'Updated'}}) }}
  37. </div>
  38. <button v-show="{{ fieldName }}" v-on:click="{{ fieldName }} = null; {{ fieldName }}Inherited = false; "
  39. class="btn btn-empty-field" type="button"><i class="fa fa-undo"></i></button>
  40. </td>
  41. {% endmacro %}
  42. {% macro priceField(field, fieldTax, fieldName, behaviorPriceValue) %}
  43. <div class="form-group field-price col-12" v-show="behaviorPrice == '{{ behaviorPriceValue }}'">
  44. <div class="row">
  45. <div class="col-12">
  46. {{ form_label(field) }}
  47. </div>
  48. <div class="col-6">
  49. <div class="form-widget">
  50. <div class="input-group">
  51. {{ form_widget(field, {'attr' : {'v-model': fieldName, '@change' : fieldName~'Updated'}}) }}
  52. <div class="input-group-append">
  53. <span class="input-group-text">€ HT
  54. {% if behaviorPriceValue == 'by-reference-unit' %}/ ${ unitReference }{% endif %}
  55. </span>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="col-6">
  61. <div class="input-group">
  62. {{ form_widget(fieldTax, {'attr' : {'v-model': fieldName ~ 'WithTax', '@change' : fieldName~'WithTaxUpdated'}}) }}
  63. <div class="input-group-append">
  64. <span class="input-group-text">€ TTC
  65. {% if behaviorPriceValue == 'by-reference-unit' %}/ ${ unitReference }{% endif %}
  66. </span>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. {% endmacro %}
  73. {% macro autoresizeField(field) %}
  74. <tr>
  75. <td>{{ form_label(field) }}</td>
  76. <td>
  77. <div class="autoresize">
  78. {{ form_widget(field, {'attr' : {rows : '1'}}) }}
  79. </div>
  80. </td>
  81. </tr>
  82. {% endmacro autoresizeField %}
  83. {% macro fieldReductionList(form, field, filterOn = false, filterType='string') %}
  84. <div class="col-12">
  85. <div class="form-group">
  86. <div class="form-group">
  87. {{ form_widget(attribute(form, field~'Active'), {"attr" : {'v-model' : 'reduction'~field|uc_first~'Active' } }) }}
  88. </div>
  89. <div class="form-widget" v-show="reduction{{ field|uc_first }}Active == true">
  90. {% set attr = {
  91. 'ref' : 'reduction'~field|uc_first ,
  92. 'v-model' : 'reduction'~field|uc_first
  93. } %}
  94. {{ form_widget(attribute(form, field), {"attr" : attr }) }}
  95. </div>
  96. </div>
  97. </div>
  98. {% endmacro fieldReductionList %}
  99. {% macro fieldReductionDateRange(form) %}
  100. <div class="col-12">
  101. <div class="form-group">
  102. <div class="form-group">
  103. {{ form_widget(form.permanent, {"attr" : {'v-model' : 'reductionPermanent' } }) }}
  104. </div>
  105. <div class="input-group" v-show="reductionPermanent == false">
  106. <div class="input-group-prepend">
  107. <span class="input-group-text"><i class="far fa-clock"></i></span>
  108. </div>
  109. <input type="text" class="form-control float-right date-time-range">
  110. <div class="hidden date-time-range-fields" style="display: none;">
  111. {{ form_widget(form.dateStart, {"attr" : {'class' : 'date-start'}}) }}
  112. {{ form_widget(form.dateEnd, {"attr" : {'class' : 'date-end'}}) }}
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. {% endmacro fieldReductionDateRange %}
  118. {% macro fieldReductionValue(form) %}
  119. <div class="col-6">
  120. <div class="form-group">
  121. {{ form_label(form.value) }}
  122. <div class="input-group">
  123. {{ form_widget(form.value, {"attr" : {":required": "reductionActive", 'v-model' : 'reductionValue'}}) }}
  124. <div class="input-group-append">
  125. <span class="input-group-text">
  126. <span v-if="reductionUnit =='amount'">€</span>
  127. <span v-else-if="reductionUnit =='percent'">%</span>
  128. </span>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. {% endmacro fieldReductionValue %}
  134. {% macro fieldReductionBehaviorTaxRate(form) %}
  135. <div class="col-6" :class="reductionUnit == 'amount' ? '' : 'hidden'">
  136. {{ form_row(form.behaviorTaxRate, {"attr" : {":required": "reductionActive && reductionUnit=='amount'", 'v-model' : 'reductionBehaviorTaxRate'}}) }}
  137. </div>
  138. {% endmacro fieldReductionBehaviorTaxRate %}
  139. {% macro fieldReductionUnit(form) %}
  140. <div class="col-12">
  141. <div class="form-group">
  142. {{ form_label(form.unit) }}
  143. {% for field in form.unit %}
  144. {{ form_widget(field, {"attr" : {":required": "reductionActive", "v-model" : 'reductionUnit'}}) }}
  145. {% endfor %}
  146. </div>
  147. </div>
  148. {% endmacro fieldReductionUnit %}
  149. {% macro reductionCatalogForm(form) %}
  150. {{ _self.startCard(6, 'ReductionCatalog.info') }}
  151. <div class="col-12">
  152. {{ form_row(form.title) }}
  153. </div>
  154. {{ _self.fieldReductionUnit(form) }}
  155. {{ _self.fieldReductionValue(form) }}
  156. {{ _self.fieldReductionBehaviorTaxRate(form) }}
  157. {{ _self.endCard() }}
  158. {{ _self.startCard(6, 'ReductionCatalog.conditions','success') }}
  159. {{ _self.fieldReductionDateRange(form) }}
  160. {{ _self.fieldReductionList(form, 'groupUsers') }}
  161. {{ _self.fieldReductionList(form, 'users') }}
  162. {% if form.suppliers is defined %}
  163. {{ _self.fieldReductionList(form, 'suppliers') }}
  164. {% endif %}
  165. {% if form.productCategories is defined %}
  166. {{ _self.fieldReductionList(form, 'productCategories') }}
  167. {% endif %}
  168. {% if form.productFamilies is defined %}
  169. {{ _self.fieldReductionList(form, 'productFamilies') }}
  170. {% endif %}
  171. {{ _self.endCard() }}
  172. {% endmacro reductionCatalogForm %}
  173. {% macro reductionCatalogFormValues(formValues, isProductFamilyForm= false) %}
  174. <script>
  175. window.mixinReductionValues = {
  176. {% if formValues.status == false and isProductFamilyForm %}reductionActive: false,{% endif %}
  177. {% if formValues.permanent is not null and formValues.permanent == false %}reductionPermanent: false,{% endif %}
  178. {% if formValues.behaviorTaxRate %}reductionBehaviorTaxRate: '{{ formValues.behaviorTaxRate }}',{% endif %}
  179. {% if formValues.value %}reductionValue: parseFloat({{ formValues.value }}),{% endif %}
  180. {% if formValues.unit %}reductionUnit: "{{ formValues.unit }}",{% endif %}
  181. {% if formValues.groupUsers is not empty %}reductionGroupUsersActive: true,{% endif %}
  182. {% if formValues.groupUsers is not empty %}reductionGroupUsers: {{ formValues.groupUsers|json_encode }},{% endif %}
  183. {% if formValues.users is not empty %}reductionUsersActive: true,{% endif %}
  184. {% if formValues.users is not empty %}reductionUsers: {{ formValues.users|json_encode }},{% endif %}
  185. {% if formValues.suppliers is not empty %}reductionSuppliersActive: true,{% endif %}
  186. {% if formValues.suppliers is not empty %}reductionSuppliers: {{ formValues.suppliers|json_encode }},{% endif %}
  187. {% if formValues.productFamilies is not empty %}reductionProductFamiliesActive: true,{% endif %}
  188. {% if formValues.productFamilies is not empty %}reductionProductFamilies: {{ formValues.productFamilies|json_encode }},{% endif %}
  189. {% if formValues.productCategories is not empty %}reductionProductCategoriesActive: true,{% endif %}
  190. {% if formValues.productCategories is not empty %}reductionProductCategories: {{ formValues.productCategories|json_encode }},{% endif %}
  191. }
  192. </script>
  193. {% endmacro reductionCatalogFormValues %}