Fixed articles module.

This commit is contained in:
benni 2012-10-28 18:03:50 +01:00
parent f30e57dd49
commit fc1c173718
14 changed files with 124 additions and 147 deletions

View file

@ -1,4 +1,4 @@
%tr{ :class => cycle('even','odd') + row_classes(article)}[article]
%tr{class: row_classes(article)}
%td= check_box_tag 'selected_articles[]', article.id.to_s, false, {:id => "checkbox_#{article.id}", 'data-ignore-onchange' => true}
%td{'data-check-this' => "#checkbox_#{article.id}", :class => 'click-me'}= article.name
%td= article.origin
@ -11,10 +11,9 @@
= number_to_currency(article.price)
%td= number_to_percentage(article.tax) if article.tax != 0
%td= number_to_currency(article.deposit) if article.deposit != 0
%td
= link_to icon(:edit), edit_supplier_article_path(@supplier, article),
:remote => true
= link_to icon(:delete), [@supplier, article],
:method => :delete, :confirm => 'Bist du sicher?', :remote => true
%td= link_to "Bearbeiten", edit_supplier_article_path(@supplier, article),
:remote => true, class: 'btn btn-mini'
%td= link_to "Löschen", [@supplier, article],
:method => :delete, :confirm => 'Bist du sicher?', :remote => true, class: 'btn btn-mini btn-danger'

View file

@ -0,0 +1,34 @@
%table.table
%thead
%tr
%th
%acronym{:title => "verfügbar"} verf.
%th Name
%th Einheit
%th
%acronym{:title => "Netto!"} Preis
%th
%acronym{:title => "Gebindegröße"} GebGr
%th Best.Nr.
%th Notiz
%th Kategorie
%th MwSt.
%th Pfand
%tbody
- @articles.each_with_index do |article, index|
= fields_for "articles[#{article.id || index}]", article do |form|
%tr
%td= form.check_box 'availability'
%td= form.text_field 'name', class: 'input-medium'
%td= form.text_field 'unit', class: 'input-mini'
%td= form.text_field 'price', class: 'input-mini'
%td= form.text_field 'unit_quantity', class: 'input-mini'
%td= form.text_field 'order_number', class: 'input-mini'
%td= form.text_field 'note', class: 'input-medium'
%td= form.collection_select 'article_category_id', ArticleCategory.all,
:id, :name, { :include_blank => true }, class: 'input-small'
%td= form.text_field 'tax', class: 'input-mini'
%td= form.text_field 'deposit', class: 'input-mini'
- unless article.errors.empty?
%tr.alert
%td(colspan="10")= article.errors.full_messages.join(", ")

View file

@ -1,62 +0,0 @@
<% title "Alle Artikel von #{@supplier.name} bearbeiten" %>
<div class="single_column" style="width:100%">
<div id="change_supplier">
<%= select_tag :switch_supplier,
options_for_select( Supplier.all.collect {|s| [s.name, edit_all_supplier_articles_url(s)] },
edit_all_supplier_articles_url(@supplier)),
'data-redirect-to' => true,
:style => "font-size: 0.9em;margin-left:1em;" %>
</div>
<div class="box_title">
<h2></h2>
</div>
<div class="box column_content">
<div id="links"><%= link_to 'zurück zur Liste', supplier_articles_path(@supplier) -%></div>
<p>
<i>
Pflichtfelder sind: Name, Einheit, (netto) Preis und Bestellnummer.
</i>
</p>
<%= form_tag(update_all_supplier_articles_path(@supplier)) do %>
<table id="articles_table" class="list">
<thead>
<tr>
<th><acronym title="verfügbar">verf.</acronym></th>
<th>Name</th>
<th>Einheit</th>
<th><acronym title="Netto!">Preis</acronym></th>
<th><acronym title="Gebindegröße">GebGr</acronym></th>
<th>Best.Nr.</th>
<th>Notiz</th>
<th>Kategorie</th>
<th>MwSt.</th>
<th>Pfand</th>
</tr>
<tbody>
<% for article in @articles %>
<%= fields_for 'articles[]', article do |form| %>
<tr class="<%= cycle('even', 'odd') %>"<%= ' style="background-color: yellow"' if @failedArticle == article %>>
<td colspan="2">
<%= form.check_box 'availability' -%>
<%= form.text_field 'name', :size => 0 -%>
</td>
<td><%= form.text_field 'unit', :size => 5 -%></td>
<td><%= form.text_field 'price', :size => 4 -%></td>
<td><%= form.text_field 'unit_quantity', :size => 4 -%></td>
<td><%= form.text_field 'order_number', :size => 6 -%></td>
<td><%= form.text_field 'note', :size => 15 -%></td>
<td><%= form.select 'article_category_id', ArticleCategory.find(:all).collect {|a| [ a.name, a.id ] }, { :include_blank => true } -%></td>
<td><%= form.text_field 'tax', :size => 4 -%></td>
<td><%= form.text_field 'deposit', :size => 4 -%></td>
</tr>
<% end %>
<% end %>
<!--[eoform:article]-->
</tbody>
</table><br />
<i>Achtung, alle Artikel werden aktualisiert!</i><br />
<%= submit_tag 'Alle Artikel aktualisieren'%> | <%= link_to 'Abbrechen', supplier_articles_path(@supplier) %>
<% end %>
</div>
</div>

