Exemplo n.º 1
0
 /**
  * Public method for getting item holdings from the catalog and selecting which
  * holding method to call
  *
  * @param string $id     An Bib ID
  * @param array  $patron An array of patron data
  *
  * @return array A sorted results set
  * @access public
  */
 public function getHoldings($id, $patron = false)
 {
     $holdings = array();
     // Get Holdings Data
     if ($this->catalog && $this->catalog->status) {
         $result = $this->catalog->getHolding($id, $patron);
         if (PEAR_Singleton::isError($result)) {
             PEAR_Singleton::raiseError($result);
         }
         $mode = CatalogConnection::getHoldsMode();
         if ($mode == "disabled") {
             $holdings = $this->standardHoldings($result);
         } else {
             if ($mode == "driver") {
                 $holdings = $this->driverHoldings($result);
             } else {
                 $holdings = $this->generateHoldings($result, $mode);
             }
         }
     }
     return $holdings;
 }
Exemplo n.º 2
0
 /**
  * Support method for getItemStatuses() -- Get Axiell Full Item Status
  *
  * @param array  $holdings Holdings for the record
  * @param object $catalog  Catalog connection
  * @param array  $patron   Patron
  *
  * @return void
  * @access public
  * @author Erik Henriksson <*****@*****.**>
  * @author Ere Maijala <*****@*****.**>
  */
 protected function getAxiellItemStatusFull($holdings, $catalog, $patron)
 {
     global $interface;
     global $configArray;
     $itemCount = 0;
     $requestCount = 0;
     $locationCount = 0;
     $branchCount = 0;
     $availableLocationCount = 0;
     $availableCount = 0;
     $itemStatusText = '';
     $closestDueDate = '';
     $closestDueDateStamp = 0;
     $journal = false;
     $itemStatusText = '';
     $isHoldable = false;
     foreach ($holdings as &$location) {
         if (is_array($location)) {
             $journal = isset($location['journal']) && $location['journal'];
             if (is_array($location['holdings'])) {
                 foreach ($location['holdings'] as $holding) {
                     if (isset($holding['total'])) {
                         $itemCount += $holding['total'];
                     }
                     if (isset($holding['status']) && trim($holding['status']) === JSON::REFERENCE_DESK_STATUS) {
                         $location['status']['availableCount']++;
                     }
                     $branchCount++;
                 }
             }
             if (isset($location['status'])) {
                 if (isset($location['status']['reservations']) && $location['status']['reservations'] > $requestCount) {
                     $requestCount = $location['status']['reservations'];
                 }
                 if (isset($location['status']['available']) && $location['status']['available']) {
                     $availableLocationCount++;
                 }
                 if (isset($location['status']['availableCount']) && $location['status']['availableCount'] > 0) {
                     $availableCount += $location['status']['availableCount'];
                 }
                 if (isset($location['status']['text']) && $location['status']['text'] != '' && $closestDueDate == '') {
                     $itemStatusText = $location['status']['text'];
                 }
                 if (isset($location['status']['dueDateStamp']) && $location['status']['dueDateStamp'] != '' && isset($location['status']['closestDueDate']) && $location['status']['closestDueDate'] != '') {
                     $dueDate = $location['status']['dueDateStamp'];
                     if ($closestDueDateStamp < $dueDate) {
                         $closestDueDate = $location['status']['closestDueDate'];
                         if (isset($location['status']['text']) && $location['status']['text'] != '') {
                             $itemStatusText = $location['status']['text'];
                         }
                     }
                 }
                 $locationCount++;
             }
             if (isset($location['is_holdable']) && $location['is_holdable']) {
                 $isHoldable = true;
             }
         }
     }
     $id = $holdings[0]['id'];
     $interface->assign('id', $id);
     $interface->assign('holdings', $holdings);
     $locationThreshold = isset($configArray['Site']['locationThreshold']) ? $configArray['Site']['locationThreshold'] : 5;
     $branchThreshold = isset($configArray['Site']['branchThreshold']) ? $configArray['Site']['branchThreshold'] : 15;
     $interface->assign('itemCount', $itemCount);
     $interface->assign('requestCount', $requestCount);
     $interface->assign('branchCount', $branchCount);
     $interface->assign('locationCount', $locationCount);
     $interface->assign('availableLocationCount', $availableLocationCount);
     $interface->assign('availableCount', $availableCount);
     $interface->assign('closestDueDate', $closestDueDate);
     $interface->assign('itemStatusText', $itemStatusText);
     $interface->assign('isHoldable', $isHoldable);
     $interface->assign('locationThreshold', $locationThreshold);
     $interface->assign('branchThreshold', $branchThreshold);
     $interface->assign('journal', $journal);
     $interface->assign('referenceDeskStatus', JSON::REFERENCE_DESK_STATUS);
     $db = ConnectionManager::connectToIndex();
     if (!($record = $db->getRecord($id))) {
         PEAR::raiseError(new PEAR_Error('Record Does Not Exist'));
     }
     $recordDriver = RecordDriverFactory::initRecordDriver($record);
     $interface->assign('patronFunctions', $recordDriver->hasPatronFunctions());
     if ("driver" == CatalogConnection::getHoldsMode()) {
         $interface->assign('driverMode', true);
     }
     if ("driver" == CatalogConnection::getTitleHoldsMode()) {
         $interface->assign('titleDriverMode', true);
     }
     if (!PEAR::isError($patron)) {
         $holdLogic = new HoldLogicTitle($catalog);
         $holdingTitleHold = $holdLogic->getHold($id, $patron);
         $interface->assign('holdingTitleHold', $holdingTitleHold);
     }
     return $interface->fetch('AJAX/holdings-axiell.tpl');
 }
