Lines 33-38
use Koha::Patrons;
Link Here
|
33 |
use Koha::Items; |
33 |
use Koha::Items; |
34 |
use Koha::Libraries; |
34 |
use Koha::Libraries; |
35 |
use Koha::SMTP::Servers; |
35 |
use Koha::SMTP::Servers; |
|
|
36 |
use Koha::Library::Hours; |
36 |
|
37 |
|
37 |
my $input = CGI->new; |
38 |
my $input = CGI->new; |
38 |
my $branchcode = $input->param('branchcode'); |
39 |
my $branchcode = $input->param('branchcode'); |
Lines 49-57
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Link Here
|
49 |
); |
50 |
); |
50 |
|
51 |
|
51 |
if ( $op eq 'add_form' ) { |
52 |
if ( $op eq 'add_form' ) { |
|
|
53 |
my $library; |
54 |
if ($branchcode) { |
55 |
$library = Koha::Libraries->find($branchcode); |
56 |
$template->param( selected_smtp_server => $library->smtp_server ); |
57 |
} |
58 |
|
59 |
my @smtp_servers = Koha::SMTP::Servers->search; |
60 |
my @opening_hours = Koha::Library::Hours->search({ branchcode => $branchcode }, { order_by => { -asc => 'day' } }); |
61 |
|
52 |
$template->param( |
62 |
$template->param( |
53 |
library => Koha::Libraries->find($branchcode), |
63 |
library => $library, |
54 |
smtp_servers => Koha::SMTP::Servers->search, |
64 |
smtp_servers => \@smtp_servers, |
|
|
65 |
opening_hours => \@opening_hours |
55 |
); |
66 |
); |
56 |
} elsif ( $op eq 'add_validate' ) { |
67 |
} elsif ( $op eq 'add_validate' ) { |
57 |
my @fields = qw( |
68 |
my @fields = qw( |
Lines 110-115
if ( $op eq 'add_form' ) {
Link Here
|
110 |
} |
121 |
} |
111 |
} |
122 |
} |
112 |
|
123 |
|
|
|
124 |
my @days = $input->multi_param("day"); |
125 |
my @open_times = $input->multi_param("open_time"); |
126 |
my @close_times = $input->multi_param("close_time"); |
127 |
|
128 |
foreach my $day ( @days ) { |
129 |
if ( $open_times[$day] and $open_times[$day] eq '' ) { |
130 |
$open_times[$day] = undef; |
131 |
} |
132 |
if ( $close_times[$day] and $close_times[$day] eq '' ) { |
133 |
$close_times[$day] = undef; |
134 |
} |
135 |
|
136 |
my $openday = Koha::Library::Hours->find({ branchcode => $branchcode, day => $day })->update({ open_time => $open_times[$day], close_time => $close_times[$day] }); |
137 |
} |
138 |
|
113 |
push @messages, { type => 'message', code => 'success_on_update' }; |
139 |
push @messages, { type => 'message', code => 'success_on_update' }; |
114 |
} |
140 |
} |
115 |
); |
141 |
); |
Lines 148-153
if ( $op eq 'add_form' ) {
Link Here
|
148 |
} |
174 |
} |
149 |
} |
175 |
} |
150 |
|
176 |
|
|
|
177 |
my @days = $input->multi_param("day"); |
178 |
my @open_times = $input->multi_param("open_time"); |
179 |
my @close_times = $input->multi_param("close_time"); |
180 |
|
181 |
foreach my $day ( @days ) { |
182 |
if ( $open_times[$day] and $open_times[$day] eq '' ) { |
183 |
$open_times[$day] = undef; |
184 |
} |
185 |
if ( $close_times[$day] and $close_times[$day] eq '' ) { |
186 |
$close_times[$day] = undef; |
187 |
} |
188 |
|
189 |
my $openday = Koha::Library::Hour->new({ branchcode => $branchcode, day => $day, open_time => $open_times[$day], close_time => $close_times[$day] })->store; |
190 |
} |
191 |
|
151 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
192 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
152 |
} |
193 |
} |
153 |
); |
194 |
); |