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 56-65
if ( $op eq 'add_form' ) {
Link Here
|
56 |
} |
57 |
} |
57 |
|
58 |
|
58 |
my @smtp_servers = Koha::SMTP::Servers->search; |
59 |
my @smtp_servers = Koha::SMTP::Servers->search; |
|
|
60 |
my @opening_hours = Koha::Library::Hours->search({ branchcode => $branchcode }, { order_by => { -asc => 'day' } }); |
59 |
|
61 |
|
60 |
$template->param( |
62 |
$template->param( |
61 |
library => $library, |
63 |
library => $library, |
62 |
smtp_servers => \@smtp_servers |
64 |
smtp_servers => \@smtp_servers, |
|
|
65 |
opening_hours => \@opening_hours |
63 |
); |
66 |
); |
64 |
} elsif ( $op eq 'add_validate' ) { |
67 |
} elsif ( $op eq 'add_validate' ) { |
65 |
my @fields = qw( |
68 |
my @fields = qw( |
Lines 117-122
if ( $op eq 'add_form' ) {
Link Here
|
117 |
} |
120 |
} |
118 |
} |
121 |
} |
119 |
|
122 |
|
|
|
123 |
my @days = $input->multi_param("day"); |
124 |
my @open_times = $input->multi_param("open_time"); |
125 |
my @close_times = $input->multi_param("close_time"); |
126 |
|
127 |
foreach my $day ( @days ) { |
128 |
if ( $open_times[$day] and $open_times[$day] eq '' ) { |
129 |
$open_times[$day] = undef; |
130 |
} |
131 |
if ( $close_times[$day] and $close_times[$day] eq '' ) { |
132 |
$close_times[$day] = undef; |
133 |
} |
134 |
|
135 |
my $openday = Koha::Library::Hours->find({ branchcode => $branchcode, day => $day })->update({ open_time => $open_times[$day], close_time => $close_times[$day] }); |
136 |
} |
137 |
|
120 |
push @messages, { type => 'message', code => 'success_on_update' }; |
138 |
push @messages, { type => 'message', code => 'success_on_update' }; |
121 |
} |
139 |
} |
122 |
); |
140 |
); |
Lines 155-160
if ( $op eq 'add_form' ) {
Link Here
|
155 |
} |
173 |
} |
156 |
} |
174 |
} |
157 |
|
175 |
|
|
|
176 |
my @days = $input->multi_param("day"); |
177 |
my @open_times = $input->multi_param("open_time"); |
178 |
my @close_times = $input->multi_param("close_time"); |
179 |
|
180 |
foreach my $day ( @days ) { |
181 |
if ( $open_times[$day] and $open_times[$day] eq '' ) { |
182 |
$open_times[$day] = undef; |
183 |
} |
184 |
if ( $close_times[$day] and $close_times[$day] eq '' ) { |
185 |
$close_times[$day] = undef; |
186 |
} |
187 |
|
188 |
my $openday = Koha::Library::Hour->new({ branchcode => $branchcode, day => $day, open_time => $open_times[$day], close_time => $close_times[$day] })->store; |
189 |
} |
190 |
|
158 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
191 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
159 |
} |
192 |
} |
160 |
); |
193 |
); |