use FrBr::Common;
use FrBr::Books::Util::Author;
-use FrBr::Books::Util::Category;
use FrBr::Books::Util::Book;
+use FrBr::Books::Util::Category;
+use FrBr::Books::Util::Verlag;
=head1 NAME
}
$c->log->debug( get_output_string( $K . "Kategorien, die fehlen: ", $c->stash->{'kategorie_list_no'} ) );
- $c->stash->{'book_edit'}{'title'} = $c->session->{'book_data_edit'}{'title'};
- $c->stash->{'book_edit'}{'untertitel'} = $c->session->{'book_data_edit'}{'untertitel'};
+ $c->stash->{'book_edit'}{'title'} = $c->session->{'book_data_edit'}{'title'};
+ $c->stash->{'book_edit'}{'untertitel'} = $c->session->{'book_data_edit'}{'untertitel'};
$c->stash->{'book_edit'}{'original_title'} = $c->session->{'book_data_edit'}{'original_title'};
- $c->stash->{'book_edit'}{'isbn'} = $c->session->{'book_data_edit'}{'isbn'};
- $c->stash->{'book_edit'}{'book_nr'} = $c->session->{'book_data_edit'}{'book_nr'};
- $c->stash->{'book_edit'}{'ausgabejahr'} = $c->session->{'book_data_edit'}{'ausgabejahr'};
- $c->stash->{'book_edit'}{'druckjahr'} = $c->session->{'book_data_edit'}{'druckjahr'};
- $c->stash->{'book_edit'}{'seiten'} = $c->session->{'book_data_edit'}{'seiten'};
- $c->stash->{'book_edit'}{'preis'} = $c->session->{'book_data_edit'}{'preis'};
+ $c->stash->{'book_edit'}{'verlags_id'} = $c->session->{'book_data_edit'}{'verlags_id'};
+ $c->stash->{'book_edit'}{'isbn'} = $c->session->{'book_data_edit'}{'isbn'};
+ $c->stash->{'book_edit'}{'book_nr'} = $c->session->{'book_data_edit'}{'book_nr'};
+ $c->stash->{'book_edit'}{'ausgabejahr'} = $c->session->{'book_data_edit'}{'ausgabejahr'};
+ $c->stash->{'book_edit'}{'druckjahr'} = $c->session->{'book_data_edit'}{'druckjahr'};
+ $c->stash->{'book_edit'}{'seiten'} = $c->session->{'book_data_edit'}{'seiten'};
+ $c->stash->{'book_edit'}{'preis'} = $c->session->{'book_data_edit'}{'preis'};
return 1;
# Original-Titel
$c->session->{'book_data_edit'}{'original_title'} = $c->request->params->{'book_original_title'} if defined $c->request->params->{'book_original_title'};
+ # Verlag
+ $c->session->{'book_data_edit'}{'verlags_id'} = $c->request->params->{'verlags_id'} if defined $c->request->params->{'verlags_id'};
+
# Kategorien
$c->session->{'book_data_edit'}{'kategorien'} = [] unless $c->session->{'book_data_edit'}{'kategorien'};
}
$c->log->debug( get_output_string( $K . "Kategorien: ", $c->stash->{'kategorie_list'} ) );
+ # Verlage zusamensammeln
+ my $verlagsliste = get_verlagsliste($c);
+ $c->log->debug( get_output_string( $K . "Verlage gesamt: ", $verlagsliste ) );
+ $c->stash->{'verlagsliste'} = {};
+ $c->stash->{'verlags_ids'} = [];
+ for my $verlag ( @$verlagsliste ) {
+ push @{$c->stash->{'verlags_ids'}}, $verlag->{'id'};
+ $c->stash->{'verlagsliste'}{$verlag->{'id'}} = $verlag->{'name'};
+ }
+ $c->log->debug( get_output_string( $K . "Verlage: ", $c->stash->{'verlagsliste'} ) );
+
return 1;
}
--- /dev/null
+package FrBr::Books::Util::Verlag;
+
+# $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_verlagsliste
+ );
+
+ #%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::Author - Modul fuer Funktionen rund um Autoren
+
+=head1 METHODS
+
+=cut
+
+#-----------------------------------------------------------------------------------
+
+=head2 get_verlagsliste( $c, $params )
+
+Sammelt alle Verlage zusammen.
+
+Folgende benannte Parameter koennen ueber $params uebergeben werden:
+
+Rueckgabe: Eine Array-Ref von Hash-Refs mit allen verlagen, die den uebergebenen Suchkriterien entsprechen:
+
+ $res = [
+ { 'id' => 1,
+ 'name' => 'Heyne',
+ 'name_long' => 'Heyne-Verlag usw. GmbH & Co. KG',
+ },
+ { 'id' => 2,
+ ...
+ },
+ ...
+ ];
+
+Die Liste ist nach den Verlags-Namen alphabetisch sortiert.
+
+=cut
+
+sub get_verlagsliste {
+
+ my $c = shift;
+ my $K = __PACKAGE__ . "::get_verlagsliste(): ";
+
+ $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'} = [ 'name_short' ];
+ $other_params->{'select'} = [
+ 'id',
+ 'name_short',
+ 'name_long',
+ ];
+ $other_params->{'as'} = [
+ 'id',
+ 'name_short',
+ 'name_long',
+ ];
+
+ for my $verlag_rs ( $c->model('Schema::Verlage')->search( $search_params, $other_params )->all() ) {
+ my $verlag = {};
+ $verlag->{'id'} = $verlag_rs->id();
+ $verlag->{'name'} = $verlag_rs->name_short();
+ $verlag->{'descr'} = $verlag_rs->name_long();
+ push @$list, $verlag;
+ }
+
+ 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;
</tr><tr>
<th>Original-Titel:</th>
<td><input type="text" name="book_original_title" size="60" maxlength="250" value="[% book_edit.original_title | html %]" /></td>
+ </tr><tr>
+ <th>Verlag:</th>
+ <td><select name="verlags_id"> size="1">
+ <option value="">-- Verlag auswählen --</option>[% FOR verlagsid IN verlags_ids %]
+ <option value="[% verlagsid %]"[% IF book_edit.verlags_id == verlagsid %] selected[% END %]>[% verlagsliste.$verlagsid %]</option>[% END %]
+ </select> <input type="submit" name="neuer_verlag" value="*" class="shift_button" title="Neuer Verlag" /></td>
</tr><tr>
<th>Kategorie(n):</th>
<td>