Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
birger
users
Commits
05e3589f
Commit
05e3589f
authored
May 24, 2021
by
o@immerda.ch
Browse files
polish the user interface part of billing
parent
d2e7ecbb
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
app/assets/javascripts/bills.js
View file @
05e3589f
//= require qrbill.js
function
loadActions
()
{
if
(
document
.
getElementById
(
'
click-me-button
'
))
{
document
.
getElementById
(
'
click-me-button
'
).
click
();
}
}
window
.
addEventListener
(
"
load
"
,
loadActions
)
app/assets/javascripts/qrbill.js
View file @
05e3589f
This diff is collapsed.
Click to expand it.
app/controllers/bills_controller.rb
View file @
05e3589f
...
...
@@ -23,6 +23,7 @@ class BillsController < ApplicationController
def
show
begin
@year
=
(
params
[
:year
]
||
DateTime
.
now
.
year
).
to_i
@pane
=
params
[
:pane
]
||
'create_bill'
res
=
api
.
get_user_transactions
(
'bill'
,
[
"
#{
@year
}
-01-01"
,
"
#{
@year
+
1
}
-01-01"
])
res
.
each
do
|
r
|
paid
=
api
.
get_global_transaction
(
'bill'
,
r
.
first
[
:reference
])
...
...
@@ -52,7 +53,7 @@ class BillsController < ApplicationController
currency:
'CHF'
,
subject:
subject
},
ttl
)
end
redirect_to
action: :show
redirect_to
action: :show
,
pane:
'show_bills'
rescue
ApiError
=>
e
flash
[
:danger
]
=
e
.
api_msg
redirect_to
bills_path
...
...
app/controllers/resources_controller.rb
View file @
05e3589f
...
...
@@ -45,7 +45,11 @@ class ResourcesController < ApplicationController
@res
=
api
.
resource_self_create
(
@resource_name
,
data
)
update_account_properties
flash
[
:success
]
=
:resource_created
if
@resource_name
==
'mailman'
||
@resource_name
==
'schleuder'
flash
[
:success
]
=
:resource_created
else
flash
[
:success
]
=
:resource_created_now
end
end
redirect_to
action: :show
,
kind:
@resource_name
rescue
ApiError
=>
e
...
...
app/views/bills/show.html.erb
View file @
05e3589f
<nav>
<div
class=
"nav nav-tabs"
id=
"nav-tab"
role=
"tablist"
>
<%
[
'create_bill'
,
'show_bills'
].
each
do
|
pane
|
%>
<a
class=
"nav-item nav-link
<%=
if
pane
==
@pane
then
"active"
else
""
end
%>
"
href=
"?pane=
<%=
pane
%>
"
role=
"tab"
>
<%=
t
(
"
#{
pane
}
"
)
%>
</a>
<%
end
%>
</div>
</nav>
<div
class=
"tab-content"
id=
"nav-tabContent"
>
<div
class=
"card-body"
>
<%
if
@pane
==
'create_bill'
%>
<p>
<%=
t
(
:create_bill_help
)
%>
</p>
<%=
form_tag
do
%>
<div
class=
"form-group"
>
<%=
label_tag
"CHF"
%>
<%=
text_field_tag
(
'amount'
,
""
,
class:
'form-control'
)
%>
</div>
<div
class=
"form-group"
>
<%=
label_tag
"subject"
%>
<%=
label_tag
t
(
"subject"
)
%>
<%=
text_field_tag
(
'subject'
,
""
,
class:
'form-control'
)
%>
</div>
<%=
submit_tag
t
(
:create
),
name:
'create'
,
class:
"btn btn-primary"
%>
<%
end
%>
<hr
/>
<%
end
%>
<%
if
@pane
==
'show_bills'
%>
<%=
form_tag
""
,
method: :get
do
%>
<div
class=
"form-group"
>
<%=
t
(
:year
)
%>
<%=
hidden_field_tag
(
'pane'
,
@pane
)
%>
<%=
select_tag
(
:year
,
options_for_select
((
0
..
5
).
map
{
|
d
|
DateTime
.
now
.
year
-
d
},
@year
),
...
...
@@ -22,6 +47,7 @@
</div>
<%
end
%>
<hr
/>
<%
id
=
0
;
sum
=
{}
%>
<%
for
e
in
@bills
%>
<%
bill
,
date
=
e
...
...
@@ -33,19 +59,23 @@
end
%>
<%=
"
#{
date
.
day
}
.
#{
date
.
month
}
.
#{
date
.
year
}
"
%>
:
<%=
bill
[
:subject
]
%>
<br
/>
<%=
bill
[
:currency
]
%>
<%
if
bill
[
:amount
]
>
0.0
%>
<%=
bill
[
:amount
]
%>
<%
end
%>
<%
if
bill
[
:paid
]
%>
<b>
<%=
bill
[
:paid
][
:status
]
%>
</b>
<b>
<%=
t
(
bill
[
:paid
][
:status
]
)
%>
</b>
<%
if
bill
[
:paid
][
:amount
]
!=
bill
[
:amount
]
||
bill
[
:paid
][
:currency
]
!=
bill
[
:currency
]
%>
(
<%=
bill
[
:paid
][
:currency
]
%>
<%=
bill
[
:paid
][
:amount
]
%>
)
<%
end
%>
<%
end
%>
<a
href=
"#"
onclick=
"this.style.display = 'none'; qrbill.createQRBill(
<a
href=
"#"
<%
if
@year
.
to_i
==
Time
.
now
.
year
&&
!
bill
[
:paid
]
&&
id
==
1
%>
id=
"click-me-button"
<%
end
%>
onclick=
"this.style.display = 'none'; qrbill.createQRBill(
'
<%=
bill
[
:currency
].
upcase
%>
',
<%=
if
bill
[
:amount
]
>
0.0
then
bill
[
:amount
]
else
'undefined'
end
%>
,
'
<%=
bill
[
:reference
]
%>
',
...
...
@@ -54,13 +84,20 @@
f.src = url;
f.style.display = 'block';
});"
/>
show
</a>
<br
/>
<%=
t
(
:show_bills
)
%>
</a>
<br
/>
<iframe
id=
"bill-
<%=
id
%>
"
style=
"width:100%; height: 450px; display: none;"
>
</iframe>
<br
/>
<%
end
%>
<%
unless
sum
.
empty?
%>
<hr
/
>
Thank you very much for donating a total of
<%=
sum
.
to_a
.
map
{
|
e
|
e
.
join
(
" "
)}.
join
(
", "
)
%>
to immerda in the year
<%=
@year
%>
.
<div
class=
"alert alert-success"
role=
"alert"
>
<%=
t
(
:bill_thanks
,
year:
@year
,
amount:
sum
.
to_a
.
map
{
|
e
|
e
.
join
(
" "
)}.
join
(
", "
)
)
%>
</div>
<%
end
%>
<%
end
%>
</div>
</div>
app/views/resources/create.html.erb
View file @
05e3589f
...
...
@@ -2,11 +2,11 @@
<nav>
<div
class=
"nav nav-tabs"
id=
"nav-tab"
role=
"tablist"
>
<%
@resource_names
.
each
do
|
pane
|
%>
<%
@resource_names
.
sort
.
each
do
|
pane
|
%>
<a
class=
"nav-item nav-link
<%=
if
pane
==
@resource_name
then
"active"
else
""
end
%>
"
href=
"?resource_name=
<%=
pane
%>
"
role=
"tab"
>
<%=
pane
%>
<%=
t
(
pane
)
%>
</a>
<%
end
%>
</div>
...
...
config/locales/de.yml
View file @
05e3589f
...
...
@@ -199,6 +199,7 @@ de:
new_resource
:
"
Dienst
erstellen"
missing_gpg_key
:
"
Hierfür
wird
ein
OpenPGP
Schlüssel
benötigt.
Bitte
lade
einen
unter
dem
Punkt
OpenPGP
Schlüssel
hoch."
resource_created
:
"
Dienst
erfolgreich
bestellt.
Du
wirst
via
E-Mail
Benachrichtigt,
dies
kann
bis
zu
24h
dauern."
resource_created_now
:
"
Erfolgreich
erstellt"
my
:
"
Meine"
mailman
:
"
Emaillisten"
mailman_description
:
"
Klassische
Emaillisten
zur
Gruppenkommunikation
oder
als
Newsletter."
...
...
@@ -206,10 +207,19 @@ de:
schleuder
:
"
Verschlüsselte
Emaillisten"
schleuder_description
:
"
Verschlüsselte
(Schleuder)
Emaillisten
zur
Gruppenkommunikation
oder
Kommunikation
mit
externen
Personen."
schleuder_edit_description
:
"
Zum
Bearbeiten
muss
ein
zusätzlicher
\"
Schleuder
Account
\"
erstellt
werden."
email_alias
:
"
Email
Alias"
mail_alias
:
"
Email
Alias"
mail_alias_description
:
"
Eine
zweite
E-Mail
Adresse,
die
auf
dein
bestehendes
Postfach
zeigt."
mail_alias_edit_description
:
"
"
bills
:
Rechnungen
create_bill
:
Rechnung erstellen
create_bill_help
:
Hier kannst du dir eine Rechnung mit Einzahlungsschein für deine Spende an immerda.ch generieren.
subject
:
Betreff
show_bills
:
Anzeigen
paid
:
bezahlt
bill_thanks
:
"
Wir
danken
dir
sehr
herzlich,
dass
du
im
Jahr
%{year}
%{amount}
an
immerda.ch
gespendet
hast!"
activerecord
:
errors
:
messages
:
...
...
config/locales/en.yml
View file @
05e3589f
...
...
@@ -200,6 +200,7 @@ en:
new_resource
:
"
Create
service"
missing_gpg_key
:
"
OpenGPG
Key
needed.
Please
upload
one
in
the
OpenPGP
Keys
settings."
resource_created
:
"
Service
successfully
scheduled
for
creation.
You
will
be
notified
by
mail.
Please
allow
for
up
to
24h
until
it
becomes
available."
resource_created_now
:
"
Created
successfully"
my
:
"
My"
mailman
:
"
Mailing
Lists"
mailman_description
:
"
Classic
mailing
lists
for
group
communication
or
as
newsletter."
...
...
@@ -207,10 +208,19 @@ en:
schleuder
:
"
Encrypted
Lists"
schleuder_description
:
"
Encrypted
mailing
lists
based
on
schleuder,
for
group
communication
or
communicating
externally."
schleuder_edit_description
:
"
For
editing
a
dedicated
\"
schleuder
account
\"
must
be
created."
email_alias
:
"
Email
Alias"
mail_alias
:
"
Email
Alias"
mail_alias_description
:
"
A
second
address
pointing
to
your
existing
mailbox."
mail_alias_edit_description
:
"
"
bills
:
bills
create_bill
:
Create invoice
create_bill_help
:
Here you can create yourself your own invoice to donate to immerda.ch
subject
:
subject
show_bills
:
Show
paid
:
paid
bill_thanks
:
"
Thank
you
very
much
for
donating
a
total
of
%{amount}
to
immerda.ch
in
the
year
%{year}!"
activerecord
:
errors
:
messages
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment