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.

260 lines
10KB

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