Skip to content

Commit

Permalink
adding export in xls to factures
Browse files Browse the repository at this point in the history
  • Loading branch information
franck committed Sep 3, 2012
1 parent cfc2f57 commit cf3f9ed
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 20 deletions.
7 changes: 3 additions & 4 deletions app/assets/stylesheets/clients.css.scss
Expand Up @@ -40,10 +40,9 @@
}

#factures-subactions {
background:pink;
clear:both; float:left; width:100%; margin-bottom:15px;
#factures-total { float:left; }
#factures-actions { float:left; }
clear:both; float:left; width:100%; margin-bottom:10px;
#factures-total { float:left; margin-right:10px; }
#factures-actions { float:right; }
}
}

Expand Down
1 change: 1 addition & 0 deletions app/controllers/prive/factures_controller.rb
Expand Up @@ -9,6 +9,7 @@ def index
@period = params[:period] ? params[:period] : 'day'

@factures = Facture.find_by_date_and_period(@date, @period, @salon)
logger.debug("Factures : #{@factures.size}")
respond_to do |format|
format.html
format.xls
Expand Down
35 changes: 27 additions & 8 deletions app/views/prive/factures/index.xls.erb
Expand Up @@ -4,21 +4,40 @@
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">

<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s21">
<Font ss:Bold="1"/>
<Alignment ss:Horizontal="Center" ss:Vertical="Bottom"/>
</Style>
<Style ss:ID="s25">
<NumberFormat ss:Format="Euro Currency"/>
</Style>
</Styles>

<Worksheet ss:Name="Sheet1">
<Table>
<Row>
<Cell><Data ss:Type="String">Date</Data></Cell>
<Cell><Data ss:Type="String">Description</Data></Cell>
<Cell><Data ss:Type="String">Prix</Data></Cell>
<Cell><Data ss:Type="String">Moyen de paiement</Data></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">Date</Data></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">Description</Data></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">Prix</Data></Cell>
<Cell ss:StyleID="s21"><Data ss:Type="String">Moyen de paiement</Data></Cell>
</Row>
<% @factures.each do |facture| %>
<% facture.items do |item| %>
<% facture.items.each do |item| %>
<Row>
<Cell><Data ss:Type="String"><%= facture.payed_at %></Data></Cell>
<Cell><Data ss:Type="String"><%= facture.payed_at.strftime("%d/%m%Y") %></Data></Cell>
<Cell><Data ss:Type="String"><%= item.description %></Data></Cell>
<Cell><Data ss:Type="String"><%= number_to_currency(item.price) %></Data></Cell>
<Cell><Data ss:Type="Number"><%= facture.mean_of_payment %></Data></Cell>
<Cell ss:StyleID="s25"><Data ss:Type="Number"><%= item.price %></Data></Cell>
<Cell><Data ss:Type="String"><%= t("factures.mean_of_payment.#{facture.mean_of_payment}") %></Data></Cell>
</Row>
<% end %>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20120515155210_create_items.rb
Expand Up @@ -4,6 +4,7 @@ def change
t.text :description
t.decimal :price, :precision => 8, :scale => 2
t.integer :facture_id
t.integer :salon_id

t.timestamps
end
Expand Down
6 changes: 0 additions & 6 deletions db/migrate/20120822085035_add_salon_id_to_items.rb

This file was deleted.

4 changes: 2 additions & 2 deletions db/schema.rb
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120828073925) do
ActiveRecord::Schema.define(:version => 20120828135549) do

create_table "clients", :force => true do |t|
t.string "name"
Expand Down Expand Up @@ -52,9 +52,9 @@
t.text "description"
t.decimal "price", :precision => 8, :scale => 2
t.integer "facture_id"
t.integer "salon_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "salon_id"
end

create_table "messages", :force => true do |t|
Expand Down

0 comments on commit cf3f9ed

Please sign in to comment.