use FrBr::Books::Util::Author;
use FrBr::Books::Util::Book;
use FrBr::Books::Util::Category;
+use FrBr::Books::Util::Serie;
use FrBr::Books::Util::Verlag;
=head1 NAME
}
$c->log->debug( get_output_string( $K . "Kategorien, die fehlen: ", $c->stash->{'kategorie_list_no'} ) );
+ my %Serien;
+
+ $c->stash->{'serienliste_book'} = [];
+ for my $serien_id ( @{$c->session->{'book_data_edit'}{'serien'}} ) {
+ push @{$c->stash->{'serienliste_book'}}, $serien_id;
+ $Serien{$serien_id} = 1;
+ }
+ $c->log->debug( get_output_string( $K . "Serien des Buches: ", $c->stash->{'serienliste_book'} ) );
+
+ $c->stash->{'serienliste_no'} = [];
+ for my $serien_id ( @{$c->stash->{'serien_ids'}} ) {
+ push @{$c->stash->{'serienliste_no'}}, $serien_id unless $Serien{$serien_id};
+ }
+ $c->log->debug( get_output_string( $K . "Serien, die fehlen: ", $c->stash->{'serienliste_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'}{'original_title'} = $c->session->{'book_data_edit'}{'original_title'};
}
}
+ # Kategorien
+ $c->session->{'book_data_edit'}{'serien'} = [] unless $c->session->{'book_data_edit'}{'serien'};
+
+ my %Buchserie;
+ $i = 1;
+ for my $serien_id ( @{$c->session->{'book_data_edit'}{'serien'}} ) {
+ $Buchserie{$serien_id} = $i;
+ $i++;
+ }
+
+ if ( $c->request->params->{'wird_serie'} ) {
+ if ( $c->request->params->{'buchserie_not'} ) {
+ my $serien = ref($c->request->params->{'buchserie_not'}) eq 'ARRAY' ? $c->request->params->{'buchserie_not'} : [$c->request->params->{'buchserie_not'}];
+ $c->log->debug( get_output_string( $K . "Fuege Buchserie hinzu: ", $serien ) );
+ for my $serien_id ( @$serien ) {
+ next unless $serien_id;
+ unless ( $Buchserie{$serien_id} ) {
+ push @{$c->session->{'book_data_edit'}{'serien'}}, $serien_id;
+ $Buchserie{$serien_id} = scalar( @{$c->session->{'book_data_edit'}{'serien'}} );
+ }
+ }
+ }
+ }
+ elsif ( $c->request->params->{'entf_serie'} ) {
+ if ( $c->request->params->{'serie_book'} ) {
+ my $serien = ref($c->request->params->{'serie_book'}) eq 'ARRAY' ? $c->request->params->{'serie_book'} : [$c->request->params->{'serie_book'}];
+ $c->log->debug( get_output_string( $K . "Loesche Serien: ", $serien ) );
+ for my $serien_id ( @$serien ) {
+ next unless $serien_id;
+ $i = $Buchserie{$serien_id};
+ next unless $i;
+ splice( @{$c->session->{'book_data_edit'}{'serien'}}, $i - 1, 1 );
+ $i = 1;
+ %Buchserie = ();
+ for my $id ( @{$c->session->{'book_data_edit'}{'serien'}} ) {
+ $Buchserie{$id} = $i;
+ $i++;
+ }
+ }
+ }
+ }
+
# ISBN
$c->session->{'book_data_edit'}{'isbn'} = $c->request->params->{'book_isbn'} if defined $c->request->params->{'book_isbn'};
}
$c->log->debug( get_output_string( $K . "Verlage: ", $c->stash->{'verlagsliste'} ) );
+ # Buchserien zusamensammeln
+ my $serienliste = get_serienliste($c);
+ $c->log->debug( get_output_string( $K . "Serien gesamt: ", $serienliste ) );
+ $c->stash->{'serienliste'} = {};
+ $c->stash->{'serien_ids'} = [];
+ for my $serie ( @$serienliste ) {
+ push @{$c->stash->{'serien_ids'}}, $serie->{'id'};
+ $c->stash->{'serienliste'}{$serie->{'id'}} = $serie->{'name'};
+ }
+ $c->log->debug( get_output_string( $K . "Serien: ", $c->stash->{'serienliste'} ) );
+
return 1;
}
--- /dev/null
+package FrBr::Books::Util::Serie;
+
+# $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_serienliste
+ );
+
+ #%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 Buchserien
+
+=head1 METHODS
+
+=cut
+
+#-----------------------------------------------------------------------------------
+
+=head2 get_serienliste( $c, $params )
+
+Sammelt alle Buchserien 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' => 'Perry Rhodan',
+ 'descr' => 'Abenteuer des Weltraumspezis',
+ 'anzahl_buecher' => 60,
+ },
+ { 'id' => 2,
+ ...
+ },
+ ...
+ ];
+
+Die Liste ist nach den Serien-Namen alphabetisch sortiert.
+
+=cut
+
+sub get_serienliste {
+
+ my $c = shift;
+ my $K = __PACKAGE__ . "::get_serienliste(): ";
+
+ $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'} = [ 'serien_name' ];
+ $other_params->{'select'} = [
+ 'id',
+ 'serien_name',
+ 'descr',
+ ];
+ $other_params->{'as'} = [
+ 'id',
+ 'serien_name',
+ 'descr',
+ ];
+
+ my %SidMap;
+
+ my $i = 0;
+ for my $serie_rs ( $c->model('Schema::Serien')->search( $search_params, $other_params )->all() ) {
+ my $serie = {};
+ $serie->{'id'} = $serie_rs->id();
+ $serie->{'name'} = $serie_rs->serien_name();
+ $serie->{'descr'} = $serie_rs->descr();
+ $serie->{'anzahl_buecher'} = 0;
+ push @$list, $serie;
+ $SidMap{$serie->{'id'}} = $i;
+ $i++;
+ }
+
+ $search_params = undef;
+ $other_params = {};
+ $other_params->{'select'} = [ 'serien_id', { 'count' => 'buch_id' } ];
+ $other_params->{'as'} = [ 'serien_id', 'anzahl_buecher' ];
+ $other_params->{'group_by'} = [ 'serien_id', ];
+ for my $rs ( $c->model('Schema::Buch2serie')->search( $search_params, $other_params )->all() ) {
+ my $sid = $rs->serien_id();
+ my $j = $SidMap{$sid};
+ $list->[$j]{'anzahl_buecher'} = $rs->get_column('anzahl_buecher');
+ }
+
+ 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;
<option value="[% cat_id %]">[% kategorie_list.$cat_id %]</option>[% END %]
</select></td>
</tr></table></td>
+ </tr><tr>
+ <th>Buchserien:</th>
+ <td>
+ <table class="two_lists" cellspacing="0">
+ <tr>
+ <th>Verfügbare Buchserien</th>
+ <th></th>
+ <th>Serien des Buchs</th>
+ </tr><tr>
+ <td><select name="buchserie_not" size="7" multiple>
+ <option value="">-- Buchserie wählen --</option>[% FOR serien_id IN serienliste_no %]
+ <option value="[% serien_id %]">[% serienliste.$serien_id %]</option>
+ [% END %]</select></td>
+ <td><input type="submit" name="wird_serie" value="⇒" class="shift_button" title="Wird Serie" /><br /><br />
+ <input type="submit" name="neue_serie" value="*" class="shift_button" title="Neue Serie" /><br /><br />
+ <input type="submit" name="entf_serie" value="⇐" class="shift_button" title="Serie entfernen" />
+ </td>
+ <td><select name="serie_book" size="7" multiple>
+ <option value="">-- Buchserie entfernen --</option>[% FOR serien_id IN serienliste_book %]
+ <option value="[% serien_id %]">[% serienliste.$serien_id %]</option>[% END %]
+ </select></td>
+ </tr></table></td>
</tr><tr>
<th>ISBN:</th>
<td><input type="text" name="book_isbn" size="20" maxlength="20" value="[% book_edit.isbn | html %]" /></td>