Lines 971-980
AddIssue does the following things :
Link Here
|
971 |
sub AddIssue { |
971 |
sub AddIssue { |
972 |
my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode) = @_; |
972 |
my ( $borrower, $barcode, $datedue, $cancelreserve, $issuedate, $sipmode) = @_; |
973 |
my $dbh = C4::Context->dbh; |
973 |
my $dbh = C4::Context->dbh; |
974 |
my $barcodecheck=CheckValidBarcode($barcode); |
974 |
|
975 |
if ($datedue && ref $datedue ne 'DateTime') { |
975 |
my $barcodecheck=CheckValidBarcode($barcode); |
976 |
$datedue = dt_from_string($datedue); |
976 |
|
977 |
} |
|
|
978 |
# $issuedate defaults to today. |
977 |
# $issuedate defaults to today. |
979 |
if ( ! defined $issuedate ) { |
978 |
if ( ! defined $issuedate ) { |
980 |
$issuedate = DateTime->now(time_zone => C4::Context->tz()); |
979 |
$issuedate = DateTime->now(time_zone => C4::Context->tz()); |
Lines 989-995
sub AddIssue {
Link Here
|
989 |
# find which item we issue |
988 |
# find which item we issue |
990 |
my $item = GetItem('', $barcode) or return undef; # if we don't get an Item, abort. |
989 |
my $item = GetItem('', $barcode) or return undef; # if we don't get an Item, abort. |
991 |
my $branch = _GetCircControlBranch($item,$borrower); |
990 |
my $branch = _GetCircControlBranch($item,$borrower); |
992 |
|
991 |
|
|
|
992 |
# $datedue was passed as a parameter, check validity |
993 |
# and adjust if mandated by sysprefs |
994 |
if ($datedue && ref $datedue ne 'DateTime') { |
995 |
$datedue = dt_from_string($datedue); |
996 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
997 |
if ( C4::Context->preference('useDaysMode') eq 'Datedue' ) { |
998 |
# use the calendar to push the due date to the next open day |
999 |
$datedue = $calendar->next_open_day($datedue); |
1000 |
} |
1001 |
} |
1002 |
|
993 |
# get actual issuing if there is one |
1003 |
# get actual issuing if there is one |
994 |
my $actualissue = GetItemIssue( $item->{itemnumber}); |
1004 |
my $actualissue = GetItemIssue( $item->{itemnumber}); |
995 |
|
1005 |
|
Lines 2819-2840
sub CalcDateDue {
Link Here
|
2819 |
C4::Context->preference('dateformat') |
2829 |
C4::Context->preference('dateformat') |
2820 |
); |
2830 |
); |
2821 |
} else { |
2831 |
} else { |
2822 |
|
|
|
2823 |
# otherwise, calculate the datedue as normal |
2832 |
# otherwise, calculate the datedue as normal |
2824 |
if ( C4::Context->preference('useDaysMode') eq 'Days' ) |
2833 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
2825 |
{ # ignoring calendar |
2834 |
|
|
|
2835 |
if ( C4::Context->preference('useDaysMode') ne 'Calendar' ) |
2836 |
{ # ignoring calendar to calculate date due |
2826 |
my $dt = |
2837 |
my $dt = |
2827 |
DateTime->now( time_zone => C4::Context->tz() ) |
2838 |
DateTime->now( time_zone => C4::Context->tz() ) |
2828 |
->truncate( to => 'minute' ); |
2839 |
->truncate( to => 'minute' ); |
2829 |
if ( $loanlength->{lengthunit} eq 'hours' ) { |
2840 |
if ( $loanlength->{lengthunit} eq 'hours' ) { |
2830 |
$dt->add( hours => $loanlength->{issuelength} ); |
2841 |
$dt->add( hours => $loanlength->{issuelength} ); |
2831 |
return $dt; |
|
|
2832 |
} else { # days |
2842 |
} else { # days |
2833 |
$dt->add( days => $loanlength->{issuelength} ); |
2843 |
$dt->add( days => $loanlength->{issuelength} ); |
2834 |
$dt->set_hour(23); |
2844 |
$dt->set_hour(23); |
2835 |
$dt->set_minute(59); |
2845 |
$dt->set_minute(59); |
2836 |
return $dt; |
|
|
2837 |
} |
2846 |
} |
|
|
2847 |
|
2848 |
if ( C4::Context->preference('useDaysMode') eq 'Datedue' ) { |
2849 |
# use the calendar to push the due date to the next open day |
2850 |
$dt = $calendar->next_open_day($dt); |
2851 |
} |
2852 |
|
2853 |
return $dt; |
2854 |
|
2838 |
} else { |
2855 |
} else { |
2839 |
my $dur; |
2856 |
my $dur; |
2840 |
if ($loanlength->{lengthunit} eq 'hours') { |
2857 |
if ($loanlength->{lengthunit} eq 'hours') { |
Lines 2846-2852
sub CalcDateDue {
Link Here
|
2846 |
if (ref $startdate ne 'DateTime' ) { |
2863 |
if (ref $startdate ne 'DateTime' ) { |
2847 |
$startdate = dt_from_string($startdate); |
2864 |
$startdate = dt_from_string($startdate); |
2848 |
} |
2865 |
} |
2849 |
my $calendar = Koha::Calendar->new( branchcode => $branch ); |
|
|
2850 |
$datedue = $calendar->addDate( $startdate, $dur, $loanlength->{lengthunit} ); |
2866 |
$datedue = $calendar->addDate( $startdate, $dur, $loanlength->{lengthunit} ); |
2851 |
if ($loanlength->{lengthunit} eq 'days') { |
2867 |
if ($loanlength->{lengthunit} eq 'days') { |
2852 |
$datedue->set_hour(23); |
2868 |
$datedue->set_hour(23); |