min_max.html.erb 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <div class="page-container">
  2. <div class="page-content-wrapper">
  3. <div class="page-head">
  4. <div class="container-fluid">
  5. <div class="page-title">
  6. <h1>Reporte de mínimos y máximos por punto de venta</h1>
  7. </div>
  8. </div>
  9. </div>
  10. <div class="page-content">
  11. <div class="container-fluid">
  12. <ul class="page-breadcrumb breadcrumb">
  13. </ul>
  14. <div class="page-content-inner">
  15. <div id="notice"><%= notice %></div>
  16. <div class="portlet light hidden-print">
  17. <div class="portlet-body">
  18. <div class="row">
  19. <div class="col-md-12">
  20. <div class="booking-search">
  21. <%= form_tag(min_max_path, method: "get", remote: true, id: "minmax_form") do %>
  22. <div class="row form-group">
  23. <!-- punto de venta -->
  24. <%= label :pointsale_id, "", { class: "col-md-1 col-sm-2 control-label" } do %>Punto de venta<% end %>
  25. <div class="col-md-4 col-sm-5 select2-bootstrap-prepend">
  26. <%= select_tag :pointsale_id, options_from_collection_for_select(@pointsales, :id, :name, selected: @pointsales.first), class: "form-control select2" %>
  27. </div>
  28. </div>
  29. <div class="row form-group">
  30. <!-- categoria -->
  31. <%= label :category, "", { class: "col-md-1 col-sm-1 control-label" } do %>Línea <% end %>
  32. <div class="col-md-4 col-sm-4 select2-bootstrap-prepend">
  33. <%= select_tag :category, options_for_select(Category.activos_padre.collect{ |p| [ "#{p.category} - #{p.description}", p.id ] }), include_blank: "Todas", class: "form-control select2-allow-clear-todas input-medium", onchange: 'getSubCategories($(this).val())' %>
  34. </div>
  35. <!-- sub- categoria -->
  36. <%= label :subcategory, "", { class: "col-md-1 col-sm-1 control-label" } do %>Sublínea <% end %>
  37. <div class="col-md-4 col-sm-4 select2-bootstrap-prepend">
  38. <div class="select2-bootstrap-prepend">
  39. <%= collection_select("", :subcategory, ({}), :id, :category_and_description, options = { include_blank: "Todas" }, html_options = { class: 'form-control select2-allow-clear-todas input-medium' }) %>
  40. </div>
  41. </div>
  42. <div class="col-md-2 col-sm-1">
  43. <button type="button" onclick="applyFilter()" class="btn blue">Buscar</button>
  44. </div>
  45. </div>
  46. <% end %>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="portlet light">
  53. <div class="portlet-title">
  54. <div class="caption">
  55. <i class="fa fa-list "></i>
  56. <span class="caption-subject bold uppercase">Lista de productos</span>
  57. </div>
  58. </div>
  59. <div class="portlet-body ">
  60. <div id="error_explanation"></div>
  61. <%= hidden_field_tag 'title_for_print', "Reporte de mínimos y máximos por punto de venta" %>
  62. <!-- lista de productos -->
  63. <table class="table table-hover table-bordered table-striped tableadvancedprintable" id="minmax_table">
  64. <thead>
  65. <th>#</th>
  66. <th width="25%">Producto</th>
  67. <th>Precio<br>unitario</th>
  68. <th width="25%">Línea</th>
  69. <th>Sublínea</th>
  70. <th class="success">Cantidad recomendada<br> a comprar</th>
  71. <th>Total</th>
  72. </thead>
  73. <tbody>
  74. <% total = 0 %>
  75. <% @products.each_with_index do |available, key| %>
  76. <% category = available.product.categories[0] %>
  77. <tr>
  78. <td><%= key += 1 %></td>
  79. <td><%= available.product.full_display %></td>
  80. <td><%= number_to_currency(available.product.price_base, precision: 2) %></td>
  81. <td><%= category.parent_id.zero? ? category.category : category.parent.category %></td>
  82. <td><%= category.category %></td>
  83. <td class="success"><%= quantity = calculate_restock(available) %></td>
  84. <td><%= number_to_currency((quantity * available.product.price_base), precision: 2) %></td>
  85. </tr>
  86. <% total += (quantity * available.product.price_base) %>
  87. <% end %>
  88. <%= hidden_field_tag :total, total %>
  89. </tbody>
  90. </table>
  91. </div>
  92. </div>
  93. <div class="row">
  94. <div class="col-md-offset-4 col-md-3">
  95. <div class="text-center well" id="container_total_prods" style="margin-bottom: 0px">
  96. <div class="font-grey-mint font-sm">Total </div>
  97. <div class="uppercase font-hg font-blue-sharp" id="total_prods"></div>
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. </div>
  106. <script type="text/javascript">
  107. $(document).ready(function(){
  108. $('#total_prods').html(accounting.formatMoney($("#total").val()) + ' MXN');
  109. });
  110. function applyFilter() {
  111. $("#minmax_form").submit();
  112. }
  113. function getSubCategories(value) {
  114. $('#_subcategory').html('');
  115. $('#_subcategory').select2("destroy").select2({
  116. placeholder: 'Seleccione',
  117. "language": {
  118. "noResults": function(){
  119. return "No se encontraron coincidencias";
  120. }
  121. }
  122. });
  123. $('#_subcategory').select2('val', null);
  124. if(value) {
  125. $.ajax({
  126. type: "get",
  127. url: '/getcategories/' + value,
  128. dataType: 'json',
  129. success: function(data) {
  130. if(data.length > 0) {
  131. $('#_subcategory').append('<option></option>')
  132. for(i in data) {
  133. $('#_subcategory').append("<option value='" + data[i].id + "'>" + data[i].category + "</option>")
  134. }
  135. $('#_subcategory').select2({
  136. allowClear: true,
  137. placeholder: 'Todas',
  138. "language": {
  139. "noResults": function(){
  140. return "No se encontraron coincidencias";
  141. }
  142. }
  143. });
  144. }
  145. }
  146. });
  147. }
  148. }
  149. </script>