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.

470 lines
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) %}
  288. <table class="table table-condensed">
  289. <thead>
  290. <tr>
  291. <th>Titre</th>
  292. <th>Montant</th>
  293. <th>En ligne</th>
  294. <th>Utilisé</th>
  295. <th></th>
  296. </tr>
  297. </thead>
  298. <tbody>
  299. {% for reductionCredit in reductionCredits %}
  300. {% set isUsed = orderUtils.isReductionCreditUsed(reductionCredit) %}
  301. <tr>
  302. <td>{{ reductionCredit.title }}</td>
  303. <td>
  304. {{ reductionCredit.value|format_price(false) }}
  305. </td>
  306. <td>
  307. {% include '@EasyAdmin/default/field_boolean.html.twig' with {value: reductionCredit.status} %}
  308. </td>
  309. <td>
  310. {% include '@EasyAdmin/default/field_boolean.html.twig' with {value: isUsed} %}
  311. </td>
  312. <td>
  313. {% if isUsed == false %}
  314. {{ _self.button('ReductionCredit', 'edit', reductionCredit.id, 'primary') }}
  315. {% endif %}
  316. </td>
  317. </tr>
  318. {% endfor %}
  319. </tbody>
  320. </table>
  321. {% endmacro list_reduction_credits %}
  322. {% macro list_reduction_carts(reductionCarts, user = false) %}
  323. <table class="table table-condensed">
  324. <thead>
  325. <tr>
  326. <th>Titre</th>
  327. <th>Montant</th>
  328. <th>Quantité utilisé</th>
  329. <th>Quantité restante</th>
  330. <th>En ligne</th>
  331. <th>Actions</th>
  332. </tr>
  333. </thead>
  334. <tbody>
  335. {% for reductionCart in reductionCarts %}
  336. <tr>
  337. <td>{{ reductionCart.title }}</td>
  338. <td>
  339. {% if reductionCart.value > 0 %}
  340. {{ reductionCart.value }}
  341. {% if reductionCart.unit == 'percent' %}%{% else %}€{% endif %}
  342. {% if reductionCart.appliedTo is defined and reductionCart.appliedTo|length > 0 %}
  343. sur
  344. {% if reductionCart.appliedTo == 'order-products' %}
  345. les produits
  346. {% endif %}
  347. {% endif %}
  348. ({% if reductionCart.behaviorTaxRate == 'tax-included' %}TTC{% else %}HT{% endif %})
  349. {% endif %}
  350. {% if reductionCart.freeShipping %}
  351. {% if reductionCart.value > 0 %}<br/>{% endif %}
  352. Livraison offerte
  353. {% endif %}
  354. </td>
  355. <td>
  356. {% if user is not null %}
  357. {% set totalUsed = orderUtils.getReductionCartUsedQuantityPerUser(reductionCart, user) %}
  358. {{ totalUsed }}
  359. {% endif %}
  360. </td>
  361. <td>
  362. {% if user is not null %}
  363. {{ reductionCart.availableQuantityPerUser - totalUsed }}
  364. {% endif %}
  365. </td>
  366. <td>
  367. {% include '@EasyAdmin/default/field_boolean.html.twig' with {value: reductionCart.status} %}
  368. </td>
  369. <td>
  370. {{ _self.button('ReductionCart', 'edit', reductionCart.id, 'primary') }}
  371. </td>
  372. </tr>
  373. {% endfor %}
  374. </tbody>
  375. </table>
  376. {% endmacro list_reduction_carts %}
  377. {% macro box_user_info(user) %}
  378. {% embed '@LcShop/backend/default/block/embed_box.twig' %}
  379. {% trans_default_domain 'lcshop' %}
  380. {% block class %}bg-info{% endblock %}
  381. {% block icon %}user{% endblock %}
  382. {% block label %}{{ "group.User.item"|trans({}, 'lcshop') }}{% endblock %}
  383. {% block value %}
  384. #{{ user.id }}&nbsp;
  385. {{ user.gender == 1 ? 'Mme.' : 'M.' }} {{ user.name }} {{ user.age < 200 ? '('~user.age~' ans)' : ''}}<br />
  386. {{ user.email }}<br />
  387. <span style="margin-top: 5px; display: inline-block;">
  388. <span data-toggle="tooltip" data-placement="bottom" title="Nombre de commandes" class="badge badge-info">
  389. {{ orderUtils.countValidOrderShopByUser(user) }} <i class="fa fa-shopping-cart"></i>
  390. </span>
  391. <span data-toggle="tooltip" data-placement="bottom" title="Total dépensés" class="badge badge-success">
  392. {{ orderUtils.getTotalSpentByUser(user) }} <i class="fa fa-euro-sign"></i>
  393. </span>
  394. <span data-toggle="tooltip" data-placement="bottom" title="Nombre de relivraisons" class="badge badge-warning">
  395. {{ orderUtils.countRedeliveryByUser(user) }} <i class="fa fa-undo"></i>
  396. </span>
  397. <span data-toggle="tooltip" data-placement="bottom" title="Nombre d'avoirs" class="badge badge-danger">
  398. {{ user.reductionCredits|length }} <i class="fa fa-backspace"></i>
  399. </span>
  400. </span>
  401. {% endblock %}
  402. {% block button %}
  403. <a class="btn btn-sm btn-secondary" href="{{ path('easyadmin', {"action" : 'show', 'entity': 'User', 'id': user.id}) }}">
  404. Voir la fiche
  405. </a>
  406. {% endblock %}
  407. {% endembed %}
  408. {% endmacro box_user_info %}