]> Frank Brehm's Git Trees - books.git/commitdiff
Verlag ansehen
authorFrank Brehm <frank@brehm-online.com>
Tue, 9 Jun 2009 22:59:23 +0000 (22:59 +0000)
committerFrank Brehm <frank@brehm-online.com>
Tue, 9 Jun 2009 22:59:23 +0000 (22:59 +0000)
lib/FrBr/Books/Controller/Verlag.pm
lib/FrBr/Books/Util/Verlag.pm
root/src/verlag/view.css [new file with mode: 0644]
root/src/verlag/view.tt2 [new file with mode: 0644]

index 7159bab3eb6269a67cf715f4c11e769f52f415fc..d77b08afc8c83b537dacf5672d9f83db6a283c13 100644 (file)
@@ -99,7 +99,7 @@ sub list : Local {
         'name' => "Liste"
     };
 
-    my $liste = get_verlagsliste( $c, 'get_books' => 1 );
+    my $liste = get_verlagsliste( $c  );
     $c->log->debug( get_output_string( $K, "Erhaltene Liste der Verlage: ", $liste ) ) if $c->stash->{'debug_level'} >= 2;
     $c->stash->{'verlage'} = $liste;
 
@@ -109,6 +109,55 @@ sub list : Local {
 
 #-------------------------------------------------------
 
+=head2 form_view( )
+
+Ansehen eines vorhandenen Verlages.
+
+=cut
+
+sub form_view : Path('view') {
+
+       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("/verlag/view"),
+               'name' => "Betrachten"
+       };
+
+       $c->stash->{'error_message'} = '';
+
+       my $verlags_id = to_int( $c->request->params->{'view_verlags_id'} || 0 );
+       unless ( $verlags_id ) {
+               $c->stash->{'template'} = 'error.tt2';
+               $c->stash->{'error'}    = 'Keine oder ung&uuml;ltige Verlags-Id &uuml;bergeben.';
+               return 1;
+       }
+
+
+       my $verlagsliste = get_verlagsliste( $c, 'verlags_id' => $verlags_id, 'get_books' => 1, );
+       $c->log->debug( get_output_string( $K, "Erhaltene Verlagsliste: ", $verlagsliste ) ) if $c->stash->{'debug_level'} >= 2;
+
+       unless ( $verlagsliste and scalar( @$verlagsliste ) ) {
+               $c->stash->{'template'} = 'error.tt2';
+               $c->stash->{'error'}    = 'Zur &uuml;bergebenen Verlags-Id wurde kein Verlag gefunden.';
+               return 1;
+       }
+
+       $c->stash->{'return_target'} = $c->web_path("/verlag/list");
+
+       $c->stash->{'verlag'}     = $verlagsliste->[0];
+       $verlagsliste = undef;
+       $c->stash->{'template'} = 'verlag/view.tt2';
+       push @{$c->stash->{'cssfiles'}}, 'verlag/view.css';
+
+}
+
+#-------------------------------------------------------
+
 =head2 form_new( )
 
 Erstellen eines neuen Verlages.
@@ -273,4 +322,4 @@ it under the same terms as Perl itself.
 
 __END__
 
-# vim: noai : ts=4 fenc=utf-8 filetype=perl expandtab : 
+# vim: noai : ts=4 fenc=utf-8 filetype=perl
index 64280b3d513b12621b0507378fc1d3bfa239d42d..6307f724cc6d1c104d4872ced59fdc65c195d9db 100644 (file)
@@ -53,6 +53,11 @@ Folgende benannte Parameter koennen ueber $params uebergeben werden:
 
 =over 4
 
+=item B<verlags_id>: Die ID eines konkreten Verlages
+
+=item B<get_books>: Bool. Zeigt an, daß zu den gefundenen Verlagen die dazugehörigen
+Bücher geholt werden sollen.
+
 =item B<page>
 
 Integer: Zeigt an, welche Seite von Verlagen dargestellt werden soll.
