'name' => "Bücher"
};
+ $c->session->{'return_target_view'} = $c->web_path("/books") unless $c->session->{'return_target_view'};
+ $c->session->{'return_target_edit'} = $c->web_path("/books") unless $c->session->{'return_target_edit'};
+ $c->session->{'return_target_del'} = $c->web_path("/books") unless $c->session->{'return_target_del'};
+ $c->session->{'return_target_new'} = $c->web_path("/books") unless $c->session->{'return_target_new'};
+
$c->stash->{'cssfiles'} = [] unless $c->stash->{'cssfiles'};
push @{$c->stash->{'cssfiles'}}, 'books/styles.css';
my ( $self, $c ) = @_;
$c->stash->{'template'} = 'books/index.tt2';
+ $c->session->{'return_target_view'} = $c->web_path("/books");
+ $c->session->{'return_target_edit'} = $c->web_path("/books");
+ $c->session->{'return_target_del'} = $c->web_path("/books");
+ $c->session->{'return_target_new'} = $c->web_path("/books");
}
$c->stash->{'books'} = $buchliste;
$c->stash->{'template'} = 'books/list.tt2';
+ $c->session->{'return_target_view'} = $c->web_path("/books/list");
+ $c->session->{'return_target_edit'} = $c->web_path("/books/list");
+ $c->session->{'return_target_del'} = $c->web_path("/books/list");
+ $c->session->{'return_target_new'} = $c->web_path("/books/list");
}
'name' => "Neu"
};
+ $c->stash->{'return_target'} = $c->session->{'return_target_new'} or $c->web_path("/books");
+
$c->stash->{'template'} = 'books/new.tt2';
push @{$c->stash->{'cssfiles'}}, 'books/form.css';
'name' => "Betrachten"
};
- $c->stash->{'template'} = 'books/view.tt2';
- push @{$c->stash->{'cssfiles'}}, 'books/view.css';
-
$c->stash->{'error_message'} = '';
- $self->prepare_data_structures($c);
-
- $self->bookdata_cgi2session($c);
-
- if ( $c->request->params->{'neuer_autor'} ) {
- $c->session->{'return_target_autor_save'} = $c->stash->{'self_url'};
- $c->detach('/autor/form_new');
+ my $buch_id = to_int( $c->request->params->{'view_book_id'} || 0 );
+ unless ( $buch_id ) {
+ $c->stash->{'template'} = 'error.tt2';
+ $c->stash->{'error'} = 'Keine oder ungültige Buch-Id übergeben.';
+ return 1;
}
- $c->stash->{'book_edit'} = {} unless $c->stash->{'book_edit'};
- $self->bookdata_session2stash($c);
- $c->stash->{'book_edit'}{'title'} = "Neues Buch" unless $c->stash->{'book_edit'}{'title'};
+ 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 ( $c->request->params->{'book_form_sent'} and $c->request->params->{'do_save'} ) {
+ unless ( $buchliste and scalar( @$buchliste ) ) {
+ $c->stash->{'template'} = 'error.tt2';
+ $c->stash->{'error'} = 'Zur übergebenen Buch-Id wurde kein Buch gefunden.';
return 1;
}
- return $self->do_save_book($c);
+ $c->stash->{'return_target'} = $c->session->{'return_target_view'} or $c->web_path("/books/list");
+
+ $c->stash->{'book'} = $buchliste->[0];
+ $buchliste = undef;
+ $c->stash->{'template'} = 'books/view.tt2';
+ push @{$c->stash->{'cssfiles'}}, 'books/view.css';
}
Folgende benannte Parameter koennen ueber $params uebergeben werden:
- - title - Ein konkreter Buchtitel (auch SQL-Metazeichen erlaubt)
- - title_original - Ein konkreter Original-Buchtitel (auch SQL-Metazeichen erlaubt)
- (Hinweis: wenn sowohl 'title' als auch 'title_original' uebergeben werden, werden
- diese ODER-verknuepft)
- - autor_id - Alle Buecher des Autors mit dieser Id
+=over 4
+
+=item I<buch_id>: Die ID eines konkreten Buches
+
+=item I<title>: Ein konkreter Buchtitel (auch SQL-Metazeichen erlaubt)
+
+=item I<title_original>: Ein konkreter Original-Buchtitel (auch SQL-Metazeichen erlaubt)
+
+(Hinweis: wenn sowohl 'title' als auch 'title_original' uebergeben werden, werden diese ODER-verknuepft)
+
+=item I<autor_id>: Alle Buecher des Autors mit dieser Id
+
+=back
Rueckgabe: Eine Array-Ref mit allen Buchtiteln, die den uebergebenen Suchkriterien entsprechen.
my $buchmap = {},
my $b_search_params = undef;
+ if ( $params->{'buch_id'} ) {
+ $b_search_params = { 'me.id' => $params->{'buch_id'} };
+ }
+
my $other_params = {};
$other_params->{'order_by'} = [ 'title' ];
$other_params->{'join'} = [ 'waehrung', 'verlag', 'ort', 'bindungsart' ];
# Autoren zusammensammeln
my $a_search_params = {};
if ( $b_search_params ) {
- my $in = "IN ( " . join( ", ", values %$buchmap ) . " )";
- $a_search_params->{'`buch_id`'} = \$in;
+ my $in = "IN ( " . join( ", ", keys %$buchmap ) . " )";
+ $a_search_params->{'buch_id'} = \$in;
}
$a_search_params = undef unless keys %$a_search_params;
** -%]
[% META title = 'Bücherliste' -%]
-
-<table class="buchliste">
+
+<div class="center">
+
+<table class="wrapper" cellspacing="0">
+<tr><th>Liste der Bücher</th> </tr>
+<tr><td class="action"><a href="[% path('/books/new') %]">Neues Buch ...</a></td></tr>
+<tr><td><table class="buchliste" cellspacing="0">
<tr>
<th>Autor (-en)</th>
<th>Titel</th>
<td class="[% rowstyle %]">[% tt_cat = [ ]; tt_cat.push(cat) FOREACH cat = book.kategorien %][% tt_cat.join(',<br />') %]</td>
<td class="[% rowstyle %]">[% book.verlagsname_short %]</td>
<td class="[% rowstyle %]">[% IF book.orts_id %][% book.ortsname %][% ELSE %]unbekannt[% END %]</td>
- <td class="button [% rowstyle %]"><a href="[% path('/books/view') %]?view_book_id=[% book.id %]">Ansehen</a></td>
- <td class="button [% rowstyle %]"><a href="[% path('/books/edit') %]?edit_book_id=[% book.id %]">Ändern</a></td>
- <td class="button [% rowstyle %]"><a href="[% path('/books/delete') %]?delete_book_id=[% book.id %]">Löschen</a></td>
+ <td class="[% rowstyle %] button"><a href="[% path('/books/view') %]?view_book_id=[% book.id %]">Ansehen</a></td>
+ <td class="[% rowstyle %] button"><a href="[% path('/books/edit') %]?edit_book_id=[% book.id %]">Ändern</a></td>
+ <td class="[% rowstyle %] button"><a href="[% path('/books/delete') %]?delete_book_id=[% book.id %]">Löschen</a></td>
</tr>
[% IF rowstyle == 'even' %][% rowstyle = 'odd'%][% ELSE %][% rowstyle = 'even' %][% END %][% END -%]
-</table>
+</table></td></tr></table>
+</div>
+
[% PROCESS books/book_form.tt2 %]
<div class="back">
-<h2><a href="[% path('/books') %]">[% 'Zurück' %]</a></h2>
+<h2><a href="[% return_target %]">[% 'Zurück' %]</a></h2>
</div>
-%]
/* Stylesheets Buecherlisten */
+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.ftable {
+ border-width: 2px;
+ border-style: solid;
+ border-top-color: [% site.col.tab_rahmen_hell %];
+ border-left-color: [% site.col.tab_rahmen_hell %];
+ border-right-color: [% site.col.tab_rahmen_dkl %];
+ border-bottom-color: [% site.col.tab_rahmen_dkl %];
+ border-collapse: separate;
+ border-spacing: 0;
+ margin: auto;
+}
+
+TABLE.ftable UL {
+ margin: 0;
+}
+
+TABLE.ftable TH {
+ vertical-align: top;
+ text-align: left;
+ padding: 2px;
+ border-width: 1px;
+ border-style: solid;
+ font-size: 1em;
+ border-top-color: [% site.col.tab_rahmen_dkl %];
+ border-left-color: [% site.col.tab_rahmen_dkl %];
+ border-right-color: [% site.col.tab_rahmen_hell %];
+ border-bottom-color: [% site.col.tab_rahmen_hell %];
+ background-color: [% site.col.list_head %];
+}
+
+TABLE.ftable TD {
+ vertical-align: top;
+ padding: 2px;
+ border-width: 1px;
+ border-style: solid;
+ border-top-color: [% site.col.tab_rahmen_dkl %];
+ border-left-color: [% site.col.tab_rahmen_dkl %];
+ border-right-color: [% site.col.tab_rahmen_hell %];
+ border-bottom-color: [% site.col.tab_rahmen_hell %];
+ background-color: [% site.col.list_row_bold %];
+}
+
TABLE.buchliste {
+ text-align: left;
border-width: 2px;
border-style: solid;
border-top-color: [% site.col.tab_rahmen_hell %];
border-bottom-color: [% site.col.tab_rahmen_dkl %];
border-collapse: separate;
border-spacing: 0;
+ margin: auto;
}
TABLE.buchliste TH {
vertical-align: top;
text-align: left;
padding: 2px;
+ font-size: 1em;
border-width: 1px;
border-style: solid;
border-top-color: [% site.col.tab_rahmen_dkl %];
}
TABLE.buchliste TD {
+ text-align: left;
vertical-align: top;
padding: 2px;
border-width: 1px;
background-color: [% site.col.list_row %];
}
+TABLE.buchliste TD.button {
+ font-weight: bolder;
+ text-align: center;
+ padding-left: 1em;
+ padding-right: 1em;
+}
+
$Id$
$URL$
+ Übergebene Struktur in [book]:
+
+ $buch = {
+ 'ausgabejahr' => '2003',
+ 'autoren' => [
+ 'Bill Napier'
+ ],
+ 'bindungsart' => 'Softcover (Taschenbuch)',
+ 'bindungsart_id' => '4',
+ 'buch_nr' => '093314',
+ 'druckjahr' => '2007',
+ 'id' => '5',
+ 'isbn' => undef,
+ 'kategorien' => [
+ 'Mystery-Thriller'
+ ],
+ 'ort_beschreibung' => undef,
+ 'ort_ist_statisch' => undef,
+ 'orts_id' => undef,
+ 'ortsname' => undef,
+ 'preis' => '7.45',
+ 'seiten' => '416',
+ 'serien' => [],
+ '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'
+ }
+
-%]
<!-- Buchanzeige -->
<table class="ftable" cellspacing="0">
<tr>
- <th colspan="2" class="title">Buchangaben '[%- book_edit.title | html -%]'</th>
+ <th colspan="2" class="title">Buchangaben '[%- book.title | html -%]'</th>
</tr><tr>
<td colspan="2"> </td>
</tr><tr>
<th>Autor (-en):</th>
- <td>[% FOR autor_id IN autor_list_book %]
- [% autor_list.$autor_id %][% END %]</td>
- </tr><tr>
- <th>Buchtitel:</th>
- <td>[% book_edit.title | html %]</td>
- </tr><tr>
- <th>Untertitel:</th>
- <td>[% book_edit.untertitel | html %]</td>
- </tr><tr>
- <th>Original-Titel:</th>
- <td>[% book_edit.original_title | html %]</td>
- </tr><tr>
- <th>Verlag:</th>
- <td>[% book_edit.verlagsname_long %]<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="button" name="neuer_verlag" value="*" class="shift_button" title="Neuer Verlag" onclick="goto_new_verlag();" /></td>
- </tr><tr>
- <th>Aufbewahrungsort:</th>
- <td><select name="orts_id" size="1">
- <option value="">-- Aufbewahrungsort auswählen --</option>[% FOR ortsid IN orts_ids %]
- <option value="[% ortsid %]"[% IF book_edit.orts_id == ortsid %] selected[% END %]>[% ortsliste.$ortsid %]</option>[% END %]
- </select> <input type="button" name="neuer_aufbewahrungsort" value="*" class="shift_button" title="Neuer Aufbewahrungsort" onclick="goto_new_ort();" /></td>
- </tr><tr>
- <th>Bindungsart:</th>
- <td><select name="bindungsart_id" size="1">
- <option value="">-- Bindungsart auswählen --</option>[% FOR bart_id IN bindungsarten_ids %]
- <option value="[% bart_id %]"[% IF book_edit.bindungsart_id == bart_id %] selected[% END %]>[% bindungsartenliste.$bart_id %]</option>[% END %]
- </select></td>
- </tr><tr>
- <th>Kategorie(n):</th>
- <td>
- <table class="two_lists" cellspacing="0">
- <tr>
- <th>Verfügbare Kategorien</th>
- <th></th>
- <th>Kategorien des Buchs</th>
- </tr><tr>
- <td><select name="kategorie_not" size="7" multiple>
- <option value="">-- Kategorie oder Kategorien wählen --</option>[% FOR cat_id IN kategorie_list_no %]
- <option value="[% cat_id %]">[% kategorie_list.$cat_id %]</option>
- [% END %]</select></td>
- <td><input type="submit" name="wird_kategorie" value="⇒" class="shift_button" title="Wird Kategorie" /><br /><br />
- <input type="button" name="neue_kategorie" value="*" class="shift_button" title="Neue Kategorie" onclick="goto_new_category();" /><br /><br />
- <input type="submit" name="entf_kategorie" value="⇐" class="shift_button" title="Kategorie entfernen" />
- </td>
- <td><select name="kategorie_book" size="7" multiple>
- <option value="">-- Kategorie oder Kategorien entfernen --</option>[% FOR cat_id IN kategorie_list_book %]
- <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="button" name="neue_serie" value="*" class="shift_button" title="Neue Serie" onclick="goto_new_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>
- </tr><tr>
- <th>Buch-Nummer (verlagseigen):</th>
- <td><input type="text" name="book_nr" size="20" maxlength="100" value="[% book_edit.book_nr | html %]" /></td>
- </tr><tr>
- <th>Ausgabejahr:</th>
- <td><input type="text" name="book_ajahr" size="20" maxlength="20" value="[% book_edit.ausgabejahr | html %]" class="zahl" /></td>
- </tr><tr>
- <th>Druckjahr:</th>
- <td><input type="text" name="book_djahr" size="20" maxlength="20" value="[% book_edit.druckjahr | html %]" class="zahl" /></td>
- </tr><tr>
- <th>Seiten:</th>
- <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" />
- <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> <input type="button" name="neue_waehrung" value="*" class="shift_button" title="Neue Währung" /></td>
- </tr><tr>
- <td colspan="2"> </td>
- </tr><tr>
- <th colspan="2" class="button"><input type="submit" name="do_save" value=" OK " /></th>
- </tr>
- </table>
-</form>
-[%- IF error_message %]
-<div class="error">
-<span class="bold">Fehler:</span> [% error_message %]
-</div>
-[% END -%]
+ <td>[% IF book.autoren.size > 1 %]<ul>[% FOR autor IN book.autoren %]<li>[% autor %]</li>[% END %]</ul>[% ELSE %][% book.autoren.0 %][% END %]</td>
+ </tr><tr>
+ <th>Buchtitel:</th>
+ <td>[% book.title | html %]</td>
+ </tr><tr>
+ <th>Untertitel:</th>
+ <td>[% book.untertitel | html %]</td>
+ </tr><tr>
+ <th>Original-Titel:</th>
+ <td>[% book.title_original | html %]</td>
+ </tr><tr>
+ <th>Verlag:</th>
+ <td>[% book.verlagsname_long | html %]</td>
+ </tr><tr>
+ <th>Aufbewahrungsort:</th>
+ <td>[% book.ortsname | html %]</td>
+ </tr><tr>
+ <th>Bindungsart:</th>
+ <td>[% book.bindungsart | html %]</td>
+ </tr><tr>
+ <th>Kategorie(n):</th>
+ <td>[% IF book.kategorien.size > 1 %]<ul>[% FOR kat IN book.kategorien %]<li>[% kat %]</li>[% END %]</ul>[% ELSE %][% book.kategorien.0 %][% END %]</td>
+ </tr><tr>
+ <th>Buchserien:</th>
+ <td>[% IF book.serien.size > 1 %]<ul>[% FOR serie IN book.serien %]<li>[% serie %]</li>[% END %]</ul>[% ELSE %][% book.serien.0 %][% END %]</td>
+ </tr><tr>
+ <th>ISBN:</th>
+ <td>[% book.isbn | html %]</td>
+ </tr><tr>
+ <th>Buch-Nummer (verlagseigen):</th>
+ <td>[% book.book_nr | html %]</td>
+ </tr><tr>
+ <th>Ausgabejahr:</th>
+ <td>[% book.ausgabejahr | html %]</td>
+ </tr><tr>
+ <th>Druckjahr:</th>
+ <td>[% book.druckjahr | html %]</td>
+ </tr><tr>
+ <th>Seiten:</th>
+ <td>[% book.seiten | html %]</td>
+ </tr><tr>
+ <th>Preis:</th>
+ <td>[% book.preis | format('%.2f') | replace('\.', ',') %] [% book.waehrungs_kuerzel | html %]</td>
+</table>
<div class="back">
-<h2><a href="[% path('/books') %]">[% 'Zurück' %]</a></h2>
+<h2><a href="[% return_target %]">[% 'Zurück' %]</a></h2>
</div>