|
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({ library_id => $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 116-121
if ( $op eq 'add_form' ) {
Link Here
|
| 116 |
} |
120 |
} |
| 117 |
} |
121 |
} |
| 118 |
|
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({ library_id => $branchcode, day => $day })->update({ open_time => $open_times[$day], close_time => $close_times[$day] }); |
| 136 |
} |
| 137 |
|
| 119 |
push @messages, { type => 'message', code => 'success_on_update' }; |
138 |
push @messages, { type => 'message', code => 'success_on_update' }; |
| 120 |
} |
139 |
} |
| 121 |
); |
140 |
); |
|
Lines 154-159
if ( $op eq 'add_form' ) {
Link Here
|
| 154 |
} |
173 |
} |
| 155 |
} |
174 |
} |
| 156 |
|
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({ library_id => $branchcode, day => $day, open_time => $open_times[$day], close_time => $close_times[$day] })->store; |
| 189 |
} |
| 190 |
|
| 157 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
191 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
| 158 |
} |
192 |
} |
| 159 |
); |
193 |
); |