list.html.twig 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. {% extends 'admin/base.html.twig' %}
  2. {% block content %}
  3. {% set city_filter = app.request.get('city') %}
  4. {% set category_filter = app.request.get('category') %}
  5. <div class="content">
  6. <div class="container-fluid">
  7. <div class="row">
  8. <div class="col-md-12">
  9. <div class="card">
  10. <div class="card-header">
  11. <div class="float-left">
  12. <h4 class="card-title">Список объектов</h4>
  13. </div>
  14. <div class="float-right">
  15. <a class="btn btn-primary btn-fill btn-icon" href="{{ path('admin.point_add') }}" role="button" title="Добавить">
  16. <i class="fa fa-plus"></i>
  17. </a>
  18. </div>
  19. </div>
  20. <div class="card-body">
  21. {% for label, messages in app.flashes(['success', 'warning', 'danger', 'info', 'primary']) %}
  22. {% for message in messages %}
  23. <div class="alert alert-{{ label }}">
  24. <span>{{ message }}</span>
  25. </div>
  26. {% endfor %}
  27. {% endfor %}
  28. <table class="table table-hover table-bordered">
  29. <thead>
  30. <th>ID</th>
  31. <th>
  32. {% set cities = global_service.cities %}
  33. <select class="form-control city-filter">
  34. <option value="0">---</option>
  35. {% for key, value in cities %}
  36. {% set city_title = 'cities.' ~ value.code %}
  37. <option value="{{ value.id }}" {% if value.id == city_filter %}selected{% endif %}>{{ city_title|trans }}</option>
  38. {% endfor %}
  39. </select>
  40. </th>
  41. <th>
  42. {% set categories = global_service.pointTypes %}
  43. <select class="form-control category-filter">
  44. <option value="0">---</option>
  45. {% for value in categories %}
  46. {% set category_title = 'categories.' ~ value.code %}
  47. <option value="{{ value.id }}" {% if value.id == category_filter %}selected{% endif %}>{{ category_title|trans }}</option>
  48. {% endfor %}
  49. </select>
  50. </th>
  51. <th>Название</th>
  52. <th>Активен</th>
  53. <th></th>
  54. </thead>
  55. <tbody>
  56. {% for point in points %}
  57. {% set city_title = 'cities.' ~ point.city %}
  58. {% set type_title = 'categories.' ~ point.type %}
  59. <tr>
  60. <td>{{ point.id }}</td>
  61. <td>{{ city_title|trans }}</td>
  62. <td>{{ type_title|trans }}</td>
  63. <td>{{ point.title }}</td>
  64. {% if point.isActive %}
  65. <td class="text-success">Да</td>
  66. {% else %}
  67. <td class="text-danger">Нет</td>
  68. {% endif %}
  69. <td style="width: 110px">
  70. <a class="btn btn-primary btn-fill btn-icon" href="{{ path('admin.point_edit', {id: point.id}) }}" role="button" title="Редактировать">
  71. <i class="fa fa-pencil"></i>
  72. </a>
  73. <a class="btn btn-danger btn-fill btn-icon" href="{{ path('admin.point_delete', {id: point.id}) }}" role="button" title="Удалить">
  74. <i class="fa fa-trash-o"></i>
  75. </a>
  76. </td>
  77. </tr>
  78. {% endfor %}
  79. </tbody>
  80. </table>
  81. <br>
  82. <ul class="pagination justify-content-center">
  83. {% if prev_page %}
  84. <li class="page-item">
  85. <a class="page-link" href="{{ path('admin.point_list', {
  86. page: prev_page,
  87. city: city_filter,
  88. category: category_filter
  89. }) }}">Предыдущая страница</a>
  90. </li>
  91. {% endif %}
  92. {% if next_page %}
  93. <li class="page-item">
  94. <a class="page-link" href="{{ path('admin.point_list', {
  95. page: next_page,
  96. city: city_filter,
  97. category: category_filter
  98. }) }}">Следующая страница</a>
  99. </li>
  100. {% endif %}
  101. </ul>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. {% endblock %}
  109. {% block admin_js_body %}
  110. {{ parent() }}
  111. <script type="text/javascript">
  112. $(".city-filter, .category-filter").change(function () {
  113. let url = '?page=1'
  114. + '&city=' + $(".city-filter").val()
  115. + '&category=' + $(".category-filter").val();
  116. window.location.href = url;
  117. });
  118. </script>
  119. {% endblock %}