Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

473 linhas
18KB

  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 button(entity, action, id=null, class="success", title=null, icon=null) %}
  240. {% if title %}
  241. {% set trad = title %}
  242. {% else %}
  243. {% set trad = 'action.'~action %}
  244. {% endif %}
  245. {% if icon is null %}
  246. {% if action=="edit" %}{% set icon = 'pen' %}
  247. {% elseif action=="show" %}{% set icon = 'eye' %}
  248. {% endif %}
  249. {% endif %}
  250. {% set param = {action : action, entity: entity, referer: app.request.requestUri} %}
  251. {% if id %}{% set param = param|merge({id: id}) %}{% endif %}
  252. <a class="btn-sm btn-{{ class }}" data-toggle="tooltip" title="{{ trad|trans({}, "lcshop") }}"
  253. href="{{ path('easyadmin', param) }}">
  254. <i class="fas fa-{{ icon }}"></i>
  255. </a>
  256. {% endmacro button %}
  257. {% macro list_tickets(tickets) %}
  258. <table class="table table-condensed">
  259. <thead>
  260. <tr>
  261. <th>Sujet</th>
  262. <th>Statut</th>
  263. <th>Dernier message</th>
  264. <th></th>
  265. </tr>
  266. </thead>
  267. <tbody>
  268. {% for ticket in tickets %}
  269. <tr>
  270. <td>{{ ticket.subject }}</td>
  271. <td>
  272. {% set value = ticket.status %}
  273. {% include '@LcShop/backend/default/field/ticket_status.html.twig' %}
  274. </td>
  275. <td>
  276. {% set item = ticket %}
  277. {% include '@LcShop/backend/default/field/ticket_last_message.html.twig' %}
  278. </td>
  279. <td>
  280. {{ _self.button('Ticket', 'show', ticket.id) }}
  281. </td>
  282. </tr>
  283. {% endfor %}
  284. </tbody>
  285. </table>
  286. {% endmacro list_tickets %}
  287. {% macro list_reduction_credits(reductionCredits, user) %}
  288. {% set merchant_current = merchantUtils.getMerchantCurrent() %}
  289. <table class="table table-condensed">
  290. <thead>
  291. <tr>
  292. <th>Titre</th>
  293. <th>Montant</th>
  294. <th>En ligne</th>
  295. <th>Utilisé</th>
  296. <th></th>
  297. </tr>
  298. </thead>
  299. <tbody>
  300. {% for reductionCredit in reductionCredits %}
  301. {% if reductionCredit.getMerchant() == merchant_current %}
  302. {% set isUsed = orderUtils.isReductionCreditUsed(reductionCredit, user) %}
  303. <tr>
  304. <td>{{ reductionCredit.title }}</td>
  305. <td>
  306. {{ reductionCredit.value|format_price(false) }}
  307. </td>
  308. <td>
  309. {% include '@LcShop/backend/default/field/status.html.twig' with {value: reductionCredit.status} %}
  310. </td>
  311. <td>
  312. {% include '@EasyAdmin/default/field_boolean.html.twig' with {value: isUsed} %}
  313. </td>
  314. <td>
  315. {% if isUsed == false and reductionCredit.status >=0 %}
  316. {{ _self.button('ReductionCredit', 'edit', reductionCredit.id, 'primary') }}
  317. {% endif %}
  318. </td>
  319. </tr>
  320. {% endif %}
  321. {% endfor %}
  322. </tbody>
  323. </table>
  324. {% endmacro list_reduction_credits %}
  325. {% macro list_reduction_carts(reductionCarts, user = false) %}
  326. <table class="table table-condensed">
  327. <thead>
  328. <tr>
  329. <th>Titre</th>
  330. <th>Montant</th>
  331. <th>Quantité utilisé</th>
  332. <th>Quantité restante</th>
  333. <th>En ligne</th>
  334. <th>Actions</th>
  335. </tr>
  336. </thead>
  337. <tbody>
  338. {% for reductionCart in reductionCarts %}
  339. <tr>
  340. <td>{{ reductionCart.title }}</td>
  341. <td>
  342. {% if reductionCart.value > 0 %}
  343. {{ reductionCart.value }}
  344. {% if reductionCart.unit == 'percent' %}%{% else %}€{% endif %}
  345. {% if reductionCart.appliedTo is defined and reductionCart.appliedTo|length > 0 %}
  346. sur
  347. {% if reductionCart.appliedTo == 'order-products' %}
  348. les produits
  349. {% endif %}
  350. {% endif %}
  351. ({% if reductionCart.behaviorTaxRate == 'tax-included' %}TTC{% else %}HT{% endif %})
  352. {% endif %}
  353. {% if reductionCart.freeShipping %}
  354. {% if reductionCart.value > 0 %}<br/>{% endif %}
  355. Livraison offerte
  356. {% endif %}
  357. </td>
  358. <td>
  359. {% if user is not null %}
  360. {% set totalUsed = orderUtils.getReductionCartUsedQuantityPerUser(reductionCart, user) %}
  361. {{ totalUsed }}
  362. {% endif %}
  363. </td>
  364. <td>
  365. {% if user is not null %}
  366. {{ reductionCart.availableQuantityPerUser - totalUsed }}
  367. {% endif %}
  368. </td>
  369. <td>
  370. {% include '@EasyAdmin/default/field_boolean.html.twig' with {value: reductionCart.status} %}
  371. </td>
  372. <td>
  373. {{ _self.button('ReductionCart', 'edit', reductionCart.id, 'primary') }}
  374. </td>
  375. </tr>
  376. {% endfor %}
  377. </tbody>
  378. </table>
  379. {% endmacro list_reduction_carts %}
  380. {% macro box_user_info(user) %}
  381. {% embed '@LcShop/backend/default/block/embed_box.twig' %}
  382. {% trans_default_domain 'lcshop' %}
  383. {% block class %}bg-info{% endblock %}
  384. {% block icon %}user{% endblock %}
  385. {% block label %}{{ "group.User.item"|trans({}, 'lcshop') }}{% endblock %}
  386. {% block value %}
  387. #{{ user.id }}&nbsp;
  388. {{ user.gender == 1 ? 'Mme.' : 'M.' }} {{ user.name }} {{ user.age < 200 ? '('~user.age~' ans)' : ''}}<br />
  389. {{ user.email }}<br />
  390. <span style="margin-top: 5px; display: inline-block;">
  391. <span data-toggle="tooltip" data-placement="bottom" title="Nombre de commandes" class="badge badge-info">
  392. {{ orderUtils.countValidOrderShopByUser(user) }} <i class="fa fa-shopping-cart"></i>
  393. </span>
  394. <span data-toggle="tooltip" data-placement="bottom" title="Total dépensés" class="badge badge-success">
  395. {{ orderUtils.getTotalSpentByUser(user) }} <i class="fa fa-euro-sign"></i>
  396. </span>
  397. <span data-toggle="tooltip" data-placement="bottom" title="Nombre de relivraisons" class="badge badge-warning">
  398. {{ orderUtils.countRedeliveryByUser(user) }} <i class="fa fa-undo"></i>
  399. </span>
  400. <span data-toggle="tooltip" data-placement="bottom" title="Nombre d'avoirs" class="badge badge-danger">
  401. {{ user.reductionCredits|length }} <i class="fa fa-backspace"></i>
  402. </span>
  403. </span>
  404. {% endblock %}
  405. {% block button %}
  406. <a class="btn btn-sm btn-secondary" href="{{ path('easyadmin', {"action" : 'show', 'entity': 'User', 'id': user.id}) }}">
  407. Voir la fiche
  408. </a>
  409. {% endblock %}
  410. {% endembed %}
  411. {% endmacro box_user_info %}