/** * Send list of checked out books to view * * @return mixed */ public function checkedoutAction() { // Stop now if the user does not have valid catalog credentials available: if (!is_array($patron = $this->catalogLogin())) { return $patron; } // Connect to the ILS: $catalog = $this->getILS(); // Get the current renewal status and process renewal form, if necessary: $renewStatus = $catalog->checkFunction('Renewals', compact('patron')); $renewResult = $renewStatus ? $this->renewals()->processRenewals($this->getRequest()->getPost(), $catalog, $patron) : []; // By default, assume we will not need to display a renewal form: $renewForm = false; // Get checked out item details: $result = $catalog->getMyTransactions($patron); // Get page size: $config = $this->getConfig(); $limit = isset($config->Catalog->checked_out_page_size) ? $config->Catalog->checked_out_page_size : 50; // Build paginator if needed: if ($limit > 0 && $limit < count($result)) { $adapter = new \Zend\Paginator\Adapter\ArrayAdapter($result); $paginator = new \Zend\Paginator\Paginator($adapter); $paginator->setItemCountPerPage($limit); $paginator->setCurrentPageNumber($this->params()->fromQuery('page', 1)); $pageStart = $paginator->getAbsoluteItemNumber(1) - 1; $pageEnd = $paginator->getAbsoluteItemNumber($limit) - 1; } else { $paginator = false; $pageStart = 0; $pageEnd = count($result); } $transactions = $hiddenTransactions = []; foreach ($result as $i => $current) { // Add renewal details if appropriate: $current = $this->renewals()->addRenewDetails($catalog, $current, $renewStatus); if ($renewStatus && !isset($current['renew_link']) && $current['renewable']) { // Enable renewal form if necessary: $renewForm = true; } // Build record driver (only for the current visible page): if ($i >= $pageStart && $i <= $pageEnd) { $transactions[] = $this->getDriverForILSRecord($current); } else { $hiddenTransactions[] = $current; } } return $this->createViewModel(compact('transactions', 'renewForm', 'renewResult', 'paginator', 'hiddenTransactions')); }
public function checkedoutAction() { // Stop now if the user does not have valid catalog credentials available: if (!($user = $this->getAuthManager()->isLoggedIn())) { $this->flashExceptions($this->flashMessenger()); return $this->forceLogin(); } // Forwarding for Dummy connector to Home page .. if ($this->isLoggedInWithDummyDriver($user)) { return $this->forwardTo('MyResearch', 'Home'); } $identities = $user->getLibraryCards(); $viewVars = $libraryIdentities = []; // Connect to the ILS: $catalog = $this->getILS(); $config = $catalog->getDriverConfig(); if (isset($config['General']['async_checkedout']) && $config['General']['async_checkedout']) { $isSynchronous = false; } else { $isSynchronous = true; } $viewVars['isSynchronous'] = $isSynchronous; foreach ($identities as $identity) { $patron = $user->libCardToPatronArray($identity); // Start of VuFind/MyResearch/checkedoutAction // Get the current renewal status and process renewal form, if necessary: $renewStatus = $catalog->checkFunction('Renewals', compact('patron')); $renewResult = $renewStatus ? $this->renewals()->processRenewals($this->getRequest()->getPost(), $catalog, $patron) : []; // By default, assume we will not need to display a renewal form: $renewForm = false; // Get checked out item details: $result = $catalog->getMyTransactions($patron); // Get page size: $config = $this->getConfig(); $limit = isset($config->Catalog->checked_out_page_size) ? $config->Catalog->checked_out_page_size : 50; // Build paginator if needed: if ($limit > 0 && $limit < count($result)) { $adapter = new \Zend\Paginator\Adapter\ArrayAdapter($result); $paginator = new \Zend\Paginator\Paginator($adapter); $paginator->setItemCountPerPage($limit); $paginator->setCurrentPageNumber($this->params()->fromQuery('page', 1)); $pageStart = $paginator->getAbsoluteItemNumber(1) - 1; $pageEnd = $paginator->getAbsoluteItemNumber($limit) - 1; } else { $paginator = false; $pageStart = 0; $pageEnd = count($result); } $transactions = $hiddenTransactions = []; foreach ($result as $i => $current) { // Add renewal details if appropriate: $current = $this->renewals()->addRenewDetails($catalog, $current, $renewStatus); if ($renewStatus && !isset($current['renew_link']) && $current['renewable']) { // Enable renewal form if necessary: $renewForm = true; } // Build record driver (only for the current visible page): if ($i >= $pageStart && $i <= $pageEnd) { $transactions[] = $this->getDriverForILSRecord($current); } else { $hiddenTransactions[] = $current; } } $currentIdentityView = compact('transactions', 'renewForm', 'renewResult', 'paginator', 'hiddenTransactions'); // End of VuFind/MyResearch/checkedoutAction // Start of MZKCommon/MyResearch/checkedoutAction $showOverdueMessage = false; foreach ($currentIdentityView['transactions'] as $resource) { $ilsDetails = $resource->getExtraDetail('ils_details'); if (isset($ilsDetails['dueStatus']) && $ilsDetails['dueStatus'] == "overdue") { $showOverdueMessage = true; break; } } if ($showOverdueMessage) { $this->flashMessenger()->setNamespace('error')->addMessage('overdue_error_message'); } $currentIdentityView['history'] = false; $currentIdentityView = $this->addViews($currentIdentityView); // End of MZKCommon/MyResearch/checkedoutAction $libraryIdentities[$identity['eppn']] = $currentIdentityView; } $viewVars['libraryIdentities'] = $libraryIdentities; $viewVars['logos'] = $user->getIdentityProvidersLogos(); $view = $this->createViewModel($viewVars); $this->flashExceptions($this->flashMessenger()); return $view; }