index.html.erb 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <!-- BEGIN CONTAINER -->
  2. <div class="page-container">
  3. <!-- BEGIN CONTENT -->
  4. <div class="page-content-wrapper">
  5. <!-- BEGIN CONTENT BODY -->
  6. <!-- BEGIN PAGE HEAD-->
  7. <div class="page-head">
  8. <div class="container-fluid">
  9. <!-- BEGIN PAGE TITLE -->
  10. <div class="page-title">
  11. <h1>Compras</h1>
  12. </div>
  13. </div>
  14. </div>
  15. <!-- END PAGE HEAD-->
  16. <!-- BEGIN PAGE CONTENT BODY -->
  17. <div class="page-content">
  18. <div class="container-fluid">
  19. <!-- BEGIN PAGE BREADCRUMBS -->
  20. <ul class="page-breadcrumb breadcrumb">
  21. <%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
  22. </ul>
  23. <!-- END PAGE BREADCRUMBS -->
  24. <!-- BEGIN PAGE CONTENT INNER -->
  25. <div class="page-content-inner">
  26. <div id="notice">
  27. <% if success %>
  28. <div class="alert alert-success">
  29. <p><%= success %></p>
  30. </div>
  31. <% elsif warning %>
  32. <div class="alert alert-warning">
  33. <p><%= warning %></p>
  34. </div>
  35. <% end %>
  36. </div>
  37. <div class="row">
  38. <div class="col-md-12">
  39. <div class="portlet light ">
  40. <div class="portlet-title">
  41. <div class="caption">
  42. <i class="fa fa-list "></i>
  43. <span class="caption-subject bold uppercase">Lista de compras</span>
  44. </div>
  45. <div class="actions">
  46. <% if can? :create, Purchase %>
  47. <%= link_to new_purchase_path, {:class=>"btn bold green pull-right filtros"} do %> Nueva Compra <i class="fa fa-plus"></i><% end %>
  48. <% end %>
  49. </div>
  50. </div>
  51. <div class="portlet-body">
  52. <div class="form-horizontal" style="margin-bottom:35px">
  53. <div class="row">
  54. <div class="col-md-11">
  55. <%= hidden_field_tag 'title_for_print' %>
  56. <div class="form-group">
  57. <%= label_tag :begin_date, "Fecha", { class: "col-md-1 control-label" } do %> Desde
  58. <% end %>
  59. <div class="col-sm-2" style="padding-left:0px;padding-right:0px;">
  60. <div class='input-group date' id='begin_date'>
  61. <input id="start" type='text' class="form-control"/>
  62. <span class="input-group-addon">
  63. <span class="glyphicon glyphicon-calendar"></span>
  64. </span>
  65. </div>
  66. </div>
  67. <%= label_tag :end_date, "Fecha", { class: "col-md-1 control-label" } do %> Hasta
  68. <% end %>
  69. <div class="col-sm-2" style="padding-left:0px;padding-right:0px;">
  70. <div class='input-group date' id='end_date'>
  71. <input id="end" type='text' class="form-control"/>
  72. <span class="input-group-addon">
  73. <span class="glyphicon glyphicon-calendar"></span>
  74. </span>
  75. </div>
  76. </div>
  77. <button class="btn btn-icon-only blue" style="margin-left:25px" onclick="purchasesByDate()">
  78. <i class="fa fa-search"></i>
  79. </button>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. <input type='hidden' name='filter' id='filter' value='<%= @filter %>' >
  85. <input type='hidden' name='current_page' id='current_page' value='<%= @current_page %>' >
  86. <table class="table table-striped table-bordered table-hover tableadvancedprintable" id="purchases_table">
  87. <thead>
  88. <tr>
  89. <th>#</th>
  90. <th>Folio</th>
  91. <th>Usuario</th>
  92. <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
  93. <th>Pto. de venta</th>
  94. <th>Almacén</th>
  95. <% end %>
  96. <th>Proveedor</th>
  97. <th>Total </th>
  98. <th>Fecha</th>
  99. <th>Status</th>
  100. <% if can? :manage, Purchase %>
  101. <th>Acciones</th>
  102. <% end %>
  103. </tr>
  104. </thead>
  105. <tbody>
  106. <% @purchases.each_with_index do |purchase, key| %>
  107. <tr <% if purchase.cancelled? %>class="danger"<% end %>>
  108. <td><%= key + 1 %></td>
  109. <td><%= purchase.purchase_code %></td>
  110. <td><%= purchase.user.first_name %></td>
  111. <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
  112. <td><%= purchase.pointsale.present? ? purchase.pointsale.name : '' %></td>
  113. <td><%= purchase.warehouse.present? ? purchase.warehouse.name : '' %></td>
  114. <% end %>
  115. <td><%= purchase.supplier.nick_name %></td>
  116. <td><%= number_to_currency(purchase.total, precision: 2) %> <%= purchase.is_in_dollars ? 'USD' : 'MXN' %></td>
  117. <td><%= l(purchase.purchase_date, :format => '%d/%B/%Y') %></td>
  118. <td class="text-center"><%= purchase_status(purchase) %></td>
  119. <td class="text-center">
  120. <%= link_to purchase, {:class=>"btn btn-icon-only default filtros", :title=>"Ver compra"} do %> <i class="fa fa-search"></i> <% end %>
  121. <% daysToCancel = @pos_config.days_cancel_purchase %>
  122. <% if (can? :manage, Purchase) && (purchase.purchase_date + daysToCancel.days >= Date.today) && !purchase.cancelled? %>
  123. <%= link_to purchase_path(purchase), method: :delete, :class => "btn btn-icon-only btn-danger", :title=>"Cancelar compra", data: { confirm: '¿Está seguro de cancelar la compra?' } do %> <i class="fa fa-times"></i> <% end %>
  124. <% end %>
  125. </td>
  126. </tr>
  127. <% end %>
  128. </tbody>
  129. </table>
  130. </div>
  131. </div>
  132. </div>
  133. </div>
  134. </div>
  135. <!-- END PAGE CONTENT INNER -->
  136. </div>
  137. </div>
  138. <!-- END PAGE CONTENT BODY -->
  139. <!-- END CONTENT BODY -->
  140. </div>
  141. <!-- END CONTENT -->
  142. </div>
  143. <script>
  144. $(document).on("page:change", function() {
  145. $('#begin_date').datetimepicker({
  146. icons: {
  147. date: "fa fa-calendar"
  148. },
  149. format: "DD/MM/YYYY",
  150. defaultDate: moment().startOf('month').toDate()
  151. });
  152. $('#end_date').datetimepicker({
  153. icons: {
  154. date: "fa fa-calendar"
  155. },
  156. format: "DD/MM/YYYY",
  157. defaultDate: moment().endOf('month').toDate()
  158. });
  159. var startDate = moment($("#begin_date").data("date"), "DD-MM-YYYY").format('DD/MM/YYYY')
  160. var endDate = moment($("#end_date").data("date"), "DD-MM-YYYY").format('DD/MM/YYYY');
  161. $('#title_for_print').val('Ventas del ' + startDate + ' al ' + endDate);
  162. });
  163. function purchasesByDate() {
  164. var start = moment($("#begin_date").data("date"), "DD-MM-YYYY").format('YYYY-MM-DD HH:mm:ss');
  165. var end = moment($("#end_date").data("date"), "DD-MM-YYYY").format('YYYY-MM-DD HH:mm:ss');
  166. App.blockUI({
  167. target: $("#purchases_table"),
  168. animate: true
  169. });
  170. $.ajax({
  171. type: "get",
  172. url: '/find_purchases_by_date/' + start + '/' + end,
  173. dataType: 'script',
  174. success: function(data) {
  175. window.setTimeout(function() {
  176. App.unblockUI($("#purchases_table"));
  177. }, 100);
  178. }
  179. });
  180. }
  181. </script>