#!/usr/bin/perl

$url = `cat /opt/folio/config/url`; chomp($url);
$headers = `cat /opt/folio/config/headers`; chomp($headers);

use CGI; 
$query = new CGI; 
$barcode = $query->param("barcode");
$username = $query->param("username");

use JSON; 
    
@mtypes = `cat /opt/folio/config/mtypes`;
foreach $row (@mtypes) {
    chomp($row);
    ($id,$name) = split(/\|/,$row);
    $materialType{$id} = $name;
}

$choices = qq[
    <form action="scanBarcode.pl" method="post" name="no"><p align="center"><table border="0" width="75%">
    <tr><th colspan="2"><hr style="height:5px;border-width:0;"></th></tr>
    <tr><td class="v18">even if this appears to be a match it doesn't have an OCLC number, so...<p align="right">put it on the "problems" shelf and click...</td>
    <td align="center" bgcolor="#f3654e" class="v18" valign="center"><input type="submit" value="no, there's a problem"></td></tr></table></form>
];

$items = `curl -s -X GET $headers $url/item-storage/items?query=barcode=="$barcode"`;
$hash = decode_json $items;
$totalItems = $hash->{totalRecords};
for ( @{$hash->{items}} ) {
    $holdingsRecordId = $_->{'holdingsRecordId'};
    $materialTypeId = $_->{'materialTypeId'};
    $mtype = $materialType{$materialTypeId};
}

if ($totalItems == 0) {
    $errorMessage = "barcode ($barcode) not found";
} else {

$holdingsRecord = `curl -s -X GET $headers $url/holdings-storage/holdings/$holdingsRecordId`;
$hash = decode_json $holdingsRecord;
$callNumber = $hash->{'callNumber'};
$instanceId = $hash->{'instanceId'};

$instance = `curl -s -X GET $headers $url/instance-storage/instances/$instanceId`;
$hash = decode_json $instance;
$title = $hash->{'title'};

$oclcIndentifierTypeId = "fa02ef8b-b0be-4183-ad46-38060d23c402";
for ( @{$hash->{identifiers}} ) {
    $thisIdentifierTypeId = $_->{identifierTypeId};
    if ($thisIdentifierTypeId eq $oclcIndentifierTypeId) {
        $oclc = $_->{value};
        if ($oclc =~ /OCoLC/) {
            $oclc =~ s/\(OCoLC\)//;
        }
        if ($oclc =~ /^o/) {
            $oclc =~ s/^[a-z]//;
            $oclc =~ s/^[a-z]//;
            $oclc =~ s/^[a-z]//;
        }
        $choices = qq[<form action="discardItem.pl" method="post" name="yes"><p align="center"><table border="0" width="75%">
            <tr><th colspan="2"><hr style="height:5px;border-width:0;"></th></tr>
            <tr><td class="v18">if this is a match...<p align="right">
            <input name="barcode" type="hidden" value="$barcode">
            <input name="callNumber" type="hidden" value="$callNumber">
            <input name="holdingsRecordId" type="hidden" value="$holdingsRecordId">
            <input name="instanceId" type="hidden" value="$instanceId">
            <input name="mtype" type="hidden" value="$mtype">
            <input name="oclc" type="hidden" value="$oclc">
            <input name="title" type="hidden" value="$title">
            <input name="username" type="hidden" value="$username">
            draw a line through the barcode,<br>put the item in the discard box,<br>and click...</td>
            <td align="center" bgcolor="#f3654e" class="v18" valign="center"><input type="submit" value="yes, this is ready for discard"></td>
            </tr></form><tr><th colspan="2"><hr style="height:15px;border-width:0;"></th></tr>
            <form action="scanBarcode.pl" method="post" name="no">
            <td class="v18">if this is not a match...<p align="right">put it on the "problems" shelf and click...</td>
            <td align="center" bgcolor="#f3654e" class="v18" valign="center"><input type="submit" value="no, there's a problem"></td></tr></table></form>
        ];
    }
}
}
$html = qq[
  <html>
  <head>
  <link rel="shortcut icon" type="image/png" href="https://folio.drew.edu/busybee.png">
  <style type="text/css">
  body {font-family: verdana, arial, sans-serif;}
  a:active {text-decoration: none; color: #f3654e;}
  a:link {text-decoration: none; color: #f3654e;}
  a:visited {text-decoration: none; color: #f3654e;}
  a:hover {text-decoration: none; color: #000000; background: #f3654e;}
  a.rusure:active {text-decoration: none; color: #cc1242;}
  a.rusure:link {text-decoration: none; color: #cc1242;}
  a.rusure:visited {text-decoration: none; color: #cc1242;}
  a.rusure:hover {text-decoration: none; color: #ffffff; background: #cc1242;}
  .v12 {font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif;color:#ffffff;}
  .v18 {font-size: 18px; font-family: Verdana, Arial, Helvetica, sans-serif;color:#ffffff;}
  .v24 {font-size: 24px; font-family: Verdana, Arial, Helvetica, sans-serif;color:#ffffff;}
  input[type=button], input[type=submit], input[type=reset] {
   background-color: #f3654e;
   border: none;
   color: white;
   font-size: 18px;
   padding: 16px 32px;
   text-decoration: none;
   margin: 4px 2px;
   cursor: pointer;
  }
  </style>
  <title>is it a match?</title>
  </head>

  <body bgcolor="#000000"><table border="0" width="100%" height="100%">
  <tr><th></th><th class="v24">folio.drew.edu | bibServices | discard items | is it a match?<br>you are logged in as $username</th><th></th></tr>
  <tr><th></th><th class="v24">&nbsp;$errorMessage</th><th></th></tr>
  <tr><th></th><th class="v18">title: $title (OCLC# $oclc)<br>call number: $callNumber ($mtype)<br>barcode: $barcode $choices
  </th><th></th></tr>
  <tr>
   <th align="left" valign="bottom"><img border="0" src="https://folio.drew.edu/busybee.png">>
   <th>&nbsp;</th><th align="right" valign="bottom"><img width="200" src="https://folio.drew.edu/faith.jpg">>
  </tr>
  <tr><td class="v18" colspan="3"></td></tr>
  </table>
  </body>
  </html>
];

print qq[Content-Type: text/html \n\n $html ];

  • No labels
Write a comment…