Exemplo n.º 3
0
 /**
  * checkRequestIsValid
  *
  * This is responsible for determining if an item is requestable
  *
  * @param string $id     The Bib ID
  * @param array  $data   An Array of item data
  * @param patron $patron An array of patron data
  *
  * @return string True if request is valid, false if not
  * @access public
  */
 public function checkRequestIsValid($id, $data, $patron)
 {
     $holdType = isset($data['holdtype']) ? $data['holdtype'] : "auto";
     $level = isset($data['level']) ? $data['level'] : "copy";
     $mode = "title" == $level ? CatalogConnection::getTitleHoldsMode() : CatalogConnection::getHoldsMode();
     if ("driver" == $mode && "auto" == $holdType) {
         $itemID = isset($data['item_id']) ? $data['item_id'] : false;
         $result = $this->determineHoldType($patron['id'], $id, $itemID);
         if (!$result || $result == 'block') {
             return $result;
         }
     }
     if ('title' == $level && $this->requestGroups) {
         // Verify that there are valid request groups
         if (!$this->getRequestGroups($id, $patron['id'])) {
             return false;
         }
     }
     return true;
 }
Exemplo n.º 4
0
 /**
  * Public method for getting item holdings from the catalog and selecting which
  * holding method to call
  *
  * @param string $id     An Bib ID
  * @param array  $patron An array of patron data
  *
  * @return array A sorted results set
  * @access public
  */
 public function getHoldings($id, $patron = false)
 {
     $holdings = array();
     // Get Holdings Data
     if ($this->catalog && $this->catalog->status) {
         $result = $this->catalog->getHolding($id, $patron);
         if (PEAR::isError($result)) {
             PEAR::raiseError($result);
         }
         $mode = CatalogConnection::getHoldsMode();
         if ($mode == "disabled") {
             $holdings = $this->standardHoldings($result);
         } else {
             if ($mode == "driver") {
                 $holdings = $this->driverHoldings($result);
             } else {
                 $holdings = $this->generateHoldings($result, $mode);
             }
         }
     }
     // Don't format holdings as we want to keep call numbers separate
     // and it would ruin notes and summaries
     //return $this->formatHoldings($holdings);
     return $this->sortHoldings($holdings);
 }
Exemplo n.º 5
0
 /**
  * Assign necessary Smarty variables and return a template name to
  * load in order to display holdings extracted from the base record
  * (i.e. URLs in MARC 856 fields) and, if necessary, the ILS driver.
  * Returns null if no data is available.
  *
  * @param array $patron An array of patron data
  *
  * @return string Name of Smarty template file to display.
  * @access public
  */
 public function getHoldings($patron = false)
 {
     global $configArray;
     global $interface;
     $disallowHolds = isset($configArray['Catalog']['disable_driver_hold_actions']) && array_intersect($this->fields['format'], $configArray['Catalog']['disable_driver_hold_actions']) ? true : false;
     if (!$disallowHolds && "driver" == CatalogConnection::getHoldsMode()) {
         $interface->assign('driverMode', true);
         if (!UserAccount::isLoggedIn()) {
             $interface->assign('showLoginMsg', true);
         }
     }
     if (!$disallowHolds && "driver" == CatalogConnection::getTitleHoldsMode()) {
         $interface->assign('titleDriverMode', true);
         if (!UserAccount::isLoggedIn()) {
             $interface->assign('showTitleLoginMsg', true);
         }
     }
     $interface->assign("holdingTitleHold", $this->getRealTimeTitleHold($patron));
     return parent::getHoldings($patron);
 }