Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

196 lines
8.4KB

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