Prechádzať zdrojové kódy

Merge branch 'apply_rubocop' of SML/pos-boutique into master

Jose Miguel Ledon 7 rokov pred
rodič
commit
d38b5b6a4f
100 zmenil súbory, kde vykonal 3425 pridanie a 3638 odobranie
  1. 33 27
      app/controllers/application_controller.rb
  2. 1 1
      app/controllers/cash_outs_controller.rb
  3. 29 31
      app/controllers/cash_registers_controller.rb
  4. 1 1
      app/controllers/commissions_controller.rb
  5. 1 1
      app/controllers/dashboard_controller.rb
  6. 6 5
      app/controllers/expenses_controller.rb
  7. 84 85
      app/controllers/expensesconcepts_controller.rb
  8. 1 6
      app/controllers/pointsales_controller.rb
  9. 24 35
      app/controllers/product_wastes_controller.rb
  10. 5 1
      app/controllers/products_controller.rb
  11. 1 1
      app/controllers/products_returns_controller.rb
  12. 86 102
      app/controllers/purchases_controller.rb
  13. 35 35
      app/controllers/sales_controller.rb
  14. 39 41
      app/controllers/sellers_controller.rb
  15. 1 1
      app/controllers/special_prices_controller.rb
  16. 1 1
      app/controllers/transfers_controller.rb
  17. 26 7
      app/controllers/users_controller.rb
  18. 30 30
      app/controllers/warehouses_controller.rb
  19. 16 24
      app/datatables/available_products_datatable.rb
  20. 58 37
      app/datatables/products_datatable.rb
  21. 17 0
      app/helpers/pointsales_helper.rb
  22. 12 0
      app/helpers/purchases_helper.rb
  23. 23 0
      app/helpers/users_helper.rb
  24. 9 5
      app/models/ability.rb
  25. 0 2
      app/models/available_product.rb
  26. 16 24
      app/models/cash_out.rb
  27. 14 15
      app/models/cash_register.rb
  28. 20 20
      app/models/open_cash_register.rb
  29. 5 7
      app/models/pointsale.rb
  30. 10 9
      app/models/product.rb
  31. 12 12
      app/models/product_waste.rb
  32. 1 1
      app/models/seller.rb
  33. 2 0
      app/models/user.rb
  34. 4 5
      app/views/available_products/_edit_price.html.erb
  35. 3 5
      app/views/available_products/stock_by_pointsale.html.erb
  36. 8 5
      app/views/cash_outs/_cash_out.html.erb
  37. 10 10
      app/views/cash_outs/index.html.erb
  38. 10 8
      app/views/cash_outs/opened_cash_registers.html.erb
  39. 185 187
      app/views/cash_outs/show.html.erb
  40. 35 57
      app/views/cash_registers/_form.html.erb
  41. 11 0
      app/views/cash_registers/create.js.erb
  42. 0 52
      app/views/cash_registers/edit.html.erb
  43. 14 0
      app/views/cash_registers/edit.js.erb
  44. 30 26
      app/views/cash_registers/index.html.erb
  45. 0 52
      app/views/cash_registers/new.html.erb
  46. 14 0
      app/views/cash_registers/new.js.erb
  47. 11 0
      app/views/cash_registers/update.js.erb
  48. 128 131
      app/views/commissions/_sellers_for_commissions.html.erb
  49. 58 72
      app/views/customers/customer_sales.html.erb
  50. 78 78
      app/views/dashboard/_dashboard_for_admin.html.erb
  51. 1 1
      app/views/dashboard/index.html.erb
  52. 54 54
      app/views/expenses/_expenses_for_admin.html.erb
  53. 2 2
      app/views/expenses/_expenses_for_manager.html.erb
  54. 68 80
      app/views/expenses/_form.html.erb
  55. 3 3
      app/views/expenses/index.html.erb
  56. 66 67
      app/views/expensesconcepts/_form.html.erb
  57. 102 103
      app/views/expensesconcepts/index.html.erb
  58. 42 42
      app/views/pointsales/_form.html.erb
  59. 19 34
      app/views/pointsales/_index.html.erb
  60. 49 50
      app/views/pointsales/edit.html.erb
  61. 77 78
      app/views/pointsales/index.html.erb
  62. 30 30
      app/views/pos_configs/_form.html.erb
  63. 8 10
      app/views/product_wastes/index.html.erb
  64. 418 442
      app/views/products/_form.html.erb
  65. 51 53
      app/views/products/_products_track_dtl.html.erb
  66. 45 0
      app/views/products/_products_track_purchases_dtl.html.erb
  67. 1 1
      app/views/products/edit.html.erb
  68. 192 195
      app/views/products/edit_variants.html.erb
  69. 2 2
      app/views/products/index.html.erb
  70. 199 180
      app/views/products/product_track.html.erb
  71. 3 10
      app/views/products/product_track.js.erb
  72. 24 61
      app/views/products/show.html.erb
  73. 1 2
      app/views/products_returns/_form.html.erb
  74. 2 2
      app/views/products_returns/index.html.erb
  75. 379 383
      app/views/purchases/_form.html.erb
  76. 15 15
      app/views/purchases/_purchase.html.erb
  77. 48 62
      app/views/purchases/index.html.erb
  78. 2 2
      app/views/sales/_sale.html.erb
  79. 3 13
      app/views/sales/_sale_for_report.html.erb
  80. 2 11
      app/views/sales/_sale_for_return.html.erb
  81. 11 11
      app/views/sales/_sale_reserved.html.erb
  82. 2 2
      app/views/sales/index.html.erb
  83. 6 8
      app/views/sales/sales_per_month_report.html.erb
  84. 11 11
      app/views/sales/sales_reserved.html.erb
  85. 60 71
      app/views/sales/show.html.erb
  86. 12 15
      app/views/sellers/_form.html.erb
  87. 11 0
      app/views/sellers/create.js.erb
  88. 0 51
      app/views/sellers/edit.html.erb
  89. 14 0
      app/views/sellers/edit.js.erb
  90. 7 10
      app/views/sellers/index.html.erb
  91. 0 52
      app/views/sellers/new.html.erb
  92. 14 0
      app/views/sellers/new.js.erb
  93. 11 0
      app/views/sellers/update.js.erb
  94. 87 97
      app/views/special_prices/_form.html.erb
  95. 27 27
      app/views/transfers/_form.html.erb
  96. 1 1
      app/views/transfers/index.html.erb
  97. 1 1
      app/views/transfers/new.html.erb
  98. 2 2
      app/views/units/update.js.erb
  99. 22 36
      app/views/users/_form.html.erb
  100. 0 0
      app/views/users/index.html.erb

+ 33 - 27
app/controllers/application_controller.rb

@@ -75,36 +75,40 @@ class ApplicationController < ActionController::Base
 
   def find_from_stock
     query = params[:query]
+
+    location =
+      if current_user.usertype == "S"
+        Warehouse.find(current_user.warehouse_id).products
+      else
+        Pointsale.find(current_user.pointsale_id).products
+      end
+
     if query.include? ':' # search with attributes
       query_array = query.split(':')
       product_name = query_array[0]
       query_array.shift # delete the name of the product from the array to iterate the attributes
       attrs_query_string = ''
       query_array.each do |attribute|
-        if attribute.present?
-          attr_type = case attribute[0]
-                      when 'c'
-                        'colors'
-                      when 't'
-                        'sizes'
-                      when 'e'
-                        'styles'
-                      end
-          attribute[0] = "" # delete the attribute type character
-          attrs_query_string.concat(" AND attributes_json::json->>'#{attr_type}' ilike '%#{attribute}%'")
-        else
-          next
-        end
+        next if attribute.nil?
+        attr_type =
+          case attribute[0]
+          when 'c'
+            'colors'
+          when 't'
+            'sizes'
+          when 'e'
+            'styles'
+          end
+        attribute[0] = "" # delete the attribute type character
+        attrs_query_string.concat(" AND attributes_json::json->>'#{attr_type}' ilike '%#{attribute}%'")
       end
+      consult = location.name_sku_barcode_attribute_like(product_name, attrs_query_string)
     else
       product_name = query
+      consult = location.name_sku_barcode_like(params[:query])
     end
 
-    if current_user.usertype == 'S'
-      render json: query.include?(":") ? Warehouse.find(current_user.warehouse_id).products.name_sku_barcode_attribute_like(product_name, attrs_query_string).where("stock > 0").limit(30).to_json(methods: [:small_img, :display_attributes]) : Warehouse.find(current_user.warehouse_id).products.name_sku_barcode_like(params[:query]).where("stock > 0").limit(30).to_json(methods: [:small_img, :display_attributes])
-    else
-      render json: query.include?(":") ? Pointsale.find(current_user.pointsale_id).products.name_sku_barcode_attribute_like(product_name, attrs_query_string).where("stock > 0").limit(30).to_json(methods: [:small_img, :display_attributes]) : Pointsale.find(current_user.pointsale_id).products.name_sku_barcode_like(params[:query]).where("stock > 0").limit(30).to_json(methods: [:small_img, :display_attributes])
-    end
+    render json: consult.where("stock > 0").limit(30).to_json(methods: [:small_img, :display_attributes])
   end
 
   # rubocop:disable Metrics/BlockNesting
@@ -216,14 +220,16 @@ class ApplicationController < ActionController::Base
   end
 
   def get_next_expense_code
-    if current_user.usertype == 'A'
-      next_id = Expense.where("expense_code ilike ?", '%ADM%').count.next
-      render json: "ADM-E-#{next_id}"
-    else
-      pointsale = OpenCashRegister.find(params[:open_cash_register_id]).cash_register.pointsale
-      next_id = pointsale.expenses.count.next
-      render json: "#{pointsale.prefix}-E-#{next_id}"
-    end
+    code =
+      if current_user.usertype == "A" || current_user.usertype == "SS"
+        next_id = Expense.where("expense_code ilike ?", '%ADM%').count.next
+        "ADM-E-#{next_id}"
+      else
+        pointsale = OpenCashRegister.find(params[:open_cash_register_id]).cash_register.pointsale
+        next_id = pointsale.expenses.count.next
+        "#{pointsale.prefix}-E-#{next_id}"
+      end
+    render json: code
   end
 
   def products_by_category_pointsale

+ 1 - 1
app/controllers/cash_outs_controller.rb

@@ -15,7 +15,7 @@ class CashOutsController < ApplicationController
   # GET /cash_outs.json
   def index
     case current_user.usertype
-    when "A"
+    when "A", "SS"
       @cash_outs = CashOut.all.includes(:open_cash_register, :user, :received_by).order('cash_outs.created_at desc')
     when "G"
       @cash_outs = Pointsale.find(current_user.pointsale_id).cash_outs.includes(:open_cash_register, :user, :received_by).order('cash_outs.created_at desc')

+ 29 - 31
app/controllers/cash_registers_controller.rb

@@ -4,9 +4,9 @@ class CashRegistersController < ApplicationController
 
   ##--- Breadcrum_rails
   add_breadcrumb I18n.t("breadcrumbs." + controller_name), :cash_registers_path
-  add_breadcrumb "Nueva Caja registradora " , :new_cash_register_path, only: :new
-  add_breadcrumb "Detalle de la Caja registradora "  , :cash_register_path, only: :show
-  add_breadcrumb "Editar Caja registradora "  , :edit_cash_register_path, only: :edit
+  add_breadcrumb "Nueva Caja registradora ", :new_cash_register_path, only: :new
+  add_breadcrumb "Detalle de la Caja registradora ", :cash_register_path, only: :show
+  add_breadcrumb "Editar Caja registradora ", :edit_cash_register_path, only: :edit
 
   before_action :set_cash_register, only: [:show, :edit, :update, :destroy]
 
@@ -15,7 +15,7 @@ class CashRegistersController < ApplicationController
   # GET /cash_registers
   # GET /cash_registers.json
   def index
-    if current_user.usertype == 'A'
+    if current_user.usertype == "A" || current_user.usertype == "SS"
       @cash_registers = CashRegister.vigentes.includes(:pointsale)
     else
       @cash_registers = CashRegister.includes(:pointsale).where(:pointsale_id => current_user.pointsale_id ).vigentes
@@ -24,8 +24,7 @@ class CashRegistersController < ApplicationController
 
   # GET /cash_registers/1
   # GET /cash_registers/1.json
-  def show
-  end
+  def show; end
 
   # GET /cash_registers/new
   def new
@@ -33,8 +32,7 @@ class CashRegistersController < ApplicationController
   end
 
   # GET /cash_registers/1/edit
-  def edit
-  end
+  def edit; end
 
   # POST /cash_registers
   # POST /cash_registers.json
@@ -43,10 +41,11 @@ class CashRegistersController < ApplicationController
     @cash_register.pointsale_id = @current_user.pointsale_id
     respond_to do |format|
       if @cash_register.save
-          format.html { redirect_to cash_registers_url, success: "La caja " + @cash_register.name + " fue registrada." }
-        format.json { render :show, status: :created, location: @cash_register }
+        format.html { redirect_to cash_registers_url, success: "La caja " + @cash_register.name + " fue registrada." }
+        format.js
       else
         format.html { render :new }
+        format.js
         format.json { render json: @cash_register.errors, status: :unprocessable_entity }
       end
     end
@@ -56,31 +55,30 @@ class CashRegistersController < ApplicationController
   # PATCH/PUT /cash_registers/1.json
   def update
     respond_to do |format|
-      cash_register_opened = OpenCashRegister.where(:cash_register_id => @cash_register.id, :status => 0).any?
-
+      cash_register_opened = OpenCashRegister.where(cash_register_id: @cash_register.id, status: 0).any?
       if cash_register_opened == true && params[:cash_register][:status] == 'inactive'
         @cash_register.errors.add(:status, "No se puede desactivar una caja abierta.")
         format.html { render :edit }
+        format.js
         format.json { render json: @cash_register.errors, status: :unprocessable_entity }
       else
         @cash_register.update(cash_register_params)
-        format.html { redirect_to cash_registers_url,   success: "La caja " + @cash_register.name + " fue modificada." }
-        format.json { render :show, status: :ok, location: @cash_register }
+        format.js
       end
     end
   end
 
   def update_status
       cash_register = CashRegister.find(params[:cash_register_id])
-      puts cash_register.active?
-      if cash_register.active?
-        cash_register.status = 2
-      elsif cash_register.inactive?
-        cash_register.status = 1
-      end
+      cash_register.status =
+        if cash_register.active?
+          2
+        elsif cash_register.inactive?
+          1
+        end
       respond_to do |format|
-        if cash_register.save(:validate => false)
-            format.html { redirect_to cash_registers_url, warning: "La caja registradora " + cash_register.name + " fue "+ (cash_register.active? ? "activada" : "desactivada")+"." }
+        if cash_register.save(validate: false)
+          format.html { redirect_to cash_registers_url, warning: "La caja registradora " + cash_register.name + " fue " + (cash_register.active? ? "activada" : "desactivada") + "." }
           # format.json { render :show, status: :ok, location: @pointsale }
           format.json { head :no_content }
         else
@@ -106,7 +104,7 @@ class CashRegistersController < ApplicationController
           format.html { redirect_to cash_registers_url,  warning: "La caja " + @cash_register.name + " no se puede eliminar por ser la principal." }
           format.json { render json: @cash_register.errors, status: :unprocessable_entity }
         else
-          @cash_register.update_attributes(:status => 0)
+          @cash_register.update_attributes(status: 0)
           format.html { redirect_to cash_registers_url,  warning: "La caja " + @cash_register.name + " fue eliminada." }
           format.json { head :no_content }
         end
@@ -120,13 +118,13 @@ class CashRegistersController < ApplicationController
   end
 
   private
-    # Use callbacks to share common setup or constraints between actions.
-    def set_cash_register
-      @cash_register = CashRegister.find(params[:id])
-    end
+  # Use callbacks to share common setup or constraints between actions.
+  def set_cash_register
+    @cash_register = CashRegister.find(params[:id])
+  end
 
-    # Never trust parameters from the scary internet, only allow the white list through.
-    def cash_register_params
-      params.require(:cash_register).permit(:name, :description, :pointsale_id, :status)
-    end
+  # Never trust parameters from the scary internet, only allow the white list through.
+  def cash_register_params
+    params.require(:cash_register).permit(:name, :description, :pointsale_id, :status)
+  end
 end

+ 1 - 1
app/controllers/commissions_controller.rb

@@ -11,7 +11,7 @@ class CommissionsController < ApplicationController
   # GET /commissions
   # GET /commissions.json
   def index
-    @commissions = current_user.usertype == 'A' ? Commission.all.includes(:pointsale, :user).order('created_at desc') : Commission.includes(:pointsale, :user).where(pointsale_id: current_user.pointsale_id).order('created_at desc')
+    @commissions = current_user.usertype == "A" || current_user.usertype == "SS" ? Commission.all.includes(:pointsale, :user).order('created_at desc') : Commission.includes(:pointsale, :user).where(pointsale_id: current_user.pointsale_id).order('created_at desc')
   end
 
   # GET /commissions/1

+ 1 - 1
app/controllers/dashboard_controller.rb

@@ -1,7 +1,7 @@
 class DashboardController < ApplicationController
   def index
     @open_cash = false
-    if current_user.usertype == 'A'
+    if current_user.usertype == "A" || current_user.usertype == "SS"
       # obtener ingresos por punto de venta
       @incomings = ActionController::Base.helpers.sanitize(CashRegistersMove.incomings_per_period('day'))
       # obtener ranking de productos y prepararlo para mandarlo al view

+ 6 - 5
app/controllers/expenses_controller.rb

@@ -14,7 +14,7 @@ class ExpensesController < ApplicationController
   # GET /expenses.json
   def index
     case current_user.usertype
-    when "A"
+    when "A", "SS"
       @from_pointsale = Expense.where.not(open_cash_register_id: nil).includes(:expensesconcept).order(" id DESC ")
       @general_expenses = Expense.where(open_cash_register_id: nil).includes(:expensesconcept).order(" id DESC ")
     when "G"
@@ -50,7 +50,7 @@ class ExpensesController < ApplicationController
       @concept_purchase_payment = Expensesconcept.find_by(expense_from_purchase: 1)
       @expense.status = :active
 
-      if current_user.usertype == "A"
+      if current_user.usertype == "A" || current_user.usertype == "SS"
         @expense.skip_open_cash_validation = true
         @expense.skip_open_cash_has_money = true
       else
@@ -67,7 +67,7 @@ class ExpensesController < ApplicationController
           end
         end
         # movimiento de efectivo
-        if current_user.usertype != "A"
+        if current_user.usertype != "A" || current_user.usertype != "SS"
           move = CashRegistersMove.new
           move.skip_received_validation = true
           move.expense_id = @expense.id
@@ -110,7 +110,7 @@ class ExpensesController < ApplicationController
   # DELETE /expenses/1.json
   def destroy
     respond_to do |format|
-      if current_user.usertype == 'A'
+      if current_user.usertype == "A" || current_user.usertype == "SS"
         @expense.skip_open_cash_validation = true
       end
 
@@ -129,7 +129,8 @@ class ExpensesController < ApplicationController
 
   def set_data
     @is_cashier = false
-    if current_user.usertype != "A"
+
+    if current_user.usertype != "A" && current_user.usertype != "SS"
       @expenses_concepts = Array.new
       Expensesconcept.where("status = 1 and allpoints = 'true'").each do |expense|
         @expenses_concepts << expense

+ 84 - 85
app/controllers/expensesconcepts_controller.rb

@@ -1,26 +1,26 @@
 class ExpensesconceptsController < ApplicationController
-	##--- Abilities
-	load_and_authorize_resource
+  ##--- Abilities
+  load_and_authorize_resource
 
-	##--- Breadcrum_rails
-	add_breadcrumb I18n.t("breadcrumbs." + controller_name), :expensesconcepts_path
-	add_breadcrumb "Nuevo Concepto de egreso" , :new_expensesconcept_path, only: :new
-	add_breadcrumb "Detalle del Concepto de egreso" , :expensesconcept_path, only: :show
-	add_breadcrumb "Editar Concepto de egreso" , :edit_expensesconcept_path, only: :edit
+  ##--- Breadcrum_rails
+  add_breadcrumb I18n.t("breadcrumbs." + controller_name), :expensesconcepts_path
+  add_breadcrumb "Nuevo Concepto de egreso", :new_expensesconcept_path, only: :new
+  add_breadcrumb "Detalle del Concepto de egreso", :expensesconcept_path, only: :show
+  add_breadcrumb "Editar Concepto de egreso", :edit_expensesconcept_path, only: :edit
 
-	before_action :set_expensesconcept, only: [:show, :edit, :update, :destroy]
-	before_action :get_filters, only: [:index, :show, :edit, :new]
-	# before_action :get_pointsales, only: [:create, :update]
+  before_action :set_expensesconcept, only: [:show, :edit, :update, :destroy]
+  before_action :get_filters, only: [:index, :show, :edit, :new]
+  # before_action :get_pointsales, only: [:create, :update]
 
-	# GET /expensesconcepts
-	# GET /expensesconcepts.json
-	def index
-    @concept_purchase_payment = Expensesconcept.find_by(:expense_from_purchase => 1)
-    if current_user.usertype == 'A'
+  # GET /expensesconcepts
+  # GET /expensesconcepts.json
+  def index
+    @concept_purchase_payment = Expensesconcept.find_by(expense_from_purchase: 1)
+    if current_user.usertype == "A" || current_user.usertype == "SS"
       @expensesconcepts = Expensesconcept.vigentes
     else
       @expensesconcepts = Array.new
-      Expensesconcept.where("status = 1 and allpoints = 'true'").each do |expense|
+      Expensesconcept.where(status: 1, allpoints: true).each do |expense|
         @expensesconcepts << expense
       end
 
@@ -31,7 +31,6 @@ class ExpensesconceptsController < ApplicationController
     end
   end
 
-
   # GET /expensesconcepts/new
   def new
     @expensesconcept = Expensesconcept.new
@@ -39,81 +38,81 @@ class ExpensesconceptsController < ApplicationController
 
   def create
     @expensesconcept = Expensesconcept.new(expensesconcept_params)
-		respond_to do |format|
-			@expensesconcept.audit_comment = "Concepto de egreso #{@expensesconcept.name} creado."
-			if @expensesconcept.save
-				# @expensesconcept.pointsales = @pointsales
-				format.html { redirect_to expensesconcepts_url, success: 'El concepto ' + @expensesconcept.name + ' fue creado.' }
-				format.json { render :show, status: :created, location: @expensesconcept }
-			else
-				format.html { render :new }
-				format.json { render json: @expensesconcept.errors, status: :unprocessable_entity }
-			end
-		end
-	end
+    respond_to do |format|
+      @expensesconcept.audit_comment = "Concepto de egreso #{@expensesconcept.name} creado."
+      if @expensesconcept.save
+        # @expensesconcept.pointsales = @pointsales
+        format.html { redirect_to expensesconcepts_url, success: 'El concepto ' + @expensesconcept.name + ' fue creado.' }
+        format.json { render :show, status: :created, location: @expensesconcept }
+      else
+        format.html { render :new }
+        format.json { render json: @expensesconcept.errors, status: :unprocessable_entity }
+      end
+    end
+  end
 
-	# PATCH/PUT /expensesconcepts/1
-	# PATCH/PUT /expensesconcepts/1.json
-	def update
-		respond_to do |format|
-			@expensesconcept.audit_comment = "Concepto de egreso #{@expensesconcept.name} modificado."
-			if @expensesconcept.update(expensesconcept_params)
+  # PATCH/PUT /expensesconcepts/1
+  # PATCH/PUT /expensesconcepts/1.json
+  def update
+    respond_to do |format|
+      @expensesconcept.audit_comment = "Concepto de egreso #{@expensesconcept.name} modificado."
+      if @expensesconcept.update(expensesconcept_params)
 
-				# @expensesconcept.pointsales = @pointsales
-				format.html { redirect_to expensesconcepts_url, success: 'El concepto ' + @expensesconcept.name + ' fue modificado.' }
-					format.json { render :show, status: :ok, location: @expensesconcept }
-			else
-				format.html { render :edit }
-				format.json { render json: @expensesconcept.errors, status: :unprocessable_entity }
-			end
-		end
-	end
+        # @expensesconcept.pointsales = @pointsales
+        format.html { redirect_to expensesconcepts_url, success: 'El concepto ' + @expensesconcept.name + ' fue modificado.' }
+        format.json { render :show, status: :ok, location: @expensesconcept }
+      else
+        format.html { render :edit }
+        format.json { render json: @expensesconcept.errors, status: :unprocessable_entity }
+      end
+    end
+  end
 
-	# DELETE /expensesconcepts/1
-	# DELETE /expensesconcepts/1.json
-	def destroy
-		#@expensesconcept.destroy
-		respond_to do |format|
-			@expensesconcept.audit_comment = "Concepto de egreso #{@expensesconcept.name} eliminado."
-			if @expensesconcept.update_attributes(:status => 0)
-						format.html { redirect_to expensesconcepts_url, warning: "El concepto " + @expensesconcept.name + " fue eliminado." }
-						format.json { head :no_content }
-			else
-				format.html { render :edit }
-				format.json { render json: @expensesconcept.errors, status: :unprocessable_entity }
-			end
-		end
-	end
+  # DELETE /expensesconcepts/1
+  # DELETE /expensesconcepts/1.json
+  def destroy
+    respond_to do |format|
+      @expensesconcept.audit_comment = "Concepto de egreso #{@expensesconcept.name} eliminado."
+      if @expensesconcept.update_attributes(status: 0)
+        format.html { redirect_to expensesconcepts_url, warning: "El concepto " + @expensesconcept.name + " fue eliminado." }
+        format.json { head :no_content }
+      else
+        format.html { render :edit }
+        format.json { render json: @expensesconcept.errors, status: :unprocessable_entity }
+      end
+    end
+  end
 
   private
-    # Use callbacks to share common setup or constraints between actions.
-    def set_expensesconcept
-      @expensesconcept = Expensesconcept.find(params[:id])
-    end
 
-    # Never trust parameters from the scary internet, only allow the white list through.
-    def expensesconcept_params
-      params.require(:expensesconcept).permit(:name, :description, :allpoints, :status, :pointsale_ids => [])
-    end
+  # Use callbacks to share common setup or constraints between actions.
+  def set_expensesconcept
+    @expensesconcept = Expensesconcept.find(params[:id])
+  end
 
-    def get_filters
-			if params[:current_page].blank?
-				@current_page = 1
-			else
-				@current_page = params[:current_page]
-			end
-			@filter = params[:filter]
-		end
+  # Never trust parameters from the scary internet, only allow the white list through.
+  def expensesconcept_params
+    params.require(:expensesconcept).permit(:name, :description, :allpoints, :status, pointsale_ids: [])
+  end
 
-    def get_pointsales
-        unless params[:expensesconcept][:pointsale_ids].nil? && params[:expensesconcept][:pointsale_ids].empty?
-            ## Issue arreglo primer elemento en blanco ...
-            params[:expensesconcept][:pointsale_ids] = params[:expensesconcept][:pointsale_ids].delete_if{ |x| x.empty? }
-            @pointsales = params[:expensesconcept][:pointsale_ids].map do |k|
-                Pointsale.find(k)
-            end
-        else
-            @pointsales = []
-        end
+  def get_filters
+    @current_page =
+      if params[:current_page].blank?
+        1
+      else
+        params[:current_page]
+      end
+    @filter = params[:filter]
+  end
+
+  def get_pointsales
+    @pointsales = []
+    unless params[:expensesconcept][:pointsale_ids].nil? && params[:expensesconcept][:pointsale_ids].empty?
+      ## Issue arreglo primer elemento en blanco ...
+      params[:expensesconcept][:pointsale_ids] = params[:expensesconcept][:pointsale_ids].delete_if(&:empty?)
+      @pointsales = params[:expensesconcept][:pointsale_ids].map do |k|
+        Pointsale.find(k)
+      end
     end
+  end
 end

+ 1 - 6
app/controllers/pointsales_controller.rb

@@ -50,12 +50,7 @@ class PointsalesController < ApplicationController
     respond_to do |format|
       if @pointsale.save
         @pointsale.users.first.pointsale_id = @pointsale.id
-        main_cash_register = CashRegister.new
-        main_cash_register.name = @pointsale.name + " Principal"
-        main_cash_register.description = "Caja registradora principal"
-        main_cash_register.pointsale_id = @pointsale.id
-        main_cash_register.main = 'yes'
-        main_cash_register.status = 'active'
+        main_cash_register = CashRegister.new(name: "#{@pointsale.name} Principal", description: "Caja registradora principal", pointsale_id: @pointsale.id, main: 'yes', status: 'active')
         main_cash_register.save
 
         format.html { redirect_to pointsales_url, success: "El punto de venta " + @pointsale.name + " fue creado." }

+ 24 - 35
app/controllers/product_wastes_controller.rb

@@ -13,13 +13,15 @@ class ProductWastesController < ApplicationController
   # GET /product_wastes
   # GET /product_wastes.json
   def index
-    if current_user.usertype == 'A'
-      @product_wastes = ProductWaste.includes(:product, :user, :pointsale, :warehouse).activos
-    elsif current_user.usertype == 'G' || current_user.usertype == 'C'
-      @product_wastes = ProductWaste.includes(:product, :user).where(pointsale_id: current_user.pointsale_id).activos
-    elsif current_user.usertype == 'S'
-      @product_wastes = ProductWaste.includes(:product, :user).where(warehouse_id: current_user.warehouse_id).activos
-    end
+    @product_wastes = ProductWaste.includes(:product, :user, :pointsale, :warehouse).activos
+    @product_wastes =
+      if current_user.usertype == 'G' || current_user.usertype == 'C'
+        @product_wastes.where(pointsale_id: current_user.pointsale_id)
+      elsif current_user.usertype == 'S'
+        @product_wastes.where(warehouse_id: current_user.warehouse_id)
+      else
+        @product_wastes
+      end
   end
 
   # GET /product_wastes/new
@@ -28,20 +30,21 @@ class ProductWastesController < ApplicationController
   # POST /product_wastes
   # POST /product_wastes.json
   def create
-    respond_to do |format|
-      @product_waste = ProductWaste.new(product_waste_params)
-      @product_waste.user_id = current_user.id
-      @product_waste.status = :active
+    @product_waste = ProductWaste.new(product_waste_params)
+    @product_waste.user_id = current_user.id
+    @product_waste.status = :active
 
-      if current_user.usertype == 'S'
-        @product_waste.warehouse_id = current_user.warehouse_id
-        @stock = WarehouseStock.find_by(warehouse_id: @product_waste.warehouse_id, product_id: @product_waste.product_id)
-      else
-        @product_waste.pointsale_id = current_user.pointsale_id
-        @stock = AvailableProduct.find_by(pointsale_id: @product_waste.pointsale_id, product_id: @product_waste.product_id)
-      end
+    if current_user.usertype == 'S'
+      @product_waste.warehouse_id = current_user.warehouse_id
+      @stock = WarehouseStock.find_by(warehouse_id: @product_waste.warehouse_id, product_id: @product_waste.product_id)
+    else
+      @product_waste.pointsale_id = current_user.pointsale_id
+      @stock = AvailableProduct.find_by(pointsale_id: @product_waste.pointsale_id, product_id: @product_waste.product_id)
+    end
+
+    respond_to do |format|
       if @stock.stock >= @product_waste.quantity
-        @product_waste.audit_comment = "Merma del producto #{@product_waste.product.name}  creada"
+        @product_waste.audit_comment = "Merma del producto #{@product_waste.product.name} creada"
         if @product_waste.save
           @stock.stock -= @product_waste.quantity
           @stock.save
@@ -50,31 +53,17 @@ class ProductWastesController < ApplicationController
           format.json { render json: @product_waste.errors.values, status: :unprocessable_entity }
         end
       else
-        @product_waste.errors.add(:base, "Stock insuficiente, solo se cuenta con #{@stock.stock} unidades del producto #{@product_waste.product.name}")
+        @product_waste.errors.add(:base, "Stock insuficiente, sólo se cuenta con #{@stock.stock} unidades del producto #{@product_waste.product.name}")
         format.json { render json: @product_waste.errors.values, status: :unprocessable_entity }
       end
     end
   end
 
-  # PATCH/PUT /product_wastes/1
-  # PATCH/PUT /product_wastes/1.json
-  def update
-    respond_to do |format|
-      if @product_waste.update(product_waste_params)
-        format.html { redirect_to @product_waste, notice: 'Product waste was successfully updated.' }
-        format.json { render :show, status: :ok, location: @product_waste }
-      else
-        format.html { render :edit }
-        format.json { render json: @product_waste.errors, status: :unprocessable_entity }
-      end
-    end
-  end
-
   # DELETE /product_wastes/1
   # DELETE /product_wastes/1.json
   def destroy
     respond_to do |format|
-      @product_waste.audit_comment = "Merma del producto #{@product_waste.product.name}  eliminada."
+      @product_waste.audit_comment = "Merma del producto #{@product_waste.product.name} eliminada."
       if @product_waste.update_attributes(status: :inactive)
         @stock = current_user.usertype == "S" ? WarehouseStock.find_by(warehouse_id: @product_waste.warehouse_id, product_id: @product_waste.product_id) : AvailableProduct.find_by(pointsale_id: @product_waste.pointsale_id, product_id: @product_waste.product_id)
         @stock.stock = @stock.stock + @product_waste.quantity

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 5 - 1
app/controllers/products_controller.rb


+ 1 - 1
app/controllers/products_returns_controller.rb

@@ -12,7 +12,7 @@ class ProductsReturnsController < ApplicationController
   # GET /products_returns
   # GET /products_returns.json
   def index
-    @products_returns = current_user.usertype == 'A' ? ProductsReturn.all.includes(:sale, :user, :pointsale) : Pointsale.find(current_user.pointsale_id).products_returns.includes(:sale, :user).order(" products_returns.id DESC ")
+    @products_returns = current_user.usertype == "A" || current_user.usertype == "SS" ? ProductsReturn.all.includes(:sale, :user, :pointsale) : Pointsale.find(current_user.pointsale_id).products_returns.includes(:sale, :user).order(" products_returns.id DESC ")
   end
 
   # GET /products_returns/1

+ 86 - 102
app/controllers/purchases_controller.rb

@@ -1,13 +1,12 @@
 class PurchasesController < ApplicationController
-
   ##--- Abilities
   load_and_authorize_resource
 
   ##--- Breadcrum_rails
   add_breadcrumb I18n.t("breadcrumbs." + controller_name), :purchases_path
   add_breadcrumb "Nueva " + I18n.t("breadcrumbs." + controller_name).singularize, :new_purchase_path, only: :new
-  add_breadcrumb "Detalle de la " + I18n.t("breadcrumbs." + controller_name).singularize , :purchase_path, only: :show
-  add_breadcrumb "Editar " + I18n.t("breadcrumbs." + controller_name).singularize , :edit_purchase_path, only: :edit
+  add_breadcrumb "Detalle de la " + I18n.t("breadcrumbs." + controller_name).singularize, :purchase_path, only: :show
+  add_breadcrumb "Editar " + I18n.t("breadcrumbs." + controller_name).singularize, :edit_purchase_path, only: :edit
 
   before_action :set_purchase, only: [:show, :edit, :update, :destroy]
   before_action :get_filters, only: [:index, :show, :edit, :new]
@@ -15,17 +14,17 @@ class PurchasesController < ApplicationController
   # GET /purchases
   # GET /purchases.json
   def index
-    if current_user.usertype == "A"
-      @purchases = Purchase.all.includes(:supplier, :pointsale, :warehouse, :user).order("created_at DESC")
-    else
-      @purchases = Purchase.includes(:supplier, :user).where(:pointsale_id => current_user.pointsale_id).order('created_at desc')
-    end
+    @purchases =
+      if current_user.usertype == "A" || current_user.usertype == "SS"
+        Purchase.all.includes(:supplier, :pointsale, :warehouse, :user).order("created_at DESC")
+      else
+        Purchase.includes(:supplier, :user).where(pointsale_id: current_user.pointsale_id).order('created_at desc')
+      end
   end
 
   # GET /purchases/1
   # GET /purchases/1.json
-  def show
-  end
+  def show; end
 
   # GET /purchases/new
   def new
@@ -38,18 +37,18 @@ class PurchasesController < ApplicationController
     @destiny = 'warehouse'
     @purchase = Purchase.new
     @purchase.purchase_details.new
-    @pre_purchases = PrePurchase.where(:user_id => current_user.id)
-    if @pre_purchases.size > 0
+    @pre_purchases = PrePurchase.where(user_id: current_user.id)
+    unless @pre_purchases.empty?
       @purchase.supplier_id = @pre_purchases[0].supplier_id
       @purchase.pointsale_id = @pre_purchases[0].pointsale_id
-      @purchase.warehouse_id =  @pre_purchases[0].warehouse_id
+      @purchase.warehouse_id = @pre_purchases[0].warehouse_id
       @destiny = @purchase.pointsale_id.present? ? 'pointsale' : 'warehouse'
       @purchase.exchange = @pre_purchases[0].exchange if @pre_purchases[0].exchange.present?
       @purchase.is_in_dollars = true if @pre_purchases[0].exchange.present?
       @disable_supplier = true
       @disable_pointsale = true
       @disable_warehouse = true
-      @disable_is_in_dollars =  true
+      @disable_is_in_dollars = true
       @disable_destiny = true
       @disabled_button = false
     end
@@ -68,7 +67,7 @@ class PurchasesController < ApplicationController
     @purchase = Purchase.new(purchase_params)
     @purchase.user_id = current_user.id
     @purchase.status = :notpaid
-    @pre_purchases = PrePurchase.where(:user_id => current_user.id)
+    @pre_purchases = PrePurchase.where(user_id: current_user.id)
 
     respond_to do |format|
       message = "compra #{@purchase.purchase_code} por #{@purchase.total} creada."
@@ -76,51 +75,7 @@ class PurchasesController < ApplicationController
       if @purchase.save
         @pre_purchases.each do |pre_purchase|
           # agregar detalles de la compra
-          detail = PurchaseDetail.new
-          detail.product_id = pre_purchase.product_id
-          detail.quantity = pre_purchase.quantity
-          detail.amount = pre_purchase.total
-          detail.price = pre_purchase.price_base
-          detail.tax = pre_purchase.tax
-          @purchase.purchase_details << detail
-          # actualizar stock del producto cuando es para punto de venta
-          if @purchase.pointsale_id.present?
-            stockProduct = AvailableProduct.find_by(:product_id => detail.product_id, :pointsale_id => @purchase.pointsale_id)
-            if stockProduct.present?
-              stockProduct.stock = 0 if stockProduct.stock.blank?
-              stockProduct.stock += detail.quantity
-              stockProduct.save
-            else
-              stockProduct = AvailableProduct.new
-              stockProduct.product_id = detail.product_id
-              stockProduct.pointsale_id = @purchase.pointsale_id
-              stockProduct.stock = detail.quantity
-              stockProduct.save
-            end
-          else
-            # actualizar stock del producto cuando es para punto de venta
-            stockProduct = WarehouseStock.find_by(:product_id => detail.product_id, :warehouse_id => @purchase.warehouse_id)
-            if stockProduct.present?
-              stockProduct.stock = 0 if stockProduct.stock.blank?
-              stockProduct.stock += detail.quantity
-              stockProduct.save
-            else
-              stockProduct = WarehouseStock.new
-              stockProduct.product_id = detail.product_id
-              stockProduct.warehouse_id = @purchase.warehouse_id
-              stockProduct.stock = detail.quantity
-              stockProduct.save
-            end
-          end
-          # guardar en bitacora de inventario
-          move = InventoriesMove.new
-          move.product_id = detail.product_id
-          move.purchase_id = @purchase.id
-          move.quantity = detail.quantity
-          move.move_type = "incoming"
-          move.reason = "purchase"
-          move.save
-
+          create_purchase_details(@purchase, pre_purchase)
           pre_purchase.destroy
         end
         format.html { redirect_to purchases_url, success: message }
@@ -137,34 +92,15 @@ class PurchasesController < ApplicationController
     respond_to do |format|
       message = "Compra #{@purchase.purchase_code} cancelada."
       @purchase.audit_comment = message
-      if @purchase.update_attributes(:status => :cancelled)
-        #checa si hay pagos de esta compra
-        CashRegistersMove.where(:purchase_id => @purchase.id).each do |move|
+      if @purchase.update_attributes(status: :cancelled)
+        # checa si hay pagos de esta compra
+        CashRegistersMove.where(purchase_id: @purchase.id).each do |move|
           new_cash_move = move.dup
           new_cash_move.move_type = :ingreso
           new_cash_move.save
         end
-
         @purchase.purchase_details.each do |detail|
-          detail.update_attributes(:status => :inactive)
-          #busca y actualiza el stock de productos
-          if @purchase.pointsale.present?
-            stockProduct = AvailableProduct.find_by(:product_id => detail.product_id, :pointsale_id => @purchase.pointsale_id)
-          else
-            stockProduct = WarehouseStock.find_by(:product_id => detail.product_id, :warehouse_id => @purchase.warehouse_id)
-          end
-          # restarle al stock del producto
-          stock = stockProduct.stock - detail.quantity
-          stockProduct.update_attributes(:stock => stock)
-
-          # guardar en bitacora de inventario
-          move = InventoriesMove.new
-          move.product_id = detail.product_id
-          move.purchase_id = @purchase.id
-          move.quantity = detail.quantity
-          move.move_type = "outgoing"
-          move.reason = "purchase_cancel"
-          move.save
+          destroy_purchase_details(@purchase, detail)
         end
         format.html { redirect_to purchases_url, warning: message }
         format.json { head :no_content }
@@ -176,35 +112,83 @@ class PurchasesController < ApplicationController
   end
 
   def find_purchases_by_date
-    startDate = DateTime.parse(params[:begin_date])
-    endDate = DateTime.parse(params[:end_date])
-    if current_user.usertype == "A"
-      @purchases = Purchase.includes(:supplier, :pointsale, :warehouse, :user).where(:purchase_date => startDate..endDate).order('purchase_date desc')
-    else
-      @purchases = Purchase.includes(:supplier, :user).where(:pointsale_id => current_user.pointsale_id, :created_at => startDate..endDate).order('purchase_date desc')
-    end
+    start_date = DateTime.parse(params[:begin_date])
+    end_date = DateTime.parse(params[:end_date])
+    @purchases =
+      if current_user.usertype == "A" || current_user.usertype == "SS"
+        Purchase.includes(:supplier, :pointsale, :warehouse, :user).where(purchase_date: start_date..end_date).order('purchase_date desc')
+      else
+        Purchase.includes(:supplier, :user).where(pointsale_id: current_user.pointsale_id, created_at: start_date..end_date).order('purchase_date desc')
+      end
     respond_to do |format|
       format.js
     end
   end
 
   private
-    # Use callbacks to share common setup or constraints between actions.
-    def set_purchase
-      @purchase = Purchase.find(params[:id])
-    end
 
-    def get_filters
+  # Use callbacks to share common setup or constraints between actions.
+  def set_purchase
+    @purchase = Purchase.find(params[:id])
+  end
+
+  def get_filters
+    @current_page =
       if params[:current_page].blank?
-        @current_page = 1
+        1
       else
-        @current_page = params[:current_page]
+        params[:current_page]
       end
-      @filter = params[:filter]
-    end
+    @filter = params[:filter]
+  end
 
-    # Never trust parameters from the scary internet, only allow the white list through.
-    def purchase_params
-      params.require(:purchase).permit(:supplier_id, :pointsale_id, :warehouse_id ,:purchase_code, :amount, :tax, :total, :observations, :purchase_date, :is_in_dollars, :exchange)
+  def create_purchase_details(purchase, pre_purchase)
+    detail = PurchaseDetail.new(product_id: pre_purchase.product_id, quantity: pre_purchase.quantity, amount: pre_purchase.total, price: pre_purchase.price_base, tax: pre_purchase.tax)
+    purchase.purchase_details << detail
+    # actualizar stock del producto cuando es para punto de venta
+    if purchase.pointsale_id.present?
+      stock_product = AvailableProduct.find_by(product_id: detail.product_id, pointsale_id: purchase.pointsale_id)
+      if stock_product.nil?
+        stock_product = AvailableProduct.create(product_id: detail.product_id, pointsale_id: purchase.pointsale_id, stock: detail.quantity)
+      else
+        stock_product = 0 if stock_product.stock.blank?
+        stock_product.stock += detail.quantity
+      end
+    else
+      # actualizar stock del producto cuando es para almacen
+      stock_product = WarehouseStock.find_by(product_id: detail.product_id, warehouse_id: purchase.warehouse_id)
+      if stock_product.nil?
+        stock_product = WarehouseStock.create(product_id: detail.product_id, warehouse_id: purchase.warehouse_id, stock: detail.quantity)
+      else
+        stock_product = 0 if stock_product.stock.blank?
+        stock_product.stock += detail.quantity
+      end
     end
+    stock_product.save
+
+    # guardar en bitacora de inventario
+    InventoriesMove.create(product_id: detail.product_id, purchase_id: purchase.id, quantity: detail.quantity, move_type: "incoming", reason: "purchase")
+  end
+
+  def destroy_purchase_details(purchase, purchase_detail)
+    purchase_detail.update_attributes(status: :inactive)
+    # busca y actualiza el stock de productos
+    stock_product =
+      if purchase.pointsale.present?
+        AvailableProduct.find_by(product_id: purchase_detail.product_id, pointsale_id: purchase.pointsale_id)
+      else
+        WarehouseStock.find_by(product_id: purchase_detail.product_id, warehouse_id: purchase.warehouse_id)
+      end
+    # restarle al stock del producto
+    stock = stock_product.stock - purchase_detail.quantity
+    stock_product.update_attributes(stock: stock)
+
+    # guardar en bitacora de inventario
+    InventoriesMove.create(product_id: purchase_detail.product_id, purchase_id: purchase.id, quantity: purchase_detail.quantity, move_type: "outgoing", reason: "purchase_cancel")
+  end
+
+  # Never trust parameters from the scary internet, only allow the white list through.
+  def purchase_params
+    params.require(:purchase).permit(:supplier_id, :pointsale_id, :warehouse_id, :purchase_code, :amount, :tax, :total, :observations, :purchase_date, :is_in_dollars, :exchange)
+  end
 end

+ 35 - 35
app/controllers/sales_controller.rb

@@ -15,13 +15,13 @@ class SalesController < ApplicationController
   def index
     today = Date.current
     thirty_day_ago = today - 30
-    @sales = current_user.usertype == 'A' ? Sale.includes(:customer, :user, :seller, :sales_details).where(date_sale: thirty_day_ago..today).where.not(saletype: 2).order(" created_at DESC ") : Pointsale.find(current_user.pointsale_id).sales.includes(:customer, :user, :seller).where(date_sale: thirty_day_ago..today).where.not(saletype: 2).order("created_at DESC")
+    @sales = current_user.usertype == "A" || current_user.usertype == "SS" ? Sale.includes(:customer, :user, :seller, :sales_details).where(date_sale: thirty_day_ago..today).where.not(saletype: 2).order(" created_at DESC ") : Pointsale.find(current_user.pointsale_id).sales.includes(:customer, :user, :seller).where(date_sale: thirty_day_ago..today).where.not(saletype: 2).order("created_at DESC")
   end
 
   def sales_reserved
     beg_of_month = Date.current.beginning_of_month
     end_of_month = Date.current.end_of_month
-    @sales = current_user.usertype == 'A' ? Sale.where(saletype: 2).order(" created_at DESC ") : Pointsale.find(current_user.pointsale_id).sales.where(saletype: 2).order(" created_at DESC")
+    @sales = current_user.usertype == "A" || current_user.usertype == "SS" ? Sale.where(saletype: 2).order(" created_at DESC ") : Pointsale.find(current_user.pointsale_id).sales.where(saletype: 2).order(" created_at DESC")
   end
 
   # GET /sales/1
@@ -193,7 +193,7 @@ class SalesController < ApplicationController
       start_date = Date.today.beginning_of_month
       end_date = Date.today.end_of_month
     end
-    @sales = current_user.usertype == 'A' ? Sale.includes(:customer, :user, :seller, :sales_details).where(date_sale: start_date..end_date).where.not(saletype: 2).order(" created_at DESC ") : Pointsale.find(current_user.pointsale_id).sales.includes(:customer, :user, :seller, :sales_details).where(date_sale: start_date..end_date).where.not(saletype: 2).order(" created_at DESC ")
+    @sales = current_user.usertype == "A" || current_user.usertype == "SS" ? Sale.includes(:customer, :user, :seller, :sales_details).where(date_sale: start_date..end_date).where.not(saletype: 2).order(" created_at DESC ") : Pointsale.find(current_user.pointsale_id).sales.includes(:customer, :user, :seller, :sales_details).where(date_sale: start_date..end_date).where.not(saletype: 2).order(" created_at DESC ")
     respond_to do |format|
       format.js
     end
@@ -223,7 +223,7 @@ class SalesController < ApplicationController
       start_date = Date.today.beginning_of_month
       end_date = Date.today.end_of_month
     end
-    @sales = current_user.usertype == 'A' ? Sale.includes(:customer, :user, :seller, :sales_details).where(date_sale: start_date..end_date, saletype: 2).order(" created_at DESC ") : Pointsale.find(current_user.pointsale_id).sales.includes(:customer, :user, :seller, :sales_details).where(date_sale: start_date..end_date).where(saletype: 2).order(" created_at DESC ")
+    @sales = current_user.usertype == "A" || current_user.usertype == "SS" ? Sale.includes(:customer, :user, :seller, :sales_details).where(date_sale: start_date..end_date, saletype: 2).order(" created_at DESC ") : Pointsale.find(current_user.pointsale_id).sales.includes(:customer, :user, :seller, :sales_details).where(date_sale: start_date..end_date).where(saletype: 2).order(" created_at DESC ")
 
     respond_to do |format|
       format.js
@@ -366,38 +366,38 @@ class SalesController < ApplicationController
   end
 
   def sales_per_month
-    respond_to do |format|
-      # start_date = DateTime.parse(params[:start_date])
-      # end_date = DateTime.parse(params[:end_date])
-      start_date = DateTime.parse(params[:start_date]).in_time_zone(Time.zone).beginning_of_day + 1.days
-      end_date = DateTime.parse(params[:end_date]).in_time_zone(Time.zone).end_of_day + 1.days
-      @cash_sales_total = 0
-      @reserved_sales_total = 0
-      @credit_sales_total = 0
-
-      if params[:pointsale_id].present?
-        @pointsale = Pointsale.find(params[:pointsale_id])
-        @incomes_in_period = @pointsale.cash_registers_moves.joins(:sale).where(move_type: '1', created_at: start_date..end_date)
-        @sales = @pointsale.sales.activas.where(created_at: start_date..end_date).order("id DESC")
-      else
-        @incomes_in_period = CashRegistersMove.joins(:sale).where(move_type: '1', created_at: start_date..end_date)
-        @sales = Sale.activas.where(created_at: start_date..end_date).order("id DESC")
-      end
+    # start_date = DateTime.parse(params[:start_date])
+    # end_date = DateTime.parse(params[:end_date])
+    start_date = DateTime.parse(params[:start_date]).in_time_zone(Time.zone).beginning_of_day + 1.days
+    end_date = DateTime.parse(params[:end_date]).in_time_zone(Time.zone).end_of_day + 1.days
+    @cash_sales_total = 0
+    @reserved_sales_total = 0
+    @credit_sales_total = 0
+
+    if params[:pointsale_id].present?
+      @pointsale = Pointsale.find(params[:pointsale_id])
+      @incomes_in_period = @pointsale.cash_registers_moves.joins(:sale).where(move_type: '1', created_at: start_date..end_date)
+      @sales = @pointsale.sales.includes(:sales_details, :user, :seller).activas.where(created_at: start_date..end_date).order("id DESC")
+    else
+      @incomes_in_period = CashRegistersMove.joins(:sale).where(move_type: '1', created_at: start_date..end_date)
+      @sales = Sale.includes(:sales_details, :user, :seller).activas.where(created_at: start_date..end_date).order("id DESC")
+    end
 
-      @sales_quantity = @sales.size
-      @prods_total = SalesDetail.where("sale_id IN (?)", @sales.pluck(:id)).sum(:quantity).round
-      # @cash_sales_income = CashRegistersMove.activos.where("sale_id IN (?)", @sales.where(saletype: 1).pluck(:id)).where(created_at: start_date..end_date).sum(:quantity)
-      # @reserved_sales_income = CashRegistersMove.activos.where("sale_id IN (?)", @sales.where(saletype: 2).pluck(:id)).where(created_at: start_date..end_date).sum(:quantity)
-      # @credit_sales_income = CashRegistersMove.activos.where("sale_id IN (?)", @sales.where(saletype: 0).pluck(:id)).where(created_at: start_date..end_date).sum(:quantity)
-      @cash_sales_income = @incomes_in_period.where('sales.saletype = 1').sum(:quantity)
-      @reserved_sales_income = @incomes_in_period.where('sales.saletype = 2').sum(:quantity)
-      @credit_sales_income = @incomes_in_period.where('sales.saletype = 0').sum(:quantity)
-      @sales_income = @incomes_in_period.sum(:quantity)
-
-      @cash_sales_total = @sales.where(saletype: 1).sum(:total)
-      @reserved_sales_total = @sales.where(saletype: 2).sum(:total)
-      @credit_sales_total = @sales.where(saletype: 0).sum(:total)
-      @sales_total = @sales.sum(:total)
+    @sales_quantity = @sales.size
+    @prods_total = SalesDetail.where("sale_id IN (?)", @sales.pluck(:id)).sum(:quantity).round
+    # @cash_sales_income = CashRegistersMove.activos.where("sale_id IN (?)", @sales.where(saletype: 1).pluck(:id)).where(created_at: start_date..end_date).sum(:quantity)
+    # @reserved_sales_income = CashRegistersMove.activos.where("sale_id IN (?)", @sales.where(saletype: 2).pluck(:id)).where(created_at: start_date..end_date).sum(:quantity)
+    # @credit_sales_income = CashRegistersMove.activos.where("sale_id IN (?)", @sales.where(saletype: 0).pluck(:id)).where(created_at: start_date..end_date).sum(:quantity)
+    @cash_sales_income = @incomes_in_period.where('sales.saletype = ?', 1).sum(:quantity)
+    @reserved_sales_income = @incomes_in_period.where('sales.saletype = ?', 2).sum(:quantity)
+    @credit_sales_income = @incomes_in_period.where('sales.saletype = ?', 0).sum(:quantity)
+    @sales_income = @incomes_in_period.sum(:quantity)
+
+    @cash_sales_total = @sales.where(saletype: 1).sum(:total)
+    @reserved_sales_total = @sales.where(saletype: 2).sum(:total)
+    @credit_sales_total = @sales.where(saletype: 0).sum(:total)
+    @sales_total = @sales.sum(:total)
+    respond_to do |format|
       format.js
     end
   end

+ 39 - 41
app/controllers/sellers_controller.rb

@@ -8,25 +8,24 @@ class SellersController < ApplicationController
 
   ##--- Breadcrum_rails
   add_breadcrumb I18n.t("breadcrumbs." + controller_name), :sellers_path
-  add_breadcrumb "Nuevo vendedor " , :new_seller_path, only: :new
-  add_breadcrumb "Detalle del vendedor "  , :seller_path, only: :show
-  add_breadcrumb "Editar vendedor "  , :edit_seller_path, only: :edit
+  add_breadcrumb "Nuevo vendedor ", :new_seller_path, only: :new
+  add_breadcrumb "Detalle del vendedor ", :seller_path, only: :show
+  add_breadcrumb "Editar vendedor ", :edit_seller_path, only: :edit
 
   # GET /sellers
   # GET /sellers.json
   def index
-    @sellers = (current_user.usertype == "A" ? Seller.vigentes.includes(:pointsale) : Seller.where(:pointsale_id => current_user.pointsale_id).vigentes)
+    @sellers = current_user.usertype == "A" || current_user.usertype == "SS" ? Seller.vigentes.includes(:pointsale) : Seller.where(pointsale_id: current_user.pointsale_id).vigentes
   end
 
   # GET /sellers/1
   # GET /sellers/1.json
-  def show
-  end
+  def show; end
 
   # GET /sellers/new
   def new
     @seller = Seller.new
-    if current_user.usertype != "A"
+    if current_user.usertype != "A" || current_user.usertype != "SS"
       @pointsale_id = current_user.pointsale_id
     end
   end
@@ -40,7 +39,7 @@ class SellersController < ApplicationController
   # POST /sellers.json
   def create
     @seller = Seller.new(seller_params)
-    if current_user.usertype != "A"
+    unless current_user.usertype == "A" || current_user.usertype == "SS"
       @seller.skip_pointsale = true
       @seller.pointsale_id = current_user.pointsale_id
     end
@@ -48,10 +47,10 @@ class SellersController < ApplicationController
       message = "El vendedor " + @seller.full_name + " fue registrado."
       @seller.audit_comment = message
       if @seller.save
-        format.html { redirect_to sellers_path, success: message }
-        format.json { render :show, status: :created, location: @seller }
+        format.js
       else
         format.html { render :new }
+        format.js
         format.json { render json: @seller.errors, status: :unprocessable_entity }
       end
     end
@@ -64,10 +63,10 @@ class SellersController < ApplicationController
       message = "El vendedor " + @seller.full_name + " fue modificado."
       @seller.audit_comment = message
       if @seller.update(seller_params)
-        format.html { redirect_to sellers_path, success: message }
-        format.json { render :show, status: :ok, location: @seller }
+        format.js
       else
         format.html { render :edit }
+        format.js
         format.json { render json: @seller.errors, status: :unprocessable_entity }
       end
     end
@@ -75,15 +74,16 @@ class SellersController < ApplicationController
 
   def update_status
     seller = Seller.find(params[:seller_id])
-    if seller.active?
-      seller.status = 2
-    elsif seller.inactive?
-      seller.status = 1
-    end
+    seller.status =
+      if seller.active?
+        2
+      elsif seller.inactive?
+        1
+      end
     respond_to do |format|
-      message = "El vendedor " + seller.full_name + " " + seller.last_name + " fue "+ (seller.active? ? "activado" : "desactivado")+"."
+      message = "El vendedor " + seller.full_name + " fue " + (seller.active? ? "activado" : "desactivado") + "."
       seller.audit_comment = message
-      if seller.save(:validate => false)
+      if seller.save(validate: false)
         format.html { redirect_to sellers_url, warning: message }
         format.json { head :no_content }
       else
@@ -99,7 +99,7 @@ class SellersController < ApplicationController
     respond_to do |format|
       message = "El vendedor " + @seller.full_name + " fue eliminado."
       @seller.audit_comment = message
-      if @seller.update_attributes(:status => 0)
+      if @seller.update_attributes(status: 0)
         format.html { redirect_to sellers_path, warning: message }
         format.json { head :no_content }
       else
@@ -109,30 +109,28 @@ class SellersController < ApplicationController
     end
   end
 
-
-
   private
-    # Use callbacks to share common setup or constraints between actions.
-    def set_seller
-      @seller = Seller.find(params[:id])
-    end
+  # Use callbacks to share common setup or constraints between actions.
+  def set_seller
+    @seller = Seller.find(params[:id])
+  end
 
-    # Never trust parameters from the scary internet, only allow the white list through.
-    def seller_params
-      params.require(:seller).permit(:pointsale_id, :name, :last_name)
-    end
+  # Never trust parameters from the scary internet, only allow the white list through.
+  def seller_params
+    params.require(:seller).permit(:pointsale_id, :name, :last_name)
+  end
 
-    def get_filters
-      if params[:current_page].blank?
-        @current_page = 1
-      else
-        @current_page = params[:current_page]
-      end
-      @filter = params[:filter]
+  def get_filters
+    if params[:current_page].blank?
+      @current_page = 1
+    else
+      @current_page = params[:current_page]
     end
+    @filter = params[:filter]
+  end
 
-    def get_info
-      @users = (current_user.usertype == "A" ? User.active : User.active.where(:pointsale_id => current_user.pointsale_id))
-      @pointsales = Pointsale.activos
-    end
+  def get_info
+    @users = (current_user.usertype == "A" || current_user.usertype == "SS" ? User.active : User.active.where(pointsale_id: current_user.pointsale_id))
+    @pointsales = Pointsale.activos
+  end
 end

+ 1 - 1
app/controllers/special_prices_controller.rb

@@ -5,7 +5,7 @@ class SpecialPricesController < ApplicationController
   ##--- Breadcrum_rails
   add_breadcrumb "Nuevo precio(s) especial", :new_special_price_path, only: :new
 
-  before_action :set_special_price, only: [:show, :edit, :update, :destroy]
+  before_action :set_special_price, only: [:update, :destroy]
 
   # GET /special_prices/new
   def new

+ 1 - 1
app/controllers/transfers_controller.rb

@@ -16,7 +16,7 @@ class TransfersController < ApplicationController
   # GET /transfers.json
   def index
     @transfers = Transfer.includes(:user, :received_by, :transfer_details).all.order('id DESC, transfer_date DESC')
-    unless current_user.usertype == "A"
+    unless current_user.usertype == "A" || current_user.usertype == "SS"
       is_destiny =
         if current_user.usertype == "S"
           id_filter = current_user.warehouse_id

+ 26 - 7
app/controllers/users_controller.rb

@@ -9,11 +9,16 @@ class UsersController < ApplicationController
   before_action :get_filters, only: [:index, :show, :edit, :new]
 
   def index
-    @users = current_user.usertype == 'A' ? User.includes(:pointsale, :warehouse).where('status > 0').order("id desc") : User.includes(:pointsale, :warehouse).where('status > 0 and pointsale_id = ?', current_user.pointsale_id).order("id desc")
+    @users = User.includes(:pointsale, :warehouse).vigentes
+    if current_user.usertype != "SS"
+      @users = @users.where.not(usertype: "SS")
+      @users = @users.where(pointsale_id: current_user.pointsale_id) if current_user.usertype != "A"
+    end
   end
 
   def new
     @user = User.new
+    set_usertypes
   end
 
   def edit; end
@@ -36,17 +41,20 @@ class UsersController < ApplicationController
   def create
     @user = User.new(user_params)
     respond_to do |format|
-      message =
-        if @user.usertype == 'A'
-          "usuario #{@user.userid} con perfil ADMINISTRADOR creado."
-        else
-          "Usuario #{@user.userid} creado y asignado al " + (@user.pointsale.present? ? "punto de venta #{@user.pointsale.name}" : "almacén #{@user.warehouse.name}")
-        end
+      message = "Usuario #{@user.userid}"
+      if @user.usertype == 'SS'
+        message += " con perfil SUPER ADMINISTRADOR creado."
+      elsif @user.usertype == "A"
+        message += " con perfil ADMINISTRADOR creado."
+      else
+        message += " creado y asignado al " + (@user.pointsale.present? ? "punto de venta #{@user.pointsale.name}" : "almacén #{@user.warehouse.name}")
+      end
       @user.audit_comment = message
       if @user.save
         format.html { redirect_to users_path, success: message }
         format.json { render :show, status: :created, location: @user }
       else
+        set_usertypes
         format.html { render :new }
         format.json { render json: @user.errors, status: :unprocessable_entity }
       end
@@ -95,6 +103,17 @@ class UsersController < ApplicationController
     end
   end
 
+  def set_usertypes
+    @options_for_select =
+      if current_user.usertype == "SS"
+        Rails.application.config.usertypes_for_super
+      elsif current_user.usertype == "A"
+        Rails.application.config.usertypes_for_admin
+      else
+        Rails.application.config.usertypes_for_manager
+      end
+  end
+
   private
 
   # Use callbacks to share common setup or constraints between actions.

+ 30 - 30
app/controllers/warehouses_controller.rb

@@ -4,8 +4,8 @@ class WarehousesController < ApplicationController
 
   ##--- Breadcrum_rails
   add_breadcrumb I18n.t("breadcrumbs." + controller_name), :warehouses_path
-  add_breadcrumb "Nuevo Almacén " , :new_warehouse_path, only: :new
-  add_breadcrumb "Editar Almacén"  , :edit_warehouse_path, only: :edit
+  add_breadcrumb "Nuevo Almacén ", :new_warehouse_path, only: :new
+  add_breadcrumb "Editar Almacén", :edit_warehouse_path, only: :edit
 
   before_action :set_warehouse, only: [:show, :edit, :update, :destroy]
   before_action :get_filters, only: [:index, :show, :edit, :new]
@@ -18,8 +18,7 @@ class WarehousesController < ApplicationController
 
   # GET /warehouses/1
   # GET /warehouses/1.json
-  def show
-  end
+  def show; end
 
   # GET /warehouses/new
   def new
@@ -27,8 +26,7 @@ class WarehousesController < ApplicationController
   end
 
   # GET /warehouses/1/edit
-  def edit
-  end
+  def edit; end
 
   # POST /warehouses
   # POST /warehouses.json
@@ -39,10 +37,10 @@ class WarehousesController < ApplicationController
       message = "Almacén #{@warehouse.name} creado."
       @warehouse.audit_comment = message
       if @warehouse.save
-        format.html { redirect_to warehouses_path, success: message }
-        format.json { render :show, status: :created, location: @warehouse }
+        format.js
       else
         format.html { render :new }
+        format.js
         format.json { render json: @warehouse.errors, status: :unprocessable_entity }
       end
     end
@@ -55,10 +53,10 @@ class WarehousesController < ApplicationController
       message = "Almacén #{@warehouse.name} modificado."
       @warehouse.audit_comment = message
       if @warehouse.update(warehouse_params)
-        format.html { redirect_to warehouses_path, success: message }
-        format.json { render :show, status: :ok, location: @warehouse }
+        format.js
       else
         format.html { render :edit }
+        format.js
         format.json { render json: @warehouse.errors, status: :unprocessable_entity }
       end
     end
@@ -78,15 +76,16 @@ class WarehousesController < ApplicationController
 
   def update_status
     warehouse = Warehouse.find(params[:warehouse_id])
-    if warehouse.active?
-      warehouse.status = "inactive"
-    elsif warehouse.inactive?
-      warehouse.status = "active"
-    end
+    warehouse.status =
+      if warehouse.active?
+        "inactive"
+      elsif warehouse.inactive?
+        "active"
+      end
     respond_to do |format|
-      message = "El almacen " + warehouse.name + " fue "+ (warehouse.active? ? "activado" : "desactivado")+"."
+      message = "El almacen " + warehouse.name + " fue " + (warehouse.active? ? "activado" : "desactivado") + "."
       warehouse.audit_comment = message
-      if warehouse.save(:validate => false)
+      if warehouse.save(validate: false)
         format.html { redirect_to warehouses_path, warning: message }
         format.json { head :no_content }
       else
@@ -97,22 +96,23 @@ class WarehousesController < ApplicationController
   end
 
   private
-    # Use callbacks to share common setup or constraints between actions.
-    def set_warehouse
-      @warehouse = Warehouse.find(params[:id])
-    end
+  # Use callbacks to share common setup or constraints between actions.
+  def set_warehouse
+    @warehouse = Warehouse.find(params[:id])
+  end
 
-    def get_filters
+  def get_filters
+    @current_page =
       if params[:current_page].blank?
-        @current_page = 1
+        1
       else
-        @current_page = params[:current_page]
+        params[:current_page]
       end
-      @filter = params[:filter]
-    end
+    @filter = params[:filter]
+  end
 
-    # Never trust parameters from the scary internet, only allow the white list through.
-    def warehouse_params
-      params.require(:warehouse).permit(:name, :status, :prefix)
-    end
+  # Never trust parameters from the scary internet, only allow the white list through.
+  def warehouse_params
+    params.require(:warehouse).permit(:name, :status, :prefix)
+  end
 end

+ 16 - 24
app/datatables/available_products_datatable.rb

@@ -31,7 +31,6 @@ class AvailableProductsDatatable
           '5' => available.stock
         }.compact.reject { |_k, v| v.nil? }
       end
-
     else
       products.map do |product|
         category = product.categories[0]
@@ -49,18 +48,9 @@ class AvailableProductsDatatable
 
   def get_display_name(product)
     name = "<label style='margin-bottom:0px'><strong>#{product.name}</strong></label> <br>"
-
-    if product.display_attributes.present?
-      name += "#{product.display_attributes} <br>"
-    end
-
-    if product.barcode.present?
-      name += "<i class='fa fa-barcode'></i>: #{product.barcode} <br>"
-    end
-
-    if product.description.present?
-      name += "Descripción: #{product.description}"
-    end
+    name += "#{product.display_attributes} <br>" if product.display_attributes.present?
+    name += "<i class='fa fa-barcode'></i>: #{product.barcode} <br>" if product.barcode.present?
+    name += "Descripción: #{product.description}" if product.barcode.present?
     name
   end
 
@@ -69,20 +59,22 @@ class AvailableProductsDatatable
   end
 
   def fetch_products
-    if params[:table] == 'in_pointsale'
-      products = AvailableProduct.activos.where(pointsale_id: params[:id]).activos
-    else
-      products_in_pointsale = @pointsale.products.activos_children.pluck(:id)
-      products = Product.activos_children.where.not(id: products_in_pointsale).order('products.name')
-    end
+    products =
+      if params[:table] == 'in_pointsale'
+        AvailableProduct.joins(:product, :categories).activos.where(pointsale_id: params[:id]).activos
+      else
+        products_in_pointsale = @pointsale.products.activos_children.pluck(:id)
+        Product.joins(:categories).activos_children.where.not(id: products_in_pointsale).order('products.name')
+      end
 
     products = products.page(page).per_page(per_page)
     search = params[:busqueda]
-    name_searched = if search.include? ':'
-                      search[0, search.index(':') - 1]
-                    else
-                      search
-                    end
+    name_searched =
+      if search.include? ':'
+        search[0, search.index(':') - 1]
+      else
+        search
+      end
     unless search.blank?
       products = products.where("products.sku ilike :search or products.name ilike :search", search: "%#{name_searched}%").order('products.name')
       if search.include? ':'

+ 58 - 37
app/datatables/products_datatable.rb

@@ -21,40 +21,61 @@ private
 
   def data
     products.map.with_index do |product, index|
-      if product.img_product?
-        img = product.img_product.url(:medium)
-      else
-        img = "/images/small/missing.png"
-      end
-      is_product_available = product.available_in_pointsale?(@current_user.pointsale_id)
-      product_available = product.get_available_in_pointsale(@current_user.pointsale_id) if is_product_available
-      [
-        (index +1),
-        (image_tag img),
-        "<label>#{product.name} </label> <br>  SKU: <b> #{product.sku} </b>
-          #{ '<i class="fa fa-cubes font-yellow-gold"></i>' if product.is_parent }
-          <br>" + (product.parent_id.nil? ? "" : "<small>#{product.display_attributes}</small><br>") + "<i class='fa fa-barcode'></i>: <b> #{product.barcode} </b>  <br>
-          <p> #{product.description} </p>",
-        (@current_user.usertype == 'A' ? (product.is_in_dollars? ? "#{number_to_currency(product.price_base_dollars, precision: 2)} USD" : "#{number_to_currency(product.price_base, precision: 2)} MXN") : nil),
-        "<h3> #{number_to_currency(product.get_price_sale(@current_user.pointsale_id), precision: 2)}</h3>
-          #{ is_product_available && (product_available && !product_available.price_sale.nil?) && @current_user.usertype == 'G' ? ('Precio de venta base <br>' + number_to_currency(product.price_sale, precision: 2) ) : ''}",
-        product.categories[0].category,
-        product.active? ? "<i class='fa fa-check fa-2 font-green'></i>" : "<i class='fa fa-times fa-2 font-red'></i>",
-        get_actions(@current_user.usertype, product, is_product_available, product_available)
-      ].compact
+      img = product.img_product? ? product.img_product.url(:medium) : img = "/images/small/missing.png"
+      product_available = @current_user.usertype == "A" || @current_user.usertype == "SS" ? nil : product.get_available_in_pointsale(@current_user.pointsale_id)
+      arr = [
+              (index + 1),
+              (image_tag img),
+              display_name(product)
+            ]
+      arr << dollar_price(product) if @current_user.usertype == "A" || @current_user.usertype == "SS"
+      arr << [
+                product_price(product, product_available),
+                product.categories[0].category,
+                product.active? ? "<i class='fa fa-check fa-2 font-green'></i>" : "<i class='fa fa-times fa-2 font-red'></i>",
+                get_actions(product, product_available)
+              ]
+      arr.flatten
+    end
+  end
+
+  def display_name(product)
+    display_product = "<label>#{product.name} </label> <br>  SKU: <b> #{product.sku} </b>"
+    display_product += "<i class='fa fa-cubes font-yellow-gold'></i>" if product.is_parent
+    display_product += "<br>" + (product.parent_id.nil? ? "" : "<small>#{product.display_attributes}</small><br>") + "<i class='fa fa-barcode'></i>: <b> #{product.barcode} </b> <br>"
+    display_product += "<p> #{product.description} </p>"
+    display_product
+  end
+
+  def dollar_price(product)
+    if @current_user.usertype == "A" || @current_user.usertype == "SS"
+      product.is_in_dollars? ? "#{number_to_currency(product.price_base_dollars, precision: 2)} USD" : "#{number_to_currency(product.price_base, precision: 2)} MXN"
+    else
+      '.'
     end
   end
 
+  def product_price(product, product_available)
+    if @current_user.usertype == "G"
+      price_sale = product_available.present? && product_available.price_sale.present? ? product_available.price_sale : product.price_sale
+      price = "<h3> #{number_to_currency(price_sale, precision: 2)}</h3>"
+      price += 'Precio de venta base <br>' + number_to_currency(product.price_sale, precision: 2)
+    else
+      ''
+    end
+  end
 
   def products
     @products ||= fetch_products
   end
 
   def fetch_products
-    products = Product.vigentes_parents.includes(:categories)
-    if @current_user.usertype == 'G'
-      products = Product.activos_children
-    end
+    products =
+      if @current_user.usertype == 'G'
+        Product.activos_children
+      else
+        Product.vigentes_parents.includes(:categories)
+      end
     products = products.page(page).per_page(per_page)
     unless params[:busqueda].blank?
       products = products.where("sku ilike :search or name ilike :search", search: "%#{params[:busqueda]}%")
@@ -63,7 +84,7 @@ private
   end
 
   def page
-    params[:start].to_i/per_page + 1
+    params[:start].to_i / per_page + 1
   end
 
   def per_page
@@ -79,19 +100,19 @@ private
     params[:sSortDir_0] == "desc" ? "desc" : "asc"
   end
 
-  def get_actions(usertype, product, is_product_available, product_available)
+  def get_actions(product, product_available)
     links = '<div class="clearfix">'
-    links += link_to(fa_icon('search'), product, {class: 'btn btn-icon-only default filtros', :title=>"Ver producto"})
+    links += link_to(fa_icon('search'), product, { class: 'btn btn-icon-only default filtros', title: "Ver producto" })
 
-    if usertype == 'G'
-      links += (link_to(fa_icon('dollar'), available_product_edit_price_path(product_available), { :remote => true, class: 'btn btn-icon-only green-dark', :title=>"Cambiar precio"})) if is_product_available
-    elsif usertype == 'A'
-      links += link_to(fa_icon('edit'), edit_product_path(product), {class: 'btn btn-icon-only btn-primary filtros', :title=>"Modificar producto"})
-      links += link_to(fa_icon('copy'), product_edit_variants_path(product.id), {:class => 'btn btn-icon-only btn-info filtros', :title=>"Modificar variantes del producto"}) if product.presentation
-      links += link_to(fa_icon('list-alt'), product_prices_path(product),  {:remote => true, :class => 'btn btn-icon-only green-dark', :title=>"Precios en punto de venta"})
-      links += (link_to(fa_icon('toggle-off'), product_update_status_path(product),  :class => 'btn btn-icon-only default', :title=>"Desactivar producto", data: { confirm: '¿Esta seguro de desactivar el producto?', method: 'post'})) if product.active?
-      links += (link_to(fa_icon('toggle-on'), product_update_status_path(product),  :class => 'btn btn-icon-only green-jungle', :title=>"Activar producto", data: { confirm: '¿Esta seguro de activar el producto?', method: 'post'})) if product.inactive?
-      links += (link_to(fa_icon('trash-o'), product, :class => 'btn btn-icon-only btn-danger', :title=>"Eliminar producto", data: { confirm: '¿Esta seguro de eliminar el producto?', method: :delete})) if product.can_be_deleted?
+    if @current_user.usertype == 'G'
+      links += (link_to(fa_icon('dollar'), available_product_edit_price_path(product_available), { remote: true, class: 'btn btn-icon-only green-dark', title: "Cambiar precio" })) if product_available
+    elsif @current_user.usertype == "A" || @current_user.usertype == "SS"
+      links += link_to(fa_icon('edit'), edit_product_path(product), { class: 'btn btn-icon-only btn-primary filtros', title: "Modificar producto" })
+      links += link_to(fa_icon('copy'), product_edit_variants_path(product.id), { class: 'btn btn-icon-only btn-info filtros', title: "Modificar variantes del producto" }) if product.presentation
+      links += link_to(fa_icon('list-alt'), product_prices_path(product), { remote: true, class: 'btn btn-icon-only green-dark', title: "Precios en punto de venta" })
+      links += (link_to(fa_icon('toggle-off'), product_update_status_path(product), class: 'btn btn-icon-only default', title: "Desactivar producto", data: { confirm: '¿Está seguro de desactivar el producto?', method: 'post' })) if product.active?
+      links += (link_to(fa_icon('toggle-on'), product_update_status_path(product), class: 'btn btn-icon-only green-jungle', title: "Activar producto", data: { confirm: '¿Está seguro de activar el producto?', method: 'post' })) if product.inactive?
+      links += (link_to(fa_icon('trash-o'), product, class: 'btn btn-icon-only btn-danger', title: "Eliminar producto", data: { confirm: '¿Esta seguro de eliminar el producto?', method: :delete })) if product.can_be_deleted?
     end
     links += '</div>'
     return links

+ 17 - 0
app/helpers/pointsales_helper.rb

@@ -3,4 +3,21 @@ module PointsalesHelper
 		(pointsale.users.blank? ? pointsale.users.new : pointsale.users)
 		pointsale
 	end
+
+  def pointsale_status(pointsale)
+    case pointsale.status
+    when "active" then
+      content_tag(:i, "", class: "fa fa-check font-green")
+    when "inactive" then
+      content_tag(:i, "", class: "fa fa-times font-red")
+    end
+  end
+
+  def product_count(count)
+    if count > 0
+      content_tag(:i, "", class: "fa fa-check font-green")
+    else
+      content_tag(:i, "", class: "fa fa-times font-red")
+    end
+  end
 end

+ 12 - 0
app/helpers/purchases_helper.rb

@@ -1,2 +1,14 @@
 module PurchasesHelper
+  def purchase_status(purchase)
+    case purchase.status
+    when "paid"
+      content_tag(:span, "Pagada", class: "label label-sm label-success")
+    when "cancelled"
+      content_tag(:span, "Cancelada", class: "label label-sm label-danger")
+    when "parcial"
+      content_tag(:span, "Abonada", class: "label label-sm label-warning")
+    when "notpaid"
+      content_tag(:span, "Pte. de pago", class: "label label-sm label-default")
+    end
+  end
 end

+ 23 - 0
app/helpers/users_helper.rb

@@ -1,2 +1,25 @@
 module UsersHelper
+  def usertype(user)
+    case user.usertype
+    when "SS" then
+      content_tag(:span, "Super Administrador", class: "label label-danger")
+    when "A" then
+      content_tag(:span, "Administrador", class: "label label-danger", style: "font-size:100%")
+    when "G" then
+      content_tag(:span, "Gerente", class: "label label-warning", style: "font-size:85%")
+    when "C" then
+      content_tag(:span, "Caja", class: "label label-info")
+    when "S" then
+      content_tag(:span, "Almacenista", class: "label label-info")
+    end
+  end
+
+  def user_status(user)
+    case user.status
+    when "active" then
+      content_tag(:span, "", class: "fa fa-check fa-2 font-green")
+    when "inactive" then
+      content_tag(:span, "", class: "fa fa-times fa-2 font-red")
+    end
+  end
 end

+ 9 - 5
app/models/ability.rb

@@ -32,14 +32,14 @@ class Ability
 
     user ||= User.new
 
-    if user.usertype == "A"
+    if user.usertype == "A" || user.usertype == "SS"
       # Cajas registradoras
-      can :read, [CashRegister, Purchase, PaymentMethod, ProductsReturn]
+      can :read, [CashRegister, Purchase, PaymentMethod, ProductsReturn, CashOut]
       # Categorias
-      can :manage, [Category, Customer, BillingInformation, Expensesconcept, Pointsale, Product, Supplier, Unit, Sale, PosConfig, Purchase, SpecialPrice, ProductWaste, Seller, CashOut, Transfer, Expense, User, Warehouse, Commission, Sellerscommission]
-
+      can :manage, [Category, Customer, BillingInformation, Expensesconcept, Pointsale, Product, Supplier, Unit, Sale, PosConfig, Purchase, SpecialPrice, ProductWaste, Seller, Transfer, Expense, User, Warehouse, Commission, Sellerscommission]
+      can [:opened_cash_registers, :find_cash_outs_by_date], CashOut
       cannot [:create, :delete, :liquidate_reserve], Sale
-
+      cannot :create, ProductWaste
     elsif user.usertype == "G"
       # Cajas registradoras
       can :manage, [CashRegister, Purchase, Product, PrePurchase, Seller, Sale, Expense, ProductWaste, Transfer, OpenCashRegister, CashOut, Supplier, Customer, Credit, CreditPayment, Commission, Sellerscommission, ProductsReturn, Category]
@@ -48,6 +48,8 @@ class Ability
       # Clientes
       can :cru, [Customer, BillingInformation, Pointsale, User, Warehouse, Credit, CreditPayment, Commission, Sellerscommission]
 
+      cannot :opened_cash_registers, CashOut
+
     elsif user.usertype == "C"
       # Cajas registradoras
       can :read, [Product, Pointsale, Customer, BillingInformation, Seller, SpecialPrice, Expensesconcept, Credit, CreditPayment]
@@ -56,6 +58,8 @@ class Ability
 
       can :manage, [CashRegister, PreSale, OpenCashRegister, Sale, Customer, Credit, CreditPayment, CashOut, Expense, Transfer, ProductsReturn, ProductWaste]
 
+      cannot :opened_cash_registers, CashOut
+
     elsif user.usertype == "S"
       can :read, [CashRegister, Product, Pointsale, Customer, BillingInformation, Seller, SpecialPrice, Expensesconcept]
 

+ 0 - 2
app/models/available_product.rb

@@ -1,8 +1,6 @@
 class AvailableProduct < ActiveRecord::Base
-
   belongs_to :product
   belongs_to :pointsale
-
   has_many :categories, :through => :product
 
   audited

+ 16 - 24
app/models/cash_out.rb

@@ -1,26 +1,18 @@
 class CashOut < ActiveRecord::Base
-	belongs_to :user, :class_name => 'User'
-	belongs_to :received_by, :class_name => 'User'
-	belongs_to :open_cash_register
-	has_many :cash_out_details
-
-	has_one :cash_register, :through => :open_cash_register
-	has_one :pointsale, :through => :cash_register
-
-	##--- Llevar registro de Actividad del usuario
-	audited
-
-  	accepts_nested_attributes_for :cash_out_details
-  	# accepts_nested_attributes_for :cash_out_details,
-  	# 	:reject_if => proc { |att| att['received_by_id'].blank? }
-
-
-	validates :received_cash, presence: { message: "Debe indicar el efectivo a retirar." }, :on => [:create]
-	validates :cash_fund, presence: { message: "Debe indicar el fondo de caja." }, :on => [:create]
-	validates :received_by_id, presence: { message: "Debe seleccionar quien recibe el dinero del corte." }, :on => [:create]
-
-
-	validates_associated :cash_out_details
-
-
+  belongs_to :user, class_name: 'User'
+  belongs_to :received_by, class_name: 'User'
+  belongs_to :open_cash_register
+  has_many :cash_out_details
+
+  has_one :cash_register, through: :open_cash_register
+  has_one :pointsale, through: :cash_register
+
+  ##--- Llevar registro de Actividad del usuario
+  audited
+
+  accepts_nested_attributes_for :cash_out_details
+  validates :received_cash, presence: { message: "Debe indicar el efectivo a retirar." }, on: [:create]
+  validates :cash_fund, presence: { message: "Debe indicar el fondo de caja." }, on: [:create]
+  validates :received_by_id, presence: { message: "Debe seleccionar quién recibe el dinero del corte." }, on: [:create]
+  validates_associated :cash_out_details
 end

+ 14 - 15
app/models/cash_register.rb

@@ -1,18 +1,17 @@
 class CashRegister < ActiveRecord::Base
-    ## Associaciones
-    belongs_to :pointsale
-    has_many :open_cash_registers
-    has_many :cash_registers_moves, :through => :open_cash_registers
-    has_many :cash_outs, :through => :open_cash_registers
-    
-	enum status: [ :erased, :active, :inactive ]
-    enum main: [:no, :yes]
-	##--- Validaciones previas de guardar
-    validates :name , presence: { message: "Debe capturar el nombre de la caja registradora." }
-    validates :pointsale_id , presence: { message: "Debe seleccionar un punto de venta." }
+  ## Associaciones
+  belongs_to :pointsale
+  has_many :open_cash_registers
+  has_many :cash_registers_moves, through: :open_cash_registers
+  has_many :cash_outs, through: :open_cash_registers
 
-	##--- Tipo de vistas / consultas
-	scope :vigentes, -> { where("status != 0").order(" status ASC, name ASC") }
-	scope :activos, -> { where( "status = 1").order(" name ASC") }
-    
+  enum status: [:erased, :active, :inactive]
+  enum main: [:no, :yes]
+  ##--- Validaciones previas de guardar
+  validates :name, presence: { message: "Debe capturar el nombre de la caja registradora." }
+  validates :pointsale_id, presence: { message: "Debe seleccionar un punto de venta." }
+
+  ##--- Tipo de vistas / consultas
+  scope :vigentes, -> { where.not(status: 0).order("status ASC, name ASC") }
+  scope :activos, -> { where(status: 1).order("name ASC") }
 end

+ 20 - 20
app/models/open_cash_register.rb

@@ -1,26 +1,26 @@
 class OpenCashRegister < ActiveRecord::Base
-	belongs_to :cash_register
-	belongs_to :user
-	has_many :cash_registers_moves
-	has_many :sales
-	has_many :sales_details, :through => :sales
-	has_many :products, :through => :sales_details
-	has_many :categories, :through => :products
-	has_many :expenses
-	has_many :pre_sales
-	has_many :cash_outs
-	has_one :pointsale, :through => :cash_register
+  belongs_to :cash_register
+  belongs_to :user
+  has_many :cash_registers_moves
+  has_many :sales
+  has_many :sales_details, through: :sales
+  has_many :products, through: :sales_details
+  has_many :categories, through: :products
+  has_many :expenses
+  has_many :pre_sales
+  has_many :cash_outs
+  has_one :pointsale, through: :cash_register
 
-  	##--- Llevar registro de Actividad del usuario
-	audited
+  ##--- Llevar registro de Actividad del usuario
+  audited
 
-	enum status: [:open, :closed]
+  enum status: [:open, :closed]
 
-	scope :abiertas, -> { where( "open_cash_registers.status = 0") }
+  scope :abiertas, -> { where("open_cash_registers.status = ?", 0) }
 
-	def self.get_pointsale(id, option)
-		if option == "open_cash_register"
-			Pointsale.find(CashRegister.find(OpenCashRegister.find(id).cash_register_id).pointsale_id)
-		end
-	end
+  def self.get_pointsale(id, option)
+    if option == "open_cash_register"
+      Pointsale.find(CashRegister.find(OpenCashRegister.find(id).cash_register_id).pointsale_id)
+    end
+  end
 end

+ 5 - 7
app/models/pointsale.rb

@@ -39,19 +39,17 @@ class Pointsale < ActiveRecord::Base
 
   ##--- Validaciones previas de guardar
   validates :name, presence: { message: "Debe capturar el nombre del punto de venta." }, unless: :skip_name_validation
-  validates :prefix, presence: { message: "Debe indicar el prefijo del punto de venta." }, length: { maximum: 3, too_long: "El maximo de caracteres debe ser %{count}.", minimum: 3, too_short: "El minimo de caracteres debe ser %{count}." }, uniqueness: { message: "El prefijo ya fue utilizado, favor de especificar otro." }
+  validates :prefix, presence: { message: "Debe indicar el prefijo del punto de venta." }, length: { maximum: 3, too_long: "El máximo de caracteres debe ser %{count}.", minimum: 3, too_short: "El mínimo de caracteres debe ser %{count}." }, uniqueness: { message: "El prefijo ya fue utilizado, favor de especificar otro." }
   # validates_attachment_content_type :img_pointsale, :content_type => /\Aimage\/.*\Z/
 
   ##--- Tipo de vistas / consultas
-  scope :vigentes, -> { where("status != 0").order("status ASC, name ASC") }
-  scope :activos, -> { where("status = 1").order("name ASC") }
+  scope :vigentes, -> { where.not(status: 0).order("status ASC, name ASC") }
+  scope :activos, -> { where(status: 1).order("name ASC") }
   scope :ignore_current, ->(pointsale_id) { where.not(id: pointsale_id) }
   # def has_stock
 
-  def total_products(pointsale_id)
-    unless pointsale_id.nil?
-      Pointsale.find(pointsale_id).products.where("stock > 0").sum(:stock).to_i
-    end
+  def total_products
+    products.where("stock > 0").sum(:stock).to_i
   end
 
   def self.get_pointsale(id, option)

+ 10 - 9
app/models/product.rb

@@ -50,14 +50,14 @@ class Product < ActiveRecord::Base
   end
 
   ##--- Tipo de vistas / consultas
-  scope :vigentes, -> { where("status != 0").order(" status ASC, name ASC") }
-  scope :activos, -> { where("status = 1").order(" name ASC") }
-  scope :activos_children, -> { where("status = 1 and is_parent = false ").order("products.name ASC") }
-  scope :vigentes_parents, -> { where("status != 0 and parent_id IS NULL ").order(" status ASC, name ASC") }
-  scope :name_sku_barcode_like, ->(name) { where("status = 1 and is_parent = false and (name ilike ? or sku ilike ? or barcode ilike ?)", "%#{name}%", "%#{name}%", "%#{name}%").order("name") }
-  scope :name_sku_barcode_attribute_like, ->(name, attributes_string) { where("status = 1 and is_parent = false and (name ilike ? or sku ilike ? or barcode ilike ?) #{attributes_string}", "%#{name}%", "%#{name}%", "%#{name}%").order("name") }
+  scope :vigentes, -> { where.not(status: 0).order(" products.status ASC, products.name ASC") }
+  scope :activos, -> { where(status: 1).order("products.name ASC") }
+  scope :activos_children, -> { activos.where(is_parent: false).order("products.name ASC") }
+  scope :vigentes_parents, -> { vigentes.where("parent_id IS NULL") }
+  scope :name_sku_barcode_like, ->(name) { activos.where("is_parent = ? and (name ilike ? or sku ilike ? or barcode ilike ?)", false, "%#{name}%", "%#{name}%", "%#{name}%") }
+  scope :name_sku_barcode_attribute_like, ->(name, attributes_string) { activos.where("is_parent = ? and (name ilike ? or sku ilike ? or barcode ilike ?) #{attributes_string}", false, "%#{name}%", "%#{name}%", "%#{name}%") }
   # para special_prices
-  scope :name_sku_barcode_like_sp, ->(name) { where("status = 1 and is_parent = true and (name ilike ? or sku ilike ? or barcode ilike ?)", "%#{name}%", "%#{name}%", "%#{name}%").order("name") }
+  scope :name_sku_barcode_like_sp, ->(name) { activos.where("is_parent = ? and (name ilike ? or sku ilike ? or barcode ilike ?)", true, "%#{name}%", "%#{name}%", "%#{name}%") }
 
   def name_with_sku
     sku.to_s + " - " + name.to_s
@@ -118,8 +118,9 @@ class Product < ActiveRecord::Base
   end
 
   def get_price_sale(pointsale_id)
-    if pointsale_id != 0 && available_in_pointsale?(pointsale_id) && !get_available_in_pointsale(pointsale_id).price_sale.nil?
-      get_available_in_pointsale(pointsale_id).price_sale
+    available = get_available_in_pointsale(pointsale_id)
+    if available.present? && available.price_sale.present?
+      available.price_sale
     else
       price_sale
     end

+ 12 - 12
app/models/product_waste.rb

@@ -1,18 +1,18 @@
 class ProductWaste < ActiveRecord::Base
-	belongs_to :product
-	belongs_to :user
-	belongs_to :pointsale
-	belongs_to :warehouse
-	belongs_to :products_return_in
+  belongs_to :product
+  belongs_to :user
+  belongs_to :pointsale
+  belongs_to :warehouse
+  belongs_to :products_return_in
 
-  	##--- Llevar registro de Actividad del usuario
-	audited
+  ##--- Llevar registro de Actividad del usuario
+  audited
 
-	validates :product_id , :presence => { message: "Debe seleccionar producto." }, :on => [:create]
-	validates :quantity , :presence => { message: "Debe indicar cantidad." }, :on => [:create]
-	validates :reason , :presence => { message: "Debe indicar el motivo." }, :on => [:create]
+  validates :product_id, presence: { message: "Debe seleccionar producto." }, on: [:create]
+  validates :quantity, presence: { message: "Debe indicar cantidad." }, on: [:create]
+  validates :reason, presence: { message: "Debe indicar el motivo." }, on: [:create]
 
-	enum status: [:active, :inactive ]
+  enum status: [:active, :inactive]
 
-	scope :activos, -> { where( "status = 0").order(" id DESC") }
+  scope :activos, -> { where(status: 0).order("id DESC") }
 end

+ 1 - 1
app/models/seller.rb

@@ -15,7 +15,7 @@ class Seller < ActiveRecord::Base
   validates :name, presence: { message: "Debe indicar nombre para el vendedor." }, on: [:create, :update]
   validates :last_name, presence: { message: "Debe indicar apellido para el vendedor." }, on: [:create, :update]
 
-  scope :vigentes, -> { where("status != 0") }
+  scope :vigentes, -> { where.not(status: 0) }
 
   ##--- Funciones personalizadas
   def full_name

+ 2 - 0
app/models/user.rb

@@ -38,6 +38,8 @@ class User < ActiveRecord::Base
 
   validates :userid, uniqueness: { message: "El usuario ya fue utilizado, favor de especificar otro." }
 
+  scope :vigentes, -> { where.not(status: 0).order(userid: :asc) }
+
   def full_name
     "#{first_name} #{last_name}"
   end

+ 4 - 5
app/views/available_products/_edit_price.html.erb

@@ -7,9 +7,9 @@
 	<% end %>
 	<div class="form-body">
 		<div class="row">
-			
+
 			<div class="col-md-12">
-				<% if current_user.usertype == "A" %>
+				<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 				<p> Punto de venta: <%= @available_product.pointsale.name %></p>
 				<% end %>
 				<p> Producto: <%= @product.name %> con precio de venta (base) de $<%= @product.price_sale %>
@@ -31,13 +31,12 @@
 		</div>
 	</div>
 	<div class="form-actions">
-	    
 		<div class="row">
 			<div class="col-md-offset-3 col-md-9">
-				<%= f.submit 'Actualizar precio', {:class=>"btn green"} %> 
+				<%= f.submit 'Actualizar precio', {:class=>"btn green"} %>
 				<button type="button" data-dismiss="modal" class="btn">Cancelar</button>
 			</div>
 		</div>
 	</div>
 </div>
-<% end %>
+<% end %>

+ 3 - 5
app/views/available_products/stock_by_pointsale.html.erb

@@ -59,7 +59,7 @@
 														<!-- sub- categoria -->
 														<%= label :sub_category, "", {:class=>"col-md-1 control-label"} do %>Sublínea <% end %>
 														<div class="col-md-3 select2-bootstrap-prepend">
-															<%= select_tag "sub_category", options_from_collection_for_select(Category.activos.where('parent_id != 0'), :id, :category), :include_blank => "Todas",  class: "form-control select2 clereable" %>
+															<%= select_tag "sub_category", options_from_collection_for_select(Category.activos.where('parent_id != 0'), :id, :category), :include_blank => "Todas", class: "form-control select2 clereable" %>
 														</div>
 													</div>
 												</div>
@@ -71,7 +71,7 @@
 														<div class="uppercase font-hg font-blue-sharp" id="total_prods"></div>
 													</div>
 												</div>
-												<% if current_user.usertype == 'A' %>
+												<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 													<div class="col-md-3 col-sm-4 col-xs-6 ">
 														<div class="text-center well" id="container_total_invested" style="margin-bottom: 0px">
 															<div class="font-grey-mint font-sm">Total invertido en pesos </div>
@@ -129,8 +129,6 @@
 		if (sub_category) { uri += '&sub_category=' + sub_category; }
 		if (search) { uri += '&search=' + encodeURIComponent(search); }
 
-		window.open('/print_stock_by_pointsale.pdf?' + uri, 'New tab', '' );
-
+		window.open('/print_stock_by_pointsale.pdf?' + uri, 'New tab', '');
 	}
 </script>
-

+ 8 - 5
app/views/cash_outs/_cash_out.html.erb

@@ -1,14 +1,14 @@
 <tr id="cash_out_<%= cash_out.id %>">
   <td><%= cash_out.id %></td>
-  <% if current_user.usertype == "A" %>
+  <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
     <td>
-    <%= OpenCashRegister.get_pointsale(cash_out.open_cash_register_id, "open_cash_register").name %> 
-    </td> 
+    <%= OpenCashRegister.get_pointsale(cash_out.open_cash_register_id, "open_cash_register").name %>
+    </td>
   <% end %>
   <td><%= cash_out.open_cash_register.cash_register.name %> </td>
   <td><%= number_to_currency(cash_out.amount_in, precision: 2) %> </td>
   <td><%= number_to_currency(cash_out.amount_out, precision: 2)  %></td>
-  <td><%= number_to_currency(cash_out.amount_in - cash_out.amount_out, precision: 2)  %></td>  
+  <td><%= number_to_currency(cash_out.amount_in - cash_out.amount_out, precision: 2)  %></td>
   <td><%= l(cash_out.created_at, :format => '%d/%B/%Y') %></td>
   <td><%= cash_out.user.first_name %></td>
   <td><%= (cash_out.received_by.blank? ? "" : cash_out.received_by.first_name) %></td>
@@ -16,5 +16,8 @@
     <%= link_to cash_out, {:class=>"btn btn-icon-only default", :title=>"Ver corte de caja"} do %>
       <i class="fa fa-search"></i>
     <% end %>
+    <%= link_to print_cash_out_receipt_path(cash_out.id, format: 'pdf'), {:class=>"btn btn-icon-only default", :target => "blank"} do %>
+      <i class="fa fa-print"></i>
+    <% end %>
   </td>
-</tr>
+</tr>

+ 10 - 10
app/views/cash_outs/index.html.erb

@@ -44,15 +44,15 @@
                     <span class="caption-subject bold uppercase">Lista de cortes de caja</span>
                   </div>
                    <div class="actions">
-                    <% if current_user.usertype == "G" %>
-                      <% if can? :create, CashOut %>
-                        <%= link_to new_open_cash_register_path, :remote => true, :class => 'btn btn bold green margin-top pull-right', :title => "Abrir caja registradora" do %> Abrir caja <i class="fa fa-plus"></i><% end %> <br>
-                        <%= link_to get_open_cash_registers_path, remote: true, data: { toggle: "modal", target: "#get_open_cash_register" }, :class=>"btn bold green pull-right", :title=>"Realizar corte de caja", :style=> "margin-top:10px"  do %> Realizar corte de caja <i class="fa fa-plus"></i>
+                    <% if can? :create, OpenCashRegister %>
+                      <%= link_to new_open_cash_register_path, remote: true, class: 'btn btn bold green margin-top pull-right', title: "Abrir caja registradora" do %> Abrir caja <i class="fa fa-plus"></i><% end %> <br>
+                    <% end %>
+                    <% if can? :get_open_cash_registers, CashOut %>
+                      <%= link_to get_open_cash_registers_path, remote: true, data: { toggle: "modal", target: "#get_open_cash_register" }, class: "btn bold green pull-right", title: "Realizar corte de caja", style: "margin-top:10px"  do %> Realizar corte de caja <i class="fa fa-plus"></i>
                         <% end %>
-                      <% end %>
                     <% end %>
-                    <% if current_user.usertype == "A" %>
-                      <%= link_to opened_cash_registers_path, {:class=>"btn bold green pull-right"} do %> <i class="fa fa-search"></i>&nbsp Ver cajas abiertas <% end %>
+                    <% if can? :opened_cash_registers, CashOut %>
+                      <%= link_to opened_cash_registers_path, { class: "btn bold green pull-right" } do %> <i class="fa fa-search"></i>&nbsp Ver cajas abiertas <% end %>
                     <% end %>
                   </div>
                 </div>
@@ -65,7 +65,7 @@
                             <%= label_tag :pointsale, "pointsale", {:class=>"col-md-2 control-label"} do %> Punto de venta
                             <% end %>
                             <div class="col-md-3">
-                              <%= select_tag "pointsale", options_from_collection_for_select(Pointsale.vigentes, :id, :name, :selected => current_user.pointsale_id), :include_blank => "Todas", :disabled => (true unless current_user.usertype == 'A'),  class: "form-control select2 col-md-3" %>
+                              <%= select_tag "pointsale", options_from_collection_for_select(Pointsale.vigentes, :id, :name, :selected => current_user.pointsale_id), :include_blank => "Todas", :disabled => (true unless current_user.usertype == "A" || current_user.usertype == "SS"),  class: "form-control select2 col-md-3" %>
                             </div>
                             <%= label_tag :begin_date, "Fecha", {:class=>"col-md-1 control-label"} do %> Desde
                             <% end %>
@@ -100,7 +100,7 @@
                     <thead>
                       <tr>
                         <th>#</th>
-                        <% if current_user.usertype == "A" %>
+                        <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
                           <th>Punto de venta</th>
                         <% end %>
                         <th>Caja registradora</th>
@@ -117,7 +117,7 @@
                       <% @cash_outs.each_with_index do |cash_out, key| %>
                       <tr>
                         <td><%= cash_out.id %></td>
-                        <% if current_user.usertype == "A" %>
+                        <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
                           <td>
                           <%= OpenCashRegister.get_pointsale(cash_out.open_cash_register_id, "open_cash_register").name %>
                           </td>

+ 10 - 8
app/views/cash_outs/opened_cash_registers.html.erb

@@ -16,6 +16,8 @@
     <!-- BEGIN PAGE CONTENT BODY -->
     <div class="page-content">
       <div class="container-fluid">
+        <%= link_to cash_outs_path(:filter => @filter, :current_page => @current_page), {:class=>"btn blue-hoki pull-right margin-bottom-10"} do %> <i class="fa fa-angle-left "></i> Regresar
+        <% end %>
         <!-- BEGIN PAGE BREADCRUMBS -->
         <ul class="page-breadcrumb breadcrumb">
           <%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
@@ -41,14 +43,14 @@
                   <div class="caption">
                     <i class="fa fa-list "></i>
                     <span class="caption-subject bold uppercase">Lista de cajas abiertas</span>
-                  </div> 
+                  </div>
                 </div>
                 <div class="portlet-body">
                   <table class="table table-striped table-bordered table-hover tableadvanced" id="cash_outs_table">
                     <thead>
                       <tr>
                         <th>#</th>
-                        <th>Punto de venta</th> 
+                        <th>Punto de venta</th>
                         <th>Caja registradora</th>
                         <th>Ingresos</th>
                         <th>Egresos</th>
@@ -62,23 +64,23 @@
                         <tr>
                           <td><%= key + 1 %></td>
                           <td>
-                            <%= OpenCashRegister.get_pointsale(open_cash.id, "open_cash_register").name %> 
-                          </td> 
+                            <%= OpenCashRegister.get_pointsale(open_cash.id, "open_cash_register").name %>
+                          </td>
                           <td><%= open_cash.cash_register.name %> </td>
                           <td>
-                            <% amount_in =  CashRegistersMove.where(:open_cash_register => open_cash.id, :move_type =>  1).sum(:quantity) %> 
+                            <% amount_in =  CashRegistersMove.where(:open_cash_register => open_cash.id, :move_type =>  1).sum(:quantity) %>
                            <%= number_to_currency(amount_in, precision: 2) %>
                           </td>
                           <td>
                             <% amount_out = CashRegistersMove.where(:open_cash_register => open_cash.id, :move_type =>  0).sum(:quantity) %>
-                           <%= number_to_currency(amount_out, precision: 2) %>   
+                           <%= number_to_currency(amount_out, precision: 2) %>
                            </td>
                            <td>
-                             <%= number_to_currency((amount_in - amount_out), precision: 2) %>   
+                             <%= number_to_currency((amount_in - amount_out), precision: 2) %>
                            </td>
                           <td><%= open_cash.user.first_name %></td>
                           <td><%= l(open_cash.created_at, :format => '%I:%M %p') %></td>
-                        </tr>                      
+                        </tr>
                       <% end %>
                     </tbody>
                   </table>

+ 185 - 187
app/views/cash_outs/show.html.erb

@@ -18,12 +18,11 @@
 		<div class="page-content">
 			<div class="container-fluid">
 				<div class="pull-right margin-bottom-10 ">
-                    <a class="btn blue hidden-print" onclick="javascript:window.print();"> Imprimir
-                        <i class="fa fa-print"></i>
-                    </a>
-					<%= link_to  cash_outs_path(:filter => @filter, :current_page => @current_page), {:class=>"fr-space btn blue-hoki hidden-print"} do %>
-						<i class="fa fa-angle-left "></i>
-						Regresar
+          <a class="btn blue hidden-print" onclick="javascript:window.print();"> Imprimir
+	          <i class="fa fa-print"></i>
+          </a>
+					<%= link_to cash_outs_path(:filter => @filter, :current_page => @current_page), {:class=>"fr-space btn blue-hoki hidden-print"} do %>
+						<i class="fa fa-angle-left "></i> Regresar
 					<% end %>
 				</div>
 				<!-- BEGIN PAGE BREADCRUMBS -->
@@ -52,7 +51,7 @@
 												&nbsp&nbsp Fecha:</div>
 												<div class="col-md-6 value"> <%= l(@cash_out.created_at, :format => '%A, %d de %B de %Y') %>  </div>
 											</div>
-											<% if current_user.usertype == "A" %>
+											<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 												<div class="row static-info">
 													<div class="col-md-6 name"><i class="fa fa-fw fa-cart-plus"></i> &nbsp Punto de venta:</div>
 													<div class="col-md-6 value"> <%= OpenCashRegister.get_pointsale(@cash_out.open_cash_register_id, "open_cash_register").name %>  </div>
@@ -81,33 +80,33 @@
 
 										<!-- para la vista de impresion -->
 										<ul class="list-unstyled visible-print">
-                                            <li>
-                                                <i class="fa fa-calendar-o"></i>&nbsp Fecha:
-                                                <strong><%= l(@cash_out.created_at, :format => '%A, %d de %B de %Y') %> </strong>
-                                            </li>
-                                            <% if current_user.usertype == "A" %>
-	                                            <li>
-	                                                <i class="fa fa-fw fa-cart-plus"></i>&nbsp Punto de venta:
-	                                                <strong><%= OpenCashRegister.get_pointsale(@cash_out.open_cash_register_id, "open_cash_register").name %></strong>
-	                                            </li>
-                                            <% end %>
-                                            <li>
-                                                <i class="fa fa-fw fa-cart-plus"></i>&nbsp Caja registradora:
-                                                <strong> <%= @cash_out.open_cash_register.cash_register.name %></strong>
-                                            </li>
-                                            <li>
-                                                <i class="fa fa-odnoklassniki"></i>&nbsp Realizó:
-                                                <strong> <%= @cash_out.user.first_name %> </strong>
-                                            </li>
-                                            <li>
-                                                <i class="fa fa-odnoklassniki"></i>&nbsp Recibió:
-                                                <strong> <%= @cash_out.received_by.first_name %> </strong>
-                                            </li>
-                                            <li>
-                                                <i class="fa fa-odnoklassniki"></i>&nbsp Observaciones:
-                                                <strong> <%= @cash_out.observations %> </strong>
-                                            </li>
-                                        </ul>
+                      <li>
+                        <i class="fa fa-calendar-o"></i>&nbsp Fecha:
+                        <strong><%= l(@cash_out.created_at, :format => '%A, %d de %B de %Y') %> </strong>
+                      </li>
+                      <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
+                        <li>
+                          <i class="fa fa-fw fa-cart-plus"></i>&nbsp Punto de venta:
+                          <strong><%= OpenCashRegister.get_pointsale(@cash_out.open_cash_register_id, "open_cash_register").name %></strong>
+                        </li>
+                      <% end %>
+                      <li>
+                        <i class="fa fa-fw fa-cart-plus"></i>&nbsp Caja registradora:
+                        <strong> <%= @cash_out.open_cash_register.cash_register.name %></strong>
+                      </li>
+                      <li>
+                        <i class="fa fa-odnoklassniki"></i>&nbsp Realizó:
+                        <strong> <%= @cash_out.user.first_name %> </strong>
+                      </li>
+                      <li>
+                        <i class="fa fa-odnoklassniki"></i>&nbsp Recibió:
+                        <strong> <%= @cash_out.received_by.first_name %> </strong>
+                      </li>
+                      <li>
+                        <i class="fa fa-odnoklassniki"></i>&nbsp Observaciones:
+                        <strong> <%= @cash_out.observations %> </strong>
+                      </li>
+                  	</ul>
 									</div>
 								</div>
 							</div>
@@ -120,106 +119,105 @@
 										<div class="">
 											<div class="row">
 												<div class="col-md-4">
-												    <div class="hidden-print" style="padding-left: 0px">
-												      <ul class="list-group">
-												        <li class="list-group-item list-group-item-default"> Total de ventas
-												        <span class="pull-right label label-warning"><%= number_to_currency(@sales_total, precision: 2) %></span>
-												        </li>
-												      </ul>
-												    </div>
+											    <div class="hidden-print" style="padding-left: 0px">
+											      <ul class="list-group">
+											        <li class="list-group-item list-group-item-default"> Total de ventas
+											        <span class="pull-right label label-warning"><%= number_to_currency(@sales_total, precision: 2) %></span>
+											        </li>
+											      </ul>
+											    </div>
 												</div>
 												<div class="col-md-4">
-												    <div class="hidden-print" style="padding-left: 0px">
-												      <ul class="list-group">
-												        <li class="list-group-item list-group-item-default"> Total de egresos
-												        <span class="pull-right label label-warning"><%= number_to_currency(@expenses_total, precision: 2) %></span>
-												        </li>
-												      </ul>
-												    </div>
+											    <div class="hidden-print" style="padding-left: 0px">
+											      <ul class="list-group">
+											        <li class="list-group-item list-group-item-default"> Total de egresos
+											        <span class="pull-right label label-warning"><%= number_to_currency(@expenses_total, precision: 2) %></span>
+											        </li>
+											      </ul>
+											    </div>
 												</div>
 
 												<div class="col-md-4">
-												    <div class="hidden-print" style="padding-left: 0px">
-												      <ul class="list-group">
-												        <li class="list-group-item list-group-item-default"> Efectivo inicial
-												        <span class="pull-right label label-warning"><%= number_to_currency(@cash_out.open_cash_register.initial_cash, precision: 2) %></span>
-												        </li>
-												      </ul>
-												    </div>
+											    <div class="hidden-print" style="padding-left: 0px">
+											      <ul class="list-group">
+											        <li class="list-group-item list-group-item-default"> Efectivo inicial
+											        <span class="pull-right label label-warning"><%= number_to_currency(@cash_out.open_cash_register.initial_cash, precision: 2) %></span>
+											        </li>
+											      </ul>
+											    </div>
 												</div>
 
 												<div class="col-md-4">
-												    <div class="hidden-print" style="padding-left: 0px">
-												      <ul class="list-group">
-												        <li class="list-group-item list-group-item-default"> Retiro
-												        <span class="pull-right label label-warning"><%= number_to_currency(@cash_out.received_cash, precision: 2) %></span>
-												        </li>
-												      </ul>
-												    </div>
+											    <div class="hidden-print" style="padding-left: 0px">
+											      <ul class="list-group">
+											        <li class="list-group-item list-group-item-default"> Retiro
+											        <span class="pull-right label label-warning"><%= number_to_currency(@cash_out.received_cash, precision: 2) %></span>
+											        </li>
+											      </ul>
+											    </div>
 												</div>
 
 												<div class="col-md-4">
-												    <div class="hidden-print" style="padding-left: 0px">
-												      <ul class="list-group">
-												        <li class="list-group-item list-group-item-default"> Fondo
-												        <span class="pull-right label label-warning"><%= number_to_currency(@cash_out.cash_fund, precision: 2) %></span>
-												        </li>
-												      </ul>
-												    </div>
+											    <div class="hidden-print" style="padding-left: 0px">
+											      <ul class="list-group">
+											        <li class="list-group-item list-group-item-default"> Fondo
+											        <span class="pull-right label label-warning"><%= number_to_currency(@cash_out.cash_fund, precision: 2) %></span>
+											        </li>
+											      </ul>
+											    </div>
 												</div>
 											</div>
 											<!-- saldo inicial de la caja para el view-->
 
 											<!-- saldo inicial de la caja para el print view -->
 											<ul class="list-unstyled visible-print">
-	                                            <li>
-	                                                <i class="fa fa-money"></i>&nbsp Total de ventas:
-	                                                <strong><%= number_to_currency(@sales_total, precision: 2) %> </strong>
-	                                            </li>
-	                                            <li>
-	                                                <i class="fa fa-money"></i>&nbsp Total de egresos:
-	                                                <strong><%= number_to_currency(@expenses_total, precision: 2) %> </strong>
-	                                            </li>
-	                                            <li>
-	                                                <i class="fa fa-money"></i>&nbsp Efectivo inicial:
-	                                                <strong><%= number_to_currency(@cash_out.open_cash_register.initial_cash, precision: 2) %> </strong>
-	                                            </li>
-	                                            <li>
-	                                                <i class="fa fa-money"></i>&nbsp Retiro de efectivo:
-	                                                <strong><%= number_to_currency(@cash_out.received_cash, precision: 2) %> </strong>
-	                                            </li>
-	                                            <li>
-	                                                <i class="fa fa-money"></i>&nbsp Fondo de caja:
-	                                                <strong><%= number_to_currency(@cash_out.cash_fund, precision: 2) %> </strong>
-	                                            </li>
-
+                        <li>
+                          <i class="fa fa-money"></i>&nbsp Total de ventas:
+                          <strong><%= number_to_currency(@sales_total, precision: 2) %> </strong>
+                        </li>
+                        <li>
+                          <i class="fa fa-money"></i>&nbsp Total de egresos:
+                          <strong><%= number_to_currency(@expenses_total, precision: 2) %> </strong>
+                        </li>
+                        <li>
+                          <i class="fa fa-money"></i>&nbsp Efectivo inicial:
+                          <strong><%= number_to_currency(@cash_out.open_cash_register.initial_cash, precision: 2) %> </strong>
+                        </li>
+                        <li>
+                          <i class="fa fa-money"></i>&nbsp Retiro de efectivo:
+                          <strong><%= number_to_currency(@cash_out.received_cash, precision: 2) %> </strong>
+                        </li>
+                        <li>
+                          <i class="fa fa-money"></i>&nbsp Fondo de caja:
+                          <strong><%= number_to_currency(@cash_out.cash_fund, precision: 2) %> </strong>
+                        </li>
 											</ul>
-									        <table class="table table-striped table-hover">
-									            <thead>
-									                <tr class="uppercase">
-									                    <th> # </th>
-									                    <th> Método de pago </th>
-									                    <th> total de ingresos </th>
-									                    <th> total de egresos </th>
-									                    <th> Total </th>
-									                </tr>
-									            </thead>
-									            <tbody>
-									              <% @cash_out.cash_out_details.each_with_index do |detail, key| %>
-									                <tr>
-									                  <td> <%= key +1 %> </td>
-									                  <td> <%= detail.payment_method.method %> </td>
-									                  <td> <%= number_to_currency(detail.incoming, precision: 2) %> </td>
-									                  <td> <%= number_to_currency(detail.outgoing, precision: 2) %> </td>
-									                  <td>
-									                    <%= number_to_currency(detail.total, precision: 2) %>
-									                  </td>
-									                </tr>
-									              <% end %>
-									            </tbody>
-					                    	</table>
+							        <table class="table table-striped table-hover">
+						            <thead>
+					                <tr class="uppercase">
+				                    <th> # </th>
+				                    <th> Método de pago </th>
+				                    <th> total de ingresos </th>
+				                    <th> total de egresos </th>
+				                    <th> Total </th>
+					                </tr>
+						            </thead>
+						            <tbody>
+						              <% @cash_out.cash_out_details.each_with_index do |detail, key| %>
+						                <tr>
+						                  <td> <%= key +1 %> </td>
+						                  <td> <%= detail.payment_method.method %> </td>
+						                  <td> <%= number_to_currency(detail.incoming, precision: 2) %> </td>
+						                  <td> <%= number_to_currency(detail.outgoing, precision: 2) %> </td>
+						                  <td>
+						                    <%= number_to_currency(detail.total, precision: 2) %>
+						                  </td>
+						                </tr>
+						              <% end %>
+						            </tbody>
+                    	</table>
 										</div>
-			                    	</div>
+                	</div>
 								</div>
 							</div>
 							<div class="col-md-12 col-sm-12">
@@ -230,41 +228,41 @@
 									<div class="portlet-body">
 										<table class="table table-striped table-hover">
 											<thead>
-										        <tr>
-										          <th>#</th>
-										          <th>Folio</th>
-										          <th>Caja registradora</th>
-										          <th>Método de pago</th>
-										          <th>Cantidad</th>
-										          <th>Concepto</th>
-										          <th>Hora</th>
-										        </tr>
+								        <tr>
+								          <th>#</th>
+								          <th>Folio</th>
+								          <th>Caja registradora</th>
+								          <th>Método de pago</th>
+								          <th>Cantidad</th>
+								          <th>Concepto</th>
+								          <th>Hora</th>
+								        </tr>
 											</thead>
 											<tbody>
-										        <% @incomings.each_with_index do |move, key| %>
-										        <tr>
-										          <td><%= key + 1 %></td>
-										          <td>
-										            <% case move.concept %>
-          												<% when "sale",  "reserved_payment", "reserved_first_payment", "reserved_last_payment", "products_return" %>
-										                <%= move.sale.sale_code %>
-										              <% when "purchase"%>
-										                <%= move.purchase.purchase_code %>
-										              <% when "expense"%>
-										                <%= move.expense.expense_code %>
-										              <% when "credit_payment"%>
-										                <%= move.credit_payment.id %>
-										            <% end %>
-										          </td>
-										          <td><%= move.open_cash_register.cash_register.name%></td>
-										          <td><%= move.payment_method.method %></td>
-										          <td><%= number_to_currency(move.quantity, precision: 2) %></td>
-										          <td>
-                                  <%= cash_move_type(move) %>
-								           		 </td>
-										          <td><%= l(move.created_at, :format => '%I:%M %p') %> </td>
-										        </tr>
-										        <% end %>
+								        <% @incomings.each_with_index do |move, key| %>
+									        <tr>
+									          <td><%= key + 1 %></td>
+									          <td>
+									            <% case move.concept %>
+        												<% when "sale",  "reserved_payment", "reserved_first_payment", "reserved_last_payment", "products_return" %>
+									                <%= move.sale.sale_code %>
+									              <% when "purchase"%>
+									                <%= move.purchase.purchase_code %>
+									              <% when "expense"%>
+									                <%= move.expense.expense_code %>
+									              <% when "credit_payment"%>
+									                <%= move.credit_payment.id %>
+									            <% end %>
+									          </td>
+									          <td><%= move.open_cash_register.cash_register.name%></td>
+									          <td><%= move.payment_method.method %></td>
+									          <td><%= number_to_currency(move.quantity, precision: 2) %></td>
+									          <td>
+                              <%= cash_move_type(move) %>
+							           		</td>
+									          <td><%= l(move.created_at, :format => '%I:%M %p') %> </td>
+									        </tr>
+								        <% end %>
 											</tbody>
 										</table>
 									</div>
@@ -278,47 +276,47 @@
 									<div class="portlet-body">
 										<table class="table table-striped table-hover">
 											<thead>
-										        <tr>
-										          <th>#</th>
-										          <th>Folio</th>
-										          <th>Caja registradora</th>
-										          <th>Método de pago</th>
-										          <th>Cantidad</th>
-										          <th>Concepto</th>
-										          <th>Hora</th>
-										        </tr>
+								        <tr>
+								          <th>#</th>
+								          <th>Folio</th>
+								          <th>Caja registradora</th>
+								          <th>Método de pago</th>
+								          <th>Cantidad</th>
+								          <th>Concepto</th>
+								          <th>Hora</th>
+								        </tr>
 											</thead>
 											<tbody>
-										        <% @outgoings.each_with_index do |move, key| %>
-										        <tr>
-										          <td><%= key + 1 %></td>
-										          <td>
-										            <% case move.concept %>
-										              <% when "sale",  "reserved_payment",  "credit_payment" %>
-										                <%= move.sale.sale_code %>
-										              <% when "purchase"%>
-										                <%= move.purchase.purchase_code %>
-										              <% when "expense"%>
-										                <%= move.expense.expense_code %>
-										            <% end %>
-										          </td>
-										          <td><%= move.open_cash_register.cash_register.name%></td>
-										          <td><%= move.payment_method.method %></td>
-										          <td><%= number_to_currency(move.quantity, precision: 2) %></td>
-										          <td>
-						                          	<% case move.concept %>
-						                          	<% when "sale"%>
-						                            	Venta cancelada
-						                          	<% when "purchase"%>
-						                            	Compra
-						                          	<% when "expense"%>
-										                <strong> <%= move.expense.expensesconcept.name %></strong> <br>
-										                <%= move.expense.observations %>
-							                          <% end %>
-								           		 </td>
-										          <td><%= l(move.created_at, :format => '%I:%M %p') %> </td>
-										        </tr>
-										        <% end %>
+								        <% @outgoings.each_with_index do |move, key| %>
+									        <tr>
+									          <td><%= key + 1 %></td>
+									          <td>
+									            <% case move.concept %>
+									              <% when "sale",  "reserved_payment",  "credit_payment" %>
+									                <%= move.sale.sale_code %>
+									              <% when "purchase"%>
+									                <%= move.purchase.purchase_code %>
+									              <% when "expense"%>
+									                <%= move.expense.expense_code %>
+									            <% end %>
+									          </td>
+									          <td><%= move.open_cash_register.cash_register.name%></td>
+									          <td><%= move.payment_method.method %></td>
+									          <td><%= number_to_currency(move.quantity, precision: 2) %></td>
+									          <td>
+	                          	<% case move.concept %>
+	                          	<% when "sale" %>
+    	                        	Venta cancelada
+	                          	<% when "purchase" %>
+	                            	Compra
+	                          	<% when "expense" %>
+								                <strong> <%= move.expense.expensesconcept.name %></strong> <br>
+								                <%= move.expense.observations %>
+		                          <% end %>
+							           		</td>
+									          <td><%= l(move.created_at, :format => '%I:%M %p') %> </td>
+									        </tr>
+								        <% end %>
 											</tbody>
 										</table>
 									</div>

+ 35 - 57
app/views/cash_registers/_form.html.erb

@@ -1,57 +1,35 @@
-											<%= form_for(@cash_register, :html => {:class=>"form-horizontal"}) do |f| %>
-											<div class="portlet-body form">
-												<% if @cash_register.errors.any? %>
-												<div class="alert alert-danger">
-													<strong>Tiene <%= pluralize(@cash_register.errors.count, "error") %> no se puede guardar la caja registradora</strong><br>
-												</div>
-												<% end %>
-												<div class="form-body">
-													<div class="form-group">
-                                                        <%= f.label :name, "Nombre de la caja", {:class=>"col-md-3 control-label"} do %> Nombre de la caja
-															<span class="required">*</span>
-														<% end %>
-														<div class="col-md-9">
-															<%= f.text_field :name, {:class=>"form-control"} %>
-														</div>
-													</div>
-													<div class="form-group">
-                                                        <%= f.label :decription, "Descripción", {:class=>"col-md-3 control-label"} %>
-														<div class="col-md-9">
-                                                            <%= f.text_field :description, {:class=>"form-control"} %>
-														</div>
-													</div>                                                 
-													<% if @cash_register.persisted? %>
-													<!-- <div class="form-group">
-														<%= f.label :status, {:class=>"col-md-3 control-label"} %>
-														<div class="col-md-9">
-															<%= f.check_box(:status,   
-																{
-																	class: "make-switch",
-																	data: {
-																		on_color: "success",
-																		off_color: "danger",
-																		on_text: "Activo", 
-																		off_text: "Inactivo"
-																	}
-																},
-																"active", "inactive"  
-															) %>
-														</div>
-													</div> -->
-													<% end %>
-                                            </div>
-												<div class="form-actions">
-													<div class="row">
-														<div class="col-md-offset-3 col-md-9">
-															<%= f.submit 'Guardar', {:class=>"btn green"} %>
-															<%= link_to 'Cancelar', cash_registers_path, {:class=>"btn default"} %>
-														</div>
-													</div>
-												</div>
-											</div>
-											<% end %>
-											<script type="text/javascript">
-												$(document).ready(function() {
-													App.init();
-												});
-											</script>
+<%= form_for(@cash_register, remote: true, html: { class: "form-horizontal" }) do |f| %>
+  <div class="portlet-body form">
+    <div class="row col-md-12">
+      <div class="alert alert-danger hidden" id="cash_register_errors"></div>
+    </div>
+    <div class="form-body">
+      <div class="form-group">
+        <%= f.label :name, "Nombre de la caja", { class: "col-md-3 control-label" } do %> Nombre de la caja
+          <span class="required">*</span>
+        <% end %>
+        <div class="col-md-8">
+          <%= f.text_field :name, { class: "form-control first_input" } %>
+        </div>
+      </div>
+      <div class="form-group">
+        <%= f.label :decription, "Descripción", { class: "col-md-3 control-label" } %>
+        <div class="col-md-8">
+          <%= f.text_area :description, { class: "form-control", rows: 4 } %>
+        </div>
+      </div>
+    </div>
+    <div class="form-actions">
+      <div class="row">
+        <div class="col-md-offset-3 col-md-9">
+          <%= f.submit 'Guardar', { class: "btn green" } %>
+        </div>
+      </div>
+    </div>
+  </div>
+<% end %>
+<script type="text/javascript">
+  $(document).ready(function() {
+    App.init();
+  });
+</script>

+ 11 - 0
app/views/cash_registers/create.js.erb

@@ -0,0 +1,11 @@
+$("#cash_register_errors").html("");
+<% if @cash_register.errors.any? %>
+  $('#cash_register_errors').removeClass('hidden');
+  <% @cash_register.errors.values.each do |message| %>
+    $("#cash_register_errors").append($("<li />").html("<%= message.first.to_s %>"));
+  <% end %>
+<% else %>
+  $('#dialog').modal('toggle');
+  window.location = "<%= cash_registers_path %>";
+  $("#notice").html("<%= flash[:notice] %>");
+<% end %>

+ 0 - 52
app/views/cash_registers/edit.html.erb

@@ -1,52 +0,0 @@
-
-	<!-- BEGIN CONTAINER -->
-	<div class="page-container">
-		<!-- BEGIN CONTENT -->
-		<div class="page-content-wrapper">
-			<!-- BEGIN CONTENT BODY -->
-			<!-- BEGIN PAGE HEAD-->
-			<div class="page-head">
-				<div class="container-fluid">
-					<!-- BEGIN PAGE TITLE -->
-					<div class="page-title">
-						<h1>Caja registradora </h1>
-					</div>
-					<!-- END PAGE TITLE -->
-				</div>
-			</div>
-			<!-- END PAGE HEAD-->
-			<!-- BEGIN PAGE CONTENT BODY -->
-			<div class="page-content">
-				<div class="container-fluid">
-					<%= link_to cash_registers_path, {:class=>"btn blue-hoki pull-right margin-bottom-10"} do %>  <i class="fa fa-angle-left "></i> Regresar
-					<% end %>
-					<!-- BEGIN PAGE BREADCRUMBS -->
-					<ul class="page-breadcrumb breadcrumb">
-						<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
-					</ul>
-					<!-- END PAGE BREADCRUMBS -->
-					<!-- BEGIN PAGE CONTENT INNER -->
-					<div class="page-content-inner">
-						<div class="row ">
-							<div class="col-md-12">
-								<div class="portlet light">
-									<div class="portlet-title">
-										<div class="caption">
-											<i class="fa fa-edit font-blue-sharp"></i>
-											<span class="caption-subject font-blue-sharp bold uppercase">Editar caja registradora</span>
-										</div>
-									</div>
-									<%= render 'form' %>
-								</div>
-							</div>
-						</div> 
-					</div>
-					<!-- END PAGE CONTENT INNER -->
-				</div>
-			</div>
-			<!-- END PAGE CONTENT BODY -->
-			<!-- END CONTENT BODY -->
-		</div>
-		<!-- END CONTENT -->
-	</div>
-	<!-- END CONTAINER -->

+ 14 - 0
app/views/cash_registers/edit.js.erb

@@ -0,0 +1,14 @@
+$('#dialog h3.modal-title').html("Editar caja registradora");
+$('#dialog').removeClass('modal-lg');
+$('.modal-footer').remove();
+$('.modal-body').html(""); //limpiar el modal antes; la siguiente linea es por si se abrio previamente el detalle de venta
+$('.modal-dialog').removeClass('modal-lg');
+// Rend$( ".selector" ).dialog({ closeOnEscape: false });er the edit form
+$('.modal-body').html('<%= j render("form") %>');
+// Show the dynamic dialog
+$('#dialog').modal("show");
+
+// Set focus to the first element
+$('#dialog').on('shown.bs.modal', function () {
+  $('.first_input').focus();
+});

+ 30 - 26
app/views/cash_registers/index.html.erb

@@ -25,7 +25,7 @@
 						<!-- BEGIN PAGE CONTENT INNER -->
 						<div class="page-content-inner">
 							<div id="notice">
-								<% if success %> 
+								<% if success %>
 								<div class="alert alert-success">
 									<p><%= success %></p>
 								</div>
@@ -45,8 +45,7 @@
 											</div>
 											<div class="actions">
 												<% if can? :create, CashRegister %>
-												<%= link_to new_cash_register_path, {:class=>"btn bold green pull-right"} do %> Nueva Caja registradora <i class="fa fa-plus"></i>
-												<% end %>
+													<%= link_to new_cash_register_path, remote: true, class: "btn bold green pull-right" do %> Nueva Caja registradora <i class="fa fa-plus"></i><% end %>
 												<% end %>
 											</div>
 										</div>
@@ -57,10 +56,12 @@
 														<th>#</th>
 														<th>Nombre</th>
 														<th>Descripción</th>
-														<% if current_user.usertype == "A" %><th>Punto de venta</th> <% end %>
+														<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
+															<th>Punto de venta</th>
+														<% end %>
 														<th>Status</th>
 														<% if can? :manage, CashRegister %>
-														<th>Acciones</th> 
+															<th>Acciones</th>
 														<% end %>
 													</tr>
 												</thead>
@@ -70,31 +71,34 @@
 														<td><%= key + 1 %></td>
 														<td><%= cash_register.name %></td>
 														<td><%= cash_register.description %></td>
-														<% if current_user.usertype == "A" %><td><%= cash_register.pointsale.name %> </td> <% end %>
-														<td class="text-center"><% if cash_register.status == "active" %>
+														<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
+															<td><%= cash_register.pointsale.name %> </td>
+														<% end %>
+														<td class="text-center">
+															<% if cash_register.active? %>
 																<i class="fa fa-check font-green"></i>
-																<% else %>
+															<% else %>
 																<i class="fa fa-times font-red"></i>
-																<% end %>
-														</td>
-														<% if can? :manage, CashRegister %>
-														<td class="text-center">
-															<%= link_to edit_cash_register_path(cash_register), {:class=>"btn btn-icon-only btn-primary", :title=>"Editar caja registradora"} do %> <i class="fa fa-edit"></i>
 															<% end %>
-															<% if !cash_register.main? && cash_register.open_cash_registers.where("status = 0").count == 0 %>
-																<% if cash_register.active? %>
-									                              <%= link_to cash_register_update_status_path(cash_register), :class=>"btn btn-icon-only default", :title=>"Desactivar caja registadora", data: { confirm: '¿Esta seguro de desactivar la caja registadora?', method: 'post'}  do %>
-									                                <i class="fa fa-toggle-off"></i>
-									                              <% end %>
-									                            <% elsif cash_register.inactive? %>
-									                              <%= link_to cash_register_update_status_path(cash_register), :class=>"btn btn-icon-only green-jungle", :title=>"Activar caja registadora", data: { confirm: '¿Esta seguro de activar la caja registadora?', method: 'post'}  do %>
-									                                <i class="fa fa-toggle-on"></i>
-									                              <% end %>
-									                            <% end %>
-																<%= link_to cash_register_path(cash_register), method: :delete, :class => "btn btn-icon-only btn-danger", :title=>"Eliminar caja registradora", data: { confirm: '¿Esta seguro de eliminar la caja registradora?'}   do %>  <i class="fa fa-trash-o"></i>
-																<% end %>      
-															<% end %>                                     
 														</td>
+														<% if can? :manage, CashRegister %>
+															<td class="text-center">
+																<%= link_to edit_cash_register_path(cash_register), remote: true, class: "btn btn-icon-only btn-primary", title: "Editar caja registradora" do %> <i class="fa fa-edit"></i>
+																<% end %>
+																<% if !cash_register.main? && cash_register.open_cash_registers.abiertas.count == 0 %>
+																	<% if cash_register.active? %>
+			                              <%= link_to cash_register_update_status_path(cash_register), class: "btn btn-icon-only default", title: "Desactivar caja registadora", data: { confirm: '¿Está seguro de desactivar la caja registadora?', method: 'post' } do %>
+			                                <i class="fa fa-toggle-off"></i>
+			                              <% end %>
+			                            <% elsif cash_register.inactive? %>
+			                              <%= link_to cash_register_update_status_path(cash_register), class: "btn btn-icon-only green-jungle", title: "Activar caja registadora", data: { confirm: '¿Está seguro de activar la caja registadora?', method: 'post' } do %>
+			                                <i class="fa fa-toggle-on"></i>
+			                              <% end %>
+			                            <% end %>
+																	<%= link_to cash_register_path(cash_register), method: :delete, class: "btn btn-icon-only btn-danger", title: "Eliminar caja registradora", data: { confirm: '¿Está seguro de eliminar la caja registradora?' } do %> <i class="fa fa-trash-o"></i>
+																	<% end %>
+																<% end %>
+															</td>
 														<% end %>
 													</tr>
 												<% end %>

+ 0 - 52
app/views/cash_registers/new.html.erb

@@ -1,52 +0,0 @@
-	<!-- BEGIN CONTAINER -->
-	<div class="page-container">
-		<!-- BEGIN CONTENT -->
-		<div class="page-content-wrapper">
-			<!-- BEGIN CONTENT BODY -->
-			<!-- BEGIN PAGE HEAD-->
-			<div class="page-head">
-				<div class="container-fluid">
-					<!-- BEGIN PAGE TITLE -->
-					<div class="page-title">
-						<h1>Caja registradora</h1>
-					</div>
-					<!-- END PAGE TITLE -->
-				</div>
-			</div>
-			<!-- END PAGE HEAD-->
-			<!-- BEGIN PAGE CONTENT BODY -->
-			<div class="page-content">
-				<div class="container-fluid">
-					<%= link_to  cash_registers_path, {:class=>"btn blue-hoki pull-right margin-bottom-10"} do %>  <i class="fa fa-angle-left "></i> Regresar
-					<% end %>
-					<!-- BEGIN PAGE BREADCRUMBS -->
-					<ul class="page-breadcrumb breadcrumb">
-						<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
-					</ul>
-					<!-- END PAGE BREADCRUMBS -->
-					<!-- BEGIN PAGE CONTENT INNER -->
-					<div class="page-content-inner">
-						<div id="notice"><%= notice %></div>
-						<div class="row ">
-							<div class="col-md-12">
-								<div class="portlet light">
-									<div class="portlet-title">
-										<div class="caption">
-											<i class="fa fa-plus font-green"></i>
-											<span class="caption-subject font-green bold uppercase">Nueva caja registradora</span>
-										</div>
-									</div>
-									<%= render 'form' %>
-								</div>
-							</div>
-						</div>                       
-					</div>
-					<!-- END PAGE CONTENT INNER -->
-				</div>
-			</div>
-			<!-- END PAGE CONTENT BODY -->
-			<!-- END CONTENT BODY -->
-		</div>
-		<!-- END CONTENT -->
-	</div>
-	<!-- END CONTAINER -->

+ 14 - 0
app/views/cash_registers/new.js.erb

@@ -0,0 +1,14 @@
+$('#dialog h3.modal-title').html("Nueva caja registradora");
+$('#dialog').removeClass('modal-lg');
+$('.modal-footer').remove();
+$('.modal-body').html(""); //limpiar el modal antes; la siguiente linea es por si se abrio previamente el detalle de venta
+$('.modal-dialog').removeClass('modal-lg');
+// Rend$( ".selector" ).dialog({ closeOnEscape: false });er the edit form
+$('.modal-body').html('<%= j render("form") %>');
+// Show the dynamic dialog
+$('#dialog').modal("show");
+
+// Set focus to the first element
+$('#dialog').on('shown.bs.modal', function () {
+  $('.first_input').focus();
+});

+ 11 - 0
app/views/cash_registers/update.js.erb

@@ -0,0 +1,11 @@
+$("#cash_register_errors").html("");
+<% if @cash_register.errors.any? %>
+  $('#cash_register_errors').removeClass('hidden');
+  <% @cash_register.errors.values.each do |message| %>
+    $("#cash_register_errors").append($("<li />").html("<%= message.first.to_s %>"));
+  <% end %>
+<% else %>
+  $('#dialog').modal('toggle');
+  window.location = "<%= cash_registers_path %>";
+  $("#notice").html("<%= flash[:notice] %>");
+<% end %>

+ 128 - 131
app/views/commissions/_sellers_for_commissions.html.erb

@@ -1,148 +1,145 @@
 <div class="form-horizontal">
-    <div class="portlet-body form">
-        <div class="form-body">
-            <div class="row">
-                <div class="col-md-12">
-                    <div class="form-group">
-                       <%= label_tag :pointsale_id,  {:class=>"col-md-3 control-label"} do %>Punto de venta <span class="required">*</span> <% end %>
-                        <div class="col-md-8" style="padding-right:0px">
-                            <% if current_user.usertype == 'A' %>
-                              <%= select_tag :pointsale_id, options_from_collection_for_select(Pointsale.activos, :id, :name), :include_blank => "Seleccione punto de venta",  class: "form-control select2" %>
-                            <% else %>
-                                <%= text_field_tag 'pointsale', current_user.pointsale.name, :class => 'form-control', :disabled => true %>
-                                <%= hidden_field_tag 'pointsale_id', current_user.pointsale_id %>
-                            <% end %>
-                        </div>
-                    </div>
-                    <div class="form-group">
-                      <%= label_tag :initial_date, "Fecha", {:class=>"col-md-2 control-label"} do %>Desde <span class="required">*</span> <% end %>
-                      <div class="col-md-3" style="padding-left:0px;padding-right:0px;margin-left:15px">
-                          <div class='input-group date' id='initial_date'>
-                              <input id="start" type='text' class="form-control"/>
-                              <span class="input-group-addon">
-                                  <span class="glyphicon glyphicon-calendar"></span>
-                              </span>
-                          </div>
-                      </div>
-                      <%= label_tag :final_date, "Fecha", {:class=>"col-md-2 control-label"} do %>Hasta <span class="required">*</span> <% end %>
-                      <div class="col-md-3" style="padding-left:0px;padding-right:0px;">
-                          <div class='input-group date' id='final_date'>
-                              <input id="end" type='text' class="form-control"/>
-                              <span class="input-group-addon">
-                                  <span class="glyphicon glyphicon-calendar"></span>
-                              </span>
-                          </div>
-                      </div>
-                      <button class="btn btn-icon-only blue" style="margin-left:25px" onclick="getSellersByDates()">
-                        <i class="fa fa-search"></i>
-                      </button>
-                    </div>
-                    <div class="form-group">
-                        <div class="form-group" id="sellers_div">
-                            <%= label_tag :sellers_ids, "Vendores", {:class=>"col-md-3 control-label"} do %>Vendedores <span class="required">*</span> <% end %>
-                            <div class="col-md-9" style="padding-left:20px">
-                                <div class="row" style="margin-bottom:10px">
-                                    <div class="col-md-12">
-                                        <button type="button" class="btn btn-default" id='select-all'><i class="fa fa fa-square-o"></i> Seleccionar todo</button>
-                                        <button style="margin-left:55px" type="button" class="btn btn-default" id='deselect-all'><i class="fa fa-square-o"></i> Deseleccionar todo</button>
-                                    </div>
-                                </div>
-                                <%= select_tag :sellers_ids, nil, multiple: true, class: 'multi-select' %>
-                            </div>
-                        </div>
-                    </div>
+  <div class="portlet-body form">
+    <div class="form-body">
+      <div class="row">
+        <div class="col-md-12">
+          <div class="form-group">
+            <%= label_tag :pointsale_id,  {:class=>"col-md-3 control-label"} do %>Punto de venta <span class="required">*</span> <% end %>
+            <div class="col-md-8" style="padding-right:0px">
+              <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
+                <%= select_tag :pointsale_id, options_from_collection_for_select(Pointsale.activos, :id, :name), :include_blank => "Seleccione punto de venta",  class: "form-control select2" %>
+              <% else %>
+                <%= text_field_tag 'pointsale', current_user.pointsale.name, :class => 'form-control', :disabled => true %>
+                <%= hidden_field_tag 'pointsale_id', current_user.pointsale_id %>
+              <% end %>
+            </div>
+          </div>
+          <div class="form-group">
+            <%= label_tag :initial_date, "Fecha", {:class=>"col-md-2 control-label"} do %>Desde <span class="required">*</span> <% end %>
+            <div class="col-md-3" style="padding-left:0px;padding-right:0px;margin-left:15px">
+              <div class='input-group date' id='initial_date'>
+                <input id="start" type='text' class="form-control"/>
+                <span class="input-group-addon">
+                  <span class="glyphicon glyphicon-calendar"></span>
+                </span>
+              </div>
+            </div>
+            <%= label_tag :final_date, "Fecha", {:class=>"col-md-2 control-label"} do %>Hasta <span class="required">*</span> <% end %>
+            <div class="col-md-3" style="padding-left:0px;padding-right:0px;">
+              <div class='input-group date' id='final_date'>
+                <input id="end" type='text' class="form-control"/>
+                <span class="input-group-addon">
+                  <span class="glyphicon glyphicon-calendar"></span>
+                </span>
+              </div>
+            </div>
+            <button class="btn btn-icon-only blue" style="margin-left:25px" onclick="getSellersByDates()">
+              <i class="fa fa-search"></i>
+            </button>
+          </div>
+          <div class="form-group">
+            <div class="form-group" id="sellers_div">
+              <%= label_tag :sellers_ids, "Vendores", {:class=>"col-md-3 control-label"} do %>Vendedores <span class="required">*</span> <% end %>
+              <div class="col-md-9" style="padding-left:20px">
+                <div class="row" style="margin-bottom:10px">
+                  <div class="col-md-12">
+                    <button type="button" class="btn btn-default" id='select-all'><i class="fa fa fa-square-o"></i> Seleccionar todo</button>
+                    <button style="margin-left:55px" type="button" class="btn btn-default" id='deselect-all'><i class="fa fa-square-o"></i> Deseleccionar todo</button>
+                  </div>
                 </div>
+                <%= select_tag :sellers_ids, nil, multiple: true, class: 'multi-select' %>
+              </div>
             </div>
+          </div>
         </div>
+      </div>
     </div>
-    <div class="form-actions">
-        <h4 class="form-section"> </h4>
-        <div class="row">
-            <div class="col-md-12">
-                <button type="button" class="btn green" disabled=​"disabled" onclick="generateCommissions()" id="generate_button">Generar comisiones</button>
-                <button type="button" class="btn default" onclick="cerrarDialog()">Cerrar</button>
-            </div>
-        </div>
+  </div>
+  <div class="form-actions">
+    <h4 class="form-section"> </h4>
+    <div class="row">
+      <div class="col-md-12">
+        <button type="button" class="btn green" disabled=​"disabled" onclick="generateCommissions()" id="generate_button">Generar comisiones</button>
+        <button type="button" class="btn default" onclick="cerrarDialog()">Cerrar</button>
+      </div>
     </div>
+  </div>
 </div>
 <script>
-    function cerrarDialog() {
-        $('#dialog').modal('toggle');
-    }
+  function cerrarDialog() {
+    $('#dialog').modal('toggle');
+  }
 
-    $('#initial_date').datetimepicker({
-        icons: {
-            date: "fa fa-calendar"
-        },
-        format: "DD/MM/YYYY"
-    });
+  $('#initial_date').datetimepicker({
+    icons: {
+      date: "fa fa-calendar"
+    },
+    format: "DD/MM/YYYY"
+  });
 
-    $('#final_date').datetimepicker({
-        icons: {
-            date: "fa fa-calendar"
-        },
-        format: "DD/MM/YYYY"
-    });
+  $('#final_date').datetimepicker({
+    icons: {
+      date: "fa fa-calendar"
+    },
+    format: "DD/MM/YYYY"
+  });
 
-    function getSellersByDates() {
-        if ($("#initial_date").data("date") && $("#final_date").data("date") && $('#pointsale_id').val()) {
+  function getSellersByDates() {
+    if ($("#initial_date").data("date") && $("#final_date").data("date") && $('#pointsale_id').val()) {
+      var initial_date = moment($("#initial_date").data("date"), "DD-MM-YYYY").startOf('day').format('YYYY-MM-DD HH:mm:ss');
+      var final_date = moment($("#final_date").data("date"), "DD-MM-YYYY").endOf('day').format('YYYY-MM-DD HH:mm:ss');
+      var pointsale_id = $('#pointsale_id').val();
+      App.blockUI({
+        target: $("#sellers_div"),
+        animate: true
+      });
 
-            var initial_date = moment($("#initial_date").data("date"), "DD-MM-YYYY").startOf('day').format('YYYY-MM-DD HH:mm:ss');
-            var final_date = moment($("#final_date").data("date"), "DD-MM-YYYY").endOf('day').format('YYYY-MM-DD HH:mm:ss');
-            var pointsale_id = $('#pointsale_id').val();
-
-            App.blockUI({
-                 target: $("#sellers_div"),
-                 animate: true
-            });
-
-            $.ajax({
-              type: "get",
-              url:  '/find_sellers_by_date/' + pointsale_id+ '/' + initial_date + '/' + final_date,
-              dataType: 'json',
-              success: function(data) {
-                  console.log(data);
-                  $('#sellers_ids').html('');
-                  for (var i = 0; i < data.length; i++) {
-                    $('#sellers_ids').append($('<option>', {
-                        value: data[i].seller_id,
-                        text : data[i].name
-                    }));
-                  }
-                  $('#sellers_ids').multiselect('refresh');
-                  App.unblockUI($("#sellers_div"));
-                  $('#generate_button').prop('disabled', false);
-              },
-                error: function (err) {
-                    App.unblockUI($("#sellers_div"));
-                    toastr["error"]('Ya se generaron comisiones para el periodo seleccionado');
-                }
-            });
-
-        } else {
-            toastr["error"]('Seleccione punto de venta y rango de fechas');
+      $.ajax({
+        type: "get",
+        url: '/find_sellers_by_date/' + pointsale_id + '/' + initial_date + '/' + final_date,
+        dataType: 'json',
+        success: function(data) {
+          $('#sellers_ids').html('');
+          for (var i = 0; i < data.length; i++) {
+            $('#sellers_ids').append($('<option>', {
+              value: data[i].seller_id,
+              text : data[i].name
+            }));
+          }
+          $('#sellers_ids').multiselect('refresh');
+          App.unblockUI($("#sellers_div"));
+          $('#generate_button').prop('disabled', false);
+        },
+        error: function (err) {
+          App.unblockUI($("#sellers_div"));
+          toastr["error"]('Ya se generaron comisiones para el periodo seleccionado');
         }
+      });
+
+    } else {
+        toastr["error"]('Seleccione punto de venta y rango de fechas');
     }
+  }
 
-    function generateCommissions() {
-       if($('#sellers_ids').val()) {
-            var initial_date = moment($("#initial_date").data("date"), "DD-MM-YYYY").startOf('day').format('YYYY-MM-DD HH:mm:ss');
-            var final_date = moment($("#final_date").data("date"), "DD-MM-YYYY").endOf('day').format('YYYY-MM-DD HH:mm:ss');
-            $.ajax({
-              type: "get",
-              url:  '/generate_commissions/',
-              dataType: 'script',
-              data: {
-                sellers_ids: $('#sellers_ids').val(),
-                pointsale_id: $('#pointsale_id').val(),
-                initial_date: initial_date,
-                final_date: final_date
-              },
-              success: function(data) {
-              }
-            });
-       } else {
-            toastr["error"]('Seleccione vendedores para generar comisiones');
-       }
+  function generateCommissions() {
+    if($('#sellers_ids').val()) {
+      var initial_date = moment($("#initial_date").data("date"), "DD-MM-YYYY").startOf('day').format('YYYY-MM-DD HH:mm:ss');
+      var final_date = moment($("#final_date").data("date"), "DD-MM-YYYY").endOf('day').format('YYYY-MM-DD HH:mm:ss');
+      $.ajax({
+        type: "get",
+        url: '/generate_commissions/',
+        dataType: 'script',
+        data: {
+          sellers_ids: $('#sellers_ids').val(),
+          pointsale_id: $('#pointsale_id').val(),
+          initial_date: initial_date,
+          final_date: final_date
+        },
+        success: function(data) {
+        }
+      });
+    } else {
+      toastr["error"]('Seleccione vendedores para generar comisiones');
     }
+  }
 </script>

+ 58 - 72
app/views/customers/customer_sales.html.erb

@@ -85,9 +85,9 @@
 																		</span>
 																	</div>
 																</div>
-															<button class="btn btn-icon-only blue" style="margin-left:25px" onclick="salesByDate()">
-																<i class="fa fa-search"></i>
-															</button>
+																<button class="btn btn-icon-only blue" style="margin-left:25px" onclick="salesByDate()">
+																	<i class="fa fa-search"></i>
+																</button>
 															</div>
 														</div>
 													</div>
@@ -99,7 +99,7 @@
 														<tr>
 															<th>#</th>
 															<th>Código de venta</th>
-															<% if current_user.usertype == 'A' %>
+															<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 																<th>Punto de venta</th>
 															<% end %>
 															<th>Vendedor</th>
@@ -113,67 +113,54 @@
 															<th width="15%">Acciones</th>
 														</tr>
 													</thead>
-													<tbody id="customer_sales" >
-													<% @sales.each_with_index do |sale, key| %>
-														<tr class=<%= (sale.cancelled? ? 'danger' : (sale.paid? ? 'success' : '')) %>>
-															<td><%= sale.id %></td>
-															<td><%= sale.sale_code %> </td>
-															<% if current_user.usertype == 'A' %>
-																<td> <%= sale.get_pointsale.name %> </td>
-															<% end %>
-															<td><%= sale.user.first_name %> </td>
-															<td><%= l(sale.date_sale, :format => '%d/%m/%Y') %></td>
-															<td>
-															<% if sale.saletype == "credit" && sale.credit_note.blank? %>
-																Crédito
-															<% elsif sale.saletype == "credit" && sale.credit_note.present? %>
-																Crédito/vale
-															<% else %>
-																Contado
-															<% end %>
-															</td>
-															<td><%= sale.products.count %></td>
-															<td>
-															<% case sale.status %>
-																<% when "paid"%>
-																	<span class="label label-success"> PAGADA </span>
-																<% when "cancelled"%>
-																	<span class="label label-danger"> CANCELADO </span>
-																<% when "parcial"%>
-																	<span class="label label-warning"> ABONADA </span>
-																<% when "notpaid"%>
-																	<span class="label label-default"> PENDIENTE PAGO </span>
-															<% end %>
-															</td>
-															<td><%= number_to_currency(sale.total, precision: 2) %></td>
-
-															<% credito = Credit.where(:sale_id => sale.id).first %>
-
-															<% if credito.present? %>
-																<% abonos = CreditPayment.where(:credit_id => credito.id, :status => 0).sum(:quantity) %>
-																<% if abonos.present? %>
-																	<td><%= number_to_currency(abonos, precision: 2) %></td>
+													<tbody id="customer_sales">
+														<% @sales.each_with_index do |sale, key| %>
+															<tr class=<%= (sale.cancelled? ? 'danger' : (sale.paid? ? 'success' : '')) %>>
+																<td><%= sale.id %></td>
+																<td><%= sale.sale_code %> </td>
+																<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
+																	<td> <%= sale.get_pointsale.name %> </td>
 																<% end %>
-																<td><%= number_to_currency(credito.rest, precision: 2) %></td>
-															<% else %>
-																<td></td>
-																<td></td>
-															<% end %>
-
-															<td class="text-center">
-																<%= link_to sale, {:class=>"btn btn-icon-only default", :title=>"Ver venta"} do %>
-																	<i class="fa fa-search"></i>
+																<td><%= sale.user.first_name %> </td>
+																<td><%= l(sale.date_sale, :format => '%d/%m/%Y') %></td>
+																<td>
+																	<% if sale.saletype == "credit" && sale.credit_note.blank? %>
+																		Crédito
+																	<% elsif sale.saletype == "credit" && sale.credit_note.present? %>
+																		Crédito/vale
+																	<% else %>
+																		Contado
+																	<% end %>
+																</td>
+																<td><%= sale.products.count %></td>
+																<td><%= sale_status(sale) %></td>
+																<td><%= number_to_currency(sale.total, precision: 2) %></td>
+																<% credito = Credit.where(:sale_id => sale.id).first %>
+																<% if credito.present? %>
+																	<% abonos = CreditPayment.where(:credit_id => credito.id, :status => 0).sum(:quantity) %>
+																	<% if abonos.present? %>
+																		<td><%= number_to_currency(abonos, precision: 2) %></td>
+																	<% end %>
+																	<td><%= number_to_currency(credito.rest, precision: 2) %></td>
+																<% else %>
+																	<td></td>
+																	<td></td>
 																<% end %>
-															<% if can? :destroy, Sale %>
-																<% daysToCancel = @pos_config.days_cancel_sale %>
-																	<% if (sale.date_sale + daysToCancel.days >= Date.today) && !sale.cancelled? %>
-																		<%= link_to sale , method: :delete, :class => "btn btn-icon-only btn-danger", :title=>"Cancelar venta", data: { confirm: '¿Esta seguro que desea cancelar la venta?'}   do %> <i class="fa fa-ban"></i>
+
+																<td class="text-center">
+																	<%= link_to sale, {:class=>"btn btn-icon-only default", :title=>"Ver venta"} do %>
+																		<i class="fa fa-search"></i>
+																	<% end %>
+																	<% if can? :destroy, Sale %>
+																		<% daysToCancel = @pos_config.days_cancel_sale %>
+																		<% if (sale.date_sale + daysToCancel.days >= Date.today) && !sale.cancelled? %>
+																			<%= link_to sale , method: :delete, :class => "btn btn-icon-only btn-danger", :title=>"Cancelar venta", data: { confirm: '¿Está seguro que desea cancelar la venta?' } do %> <i class="fa fa-ban"></i>
+																			<% end %>
 																		<% end %>
 																	<% end %>
-															<% end %>
-															</td>
-														</tr>
-													<% end %>
+																</td>
+															</tr>
+														<% end %>
 													</tbody>
 												</table>
 												</div>
@@ -212,11 +199,10 @@
 																		<span class="label label-success"> ACTIVO </span>
 																	<% end %>
 																</td>
-
 																<td class="text-center">
 																<% if !abono.cancelled? && abono.cash_registers_move.present? && abono.cash_registers_move.open_cash_register.open?%>
-																		<%= link_to cash_move_delete_payment_path(:credit_payment_id => abono.id, :credit => credit.id) , method: :delete_credit_payment, :class => "btn btn-icon-only btn-danger", :title=>"Cancelar abono", data: { confirm: '¿Esta seguro que desea cancelar el abono?'}   do %> <i class="fa fa-ban"></i>
-																		<% end %>
+																	<%= link_to cash_move_delete_payment_path(:credit_payment_id => abono.id, :credit => credit.id) , method: :delete_credit_payment, :class => "btn btn-icon-only btn-danger", :title=>"Cancelar abono", data: { confirm: '¿Está seguro que desea cancelar el abono?' } do %> <i class="fa fa-ban"></i>
+																	<% end %>
 																<% end %>
 																</td>
 															</tr>
@@ -269,20 +255,20 @@
 		var end = moment($("#end_date").data("date"), "DD-MM-YYYY").format('YYYY-MM-DD HH:mm:ss');
 		var cliente = '<%= @custom.id %>'
 		App.blockUI({
-				 target: $("#sales_table"),
-				 animate: true
+			target: $("#sales_table"),
+			animate: true
 		});
 		$.ajax({
 			type: "get",
 			url:  '/find_customer_sales_by_date/' + start + '/' + end + '/' + cliente,
 			dataType: 'script',
 			success: function(data) {
-					window.setTimeout(function() {
-						App.unblockUI($("#sales_table"));
-						var startDate = moment($("#begin_date").data("date"), "DD-MM-YYYY").format('DD/MM/YYYY')
-						var endDate = moment($("#end_date").data("date"), "DD-MM-YYYY").format('DD/MM/YYYY');
-						$('#title_for_print').val('Ventas del ' + startDate + ' al ' + endDate);
-					}, 100);
+				window.setTimeout(function() {
+					App.unblockUI($("#sales_table"));
+					var startDate = moment($("#begin_date").data("date"), "DD-MM-YYYY").format('DD/MM/YYYY')
+					var endDate = moment($("#end_date").data("date"), "DD-MM-YYYY").format('DD/MM/YYYY');
+					$('#title_for_print').val('Ventas del ' + startDate + ' al ' + endDate);
+				}, 100);
 			}
 		});
 	}

+ 78 - 78
app/views/dashboard/_dashboard_for_admin.html.erb

@@ -1,104 +1,104 @@
 <div class="row">
-    <div class="col-md-12">
-        <div class="col-md-6">
-            <div class="portlet light">
-                <div class="portlet-title">
-                    <div class="caption caption-md">
-                        <i class="icon-bar-chart font-red"></i>
-                        <span class="caption-subject font-red uppercase bold">Ingresos por punto de venta</span>
-                    </div>
-                    <div class="actions">
-                        <div class="btn-group btn-group-devided" data-toggle="buttons">
-                            <label class="btn btn-transparent grey-salsa btn-outline btn-circle btn-sm active">
-                                <input type="radio" name="optionsIncomings" class="toggle" value="day">Día
-                            </label>                        
-                            <label class="btn btn-transparent grey-salsa btn-outline btn-circle btn-sm">
-                                <input type="radio" name="optionsIncomings" class="toggle" value="week">Semana
-                            </label>
-                            <label class="btn btn-transparent grey-salsa btn-outline btn-circle btn-sm">
-                                <input type="radio" name="optionsIncomings" class="toggle" value="month">Mes
-                            </label>
-                        </div>
-                    </div>
-                </div>
-                    <div id="incomingsByPointsaleChart" class="chart" style="width:100%;height:400px;font-size:11px;"></div>
+  <div class="col-md-12">
+    <div class="col-md-6">
+      <div class="portlet light">
+        <div class="portlet-title">
+          <div class="caption caption-md">
+            <i class="icon-bar-chart font-red"></i>
+            <span class="caption-subject font-red uppercase bold">Ingresos por punto de venta</span>
+          </div>
+          <div class="actions">
+            <div class="btn-group btn-group-devided" data-toggle="buttons">
+              <label class="btn btn-transparent grey-salsa btn-outline btn-circle btn-sm active">
+                <input type="radio" name="optionsIncomings" class="toggle" value="day">Día
+              </label>
+              <label class="btn btn-transparent grey-salsa btn-outline btn-circle btn-sm">
+                <input type="radio" name="optionsIncomings" class="toggle" value="week">Semana
+              </label>
+              <label class="btn btn-transparent grey-salsa btn-outline btn-circle btn-sm">
+                <input type="radio" name="optionsIncomings" class="toggle" value="month">Mes
+              </label>
             </div>
+          </div>
         </div>
+          <div id="incomingsByPointsaleChart" class="chart" style="width:100%;height:400px;font-size:11px;"></div>
+      </div>
+    </div>
 
-        <div class="col-md-6">
-            <div class="portlet light">
-                <div class="portlet-title">
-                    <div class="caption caption-md">
-                        <i class="icon-bar-chart font-red"></i>
-                        <span class="caption-subject font-red uppercase bold">10 productos mas vendidos</span>
-                    </div>
-                    <div class="actions">
-                        <div class="btn-group btn-group-devided" data-toggle="buttons">
-                            <label class="btn btn-transparent grey-salsa btn-outline btn-circle btn-sm active">
-                                <input type="radio" name="optionsRanking" class="toggle" value="week">Semana
-                            </label>
-                            <label class="btn btn-transparent grey-salsa btn-outline btn-circle btn-sm">
-                                <input type="radio" name="optionsRanking" class="toggle" value="month">Mes
-                            </label>
-                        </div>
-                    </div>
-                </div>
-                 <div id="productRankingChart" class="chart" style="width:100%;height:400px;font-size:11px;"></div>
+    <div class="col-md-6">
+      <div class="portlet light">
+        <div class="portlet-title">
+          <div class="caption caption-md">
+            <i class="icon-bar-chart font-red"></i>
+            <span class="caption-subject font-red uppercase bold">10 productos mas vendidos</span>
+          </div>
+          <div class="actions">
+            <div class="btn-group btn-group-devided" data-toggle="buttons">
+              <label class="btn btn-transparent grey-salsa btn-outline btn-circle btn-sm active">
+                <input type="radio" name="optionsRanking" class="toggle" value="week">Semana
+              </label>
+              <label class="btn btn-transparent grey-salsa btn-outline btn-circle btn-sm">
+                <input type="radio" name="optionsRanking" class="toggle" value="month">Mes
+              </label>
             </div>
+          </div>
         </div>
+         <div id="productRankingChart" class="chart" style="width:100%;height:400px;font-size:11px;"></div>
+      </div>
     </div>
+  </div>
 </div>
 
 <script type="text/javascript">
 $(document).on("page:change", function() {
-    // ingresos por punto de venta
-    MakeChart('serial', <%= @incomings %>, 'incomingsByPointsaleChart', 'pointsale', 'total');
-    // ranking de productos
-    MakeChart('pie', <%= @product_ranking %>, 'productRankingChart', 'product', 'quantity');    
+  // ingresos por punto de venta
+  MakeChart('serial', <%= @incomings %>, 'incomingsByPointsaleChart', 'pointsale', 'total');
+  // ranking de productos
+  MakeChart('pie', <%= @product_ranking %>, 'productRankingChart', 'product', 'quantity');
 });
 
 
 $('input:radio[name=optionsIncomings]').change(function() {
-    var period = $('input:radio[name=optionsIncomings]:checked').val();
-    getChart('incomings', period);
+  var period = $('input:radio[name=optionsIncomings]:checked').val();
+  getChart('incomings', period);
 });
 
 $('input:radio[name=optionsRanking]').change(function() {
-    var period = $('input:radio[name=optionsRanking]:checked').val();
-    getChart('products', period);
+  var period = $('input:radio[name=optionsRanking]:checked').val();
+  getChart('products', period);
 });
 
 setTimeout(function() {
-    $('.chart a').remove();
+  $('.chart a').remove();
 }, 1000);
 
 
 function getChart(chart, period) {
-    App.blockUI({
-         target: $((chart == "incomings" ? "#incomingsByPointsaleChart" : "#productRankingChart")),
-         animate: true
-    });
-    $.ajax({
-      type: "get",
-      url:  '/get_chart_data_for_dashboard/',
-      data: {
-        period: period,
-        chart: chart
-      },
-      dataType: 'text',
-      success: function(data) {
-          var data = JSON.parse(data);
-          window.setTimeout(function() {
-            App.unblockUI($((chart == "incomings" ? "#incomingsByPointsaleChart" : "#productRankingChart")));
-            
-            if (chart == 'incomings') {
-                MakeChart('serial', data, 'incomingsByPointsaleChart', 'pointsale', 'total');
-            } else {
-                MakeChart('pie', data, 'productRankingChart', 'product', 'quantity');
-            }
-            $('.chart a').remove();
-          }, 100);
-      }
-    });    
+  App.blockUI({
+    target: $((chart == "incomings" ? "#incomingsByPointsaleChart" : "#productRankingChart")),
+    animate: true
+  });
+  $.ajax({
+    type: "get",
+    url:  '/get_chart_data_for_dashboard/',
+    data: {
+    period: period,
+    chart: chart
+    },
+    dataType: 'text',
+    success: function(data) {
+      var data = JSON.parse(data);
+      window.setTimeout(function() {
+        App.unblockUI($((chart == "incomings" ? "#incomingsByPointsaleChart" : "#productRankingChart")));
+
+        if (chart == 'incomings') {
+          MakeChart('serial', data, 'incomingsByPointsaleChart', 'pointsale', 'total');
+        } else {
+          MakeChart('pie', data, 'productRankingChart', 'product', 'quantity');
+        }
+        $('.chart a').remove();
+      }, 100);
+    }
+  });
 }
-</script>
+</script>

+ 1 - 1
app/views/dashboard/index.html.erb

@@ -40,7 +40,7 @@
 							</div>
 						<% end %>
 					</div>
-					<% if current_user.usertype == 'A' %>
+					<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 						<%= render 'dashboard/dashboard_for_admin' %>
 					<% elsif current_user.usertype == 'G' %>
 						<%= render 'dashboard/dashboard_for_manager' %>

+ 54 - 54
app/views/expenses/_expenses_for_admin.html.erb

@@ -2,10 +2,10 @@
   <div class="col-md-2 col-sm-3 col-xs-3">
     <ul class="nav nav-tabs tabs-left">
       <li class="active">
-          <a href="#puntosdeventa" data-toggle="tab"> Puntos de venta </a>
+        <a href="#puntosdeventa" data-toggle="tab"> Puntos de venta </a>
       </li>
       <li>
-          <a href="#generales" data-toggle="tab"> Generales </a>
+        <a href="#generales" data-toggle="tab"> Generales </a>
       </li>
     </ul>
   </div>
@@ -18,10 +18,10 @@
               <thead>
                 <tr>
                   <th>#</th>
-                  <th>Código de egreso</th>
-                  <th>Concepto de egreso</th>
-                  <th>Punto de venta</th>
-                  <th>Caja registradora</th>
+                  <th>Código<br>de egreso</th>
+                  <th>Concepto<br>de egreso</th>
+                  <th>Punto<br>de venta</th>
+                  <th>Caja<br>registradora</th>
                   <th>Fecha</th>
                   <th>Cantidad</th>
                   <th>Observaciones</th>
@@ -31,31 +31,31 @@
               </thead>
               <tbody>
                 <% @from_pointsale.each_with_index do |expense, key| %>
-                <tr>
-                  <td><%= expense.id %></td>
-                  <td><%= expense.expense_code %></td>
-                  <td><%= expense.expensesconcept.name %></td>
-                  <td><%= expense.open_cash_register.cash_register.pointsale.name %></td>
-                  <td><%= expense.open_cash_register.cash_register.name %></td>
-                  <td><%= l(expense.created_at, :format => '%d/%B/%Y') %> </td>
-                  <td><%= number_to_currency(expense.quantity, precision: 2) %> </td>
-                  <td><%= expense.observations %> </td>
-                  <td>
-                    <% case expense.status %>
-                    <% when "active"%>
-                      <span class="label label-sm label-warning"> <i class="fa fa-clock-o"></i> Caja abierta </span>
-                    <% when "canceled"%>
-                       <span class="label label-sm label-danger"> <i class="fa fa-close"></i> Cancelada </span>
-                    <% when "registered"%>
-                       <span class="label label-sm label-success"><i class="fa fa-check"></i>  Caja cerrada </span>
-                    <% end %>
-                  </td>
-                  <td class="text-center">
-                    <% if expense.status == "active" %>
-                      <%= link_to expense, method: :delete, :class => "btn btn-icon-only btn-danger", :title=>"Cancelar egreso", data: { confirm: '¿Está seguro que desea cancelar el egreso?' } do %> <i class="fa fa-ban"></i><% end %>
-                    <% end %>
-                  </td>
-                </tr>
+                  <tr>
+                    <td><%= expense.id %></td>
+                    <td><%= expense.expense_code %></td>
+                    <td><%= expense.expensesconcept.name %></td>
+                    <td><%= expense.open_cash_register.cash_register.pointsale.name %></td>
+                    <td><%= expense.open_cash_register.cash_register.name %></td>
+                    <td><%= l(expense.created_at, format: '%d/%B/%Y') %> </td>
+                    <td><%= number_to_currency(expense.quantity, precision: 2) %> </td>
+                    <td><%= expense.observations %> </td>
+                    <td>
+                      <% case expense.status %>
+                      <% when "active"%>
+                        <span class="label label-sm label-warning"> <i class="fa fa-clock-o"></i> Caja abierta </span>
+                      <% when "canceled"%>
+                         <span class="label label-sm label-danger"> <i class="fa fa-close"></i> Cancelada </span>
+                      <% when "registered"%>
+                         <span class="label label-sm label-success"><i class="fa fa-check"></i>  Caja cerrada </span>
+                      <% end %>
+                    </td>
+                    <td class="text-center">
+                      <% if expense.active? %>
+                        <%= link_to expense, method: :delete, class: "btn btn-icon-only btn-danger", title: "Cancelar egreso", data: { confirm: '¿Está seguro que desea cancelar el egreso?' } do %> <i class="fa fa-ban"></i><% end %>
+                      <% end %>
+                    </td>
+                  </tr>
                 <% end %>
               </tbody>
             </table>
@@ -69,8 +69,8 @@
               <thead>
                 <tr>
                   <th>#</th>
-                  <th>Código de egreso</th>
-                  <th>Concepto de gasto</th>
+                  <th>Código<br>de egreso</th>
+                  <th>Concepto<br>de gasto</th>
                   <th>Fecha</th>
                   <th>Cantidad</th>
                   <th>Observaciones</th>
@@ -80,27 +80,27 @@
               </thead>
               <tbody>
                 <% @general_expenses.each_with_index do |expense, key| %>
-                <tr>
-                  <td><%= expense.id %></td>
-                  <td><%= expense.expense_code %></td>
-                  <td><%= expense.expensesconcept.name %></td>
-                  <td><%= l(expense.expense_date, :format => '%d/%B/%Y') %> </td>
-                  <td><%= number_to_currency(expense.quantity, precision: 2) %> </td>
-                  <td><%= expense.observations %> </td>
-                  <td>
-                    <% case expense.status %>
-                    <% when "active"%>
-                      <span class="label label-sm label-success"> <i class="fa fa-check"></i> Activo </span>
-                    <% when "canceled"%>
-                       <span class="label label-sm label-danger"> <i class="fa fa-close"></i> Cancelado </span>
-                    <% end %>
-                  </td>
-                  <td class="text-center">
-                    <% if expense.active? %>
-                      <%= link_to expense, method: :delete, :class => "btn btn-icon-only btn-danger", :title=>"Cancelar egreso", data: { confirm: '¿Está seguro que desea cancelar el egreso?' } do %> <i class="fa fa-ban"></i><% end %>
-                    <% end %>
-                  </td>
-                </tr>
+                  <tr>
+                    <td><%= expense.id %></td>
+                    <td><%= expense.expense_code %></td>
+                    <td><%= expense.expensesconcept.name %></td>
+                    <td><%= l(expense.expense_date, format: '%d/%B/%Y') %> </td>
+                    <td><%= number_to_currency(expense.quantity, precision: 2) %> </td>
+                    <td><%= expense.observations %> </td>
+                    <td>
+                      <% case expense.status %>
+                      <% when "active"%>
+                        <span class="label label-sm label-success"> <i class="fa fa-check"></i> Activo </span>
+                      <% when "canceled"%>
+                         <span class="label label-sm label-danger"> <i class="fa fa-close"></i> Cancelado </span>
+                      <% end %>
+                    </td>
+                    <td class="text-center">
+                      <% if expense.active? %>
+                        <%= link_to expense, method: :delete, class: "btn btn-icon-only btn-danger", title: "Cancelar egreso", data: { confirm: '¿Está seguro que desea cancelar el egreso?' } do %> <i class="fa fa-ban"></i> <% end %>
+                      <% end %>
+                    </td>
+                  </tr>
                 <% end %>
               </tbody>
             </table>

+ 2 - 2
app/views/expenses/_expenses_for_manager.html.erb

@@ -33,8 +33,8 @@
         <% end %>
       </td>
       <td class="text-center">
-        <% if expense.status == "active" %>
-          <%= link_to expense , method: :delete, :class => "btn btn-icon-only btn-danger", :title=>"Cancelar egreso", data: { confirm: '¿Esta seguro que desea cancelar el egreso?'}   do %> <i class="fa fa-ban"></i><% end %>
+        <%= expense.active? %>
+          <%= link_to expense, method: :delete, class: "btn btn-icon-only btn-danger", title: "Cancelar egreso", data: { confirm: '¿Está seguro que desea cancelar el egreso?' } do %> <i class="fa fa-ban"></i><% end %>
         <% end %>
       </td>
     </tr>

+ 68 - 80
app/views/expenses/_form.html.erb

@@ -1,97 +1,86 @@
-<!-- BEGIN FORM-->
-<%= form_for(@expense, :html => {:class=>"form-horizontal"}) do |f| %>
-<div class="portlet-body form">
-  <% if @expense.errors.any? %>
-    <div class="alert alert-danger">
-      <strong>Tiene <%= pluralize(@expense.errors.count, "error") %> no se puede guardar el gasto</strong><br>
-    </div>
-  <% end %>
-  <div class="form-body">
-    <div class="row">
-      <div class="col-md-8">
-        <%= hidden_field_tag :concept_purchase_payment, @concept_purchase_payment.id %>
-        <div class="form-group">
-          <%= f.label :expense_code, {:class=>"col-md-3 control-label"} do %> Código de egreso
-          <span class="required">*</span>
-          <% end %>
-          <div class="col-md-4 input-group">
-            <span class="input-group-addon"><i class="fa fa-barcode"></i></span>
-            <%= f.text_field :expense_code, { :class=>"form-control", :readonly => true} %>
-          </div>
-        </div>
-        <% if current_user.usertype == "A" %>
+<%= form_for(@expense, html: { class: "form-horizontal" }) do |f| %>
+  <div class="portlet-body form">
+    <% if @expense.errors.any? %>
+      <div class="alert alert-danger">
+        <strong>Tiene <%= pluralize(@expense.errors.count, "error") %> no se puede guardar el gasto</strong><br>
+      </div>
+    <% end %>
+    <div class="form-body">
+      <div class="row">
+        <div class="col-md-8">
+          <%= hidden_field_tag :concept_purchase_payment, @concept_purchase_payment.id %>
           <div class="form-group">
-            <%= f.label :expense_date, "Fecha", {:class=>"col-md-3 control-label"} do %> Fecha
-            <span class="required">*</span>
-            <% end %>
-                <div class="col-sm-4" style="padding-left:0px;padding-right:0px;">
-                    <div class='input-group date' id='datetimepicker1'>
-                        <span class="input-group-addon">
-                            <span class="glyphicon glyphicon-calendar"></span>
-                        </span>
-                        <%= f.text_field :expense_date, class: 'form-control'%>
-                    </div>
-                </div>
+            <%= f.label :expense_code, { class: "col-md-3 control-label" } do %> Código de egreso <span class="required">*</span> <% end %>
+            <div class="col-md-4 input-group">
+              <span class="input-group-addon"><i class="fa fa-barcode"></i></span>
+              <%= f.text_field :expense_code, { class: "form-control", readonly: true } %>
+            </div>
           </div>
-        <% end %>
-        <% if current_user.usertype != "A" %>
+          <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
+            <div class="form-group">
+              <%= f.label :expense_date, "Fecha", { class: "col-md-3 control-label" } do %> Fecha <span class="required">*</span> <% end %>
+              <div class="col-sm-4" style="padding-left:0px;padding-right:0px;">
+                <div class='input-group date' id='datetimepicker1'>
+                  <span class="input-group-addon">
+                    <span class="glyphicon glyphicon-calendar"></span>
+                  </span>
+                  <%= f.text_field :expense_date, class: 'form-control' %>
+                </div>
+              </div>
+            </div>
+          <% else %>
+            <div class="form-group">
+              <%= f.label :open_cash_register_id, "Caja registradora", { class: "col-md-3 control-label" } do %> Caja registradora <span class="required">*</span> <% end %>
+              <div class="input-group col-md-4 select2-bootstrap-prepend">
+                <%= f.select :open_cash_register_id, @current_user.pointsale.open_cash_registers.abiertas.map{ |o| [o.cash_register.name, o.id] }, { prompt: "Seleccione" }, { class: 'form-control select2', disabled: @is_cashier } %>
+                <% if current_user.usertype == 'C' %>
+                  <%= f.hidden_field :open_cash_register_id %>
+                <% end %>
+              </div>
+            </div>
+          <% end %>
           <div class="form-group">
-            <%= f.label :open_cash_register_id, "Caja registradora", {:class=>"col-md-3 control-label"} do %> Caja registradora
+            <%= f.label :expensesconcept_id, "Concepto", { class: "col-md-3 control-label" } do %>Concepto de egreso <span class="required">*</span> <% end %>
+            <div class="input-group col-md-4 select2-bootstrap-prepend">
+              <%= f.collection_select :expensesconcept_id, @expenses_concepts, :id, :name, { prompt: "Seleccione" }, { class: "form-control select2", style: "width: 100%" } %>
+            </div>
+          </div>
+          <div class="form-group hidden" id="purchases_div">
+            <%= f.label :purchases, "Concepto", { class: "col-md-3 control-label" } do %>Compras
             <span class="required">*</span>
             <% end %>
             <div class="input-group col-md-4 select2-bootstrap-prepend">
-              <%= f.select :open_cash_register_id, @current_user.pointsale.open_cash_registers.abiertas.map{|o| [o.cash_register.name, o.id]}, {:prompt => "Seleccione"}, { :class => 'form-control select2', :disabled => @is_cashier} %>
-              <% if current_user.usertype == 'C' %>
-                <%= f.hidden_field :open_cash_register_id %>
+              <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
+                <%= select_tag "purchases", options_from_collection_for_select(Purchase.notpaid, :id, :code_with_price), include_blank: "Seleccione", class: "form-control select2" %>
+              <% else %>
+                <%= select_tag "purchases", options_from_collection_for_select(Purchase.notpaid.where(pointsale_id: current_user.pointsale_id), :id, :code_with_price), include_blank: "Seleccione", class: "form-control select2" %>
               <% end %>
             </div>
           </div>
-        <% end %>
-        <div class="form-group">
-          <%= f.label :expensesconcept_id, "Concepto", {:class=>"col-md-3 control-label"} do %>Concepto de egreso
-          <span class="required">*</span>
-          <% end %>
-          <div class="input-group col-md-4 select2-bootstrap-prepend">
-            <%= f.collection_select :expensesconcept_id, @expenses_concepts, :id, :name, {:prompt => "Seleccione"}, {:class => "form-control select2", :style => "width: 100%"} %>
-          </div>
-        </div>
-
-        <div class="form-group hidden" id="purchases_div">
-          <%= f.label :purchases, "Concepto", {:class=>"col-md-3 control-label"} do %>Compras
-          <span class="required">*</span>
-          <% end %>
-          <div class="input-group col-md-4 select2-bootstrap-prepend">
-            <% if current_user.usertype == 'A' %>
-              <%= select_tag "purchases", options_from_collection_for_select(Purchase.notpaid, :id, :code_with_price), :include_blank => "Seleccione",  class: "form-control select2" %>
-            <% else %>
-              <%= select_tag "purchases", options_from_collection_for_select(Purchase.notpaid.where(:pointsale_id => current_user.pointsale_id), :id, :code_with_price), :include_blank => "Seleccione",  class: "form-control select2" %>
+          <div class="form-group">
+            <%= f.label :quantity, { class: "col-md-3 control-label" } do %>Cantidad <span class="required">*</span>
             <% end %>
+            <div class="col-md-4" style="padding-left:0px;padding-right:0px">
+              <%= f.number_field :quantity, { class: "form-control" } %>
+            </div>
           </div>
-        </div>
-        <div class="form-group">
-          <%= f.label :quantity,  {:class=>"col-md-3 control-label"} do %>Cantidad <span class="required">*</span>
-          <% end %>
-          <div class="col-md-4" style="padding-left:0px;padding-right:0px">
-            <%= f.number_field :quantity, {:class=>"form-control" }  %>
-          </div>
-        </div>
-        <div class="form-group">
-          <%= f.label :observations, "Observaciones", {:class=>"col-md-3 control-label"} %>
-          <div class="col-md-9" style="padding-left:0px">
-            <%= f.text_area :observations, {:class=>"form-control", :rows=>5} %>
+          <div class="form-group">
+            <%= f.label :observations, "Observaciones", { class: "col-md-3 control-label" } %>
+            <div class="col-md-9" style="padding-left:0px">
+              <%= f.text_area :observations, { class: "form-control", rows: 5 } %>
+            </div>
           </div>
-        </div>
+      </div>
     </div>
-  </div>
-  <div class="form-actions">
-    <div class="row">
-      <div class="col-md-9">
-        <%= f.submit 'Guardar', {:class=>"btn green"} %>
-        <%= link_to 'Cancelar', expenses_path, {:class=>"btn default"} %>
+    <div class="form-actions">
+      <div class="row">
+        <div class="col-md-9">
+          <%= f.submit 'Guardar', { class: "btn green" } %>
+          <%= link_to 'Cancelar', expenses_path, { class: "btn default" } %>
+        </div>
       </div>
     </div>
   </div>
-</div>
 <% end %>
 <script type="text/javascript">
   $(document).on('page:change', function() {
@@ -126,7 +115,7 @@
     });
 
   function generateExpenseCode() {
-    <% if current_user.usertype == 'A' %>
+    <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
       $.ajax({
         type: "get",
         url:  '/get_next_expense_code/0',
@@ -149,4 +138,3 @@
     <% end %>
   }
 </script>
-

+ 3 - 3
app/views/expenses/index.html.erb

@@ -44,13 +44,13 @@
                   </div>
                   <div class="actions">
                     <% if can? :create, Expense %>
-                    <%= link_to new_expense_path, {:class=>"btn bold green pull-right"} do %> Nuevo egreso <i class="fa fa-plus"></i>
-                    <% end %>
+                      <%= link_to new_expense_path, {:class=>"btn bold green pull-right"} do %> Nuevo egreso <i class="fa fa-plus"></i>
+                      <% end %>
                     <% end %>
                   </div>
                 </div>
                 <div class="portlet-body">
-                  <% if current_user.usertype == "A" %>
+                  <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
                     <%= render partial: 'expenses/expenses_for_admin' %>
                   <% else %>
                     <%= render partial: 'expenses/expenses_for_manager' %>

+ 66 - 67
app/views/expensesconcepts/_form.html.erb

@@ -1,78 +1,78 @@
-<%= form_for(@expensesconcept, :html => {:class=>"form-horizontal"}) do |f| %>
-
-<div class="portlet-body form">
-	<% if @expensesconcept.errors.any? %>
-	<div class="alert alert-danger">
-		<strong>Tiene <%= pluralize(@expensesconcept.errors.count, "error") %> no se puede guardar el concepto de egreso</strong><br>
-	</div>
-	<% end %>
-	<div class="form-body">
-		<div class="form-group">
-			<%= f.label :name, "Nombre del Concepto", {:class=>"col-md-3 control-label"} do %> Nombre del concepto
-				<span class="required">*</span>
-			<% end %>
-			<div class="col-md-9">
-				<%= f.text_field :name, {:class=>"form-control"} %>
-			</div>
+<%= form_for(@expensesconcept, html: { class: "form-horizontal" }) do |f| %>
+	<div class="portlet-body form">
+		<% if @expensesconcept.errors.any? %>
+		<div class="alert alert-danger">
+			<strong>Tiene <%= pluralize(@expensesconcept.errors.count, "error") %> no se puede guardar el concepto de egreso</strong><br>
 		</div>
-		<div class="form-group">
-			<%= f.label :decription, "Descripción", {:class=>"col-md-3 control-label"} %>
-			<div class="col-md-9">
-				<%= f.text_field :description, {:class=>"form-control"} %>
+		<% end %>
+		<div class="form-body">
+			<div class="form-group">
+				<%= f.label :name, "Nombre del Concepto", { class: "col-md-3 col-sm-3 control-label" } do %> Nombre del concepto
+					<span class="required">*</span>
+				<% end %>
+				<div class="col-md-5 col-sm-5">
+					<%= f.text_field :name, { class: "form-control" } %>
+				</div>
 			</div>
-		</div>
-		<% if @expensesconcept.persisted? %>
-		<div class="form-group">
-			<%= f.label :status, {:class=>"col-md-3 control-label"} %>
-			<div class="col-md-9">
-				<%= f.check_box(:status,
-					{
-						class: "make-switch",
-						data: {
-							on_color: "success",
-							off_color: "danger",
-							on_text: "Activo",
-							off_text: "Inactivo"
-						}
-					},
-					"active", "inactive"
-				) %>
+			<div class="form-group">
+				<%= f.label :decription, "Descripción", { class: "col-md-3 col-sm-3 control-label" } %>
+				<div class="col-md-5 col-sm-5">
+					<%= f.text_area :description, { class: "form-control", rows: 5 } %>
+				</div>
 			</div>
-		</div>
-		<% end %>
-		<div class="form-group ">
-			<%= f.label :allpoints, "Aplica a todo los puntos de venta?", {:class=>"col-md-3 control-label"} %>
-			<div class="col-md-9">
-				<%= f.check_box(:allpoints,
-					{
-						class: "make-switch",
-						data: {
-							on_color: "success",
-							off_color: "danger",
-							on_text: "Si",
-							off_text: "No"
-						}
-					},"true", "false"
-				) %>
+			<% if @expensesconcept.persisted? %>
+			<div class="form-group">
+				<%= f.label :status, { class: "col-md-3 col-sm-3 control-label" } %>
+				<div class="col-md-2 col-sm-2">
+					<%= f.check_box(:status,
+						{
+							class: "make-switch",
+							data: {
+								on_color: "success",
+								off_color: "danger",
+								on_text: "Activo",
+								off_text: "Inactivo"
+							}
+						},
+						"active", "inactive"
+					) %>
+				</div>
 			</div>
-		</div>
-		<div class="form-group" id="boxpointsales" <% if @expensesconcept.allpoints? %> style="display:none;"  <% end %> >
-			<%= f.label :pointsale_ids, "Puntos de Venta", {:class=>"col-md-3 control-label"} %>
-			<div class="col-md-9">
-				<%= f.collection_select :pointsale_ids, Pointsale.activos, :id, :name, {:selected => @expensesconcept.pointsale_ids, :include_blank => false}, {:multiple => true, :class => "multi-select "}   %>
+			<% end %>
+			<div class="form-group ">
+				<%= f.label :allpoints, "Aplica a todo los puntos de venta?", { class: "col-md-3 col-sm-3 control-label" } %>
+				<div class="col-md-2 col-sm-2">
+					<%= f.check_box(:allpoints,
+						{
+							class: "make-switch",
+							data: {
+								on_color: "success",
+								off_color: "danger",
+								on_text: "Si",
+								off_text: "No"
+							}
+						},"true", "false"
+					) %>
+				</div>
+			</div>
+			<div class="form-group" id="boxpointsales" <% if @expensesconcept.allpoints? %> style="display:none;" <% end %> >
+				<%= f.label :pointsale_ids, "Puntos de Venta", { class: "col-md-3 col-sm-3 control-label" } %>
+				<div class="col-md-5 col-sm-5">
+					<%= f.collection_select :pointsale_ids, Pointsale.activos, :id, :name, { selected: @expensesconcept.pointsale_ids, include_blank: false }, { multiple: true, class: "multi-select" } %>
+				</div>
 			</div>
 		</div>
-	</div>
-	<div class="form-actions">
-		<div class="row">
-			<div class="col-md-offset-3 col-md-9">
-				<%= f.submit 'Guardar', {:class=>"btn green"} %>
-				<%= link_to 'Cancelar', expensesconcepts_path(:filter => @filter, :current_page => @current_page), {:class=>"btn default"} %>
+		<div class="form-actions">
+			<div class="row">
+				<div class="col-md-offset-3 col-md-9">
+					<%= f.submit 'Guardar', { class: "btn green" } %>
+					<%= link_to 'Cancelar', expensesconcepts_path(filter: @filter, current_page: @current_page), { class: "btn default" } %>
+				</div>
 			</div>
 		</div>
 	</div>
-</div>
 <% end %>
+
 <script type="text/javascript">
 	$(document).ready(function() {
 		handleMultiSelect();
@@ -81,8 +81,7 @@
 		$('input[name="expensesconcept[allpoints]"]').on('switchChange.bootstrapSwitch', function(event, state) {
 			if (state) {
 				$("#boxpointsales").hide();
-
-			}else{
+			} else {
 				$("#boxpointsales").show();
 			}
 		});

+ 102 - 103
app/views/expensesconcepts/index.html.erb

@@ -1,123 +1,122 @@
-		<!-- BEGIN CONTAINER -->
-		<div class="page-container">
-			<!-- BEGIN CONTENT -->
-			<div class="page-content-wrapper">
-				<!-- BEGIN CONTENT BODY -->
-				<!-- BEGIN PAGE HEAD-->
-				<div class="page-head">
-					<div class="container-fluid">
-						<!-- BEGIN PAGE TITLE -->
-						<div class="page-title">
-							<h1>Conceptos de Egresos </h1>
-						</div>
-						<!-- END PAGE TITLE -->
-					</div>
+<!-- BEGIN CONTAINER -->
+<div class="page-container">
+	<!-- BEGIN CONTENT -->
+	<div class="page-content-wrapper">
+		<!-- BEGIN CONTENT BODY -->
+		<!-- BEGIN PAGE HEAD-->
+		<div class="page-head">
+			<div class="container-fluid">
+				<!-- BEGIN PAGE TITLE -->
+				<div class="page-title">
+					<h1>Conceptos de Egresos </h1>
 				</div>
-				<!-- END PAGE HEAD-->
-				<!-- BEGIN PAGE CONTENT BODY -->
-				<div class="page-content">
-					<div class="container-fluid">
-						<!-- BEGIN PAGE BREADCRUMBS -->
-						<ul class="page-breadcrumb breadcrumb">
-							<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
-						</ul>
-						<!-- END PAGE BREADCRUMBS -->
-						<!-- BEGIN PAGE CONTENT INNER -->
-						<div class="page-content-inner">
-							<div id="notice">
-							<% if success %>
-							<div class="alert alert-success">
-								<p><%= success %></p>
-							</div>
-							<% elsif warning %>
-							<div class="alert alert-warning">
-								<p><%= warning %></p>
-							</div>
-							<% end %>
-							</div>
-							<div class="row">
-								<div class="col-md-12">
-									<div class="portlet light ">
-										<div class="portlet-title">
-											<div class="caption">
-												<i class="fa fa-list "></i>
-												<span class="caption-subject bold uppercase">Lista de conceptos de egresos</span>
-											</div>
-											<div class="actions">
-												<% if can? :create, Expensesconcept %>
-												<%= link_to new_expensesconcept_path, {:class=>"btn bold green pull-right filtros"} do %> Nuevo Concepto de egreso <i class="fa fa-plus"></i>
+				<!-- END PAGE TITLE -->
+			</div>
+		</div>
+		<!-- END PAGE HEAD-->
+		<!-- BEGIN PAGE CONTENT BODY -->
+		<div class="page-content">
+			<div class="container-fluid">
+				<!-- BEGIN PAGE BREADCRUMBS -->
+				<ul class="page-breadcrumb breadcrumb">
+					<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
+				</ul>
+				<!-- END PAGE BREADCRUMBS -->
+				<!-- BEGIN PAGE CONTENT INNER -->
+				<div class="page-content-inner">
+					<div id="notice">
+					<% if success %>
+					<div class="alert alert-success">
+						<p><%= success %></p>
+					</div>
+					<% elsif warning %>
+					<div class="alert alert-warning">
+						<p><%= warning %></p>
+					</div>
+					<% end %>
+					</div>
+					<div class="row">
+						<div class="col-md-12">
+							<div class="portlet light ">
+								<div class="portlet-title">
+									<div class="caption">
+										<i class="fa fa-list "></i>
+										<span class="caption-subject bold uppercase">Lista de conceptos de egresos</span>
+									</div>
+									<div class="actions">
+										<% if can? :create, Expensesconcept %>
+										<%= link_to new_expensesconcept_path, {:class=>"btn bold green pull-right filtros"} do %> Nuevo Concepto de egreso <i class="fa fa-plus"></i>
+										<% end %>
+										<% end %>
+									</div>
+								</div>
+								<div class="portlet-body">
+									<input type='hidden' name='filter' id='filter' value='<%= @filter %>' >
+									<input type='hidden' name='current_page' id='current_page' value='<%= @current_page %>' >
+									<table class="table table-striped table-bordered table-hover tableadvanced">
+										<thead>
+											<tr>
+												<th>#</th>
+												<th>Nombre</th>
+												<th>Descripción</th>
+												<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
+													<th>Puntos de venta</th>
 												<% end %>
+												<th>Status</th>
+												<% if can? :manage, Expensesconcept %>
+													<th>Acciones</th>
 												<% end %>
-											</div>
-										</div>
-										<div class="portlet-body">
-											<input type='hidden' name='filter' id='filter' value='<%= @filter %>' >
-											<input type='hidden' name='current_page' id='current_page' value='<%= @current_page %>' >
-											<table class="table table-striped table-bordered table-hover tableadvanced">
-												<thead>
-													<tr>
-														<th>#</th>
-														<th>Nombre</th>
-														<th>Descripción</th>
-														<% if current_user.usertype == 'A' %>
-															<th>Puntos de venta</th>
-														<% end %>
-														<th>Status</th>
-														<% if can? :manage, Expensesconcept %>
-														<th>Acciones</th>
-														<% end %>
-													</tr>
-												</thead>
-												<tbody>
-													<% @expensesconcepts.each_with_index do |expensesconcept, key| %>
-													<tr>
-														<td><%= key + 1 %></td>
-														<td><%= expensesconcept.name %></td>
-                                                        <td><%= expensesconcept.description %></td>
-                                                        <% if current_user.usertype == 'A' %>
-	                                                        <td>
-	                                                        	<% if expensesconcept.allpoints %>
-	                                                        	Todos
-	                                                        	<% else %>
-	                                                        	<%= expensesconcept.pointsales.map { |pv| pv.name }.join(", ")  %>
-	                                                        	<% end %>
-	                                                        </td>
-                                                        <% end %>
-
-														<td class="text-center"><% if expensesconcept.status == "active" %>
+											</tr>
+										</thead>
+										<tbody>
+											<% @expensesconcepts.each_with_index do |expensesconcept, key| %>
+												<tr>
+													<td><%= key + 1 %></td>
+													<td><%= expensesconcept.name %></td>
+                          <td><%= expensesconcept.description %></td>
+                          <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
+                            <td>
+                            	<% if expensesconcept.allpoints %>
+                            	Todos
+                            	<% else %>
+                            	<%= expensesconcept.pointsales.map { |pv| pv.name }.join(", ") %>
+                            	<% end %>
+                            </td>
+                          <% end %>
+													<td class="text-center">
+														<% if expensesconcept.active? %>
 															<i class="fa fa-check font-green"></i>
-															<% else %>
+														<% else %>
 															<i class="fa fa-times font-red"></i>
-															<% end %>
-														</td>
-														<% if can? :manage, Expensesconcept %>
+														<% end %>
+													</td>
+													<% if can? :manage, Expensesconcept %>
 														<td class="text-center">
-															<%= link_to edit_expensesconcept_path(expensesconcept), {:class=>"btn btn-icon-only btn-primary filtros", :title=>"Editar concepto de egreso"} do %>
+															<%= link_to edit_expensesconcept_path(expensesconcept), {:class=>"btn btn-icon-only btn-primary filtros", :title=>"Editar concepto de egreso" } do %>
 																<i class="fa fa-edit"></i>
 															<% end %>
 															<% unless @concept_purchase_payment.id == expensesconcept.id %>
-																<%= link_to expensesconcept_path(expensesconcept), method: :delete, :class => "btn btn-icon-only btn-danger", :title=>"Eliminar concepto de egreso", data: { confirm: '¿Esta seguro de eliminar el concepto de egreso?'}   do %>
+																<%= link_to expensesconcept_path(expensesconcept), method: :delete, :class => "btn btn-icon-only btn-danger", :title=>"Eliminar concepto de egreso", data: { confirm: '¿Está seguro de eliminar el concepto de egreso?' } do %>
 																	<i class="fa fa-trash-o"></i>
 																<% end %>
 															<% end %>
-
 														</td>
-														<% end %>
-													</tr>
-												<% end %>
-												</tbody>
-											</table>
-										</div>
-									</div>
+													<% end %>
+												</tr>
+											<% end %>
+										</tbody>
+									</table>
 								</div>
 							</div>
 						</div>
-						<!-- END PAGE CONTENT INNER -->
 					</div>
 				</div>
-				<!-- END PAGE CONTENT BODY -->
-				<!-- END CONTENT BODY -->
+				<!-- END PAGE CONTENT INNER -->
 			</div>
-			<!-- END CONTENT -->
 		</div>
-		<!-- END CONTAINER -->
+		<!-- END PAGE CONTENT BODY -->
+		<!-- END CONTENT BODY -->
+	</div>
+	<!-- END CONTENT -->
+</div>
+<!-- END CONTAINER -->

+ 42 - 42
app/views/pointsales/_form.html.erb

@@ -1,4 +1,4 @@
-<%= form_for(setup_pointsale(@pointsale), :html => {:class=>"form-horizontal"}) do |f| %>
+<%= form_for(setup_pointsale(@pointsale), html: { class: "form-horizontal" }) do |f| %>
 	<div class="portlet-body form">
 		<% if @pointsale.errors.any? %>
 		<div class="alert alert-danger">
@@ -9,49 +9,49 @@
 			<!-- <div class="profile-sidebar"></div>	-->
 			<h4 class="form-section">Información del punto de venta</h4>
 			<div class="form-group">
-				<%= f.label :name, "Nombre del punto de venta", {:class=>"col-md-3 control-label"} do %> Nombre del punto de venta
+				<%= f.label :name, "Nombre del punto de venta", { class: "col-md-3 col-sm-3 control-label" } do %> Nombre del punto de venta
 					<span class="required">*</span>
 				<% end %>
-				<div class="col-md-9">
-					<%= f.text_field :name, {:class=>"form-control"} %>
+				<div class="col-md-4 col-sm-6">
+					<%= f.text_field :name, { class: "form-control" } %>
 				</div>
 			</div>
 			<div class="form-group">
-				<%= f.label :prefix, "Prefijo", {:class=>"col-md-3 control-label"} do %> Prefijo
+				<%= f.label :prefix, "Prefijo", { class: "col-md-3 col-sm-3 control-label" } do %> Prefijo
 					<span class="required">*</span>
 				<% end %>
-				<div class="col-md-9">
-					<%= f.text_field :prefix, {:class=>"form-control"} %>
+				<div class="col-md-3 col-sm-6">
+					<%= f.text_field :prefix, { class: "form-control input-xsmall", maxlength: 3 } %>
 					<span class="help-block">El prefijo es la abreviación que se utilizará para identificar al punto de venta, debe conformarse de 3 letras.</span>
 				</div>
 			</div>
 			<div class="form-group">
-				<%= f.label :address, "Dirección", {:class=>"col-md-3 control-label"} %>
-				<div class="col-md-9">
-					<%= f.text_field :address, {:class=>"form-control"} %>
+				<%= f.label :address, "Dirección", { class: "col-md-3 col-sm-3 control-label" } %>
+				<div class="col-md-4 col-sm-6">
+					<%= f.text_field :address, { class: "form-control" } %>
 				</div>
 			</div>
 			<div class="form-group">
-				<%= f.label :haggle_percent, {:class=>"col-md-3 control-label"} do %> Porcentaje de regateo para ventas <% end %>
-				<div class="col-md-2">
-					<%= f.number_field :haggle_percent, {:class=>"form-control" }  %>
+				<%= f.label :haggle_percent, { class: "col-md-3 col-sm-3 control-label" } do %> Porcentaje de regateo para ventas <% end %>
+				<div class="col-md-2 col-sm-6">
+					<%= f.number_field :haggle_percent, { class: "form-control input-xsmall" } %>
 				</div>
 			</div>
 			<div class="form-group">
-				<%= f.label :notes, "Encabezado para el ticket", {:class=>"col-md-3 control-label"} %>
-				<div class="col-md-9">
-					<%= f.text_area :notes, {:class=>"form-control", :rows => 5} %>
+				<%= f.label :notes, "Encabezado para el ticket", { class: "col-md-3 col-sm-3 control-label" } %>
+				<div class="col-md-4 col-sm-6">
+					<%= f.text_area :notes, { class: "form-control", rows: 5 } %>
 				</div>
 			</div>
 			<div class="form-group">
-				<%= f.label :ticket_footer, "Pie de pagina para ticket", {:class=>"col-md-3 control-label"} %>
-				<div class="col-md-9">
-					<%= f.text_area :ticket_footer, {:class=>"form-control", :rows => 5} %>
+				<%= f.label :ticket_footer, "Pie de pagina para ticket", { class: "col-md-3 col-sm-3 control-label" } %>
+				<div class="col-md-4 col-sm-6">
+					<%= f.text_area :ticket_footer, { class: "form-control", rows: 5 } %>
 				</div>
 			</div>
 			<div class="form-group">
-				<%= f.label :img_pointsale, "Imagen para el ticket", {:class=>"col-md-3 control-label"} %>
-				<div class="col-md-9">
+				<%= f.label :img_pointsale, "Imagen para el ticket", { class: "col-md-3 col-sm-3 control-label" } %>
+				<div class="col-md-4 col-sm-6">
 					<div class="fileinput fileinput-new" data-provides="fileinput">
 						<div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
 							<% if @pointsale.img_pointsale? %>
@@ -65,7 +65,7 @@
 							<span class="btn default btn-file">
 								<span class="fileinput-new"> Seleccione imagen </span>
 								<span class="fileinput-exists"> Cambiar </span>
-								<%= f.file_field :img_pointsale, {:class=>"default"} %>
+								<%= f.file_field :img_pointsale, { class: "default" } %>
 								<%= f.hidden_field :img_pointsale_cache %>
 							</span>
 							<a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput"> Borrar </a>
@@ -77,51 +77,51 @@
 				<h4 class="form-section">Usuario responsable de punto de venta</h4>
 				<%= f.fields_for :users, @pointsale.users do |u| %>
 					<div class="form-group">
-						<%= u.label :first_name, "Nombre", {:class=>"col-md-3 control-label"} do %> Nombre
+						<%= u.label :first_name, "Nombre", { class: "col-md-3 col-sm-3 control-label" } do %> Nombre
 							<span class="required">*</span>
 						<% end %>
-						<div class="col-md-9">
-							<%= u.text_field :first_name, {:class=>"form-control"} %>
+						<div class="col-md-3 col-sm-3">
+							<%= u.text_field :first_name, { class: "form-control" } %>
 						</div>
 					</div>
 					<div class="form-group">
-						<%= u.label :last_name, "Apellidos", {:class=>"col-md-3 control-label"} do %> Apellidos
+						<%= u.label :last_name, "Apellidos", { class: "col-md-3 col-sm-3 control-label" } do %> Apellidos
 							<span class="required">*</span>
 						<% end %>
-						<div class="col-md-9">
-							<%= u.text_field :last_name, {:class=>"form-control"} %>
+						<div class="col-md-3 col-sm-3">
+							<%= u.text_field :last_name, { class: "form-control" } %>
 						</div>
 					</div>
 					<div class="form-group">
-						<%= u.label :email, "Correo", {:class=>"col-md-3 control-label"} do %> Correo electrónico
+						<%= u.label :email, "Correo", { class: "col-md-3 col-sm-3 control-label" } do %> Correo electrónico
 							<span class="required">*</span>
 						<% end %>
-						<div class="col-md-9">
-							<%= u.text_field :email, {:class=>"form-control"} %>
+						<div class="col-md-3 col-sm-3">
+							<%= u.text_field :email, { class: "form-control" } %>
 						</div>
 					</div>
 					<div class="form-group">
-						<%= u.label :userid, "Nombre del punto de venta", {:class=>"col-md-3 control-label"} do %> Usuario
+						<%= u.label :userid, "Nombre del punto de venta", { class: "col-md-3 col-sm-3 control-label" } do %> Usuario
 							<span class="required">*</span>
 						<% end %>
-						<div class="col-md-9">
-							<%= u.text_field :userid, {:class=>"form-control"} %>
+						<div class="col-md-3 col-sm-3">
+							<%= u.text_field :userid, { class: "form-control" } %>
 						</div>
 					</div>
 					<div class="form-group">
-						<%= u.label :password, "Nombre del punto de venta", {:class=>"col-md-3 control-label"} do %> Contraseña
+						<%= u.label :password, "Nombre del punto de venta", { class: "col-md-3 col-sm-3 control-label" } do %> Contraseña
 							<span class="required">*</span>
 						<% end %>
-						<div class="col-md-9">
-							<%= u.password_field :password, {:class=>"form-control"} %>
+						<div class="col-md-3 col-sm-3">
+							<%= u.password_field :password, { class: "form-control" } %>
 						</div>
 					</div>
 					<div class="form-group">
-						<%= u.label :password_confirmation, "Confirmar contraseña", {:class=>"col-md-3 control-label"} do %> Confirmar Contraseña
+						<%= u.label :password_confirmation, "Confirmar contraseña", { class: "col-md-3 col-sm-3 control-label" } do %> Confirmar Contraseña
 							<span class="required">*</span>
 						<% end %>
-						<div class="col-md-9">
-							<%= u.password_field :password_confirmation, {:class=>"form-control"} %>
+						<div class="col-md-3 col-sm-3">
+							<%= u.password_field :password_confirmation, { class: "form-control" } %>
 						</div>
 					</div>
 				<% end %>
@@ -130,8 +130,8 @@
 		<div class="form-actions">
 			<div class="row">
 				<div class="col-md-offset-3 col-md-9">
-					<%= f.submit 'Guardar', {:class=>"btn green"} %>
-					<%= link_to 'Cancelar', pointsales_path(:filter => @filter, :current_page => @current_page), {:class=>"btn default"} %>
+					<%= f.submit 'Guardar', { class: "btn green" } %>
+					<%= link_to 'Cancelar', pointsales_path(filter: @filter, current_page: @current_page), { class: "btn default" } %>
 				</div>
 			</div>
 		</div>

+ 19 - 34
app/views/pointsales/_index.html.erb

@@ -1,43 +1,28 @@
 <% @pointsales.each_with_index do |pointsale, key| %>
-<tr>
+  <tr>
     <td><%= key + 1 %></td>
     <td><%= pointsale.name %></td>
     <td><%= pointsale.prefix %></td>
     <td><%= pointsale.address %></td>
-    <td class="text-center"><% if pointsale.products.count > 0 %>
-            <i class="fa fa-check font-green"></i>
-            <% else %>
-            <i class="fa fa-times font-red"></i>
-        <% end %></td>
-    <td class="text-center">
-        <% if pointsale.total_products(pointsale.id) > 0 %>
-            <i class="fa fa-check font-green"></i>
-            <% else %>
-            <i class="fa fa-times font-red"></i>
-        <% end %></td>
-    <td class="text-center"><% if pointsale.status == "active" %>
-            <i class="fa fa-check font-green"></i>
-            <% else %>
-            <i class="fa fa-times font-red"></i>
-            <% end %></td>
-    <td >
-        <%= link_to edit_pointsale_path(pointsale, :todo => "products"), {:class=>"btn btn-icon-only default", :title=>"Actualizar productos disponibles"} do %>
-             <i class="fa fa-object-group"></i>
+    <td class="text-center"><%= product_count(pointsale.products.count) %></td>
+    <td class="text-center"><%= product_count(pointsale.total_products) %></td>
+    <td class="text-center"><%= pointsale_status(pointsale) %></td>
+    <td>
+      <%= link_to edit_pointsale_path(pointsale, todo: "products"), { class: "btn btn-icon-only default", title: "Actualizar productos disponibles" } do %>
+         <i class="fa fa-object-group"></i>
+      <% end %>
+      <%= link_to edit_pointsale_path(pointsale), { class: "btn btn-icon-only btn-primary", title: "Editar punto de venta" } do %>
+         <i class="fa fa-edit"></i>
+      <% end %>
+      <% if pointsale.active? && pointsale.open_cash_registers.where("open_cash_registers.status = ?", 0).count == 0 %>
+        <%= link_to pointsale_update_status_path(pointsale), class: "btn btn-icon-only default", title: "Desactivar punto de venta", data: { confirm: '¿Está seguro de desactivar el punto de venta?', method: 'post' } do %>
+          <i class="fa fa-toggle-off"></i>
         <% end %>
-        <%= link_to edit_pointsale_path(pointsale), {:class=>"btn btn-icon-only btn-primary", :title=>"Editar punto de venta"} do %>
-             <i class="fa fa-edit"></i>
+      <% elsif pointsale.inactive? %>
+        <%= link_to pointsale_update_status_path(pointsale), class: "btn btn-icon-only green-jungle", title: "Activar punto de venta", data: { confirm: '¿Está seguro de activar el punto de venta?', method: 'post' } do %>
+          <i class="fa fa-toggle-on"></i>
         <% end %>
-        <% if pointsale.active? && pointsale.open_cash_registers.where("open_cash_registers.status = 0").count == 0 %>
-            <%= link_to pointsale_update_status_path(pointsale), :class=>"btn btn-icon-only default", :title=>"Desactivar punto de venta", data: { confirm: '¿Esta seguro de desactivar el punto de venta?', method: 'post'}  do %>
-                <i class="fa fa-toggle-off"></i>
-            <% end %>
-        <% elsif pointsale.inactive? %>
-            <%= link_to pointsale_update_status_path(pointsale), :class=>"btn btn-icon-only green-jungle", :title=>"Activar punto de venta", data: { confirm: '¿Esta seguro de activar el punto de venta?', method: 'post'}  do %>
-                <i class="fa fa-toggle-on"></i>
-            <% end %>
-        <% end %>
-
-
+      <% end %>
     </td>
-</tr>
+  </tr>
 <% end %>

+ 49 - 50
app/views/pointsales/edit.html.erb

@@ -1,62 +1,61 @@
-	<!-- BEGIN CONTAINER -->
-	<div class="page-container">
-		<!-- BEGIN CONTENT -->
-		<div class="page-content-wrapper">
-			<!-- BEGIN CONTENT BODY -->
-			<!-- BEGIN PAGE HEAD-->
-			<div class="page-head">
-				<div class="container-fluid">
-					<!-- BEGIN PAGE TITLE -->
-					<div class="page-title">
-						<h1> Punto de Venta </h1>
-					</div>
-					<!-- END PAGE TITLE -->
+<!-- BEGIN CONTAINER -->
+<div class="page-container">
+	<!-- BEGIN CONTENT -->
+	<div class="page-content-wrapper">
+		<!-- BEGIN CONTENT BODY -->
+		<!-- BEGIN PAGE HEAD-->
+		<div class="page-head">
+			<div class="container-fluid">
+				<!-- BEGIN PAGE TITLE -->
+				<div class="page-title">
+					<h1> Punto de Venta </h1>
 				</div>
+				<!-- END PAGE TITLE -->
 			</div>
-			<!-- END PAGE HEAD-->
-			<!-- BEGIN PAGE CONTENT BODY -->
-			<div class="page-content">
-				<div class="container-fluid">
-					<%= link_to  pointsales_path(:filter => @filter, :current_page => @current_page), {:class=>"btn blue-hoki pull-right margin-bottom-10"} do %> <i class="fa fa-angle-left "></i> Regresar
-					<% end %>
-					<!-- BEGIN PAGE BREADCRUMBS -->
-					<ul class="page-breadcrumb breadcrumb">
-						<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
-					</ul>
-					<!-- END PAGE BREADCRUMBS -->
-					<!-- BEGIN PAGE CONTENT INNER -->
-					<div class="page-content-inner">
-						<div class="row ">
-							<!-- editar punto de venta -->
-							<div class='col-md-12'>
-								<div class="portlet light">
-									<div class="portlet-title">
-										<div class="caption">
-											<i class="fa fa-edit font-blue-sharp"></i>
-											<span class="caption-subject font-blue-sharp bold uppercase">
-												<% if @todo == "products" %>
+		</div>
+		<!-- END PAGE HEAD-->
+		<!-- BEGIN PAGE CONTENT BODY -->
+		<div class="page-content">
+			<div class="container-fluid">
+				<%= link_to pointsales_path(:filter => @filter, :current_page => @current_page), {:class=>"btn blue-hoki pull-right margin-bottom-10"} do %> <i class="fa fa-angle-left "></i> Regresar
+				<% end %>
+				<!-- BEGIN PAGE BREADCRUMBS -->
+				<ul class="page-breadcrumb breadcrumb">
+					<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
+				</ul>
+				<!-- END PAGE BREADCRUMBS -->
+				<!-- BEGIN PAGE CONTENT INNER -->
+				<div class="page-content-inner">
+					<div class="row ">
+						<!-- editar punto de venta -->
+						<div class='col-md-12'>
+							<div class="portlet light">
+								<div class="portlet-title">
+									<div class="caption">
+										<i class="fa fa-edit font-blue-sharp"></i>
+										<span class="caption-subject font-blue-sharp bold uppercase">
+											<% if @todo == "products" %>
 												actualizar productos del punto de venta
-												<% else %>
+											<% else %>
 												EDITAR PUNTO DE VENTA
-												<% end %>
-											</span>
-										</div>
+											<% end %>
+										</span>
 									</div>
-									<% if @todo == "products" %>
+								</div>
+								<% if @todo == "products" %>
 									<%= render 'assign_delete_prods' %>
-									<% else %>
+								<% else %>
 									<%= render 'form' %>
-									<% end %>
-								</div>
-							</div>						
-						</div> 
+								<% end %>
+							</div>
+						</div>
 					</div>
-					<!-- END PAGE CONTENT INNER -->
 				</div>
+				<!-- END PAGE CONTENT INNER -->
 			</div>
-			<!-- END PAGE CONTENT BODY -->
-			<!-- END CONTENT BODY -->
 		</div>
-		<!-- END CONTENT -->
+		<!-- END PAGE CONTENT BODY -->
+		<!-- END CONTENT BODY -->
 	</div>
-	<!-- END CONTAINER -->
+	<!-- END CONTENT -->
+</div>

+ 77 - 78
app/views/pointsales/index.html.erb

@@ -1,87 +1,86 @@
-		<!-- BEGIN CONTAINER -->
-		<div class="page-container">
-			<!-- BEGIN CONTENT -->
-			<div class="page-content-wrapper">
-				<!-- BEGIN CONTENT BODY -->
-				<!-- BEGIN PAGE HEAD-->
-				<div class="page-head">
-					<div class="container-fluid">
-						<!-- BEGIN PAGE TITLE -->
-						<div class="page-title">
-							<h1>Puntos de Ventas </h1>
-						</div>
-						<!-- END PAGE TITLE -->
-					</div>
+<!-- BEGIN CONTAINER -->
+<div class="page-container">
+	<!-- BEGIN CONTENT -->
+	<div class="page-content-wrapper">
+		<!-- BEGIN CONTENT BODY -->
+		<!-- BEGIN PAGE HEAD-->
+		<div class="page-head">
+			<div class="container-fluid">
+				<!-- BEGIN PAGE TITLE -->
+				<div class="page-title">
+					<h1>Puntos de Ventas </h1>
 				</div>
-				<!-- END PAGE HEAD-->
-				<!-- BEGIN PAGE CONTENT BODY -->
-				<div class="page-content">
-					<div class="container-fluid">
-						<!-- BEGIN PAGE BREADCRUMBS -->
-						<ul class="page-breadcrumb breadcrumb">
-							<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
-						</ul>
-						<!-- END PAGE BREADCRUMBS -->
-						<!-- BEGIN PAGE CONTENT INNER -->
-						<div class="page-content-inner">
-							<div id="notice">
-								<% if success %>
-								<div class="alert alert-success">
-									<p><%= success %></p>
-								</div>
-								<% elsif warning %>
-								<div class="alert alert-warning">
-									<p><%= warning %></p>
-								</div>
-								<% end %>
-							 </div>
-							<div class="row">
-								<div class="col-md-12">
-									<div class="portlet light ">
-										<div class="portlet-title">
-											<div class="caption">
-												<i class="fa fa-list "></i>
-												<span class="caption-subject bold uppercase">Lista de Puntos de venta</span>
-											</div>
-											<div class="actions">
-												<% if can? :create, Pointsale %>
-												<%= link_to new_pointsale_path, {:class=>"btn bold green pull-right filtros"} do %> Nuevo punto de venta <i class="fa fa-plus"></i>
-												<% end %>
-												<% end %>
-											</div>
-										</div>
-										<div class="portlet-body">
-											<input type='hidden' name='filter' id='filter' value='<%= @filter %>' >
-											<input type='hidden' name='current_page' id='current_page' value='<%= @current_page %>' >
-											<table class="table table-striped table-bordered table-hover tableadvanced">
-												<thead>
-													<tr>
-														<th>#</th>
-														<th>Nombre</th>
-														<th>Prefijo</th>
-														<th>Direcci&oacute;n</th>
-														<th>Productos<br>disponibles</th>
-														<th>¿Tiene inventario?</th>
-														<th>Status</th>
-														<th>Acciones</th>
-													</tr>
-												</thead>
-												<tbody  class="pointsale-index">
-													<%= render "index" %>
-												</tbody>
-											</table>
-										</div>
+				<!-- END PAGE TITLE -->
+			</div>
+		</div>
+		<!-- END PAGE HEAD-->
+		<!-- BEGIN PAGE CONTENT BODY -->
+		<div class="page-content">
+			<div class="container-fluid">
+				<!-- BEGIN PAGE BREADCRUMBS -->
+				<ul class="page-breadcrumb breadcrumb">
+					<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
+				</ul>
+				<!-- END PAGE BREADCRUMBS -->
+				<!-- BEGIN PAGE CONTENT INNER -->
+				<div class="page-content-inner">
+					<div id="notice">
+						<% if success %>
+						<div class="alert alert-success">
+							<p><%= success %></p>
+						</div>
+						<% elsif warning %>
+						<div class="alert alert-warning">
+							<p><%= warning %></p>
+						</div>
+						<% end %>
+					 </div>
+					<div class="row">
+						<div class="col-md-12">
+							<div class="portlet light ">
+								<div class="portlet-title">
+									<div class="caption">
+										<i class="fa fa-list "></i>
+										<span class="caption-subject bold uppercase">Lista de Puntos de venta</span>
 									</div>
+									<div class="actions">
+										<% if can? :create, Pointsale %>
+											<%= link_to new_pointsale_path, {:class=>"btn bold green pull-right filtros"} do %> Nuevo punto de venta <i class="fa fa-plus"></i><% end %>
+										<% end %>
+									</div>
+								</div>
+								<div class="portlet-body">
+									<input type='hidden' name='filter' id='filter' value='<%= @filter %>' >
+									<input type='hidden' name='current_page' id='current_page' value='<%= @current_page %>' >
+									<table class="table table-striped table-bordered table-hover tableadvanced">
+										<thead>
+											<tr>
+												<th>#</th>
+												<th>Nombre</th>
+												<th>Prefijo</th>
+												<th>Direcci&oacute;n</th>
+												<th>Productos<br>disponibles</th>
+												<th>¿Tiene inventario?</th>
+												<th>Status</th>
+												<th>Acciones</th>
+											</tr>
+										</thead>
+										<tbody  class="pointsale-index">
+											<%= render "index" %>
+										</tbody>
+									</table>
 								</div>
 							</div>
 						</div>
-						<!-- END PAGE CONTENT INNER -->
 					</div>
 				</div>
-				<!-- END PAGE CONTENT BODY -->
-				<!-- END CONTENT BODY -->
+				<!-- END PAGE CONTENT INNER -->
 			</div>
-			<!-- END CONTENT -->	
 		</div>
-		<!-- END CONTAINER -->
-		<div id="form-modal" class="modal fade" tabindex="-1" role="basic" aria-hidden="true"> </div>
+		<!-- END PAGE CONTENT BODY -->
+		<!-- END CONTENT BODY -->
+	</div>
+	<!-- END CONTENT -->
+</div>
+<!-- END CONTAINER -->
+<div id="form-modal" class="modal fade" tabindex="-1" role="basic" aria-hidden="true"> </div>

+ 30 - 30
app/views/pos_configs/_form.html.erb

@@ -9,70 +9,70 @@
     <div class="row">
       <div class="col-md-11 col-sm-12">
         <div class="form-group">
-          <%= f.label :cancel_partial_payment, { class: "col-md-3 col-sm-6 control-label" } do %>Días para cancelar abono
+          <%= f.label :cancel_partial_payment, { class: "col-md-3 col-sm-3 control-label" } do %>Días para cancelar abono
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1 col-sm-3">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :cancel_partial_payment, { class: "form-control input-xsmall" } %>
           </div>
-          <%= f.label :refund_sale, { class: "col-md-3 col-sm-6 control-label" } do %>Días para aceptar devolución
+          <%= f.label :refund_sale, { class: "col-md-3 col-sm-3 control-label" } do %>Días para aceptar devolución
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1 col-sm-3">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :refund_sale, { class: "form-control input-xsmall" } %>
           </div>
         </div>
         <div class="form-group">
-          <%= f.label :days_cancel_sale, { class: "col-md-3 col-sm-6 control-label" } do %>Días para cancelar venta
+          <%= f.label :days_cancel_sale, { class: "col-md-3 col-sm-3 control-label" } do %>Días para cancelar venta
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1 col-sm-3">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :days_cancel_sale, { class: "form-control input-xsmall" } %>
           </div>
-          <%= f.label :days_cancel_purchase, { class: "col-md-3 col-sm-6 control-label"} do %>Días para cancelar compra
+          <%= f.label :days_cancel_purchase, { class: "col-md-3 col-sm-3 control-label"} do %>Días para cancelar compra
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1 col-sm-3">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :days_cancel_purchase, { class: "form-control input-xsmall" } %>
           </div>
         </div>
         <div class="form-group">
-          <%= f.label :reserve_sale_percent, { class: "col-md-3 col-sm-6 control-label" } do %>Porcentaje para realizar apartado
+          <%= f.label :reserve_sale_percent, { class: "col-md-3 col-sm-3 control-label" } do %>Porcentaje para realizar apartado
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1 col-sm-3">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :reserve_sale_percent, { class: "form-control input-xsmall" } %>
           </div>
-          <%= f.label :days_cancel_reserved, { class: "col-md-3 control-label" } do %>Días para cancelar apartado
+          <%= f.label :days_cancel_reserved, { class: "col-md-3 col-sm-3 control-label" } do %>Días para cancelar apartado
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :days_cancel_reserved, { class: "form-control input-xsmall" } %>
           </div>
         </div>
         <div class="form-group">
-          <%= f.label :tax_percent, { class: "col-md-3 control-label" } do %>IVA a aplicar
+          <%= f.label :tax_percent, { class: "col-md-3 col-sm-3 control-label" } do %>IVA a aplicar
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :tax_percent, { class: "form-control input-xsmall" } %>
           </div>
-          <%= f.label :commission_percent, { class: "col-md-3 control-label" } do %>Porcentaje por comisión de venta
+          <%= f.label :commission_percent, { class: "col-md-3 col-sm-3 control-label" } do %>Porcentaje por comisión de venta
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :commission_percent, { class: "form-control input-xsmall" } %>
           </div>
         </div>
         <div class="form-group">
-          <%= f.label :gain_margin, { class: "col-md-3 control-label" } do %>Porcentaje de margen de ganancia
+          <%= f.label :gain_margin, { class: "col-md-3 col-sm-3 control-label" } do %>Porcentaje de margen de ganancia
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1">
+          <div class="col-md-1 col-sm-2">
             <%= f.number_field :gain_margin, { class: "form-control input-xsmall" } %>
           </div>
-          <%= f.label :enable_haggle, { class: "col-md-3 control-label" } do %> ¿Permitir regateo en ventas? <span class="required">*</span><% end %>
-          <div class="col-md-1">
+          <%= f.label :enable_haggle, { class: "col-md-3 col-sm-3 control-label" } do %> ¿Permitir regateo en ventas? <span class="required">*</span><% end %>
+          <div class="col-md-1 col-sm-2">
             <%= f.check_box(:enable_haggle,
               {
                 class: "make-switch",
@@ -89,42 +89,42 @@
         </div>
         <div class="form-group">
           <div id="haggle_div" class="<%= 'hidden' unless @pos_config.enable_haggle %>">
-            <%= f.label :haggle_in_sale_percent, { class: "col-md-3 control-label" } do %>Porcentaje máximo de regateo para ventas
+            <%= f.label :haggle_in_sale_percent, { class: "col-md-3 col-sm-3 control-label" } do %>Porcentaje máximo de regateo para ventas
               <span class="required">*</span>
             <% end %>
-            <div class="col-md-3">
+            <div class="col-md-3 col-sm-2">
               <%= f.number_field :haggle_in_sale_percent, { class: "form-control input-xsmall" } %>
             </div>
           </div>
         </div>
         <div class="form-group">
-          <%= f.label :time_zone, { class: "col-md-3 control-label" } do %>Zona horaria
+          <%= f.label :time_zone, { class: "col-md-3 col-sm-3 control-label" } do %>Zona horaria
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-1">
+          <div class="col-md-1 col-sm-2">
             <%= f.time_zone_select :time_zone, ActiveSupport::TimeZone.us_zones, {}, {:class => 'form-control select2 input-large' } %>
           </div>
         </div>
         <div class="form-group">
-          <%= f.label :ticket_description, { class: "col-md-3 control-label" } do %>Encabezado para tickets
+          <%= f.label :ticket_description, { class: "col-md-3 col-sm-3 control-label" } do %>Encabezado para tickets
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-7">
+          <div class="col-md-7 col-sm-6">
             <%= f.text_area :ticket_description, { class: "form-control", rows: 5 } %>
             <span class="help-block">Si no se especifica un encabezado para cada uno de los puntos de venta, se usará este de manera general.</span>
           </div>
         </div>
         <div class="form-group">
-          <%= f.label :ticket_footer, { class: "col-md-3 control-label" } do %>Pie de página para tickets
+          <%= f.label :ticket_footer, { class: "col-md-3 col-sm-3 control-label" } do %>Pie de página para tickets
             <span class="required">*</span>
           <% end %>
-          <div class="col-md-7">
+          <div class="col-md-7 col-sm-6">
             <%= f.text_area :ticket_footer, { class: "form-control", rows: 5 } %>
           </div>
         </div>
         <div class="form-group">
-          <%= f.label :ticket_img, "Imagen para el ticket", { class: "col-md-3 control-label"} %>
-          <div class="col-md-9">
+          <%= f.label :ticket_img, "Imagen para el ticket", { class: "col-md-3 col-sm-3 control-label"} %>
+          <div class="col-md-9 col-sm-3">
             <div class="fileinput fileinput-new" data-provides="fileinput">
               <div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
                 <% if @pos_config.ticket_img? %>

+ 8 - 10
app/views/product_wastes/index.html.erb

@@ -43,9 +43,8 @@
 										<span class="caption-subject bold uppercase">Lista de mermas</span>
 									</div>
 									<div class="actions">
-										<% if current_user.usertype != 'A' %>
-										<%= link_to new_product_waste_path, {:class=>"btn bold green pull-right"} do %> Nueva Merma de producto <i class="fa fa-plus"></i>
-										<% end %>
+										<% if can? :create, ProductWaste %>
+											<%= link_to new_product_waste_path, {:class=>"btn bold green pull-right"} do %> Nueva Merma de producto <i class="fa fa-plus"></i><% end %>
 										<% end %>
 									</div>
 								</div>
@@ -60,7 +59,7 @@
 												<th>Motivo</th>
 												<th>Registró</th>
 												<th>Fecha</th>
-												<% if current_user.usertype == 'A'%>
+												<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 													<th>Localización</th>
 												<% end %>
 												<th>Status</th>
@@ -70,7 +69,7 @@
 										<tbody>
 											<% @product_wastes.each_with_index do |product_waste, key| %>
 											<tr>
-												<td><%= key +1 %></td>
+												<td><%= key + 1 %></td>
 												<td><%= product_waste.product.sku %> </td>
 												<td>
 													<%= product_waste.product.name %><br>
@@ -80,19 +79,19 @@
 												<td><%= product_waste.reason %> </td>
 												<td><%= product_waste.user.first_name %> </td>
 												<td><%= l(product_waste.created_at, :format => '%d/%B/%Y') %></td>
-												<% if current_user.usertype == 'A'%>
-													<td> <%= product_waste.pointsale.present? ?  product_waste.pointsale.name : product_waste.warehouse.name %> </td>
+												<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
+													<td> <%= product_waste.pointsale.present? ? product_waste.pointsale.name : product_waste.warehouse.name %> </td>
 												<% end %>
 												<td class="text-center">
 													<% case product_waste.status %>
 													<% when "active"%>
 														<i class="fa fa-check font-green"></i>
 													<% when "inactive"%>
-														<i class="fa fa-close font-red"></i>                         
+														<i class="fa fa-close font-red"></i>
 													<% end %>
 												</td>
 												<td class="text-center">
-													<%= link_to product_waste, method: :delete, :class => "btn btn-icon-only btn-danger", :title => "Eliminar merma", data: { confirm: '¿Esta seguro de eliminar la merma del producto?'}   do %> 
+													<%= link_to product_waste, method: :delete, :class => "btn btn-icon-only btn-danger", :title => "Eliminar merma", data: { confirm: '¿Está seguro de eliminar la merma del producto?' } do %>
 														<i class="fa fa-trash-o"></i>
 													<% end %>
 												</td>
@@ -113,4 +112,3 @@
 	</div>
 	<!-- END CONTENT -->
 </div>
-<!-- END CONTAINER

+ 418 - 442
app/views/products/_form.html.erb

@@ -1,465 +1,441 @@
 <!-- BEGIN FORM-->
-<%= form_for(@product, :html => {:class=>"form-horizontal"}) do |f| %>
-	<div class="portlet-body form" id="products_form">
-		<% if @product.errors.any? %>
-			<div class="alert alert-danger">
-				<strong>Tiene <%= pluralize(@product.errors.count, "error") %> no se puede guardar el producto</strong><br>
-			</div>
-		<% end %>
-		<div class="form-body">
-			<input type="text" class="hidden" value="<%= @product.id %>" id="idproduct">
-			<h4 class="form-section">Información general</h4>
-			<div class="row">
-				<div class="col-md-7">
-					<%= hidden_field_tag :gain_margin, @pos_config.gain_margin %>
-					<%= hidden_field_tag :tax_percent, @pos_config.tax_percent %>
-					<div class="form-group">
-						<%= f.label :sku, {:class=>"col-md-3 control-label"} do %>SKU <span class="required">*</span>
-						<% end %>
-						<div class="col-md-9">
-							<div class="input-icon">
-								<i class="fa fa-tag"></i>
-								<%= f.text_field :sku, {:class=>"form-control input-medium", :readonly => true } %>
-							</div>
-							<span class="help-block">El SKU se genera automaticamente en base a la linea y sublinea seleccionadas. </span>
-						</div>
-					</div>
-					<div class="form-group">
-						<%= f.label :barcode, {:class=>"col-md-3 control-label"} do %> Codigo de barras <span class="required">*</span>
-						<% end %>
-						<div class="col-md-9">
-							<div class="input-icon">
-								<i class="fa fa-barcode"></i>
-								<%= f.text_field :barcode, {:class=>"form-control input-medium", :readonly => true } %>
-							</div>
-							<span class="help-block">Para indicar el codigo de barras, debe de escanearlo. </span>
-						</div>
-					</div>
-					<div class="form-group">
-						<%= f.label :name, "Producto", {:class=>"col-md-3 control-label"} do %>Nombre
-							<span class="required">*</span>
-						<% end %>
-						<div class="col-md-9">
-							<%= f.text_field :name, {:class=>"form-control"} %>
-						</div>
-					</div>
-					<div class="form-group">
-						<%= f.label :description, "Descripción", {:class=>"col-md-3 control-label"} %>
-						<div class="col-md-9">
-							<%= f.text_area :description, {:class=>"form-control"} %>
-						</div>
-					</div>
-					<div class="form-group">
-						<%= f.label :unit_id, "Unidad de medida", {:class=>"col-md-3 control-label"} do %>Unidad de medida <span class="required">*</span>
-						<% end %>
-						<div class="col-md-9">
-							<%= f.collection_select :unit_id, Unit.vigentes, :id, :unit, {:prompt => "Seleccione"}, {:class => "form-control input-medium"}   %>
-						</div>
-					</div>
-				</div>
-				<div class="col-md-5">
-					<div class="form-group">
-						<%= f.label :img_product, "Imagen producto", {:class=>"col-md-5 control-label"} %>
-						<div class="col-md-7">
-							<div class="fileinput fileinput-new" data-provides="fileinput">
-								<div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
-									<% if @product.img_product? %>
-										<%= image_tag @product.img_product %>
-									<% else %>
-										<%= image_tag "no-image.png" %>
-									<% end %>
-								</div>
-								<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"> </div>
-								<div>
-									<span class="btn default btn-file">
-										<span class="fileinput-new"> Seleccione imagen </span>
-										<span class="fileinput-exists"> Cambiar </span>
-										<%= f.file_field :img_product, {:class=>"default"} %>
-										<%= f.hidden_field :img_product_cache %>
-									</span>
-									<a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput"> Borrar </a>
-								</div>
-							</div>
-						</div>
-					</div>
-				</div>
-			</div>
-			<h4 class="form-section">Información del producto</h4>
-			<div class="row">
-				<div class="form-group ">
-					<%= f.label :inventory, "¿Se maneja inventario de este producto?", {:class=>"col-md-3 control-label"} do %>¿Este producto tendrá inventario?
-						<span class="required">*</span>
-					<% end %>
-					<div class="col-md-9">
-						<%= f.check_box(:inventory,
-							{
-								class: "make-switch",
-								data: {
-									on_color: "success",
-									off_color: "danger",
-									on_text: "Si",
-									off_text: "No"
-								}
-							}, "true","false"
-						) %>
-					</div>
-				</div>
-
-				<div class="form-group">
-					<%
-						@category = nil
-						@subcategory = nil;
-						@prompt = 'Seleccione'
-						@disabled = true
-						if @product.categories[0].present? && @product.categories[0].parent_id == 0
-							@category = @product.categories[0]
-							@prompt = ''
-						elsif @product.categories[0].present?
-							@category = Category.find(@product.categories[0].parent_id)
-							@subcategory = @product.categories[0]
-							@disabled = false
-						end
-					%>
-					<%= label_tag :categorias, "Líneas de producto", {:class=>"col-md-3 control-label"} do %>Líneas de producto
-						<span class="required">*</span>
-					<% end %>
-					<div class="col-md-4">
-							<%= select_tag 'categorias',
-								options_from_collection_for_select(Category.activos_padre, 'id', 'category',
-									:selected => (@category.id unless @category.nil?)),
-									{:include_blank => "Seleccione", :class => 'form-control'} %>
-					</div>
-				</div>
-				<div class="form-group">
-					<%= f.label :category_ids, "Sublinea del producto", {:class=>"col-md-3 control-label"}   %>
-					<div class="col-md-4">
-						<%= f.collection_select(:category_ids, @category.nil? ? {} : Category.where(:parent_id => @category.id), :id, :category , options ={:include_blank => @prompt, :selected => (@subcategory.id unless @subcategory.nil?) }, :class => "form-control", :disabled => @disabled) %>
-						<%= f.hidden_field :category_ids, {:id => 'subcategory_hidden'}%>
-					</div>
-				</div>
-				<div class="form-group">
-					<%= f.label :include_purchase_tax, "¿Incluir IVA en compra?", {:class=>"col-md-3 control-label"} do %> ¿Incluir IVA en compra?
-						<span class="required">*</span>
-					<% end %>
-					<div class="col-md-9">
-						<%= f.check_box(:include_purchase_tax,
-							{
-								class: "make-switch",
-								data: {
-									on_color: "success",
-									off_color: "danger",
-									on_text: "Si",
-									off_text: "No"
-								}
-							}, "1","0"
-						) %>
-					</div>
-				</div>
-				<div class="form-group">
-					<%= f.label :include_sale_tax, "¿Incluir IVA en venta?", {:class=>"col-md-3 control-label"} do %> ¿Incluir IVA en venta?
-						<span class="required">*</span>
-					<% end %>
-					<div class="col-md-9">
-						<%= f.check_box(:include_sale_tax,
-							{
-								class: "make-switch",
-								data: {
-									on_color: "success",
-									off_color: "danger",
-									on_text: "Si",
-									off_text: "No"
-								}
-							}, "1","0"
-						) %>
-					</div>
-				</div>
-				<div class="form-group">
-					<%= f.label :is_in_dollars, "¿Se compra en dolares?", {:class=>"col-md-3 control-label"} do %> ¿Se compra en dolares?
-						<span class="required">*</span>
-					<% end %>
-					<div class="col-md-9">
-						<%= f.check_box(:is_in_dollars,
-							{
-								class: "make-switch",
-								data: {
-									on_color: "success",
-									off_color: "danger",
-									on_text: "Si",
-									off_text: "No"
-								}
-							}, "true","false"
-						) %>
-					</div>
-				</div>
-				<div class="form-group inventory">
-					<%= f.label :price_base_dollars, "Precio de compra neto", {:class=>"col-md-3 control-label"} %>
-					<div class="col-md-3">
-
-						<div class="input-group <%=(@product.persisted? && @product.is_in_dollars?) ? '' : 'hidden' %>" id="price_base_usd_div">
-							<span class="input-group-addon"> $ </span>
-							<%= f.text_field :price_base_dollars, {:class=>"form-control mask_decimal"} %>
-							<span class="input-group-addon"> USD </span>
-						</div>
-
-						<div class="input-group <%=(@product.persisted? && !@product.is_in_dollars?) ? '' : 'hidden' %>" id="price_base_mxn_div">
-							<span class="input-group-addon"> $ </span>
-							<%= f.text_field :price_base, {:class=>"form-control mask_decimal"} %>
-							<span class="input-group-addon"> MXN </span>
-						</div>
-
-					</div>
-				</div>
-				<div class="form-group inventory">
-					<%= f.label :price_sale, "Precio de venta base", {:class=>"col-md-3 control-label"} do %> Precio de venta base
-						<span class="required">*</span>
-					<% end %>
-					<div class="col-md-3">
-						<div class="input-group">
-							<span class="input-group-addon"> $ </span>
-							<%= f.text_field :price_sale, {:class=>"form-control mask_decimal"} %>
-							<span class="input-group-addon"> MXN </span>
-						</div>
-					</div>
-					<div class="col-md-6">
-						<span class="help-block">El precio de venta base será calculado de acuerdo al porcentaje de utilidad especificado, solo en en caso de especificar el precio de compra neto.</span>
-					</div>
-				</div>
-				<div class="form-group">
-					<%= f.label :presentation, "¿El producto tiene variantes?", {:class=>"col-md-3 control-label"} do %>¿El producto tiene variantes?
-						<span class="required">*</span>
-					<% end %>
-					<div class="col-md-9">
-						<%= f.check_box(:presentation,
-							{
-								class: "make-switch",
-								data: {
-									on_color: "success",
-									off_color: "danger",
-									on_text: "Si",
-									off_text: "No"
-								},
-								readonly: @with_presentation
-							}, "true","false"
-						) %>
-					</div>
-				</div>
-			</div>
-			<h4 class="form-section presentaciones">Variantes</h4>
-			<div class="row presentaciones">
-				<% if @product.persisted? %>
-				<div class="col-md-9 col-md-offset-3">
-					<%= render 'products_children' %>
-				</div>
-				<% else %>
-				<div class="col-md-9 col-md-offset-3">
-					<div class="alert alert-warning hidden">
-						Son <strong id="variantes"></strong> variantes del producto.
-					</div>
-				</div>
-				<div class="form-group ">
-					<%= f.label :size_list, "Tallas", {:class=>"col-md-3 control-label"} %>
-					<div class="col-md-9">
-						<%= f.collection_select(:size_list, @product.size_list, :to_s, :to_s, { :include_blank => false }, {:class=>"form-control input-medium", 'data-role'=>'tagsinput', :multiple => true} ) %>
-						<span class="help-block">Ingrese las diferentes tallas, separandolas con coma (,). </span>
-					</div>
-				</div>
-				<div class="form-group ">
-					<%= f.label :color_list, "Colores", {:class=>"col-md-3 control-label"} %>
-					<div class="col-md-9">
-						<%= f.collection_select(:color_list, @product.color_list, :to_s, :to_s, { :include_blank => false }, {:class=>"form-control input-medium", 'data-role'=>'tagsinput', :multiple => true} ) %>
-						<span class="help-block">Ingrese los diferentes colores, separandolos con coma (,). </span>
-					</div>
-				</div>
-				<div class="form-group ">
-					<%= f.label :style_list, "Estilos", {:class=>"col-md-3 control-label"} %>
-					<div class="col-md-9">
-						<%= f.collection_select(:style_list, @product.style_list, :to_s, :to_s, { :include_blank => false }, {:class=>"form-control input-medium", 'data-role'=>'tagsinput', :multiple => true} ) %>
-						<span class="help-block">Ingrese los diferentes estilos, separandolos con coma (,). </span>
-					</div>
-				</div>
-				<%= hidden_field_tag :variants %>
-				<% end %>
-			</div>
-		</div>
-		<div class="form-actions">
-			<div class="row">
-				<div class="col-md-offset-3 col-md-9">
-					<%= f.submit 'Guardar', {:class=>"btn green"} %>
-					<%= link_to 'Cancelar', products_path(:filter => @filter, :current_page => @current_page), {:class=>"btn default"} %>
-				</div>
-			</div>
-		</div>
-	</div>
+<%= form_for(@product, html: { class: "form-horizontal" }) do |f| %>
+  <div class="portlet-body form" id="products_form">
+    <% if @product.errors.any? %>
+      <div class="alert alert-danger">
+        <strong>Tiene <%= pluralize(@product.errors.count, "error") %> no se puede guardar el producto</strong><br>
+      </div>
+    <% end %>
+    <div class="form-body">
+      <input type="text" class="hidden" value="<%= @product.id %>" id="idproduct">
+      <h4 class="form-section">Información general</h4>
+      <div class="row">
+        <div class="col-md-7">
+          <%= hidden_field_tag :gain_margin, @pos_config.gain_margin %>
+          <%= hidden_field_tag :tax_percent, @pos_config.tax_percent %>
+          <div class="form-group">
+            <%= f.label :sku, { class: "col-md-3 col-sm-2 control-label" } do %>SKU <span class="required">*</span>
+            <% end %>
+            <div class="col-md-9 col-sm-4">
+              <div class="input-icon">
+                <i class="fa fa-tag"></i>
+                <%= f.text_field :sku, { class: "form-control input-medium", readonly: true } %>
+              </div>
+              <span class="help-block">El SKU se genera automáticamente en base a la línea y sublínea seleccionadas. </span>
+            </div>
+          </div>
+          <div class="form-group">
+            <%= f.label :barcode, { class: "col-md-3 col-sm-2 control-label" } do %> Código de barras <span class="required">*</span> <% end %>
+            <div class="col-md-9 col-sm-4">
+              <div class="input-icon">
+                <i class="fa fa-barcode"></i>
+                <%= f.text_field :barcode, { class: "form-control input-medium", readonly: true } %>
+              </div>
+              <span class="help-block">Para indicar el código de barras, debe escanearlo. </span>
+            </div>
+          </div>
+          <div class="form-group">
+            <%= f.label :name, "Producto", { class: "col-md-3 col-sm-2 control-label" } do %>Nombre <span class="required">*</span> <% end %>
+            <div class="col-md-9 col-sm-4">
+              <%= f.text_field :name, { class: "form-control input-large" } %>
+            </div>
+          </div>
+          <div class="form-group">
+            <%= f.label :description, "Descripción", { class: "col-md-3 col-sm-2 control-label" } %>
+            <div class="col-md-9 col-sm-4">
+              <%= f.text_area :description, { class: "form-control input-large" } %>
+            </div>
+          </div>
+          <div class="form-group">
+            <%= f.label :unit_id, "Unidad de medida", { class: "col-md-3 col-sm-2 control-label" } do %>Unidad de medida <span class="required">*</span> <% end %>
+            <div class="col-md-9 col-sm-4">
+              <%= f.collection_select :unit_id, Unit.vigentes, :id, :unit, { prompt: "Seleccione" }, { class: "form-control input-medium" } %>
+            </div>
+          </div>
+        </div>
+        <div class="col-md-5">
+          <div class="form-group">
+            <%= f.label :img_product, "Imagen producto", { class: "col-md-5 col-sm-2 control-label" } %>
+            <div class="col-md-7 col-sm-4">
+              <div class="fileinput fileinput-new" data-provides="fileinput">
+                <div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
+                  <% if @product.img_product? %>
+                    <%= image_tag @product.img_product %>
+                  <% else %>
+                    <%= image_tag "no-image.png" %>
+                  <% end %>
+                </div>
+                <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"> </div>
+                <div>
+                  <span class="btn default btn-file">
+                    <span class="fileinput-new"> Seleccione imagen </span>
+                    <span class="fileinput-exists"> Cambiar </span>
+                    <%= f.file_field :img_product, { class: "default" } %>
+                    <%= f.hidden_field :img_product_cache %>
+                  </span>
+                  <a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput"> Borrar </a>
+                </div>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+      <h4 class="form-section">Información del producto</h4>
+      <div class="row">
+        <div class="form-group ">
+          <%= f.label :inventory, "¿Se maneja inventario de este producto?", { class: "col-md-3 col-sm-3 control-label" } do %>¿Este producto tendrá inventario? <span class="required">*</span> <% end %>
+          <div class="col-md-9 col-sm-2">
+            <%= f.check_box(:inventory,
+              {
+                class: "make-switch",
+                data: {
+                  on_color: "success",
+                  off_color: "danger",
+                  on_text: "Si",
+                  off_text: "No"
+                }
+              }, "true","false"
+            ) %>
+          </div>
+        </div>
+        <div class="form-group">
+          <%
+            @category = nil
+            @subcategory = nil;
+            @prompt = 'Seleccione'
+            @disabled = true
+            if @product.categories[0].present? && @product.categories[0].parent_id == 0
+              @category = @product.categories[0]
+              @prompt = ''
+            elsif @product.categories[0].present?
+              @category = Category.find(@product.categories[0].parent_id)
+              @subcategory = @product.categories[0]
+              @disabled = false
+            end
+          %>
+          <%= label_tag :categorias, "Líneas de producto", { class: "col-md-3 col-sm-3 control-label" } do %>Líneas de producto <span class="required">*</span> <% end %>
+          <div class="col-md-4 col-sm-4">
+            <%= select_tag 'categorias', options_from_collection_for_select(Category.activos_padre, 'id', 'category', :selected => (@category.id unless @category.nil?)), { :include_blank => "Seleccione", :class => 'form-control' } %>
+          </div>
+        </div>
+        <div class="form-group">
+          <%= f.label :category_ids, "Sublinea del producto", { class: "col-md-3 col-sm-3 control-label" }   %>
+          <div class="col-md-4 col-sm-4">
+            <%= f.collection_select(:category_ids, @category.nil? ? {} : Category.where(:parent_id => @category.id), :id, :category , options = { :include_blank => @prompt, :selected => (@subcategory.id unless @subcategory.nil?) }, :class => "form-control", :disabled => @disabled) %>
+            <%= f.hidden_field :category_ids, { :id => 'subcategory_hidden' } %>
+          </div>
+        </div>
+        <div class="form-group">
+          <%= f.label :include_purchase_tax, "¿Incluir IVA en compra?", { class: "col-md-3 col-sm-3 control-label" } do %> ¿Incluir IVA en compra? <span class="required">*</span> <% end %>
+          <div class="col-md-9 col-sm-2">
+            <%= f.check_box(:include_purchase_tax,
+              {
+                class: "make-switch",
+                data: {
+                  on_color: "success",
+                  off_color: "danger",
+                  on_text: "Si",
+                  off_text: "No"
+                }
+              }, "1","0"
+            ) %>
+          </div>
+        </div>
+        <div class="form-group">
+          <%= f.label :include_sale_tax, "¿Incluir IVA en venta?", { class: "col-md-3 col-sm-3 control-label" } do %> ¿Incluir IVA en venta? <span class="required">*</span> <% end %>
+          <div class="col-md-9 col-sm-2">
+            <%= f.check_box(:include_sale_tax,
+              {
+                class: "make-switch",
+                data: {
+                  on_color: "success",
+                  off_color: "danger",
+                  on_text: "Si",
+                  off_text: "No"
+                }
+              }, "1","0"
+            ) %>
+          </div>
+        </div>
+        <div class="form-group">
+          <%= f.label :is_in_dollars, "¿Se compra en dólares?", { class: "col-md-3 col-sm-3 control-label" } do %> ¿Se compra en dólares? <span class="required">*</span> <% end %>
+          <div class="col-md-9 col-sm-2">
+            <%= f.check_box(:is_in_dollars,
+              {
+                class: "make-switch",
+                data: {
+                  on_color: "success",
+                  off_color: "danger",
+                  on_text: "Si",
+                  off_text: "No"
+                }
+              }, "true","false"
+            ) %>
+          </div>
+        </div>
+        <div class="form-group inventory">
+          <%= f.label :price_base_dollars, "Precio de compra neto", { class: "col-md-3 col-sm-3 control-label" } %>
+          <div class="col-md-3 col-sm-3">
+            <div class="input-group <%= (@product.persisted? && @product.is_in_dollars?) ? '' : 'hidden' %>" id="price_base_usd_div">
+              <span class="input-group-addon"> $ </span>
+              <%= f.text_field :price_base_dollars, { class: "form-control mask_decimal" } %>
+              <span class="input-group-addon"> USD </span>
+            </div>
+            <div class="input-group <%= (@product.persisted? && !@product.is_in_dollars?) ? '' : 'hidden' %>" id="price_base_mxn_div">
+              <span class="input-group-addon"> $ </span>
+              <%= f.text_field :price_base, { class: "form-control mask_decimal" } %>
+              <span class="input-group-addon"> MXN </span>
+            </div>
+          </div>
+        </div>
+        <div class="form-group inventory">
+          <%= f.label :price_sale, "Precio de venta base", { class: "col-md-3 col-sm-3 control-label" } do %> Precio de venta base
+            <span class="required">*</span>
+          <% end %>
+          <div class="col-md-3 col-sm-3">
+            <div class="input-group">
+              <span class="input-group-addon"> $ </span>
+              <%= f.text_field :price_sale, { class: "form-control mask_decimal" } %>
+              <span class="input-group-addon"> MXN </span>
+            </div>
+          </div>
+          <div class="col-md-6 col-sm-6">
+            <span class="help-block">El precio de venta base será calculado de acuerdo al porcentaje de utilidad especificado, sólo en caso de especificar el precio de compra neto.</span>
+          </div>
+        </div>
+        <div class="form-group">
+          <%= f.label :presentation, "¿El producto tiene variantes?", { class: "col-md-3 col-sm-3 control-label" } do %>¿El producto tiene variantes?
+            <span class="required">*</span>
+          <% end %>
+          <div class="col-md-9 col-sm-2">
+            <%= f.check_box(:presentation,
+              {
+                class: "make-switch",
+                data: {
+                  on_color: "success",
+                  off_color: "danger",
+                  on_text: "Si",
+                  off_text: "No"
+                },
+                readonly: @with_presentation
+              }, "true", "false"
+            ) %>
+          </div>
+        </div>
+      </div>
+      <h4 class="form-section presentaciones">Variantes</h4>
+      <div class="row presentaciones">
+        <% if @product.persisted? %>
+        <div class="col-md-offset-2 col-md-9 col-sm-offset-2 col-sm-9">
+          <%= render 'products_children' %>
+        </div>
+        <% else %>
+        <div class="col-md-9 col-md-offset-3">
+          <div class="alert alert-warning hidden">
+            Son <strong id="variantes"></strong> variantes del producto.
+          </div>
+        </div>
+        <div class="form-group ">
+          <%= f.label :size_list, "Tallas", { class: "col-md-3 control-label" } %>
+          <div class="col-md-9">
+            <%= f.collection_select(:size_list, @product.size_list, :to_s, :to_s, { include_blank: false }, { class: "form-control input-medium", 'data-role'=>'tagsinput', multiple: true }) %>
+            <span class="help-block">Ingrese las diferentes tallas, separándolas con coma (,) </span>
+          </div>
+        </div>
+        <div class="form-group ">
+          <%= f.label :color_list, "Colores", { class: "col-md-3 control-label" } %>
+          <div class="col-md-9">
+            <%= f.collection_select(:color_list, @product.color_list, :to_s, :to_s, { include_blank: false }, { class: "form-control input-medium", 'data-role'=>'tagsinput', multiple: true }) %>
+            <span class="help-block">Ingrese los diferentes colores, separándolos con coma (,) </span>
+          </div>
+        </div>
+        <div class="form-group ">
+          <%= f.label :style_list, "Estilos", { class: "col-md-3 control-label" } %>
+          <div class="col-md-9">
+            <%= f.collection_select(:style_list, @product.style_list, :to_s, :to_s, { include_blank: false }, { class: "form-control input-medium", 'data-role'=>'tagsinput', multiple: true }) %>
+            <span class="help-block">Ingrese los diferentes estilos, separándolos con coma (,) </span>
+          </div>
+        </div>
+        <%= hidden_field_tag :variants %>
+        <% end %>
+      </div>
+    </div>
+    <div class="form-actions">
+      <div class="row">
+        <div class="col-md-offset-3 col-md-9">
+          <%= f.submit 'Guardar', { class: "btn green" } %>
+          <%= link_to 'Cancelar', products_path(filter: @filter, current_page: @current_page), { class: "btn default" } %>
+        </div>
+      </div>
+    </div>
+  </div>
 <% end %>
 <script type="text/javascript">
-	var timeout = null;
-	var regex = /[a,e,i,o,u]/gi;
-	var skuEdit = "";
-
-	$(document).on('page:change', function() {
+  var timeout = null;
+  var regex = /[a,e,i,o,u]/gi;
+  var skuEdit = "";
 
-		App.init();
+  $(document).on('page:change', function() {
+    App.init();
+    $('.fileinput').fileinput();
+    <% if @product.barcode.blank? %>
+      $('body').barcodeListener().on('barcode.valid', function(e, code) {
+        if($('#product_barcode').length > 0) {
+          $('#product_barcode').val(code);
+          validateBarcode(code);
+        }
+      });
+    <% end %>
 
-		$('.fileinput').fileinput();
+    presentaciones();
+    // < % if @product.children.present? %>
+      getVariants();
+    // < % end %>
+    showPriceBaseInput(<%= @product.is_in_dollars? %>);
 
-		<% if @product.barcode.blank? %>
-			$('body').barcodeListener().on('barcode.valid', function(e, code) {
-				if($('#product_barcode').length > 0) {
-					$('#product_barcode').val(code);
-					validateBarcode(code);
-				}
-			});
-		<% end %>
+    $(document).on("cut copy paste",'form#new_product .presentaciones input[type=text]', function(e) {
+      // evitar que se pueda copiar y pegar en los inputs de los tags de variantes
+      e.preventDefault();
+    });
+  });
 
-		presentaciones();
-		getVariants();
-		showPriceBaseInput(<%= @product.is_in_dollars? %>);
+  $('#product_size_list').on('change', function(event) { getVariants(); });
+  $('#product_color_list').on('change', function(event) { getVariants(); });
+  $('#product_style_list').on('change', function(event) { getVariants(); });
 
+  function presentaciones(){
+    if ($('#product_presentation').is(':checked')){
+      $('.presentaciones').removeClass('hidden');
+    } else {
+      $('.presentaciones').addClass('hidden');
+    }
+  }
 
-		$(document).on("cut copy paste",'form#new_product .presentaciones input[type=text]',function(e) {
-			// evitar que se pueda copiar y pegar en los inputs de los tags de variantes
-			e.preventDefault();
-		});
-	});
+  $('#product_presentation').on('switchChange.bootstrapSwitch', function(event, state) {
+    presentaciones();
+  });
 
-	$('#product_size_list').on('change', function(event) { getVariants(); });
-	$('#product_color_list').on('change', function(event) { getVariants(); });
-	$('#product_style_list').on('change', function(event) { getVariants(); });
+  function getVariants(){
+    sizes = $('#product_size_list').tagsinput('items');
+    colors = $('#product_color_list').tagsinput('items');
+    styles = $('#product_style_list').tagsinput('items');
 
-	function presentaciones(){
-		if ($('#product_presentation').is(':checked')){
-			$('.presentaciones').removeClass('hidden');
-		}
-		else{ $('.presentaciones').addClass('hidden'); }
-	}
+    variantes = (sizes.length > 0 ? sizes.length : 1)
+      * (colors.length > 0 ? colors.length : 1 )
+      * (styles.length > 0 ? styles.length : 1);
+    $('#variants').html(variantes);
+    $('.alert-warning').removeClass('hidden');
+    $('#variantes').html(variantes);
+  }
 
-	$('#product_presentation').on('switchChange.bootstrapSwitch', function(event, state) {
-		presentaciones();
-	});
+  $('#categorias').on('change', function() {
+    $('#product_sku').val('');
+    if($('#categorias').val()) {
+      $.ajax({
+        type: "get",
+        url:  '/getcategories/' + $(this).val(),
+        dataType: 'json',
+        success: function(data) {
+          $('#product_category_ids').empty();
+          if(data.length > 0) {
+            $('#product_category_ids').attr('disabled', false);
+            $('#product_category_ids').append("<option selected value='0'>Seleccione</option>")
+          } else {
+            $('#product_category_ids').attr('disabled', true);
+            $('#subcategory_hidden').val($('#categorias').val());
+            $('#product_category_ids').append("<option selected value='" + $('#categorias').val() +"'></option>")
+          }
+          for(i in data){
+            $('#product_category_ids').append("<option value='" + data[i].id +"'>" + data[i].category+ "</option>")
+          }
+          fillSKU();
+        }
+      });
+    }
+  });
 
-	function getVariants(){
-		sizes = $('#product_size_list').tagsinput('items');
-		colors = $('#product_color_list').tagsinput('items');
-		styles = $('#product_style_list').tagsinput('items');
+  $('#product_category_ids').on('change', function() {
+    $('#subcategory_hidden').val($(this).val());
+    fillSKU();
+  });
 
-		variantes = (sizes.length > 0 ? sizes.length : 1)
-			* (colors.length > 0 ? colors.length : 1 )
-				* (styles.length > 0 ? styles.length : 1);
-		$('#variants').html(variantes);
-		$('.alert-warning').removeClass('hidden');
-		$('#variantes').html(variantes);
-	}
+  $('#product_price_base').on('input', function() {
+    getSalePrice($(this));
+  });
 
-	$('#categorias').on('change', function() {
-		$('#product_sku').val('');
-		if($('#categorias').val()) {
-			$.ajax({
-				type: "get",
-				url:  '/getcategories/' + $(this).val(),
-				dataType: 'json',
-				success: function(data) {
-					$('#product_category_ids').empty();
-					if(data.length > 0) {
-						$('#product_category_ids').attr('disabled', false);
-						$('#product_category_ids').append("<option selected value='0'>Seleccione</option>")
-					} else {
-						$('#product_category_ids').attr('disabled', true);
-						$('#subcategory_hidden').val($('#categorias').val());
-						$('#product_category_ids').append("<option selected value='" + $('#categorias').val() +"'></option>")
-					}
-					for(i in data){
-						$('#product_category_ids').append("<option value='" + data[i].id +"'>" + data[i].category+ "</option>")
-					}
-					fillSKU();
-				}
-			});
-		}
-	});
+  $('#product_is_in_dollars').on('switchChange.bootstrapSwitch', function(event, state) {
+    showPriceBaseInput(state);
+  });
 
-	$('#product_category_ids').on('change', function() {
-		$('#subcategory_hidden').val($(this).val());
-		fillSKU();
-	});
+  function getSalePrice(input){
+    clearTimeout(timeout);
+    timeout = setTimeout(function () {
+      var gainMargin = parseFloat($('#gain_margin').val());
+      var purchasePrice = parseFloat(input.val());
+      var gain = (gainMargin / 100) * purchasePrice
+      $('#product_price_sale').val( (purchasePrice + gain).toFixed(2) );
+    }, 500);
+  }
 
-	$('#product_price_base').on('input', function() {
-		getSalePrice($(this));
-	});
 
-	$('#product_is_in_dollars').on('switchChange.bootstrapSwitch', function(event, state) {
-		showPriceBaseInput(state);
-	});
+  function getProductId() {
+    $('#categorias').attr('disabled', true);
+    $.ajax({
+      type: "get",
+      url:  '/get_max_product_id',
+      dataType: 'json',
+      success: function(data) {
+        $('#categorias').attr('disabled', false);
+        var sku = $('#product_sku').val();
+        if(sku.length && !$('#idproduct').val()) {
+          $('#product_sku').val(sku + "-" + data);
+        } else {
+          $('#product_sku').val(sku + "-" + $('#idproduct').val());
+        }
+      },
+    });
+  }
 
-	function getSalePrice(input){
-		clearTimeout(timeout);
-		timeout = setTimeout(function () {
-			var gainMargin = parseFloat($('#gain_margin').val());
-			var purchasePrice = parseFloat(input.val());
-			var gain = (gainMargin / 100) * purchasePrice
-			$('#product_price_sale').val( (purchasePrice + gain).toFixed(2) );
-		}, 500);
-	}
+  function fillSKU() {
+    var sku = $('#product_sku').val();
+    if(sku.length <= 3) {
+      $('#product_sku').val($('#categorias option:selected').text().substring(0,3).toUpperCase());
+      getProductId();
+    }
 
+    sku = $('#product_sku').val();
+    if(sku.length >= 3 && $('#product_category_ids').val() != "0") {
+      var subcategory = $('#product_category_ids option:selected').text();
+      if(subcategory){
+        $('#product_sku').val(sku.substring(0,3) + '-' + subcategory.replace(regex, '').substring(0,3).toUpperCase());
+        getProductId();
+      }
+    }
+  }
 
-	function getProductId() {
-		$('#categorias').attr('disabled', true);
-		$.ajax({
-			type: "get",
-			url:  '/get_max_product_id',
-			dataType: 'json',
-			success: function(data) {
-				$('#categorias').attr('disabled', false);
-				var sku = $('#product_sku').val();
-				if(sku.length && !$('#idproduct').val()) {
-					$('#product_sku').val(sku + "-" + data);
-				} else {
-					$('#product_sku').val(sku + "-" + $('#idproduct').val());
-				}
-			},
-		});
-	}
+  function validateBarcode(barcode) {
+    $.ajax({
+      type: "get",
+      url: '/validate_unique_barcode/' + barcode,
+      dataType: 'script',
+      success: function(data) {
+      }
+    });
+  }
 
-	function fillSKU() {
-		var sku = $('#product_sku').val();
-		if(sku.length <= 3) {
-			$('#product_sku').val($('#categorias option:selected').text().substring(0,3).toUpperCase());
-			getProductId();
-		}
-
-		sku = $('#product_sku').val();
-		if(sku.length >= 3 && $('#product_category_ids').val() != "0") {
-			var subcategory = $('#product_category_ids option:selected').text();
-			if(subcategory){
-				$('#product_sku').val(sku.substring(0,3) + '-' + subcategory.replace(regex, '')
-					.substring(0,3).toUpperCase());
-				getProductId();
-			}
-		}
-	}
-
-	function validateBarcode(barcode) {
-		$.ajax({
-			type: "get",
-			url:  '/validate_unique_barcode/' + barcode,
-			dataType: 'script',
-			success: function(data) {
-			}
-		});
-	}
-
-	function showPriceBaseInput(state) {
-		//true es en dolares, false en pesos
-		if (state) {
-		$('#price_base_usd_div').removeClass('hidden');
-		$('#price_base_mxn_div').addClass('hidden');
-		$('#product_price_base').val('');
-		 <% unless @product.persisted? %>
-			$('#product_price_sale').val('');
-		 <% end %>
-		} else {
-		$('#price_base_mxn_div').removeClass('hidden');
-		$('#price_base_usd_div').addClass('hidden');
-		$('#product_price_base_dollars').val('');
-		}
-	}
+  function showPriceBaseInput(state) {
+    //true es en dolares, false en pesos
+    if (state) {
+    $('#price_base_usd_div').removeClass('hidden');
+    $('#price_base_mxn_div').addClass('hidden');
+    $('#product_price_base').val('');
+     <% unless @product.persisted? %>
+      $('#product_price_sale').val('');
+     <% end %>
+    } else {
+    $('#price_base_mxn_div').removeClass('hidden');
+    $('#price_base_usd_div').addClass('hidden');
+    $('#product_price_base_dollars').val('');
+    }
+  }
 </script>
-

+ 51 - 53
app/views/products/_products_track_dtl.html.erb

@@ -1,53 +1,51 @@
-										<% if !@sales.nil? %>
-										<div class="row">
-											<div class="col-md-12">
-												<div class="col-md-6 col-sm-3 col-xs-6 " >
-													<div class="text-center well" id="container_total_prods" style="margin-bottom: 0px">
-														<div class="font-grey-mint font-sm">Cantidad vendida</div>
-														<div class="uppercase font-hg font-blue-sharp" id="total_prods"> <%= @sales.sum(:quantity) %></div>
-													</div>
-												</div>
-												<div class="col-md-6 col-sm-3 col-xs-6 " >
-													<div class="text-center well" id="container_total_prods" style="margin-bottom: 0px">
-														<div class="font-grey-mint font-sm">Total de ingresos </div>
-														<div class="uppercase font-hg font-blue-sharp" id="total_prods"> <%= number_to_currency(@sales.sum(:total) , precision: 2) %></div>
-													</div>
-												</div>
-											</div>
-										</div>
-										<br>
-										<% end %>
-										<div class="row">
-											<div class="col-md-12">
-												<table class="table table-striped table-bordered table-hover tableadvanced"  >
-													<thead>
-														<tr>
-															<th>Folio Venta</th>
-															<th>Fecha</th>
-															<th>Punto de venta</th>
-															<th>Vendido por </th>
-															<th>Cantidad</th>
-															<th>Precio</th>
-															<th>Descto.</th>
-															<th>Importe</th>
-														</tr>
-													</thead>
-													<tbody>
-													<% if !@sales.nil? %>
-													<% @sales.each_with_index do |sale, key| %>
-														<tr>
-															<td><%= l(sale.sale.date_sale, :format => '%d/%m/%Y') %></td>
-															<td><%= sale.sale.sale_code %> </td>
-															<td><%= sale.sale.get_pointsale.name %></td>
-															<td><%= sale.sale.seller.name %> </td>
-															<td><%= sale.quantity %> </td>
-															<td><%= number_to_currency(sale.amount, precision: 2) %></td>
-															<td><%= number_to_currency(sale.discount, precision: 2) %></td>
-															<td><%= number_to_currency(sale.total, precision: 2) %></td>
-														</tr>
-													<% end %>
-													<% end %>
-													</tbody>
-												</table>
-											</div>
-										</div>
+<% unless @sales.nil? %>
+  <div class="row">
+    <div class="col-md-12">
+      <div class="col-md-6 col-sm-3 col-xs-6 " >
+        <div class="text-center well" id="container_total_prods" style="margin-bottom: 0px">
+          <div class="font-grey-mint font-sm">Cantidad vendida</div>
+          <div class="uppercase font-hg font-blue-sharp" id="total_prods"> <%= @total_quantity.to_i %></div>
+        </div>
+      </div>
+      <div class="col-md-6 col-sm-3 col-xs-6 " >
+        <div class="text-center well" id="container_total_prods" style="margin-bottom: 0px">
+          <div class="font-grey-mint font-sm">Total de ingresos </div>
+          <div class="uppercase font-hg font-blue-sharp" id="total_prods"> <%= number_to_currency(@total_sales, precision: 2) %></div>
+        </div>
+      </div>
+    </div>
+  </div>
+  <br>
+<% end %>
+<div class="row">
+  <div class="col-md-12">
+    <table class="table table-striped table-bordered table-hover tableadvanced">
+      <thead>
+        <tr>
+          <th>Folio Venta</th>
+          <th>Fecha</th>
+          <th>Punto de venta</th>
+          <th>Vendido por </th>
+          <th>Cantidad</th>
+          <th>Precio</th>
+          <th>Descto.</th>
+          <th>Importe</th>
+        </tr>
+      </thead>
+      <tbody>
+        <% @sales.each do |sale, key| %>
+          <tr>
+            <td><%= l(sale.sale.date_sale, format: '%d/%m/%Y') %></td>
+            <td><%= sale.sale.sale_code %> </td>
+            <td><%= sale.sale.get_pointsale.name %></td>
+            <td><%= sale.sale.seller.name %> </td>
+            <td><%= sale.quantity %> </td>
+            <td><%= number_to_currency(sale.amount, precision: 2) %></td>
+            <td><%= number_to_currency(sale.discount, precision: 2) %></td>
+            <td><%= number_to_currency(sale.total, precision: 2) %></td>
+          </tr>
+        <% end %>
+      </tbody>
+    </table>
+  </div>
+</div>

+ 45 - 0
app/views/products/_products_track_purchases_dtl.html.erb

@@ -0,0 +1,45 @@
+<% unless @purchases.nil? %>
+  <div class="row">
+    <div class="col-md-12">
+      <div class="col-md-6 col-sm-3 col-xs-6 " >
+        <div class="text-center well" id="container_total_prods" style="margin-bottom: 0px">
+          <div class="font-grey-mint font-sm">Cantidad comprada</div>
+          <div class="uppercase font-hg font-blue-sharp" id="total_prods"> <%= @total_quantity_purchases %></div>
+        </div>
+      </div>
+    </div>
+  </div>
+  <br>
+<% end %>
+<div class="row">
+  <div class="col-md-12">
+    <table class="table table-striped table-bordered table-hover tableadvanced">
+      <thead>
+        <tr>
+          <th>Folio compra</th>
+          <th>Fecha</th>
+          <th>Lugar</th>
+          <th>Proveedor</th>
+          <th>Cantidad</th>
+          <th>Capturó</th>
+        </tr>
+      </thead>
+      <tbody>
+        <% @purchases.each_with_index do |purchase_detail, key| %>
+          <tr>
+            <td><%= purchase_detail.purchase.purchase_code %> </td>
+            <td><%= l(purchase_detail.purchase.purchase_date, :format => '%d/%m/%Y') %></td>
+            <% if purchase_detail.purchase.pointsale.present? %>
+             <td><%= purchase_detail.purchase.pointsale.name %></td>
+            <% else %>
+              <td><%= purchase_detail.purchase.warehouse.name %></td>
+            <% end %>
+            <td><%= purchase_detail.purchase.supplier.nick_name %> </td>
+            <td><%= purchase_detail.quantity %> </td>
+            <td><%= purchase_detail.purchase.user.userid %> </td>
+          </tr>
+        <% end %>
+      </tbody>
+    </table>
+  </div>
+</div>

+ 1 - 1
app/views/products/edit.html.erb

@@ -17,7 +17,7 @@
 			<!-- BEGIN PAGE CONTENT BODY -->
 			<div class="page-content">
 				<div class="container-fluid">
-					<%= link_to  products_path(:filter => @filter, :current_page => @current_page), {:class=>"fr-space btn blue-hoki "} do %>
+					<%= link_to  products_path(:filter => @filter, :current_page => @current_page), {:class=>"fr-space btn blue-hoki pull-right margin-bottom-10"} do %>
 						<i class="fa fa-angle-left "></i>
 						Regresar
 					<% end %>

+ 192 - 195
app/views/products/edit_variants.html.erb

@@ -1,251 +1,248 @@
 	<!-- BEGIN CONTAINER -->
-	<div class="page-container">
+<div class="page-container">
 		<!-- BEGIN CONTENT -->
-		<div class="page-content-wrapper">
+	<div class="page-content-wrapper">
 			<!-- BEGIN CONTENT BODY -->
 			<!-- BEGIN PAGE HEAD-->
-			<div class="page-head">
-				<div class="container-fluid">
+		<div class="page-head">
+			<div class="container-fluid">
 					<!-- BEGIN PAGE TITLE -->
-					<div class="page-title">
-						<h1> Producto </h1>
-					</div>
-					<!-- END PAGE TITLE -->
+				<div class="page-title">
+					<h1> Producto </h1>
 				</div>
+					<!-- END PAGE TITLE -->
 			</div>
+		</div>
 			<!-- END PAGE HEAD-->
 			<!-- BEGIN PAGE CONTENT BODY -->
-			<div class="page-content">
-				<div class="container-fluid">
-					<%= link_to  products_path(:filter => @filter, :current_page => @current_page), {:class=>"fr-space btn blue-hoki "} do %>
-						<i class="fa fa-angle-left "></i>
-						Regresar
-					<% end %>
-					<!-- BEGIN PAGE BREADCRUMBS -->
-					<ul class="page-breadcrumb breadcrumb">
-						<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
-					</ul>
-					<!-- END PAGE BREADCRUMBS -->
-					<!-- BEGIN PAGE CONTENT INNER -->
-					<div class="page-content-inner">
-						<div id="notice"><%= notice %></div>
-						<div class="row">
-							<div class="col-md-12">
-								<%= form_tag(product_update_variants_path(@product.id), :multipart => true, :class => "form-horizontal", :id => "form") do |f| %>
-								<div class="portlet light  ">
-									<div class="portlet-title">
-										<div class="caption">
-											<i class="fa fa-edit font-blue-sharp"></i>
-											<span class="caption-subject font-blue-sharp bold uppercase">Modificar variantes del producto</span>
-											<span class="caption-helper"></span>
-										</div>
+		<div class="page-content">
+			<div class="container-fluid">
+				<%= link_to products_path(:filter => @filter, :current_page => @current_page), { class: "fr-space btn blue-hoki pull-right margin-bottom-10" } do %>
+					<i class="fa fa-angle-left "></i>
+					Regresar
+				<% end %>
+				<!-- BEGIN PAGE BREADCRUMBS -->
+				<ul class="page-breadcrumb breadcrumb">
+					<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
+				</ul>
+				<!-- END PAGE BREADCRUMBS -->
+				<!-- BEGIN PAGE CONTENT INNER -->
+				<div class="page-content-inner">
+					<div id="notice"><%= notice %></div>
+					<div class="row">
+						<div class="col-md-12">
+							<%= form_tag(product_update_variants_path(@product.id), :multipart => true, :class => "form-horizontal", :id => "form") do |f| %>
+							<div class="portlet light">
+								<div class="portlet-title">
+									<div class="caption">
+										<i class="fa fa-edit font-blue-sharp"></i>
+										<span class="caption-subject font-blue-sharp bold uppercase">Modificar variantes del producto</span>
+										<span class="caption-helper"></span>
 									</div>
-
-									<div class="portlet-body">
-										<div class="row">
-											<div class="col-md-6">
-												<div class="row static-info">
-													<div class="col-md-4 name"> SKU: </div>
-													<div class="col-md-8 value"> <%= @product.sku %></div>
-												</div>
-												<div class="row static-info">
-													<div class="col-md-4 name"> Producto: </div>
-													<div class="col-md-8 value"> <%= @product.name %> </div>
-												</div>
-												<% unless @product.parent_id.nil? %>
+								</div>
+								<div class="portlet-body">
+									<div class="row">
+										<div class="col-md-6">
+											<div class="row static-info">
+												<div class="col-md-4 name"> SKU: </div>
+												<div class="col-md-8 value"> <%= @product.sku %></div>
+											</div>
+											<div class="row static-info">
+												<div class="col-md-4 name"> Producto: </div>
+												<div class="col-md-8 value"> <%= @product.name %> </div>
+											</div>
+											<% unless @product.parent_id.nil? %>
 												<div class="row static-info">
-													<div class="col-md-4 name"> Presentacion: </div>
+													<div class="col-md-4 name"> Presentación: </div>
 													<div class="col-md-8 value"> <%= @product.display_attributes %> </div>
 												</div>
-												<% end %>
-												<div class="row static-info">
-													<div class="col-md-4 name"> Descripcion: </div>
-													<div class="col-md-8 value"> <%= @product.description %> </div>
-												</div>
-												<div class="row static-info">
-													<div class="col-md-4 name"> Unidad de medida: </div>
-													<div class="col-md-8 value"> <%= @product.unit.unit %> </div>
-												</div>
-												<div class="row static-info">
-													<div class="col-md-4 name"> Status: </div>
-													<div class="col-md-8 value"> <% if @product.status == "active" %> <span class="badge badge-success"> Activo</span>  <% else %> <span class="badge badge-danger"> Inactivo</span> <% end %></div>
-												</div>
+											<% end %>
+											<div class="row static-info">
+												<div class="col-md-4 name"> Descripción: </div>
+												<div class="col-md-8 value"> <%= @product.description %> </div>
 											</div>
-											<div class="col-md-6">
-												<div class="row static-info">
-													<div class="col-md-4 name"> Inventariado: </div>
-													<div class="col-md-8 value"> <% if @product.inventory %> <span class="label label-success"> Si</span>  <% else %> <span class="label label-danger"> No</span> <% end %> </div>
-												</div>
-												<div class="row static-info">
-													<div class="col-md-4 name"> Categorías: </div>
-													<div class="col-md-8 value">
-														<%  @product.categories.each_with_index do | cat, index | %>
-															<% if index > 0 %>  <br> <% end %>
-															<span class="badge badge-default badge-roundless" > <%= cat.category %> </span>
-														<% end %>
-													</div>
+											<div class="row static-info">
+												<div class="col-md-4 name"> Unidad de medida: </div>
+												<div class="col-md-8 value"> <%= @product.unit.unit %> </div>
+											</div>
+											<div class="row static-info">
+												<div class="col-md-4 name"> Status: </div>
+												<div class="col-md-8 value"> <% if @product.status == "active" %> <span class="badge badge-success"> Activo</span>  <% else %> <span class="badge badge-danger"> Inactivo</span> <% end %></div>
+											</div>
+										</div>
+										<div class="col-md-6">
+											<div class="row static-info">
+												<div class="col-md-4 name"> Inventariado: </div>
+												<div class="col-md-8 value"> <% if @product.inventory %> <span class="label label-success"> Si</span>  <% else %> <span class="label label-danger"> No</span> <% end %> </div>
+											</div>
+											<div class="row static-info">
+												<div class="col-md-4 name"> Categorías: </div>
+												<div class="col-md-8 value">
+													<% @product.categories.each_with_index do |cat, index| %>
+														<% if index > 0 %>  <br> <% end %>
+														<span class="badge badge-default badge-roundless" > <%= cat.category %> </span>
+													<% end %>
 												</div>
-												<% if current_user.usertype == "A" %>
+											</div>
+											<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 												<div class="row static-info">
 													<div class="col-md-4 name"> Precio compra: </div>
 													<div class="col-md-8 value"><%= (@product.is_in_dollars? ? "#{number_to_currency(@product.price_base_dollars, precision: 2)} USD" : "#{number_to_currency(@product.price_base, precision: 2)} MXN") %> </div>
 												</div>
-												<% end %>
-												<div class="row static-info">
-													<div class="col-md-4 name"> Precio venta base: </div>
-													<div class="col-md-8 value"> $ <%= @product.price_sale %> </div>
-												</div>
-
-											</div>
-										</div><br>
-										<h4 class="form-section presentaciones">Variantes</h4><hr>
-										<div class="col-md-9 col-md-offset-3">
-											<div class="alert alert-warning hidden">
-												Son <strong id="variantes"></strong> variantes del producto.
+											<% end %>
+											<div class="row static-info">
+												<div class="col-md-4 name"> Precio venta base: </div>
+												<div class="col-md-8 value"> $ <%= @product.price_sale %> </div>
 											</div>
 										</div>
+									</div><br>
+									<h4 class="form-section presentaciones">Variantes</h4><hr>
+									<div class="col-md-9 col-md-offset-3">
+										<div class="alert alert-warning hidden">
+											Son <strong id="variantes"></strong> variantes del producto.
+										</div>
+									</div>
 
-										<div class="form-group ">
-											<%= label_tag :size_list, "Tallas", {:class=>"col-md-3 control-label"} %>
-											<div class="col-md-9 div_sizes">
-												<button class="btn btn-primary btn-sm margin-bottom-10 add_size">Agregar talla</button>
-												<% @product.sizes.each_with_index do |s, i| %>
-													<%= text_field_tag "#{s.id}", s.name, :class => "form-control input-medium margin-bottom-10 sizes"  %>
-													<!-- < %= hidden_field_tag "size_#{s.id}", s.name %> -->
-												<% end %>
-												<%= hidden_field_tag "new_size_list", @product.sizes.to_json.to_s %>
-											</div>
+									<div class="form-group ">
+										<%= label_tag :size_list, "Tallas", {:class=>"col-md-3 control-label"} %>
+										<div class="col-md-9 div_sizes">
+											<button class="btn btn-primary btn-sm margin-bottom-10 add_size">Agregar talla</button>
+											<% @product.sizes.each_with_index do |s, i| %>
+												<%= text_field_tag "#{s.id}", s.name, :class => "form-control input-medium margin-bottom-10 sizes"  %>
+												<!-- < %= hidden_field_tag "size_#{s.id}", s.name %> -->
+											<% end %>
+											<%= hidden_field_tag "new_size_list", @product.sizes.to_json.to_s %>
 										</div>
+									</div>
 
-										<div class="form-group ">
-											<%= label_tag :color_list, "Colores", {:class=>"col-md-3 control-label"} %>
-											<div class="col-md-9 div_colors">
-												<button class="btn btn-primary btn-sm margin-bottom-10 add_color">Agregar color</button>
-												<% @product.colors.each_with_index do |s, i| %>
-													<%= text_field_tag "#{s.id}", s.name, :class => "form-control input-medium margin-bottom-10 colors"  %>
-													<!-- < %= hidden_field_tag "color_#{s.id}", s.name %> -->
-												<% end %>
-												<%= hidden_field_tag "new_color_list", @product.colors.to_json %>
-											</div>
+									<div class="form-group ">
+										<%= label_tag :color_list, "Colores", {:class=>"col-md-3 control-label"} %>
+										<div class="col-md-9 div_colors">
+											<button class="btn btn-primary btn-sm margin-bottom-10 add_color">Agregar color</button>
+											<% @product.colors.each_with_index do |s, i| %>
+												<%= text_field_tag "#{s.id}", s.name, :class => "form-control input-medium margin-bottom-10 colors"  %>
+												<!-- < %= hidden_field_tag "color_#{s.id}", s.name %> -->
+											<% end %>
+											<%= hidden_field_tag "new_color_list", @product.colors.to_json %>
 										</div>
+									</div>
 
-										<div class="form-group ">
-											<%= label_tag :style_list, "Estilos", {:class=>"col-md-3 control-label"} %>
-											<div class="col-md-9 div_styles">
-												<button class="btn btn-primary btn-sm margin-bottom-10 add_style">Agregar estilo</button>
-												<% @product.styles.each_with_index do |s, i| %>
-													<%= text_field_tag "#{s.id}", s.name, :class => "form-control input-medium margin-bottom-10 styles"  %>
-													<!-- < %= hidden_field_tag "style_#{s.id}", s.name %> -->
-												<% end %>
-												<%= hidden_field_tag "new_style_list", @product.styles.to_json %>
-											</div>
+									<div class="form-group ">
+										<%= label_tag :style_list, "Estilos", {:class=>"col-md-3 control-label"} %>
+										<div class="col-md-9 div_styles">
+											<button class="btn btn-primary btn-sm margin-bottom-10 add_style">Agregar estilo</button>
+											<% @product.styles.each_with_index do |s, i| %>
+												<%= text_field_tag "#{s.id}", s.name, :class => "form-control input-medium margin-bottom-10 styles"  %>
+												<!-- < %= hidden_field_tag "style_#{s.id}", s.name %> -->
+											<% end %>
+											<%= hidden_field_tag "new_style_list", @product.styles.to_json %>
 										</div>
-										<hr>
-										<div class="form-actions">
-											<div class="row">
-												<div class="col-md-9">
-													<%= submit_tag 'Guardar', {:class=>"btn green"} %>
-													<%= link_to 'Cancelar', products_path(:filter => @filter, :current_page => @current_page), {:class=>"btn default"} %>
-												</div>
+									</div>
+									<hr>
+									<div class="form-actions">
+										<div class="row">
+											<div class="col-md-9">
+												<%= submit_tag 'Guardar', {:class=>"btn green"} %>
+												<%= link_to 'Cancelar', products_path(:filter => @filter, :current_page => @current_page), {:class=>"btn default"} %>
 											</div>
 										</div>
-										<%= hidden_field_tag :variants %>
 									</div>
-
+									<%= hidden_field_tag :variants %>
 								</div>
-								<% end %>
 							</div>
+							<% end %>
 						</div>
 					</div>
-					<!-- END PAGE CONTENT INNER -->
 				</div>
+				<!-- END PAGE CONTENT INNER -->
 			</div>
+		</div>
 			<!-- END PAGE CONTENT BODY -->
 			<!-- END CONTENT BODY -->
-		</div>
-		<!-- END CONTENT -->
 	</div>
+		<!-- END CONTENT -->
+</div>
 	<!-- END CONTAINER -->
-	<script>
+<script>
 	$("#form").submit(function(e) {
 		var self = this;
 		e.preventDefault();
 
 		<% if @product.sizes.count > 0 %>
-		var sizes = JSON.parse($('#new_size_list').val());
-		$('.sizes').each(function () {
-			// console.log(this);
-			for (var i = 0; i < sizes.length ; i++) {
-				if(sizes[i].id == this.name){
-					sizes[i].name = this.value;
-				}
-			};
-		});
-		$('#new_size_list').val(JSON.stringify(sizes));
+			var sizes = JSON.parse($('#new_size_list').val());
+			$('.sizes').each(function () {
+				// console.log(this);
+				for (var i = 0; i < sizes.length ; i++) {
+					if(sizes[i].id == this.name){
+						sizes[i].name = this.value;
+					}
+				};
+			});
+			$('#new_size_list').val(JSON.stringify(sizes));
 		<% end %>
+
 		<% if @product.colors.count > 0 %>
-		var colors = JSON.parse($('#new_color_list').val());
-		$('.colors').each(function () {
-			// console.log(this);
-			for (var i = 0; i < colors.length ; i++) {
-				if(colors[i].id == this.name){
-					colors[i].name = this.value;
-				}
-			};
-		});
-		$('#new_color_list').val(JSON.stringify(colors));
+			var colors = JSON.parse($('#new_color_list').val());
+			$('.colors').each(function () {
+				// console.log(this);
+				for (var i = 0; i < colors.length ; i++) {
+					if(colors[i].id == this.name){
+						colors[i].name = this.value;
+					}
+				};
+			});
+			$('#new_color_list').val(JSON.stringify(colors));
 		<% end %>
+
 		<% if @product.styles.count > 0 %>
-		var styles = JSON.parse($('#new_style_list').val());
-		$('.styles').each(function () {
-			// console.log(this);
-			for (var i = 0; i < styles.length ; i++) {
-				if(styles[i].id == this.name){
-					styles[i].name = this.value;
-				}
-			};
-		});
-		$('#new_style_list').val(JSON.stringify(styles));
+			var styles = JSON.parse($('#new_style_list').val());
+			$('.styles').each(function () {
+				// console.log(this);
+				for (var i = 0; i < styles.length ; i++) {
+					if(styles[i].id == this.name){
+						styles[i].name = this.value;
+					}
+				};
+			});
+			$('#new_style_list').val(JSON.stringify(styles));
 		<% end %>
+
 		self.submit();
 		return false; //is superfluous, but I put it here as a fallback
 	});
 
 	$(document).ready(function() {
-	    var x = 1; //initlal text box count
-	    $('.add_size').click(function(e){ //on add input button click
-	        e.preventDefault();
-	        x++; //text box increment
-	        $('.div_sizes').append('<div class="margin-bottom-10"><div class="input-group"><input type="text" name="mynewsizes[]" class="form-control input-medium "/><a href="#" class="remove_field btn btn-icon-only red"><i class="fa fa-times"></i></a></div></div>'); //add input box
-
-	    });
-
-	    $('.div_sizes').on("click",".remove_field", function(e){ //user click on remove text
-	        e.preventDefault(); $(this).parent('div').remove(); x--;
-	    });
-
-	    var y = 1;
-	    $('.add_color').click(function(e){ //on add input button click
-	        e.preventDefault();
-	        y++; //text box increment
-	        $('.div_colors').append('<div class="margin-bottom-10"><div class="input-group"><input type="text" name="mynewcolors[]" class="form-control input-medium "/><a href="#" class="remove_field btn btn-icon-only red"><i class="fa fa-times"></i></a></div></div>'); //add input box
-
-	    });
-
-	    $('.div_colors').on("click",".remove_field", function(e){ //user click on remove text
-	        e.preventDefault(); $(this).parent('div').remove(); y--;
-	    });
-
-	    var z = 1;
-	    $('.add_style').click(function(e){ //on add input button click
-	        e.preventDefault();
-	        z++; //text box increment
-	        $('.div_styles').append('<div class="margin-bottom-10"><div class="input-group"><input type="text" name="mynewstyles[]" class="form-control input-medium "/><a href="#" class="remove_field btn btn-icon-only red"><i class="fa fa-times"></i></a></div></div>'); //add input box
-
-	    });
-
-	    $('.div_styles').on("click",".remove_field", function(e){ //user click on remove text
-	        e.preventDefault(); $(this).parent('div').remove(); z--;
-	    });
+    var x = 1; //initlal text box count
+    $('.add_size').click(function(e){ //on add input button click
+      e.preventDefault();
+      x++; //text box increment
+      $('.div_sizes').append('<div class="margin-bottom-10"><div class="input-group"><input type="text" name="mynewsizes[]" class="form-control input-medium "/><a href="#" class="remove_field btn btn-icon-only red"><i class="fa fa-times"></i></a></div></div>'); //add input box
+    });
+
+    $('.div_sizes').on("click",".remove_field", function(e){ //user click on remove text
+      e.preventDefault(); $(this).parent('div').remove(); x--;
+    });
+
+    var y = 1;
+    $('.add_color').click(function(e){ //on add input button click
+      e.preventDefault();
+      y++; //text box increment
+      $('.div_colors').append('<div class="margin-bottom-10"><div class="input-group"><input type="text" name="mynewcolors[]" class="form-control input-medium "/><a href="#" class="remove_field btn btn-icon-only red"><i class="fa fa-times"></i></a></div></div>'); //add input box
+    });
+
+    $('.div_colors').on("click",".remove_field", function(e){ //user click on remove text
+	    e.preventDefault(); $(this).parent('div').remove(); y--;
+    });
+
+    var z = 1;
+    $('.add_style').click(function(e){ //on add input button click
+      e.preventDefault();
+      z++; //text box increment
+      $('.div_styles').append('<div class="margin-bottom-10"><div class="input-group"><input type="text" name="mynewstyles[]" class="form-control input-medium "/><a href="#" class="remove_field btn btn-icon-only red"><i class="fa fa-times"></i></a></div></div>'); //add input box
+    });
+
+    $('.div_styles').on("click",".remove_field", function(e){ //user click on remove text
+      e.preventDefault(); $(this).parent('div').remove(); z--;
+	  });
 	});
-	</script>
+</script>

+ 2 - 2
app/views/products/index.html.erb

@@ -44,7 +44,7 @@
 												<span class="caption-subject bold uppercase">Lista de productos</span>
 											</div>
 											<div class="actions">
-												<% if current_user.usertype == 'A' || current_user.usertype == 'G' %>
+												<% if can? :create, Product %>
 													<%= link_to new_product_path(:filter => @filter, :current_page => @current_page), {:class=>"btn bold green pull-right filtros"} do %>
 														Nuevo Producto <i class="fa fa-plus"></i>
 													<% end %>
@@ -61,7 +61,7 @@
 														<th>#</th>
 														<th>Imagen</th>
 														<th>Producto</th>
-														<% if current_user.usertype == "A" %>
+														<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 														<th>Precio compra</th>
 														<% end %>
 														<th>Precio venta</th>

+ 199 - 180
app/views/products/product_track.html.erb

@@ -1,205 +1,224 @@
-	<!-- BEGIN CONTAINER -->
-	<div class="page-container">
-		<!-- BEGIN CONTENT -->
-		<div class="page-content-wrapper">
-			<!-- BEGIN CONTENT BODY -->
-			<!-- BEGIN PAGE HEAD-->
-			<div class="page-head">
-				<div class="container-fluid">
-					<!-- BEGIN PAGE TITLE -->
-					<div class="page-title">
-						<h1>Seguimiento de productos </h1>
-					</div>
-					<!-- END PAGE TITLE -->
+<!-- BEGIN CONTAINER -->
+<div class="page-container">
+	<!-- BEGIN CONTENT -->
+	<div class="page-content-wrapper">
+		<!-- BEGIN CONTENT BODY -->
+		<!-- BEGIN PAGE HEAD-->
+		<div class="page-head">
+			<div class="container-fluid">
+				<!-- BEGIN PAGE TITLE -->
+				<div class="page-title">
+					<h1>Seguimiento de productos </h1>
 				</div>
+				<!-- END PAGE TITLE -->
 			</div>
-			<!-- END PAGE HEAD-->
-			<!-- BEGIN PAGE CONTENT BODY -->
-			<div class="page-content">
-				<div class="container-fluid">
-					<!-- BEGIN PAGE BREADCRUMBS -->
-					<ul class="page-breadcrumb breadcrumb">
-						<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
-					</ul>
-					<!-- END PAGE BREADCRUMBS -->
-					<div class="search-page search-content-3">
-						<div class="row">
-							<div class="col-md-12">
-								<div class="search-filter bordered">
-								<!-- <h4 class=" uppercase form-section"> Búsqueda de producto </h4> <hr> -->
-									<div class="form-group">
-										<div class="row">
-											<div class="col-md-6">
-												<div class="search-label uppercase"> Del </div>
-												<div class="col-md-6">
-													<!-- <div class='input-group date' id='begin_date'> -->
-													<div class="input-group input-medium date date-picker" data-date-format="dd/mm/yyyy">
-														<input id="start" type='text' class="form-control"/>
-														<span class="input-group-addon">
-															<span class="glyphicon glyphicon-calendar"></span>
-														</span>
-													</div>
-												</div>
-											</div>
-											<div class="col-md-6">
-												<div class="search-label uppercase"> Al </div>
-												<div class="col-md-6">
-													<!-- <div class='input-group date' id='end_date'> -->
-													<div class="input-group input-medium date date-picker" data-date-format="dd/mm/yyyy">
-														<input id="end" type='text' class="form-control"/>
-														<span class="input-group-addon">
-															<span class="glyphicon glyphicon-calendar"></span>
-														</span>
-													</div>
-												</div>
-											</div>
-										</div>
-									</div>
-									<div class=" form-group">
-										<div class="row">
-											<div class="col-md-6">
-												<div class="search-label uppercase">Producto <span class="required">*</span></div>
-												<div class="col-md-12">
+		</div>
+		<!-- END PAGE HEAD-->
+		<!-- BEGIN PAGE CONTENT BODY -->
+		<div class="page-content">
+			<div class="container-fluid">
+				<!-- BEGIN PAGE BREADCRUMBS -->
+				<ul class="page-breadcrumb breadcrumb">
+					<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
+				</ul>
+
+				<div class="page-content-inner">
+					<div class="row ">
+						<div class="portlet light">
+							<div class="portlet-title">
+								<div class="caption">
+									<i class="fa fa-location-arrow font-blue-dark"></i>
+									<span class="caption-subject font-blue-dark bold uppercase">Seguimiento de productos</span>
+								</div>
+							</div>
+							<div class="portlet-body form" id="tracking">
+								<div class="form-horizontal">
+									<div class="row">
+										<div class="form-group">
+										  <div class="col-md-6 col-sm-12">
+										  	<%= label_tag :begin_date, "Fecha", { class: "col-md-2 col-sm-1 control-label" } do %> Desde <% end %>
+											  <div class="col-sm-2 col-md-4" style="padding-left:0px;padding-right:0px;">
+											    <div class='input-group date' id='begin_date'>
+											      <input id="start" type='text' class="form-control" value="<%= l(Date.today.beginning_of_month, format: '%d/%m/%Y') %>" />
+											      <span class="input-group-addon">
+											        <span class="glyphicon glyphicon-calendar"></span>
+											      </span>
+											    </div>
+											  </div>
+											  <%= label_tag :end_date, "Fecha", { class: "col-md-2 col-sm-1 control-label" } do %> Hasta <% end %>
+											  <div class="col-sm-2 col-md-4" style="padding-left:0px;padding-right:0px;">
+											    <div class='input-group date' id='end_date'>
+											      <input id="end" type='text' class="form-control" value="<%= l(Date.today.end_of_month, format: '%d/%m/%Y') %>" />
+											      <span class="input-group-addon">
+											        <span class="glyphicon glyphicon-calendar"></span>
+											      </span>
+											    </div>
+											  </div>
+										  </div>
+										</div><!--   -->
+										<div class="form-group">
+											<div class="col-md-5 col-sm-5">
+										  	<label class="col-md-3 col-sm-3 control-label" for="typeahead"> Producto <span class="required">*</span> </label>
+												<div class="col-md-9 col-sm-9">
 													<input class="form-control" type="text" id="typeahead">
-													<%= hidden_field_tag :product_id %>
-												</div>
-											</div>
-											<div class="col-md-6">
-												<div class="search-label uppercase">Punto de venta</div>
-												<div class="col-md-12">
-													<%= select_tag "pointsale", options_from_collection_for_select(Pointsale.vigentes, :id, :name), :include_blank => "Todas",  class: "form-control  input-medium" %>
 												</div>
+										  </div>
+											<div class="col-md-6 col-sm-6">
+												<%= label_tag :pointsale, "Punto de venta", class: "control-label col-md-3 col-sm-3" %>
+												<div class="col-md-6 col-sm-7">
+										      <%= select_tag "pointsale", options_from_collection_for_select(Pointsale.vigentes, :id, :name), include_blank: "Todos",  class: "form-control input-medium" %>
+										    </div>
+										    <button class="btn btn-icon-only blue" onclick="findSalesByPeriod()">
+	                        <i class="fa fa-search"></i>
+	                      </button>
 											</div>
 										</div>
 									</div>
-									<div class="search-filter-divider bg-grey-steel"></div>
-									<button class="btn green bold uppercase btn-block" onclick="findSalesByPeriod()">Buscar <i class="m-icon-swapright m-icon-white"></i> </button>
-								</div>
-							</div>
-						</div>
-					</div>
-					<!-- BEGIN PAGE CONTENT INNER -->
-					<div class="page-content-inner">
-						<div class="row ">
-							<div class="portlet light">
-								<div class="portlet-title">
-									<div class="caption">
-										<i class="fa fa-location-arrow font-blue-dark"></i>
-										<span class="caption-subject font-blue-dark bold uppercase">Seguimiento de productos</span>
-									</div>
 								</div>
-								<div class="portlet-body form" id="tracking">
-
-									<div class="product_track_search" id='track_detail'>
-										<%= render "products_track_dtl" %>
+								<div class="product_track_search">
+									<div class="row">
+									  <div class="col-md-12">
+									    <div class="tabbable-custom">
+									      <ul class="nav nav-tabs">
+									        <li class="active">
+									          <a href="#sales_tab" data-toggle="tab" aria-expanded="false">Ventas</a>
+									        </li>
+									        <li>
+									          <a href="#purchases_tab" data-toggle="tab" aria-expanded="false">Compras</a>
+									        </li>
+									      </ul>
+									      <div class="tab-content">
+									        <div class="tab-pane active" id="sales_tab">
+									          <div class="product_track_search" id='track_detail'>
+									            <!-- < %= render "products_track_dtl" %> -->
+									          </div>
+									        </div>
+									        <div class="tab-pane" id="purchases_tab">
+									          <div class="product_track_purchases_search" id='track_detail_purchases'>
+									            <!-- < %= render "products_track_purchases_dtl" %> -->
+									          </div>
+									        </div>
+									      </div>
+									    </div>
+									  </div>
 									</div>
-
 								</div>
 							</div>
 						</div>
 					</div>
-					<!-- END PAGE CONTENT INNER -->
 				</div>
+				<!-- END PAGE CONTENT INNER -->
 			</div>
-			<!-- END PAGE CONTENT BODY -->
-			<!-- END CONTENT BODY -->
 		</div>
-		<!-- END CONTENT -->
+		<!-- END PAGE CONTENT BODY -->
+		<!-- END CONTENT BODY -->
 	</div>
-	<!-- END CONTAINER -->
-	<script type="text/javascript">
-		var rows_selected = [];
-		var selectedProduct = null;
-		var timeout = null;
-		//para no avanzar cuando la cantidad a regresar sea mayor
-		var shouldProcess = false;
-		var sale_id = null;
+	<!-- END CONTENT -->
+</div>
+<!-- END CONTAINER -->
+<script type="text/javascript">
+	$(document).on("page:change", function() {
+    App.init();
+     $('#start').datetimepicker({
+      icons: {
+        date: "fa fa-calendar"
+      },
+      format: "DD/MM/YYYY"
+    });
 
-		var bloodhound = new Bloodhound({
-			datumTokenizer: function (d) {
-				return Bloodhound.tokenizers.whitespace(d.value);
-			},
-			queryTokenizer: Bloodhound.tokenizers.whitespace,
-			remote: {
-				url: '/find_products?query=%QUERY',
-				wildcard: '%QUERY'
-			}
-		});
-		bloodhound.initialize();
+    $('#end').datetimepicker({
+      icons: {
+        date: "fa fa-calendar"
+      },
+      format: "DD/MM/YYYY"
+    });
+  });
 
-		$('#typeahead').typeahead(
-			{
-				minLength: 3
-			},
-			{
-				displayKey: 'name',
-				source: bloodhound.ttAdapter(),
-				limit: Infinity,
-				templates: {
-					empty: [
-						'<div class="empty-message">',
-							'No se encontró ningun producto. Favor de verificar',
-						'</div>'
-					].join('\n'),
-					 suggestion: Handlebars.compile(
-							'<div class="media">' +
-								'<div class="pull-left">' +
-									'<div class="media-object">' +
-										'<img src="{{small_img}}" width="50" height="50"/>' +
-									'</div>' +
-								'</div>' +
-								'<div class="media-body">' +
-									'<h4 class="media-heading"><strong>{{sku}}</strong> | {{name}}</h4>' +
-									'<p>{{barcode}}</p>' +
-									'<p>{{description}}</p>' +
-									'<p>{{display_attributes}}</p>' +
-								'</div>' +
-							'</div>')
-				}
-		});
+	var rows_selected = [];
+	var selectedProduct = null;
+	var timeout = null;
+	//para no avanzar cuando la cantidad a regresar sea mayor
+	var shouldProcess = false;
+	var sale_id = null;
 
-		$('#typeahead').bind('typeahead:selected', function(event, datum, name) {
-			selectedProduct = datum;
-			$('#btn_search_by_period').attr('disabled', false);
-		});
-		//buscar ventas por periodo de tiempo
-		function findSalesByPeriod() {
-			var product = selectedProduct ? selectedProduct.id : '';
-			var pointsale = $('#pointsale').val();
-			// var start = $("#start").val();
-   //  		var end = $("#end").val();
+	var bloodhound = new Bloodhound({
+		datumTokenizer: function (d) {
+			return Bloodhound.tokenizers.whitespace(d.value);
+		},
+		queryTokenizer: Bloodhound.tokenizers.whitespace,
+		remote: {
+			url: '/find_products?query=%QUERY',
+			wildcard: '%QUERY'
+		}
+	});
+	bloodhound.initialize();
 
-    		var start = moment($("#start").val(), "DD-MM-YYYY").format('YYYY-MM-DD');
-    		var end = moment($("#end").val(), "DD-MM-YYYY").format('YYYY-MM-DD');
-    		$('#product_id').val(product);
+	$('#typeahead').typeahead(
+		{
+			minLength: 3
+		},
+		{
+			displayKey: 'name',
+			source: bloodhound.ttAdapter(),
+			limit: Infinity,
+			templates: {
+				empty: [
+					'<div class="empty-message">',
+						'No se encontró ningun producto. Favor de verificar',
+					'</div>'
+				].join('\n'),
+				 suggestion: Handlebars.compile(
+						'<div class="media">' +
+							'<div class="pull-left">' +
+								'<div class="media-object">' +
+									'<img src="{{small_img}}" width="50" height="50"/>' +
+								'</div>' +
+							'</div>' +
+							'<div class="media-body">' +
+								'<h4 class="media-heading"><strong>{{sku}}</strong> | {{name}}</h4>' +
+								'<p>{{barcode}}</p>' +
+								'<p>{{description}}</p>' +
+								'<p>{{display_attributes}}</p>' +
+							'</div>' +
+						'</div>')
+			}
+	});
+
+	$('#typeahead').bind('typeahead:selected', function(event, datum, name) {
+		selectedProduct = datum;
+		$('#btn_search_by_period').attr('disabled', false);
+	});
 
-			if ($("#start").val() && $("#end").val()) {
-				if (product) {
-					App.blockUI({
-						target: $("#track_detail"),
-						animate: true
-					});
+	//buscar ventas por periodo de tiempo
+	function findSalesByPeriod() {
+		var product = selectedProduct ? selectedProduct.id : '';
+		var pointsale = $('#pointsale').val();
+		var start = moment($("#start").data("date"), "DD-MM-YYYY").startOf('day').format('YYYY-MM-DD HH:mm:ss');
+    var end = moment($("#end").data("date"), "DD-MM-YYYY").add(23, 'hours').add(59, 'minutes').add(59, 'seconds').format('YYYY-MM-DD HH:mm:ss');
+		$('#product_id').val(product);
 
-					$.ajax({
-						type: "get",
-						url:  '/product_track/',
-						data: {
-							start_date: start,
-	          				end_date: end,
-							product_id: product,
-							pointsale_id: pointsale
-						},
-						dataType: 'script',
-						success: function(data) {
-							App.unblockUI($("#track_detail"));
-						}
-					});
-				} else {
-					toastr["error"]("Es necesario indicar un producto.");
-				}
-			}else{
-				toastr["error"]("Es necesario indicar fechas.");
+		if ($("#start").val() && $("#end").val()) {
+			if (product) {
+				$.ajax({
+					type: "get",
+					url: '/product_track/',
+					data: {
+						start_date: start,
+    				end_date: end,
+						product_id: product,
+						pointsale_id: pointsale
+					},
+					dataType: 'script',
+					success: function(data) {
+						App.unblockUI($("#track_detail"));
+						App.unblockUI($("#track_detail_purchases"));
+					}
+				});
+			} else {
+				toastr["error"]("Es necesario indicar un producto.");
 			}
+		} else {
+			toastr["error"]("Es necesario indicar fechas.");
 		}
-
-	</script>
+	}
+</script>

+ 3 - 10
app/views/products/product_track.js.erb

@@ -1,10 +1,3 @@
-
-// var table = $('#track_detail').DataTable();
-// $('#track_detail').dataTable().fnClearTable();
-// <% @sales.each_with_index do |sale, key| %>
-// 	var row = $('<%= j render partial: "products_track_dtl", locals: {sale: sale} %>');
-// 	table.row.add(row).draw();
-// <% end %>
-
-$('.product_track_search').html('<%= j render "products_track_dtl" %>');
-TableAdvanced.init();
+$('#track_detail').html('<%= j render "products_track_dtl" %>');
+$('#track_detail_purchases').html('<%= j render "products_track_purchases_dtl" %>');
+TableAdvanced.init();

+ 24 - 61
app/views/products/show.html.erb

@@ -22,7 +22,7 @@
 							<i class="fa fa-angle-left "></i>
 							Regresar
 						<% end %>
-						<% if @current_user.usertype == 'A' %>
+						<% if @current_user.usertype == "A" || @current_user.usertype == "SS" %>
 							<%= link_to  edit_product_path(@product), {:class=>"btn btn-primary "} do %>
 								<i class="fa fa-edit"></i> Modificar
 							<% end %>
@@ -58,25 +58,6 @@
 												<!-- <button type="button" class="btn btn-circle green btn-sm">Follow</button>
 												<button type="button" class="btn btn-circle red btn-sm">Message</button>-->
 										</div>
-										<!-- END SIDEBAR BUTTONS -->
-										<!-- SIDEBAR MENU -->
-										<!-- <div class="profile-usermenu">
-												<ul class="nav">
-														<li class="active">
-																<a href="page_user_profile_1.html">
-																		<i class="icon-home"></i> Overview </a>
-														</li>
-														<li>
-																<a href="page_user_profile_1_account.html">
-																		<i class="icon-settings"></i> Account Settings </a>
-														</li>
-														<li>
-																<a href="page_user_profile_1_help.html">
-																		<i class="icon-info"></i> Help </a>
-														</li>
-												</ul>
-										</div> -->
-										<!-- END MENU -->
 									</div>
 									<!-- END PORTLET MAIN -->
 
@@ -143,13 +124,13 @@
 													<div class="row static-info">
 														<div class="col-md-4 name"> Categorías: </div>
 														<div class="col-md-8 value">
-															<%  @product.categories.each_with_index do | cat, index | %>
+															<%  @product.categories.each_with_index do |cat, index| %>
 																<% if index > 0 %>  <br> <% end %>
 																<span class="badge badge-default badge-roundless" > <%= cat.category %> </span>
 															<% end %>
 														</div>
 													</div>
-													<% if current_user.usertype == "A" %>
+													<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 													<div class="row static-info">
 														<div class="col-md-4 name"> Precio compra: </div>
 														<div class="col-md-8 value"><%= (@product.is_in_dollars? ? "#{number_to_currency(@product.price_base_dollars, precision: 2)} USD" : "#{number_to_currency(@product.price_base, precision: 2)} MXN") %> </div>
@@ -175,7 +156,7 @@
 											</div>
 										</div>
 									</div>
-									<% if current_user.usertype == "A" %>
+									<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 									<div class="row">
 										<div class="col-md-6">
 											<!-- BEGIN PORTLET -->
@@ -189,48 +170,30 @@
 												</div>
 												<div class="portlet-body">
 													<table class="table table-hover table-light">
-                                                    <thead>
-                                                        <tr class="uppercase">
-                                                            <th> punto de<br>venta </th>
-                                                            <th> existencia<br>de producto </th>
-                                                            <th> Ultima<br>venta </th>
-
-                                                        </tr>
-                                                    </thead>
-                                                    <tbody>
-                                                    	<% @product.pointsales.each_with_index do |pointsale, key|  %>
-                                                    	<tr>
-	                                                        <td>
-	                                                        	<%= pointsale.name %>
-	                                                        </td>
-	                                                        <td class="text-center">
-	                                                        	<%= @product.stock_in_pointsale(pointsale.id).round %>
-	                                                        </td>
-	                                                        <td>
-	                                                        	<% last_sale =  @product.last_sale(pointsale.id) %>
-	                                                        	<%= l(last_sale.created_at, :format => '%d/%m/%Y') unless last_sale.blank? %>
-	                                                        </td>
-	                                                    </tr>
-	                                                    <% end %>
-                                                    </tbody>
-                                                	</table>
+                            <thead>
+                              <tr class="uppercase">
+                                <th> punto de<br>venta </th>
+                                <th> existencia<br>de producto </th>
+                                <th> Ultima<br>venta </th>
+                              </tr>
+                            </thead>
+                            <tbody>
+	                          	<% @product.pointsales.each_with_index do |pointsale, key| %>
+                              	<tr>
+      	                          <td> <%= pointsale.name %> </td>
+                                  <td class="text-center"> <%= @product.stock_in_pointsale(pointsale.id).round %> </td>
+                                  <td>
+                                  	<% last_sale = @product.last_sale(pointsale.id) %>
+                                  	<%= l(last_sale.created_at, :format => '%d/%m/%Y') unless last_sale.blank? %>
+                                  </td>
+                                </tr>
+                              <% end %>
+                            </tbody>
+                        	</table>
 												</div>
 											</div>
 										</div>
 										<div class="col-md-6">
-											<!-- BEGIN PORTLET -->
-											<!-- <div class="portlet light ">
-												<div class="portlet-title">
-													<div class="caption caption-md">
-														<i class="fa fa-bar-chart theme-font hide"></i>
-														<span class="caption-subject font-green bold uppercase">Ventas del mes</span>
-														<span class="caption-helper hide"></span>
-													</div>
-												</div>
-												<div class="portlet-body">
-
-												</div>
-											</div> -->
 										</div>
 
 									</div>

+ 1 - 2
app/views/products_returns/_form.html.erb

@@ -128,7 +128,7 @@
                       <tr>
                         <th>#</th>
                         <th>Folio</th>
-                        <% if current_user.usertype == 'A' %>
+                        <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
                           <th>Pto. de venta</th>
                         <% end %>
                         <th>Cliente</th>
@@ -198,7 +198,6 @@
             </div>
             <div class="tab-pane" id="tab4">
               <h3 class="block">Finalizar devolución</h3>
-
               <div class="col-md-12 margin-top-10">
                 <table class="pull-right">
                   <thead>

+ 2 - 2
app/views/products_returns/index.html.erb

@@ -58,7 +58,7 @@
                     <thead>
                       <tr>
                         <th>Folio</th>
-                        <% if current_user.usertype == "A" %>
+                        <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
                           <th>Punto de venta</th>
                         <% end %>
                         <th>Fecha</th>
@@ -75,7 +75,7 @@
                     <% @products_returns.each_with_index do |product_return, key| %>
                         <tr>
                           <td> <%= product_return.return_code %></td>
-                          <% if current_user.usertype == "A" %>
+                          <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
                             <td><%= product_return.pointsale.name %></td>
                           <% end %>
                           <td><%= l(product_return.created_at, :format => '%d/%m/%Y') %></td>

+ 379 - 383
app/views/purchases/_form.html.erb

@@ -1,30 +1,30 @@
-<%= form_for(@purchase, :html => {:class=>"form-horizontal", :id=> "purchase_form"}) do |f| %>
+<%= form_for(@purchase, html: { class: "form-horizontal", id: "purchase_form" }) do |f| %>
 	<div class="portlet-body form">
 	<%= hidden_field_tag :tax_percent, @pos_config.tax_percent %>
 	<div id="error_explanation"></div>
 		<!-- purchase code -->
 		<div class="form-group">
-			<%= f.label :purchase_code, {:class=>"col-md-2 control-label"} do %> Codigo de compra
+			<%= f.label :purchase_code, { class: "col-md-2 control-label" } do %> Código de compra
 			<span class="required">*</span>
 			<% end %>
 			<div class="col-md-3 input-group">
 				<span class="input-group-addon"><i class="fa fa-barcode"></i></span>
-				<%= f.text_field :purchase_code, {:class=>"form-control", :readonly => true} %>
+				<%= f.text_field :purchase_code, { class: "form-control", readonly: true } %>
 			</div>
 		</div>
 		<!-- fecha -->
 		<div class="form-group">
-			<%= f.label :purchase_date, {:class=>"col-md-2 control-label"} do %> Fecha
+			<%= f.label :purchase_date, { class: "col-md-2 control-label" } do %> Fecha
 			<span class="required">*</span>
 			<% end %>
 			<div class="col-md-3 input-group date date-picker">
 				<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
-				<%= f.date_field :purchase_date, {:value=>Date.today, :class=>"form-control", :readonly => true} %>
+				<%= f.date_field :purchase_date, { value: Date.today, class: "form-control", readonly: true } %>
 			</div>
 		</div>
 		<!-- tipo de destino -->
 		<div class="form-group">
-			<%= label_tag 'destiny', {:class=>"col-md-2 control-label"} do %> Destino del producto
+			<%= label_tag 'destiny', { class: "col-md-2 control-label" } do %> Destino del producto
 			<span class="required">*</span>
 			<% end %>
 			<div class="col-md-3" style="padding-left:0px;padding-right:0px">
@@ -42,40 +42,40 @@
 			</div>
 		</div>
 		<!-- punto de venta -->
-		<div class= "form-group <%=(@destiny == 'pointsale' ? '' : 'hidden')%>"  id='pointsale_div'>
-			<%= f.label :pointsale_id, "Punto de venta", {:class=>"col-md-2 control-label"} do %> Punto de venta
+		<div class= "form-group <%=(@destiny == 'pointsale' ? '' : 'hidden')%>" id='pointsale_div'>
+			<%= f.label :pointsale_id, "Punto de venta", { class: "col-md-2 control-label" } do %> Punto de venta
 			<span class="required">*</span>
 			<% end %>
 			<div class="input-group col-md-3 select2-bootstrap-prepend">
-				<%= f.collection_select :pointsale_id, Pointsale.activos, :id, :name, {:prompt => "Seleccione"}, {:class => "form-control select2", :disabled => @disable_pointsale} %>
-				<%= f.hidden_field :pointsale_id, {:id => 'pointsale'} %>
+				<%= f.collection_select :pointsale_id, Pointsale.activos, :id, :name, { prompt: "Seleccione" }, { class: "form-control select2", disabled: @disable_pointsale } %>
+				<%= f.hidden_field :pointsale_id, { id: 'pointsale' } %>
 			</div>
 		</div>
 		<!-- almacen -->
-		<div class= "form-group <%=(@destiny == 'warehouse' ? '' : 'hidden')%>"  id='warehouse_div'>
-			<%= f.label :warehouse_id, "Almacén", {:class=>"col-md-2 control-label"} do %> Almacén
+		<div class= "form-group <%=(@destiny == 'warehouse' ? '' : 'hidden')%>" id='warehouse_div'>
+			<%= f.label :warehouse_id, "Almacén", { class: "col-md-2 control-label" } do %> Almacén
 			<span class="required">*</span>
 			<% end %>
 			<div class="input-group col-md-3 select2-bootstrap-prepend">
-				<%= f.collection_select :warehouse_id, Warehouse.activos, :id, :name, {:prompt => "Seleccione"}, {:class => "form-control select2", :disabled => @disable_warehouse} %>
-				<%= f.hidden_field :warehouse_id, {:id => 'warehouse'} %>
+				<%= f.collection_select :warehouse_id, Warehouse.activos, :id, :name, { prompt: "Seleccione" }, { class: "form-control select2", disabled: @disable_warehouse } %>
+				<%= f.hidden_field :warehouse_id, { id: 'warehouse' } %>
 			</div>
 		</div>
 		<!-- proveedor -->
 		<div class="form-group">
-			<%= f.label :supplier_id, "Proveedor", {:class=>"col-md-2 control-label"} do %> Proveedor
+			<%= f.label :supplier_id, "Proveedor", { class: "col-md-2 control-label" } do %> Proveedor
 			<span class="required">*</span>
 			<% end %>
 			<div class="input-group col-md-3 select2-bootstrap-prepend">
-				<%= f.collection_select :supplier_id, Supplier.activos, :id, :nick_name, {:prompt => "Seleccione"}, {:class => "form-control select2", :disabled => @disable_supplier} %>
-				<%= f.hidden_field :supplier_id, {:id => 'supplier'} %>
+				<%= f.collection_select :supplier_id, Supplier.activos, :id, :nick_name, { prompt: "Seleccione" }, { class: "form-control select2", disabled: @disable_supplier } %>
+				<%= f.hidden_field :supplier_id, { id: 'supplier' } %>
 			</div>
 		</div>
 		<div class="form-group">
-			<%= f.label :is_in_dollars, {:class=>"col-md-2 control-label"} do %> tipo de Moneda
+			<%= f.label :is_in_dollars, { class: "col-md-2 control-label" } do %> Tipo de Moneda
 				<span class="required">*</span>
 			<% end %>
-			<div class="col-md-3"  style="padding-left:0px;padding-right:0px">
+			<div class="col-md-3" style="padding-left:0px;padding-right:0px">
 				<%= f.check_box(:is_in_dollars,
 					{
 						class: "make-switch",
@@ -90,15 +90,15 @@
 					"true", "false"
 				) %>
 			</div>
-			<%= f.hidden_field :is_in_dollars, {:id => 'is_in_dollars'} %>
+			<%= f.hidden_field :is_in_dollars, { id: 'is_in_dollars' } %>
 		</div>
 		<div class="form-group hidden" id="exchange_div">
-			<%= f.label :exchange, {:class=>"col-md-2 control-label"} do %> Tipo de cambio
+			<%= f.label :exchange, { class: "col-md-2 control-label" } do %> Tipo de cambio
 			<span class="required">*</span>
 			<% end %>
 			<div class="col-md-3 input-group">
 				<span class="input-group-addon"><i class="fa fa-usd"></i></span>
-				<%= f.number_field :exchange, {:class=>"form-control", :step=>"any"} %>
+				<%= f.number_field :exchange, { class: "form-control", step: "any" } %>
 			</div>
 		</div>
 		<!-- boton para resetear datos -->
@@ -121,7 +121,7 @@
 					</div>
 				</div>
 				<div class="col-md-2">
-					<button id="products_add_new" class="btn btn-success" type="button" onclick="addNewProduct()">  <i class="fa fa-plus"></i> Nuevo Producto </button>
+					<button id="products_add_new" class="btn btn-success" type="button" onclick="addNewProduct()"> <i class="fa fa-plus"></i> Nuevo Producto </button>
 				</div>
 			</div>
 		</div>
@@ -143,7 +143,7 @@
 					</tr>
 				</thead>
 				<tbody>
-				<%= render @pre_purchases %>
+					<%= render @pre_purchases %>
 				</tbody>
 			</table>
 		</div>
@@ -152,67 +152,67 @@
 		<div class="row">
 			<div class="col-md-6">
 				<div class="form-group">
-					 <%= f.label :observations, "Observaciones", {:class=>"col-md-3 control-label"} %>
+					 <%= f.label :observations, "Observaciones", { class: "col-md-3 control-label" } %>
 					 <div class="col-md-8">
-						 <%= f.text_area :observations, {:class=>"form-control", :rows=>5} %>
+						 <%= f.text_area :observations, { class: "form-control", rows: 5 } %>
 					 </div>
 				 </div>
 			 </div>
 			<div class="col-md-offset-1 col-md-5">
-					<div class="well">
-							<div class="row static-info align-reverse">
-									<div class="col-md-4 name"> Sub Total: </div>
-									<div class="col-md-8 value " id="amount_div">
-											<div class="input-group">
-												<span class="input-group-addon">$ </span>
-												<%= f.text_field :amount, {:class=>"form-control sub_total", :readonly => true, :id => "amount"}  %>
-												<span class="input-group-addon"></span>
-											</div>
-									</div>
+				<div class="well">
+					<div class="row static-info align-reverse">
+						<div class="col-md-4 name"> Sub Total: </div>
+						<div class="col-md-8 value " id="amount_div">
+							<div class="input-group">
+								<span class="input-group-addon">$ </span>
+								<%= f.text_field :amount, { class: "form-control sub_total", readonly: true, id: "amount" } %>
+								<span class="input-group-addon"></span>
 							</div>
-							<div class="row static-info align-reverse">
-									<div class="col-md-4 name"> IVA: </div>
-									<div class="col-md-8 value " id="tax_div">
-											<div class="input-group">
-												<span class="input-group-addon">$ </span>
-												<%= f.text_field :tax, {:class=>"form-control descto", :readonly => true, :id => "tax"}  %>
-												<span class="input-group-addon"></span>
-											</div>
-									</div>
+						</div>
+					</div>
+					<div class="row static-info align-reverse">
+						<div class="col-md-4 name"> IVA: </div>
+						<div class="col-md-8 value " id="tax_div">
+							<div class="input-group">
+								<span class="input-group-addon">$ </span>
+								<%= f.text_field :tax, { class: "form-control descto", readonly: true, id: "tax" } %>
+								<span class="input-group-addon"></span>
 							</div>
-							<div class="row static-info align-reverse">
-									<div class="col-md-4 name"> Total: </div>
-									<div class="col-md-8 value " id="total_div">
-											<div class="input-group">
-												<span class="input-group-addon">$ </span>
-												<%= f.text_field :total, {:class=>"form-control descto", :readonly => true, :id => "total"}  %>
-												<span class="input-group-addon"></span>
-											</div>
-									</div>
+						</div>
+					</div>
+					<div class="row static-info align-reverse">
+						<div class="col-md-4 name"> Total: </div>
+						<div class="col-md-8 value " id="total_div">
+							<div class="input-group">
+								<span class="input-group-addon">$ </span>
+								<%= f.text_field :total, { class: "form-control descto", readonly: true, id: "total" } %>
+								<span class="input-group-addon"></span>
 							</div>
+						</div>
 					</div>
+				</div>
 			</div>
 			<div class="col-md-offset-7 col-md-5 hidden" id="total_in_mxn_div">
-					<div class="well">
-						<div class="row static-info align-reverse">
-								<div class="col-md-4 name"> Total en pesos: </div>
-								<div class="col-md-8 value ">
-										<div class="input-group">
-											<span class="input-group-addon">$ </span>
-												<%= text_field_tag :total_in_mxn, '' , :class=>"form-control", :readonly => true %>
-											<span class="input-group-addon">MXN</span>
-										</div>
-								</div>
+				<div class="well">
+					<div class="row static-info align-reverse">
+						<div class="col-md-4 name"> Total en pesos: </div>
+						<div class="col-md-8 value ">
+							<div class="input-group">
+								<span class="input-group-addon">$ </span>
+								<%= text_field_tag :total_in_mxn, '' , class: "form-control", readonly: true %>
+								<span class="input-group-addon">MXN</span>
+							</div>
 						</div>
 					</div>
+				</div>
 			</div>
 		</div>
 		<!-- acciones del form -->
 		<div class="form-actions">
 			<div class="row">
 				<div class="col-md-offset-2 col-md-9">
-					<%= f.submit 'Guardar', {:class=>"btn green"} %>
-					<%= link_to 'Cancelar', purchases_path(:filter => @filter, :current_page => @current_page), {:class=>"btn default"} %>
+					<%= f.submit 'Guardar', { class: "btn green" } %>
+					<%= link_to 'Cancelar', purchases_path(filter: @filter, current_page: @current_page), { class: "btn default" } %>
 				</div>
 			</div>
 		</div>
@@ -272,354 +272,350 @@
 			generatePurchaseCode();
 		});
 
-	 });
-
-		$('body').barcodeListener().on('barcode.valid', function(e, code) {
-			findProductByBarcode(code);
-		});
-
-			var bloodhound = new Bloodhound({
-				datumTokenizer: function (d) {
-					return Bloodhound.tokenizers.whitespace(d.value);
-				},
-				queryTokenizer: Bloodhound.tokenizers.whitespace,
-				remote: {
-					url: '/find_products?query=%QUERY',
-					wildcard: '%QUERY'
-				}
-			});
-			bloodhound.initialize();
-
-		$('#typeahead').typeahead(
-			{
-				minLength: 3
-			},
-			{
-				displayKey: 'name',
-				source: bloodhound.ttAdapter(),
-				limit: Infinity,
-				templates: {
-					empty: [
-						'<div class="empty-message">',
-							'No se encontró ningun producto. Favor de verificar',
-						'</div>'
-					].join('\n'),
-					 suggestion: Handlebars.compile(
-							'<div class="media">' +
-								'<div class="pull-left">' +
-										'<div class="media-object">' +
-												'<img src="{{small_img}}" width="50" height="50"/>' +
-										'</div>' +
-								'</div>' +
-								'<div class="media-body">' +
-										'<h4 class="media-heading"><strong>{{sku}}</strong> | {{name}}</h4>' +
-										'<p>{{barcode}}</p>' +
-										'<p>{{description}}</p>' +
-										'<p>{{display_attributes}}</p>' +
-								'</div>' +
-							'</div>')
-				}
-		});
-
-		// this is the event that is fired when a user clicks on a suggestion
-		$('#typeahead').bind('typeahead:selected', function(event, datum, name) {
-			selectedProduct = datum;
+	});
 
-			var supplier = $('#purchase_supplier_id').val();
-			var pointsale = $('#purchase_pointsale_id').val();
-			var warehouse = $('#purchase_warehouse_id').val();
+	$('body').barcodeListener().on('barcode.valid', function(e, code) {
+		findProductByBarcode(code);
+	});
 
-			if( (supplier && pointsale) || (supplier && warehouse) ) {
-				$('#products_new').attr('disabled', false);
-			} else {
-				toastr["error"]("Se debe seleccionar proveedor y destino de la compra.");
+	var bloodhound = new Bloodhound({
+		datumTokenizer: function (d) {
+			return Bloodhound.tokenizers.whitespace(d.value);
+		},
+		queryTokenizer: Bloodhound.tokenizers.whitespace,
+		remote: {
+			url: '/find_products?query=%QUERY',
+			wildcard: '%QUERY'
+		}
+	});
+	bloodhound.initialize();
+
+	$('#typeahead').typeahead(
+		{
+			minLength: 3
+		},
+		{
+			displayKey: 'name',
+			source: bloodhound.ttAdapter(),
+			limit: Infinity,
+			templates: {
+				empty: [
+					'<div class="empty-message">',
+						'No se encontró ningun producto. Favor de verificar',
+					'</div>'
+				].join('\n'),
+				 suggestion: Handlebars.compile(
+						'<div class="media">' +
+							'<div class="pull-left">' +
+									'<div class="media-object">' +
+											'<img src="{{small_img}}" width="50" height="50"/>' +
+									'</div>' +
+							'</div>' +
+							'<div class="media-body">' +
+									'<h4 class="media-heading"><strong>{{sku}}</strong> | {{name}}</h4>' +
+									'<p>{{barcode}}</p>' +
+									'<p>{{description}}</p>' +
+									'<p>{{display_attributes}}</p>' +
+							'</div>' +
+						'</div>')
 			}
+	});
 
-		});
+	// this is the event that is fired when a user clicks on a suggestion
+	$('#typeahead').bind('typeahead:selected', function(event, datum, name) {
+		selectedProduct = datum;
 
-		function addNewProduct() {
-			var pointsale = $('#purchase_pointsale_id').val();
-			var supplier = $('#purchase_supplier_id').val();
-			var warehouse = $('#purchase_warehouse_id').val();
-			var exchange = $('#purchase_exchange').val();
-			if( (supplier && pointsale) || (supplier && warehouse) ) {
-				$.ajax({
-					type: "GET",
-					url: "/products/new",
-					dataType: "script",
-					data: {
-						remoto: true,
-						pointsale: pointsale,
-						warehouse: warehouse,
-						supplier: supplier,
-						exchange: exchange
-					},
-					success: function(xhr, status, error) {}
-				});
-			} else {
-				toastr["error"]("Se debe seleccionar proveedor y destino de la compra.");
-			}
-		}
+		var supplier = $('#purchase_supplier_id').val();
+		var pointsale = $('#purchase_pointsale_id').val();
+		var warehouse = $('#purchase_warehouse_id').val();
 
-		function addRow() {
-			if(selectedProduct) {
-				$('#pre_purchase_supplier_id').val($('#supplier').val());
-				$('#pre_purchase_pointsale_id').val($('#pointsale').val());
-				$('#pre_purchase_warehouse_id').val($('#warehouse').val());
-				$('#pre_purchase_exchange').val($('#purchase_exchange').val());
-				$('#pre_purchase_price_base').val();
-				$('#pre_purchase_product_id').val(selectedProduct.id);
-				$('#pre_purchase_quantity').val(1);
-				$('#pre_purchase_amount').val(selectedProduct.price_sale);
-				$('#pre_purchase_tax').val(0);
-				$('#pre_purchase_total').val(0);
-
-				$('#new_pre_purchase').submit();
-				$('#typeahead').typeahead('val','');
-				$('#products_new').attr('disabled', true);
-			}
+		if( (supplier && pointsale) || (supplier && warehouse) ) {
+			$('#products_new').attr('disabled', false);
+		} else {
+			toastr["error"]("Se debe seleccionar proveedor y destino de la compra.");
 		}
-
-		function deleteRow(input) {
-			var table = $('#products_table').DataTable();
-			var idText = input.closest('tr').attr('id');
-			var prePurchaseId = idText.substring(idText.lastIndexOf('_') + 1, idText.length);
+	});
+
+	function addNewProduct() {
+		var pointsale = $('#purchase_pointsale_id').val();
+		var supplier = $('#purchase_supplier_id').val();
+		var warehouse = $('#purchase_warehouse_id').val();
+		var exchange = $('#purchase_exchange').val();
+		if( (supplier && pointsale) || (supplier && warehouse) ) {
 			$.ajax({
-				type: "DELETE",
-				url: "/pre_purchases/" + prePurchaseId,
-				dataType: "json",
-				data: "",
-				success: function(xhr, status, error) {
-					table.row(input.closest('tr')).remove().draw();
-					calculateTotals();
-				}
+				type: "GET",
+				url: "/products/new",
+				dataType: "script",
+				data: {
+					remoto: true,
+					pointsale: pointsale,
+					warehouse: warehouse,
+					supplier: supplier,
+					exchange: exchange
+				},
+				success: function(xhr, status, error) {}
 			});
+		} else {
+			toastr["error"]("Se debe seleccionar proveedor y destino de la compra.");
 		}
+	}
+
+	function addRow() {
+		if(selectedProduct) {
+			$('#pre_purchase_supplier_id').val($('#supplier').val());
+			$('#pre_purchase_pointsale_id').val($('#pointsale').val());
+			$('#pre_purchase_warehouse_id').val($('#warehouse').val());
+			$('#pre_purchase_exchange').val($('#purchase_exchange').val());
+			$('#pre_purchase_price_base').val();
+			$('#pre_purchase_product_id').val(selectedProduct.id);
+			$('#pre_purchase_quantity').val(1);
+			$('#pre_purchase_amount').val(selectedProduct.price_sale);
+			$('#pre_purchase_tax').val(0);
+			$('#pre_purchase_total').val(0);
+
+			$('#new_pre_purchase').submit();
+			$('#typeahead').typeahead('val','');
+			$('#products_new').attr('disabled', true);
+		}
+	}
+
+	function deleteRow(input) {
+		var table = $('#products_table').DataTable();
+		var idText = input.closest('tr').attr('id');
+		var prePurchaseId = idText.substring(idText.lastIndexOf('_') + 1, idText.length);
+		$.ajax({
+			type: "DELETE",
+			url: "/pre_purchases/" + prePurchaseId,
+			dataType: "json",
+			data: "",
+			success: function(xhr, status, error) {
+				table.row(input.closest('tr')).remove().draw();
+				calculateTotals();
+			}
+		});
+	}
+
+	function updateQuantity(input) {
+		if(input.val()) {
+			clearTimeout(timeout);
+			timeout = setTimeout(function () {
+				tax = 0;
+				quantity = parseInt(input.val());
+				// sacar el precio del producto
+				if (input.closest('tr').find('td:eq(5) input').val()) {
+					price = parseFloat(input.closest('tr').find('td:eq(5) input').val());
+				} else {
+					price = 0;
+				}
+				amount = price * quantity;
+				if(input.closest('tr').find('td:eq(0) input').val() == '1') {
+					taxPercent = parseFloat($('#tax_percent').val()) / 100
+					tax = (taxPercent * amount) / (1 + taxPercent);
+				}
+				input.closest('tr').find('td:eq(6)').text(Math.round(tax * 100) / 100);
+				input.closest('tr').find('td:eq(7)').text(Math.round(amount * 100) / 100);
+				calculateTotals();
 
-		function updateQuantity(input) {
-			if(input.val()) {
-				clearTimeout(timeout);
-				timeout = setTimeout(function () {
-					tax = 0;
-					quantity = parseInt(input.val());
-					// sacar el precio del producto
-					if (input.closest('tr').find('td:eq(5) input').val()) {
-						price = parseFloat(input.closest('tr').find('td:eq(5) input').val());
-					} else {
-						price = 0;
-					}
-					amount = price * quantity;
-					if(input.closest('tr').find('td:eq(0) input').val() == '1') {
-						taxPercent = parseFloat($('#tax_percent').val()) / 100
-						tax =  (taxPercent  * amount) / (1 + taxPercent);
-					}
-					input.closest('tr').find('td:eq(6)').text(Math.round(tax * 100) / 100);
-					input.closest('tr').find('td:eq(7)').text(Math.round(amount * 100) / 100);
-					calculateTotals();
-
-					var idText = input.closest('tr').attr('id');
-					var prePurchaseId = idText.substring(idText.lastIndexOf('_') + 1, idText.length);
+				var idText = input.closest('tr').attr('id');
+				var prePurchaseId = idText.substring(idText.lastIndexOf('_') + 1, idText.length);
 
-					$.ajax({
+				$.ajax({
+					type: "PUT",
+					url: "/pre_purchases/" + prePurchaseId,
+					dataType: "json",
+					data: {pre_purchase: {quantity: quantity }},
+					success: function(xhr, status, error) {
+					}
+				});
+			}, 700);
+		}
+	}
+
+	function updateProductPrice(input) {
+		if(input.val()) {
+			clearTimeout(timeout);
+			timeout = setTimeout(function () {
+				price = parseFloat(input.val());
+				var is_in_dollars = $('#purchase_is_in_dollars').bootstrapSwitch('state');
+				var exchange = $('#purchase_exchange').val() ? parseFloat($('#purchase_exchange').val()) : '';
+				var productId = input.closest('td').find('span').text();
+				$.ajax({
+					type: "POST",
+					url: "/products/" + productId + "/edit_from_purchase",
+					dataType: "script",
+					data: {product: {price_base: price }, is_in_dollars: is_in_dollars, exchange: exchange},
+					success: function(xhr, status, error) {
+							//actualizar datos en la tabla
+						tax = 0;
+						hasTax = input.closest('tr').find('td:eq(0) input').val();
+						quantity = parseFloat(input.closest('tr').find('td:eq(4) input').val());
+						price = parseFloat(input.closest('tr').find('td:eq(5) input').val());
+						amount = price * quantity;
+						if(hasTax == '1') {
+							taxPercent = parseFloat($('#tax_percent').val()) / 100
+							tax = (taxPercent * amount) / (1 + taxPercent);
+						}
+						input.closest('tr').find('td:eq(6)').text(Math.round(tax * 100) / 100);
+						input.closest('tr').find('td:eq(7)').text(Math.round(amount * 100) / 100);
+						var preIdText = input.closest('tr').attr('id');
+						var prePurchaseId = preIdText.substring(preIdText.lastIndexOf('_') + 1, preIdText.length);
+						$.ajax({
 							type: "PUT",
 							url: "/pre_purchases/" + prePurchaseId,
 							dataType: "json",
 							data: {pre_purchase: {quantity: quantity }},
 							success: function(xhr, status, error) {
+								calculateTotals();
 							}
-					});
-				}, 700);
-			}
+						});
+					}
+				});
+			}, 600);
 		}
-
-		function updateProductPrice(input) {
-			if(input.val()) {
-				clearTimeout(timeout);
-				timeout = setTimeout(function () {
-					price = parseFloat(input.val());
-					var is_in_dollars = $('#purchase_is_in_dollars').bootstrapSwitch('state');
-					var exchange = $('#purchase_exchange').val() ? parseFloat($('#purchase_exchange').val()) : '';
-					var productId = input.closest('td').find('span').text();
-					$.ajax({
-							type: "POST",
-							url: "/products/" + productId + "/edit_from_purchase",
-							dataType: "script",
-							data: {product: {price_base: price }, is_in_dollars: is_in_dollars, exchange: exchange},
-							success: function(xhr, status, error) {
-									//actualizar datos en la tabla
-									tax = 0;
-									hasTax = input.closest('tr').find('td:eq(0) input').val();
-									quantity = parseFloat(input.closest('tr').find('td:eq(4) input').val());
-									price = parseFloat(input.closest('tr').find('td:eq(5) input').val());
-									amount = price * quantity;
-									if(hasTax == '1') {
-										taxPercent = parseFloat($('#tax_percent').val()) / 100
-										tax =  (taxPercent  * amount) / (1 + taxPercent);
-									}
-									input.closest('tr').find('td:eq(6)').text(Math.round(tax * 100) / 100);
-									input.closest('tr').find('td:eq(7)').text(Math.round(amount * 100) / 100);
-									var preIdText = input.closest('tr').attr('id');
-									var prePurchaseId = preIdText.substring(preIdText.lastIndexOf('_') + 1, preIdText.length);
-									$.ajax({
-											type: "PUT",
-											url: "/pre_purchases/" + prePurchaseId,
-											dataType: "json",
-											data: {pre_purchase: {quantity: quantity }},
-											success: function(xhr, status, error) {
-												calculateTotals();
-											}
-									});
-							}
-					});
-				}, 600);
-			}
+	}
+
+	function calculateTotals() {
+		var amount = 0;
+		var tax = 0;
+		var total = 0;
+		$('#products_table tbody tr td:nth-child(7)').each(function() {
+			tax += parseFloat($(this).text());
+		});
+		$('#products_table tbody tr td:nth-child(8)').each(function() {
+			amount += parseFloat($(this).text());
+		});
+		amount = amount - tax;
+		total = amount + tax;
+		$('#tax').val(Math.round(tax * 100) / 100);
+		$('#amount').val(Math.round(amount * 100) / 100);
+		$('#total').val(Math.round(total * 100) / 100);
+
+		// mostrar el total en pesos cuando es en dolares
+		var is_in_dollars = $('#purchase_is_in_dollars').bootstrapSwitch('state');
+		if (is_in_dollars) {
+			$('#total_in_mxn').val(Math.round((total * $('#purchase_exchange').val()) * 100) / 100);
 		}
-
-		function calculateTotals() {
-			var amount = 0;
-			var tax    = 0;
-			var total  = 0;
-			$('#products_table tbody tr td:nth-child(7)').each(function() {
-				 tax+= parseFloat($(this).text());
-			});
-			$('#products_table tbody tr td:nth-child(8)').each(function() {
-				 amount+= parseFloat($(this).text());
-			});
-			amount = amount - tax;
-			total = amount + tax;
-			$('#tax').val(Math.round(tax * 100) / 100);
-			$('#amount').val(Math.round(amount * 100) / 100);
-			$('#total').val(Math.round(total * 100) / 100);
-
-			// mostrar el total en pesos cuando es en dolares
-			var is_in_dollars = $('#purchase_is_in_dollars').bootstrapSwitch('state');
-			if (is_in_dollars) {
-				$('#total_in_mxn').val(Math.round((total * $('#purchase_exchange').val()) * 100) / 100);
+	}
+
+	function deletePrePurchases() {
+		$.ajax({
+			type: "get",
+			url: '/delete_pre_purchases',
+			dataType: 'json',
+			success: function(xhr, status, error){
+				$('#products_table').dataTable().fnClearTable();
+				$('#purchase_purchase_code').val('');
+				$("#purchase_supplier_id").select2().select2("val", null);
+				$("#purchase_supplier_id").attr('disabled',false);
+				$("#purchase_pointsale_id").select2().select2("val", null);
+				$("#purchase_pointsale_id").attr('disabled',false);
+				$("#purchase_warehouse_id").select2().select2("val", null);
+				$("#purchase_warehouse_id").attr('disabled',false);
+				$("#reset_pre_purchases").attr('disabled',true);
+				$('#destiny').bootstrapSwitch('disabled',false);
+				$('#purchase_is_in_dollars').bootstrapSwitch('disabled', false);
+				$('#purchase_is_in_dollars').bootstrapSwitch('state', false);
+				calculateTotals();
 			}
-		}
+		});
+	}
+
+	function addPurchase() {
+		$('#purchase_form').submit();
+	}
 
-		function deletePrePurchases() {
+	function generatePurchaseCode() {
+		if($('#purchase_pointsale_id').val()) {
 			$.ajax({
 				type: "get",
-				url:  '/delete_pre_purchases',
-				dataType: 'json',
-				success: function(xhr, status, error){
-					$('#products_table').dataTable().fnClearTable();
-					$('#purchase_purchase_code').val('');
-					$("#purchase_supplier_id").select2().select2("val", null);
-					$("#purchase_supplier_id").attr('disabled',false);
-					$("#purchase_pointsale_id").select2().select2("val", null);
-					$("#purchase_pointsale_id").attr('disabled',false);
-					$("#purchase_warehouse_id").select2().select2("val", null);
-					$("#purchase_warehouse_id").attr('disabled',false);
-					$("#reset_pre_purchases").attr('disabled',true);
-					$('#destiny').bootstrapSwitch('disabled',false);
-					$('#purchase_is_in_dollars').bootstrapSwitch('disabled', false);
-					$('#purchase_is_in_dollars').bootstrapSwitch('state', false);
-					calculateTotals();
-				}
+				url: '/get_max_purchaseid_by_pointsale/' + $('#purchase_pointsale_id').val(),
+				dataType: 'text',
+				success: function(data) {
+					$('#purchase_purchase_code').val(data);
+				},
+			});
+		} else if($('#purchase_warehouse_id').val()) {
+			$.ajax({
+				type: "get",
+				url: '/get_max_purchaseid_by_warehouse/' + $('#purchase_warehouse_id').val(),
+				dataType: 'text',
+				success: function(data) {
+					$('#purchase_purchase_code').val(data);
+				},
 			});
 		}
+	}
 
-		function addPurchase() {
-			$('#purchase_form').submit();
-		}
+	function findProductByBarcode(barcode) {
+		var supplier = $('#purchase_supplier_id').val();
+		var pointsale = $('#purchase_pointsale_id').val();
+		var warehouse = $('#purchase_warehouse_id').val();
 
-		function generatePurchaseCode() {
-			if($('#purchase_pointsale_id').val()) {
-				$.ajax({
-					type: "get",
-					url:  '/get_max_purchaseid_by_pointsale/' + $('#purchase_pointsale_id').val(),
-					dataType: 'text',
-					success: function(data) {
-						$('#purchase_purchase_code').val(data);
-					},
-				});
-			} else if($('#purchase_warehouse_id').val()) {
-				$.ajax({
-					type: "get",
-					url:  '/get_max_purchaseid_by_warehouse/' + $('#purchase_warehouse_id').val(),
-					dataType: 'text',
-					success: function(data) {
-						$('#purchase_purchase_code').val(data);
-					},
-				});
-			}
+		if (pointsale) {
+			url = '/add_pre_purchase_by_barcode_pointsale/' + barcode + "/" + supplier + "/" + pointsale;
+		} else {
+			url = '/add_pre_purchase_by_barcode_warehouse/' + barcode + "/" + supplier + "/" + warehouse;
 		}
-
-		function findProductByBarcode(barcode) {
-			var supplier = $('#purchase_supplier_id').val();
-			var pointsale = $('#purchase_pointsale_id').val();
-			var warehouse = $('#purchase_warehouse_id').val();
-
-			if (pointsale) {
-				url = '/add_pre_purchase_by_barcode_pointsale/' + barcode + "/" + supplier + "/" + pointsale;
-			} else {
-				url = '/add_pre_purchase_by_barcode_warehouse/' + barcode + "/" + supplier + "/" + warehouse;
-			}
-			if((supplier && pointsale) || (supplier && warehouse)) {
-				$.ajax({
-					type: "get",
-					url:  url,
-					dataType: 'script',
-					success: function(data) {
-						calculateTotals();
-					},
-				});
-			} else {
-				toastr["error"]("Se debe seleccionar proveedor y destino de la compra.");
-			}
+		if((supplier && pointsale) || (supplier && warehouse)) {
+			$.ajax({
+				type: "get",
+				url: url,
+				dataType: 'script',
+				success: function(data) {
+					calculateTotals();
+				},
+			});
+		} else {
+			toastr["error"]("Se debe seleccionar proveedor y destino de la compra.");
 		}
-
-		function enumeratePrePurchases() {
-			if($('#reset_pre_purchases').prop("disabled") == false) {
-				var table = $('#products_table').dataTable();
-				var counter = 1;
-				$('#products_table tbody tr').each(function() {
-					$(this).find('td:eq(0)').html($(this).find('td:eq(0)').html().replace('#', counter));
-					counter++;
-				});
-			}
+	}
+
+	function enumeratePrePurchases() {
+		if($('#reset_pre_purchases').prop("disabled") == false) {
+			var table = $('#products_table').dataTable();
+			var counter = 1;
+			$('#products_table tbody tr').each(function() {
+				$(this).find('td:eq(0)').html($(this).find('td:eq(0)').html().replace('#', counter));
+				counter++;
+			});
 		}
-
-		function setDestiny(state) {
-			// true es almacen| false es punto de venta
-			$('#purchase_purchase_code').val('');
-			if (state) {
-				$('#warehouse_div').removeClass('hidden');
-				$("#purchase_warehouse_id").select2();
-				$('#pointsale_div').addClass('hidden');
-				<% if current_user.usertype == 'A' %>
-					$('#purchase_pointsale_id').select2('val', null);
-				<% end %>
-			} else {
-				$('#pointsale_div').removeClass('hidden');
-				$("#purchase_pointsale_id").select2();
-				$('#warehouse_div').addClass('hidden');
-				<% if current_user.usertype == 'A' %>
-					$('#purchase_warehouse_id').select2('val', null);
-				<% end %>
-			}
+	}
+
+	function setDestiny(state) {
+		// true es almacen| false es punto de venta
+		$('#purchase_purchase_code').val('');
+		if (state) {
+			$('#warehouse_div').removeClass('hidden');
+			$("#purchase_warehouse_id").select2();
+			$('#pointsale_div').addClass('hidden');
+			<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
+				$('#purchase_pointsale_id').select2('val', null);
+			<% end %>
+		} else {
+			$('#pointsale_div').removeClass('hidden');
+			$("#purchase_pointsale_id").select2();
+			$('#warehouse_div').addClass('hidden');
+			<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
+				$('#purchase_warehouse_id').select2('val', null);
+			<% end %>
 		}
-
-		function showExchangeField(state) {
-			// true es dolares | false es pesos
-			if (state) {
-				$('#exchange_div').removeClass('hidden');
-				$('#amount_div div span:last-child').html('USD');
-				$('#tax_div div span:last-child').html('USD');
-				$('#total_div div span:last-child').html('USD');
-				$("#total_in_mxn_div").removeClass('hidden');
-			} else {
-				$('#exchange_div').addClass('hidden');
-				$('#purchase_exchange').val('');
-				$('#amount_div div span:last-child').html('MXN');
-				$('#tax_div div span:last-child').html('MXN');
-				$('#total_div div span:last-child').html('MXN');
-				$("#total_in_mxn_div").addClass('hidden');
-			}
+	}
+
+	function showExchangeField(state) {
+		// true es dolares | false es pesos
+		if (state) {
+			$('#exchange_div').removeClass('hidden');
+			$('#amount_div div span:last-child').html('USD');
+			$('#tax_div div span:last-child').html('USD');
+			$('#total_div div span:last-child').html('USD');
+			$("#total_in_mxn_div").removeClass('hidden');
+		} else {
+			$('#exchange_div').addClass('hidden');
+			$('#purchase_exchange').val('');
+			$('#amount_div div span:last-child').html('MXN');
+			$('#tax_div div span:last-child').html('MXN');
+			$('#total_div div span:last-child').html('MXN');
+			$("#total_in_mxn_div").addClass('hidden');
 		}
+	}
 </script>
-
-
-

+ 15 - 15
app/views/purchases/_purchase.html.erb

@@ -2,31 +2,31 @@
 	<td> # </td>
 	<td><%= purchase.purchase_code %></td>
 	<td><%= purchase.user.first_name%></td>
-  <% if current_user.usertype == "A" %>
+  <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
     <td><%= purchase.pointsale.present? ? purchase.pointsale.name : '' %></td>
     <td><%= purchase.warehouse.present? ? purchase.warehouse.name : '' %></td>
   <% end %>
 	<td><%= purchase.supplier.nick_name %></td>
   <td><%= number_to_currency(purchase.total, precision: 2) %> <%= purchase.is_in_dollars ? 'USD' : 'MXN' %></td>
 
-	<td> <%= l(purchase.purchase_date, :format => '%d/%B/%Y')  %> </td>
-    <td class="text-center">
-      <% case purchase.status %>
-          <% when "paid"%>
-            <span class="label label-sm label-success"> <i class="fa fa-check"></i> Pagada </span>
-          <% when "cancelled"%>
-             <span class="label label-sm label-danger"> <i class="fa fa-close"></i> Cancelada </span>
-          <% when "parcial"%>
-            <span class="label label-sm label-warning"> <i class="fa fa-clock-o"></i> Abonada </span>
-          <% when "notpaid"%>
-            <span class="label label-sm label-default"> <i class="fa fa-clock-o"></i> Pendiente de pago </span>
-      <% end %>
-    </td>
+	<td> <%= l(purchase.purchase_date, format: '%d/%B/%Y') %> </td>
+  <td class="text-center">
+    <% case purchase.status %>
+    <% when "paid"%>
+      <span class="label label-sm label-success"> <i class="fa fa-check"></i> Pagada </span>
+    <% when "cancelled"%>
+      <span class="label label-sm label-danger"> <i class="fa fa-close"></i> Cancelada </span>
+    <% when "parcial"%>
+      <span class="label label-sm label-warning"> <i class="fa fa-clock-o"></i> Abonada </span>
+    <% when "notpaid"%>
+      <span class="label label-sm label-default"> <i class="fa fa-clock-o"></i> Pendiente de pago </span>
+    <% end %>
+  </td>
 	<td class="text-center">
       	<%= link_to purchase, {:class=>"btn btn-icon-only default", :title=>"Ver compra"} do %> <i class="fa fa-search"></i> <% end %>
       	<% daysToCancel = @pos_config.days_cancel_purchase %>
       	<% if (can? :manage, Purchase) && (purchase.purchase_date + daysToCancel.days >= Date.today) && !purchase.cancelled? %>
-			<%= 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 %>
+			<%= 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 %>
 		<% end %>
 	</td>
 </tr>

+ 48 - 62
app/views/purchases/index.html.erb

@@ -44,44 +44,43 @@
 									</div>
 									<div class="actions">
 										<% if can? :create, Purchase %>
-										<%= link_to new_purchase_path, {:class=>"btn bold green pull-right filtros"} do %> Nueva Compra <i class="fa fa-plus"></i>
-										<% end %>
+											<%= link_to new_purchase_path, {:class=>"btn bold green pull-right filtros"} do %> Nueva Compra <i class="fa fa-plus"></i><% end %>
 										<% end %>
 									</div>
 								</div>
 								<div class="portlet-body">
-				                    <div class="form-horizontal" style="margin-bottom:35px">
-				                      <div class="row">
-				                        <div class="col-md-11">
-                          					<%= hidden_field_tag 'title_for_print' %>
-				                          <div class="form-group">
-				                            <%= label_tag :begin_date, "Fecha", {:class=>"col-md-1 control-label"} do %> Desde
-				                            <% end %>
-				                            <div class="col-sm-2" style="padding-left:0px;padding-right:0px;">
-				                                <div class='input-group date' id='begin_date'>
-				                                    <input id="start" type='text' class="form-control"/>
-				                                    <span class="input-group-addon">
-				                                        <span class="glyphicon glyphicon-calendar"></span>
-				                                    </span>
-				                                </div>
-				                            </div>
-				                            <%= label_tag :end_date, "Fecha", {:class=>"col-md-1 control-label"} do %> Hasta
-				                            <% end %>
-				                            <div class="col-sm-2" style="padding-left:0px;padding-right:0px;">
-				                                <div class='input-group date' id='end_date'>
-				                                    <input id="end" type='text' class="form-control"/>
-				                                    <span class="input-group-addon">
-				                                        <span class="glyphicon glyphicon-calendar"></span>
-				                                    </span>
-				                                </div>
-				                            </div>
-				                            <button class="btn btn-icon-only blue" style="margin-left:25px" onclick="purchasesByDate()">
-				                              <i class="fa fa-search"></i>
-				                            </button>
-				                          </div>
-				                        </div>
-				                      </div>
-				                    </div>
+                  <div class="form-horizontal" style="margin-bottom:35px">
+                    <div class="row">
+                      <div class="col-md-11">
+              					<%= hidden_field_tag 'title_for_print' %>
+                        <div class="form-group">
+                          <%= label_tag :begin_date, "Fecha", { class: "col-md-1 control-label" } do %> Desde
+                          <% end %>
+                          <div class="col-sm-2" style="padding-left:0px;padding-right:0px;">
+                            <div class='input-group date' id='begin_date'>
+                              <input id="start" type='text' class="form-control"/>
+                              <span class="input-group-addon">
+                                <span class="glyphicon glyphicon-calendar"></span>
+                              </span>
+                            </div>
+                          </div>
+                          <%= label_tag :end_date, "Fecha", { class: "col-md-1 control-label" } do %> Hasta
+                          <% end %>
+                          <div class="col-sm-2" style="padding-left:0px;padding-right:0px;">
+                            <div class='input-group date' id='end_date'>
+                              <input id="end" type='text' class="form-control"/>
+                              <span class="input-group-addon">
+                                <span class="glyphicon glyphicon-calendar"></span>
+                              </span>
+                            </div>
+                          </div>
+                          <button class="btn btn-icon-only blue" style="margin-left:25px" onclick="purchasesByDate()">
+                            <i class="fa fa-search"></i>
+                          </button>
+                        </div>
+                      </div>
+                    </div>
+                  </div>
 
 									<input type='hidden' name='filter' id='filter' value='<%= @filter %>' >
 									<input type='hidden' name='current_page' id='current_page' value='<%= @current_page %>' >
@@ -91,7 +90,7 @@
 												<th>#</th>
 												<th>Folio</th>
 												<th>Usuario</th>
-												<% if current_user.usertype == "A" %>
+												<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 													<th>Pto. de venta</th>
 													<th>Almacén</th>
 												<% end %>
@@ -106,36 +105,23 @@
 										</thead>
 										<tbody>
 											<% @purchases.each_with_index do |purchase, key| %>
-												<tr <% if purchase.status == "cancelled" %>class="danger"<% end %>>
+												<tr <% if purchase.cancelled? %>class="danger"<% end %>>
 													<td><%= key + 1 %></td>
 													<td><%= purchase.purchase_code %></td>
-													<td><%= purchase.user.first_name%></td>
-													<% if current_user.usertype == "A" %>
+													<td><%= purchase.user.first_name %></td>
+													<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 														<td><%= purchase.pointsale.present? ? purchase.pointsale.name : '' %></td>
 														<td><%= purchase.warehouse.present? ? purchase.warehouse.name : '' %></td>
 													<% end %>
 													<td><%= purchase.supplier.nick_name %></td>
 													<td><%= number_to_currency(purchase.total, precision: 2) %> <%= purchase.is_in_dollars ? 'USD' : 'MXN' %></td>
-
-													<td><%= l(purchase.purchase_date, :format => '%d/%B/%Y') %>
-													</td>
-							                        <td class="text-center">
-							                          <% case purchase.status %>
-								                          <% when "paid"%>
-								                            <span class="label label-sm label-success"> <i class="fa fa-check"></i> Pagada </span>
-								                          <% when "cancelled"%>
-								                             <span class="label label-sm label-danger"> <i class="fa fa-close"></i> Cancelada </span>
-								                          <% when "parcial"%>
-								                            <span class="label label-sm label-warning"> <i class="fa fa-clock-o"></i> Abonada </span>
-								                          <% when "notpaid"%>
-								                            <span class="label label-sm label-default"> <i class="fa fa-clock-o"></i> Pte. de pago</span>
-							                          <% end %>
-							                        </td>
+													<td><%= l(purchase.purchase_date, :format => '%d/%B/%Y') %></td>
+	                        <td class="text-center"><%= purchase_status(purchase) %></td>
 													<td class="text-center">
-							                          	<%= link_to purchase, {:class=>"btn btn-icon-only default filtros", :title=>"Ver compra"} do %> <i class="fa fa-search"></i> <% end %>
-							                          	<% daysToCancel = @pos_config.days_cancel_purchase %>
-							                          	<% if (can? :manage, Purchase) && (purchase.purchase_date + daysToCancel.days >= Date.today) && !purchase.cancelled? %>
-															<%= 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 %>
+                          	<%= link_to purchase, {:class=>"btn btn-icon-only default filtros", :title=>"Ver compra"} do %> <i class="fa fa-search"></i> <% end %>
+                          	<% daysToCancel = @pos_config.days_cancel_purchase %>
+                          	<% if (can? :manage, Purchase) && (purchase.purchase_date + daysToCancel.days >= Date.today) && !purchase.cancelled? %>
+															<%= 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 %>
 														<% end %>
 													</td>
 												</tr>
@@ -183,17 +169,17 @@
 	var start = moment($("#begin_date").data("date"), "DD-MM-YYYY").format('YYYY-MM-DD HH:mm:ss');
     var end = moment($("#end_date").data("date"), "DD-MM-YYYY").format('YYYY-MM-DD HH:mm:ss');
     App.blockUI({
-         target: $("#purchases_table"),
-         animate: true
+      target: $("#purchases_table"),
+      animate: true
     });
     $.ajax({
       type: "get",
       url:  '/find_purchases_by_date/' + start + '/' + end,
       dataType: 'script',
       success: function(data) {
-          window.setTimeout(function() {
-            App.unblockUI($("#purchases_table"));
-          }, 100);
+        window.setTimeout(function() {
+          App.unblockUI($("#purchases_table"));
+        }, 100);
       }
     });
   }

+ 2 - 2
app/views/sales/_sale.html.erb

@@ -1,7 +1,7 @@
 <tr class=<%= (sale.cancelled? ? 'danger' : '') %>>
 	<td><%= sale.id %></td>
 	<td><%= sale.sale_code %> </td>
-	<% if current_user.usertype == 'A' %>
+	<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 		<td> <%= sale.get_pointsale.name %> </td>
 	<% end %>
 	<td><%= sale.customer.nick_name %> </td>
@@ -29,4 +29,4 @@
       <%= link_to sale, method: :delete, class: "btn btn-icon-only btn-danger", title: "Cancelar venta", data: { confirm: '¿Está seguro que desea cancelar la venta?' } do %> <i class="fa fa-ban"></i><% end %>
     <% end %>
   </td>
-</tr>
+</tr>

+ 3 - 13
app/views/sales/_sale_for_report.html.erb

@@ -9,24 +9,14 @@
     Crédito
     <% elsif sale.saletype == "credit" && sale.credit_note.present? %>
     Crédito/vale
-    <% elsif sale.saletype == "cash"%>
+    <% elsif sale.saletype == "cash" %>
     Contado
-    <% elsif sale.saletype == "reserved"%>
+    <% elsif sale.saletype == "reserved" %>
     Apartado
     <% end %>
   </td>
   <td>
-    <% case sale.status %>
-    <% when "paid"%>
-      <span class="label label-success"> PAGADA </span>
-    <% when "cancelled"%>
-      <span class="label label-danger"> CANCELADO </span>
-    <% when "parcial"%>
-      <span class="label label-warning"> ABONADA </span>
-
-    <% when "notpaid"%>
-      <span class="label label-default">PAGO PENDIENTE</span>
-    <% end %>
+    <%= sale_status(sale) %>
   </td>
   <td><%= number_to_currency(sale.amount, precision: 2) %></td>
   <td><%= number_to_currency(sale.tax, precision: 2) %></td>

+ 2 - 11
app/views/sales/_sale_for_return.html.erb

@@ -1,6 +1,6 @@
 <tr id="sale_<%=sale.id%>">
   <td><%= sale.id %></td>
-  <td><%= sale.sale_code %> </td>     
+  <td><%= sale.sale_code %> </td>
   <td><%= sale.customer.nick_name %> </td>
   <td><%= sale.seller.name %> </td>
   <td><%= l(sale.date_sale, :format => '%d/%m/%Y') %></td>
@@ -17,16 +17,7 @@
   </td>
   <td><%= sale.products.count %></td>
   <td>
-    <% case sale.status %>
-    <% when "paid"%>
-      <span class="label label-success"> PAGADA </span>
-    <% when "cancelled"%>
-      <span class="label label-danger"> CANCELADO </span>
-    <% when "parcial"%>                     
-      <span class="label label-warning"> ABONADA </span> 
-    <% when "notpaid"%>                     
-      <span class="label label-default"> PENDIENTE PAGO </span>                             
-    <% end %>
+    <%= sale_status(sale) %>
   </td>
   <td><%= number_to_currency(sale.total, precision: 2) %></td>
 </tr>

+ 11 - 11
app/views/sales/_sale_reserved.html.erb

@@ -1,7 +1,7 @@
 <tr class=<%= (sale.cancelled? ? 'danger' : '') %>>
   <td><%= sale.id %></td>
   <td><%= sale.sale_code %> </td>
-  <% if current_user.usertype == 'A' %>
+  <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
     <td> <%= sale.get_pointsale.name %> </td>
   <% end %>
   <td> <%= sale.customer.nick_name %> </td>
@@ -10,15 +10,15 @@
   <td> <%= l(sale.expiration_date, :format => '%d/%B/%Y') %> </td>
   <td> <%= sale.sales_details.sum(:quantity) %> </td>
   <td>
-      <% if sale.reserve_is_expired? && !sale.paid? && !sale.cancelled? %>
-        <span class="label label-warning"> VENCIDO </span>
-      <% elsif sale.cancelled? %>
-        <span class="label label-danger"> CANCELADO </span>
-      <% elsif sale.parcial? %>
-        <span class="label label-success"> VIGENTE </span>
-      <% elsif sale.paid? %>
-        <span class="label label-success"> PAGADO </span>
-      <% end %>
+    <% if sale.reserve_is_expired? && !sale.paid? && !sale.cancelled? %>
+      <span class="label label-warning"> VENCIDO </span>
+    <% elsif sale.cancelled? %>
+      <span class="label label-danger"> CANCELADO </span>
+    <% elsif sale.parcial? %>
+      <span class="label label-success"> VIGENTE </span>
+    <% elsif sale.paid? %>
+      <span class="label label-success"> PAGADO </span>
+    <% end %>
   </td>
   <td><%= number_to_currency(sale.total, precision: 2) %></td>
   <td><%= number_to_currency(sale.reserve_debt, precision: 2) %></td>
@@ -33,7 +33,7 @@
     <% end %>
     <!-- regresar productos a inventario cuando vencio el apartado -->
     <% if sale.reserve_is_expired? && !sale.cancelled_by_expiration? && !sale.paid? && !sale.cancelled? %>
-      <%= link_to sale_return_expired_path(sale), :class=>"btn btn-icon-only btn-info", :title=>"Regresar producto(s) a inventario", data: { confirm: '¿Esta seguro que desea reingresar los productos a inventario?', method: 'post'}  do %>
+      <%= link_to sale_return_expired_path(sale), :class=>"btn btn-icon-only btn-info", :title=>"Regresar producto(s) a inventario", data: { confirm: '¿Está seguro que desea reingresar los productos a inventario?', method: 'post' } do %>
           <i class="fa fa-reply"></i>
       <% end %>
     <% end %>

+ 2 - 2
app/views/sales/index.html.erb

@@ -87,7 +87,7 @@
                       <tr>
                         <th>#</th>
                         <th>Folio</th>
-                        <% if current_user.usertype == 'A' %>
+                        <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
                           <th>Pto. de venta</th>
                         <% end %>
                         <th>Cliente</th>
@@ -105,7 +105,7 @@
                       <tr class=<%= (sale.cancelled? ? 'danger' : '') %>>
                         <td><%= sale.id %></td>
                         <td><%= sale.sale_code %> </td>
-                        <% if current_user.usertype == 'A' %>
+                        <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
                           <td> <%= sale.get_pointsale.name %> </td>
                         <% end %>
                         <td><%= sale.customer.nick_name %> </td>

+ 6 - 8
app/views/sales/sales_per_month_report.html.erb

@@ -32,14 +32,14 @@
                       <div class="col-md-3">
                         <div class="search-label uppercase">Punto de venta</div>
                         <div class="col-md-12">
-                          <%= select_tag "pointsale", options_from_collection_for_select(Pointsale.vigentes, :id, :name), :include_blank => "Todas",  class: "form-control  input-medium" %>
+                          <%= select_tag "pointsale", options_from_collection_for_select(Pointsale.vigentes, :id, :name), :include_blank => "Todos", class: "form-control  input-medium" %>
                         </div>
                       </div>
                       <div class="col-md-3">
                         <div class="search-label uppercase"> Del </div>
                         <div class="col-md-6">
                           <div class="input-group input-medium date date-picker" data-date-format="dd/mm/yyyy">
-                            <input id="start" type='text' class="form-control"/>
+                            <input id="start" type='text' class="form-control" value="<%= l(Date.today.beginning_of_month, format: '%d/%m/%Y') %>" />
                             <span class="input-group-addon">
                               <span class="glyphicon glyphicon-calendar"></span>
                             </span>
@@ -50,7 +50,7 @@
                         <div class="search-label uppercase"> Al </div>
                         <div class="col-md-6">
                           <div class="input-group input-medium date date-picker" data-date-format="dd/mm/yyyy">
-                            <input id="end" type='text' class="form-control"/>
+                            <input id="end" type='text' class="form-control" value="<%= l(Date.today.end_of_month, format: '%d/%m/%Y') %>" />
                             <span class="input-group-addon">
                               <span class="glyphicon glyphicon-calendar"></span>
                             </span>
@@ -58,7 +58,7 @@
                         </div>
                       </div>
                       <div class="col-md-3" style="margin-top: 20px">
-                        <button class="btn green bold  btn-block" onclick="findSalesByPeriod()" style="margin:0px">Filtrar <i class="m-icon-swapright m-icon-white"></i> </button>
+                        <button class="btn green bold btn-block" onclick="findSalesByPeriod()" style="margin:0px">Filtrar <i class="m-icon-swapright m-icon-white"></i> </button>
                       </div>
                     </div>
                   </div>
@@ -82,10 +82,9 @@
                         <div class="note note-success hidden" id="note_info">
                           <h4 class="block">Detalle de ventas e ingresos del periodo: <strong><span id="start_date_display"></span></strong> al <strong><span id="end_date_display"></span></strong> en <strong><span id="pointsale_display"></span></strong></h4>
                         </div>
-
                         <div class="col-xs-offset-1 col-xs-5">
                           <div class="text-center well" id="container_total_prods" style="margin-bottom: 0px">
-                            <div class="font-grey-mint font-sm">NUMERO DE VENTAS</div>
+                            <div class="font-grey-mint font-sm">NÚMERO DE VENTAS</div>
                             <div class="uppercase font-hg font-blue-sharp" id="sales_quantity">0</div>
                           </div>
                         </div>
@@ -223,9 +222,8 @@
             $('#note_info').removeClass('hidden');
           }
         });
-      }else{
+      } else {
         toastr["error"]("Es necesario seleccionar fechas.");
       }
     }
-
   </script>

+ 11 - 11
app/views/sales/sales_reserved.html.erb

@@ -81,7 +81,7 @@
                       <tr>
                         <th>#</th>
                         <th>Folio</th>
-                        <% if current_user.usertype == 'A' %>
+                        <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
                           <th>Punto de venta</th>
                         <% end %>
                         <th>Cliente</th>
@@ -100,7 +100,7 @@
                       <tr class=<%= (sale.cancelled? ? 'danger' : '') %>>
                         <td><%= sale.id %></td>
                         <td><%= sale.sale_code %> </td>
-                        <% if current_user.usertype == 'A' %>
+                        <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
                           <td> <%= sale.get_pointsale.name %> </td>
                         <% end %>
                         <td> <%= sale.customer.nick_name %> </td>
@@ -109,15 +109,15 @@
                         <td> <%= l(sale.expiration_date, :format => '%d/%B/%Y') %> </td>
                         <td> <%= sale.sales_details.sum(:quantity) %> </td>
                         <td>
-                            <% if sale.reserve_is_expired? && !sale.paid? && !sale.cancelled? %>
-                              <span class="label label-warning"> VENCIDO </span>
-                            <% elsif sale.cancelled? %>
-                              <span class="label label-danger"> CANCELADO </span>
-                            <% elsif sale.parcial? %>
-                              <span class="label label-success"> VIGENTE </span>
-                            <% elsif sale.paid? %>
-                              <span class="label label-success"> PAGADO </span>
-                            <% end %>
+                          <% if sale.reserve_is_expired? && !sale.paid? && !sale.cancelled? %>
+                            <span class="label label-warning"> VENCIDO </span>
+                          <% elsif sale.cancelled? %>
+                            <span class="label label-danger"> CANCELADO </span>
+                          <% elsif sale.parcial? %>
+                            <span class="label label-success"> VIGENTE </span>
+                          <% elsif sale.paid? %>
+                            <span class="label label-success"> PAGADO </span>
+                          <% end %>
                         </td>
                         <td><%= number_to_currency(sale.total, precision: 2) %></td>
                         <td><%= number_to_currency(sale.reserve_debt, precision: 2) %></td>

+ 60 - 71
app/views/sales/show.html.erb

@@ -19,17 +19,16 @@
 			<div class="container-fluid">
 				<div class="pull-right margin-bottom-10 ">
 					<% if @sale.reserved? %>
-						<%= link_to  sales_reserved_path(:filter => @filter, :current_page => @current_page), {:class=>"fr-space btn blue-hoki "} do %>
+						<%= link_to sales_reserved_path(:filter => @filter, :current_page => @current_page), {:class=>"fr-space btn blue-hoki "} do %>
 							<i class="fa fa-angle-left "></i>
 							Regresar
 						<% end %>
 					<% else %>
-						<%= link_to  sales_path(:filter => @filter, :current_page => @current_page), {:class=>"fr-space btn blue-hoki "} do %>
+						<%= link_to sales_path(:filter => @filter, :current_page => @current_page), {:class=>"fr-space btn blue-hoki "} do %>
 							<i class="fa fa-angle-left "></i>
 							Regresar
 						<% end %>
 					<% end %>
-
 				</div>
 				<!-- BEGIN PAGE BREADCRUMBS -->
 				<ul class="page-breadcrumb breadcrumb">
@@ -69,15 +68,15 @@
 									<div class="row static-info">
 										<div class="col-md-1 name"> <i class="fa fa-credit-card"></i> </div>
 										<div class="col-md-8 value">
-				                        <% if @sale.saletype == "credit" && @sale.credit_note.blank? %>
-				                          	<span class="label label-warning"> Venta a crédito </span>
-				                        <% elsif @sale.saletype == "credit" && @sale.credit_note.present? %>
-				                          	<span class="label label-warning"> Crédito/vale </span>
-										<% elsif @sale.saletype == "cash" %>
-											<span class="label label-success"> Venta a contado </span>
-										<% elsif @sale.saletype == "reserved" %>
-											<span class="label label-primary"> Apartado </span>
-										<% end %>
+                  	  <% if @sale.saletype == "credit" && @sale.credit_note.blank? %>
+                      	<span class="label label-warning"> Venta a crédito </span>
+                      <% elsif @sale.saletype == "credit" && @sale.credit_note.present? %>
+                      	<span class="label label-warning"> Crédito/vale </span>
+											<% elsif @sale.saletype == "cash" %>
+												<span class="label label-success"> Venta a contado </span>
+											<% elsif @sale.saletype == "reserved" %>
+												<span class="label label-primary"> Apartado </span>
+											<% end %>
 										</div>
 									</div>
 									<div class="row static-info">
@@ -87,16 +86,7 @@
 									<div class="row static-info">
 										<div class="col-md-1 name"> <i class="fa fa-info-circle"></i> </div>
 										<div class="col-md-8 value">
-											<% case @sale.status %>
-					                          <% when "paid"%>
-					                            <span class="label label-success"> <i class="fa fa-check"></i> Pagada </span>
-					                          <% when "canceled"%>
-					                             <span class="label label-danger"> <i class="fa fa-close"></i> Cancelada </span>
-					                          <% when "parcial"%>
-					                            <span class="label label-warning"> <i class="fa fa-clock-o"></i> Abonada </span>
-					                          <% when "notpaid"%>
-					                            <span class="label label-default"> <i class="fa fa-clock-o"></i> Pendiente de pago </span>
-					                      	<% end %>
+											<%= sale_status(@sale) %>
 										</div>
 									</div>
 									<% if @sale.credit_note.present? %>
@@ -118,18 +108,17 @@
 								</div>
 								<div class="portlet-body">
 									<table class="table table-striped table-hover">
-
 										<thead>
 											<tr>
 												<th>#</th>
-									            <th>SKU</th>
-									            <th>Imagen</th>
-									            <th>Producto</th>
-									            <th>Cantidad</th>
-									            <th>Precio</th>
-									            <th>IVA</th>
-									            <th>Descuento</th>
-									            <th>Importe</th>
+						            <th>SKU</th>
+						            <th>Imagen</th>
+						            <th>Producto</th>
+						            <th>Cantidad</th>
+						            <th>Precio</th>
+						            <th>IVA</th>
+						            <th>Descuento</th>
+						            <th>Importe</th>
 											</tr>
 										</thead>
 										<tbody>
@@ -167,49 +156,49 @@
 									<div class="portlet-body">
 										<div class="row">
 											<div class="col-md-4">
-											    <div class="hidden-print" style="padding-left: 0px">
-											      <ul class="list-group">
-											        <li class="list-group-item list-group-item-default"> Monto devuelto
-												        <span class="pull-right label label-warning">
-												        	<%= number_to_currency(@products_return.returned_amount, precision: 2) %>
-											        	</span>
-											        </li>
-											      </ul>
-											    </div>
+										    <div class="hidden-print" style="padding-left: 0px">
+										      <ul class="list-group">
+										        <li class="list-group-item list-group-item-default"> Monto devuelto
+											        <span class="pull-right label label-warning">
+											        	<%= number_to_currency(@products_return.returned_amount, precision: 2) %>
+										        	</span>
+										        </li>
+										      </ul>
+										    </div>
 											</div>
 											<div class="col-md-4">
-											    <div class="hidden-print" style="padding-left: 0px">
-											      <ul class="list-group">
-											        <li class="list-group-item list-group-item-default"> Nuevo monto
-											        	<span class="pull-right label label-warning">
-											        		<%= number_to_currency(@products_return.new_amount, precision: 2) %>
-											        	</span>
-											        </li>
-											      </ul>
-											    </div>
+										    <div class="hidden-print" style="padding-left: 0px">
+										      <ul class="list-group">
+										        <li class="list-group-item list-group-item-default"> Nuevo monto
+										        	<span class="pull-right label label-warning">
+										        		<%= number_to_currency(@products_return.new_amount, precision: 2) %>
+										        	</span>
+										        </li>
+										      </ul>
+										    </div>
 											</div>
 											<div class="col-md-4">
-											    <div class="hidden-print" style="padding-left: 0px">
-											      <ul class="list-group">
-											        <li class="list-group-item list-group-item-default"> Diferencia
-											        	<span class="pull-right label label-warning">
-											        		<%= number_to_currency(@products_return.difference_amount, precision: 2) %>
-											        	</span>
-											        </li>
-											      </ul>
-											    </div>
+										    <div class="hidden-print" style="padding-left: 0px">
+										      <ul class="list-group">
+										        <li class="list-group-item list-group-item-default"> Diferencia
+										        	<span class="pull-right label label-warning">
+										        		<%= number_to_currency(@products_return.difference_amount, precision: 2) %>
+										        	</span>
+										        </li>
+										      </ul>
+										    </div>
 											</div>
 										</div>
 										<h3>Productos devueltos</h3>
 										<table class="table table-striped table-hover">
 											<thead>
 												<tr>
-										            <th>Cantidad</th>
-										            <th>Imagen</th>
-										            <th>Producto</th>
-										            <th>Monto</th>
-										            <th>Razón</th>
-										            <th>Destino</th>
+							            <th>Cantidad</th>
+							            <th>Imagen</th>
+							            <th>Producto</th>
+							            <th>Monto</th>
+							            <th>Razón</th>
+							            <th>Destino</th>
 												</tr>
 											</thead>
 											<tbody>
@@ -237,10 +226,10 @@
 										<table class="table table-striped table-hover">
 											<thead>
 												<tr>
-										            <th>Cantidad</th>
-										            <th>Imagen</th>
-										            <th>Producto</th>
-										            <th>Monto</th>
+							            <th>Cantidad</th>
+							            <th>Imagen</th>
+							            <th>Producto</th>
+							            <th>Monto</th>
 												</tr>
 											</thead>
 											<tbody>
@@ -278,9 +267,9 @@
 											<tr>
 												<th>#</th>
 												<th>Fecha</th>
-									            <th>Metodo de pago</th>
-									            <th>Monto</th>
-									            <th>Info. Adicional</th>
+						            <th>Metodo de pago</th>
+						            <th>Monto</th>
+						            <th>Info. Adicional</th>
 											</tr>
 										</thead>
 										<tbody>

+ 12 - 15
app/views/sellers/_form.html.erb

@@ -1,34 +1,32 @@
-<%= form_for(@seller, :html => {:class=>"form-horizontal"}) do |f| %>
+<%= form_for(@seller, remote: true, :html => {:class=>"form-horizontal"}) do |f| %>
 	<div class="portlet-body form">
-		<% if @seller.errors.any? %>
-			<div class="alert alert-danger">
-				<strong>Tiene <%= pluralize(@seller.errors.count, "error") %> no se puede guardar el vendedor</strong><br>
-			</div>
-		<% end %>
+		<div class="row col-md-12">
+      <div class="alert alert-danger hidden" id="seller_errors"></div>
+    </div>
 		<div class="form-body">
 			<div class="row">
 				<!-- nombre del vendedor -->
 				<div class="form-group">
-					<%= f.label :name, "Nombre", {:class=>"col-md-2 control-label"} do %> Nombre <span class="required">*</span>
+					<%= f.label :name, "Nombre", {:class=>"col-md-2 col-sm-3 control-label"} do %> Nombre <span class="required">*</span>
 					<% end %>
-					<div class="col-md-3" style="padding-left: 0px;padding-right: 0px">
-						<%= f.text_field :name, {:class=>"form-control"} %>
+					<div class="col-md-6 col-sm-6" style="padding-left: 0px;padding-right: 0px">
+						<%= f.text_field :name, {:class=>"form-control first_input"} %>
 					</div>
 				</div>
 				<!-- apellido vendedor -->
 				<div class="form-group">
-					<%= f.label :last_name, "Apellidos", {:class=>"col-md-2 control-label"} do %> Apellido <span class="required">*</span>
+					<%= f.label :last_name, "Apellidos", {:class=>"col-md-2 col-sm-3 control-label"} do %> Apellido <span class="required">*</span>
 					<% end %>
-					<div class="col-md-3" style="padding-left: 0px;padding-right: 0px">
+					<div class="col-md-6 col-sm-6" style="padding-left: 0px;padding-right: 0px">
 						<%= f.text_field :last_name, {:class=>"form-control"} %>
 					</div>
 				</div>
 				<!-- punto de venta -->
-				<div class=<%= (current_user.usertype == "A" ? "form-group" : "form-group hidden") %>>
-					<%= f.label :pointsale_id, "Punto de venta", {:class=>"col-md-2 control-label"} do %> Punto de venta
+				<div class=<%= (current_user.usertype == "A" || current_user.usertype == "SS" ? "form-group" : "form-group hidden") %>>
+					<%= f.label :pointsale_id, "Punto de venta", {:class=>"col-md-2 col-sm-3 control-label"} do %> Punto de venta
 					<span class="required">*</span>
 					<% end %>
-					<div class="input-group col-md-3 select2-bootstrap-prepend">
+					<div class="input-group col-md-6 col-sm-6 select2-bootstrap-prepend">
 						<%= f.collection_select :pointsale_id, @pointsales, :id, :name, {:prompt => "Seleccione", :selected => @pointsale_id.blank? ? '' : @pointsale_id.to_i}, {:class => "form-control select2"} %>
 					</div>
 				</div>
@@ -38,7 +36,6 @@
 			<div class="row">
 				<div class="col-md-offset-2 col-md-10">
 					<%= f.submit 'Guardar', {:class=>"btn green"} %>
-					<%= link_to 'Cancelar', sellers_path(:filter => @filter, :current_page => @current_page), {:class=>"btn default"} %>
 				</div>
 			</div>
 		</div>

+ 11 - 0
app/views/sellers/create.js.erb

@@ -0,0 +1,11 @@
+$("#seller_errors").html("");
+<% if @seller.errors.any? %>
+  $('#seller_errors').removeClass('hidden');
+  <% @seller.errors.values.each do |message| %>
+    $("#seller_errors").append($("<li />").html("<%= message.first.to_s %>"));
+  <% end %>
+<% else %>
+  $('#dialog').modal('toggle');
+  window.location = "<%= sellers_path %>";
+  $("#notice").html("<%= flash[:notice] %>");
+<% end %>

+ 0 - 51
app/views/sellers/edit.html.erb

@@ -1,51 +0,0 @@
-<!-- BEGIN CONTAINER -->
-<div class="page-container">
-	<!-- BEGIN CONTENT -->
-	<div class="page-content-wrapper">
-		<!-- BEGIN CONTENT BODY -->
-		<!-- BEGIN PAGE HEAD-->
-		<div class="page-head">
-			<div class="container-fluid">
-				<!-- BEGIN PAGE TITLE -->
-				<div class="page-title">
-					<h1> Vendedor </h1>
-				</div>
-				<!-- END PAGE TITLE -->
-			</div>
-		</div>
-		<!-- END PAGE HEAD-->
-		<!-- BEGIN PAGE CONTENT BODY -->
-		<div class="page-content">
-			<div class="container-fluid">
-				<!-- BEGIN PAGE BREADCRUMBS -->
-				<ul class="page-breadcrumb breadcrumb">
-					<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
-				</ul>
-				<!-- END PAGE BREADCRUMBS -->
-				<!-- BEGIN PAGE CONTENT INNER -->
-				<div class="page-content-inner">
-					<div id="notice"><%= notice %></div>
-					<div class="row">
-						<div class="col-md-12">
-							<div class="portlet light ">
-								<div class="portlet-title">
-									<div class="caption">
-										<i class="fa fa-edit font-blue-sharp"></i>
-										<span class="caption-subject font-blue-sharp bold uppercase">Editar vendedor</span>
-										<span class="caption-helper"></span>
-									</div>
-								</div>
-								<%= render 'form' %>
-							</div>
-						</div>
-					</div>
-				</div>
-				<!-- END PAGE CONTENT INNER -->
-			</div>
-		</div>
-		<!-- END PAGE CONTENT BODY -->
-		<!-- END CONTENT BODY -->
-	</div>
-	<!-- END CONTENT -->
-</div>
-<!-- END CONTAINER -->

+ 14 - 0
app/views/sellers/edit.js.erb

@@ -0,0 +1,14 @@
+$('#dialog h3.modal-title').html("Editar vendedor");
+$('#dialog').removeClass('modal-lg');
+$('.modal-footer').remove();
+$('.modal-body').html(""); //limpiar el modal antes; la siguiente linea es por si se abrio previamente el detalle de venta
+$('.modal-dialog').removeClass('modal-lg');
+// Rend$( ".selector" ).dialog({ closeOnEscape: false });er the edit form
+$('.modal-body').html('<%= j render("form") %>');
+// Show the dynamic dialog
+$('#dialog').modal("show");
+
+// Set focus to the first element
+$('#dialog').on('shown.bs.modal', function () {
+  $('.first_input').focus();
+});

+ 7 - 10
app/views/sellers/index.html.erb

@@ -45,21 +45,18 @@
 									</div>
 									<div class="actions">
 										<% if can? :create, Seller %>
-										<%= link_to new_seller_path, {:class=>"btn bold green pull-right filtros"} do %> Nuevo Vendedor <i class="fa fa-plus"></i>
-										<% end %>
+											<%= link_to new_seller_path, remote: true, class: "btn bold green pull-right" do %> Nuevo Vendedor <i class="fa fa-plus"></i> <% end %>
 										<% end %>
 									</div>
 								</div>
 								<div class="portlet-body">
-									<input type='hidden' name='filter' id='filter' value='<%= @filter %>' >
-									<input type='hidden' name='current_page' id='current_page' value='<%= @current_page %>' >
 									<table class="table table-striped table-bordered table-hover tableadvanced">
 										<thead>
 											<tr>
 												<th>#</th>
 												<th>Nombre</th>
 												<th>Apellido</th>
-												<% if current_user.usertype == "A" %>
+												<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 													<th>Punto de venta</th>
 												<% end %>
 												<th>Status</th>
@@ -72,7 +69,7 @@
 												<td><%= key + 1 %></td>
 												<td><%= seller.name %></td>
 												<td><%= seller.last_name %></td>
-												<% if current_user.usertype == "A" %>
+												<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 													<td> <%= seller.pointsale.name %> </td>
 												<% end %>
 												<td>
@@ -84,21 +81,21 @@
 												</td>
 												<td>
 												<% if can? :update, Seller %>
-													<%= link_to edit_seller_path(seller), {:class=>"btn btn-icon-only btn-primary filtros", :title=>"Editar vendedor"} do %>
+													<%= link_to edit_seller_path(seller), remote: true, class: "btn btn-icon-only btn-primary", title: "Editar vendedor" do %>
 														<i class="fa fa-edit"></i>
 													<% end %>
 													<% if seller.active? %>
-														<%= link_to seller_update_status_path(seller), :class=>"btn btn-icon-only default", :title=>"Desactivar vendedor", data: { confirm: '¿Esta seguro de desactivar el vendedor?', method: 'post'}  do %>
+														<%= link_to seller_update_status_path(seller), :class=>"btn btn-icon-only default", title: "Desactivar vendedor", data: { confirm: '¿Esta seguro de desactivar el vendedor?', method: 'post' } do %>
 															<i class="fa fa-toggle-off"></i>
 														<% end %>
 													<% elsif seller.inactive? %>
-														<%= link_to seller_update_status_path(seller), :class=>"btn btn-icon-only green-jungle", :title=>"Activar vendedor", data: { confirm: '¿Esta seguro de activar el vendedor?', method: 'post'}  do %>
+														<%= link_to seller_update_status_path(seller), :class=>"btn btn-icon-only green-jungle", title: "Activar vendedor", data: { confirm: '¿Esta seguro de activar el vendedor?', method: 'post' } do %>
 															<i class="fa fa-toggle-on"></i>
 														<% end %>
 													<% end %>
 												<% end %>
 												<% if can? :destroy, Seller %>
-													<%= link_to seller , method: :delete, :class => "btn btn-icon-only btn-danger", :title=>"Eliminar vendedor", data: { confirm: '¿Esta seguro de eliminar al vendedor?'}   do %>
+													<%= link_to seller, method: :delete, :class => "btn btn-icon-only btn-danger", title: "Eliminar vendedor", data: { confirm: '¿Esta seguro de eliminar al vendedor?'} do %>
 														<i class="fa fa-trash-o"></i>
 													<% end %>
 												<% end %>

+ 0 - 52
app/views/sellers/new.html.erb

@@ -1,52 +0,0 @@
-<!-- BEGIN CONTAINER -->
-<div class="page-container">
-	<!-- BEGIN CONTENT -->
-	<div class="page-content-wrapper">
-		<!-- BEGIN CONTENT BODY -->
-		<!-- BEGIN PAGE HEAD-->
-		<div class="page-head">
-			<div class="container-fluid">
-				<!-- BEGIN PAGE TITLE -->
-				<div class="page-title">
-					<h1>Vendedores</h1>
-				</div>
-				<!-- END PAGE TITLE -->
-			</div>
-		</div>
-		<!-- END PAGE HEAD-->
-		<!-- BEGIN PAGE CONTENT BODY -->
-		<div class="page-content">
-			<div class="container-fluid">
-                <%= link_to sellers_path(:filter => @filter, :current_page => @current_page), {:class=>"btn blue-hoki pull-right margin-bottom-10"} do %> <i class="fa fa-angle-left "></i> Regresar
-				<% end %>
-				<!-- BEGIN PAGE BREADCRUMBS -->
-				<ul class="page-breadcrumb breadcrumb">
-					<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
-				</ul>
-				<!-- END PAGE BREADCRUMBS -->
-				<!-- BEGIN PAGE CONTENT INNER -->
-				<div class="page-content-inner">
-					<div id="notice"><%= notice %></div>
-					<div class="row ">
-						<div class="col-md-12">
-							<div class="portlet light">
-								<div class="portlet-title">
-									<div class="caption">
-										<i class="fa fa-plus font-green"></i>
-										<span class="caption-subject font-green bold uppercase">Nuevo Vendedor</span>
-									</div>
-								</div>
-								<%= render 'form' %>
-							</div>
-						</div>
-					</div>
-				</div>
-				<!-- END PAGE CONTENT INNER -->
-			</div>
-		</div>
-		<!-- END PAGE CONTENT BODY -->
-		<!-- END CONTENT BODY -->
-	</div>
-	<!-- END CONTENT -->
-</div>
-<!-- END CONTAINER -->

+ 14 - 0
app/views/sellers/new.js.erb

@@ -0,0 +1,14 @@
+$('#dialog h3.modal-title').html("Nuevo vendedor");
+$('#dialog').removeClass('modal-lg');
+$('.modal-footer').remove();
+$('.modal-body').html(""); //limpiar el modal antes; la siguiente linea es por si se abrio previamente el detalle de venta
+$('.modal-dialog').removeClass('modal-lg');
+// Rend$( ".selector" ).dialog({ closeOnEscape: false });er the edit form
+$('.modal-body').html('<%= j render("form") %>');
+// Show the dynamic dialog
+$('#dialog').modal("show");
+
+// Set focus to the first element
+$('#dialog').on('shown.bs.modal', function () {
+  $('.first_input').focus();
+});

+ 11 - 0
app/views/sellers/update.js.erb

@@ -0,0 +1,11 @@
+$("#seller_errors").html("");
+<% if @seller.errors.any? %>
+  $('#seller_errors').removeClass('hidden');
+  <% @seller.errors.values.each do |message| %>
+    $("#seller_errors").append($("<li />").html("<%= message.first.to_s %>"));
+  <% end %>
+<% else %>
+  $('#dialog').modal('toggle');
+  window.location = "<%= sellers_path %>";
+  $("#notice").html("<%= flash[:notice] %>");
+<% end %>

+ 87 - 97
app/views/special_prices/_form.html.erb

@@ -1,92 +1,84 @@
-<%= form_for(@special_price, :remote => true, :html => {:class=>"form-horizontal"}) do |f| %>
-<div class="portlet-body form">
-   <div id="error_explanation"></div>
-  <div class="form-body">
-    <div class="row">
-      <div class="col-md-12">
-        <!-- cliente -->
-
-        <div class="note note-success">
-          <h4 class="block">Instrucciones:</h4>
-          <p> Al seleccionar un cliente se mostrará en la tabla los productos que tiene asignados con precio especial.</br>
-          Tras buscar y seleccionar un producto, se agrega automaticamente al cliente y se debe asignar ya sea el precio o el porcentaje de descuento que tendra al momento de la venta.</p>
-        </div>
-        <div class="form-group">
-            <%= f.label :customer_id, "Cliente", {:class=>"col-md-2 control-label"} do %> Cliente
-            <span class="required">*</span>
-            <% end %>
+<%= form_for(@special_price, remote: true, html: { class: "form-horizontal" }) do |f| %>
+  <div class="portlet-body form">
+    <div id="error_explanation"></div>
+    <div class="form-body">
+      <div class="row">
+        <div class="col-md-12">
+          <!-- cliente -->
+          <div class="note note-success">
+            <h4 class="block">Instrucciones:</h4>
+            <p> Al seleccionar un cliente se mostrará en la tabla los productos que tiene asignados con precio especial.</br>
+            Tras buscar y seleccionar un producto, se agrega automaticamente al cliente y se debe asignar ya sea el precio o el porcentaje de descuento que tendra al momento de la venta.</p>
+          </div>
+          <div class="form-group">
+            <%= f.label :customer_id, "Cliente", { class: "col-md-2 control-label" } do %> Cliente <span class="required">*</span> <% end %>
             <div class="input-group col-md-5 select2-bootstrap-prepend">
-              <%= f.collection_select :customer_id, Customer.vigentes, :id, :nick_name, {:prompt => "Seleccione"}, {:class => "form-control select2", :disabled => @disabled_select} %>
-              <%= f.hidden_field :customer_id, {:id => 'customer'} %>
-              <%= f.hidden_field :product_id, {:id => 'product'} %>
+              <%= f.collection_select :customer_id, Customer.vigentes, :id, :nick_name, { prompt: "Seleccione" }, { class: "form-control select2", disabled: @disabled_select} %>
+              <%= f.hidden_field :customer_id, { id: 'customer' } %>
+              <%= f.hidden_field :product_id, { id: 'product' } %>
             </div>
           </div>
         </div>
-        <!-- agregar productos -->
-        <h4 class="form-section"> Agregar producto</h4>
-
-        <div class="row">
-
-          <div class='col-md-12'>
-
-            <div class="form-group">
-              <%= label_tag 'destiny', {:class=>"col-md-2 control-label"} do %> ¿El producto tiene variantes?
-              <span class="required">*</span>
-              <% end %>
-              <div class="col-md-3" style="padding-left:0px;padding-right:0px">
-                <%= check_box_tag('product_has_variants', 'no', false,
-                  {
-                    class: "make-switch",
-                    disabled: false,
-                    data: {
-                      on_color: "success",
-                      off_color: "warning",
-                      on_text: "SI",
-                      off_text: "NO"
-                    }
-                  }) %>
+          <!-- agregar productos -->
+          <h4 class="form-section"> Agregar producto</h4>
+          <div class="row">
+            <div class='col-md-12'>
+              <div class="form-group">
+                <%= label_tag 'destiny', { class: "col-md-2 control-label" } do %> ¿El producto tiene variantes? <span class="required">*</span> <% end %>
+                <div class="col-md-3" style="padding-left:0px;padding-right:0px">
+                  <%= check_box_tag('product_has_variants', 'no', false,
+                    {
+                      class: "make-switch",
+                      disabled: false,
+                      data: {
+                        on_color: "success",
+                        off_color: "warning",
+                        on_text: "SI",
+                        off_text: "NO"
+                      }
+                    }) %>
+                </div>
               </div>
-            </div>
-
-            <div class="form-group">
-              <label class="col-md-2 control-label" for="typeahead"> Producto
-                <span class="required">*</span>
-              </label>
-              <div class="col-md-4" style="padding-left:0px">
-                <input class="form-control" type="text" id="typeahead" data-option-url="/URL/%QUERY">
+              <div class="form-group">
+                <label class="col-md-2 control-label" for="typeahead"> Producto
+                  <span class="required">*</span>
+                </label>
+                <div class="col-md-4" style="padding-left:0px">
+                  <input class="form-control" type="text" id="typeahead" data-option-url="/URL/%QUERY">
+                </div>
+                <button id="products_new" disabled class="btn btn-success" type="button" onclick="addRow()"> Agregar <i class="fa fa-plus"></i> </button>
+              </div>
+              <div class="alert alert-info col-md-offset-2 col-md-8">
+                <strong>Aviso:</strong> Para agregar un producto a la lista puede escanear su código de barras o buscar por nombre o SKU.
               </div>
-              <button id="products_new" disabled class="btn btn-success" type="button" onclick="addRow()"> Agregar <i class="fa fa-plus"></i> </button>
-            </div>
-            <div class="alert alert-info col-md-offset-2 col-md-8">
-              <strong>Aviso:</strong> Para agregar un producto a la lista puede scannear su código de barras ó buscar por nombre o SKU.
             </div>
           </div>
-        </div>
-        <!-- lista de productos -->
-        <h4 class="form-section"> Lista de productos</h4>
-        <div class="portlet-body">
-          <table class="table table-striped table-bordered table-hover tableadvanced" id="products_table">
-            <thead>
-              <tr>
-                <th>#</th>
-                <th>SKU</th>
-                <th>Producto</th>
-                <th>Imagen</th>
-                <th>Precio de venta</th>
-                <th>Descuento en cantidad</th>
-                <th>% de descuento</th>
-                <th width="15%">Acciones</th>
-              </tr>
-            </thead>
-            <tbody>
-            </tbody>
-          </table>
+          <!-- lista de productos -->
+          <h4 class="form-section"> Lista de productos</h4>
+          <div class="portlet-body">
+            <table class="table table-striped table-bordered table-hover tableadvanced" id="products_table">
+              <thead>
+                <tr>
+                  <th>#</th>
+                  <th>SKU</th>
+                  <th>Producto</th>
+                  <th>Imagen</th>
+                  <th>Precio de venta</th>
+                  <th>Descuento en cantidad</th>
+                  <th>% de descuento</th>
+                  <th width="15%">Acciones</th>
+                </tr>
+              </thead>
+              <tbody>
+              </tbody>
+            </table>
+          </div>
         </div>
       </div>
     </div>
   </div>
-</div>
 <% end %>
+
 <script type="text/javascript">
 
   var selectedProduct;
@@ -94,7 +86,6 @@
 
   $(document).on("page:change", function() {
     App.init();
-
   });
 
   $('body').barcodeListener().on('barcode.valid', function(e, code) {
@@ -104,11 +95,11 @@
   $('#special_price_customer_id').on('change', function() {
     $('#customer').val($(this).val());
     $.ajax({
-        type: "GET",
-        url: "/get_special_price_by_customer/" + $(this).val(),
-        dataType: "script",
-        success: function(xhr, status, error) {
-        }
+      type: "GET",
+      url: "/get_special_price_by_customer/" + $(this).val(),
+      dataType: "script",
+      success: function(xhr, status, error) {
+      }
     });
   });
 
@@ -198,13 +189,13 @@
           toastr["error"]("El descuento no puede ser mayor al precio de venta del producto.");
         } else {
           $.ajax({
-              type: "PUT",
-              url: "/special_prices/" + specialPriceId,
-              dataType: "json",
-              data: {special_price: {price: newPrice}},
-              success: function(xhr, status, error) {
-                toastr["success"]("Precio especial actualizado.");
-              }
+            type: "PUT",
+            url: "/special_prices/" + specialPriceId,
+            dataType: "json",
+            data: {special_price: {price: newPrice}},
+            success: function(xhr, status, error) {
+              toastr["success"]("Precio especial actualizado.");
+            }
           });
         }
       }, 300);
@@ -215,7 +206,6 @@
     if(input.val()) {
       clearTimeout(timeout);
       timeout = setTimeout(function () {
-
         var idText = input.closest('tr').attr('id');
         var specialPriceId = idText.substring(idText.lastIndexOf('_') + 1, idText.length);
         input.closest('tr').find('td:eq(5) input').val("");
@@ -224,13 +214,13 @@
           toastr["error"]("El porcentaje de descuento no puede ser mayor a 100%");
         } else {
           $.ajax({
-              type: "PUT",
-              url: "/special_prices/" + specialPriceId,
-              dataType: "json",
-              data: {special_price: {percent: input.val()}},
-              success: function(xhr, status, error) {
-                toastr["success"]("Precio especial actualizado.");
-              }
+            type: "PUT",
+            url: "/special_prices/" + specialPriceId,
+            dataType: "json",
+            data: {special_price: {percent: input.val()}},
+            success: function(xhr, status, error) {
+              toastr["success"]("Precio especial actualizado.");
+            }
           });
         }
       }, 300);

+ 27 - 27
app/views/transfers/_form.html.erb

@@ -19,17 +19,17 @@
         <!-- fecha -->
         <div class="form-group">
           <%= f.label :transfer_date, "Fecha", {:class=>"col-md-3 control-label"} do %> Fecha
-          <span class="required">*</span>
+            <span class="required">*</span>
           <% end %>
-            <%= f.hidden_field :transfer_date, {:value=>Date.today} %>
-              <div class="col-sm-6" style="padding-left:0px;padding-right:0px;">
-                  <div class='input-group date' id='datetimepicker1'>
-                      <input type='text' class="form-control" disabled/>
-                      <span class="input-group-addon">
-                          <span class="glyphicon glyphicon-calendar"></span>
-                      </span>
-                  </div>
-              </div>
+          <%= f.hidden_field :transfer_date, { value: Date.today } %>
+          <div class="col-sm-6" style="padding-left:0px;padding-right:0px;">
+            <div class='input-group date' id='datetimepicker1'>
+              <input type='text' class="form-control" disabled/>
+              <span class="input-group-addon">
+                <span class="glyphicon glyphicon-calendar"></span>
+              </span>
+            </div>
+          </div>
         </div>
         <!-- origen -->
         <div class="form-group">
@@ -144,8 +144,8 @@
       url: "/find_from_stock_by_pointsale?pointsale_id=ID&query=%QUERY",
       wildcard: '%QUERY',
       replace: function(url, uriEncodedQuery) {
-          origin = $('#origin_id').val();
-          return url.replace('ID', origin).replace('%QUERY', uriEncodedQuery)
+        origin = $('#origin_id').val();
+        return url.replace('ID', origin).replace('%QUERY', uriEncodedQuery)
       }
     }
   });
@@ -240,12 +240,12 @@
   function deletePreTransfers() {
     $.ajax({
       type: "get",
-      url:  '/delete_pre_transfers',
+      url: '/delete_pre_transfers',
       dataType: 'json',
       success: function(xhr, status, error){
         $('#products_table').dataTable().fnClearTable();
         $("#transfer_destiny_id").select2().select2("val", null);
-        <% if current_user.usertype == 'A' %>
+        <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
           $("#transfer_origin_id").attr('disabled', false);
           $("#transfer_origin_id").select2().select2("val", null);
         <% end %>
@@ -262,19 +262,19 @@
         var idText = input.closest('tr').attr('id');
         var preTransferId = idText.substring(idText.lastIndexOf('_') + 1, idText.length);
         $.ajax({
-            type: "PUT",
-            url: "/pre_transfers/" + preTransferId,
-            dataType: "json",
-            data: {pre_transfer: {quantity: input.val()}},
-            success: function(xhr, status, error) {
-              $("#save_transfer").attr("disabled", false);
-            },
-            statusCode: {
-              422: function() {
-                $("#save_transfer").attr("disabled", true);
-                toastr["error"]("Error, El stock es insuficiente.");
-              }
+          type: "PUT",
+          url: "/pre_transfers/" + preTransferId,
+          dataType: "json",
+          data: {pre_transfer: {quantity: input.val()}},
+          success: function(xhr, status, error) {
+            $("#save_transfer").attr("disabled", false);
+          },
+          statusCode: {
+            422: function() {
+              $("#save_transfer").attr("disabled", true);
+              toastr["error"]("Error, El stock es insuficiente.");
             }
+          }
         });
       }, 700);
     } else {
@@ -289,7 +289,7 @@
     if((origin && destiny) && (origin != destiny)) {
       $.ajax({
         type: "get",
-        url:  '/add_pre_transfer_by_barcode/' + barcode + "/" + origin + "/" + destiny,
+        url: '/add_pre_transfer_by_barcode/' + barcode + "/" + origin + "/" + destiny,
         dataType: 'script',
         success: function(data) {
         },

+ 1 - 1
app/views/transfers/index.html.erb

@@ -48,7 +48,7 @@
                   </div>
                 </div>
                 <div class="portlet-body">
-                    <% if current_user.usertype == "A" %>
+                    <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
                       <%= render partial: 'transfers/index_for_admin' %>
                     <% elsif current_user.usertype == "C" %>
                       <%= render partial: 'transfers/index_for_cashier' %>

+ 1 - 1
app/views/transfers/new.html.erb

@@ -17,7 +17,7 @@
 		<!-- BEGIN PAGE CONTENT BODY -->
 		<div class="page-content">
 			<div class="container-fluid">
-                <%= link_to transfers_path(:filter => @filter, :current_page => @current_page), {:class=>"btn blue-hoki pull-right margin-bottom-10"} do %> <i class="fa fa-angle-left "></i> Regresar
+        <%= link_to transfers_path(:filter => @filter, :current_page => @current_page), {:class=>"btn blue-hoki pull-right margin-bottom-10"} do %> <i class="fa fa-angle-left "></i> Regresar
 				<% end %>
 				<!-- BEGIN PAGE BREADCRUMBS -->
 				<ul class="page-breadcrumb breadcrumb">

+ 2 - 2
app/views/units/update.js.erb

@@ -1,8 +1,8 @@
 $("#errors").html("");
 <% if @unit.errors.any? %>
-  $('#unit').removeClass('hidden');
+  $('#errors').removeClass('hidden');
   <% @unit.errors.values.each do |message| %>
-    $("#unit").append($("<li />").html("<%= message.first.to_s %>"));
+    $("#errors").append($("<li />").html("<%= message.first.to_s %>"));
   <% end %>
 <% else %>
   $('#dialog').modal('toggle');

+ 22 - 36
app/views/users/_form.html.erb

@@ -1,5 +1,5 @@
 <div id="form_wizard_1">
-	<%= form_for(@user, :html => {:class=>"form-horizontal", :id=> "submit_form"}) do |f| %>
+	<%= form_for(@user, html: { class: "form-horizontal", id: "submit_form" }) do |f| %>
 		<div class="portlet-body form">
 			<% if @user.errors.any? %>
 				<div class="alert alert-danger">
@@ -49,54 +49,45 @@
 							<h3 class="block">Proporciona la información de la cuenta de usuario</h3>
 							<div id="error_explanation"></div>
 							<div class="form-group">
-								<%= f.label :usertype, "", {:class=>"col-md-3 control-label"} do %> Tipo de usuario
-									<span class="required">*</span><% end %>
+								<%= f.label :usertype, "", { class: "col-md-3 control-label" } do %> Tipo de usuario <span class="required">*</span> <% end %>
 								<div class="col-md-4">
-									<%= f.select :usertype, (current_user.usertype=="A" ? Rails.application.config.usertypes_for_admin : Rails.application.config.usertypes_for_manager), {:prompt => "Seleccione"}, { :class => 'form-control select2' } %>
+									<%= f.select :usertype, (@options_for_select), { prompt: "Seleccione" }, { class: 'form-control select2' } %>
 								</div>
 							</div>
 							<div class="form-group hidden" id="pointsale_div">
-								<%= f.label :pointsale_id, "", {:class=>"col-md-3 control-label"} do %> Punto de venta
-									<span class="required">*</span><% end %>
+								<%= f.label :pointsale_id, "", {:class=>"col-md-3 control-label"} do %> Punto de venta <span class="required">*</span> <% end %>
 								<div class="col-md-4">
-									<%= f.collection_select :pointsale_id, Pointsale.activos, :id, :name, {:prompt => "Seleccione", :selected => (current_user.usertype == 'G' ? current_user.pointsale_id : @user.pointsale_id) }, {:class => "form-control select2",
-										:disabled => (true if current_user.usertype == 'G')  } %>
-									<%= f.hidden_field :pointsale_id, :value => (current_user.usertype == 'G' ? current_user.pointsale_id : @user.pointsale_id), :id => 'pointsale_id' %>
+									<%= f.collection_select :pointsale_id, Pointsale.activos, :id, :name, { prompt: "Seleccione", selected: (current_user.usertype == 'G' ? current_user.pointsale_id : @user.pointsale_id) }, { class: "form-control select2",
+										disabled: (true if current_user.usertype == 'G') } %>
+									<%= f.hidden_field :pointsale_id, value: (current_user.usertype == 'G' ? current_user.pointsale_id : @user.pointsale_id), id: 'pointsale_id' %>
 								</div>
 							</div>
-							<% if current_user.usertype == "A" %>
+							<% if current_user.usertype == "A" || current_user.usertype == "SS" %>
 								<div class="form-group hidden" id="warehouse_div">
-									<%= f.label :warehouse_id, "", {:class=>"col-md-3 control-label"} do %> Almacen
-										<span class="required">*</span><% end %>
+									<%= f.label :warehouse_id, "", { class: "col-md-3 control-label" } do %> Almacén <span class="required">*</span> <% end %>
 									<div class="col-md-4">
-										<%= f.collection_select :warehouse_id, Warehouse.activos, :id, :name, {:prompt => "Seleccione"}, {:class => "form-control select2" } %>
+										<%= f.collection_select :warehouse_id, Warehouse.activos, :id, :name, { prompt: "Seleccione" }, { class: "form-control select2" } %>
 									</div>
 								</div>
 							<% end %>
 							<div class="form-group">
-								<%= f.label :userid, "Nombre de usuario", {:class=>"col-md-3 control-label"} do %> Usuario
-									<span class="required">*</span>
-								<% end %>
+								<%= f.label :userid, "Nombre de usuario", { class: "col-md-3 control-label" } do %> Usuario <span class="required">*</span> <% end %>
 								<div class="col-md-4">
-									<%= f.text_field :userid, {:class=>"form-control", :disabled => @user.persisted?} %>
+									<%= f.text_field :userid, { class: "form-control", disabled: @user.persisted? } %>
 									<span class="help-block"> El usuario no debe de contener espacios. </span>
 								</div>
 							</div>
 							<% unless @user.persisted? %>
 								<div class="form-group">
-									<%= f.label :password, "Contraseña", {:class=>"col-md-3 control-label"} do %> Contraseña
-										<span class="required">*</span>
-									<% end %>
+									<%= f.label :password, "Contraseña", { class: "col-md-3 control-label" } do %> Contraseña <span class="required">*</span> <% end %>
 									<div class="col-md-4">
-										<%= f.password_field :password, {:class=>"form-control"} %>
+										<%= f.password_field :password, { class: "form-control"} %>
 									</div>
 								</div>
 								<div class="form-group">
-									<%= f.label :password_confirmation, "Confirmar contraseña", {:class=>"col-md-3 control-label"} do %> Confirmar Contraseña
-										<span class="required">*</span>
-									<% end %>
+									<%= f.label :password_confirmation, "Confirmar contraseña", { class: "col-md-3 control-label" } do %> Confirmar Contraseña <span class="required">*</span> <% end %>
 									<div class="col-md-4">
-										<%= f.password_field :password_confirmation, {:class=>"form-control"} %>
+										<%= f.password_field :password_confirmation, { class: "form-control" } %>
 									</div>
 								</div>
 							<% end %>
@@ -104,28 +95,23 @@
 						<div class="tab-pane" id="tab2">
 							<h3 class="block">Proporciona los datos particulares del usuario</h3>
 							<div class="form-group">
-								<%= f.label :first_name, "Nombre", {:class=>"col-md-3 control-label"} do %> Nombre
-									<span class="required">*</span>
-								<% end %>
+								<%= f.label :first_name, "Nombre", { class: "col-md-3 control-label" } do %> Nombre <span class="required">*</span> <% end %>
 								<div class="col-md-4">
-									<%= f.text_field :first_name, {:class=>"form-control"} %>
+									<%= f.text_field :first_name, { class: "form-control" } %>
 								</div>
 							</div>
 							<div class="form-group">
-								<%= f.label :last_name, "Apellidos", {:class=>"col-md-3 control-label"} do %> Apellidos
-									<span class="required">*</span>
-								<% end %>
+								<%= f.label :last_name, "Apellidos", { class: "col-md-3 control-label" } do %> Apellidos <span class="required">*</span> <% end %>
 								<div class="col-md-4">
-									<%= f.text_field :last_name, {:class=>"form-control"} %>
+									<%= f.text_field :last_name, { class: "form-control" } %>
 								</div>
 							</div>
 							<div class="form-group">
-								<%= f.label :email, "Correo", {:class=>"col-md-3 control-label"} do %> Correo electrónico <span class="required">*</span>
-								<% end %>
+								<%= f.label :email, "Correo", { class: "col-md-3 control-label" } do %> Correo electrónico <span class="required">*</span> <% end %>
 								<div class="col-md-4">
 									<div class="input-icon">
 										<i class="fa fa-envelope"></i>
-										<%= f.text_field :email, {:class=>"form-control", :placeholder=>"ejemplo@correo.com" } %>
+										<%= f.text_field :email, { class: "form-control", placeholder: "ejemplo@correo.com" } %>
 									</div>
 								</div>
 							</div>

+ 0 - 0
app/views/users/index.html.erb


Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov