<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/views/customers/_invoice.html.erb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,8 +1,14 @@
 class CustomersController &lt; ApplicationController
   def index
-    @customers = current_user.customers.find :all
-
+    if params[:search]
+      @customers = current_user.customers.find :all, :conditions =&gt; ['name LIKE ?', &quot;%#{params[:search]}%&quot;]
+    else
+      unless read_fragment({:id =&gt; current_user.id})
+        @customers = current_user.customers.find :all
+      end
+    end
     respond_to do |format|
+      format.js
       format.html # index.html.erb
       format.xml  { render :xml =&gt; @customers }
     end
@@ -68,7 +74,7 @@ class CustomersController &lt; ApplicationController
 
     respond_to do |format|
       flash[:notice] = &quot;Kunde wurde gel&#246;scht&quot;
-      format.html { redirect_to(admin_customers_url) }
+      format.html { redirect_to(customers_url) }
       format.xml  { head :ok }
     end
   end</diff>
      <filename>app/controllers/customers_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,8 @@
 class Customer &lt; ActiveRecord::Base
   belongs_to :user
   has_many :addresses
+  has_many :invoices, :through =&gt; :addresses
+  has_many :open_invoices, :through =&gt; :addresses, :source =&gt; :invoices, :conditions =&gt; ['payed = ?', false]
 
   attr_protected :user_id
   attr_protected :customer_id</diff>
      <filename>app/models/customer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,6 @@
 &lt;% if params[:customer_id] %&gt;
-  &lt;li&gt;&lt;%= link_to_unless_current 'neue Adresse', new_customer_address_path(:customer_id =&gt; params[:customer_id]) %&gt;&lt;/li&gt;
+  &lt;li&gt;&lt;%= link_to_unless_current 'zur&#252;ck zum Kunden', customer_path(params[:customer_id]) %&gt;&lt;/li&gt;
+  &lt;li&gt;&lt;%= link_to_unless_current 'neue Adresse', new_customer_address_path(params[:customer_id]) %&gt;&lt;/li&gt;
 &lt;% else %&gt;
   &lt;li&gt;&lt;%= link_to_unless_current 'neue Adresse', new_address_path %&gt;&lt;/li&gt;
 &lt;% end %&gt;</diff>
      <filename>app/views/addresses/_navigation.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,7 @@
 
 &lt;%= error_messages_for :address %&gt;
 &lt;% form_for :address, @address, :url =&gt; address_url(@address), :html =&gt; {:method =&gt; :put} do |f| %&gt;
+  &lt;%= hidden_field_tag(:customer_id, params[:customer_id]) unless params[:customer_id].nil? %&gt;
   &lt;%= render :partial =&gt; 'form', :locals =&gt; {:f =&gt; f} %&gt;
   &lt;%= submit_tag 'Speichern' %&gt;
 &lt;% end %&gt;</diff>
      <filename>app/views/addresses/edit.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,9 @@
-&lt;tr&gt;
-  &lt;td&gt;&lt;%= link_to h(address.company), customer_address_url(@customerw, address) %&gt;&lt;/td&gt;
+&lt;tr class=&quot;&lt;%= cycle 'odd', 'even' %&gt;&quot;&gt;
+  &lt;td&gt;&lt;%= link_to h(address.company), customer_address_path(@customer, address) %&gt;&lt;/td&gt;
   &lt;td&gt;&lt;%= h address.name %&gt;&lt;/td&gt;
   &lt;td&gt;&lt;%= h address.street %&gt; &lt;%= h address.postcode %&gt; &lt;%= h address.city %&gt; &lt;%= h address.country %&gt;&lt;/td&gt;
   &lt;td&gt;&lt;%= h address.tax_number %&gt;&lt;/td&gt;
+  &lt;td&gt;&lt;%= link_to 'zeigen', customer_address_path(@customer, address) %&gt;
+    &lt;%= link_to 'bearbeiten', edit_customer_address_path(@customer, address) %&gt;
+    &lt;%= link_to_destroy 'l&#246;schen', {:id =&gt; address.id}, {:href =&gt; confirm_destroy_customer_address_path(@customer, address)} %&gt;&lt;/td&gt;
 &lt;/tr&gt;</diff>
      <filename>app/views/customers/_address.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1,7 @@
-&lt;li&gt;&lt;%= link_to customer.name, customer_url(customer) %&gt;&lt;/li&gt;
\ No newline at end of file
+&lt;tr id=&quot;customer-&lt;%= customer.id %&gt;&quot; class=&quot;&lt;%= cycle 'odd', 'even' %&gt;&quot;&gt;
+  &lt;td&gt;&lt;%= customer.id %&gt;&lt;/td&gt;
+  &lt;td&gt;&lt;%= link_to customer.name, customer_url(customer) %&gt;&lt;/td&gt;
+  &lt;td&gt;&lt;%= customer.invoices.count %&gt;&lt;/td&gt;
+  &lt;td&gt;&lt;%= customer.open_invoices.count %&gt;&lt;/td&gt;
+  &lt;td&gt;&lt;%= link_to '&#228;ndern', edit_customer_path(customer) %&gt; &lt;%= link_to 'zeigen', customer_path(customer) %&gt; &lt;%= link_to_destroy 'l&#246;schen', {:id =&gt; customer.id}, {:href =&gt; confirm_destroy_customer_path(customer)} %&gt;&lt;/td&gt;
+&lt;/tr&gt;</diff>
      <filename>app/views/customers/_customer.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,14 @@
-&lt;ul&gt;
+&lt;% @page_title = 'Kunden' %&gt;
+
+&lt;table id=&quot;customers&quot;&gt;
+  &lt;tr&gt;
+    &lt;th&gt;#&lt;/th&gt;
+    &lt;th&gt;Name&lt;/th&gt;
+    &lt;th&gt;Rechnungen&lt;/th&gt;
+    &lt;th&gt;davon offen&lt;/th&gt;
+    &lt;th&gt;Aktionen&lt;/th&gt;
+  &lt;/tr&gt;
+  &lt;% cache({:id =&gt; current_user.id}) do %&gt;
   &lt;%= render :partial =&gt; 'customer', :collection =&gt; @customers %&gt;
-&lt;/ul&gt;
\ No newline at end of file
+  &lt;% end %&gt;
+&lt;/table&gt;
\ No newline at end of file</diff>
      <filename>app/views/customers/index.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,17 +1,38 @@
 &lt;% @page_title = 'Kunde %s ' % @customer.name %&gt;
 
 &lt;h3&gt;Adressen&lt;/h3&gt;
-  &lt;%= link_to 'Neue Adresse anlegen', new_customer_address_url(@customer) %&gt;
+  &lt;%= link_to 'Neue Adresse anlegen', new_customer_address_path(@customer) %&gt;
 &lt;% if @customer.addresses.nil? %&gt;
   &lt;p&gt;Noch keine Adressen vorhanden&lt;/p&gt;
 &lt;% else %&gt;
-&lt;table class=&quot;form&quot;&gt;
+&lt;table id=&quot;addresses&quot;&gt;
   &lt;tr&gt;
-    &lt;th width=&quot;20%&quot;&gt;Firmenname&lt;/th&gt;
-    &lt;th width=&quot;20%&quot;&gt;Ansprechperson&lt;/th&gt;
-    &lt;th width=&quot;50%&quot;&gt;Adresse&lt;/th&gt;
-    &lt;th width=&quot;10%&quot;&gt;Steuernummer&lt;/th&gt;
+    &lt;th width=&quot;14%&quot;&gt;Firmenname&lt;/th&gt;
+    &lt;th width=&quot;10%&quot;&gt;Ansprechperson&lt;/th&gt;
+    &lt;th width=&quot;40%&quot;&gt;Adresse&lt;/th&gt;
+    &lt;th width=&quot;16%&quot;&gt;Steuernummer&lt;/th&gt;
+    &lt;th width=&quot;20%&quot;&gt;Aktionen&lt;/th&gt;
   &lt;/tr&gt;
   &lt;%= render :partial =&gt; 'address', :collection =&gt; @customer.addresses %&gt;
 &lt;/table&gt;
+&lt;% end %&gt;
+&lt;h3&gt;Rechnungen&lt;/h3&gt;
+  &lt;%= link_to 'Neue Rechnung stellen', new_customer_invoice_path(@customer) %&gt;
+&lt;% if @customer.invoices.nil? %&gt;
+  &lt;p&gt;Noch keine Rechnungen vorhanden.&lt;/p&gt;
+&lt;% else %&gt;  
+&lt;table id=&quot;invoices&quot;&gt;
+  &lt;tr&gt;
+    &lt;th width=&quot;2%&quot;&gt;#&lt;/th&gt;
+    &lt;th width=&quot;12%&quot;&gt;Rechnungsdatum&lt;/th&gt;
+    &lt;th width=&quot;10%&quot;&gt;bezahlt am&lt;/th&gt;
+    &lt;th width=&quot;40%&quot;&gt;Titel&lt;/th&gt;
+    &lt;th width=&quot;8%&quot;&gt;Bruttobetrag&lt;/th&gt;
+    &lt;th width=&quot;8%&quot;&gt;Steueranteil&lt;/th&gt;
+    &lt;th width=&quot;20%&quot;&gt;Aktionen&lt;/th&gt;
+  &lt;/tr&gt;
+  &lt;% reset_cycle %&gt;
+  &lt;%= render :partial =&gt; 'invoice', :collection =&gt; @customer.invoices %&gt;
+&lt;/table&gt;
+
 &lt;% end %&gt;
\ No newline at end of file</diff>
      <filename>app/views/customers/show.html.erb</filename>
    </modified>
    <modified>
      <diff>@@ -1,9 +1,11 @@
 ActionController::Routing::Routes.draw do |map|
 
-  map.resources :customers, :has_many =&gt; :addresses
+  map.resources :customers, :member =&gt; {:confirm_destroy =&gt; :get} do |customer|
+    customer.resources :addresses, :invoices, :member =&gt; {:confirm_destroy =&gt; :get}
+  end
   map.resources :users, :has_many =&gt; :addresses
-  map.resources :addresses
-  map.resources :invoices, :has_many =&gt; :items, :member =&gt; {:confirm_destroy =&gt; :get}
+  map.resources :addresses, :member =&gt; {:confirm_destroy =&gt; :get}
+  map.resources :invoices, :has_many =&gt; :items, :member =&gt; {:confirm_destroy =&gt; :get}, :has_one =&gt; :customer
   map.resources :items
 
   map.root :controller =&gt; 'invoices'</diff>
      <filename>config/routes.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1a73e87734b98d1b04112222bf6292e67141bd2e</id>
    </parent>
  </parents>
  <author>
    <name>TomK32</name>
    <email>tomk32@tomk32.de</email>
  </author>
  <url>http://github.com/TomK32/exabuch/commit/2b7905c9858878abd2c823fba5ad621e543a022d</url>
  <id>2b7905c9858878abd2c823fba5ad621e543a022d</id>
  <committed-date>2008-05-13T00:09:07-07:00</committed-date>
  <authored-date>2008-05-13T00:09:07-07:00</authored-date>
  <message>completed customer controller</message>
  <tree>a4fd6f74aad6ef8ff534eb22024534ae7d046d51</tree>
  <committer>
    <name>TomK32</name>
    <email>tomk32@tomk32.de</email>
  </committer>
</commit>
