|
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 ( $branchcode && $op eq 'view' ) { |
67 |
} elsif ( $branchcode && $op eq 'view' ) { |
| 57 |
my $library = Koha::Libraries->find($branchcode); |
68 |
my $library = Koha::Libraries->find($branchcode); |
|
Lines 114-119
if ( $op eq 'add_form' ) {
Link Here
|
| 114 |
} |
125 |
} |
| 115 |
} |
126 |
} |
| 116 |
|
127 |
|
|
|
128 |
my @days = $input->multi_param("day"); |
| 129 |
my @open_times = $input->multi_param("open_time"); |
| 130 |
my @close_times = $input->multi_param("close_time"); |
| 131 |
|
| 132 |
foreach my $day ( @days ) { |
| 133 |
if ( $open_times[$day] and $open_times[$day] eq '' ) { |
| 134 |
$open_times[$day] = undef; |
| 135 |
} |
| 136 |
if ( $close_times[$day] and $close_times[$day] eq '' ) { |
| 137 |
$close_times[$day] = undef; |
| 138 |
} |
| 139 |
|
| 140 |
my $openday = Koha::Library::Hours->find({ branchcode => $branchcode, day => $day })->update({ open_time => $open_times[$day], close_time => $close_times[$day] }); |
| 141 |
} |
| 142 |
|
| 117 |
push @messages, { type => 'message', code => 'success_on_update' }; |
143 |
push @messages, { type => 'message', code => 'success_on_update' }; |
| 118 |
} |
144 |
} |
| 119 |
); |
145 |
); |
|
Lines 152-157
if ( $op eq 'add_form' ) {
Link Here
|
| 152 |
} |
178 |
} |
| 153 |
} |
179 |
} |
| 154 |
|
180 |
|
|
|
181 |
my @days = $input->multi_param("day"); |
| 182 |
my @open_times = $input->multi_param("open_time"); |
| 183 |
my @close_times = $input->multi_param("close_time"); |
| 184 |
|
| 185 |
foreach my $day ( @days ) { |
| 186 |
if ( $open_times[$day] and $open_times[$day] eq '' ) { |
| 187 |
$open_times[$day] = undef; |
| 188 |
} |
| 189 |
if ( $close_times[$day] and $close_times[$day] eq '' ) { |
| 190 |
$close_times[$day] = undef; |
| 191 |
} |
| 192 |
|
| 193 |
my $openday = Koha::Library::Hour->new({ branchcode => $branchcode, day => $day, open_time => $open_times[$day], close_time => $close_times[$day] })->store; |
| 194 |
} |
| 195 |
|
| 155 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
196 |
push @messages, { type => 'message', code => 'success_on_insert' }; |
| 156 |
} |
197 |
} |
| 157 |
); |
198 |
); |