|
20 | 20 | <% end %>
|
21 | 21 |
|
22 | 22 | <div class="row justify-content-center">
|
23 |
| - <% if @all_items.present? %> |
24 |
| - <% @all_items.group_by { |item| item.bling_order_item.store_name }.each do |loja_name, items| %> |
| 23 | + <% if @sorted_stores.present? %> |
| 24 | + <% @sorted_stores.each do |loja_name, items| %> |
25 | 25 | <div class="col-md-12">
|
26 | 26 | <div class="card mb-4">
|
| 27 | + <div class="card-header bg-primary text-white"> |
| 28 | + <h5 class="mb-0"><%= loja_name %> - Total: <%= items.sum(&:quantity) %> unidades</h5> |
| 29 | + </div> |
27 | 30 | <div class="card-body">
|
28 |
| - <h5 class="card-title"><%= loja_name %></h5> |
29 |
| - <% items.group_by(&:sku).each do |codigo, sku_items| %> |
30 |
| - <% sorted_sku_items = sku_items.sort_by { |item| -item.quantity.to_i } %> |
31 |
| - <div> |
32 |
| - <a href="#" class="btn btn-info" data-toggle="collapse" data-target=".collapse<%= codigo %>"> |
33 |
| - Código <%= codigo %> - <%= sorted_sku_items.sum { |item| item.quantity.to_i } %> unidades |
34 |
| - </a> |
35 |
| - <% sorted_sku_items.each do |item| %> |
36 |
| - <div class="collapse collapse<%= codigo %> mt-2"> |
37 |
| - <div class="card card-body"> |
38 |
| - Pedido: <%= item.bling_order_item.bling_order_id %>, Quantidade: <%= item.quantity %> unidades<br> |
39 |
| - <a href='https://www.bling.com.br/vendas.php#edit/<%= item.bling_order_item.bling_order_id %>'>Ver Pedido no Bling</a> |
40 |
| - <p>Status: <%= item.pending? ? 'Pendente' : 'Não Pendente' %></p> |
41 |
| - <% if item.bling_order_item.situation_id == BlingOrderItem::Status::PENDING %> |
42 |
| - <%= link_to 'Marcar como Pendente', update_status_item_path(item, status: 'pendente'), method: :patch, class: 'btn btn-success' %> |
43 |
| - <%= link_to 'Marcar como Não Pendente', update_status_item_path(item, status: 'nao_pendente'), method: :patch, class: 'btn btn-danger' %> |
44 |
| - <% end %> |
45 |
| - </div> |
| 31 | + <% items.group_by(&:sku).sort_by { |_, sku_items| -sku_items.sum(&:quantity) }.each do |codigo, sku_items| %> |
| 32 | + <div class="mb-3"> |
| 33 | + <button class="btn btn-info btn-block text-left" type="button" data-toggle="collapse" data-target=".collapse<%= codigo %>"> |
| 34 | + <strong>Código <%= codigo %></strong> - <%= sku_items.sum(&:quantity) %> unidades |
| 35 | + </button> |
| 36 | + <div class="collapse collapse<%= codigo %> mt-2"> |
| 37 | + <div class="table-responsive"> |
| 38 | + <table class="table table-bordered table-striped"> |
| 39 | + <thead class="thead-light"> |
| 40 | + <tr> |
| 41 | + <th>Pedido</th> |
| 42 | + <th>Quantidade</th> |
| 43 | + <th>Status</th> |
| 44 | + <th>Ações</th> |
| 45 | + </tr> |
| 46 | + </thead> |
| 47 | + <tbody> |
| 48 | + <% sku_items.sort_by(&:quantity).reverse.each do |item| %> |
| 49 | + <tr> |
| 50 | + <td> |
| 51 | + <%= item.bling_order_item.bling_order_id %> |
| 52 | + <a href='https://www.bling.com.br/vendas.php#edit/<%= item.bling_order_item.bling_order_id %>' target="_blank" class="btn btn-sm btn-outline-secondary ml-2"> |
| 53 | + Ver no Bling |
| 54 | + </a> |
| 55 | + </td> |
| 56 | + <td><%= item.quantity %> unidades</td> |
| 57 | + <td><%= item.pending? ? 'Pendente' : 'Não Pendente' %></td> |
| 58 | + <td> |
| 59 | + <% if item.bling_order_item.situation_id == BlingOrderItem::Status::PENDING %> |
| 60 | + <%= link_to 'Marcar Pendente', update_status_item_path(item, status: 'pendente'), method: :patch, class: 'btn btn-sm btn-success' %> |
| 61 | + <%= link_to 'Marcar Não Pendente', update_status_item_path(item, status: 'nao_pendente'), method: :patch, class: 'btn btn-sm btn-danger' %> |
| 62 | + <% end %> |
| 63 | + </td> |
| 64 | + </tr> |
| 65 | + <% end %> |
| 66 | + </tbody> |
| 67 | + </table> |
46 | 68 | </div>
|
47 |
| - <% end %> |
| 69 | + </div> |
48 | 70 | </div>
|
49 | 71 | <% end %>
|
50 | 72 | </div>
|
|
0 commit comments