|
Lines 725-730
sub _core_status_graph {
Link Here
|
| 725 |
ui_method_icon => 'fa-download', |
725 |
ui_method_icon => 'fa-download', |
| 726 |
} |
726 |
} |
| 727 |
}; |
727 |
}; |
|
|
728 |
|
| 729 |
# Lending Status Graph |
| 730 |
sub _core_lending_status_graph { |
| 731 |
|
| 732 |
# Supplying agency has recieved a request/more information from a retry |
| 733 |
RequestReceived => { |
| 734 |
prev_actions => ['RetryPossible'], |
| 735 |
id => 'RequestReceived', |
| 736 |
name => __('Lending request recieved'), |
| 737 |
ui_method_name => 0, |
| 738 |
method => 'create_lending', |
| 739 |
next_actions => [ 'ExpectToSupply', 'WillSupply', 'Loaned', 'RetryPossible', 'Unfilled', 'CopyCompleted' ], |
| 740 |
ui_method_icon => 'fa-plus', |
| 741 |
}, |
| 742 |
|
| 743 |
# Suppling library expects to fill the request. Can include ExpectedDeliveryDate |
| 744 |
ExpectToSupply => { |
| 745 |
prev_actions => ['RequestReceived'], |
| 746 |
id => 'ExpectToSupply', |
| 747 |
name => __('Expect to supply'), |
| 748 |
ui_method_name => __('Expect to supply'), |
| 749 |
method => 'expect_to_supply', |
| 750 |
next_actions => [ 'WillSupply', 'Loaned', 'RetryPossible', 'Unfilled' ], |
| 751 |
}, |
| 752 |
|
| 753 |
# Supplying library has located the item but has not sent it |
| 754 |
WillSupply => { |
| 755 |
prev_actions => [ 'RequestReceived', 'ExpectToSupply' ], |
| 756 |
id => 'WillSupply', |
| 757 |
name => __('Will supply'), |
| 758 |
ui_method_name => __('Will supply'), |
| 759 |
method => 'will_supply', |
| 760 |
next_actions => [ 'Loaned', 'RetryPossible', 'CopyCompleted', 'Unfilled' ], |
| 761 |
}, |
| 762 |
|
| 763 |
# The item is currently on loan to the partner library for the request |
| 764 |
Loaned => { |
| 765 |
prev_actions => [ 'RequestReceived', 'ExpectToSupply', 'WillSupply' ], |
| 766 |
id => 'Loaned', |
| 767 |
name => __('Loaned to partner library'), |
| 768 |
ui_method_name => __('Loan to partner library'), |
| 769 |
needs_prefs => ['CirculateILL'], |
| 770 |
needs_perms => ['user_circulate_circulate_remaining_permissions'], |
| 771 |
next_actions => [ 'Recalled', 'HoldReturn', 'LoanCompleted', 'CompletedWithoutReturn' ], |
| 772 |
|
| 773 |
# An array of functions that all must return true |
| 774 |
needs_all => [ sub { my $r = shift; return $r->biblio; } ], |
| 775 |
method => 'lend', |
| 776 |
next_actions => [], |
| 777 |
ui_method_icon => 'fa-upload', |
| 778 |
}, |
| 779 |
|
| 780 |
# The item is on loan to the partner library and is overdue |
| 781 |
Overdue => { |
| 782 |
prev_actions => ['Loaned'], |
| 783 |
id => 'Overdue', |
| 784 |
name => __('Loaned item is overdue'), |
| 785 |
ui_method_name => 0, |
| 786 |
method => 0, |
| 787 |
next_actions => [ 'Recalled', 'HoldReturn', 'LoanCompleted', 'CompletedWithoutReturn' ], |
| 788 |
}, |
| 789 |
|
| 790 |
# The item has been recalled to the supplying library |
| 791 |
Recalled => { |
| 792 |
prev_actions => [ 'Loaned', 'Overdue' ], |
| 793 |
id => 'Recalled', |
| 794 |
name => __('Recall requested to partner library'), |
| 795 |
ui_method_name => __('Request recall to partner library'), |
| 796 |
method => 'recall', |
| 797 |
next_actions => [ 'LoanCompleted', 'CompletedWithoutReturn' ], |
| 798 |
}, |
| 799 |
|
| 800 |
# The supplying library cannot fill currently and needs more information. Send a reason with RetryInfo section |
| 801 |
RetryPossible => { |
| 802 |
prev_actions => [ 'WillSupply', 'RequestReceived', 'ExpectToSupply' ], |
| 803 |
id => 'RetryPossible', |
| 804 |
name => __('Retry possible'), |
| 805 |
ui_method_name => __('Not currently available'), |
| 806 |
method => 'retry_possible', |
| 807 |
next_actions => [''], |
| 808 |
}, |
| 809 |
|
| 810 |
# The request will not be filled. A reason can be supplied with the ReasonUnfilled data element |
| 811 |
Unfilled => { |
| 812 |
prev_actions => [ 'WillSupply', 'RequestReceived', 'ExpectToSupply' ], |
| 813 |
id => 'Unfilled', |
| 814 |
name => __('Request unfilled'), |
| 815 |
ui_method_name => __('Will not fill'), |
| 816 |
method => 'unfilled', |
| 817 |
next_actions => [''], |
| 818 |
}, |
| 819 |
|
| 820 |
# The item is currently on loan to the partner library and cannot yet be returned |
| 821 |
HoldReturn => { |
| 822 |
prev_actions => [ 'Loaned', 'Overdue' ], |
| 823 |
id => 'HoldReturn', |
| 824 |
name => __('Return hold'), |
| 825 |
ui_method_name => __('Request partner not return'), |
| 826 |
method => 'hold_return', |
| 827 |
next_actions => ['ReleaseHoldReturn'], |
| 828 |
}, |
| 829 |
|
| 830 |
# An item that did have a return hold can now be returned by the partner library |
| 831 |
ReleaseHoldReturn => { |
| 832 |
prev_actions => ['HoldReturn'], |
| 833 |
id => 'ReleaseHoldReturn', |
| 834 |
name => __('Return hold released'), |
| 835 |
ui_method_name => __('Release return hold'), |
| 836 |
method => 'release_hold_return', |
| 837 |
next_actions => [ 'LoanCompleted', 'CompletedWithoutReturn' ], |
| 838 |
}, |
| 839 |
|
| 840 |
# The supplying library has sent the requested item and there is no need to return it |
| 841 |
CopyCompleted => { |
| 842 |
prev_actions => [ 'WillSupply', 'RequestReceived', 'ExpectToSupply' ], |
| 843 |
id => 'CopyCompleted', |
| 844 |
name => __('Copy sent'), |
| 845 |
ui_method_name => __('Send copy'), |
| 846 |
method => 'send_copy', |
| 847 |
next_actions => [''], |
| 848 |
ui_method_icon => 'fa-envelope-open-text', |
| 849 |
}, |
| 850 |
|
| 851 |
# The loan has been returned from the partner library and checked in |
| 852 |
LoanCompleted => { |
| 853 |
prev_actions => [ 'Loaned', 'Overdue', 'Recalled', 'ReleaseHoldReturn' ], |
| 854 |
id => 'LoanCompleted', |
| 855 |
name => __('Completed'), |
| 856 |
ui_method_name => __('Complete request'), |
| 857 |
method => 'loan_complete', |
| 858 |
next_actions => [''], |
| 859 |
ui_method_icon => 'fa-download', |
| 860 |
}, |
| 861 |
|
| 862 |
# The loan has been marked as completed without reciving the item back due to loss or damage |
| 863 |
CompletedWithoutReturn => { |
| 864 |
prev_actions => [ 'Loaned', 'Overdue', 'Recalled', 'ReleaseHoldReturn' ], |
| 865 |
id => 'CompletedWithoutReturn', |
| 866 |
name => __('Request completed without return'), |
| 867 |
ui_method_name => __('Complete without return'), |
| 868 |
method => 'loan_complete_no_return', |
| 869 |
next_actions => [''], |
| 870 |
ui_method_icon => 'fa-download', |
| 871 |
}, |
| 872 |
|
| 873 |
# The supplying library has cancelled the request - Reported by partner library |
| 874 |
Cancelled => { |
| 875 |
prev_actions => [ 'WillSupply', 'RequestReceived', 'ExpectToSupply' ], |
| 876 |
id => 'Cancelled', |
| 877 |
name => __('Request cancelled (borrowing)'), |
| 878 |
ui_method_name => 0, |
| 879 |
method => 'cancelled_borrowing', |
| 880 |
next_actions => [''], |
| 881 |
ui_method_icon => 'fa-trash', |
| 882 |
}, |
| 883 |
; |
| 884 |
} |
| 728 |
} |
885 |
} |
| 729 |
|
886 |
|
| 730 |
=head3 _status_graph_union |
887 |
=head3 _status_graph_union |
|
Lines 797-802
sub _status_graph_union {
Link Here
|
| 797 |
return $status_graph; |
954 |
return $status_graph; |
| 798 |
} |
955 |
} |
| 799 |
|
956 |
|
|
|
957 |
=head3 _lending_status_graph_union |
| 958 |
|
| 959 |
my $lending_status_graph = $illrequest->_status_graph_union($origin, $new_graph); |
| 960 |
|
| 961 |
Return a new status_graph, the result of merging $origin & new_graph. This is |
| 962 |
operation is a union over the sets defied by the two graphs. |
| 963 |
|
| 964 |
Each entry in $new_graph is added to $origin. We do not provide a syntax for |
| 965 |
'subtraction' of entries from $origin. |
| 966 |
|
| 967 |
Whilst it is not intended that this works, you can override entries in $origin |
| 968 |
with entries with the same key in $new_graph. This can lead to problematic |
| 969 |
behaviour when $new_graph adds an entry, which modifies a dependent entry in |
| 970 |
$origin, only for the entry in $origin to be replaced later with a new entry |
| 971 |
from $new_graph. |
| 972 |
|
| 973 |
NOTE: this procedure does not "re-link" entries in $origin or $new_graph, |
| 974 |
i.e. each of the graphs need to be correct at the outset of the operation. |
| 975 |
|
| 976 |
=cut |
| 977 |
|
| 978 |
sub _lending_status_graph_union { |
| 979 |
my ( $self, $core_lending_status_graph, $backend_lending_status_graph ) = @_; |
| 980 |
|
| 981 |
# Create new status graph with: |
| 982 |
# - all core_lending_status_graph |
| 983 |
# - for-each each backend_lending_status_graph |
| 984 |
# + add to new status graph |
| 985 |
# + for each core prev_action: |
| 986 |
# * locate core_status |
| 987 |
# * update next_actions with additional next action. |
| 988 |
# + for each core next_action: |
| 989 |
# * locate core_status |
| 990 |
# * update prev_actions with additional prev action |
| 991 |
|
| 992 |
my @core_lending_status_ids = keys %{$core_lending_status_graph}; |
| 993 |
my $lending_status_graph = clone($core_lending_status_graph); |
| 994 |
|
| 995 |
foreach my $backend_lending_status_key ( keys %{$backend_lending_status_graph} ) { |
| 996 |
my $backend_lending_status = $backend_lending_status_graph->{$backend_lending_status_key}; |
| 997 |
|
| 998 |
# Add to new status graph |
| 999 |
$lending_status_graph->{$backend_lending_status_key} = $backend_lending_status; |
| 1000 |
|
| 1001 |
# Update all core methods' next_actions. |
| 1002 |
foreach my $prev_action ( @{ $backend_lending_status->{prev_actions} } ) { |
| 1003 |
if ( grep { $prev_action eq $_ } @core_lending_status_ids ) { |
| 1004 |
my @next_actions = |
| 1005 |
@{ $lending_status_graph->{$prev_action}->{next_actions} }; |
| 1006 |
push @next_actions, $backend_lending_status_key |
| 1007 |
if ( !grep( /^$backend_lending_status_key$/, @next_actions ) ); |
| 1008 |
$lending_status_graph->{$prev_action}->{next_actions} = \@next_actions; |
| 1009 |
} |
| 1010 |
} |
| 1011 |
|
| 1012 |
# Update all core methods' prev_actions |
| 1013 |
foreach my $next_action ( @{ $backend_lending_status->{next_actions} } ) { |
| 1014 |
if ( grep { $next_action eq $_ } @core_lending_status_ids ) { |
| 1015 |
my @prev_actions = |
| 1016 |
@{ $lending_status_graph->{$next_action}->{prev_actions} }; |
| 1017 |
push @prev_actions, $backend_lending_status_key |
| 1018 |
if ( !grep( /^$backend_lending_status_key$/, @prev_actions ) ); |
| 1019 |
$lending_status_graph->{$next_action}->{prev_actions} = \@prev_actions; |
| 1020 |
} |
| 1021 |
} |
| 1022 |
} |
| 1023 |
|
| 1024 |
return $lending_status_graph; |
| 1025 |
} |
| 1026 |
|
| 800 |
### Core API methods |
1027 |
### Core API methods |
| 801 |
|
1028 |
|
| 802 |
=head3 capabilities |
1029 |
=head3 capabilities |
|
Lines 829-840
sub capabilities {
Link Here
|
| 829 |
# Generate up to date status_graph |
1056 |
# Generate up to date status_graph |
| 830 |
my $status_graph = $self->_status_graph_union( |
1057 |
my $status_graph = $self->_status_graph_union( |
| 831 |
$self->_core_status_graph, |
1058 |
$self->_core_status_graph, |
|
|
1059 |
$self->_core_lending_status_graph, |
| 832 |
$self->_backend->status_graph( |
1060 |
$self->_backend->status_graph( |
| 833 |
{ |
1061 |
{ |
| 834 |
request => $self, |
1062 |
request => $self, |
| 835 |
other => {} |
1063 |
other => {} |
| 836 |
} |
1064 |
} |
| 837 |
) |
1065 |
), |
|
|
1066 |
$self->_backend->lending_status_graph( { request => $self . other => {} } ) |
| 838 |
); |
1067 |
); |
| 839 |
|
1068 |
|
| 840 |
# Extract available actions from graph. |
1069 |
# Extract available actions from graph. |
| 841 |
- |
|
|