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);
             //Vars for the IDCLREADER TEMPLATE
             $interface->assign('ButtonBack', true);
             $interface->assign('ButtonHome', true);
             $interface->assign('MobileTitle', 'eContents Checked Out');
             require_once ROOT_DIR . '/Drivers/EContentDriver.php';
             $driver = new EContentDriver();
             $result = $driver->getMyTransactions($user);
             $interface->assign('checkedOut', $result['transactions']);
             $timer->logTime("Loaded econtent from catalog.");
         }
     }
     $interface->setTemplate('eContentCheckedOut.tpl');
     $interface->setPageTitle('Checked Out eContent');
     $interface->display('layout.tpl');
 }
示例#2
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     global $timer;
     $allCheckedOut = array();
     if ($configArray['Catalog']['offline']) {
         $interface->assign('offline', true);
     } else {
         $interface->assign('offline', false);
         //Determine which columns to show
         $ils = $configArray['Catalog']['ils'];
         $showOut = $ils == 'Horizon';
         $showRenewed = $ils == 'Horizon' || $ils == 'Millennium' || $ils == 'Sierra' || $ils == 'Koha';
         $showWaitList = $ils == 'Horizon';
         $interface->assign('showOut', $showOut);
         $interface->assign('showRenewed', $showRenewed);
         $interface->assign('showWaitList', $showWaitList);
         // Define sorting options
         $sortOptions = array('title' => 'Title', 'author' => 'Author', 'dueDate' => 'Due Date', 'format' => 'Format');
         if ($showWaitList) {
             $sortOptions['holdQueueLength'] = 'Wait List';
         }
         if ($showRenewed) {
             $sortOptions['renewed'] = 'Times Renewed';
         }
         $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 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.");
                 $libraryHoursMessage = Location::getLibraryHoursMessage($patronResult['homeLocationId']);
                 $interface->assign('libraryHoursMessage', $libraryHoursMessage);
                 //Get checked out titles from the ILS
                 $catalogTransactions = $this->catalog->getMyTransactions(1, -1, $selectedSortOption);
                 $timer->logTime("Loaded transactions from catalog.");
                 //Get checked out titles from OverDrive
                 require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
                 $overDriveDriver = OverDriveDriverFactory::getDriver();
                 $overDriveCheckedOutItems = $overDriveDriver->getOverDriveCheckedOutItems($user);
                 //Get a list of eContent that has been checked out
                 require_once ROOT_DIR . '/Drivers/EContentDriver.php';
                 $driver = new EContentDriver();
                 $eContentCheckedOut = $driver->getMyTransactions($user);
                 $allCheckedOut = array_merge($catalogTransactions['transactions'], $overDriveCheckedOutItems['items'], $eContentCheckedOut['transactions']);
                 if (!PEAR_Singleton::isError($catalogTransactions)) {
                     $interface->assign('showNotInterested', false);
                     foreach ($allCheckedOut as $i => $curTitle) {
                         $sortTitle = isset($curTitle['title_sort']) ? $curTitle['title_sort'] : $curTitle['title'];
                         $sortKey = $sortTitle;
                         if ($selectedSortOption == 'title') {
                             $sortKey = $sortTitle;
                         } elseif ($selectedSortOption == 'author') {
                             $sortKey = (isset($curTitle['author']) ? $curTitle['author'] : "Unknown") . '-' . $sortTitle;
                         } elseif ($selectedSortOption == 'dueDate') {
                             if (isset($curTitle['duedate'])) {
                                 if (preg_match('/.*?(\\d{1,2})[-\\/](\\d{1,2})[-\\/](\\d{2,4}).*/', $curTitle['duedate'], $matches)) {
                                     $sortKey = $matches[3] . '-' . $matches[1] . '-' . $matches[2] . '-' . $sortTitle;
                                 } else {
                                     $sortKey = $curTitle['duedate'] . '-' . $sortTitle;
                                 }
                             }
                         } elseif ($selectedSortOption == 'format') {
                             $sortKey = (isset($curTitle['format']) ? $curTitle['format'] : "Unknown") . '-' . $sortTitle;
                         } elseif ($selectedSortOption == 'renewed') {
                             $sortKey = str_pad(isset($curTitle['renewCount']) ? $curTitle['renewCount'] : 0, 3, '0', STR_PAD_LEFT) . '-' . $sortTitle;
                         } elseif ($selectedSortOption == 'holdQueueLength') {
                             $sortKey = str_pad(isset($curTitle['holdQueueLength']) ? $curTitle['holdQueueLength'] : 0, 3, '0', STR_PAD_LEFT) . '-' . $sortTitle;
                         }
                         $itemBarcode = isset($curTitle['barcode']) ? $curTitle['barcode'] : null;
                         $itemId = isset($curTitle['itemid']) ? $curTitle['itemid'] : null;
                         if ($itemBarcode != null && isset($_SESSION['renew_message'][$itemBarcode])) {
                             $renewMessage = $_SESSION['renew_message'][$itemBarcode]['message'];
                             $renewResult = $_SESSION['renew_message'][$itemBarcode]['result'];
                             $curTitle['renewMessage'] = $renewMessage;
                             $curTitle['renewResult'] = $renewResult;
                             $allCheckedOut[$sortKey] = $curTitle;
                             unset($_SESSION['renew_message'][$itemBarcode]);
                             //$logger->log("Found renewal message in session for $itemBarcode", PEAR_LOG_INFO);
                         } else {
                             if ($itemId != null && isset($_SESSION['renew_message'][$itemId])) {
                                 $renewMessage = $_SESSION['renew_message'][$itemId]['message'];
                                 $renewResult = $_SESSION['renew_message'][$itemId]['result'];
                                 $curTitle['renewMessage'] = $renewMessage;
                                 $curTitle['renewResult'] = $renewResult;
                                 $allCheckedOut[$sortKey] = $curTitle;
                                 unset($_SESSION['renew_message'][$itemId]);
                                 //$logger->log("Found renewal message in session for $itemBarcode", PEAR_LOG_INFO);
                             } else {
                                 $allCheckedOut[$sortKey] = $curTitle;
                                 $renewMessage = null;
                                 $renewResult = null;
                             }
                         }
                         unset($allCheckedOut[$i]);
                     }
                     //Now that we have all the transactions we can sort them
                     if ($selectedSortOption == 'renewed' || $selectedSortOption == 'holdQueueLength') {
                         krsort($allCheckedOut);
                     } else {
                         ksort($allCheckedOut);
                     }
                     $interface->assign('transList', $allCheckedOut);
                     unset($_SESSION['renew_message']);
                 }
             }
         }
     }
     if (isset($_GET['exportToExcel']) && isset($allCheckedOut)) {
         $this->exportToExcel($allCheckedOut, $showOut, $showRenewed, $showWaitList);
     }
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->setTemplate('checkedout.tpl');
     $interface->setPageTitle('Checked Out Items');
     $interface->display('layout.tpl');
 }
