示例#1
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     global $timer;
     // Get My Transactions
     if ($this->catalog->status) {
         if ($user->cat_username) {
             $patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password);
             $timer->logTime("Logged in patron to get checked out items.");
             if (PEAR_Singleton::isError($patron)) {
                 PEAR_Singleton::raiseError($patron);
             }
             $patronResult = $this->catalog->getMyProfile($patron);
             if (!PEAR_Singleton::isError($patronResult)) {
                 $interface->assign('profile', $patronResult);
             }
             $timer->logTime("Got patron profile to get checked out items.");
             // Define sorting options
             $sortOptions = array('title' => 'Title', 'author' => 'Author', 'dueDate' => 'Due Date', 'format' => 'Format');
             $interface->assign('sortOptions', $sortOptions);
             $selectedSortOption = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'dueDate';
             $interface->assign('defaultSortOption', $selectedSortOption);
             $interface->assign('showNotInterested', false);
             require_once ROOT_DIR . '/Drivers/EContentDriver.php';
             $driver = new EContentDriver();
             if (isset($_REQUEST['multiAction']) && $_REQUEST['multiAction'] == 'suspendSelected') {
                 $ids = array();
                 foreach ($_REQUEST['unavailableHold'] as $id => $selected) {
                     $ids[] = $id;
                 }
                 $suspendDate = $_REQUEST['suspendDate'];
                 $dateToReactivate = strtotime($suspendDate);
                 $suspendResult = $driver->suspendHolds($ids, $dateToReactivate);
                 //Redirect back to the EContentHolds page
                 header("Location: " . $configArray['Site']['path'] . "/MyResearch/EContentHolds?section=unavailable");
             }
             $result = $driver->getMyHolds($user);
             $interface->assign('holds', $result['holds']);
             $timer->logTime("Loaded econtent from catalog.");
         }
     }
     $hasSeparateTemplates = $interface->template_exists('MyResearch/eContentAvailableHolds.tpl');
     if ($hasSeparateTemplates) {
         $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : 'available';
         $interface->assign('section', $section);
         if ($section == 'available') {
             $interface->setPageTitle('Available eContent');
             $interface->setTemplate('eContentAvailableHolds.tpl');
         } else {
             $interface->setPageTitle('eContent On Hold');
             $interface->setTemplate('eContentUnavailableHolds.tpl');
         }
     } else {
         $interface->setTemplate('eContentHolds.tpl');
         $interface->setPageTitle('On Hold eContent');
     }
     $interface->display('layout.tpl');
 }
示例#2
0
 /**
  * Get eContent holds for a user based on username and password.
  *
  * Parameters:
  * <ul>
  * <li>username - The barcode of the user.  Can be truncated to the last 7 or 9 digits.</li>
  * <li>password - The pin number for the user. </li>
  * </ul>
  *
  * Sample Call:
  * <code>
  * http://catalog.douglascountylibraries.org/API/UserAPI?method=getPatronHoldsEContent&username=23025003575917&password=7604
  * </code>
  *
  * Sample Response:
  * <code>
  * {"result":{
  *   "success":true,
  *   "holds":{
  *     "available":[
  *       {"id":"522",
  *        "source":"CIPA",
  *        "title":"Into the path of gods",
  *        "author":"Guler, Kathleen Cunningham.",
  *        "available":true,
  *        "create":"1325962832",
  *        "expire":1326394839,
  *        "status":"available",
  *        "links":[
  *          {"text":
  *           "Cancel Hold",
  *           "onclick":"if (confirm('Are you sure you want to cancel this title?')){cancelEContentHold('\/EContentRecord\/522\/CancelHold')};return false;"
  *          },
  *          {"text":"Checkout",
  *           "url":"\/EContentRecord\/522\/Checkout"
  *          }
  *        ]
  *       }
  *     ],
  *     "unavailable":[
  *       {"id":"521",
  *        "source":"CIPA",
  *        "title":"Turn eye appeal into buy appeal how to easily transform your marketing pieces into dazzling, persuasive sales tools! \/",
  *        "author":"Saunders, Karen.",
  *        "available":true,
  *        "createTime":"1325962794",
  *        "status":"active",
  *        "position":1,
  *        "links":[
  *          {"text":"Cancel Hold",
  *           "onclick":"if (confirm('Are you sure you want to cancel this title?')){cancelEContentHold('\/EContentRecord\/521\/CancelHold')};return false;"
  *          }
  *        ],
  *        "frozen":false,
  *        "reactivateDate":null
  *       }
  *     ]
  *   }
  * }}
  * </code>
  *
  * @author Mark Noble <*****@*****.**>
  */
 function getPatronHoldsEContent()
 {
     $username = $_REQUEST['username'];
     $password = $_REQUEST['password'];
     global $user;
     $user = UserAccount::validateAccount($username, $password);
     if ($user && !PEAR_Singleton::isError($user)) {
         require_once ROOT_DIR . '/Drivers/EContentDriver.php';
         $eContentDriver = new EContentDriver();
         $eContentHolds = $eContentDriver->getMyHolds($user);
         return array('success' => true, 'holds' => $eContentHolds['holds']);
     } else {
         return array('success' => false, 'message' => 'Login unsuccessful');
     }
 }
