Signed-off-by: Adrian Hinz <ahinz@voicetelecom.pl>
This commit is contained in:
parent
6448fc0281
commit
a5e543d298
|
|
@ -420,6 +420,7 @@ body {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
.login-wrapper .box input[type="email"],
|
||||||
.login-wrapper .box input[type="text"],
|
.login-wrapper .box input[type="text"],
|
||||||
.login-wrapper .box input[type="password"] {
|
.login-wrapper .box input[type="password"] {
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
|
|
@ -429,6 +430,7 @@ body {
|
||||||
padding-left: 12px;
|
padding-left: 12px;
|
||||||
}
|
}
|
||||||
.login-wrapper .box input[type="text"]:focus,
|
.login-wrapper .box input[type="text"]:focus,
|
||||||
|
.login-wrapper .box input[type="email"]:focus,
|
||||||
.login-wrapper .box input[type="password"]:focus {
|
.login-wrapper .box input[type="password"]:focus {
|
||||||
border: 1px solid #28a0e5;
|
border: 1px solid #28a0e5;
|
||||||
outline: none;
|
outline: none;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
class CustomersController < ApplicationController
|
class CustomersController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@customers = Customer.all
|
@customers = Customer.where(user_id: current_user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
@ -10,6 +10,7 @@ class CustomersController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@customer = Customer.new(customer_params)
|
@customer = Customer.new(customer_params)
|
||||||
|
@customer.user_id = current_user.id
|
||||||
if @customer.save
|
if @customer.save
|
||||||
redirect_to customers_path
|
redirect_to customers_path
|
||||||
else
|
else
|
||||||
|
|
@ -23,7 +24,7 @@ class CustomersController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@customer = Customer.find(params[:id])
|
@customer = Customer.find(params[:id])
|
||||||
|
@customer.user_id = current_user.id
|
||||||
if @customer.update(customer_params)
|
if @customer.update(customer_params)
|
||||||
redirect_to customers_path
|
redirect_to customers_path
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ class Customer < ApplicationRecord
|
||||||
validates :city, presence: true, length: { minimum: 3 }
|
validates :city, presence: true, length: { minimum: 3 }
|
||||||
validates :nip, presence: true, length: {minimum: 13}
|
validates :nip, presence: true, length: {minimum: 13}
|
||||||
|
|
||||||
|
belongs_to :user
|
||||||
|
|
||||||
def adress
|
def adress
|
||||||
self.street + "; " + self.postcode + " " + self.city
|
self.street + "; " + self.postcode + " " + self.city
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
class Product < ApplicationRecord
|
class Product < ApplicationRecord
|
||||||
belongs_to :vat
|
belongs_to :vat
|
||||||
|
belongs_to :user
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,8 @@ class User < ApplicationRecord
|
||||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||||
devise :database_authenticatable, :registerable,
|
devise :database_authenticatable, :registerable,
|
||||||
:recoverable, :rememberable, :trackable, :validatable
|
:recoverable, :rememberable, :trackable, :validatable
|
||||||
|
|
||||||
|
has_many :user_firms
|
||||||
|
has_many :products
|
||||||
|
has_many :customers
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<%= form_for @customer do |f| %>
|
|
||||||
|
<%= form_for @customer, html: {class: "form-horizontal"} do |f| %>
|
||||||
<% if @customer.errors.any? %>
|
<% if @customer.errors.any? %>
|
||||||
<div id="error_explanation">
|
<div id="error_explanation">
|
||||||
<h2>
|
<h2>
|
||||||
|
|
@ -12,32 +13,45 @@
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<p>
|
<div class="form-group">
|
||||||
<%= f.label :name %><br>
|
<%= f.label :name, class: "col-sm-2 control-label" %>
|
||||||
<%= f.text_field :name %>
|
<div class="col-sm-10">
|
||||||
</p>
|
<%= f.text_field :name, class: "form-control", placeholder: 'Nazwa' %>
|
||||||
<p>
|
</div>
|
||||||
<%= f.label :street %><br>
|
</div>
|
||||||
<%= f.text_field :street %>
|
<div class="form-group">
|
||||||
</p>
|
<%= f.label :street, class: "col-sm-2 control-label" %>
|
||||||
<p>
|
<div class="col-sm-10">
|
||||||
<%= f.label :postcode %><br>
|
<%= f.text_field :street, class: "form-control", placeholder: 'Ulica' %>
|
||||||
<%= f.text_field :postcode %>
|
</div>
|
||||||
</p>
|
</div>
|
||||||
<p>
|
<div class="form-group">
|
||||||
<%= f.label :city %><br>
|
<%= f.label :postcode, class: "col-sm-2 control-label" %>
|
||||||
<%= f.text_field :city %>
|
<div class="col-sm-10">
|
||||||
</p>
|
<%= f.text_field :postcode, class: "form-control", placeholder: 'Kod pocztowy' %>
|
||||||
<p>
|
</div>
|
||||||
<%= f.label :nip %><br>
|
</div>
|
||||||
<%= f.text_field :nip %>
|
<div class="form-group">
|
||||||
</p>
|
<%= f.label :city, class: "col-sm-2 control-label" %>
|
||||||
<p>
|
<div class="col-sm-10">
|
||||||
<%= f.label :regon %><br>
|
<%= f.text_field :city, class: "form-control", placeholder: 'Miasto' %>
|
||||||
<%= f.text_field :regon %>
|
</div>
|
||||||
</p>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
<p>
|
<%= f.label :nip, class: "col-sm-2 control-label" %>
|
||||||
<%= f.submit %>
|
<div class="col-sm-10">
|
||||||
</p>
|
<%= f.text_field :nip, class: "form-control", placeholder: 'NIP' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<%= f.label :regon, class: "col-sm-2 control-label" %>
|
||||||
|
<div class="col-sm-10">
|
||||||
|
<%= f.text_field :regon, class: "form-control", placeholder: 'Regon' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
|
<%= f.submit 'Zapisz', class: "btn btn-primary" %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,13 @@
|
||||||
<h1>Edycja klienta</h1>
|
<div class="col-lg-8 col-md-12">
|
||||||
<%= link_to 'Powrot', customers_path %><br/>
|
<div class="content-box-large">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<div class="panel-title">Edycja klienta</div>
|
||||||
|
<div class="panel-options">
|
||||||
|
<%= link_to raw("<i class=\"glyphicon glyphicon-arrow-left\"></i> Powrot"), customers_path, title: 'Powrot' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
<%= render 'form' %>
|
<%= render 'form' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,13 @@
|
||||||
<h1>Nowy klient</h1>
|
<div class="col-lg-8 col-md-12">
|
||||||
<%= link_to 'Powrot', customers_path %><br/>
|
<div class="content-box-large">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<div class="panel-title">Nowy klient</div>
|
||||||
|
<div class="panel-options">
|
||||||
|
<%= link_to raw("<i class=\"glyphicon glyphicon-arrow-left\"></i> Powrot"), customers_path, title: 'Powrot' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body">
|
||||||
<%= render 'form' %>
|
<%= render 'form' %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,17 @@
|
||||||
<h2>Log in</h2>
|
<%# render "devise/shared/links" %>
|
||||||
|
|
||||||
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
|
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
|
||||||
<div class="field">
|
<div class="col-md-4 col-md-offset-4">
|
||||||
<%= f.label :email %><br />
|
<div class="login-wrapper">
|
||||||
<%= f.email_field :email, autofocus: true %>
|
<div class="box">
|
||||||
|
<div class="content-wrap">
|
||||||
|
<h6>Logowanie</h6>
|
||||||
|
<%= f.email_field :email, autofocus: true, class: 'form-control', placeholder: 'E-mail' %>
|
||||||
|
<%= f.password_field :password, autocomplete: "off", class: 'form-control', placeholder: 'Hasło' %>
|
||||||
|
<div class="action">
|
||||||
|
<%= f.submit "Zaloguj", class: "btn btn-primary signup" %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
|
||||||
<%= f.label :password %><br />
|
|
||||||
<%= f.password_field :password, autocomplete: "off" %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if devise_mapping.rememberable? -%>
|
|
||||||
<div class="field">
|
|
||||||
<%= f.check_box :remember_me %>
|
|
||||||
<%= f.label :remember_me %>
|
|
||||||
</div>
|
</div>
|
||||||
<% end -%>
|
|
||||||
|
|
||||||
<div class="actions">
|
|
||||||
<%= f.submit "Log in" %>
|
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= render "devise/shared/links" %>
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>FireStorm - Faktury</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<%= csrf_meta_tags %>
|
||||||
|
|
||||||
|
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||||
|
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
||||||
|
</head>
|
||||||
|
<body class="login-bg">
|
||||||
|
<div class="header">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<!-- Logo -->
|
||||||
|
<div class="logo">
|
||||||
|
<h1><a href="index.html">FireStorm - Faktury</a></h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="page-content container">
|
||||||
|
<div class="row">
|
||||||
|
<%= yield %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddUserToProducts < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
add_reference :products, :user, foreign_key: true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddUserToCustomers < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
add_reference :customers, :user, foreign_key: true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20161003081718) do
|
ActiveRecord::Schema.define(version: 20161003103325) do
|
||||||
|
|
||||||
create_table "customers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
|
create_table "customers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
|
|
@ -21,6 +21,8 @@ ActiveRecord::Schema.define(version: 20161003081718) do
|
||||||
t.string "regon"
|
t.string "regon"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
|
t.integer "user_id"
|
||||||
|
t.index ["user_id"], name: "index_customers_on_user_id", using: :btree
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "products", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
|
create_table "products", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci" do |t|
|
||||||
|
|
@ -30,6 +32,8 @@ ActiveRecord::Schema.define(version: 20161003081718) do
|
||||||
t.string "qnt_name"
|
t.string "qnt_name"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
|
t.integer "user_id"
|
||||||
|
t.index ["user_id"], name: "index_products_on_user_id", using: :btree
|
||||||
t.index ["vat_id"], name: "index_products_on_vat_id", using: :btree
|
t.index ["vat_id"], name: "index_products_on_vat_id", using: :btree
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -75,6 +79,8 @@ ActiveRecord::Schema.define(version: 20161003081718) do
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_foreign_key "customers", "users"
|
||||||
|
add_foreign_key "products", "users"
|
||||||
add_foreign_key "products", "vats"
|
add_foreign_key "products", "vats"
|
||||||
add_foreign_key "user_firms", "users"
|
add_foreign_key "user_firms", "users"
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue