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.

macros.html.twig 12KB

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