You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
9.3KB

  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 fieldReductionList(form, field, filterOn = false, filterType='string') %}
  74. <div class="col-12">
  75. <div class="form-group">
  76. <div class="form-group">
  77. {{ form_widget(attribute(form, field~'Active'), {"attr" : {'v-model' : 'reduction'~field|uc_first~'Active' } }) }}
  78. </div>
  79. <div class="form-widget" v-show="reduction{{ field|uc_first }}Active == true">
  80. {% set attr = {
  81. 'ref' : 'reduction'~field|uc_first ,
  82. 'v-model' : 'reduction'~field|uc_first
  83. } %}
  84. {{ form_widget(attribute(form, field), {"attr" : attr }) }}
  85. </div>
  86. </div>
  87. </div>
  88. {% endmacro fieldReductionList %}
  89. {% macro fieldReductionDateRange(form) %}
  90. <div class="col-12">
  91. <div class="form-group">
  92. <div class="form-group">
  93. {{ form_widget(form.permanent, {"attr" : {'v-model' : 'reductionPermanent' } }) }}
  94. </div>
  95. <div class="input-group" v-show="reductionPermanent == false">
  96. <div class="input-group-prepend">
  97. <span class="input-group-text"><i class="far fa-clock"></i></span>
  98. </div>
  99. <input type="text" class="form-control float-right date-time-range">
  100. <div class="hidden date-time-range-fields" style="display: none;">
  101. {{ form_widget(form.dateStart, {"attr" : {'class' : 'date-start'}}) }}
  102. {{ form_widget(form.dateEnd, {"attr" : {'class' : 'date-end'}}) }}
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. {% endmacro fieldReductionDateRange %}
  108. {% macro fieldReductionValue(form) %}
  109. <div class="col-6">
  110. <div class="form-group">
  111. {{ form_label(form.value) }}
  112. <div class="input-group">
  113. {{ form_widget(form.value, {"attr" : {":required": "reductionActive", 'v-model' : 'reductionValue'}}) }}
  114. <div class="input-group-append">
  115. <span class="input-group-text">
  116. <span v-if="reductionUnit =='amount'">€</span>
  117. <span v-else-if="reductionUnit =='percent'">%</span>
  118. </span>
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. {% endmacro fieldReductionValue %}
  124. {% macro fieldReductionBehaviorTaxRate(form) %}
  125. <div class="col-6" :class="reductionUnit == 'amount' ? '' : 'hidden'">
  126. {{ form_row(form.behaviorTaxRate, {"attr" : {":required": "reductionActive && reductionUnit=='amount'", 'v-model' : 'reductionBehaviorTaxRate'}}) }}
  127. </div>
  128. {% endmacro fieldReductionBehaviorTaxRate %}
  129. {% macro fieldReductionUnit(form) %}
  130. <div class="col-12">
  131. <div class="form-group">
  132. {{ form_label(form.unit) }}
  133. {% for field in form.unit %}
  134. {{ form_widget(field, {"attr" : {":required": "reductionActive", "v-model" : 'reductionUnit'}}) }}
  135. {% endfor %}
  136. </div>
  137. </div>
  138. {% endmacro fieldReductionUnit %}
  139. {% macro reductionCatalogForm(form) %}
  140. {{ _self.startCard(6, 'ReductionCatalog.info') }}
  141. <div class="col-12">
  142. {{ form_row(form.title) }}
  143. </div>
  144. {{ _self.fieldReductionUnit(form) }}
  145. {{ _self.fieldReductionValue(form) }}
  146. {{ _self.fieldReductionBehaviorTaxRate(form) }}
  147. {{ _self.endCard() }}
  148. {{ _self.startCard(6, 'ReductionCatalog.conditions','success') }}
  149. {{ _self.fieldReductionDateRange(form) }}
  150. {{ _self.fieldReductionList(form, 'groupUsers') }}
  151. {{ _self.fieldReductionList(form, 'users') }}
  152. {% if form.suppliers is defined %}
  153. {{ _self.fieldReductionList(form, 'suppliers') }}
  154. {% endif %}
  155. {% if form.productCategories is defined %}
  156. {{ _self.fieldReductionList(form, 'productCategories') }}
  157. {% endif %}
  158. {% if form.productFamilies is defined %}
  159. {{ _self.fieldReductionList(form, 'productFamilies') }}
  160. {% endif %}
  161. {{ _self.endCard() }}
  162. {% endmacro reductionCatalogForm %}
  163. {% macro reductionCatalogFormValues(formValues, isProductFamilyForm= false) %}
  164. <script>
  165. window.mixinReductionValues = {
  166. {% if formValues.status == false and isProductFamilyForm %}reductionActive: false,{% endif %}
  167. {% if formValues.permanent is not null and formValues.permanent == false %}reductionPermanent: false,{% endif %}
  168. {% if formValues.behaviorTaxRate %}reductionBehaviorTaxRate: '{{ formValues.behaviorTaxRate }}',{% endif %}
  169. {% if formValues.value %}reductionValue: parseFloat({{ formValues.value }}),{% endif %}
  170. {% if formValues.unit %}reductionUnit: "{{ formValues.unit }}",{% endif %}
  171. {% if formValues.groupUsers is not empty %}reductionGroupUsersActive: true,{% endif %}
  172. {% if formValues.groupUsers is not empty %}reductionGroupUsers: {{ formValues.groupUsers|json_encode }},{% endif %}
  173. {% if formValues.users is not empty %}reductionUsersActive: true,{% endif %}
  174. {% if formValues.users is not empty %}reductionUsers: {{ formValues.users|json_encode }},{% endif %}
  175. {% if formValues.suppliers is not empty %}reductionSuppliersActive: true,{% endif %}
  176. {% if formValues.suppliers is not empty %}reductionSuppliers: {{ formValues.suppliers|json_encode }},{% endif %}
  177. {% if formValues.productFamilies is not empty %}reductionProductFamiliesActive: true,{% endif %}
  178. {% if formValues.productFamilies is not empty %}reductionProductFamilies: {{ formValues.productFamilies|json_encode }},{% endif %}
  179. {% if formValues.productCategories is not empty %}reductionProductCategoriesActive: true,{% endif %}
  180. {% if formValues.productCategories is not empty %}reductionProductCategories: {{ formValues.productCategories|json_encode }},{% endif %}
  181. }
  182. </script>
  183. {% endmacro reductionCatalogFormValues %}