| 1234567891011121314151617181920212223242526272829303132333435363738 |
- <% if @error.blank? %>
- //toastr["error"]("Error, El cliente ya tiene asignado el producto seleccionado.");
- var table = $('#products_table').DataTable();
- var newRow = '<%= j render (@special_price) %>';
- table.row.add($(newRow)).draw();
- //agregar variantes
- <% @variantes.each do |v| %>
- <% existing_variant = SpecialPrice.find_by_product_id(v) %> //ver si ya está agregado el producto
- <% if existing_variant.blank? %>
- <% special_price = SpecialPrice.new %>
- <% special_price.product_id = v.id %>
- <% special_price.customer_id = @special_price.customer_id %>
- <% special_price.user_id = current_user.id %>
- <% special_price.save %>
- var newRow = '<%= j render (special_price) %>';
- table.row.add($(newRow)).draw();
- <% end %>
- <% end %>
- //
- <% else %>
- //agregar variantes
- <% @variantes.each do |va| %>
- <% existing_variant = SpecialPrice.find_by_product_id(va) %> //ver si ya está agregado el producto
- <% if existing_variant.blank? %>
- <% special_price = SpecialPrice.new %>
- <% special_price.product_id = va.id %>
- <% special_price.customer_id = @special_price.customer_id %>
- <% special_price.user_id = current_user.id %>
- <% special_price.save %>
- var newRow = '<%= j render (special_price) %>';
- table.row.add($(newRow)).draw();
- <% end %>
- <% end %>
- //
- <% end %>
|