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