|
Lines 20-26
package C4::Serials;
Link Here
|
| 20 |
|
20 |
|
| 21 |
use Modern::Perl; |
21 |
use Modern::Perl; |
| 22 |
|
22 |
|
| 23 |
use Carp qw( croak ); |
23 |
use Carp qw( croak ); |
| 24 |
use Date::Calc qw( |
24 |
use Date::Calc qw( |
| 25 |
Add_Delta_Days |
25 |
Add_Delta_Days |
| 26 |
Add_Delta_YM |
26 |
Add_Delta_YM |
|
Lines 30-43
use Date::Calc qw(
Link Here
|
| 30 |
Today |
30 |
Today |
| 31 |
); |
31 |
); |
| 32 |
use DateTime; |
32 |
use DateTime; |
| 33 |
use POSIX qw( strftime ); |
33 |
use POSIX qw( strftime ); |
| 34 |
use Scalar::Util qw( looks_like_number ); |
34 |
use Scalar::Util qw( looks_like_number ); |
| 35 |
use Try::Tiny; |
35 |
use Try::Tiny; |
| 36 |
|
36 |
|
| 37 |
use C4::Auth qw( haspermission ); |
37 |
use C4::Auth qw( haspermission ); |
| 38 |
use C4::Biblio qw( GetMarcFromKohaField ModBiblio ); |
38 |
use C4::Biblio qw( GetMarcFromKohaField ModBiblio ); |
| 39 |
use C4::Context; |
39 |
use C4::Context; |
| 40 |
use C4::Log qw( logaction ); # logaction |
40 |
use C4::Log qw( logaction ); # logaction |
| 41 |
use C4::Serials::Frequency qw( GetSubscriptionFrequency ); |
41 |
use C4::Serials::Frequency qw( GetSubscriptionFrequency ); |
| 42 |
use C4::Serials::Numberpattern; |
42 |
use C4::Serials::Numberpattern; |
| 43 |
use Koha::AdditionalFieldValues; |
43 |
use Koha::AdditionalFieldValues; |
|
Lines 107-112
BEGIN {
Link Here
|
| 107 |
HasItems |
107 |
HasItems |
| 108 |
|
108 |
|
| 109 |
findSerialsByStatus |
109 |
findSerialsByStatus |
|
|
110 |
&subscriptionCurrentlyOnOrder |
| 111 |
&issue_number |
| 110 |
|
112 |
|
| 111 |
); |
113 |
); |
| 112 |
} |
114 |
} |
|
Lines 1300-1336
sub ModNextExpected {
Link Here
|
| 1300 |
|
1302 |
|
| 1301 |
} |
1303 |
} |
| 1302 |
|
1304 |
|
| 1303 |
=head2 GetSubscriptionIrregularities |
|
|
| 1304 |
|
| 1305 |
=over 4 |
| 1306 |
|
| 1307 |
=item @irreg = &GetSubscriptionIrregularities($subscriptionid); |
| 1308 |
get the list of irregularities for a subscription |
| 1309 |
|
| 1310 |
=back |
| 1311 |
|
| 1312 |
=cut |
| 1313 |
|
| 1314 |
sub GetSubscriptionIrregularities { |
| 1315 |
my $subscriptionid = shift; |
| 1316 |
|
| 1317 |
return unless $subscriptionid; |
| 1318 |
|
| 1319 |
my $dbh = C4::Context->dbh; |
| 1320 |
my $query = qq{ |
| 1321 |
SELECT irregularity |
| 1322 |
FROM subscription |
| 1323 |
WHERE subscriptionid = ? |
| 1324 |
}; |
| 1325 |
my $sth = $dbh->prepare($query); |
| 1326 |
$sth->execute($subscriptionid); |
| 1327 |
|
| 1328 |
my ($result) = $sth->fetchrow_array; |
| 1329 |
my @irreg = split /;/, $result; |
| 1330 |
|
| 1331 |
return @irreg; |
| 1332 |
} |
| 1333 |
|
| 1334 |
=head2 ModSubscription |
1305 |
=head2 ModSubscription |
| 1335 |
|
1306 |
|
| 1336 |
this function modifies a subscription. Put all new values on input args. |
1307 |
this function modifies a subscription. Put all new values on input args. |
|
Lines 1340-1350
returns the number of rows affected
Link Here
|
| 1340 |
|
1311 |
|
| 1341 |
sub ModSubscription { |
1312 |
sub ModSubscription { |
| 1342 |
my ( |
1313 |
my ( |
| 1343 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, |
1314 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $startdate, |
| 1344 |
$periodicity, $firstacquidate, $irregularity, $numberpattern, $locale, |
1315 |
$periodicity, $firstacquidate, $irregularity, $permanent_irregularity, $numberpattern, $locale, |
| 1345 |
$numberlength, $weeklength, $monthlength, $lastvalue1, $innerloop1, |
1316 |
$numberlength, $weeklength, $monthlength, $lastvalue1, $innerloop1, |
| 1346 |
$lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status, |
1317 |
$lastvalue2, $innerloop2, $lastvalue3, $innerloop3, $status, |
| 1347 |
$biblionumber, $callnumber, $notes, $letter, $manualhistory, |
1318 |
$biblionumber, $callnumber, $notes, $letter, $manualhistory, |
| 1348 |
$internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, |
1319 |
$internalnotes, $serialsadditems, $staffdisplaycount, $opacdisplaycount, |
| 1349 |
$graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq, |
1320 |
$graceperiod, $location, $enddate, $subscriptionid, $skip_serialseq, |
| 1350 |
$itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template |
1321 |
$itemtype, $previousitemtype, $mana_id, $ccode, $published_on_template |
|
Lines 1353-1397
sub ModSubscription {
Link Here
|
| 1353 |
my $subscription = Koha::Subscriptions->find($subscriptionid); |
1324 |
my $subscription = Koha::Subscriptions->find($subscriptionid); |
| 1354 |
$subscription->set( |
1325 |
$subscription->set( |
| 1355 |
{ |
1326 |
{ |
| 1356 |
librarian => $auser, |
1327 |
librarian => $auser, |
| 1357 |
branchcode => $branchcode, |
1328 |
branchcode => $branchcode, |
| 1358 |
aqbooksellerid => $aqbooksellerid, |
1329 |
aqbooksellerid => $aqbooksellerid, |
| 1359 |
cost => $cost, |
1330 |
cost => $cost, |
| 1360 |
aqbudgetid => $aqbudgetid, |
1331 |
aqbudgetid => $aqbudgetid, |
| 1361 |
biblionumber => $biblionumber, |
1332 |
biblionumber => $biblionumber, |
| 1362 |
startdate => $startdate, |
1333 |
startdate => $startdate, |
| 1363 |
periodicity => $periodicity, |
1334 |
periodicity => $periodicity, |
| 1364 |
numberlength => $numberlength, |
1335 |
numberlength => $numberlength, |
| 1365 |
weeklength => $weeklength, |
1336 |
weeklength => $weeklength, |
| 1366 |
monthlength => $monthlength, |
1337 |
monthlength => $monthlength, |
| 1367 |
lastvalue1 => $lastvalue1, |
1338 |
lastvalue1 => $lastvalue1, |
| 1368 |
innerloop1 => $innerloop1, |
1339 |
innerloop1 => $innerloop1, |
| 1369 |
lastvalue2 => $lastvalue2, |
1340 |
lastvalue2 => $lastvalue2, |
| 1370 |
innerloop2 => $innerloop2, |
1341 |
innerloop2 => $innerloop2, |
| 1371 |
lastvalue3 => $lastvalue3, |
1342 |
lastvalue3 => $lastvalue3, |
| 1372 |
innerloop3 => $innerloop3, |
1343 |
innerloop3 => $innerloop3, |
| 1373 |
status => $status, |
1344 |
status => $status, |
| 1374 |
notes => $notes, |
1345 |
notes => $notes, |
| 1375 |
letter => $letter, |
1346 |
letter => $letter, |
| 1376 |
firstacquidate => $firstacquidate, |
1347 |
firstacquidate => $firstacquidate, |
| 1377 |
irregularity => $irregularity, |
1348 |
irregularity => $irregularity, |
| 1378 |
numberpattern => $numberpattern, |
1349 |
permanent_irregularity => $permanent_irregularity, |
| 1379 |
locale => $locale, |
1350 |
numberpattern => $numberpattern, |
| 1380 |
callnumber => $callnumber, |
1351 |
locale => $locale, |
| 1381 |
manualhistory => $manualhistory, |
1352 |
callnumber => $callnumber, |
| 1382 |
internalnotes => $internalnotes, |
1353 |
manualhistory => $manualhistory, |
| 1383 |
serialsadditems => $serialsadditems, |
1354 |
internalnotes => $internalnotes, |
| 1384 |
staffdisplaycount => $staffdisplaycount, |
1355 |
serialsadditems => $serialsadditems, |
| 1385 |
opacdisplaycount => $opacdisplaycount, |
1356 |
staffdisplaycount => $staffdisplaycount, |
| 1386 |
graceperiod => $graceperiod, |
1357 |
opacdisplaycount => $opacdisplaycount, |
| 1387 |
location => $location, |
1358 |
graceperiod => $graceperiod, |
| 1388 |
enddate => $enddate, |
1359 |
location => $location, |
| 1389 |
skip_serialseq => $skip_serialseq, |
1360 |
enddate => $enddate, |
| 1390 |
itemtype => $itemtype, |
1361 |
skip_serialseq => $skip_serialseq, |
| 1391 |
previousitemtype => $previousitemtype, |
1362 |
itemtype => $itemtype, |
| 1392 |
mana_id => $mana_id, |
1363 |
previousitemtype => $previousitemtype, |
| 1393 |
ccode => $ccode, |
1364 |
mana_id => $mana_id, |
| 1394 |
published_on_template => $published_on_template, |
1365 |
ccode => $ccode, |
|
|
1366 |
published_on_template => $published_on_template, |
| 1395 |
} |
1367 |
} |
| 1396 |
)->store; |
1368 |
)->store; |
| 1397 |
|
1369 |
|
|
Lines 1424-1481
the id of this new subscription
Link Here
|
| 1424 |
|
1396 |
|
| 1425 |
sub NewSubscription { |
1397 |
sub NewSubscription { |
| 1426 |
my ( |
1398 |
my ( |
| 1427 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber, |
1399 |
$auser, $branchcode, $aqbooksellerid, $cost, $aqbudgetid, $biblionumber, |
| 1428 |
$startdate, $periodicity, $numberlength, $weeklength, $monthlength, |
1400 |
$startdate, $periodicity, $numberlength, $weeklength, $monthlength, |
| 1429 |
$lastvalue1, $innerloop1, $lastvalue2, $innerloop2, $lastvalue3, |
1401 |
$lastvalue1, $innerloop1, $lastvalue2, $innerloop2, $lastvalue3, |
| 1430 |
$innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity, |
1402 |
$innerloop3, $status, $notes, $letter, $firstacquidate, $irregularity, |
| 1431 |
$numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, |
1403 |
$permanent_irregularity, $numberpattern, $locale, $callnumber, $manualhistory, $internalnotes, |
| 1432 |
$serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, |
1404 |
$serialsadditems, $staffdisplaycount, $opacdisplaycount, $graceperiod, |
| 1433 |
$location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, |
1405 |
$location, $enddate, $skip_serialseq, $itemtype, $previousitemtype, $mana_id, $ccode, |
| 1434 |
$published_on_template, |
1406 |
$published_on_template, |
| 1435 |
) = @_; |
1407 |
) = @_; |
| 1436 |
my $dbh = C4::Context->dbh; |
1408 |
my $dbh = C4::Context->dbh; |
| 1437 |
|
1409 |
|
| 1438 |
my $subscription = Koha::Subscription->new( |
1410 |
my $subscription = Koha::Subscription->new( |
| 1439 |
{ |
1411 |
{ |
| 1440 |
librarian => $auser, |
1412 |
librarian => $auser, |
| 1441 |
branchcode => $branchcode, |
1413 |
branchcode => $branchcode, |
| 1442 |
aqbooksellerid => $aqbooksellerid, |
1414 |
aqbooksellerid => $aqbooksellerid, |
| 1443 |
cost => $cost, |
1415 |
cost => $cost, |
| 1444 |
aqbudgetid => $aqbudgetid, |
1416 |
aqbudgetid => $aqbudgetid, |
| 1445 |
biblionumber => $biblionumber, |
1417 |
biblionumber => $biblionumber, |
| 1446 |
startdate => $startdate, |
1418 |
startdate => $startdate, |
| 1447 |
periodicity => $periodicity, |
1419 |
periodicity => $periodicity, |
| 1448 |
numberlength => $numberlength, |
1420 |
numberlength => $numberlength, |
| 1449 |
weeklength => $weeklength, |
1421 |
weeklength => $weeklength, |
| 1450 |
monthlength => $monthlength, |
1422 |
monthlength => $monthlength, |
| 1451 |
lastvalue1 => $lastvalue1, |
1423 |
lastvalue1 => $lastvalue1, |
| 1452 |
innerloop1 => $innerloop1, |
1424 |
innerloop1 => $innerloop1, |
| 1453 |
lastvalue2 => $lastvalue2, |
1425 |
lastvalue2 => $lastvalue2, |
| 1454 |
innerloop2 => $innerloop2, |
1426 |
innerloop2 => $innerloop2, |
| 1455 |
lastvalue3 => $lastvalue3, |
1427 |
lastvalue3 => $lastvalue3, |
| 1456 |
innerloop3 => $innerloop3, |
1428 |
innerloop3 => $innerloop3, |
| 1457 |
status => $status, |
1429 |
status => $status, |
| 1458 |
notes => $notes, |
1430 |
notes => $notes, |
| 1459 |
letter => $letter, |
1431 |
letter => $letter, |
| 1460 |
firstacquidate => $firstacquidate, |
1432 |
firstacquidate => $firstacquidate, |
| 1461 |
irregularity => $irregularity, |
1433 |
irregularity => $irregularity, |
| 1462 |
numberpattern => $numberpattern, |
1434 |
permanent_irregularity => $permanent_irregularity, |
| 1463 |
locale => $locale, |
1435 |
numberpattern => $numberpattern, |
| 1464 |
callnumber => $callnumber, |
1436 |
locale => $locale, |
| 1465 |
manualhistory => $manualhistory, |
1437 |
callnumber => $callnumber, |
| 1466 |
internalnotes => $internalnotes, |
1438 |
manualhistory => $manualhistory, |
| 1467 |
serialsadditems => $serialsadditems, |
1439 |
internalnotes => $internalnotes, |
| 1468 |
staffdisplaycount => $staffdisplaycount, |
1440 |
serialsadditems => $serialsadditems, |
| 1469 |
opacdisplaycount => $opacdisplaycount, |
1441 |
staffdisplaycount => $staffdisplaycount, |
| 1470 |
graceperiod => $graceperiod, |
1442 |
opacdisplaycount => $opacdisplaycount, |
| 1471 |
location => $location, |
1443 |
graceperiod => $graceperiod, |
| 1472 |
enddate => $enddate, |
1444 |
location => $location, |
| 1473 |
skip_serialseq => $skip_serialseq, |
1445 |
enddate => $enddate, |
| 1474 |
itemtype => $itemtype, |
1446 |
skip_serialseq => $skip_serialseq, |
| 1475 |
previousitemtype => $previousitemtype, |
1447 |
itemtype => $itemtype, |
| 1476 |
mana_id => $mana_id, |
1448 |
previousitemtype => $previousitemtype, |
| 1477 |
ccode => $ccode, |
1449 |
mana_id => $mana_id, |
| 1478 |
published_on_template => $published_on_template, |
1450 |
ccode => $ccode, |
|
|
1451 |
published_on_template => $published_on_template, |
| 1479 |
} |
1452 |
} |
| 1480 |
)->store; |
1453 |
)->store; |
| 1481 |
$subscription->discard_changes; |
1454 |
$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 |
|