示例#3
0
 /**
  * Get eContent records that are checked out to 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=getPatronCheckedOutItems&username=23025003575917&password=7604
  * </code>
  *
  * Sample Response:
  * <code>
  * {"result":{
  *   "success":true,
  *   "checkedOutItems":[{
  *     {"id":"534",
  *      "source":"CIPA",
  *      "title":"Unsinkable the Molly Brown story \/",
  *      "author":"Lohse, Joyce B.",
  *      "duedate":"1326135657",
  *      "checkoutdate":"1325962857",
  *      "daysUntilDue":2,
  *      "holdQueueLength":0,
  *      "links":[
  *        {"url":"\/EContent\/534\/Viewer?item=130",
  *         "text":"Read Online"
  *        },
  *        {"url":"http:\/\/fulfillment.douglascountylibraries.org\/fulfillment\/URLLink.acsm?action=enterloan&ordersource=DCL+Test&orderid=ACS4-1206216092244346610125819&resid=urn%3Auuid%3A130b9d63-5e4f-430c-aa16-8fb33822aba8&gbauthdate=Sat%2C+07+Jan+2012+19%3A00%3A58+%2B0000&dateval=1325962858&gblver=4&auth=8c6e70a135a7418c441a9b2b32b9ff6cb413e4cf",
  *         "text":"Download"
  *        },
  *        {"text":"Return Now",
  *         "onclick":"if (confirm('Are you sure you want to return this title?')){returnEpub('\/EContentRecord\/534\/ReturnTitle')};return false;"
  *        }
  *      ]
  *     }
  *   }]
  * }}
  * </code>
  *
  * @author Mark Noble <*****@*****.**>
  */
 function getPatronCheckedOutEContent()
 {
     $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();
         $eContentTransactions = $eContentDriver->getMyTransactions($user);
         $allTransactions = $eContentTransactions['transactions'];
         return array('success' => true, 'checkedOutItems' => $allTransactions);
     } else {
         return array('success' => false, 'message' => 'Login unsuccessful');
     }
 }