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.

236 lines
9.5KB

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