Lines 46-51
BEGIN {
Link Here
|
46 |
|
46 |
|
47 |
&TransportCostMatrix |
47 |
&TransportCostMatrix |
48 |
&UpdateTransportCostMatrix |
48 |
&UpdateTransportCostMatrix |
|
|
49 |
|
50 |
&MarkHoldPrinted |
51 |
&GetItemNumberFromTmpHold |
49 |
); |
52 |
); |
50 |
} |
53 |
} |
51 |
|
54 |
|
Lines 116-122
Returns hold queue for a holding branch. If branch is omitted, then whole queue
Link Here
|
116 |
=cut |
119 |
=cut |
117 |
|
120 |
|
118 |
sub GetHoldsQueueItems { |
121 |
sub GetHoldsQueueItems { |
119 |
my ($branchlimit) = @_; |
122 |
my ($branchlimit, $printstatus) = @_; |
120 |
my $dbh = C4::Context->dbh; |
123 |
my $dbh = C4::Context->dbh; |
121 |
|
124 |
|
122 |
my @bind_params = (); |
125 |
my @bind_params = (); |
Lines 130-135
sub GetHoldsQueueItems {
Link Here
|
130 |
$query .=" WHERE tmp_holdsqueue.holdingbranch = ?"; |
133 |
$query .=" WHERE tmp_holdsqueue.holdingbranch = ?"; |
131 |
push @bind_params, $branchlimit; |
134 |
push @bind_params, $branchlimit; |
132 |
} |
135 |
} |
|
|
136 |
if (C4::Context->preference('printSlipFromHoldsQueue')){ |
137 |
$query .= $branchlimit ? " AND" : " WHERE"; |
138 |
$query .= " tmp_holdsqueue.print_status = ?"; |
139 |
push @bind_params, $printstatus; |
140 |
} |
133 |
$query .= " ORDER BY ccode, location, cn_sort, author, title, pickbranch, reservedate"; |
141 |
$query .= " ORDER BY ccode, location, cn_sort, author, title, pickbranch, reservedate"; |
134 |
my $sth = $dbh->prepare($query); |
142 |
my $sth = $dbh->prepare($query); |
135 |
$sth->execute(@bind_params); |
143 |
$sth->execute(@bind_params); |
Lines 267-274
sub GetPendingHoldRequestsForBib {
Link Here
|
267 |
|
275 |
|
268 |
my $dbh = C4::Context->dbh; |
276 |
my $dbh = C4::Context->dbh; |
269 |
|
277 |
|
270 |
my $request_query = "SELECT biblionumber, borrowernumber, itemnumber, priority, reserves.branchcode, |
278 |
my $request_query = "SELECT reserve_id, biblionumber, borrowernumber, itemnumber, priority, reserves.branchcode, |
271 |
reservedate, reservenotes, borrowers.branchcode AS borrowerbranch |
279 |
reservedate, reservenotes, borrowers.branchcode AS borrowerbranch, print_status |
272 |
FROM reserves |
280 |
FROM reserves |
273 |
JOIN borrowers USING (borrowernumber) |
281 |
JOIN borrowers USING (borrowernumber) |
274 |
WHERE biblionumber = ? |
282 |
WHERE biblionumber = ? |
Lines 386-391
sub MapItemsToHoldRequests {
Link Here
|
386 |
if (exists $items_by_itemnumber{$request->{itemnumber}} and |
394 |
if (exists $items_by_itemnumber{$request->{itemnumber}} and |
387 |
not exists $allocated_items{$request->{itemnumber}}) { |
395 |
not exists $allocated_items{$request->{itemnumber}}) { |
388 |
$item_map{$request->{itemnumber}} = { |
396 |
$item_map{$request->{itemnumber}} = { |
|
|
397 |
reserve_id => $request->{reserve_id}, |
389 |
borrowernumber => $request->{borrowernumber}, |
398 |
borrowernumber => $request->{borrowernumber}, |
390 |
biblionumber => $request->{biblionumber}, |
399 |
biblionumber => $request->{biblionumber}, |
391 |
holdingbranch => $items_by_itemnumber{$request->{itemnumber}}->{holdingbranch}, |
400 |
holdingbranch => $items_by_itemnumber{$request->{itemnumber}}->{holdingbranch}, |
Lines 393-398
sub MapItemsToHoldRequests {
Link Here
|
393 |
item_level => 1, |
402 |
item_level => 1, |
394 |
reservedate => $request->{reservedate}, |
403 |
reservedate => $request->{reservedate}, |
395 |
reservenotes => $request->{reservenotes}, |
404 |
reservenotes => $request->{reservenotes}, |
|
|
405 |
print_status => $request->{print_status}, |
396 |
}; |
406 |
}; |
397 |
$allocated_items{$request->{itemnumber}}++; |
407 |
$allocated_items{$request->{itemnumber}}++; |
398 |
$num_items_remaining--; |
408 |
$num_items_remaining--; |
Lines 492-497
sub MapItemsToHoldRequests {
Link Here
|
492 |
delete $items_by_branch{$holdingbranch} unless @$holding_branch_items; |
502 |
delete $items_by_branch{$holdingbranch} unless @$holding_branch_items; |
493 |
|
503 |
|
494 |
$item_map{$itemnumber} = { |
504 |
$item_map{$itemnumber} = { |
|
|
505 |
reserve_id => $request->{reserve_id}, |
495 |
borrowernumber => $request->{borrowernumber}, |
506 |
borrowernumber => $request->{borrowernumber}, |
496 |
biblionumber => $request->{biblionumber}, |
507 |
biblionumber => $request->{biblionumber}, |
497 |
holdingbranch => $holdingbranch, |
508 |
holdingbranch => $holdingbranch, |
Lines 499-504
sub MapItemsToHoldRequests {
Link Here
|
499 |
item_level => 0, |
510 |
item_level => 0, |
500 |
reservedate => $request->{reservedate}, |
511 |
reservedate => $request->{reservedate}, |
501 |
reservenotes => $request->{reservenotes}, |
512 |
reservenotes => $request->{reservenotes}, |
|
|
513 |
print_status => $request->{print_status}, |
502 |
}; |
514 |
}; |
503 |
$num_items_remaining--; |
515 |
$num_items_remaining--; |
504 |
} |
516 |
} |
Lines 516-529
sub CreatePicklistFromItemMap {
Link Here
|
516 |
my $dbh = C4::Context->dbh; |
528 |
my $dbh = C4::Context->dbh; |
517 |
|
529 |
|
518 |
my $sth_load=$dbh->prepare(" |
530 |
my $sth_load=$dbh->prepare(" |
519 |
INSERT INTO tmp_holdsqueue (biblionumber,itemnumber,barcode,surname,firstname,phone,borrowernumber, |
531 |
INSERT INTO tmp_holdsqueue (reserve_id,biblionumber,itemnumber,barcode,surname,firstname,phone,borrowernumber, |
520 |
cardnumber,reservedate,title, itemcallnumber, |
532 |
cardnumber,reservedate,title, itemcallnumber, |
521 |
holdingbranch,pickbranch,notes, item_level_request) |
533 |
holdingbranch,pickbranch,notes, item_level_request,print_status) |
522 |
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |
534 |
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |
523 |
"); |
535 |
"); |
524 |
|
536 |
|
525 |
foreach my $itemnumber (sort keys %$item_map) { |
537 |
foreach my $itemnumber (sort keys %$item_map) { |
526 |
my $mapped_item = $item_map->{$itemnumber}; |
538 |
my $mapped_item = $item_map->{$itemnumber}; |
|
|
539 |
my $reserve_id = $mapped_item->{reserve_id}; |
527 |
my $biblionumber = $mapped_item->{biblionumber}; |
540 |
my $biblionumber = $mapped_item->{biblionumber}; |
528 |
my $borrowernumber = $mapped_item->{borrowernumber}; |
541 |
my $borrowernumber = $mapped_item->{borrowernumber}; |
529 |
my $pickbranch = $mapped_item->{pickup_branch}; |
542 |
my $pickbranch = $mapped_item->{pickup_branch}; |
Lines 531-536
sub CreatePicklistFromItemMap {
Link Here
|
531 |
my $reservedate = $mapped_item->{reservedate}; |
544 |
my $reservedate = $mapped_item->{reservedate}; |
532 |
my $reservenotes = $mapped_item->{reservenotes}; |
545 |
my $reservenotes = $mapped_item->{reservenotes}; |
533 |
my $item_level = $mapped_item->{item_level}; |
546 |
my $item_level = $mapped_item->{item_level}; |
|
|
547 |
my $print_status = $mapped_item->{print_status}; |
534 |
|
548 |
|
535 |
my $item = GetItem($itemnumber); |
549 |
my $item = GetItem($itemnumber); |
536 |
my $barcode = $item->{barcode}; |
550 |
my $barcode = $item->{barcode}; |
Lines 545-553
sub CreatePicklistFromItemMap {
Link Here
|
545 |
my $bib = GetBiblioData($biblionumber); |
559 |
my $bib = GetBiblioData($biblionumber); |
546 |
my $title = $bib->{title}; |
560 |
my $title = $bib->{title}; |
547 |
|
561 |
|
548 |
$sth_load->execute($biblionumber, $itemnumber, $barcode, $surname, $firstname, $phone, $borrowernumber, |
562 |
$sth_load->execute($reserve_id,$biblionumber, $itemnumber, $barcode, $surname, $firstname, $phone, $borrowernumber, |
549 |
$cardnumber, $reservedate, $title, $itemcallnumber, |
563 |
$cardnumber, $reservedate, $title, $itemcallnumber, |
550 |
$holdingbranch, $pickbranch, $reservenotes, $item_level); |
564 |
$holdingbranch, $pickbranch, $reservenotes, $item_level,$print_status); |
551 |
} |
565 |
} |
552 |
} |
566 |
} |
553 |
|
567 |
|
Lines 636-641
sub least_cost_branch {
Link Here
|
636 |
# XXX return a random @branch with minimum cost instead of the first one; |
650 |
# XXX return a random @branch with minimum cost instead of the first one; |
637 |
# return $branch[0] if @branch == 1; |
651 |
# return $branch[0] if @branch == 1; |
638 |
} |
652 |
} |
|
|
653 |
=head2 MarkHoldPrinted |
654 |
MarkHoldPrinted($reserve_id) |
655 |
Change print status as printed. |
656 |
=cut |
657 |
|
658 |
sub MarkHoldPrinted { |
659 |
my ( $reserve_id ) = @_; |
660 |
my $dbh = C4::Context->dbh; |
661 |
my $strsth="UPDATE reserves INNER JOIN tmp_holdsqueue USING (reserve_id) |
662 |
SET reserves.print_status = 1 , tmp_holdsqueue.print_status = 1 |
663 |
WHERE reserve_id = ? |
664 |
"; |
665 |
my $sth = $dbh->prepare($strsth); |
666 |
$sth->execute($reserve_id); |
667 |
|
668 |
return 1; |
669 |
} |
639 |
|
670 |
|
|
|
671 |
=head2 GetItemNumberFromTmpHold |
672 |
$itemnumber = GetItemNumberFromTmpHold($reserve_id) |
673 |
Returns itemnumber associated with hold. |
674 |
Item number is taken from tmp_holdsqueue table, which is |
675 |
populated by bulid_holds_queue.pl script. |
676 |
|
677 |
=cut |
678 |
sub GetItemNumberFromTmpHold{ |
679 |
my ( $reserve_id ) = @_; |
680 |
my $dbh = C4::Context->dbh; |
681 |
my $strsth="SELECT itemnumber |
682 |
FROM tmp_holdsqueue |
683 |
WHERE reserve_id = ? |
684 |
"; |
685 |
my $sth = $dbh->prepare($strsth); |
686 |
$sth->execute($reserve_id); |
687 |
|
688 |
my $data = $sth->fetchrow; |
689 |
return $data; |
690 |
} |
640 |
|
691 |
|
641 |
1; |
692 |
1; |