|
Lines 24-29
use Try::Tiny qw( catch try );
Link Here
|
| 24 |
use DateTime; |
24 |
use DateTime; |
| 25 |
|
25 |
|
| 26 |
use C4::Letters; |
26 |
use C4::Letters; |
|
|
27 |
|
| 28 |
use Koha::Cache::Memory::Lite; |
| 27 |
use Koha::Database; |
29 |
use Koha::Database; |
| 28 |
use Koha::DateUtils qw( dt_from_string ); |
30 |
use Koha::DateUtils qw( dt_from_string ); |
| 29 |
use Koha::Exceptions::Ill; |
31 |
use Koha::Exceptions::Ill; |
|
Lines 1879-1884
sub TO_JSON {
Link Here
|
| 1879 |
|
1881 |
|
| 1880 |
=head2 Internal methods |
1882 |
=head2 Internal methods |
| 1881 |
|
1883 |
|
|
|
1884 |
=head3 to_api_mapping |
| 1885 |
|
| 1886 |
=cut |
| 1887 |
|
| 1888 |
sub to_api_mapping { |
| 1889 |
return { |
| 1890 |
illrequest_id => 'ill_request_id', |
| 1891 |
borrowernumber => 'patron_id', |
| 1892 |
branchcode => 'library_id', |
| 1893 |
status_alias => 'status_av', |
| 1894 |
placed => 'requested_date', |
| 1895 |
replied => 'replied_date', |
| 1896 |
updated => 'timestamp', |
| 1897 |
completed => 'completed_date', |
| 1898 |
accessurl => 'access_url', |
| 1899 |
price_paid => 'paid_price', |
| 1900 |
notesopac => 'opac_notes', |
| 1901 |
notesstaff => 'staff_notes', |
| 1902 |
orderid => 'ill_backend_request_id', |
| 1903 |
backend => 'ill_backend_id', |
| 1904 |
}; |
| 1905 |
} |
| 1906 |
|
| 1907 |
=head3 strings_map |
| 1908 |
|
| 1909 |
my $strings = $self->string_map({ [ public => 0|1 ] }); |
| 1910 |
|
| 1911 |
Returns a map of column name to string representations. Extra information |
| 1912 |
is returned depending on the column characteristics as shown below. |
| 1913 |
|
| 1914 |
Accepts a param hashref where the I<public> key denotes whether we want the public |
| 1915 |
or staff client strings. |
| 1916 |
|
| 1917 |
Example: |
| 1918 |
|
| 1919 |
{ |
| 1920 |
status => { |
| 1921 |
backend => 'backendName', |
| 1922 |
str => 'Status description', |
| 1923 |
type => 'ill_status', |
| 1924 |
}, |
| 1925 |
status_alias => { |
| 1926 |
category => 'ILL_STATUS_ALIAS, |
| 1927 |
str => $value, # the AV description, depending on $params->{public} |
| 1928 |
type => 'av', |
| 1929 |
} |
| 1930 |
} |
| 1931 |
|
| 1932 |
=cut |
| 1933 |
|
| 1934 |
sub strings_map { |
| 1935 |
my ( $self, $params ) = @_; |
| 1936 |
|
| 1937 |
my $cache = Koha::Cache::Memory::Lite->get_instance(); |
| 1938 |
my $cache_key = 'ill:status_graph:' . $self->backend; |
| 1939 |
|
| 1940 |
my $status_graph_union = $cache->get($cache_key); |
| 1941 |
unless ($status_graph_union) { |
| 1942 |
$status_graph_union = $self->capabilities; |
| 1943 |
$cache->set( $cache_key, $status_graph_union ); |
| 1944 |
} |
| 1945 |
|
| 1946 |
my $status_string = |
| 1947 |
( exists $status_graph_union->{ $self->status } && defined $status_graph_union->{ $self->status }->{name} ) |
| 1948 |
? $status_graph_union->{ $self->status }->{name} |
| 1949 |
: $self->status; |
| 1950 |
|
| 1951 |
my $status_code = |
| 1952 |
( exists $status_graph_union->{ $self->status } && defined $status_graph_union->{ $self->status }->{id} ) |
| 1953 |
? $status_graph_union->{ $self->status }->{id} |
| 1954 |
: $self->status; |
| 1955 |
|
| 1956 |
my $strings = { |
| 1957 |
status => { |
| 1958 |
backend => $self->backend, # the backend identifier |
| 1959 |
str => $status_string, # the status description, taken from the status graph |
| 1960 |
code => $status_code, # the status id, taken from the status graph |
| 1961 |
type => 'ill_status', # fixed type |
| 1962 |
} |
| 1963 |
}; |
| 1964 |
|
| 1965 |
my $status_alias = $self->statusalias; |
| 1966 |
if ($status_alias) { |
| 1967 |
$strings->{"status_alias"} = { |
| 1968 |
category => 'ILL_STATUS_ALIAS', |
| 1969 |
str => $params->{public} ? $status_alias->lib_opac : $status_alias->lib, |
| 1970 |
code => $status_alias->authorised_value, |
| 1971 |
type => 'av', |
| 1972 |
}; |
| 1973 |
} |
| 1974 |
|
| 1975 |
return $strings; |
| 1976 |
} |
| 1977 |
|
| 1882 |
=head3 _type |
1978 |
=head3 _type |
| 1883 |
|
1979 |
|
| 1884 |
=cut |
1980 |
=cut |