/[Frey]/branches/zimbardo/lib/App/RoomReservation/Reservation.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /branches/zimbardo/lib/App/RoomReservation/Reservation.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/lib/App/RoomReservation/Reservation.pm revision 1163 by dpavlin, Thu Jul 2 17:57:07 2009 UTC branches/zimbardo/lib/App/RoomReservation/Reservation.pm revision 1181 by dpavlin, Tue Jul 7 22:07:51 2009 UTC
# Line 7  use Regexp::Common qw[Email::Address]; Line 7  use Regexp::Common qw[Email::Address];
7  subtype 'Email',  subtype 'Email',
8          as 'Str',          as 'Str',
9          where { /^$RE{Email}{Address}$/ },          where { /^$RE{Email}{Address}$/ },
10          message { "$_ is not valid e-mail" };          message { qq|<error>$_ nije valjana e-mail adresa / $_ is not valid e-mail address</error>| };
11    
12  extends 'App::RoomReservation';  extends 'App::RoomReservation';
13    
# Line 95  has _canceled => ( Line 95  has _canceled => (
95  );  );
96    
97  sub form_labels {{  sub form_labels {{
98          ime => 'Ime',          ime => 'Ime / Name',
99          prezime => 'Prezime',          prezime => 'Prezime / Surname',
100          institucija => 'Institucija',          institucija => 'Institucija / Institution',
101          zanimanje => 'Zanimanje',          zanimanje => 'Zanimanje / Profession',
102          grad => 'Grad',          grad => 'Grad / City',
103          drzava => 'Država',          drzava => 'Država / Country',
104          telefon => 'Telefon',          telefon => 'Telefon / Phone',
105          mobitel => 'Mobitel',          mobitel => 'Mobitel / Cellular phone',
106          email => 'e-mail adresa',          email => 'e-mail',
107          verify => 'unesite ponovo',          verify => 'ponovo / again',
108            submit => 'Pošalji / Submit', # submit button
109  }}  }}
110    
111    sub form_value_len {
112            my $self = shift;
113            my $sth = $self->dbh->prepare(qq{
114                    select * from reservation limit 1
115            });
116            $sth->execute;
117            my @columns = $sth->fetchrow_array;
118    
119            $sth = $self->dbh->prepare(qq{
120                    select
121            } . join(',', map { "max(length($_)) as $_" } grep { !/^_/ && !/id/ } @{ $sth->{NAME} } ) . qq{
122                    from reservation
123            });
124            $sth->execute;
125            my $max_len = $sth->fetchrow_hashref;
126            warn "# max_len = ", $self->dump( $max_len );
127            return $max_len;
128    }
129    
130  sub BUILD {  sub BUILD {
131          my $self = shift;          my $self = shift;
132          my $email = $self->email;          my $email = $self->email;
133          die "e-mail not verified\n" unless $email eq $self->email_verify;          die qq|<error>e-mail addresses not same</error>| unless $email eq $self->email_verify;
134          my $sth = $self->dbh->prepare(qq{          my $sth = $self->dbh->prepare(qq{
135                  select count(*) from reservation where email = ?                  select count(*) from reservation where email = ?
136          });          });
137          $sth->execute( $email );          $sth->execute( $email );
138          my ($registred) = $sth->fetchrow_array;          my ($registred) = $sth->fetchrow_array;
139          if ( $registred ) {          if ( $registred ) {
140                  die qq|                  die
141                          <big>e-mail address $email allready registred</big>                  qq|
142                  | . $self->seat_confirmation_message( email => $email )                          <error>
143                            <big>e-mail $email je već registriran / allready registred</big>
144                            <br><br>
145                    |
146                    . $self->seat_confirmation_message( email => $email )
147                    . qq|
148                            </error>
149                    |
150                  ;                  ;
151          }          }
152  }  }

Legend:
Removed from v.1163  
changed lines
  Added in v.1181

  ViewVC Help
Powered by ViewVC 1.1.26