@@ -103,6 +108,11 @@ sub get_verlagsliste {
        $rows = $c->stash->{'list_length'} || 20 if defined $page;
 
     my $search_params = undef;
+       if ( $params->{'verlags_id'} ) {
+               $search_params = {
+                       'me.id' => $params->{'verlags_id'},
+               };
+       }
 
     my $other_params = {};
     $other_params->{'order_by'} = [ 'name_short' ];
@@ -135,7 +145,132 @@ sub get_verlagsliste {
         push @$list, $verlag;
     }
 
-    return $list;
+       return $list unless scalar $list;
+    return $list unless $params->{'get_books'};
+
+       for my $verlag ( @$list ) {
+
+               $verlag->{'books'} = [];
+
+               my $vid = $verlag->{'id'};
+               $search_params = {
+                       "verlags_id" => $vid,
+               };
+               $other_params = {};
+               $other_params->{'join'}     = [ 'waehrung', 'ort', 'bindungsart' ];
+               $other_params->{'select'} = [
+                       'me.id',
+                       'me.title',
+                       'me.title_original',
+                       'me.untertitel',
+                       'me.bindungsart_id',
+                       'bindungsart.art_name',
+                       'me.orts_id',
+                       'me.isbn',
+                       'me.buch_nr',
+                       'me.ausgabejahr',
+                       'me.druckjahr',
+                       'me.seiten',
+                       'me.preis',
+                       'me.waehrungs_id',
+                       'waehrung.waehrungs_kuerzel',
+                       'waehrung.waehrungs_name',
+                       'waehrung.umrechnung_in_euro',
+                       'ort.name',
+                       'ort.descr',
+                       'ort.statisch',
+               ];
+               $other_params->{'as'} = [
+                       'id',
+                       'title',
+                       'title_original',
+                       'untertitel',
+                       'bindungsart_id',
+                       'bindungsart',
+                       'orts_id',
+                       'isbn',
+                       'buch_nr',
+                       'ausgabejahr',
+                       'druckjahr',
+                       'seiten',
+                       'preis',
+                       'waehrungs_id',
+                       'waehrungs_kuerzel',
+                       'waehrungs_name',
+                       'umrechnung_in_euro',
+                       'ortsname',
+                       'ort_beschreibung',
+                       'ort_ist_statisch',
+               ];
+
+               for my $book ( $c->model('Schema::Buecher')->search( $search_params, $other_params )->all() ) {
+                       my $buch = {};
+                       $buch->{'id'}                 = $book->id();
+                       $buch->{'title'}              = $book->title();
+                       $buch->{'title_original'}     = $book->title_original();
+                       $buch->{'untertitel'}         = $book->untertitel();
+                       $buch->{'bindungsart_id'}     = $book->bindungsart_id();
+                       $buch->{'bindungsart'}        = $book->get_column('bindungsart');
+                       $buch->{'orts_id'}            = $book->orts_id();
+                       $buch->{'isbn'}               = $book->isbn();
+                       $buch->{'buch_nr'}            = $book->buch_nr();
+                       $buch->{'ausgabejahr'}        = $book->ausgabejahr();
+                       $buch->{'druckjahr'}          = $book->druckjahr();
+                       $buch->{'seiten'}             = $book->seiten();
+                       $buch->{'preis'}              = $book->preis();
+                       $buch->{'waehrungs_id'}       = $book->waehrungs_id();
+                       $buch->{'waehrungs_kuerzel'}  = $book->get_column('waehrungs_kuerzel');
+                       $buch->{'waehrungs_name'}     = $book->get_column('waehrungs_name');
+                       $buch->{'umrechnung_in_euro'} = $book->get_column('umrechnung_in_euro');
+                       $buch->{'ortsname'}           = $book->get_column('ortsname');
+                       $buch->{'ort_beschreibung'}   = $book->get_column('ort_beschreibung');
+                       $buch->{'ort_ist_statisch'}   = $book->get_column('ort_ist_statisch');
+                       $buch->{'autoren'}            = [];
+                       $buch->{'autor_ids'}          = [];
+
+                       my $a_search_params = {};
+                       $a_search_params->{'buch_id'} = $buch->{'id'};
+                       $other_params = {};
+                       $other_params->{'order_by'} = [ 'ord_num' ];
+                       $other_params->{'join'}     = [ 'autor' ];
+                       $other_params->{'select'} = [
+                               'me.buch_id',
+                               'autor.id',
+                               'autor.titel',
+                               'autor.vorname',
+                               'autor.mittelname',
+                               'autor.nachname',
+                               'autor.name_suffix',
+                       ];
+                       $other_params->{'as'} = [
+                               'buch_id',
+                               'autor_id',
+                               'titel',
+                               'vorname',
+                               'mittelname',
+                               'nachname',
+                               'name_suffix',
+                       ];
+                       for my $ref ( $c->model('Schema::Autor2buch')->search( $a_search_params, $other_params )->all() ) {
+                               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');
+                               push @N, $ref->get_column('mittelname') if $ref->get_column('mittelname');
+                               push @N, $ref->get_column('nachname');
+                               push @N, $ref->get_column('name_suffix') if $ref->get_column('name_suffix');
+                               my $autor = join( " ", @N );
+                               push @{ $buch->{'autoren'} },   $autor;
+                               push @{ $buch->{'autor_ids'} }, $aid;
+                       }
+
+                       push @{ $verlag->{'books'} }, $buch;
+
+               }
+
+       }
+
+       return $list;
 }
 
 #-----------------------------------------------------------------------------------
