|
Lines 51-61
BEGIN {
Link Here
|
| 51 |
HasItems |
51 |
HasItems |
| 52 |
|
52 |
|
| 53 |
findSerialsByStatus |
53 |
findSerialsByStatus |
|
|
54 |
&subscriptionCurrentlyOnOrder |
| 55 |
&issue_number |
| 54 |
|
56 |
|
| 55 |
); |
57 |
); |
| 56 |
} |
58 |
} |
| 57 |
|
59 |
|
| 58 |
use Carp qw( croak ); |
60 |
use Carp qw( croak ); |
| 59 |
use Date::Calc qw( |
61 |
use Date::Calc qw( |
| 60 |
Add_Delta_Days |
62 |
Add_Delta_Days |
| 61 |
Add_Delta_YM |
63 |
Add_Delta_YM |
|
Lines 65-78
use Date::Calc qw(
Link Here
|
| 65 |
Today |
67 |
Today |
| 66 |
); |
68 |
); |
| 67 |
use DateTime; |
69 |
use DateTime; |
| 68 |
use POSIX qw( strftime ); |
70 |
use POSIX qw( strftime ); |
| 69 |
use Scalar::Util qw( looks_like_number ); |
71 |
use Scalar::Util qw( looks_like_number ); |
| 70 |
use Try::Tiny; |
72 |
use Try::Tiny; |
| 71 |
|
73 |
|
| 72 |
use C4::Auth qw( haspermission ); |
74 |
use C4::Auth qw( haspermission ); |
| 73 |
use C4::Biblio qw( GetMarcFromKohaField ModBiblio ); |
75 |
use C4::Biblio qw( GetMarcFromKohaField ModBiblio ); |
| 74 |
use C4::Context; |
76 |
use C4::Context; |
| 75 |
use C4::Log qw( logaction ); # logaction |
77 |
use C4::Log qw( logaction ); # logaction |
| 76 |
use C4::Serials::Frequency qw( GetSubscriptionFrequency ); |
78 |
use C4::Serials::Frequency qw( GetSubscriptionFrequency ); |
| 77 |
use C4::Serials::Numberpattern; |
79 |
use C4::Serials::Numberpattern; |
| 78 |
use Koha::AdditionalFieldValues; |
80 |
use Koha::AdditionalFieldValues; |
|
Lines 1299-1335
sub ModNextExpected {
Link Here
|
| 1299 |
|
1301 |
|
| 1300 |
} |
1302 |
} |
| 1301 |
|
1303 |
|
| 1302 |
=head2 GetSubscriptionIrregularities |
|
|
| 1303 |
|
| 1304 |
=over 4 |
| 1305 |
|
| 1306 |
=item @irreg = &GetSubscriptionIrregularities($subscriptionid); |
| 1307 |
get the list of irregularities for a subscription |
| 1308 |
|
| 1309 |
=back |
| 1310 |
|
| 1311 |
=cut |
| 1312 |
|
| 1313 |
sub GetSubscriptionIrregularities { |
| 1314 |
my $subscriptionid = shift; |
| 1315 |
|
| 1316 |
return unless $subscriptionid; |
| 1317 |
|
| 1318 |
my $dbh = C4::Context->dbh; |
| 1319 |
my $query = qq{ |
| 1320 |
SELECT irregularity |
| 1321 |
FROM subscription |
| 1322 |
WHERE subscriptionid = ? |
| 1323 |
}; |
| 1324 |
my $sth = $dbh->prepare($query); |
| 1325 |
$sth->execute($subscriptionid); |
| 1326 |
|
| 1327 |
my ($result) = $sth->fetchrow_array; |
| 1328 |
my @irreg = split /;/, $result; |
| 1329 |
|
| 1330 |
return @irreg; |
| 1331 |
} |
| 1332 |
|
| 1333 |
=head2 ModSubscription |
1304 |
=head2 ModSubscription |
| 1334 |
|
1305 |
|
| 1335 |
this function modifies a subscription. Put all new values on input args. |
1306 |
this function modifies a subscription. Put all new values on input args. |
|
Lines 1339-1349
returns the number of rows affected
Link Here
|
| 1339 |
|
1310 |
|
| 1340 |
sub ModSubscription { |
1311 |
sub ModSubscription { |
| 1341 |
my ( |
1312 |
my ( |
| 1342 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, |
1313 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, |
| 1343 |
$periodicity, $firstacquidate, $irregularity, $numberpattern, $locale, |
1314 |
$periodicity, $firstacquidate, $irregularity, $permanent_irregularity, $numberpattern, $locale, |
| 1344 |
$numberlength, $weeklength, $monthlength, $lastvalue1, $innerloop1, |
1315 |
$numberlength, $weeklength, $monthlength, $lastvalue1, $innerloop1, |
| 1345 |
$lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status, |
1316 |
$lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status, |
| 1346 |
$biblionumber, $callnumber, $notes, $letter, $manualhistory, |
1317 |
$biblionumber, $callnumber, $notes, $letter, $manualhistory, |
| 1347 |
$internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, |
1318 |
$internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, |
| 1348 |
$graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq, |
1319 |
$graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq, |
| 1349 |
$itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template |
1320 |
$itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template |
|
Lines 1352-1396
sub ModSubscription {
Link Here
|
| 1352 |
my $subscription = Koha::Subscriptions->find($subscriptionid); |
1323 |
my $subscription = Koha::Subscriptions->find($subscriptionid); |
| 1353 |
$subscription->set( |
1324 |
$subscription->set( |
| 1354 |
{ |
1325 |
{ |
| 1355 |
librarian => $auser, |
1326 |
librarian => $auser, |
| 1356 |
branchcode => $branchcode, |
1327 |
branchcode => $branchcode, |
| 1357 |
aqbooksellerid => $aqbooksellerid, |
1328 |
aqbooksellerid => $aqbooksellerid, |
| 1358 |
cost => $cost, |
1329 |
cost => $cost, |
| 1359 |
aqbudgetid => $aqbudgetid, |
1330 |
aqbudgetid => $aqbudgetid, |
| 1360 |
biblionumber => $biblionumber, |
1331 |
biblionumber => $biblionumber, |
| 1361 |
startdate => $startdate, |
1332 |
startdate => $startdate, |
| 1362 |
periodicity => $periodicity, |
1333 |
periodicity => $periodicity, |
| 1363 |
numberlength => $numberlength, |
1334 |
numberlength => $numberlength, |
| 1364 |
weeklength => $weeklength, |
1335 |
weeklength => $weeklength, |
| 1365 |
monthlength => $monthlength, |
1336 |
monthlength => $monthlength, |
| 1366 |
lastvalue1 => $lastvalue1, |
1337 |
lastvalue1 => $lastvalue1, |
| 1367 |
innerloop1 => $innerloop1, |
1338 |
innerloop1 => $innerloop1, |
| 1368 |
lastvalue2 => $lastvalue2, |
1339 |
lastvalue2 => $lastvalue2, |
| 1369 |
innerloop2 => $innerloop2, |
1340 |
innerloop2 => $innerloop2, |
| 1370 |
lastvalue3 => $lastvalue3, |
1341 |
lastvalue3 => $lastvalue3, |
| 1371 |
innerloop3 => $innerloop3, |
1342 |
innerloop3 => $innerloop3, |
| 1372 |
status => $status, |
1343 |
status => $status, |
| 1373 |
notes => $notes, |
1344 |
notes => $notes, |
| 1374 |
letter => $letter, |
1345 |
letter => $letter, |
| 1375 |
firstacquidate => $firstacquidate, |
1346 |
firstacquidate => $firstacquidate, |
| 1376 |
irregularity => $irregularity, |
1347 |
irregularity => $irregularity, |
| 1377 |
numberpattern => $numberpattern, |
1348 |
permanent_irregularity => $permanent_irregularity, |
| 1378 |
locale => $locale, |
1349 |
numberpattern => $numberpattern, |
| 1379 |
callnumber => $callnumber, |
1350 |
locale => $locale, |
| 1380 |
manualhistory => $manualhistory, |
1351 |
callnumber => $callnumber, |
| 1381 |
internalnotes => $internalnotes, |
1352 |
manualhistory => $manualhistory, |
| 1382 |
serialsadditems => $serialsadditems, |
1353 |
internalnotes => $internalnotes, |
| 1383 |
staffdisplaycount => $staffdisplaycount, |
1354 |
serialsadditems => $serialsadditems, |
| 1384 |
opacdisplaycount => $opacdisplaycount, |
1355 |
staffdisplaycount => $staffdisplaycount, |
| 1385 |
graceperiod => $graceperiod, |
1356 |
opacdisplaycount => $opacdisplaycount, |
| 1386 |
location => $location, |
1357 |
graceperiod => $graceperiod, |
| 1387 |
enddate => $enddate, |
1358 |
location => $location, |
| 1388 |
skip_serialseq => $skip_serialseq, |
1359 |
enddate => $enddate, |
| 1389 |
itemtype => $itemtype, |
1360 |
skip_serialseq => $skip_serialseq, |
| 1390 |
previousitemtype => $previousitemtype, |
1361 |
itemtype => $itemtype, |
| 1391 |
mana_id => $mana_id, |
1362 |
previousitemtype => $previousitemtype, |
| 1392 |
ccode => $ccode, |
1363 |
mana_id => $mana_id, |
| 1393 |
published_on_template => $published_on_template, |
1364 |
ccode => $ccode, |
|
|
1365 |
published_on_template => $published_on_template, |
| 1394 |
} |
1366 |
} |
| 1395 |
)->store; |
1367 |
)->store; |
| 1396 |
|
1368 |
|
|
Lines 1423-1480
the id of this new subscription
Link Here
|
| 1423 |
|
1395 |
|
| 1424 |
sub NewSubscription { |
1396 |
sub NewSubscription { |
| 1425 |
my ( |
1397 |
my ( |
| 1426 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber, |
1398 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber, |
| 1427 |
$startdate, $periodicity, $numberlength, $weeklength, $monthlength, |
1399 |
$startdate, $periodicity, $numberlength, $weeklength, $monthlength, |
| 1428 |
$lastvalue1, $innerloop1, $lastvalue2, $innerloop2, $lastvalue3, |
1400 |
$lastvalue1, $innerloop1, $lastvalue2, $innerloop2, $lastvalue3, |
| 1429 |
$innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity, |
1401 |
$innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity, |
| 1430 |
$numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, |
1402 |
$permanent_irregularity, $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, |
| 1431 |
$serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, |
1403 |
$serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, |
| 1432 |
$location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, |
1404 |
$location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, |
| 1433 |
$published_on_template, |
1405 |
$published_on_template, |
| 1434 |
) = @_; |
1406 |
) = @_; |
| 1435 |
my $dbh = C4::Context->dbh; |
1407 |
my $dbh = C4::Context->dbh; |
| 1436 |
|
1408 |
|
| 1437 |
my $subscription = Koha::Subscription->new( |
1409 |
my $subscription = Koha::Subscription->new( |
| 1438 |
{ |
1410 |
{ |
| 1439 |
librarian => $auser, |
1411 |
librarian => $auser, |
| 1440 |
branchcode => $branchcode, |
1412 |
branchcode => $branchcode, |
| 1441 |
aqbooksellerid => $aqbooksellerid, |
1413 |
aqbooksellerid => $aqbooksellerid, |
| 1442 |
cost => $cost, |
1414 |
cost => $cost, |
| 1443 |
aqbudgetid => $aqbudgetid, |
1415 |
aqbudgetid => $aqbudgetid, |
| 1444 |
biblionumber => $biblionumber, |
1416 |
biblionumber => $biblionumber, |
| 1445 |
startdate => $startdate, |
1417 |
startdate => $startdate, |
| 1446 |
periodicity => $periodicity, |
1418 |
periodicity => $periodicity, |
| 1447 |
numberlength => $numberlength, |
1419 |
numberlength => $numberlength, |
| 1448 |
weeklength => $weeklength, |
1420 |
weeklength => $weeklength, |
| 1449 |
monthlength => $monthlength, |
1421 |
monthlength => $monthlength, |
| 1450 |
lastvalue1 => $lastvalue1, |
1422 |
lastvalue1 => $lastvalue1, |
| 1451 |
innerloop1 => $innerloop1, |
1423 |
innerloop1 => $innerloop1, |
| 1452 |
lastvalue2 => $lastvalue2, |
1424 |
lastvalue2 => $lastvalue2, |
| 1453 |
innerloop2 => $innerloop2, |
1425 |
innerloop2 => $innerloop2, |
| 1454 |
lastvalue3 => $lastvalue3, |
1426 |
lastvalue3 => $lastvalue3, |
| 1455 |
innerloop3 => $innerloop3, |
1427 |
innerloop3 => $innerloop3, |
| 1456 |
status => $status, |
1428 |
status => $status, |
| 1457 |
notes => $notes, |
1429 |
notes => $notes, |
| 1458 |
letter => $letter, |
1430 |
letter => $letter, |
| 1459 |
firstacquidate => $firstacquidate, |
1431 |
firstacquidate => $firstacquidate, |
| 1460 |
irregularity => $irregularity, |
1432 |
irregularity => $irregularity, |
| 1461 |
numberpattern => $numberpattern, |
1433 |
permanent_irregularity => $permanent_irregularity, |
| 1462 |
locale => $locale, |
1434 |
numberpattern => $numberpattern, |
| 1463 |
callnumber => $callnumber, |
1435 |
locale => $locale, |
| 1464 |
manualhistory => $manualhistory, |
1436 |
callnumber => $callnumber, |
| 1465 |
internalnotes => $internalnotes, |
1437 |
manualhistory => $manualhistory, |
| 1466 |
serialsadditems => $serialsadditems, |
1438 |
internalnotes => $internalnotes, |
| 1467 |
staffdisplaycount => $staffdisplaycount, |
1439 |
serialsadditems => $serialsadditems, |
| 1468 |
opacdisplaycount => $opacdisplaycount, |
1440 |
staffdisplaycount => $staffdisplaycount, |
| 1469 |
graceperiod => $graceperiod, |
1441 |
opacdisplaycount => $opacdisplaycount, |
| 1470 |
location => $location, |
1442 |
graceperiod => $graceperiod, |
| 1471 |
enddate => $enddate, |
1443 |
location => $location, |
| 1472 |
skip_serialseq => $skip_serialseq, |
1444 |
enddate => $enddate, |
| 1473 |
itemtype => $itemtype, |
1445 |
skip_serialseq => $skip_serialseq, |
| 1474 |
previousitemtype => $previousitemtype, |
1446 |
itemtype => $itemtype, |
| 1475 |
mana_id => $mana_id, |
1447 |
previousitemtype => $previousitemtype, |
| 1476 |
ccode => $ccode, |
1448 |
mana_id => $mana_id, |
| 1477 |
published_on_template => $published_on_template, |
1449 |
ccode => $ccode, |
|
|
1450 |
published_on_template => $published_on_template, |
| 1478 |
} |
1451 |
} |
| 1479 |
)->store; |
1452 |
)->store; |
| 1480 |
$subscription->discard_changes; |
1453 |
$subscription->discard_changes; |
|
Lines 2820-2825
sub findSerialsByStatus {
Link Here
|
| 2820 |
return @$serials; |
2793 |
return @$serials; |
| 2821 |
} |
2794 |
} |
| 2822 |
|
2795 |
|
|
|
2796 |
=head2 issue_number |
| 2797 |
|
| 2798 |
my $week_number = issue_number($dt, 'week'); |
| 2799 |
|
| 2800 |
=cut |
| 2801 |
|
| 2802 |
sub issue_number { |
| 2803 |
my ( $date, $issue_type ) = @_; |
| 2804 |
|
| 2805 |
unless ( ref($date) eq 'DateTime' ) { |
| 2806 |
Koha::Exceptions::WrongParameter->throw("Date passed to issue_number is not a valid DateTime object"); |
| 2807 |
} |
| 2808 |
|
| 2809 |
if ( $issue_type eq 'day' ) { |
| 2810 |
return $date->dow; |
| 2811 |
} |
| 2812 |
|
| 2813 |
if ( $issue_type eq 'week' ) { |
| 2814 |
return $date->week_number; |
| 2815 |
} |
| 2816 |
|
| 2817 |
if ( $issue_type eq 'month' ) { |
| 2818 |
return $date->month; |
| 2819 |
} |
| 2820 |
|
| 2821 |
return 0; |
| 2822 |
} |
| 2823 |
|
| 2823 |
1; |
2824 |
1; |
| 2824 |
__END__ |
2825 |
__END__ |
| 2825 |
|
2826 |
|