Signed-off-by: Adrian Hinz <ahinz@voicetelecom.pl>
This commit is contained in:
parent
9f515eb9d1
commit
c5fac2a54b
|
|
@ -1,4 +1,9 @@
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
before_action :set_locale
|
||||||
|
|
||||||
|
def set_locale
|
||||||
|
I18n.locale = params[:lang] || I18n.default_locale
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,45 @@
|
||||||
class ProductsController < ApplicationController
|
class ProductsController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@products = Product.where(user_id: current_user.id).order('name ASC')
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@product = Product.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@product = Product.new(product_params)
|
||||||
|
@product.user_id = current_user.id
|
||||||
|
if @product.save
|
||||||
|
redirect_to products_path
|
||||||
|
else
|
||||||
|
render :new
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@product = Product.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@product = Product.find(params[:id])
|
||||||
|
if @product.update_attributes(product_params)
|
||||||
|
redirect_to products_path
|
||||||
|
else
|
||||||
|
render :edit
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@product = Product.find(params[:id])
|
||||||
|
@product.destroy unless @product.blank?
|
||||||
|
redirect_to products_path
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def product_params
|
def product_params
|
||||||
params.require(:product).permit(:name, :vat_id)
|
params.require(:product).permit(:name, :vat_id, :netto_price, :qnt_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -22,4 +22,16 @@ module ApplicationHelper
|
||||||
"<li#{active}><a href=\"#{link}\">#{icn}#{name}</a></li>"
|
"<li#{active}><a href=\"#{link}\">#{icn}#{name}</a></li>"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def errors_to_html(errors)
|
||||||
|
ret = '<div class="row"><div class="col-lg-12 col-md-12 panel-danger"><div class="content-box-header panel-heading"><div class="panel-title">'
|
||||||
|
ret += I18n.t('activerecord.errors.messages.record_invalid', errors: errors.count)
|
||||||
|
ret += '</div></div><div class="content-box-large box-with-header" style="background:#f9dddd"><ul>'
|
||||||
|
errors.full_messages.each do |msg|
|
||||||
|
ret += "<li>#{msg}</li>"
|
||||||
|
end
|
||||||
|
ret += '</ul></div></div></div>'
|
||||||
|
ret
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,7 @@
|
||||||
|
|
||||||
<%= form_for @customer, html: {class: "form-horizontal"} do |f| %>
|
<%= form_for @customer, html: {class: "form-horizontal"} do |f| %>
|
||||||
<% if @customer.errors.any? %>
|
<% if @customer.errors.any? %>
|
||||||
<div id="error_explanation">
|
<%= raw errors_to_html(@customer.errors) %>
|
||||||
<h2>
|
|
||||||
<%= pluralize(@customer.errors.count, "error") %> prohibited
|
|
||||||
this article from being saved:
|
|
||||||
</h2>
|
|
||||||
<ul>
|
|
||||||
<% @customer.errors.full_messages.each do |msg| %>
|
|
||||||
<li><%= msg %></li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :name, class: "col-sm-2 control-label" %>
|
<%= f.label :name, class: "col-sm-2 control-label" %>
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
<div class="col-lg-8 col-md-12">
|
<div class="col-lg-8 col-md-12 panel-default">
|
||||||
<div class="content-box-large">
|
<div class="content-box-header panel-heading">
|
||||||
<div class="panel-heading">
|
<div class="panel-title">Edycja klienta</div>
|
||||||
<div class="panel-title">Edycja klienta</div>
|
<div class="panel-options">
|
||||||
<div class="panel-options">
|
<%= link_to raw("<i class=\"glyphicon glyphicon-arrow-left text-success\"></i> " + I18n.t('back')), customers_path, title: I18n.t('back'), class: "text-primary" %>
|
||||||
<%= link_to raw("<i class=\"glyphicon glyphicon-arrow-left\"></i> Powrot"), customers_path, title: 'Powrot' %>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
</div>
|
||||||
|
<div class="content-box-large box-with-header">
|
||||||
<%= render 'form' %>
|
<%= render 'form' %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -30,5 +30,4 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
<div class="col-lg-8 col-md-12">
|
<div class="col-lg-8 col-md-12 panel-default">
|
||||||
<div class="content-box-large">
|
<div class="content-box-header panel-heading">
|
||||||
<div class="panel-heading">
|
|
||||||
<div class="panel-title">Nowy klient</div>
|
<div class="panel-title">Nowy klient</div>
|
||||||
<div class="panel-options">
|
<div class="panel-options">
|
||||||
<%= link_to raw("<i class=\"glyphicon glyphicon-arrow-left\"></i> Powrot"), customers_path, title: 'Powrot' %>
|
<%= link_to raw("<i class=\"glyphicon glyphicon-arrow-left text-success\"></i> " + I18n.t('back')), customers_path, title: I18n.t('back'), class: "text-primary" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="content-box-large box-with-header">
|
||||||
<%= render 'form' %>
|
<%= render 'form' %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ module InvoiceKeeper
|
||||||
# Settings in config/environments/* take precedence over those specified here.
|
# Settings in config/environments/* take precedence over those specified here.
|
||||||
# Application configuration should go into files in config/initializers
|
# Application configuration should go into files in config/initializers
|
||||||
# -- all .rb files in that directory are automatically loaded.
|
# -- all .rb files in that directory are automatically loaded.
|
||||||
|
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
|
||||||
|
config.i18n.default_locale = :pl
|
||||||
|
|
||||||
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
|
config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
|
||||||
config.assets.precompile += %w( .svg .eot .woff .ttf .otf .woff2 )
|
config.assets.precompile += %w( .svg .eot .woff .ttf .otf .woff2 )
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,254 @@
|
||||||
|
pl:
|
||||||
|
back: 'Powrót'
|
||||||
|
save: 'Zapisz'
|
||||||
|
menu:
|
||||||
|
dashboard: 'Dashboard'
|
||||||
|
customers: 'Klienci'
|
||||||
|
products: 'Produkty'
|
||||||
|
invoices: 'Faktury'
|
||||||
|
activerecord:
|
||||||
|
attributes:
|
||||||
|
customer:
|
||||||
|
name: 'Nazwa firmy'
|
||||||
|
street: 'Adres'
|
||||||
|
city: 'Miasto'
|
||||||
|
postcode: 'Kod pocztowy'
|
||||||
|
nip: 'NIP'
|
||||||
|
regon: 'Regon'
|
||||||
|
errors:
|
||||||
|
messages:
|
||||||
|
record_invalid: 'Negatywne sprawdzenie poprawności: %{errors}'
|
||||||
|
restrict_dependent_destroy:
|
||||||
|
has_many: Nie może zostać usunięte, gdyż istnieją zależne od niego %{record}
|
||||||
|
has_one: Nie może zostać usunięte, gdyż istnieje zależny od niego %{record}
|
||||||
|
date:
|
||||||
|
abbr_day_names:
|
||||||
|
- nie
|
||||||
|
- pon
|
||||||
|
- wto
|
||||||
|
- śro
|
||||||
|
- czw
|
||||||
|
- pią
|
||||||
|
- sob
|
||||||
|
abbr_month_names:
|
||||||
|
-
|
||||||
|
- sty
|
||||||
|
- lut
|
||||||
|
- mar
|
||||||
|
- kwi
|
||||||
|
- maj
|
||||||
|
- cze
|
||||||
|
- lip
|
||||||
|
- sie
|
||||||
|
- wrz
|
||||||
|
- paź
|
||||||
|
- lis
|
||||||
|
- gru
|
||||||
|
day_names:
|
||||||
|
- niedziela
|
||||||
|
- poniedziałek
|
||||||
|
- wtorek
|
||||||
|
- środa
|
||||||
|
- czwartek
|
||||||
|
- piątek
|
||||||
|
- sobota
|
||||||
|
formats:
|
||||||
|
default: "%d-%m-%Y"
|
||||||
|
long: "%B %d, %Y"
|
||||||
|
short: "%d %b"
|
||||||
|
month_names:
|
||||||
|
-
|
||||||
|
- styczeń
|
||||||
|
- luty
|
||||||
|
- marzec
|
||||||
|
- kwiecień
|
||||||
|
- maj
|
||||||
|
- czerwiec
|
||||||
|
- lipiec
|
||||||
|
- sierpień
|
||||||
|
- wrzesień
|
||||||
|
- październik
|
||||||
|
- listopad
|
||||||
|
- grudzień
|
||||||
|
order:
|
||||||
|
- :day
|
||||||
|
- :month
|
||||||
|
- :year
|
||||||
|
datetime:
|
||||||
|
distance_in_words:
|
||||||
|
about_x_hours:
|
||||||
|
few: około %{count} godziny
|
||||||
|
many: około %{count} godzin
|
||||||
|
one: około godziny
|
||||||
|
other: około %{count} godzin
|
||||||
|
about_x_months:
|
||||||
|
few: około %{count} miesiące
|
||||||
|
many: około %{count} miesięcy
|
||||||
|
one: około miesiąca
|
||||||
|
other: około %{count} miesięcy
|
||||||
|
about_x_years:
|
||||||
|
few: około %{count} lata
|
||||||
|
many: około %{count} lat
|
||||||
|
one: około rok
|
||||||
|
other: około %{count} lat
|
||||||
|
almost_x_years:
|
||||||
|
few: prawie %{count} lata
|
||||||
|
many: prawie %{count} lat
|
||||||
|
one: prawie rok
|
||||||
|
other: prawie %{count} lat
|
||||||
|
half_a_minute: pół minuty
|
||||||
|
less_than_x_minutes:
|
||||||
|
few: mniej niż %{count} minuty
|
||||||
|
many: mniej niż %{count} minut
|
||||||
|
one: mniej niż minutę
|
||||||
|
other: mniej niż %{count} minut
|
||||||
|
less_than_x_seconds:
|
||||||
|
few: mniej niż %{count} sekundy
|
||||||
|
many: mniej niż %{count} sekund
|
||||||
|
one: mniej niż sekundę
|
||||||
|
other: mniej niż %{count} sekund
|
||||||
|
over_x_years:
|
||||||
|
few: ponad %{count} lata
|
||||||
|
many: ponad %{count} lat
|
||||||
|
one: ponad rok
|
||||||
|
other: ponad %{count} lat
|
||||||
|
x_days:
|
||||||
|
few: "%{count} dni"
|
||||||
|
many: "%{count} dni"
|
||||||
|
one: 1 dzień
|
||||||
|
other: "%{count} dni"
|
||||||
|
x_minutes:
|
||||||
|
few: "%{count} minuty"
|
||||||
|
many: "%{count} minut"
|
||||||
|
one: 1 minuta
|
||||||
|
other: "%{count} minut"
|
||||||
|
x_months:
|
||||||
|
few: "%{count} miesiące"
|
||||||
|
many: "%{count} miesięcy"
|
||||||
|
one: 1 miesiąc
|
||||||
|
other: "%{count} miesięcy"
|
||||||
|
x_seconds:
|
||||||
|
few: "%{count} sekundy"
|
||||||
|
many: "%{count} sekund"
|
||||||
|
one: 1 sekunda
|
||||||
|
other: "%{count} sekund"
|
||||||
|
prompts:
|
||||||
|
day: Dzień
|
||||||
|
hour: Godzina
|
||||||
|
minute: Minuta
|
||||||
|
month: Miesiąc
|
||||||
|
second: Sekundy
|
||||||
|
year: Rok
|
||||||
|
errors:
|
||||||
|
format: "%{attribute} %{message}"
|
||||||
|
messages:
|
||||||
|
accepted: musi zostać zaakceptowane
|
||||||
|
blank: nie może być puste
|
||||||
|
confirmation: nie zgadza się z polem %{attribute}
|
||||||
|
empty: nie może być puste
|
||||||
|
equal_to: musi być równe %{count}
|
||||||
|
even: musi być parzyste
|
||||||
|
exclusion: jest zarezerwowane
|
||||||
|
greater_than: musi być większe od %{count}
|
||||||
|
greater_than_or_equal_to: musi być większe lub równe %{count}
|
||||||
|
inclusion: nie znajduje się na liście dopuszczalnych wartości
|
||||||
|
invalid: jest nieprawidłowe
|
||||||
|
less_than: musi być mniejsze od %{count}
|
||||||
|
less_than_or_equal_to: musi być mniejsze lub równe %{count}
|
||||||
|
not_a_number: nie jest liczbą
|
||||||
|
not_an_integer: musi być liczbą całkowitą
|
||||||
|
odd: musi być nieparzyste
|
||||||
|
present: musi być puste
|
||||||
|
taken: zostało już zajęte
|
||||||
|
too_long:
|
||||||
|
few: jest za długie (maksymalnie %{count} znaki)
|
||||||
|
many: jest za długie (maksymalnie %{count} znaków)
|
||||||
|
one: jest za długie (maksymalnie jeden znak)
|
||||||
|
other: jest za długie (maksymalnie %{count} znaków)
|
||||||
|
too_short:
|
||||||
|
few: jest za krótkie (przynajmniej %{count} znaki)
|
||||||
|
many: jest za krótkie (przynajmniej %{count} znaków)
|
||||||
|
one: jest za krótkie (przynajmniej jeden znak)
|
||||||
|
other: jest za krótkie (przynajmniej %{count} znaków)
|
||||||
|
wrong_length:
|
||||||
|
few: ma nieprawidłową długość (powinna wynosić %{count} znaki)
|
||||||
|
many: ma nieprawidłową długość (powinna wynosić %{count} znaków)
|
||||||
|
one: ma nieprawidłową długość (powinna wynosić jeden znak)
|
||||||
|
other: ma nieprawidłową długość (powinna wynosić %{count} znaków)
|
||||||
|
other_than: musi być inna niż %{count}
|
||||||
|
template:
|
||||||
|
body: 'Błędy dotyczą następujących pól:'
|
||||||
|
header:
|
||||||
|
few: "%{model} nie został zachowany z powodu %{count} błędów"
|
||||||
|
many: "%{model} nie został zachowany z powodu %{count} błędów"
|
||||||
|
one: "%{model} nie został zachowany z powodu jednego błędu"
|
||||||
|
other: "%{model} nie został zachowany z powodu %{count} błędów"
|
||||||
|
helpers:
|
||||||
|
select:
|
||||||
|
prompt: Proszę wybrać
|
||||||
|
submit:
|
||||||
|
create: Utwórz %{model}
|
||||||
|
submit: Zapisz %{model}
|
||||||
|
update: Aktualizuj %{model}
|
||||||
|
number:
|
||||||
|
currency:
|
||||||
|
format:
|
||||||
|
delimiter: " "
|
||||||
|
format: "%n %u"
|
||||||
|
precision: 2
|
||||||
|
separator: ","
|
||||||
|
significant: false
|
||||||
|
strip_insignificant_zeros: true
|
||||||
|
unit: zł
|
||||||
|
format:
|
||||||
|
delimiter: " "
|
||||||
|
precision: 3
|
||||||
|
separator: ","
|
||||||
|
significant: false
|
||||||
|
strip_insignificant_zeros: false
|
||||||
|
human:
|
||||||
|
decimal_units:
|
||||||
|
format: "%n %u"
|
||||||
|
units:
|
||||||
|
billion: Miliard
|
||||||
|
million: Milion
|
||||||
|
quadrillion: Biliard
|
||||||
|
thousand: Tysiąc
|
||||||
|
trillion: Bilion
|
||||||
|
unit: ''
|
||||||
|
format:
|
||||||
|
delimiter: ''
|
||||||
|
precision: 3
|
||||||
|
significant: true
|
||||||
|
strip_insignificant_zeros: true
|
||||||
|
storage_units:
|
||||||
|
format: "%n %u"
|
||||||
|
units:
|
||||||
|
byte:
|
||||||
|
few: bajty
|
||||||
|
many: bajtów
|
||||||
|
one: bajt
|
||||||
|
other: bajty
|
||||||
|
gb: GB
|
||||||
|
kb: KB
|
||||||
|
mb: MB
|
||||||
|
tb: TB
|
||||||
|
percentage:
|
||||||
|
format:
|
||||||
|
delimiter: ''
|
||||||
|
format: "%n%"
|
||||||
|
precision:
|
||||||
|
format:
|
||||||
|
delimiter: ''
|
||||||
|
support:
|
||||||
|
array:
|
||||||
|
last_word_connector: " oraz "
|
||||||
|
two_words_connector: " i "
|
||||||
|
words_connector: ", "
|
||||||
|
time:
|
||||||
|
am: przed południem
|
||||||
|
formats:
|
||||||
|
default: "%a, %d %b %Y %H:%M:%S %z"
|
||||||
|
long: "%B %d, %Y %H:%M"
|
||||||
|
short: "%d %b %H:%M"
|
||||||
|
pm: po południu
|
||||||
Loading…
Reference in New Issue