diff --git a/root/src/verlag/view.css b/root/src/verlag/view.css
new file mode 100644 (file)
index 0000000..8cb7532
--- /dev/null
@@ -0,0 +1,74 @@
+/* [%#
+   # Template fuer Stylesheets Buchanzeige
+   #
+   # vim: noai : ts=4 fenc=utf-8 filetype=css 
+   #
+   # $Id$
+   # $URL$
+   #
+-%]
+  Stylesheets Verlagsanzeige */
+
+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.ftable TD.empty {
+  height:              0.5em;
+}
+
+TABLE.ftable TH.button {
+  font-weight:         bolder;
+  text-align:           center;
+  font-size:           1.2em;
+  padding-left:                1em;
+  padding-right:       1em;
+}
+
+TABLE.ftable TH.button INPUT {
+  font-weight:         bolder;
+  text-align:           center;
+  font-size:           1em;
+  padding-left:                1em;
+  padding-right:       1em;
+}
+
+
diff --git a/root/src/verlag/view.tt2 b/root/src/verlag/view.tt2
new file mode 100644 (file)
index 0000000..9144f86
--- /dev/null
@@ -0,0 +1,82 @@
+<!-- [%#
+
+    Template fuer Verlagsanzeige
+
+    vim: noai : ts=4 fenc=utf-8 filetype=html
+
+    $Id$
+    $URL$
+
+    Übergebene Struktur in [verlag]:
+
+       $verlag = {
+               'books' => [
+                       {
+                               'ausgabejahr' => '2004',
+                               'autor_ids' => [
+                                       '11',
+                               ],
+                               'autoren' => [
+                                       'Markus Heitz',
+                               ],
+                               'bindungsart' => 'Softcover (Taschenbuch)',
+                               'bindungsart_id' => '4',
+                               'buch_nr' => undef,
+                               'druckjahr' => '2006',
+                               'id' => '11',
+                               'isbn' => '3-492-70076-4',
+                               'ort_beschreibung' => '',
+                               'ort_ist_statisch' => 'n',
+                               'orts_id' => '2',
+                               'ortsname' => 'Flur - Glasvitrine',
+                               'preis' => '14',
+                               'seiten' => '640',
+                               'title' => 'Die Zwerge',
+                               'title_original' => undef,
+                               'umrechnung_in_euro' => '1',
+                               'untertitel' => undef,
+                               'waehrungs_id' => '1',
+                               'waehrungs_kuerzel' => '€',
+                               'waehrungs_name' => 'Euro',
+               },
+                       {
+                               ...
+                       },
+               ],
+               'count_books' => '1',
+               'descr' => '',
+               'id' => '8',
+               'name' => 'Piper',
+       };
+
+-%]
+[%- BLOCK book_entry -%]
+[% book.title | html %][% IF book.autoren.size %] ([% book.autoren.join( ', ' ) | html %])[% END %]
+[%- END -%]
+
+
+Verlagsanzeige -->
+
+<table class="ftable" cellspacing="0">
+  <tr>
+    <th colspan="2" class="title">Verlagsangaben '[%- verlag.name | html -%]'</th>
+  </tr><tr>
+    <td colspan="2" class="empty"></td>
+  </tr><tr>
+    <th>Verlag:</th>
+    <td>[%- verlag.name | html -%]</td>
+  </tr><tr>
+    <th>Kompletter Verlagsname / Beschreibung:</th>
+    <td>[%- verlag.descr | html %]</td>
+  </tr><tr>
+    <th>Anzahl Bücher:</th>
+    <td>[%- verlag.count_books | html -%]</td>
+  </tr><tr>
+    <th>Bücher:</th>
+    <td>[% IF verlag.count_books > 1 %]<ul>[% FOR buch IN verlag.books %]<li>[% PROCESS book_entry book=buch %]</li>[% END %]</ul>[% ELSE %][% PROCESS book_entry book=verlag.books.0 %][% END %]</td>
+</table>
+
+<div class="back">
+<h2><a href="[% return_target %]">[% 'Zurück' %]</a></h2>
+</div>
+