Explorar el Código

Removed pointsale select from initial stock/stock for warehouse users

Jacqueline Maldonado hace 7 años
padre
commit
f3a04ba6a0

+ 43 - 44
app/views/available_products/_form.html.erb

@@ -57,19 +57,19 @@
   }
 
   function updateStock() {
-  var min = parseInt($('#min_stock_general').val());
-  var max = parseInt($('#max_stock_general').val());
-  // checar por campos vacios
-  if(!min || !max ) {
+    var min = parseInt($('#min_stock_general').val());
+    var max = parseInt($('#max_stock_general').val());
+    // checar por campos vacios
+    if(!min || !max ) {
       toastr["error"]("Error, No pueden quedar vacios los campos de mínimo y máximo");
-  } else {
-    //maximo sea menor al minimo
-    if( max < min) {
-      toastr["error"]("Error, El máximo debe de ser mayor al mínimo");
-      //almenos 1 producto seleccionado
-    } else if(rows_selected.length == 0) {
-      toastr["error"]("Error, Se debe seleccionar al menos un producto para actualizar");
     } else {
+      //maximo sea menor al minimo
+      if( max < min) {
+        toastr["error"]("Error, El máximo debe de ser mayor al mínimo");
+        //almenos 1 producto seleccionado
+      } else if(rows_selected.length == 0) {
+        toastr["error"]("Error, Se debe seleccionar al menos un producto para actualizar");
+      } else {
         $.ajax({
           type: "PUT",
           url: "/update_stock",
@@ -84,7 +84,6 @@
             var rows = $(".stock-table").dataTable().fnGetNodes();
             $.each(rows, function(i, row) {
               var id = $(this).attr('id').substring($(this).attr('id').indexOf('_') + 1, $(this).attr('id').length);
-
               if($.inArray(id, rows_selected) != -1) {
                 minInput = $(row).find("td:eq(6)")
                 minInput.text(min);
@@ -92,49 +91,49 @@
                 maxInput.text(max);
               }
             });
-              $('#select-all').click();
-              $('#min_stock_general').val("");
-              $('#max_stock_general').val("");
-              toastr["success"]("Stock mínimo y máximo actualizado.");
+            $('#select-all').click();
+            $('#min_stock_general').val("");
+            $('#max_stock_general').val("");
+            toastr["success"]("Stock mínimo y máximo actualizado.");
           }
         });
+      }
     }
   }
-  }
 
   function initialStock() {
-  var initialStock = parseInt($('#initial_stock_input').val());
-  if (initialStock || initialStock == 0) {
-    if(rows_selected.length > 0) {
-      $.ajax({
-        type: "PUT",
-        url: "/set_initial_stock",
-        dataType: "json",
-        data: {
-          ids: rows_selected,
-          stock: initialStock
-        },
-        success: function(xhr, status, error) {
-          var table = $('.stock-table').dataTable();
-          var rows = $(".stock-table").dataTable().fnGetNodes();
-          $.each(rows, function(i, row) {
-            var id = $(this).attr('id').substring($(this).attr('id').indexOf('_') + 1, $(this).attr('id').length);
+    var initialStock = parseInt($('#initial_stock_input').val());
+    if (initialStock || initialStock == 0) {
+      if(rows_selected.length > 0) {
+        $.ajax({
+          type: "PUT",
+          url: "/set_initial_stock",
+          dataType: "json",
+          data: {
+            ids: rows_selected,
+            stock: initialStock
+          },
+          success: function(xhr, status, error) {
+            var table = $('.stock-table').dataTable();
+            var rows = $(".stock-table").dataTable().fnGetNodes();
+            $.each(rows, function(i, row) {
+              var id = $(this).attr('id').substring($(this).attr('id').indexOf('_') + 1, $(this).attr('id').length);
 
-            if($.inArray(id, rows_selected) != -1) {
-              initialStockInput = $(row).find("td:eq(6)");
-              initialStockInput.text(initialStock);
-            }
-          });
+              if($.inArray(id, rows_selected) != -1) {
+                initialStockInput = $(row).find("td:eq(6)");
+                initialStockInput.text(initialStock);
+              }
+            });
             $('#select-all').click();
             $('#initial_stock').val("");
             toastr["success"]("Stock inicial actualizado.");
-        }
-      });
+          }
+        });
+      } else {
+        toastr["error"]("Error, Se debe seleccionar al menos un producto para actualizar");
+      }
     } else {
-      toastr["error"]("Error, Se debe seleccionar al menos un producto para actualizar");
+      toastr["error"]("Error, NO puede quedar vacío el campo de stock inicial");
     }
-  } else {
-    toastr["error"]("Error, NO puede quedar vacio el campo de stock inicial");
-  }
   }
 </script>

+ 1 - 1
app/views/available_products/initial_stock.html.erb

@@ -33,7 +33,7 @@
                   <h4 class="form-section"> Lista de productos</h4>
                   <div class="portlet-body">
                     <div class="row">
-                      <% unless current_user.usertype == "G" %>
+                      <% unless current_user.usertype == "G" || current_user.usertype == "S" %>
                         <%= label_tag :pointsale, "Puntos de venta", class: "control-label col-md-1 col-sm-2" %>
                         <div class="col-md-3 col-sm-4">
                           <%= select_tag "pointsale", options_from_collection_for_select(@pointsales, :id, :name), class: "form-control input-medium" %>

+ 1 - 1
app/views/available_products/stock.html.erb

@@ -34,7 +34,7 @@
                   <h4 class="form-section"> Lista de productos</h4>
                   <div class="portlet-body">
                     <div class="row">
-                      <% unless current_user.usertype == "G" %>
+                      <% unless current_user.usertype == "G" || current_user.usertype == "S" %>
                         <%= label_tag :pointsale, "Puntos de venta", class: "control-label col-md-1 col-sm-2" %>
                         <div class="col-md-3 col-sm-4">
                           <%= select_tag "pointsale", options_from_collection_for_select(@pointsales, :id, :name), class: "form-control input-medium" %>