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