Signed-off-by: Adrian Hinz <ahinz@voicetelecom.pl>

This commit is contained in:
Adrian Hinz 2016-10-03 14:50:49 +02:00
parent 6448fc0281
commit a5e543d298
13 changed files with 153 additions and 74 deletions

View File

@ -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;
}
}
}
}

View File

@ -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

View File

@ -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

View File

@ -1,3 +1,4 @@
class Product < ApplicationRecord
belongs_to :vat
belongs_to :user
end

View File

@ -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

View File

@ -1,4 +1,5 @@
<%= form_for @customer do |f| %>
<%= form_for @customer, html: {class: "form-horizontal"} do |f| %>
<% if @customer.errors.any? %>
<div id="error_explanation">
<h2>
@ -12,32 +13,45 @@
</ul>
</div>
<% end %>
<p>
<%= f.label :name %><br>
<%= f.text_field :name %>
</p>
<p>
<%= f.label :street %><br>
<%= f.text_field :street %>
</p>
<p>
<%= f.label :postcode %><br>
<%= f.text_field :postcode %>
</p>
<p>
<%= f.label :city %><br>
<%= f.text_field :city %>
</p>
<p>
<%= f.label :nip %><br>
<%= f.text_field :nip %>
</p>
<p>
<%= f.label :regon %><br>
<%= f.text_field :regon %>
</p>
<p>
<%= f.submit %>
</p>
<div class="form-group">
<%= f.label :name, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.text_field :name, class: "form-control", placeholder: 'Nazwa' %>
</div>
</div>
<div class="form-group">
<%= f.label :street, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.text_field :street, class: "form-control", placeholder: 'Ulica' %>
</div>
</div>
<div class="form-group">
<%= f.label :postcode, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.text_field :postcode, class: "form-control", placeholder: 'Kod pocztowy' %>
</div>
</div>
<div class="form-group">
<%= f.label :city, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.text_field :city, class: "form-control", placeholder: 'Miasto' %>
</div>
</div>
<div class="form-group">
<%= f.label :nip, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= 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 %>

View File

@ -1,4 +1,13 @@
<h1>Edycja klienta</h1>
<%= link_to 'Powrot', customers_path %><br/>
<%= render 'form' %>
<div class="col-lg-8 col-md-12">
<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' %>
</div>
</div>
</div>

View File

@ -1,4 +1,13 @@
<h1>Nowy klient</h1>
<%= link_to 'Powrot', customers_path %><br/>
<%= render 'form' %>
<div class="col-lg-8 col-md-12">
<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' %>
</div>
</div>
</div>

View File

@ -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| %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="field">
<%= f.label :password %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<% if devise_mapping.rememberable? -%>
<div class="field">
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
</div>
<% end -%>
<div class="actions">
<%= f.submit "Log in" %>
<div class="col-md-4 col-md-offset-4">
<div class="login-wrapper">
<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>
</div>
<% end %>
<%= render "devise/shared/links" %>

View File

@ -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>

View File

@ -0,0 +1,5 @@
class AddUserToProducts < ActiveRecord::Migration[5.0]
def change
add_reference :products, :user, foreign_key: true
end
end

View File

@ -0,0 +1,5 @@
class AddUserToCustomers < ActiveRecord::Migration[5.0]
def change
add_reference :customers, :user, foreign_key: true
end
end

View File

@ -10,7 +10,7 @@
#
# 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|
t.string "name"
@ -21,6 +21,8 @@ ActiveRecord::Schema.define(version: 20161003081718) do
t.string "regon"
t.datetime "created_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
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.datetime "created_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
end
@ -75,6 +79,8 @@ ActiveRecord::Schema.define(version: 20161003081718) do
t.datetime "updated_at", null: false
end
add_foreign_key "customers", "users"
add_foreign_key "products", "users"
add_foreign_key "products", "vats"
add_foreign_key "user_firms", "users"
end