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 @opening_hours = Koha::Library::Hours->search({ branchcode => $branchcode }, { order_by => { -asc => 'day' } })->as_list; |
54 |
|
52 |
$template->param( |
55 |
$template->param( |
53 |
library => Koha::Libraries->find($branchcode), |
56 |
library => Koha::Libraries->find($branchcode), |
54 |
smtp_servers => Koha::SMTP::Servers->search, |
57 |
smtp_servers => Koha::SMTP::Servers->search, |
|
|
58 |
opening_hours => \@opening_hours |
55 |
); |
59 |
); |
56 |
} elsif ( $branchcode && $op eq 'view' ) { |
60 |
} elsif ( $branchcode && $op eq 'view' ) { |
57 |
my $library = Koha::Libraries->find($branchcode); |
61 |
my $library = Koha::Libraries->find($branchcode); |
Lines 114-119
if ( $op eq 'add_form' ) {
Link Here
|
114 |
} |
118 |
} |
115 |
} |
119 |
} |
116 |
|
120 |
|
|
|
121 |
my @days = $input->multi_param("day"); |
122 |
my @open_times = $input->multi_param("open_time"); |
123 |
my @close_times = $input->multi_param("close_time"); |
124 |
|
125 |
foreach my $day ( @days ) { |
126 |
if ( $open_times[$day] and $open_times[$day] eq '' ) { |
127 |
$open_times[$day] = undef; |
128 |
} |
129 |
if ( $close_times[$day] and $close_times[$day] eq '' ) { |
130 |
$close_times[$day] = undef; |
131 |
} |
132 |
|
133 |
my $openday = Koha::Library::Hours->find({ branchcode => $branchcode, day => $day })->update({ open_time => $open_times[$day], close_time => $close_times[$day] }); |
134 |
} |
135 |
|
117 |
push @messages, { type => 'message', code => 'success_on_update' }; |
136 |
push @messages, { type => 'message', code => 'success_on_update' }; |
118 |
} |
137 |
} |
119 |
); |
138 |
); |
Lines 152-157
if ( $op eq 'add_form' ) {
Link Here
|
152 |
} |
171 |
} |
153 |
} |
172 |
} |
154 |
|
173 |
|
|
|
174 |
my @days = $input->multi_param("day"); |
175 |
my @open_times = $input->multi_param("open_time"); |
176 |
my @close_times = $input->multi_param("close_time"); |
177 |
|
178 |
foreach my $day ( @days ) { |
179 |
if ( $open_times[$day] and $open_times[$day] eq '' ) { |
180 |
$open_times[$day] = undef; |
181 |
} |
182 |
if ( $close_times[$day] and $close_times[$day] eq '' ) { |
183 |
$close_times[$day] = undef; |
184 |
} |
185 |
|
186 |
my $openday = Koha::Library::Hour->new({ branchcode => $branchcode, day => $day, open_time => $open_times[$day], close_time => $close_times[$day] })->store; |
187 |
} |
188 |
|
155 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
189 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
156 |
} |
190 |
} |
157 |
); |
191 |
); |