Esempio n. 1
0
 protected function barcodeToID($bar)
 {
     if (!$this->alephWebService->isXServerEnabled()) {
         return null;
     }
     foreach ($this->bib as $base) {
         try {
             $xml = $this->alephWebService->doXRequest("find", array("base" => $base, "request" => "BAR={$bar}"), false);
             $docs = (int) $xml->{"no_records"};
             if ($docs == 1) {
                 $set = (string) $xml->{"set_number"};
                 $result = $this->alephWebService->doXRequest("present", array("set_number" => $set, "set_entry" => "1"), false);
                 $id = $result->xpath('//doc_number/text()');
                 if (count($this->bib) == 1) {
                     return (string) $id[0];
                 } else {
                     return $base . "-" . $id[0];
                 }
             }
         } catch (\Exception $ex) {
             // not found
         }
     }
     return null;
 }
Esempio n. 2
0
 public function placeILLRequest($user, $attrs)
 {
     $payment = $attrs['payment'];
     unset($attrs['payment']);
     $new = $attrs['new'];
     unset($attrs['new']);
     $additional_authors = $attrs['additional_authors'];
     unset($attrs['additional_authors']);
     $source = $attrs['source'];
     $publisher = $attrs['publisher'];
     unset($attrs['source']);
     if (!isset($attrs['ill-unit'])) {
         $attrs['ill-unit'] = $this->defaultIllUnit;
     }
     if (!isset($attrs['pickup-location'])) {
         $attrs['pickup-location'] = $this->defaultIllPickupPlocation;
     }
     try {
         $attrs['last-interest-date'] = $this->dateConverter->convertFromDisplayDate('Ymd', $attrs['last-interest-date']);
     } catch (DateException $de) {
         return array('success' => false, 'sysMessage' => 'hold_date_invalid');
     }
     $attrs['allowed-media'] = $attrs['media'];
     $attrs['send-directly'] = 'N';
     $attrs['delivery-method'] = 'S';
     if ($new == 'serial') {
         $new = 'SE';
     } else {
         if ($new == 'monography') {
             $new = 'MN';
         }
     }
     $patronId = $user['id'];
     $illDom = new \DOMDocument('1.0', 'UTF-8');
     $illRoot = $illDom->createElement('ill-parameters');
     $illRootNode = $illDom->appendChild($illRoot);
     foreach ($attrs as $key => $value) {
         $element = $illDom->createElement($key);
         $element->appendChild($illDom->createTextNode($value));
         $illRootNode->appendChild($element);
     }
     $xml = $illDom->saveXML();
     try {
         $path = array('patron', $patronId, 'record', $new, 'ill');
         $result = $this->alephWebService->doRestDLFRequest($path, null, 'PUT', 'post_xml=' . $xml);
     } catch (\Exception $ex) {
         return array('success' => false, 'sysMessage' => $ex->getMessage());
     }
     $baseAndDocNumber = $result->{'create-ill'}->{'request-number'};
     $base = substr($baseAndDocNumber, 0, 5);
     $docNum = substr($baseAndDocNumber, 5);
     $findDocParams = array('base' => $base, 'doc_num' => $docNum);
     $document = $this->alephWebService->doXRequest('find-doc', $findDocParams, true);
     // create varfield for ILL request type
     $varfield = $document->{'record'}->{'metadata'}->{'oai_marc'}->addChild('varfield');
     $varfield->addAttribute('id', 'PNZ');
     $varfield->addAttribute('i1', ' ');
     $varfield->addAttribute('i2', ' ');
     $subfield = $varfield->addChild('subfield', $payment);
     $subfield->addAttribute('label', 'a');
     if (!empty($additional_authors)) {
         $varfield = $document->{'record'}->{'metadata'}->{'oai_marc'}->addChild('varfield');
         $varfield->addAttribute('id', '700');
         $varfield->addAttribute('i1', '1');
         $varfield->addAttribute('i2', ' ');
         $subfield = $varfield->addChild('subfield', $additional_authors);
         $subfield->addAttribute('label', 'a');
     }
     if (!empty($source)) {
         $varfield = $document->{'record'}->{'metadata'}->{'oai_marc'}->addChild('varfield');
         $varfield->addAttribute('id', '590');
         $varfield->addAttribute('i1', ' ');
         $varfield->addAttribute('i2', ' ');
         $subfield = $varfield->addChild('subfield', htmlspecialchars($source));
         $subfield->addAttribute('label', 'a');
     }
     if (!empty($publisher)) {
         $varfield = $document->{'record'}->{'metadata'}->{'oai_marc'}->addChild('varfield');
         $varfield->addAttribute('id', '260');
         $varfield->addAttribute('i1', ' ');
         $varfield->addAttribute('i2', ' ');
         $subfield = $varfield->addChild('subfield', htmlspecialchars($source));
         $subfield->addAttribute('label', 'b');
     }
     $updateDocParams = array('library' => $base, 'doc_num' => $docNum);
     $updateDocParams['xml_full_req'] = $document->asXml();
     $updateDocParams['doc_action'] = 'UPDATE';
     try {
         $update = $this->alephWebService->doXRequestUsingPost('update-doc', $updateDocParams, true);
     } catch (\Exception $ex) {
         return array('success' => false, 'sysMessage' => $ex->getMessage());
     }
     return array('success' => true, 'id' => $docNum);
 }