diff --git a/app/assets/stylesheets/styles.css b/app/assets/stylesheets/styles.css index e8fc682..b1a2c66 100644 --- a/app/assets/stylesheets/styles.css +++ b/app/assets/stylesheets/styles.css @@ -224,7 +224,7 @@ footer .copy{ border-left:1px solid #eee; border-top:1px solid #eee; border-right:2px solid #eee; - border-bottom:2px solid #eee; + border-bottom:2px solid #eee; } .content-box-large { @@ -420,6 +420,7 @@ body { font-size: 18px; font-weight: 600; } +.login-wrapper .box input[type="email"], .login-wrapper .box input[type="text"], .login-wrapper .box input[type="password"] { font-size: 15px; @@ -429,6 +430,7 @@ body { padding-left: 12px; } .login-wrapper .box input[type="text"]:focus, +.login-wrapper .box input[type="email"]:focus, .login-wrapper .box input[type="password"]:focus { border: 1px solid #28a0e5; outline: none; @@ -486,8 +488,8 @@ body { background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6887c4), color-stop(100%,#4566a9)); background: -webkit-linear-gradient(top, #6887c4 0%,#4566a9 100%); background: -o-linear-gradient(top, #6887c4 0%,#4566a9 100%); - background: -ms-linear-gradient(top, #6887c4 0%,#4566a9 100%); - background: linear-gradient(to bottom, #6887c4 0%,#4566a9 100%); + background: -ms-linear-gradient(top, #6887c4 0%,#4566a9 100%); + background: linear-gradient(to bottom, #6887c4 0%,#4566a9 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6887c4', endColorstr='#4566a9',GradientType=0 ); border: 1px solid #3B4868; border-radius: 3px 3px 3px 3px; @@ -504,8 +506,8 @@ body { background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6887c4), color-stop(100%,#5773AC)); background: -webkit-linear-gradient(top, #6887c4 0%,#5773AC 100%); background: -o-linear-gradient(top, #6887c4 0%,#5773AC 100%); - background: -ms-linear-gradient(top, #6887c4 0%,#5773AC 100%); - background: linear-gradient(to bottom, #6887c4 0%,#5773AC 100%); + background: -ms-linear-gradient(top, #6887c4 0%,#5773AC 100%); + background: linear-gradient(to bottom, #6887c4 0%,#5773AC 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6887c4', endColorstr='#5773AC',GradientType=0 ); } .login-wrapper .box .social a.face_login span.face_icon{ @@ -595,7 +597,7 @@ body { .header{ height:auto; padding:15px 0px; - } + } .header .logo{ text-align:center; padding-bottom:10px; @@ -615,7 +617,7 @@ body { .header{ height:auto; padding:15px 0px; - } + } .header .logo{ text-align:center; padding-bottom:10px; @@ -628,7 +630,7 @@ body { width:100%; float:none; position:relative; - } + } .mainy{ margin-left: 0px; } @@ -648,5 +650,5 @@ body { border-bottom:0px; box-shadow:0px 0px 1px #0fa6bc; border-radius:10px; - } -} \ No newline at end of file + } +} diff --git a/app/controllers/customers_controller.rb b/app/controllers/customers_controller.rb index 76ae92b..6d6f369 100644 --- a/app/controllers/customers_controller.rb +++ b/app/controllers/customers_controller.rb @@ -1,7 +1,7 @@ class CustomersController < ApplicationController - + def index - @customers = Customer.all + @customers = Customer.where(user_id: current_user.id) end def new @@ -10,6 +10,7 @@ class CustomersController < ApplicationController def create @customer = Customer.new(customer_params) + @customer.user_id = current_user.id if @customer.save redirect_to customers_path else @@ -23,7 +24,7 @@ class CustomersController < ApplicationController def update @customer = Customer.find(params[:id]) - + @customer.user_id = current_user.id if @customer.update(customer_params) redirect_to customers_path else diff --git a/app/models/customer.rb b/app/models/customer.rb index 7c0e402..5d47d3e 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -5,6 +5,7 @@ class Customer < ApplicationRecord validates :city, presence: true, length: { minimum: 3 } validates :nip, presence: true, length: {minimum: 13} + belongs_to :user def adress self.street + "; " + self.postcode + " " + self.city diff --git a/app/models/product.rb b/app/models/product.rb index e72d315..f00671a 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -1,3 +1,4 @@ class Product < ApplicationRecord belongs_to :vat + belongs_to :user end diff --git a/app/models/user.rb b/app/models/user.rb index b2091f9..8fb58bd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,4 +3,8 @@ class User < ApplicationRecord # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable + + has_many :user_firms + has_many :products + has_many :customers end diff --git a/app/views/customers/_form.html.erb b/app/views/customers/_form.html.erb index e217424..317132d 100644 --- a/app/views/customers/_form.html.erb +++ b/app/views/customers/_form.html.erb @@ -1,4 +1,5 @@ -<%= form_for @customer do |f| %> + +<%= form_for @customer, html: {class: "form-horizontal"} do |f| %> <% if @customer.errors.any? %>
- <%= f.label :name %>
- <%= f.text_field :name %>
-
- <%= f.label :street %>
- <%= f.text_field :street %>
-
- <%= f.label :postcode %>
- <%= f.text_field :postcode %>
-
- <%= f.label :city %>
- <%= f.text_field :city %>
-
- <%= f.label :nip %>
- <%= f.text_field :nip %>
-
- <%= f.label :regon %>
- <%= f.text_field :regon %>
-
- <%= f.submit %> -
+