sub auto : Private {
my ( $self, $c ) = @_;
- my $K = __PACKAGE__ . "::auto(): ";
+ my $K = ( caller(0) )[3] . "(): ";
$c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
sub default : Private {
my ( $self, $c ) = @_;
- my $K = __PACKAGE__ . "::default(): ";
+ my $K = ( caller(0) )[3] . "(): ";
$c->stash->{'template'} = 'not_implemented.tt2';
sub form_new : Path('new') {
my ( $self, $c ) = @_;
- my $K = __PACKAGE__ . "::form_new(): ";
+ my $K = ( caller(0) )[3] . "(): ";
$c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
$self->autor_session2stash($c);
$c->stash->{'autor_edit'}{'name'} = "Neuer Autor" unless $c->stash->{'autor_edit'}{'name'};
- $c->stash->{'return_target_autor_save'} = $c->session->{'return_target_autor_save'} || $c->web_path('/autor');
-
return 1 unless $c->request->params->{'autor_form_sent'} and $c->request->params->{'do_save'};
return $self->save_author($c);
sub save_author : Private {
my ( $self, $c ) = @_;
- my $K = __PACKAGE__ . "::save_author(): ";
+ my $K = ( caller(0) )[3] . "(): ";
return 1 unless $self->check_formparams($c);
sub check_formparams : Private {
my ( $self, $c ) = @_;
- my $K = __PACKAGE__ . "::check_formparams(): ";
+ my $K = ( caller(0) )[3] . "(): ";
unless ( $c->stash->{'autor_edit'} ) {
$c->stash->{'error_message'} = "Interner Fehler";
sub autor_session2stash : Private {
my ( $self, $c ) = @_;
- my $K = __PACKAGE__ . "::autor_session2stash(): ";
+ my $K = ( caller(0) )[3] . "(): ";
$c->stash->{'autor_edit'} = {} unless $c->stash->{'autor_edit'};
$c->stash->{'autor_edit'}{'id'} = $c->session->{'autor_data_edit'}{'id'} if $c->session->{'autor_data_edit'}{'id'};
$c->stash->{'autor_edit'}{'name'} = $c->session->{'autor_data_edit'}{'name'} if $c->session->{'autor_data_edit'}{'name'};
$c->stash->{'autor_edit'}{'desc'} = $c->session->{'autor_data_edit'}{'desc'} if $c->session->{'autor_data_edit'}{'desc'};
+ $c->stash->{'return_target_autor_save'} = $c->session->{'return_target_autor_save'} || $c->web_path('/autor');
+
return 1;
}
sub autor_cgi2session : Private {
my ( $self, $c ) = @_;
- my $K = __PACKAGE__ . "::autor_cgi2session(): ";
-
- return 1 unless $c->request->params->{'autor_form_sent'};
+ my $K = ( caller(0) )[3] . "(): ";
$c->session->{'return_target_autor_save'} = $c->request->params->{'return_target_form'} if $c->request->params->{'return_target_form'};
+ return 1 unless $c->request->params->{'autor_form_sent'};
+
# Basis anlegen, wenn notwendig
$c->session->{'autor_data_edit'} = {} unless $c->session->{'autor_data_edit'};
--- /dev/null
+package FrBr::Books::Controller::Serie;
+
+# $Id$
+# $URL$
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+
+use FrBr::Common;
+use FrBr::Books::Util::Serie;
+
+=head1 NAME
+
+FrBr::Books::Controller::Serie - Catalyst Controller fuer alles rund um Buchserien
+
+=head1 DESCRIPTION
+
+Catalyst Controller.
+
+=head1 METHODS
+
+=cut
+
+#-------------------------------------------------------
+
+=head2 auto
+
+=cut
+
+sub auto : Private {
+
+ 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("/serie"),
+ 'name' => "Serie"
+ };
+
+ $c->stash->{'cssfiles'} = [] unless $c->stash->{'cssfiles'};
+ push @{$c->stash->{'cssfiles'}}, 'serie/styles.css';
+
+ 1;
+
+} ## end sub auto :
+
+#-------------------------------------------------------
+
+=head2 index
+
+=cut
+
+sub index : Private {
+ my ( $self, $c ) = @_;
+ my $K = ( caller(0) )[3] . "(): ";
+
+ $c->stash->{'template'} = 'serie/index.tt2';
+}
+
+#-------------------------------------------------------
+
+=head2 default
+
+=cut
+
+sub default : Private {
+
+ my ( $self, $c ) = @_;
+ my $K = ( caller(0) )[3] . "(): ";
+
+ $c->stash->{'template'} = 'not_implemented.tt2';
+
+ push @{ $c->stash->{'menu_path'} }, {
+ 'path' => $c->web_path("/serie/default"),
+ 'name' => "Nicht Implementiert"
+ };
+
+} ## end sub default :
+
+#-------------------------------------------------------
+
+=head2 form_new( )
+
+Erstellen einer neuen Buchserie.
+
+=cut
+
+sub form_new : Path('new') {
+
+ 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("/serie/new"),
+ 'name' => "Neu"
+ };
+
+ $c->stash->{'template'} = 'serie/new.tt2';
+ push @{$c->stash->{'cssfiles'}}, 'serie/form.css';
+
+ $c->stash->{'error_message'} = '';
+
+# $self->prepare_data_structures($c);
+
+ $self->serie_cgi2session($c);
+
+ $c->stash->{'serie_edit'} = {} unless $c->stash->{'serie_edit'};
+ $self->serie_session2stash($c);
+ $c->stash->{'serie_edit'}{'name'} = "Neue Buchserie" unless $c->stash->{'serie_edit'}{'name'};
+ $c->stash->{'serie_edit'}{'descr'} = "Beschreibung der Buchserie" unless defined $c->stash->{'serie_edit'}{'descr'};
+
+ return 1 unless $c->request->params->{'serie_form_sent'} and $c->request->params->{'do_save'};
+
+ return $self->do_save_serie($c);
+
+}
+
+#-------------------------------------------------------
+
+sub do_save_serie : Private {
+
+ my ( $self, $c ) = @_;
+ my $K = ( caller(0) )[3] . "(): ";
+
+ return 1 unless $self->check_formparams($c);
+
+ eval {
+ die "Speichern der Buchserie mißlungen." unless save_serie( $c, $c->stash->{'serie_edit'} );
+ };
+ if ( $@ ) {
+ $c->stash->{'error_message'} = $@;
+ return undef;
+ }
+
+ $c->stash->{'template'} = 'serie/save_success.tt2';
+ delete $c->session->{'serie_data_edit'} if exists $c->session->{'serie_data_edit'};
+ delete $c->session->{'return_target_serie_save'} if exists $c->session->{'return_target_serie_save'};
+
+ return 1;
+
+}
+
+#-------------------------------------------------------
+
+sub check_formparams : Private {
+
+ my ( $self, $c ) = @_;
+ my $K = ( caller(0) )[3] . "(): ";
+
+ unless ( $c->stash->{'serie_edit'} ) {
+ $c->stash->{'error_message'} = "Interner Fehler";
+ return undef;
+ }
+
+ unless ( $c->stash->{'serie_edit'}{'name'} ) {
+ $c->stash->{'error_message'} = "Kein Name der Buchserie angegeben.";
+ return undef;
+ }
+
+ return 1;
+
+}
+
+#-------------------------------------------------------
+
+sub serie_cgi2session : Private {
+
+ my ( $self, $c ) = @_;
+ my $K = ( caller(0) )[3] . "(): ";
+
+ $c->session->{'return_target_serie_save'} = $c->request->params->{'return_target_form'} if $c->request->params->{'return_target_form'};
+
+ return 1 unless $c->request->params->{'serie_form_sent'};
+
+ # Basis anlegen, wenn notwendig
+ $c->session->{'serie_data_edit'} = {} unless $c->session->{'serie_data_edit'};
+
+ # Serien-Id eintragen, wenn notwendig
+ $c->session->{'serie_data_edit'}{'id'} = $c->request->params->{'serien_id'} if $c->request->params->{'serien_id'};
+
+ # Name der Serie
+ if ( defined $c->request->params->{'serien_name'} ) {
+ my $name = $c->request->params->{'serien_name'};
+ $name =~ s/^\s+//;
+ $name =~ s/\s+$//;
+ $c->session->{'serie_data_edit'}{'name'} = $name;
+ }
+
+ # Beschreibung der Serie
+ if ( defined $c->request->params->{'serien_descr'} ) {
+ my $descr = $c->request->params->{'serien_descr'};
+ $descr =~ s/^\s+//;
+ $descr =~ s/\s+$//;
+ $c->session->{'serie_data_edit'}{'descr'} = $descr;
+ }
+ else {
+ $c->session->{'serie_data_edit'}{'descr'} = '';
+ }
+
+ return 1;
+
+}
+
+#-------------------------------------------------------
+
+sub serie_session2stash : Private {
+
+ my ( $self, $c ) = @_;
+ my $K = ( caller(0) )[3] . "(): ";
+
+ $c->log->debug( get_output_string( $K . "Buchserie in der Session:", $c->session->{'serie_data_edit'} ) ) if $c->stash->{'debug_level'} > 2;
+
+ $c->stash->{'serie_edit'} = {} unless $c->stash->{'serie_edit'};
+ $c->stash->{'serie_edit'}{'id'} = $c->session->{'serie_data_edit'}{'id'} if $c->session->{'serie_data_edit'}{'id'};
+ $c->stash->{'serie_edit'}{'name'} = $c->session->{'serie_data_edit'}{'name'} if $c->session->{'serie_data_edit'}{'name'};
+ $c->stash->{'serie_edit'}{'descr'} = $c->session->{'serie_data_edit'}{'descr'};
+
+ $c->stash->{'return_target_serie_save'} = $c->session->{'return_target_serie_save'} || $c->web_path('/kategorie');
+
+ return 1;
+
+}
+
+#-------------------------------------------------------
+
+=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;
+
+__END__
+
+# vim: noai : ts=4 fenc=utf-8 filetype=perl expandtab :
"untertitel" => { data_type => "VARCHAR", default_value => undef, is_nullable => 1, size => 250, },
"bindungsart_id" => { data_type => "INT", default_value => undef, is_nullable => 1, size => 10 },
"verlags_id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 },
+ "orts_id" => { data_type => "INT", default_value => undef, is_nullable => 1, size => 10 },
"isbn" => { data_type => "VARCHAR", default_value => undef, is_nullable => 1, size => 20, },
"buch_nr" => { data_type => "VARCHAR", default_value => undef, is_nullable => 1, size => 100, },
"ausgabejahr" => { data_type => "MEDIUMINT", default_value => undef, is_nullable => 1, size => 8, },
__PACKAGE__->might_have( 'waehrung' => 'FrBr::Books::Db::Waehrungen', { 'foreign.id' => 'self.waehrungs_id' } );
__PACKAGE__->might_have( 'verlag' => 'FrBr::Books::Db::Verlage', { 'foreign.id' => 'self.verlags_id' } );
+__PACKAGE__->might_have( 'ort' => 'FrBr::Books::Db::Orte', { 'foreign.id' => 'self.orts_id' } );
__PACKAGE__->might_have( 'bindungsart' => 'FrBr::Books::Db::Bindungsarten', { 'foreign.id' => 'self.bindungsart_id' } );
# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-03-17 17:53:52
--- /dev/null
+package FrBr::Books::Db::Orte;
+
+# $Id$
+# $URL$
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class';
+
+__PACKAGE__->load_components("Core");
+__PACKAGE__->table("orte");
+__PACKAGE__->add_columns(
+ "id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 },
+ "name" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 100, },
+ "descr" => { data_type => "TEXT", default_value => undef, is_nullable => 0, size => 65535, },
+ "statisch" => { data_type => "ENUM", default_value => "n", is_nullable => 0, size => 1 },
+);
+__PACKAGE__->set_primary_key("id");
+__PACKAGE__->add_unique_constraint("name", ["name"]);
+
+
+# Created by DBIx::Class::Schema::Loader v0.04004 @ 2008-03-17 17:53:52
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QwPjYKNwUnR5b418xxulDg
+
+
+# You can replace this text with custom content, and it will be preserved on regeneration
+1;
+
+__END__
+
+# vim: noai : ts=4 fenc=utf-8 filetype=perl expandtab :
@ISA = qw(Exporter);
@EXPORT = qw(
&get_serienliste
+ &save_serie
);
#%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
sub get_serienliste {
my $c = shift;
- my $K = __PACKAGE__ . "::get_serienliste(): ";
+ my $K = ( caller(0) )[3] . "(): ";
$c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
#-----------------------------------------------------------------------------------
+=head2 save_serie( $c, $serie )
+
+=cut
+
+sub save_serie {
+
+ my $c = shift;
+ my $serie = shift;
+ my $K = ( caller(0) )[3] . "(): ";
+
+ $c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
+
+ my $storage = $c->stash->{'storage'};
+
+ my $save_func = sub {
+ my ( $storage, $dbh, $serien_id, $serien_name, $serien_desc ) = @_;
+ my $sql = <<ENDE;
+INSERT INTO `serien` (
+ `id`, `serien_name`, `descr` )
+ VALUES (
+ ?, ?, ? )
+ ON DUPLICATE KEY UPDATE
+ `id` = LAST_INSERT_ID(`id`), `serien_name` = ?, `descr` = ?
+ENDE
+
+ if ( $storage->debug() ) {
+ my $text = $sql;
+ $text =~ s/\s+$//;
+ $text .= ": " . join( ", ", map { $dbh->quote($_) } ( $serien_id, $serien_name, $serien_desc, $serien_name, $serien_desc ) ) . "\n";
+ warn $text;
+ }
+
+ my $sth = $dbh->prepare($sql);
+ $sth->execute( $serien_id, $serien_name, $serien_desc, $serien_name, $serien_desc );
+ };
+
+ $storage->dbh_do( $save_func, $serie->{'id'}, $serie->{'name'}, $serie->{'descr'} );
+
+ return $storage->last_insert_id();
+
+}
+
+#-----------------------------------------------------------------------------------
+
=head1 AUTHOR
Frank Brehm
window.location.href = target;
}
+function goto_new_serie() {
+ var target = '[% Catalyst.web_path( '/serie/new', { 'return_target_form' => self_url } ) %]';
+ window.location.href = target;
+}
+
//]]></script>
<form method="post" name="book_form" action="[% self_url %]">
<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" /><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>
</td>
<td class="item">
<a href="[% path('/kategorie') %]">Kategorien</a></td>
+ </tr><tr>
+ <td colspan="2" class="empty">
+ </td>
+ </tr><tr>
+ <td class="button">
+ </td>
+ <td class="item">
+ <a href="[% path('/serie') %]">Buchserien</a></td>
</tr>
</table>
</div>
--- /dev/null
+[%#
+ # Template fuer Stylesheets Buchserienformular
+ #
+ # $Id$
+ # $URL$
+ #
+-%]
+/* Stylesheets Buchserienformular */
+
+
--- /dev/null
+[%#
+
+ Template für Formular Buchserie
+
+ vim: noai : ts=4 fenc=utf-8 filetype=html expandtab :
+
+ $Id$
+ $URL$
+
+-%]
+
+<!-- Buchserien-Formular -->
+
+<form method="post" name="serien_form" action="[% self_url %]">
+<input type="hidden" name="serie_form_sent" value="sent" />
+[%- IF serie_edit.id %]<input type="hidden" name="serien_id" value="[% serie_edit.id | html %]" />[% END %]
+ <table class="ftable" cellspacing="0">
+ <tr>
+ <th colspan="2" class="title">[% serie_form_title %]</th>
+ </tr><tr>
+ <td colspan="2"> </td>
+ </tr><tr>
+ <th>Buchserie:</th>
+ <td><input type="text" name="serien_name" size="50" maxlength="100" value="[% serie_edit.name | html %]" /></td>
+ </tr><tr>
+ <td colspan="2"> </td>
+ </tr><tr>
+ <th>Beschreibung:</th>
+ <td><textarea name="serien_descr" cols="50" rows="10">[% serie_edit.descr | html %]</textarea></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 -%]
--- /dev/null
+[%#
+
+ index.tt2 - Index-Template (Menue) fuer Buchserien
+
+ vim: noai : ts=4 fenc=utf-8 filetype=html expandtab :
+
+ $Id$
+ $URL$
+
+-%]
+<div style="text-align: center">
+<table class="menu" cellspacing="0">
+ <tr>
+ <th colspan="2">Menü</th>
+ </tr>
+ <tr>
+ <td colspan="2" class="empty">
+ </td>
+ </tr>
+ <tr>
+ <td class="button">
+ </td>
+ <td class="item">
+ <a href="[% path('/serie/list') %]">Liste der Buchserien</a></td>
+ </tr>
+ <tr>
+ <td colspan="2" class="empty">
+ </td>
+ </tr>
+ <tr>
+ <td class="button">
+ </td>
+ <td class="item">
+ <a href="[% path('/serie/new') %]">Neue Buchserie</a></td>
+ </tr>
+ <tr>
+ <td colspan="2" class="empty">
+ </td>
+ </tr>
+ <tr>
+ <td class="button">
+ </td>
+ <td class="item">
+ <a href="[% path('/') %]">Zurück zum Hauptmenü</a></td>
+ </tr>
+</table>
+</div>
--- /dev/null
+[%#
+
+ Template für neue Buchserie
+
+ vim: noai : ts=4 fenc=utf-8 filetype=html expandtab :
+
+ $Id$
+ $URL$
+
+-%]
+[%- serie_form_title = 'Neue Buchserie' -%]
+[% PROCESS serie/form.tt2 %]
+
+<div class="back">
+<h2><a href="[% return_target_serie_save %]">[% 'Zurück' %]</a></h2>
+</div>
--- /dev/null
+[%#
+
+ save_success.tt2 - Template fuer erfolgreiches Speichern der Buchserie
+
+ vim: noai : ts=4 fenc=utf-8 filetype=html expandtab :
+
+ $Id$
+ $URL$
+
+-%]
+<div style="text-align: center">
+
+Die Buchserie <b>"[% serie_edit.name %]</b> wurde erfolgreich gespeichert.
+
+<h2><a href="[% return_target_serie_save %]">OK</a></h2>
+
+</div>
--- /dev/null
+/* [%#
+ # Template fuer Stylesheets Buchserien
+ #
+ # $Id$
+ # $URL$
+ #
+-%]
+ Stylesheets Buchserien */
+
+