};
if ( $@ ) {
$c->stash->{'error_message'} = $@;
+ $c->log->warn( "Fehler beim Speichern des Autors: " . $@ );
return undef;
}
unless ( $autor_id ) {
#-------------------------------------------------------
+=head2 form_edit( )
+
+Aendern eines vorhandenen Buches.
+
+=cut
+
+sub form_edit : Path('edit') {
+
+ my ( $self, $c ) = @_;
+ my $K = ( caller(0) )[3] . "(): ";
+
+ $c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
+
+ $c->stash->{'menu_path'} = [] unless $c->stash->{'menu_path'};
+ push @{ $c->stash->{'menu_path'} }, {
+ 'path' => $c->web_path("/books/edit"),
+ 'name' => "Ändern"
+ };
+
+ $c->stash->{'error_message'} = '';
+
+ my $buch_id = to_int( $c->request->params->{'edit_book_id'} || 0 );
+ unless ( $buch_id ) {
+ $c->stash->{'template'} = 'error.tt2';
+ $c->stash->{'error'} = 'Keine oder ungültige Buch-Id übergeben.';
+ return 1;
+ }
+
+ my $buchliste = get_booklist( $c, 'buch_id' => $buch_id );
+ $c->log->debug( get_output_string( $K, "Erhaltene Buchliste: ", $buchliste ) ) if $c->stash->{'debug_level'} >= 2;
+
+ unless ( $buchliste and scalar( @$buchliste ) ) {
+ $c->stash->{'template'} = 'error.tt2';
+ $c->stash->{'error'} = 'Zur übergebenen Buch-Id wurde kein Buch gefunden.';
+ return 1;
+ }
+
+ my $buch = $buchliste->[0];
+
+ $buch->{'autoren'} = $buch->{'autor_ids'};
+ delete $buch->{'autor_ids'} if exists $buch->{'autor_ids'};
+
+ $buch->{'kategorien'} = $buch->{'kategorie_ids'};
+ delete $buch->{'kategorie_ids'} if exists $buch->{'kategorie_ids'};
+
+ $buch->{'serien'} = $buch->{'serien_ids'};
+ delete $buch->{'serien_ids'} if exists $buch->{'serien_ids'};
+
+ $c->stash->{'return_target'} = $c->session->{'return_target_edit'} or $c->web_path("/books/list");
+
+ $c->stash->{'book_edit'} = $buch;
+ $c->session->{'book_data_edit'} = $buch;
+ $buchliste = undef;
+
+ $self->prepare_data_structures($c);
+ $self->bookdata_cgi2session($c);
+
+ $c->stash->{'template'} = 'books/edit.tt2';
+ push @{$c->stash->{'cssfiles'}}, 'books/form.css';
+
+ $self->bookdata_session2stash($c);
+
+ unless ( $c->request->params->{'book_form_sent'} and $c->request->params->{'do_save'} ) {
+ return 1;
+ }
+
+ return $self->do_save_book($c);
+
+}
+
+#-------------------------------------------------------
+
sub do_save_book : Private {
my ( $self, $c ) = @_;
};
if ( $@ ) {
$c->stash->{'error_message'} = $@;
+ $c->log->warn( "Fehler beim Speichern des Buches: " . $@ );
return undef;
}
unless ( $book_id ) {
Rueckgabe: Eine Array-Ref mit allen Buchtiteln, die den uebergebenen Suchkriterien entsprechen.
+ $list = [
+ {
+ 'ausgabejahr' => '2003',
+ 'autor_ids' => [
+ '5'
+ ],
+ 'autoren' => [
+ 'Bill Napier'
+ ],
+ 'bindungsart' => 'Softcover (Taschenbuch)',
+ 'bindungsart_id' => '4',
+ 'buch_nr' => '093314',
+ 'druckjahr' => '2007',
+ 'id' => '5',
+ 'isbn' => undef,
+ 'kategorie_ids' => [
+ '4'
+ ],
+ 'kategorien' => [
+ 'Mystery-Thriller'
+ ],
+ 'ort_beschreibung' => undef,
+ 'ort_ist_statisch' => undef,
+ 'orts_id' => undef,
+ 'ortsname' => undef,
+ 'preis' => '7.45',
+ 'seiten' => '416',
+ 'serien' => [],
+ 'serien_ids' => [],
+ 'title' => 'Der 77. Grad',
+ 'title_original' => 'Shattered Icon',
+ 'umrechnung_in_euro' => '1',
+ 'untertitel' => undef,
+ 'verlags_id' => '3',
+ 'verlagsname_long' => 'Bertelsmann Club GmbH - Taschenbuch',
+ 'verlagsname_short' => 'Club Taschenbuch',
+ 'waehrungs_id' => '1',
+ 'waehrungs_kuerzel' => '€',
+ 'waehrungs_name' => 'Euro'
+ },
+ ...
+ ];
+
=cut
sub get_booklist {
$buch->{'ort_beschreibung'} = $book->get_column('ort_beschreibung');
$buch->{'ort_ist_statisch'} = $book->get_column('ort_ist_statisch');
$buch->{'autoren'} = [];
+ $buch->{'autor_ids'} = [];
$buch->{'kategorien'} = [];
+ $buch->{'kategorie_ids'} = [];
$buch->{'serien'} = [];
+ $buch->{'serien_ids'} = [];
push @$list, $buch;
$buchmap->{$id} = $i;
$i++;
$other_params->{'join'} = [ 'autor' ];
$other_params->{'select'} = [
'me.buch_id',
+ 'autor.id',
'autor.titel',
'autor.vorname',
'autor.mittelname',
];
$other_params->{'as'} = [
'buch_id',
+ 'autor_id',
'titel',
'vorname',
'mittelname',
'name_suffix',
];
for my $ref ( $c->model('Schema::Autor2buch')->search( $a_search_params, $other_params )->all() ) {
- my $bid = $ref->get_column('buch_id');
+ my $bid = $ref->get_column('buch_id');
+ my $aid = $ref->get_column('autor_id');
my @N;
push @N, $ref->get_column('titel') if $ref->get_column('titel');
push @N, $ref->get_column('vorname') if $ref->get_column('vorname');
next unless defined $j;
my $buch = $list->[$j];
next unless $buch;
- push @{$buch->{'autoren'}}, $autor;
+ push @{$buch->{'autoren'}}, $autor;
+ push @{$buch->{'autor_ids'}}, $aid;
}
# Kategorien zusammensammeln
$other_params->{'join'} = [ 'kategorie' ];
$other_params->{'select'} = [
'me.buch_id',
+ 'kategorie.id',
'kategorie.kategorie_name',
];
$other_params->{'as'} = [
'buch_id',
+ 'kategorie_id',
'kategorie_name',
];
for my $ref ( $c->model('Schema::Buch2kategorie')->search( $a_search_params, $other_params )->all() ) {
my $bid = $ref->get_column('buch_id');
+ my $kid = $ref->get_column('kategorie_id');
my $name = $ref->get_column('kategorie_name');
my $j = $buchmap->{$bid};
next unless defined $j;
my $buch = $list->[$j];
next unless $buch;
push @{$buch->{'kategorien'}}, $name;
+ push @{$buch->{'kategorie_ids'}}, $kid;
}
# Buchserien zusammensammeln
$other_params->{'join'} = [ 'serie' ];
$other_params->{'select'} = [
'me.buch_id',
+ 'serie.id',
'serie.serien_name',
];
$other_params->{'as'} = [
'buch_id',
+ 'serien_id',
'serien_name',
];
for my $ref ( $c->model('Schema::Buch2serie')->search( $a_search_params, $other_params )->all() ) {
my $bid = $ref->get_column('buch_id');
+ my $sid = $ref->get_column('serien_id');
my $name = $ref->get_column('serien_name');
my $j = $buchmap->{$bid};
next unless defined $j;
my $buch = $list->[$j];
next unless $buch;
push @{$buch->{'serien'}}, $name;
+ push @{$buch->{'serien_ids'}}, $sid;
}
return $list;
** -%]
[% META title = 'Autorenliste' -%]
-
-<table class="autorliste">
+
+<div class="center">
+
+<table class="wrapper" cellspacing="0">
+<tr><th>Liste der Bücher</th> </tr>
+<tr><td class="action"><a href="[% path('/autor/new') %]">Neuer Autor ...</a></td></tr>
+<tr><td><table class="autorliste">
<tr>
<th>Name des Autors</th>
<th>zusätzliche Angaben</th>
</ul></td>
<td class="button [% rowstyle %]"><a href="[% path('/autor/view') %]?view_autor_id=[% author.id %]">Ansehen</a></td>
<td class="button [% rowstyle %]"><a href="[% path('/autor/edit') %]?edit_autor_id=[% author.id %]">Ändern</a></td>
- <td class="button [% rowstyle %]"><a href="[% path('/autor/delete') %]?delete_autor_id=[% author.id %]">Löschen</a></td>
+ <td class="button [% rowstyle %]">[% IF author.books and author.books.size > 0 %]Löschen[% ELSE %]<a href="[% path('/autor/delete') %]?delete_autor_id=[% author.id %]">Löschen</a>[% END %]</td>
</tr>
[% IF rowstyle == 'even' %][% rowstyle = 'odd'%][% ELSE %][% rowstyle = 'even' %][% END %][% END -%]
-</table>
+</table></td></tr></table>
+</div>
-%]
/* Stylesheets Autoren */
+DIV.center {
+ margin: auto;
+ text-align: center;
+ width: auto;
+}
+
+TABLE.wrapper {
+ border-spacing: 0;
+ margin: auto;
+}
+
+TABLE.wrapper TH {
+ text-align: center;
+ font-size: 1.2em;
+}
+
+TABLE.wrapper TD {
+ text-align: left;
+}
+
+TABLE.wrapper TD.action {
+ font-weight: bolder;
+ padding-top: 1em;
+ padding-bottom: 1em;
+}
+
TABLE.autorliste {
border-width: 2px;
border-style: solid;
TABLE.autorliste TH {
vertical-align: top;
text-align: left;
+ font-size: 1em;
padding: 2px;
border-width: 1px;
border-style: solid;
TABLE.autorliste TD {
vertical-align: top;
+ font-size: 1em;
padding: 2px;
border-width: 1px;
border-style: solid;
margin: 0;
}
+TABLE.autorliste TD.button {
+ font-weight: bolder;
+ text-align: center;
+ padding-left: 1em;
+ padding-right: 1em;
+}
+
--- /dev/null
+[%#
+ Template zum Ändern der Angaben eines Buches
+
+ vim: noai : ts=4 fenc=utf-8 filetype=html expandtab :
+
+ $Id$
+ $URL$
+
+-%]
+[%- book_form_title = 'Buch ändern' -%]
+[% PROCESS books/form.tt2 %]
+
+<div class="back">
+<h2><a href="[% return_target %]">[% 'Zurück' %]</a></h2>
+</div>
<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><input type="text" name="book_preis" size="20" maxlength="20" value="[% book_edit.preis | format('%.2f') | 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 %]
background-color: [% site.col.list_row_bold %];
}
+TABLE.ftable TH.button {
+ font-weight: bolder;
+ text-align: center;
+ font-size: 1.2em;
+ padding-left: 1em;
+ padding-right: 1em;
+}
+
TABLE.buchliste {
text-align: left;
border-width: 2px;