Lines 1158-1167
AddIssue does the following things :
Link Here
|
1158 |
sub AddIssue { |
1158 |
sub AddIssue { |
1159 |
my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode) = @_; |
1159 |
my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode) = @_; |
1160 |
my $dbh = C4::Context->dbh; |
1160 |
my $dbh = C4::Context->dbh; |
1161 |
my $barcodecheck=CheckValidBarcode($barcode); |
1161 |
|
1162 |
if ($datedue && ref $datedue ne 'DateTime') { |
1162 |
my $barcodecheck=CheckValidBarcode($barcode); |
1163 |
$datedue = dt_from_string($datedue); |
1163 |
|
1164 |
} |
|
|
1165 |
# $issuedate defaults to today. |
1164 |
# $issuedate defaults to today. |
1166 |
if ( ! defined $issuedate ) { |
1165 |
if ( ! defined $issuedate ) { |
1167 |
$issuedate = DateTime->now(time_zone => C4::Context->tz()); |
1166 |
$issuedate = DateTime->now(time_zone => C4::Context->tz()); |
Lines 1176-1182
sub AddIssue {
Link Here
|
1176 |
# find which item we issue |
1175 |
# find which item we issue |
1177 |
my $item = GetItem('', $barcode) or return; # if we don't get an Item, abort. |
1176 |
my $item = GetItem('', $barcode) or return; # if we don't get an Item, abort. |
1178 |
my $branch = _GetCircControlBranch($item,$borrower); |
1177 |
my $branch = _GetCircControlBranch($item,$borrower); |
1179 |
|
1178 |
|
|
|
1179 |
# $datedue was passed as a parameter, check validity |
1180 |
# and adjust if mandated by sysprefs |
1181 |
if ($datedue && ref $datedue ne 'DateTime') { |
1182 |
$datedue = dt_from_string($datedue); |
1183 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
1184 |
if ( C4::Context->preference('useDaysMode') eq 'Datedue' |
1185 |
|| C4::Context->preference('useDaysMode') eq 'Calendar' ) |
1186 |
{ |
1187 |
# use the calendar to push the due date to the next open day |
1188 |
$datedue = $calendar->next_open_day($datedue); |
1189 |
} |
1190 |
} |
1191 |
|
1180 |
# get actual issuing if there is one |
1192 |
# get actual issuing if there is one |
1181 |
my $actualissue = GetItemIssue( $item->{itemnumber}); |
1193 |
my $actualissue = GetItemIssue( $item->{itemnumber}); |
1182 |
|
1194 |
|
Lines 3004-3025
sub CalcDateDue {
Link Here
|
3004 |
C4::Context->preference('dateformat') |
3016 |
C4::Context->preference('dateformat') |
3005 |
); |
3017 |
); |
3006 |
} else { |
3018 |
} else { |
3007 |
|
|
|
3008 |
# otherwise, calculate the datedue as normal |
3019 |
# otherwise, calculate the datedue as normal |
3009 |
if ( C4::Context->preference('useDaysMode') eq 'Days' ) |
3020 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
3010 |
{ # ignoring calendar |
3021 |
|
|
|
3022 |
if ( C4::Context->preference('useDaysMode') ne 'Calendar' ) |
3023 |
{ # ignoring calendar to calculate date due |
3011 |
my $dt = |
3024 |
my $dt = |
3012 |
DateTime->now( time_zone => C4::Context->tz() ) |
3025 |
DateTime->now( time_zone => C4::Context->tz() ) |
3013 |
->truncate( to => 'minute' ); |
3026 |
->truncate( to => 'minute' ); |
3014 |
if ( $loanlength->{lengthunit} eq 'hours' ) { |
3027 |
if ( $loanlength->{lengthunit} eq 'hours' ) { |
3015 |
$dt->add( hours => $loanlength->{issuelength} ); |
3028 |
$dt->add( hours => $loanlength->{issuelength} ); |
3016 |
return $dt; |
|
|
3017 |
} else { # days |
3029 |
} else { # days |
3018 |
$dt->add( days => $loanlength->{issuelength} ); |
3030 |
$dt->add( days => $loanlength->{issuelength} ); |
3019 |
$dt->set_hour(23); |
3031 |
$dt->set_hour(23); |
3020 |
$dt->set_minute(59); |
3032 |
$dt->set_minute(59); |
3021 |
return $dt; |
|
|
3022 |
} |
3033 |
} |
|
|
3034 |
|
3035 |
if ( C4::Context->preference('useDaysMode') eq 'Datedue' ) { |
3036 |
# use the calendar to push the due date to the next open day |
3037 |
$dt = $calendar->next_open_day($dt); |
3038 |
} |
3039 |
|
3040 |
return $dt; |
3041 |
|
3023 |
} else { |
3042 |
} else { |
3024 |
my $dur; |
3043 |
my $dur; |
3025 |
if ($loanlength->{lengthunit} eq 'hours') { |
3044 |
if ($loanlength->{lengthunit} eq 'hours') { |
Lines 3031-3037
sub CalcDateDue {
Link Here
|
3031 |
if (ref $startdate ne 'DateTime' ) { |
3050 |
if (ref $startdate ne 'DateTime' ) { |
3032 |
$startdate = dt_from_string($startdate); |
3051 |
$startdate = dt_from_string($startdate); |
3033 |
} |
3052 |
} |
3034 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
|
|
3035 |
$datedue = $calendar->addDate( $startdate, $dur, $loanlength->{lengthunit} ); |
3053 |
$datedue = $calendar->addDate( $startdate, $dur, $loanlength->{lengthunit} ); |
3036 |
if ($loanlength->{lengthunit} eq 'days') { |
3054 |
if ($loanlength->{lengthunit} eq 'days') { |
3037 |
$datedue->set_hour(23); |
3055 |
$datedue->set_hour(23); |