View file

@ -0,0 +1,11 @@
- title "Alle Artikel von #{@supplier.name} bearbeiten" |
%p
%i
Pflichtfelder sind: Name, Einheit, (netto) Preis und Bestellnummer.
= form_tag(update_all_supplier_articles_path(@supplier)) do
= render 'edit_all_table'
%br/
%i Achtung, alle Artikel werden aktualisiert!
.form-actions
= submit_tag 'Alle Artikel aktualisieren', class: 'btn btn-primary'
= link_to 'oder abbrechen', supplier_articles_path(@supplier)

View file

@ -6,35 +6,8 @@
Achtung, momentan gibt es keine Überprüfung auf doppelte Artikel.
= form_tag(create_from_upload_supplier_articles_path(@supplier)) do
%table
%tr
%th Nummer
%th Name
%th Notiz
%th Hersteller
%th Herkunft
%th Einheit
%th Nettopreis
%th MwSt
%th Pfand
%th Gebindegröße
%th Kategorie
- for article in @articles
= fields_for "articles[]", article do |form|
%tr{:class => cycle('even', 'odd')}
%td= form.text_field 'order_number', :size => 6
%td= form.text_field 'name', :size => 0
%td= form.text_field 'note', :size => 15
%td= form.text_field 'manufacturer', :size => 6
%td= form.text_field 'origin', :size => 6
%td= form.text_field 'unit', :size => 5
%td= form.text_field 'price', :size => 4
%td= form.text_field 'tax', :size => 4
%td= form.text_field 'deposit', :size => 4
%td= form.text_field 'unit_quantity', :size => 4
%td= form.select 'article_category_id', ArticleCategory.find(:all).collect {|a| [ a.name, a.id ] }
%p
= submit_tag "Speichere neue Artikel für #{@supplier.name}"
|
= link_to "Zurück", upload_supplier_articles_path(@supplier)
= render 'edit_all_table'
.form-actions
= submit_tag "Speichere neue Artikel für #{@supplier.name}", class: 'btn btn-primary'
= link_to "order abbrechen", upload_supplier_articles_path(@supplier)

View file

@ -1,23 +1,21 @@
- title "#{@supplier.name} / Artikel hochladen"
%p
%i
Die Datei muss eine Textdatei mit der Endung '.csv' sein. Die erste Zeile
wird beim Einlesen ignoriert.
%br/
Die Felder müssen mit einem Semikolon (';') getrennt und der Text mit doppelten
Anführungszeichen ("Text...") umklammert werden.
%br/
Als Zeichensatz wird UTF-8 erwartet.
%p
%i
Korrekte Reihenfolge der Spalten:
%br/
Die Datei muss eine Textdatei mit der Endung '.csv' sein. Die erste Zeile
wird beim Einlesen ignoriert.
%br/
Die Felder müssen mit einem Semikolon (';') getrennt und der Text mit doppelten
Anführungszeichen ("Text...") umklammert werden.
%br/
Als Zeichensatz wird UTF-8 erwartet. Korrekte Reihenfolge der Spalten:
%pre
= ["Status (x=ausgelistet)", "Bestellnummer", "Name", "Notiz", "Hersteller", "Herkunft",
"Einheit", "Preis(netto)", "MwSt", "Pfand", "Gebindegröße",
"Staffelmenge", "Staffelpreis", "Kategorie"].join(" | ")
#uploadArticles.uploadForm
= form_for :articles, :url => parse_upload_supplier_articles_path(@supplier),
:html => { :multipart => true } do |form|
%p= form.file_field "file"
%p= submit_tag "Datei hochladen"
= form_for :articles, :url => parse_upload_supplier_articles_path(@supplier),
:html => { :multipart => true } do |f|
%label(for="articles_file")
Bitte wähle eine kompatible Datei aus
= f.file_field "file"
.form-actions
= submit_tag "Datei hochladen", class: 'btn'