Lines 6-12
use Koha::Database qw( schema );
Link Here
|
6 |
use C4::Biblio qw( AddBiblio ); |
6 |
use C4::Biblio qw( AddBiblio ); |
7 |
use Koha::Biblios qw( _type ); |
7 |
use Koha::Biblios qw( _type ); |
8 |
use Koha::Items qw( _type ); |
8 |
use Koha::Items qw( _type ); |
9 |
use Koha::DateUtils qw( dt_from_string ); |
9 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
10 |
|
10 |
|
11 |
use Bytes::Random::Secure; |
11 |
use Bytes::Random::Secure; |
12 |
use Carp qw( carp ); |
12 |
use Carp qw( carp ); |
Lines 146-151
sub build {
Link Here
|
146 |
if scalar @{ $fk->{keys} } == 1 |
146 |
if scalar @{ $fk->{keys} } == 1 |
147 |
} |
147 |
} |
148 |
|
148 |
|
|
|
149 |
if ($source eq 'Branch') { |
150 |
$self->fill_discrete_calendar({ branchcode => $col_values->{branchcode} }); |
151 |
} |
152 |
|
149 |
# store this record and return hashref |
153 |
# store this record and return hashref |
150 |
return $self->_storeColumnValues({ |
154 |
return $self->_storeColumnValues({ |
151 |
source => $source, |
155 |
source => $source, |
Lines 210-215
sub build_sample_item {
Link Here
|
210 |
)->store->get_from_storage; |
214 |
)->store->get_from_storage; |
211 |
} |
215 |
} |
212 |
|
216 |
|
|
|
217 |
sub fill_discrete_calendar { |
218 |
my ( $self, $args ) = @_; |
219 |
|
220 |
my $branchcode = $args->{branchcode} || ''; |
221 |
my $start_date = ($args->{start_date}) ? dt_from_string($args->{start_date}) : DateTime->today(); |
222 |
my $days = $args->{days} || 60; |
223 |
|
224 |
my $end_date = $start_date->clone(); |
225 |
$start_date->add(days => 0 - $days); |
226 |
$end_date->add(days => $days); |
227 |
|
228 |
for (1; $start_date <= $end_date; $start_date->add(days => 1)) { |
229 |
my $data = { |
230 |
date => output_pref( { dt => $start_date, dateformat => 'iso', dateonly => 1 }), |
231 |
branchcode => $branchcode, |
232 |
is_opened => 1, |
233 |
open_hour => "08:00:00", |
234 |
close_hour => "17:00:00", |
235 |
}; |
236 |
|
237 |
$self->schema->resultset( "DiscreteCalendar" )->update_or_create( $data ); |
238 |
} |
239 |
|
240 |
return |
241 |
} |
242 |
|
213 |
# ------------------------------------------------------------------------------ |
243 |
# ------------------------------------------------------------------------------ |
214 |
# Internal helper routines |
244 |
# Internal helper routines |
215 |
|
245 |
|
216 |
- |
|
|