use FrBr::Books::Util::Category;
use FrBr::Books::Util::Serie;
use FrBr::Books::Util::Verlag;
+use FrBr::Books::Util::Waehrung;
=head1 NAME
}
$c->log->debug( get_output_string( $K . "Serien: ", $c->stash->{'serienliste'} ) );
+ # Waehrungen zusammensammeln
+ my $waehrungsliste = get_waehrungsliste($c);
+ $c->log->debug( get_output_string( $K . "Waehrungen gesamt: ", $waehrungsliste ) );
+ $c->stash->{'waehrungsliste'} = {};
+ $c->stash->{'waehrungs_ids'} = [];
+ for my $waehrung ( @$waehrungsliste ) {
+ push @{$c->stash->{'waehrungs_ids'}}, $waehrung->{'id'};
+ $c->stash->{'waehrungsliste'}{$waehrung->{'id'}} = $waehrung;
+ }
+ $c->log->debug( get_output_string( $K . "Waehrungen: ", $c->stash->{'waehrungsliste'} ) );
+
return 1;
}
--- /dev/null
+package FrBr::Books::Util::Waehrung;
+
+# $Id$
+# $URL$
+
+use strict;
+use warnings;
+
+use FrBr::Common;
+
+# Export-Deklarationen
+
+BEGIN {
+
+ use Exporter();
+ our ( $VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS );
+
+ # set the version for version checking
+ $VERSION = 0.1;
+ my ($rev) = '$Revision$' =~ /(\d+)/;
+ $VERSION = sprintf( $VERSION . ".%d", $rev );
+
+ @ISA = qw(Exporter);
+ @EXPORT = qw(
+ &get_waehrungsliste
+ );
+
+ #%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
+
+ # your exported package globals go here,
+ # as well as any optionally exported functions
+ #@EXPORT_OK = qw($Var1 %Hashit &func3);
+} ## end BEGIN
+
+our @EXPORT_OK;
+
+=head1 NAME
+
+FrBr::Books::Util::Waehrung - Modul fuer Funktionen rund um Waehrungen
+
+=head1 METHODS
+
+=cut
+
+#-----------------------------------------------------------------------------------
+
+=head2 get_waehrungsliste( $c, $params )
+
+Sammelt alle Waehrungen zusammen.
+
+Folgende benannte Parameter koennen ueber $params uebergeben werden:
+
+Rueckgabe: Eine Array-Ref von Hash-Refs mit allen Waehrungen, die den uebergebenen Suchkriterien entsprechen:
+
+ $res = [
+ { 'id' => 1,
+ 'kuerzel' => '$',
+ 'name' => 'US-Dollar',
+ 'in_euro' => 0.66225,
+ },
+ { 'id' => 2,
+ ...
+ },
+ ...
+ ];
+
+Die Liste ist nach den Waehrungs-Namen alphabetisch sortiert.
+
+=cut
+
+sub get_waehrungsliste {
+
+ my $c = shift;
+ my $K = __PACKAGE__ . "::get_waehrungsliste(): ";
+
+ $c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
+
+ my $params = {};
+ if ( ref($_[0]) and ref($_[0]) eq 'HASH' ) {
+ $params = $_[0];
+ }
+ else {
+ %$params = @_;
+ }
+ $c->log->debug( get_output_string( $K, "Uebergebene Parameter: ", $params ) ) if $c->stash->{'debug_level'} >= 2;
+
+ my $list = [];
+
+ my $search_params = undef;
+
+ my $other_params = {};
+ $other_params->{'order_by'} = [ 'waehrungs_name' ];
+ $other_params->{'select'} = [
+ 'id',
+ 'waehrungs_kuerzel',
+ 'waehrungs_name',
+ 'umrechnung_in_euro',
+ ];
+ $other_params->{'as'} = [
+ 'id',
+ 'waehrungs_kuerzel',
+ 'waehrungs_name',
+ 'umrechnung_in_euro',
+ ];
+
+ for my $waehrung_rs ( $c->model('Schema::Waehrungen')->search( $search_params, $other_params )->all() ) {
+ my $waehrung = {};
+ $waehrung->{'id'} = $waehrung_rs->id();
+ $waehrung->{'kuerzel'} = $waehrung_rs->waehrungs_kuerzel();
+ $waehrung->{'name'} = $waehrung_rs->waehrungs_name();
+ $waehrung->{'in_euro'} = $waehrung_rs->umrechnung_in_euro();
+ push @$list, $waehrung;
+ }
+
+ return $list;
+}
+
+#-----------------------------------------------------------------------------------
+
+=head1 AUTHOR
+
+Frank Brehm
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
<td><input type="text" name="book_seiten" size="20" maxlength="20" value="[% book_edit.seiten | html %]" class="zahl" /></td>
</tr><tr>
<th>Preis:</th>
- <td><input type="text" name="book_preis" size="20" maxlength="20" value="[% book_edit.preis | replace('\.', ',') %]" class="zahl" /></td>
+ <td><input type="text" name="book_preis" size="20" maxlength="20" value="[% book_edit.preis | replace('\.', ',') %]" class="zahl" />
+ <select name="waehrungs_id" size="1">
+ <option value="">-- Währung auswählen --</option>[% FOR waehrungsid IN waehrungs_ids %]
+ <option value="[% waehrungsid %]"[% IF book_edit.waehrungs_id == waehrungsid %] selected[% END %]>[% waehrungsliste.$waehrungsid.kuerzel %]</option>[% END %]
+ </select></td>
</tr><tr>
<td colspan="2"> </td>
</tr><tr>