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 387-392
sub MapItemsToHoldRequests {
Link Here
|
387 |
if (exists $items_by_itemnumber{$request->{itemnumber}} and |
395 |
if (exists $items_by_itemnumber{$request->{itemnumber}} and |
388 |
not exists $allocated_items{$request->{itemnumber}}) { |
396 |
not exists $allocated_items{$request->{itemnumber}}) { |
389 |
$item_map{$request->{itemnumber}} = { |
397 |
$item_map{$request->{itemnumber}} = { |
|
|
398 |
reserve_id => $request->{reserve_id}, |
390 |
borrowernumber => $request->{borrowernumber}, |
399 |
borrowernumber => $request->{borrowernumber}, |
391 |
biblionumber => $request->{biblionumber}, |
400 |
biblionumber => $request->{biblionumber}, |
392 |
holdingbranch => $items_by_itemnumber{$request->{itemnumber}}->{holdingbranch}, |
401 |
holdingbranch => $items_by_itemnumber{$request->{itemnumber}}->{holdingbranch}, |
Lines 394-399
sub MapItemsToHoldRequests {
Link Here
|
394 |
item_level => 1, |
403 |
item_level => 1, |
395 |
reservedate => $request->{reservedate}, |
404 |
reservedate => $request->{reservedate}, |
396 |
reservenotes => $request->{reservenotes}, |
405 |
reservenotes => $request->{reservenotes}, |
|
|
406 |
print_status => $request->{print_status}, |
397 |
}; |
407 |
}; |
398 |
$allocated_items{$request->{itemnumber}}++; |
408 |
$allocated_items{$request->{itemnumber}}++; |
399 |
$num_items_remaining--; |
409 |
$num_items_remaining--; |
Lines 493-498
sub MapItemsToHoldRequests {
Link Here
|
493 |
delete $items_by_branch{$holdingbranch} unless @$holding_branch_items; |
503 |
delete $items_by_branch{$holdingbranch} unless @$holding_branch_items; |
494 |
|
504 |
|
495 |
$item_map{$itemnumber} = { |
505 |
$item_map{$itemnumber} = { |
|
|
506 |
reserve_id => $request->{reserve_id}, |
496 |
borrowernumber => $request->{borrowernumber}, |
507 |
borrowernumber => $request->{borrowernumber}, |
497 |
biblionumber => $request->{biblionumber}, |
508 |
biblionumber => $request->{biblionumber}, |
498 |
holdingbranch => $holdingbranch, |
509 |
holdingbranch => $holdingbranch, |
Lines 500-505
sub MapItemsToHoldRequests {
Link Here
|
500 |
item_level => 0, |
511 |
item_level => 0, |
501 |
reservedate => $request->{reservedate}, |
512 |
reservedate => $request->{reservedate}, |
502 |
reservenotes => $request->{reservenotes}, |
513 |
reservenotes => $request->{reservenotes}, |
|
|
514 |
print_status => $request->{print_status}, |
503 |
}; |
515 |
}; |
504 |
$num_items_remaining--; |
516 |
$num_items_remaining--; |
505 |
} |
517 |
} |
Lines 517-530
sub CreatePicklistFromItemMap {
Link Here
|
517 |
my $dbh = C4::Context->dbh; |
529 |
my $dbh = C4::Context->dbh; |
518 |
|
530 |
|
519 |
my $sth_load=$dbh->prepare(" |
531 |
my $sth_load=$dbh->prepare(" |
520 |
INSERT INTO tmp_holdsqueue (biblionumber,itemnumber,barcode,surname,firstname,phone,borrowernumber, |
532 |
INSERT INTO tmp_holdsqueue (reserve_id,biblionumber,itemnumber,barcode,surname,firstname,phone,borrowernumber, |
521 |
cardnumber,reservedate,title, itemcallnumber, |
533 |
cardnumber,reservedate,title, itemcallnumber, |
522 |
holdingbranch,pickbranch,notes, item_level_request) |
534 |
holdingbranch,pickbranch,notes, item_level_request,print_status) |
523 |
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |
535 |
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) |
524 |
"); |
536 |
"); |
525 |
|
537 |
|
526 |
foreach my $itemnumber (sort keys %$item_map) { |
538 |
foreach my $itemnumber (sort keys %$item_map) { |
527 |
my $mapped_item = $item_map->{$itemnumber}; |
539 |
my $mapped_item = $item_map->{$itemnumber}; |
|
|
540 |
my $reserve_id = $mapped_item->{reserve_id}; |
528 |
my $biblionumber = $mapped_item->{biblionumber}; |
541 |
my $biblionumber = $mapped_item->{biblionumber}; |
529 |
my $borrowernumber = $mapped_item->{borrowernumber}; |
542 |
my $borrowernumber = $mapped_item->{borrowernumber}; |
530 |
my $pickbranch = $mapped_item->{pickup_branch}; |
543 |
my $pickbranch = $mapped_item->{pickup_branch}; |
Lines 532-537
sub CreatePicklistFromItemMap {
Link Here
|
532 |
my $reservedate = $mapped_item->{reservedate}; |
545 |
my $reservedate = $mapped_item->{reservedate}; |
533 |
my $reservenotes = $mapped_item->{reservenotes}; |
546 |
my $reservenotes = $mapped_item->{reservenotes}; |
534 |
my $item_level = $mapped_item->{item_level}; |
547 |
my $item_level = $mapped_item->{item_level}; |
|
|
548 |
my $print_status = $mapped_item->{print_status}; |
535 |
|
549 |
|
536 |
my $item = GetItem($itemnumber); |
550 |
my $item = GetItem($itemnumber); |
537 |
my $barcode = $item->{barcode}; |
551 |
my $barcode = $item->{barcode}; |
Lines 546-554
sub CreatePicklistFromItemMap {
Link Here
|
546 |
my $bib = GetBiblioData($biblionumber); |
560 |
my $bib = GetBiblioData($biblionumber); |
547 |
my $title = $bib->{title}; |
561 |
my $title = $bib->{title}; |
548 |
|
562 |
|
549 |
$sth_load->execute($biblionumber, $itemnumber, $barcode, $surname, $firstname, $phone, $borrowernumber, |
563 |
$sth_load->execute($reserve_id,$biblionumber, $itemnumber, $barcode, $surname, $firstname, $phone, $borrowernumber, |
550 |
$cardnumber, $reservedate, $title, $itemcallnumber, |
564 |
$cardnumber, $reservedate, $title, $itemcallnumber, |
551 |
$holdingbranch, $pickbranch, $reservenotes, $item_level); |
565 |
$holdingbranch, $pickbranch, $reservenotes, $item_level,$print_status); |
552 |
} |
566 |
} |
553 |
} |
567 |
} |
554 |
|
568 |
|
Lines 637-642
sub least_cost_branch {
Link Here
|
637 |
# XXX return a random @branch with minimum cost instead of the first one; |
651 |
# XXX return a random @branch with minimum cost instead of the first one; |
638 |
# return $branch[0] if @branch == 1; |
652 |
# return $branch[0] if @branch == 1; |
639 |
} |
653 |
} |
|
|
654 |
=head2 MarkHoldPrinted |
655 |
MarkHoldPrinted($reserve_id) |
656 |
Change print status as printed. |
657 |
=cut |
658 |
|
659 |
sub MarkHoldPrinted { |
660 |
my ( $reserve_id ) = @_; |
661 |
my $dbh = C4::Context->dbh; |
662 |
my $strsth="UPDATE reserves INNER JOIN tmp_holdsqueue USING (reserve_id) |
663 |
SET reserves.print_status = 1 , tmp_holdsqueue.print_status = 1 |
664 |
WHERE reserve_id = ? |
665 |
"; |
666 |
my $sth = $dbh->prepare($strsth); |
667 |
$sth->execute($reserve_id); |
668 |
|
669 |
return 1; |
670 |
} |
640 |
|
671 |
|
|
|
672 |
=head2 GetItemNumberFromTmpHold |
673 |
$itemnumber = GetItemNumberFromTmpHold($reserve_id) |
674 |
Returns itemnumber associated with hold. |
675 |
Item number is taken from tmp_holdsqueue table, which is |
676 |
populated by bulid_holds_queue.pl script. |
677 |
|
678 |
=cut |
679 |
sub GetItemNumberFromTmpHold{ |
680 |
my ( $reserve_id ) = @_; |
681 |
my $dbh = C4::Context->dbh; |
682 |
my $strsth="SELECT itemnumber |
683 |
FROM tmp_holdsqueue |
684 |
WHERE reserve_id = ? |
685 |
"; |
686 |
my $sth = $dbh->prepare($strsth); |
687 |
$sth->execute($reserve_id); |
688 |
|
689 |
my $data = $sth->fetchrow; |
690 |
return $data; |
691 |
} |
641 |
|
692 |
|
642 |
1; |
693 |
1; |