示例#3
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     //these actions are being moved to MyAccount/AJAX.php
     if (isset($_REQUEST['multiAction'])) {
         $multiAction = $_REQUEST['multiAction'];
         $locationId = isset($_REQUEST['location']) ? $_REQUEST['location'] : null;
         $cancelId = array();
         $type = 'update';
         $freeze = '';
         if ($multiAction == 'cancelSelected') {
             $type = 'cancel';
             //				$freeze = ''; // same as default setting.
         } elseif ($multiAction == 'freezeSelected') {
             //				$type = 'update'; // same as default setting.
             $freeze = 'on';
         } elseif ($multiAction == 'thawSelected') {
             //				$type = 'update'; // same as default setting.
             $freeze = 'off';
         }
         //			elseif ($multiAction == 'updateSelected'){ // same as default settings.
         //				$type = 'update';
         //				$freeze = '';
         //			}
         $result = $this->catalog->driver->updateHoldDetailed($user->password, $type, '', null, $cancelId, $locationId, $freeze);
         //			$interface->assign('holdResult', $result);
         //Redirect back here without the extra parameters.
         $redirectUrl = $configArray['Site']['path'] . '/MyAccount/Holds?accountSort=' . ($selectedSortOption = isset($_REQUEST['accountSort']) ? $_REQUEST['accountSort'] : 'title');
         header("Location: " . $redirectUrl);
         die;
     }
     $interface->assign('allowFreezeHolds', true);
     $ils = $configArray['Catalog']['ils'];
     $showPosition = $ils == 'Horizon' || ($ils = 'Koha');
     $showExpireTime = $ils == 'Horizon';
     $suspendRequiresReactivationDate = $ils == 'Horizon';
     $interface->assign('suspendRequiresReactivationDate', $suspendRequiresReactivationDate);
     $canChangePickupLocation = $ils != 'Koha';
     $interface->assign('canChangePickupLocation', $canChangePickupLocation);
     // Define sorting options
     $sortOptions = array('title' => 'Title', 'author' => 'Author', 'format' => 'Format', 'placed' => 'Date Placed', 'location' => 'Pickup Location', 'status' => 'Status');
     if ($showPosition) {
         $sortOptions['position'] = 'Position';
     }
     $interface->assign('sortOptions', $sortOptions);
     $selectedSortOption = isset($_REQUEST['accountSort']) ? $_REQUEST['accountSort'] : 'title';
     $interface->assign('defaultSortOption', $selectedSortOption);
     $profile = $this->catalog->getMyProfile($user);
     // TODO: getMyProfile called for second time. First time on index.php
     $libraryHoursMessage = Location::getLibraryHoursMessage($profile['homeLocationId']);
     $interface->assign('libraryHoursMessage', $libraryHoursMessage);
     $allowChangeLocation = $ils == 'Millennium' || $ils == 'Sierra';
     $interface->assign('allowChangeLocation', $allowChangeLocation);
     //$showPlacedColumn = ($ils == 'Horizon');
     //Horizon Web Services does not include data placed anymore
     $showPlacedColumn = false;
     $interface->assign('showPlacedColumn', $showPlacedColumn);
     $showDateWhenSuspending = $ils == 'Horizon';
     $interface->assign('showDateWhenSuspending', $showDateWhenSuspending);
     $interface->assign('showPosition', $showPosition);
     $interface->assign('showNotInterested', false);
     // Get My Transactions
     if ($configArray['Catalog']['offline']) {
         $interface->assign('offline', true);
     } else {
         $patron = null;
         if ($this->catalog->status) {
             if ($user->cat_username) {
                 $patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password);
                 $patronResult = $this->catalog->getMyProfile($patron);
                 // TODO: getMyProfile called above already. Is this call necessary?
                 if (!PEAR_Singleton::isError($patronResult)) {
                     $interface->assign('profile', $patronResult);
                 }
                 $interface->assign('sortOptions', $sortOptions);
                 $selectedSortOption = isset($_REQUEST['accountSort']) ? $_REQUEST['accountSort'] : 'dueDate';
                 $interface->assign('defaultSortOption', $selectedSortOption);
                 $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
                 $recordsPerPage = isset($_REQUEST['pagesize']) && is_numeric($_REQUEST['pagesize']) ? $_REQUEST['pagesize'] : 25;
                 $interface->assign('recordsPerPage', $recordsPerPage);
                 if (isset($_GET['exportToExcel'])) {
                     $recordsPerPage = -1;
                     $page = 1;
                 }
                 //Get Holds from the ILS
                 $ilsHolds = $this->catalog->getMyHolds($patron, 1, -1, $selectedSortOption);
                 if (PEAR_Singleton::isError($ilsHolds)) {
                     $ilsHolds = array();
                 }
                 //Get holds from OverDrive
                 require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
                 $overDriveDriver = OverDriveDriverFactory::getDriver();
                 $overDriveHolds = $overDriveDriver->getOverDriveHolds($user);
                 //Get a list of eContent that has been checked out
                 require_once ROOT_DIR . '/Drivers/EContentDriver.php';
                 $driver = new EContentDriver();
                 $eContentHolds = $driver->getMyHolds($user);
                 $allHolds = array_merge_recursive($ilsHolds, $overDriveHolds, $eContentHolds);
                 /* pickUpLocations doesn't seem to be used by the Holds summary page. plb 1-26-2015
                 			$location = new Location();
                 			$pickupBranches = $location->getPickupBranches($patronResult, null);
                 			$locationList = array();
                 			foreach ($pickupBranches as $curLocation) {
                 				$locationList[$curLocation->locationId] = $curLocation->displayName;
                 			}
                 			$interface->assign('pickupLocations', $locationList); */
                 //Make sure available holds come before unavailable
                 $interface->assign('recordList', $allHolds['holds']);
                 //make call to export function
                 if (isset($_GET['exportToExcelAvailable']) || isset($_GET['exportToExcelUnavailable'])) {
                     if (isset($_GET['exportToExcelAvailable'])) {
                         $exportType = "available";
                     } else {
                         $exportType = "unavailable";
                     }
                     $this->exportToExcel($allHolds['holds'], $exportType, $showDateWhenSuspending, $showPosition, $showExpireTime);
                 }
             }
         }
         $interface->assign('patron', $patron);
     }
     //Load holds that have been entered offline
     if ($user) {
         require_once ROOT_DIR . '/sys/OfflineHold.php';
         $twoDaysAgo = time() - 48 * 60 * 60;
         $twoWeeksAgo = time() - 14 * 24 * 60 * 60;
         $offlineHoldsObj = new OfflineHold();
         $offlineHoldsObj->patronId = $user->id;
         $offlineHoldsObj->whereAdd("status = 'Not Processed' OR (status = 'Hold Placed' AND timeEntered >= {$twoDaysAgo}) OR (status = 'Hold Failed' AND timeEntered >= {$twoWeeksAgo})");
         // mysql has these functions as well: "status = 'Not Processed' OR (status = 'Hold Placed' AND timeEntered >= DATE_SUB(NOW(), INTERVAL 2 DAYS)) OR (status = 'Hold Failed' AND timeEntered >= DATE_SUB(NOW(), INTERVAL 2 WEEKS))");
         $offlineHolds = array();
         if ($offlineHoldsObj->find()) {
             while ($offlineHoldsObj->fetch()) {
                 //Load the title
                 $offlineHold = array();
                 require_once ROOT_DIR . '/RecordDrivers/MarcRecord.php';
                 $recordDriver = new MarcRecord($offlineHoldsObj->bibId);
                 if ($recordDriver->isValid()) {
                     $offlineHold['title'] = $recordDriver->getTitle();
                 }
                 $offlineHold['bibId'] = $offlineHoldsObj->bibId;
                 $offlineHold['timeEntered'] = $offlineHoldsObj->timeEntered;
                 $offlineHold['status'] = $offlineHoldsObj->status;
                 $offlineHold['notes'] = $offlineHoldsObj->notes;
                 $offlineHolds[] = $offlineHold;
             }
         }
         $interface->assign('offlineHolds', $offlineHolds);
     }
     $interface->setPageTitle('My Holds');
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     global $library;
     if (!$library->showDetailedHoldNoticeInformation) {
         $notification_method = '';
     } else {
         $notification_method = $profile['noticePreferenceLabel'] != 'Unknown' ? $profile['noticePreferenceLabel'] : '';
         if ($notification_method == 'Mail' && $library->treatPrintNoticesAsPhoneNotices) {
             $notification_method = 'Telephone';
         }
     }
     $interface->assign('notification_method', strtolower($notification_method));
     $interface->setTemplate('holds.tpl');
     //print_r($patron);
     $interface->display('layout.tpl');
 }