|
|
@@ -6,12 +6,13 @@
|
|
|
<tr>
|
|
|
<th> Producto </th>
|
|
|
<th> Stock inicial </th>
|
|
|
+ <th> Precio de venta </th>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
<tbody>
|
|
|
<% @products.each do |product| %>
|
|
|
<tr id="product_<%= product.id %>">
|
|
|
- <td>
|
|
|
+ <td>
|
|
|
<strong><%= product.name %></strong> <br>
|
|
|
SKU: <%= product.sku %> <br>
|
|
|
<% if product.display_attributes.present? %>
|
|
|
@@ -19,8 +20,14 @@
|
|
|
<% end %>
|
|
|
<%= product.description if product.description.present? %>
|
|
|
</td>
|
|
|
- <td>
|
|
|
- <input type="number" min="0" class="form-control" value="0" pattern="^[0-9]*[1-9][0-9]*$" title="Stock con el que se agregará el producto al punto de venta">
|
|
|
+ <td>
|
|
|
+ <input type="number" min="0" class="form-control" id="stock_<%= product.id %>" value="0" pattern="^[0-9]*[1-9][0-9]*$" title="Stock con el que se agregará el producto al punto de venta">
|
|
|
+ </td>
|
|
|
+ <td>
|
|
|
+ <div class="input-group">
|
|
|
+ <span class="input-group-addon"> $ </span>
|
|
|
+ <%= number_field_tag "price_sale", product.price_sale, class: 'form-control input-small', id: "price_" + product.id.to_s, min: 0.01 %>
|
|
|
+ </div>
|
|
|
</td>
|
|
|
</tr>
|
|
|
<% end %>
|
|
|
@@ -30,16 +37,20 @@
|
|
|
<div class="form-actions">
|
|
|
<div class="row">
|
|
|
<div class="col-md-9">
|
|
|
- <button type="button" title="Asignar los productos seleccionados al punto de venta" class="btn blue" onclick="assignOrDeleteProducts($(this))">
|
|
|
- <i class="fa fa-long-arrow-right"></i> Asignar productos
|
|
|
+ <button type="button" title="Asignar los productos seleccionados al punto de venta" class="btn blue" onclick="assignOrDeleteProducts($(this))">
|
|
|
+ <i class="fa fa-long-arrow-right"></i> Asignar productos
|
|
|
</button>
|
|
|
<button class="btn default" onclick="closeModal()">Cancelar</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
<script>
|
|
|
+ $(document).ready(function(){
|
|
|
+ App.init();
|
|
|
+ });
|
|
|
+
|
|
|
function closeModal() {
|
|
|
$('#dialog').modal('toggle');
|
|
|
}
|
|
|
@@ -49,26 +60,25 @@
|
|
|
var products = [];
|
|
|
$('#table_assign_or_delete tbody tr').each(function(row) {
|
|
|
var idText = $(this).attr('id');
|
|
|
- var product_id = idText.substring(idText.lastIndexOf('_') + 1, idText.length);
|
|
|
- var obj = { id: product_id, stock: $(this).find('input').val() };
|
|
|
- products.push(obj);
|
|
|
- });
|
|
|
-
|
|
|
- $.ajax({
|
|
|
- type: "POST",
|
|
|
- url: "/pointsales/"+ <%= @pointsale.id %> + "/assign_products_to_pointsale",
|
|
|
- dataType: "json",
|
|
|
- data: {
|
|
|
- products: JSON.stringify(products)
|
|
|
- },
|
|
|
- success: function(xhr, status, error) {
|
|
|
- button.attr('disabled', false);
|
|
|
- toastr["success"]("Productos asignados correctamente.");
|
|
|
- $('#dialog').modal('toggle');
|
|
|
- $(class_1).DataTable().draw();
|
|
|
- $(class_2).DataTable().draw();
|
|
|
+ var product_id = idText.substring(idText.lastIndexOf('_') + 1, idText.length);
|
|
|
+ var obj = { id: product_id, stock: $("#stock_" + product_id).val(), price: $("#price_" + product_id).val() };
|
|
|
+ products.push(obj);
|
|
|
+ });
|
|
|
|
|
|
- }
|
|
|
- });
|
|
|
+ $.ajax({
|
|
|
+ type: "POST",
|
|
|
+ url: "/pointsales/"+ <%= @pointsale.id %> + "/assign_products_to_pointsale",
|
|
|
+ dataType: "json",
|
|
|
+ data: {
|
|
|
+ products: JSON.stringify(products)
|
|
|
+ },
|
|
|
+ success: function(xhr, status, error) {
|
|
|
+ button.attr('disabled', false);
|
|
|
+ toastr["success"]("Productos asignados correctamente.");
|
|
|
+ $('#dialog').modal('toggle');
|
|
|
+ $(class_1).DataTable().draw();
|
|
|
+ $(class_2).DataTable().draw();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
</script>
|