Fixed admin, orders, wiki views. Converted all erb to haml.

This commit is contained in:
benni 2012-10-15 21:19:17 +02:00
parent 699fb9b233
commit 552c553b77
169 changed files with 1158 additions and 1307 deletions

View file

@ -1,4 +1,4 @@
- content_for :head do
- content_for :javascript do
:javascript
$(function() {
#{data_to_js(@ordering_data)}
@ -10,123 +10,107 @@
- title "Bestellen"
.left_column{:style => "width:49em"}
.box_title
%h2=h @order.name
.column_content
%table
%tr{:valign => "top"}
%td{:width => "60%"}
%p
%b Lieferantin:
=h @order.name
%p
%b Ende:
=h format_time(@order.ends)
- if @group_order && @group_order.updated_by
%p
%b Zuletzt bestellt:
=h @group_order.updated_by.nick if @group_order.updated_by
= "(#{format_time(@group_order.updated_on)})"
%p
%b Verfügbares Guthaben:
= number_to_currency(@ordering_data[:available_funds])
%td
- unless @order.note.empty?
%p
%b Notiz:
= simple_format(@order.note)
- unless @order.stockit? || @order.supplier.min_order_quantity.blank?
%p
%b Mindestellmenge:
=h @order.supplier.min_order_quantity
%p
%b Gesamtbestellmenge bisher:
= number_to_currency @order.sum
.well.pull-left
%h2= @order.name
%dl.dl-horizontal
- unless @order.note.blank?
%dt Notiz
%dd= @order.note
%dt Ende
%dd= format_time(@order.ends)
- unless @order.stockit? or @order.supplier.min_order_quantity.blank?
%dt Mindestbestellmenge
%dd= @order.supplier.min_order_quantity
%dt Gesamtbestellmenge bisher:
%dd= number_to_currency @order.sum
%dt Zuletzt bestellt
%dd
= @group_order.updated_by.nick if @group_order.updated_by
(#{format_time(@group_order.updated_on)})
%dt Guthaben
%dd= number_to_currency(@ordering_data[:available_funds])
= render :partial => 'switch_order', :locals => {:current_order => @order}
.well.pull-right
= render 'switch_order', current_order: @order
= form_for @group_order do |f|
= f.hidden_field :lock_version
= f.hidden_field :order_id
= f.hidden_field :updated_by_user_id
= f.hidden_field :ordergroup_id
.single_column{:style => "clear:both;margin-bottom:7em;"}
.box_title
%h2 Artikel
.column_content
%table#order.list
%thead
%tr
%th Name
%th{:style => "width:13px;"}
%th{:style => "width:4.5em;"} Preis
%th{:style => "width:4.5em;"} Einheit
- unless @order.stockit?
%th{:style => "width:70px;"} Fehlende Einheiten
%th#col_required Menge
%th#col_tolerance Toleranz
- else
%th(style="width:20px") Verfügbar
%th#col_required Menge
%th{:style => "width:15px;"} Summe
%tbody
- @order.articles_grouped_by_category.each do |category, order_articles|
%tr{:style => "background-color:#EFEFEF"}
%td{:style => "text-align:left"}
%b= h category
%td{:colspan => "9"}
- order_articles.each do |order_article|
%tr{:class => "#{cycle('even', 'odd', :name => 'articles')} order-article", :valign => "top"}
%td.name= order_article.article.name
%td= h order_article.article.origin
%td= number_to_currency(@ordering_data[:order_articles][order_article.id][:price])
%td= order_article.article.unit
%td
- if @order.stockit?
= @ordering_data[:order_articles][order_article.id][:quantity_available]
- else
%span{:id => "missing_units_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:missing_units]
%table.table.table-hover
%thead
%tr
%th Name
%th{style: "width:13px;"}
%th{style: "width:4.5em;"} Preis
%th{style: "width:4.5em;"} Einheit
- unless @order.stockit?
%th{style: "width:70px;"} Fehlende Einheiten
%th#col_required Menge
%th#col_tolerance Toleranz
- else
%th(style="width:20px") Verfügbar
%th#col_required Menge
%th{style: "width:15px;"} Summe
%tbody
- @order.articles_grouped_by_category.each do |category, order_articles|
%tr.article-category
%td
= category
%i.icon-tag
%td{colspan: "9"}
- order_articles.each do |order_article|
%tr{class: "#{cycle('even', 'odd', name: 'articles')} order-article", valign: "top"}
%td.name= order_article.article.name
%td= h order_article.article.origin
%td= number_to_currency(@ordering_data[:order_articles][order_article.id][:price])
%td= order_article.article.unit
%td
- if @order.stockit?
= @ordering_data[:order_articles][order_article.id][:quantity_available]
- else
%span{id: "missing_units_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:missing_units]
%td.quantity
%input{:id => "q_#{order_article.id}", :name => "group_order[group_order_articles_attributes][#{order_article.id}][quantity]", :size => "2", :type => "hidden", :value => @ordering_data[:order_articles][order_article.id][:quantity]}/
%span.used{:id => "q_used_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:used_quantity]
+
%span.unused{:id => "q_unused_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:quantity] - @ordering_data[:order_articles][order_article.id][:used_quantity]
%input{:type => 'button', :value => '+', 'data-increase_quantity' => order_article.id}
%input{:type => 'button', :value => '-', 'data-decrease_quantity' => order_article.id}
%td.quantity
%input{id: "q_#{order_article.id}", name: "group_order[group_order_articles_attributes][#{order_article.id}][quantity]", size: "2", type: "hidden", value: @ordering_data[:order_articles][order_article.id][:quantity]}/
%span.used{id: "q_used_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:used_quantity]
+
%span.unused{id: "q_unused_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:quantity] - @ordering_data[:order_articles][order_article.id][:used_quantity]
%input{type: 'button', value: '+', 'data-increase_quantity' => order_article.id}
%input{type: 'button', value: '-', 'data-decrease_quantity' => order_article.id}
%td.tolerance{:style => ('display:none' if @order.stockit?)}
%input{:id => "t_#{order_article.id}", :name => "group_order[group_order_articles_attributes][#{order_article.id}][tolerance]", :size => "2", :type => "hidden", :value => @ordering_data[:order_articles][order_article.id][:tolerance]}/
- if (@ordering_data[:order_articles][order_article.id][:unit] > 1)
%span.used{:id => "t_used_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:used_tolerance]
+
%span.unused{:id => "t_unused_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:tolerance] - @ordering_data[:order_articles][order_article.id][:used_tolerance]
%input{:type => 'button', :value => '+', 'data-increase_tolerance' => order_article.id}
%input{:type => 'button', :value => '-', 'data-decrease_tolerance' => order_article.id}
%td.tolerance{style: ('display:none' if @order.stockit?)}
%input{id: "t_#{order_article.id}", name: "group_order[group_order_articles_attributes][#{order_article.id}][tolerance]", size: "2", type: "hidden", value: @ordering_data[:order_articles][order_article.id][:tolerance]}/
- if (@ordering_data[:order_articles][order_article.id][:unit] > 1)
%span.used{id: "t_used_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:used_tolerance]
+
%span.unused{id: "t_unused_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:tolerance] - @ordering_data[:order_articles][order_article.id][:used_tolerance]
%input{type: 'button', value: '+', 'data-increase_tolerance' => order_article.id}
%input{type: 'button', value: '-', 'data-decrease_tolerance' => order_article.id}
%td{:id => "td_price_#{order_article.id}", :style => "text-align:right; padding-right:10px; width:4em"}
%span{:id => "price_#{order_article.id}_display"}= number_to_currency(@ordering_data[:order_articles][order_article.id][:total_price], :unit => "")
.article-info
%h3= order_article.article.name
.right
Volle Gebinde:
%span{:id => "units_#{order_article.id}"}= order_article.units_to_order
%br/
Gesamt-Einheiten:
%span{:id => "q_total_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:quantity] + @ordering_data[:order_articles][order_article.id][:others_quantity]
%br/
Gesamt-Toleranz:
%span{:id => "t_total_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:tolerance] + @ordering_data[:order_articles][order_article.id][:others_tolerance]
%br/
.left
Hersteller: #{order_article.article.manufacturer}
%br/
Gebinde: #{@order.stockit? ? order_article.article.quantity_available : @ordering_data[:order_articles][order_article.id][:unit]} * #{h order_article.article.unit}
%br/
Notiz: #{order_article.article.note}
%br/
%td{id: "td_price_#{order_article.id}", style: "text-align:right; padding-right:10px; width:4em"}
%span{id: "price_#{order_article.id}_display"}= number_to_currency(@ordering_data[:order_articles][order_article.id][:total_price], unit: "")
.article-info
.article-name= order_article.article.name
.pull-right
Volle Gebinde:
%span{id: "units_#{order_article.id}"}= order_article.units_to_order
%br/
Gesamt-Einheiten:
%span{id: "q_total_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:quantity] + @ordering_data[:order_articles][order_article.id][:others_quantity]
%br/
Gesamt-Toleranz:
%span{id: "t_total_#{order_article.id}"}= @ordering_data[:order_articles][order_article.id][:tolerance] + @ordering_data[:order_articles][order_article.id][:others_tolerance]
%br/
.pull-left
Hersteller: #{order_article.article.manufacturer}
%br/
Gebinde: #{@order.stockit? ? order_article.article.quantity_available : @ordering_data[:order_articles][order_article.id][:unit]} * #{h order_article.article.unit}
%br/
Notiz: #{order_article.article.note}
%br/
#order-footer
#info-box
#total-sum
@ -146,7 +130,7 @@
%span#new_balance= @ordergroup.account_balance - @group_order.price
#order-button
= submit_tag( "Bestellung speichern", :id => 'submit_button' )
= submit_tag( "Bestellung speichern", id: 'submit_button', class: 'btn btn-primary' )
oder #{link_to "abbrechen", group_orders_path}
%input#total_balance{:name => "total_balance", :type => "hidden", :value => @ordergroup.account_balance - @group_order.price}/
%input{:name => "version", :type => "hidden", :value => @version}/
%input#total_balance{name: "total_balance", type: "hidden", value: @ordergroup.account_balance - @group_order.price}/
%input{name: "version", type: "hidden", value: @version}/

View file

@ -1,6 +1,4 @@
- if pagination
= pagination_links_remote @closed_orders, :per_page => 10, :update => 'closed_orders'
%table.list
%table.table.table-striped
%thead
%tr
%th Lieferantin
@ -13,5 +11,6 @@
%tr{:class=> cycle('even', 'odd', :name => 'orders'), :style => order_class}
%td= group_order.present? ? link_to(order.name, group_order_path(group_order)) : order.name
%td= format_time(order.ends)
%td{:class => "currency"}= group_order ? number_to_currency(group_order.price) : "--"
%td.numeric= group_order ? number_to_currency(group_order.price) : "--"
- if pagination
= pagination_links_remote @closed_orders

View file

@ -1,12 +1,9 @@
- orders = Order.open.reject{ |order| order == current_order }
- unless orders.empty?
.right_column{:style => "width:22em"}
.box_title
%h2 Laufende Bestellungen
.column_content
%table
- for order in orders
%tr
%td
= link_to_ordering(order, 'data-confirm_switch_order' => true)
%td= "noch #{time_ago_in_words(order.ends)}" if order.ends
%h2 Laufende Bestellungen
%ul.unstyled
- orders.each do |order|
%li
= link_to_ordering(order, 'data-confirm_switch_order' => true)
- if order.ends
noch #{time_ago_in_words(order.ends)}

View file

@ -3,15 +3,12 @@
Siehe hier alle
= link_to "laufenden Bestellungen.", group_orders_path
.single_column{:style => "width:50em"}
.box_title
.row-fluid
.span6
%h2 beendet/nicht abgerechnet
.column_content
= render :partial => "orders", :locals => {:orders => Order.finished_not_closed, :pagination => false}
.single_column{:style => "width:50em"}
.box_title
.span6
%h2 abgerechnet
.column_content
#closed_orders
= render :partial => "orders", :locals => {:orders => @closed_orders, :pagination => true}

View file

@ -1 +0,0 @@
$('#closed_orders').html('<%= escape_javascript(render("orders", orders: @closed_orders, pagination: true)) %>');

View file

@ -0,0 +1 @@
$('#closed_orders').html('#{escape_javascript(render("orders", orders: @closed_orders, pagination: true))}');

View file

@ -1,43 +1,39 @@
- title "Bestellüberblick"
// Ordergroups Account Balance
.left_column{:style => "width:26%"}
.box_title
%h2=h @ordergroup.name
.column_content
%table
- content_for :sidebar do
.well.well-small
// Ordergroups Account Balance
%h2 Guthaben
%table.table.table-striped
%tr
%td Kontostand:
%td{:class => "currency", :style => "width:5em"}= number_to_currency(@ordergroup.account_balance)
%td.numeric{:style => "width:5em"}= number_to_currency(@ordergroup.account_balance)
%tr
%td= "- laufende Bestellungen:"
%td{:class => "currency"}= number_to_currency(@ordergroup.value_of_open_orders)
%td - laufende Bestellungen:
%td.numeric= number_to_currency(@ordergroup.value_of_open_orders)
%tr
%td= "- nicht abgerechnete Bestellungen:"
%td{:class => "currency"}= number_to_currency(@ordergroup.value_of_finished_orders)
%td.numeric= number_to_currency(@ordergroup.value_of_finished_orders)
%tr
%th verfügbares Guthaben:
%th{:class => "currency"}= number_to_currency(@ordergroup.get_available_funds)
%th.numeric= number_to_currency(@ordergroup.get_available_funds)
.right_column{:style => "width:70%"}
= render :partial => "shared/open_orders", :locals => {:ordergroup => @ordergroup}
= render :partial => "shared/open_orders", :locals => {:ordergroup => @ordergroup}
// finished orders
- unless Order.finished.empty?
.box_title
%h2 Nicht abgerechnete Bestellungen
.column_content
= render :partial => "orders", :locals => {:orders => Order.finished_not_closed, :pagination => false}
- if @ordergroup.value_of_finished_orders > 0
%p
Gesamtsumme:
%b= number_to_currency(@ordergroup.value_of_finished_orders)
// finished orders
- unless Order.finished.empty?
%section
%h2 Nicht abgerechnete Bestellungen
= render :partial => "orders", :locals => {:orders => Order.finished_not_closed, :pagination => false}
- if @ordergroup.value_of_finished_orders > 0
%p
Gesamtsumme:
%b= number_to_currency(@ordergroup.value_of_finished_orders)
// closed orders
- unless Order.closed.empty?
.box_title
%h2 Abgerechnete Bestellungen
.column_content
= render :partial => "orders", :locals => {:orders => Order.closed.all(:limit => 5), :pagination => false}
%br/
= link_to "mehr...", archive_group_orders_path
// closed orders
- unless Order.closed.empty?
%section
%h2 Abgerechnete Bestellungen
= render :partial => "orders", :locals => {:orders => Order.closed.all(:limit => 5), :pagination => false}
%br/
= link_to "mehr...", archive_group_orders_path

View file

@ -1,4 +1,4 @@
- content_for :head do
- content_for :javascript do
:javascript
$(function() {
$('tr.ignored').hide();
@ -6,55 +6,42 @@
- title "Dein Bestellergebnis für #{@order.name}"
// Order summary
.left_column{:style => "width:45em"}
.box_title
%h2 Zusammenfassung
.column_content
%table
%tr{:valign => "top"}
%td{:style => "width:50%"}
%p
Lieferantin:
%b=h @order.name
- unless @order.note.blank?
%p
Notiz:
=h @order.note
%p
Ende:
%b=h format_time(@order.ends)
%p
Bestellsumme:
- if @group_order
%b=h number_to_currency(@group_order.price)
- else
%b Du hast nicht bestellt.
- if @order.closed?
%p
= "Abgerechnet von #{@order.updated_by.nick}"
= link_to "Kommentare lesen/schreiben", "#comments"
= render :partial => "switch_order", :locals => {:current_order => @order}
.well
// Order summary
%dl.dl-horizontal
%dt Lieferantin
%dd= @order.name
%dt Notiz
%dd= @order.note
%dt Ende
%dd= format_time(@order.ends)
%dt Bestellsumme
%dd
- if @group_order
= number_to_currency(@group_order.price)
- else
Du hast nicht bestellt.
- if @order.closed?
%p Abgerechnet von #{@order.updated_by.nick}
= link_to "Kommentare lesen/schreiben", "#comments"
// Article box
.single_column{:style => "clear:both; width:70em;"}
.box_title
%h2 Artikelübersicht
%section
%h2 Artikelübersicht
.column_content#result
- if @group_order
%p(style="float:right")= link_to "Zeige/Verstecke nicht bestellte Artikel", '#', 'data-toggle-this' => 'tr.ignored'
%p= link_to("Bestellung ändern", edit_group_order_path(@group_order, :order_id => @order.id)) if @order.open?
%table.list
%p.pull-right= link_to "Zeige/Verstecke nicht bestellte Artikel", '#', 'data-toggle-this' => 'tr.ignored'
%p= link_to("Bestellung anpassen", edit_group_order_path(@group_order, order_id: @order.id), class: 'btn btn-primary') if @order.open?
%table.table.table-hover
%thead
%tr
%th{:style => "width:40%"} Name
%th{style: "width:40%"} Name
%th Gebinde
%th Einzelpreis
%th
%abbr{:title => "Menge + Toleranz"} Bestellt
%abbr{title: "Menge + Toleranz"} Bestellt
%th
%abbr{:title => "Unter Berücksichtigung der derzeitigen Bestellungen aller Gruppen"}
%abbr{title: "Unter Berücksichtigung der derzeitigen Bestellungen aller Gruppen"}
- if @order.open?
Zu
Erhalten
@ -62,9 +49,11 @@
%tbody
- total = 0 #set counter for order-sum
- for category_name, order_articles in @order.articles_grouped_by_category
%tr{:style => "background-color:#EFEFEF"}
%td{:style => "text-align:left;"}=h category_name
%td{:colspan => "9"}
%tr.article-category
%td
= category_name
%i.icon-tag
%td{colspan: "9"}
- for oa in order_articles
- # get the order-results for the ordergroup
- goa = oa.group_order_articles.find_by_group_order_id(@group_order.id)
@ -73,11 +62,11 @@
- result = goa.result
- sub_total = goa.total_price
- total += sub_total
%tr{:class => cycle('even', 'odd', :name => 'articles') + " " + order_article_class_name(quantity, tolerance, result)}
%td{:style => "width:40%"}
%tr{class: cycle('even', 'odd', name: 'articles') + " " + order_article_class_name(quantity, tolerance, result)}
%td{style: "width:40%"}
=h oa.article.name
- unless oa.article.note.blank?
= image_tag("lamp_grey.png", {:alt => "Notiz anzeigen", :size => "15x16", :border => "0", :onmouseover => "$('note_#{oa.id}').show();", :onmouseout => "$('note_#{oa.id}').hide();"})
= image_tag("lamp_grey.png", {alt: "Notiz anzeigen", size: "15x16", border: "0", onmouseover: "$('note_#{oa.id}').show();", onmouseout: "$('note_#{oa.id}').hide();"})
%td= "#{oa.price.unit_quantity} x #{oa.article.unit}"
%td= number_to_currency(oa.price.fc_price)
%td
@ -86,26 +75,24 @@
%td= result > 0 ? result : "0"
%td= number_to_currency(sub_total)
- unless oa.article.note.blank?
%tr{:id => "note_#{oa.id}", :class => "note even", :style => "display:none"}
%td{:colspan => "6"}=h oa.article.note
%tr{:class => cycle('even', 'odd', :name => 'articles')}
%th{:colspan => "5"} Summe
%tr{id: "note_#{oa.id}", class: "note even", style: "display:none"}
%td{colspan: "6"}=h oa.article.note
%tr{class: cycle('even', 'odd', name: 'articles')}
%th{colspan: "5"} Summe
%th= number_to_currency(total)
%br/
= link_to_top
- else
- if @order.open?
Du hast noch nicht bestellt.
= link_to "Das ist Deine Chance!", :action => "order", :id => @order
= link_to "Das ist Deine Chance!", action: "order", id: @order
- else
Die Bestellung is leider schon zu Ende. Beim nächsten mal früher aufstehen...
// Comments box
.single_column{:style => "width:70em;"}
.box_title
%h2 Kommentare
.column_content
#comments
= render :partial => 'shared/comments', :locals => { :comments => @order.comments }
#new_comment= render :partial => 'order_comments/form', :locals => { :order_comment => @order.comments.build(:user => current_user)}
= link_to_top
%section
%h2 Kommentare
#comments
= render 'shared/comments', comments: @order.comments
#new_comment= render 'order_comments/form', order_comment: @order.comments.build(user: current_user)
= link_to_top