]> git.imager.perl.org - bse.git/blob - site/cgi-bin/modules/BSE/TB/Seminar.pm
add support for storing custom metadata to cart/order items and options
[bse.git] / site / cgi-bin / modules / BSE / TB / Seminar.pm
1 package BSE::TB::Seminar;
2 use strict;
3 # represents a seminar from the database
4 use BSE::TB::Product;
5 use vars qw/@ISA/;
6 @ISA = qw/BSE::TB::Product/;
7 use BSE::Util::SQL qw(now_sqldatetime);
8
9 our $VERSION = "1.001";
10
11 sub columns {
12   return ($_[0]->SUPER::columns(), 
13           qw/seminar_id duration/ );
14 }
15
16 sub bases {
17   return { seminar_id=>{ class=>'BSE::TB::Product'} };
18 }
19
20 sub sessions {
21   my ($self) = @_;
22
23   require BSE::TB::SeminarSessions;
24   BSE::TB::SeminarSessions->getBy(seminar_id => $self->{id});
25 }
26
27 sub future_sessions {
28   my ($self) = @_;
29
30   require BSE::TB::SeminarSessions;
31   BSE::TB::SeminarSessions->getSpecial(futureSessions => $self->{id}, now_sqldatetime());
32 }
33
34 sub session_info {
35   my ($self) = @_;
36
37   BSE::DB->query(seminarSessionInfo => $self->{id});
38 }
39
40 sub session_info_unbooked {
41   my ($self, $user) = @_;
42
43   BSE::DB->query(seminarSessionInfoUnbooked => $user->{id}, $self->{id});
44 }
45
46 sub future_session_info {
47   my ($self) = @_;
48
49   BSE::DB->query(seminarFutureSessionInfo=>$self->{id}, now_sqldatetime());
50 }
51
52 sub add_session {
53   my ($self, $when, $location) = @_;
54
55   require BSE::TB::SeminarSessions;
56   my %cols = 
57     ( 
58      seminar_id => $self->{id},
59      when_at => $when,
60      location_id => ref $location ? $location->{id} : $location,
61      roll_taken => 0,
62     );
63   my @cols = BSE::TB::SeminarSession->columns;
64   shift @cols;
65   return BSE::TB::SeminarSessions->add(@cols{@cols});
66 }
67
68 sub future_locations {
69   my ($self) = @_;
70
71   require BSE::TB::Locations;
72   return BSE::TB::Locations->getSpecial
73     (seminarFuture => $self->{id}, now_sqldatetime());
74 }
75
76 sub future_location_sessions {
77   my ($self, $location) = @_;
78
79   require BSE::TB::SeminarSessions;
80   return BSE::TB::SeminarSessions->getSpecial
81     (futureSeminarLocation => $self->{id}, $location->{id}, now_sqldatetime());
82 }
83
84 sub get_unbooked_by_user {
85   my ($self, $user) = @_;
86
87   require BSE::TB::SeminarSessions;
88   BSE::TB::SeminarSessions->getSpecial(sessionsUnbookedByUser => 
89                                        $user->{id}, $self->{id});
90 }
91
92 1;