Forum - Aleph RESTful APIs – ILL per Title from Primo to Aleph

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #34178
    Anonymous
    Inactive

    ILL per Title
    After closing our old Web OPAC, which was a part of ALEPH 500, we needed to find a new way to create ILL bookings for material not found in Primo (http://leitir.is) and Aleph. For this purpose we used Aleph RESTful APIs (https://developers.exlibrisgroup.com/aleph/apis/Aleph-RESTful-APIs). To be more specific we used ILL per Title (https://developers.exlibrisgroup.com/aleph/apis/Aleph-RESTful-APIs/ILL-per-Title).

    The steps
    We created a new file in Primo that is opened in a modal window which includes a form with all needed fields. This form is connected with JavaScript using ajax to a PHP file that sends the information into Aleph. There are two tabs for book and article. See a list below on mapping of fields from the form in Primo into the ILL module in Aleph.

    Book
    Name and email are added to note
    SSN used as patron
    Requested media goes into media
    Library goes into ill-unit
    Author/Editor goes into author
    Title goes into title
    Edition goes into edition
    Place of publication goes into place-of-publication
    Publisher goes into publisher
    Year of publication goes into year-of-publication
    ISBN goes into isbn
    Series goes into series
    Source goes into source
    Author part goes into sub-author
    Title of part goes into sub-title
    Pages goes into pages
    Free text note is added to Note goes into note

    Article
    Name and email are added to note
    SSN used as patron
    Requested media goes into media
    Library goes into ill-unit
    Title of journal goes into title
    ISSN goes into issn
    Journal year goes into year
    Journal month goes into month
    Journal day goes into day
    Journal volume goes into volume
    Journal issue goes into issue
    Author of article goes into sub-author
    Title of article goes into sub-title
    Pages goes into pages
    Free text note is added to Note goes into note

    Code examples
    JavaScript

    Code:
    $(‘.form-book’).on(‘submit’, function(event) {
    var elm = $(this);
    var lang = ‘is’;
    if (elm.find(‘[name=”lang”]’).val() == ‘en’)
    lang = ‘en’;

    var browsertype = navigator.appName;

    if (browsertype == ‘Microsoft Internet Explorer’) {
    charset = ‘ISO-8859-1’;
    }
    else {
    charset = ‘UTF-8’;
    }
    var f_error = false;
    elm.find(‘[data-required]’).each( function(index) {
    var elms = $(this);
    elms.prev(‘label’).find(‘span’).remove();
    if (elms.val() == ”) {
    f_error = true;
    elms.prev(‘label’).append(‘<span class=”error”>’ + elms.data(‘reqtext’) + ‘</span>’);
    }
    });
    if (f_error == false) {
    elm.find(‘.form-missing’).text(”);
    $.ajax({
    url: "/ajax.php",
    type: "GET",
    contentType: "application/json",
    dataType: "json",
    scriptCharset : charset,
    async: false,
    data: "form=interlibrary&" + elm.serialize() + "&encode="+charset+"&lang="+lang,
    success: function(data) {
    var dataJSON = $.parseJSON(data);

    if (data.msg == ‘Beiðni hefur verið send’ || data.msg == ‘Your request has been sent’) {
    setTimeout(function(){ hideLightBox(); }, 7000);
    }
    elm.find(‘.form-missing’).text(data.msg);
    }
    });
    }
    else {
    if (lang == ‘is’)
    elm.find(‘.form-missing’).text(‘Vantar upplýsingar í form’);
    else
    elm.find(‘.form-missing’).text(‘Information missing in form’);
    }

    return false;
    });

    PHP

    Code:
    if(isset($_GET[‘form’]) && $_GET[‘form’] == ‘interlibrary’) {

    $ill_unit = array(
    "Landsbókasafn Íslands-Háskólabókasafn" => "IC-LBSHL",
    "Amtsbókasafnið á Akureyri" => "IC-AMAAN",
    "Borgarbókasafn Reykjavíkur" => "IC-BBAAA",
    "Bóka- og héraðsskjalasafn Fjallabyggðar" => "IC-OLAAN",
    "Bókasafn Akraness" => "IC-AKRAV",
    "Bókasafn Árborgar" => "IC-SELAS",
    "Bókasafn Grindavíkur" => "IC-GRIAS",
    "Bókasafn Hafnarfjarðar" => "IC-HAFAA",
    "Bókasafn Reykjaness" => "IC-REYAS",
    "Bókasafnið í Hveragerði" => "IC-HVEAS",
    "Bæjarbókasafn Ölfuss" => "IC-OLFAS",
    "Grunnskóli Borgarfjarðar" => "IC-KLEGV",
    "Háskólinn á Akureyri" => "IC-HAKHN",
    "Háskólinn á Bifröst" => "IC-VIBHH",
    "Háskólinn í Reykjavík" => "IC-HREHH",
    "Heilbrigðisvísindabókasafn" => "IC-LHRML",
    "Keilir, Ásbrú" => "IC-KEIHS",
    "Listaháskóli Íslands" => "IC-LISHH",
    "Menntavísindasvið HÍ" => "IC-KHIHK"
    );

    $type = $_GET[‘Media’];

    $mn_or_se = ‘MN’;
    switch ($_GET[‘formis’]) {
    case ‘Bók’:
    case ‘Book’:
    $mn_or_se = ‘MN’;
    break;
    case ‘Grein’:
    case ‘Article’:
    $mn_or_se = ‘SE’;
    break;
    default:
    $mn_or_se = ‘MN’;
    }

    $lang = ‘ICE’;
    switch ($_GET[‘lang’]) {
    case ‘is’:
    $lang = ‘ICE’;
    break;
    case ‘en’:
    $lang = ‘ENG’;
    break;
    }

    $url = ‘http://snorri.lb.is:1892/rest-dlf/patron/&#8217; . $_GET[‘UserSS’]. ‘/record/’ . $mn_or_se .’/ill’;
    $ch = curl_init();
    curl_setopt( $ch, CURLOPT_URL, $url );
    curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, ‘PUT’);
    curl_setopt( $ch, CURLOPT_HTTPHEADER, array(‘Content-Type: text/xml’));
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch, CURLOPT_POSTFIELDS, "post_xml=<ill-parameters><ill-unit>” .$ill_unit[$_GET[‘Library’]] . “</ill-unit><last-interest-date>” . date(‘Ymd’, strtotime(“+3 weeks”)) . “</last-interest-date><pickup-location>POSTE</pickup-location><media>” . $type . “</media><sub-author>” . (isset($_GET[‘sub-author’]) ? $_GET[‘sub-author’] : “”) . “</sub-author><sub-title>” . (isset($_GET[‘sub-title’]) ? $_GET[‘sub-title’] : “”) . “</sub-title><volume>” . (isset($_GET[‘volume’]) ? $_GET[‘volume’] : “”) . “</volume><level-of-service>L</level-of-service><willing-to-pay></willing-to-pay><language>ICE</language><send-directly>N</send-directly><delivery-method>S</delivery-method><copyright>Y</copyright><pages>” . (isset($_GET[‘pages’]) ? $_GET[‘pages’] : “”) . “</pages><note>” . (isset($_GET[‘UserName’]) ? $_GET[‘UserName’] . “n” : “”) . “” . (isset($_GET[‘UserEmail’]) ? $_GET[‘UserEmail’] . “n” : “”) . “” . (isset($_GET[‘note’]) ? $_GET[‘note’] : “”) . “</note><year>” . (isset($_GET[‘year’]) ? $_GET[‘year’] : “”) . “</year><month>” . (isset($_GET[‘month’]) ? $_GET[‘month’] : “”) . “</month><day>” . (isset($_GET[‘day’]) ? $_GET[‘day’] : “”) . “</day><issue>” . (isset($_GET[‘issue’]) ? $_GET[‘issue’] : “”) . “</issue><author>” . (isset($_GET[‘author’]) ? $_GET[‘author’] : “”) . “</author><title>” . (isset($_GET[‘title’]) ? $_GET[‘title’] : “”) . “</title><edition>” . (isset($_GET[‘edition’]) ? $_GET[‘edition’] : “”) . “</edition><place-of-publication>” . (isset($_GET[‘place-of-publication’]) ? $_GET[‘place-of-publication’] : “”) . “</place-of-publication><publisher>” . (isset($_GET[‘publisher’]) ? $_GET[‘publisher’] : “”) . “</publisher><year-of-publication>” . (isset($_GET[‘year-of-publication’]) ? $_GET[‘year-of-publication’] : “”) . “</year-of-publication><isbn>” . (isset($_GET[‘isbn’]) ? $_GET[‘isbn’] : “”) . “</isbn><series>” . (isset($_GET[‘series’]) ? $_GET[‘series’] : “”) . “</series><source>” . (isset($_GET[‘source’]) ? $_GET[‘source’] : “”) . “</source><issn>” . (isset($_GET[‘issn’]) ? $_GET[‘issn’] : “”) . “</issn></ill-parameters>" );

    $result = curl_exec($ch);

    $xml = new SimpleXMLElement($result);

    $xmlArr = array();
    foreach ($xml as $key => $value) {
    if ($value instanceof StdClass) {
    $xmlArr[$key] = $value->toArray();
    } else {
    $xmlArr[$key] = $value;
    }
    }

    if ($xmlArr[‘reply-code’] == ‘0000’) {
    $response = array(‘lang’ => $lang, ‘msg’ => ($lang == ‘ICE’ ? ‘Beiðni hefur verið send’ : ‘Your request has been sent’));
    echo json_encode($response);
    }
    elseif ($xmlArr[‘reply-code’] == ‘0025’ && $xmlArr[‘create-ill’]->note == ‘Invalid or missing ILL unit for patron.’) {
    $response = array(‘lang’ => $lang, ‘msg’ => ($lang == ‘ICE’ ? ‘Kannaðu hvort að rétt bókasafn sé valið, annars hafðu samband við þitt bókasafn fyrir nánari upplýsingar’ : ‘Check if correct library has been selected, or else contact your library for further information’));
    echo json_encode($response);
    }
    elseif ($xmlArr[‘reply-code’] == ‘0025’ && $xmlArr[‘create-ill’]->note == ‘Patron has exceeded requests limit’) {
    $response = array(‘lang’ => $lang, ‘msg’ => ($lang == ‘ICE’ ? ‘Hámarki beiðna náð. Hafðu samband við bókasafnið þitt’ : ‘You have exceeded requests limit. Please contact your library.’));
    echo json_encode($response);
    }
    else {
    $response = array(‘lang’ => $lang, ‘msg’ => ($lang == ‘ICE’ ? ‘Kannaðu hvort að rétt bókasafn sé valið, annars hafðu samband við þitt bókasafn fyrir nánari upplýsingar’ : ‘Check if correct library has been selected, or else contact your library for further information’));
    echo json_encode($response);
    }

    curl_close($ch);

    }

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.