Esempio n. 1
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     $showOpen = true;
     if (isset($_REQUEST['requestsToShow']) && $_REQUEST['requestsToShow'] == 'allRequests') {
         $showOpen = false;
     }
     $interface->assign('showOpen', $showOpen);
     $defaultStatus = new MaterialsRequestStatus();
     $defaultStatus->isDefault = 1;
     $defaultStatus->libraryId = Library::getPatronHomeLibrary()->libraryId;
     $defaultStatus->find(true);
     $interface->assign('defaultStatus', $defaultStatus->id);
     //Get a list of all materials requests for the user
     $allRequests = array();
     if ($user) {
         $materialsRequests = new MaterialsRequest();
         $materialsRequests->createdBy = $user->id;
         $materialsRequests->orderBy('title, dateCreated');
         $statusQuery = new MaterialsRequestStatus();
         if ($showOpen) {
             $homeLibrary = Library::getPatronHomeLibrary();
             $statusQuery->libraryId = $homeLibrary->libraryId;
             $statusQuery->isOpen = 1;
         }
         $materialsRequests->joinAdd($statusQuery);
         $materialsRequests->selectAdd();
         $materialsRequests->selectAdd('materials_request.*, description as statusLabel');
         $materialsRequests->find();
         while ($materialsRequests->fetch()) {
             $allRequests[] = clone $materialsRequests;
         }
     } else {
         header('Location: ' . $configArray['Site']['path'] . '/MyResearch/Home?followupModule=MaterialsRequest&followupAction=MyRequests');
         //$interface->assign('error', "You must be logged in to view your requests.");
     }
     $interface->assign('allRequests', $allRequests);
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->setTemplate('myMaterialRequests.tpl');
     $interface->setPageTitle('My Materials Requests');
     $interface->display('layout.tpl');
 }
Esempio n. 2
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     //Load status information
     $materialsRequestStatus = new MaterialsRequestStatus();
     $materialsRequestStatus->orderBy('isDefault DESC, isOpen DESC, description ASC');
     if ($user->hasRole('library_material_requests')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $materialsRequestStatus->libraryId = $homeLibrary->libraryId;
     }
     $materialsRequestStatus->find();
     $availableStatuses = array();
     $defaultStatusesToShow = array();
     while ($materialsRequestStatus->fetch()) {
         $availableStatuses[$materialsRequestStatus->id] = $materialsRequestStatus->description;
         if ($materialsRequestStatus->isOpen == 1 || $materialsRequestStatus->isDefault == 1) {
             $defaultStatusesToShow[] = $materialsRequestStatus->id;
         }
     }
     $interface->assign('availableStatuses', $availableStatuses);
     if (isset($_REQUEST['statusFilter'])) {
         $statusesToShow = $_REQUEST['statusFilter'];
     } else {
         $statusesToShow = $defaultStatusesToShow;
     }
     $interface->assign('statusFilter', $statusesToShow);
     //Get a list of users that have requests open
     $materialsRequest = new MaterialsRequest();
     $materialsRequest->joinAdd(new User());
     $materialsRequest->joinAdd(new MaterialsRequestStatus());
     $materialsRequest->selectAdd();
     $materialsRequest->selectAdd('COUNT(materials_request.id) as numRequests');
     $materialsRequest->selectAdd('user.id as userId, status, description, user.firstName, user.lastName, user.cat_username, user.cat_password');
     if ($user->hasRole('library_material_requests')) {
         //Need to limit to only requests submitted for the user's home location
         $userHomeLibrary = Library::getPatronHomeLibrary();
         $locations = new Location();
         $locations->libraryId = $userHomeLibrary->libraryId;
         $locations->find();
         $locationsForLibrary = array();
         while ($locations->fetch()) {
             $locationsForLibrary[] = $locations->locationId;
         }
         $materialsRequest->whereAdd('user.homeLocationId IN (' . implode(', ', $locationsForLibrary) . ')');
     }
     $statusSql = "";
     foreach ($statusesToShow as $status) {
         if (strlen($statusSql) > 0) {
             $statusSql .= ",";
         }
         $statusSql .= "'" . $materialsRequest->escape($status) . "'";
     }
     $materialsRequest->whereAdd("status in ({$statusSql})");
     $materialsRequest->groupBy('userId, status');
     $materialsRequest->find();
     $userData = array();
     while ($materialsRequest->fetch()) {
         if (!array_key_exists($materialsRequest->userId, $userData)) {
             $userData[$materialsRequest->userId] = array();
             $userData[$materialsRequest->userId]['firstName'] = $materialsRequest->firstName;
             $userData[$materialsRequest->userId]['lastName'] = $materialsRequest->lastName;
             $barcodeProperty = $configArray['Catalog']['barcodeProperty'];
             $userData[$materialsRequest->userId]['barcode'] = $materialsRequest->{$barcodeProperty};
             $userData[$materialsRequest->userId]['totalRequests'] = 0;
             $userData[$materialsRequest->userId]['requestsByStatus'] = array();
         }
         $userData[$materialsRequest->userId]['requestsByStatus'][$materialsRequest->description] = $materialsRequest->numRequests;
         $userData[$materialsRequest->userId]['totalRequests'] += $materialsRequest->numRequests;
     }
     $interface->assign('userData', $userData);
     //Get a list of all of the statuses that will be shown
     $statuses = array();
     foreach ($userData as $userInfo) {
         foreach ($userInfo['requestsByStatus'] as $status => $numRequests) {
             $statuses[$status] = translate($status);
         }
     }
     $interface->assign('statuses', $statuses);
     //Check to see if we are exporting to Excel
     if (isset($_REQUEST['exportToExcel'])) {
         $this->exportToExcel($userData, $statuses);
     }
     $interface->setTemplate('userReport.tpl');
     $interface->setPageTitle('Materials Request User Report');
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->display('layout.tpl');
 }
Esempio n. 3
0
 public function getMyProfile($patron, $forceReload = false)
 {
     global $timer;
     global $configArray;
     /** @var Memcache $memCache */
     global $memCache;
     global $serverName;
     $memCacheProfileKey = "patronProfile_{$serverName}_";
     if (is_object($patron)) {
         $patron = get_object_vars($patron);
         $userId = $patron['id'];
         $patronUserName = $patron['username'];
         $memCacheProfileKey .= $patron['username'];
     } else {
         global $user;
         $userId = $user->id;
         $patronUserName = $user->username;
         $memCacheProfileKey .= $user->username;
     }
     if (!$forceReload && !isset($_REQUEST['reload'])) {
         $patronProfile = $memCache->get($memCacheProfileKey);
         if ($patronProfile) {
             $timer->logTime('Retrieved Cached Profile for Patron');
             return $patronProfile;
         }
     }
     global $user;
     if ($configArray['Catalog']['offline'] == true) {
         $fullName = $patron['cat_username'];
         $Address1 = "";
         $City = "";
         $State = "";
         $Zip = "";
         $Email = "";
         $finesVal = 0;
         $expireClose = false;
         $homeBranchCode = '';
         $numHoldsAvailable = '?';
         $numHoldsRequested = '?';
         if (!$user) {
             $user = new User();
             $user->username = $patronUserName;
             if ($user->find(true)) {
                 $location = new Location();
                 $location->locationId = $user->homeLocationId;
                 $location->find(1);
                 $homeBranchCode = $location->code;
             }
         }
     } else {
         //Load the raw information about the patron from web services
         if (isset(HorizonAPI::$sessionIdsForUsers[$userId])) {
             $sessionToken = HorizonAPI::$sessionIdsForUsers[$userId];
             // keys off username
         } else {
             //Log the user in
             $return = $this->loginViaWebService($patron['cat_username'], $patron['cat_password']);
             if (count($return) == 1) {
                 $userValid = $return[0];
             } else {
                 list($userValid, $sessionToken) = $return;
             }
             if (!$userValid) {
                 echo "No session id found for user";
                 return PEAR_Singleton::raiseError("Could not login to web service " . $return);
             }
         }
         $lookupMyAccountInfoResponse = $this->getWebServiceResponse($configArray['Catalog']['webServiceUrl'] . '/standard/lookupMyAccountInfo?clientID=' . $configArray['Catalog']['clientId'] . '&sessionToken=' . $sessionToken . '&includeAddressInfo=true&includeHoldInfo=true&includeBlockInfo=true&includeItemsOutInfo=true');
         if ($lookupMyAccountInfoResponse === false) {
             global $logger;
             $logger->log("Unable to login", PEAR_LOG_WARNING);
             return null;
         }
         if (isset($lookupMyAccountInfoResponse->AddressInfo)) {
             $Address1 = (string) $lookupMyAccountInfoResponse->AddressInfo->line1;
             if (isset($lookupMyAccountInfoResponse->AddressInfo->cityState)) {
                 $cityState = (string) $lookupMyAccountInfoResponse->AddressInfo->cityState;
                 list($City, $State) = explode(', ', $cityState);
             } else {
                 $City = "";
                 $State = "";
             }
             $Zip = (string) $lookupMyAccountInfoResponse->AddressInfo->postalCode;
             if (isset($lookupMyAccountInfoResponse->AddressInfo->email)) {
                 $Email = (string) $lookupMyAccountInfoResponse->AddressInfo->email;
             }
         } else {
             $Address1 = "";
             $City = "";
             $State = "";
             $Zip = "";
             $Email = '';
         }
         $fullName = $lookupMyAccountInfoResponse->name;
         //Get additional information about the patron's home branch for display.
         if (isset($lookupMyAccountInfoResponse->locationID)) {
             $homeBranchCode = trim((string) $lookupMyAccountInfoResponse->locationID);
             //Translate home branch to plain text
             $location = new Location();
             $location->code = $homeBranchCode;
             $location->find(1);
             if ($location->N == 0) {
                 unset($location);
             }
         }
         if ($user) {
             if ($user->homeLocationId == 0 && isset($location)) {
                 $user->homeLocationId = $location->locationId;
                 if ($location->nearbyLocation1 > 0) {
                     $user->myLocation1Id = $location->nearbyLocation1;
                 } else {
                     $user->myLocation1Id = $location->locationId;
                 }
                 if ($location->nearbyLocation2 > 0) {
                     $user->myLocation2Id = $location->nearbyLocation2;
                 } else {
                     $user->myLocation2Id = $location->locationId;
                 }
                 if ($user instanceof User) {
                     //Update the database
                     $user->update();
                     //Update the serialized instance stored in the session
                     $_SESSION['userinfo'] = serialize($user);
                 }
             } else {
                 if (isset($location) && $location->locationId != $user->homeLocationId) {
                     $user->homeLocationId = $location->locationId;
                     //Update the database
                     $user->update();
                     //Update the serialized instance stored in the session
                     $_SESSION['userinfo'] = serialize($user);
                 }
             }
         }
         //TODO: See if we can get information about card expiration date
         $expireClose = 0;
         $finesVal = 0;
         if (isset($lookupMyAccountInfoResponse->BlockInfo)) {
             foreach ($lookupMyAccountInfoResponse->BlockInfo as $block) {
                 // $block is a simplexml object with attribute info about currency, type casting as below seems to work for adding up. plb 3-27-2015
                 $fineAmount = (double) $block->balance;
                 $finesVal += $fineAmount;
             }
         }
         $numHoldsAvailable = 0;
         $numHoldsRequested = 0;
         if (isset($lookupMyAccountInfoResponse->HoldInfo)) {
             foreach ($lookupMyAccountInfoResponse->HoldInfo as $hold) {
                 if ($hold->status == 'FILLED') {
                     $numHoldsAvailable++;
                 } else {
                     $numHoldsRequested++;
                 }
             }
         }
     }
     if ($user) {
         //Get display name for preferred location 1
         $myLocation1 = new Location();
         $myLocation1->whereAdd("locationId = '{$user->myLocation1Id}'");
         $myLocation1->find(1);
         //Get display name for preferred location 1
         $myLocation2 = new Location();
         $myLocation2->whereAdd("locationId = '{$user->myLocation2Id}'");
         $myLocation2->find(1);
     }
     list($fullName, $lastName, $firstName) = $this->splitFullName($fullName);
     $profile = array('lastname' => $lastName, 'firstname' => $firstName, 'fullname' => $fullName, 'address1' => $Address1, 'address2' => $City . ', ' . $State, 'city' => $City, 'state' => $State, 'zip' => $Zip, 'email' => $user && $user->email ? $user->email : $Email, 'overdriveEmail' => $user ? $user->overdriveEmail : $Email, 'promptForOverdriveEmail' => $user ? $user->promptForOverdriveEmail : 1, 'phone' => isset($lookupMyAccountInfoResponse->phone) ? (string) $lookupMyAccountInfoResponse->phone : '', 'workPhone' => '', 'mobileNumber' => '', 'fines' => sprintf('$%01.2f', $finesVal), 'finesval' => $finesVal, 'expires' => '', 'expireclose' => $expireClose, 'homeLocationCode' => isset($homeBranchCode) ? trim($homeBranchCode) : '', 'homeLocationId' => isset($location) ? $location->locationId : 0, 'homeLocation' => isset($location) ? $location->displayName : '', 'myLocation1Id' => $user ? $user->myLocation1Id : -1, 'myLocation1' => isset($myLocation1) ? $myLocation1->displayName : '', 'myLocation2Id' => $user ? $user->myLocation2Id : -1, 'myLocation2' => isset($myLocation2) ? $myLocation2->displayName : '', 'numCheckedOut' => isset($lookupMyAccountInfoResponse->ItemsOutInfo) ? count($lookupMyAccountInfoResponse->ItemsOutInfo) : 0, 'numHolds' => $numHoldsAvailable + $numHoldsRequested, 'numHoldsAvailable' => $numHoldsAvailable, 'numHoldsRequested' => $numHoldsRequested, 'bypassAutoLogout' => $user ? $user->bypassAutoLogout : 0, 'ptype' => 0, 'notices' => '-', 'noticePreferenceLabel' => 'e-mail', 'web_note' => '');
     //Get eContent info as well
     require_once ROOT_DIR . '/Drivers/EContentDriver.php';
     $eContentDriver = new EContentDriver();
     $eContentAccountSummary = $eContentDriver->getAccountSummary();
     $profile = array_merge($profile, $eContentAccountSummary);
     require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
     $overDriveDriver = OverDriveDriverFactory::getDriver();
     if ($overDriveDriver->isUserValidForOverDrive($user)) {
         $overDriveSummary = $overDriveDriver->getOverDriveSummary($user);
         $profile['numOverDriveCheckedOut'] = $overDriveSummary['numCheckedOut'];
         $profile['numOverDriveHoldsAvailable'] = $overDriveSummary['numAvailableHolds'];
         $profile['numOverDriveHoldsRequested'] = $overDriveSummary['numUnavailableHolds'];
         $profile['canUseOverDrive'] = true;
     } else {
         $profile['numOverDriveCheckedOut'] = 0;
         $profile['numOverDriveHoldsAvailable'] = 0;
         $profile['numOverDriveHoldsRequested'] = 0;
         $profile['canUseOverDrive'] = false;
     }
     $profile['numCheckedOutTotal'] = $profile['numCheckedOut'] + $profile['numOverDriveCheckedOut'] + $eContentAccountSummary['numEContentCheckedOut'];
     $profile['numHoldsAvailableTotal'] = $profile['numHoldsAvailable'] + $profile['numOverDriveHoldsAvailable'] + $eContentAccountSummary['numEContentAvailableHolds'];
     $profile['numHoldsRequestedTotal'] = $profile['numHoldsRequested'] + $profile['numOverDriveHoldsRequested'] + $eContentAccountSummary['numEContentUnavailableHolds'];
     $profile['numHoldsTotal'] = $profile['numHoldsAvailableTotal'] + $profile['numHoldsRequestedTotal'];
     //Get a count of the materials requests for the user
     if ($user) {
         $materialsRequest = new MaterialsRequest();
         $materialsRequest->createdBy = $user->id;
         $homeLibrary = Library::getPatronHomeLibrary();
         $statusQuery = new MaterialsRequestStatus();
         $statusQuery->isOpen = 1;
         $statusQuery->libraryId = $homeLibrary->libraryId;
         $materialsRequest->joinAdd($statusQuery);
         $materialsRequest->find();
         $profile['numMaterialsRequests'] = $materialsRequest->N;
     }
     $timer->logTime("Got Patron Profile");
     $memCache->set($memCacheProfileKey, $profile, 0, $configArray['Caching']['patron_profile']);
     return $profile;
 }
Esempio n. 4
0
 public function getMyProfile($patron, $forceReload = false)
 {
     global $timer;
     global $configArray;
     if (is_object($patron)) {
         $patron = get_object_vars($patron);
     }
     if (array_key_exists($patron['username'], $this->patronProfiles) && !$forceReload) {
         $timer->logTime('Retrieved Cached Profile for Patron');
         return $this->patronProfiles[$patron['username']];
     }
     $mysip = new sip2();
     $mysip->hostname = $configArray['SIP2']['host'];
     $mysip->port = $configArray['SIP2']['port'];
     if ($mysip->connect()) {
         //send selfcheck status message
         $in = $mysip->msgSCStatus();
         $msg_result = $mysip->get_message($in);
         // Make sure the response is 98 as expected
         if (preg_match("/^98/", $msg_result)) {
             $result = $mysip->parseACSStatusResponse($msg_result);
             //  Use result to populate SIP2 setings
             $mysip->AO = $result['variable']['AO'][0];
             /* set AO to value returned */
             $mysip->AN = $result['variable']['AN'][0];
             /* set AN to value returned */
             $mysip->patron = $patron['username'];
             $mysip->patronpwd = $patron['cat_password'];
             $in = $mysip->msgPatronInformation('fine');
             $msg_result = $mysip->get_message($in);
             // Make sure the response is 24 as expected
             if (preg_match("/^64/", $msg_result)) {
                 $result = $mysip->parsePatronInfoResponse($msg_result);
                 $address = $result['variable']['BD'][0];
                 $addressParts = explode(',', $address);
                 $expirationDate = $result['variable']['PE'][0];
                 $formattedExpiration = substr($expirationDate, 4, 2) . '/' . substr($expirationDate, 6, 2) . '/' . substr($expirationDate, 0, 4);
                 //$fines = $this->parseSip2Fines($result['variable']['AV']);
                 $location = new Location();
                 $location->code = $result['variable']['AQ'][0];
                 $location->find();
                 if ($location->N > 0) {
                     $location->fetch();
                     $homeLocationId = $location->locationId;
                 }
                 global $user;
                 $profile = array('lastname' => $result['variable']['DJ'][0], 'firstname' => isset($result['variable']['DH'][0]) ? $result['variable']['DH'][0] : '', 'displayName' => $patron['displayName'], 'fullname' => $result['variable']['AE'][0], 'address1' => trim($addressParts[0]), 'city' => trim($addressParts[1]), 'state' => trim($addressParts[2]), 'zip' => isset($addressParts[3]) ? trim($addressParts[3]) : '', 'phone' => isset($result['variable']['BF'][0]) ? $result['variable']['BF'][0] : '', 'email' => isset($result['variable']['BE'][0]) ? $result['variable']['BE'][0] : '', 'homeLocationId' => isset($homeLocationId) ? $homeLocationId : -1, 'homeLocationName' => $this->translateLocation($result['variable']['AQ'][0]), 'expires' => $formattedExpiration, 'fines' => isset($result['variable']['BV']) ? sprintf('$%01.2f', $result['variable']['BV'][0]) : 0, 'finesval' => isset($result['variable']['BV']) ? $result['variable']['BV'][0] : '', 'numHolds' => $result['fixed']['HoldCount'] + $result['fixed']['UnavailableCount'], 'numHoldsAvailable' => $result['fixed']['HoldCount'], 'numHoldsRequested' => $result['fixed']['UnavailableCount'], 'numCheckedOut' => $result['fixed']['ChargedCount'], 'bypassAutoLogout' => $user ? $user->bypassAutoLogout : false);
                 //Get eContent info as well
                 require_once ROOT_DIR . '/Drivers/EContentDriver.php';
                 $eContentDriver = new EContentDriver();
                 $eContentAccountSummary = $eContentDriver->getAccountSummary();
                 $profile = array_merge($profile, $eContentAccountSummary);
                 //Get a count of the materials requests for the user
                 $materialsRequest = new MaterialsRequest();
                 $materialsRequest->createdBy = $user->id;
                 $statusQuery = new MaterialsRequestStatus();
                 $statusQuery->isOpen = 1;
                 $materialsRequest->joinAdd($statusQuery);
                 $materialsRequest->find();
                 $profile['numMaterialsRequests'] = $materialsRequest->N;
             } else {
                 $profile = new PEAR_Error('patron_info_error_technical');
             }
         } else {
             $profile = new PEAR_Error('patron_info_error_technical');
         }
         $mysip->disconnect();
     } else {
         $profile = new PEAR_Error('patron_info_error_technical');
     }
     $this->patronProfiles[$patron['username']] = $profile;
     $timer->logTime('Retrieved Profile for Patron from SIP 2');
     return $profile;
 }
Esempio n. 5
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     //Load the materials request to determine if it can be edited
     $materialsRequest = new MaterialsRequest();
     $materialsRequest->id = $_REQUEST['id'];
     if (!$materialsRequest->find(true)) {
         $materialsRequest = null;
         $requestUser = false;
     } else {
         $requestUser = new User();
         $requestUser->id = $materialsRequest->createdBy;
         if ($requestUser->find(true)) {
             $interface->assign('requestUser', $requestUser);
         } else {
             $requestUser = false;
         }
     }
     //Make sure that the user is valid
     $processForm = true;
     if ($materialsRequest == null) {
         $interface->assign('success', false);
         $interface->assign('error', 'Sorry, we could not find a request with that id.');
         $processForm = false;
     } else {
         if (!$user) {
             $interface->assign('error', 'Sorry, you must be logged in to update a materials request.');
             $processForm = false;
         } else {
             if ($user->hasRole('cataloging')) {
                 //Ok to process the form even if it wasn't created by the current user
             } else {
                 if ($user->hasRole('library_material_requests') && $requestUser && Library::getLibraryForLocation($requestUser->homeLocationId)->libraryId == Library::getLibraryForLocation($user->homeLocationId)->libraryId) {
                     //Ok to process because they are an admin for the user's home library
                 } else {
                     if ($user->id != $materialsRequest->createdBy) {
                         $interface->assign('error', 'Sorry, you do not have permission to update this materials request.');
                         $processForm = false;
                     }
                 }
             }
         }
     }
     if ($processForm) {
         //Materials request can be submitted.
         $materialsRequest->title = strip_tags($_REQUEST['title']);
         $materialsRequest->season = isset($_REQUEST['season']) ? strip_tags($_REQUEST['season']) : '';
         $materialsRequest->magazineTitle = isset($_REQUEST['magazineTitle']) ? strip_tags($_REQUEST['magazineTitle']) : '';
         $materialsRequest->magazineDate = isset($_REQUEST['magazineDate']) ? strip_tags($_REQUEST['magazineDate']) : '';
         $materialsRequest->magazineVolume = isset($_REQUEST['magazineVolume']) ? strip_tags($_REQUEST['magazineVolume']) : '';
         $materialsRequest->magazineNumber = isset($_REQUEST['magazineNumber']) ? strip_tags($_REQUEST['magazineNumber']) : '';
         $materialsRequest->magazinePageNumbers = isset($_REQUEST['magazinePageNumbers']) ? strip_tags($_REQUEST['magazinePageNumbers']) : '';
         $materialsRequest->author = strip_tags($_REQUEST['author']);
         $materialsRequest->format = strip_tags($_REQUEST['format']);
         $materialsRequest->subFormat = isset($_REQUEST['subFormat']) ? strip_tags($_REQUEST['subFormat']) : '';
         $materialsRequest->ageLevel = strip_tags($_REQUEST['ageLevel']);
         $materialsRequest->bookType = isset($_REQUEST['bookType']) ? strip_tags($_REQUEST['bookType']) : '';
         $materialsRequest->isbn = isset($_REQUEST['isbn']) ? strip_tags($_REQUEST['isbn']) : '';
         $materialsRequest->upc = isset($_REQUEST['upc']) ? strip_tags($_REQUEST['upc']) : '';
         $materialsRequest->issn = isset($_REQUEST['issn']) ? strip_tags($_REQUEST['issn']) : '';
         $materialsRequest->oclcNumber = isset($_REQUEST['oclcNumber']) ? strip_tags($_REQUEST['oclcNumber']) : '';
         $materialsRequest->publisher = strip_tags($_REQUEST['publisher']);
         $materialsRequest->publicationYear = strip_tags($_REQUEST['publicationYear']);
         if (isset($_REQUEST['abridged'])) {
             if ($_REQUEST['abridged'] == 'abridged') {
                 $materialsRequest->abridged = 1;
             } elseif ($_REQUEST['abridged'] == 'unabridged') {
                 $materialsRequest->abridged = 0;
             } else {
                 $materialsRequest->abridged = 2;
                 //Not applicable
             }
         }
         $materialsRequest->comments = strip_tags($_REQUEST['comments']);
         $materialsRequest->dateUpdated = time();
         if ($materialsRequest->update()) {
             $interface->assign('success', true);
             $interface->assign('materialsRequest', $materialsRequest);
         } else {
             $interface->assign('success', false);
             $interface->assign('error', 'There was an error updating the materials request.');
         }
     } else {
         $interface->assign('success', false);
         $interface->assign('error', 'Sorry, we could not find a request with that id.');
     }
     //Get a list of formats to show
     $availableFormats = MaterialsRequest::getFormats();
     $interface->assign('availableFormats', $availableFormats);
     $interface->assign('showPhoneField', $configArray['MaterialsRequest']['showPhoneField']);
     $interface->assign('showAgeField', $configArray['MaterialsRequest']['showAgeField']);
     $interface->assign('showBookTypeField', $configArray['MaterialsRequest']['showBookTypeField']);
     $interface->assign('showEbookFormatField', $configArray['MaterialsRequest']['showEbookFormatField']);
     $interface->assign('showEaudioFormatField', $configArray['MaterialsRequest']['showEaudioFormatField']);
     $interface->assign('showPlaceHoldField', $configArray['MaterialsRequest']['showPlaceHoldField']);
     $interface->assign('showIllField', $configArray['MaterialsRequest']['showIllField']);
     $interface->setTemplate('update-result.tpl');
     $interface->setPageTitle('Update Result');
     $interface->display('layout.tpl');
 }
Esempio n. 6
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     //Load status information
     $materialsRequestStatus = new MaterialsRequestStatus();
     $materialsRequestStatus->orderBy('isDefault DESC, isOpen DESC, description ASC');
     if ($user->hasRole('library_material_requests')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $materialsRequestStatus->libraryId = $homeLibrary->libraryId;
     } else {
         $libraryList[-1] = 'Default';
     }
     $materialsRequestStatus->find();
     $allStatuses = array();
     $availableStatuses = array();
     $defaultStatusesToShow = array();
     while ($materialsRequestStatus->fetch()) {
         $availableStatuses[$materialsRequestStatus->id] = $materialsRequestStatus->description;
         $allStatuses[$materialsRequestStatus->id] = clone $materialsRequestStatus;
         if ($materialsRequestStatus->isOpen == 1 || $materialsRequestStatus->isDefault == 1) {
             $defaultStatusesToShow[] = $materialsRequestStatus->id;
         }
     }
     $interface->assign('availableStatuses', $availableStatuses);
     if (isset($_REQUEST['statusFilter'])) {
         $statusesToShow = $_REQUEST['statusFilter'];
         $_SESSION['materialsRequestStatusFilter'] = $statusesToShow;
     } elseif (isset($_SESSION['materialsRequestStatusFilter'])) {
         $statusesToShow = $_SESSION['materialsRequestStatusFilter'];
     } else {
         $statusesToShow = $defaultStatusesToShow;
     }
     $interface->assign('statusFilter', $statusesToShow);
     //Process status change if needed
     if (isset($_REQUEST['updateStatus']) && isset($_REQUEST['select'])) {
         //Look for which titles should be modified
         $selectedRequests = $_REQUEST['select'];
         $statusToSet = $_REQUEST['newStatus'];
         require_once ROOT_DIR . '/sys/Mailer.php';
         $mail = new VuFindMailer();
         foreach ($selectedRequests as $requestId => $selected) {
             $materialRequest = new MaterialsRequest();
             $materialRequest->id = $requestId;
             if ($materialRequest->find(true)) {
                 $materialRequest->status = $statusToSet;
                 $materialRequest->dateUpdated = time();
                 $materialRequest->update();
                 if ($allStatuses[$statusToSet]->sendEmailToPatron == 1 && $materialRequest->email) {
                     $body = '*****This is an auto-generated email response. Please do not reply.*****';
                     $body .= "\r\n" . $allStatuses[$statusToSet]->emailTemplate;
                     //Replace tags with appropriate values
                     $materialsRequestUser = new User();
                     $materialsRequestUser->id = $materialRequest->createdBy;
                     $materialsRequestUser->find(true);
                     foreach ($materialsRequestUser as $fieldName => $fieldValue) {
                         if (!is_array($fieldValue)) {
                             $body = str_replace('{' . $fieldName . '}', $fieldValue, $body);
                         }
                     }
                     foreach ($materialRequest as $fieldName => $fieldValue) {
                         if (!is_array($fieldValue)) {
                             $body = str_replace('{' . $fieldName . '}', $fieldValue, $body);
                         }
                     }
                     $materialsRequestUser->find(true);
                     $mail->send($materialRequest->email, $configArray['Site']['email'], "Your Materials Request Update", $body, $configArray['Site']['email']);
                 }
             }
         }
     }
     $availableFormats = MaterialsRequest::getFormats();
     $interface->assign('availableFormats', $availableFormats);
     $defaultFormatsToShow = array_keys($availableFormats);
     if (isset($_REQUEST['formatFilter'])) {
         $formatsToShow = $_REQUEST['formatFilter'];
         $_SESSION['materialsRequestFormatFilter'] = $formatsToShow;
     } elseif (isset($_SESSION['materialsRequestFormatFilter'])) {
         $formatsToShow = $_SESSION['materialsRequestFormatFilter'];
     } else {
         $formatsToShow = $defaultFormatsToShow;
     }
     $interface->assign('formatFilter', $formatsToShow);
     //Get a list of all materials requests for the user
     $allRequests = array();
     if ($user) {
         $materialsRequests = new MaterialsRequest();
         $materialsRequests->joinAdd(new Location(), "LEFT");
         $materialsRequests->joinAdd(new MaterialsRequestStatus());
         $materialsRequests->joinAdd(new User(), 'INNER', 'user');
         $materialsRequests->selectAdd();
         $materialsRequests->selectAdd('materials_request.*, description as statusLabel, location.displayName as location, firstname, lastname, ' . $configArray['Catalog']['barcodeProperty'] . ' as barcode');
         if ($user->hasRole('library_material_requests')) {
             //Need to limit to only requests submitted for the user's home location
             $userHomeLibrary = Library::getPatronHomeLibrary();
             $locations = new Location();
             $locations->libraryId = $userHomeLibrary->libraryId;
             $locations->find();
             $locationsForLibrary = array();
             while ($locations->fetch()) {
                 $locationsForLibrary[] = $locations->locationId;
             }
             $materialsRequests->whereAdd('user.homeLocationId IN (' . implode(', ', $locationsForLibrary) . ')');
         }
         if (count($availableStatuses) > count($statusesToShow)) {
             $statusSql = "";
             foreach ($statusesToShow as $status) {
                 if (strlen($statusSql) > 0) {
                     $statusSql .= ",";
                 }
                 $statusSql .= "'" . $materialsRequests->escape($status) . "'";
             }
             $materialsRequests->whereAdd("status in ({$statusSql})");
         }
         if (count($availableFormats) > count($formatsToShow)) {
             //At least one format is disabled
             $formatSql = "";
             foreach ($formatsToShow as $format) {
                 if (strlen($formatSql) > 0) {
                     $formatSql .= ",";
                 }
                 $formatSql .= "'" . $materialsRequests->escape($format) . "'";
             }
             $materialsRequests->whereAdd("format in ({$formatSql})");
         }
         //Add filtering by date as needed
         if (isset($_REQUEST['startDate']) && strlen($_REQUEST['startDate']) > 0) {
             $startDate = strtotime($_REQUEST['startDate']);
             $materialsRequests->whereAdd("dateCreated >= {$startDate}");
             $interface->assign('startDate', $_REQUEST['startDate']);
         }
         if (isset($_REQUEST['endDate']) && strlen($_REQUEST['endDate']) > 0) {
             $endDate = strtotime($_REQUEST['endDate']);
             $materialsRequests->whereAdd("dateCreated <= {$endDate}");
             $interface->assign('endDate', $_REQUEST['endDate']);
         }
         $materialsRequests->find();
         while ($materialsRequests->fetch()) {
             $allRequests[] = clone $materialsRequests;
         }
     } else {
         $interface->assign('error', "You must be logged in to manage requests.");
     }
     $interface->assign('allRequests', $allRequests);
     if (isset($_REQUEST['exportSelected'])) {
         $this->exportToExcel($_REQUEST['select'], $allRequests);
     } else {
         $interface->setTemplate('manageRequests.tpl');
         $interface->setPageTitle('Manage Materials Requests');
         $interface->display('layout.tpl');
     }
 }
Esempio n. 7
0
 /**
  * @param User $patron
  * @param bool $forceReload
  * @return array
  */
 public function getMyProfile($patron, $forceReload = false)
 {
     //Update to not use SIP, just screen scrape for performance (sigh)
     global $timer;
     /** @var Memcache $memCache */
     global $memCache;
     if (!is_object($patron)) {
         $tmpPatron = new User();
         $tmpPatron->username = $patron['username'];
         $tmpPatron->cat_username = $patron['cat_username'];
         $tmpPatron->cat_password = $patron['cat_password'];
         $tmpPatron->firstname = $patron['firstname'];
         $tmpPatron->lastname = $patron['lastname'];
         $tmpPatron->email = $patron['email'];
         $tmpPatron->patronType = $patron['patronType'];
         $patron = $tmpPatron;
     }
     if (!$forceReload && !isset($_REQUEST['reload'])) {
         // Check the Object for profile
         if (array_key_exists($patron->username, $this->patronProfiles)) {
             $timer->logTime('Retrieved Cached Profile for Patron');
             return $this->patronProfiles[$patron->username];
         }
     }
     // Determine memcache key
     global $serverName;
     $memCacheProfileKey = "patronProfile_{$serverName}_";
     if (is_object($patron) && !isset($tmpPatron)) {
         // exclude the new patron object $tmpPatron created above. It won't have an id or be stored in memcache
         //				$patron         = get_object_vars($patron);
         //			$memCacheProfileKey = $patron['username'];
         // $patron needs to remain an object for initial loading below
         $memCacheProfileKey .= $patron->username;
     } else {
         global $user;
         //				$memCacheProfileKey = $user->id;
         $memCacheProfileKey .= $user->username;
     }
     // Check MemCache for profile
     if (!$forceReload && !isset($_REQUEST['reload'])) {
         $patronProfile = $memCache->get($memCacheProfileKey);
         if ($patronProfile) {
             //echo("Using cached profile for patron " . $userId);
             $timer->logTime('Retrieved Cached Profile for Patron');
             return $patronProfile;
         }
     }
     $this->initDatabaseConnection();
     $this->getUserInfoStmt->bind_param('ss', $patron->cat_username, $patron->cat_username);
     if ($this->getUserInfoStmt->execute()) {
         if ($userFromDbResultSet = $this->getUserInfoStmt->get_result()) {
             $userFromDb = $userFromDbResultSet->fetch_assoc();
             $userFromDbResultSet->close();
             //				$city = $userFromDb['city'];
             //				$state = "";
             //				$commaPos = strpos($city, ',');
             //				if ($commaPos !== false){ // fix this
             //					$cityState = $city;
             //					$city = substr($cityState, 0, $commaPos);
             //					$state = substr($cityState, $commaPos);
             //				}
             $city = strtok($userFromDb['city'], ',');
             $state = strtok(',');
             $city = trim($city);
             $state = trim($state);
             //Get fines
             //Load fines from database
             $outstandingFines = $this->getOutstandingFineTotal();
             //Get number of items checked out
             $checkedOutItemsRS = mysqli_query($this->dbConnection, 'SELECT count(*) as numCheckouts FROM issues WHERE borrowernumber = ' . $patron->username);
             $numCheckouts = 0;
             if ($checkedOutItemsRS) {
                 $checkedOutItems = $checkedOutItemsRS->fetch_assoc();
                 $numCheckouts = $checkedOutItems['numCheckouts'];
                 $checkedOutItemsRS->close();
             }
             //Get number of available holds
             $availableHoldsRS = mysqli_query($this->dbConnection, 'SELECT count(*) as numHolds FROM reserves WHERE waitingdate is not null and borrowernumber = ' . $patron->username);
             $numAvailableHolds = 0;
             if ($availableHoldsRS) {
                 $availableHolds = $availableHoldsRS->fetch_assoc();
                 $numAvailableHolds = $availableHolds['numHolds'];
                 $availableHoldsRS->close();
             }
             //Get number of unavailable
             $waitingHoldsRS = mysqli_query($this->dbConnection, 'SELECT count(*) as numHolds FROM reserves WHERE waitingdate is null and borrowernumber = ' . $patron->username);
             $numWaitingHolds = 0;
             if ($waitingHoldsRS) {
                 $waitingHolds = $waitingHoldsRS->fetch_assoc();
                 $numWaitingHolds = $waitingHolds['numHolds'];
                 $waitingHoldsRS->close();
             }
             $homeBranchCode = $userFromDb['branchcode'];
             $location = new Location();
             $location->code = $homeBranchCode;
             $location->find(1);
             if ($location->N == 0) {
                 unset($location);
             }
             global $user;
             $profile = array('lastname' => $patron->lastname, 'firstname' => $patron->firstname, 'displayName' => isset($patron->displayName) ? $patron->displayName : '', 'fullname' => $user->lastname . ', ' . $user->firstname, 'address1' => trim($userFromDb['streetnumber'] . ' ' . $userFromDb['address'] . ' ' . $userFromDb['address2']), 'city' => $city, 'state' => $state, 'zip' => $userFromDb['zipcode'], 'phone' => $userFromDb['phone'], 'email' => $userFromDb['email'], 'homeLocationId' => isset($location) ? $location->locationId : -1, 'homeLocationName' => '', 'expires' => $userFromDb['dateexpiry'], 'fines' => sprintf('$%0.2f', $outstandingFines), 'finesval' => floatval($outstandingFines), 'numHolds' => $numWaitingHolds + $numAvailableHolds, 'numHoldsAvailable' => $numAvailableHolds, 'numHoldsRequested' => $numWaitingHolds, 'numCheckedOut' => $numCheckouts, 'bypassAutoLogout' => $user ? $user->bypassAutoLogout : false);
             $profile['noticePreferenceLabel'] = 'Unknown';
             //Get eContent info as well
             require_once ROOT_DIR . '/Drivers/EContentDriver.php';
             $eContentDriver = new EContentDriver();
             $eContentAccountSummary = $eContentDriver->getAccountSummary();
             $profile = array_merge($profile, $eContentAccountSummary);
             require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
             $overDriveDriver = OverDriveDriverFactory::getDriver();
             if ($overDriveDriver->isUserValidForOverDrive($user)) {
                 $overDriveSummary = $overDriveDriver->getOverDriveSummary($user);
                 $profile['numOverDriveCheckedOut'] = $overDriveSummary['numCheckedOut'];
                 $profile['numOverDriveHoldsAvailable'] = $overDriveSummary['numAvailableHolds'];
                 $profile['numOverDriveHoldsRequested'] = $overDriveSummary['numUnavailableHolds'];
                 $profile['canUseOverDrive'] = true;
             } else {
                 $profile['numOverDriveCheckedOut'] = 0;
                 $profile['numOverDriveHoldsAvailable'] = 0;
                 $profile['numOverDriveHoldsRequested'] = 0;
                 $profile['canUseOverDrive'] = false;
             }
             $profile['numCheckedOutTotal'] = $profile['numCheckedOut'] + $profile['numOverDriveCheckedOut'] + $eContentAccountSummary['numEContentCheckedOut'];
             $profile['numHoldsAvailableTotal'] = $profile['numHoldsAvailable'] + $profile['numOverDriveHoldsAvailable'] + $eContentAccountSummary['numEContentAvailableHolds'];
             $profile['numHoldsRequestedTotal'] = $profile['numHoldsRequested'] + $profile['numOverDriveHoldsRequested'] + $eContentAccountSummary['numEContentUnavailableHolds'];
             $profile['numHoldsTotal'] = $profile['numHoldsAvailableTotal'] + $profile['numHoldsRequestedTotal'];
             //Get a count of the materials requests for the user
             if ($user) {
                 $homeLibrary = Library::getPatronHomeLibrary();
                 if ($homeLibrary) {
                     $materialsRequest = new MaterialsRequest();
                     $materialsRequest->createdBy = $user->id;
                     $statusQuery = new MaterialsRequestStatus();
                     $statusQuery->isOpen = 1;
                     $statusQuery->libraryId = $homeLibrary->libraryId;
                     $materialsRequest->joinAdd($statusQuery);
                     $materialsRequest->find();
                     $profile['numMaterialsRequests'] = $materialsRequest->N;
                 } else {
                     $profile['numMaterialsRequests'] = 0;
                 }
                 if ($user->homeLocationId == 0 && isset($location)) {
                     $user->homeLocationId = $location->locationId;
                     if ($location->nearbyLocation1 > 0) {
                         $user->myLocation1Id = $location->nearbyLocation1;
                     } else {
                         $user->myLocation1Id = $location->locationId;
                     }
                     if ($location->nearbyLocation2 > 0) {
                         $user->myLocation2Id = $location->nearbyLocation2;
                     } else {
                         $user->myLocation2Id = $location->locationId;
                     }
                     if ($user instanceof User) {
                         //Update the database
                         $user->update();
                         //Update the serialized instance stored in the session
                         $_SESSION['userinfo'] = serialize($user);
                     }
                 } else {
                     if (isset($location) && $location->locationId != $user->homeLocationId) {
                         $user->homeLocationId = $location->locationId;
                         //Update the database
                         $user->update();
                         //Update the serialized instance stored in the session
                         $_SESSION['userinfo'] = serialize($user);
                     }
                 }
             }
         } else {
             $profile = PEAR_Singleton::raiseError('patron_info_error_technical - could not load from database');
         }
     } else {
         $profile = PEAR_Singleton::raiseError('patron_info_error_technical - could not execute user info statement');
     }
     $this->patronProfiles[$patron->username] = $profile;
     $timer->logTime('Retrieved Profile for Patron from Database');
     global $configArray, $serverName;
     $memCache->set($memCacheProfileKey, $profile, 0, $configArray['Caching']['patron_profile']);
     // Looks like all drivers but aspencat use id rather than username.
     // plb 4-16-2014
     return $profile;
 }
Esempio n. 8
0
 function launch()
 {
     global $interface;
     global $user;
     $period = isset($_REQUEST['period']) ? $_REQUEST['period'] : 'week';
     if ($period == 'week') {
         $periodLength = new DateInterval("P1W");
     } elseif ($period == 'day') {
         $periodLength = new DateInterval("P1D");
     } elseif ($period == 'month') {
         $periodLength = new DateInterval("P1M");
     } else {
         //year
         $periodLength = new DateInterval("P1Y");
     }
     $interface->assign('period', $period);
     $endDate = isset($_REQUEST['endDate']) && strlen($_REQUEST['endDate']) > 0 ? DateTime::createFromFormat('m/d/Y', $_REQUEST['endDate']) : new DateTime();
     $interface->assign('endDate', $endDate->format('m/d/Y'));
     if (isset($_REQUEST['startDate']) && strlen($_REQUEST['startDate']) > 0) {
         $startDate = DateTime::createFromFormat('m/d/Y', $_REQUEST['startDate']);
     } else {
         if ($period == 'day') {
             $startDate = new DateTime($endDate->format('m/d/Y') . " - 7 days");
         } elseif ($period == 'week') {
             //Get the sunday after this
             $endDate->setISODate($endDate->format('Y'), $endDate->format("W"), 0);
             $endDate->modify("+7 days");
             $startDate = new DateTime($endDate->format('m/d/Y') . " - 28 days");
         } elseif ($period == 'month') {
             $endDate->modify("+1 month");
             $numDays = $endDate->format("d");
             $endDate->modify(" -{$numDays} days");
             $startDate = new DateTime($endDate->format('m/d/Y') . " - 6 months");
         } else {
             //year
             $endDate->modify("+1 year");
             $numDays = $endDate->format("m");
             $endDate->modify(" -{$numDays} months");
             $numDays = $endDate->format("d");
             $endDate->modify(" -{$numDays} days");
             $startDate = new DateTime($endDate->format('m/d/Y') . " - 2 years");
         }
     }
     $interface->assign('startDate', $startDate->format('m/d/Y'));
     //Set the end date to the end of the day
     $endDate->setTime(24, 0, 0);
     $startDate->setTime(0, 0, 0);
     //Create the periods that are being represented
     $periods = array();
     $periodEnd = clone $endDate;
     while ($periodEnd >= $startDate) {
         array_unshift($periods, clone $periodEnd);
         $periodEnd->sub($periodLength);
     }
     //print_r($periods);
     //Load data for each period
     //this will be a two dimensional array
     //         Period 1, Period 2, Period 3
     //Status 1
     //Status 2
     //Status 3
     $periodData = array();
     for ($i = 0; $i < count($periods) - 1; $i++) {
         /** @var DateTime $periodStart */
         $periodStart = clone $periods[$i];
         /** @var DateTime $periodEnd */
         $periodEnd = clone $periods[$i + 1];
         $periodData[$periodStart->getTimestamp()] = array();
         //Determine how many requests were created
         $materialsRequest = new MaterialsRequest();
         $materialsRequest->joinAdd(new User(), 'INNER', 'user');
         $materialsRequest->selectAdd();
         $materialsRequest->selectAdd('COUNT(id) as numRequests');
         $materialsRequest->whereAdd('dateCreated >= ' . $periodStart->getTimestamp() . ' AND dateCreated < ' . $periodEnd->getTimestamp());
         if ($user->hasRole('library_material_requests')) {
             //Need to limit to only requests submitted for the user's home location
             $userHomeLibrary = Library::getPatronHomeLibrary();
             $locations = new Location();
             $locations->libraryId = $userHomeLibrary->libraryId;
             $locations->find();
             $locationsForLibrary = array();
             while ($locations->fetch()) {
                 $locationsForLibrary[] = $locations->locationId;
             }
             $materialsRequest->whereAdd('user.homeLocationId IN (' . implode(', ', $locationsForLibrary) . ')');
         }
         $materialsRequest->find();
         while ($materialsRequest->fetch()) {
             $periodData[$periodStart->getTimestamp()]['Created'] = $materialsRequest->numRequests;
         }
         //Get a list of all requests by the status of the request
         $materialsRequest = new MaterialsRequest();
         $materialsRequest->joinAdd(new MaterialsRequestStatus());
         $materialsRequest->joinAdd(new User(), 'INNER', 'user');
         $materialsRequest->selectAdd();
         $materialsRequest->selectAdd('COUNT(materials_request.id) as numRequests,description');
         $materialsRequest->whereAdd('dateUpdated >= ' . $periodStart->getTimestamp() . ' AND dateUpdated < ' . $periodEnd->getTimestamp());
         if ($user->hasRole('library_material_requests')) {
             //Need to limit to only requests submitted for the user's home location
             $userHomeLibrary = Library::getPatronHomeLibrary();
             $locations = new Location();
             $locations->libraryId = $userHomeLibrary->libraryId;
             $locations->find();
             $locationsForLibrary = array();
             while ($locations->fetch()) {
                 $locationsForLibrary[] = $locations->locationId;
             }
             $materialsRequest->whereAdd('user.homeLocationId IN (' . implode(', ', $locationsForLibrary) . ')');
         }
         $materialsRequest->groupBy('status');
         $materialsRequest->orderBy('status');
         $materialsRequest->find();
         while ($materialsRequest->fetch()) {
             $periodData[$periodStart->getTimestamp()][$materialsRequest->description] = $materialsRequest->numRequests;
         }
     }
     $interface->assign('periodData', $periodData, $periods);
     //Get a list of all of the statuses that will be shown
     $statuses = array();
     foreach ($periodData as $periodInfo) {
         foreach ($periodInfo as $status => $numRequests) {
             $statuses[$status] = translate($status);
         }
     }
     $interface->assign('statuses', $statuses);
     //Check to see if we are exporting to Excel
     if (isset($_REQUEST['exportToExcel'])) {
         $this->exportToExcel($periodData, $statuses);
     } else {
         //Generate the graph
         $this->generateGraph($periodData, $statuses);
     }
     $interface->setTemplate('summaryReport.tpl');
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->setPageTitle('Materials Request Summary Report');
     $interface->display('layout.tpl');
 }
Esempio n. 9
0
 /**
  * Get Patron Profile
  *
  * This is responsible for retrieving the profile for a specific patron.
  * Interface defined in CatalogConnection.php
  *
  * @param   array   $patron     The patron array
  * @return  array               Array of the patron's profile data
  *                              If an error occures, return a PEAR_Error
  * @access  public
  */
 public function getMyProfile($patron)
 {
     global $timer;
     global $configArray;
     if (is_object($patron)) {
         $patron = get_object_vars($patron);
         $id2 = $this->_getBarcode();
     } else {
         $id2 = $patron['id'];
     }
     if (array_key_exists($patron['id'], $this->patronProfiles)) {
         $timer->logTime('Retrieved Cached Profile for Patron');
         return $this->patronProfiles[$patron['id']];
     }
     //Load the raw information about the patron
     $patronDump = $this->_getPatronDump($id2);
     if (isset($patronDump['ADDRESS'])) {
         $Fulladdress = $patronDump['ADDRESS'];
         $addressParts = explode('$', $Fulladdress);
         $Address1 = $addressParts[0];
         $City = isset($addressParts[1]) ? $addressParts[1] : '';
         $State = isset($addressParts[2]) ? $addressParts[2] : '';
         $Zip = isset($addressParts[3]) ? $addressParts[3] : '';
         if (preg_match('/(.*?),\\s+(.*)\\s+(\\d*(?:-\\d*)?)/', $City, $matches)) {
             $City = $matches[1];
             $State = $matches[2];
             $Zip = $matches[3];
         }
     } else {
         $Address1 = "";
         $City = "";
         $State = "";
         $Zip = "";
     }
     $fullName = $patronDump['PATRN_NAME'];
     $nameParts = explode(', ', $fullName);
     $lastName = $nameParts[0];
     $secondName = isset($nameParts[1]) ? $nameParts[1] : '';
     if (strpos($secondName, ' ')) {
         $nameParts2 = explode(' ', $secondName);
         $firstName = $nameParts2[0];
     } else {
         $firstName = $secondName;
     }
     //Get additional information about the patron's home branch for display.
     $homeBranchCode = $patronDump['HOME_LIBR'];
     //Translate home branch to plain text
     global $user;
     $location = new Location();
     $location->whereAdd("code = '{$homeBranchCode}'");
     $location->find(1);
     if ($user) {
         if ($user->homeLocationId == 0) {
             $user->homeLocationId = $location->locationId;
             if ($location->nearbyLocation1 > 0) {
                 $user->myLocation1Id = $location->nearbyLocation1;
             } else {
                 $user->myLocation1Id = $location->locationId;
             }
             if ($location->nearbyLocation2 > 0) {
                 $user->myLocation2Id = $location->nearbyLocation2;
             } else {
                 $user->myLocation2Id = $location->locationId;
             }
             if ($user instanceof User) {
                 //Update the database
                 $user->update();
                 //Update the serialized instance stored in the session
                 $_SESSION['userinfo'] = serialize($user);
             }
         }
         //Get display name for preferred location 1
         $myLocation1 = new Location();
         $myLocation1->whereAdd("locationId = '{$user->myLocation1Id}'");
         $myLocation1->find(1);
         //Get display name for preferred location 1
         $myLocation2 = new Location();
         $myLocation2->whereAdd("locationId = '{$user->myLocation2Id}'");
         $myLocation2->find(1);
     }
     //see if expiration date is close
     list($monthExp, $dayExp, $yearExp) = explode("-", $patronDump['EXP_DATE']);
     $timeExpire = strtotime($monthExp . "/" . $dayExp . "/" . $yearExp);
     $timeNow = time();
     $timeToExpire = $timeExpire - $timeNow;
     if ($timeToExpire <= 30 * 24 * 60 * 60) {
         $expireClose = 1;
     } else {
         $expireClose = 0;
     }
     $finesVal = floatval(preg_replace('/[^\\d.]/', '', $patronDump['MONEY_OWED']));
     $numHoldsAvailable = 0;
     $numHoldsRequested = 0;
     $availableStatusRegex = isset($configArray['Catalog']['patronApiAvailableHoldsRegex']) ? $configArray['Catalog']['patronApiAvailableHoldsRegex'] : "/ST=(105|98),/";
     if (isset($patronDump['HOLD']) && count($patronDump['HOLD']) > 0) {
         foreach ($patronDump['HOLD'] as $hold) {
             if (preg_match("{$availableStatusRegex}", $hold)) {
                 $numHoldsAvailable++;
             } else {
                 $numHoldsRequested++;
             }
         }
     }
     $profile = array('lastname' => $lastName, 'firstname' => $firstName, 'fullname' => $fullName, 'address1' => $Address1, 'address2' => $City . ', ' . $State, 'city' => $City, 'state' => $State, 'zip' => $Zip, 'email' => isset($patronDump['EMAIL_ADDR']) ? $patronDump['EMAIL_ADDR'] : '', 'overdriveEmail' => $user ? $user->overdriveEmail : (isset($patronDump['EMAIL_ADDR']) ? $patronDump['EMAIL_ADDR'] : ''), 'promptForOverdriveEmail' => $user ? $user->promptForOverdriveEmail : 1, 'phone' => isset($patronDump['TELEPHONE']) ? $patronDump['TELEPHONE'] : '', 'fines' => $patronDump['MONEY_OWED'], 'finesval' => $finesVal, 'expires' => $patronDump['EXP_DATE'], 'expireclose' => $expireClose, 'homeLocationCode' => trim($homeBranchCode), 'homeLocationId' => $location->locationId, 'homeLocation' => $location->displayName, 'myLocation1Id' => $user ? $user->myLocation1Id : -1, 'myLocation1' => isset($myLocation1) ? $myLocation1->displayName : '', 'myLocation2Id' => $user ? $user->myLocation2Id : -1, 'myLocation2' => isset($myLocation2) ? $myLocation2->displayName : '', 'numCheckedOut' => $patronDump['CUR_CHKOUT'], 'numHolds' => isset($patronDump['HOLD']) ? count($patronDump['HOLD']) : 0, 'numHoldsAvailable' => $numHoldsAvailable, 'numHoldsRequested' => $numHoldsRequested, 'bypassAutoLogout' => $user ? $user->bypassAutoLogout : 0, 'ptype' => $patronDump['P_TYPE'], 'notices' => $patronDump['NOTICE_PREF'], 'web_note' => isset($patronDump['WEB_NOTE']) ? $patronDump['WEB_NOTE'] : '');
     //Get eContent info as well
     require_once ROOT_DIR . '/Drivers/EContentDriver.php';
     $eContentDriver = new EContentDriver();
     $eContentAccountSummary = $eContentDriver->getAccountSummary();
     $profile = array_merge($profile, $eContentAccountSummary);
     //Get a count of the materials requests for the user
     if ($user) {
         $materialsRequest = new MaterialsRequest();
         $materialsRequest->createdBy = $user->id;
         $homeLibrary = Library::getPatronHomeLibrary();
         $statusQuery = new MaterialsRequestStatus();
         $statusQuery->isOpen = 1;
         $statusQuery->libraryId = $homeLibrary->libraryId;
         $materialsRequest->joinAdd($statusQuery);
         $materialsRequest->find();
         $profile['numMaterialsRequests'] = $materialsRequest->N;
     }
     $timer->logTime("Got Patron Profile");
     $this->patronProfiles[$patron['id']] = $profile;
     return $profile;
 }
Esempio n. 10
0
 function MaterialsRequestDetails()
 {
     global $interface;
     if (!isset($_REQUEST['id'])) {
         $interface->assign('error', 'Please provide an id of the materials request to view.');
     } else {
         $id = $_REQUEST['id'];
         $materialsRequest = new MaterialsRequest();
         $materialsRequest->id = $id;
         $statusQuery = new MaterialsRequestStatus();
         $materialsRequest->joinAdd($statusQuery);
         $locationQuery = new Location();
         $materialsRequest->joinAdd($locationQuery, "LEFT");
         $materialsRequest->selectAdd();
         $materialsRequest->selectAdd('materials_request.*, description as statusLabel, location.displayName as location');
         if ($materialsRequest->find(true)) {
             $interface->assign('materialsRequest', $materialsRequest);
             global $user;
             if ($user && $user->hasRole('cataloging') || $user->hasRole('library_material_requests')) {
                 $interface->assign('showUserInformation', true);
                 //Load user information
                 $requestUser = new User();
                 $requestUser->id = $materialsRequest->createdBy;
                 if ($requestUser->find(true)) {
                     $interface->assign('requestUser', $requestUser);
                 }
             } else {
                 $interface->assign('showUserInformation', false);
             }
         } else {
             $interface->assign('error', 'Sorry, we couldn\'t find a materials request for that id.');
         }
     }
     $return = array('title' => 'Materials Request Details', 'modalBody' => $interface->fetch('MaterialsRequest/ajax-request-details.tpl'), 'modalButtons' => '');
     return $return;
 }
Esempio n. 11
0
 /**
  * Get Patron Profile
  *
  * This is responsible for retrieving the profile for a specific patron.
  * Interface defined in CatalogConnection.php
  *
  * @param   array   $patron     The patron array
  * @param   boolean $forceReload Whether or not we should force a reload of the data
  * @return  array               Array of the patron's profile data
  *                              If an error occurs, return a PEAR_Error
  * @access  public
  */
 public function getMyProfile($patron, $forceReload = false)
 {
     global $timer;
     global $configArray;
     /** @var Memcache $memCache */
     global $memCache;
     global $serverName;
     $memCacheProfileKey = "patronProfile_{$serverName}_";
     if (is_object($patron)) {
         $patron = get_object_vars($patron);
         $memCacheProfileKey .= $patron['username'];
         $id2 = $this->_getBarcode($patron);
     } else {
         global $user;
         $memCacheProfileKey .= $user->username;
         $id2 = $patron['cat_password'];
     }
     if (!$forceReload && !isset($_REQUEST['reload'])) {
         $patronProfile = $memCache->get($memCacheProfileKey);
         if ($patronProfile) {
             $timer->logTime('Retrieved Cached Profile for Patron');
             return $patronProfile;
         }
     }
     global $user;
     if ($configArray['Catalog']['offline'] == true) {
         $fullName = $patron['cat_username'];
         $Address1 = "";
         $City = "";
         $State = "";
         $Zip = "";
         $finesVal = 0;
         $expireClose = false;
         $homeBranchCode = '';
         $numHoldsAvailable = '?';
         $numHoldsRequested = '?';
         if (!$user) {
             $user = new User();
             $user->cat_password = $id2;
             if ($user->find(true)) {
                 $location = new Location();
                 $location->locationId = $user->homeLocationId;
                 $location->find(1);
                 $homeBranchCode = $location->code;
             }
         }
     } else {
         //Load the raw information about the patron
         $patronDump = $this->_getPatronDump($id2);
         if (isset($patronDump['ADDRESS'])) {
             $fullAddress = $patronDump['ADDRESS'];
             $addressParts = explode('$', $fullAddress);
             $Address1 = $addressParts[0];
             $City = isset($addressParts[1]) ? $addressParts[1] : '';
             $State = isset($addressParts[2]) ? $addressParts[2] : '';
             $Zip = isset($addressParts[3]) ? $addressParts[3] : '';
             if (preg_match('/(.*?),\\s+(.*)\\s+(\\d*(?:-\\d*)?)/', $City, $matches)) {
                 $City = $matches[1];
                 $State = $matches[2];
                 $Zip = $matches[3];
             } else {
                 if (preg_match('/(.*?)\\s+(\\w{2})\\s+(\\d*(?:-\\d*)?)/', $City, $matches)) {
                     $City = $matches[1];
                     $State = $matches[2];
                     $Zip = $matches[3];
                 }
             }
         } else {
             $Address1 = "";
             $City = "";
             $State = "";
             $Zip = "";
         }
         $fullName = $patronDump['PATRN_NAME'];
         //Get additional information about the patron's home branch for display.
         $location = null;
         if (isset($patronDump['HOME_LIBR']) || isset($patronDump['HOLD_LIBR'])) {
             $homeBranchCode = isset($patronDump['HOME_LIBR']) ? $patronDump['HOME_LIBR'] : $patronDump['HOLD_LIBR'];
             $homeBranchCode = str_replace('+', '', $homeBranchCode);
             //Translate home branch to plain text
             $location = new Location();
             $location->whereAdd("code = '{$homeBranchCode}'");
             $location->find(1);
             if ($location->N == 0) {
                 unset($location);
             }
         }
         if ($user) {
             if (isset($location)) {
                 if ($user->homeLocationId == 0) {
                     $user->homeLocationId = $location->locationId;
                     if ($location->nearbyLocation1 > 0) {
                         $user->myLocation1Id = $location->nearbyLocation1;
                     } else {
                         $user->myLocation1Id = $location->locationId;
                     }
                     if ($location->nearbyLocation2 > 0) {
                         $user->myLocation2Id = $location->nearbyLocation2;
                     } else {
                         $user->myLocation2Id = $location->locationId;
                     }
                     if ($user instanceof User) {
                         //Update the database
                         $user->update();
                         //Update the serialized instance stored in the session
                         $_SESSION['userinfo'] = serialize($user);
                     }
                 } else {
                     if ($location->locationId != $user->homeLocationId) {
                         $user->homeLocationId = $location->locationId;
                         //Update the database
                         $user->update();
                         //Update the serialized instance stored in the session
                         $_SESSION['userinfo'] = serialize($user);
                     }
                 }
             }
         }
         //see if expiration date is close
         if (trim($patronDump['EXP_DATE']) != '-  -') {
             list($monthExp, $dayExp, $yearExp) = explode("-", $patronDump['EXP_DATE']);
             $timeExpire = strtotime($monthExp . "/" . $dayExp . "/" . $yearExp);
             $timeNow = time();
             $timeToExpire = $timeExpire - $timeNow;
             $expired = 0;
             if ($timeToExpire <= 30 * 24 * 60 * 60) {
                 if ($timeToExpire <= 0) {
                     $expired = 1;
                 }
                 $expireClose = 1;
             } else {
                 $expireClose = 0;
             }
         } else {
             $expired = 0;
             $expireClose = 0;
         }
         $finesVal = floatval(preg_replace('/[^\\d.]/', '', $patronDump['MONEY_OWED']));
         $numHoldsAvailable = 0;
         $numHoldsRequested = 0;
         $availableStatusRegex = isset($configArray['Catalog']['patronApiAvailableHoldsRegex']) ? $configArray['Catalog']['patronApiAvailableHoldsRegex'] : "/ST=(105|98),/";
         if (isset($patronDump) && isset($patronDump['HOLD']) && count($patronDump['HOLD']) > 0) {
             foreach ($patronDump['HOLD'] as $hold) {
                 if (preg_match("{$availableStatusRegex}", $hold)) {
                     $numHoldsAvailable++;
                 } else {
                     $numHoldsRequested++;
                 }
             }
         }
     }
     $nameParts = explode(', ', $fullName);
     $lastName = $nameParts[0];
     $secondName = isset($nameParts[1]) ? $nameParts[1] : '';
     if (strpos($secondName, ' ')) {
         $nameParts2 = explode(' ', $secondName);
         $firstName = $nameParts2[0];
     } else {
         $firstName = $secondName;
     }
     if ($user) {
         //Get display name for preferred location 1
         $myLocation1 = new Location();
         $myLocation1->whereAdd("locationId = '{$user->myLocation1Id}'");
         $myLocation1->find(1);
         //Get display name for preferred location 1
         $myLocation2 = new Location();
         $myLocation2->whereAdd("locationId = '{$user->myLocation2Id}'");
         $myLocation2->find(1);
     }
     $noticeLabels = array('-' => '', 'a' => 'Mail', 'p' => 'Telephone', 'z' => 'E-mail');
     $profile = array('lastname' => $lastName, 'firstname' => $firstName, 'fullname' => $fullName, 'address1' => $Address1, 'address2' => $City . ', ' . $State, 'city' => $City, 'state' => $State, 'zip' => $Zip, 'email' => $user && $user->email ? $user->email : (isset($patronDump) && isset($patronDump['EMAIL_ADDR']) ? $patronDump['EMAIL_ADDR'] : ''), 'overdriveEmail' => $user ? $user->overdriveEmail : (isset($patronDump) && isset($patronDump['EMAIL_ADDR']) ? $patronDump['EMAIL_ADDR'] : ''), 'promptForOverdriveEmail' => $user ? $user->promptForOverdriveEmail : 1, 'phone' => isset($patronDump) && isset($patronDump['TELEPHONE']) ? $patronDump['TELEPHONE'] : (isset($patronDump['HOME_PHONE']) ? $patronDump['HOME_PHONE'] : ''), 'workPhone' => isset($patronDump) && isset($patronDump['G/WK_PHONE']) ? $patronDump['G/WK_PHONE'] : '', 'mobileNumber' => isset($patronDump) && isset($patronDump['MOBILE_NO']) ? $patronDump['MOBILE_NO'] : '', 'fines' => isset($patronDump) ? $patronDump['MONEY_OWED'] : '0', 'finesval' => $finesVal, 'expires' => isset($patronDump) ? $patronDump['EXP_DATE'] : '', 'expireclose' => $expireClose, 'expired' => $expired, 'homeLocationCode' => isset($homeBranchCode) ? trim($homeBranchCode) : '', 'homeLocationId' => isset($location) ? $location->locationId : 0, 'homeLocation' => isset($location) ? $location->displayName : '', 'myLocation1Id' => $user ? $user->myLocation1Id : -1, 'myLocation1' => isset($myLocation1) ? $myLocation1->displayName : '', 'myLocation2Id' => $user ? $user->myLocation2Id : -1, 'myLocation2' => isset($myLocation2) ? $myLocation2->displayName : '', 'numCheckedOut' => isset($patronDump) ? $patronDump['CUR_CHKOUT'] : '?', 'numHolds' => isset($patronDump) ? isset($patronDump['HOLD']) ? count($patronDump['HOLD']) : 0 : '?', 'numHoldsAvailable' => $numHoldsAvailable, 'numHoldsRequested' => $numHoldsRequested, 'bypassAutoLogout' => $user ? $user->bypassAutoLogout : 0, 'ptype' => $user && $user->patronType ? $user->patronType : (isset($patronDump) ? $patronDump['P_TYPE'] : 0), 'notices' => isset($patronDump) ? $patronDump['NOTICE_PREF'] : '-', 'web_note' => isset($patronDump) ? isset($patronDump['WEB_NOTE']) ? $patronDump['WEB_NOTE'] : '' : '');
     if (array_key_exists($profile['notices'], $noticeLabels)) {
         $profile['noticePreferenceLabel'] = $noticeLabels[$profile['notices']];
     } else {
         $profile['noticePreferenceLabel'] = 'Unknown';
     }
     //Get eContent info as well
     require_once ROOT_DIR . '/Drivers/EContentDriver.php';
     $eContentDriver = new EContentDriver();
     $eContentAccountSummary = $eContentDriver->getAccountSummary();
     $profile = array_merge($profile, $eContentAccountSummary);
     require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
     $overDriveDriver = OverDriveDriverFactory::getDriver();
     if ($overDriveDriver->isUserValidForOverDrive($user)) {
         $overDriveSummary = $overDriveDriver->getOverDriveSummary($user);
         $profile['numOverDriveCheckedOut'] = $overDriveSummary['numCheckedOut'];
         $profile['numOverDriveHoldsAvailable'] = $overDriveSummary['numAvailableHolds'];
         $profile['numOverDriveHoldsRequested'] = $overDriveSummary['numUnavailableHolds'];
         $profile['canUseOverDrive'] = true;
     } else {
         $profile['numOverDriveCheckedOut'] = 0;
         $profile['numOverDriveHoldsAvailable'] = 0;
         $profile['numOverDriveHoldsRequested'] = 0;
         $profile['canUseOverDrive'] = false;
     }
     $profile['numCheckedOutTotal'] = $profile['numCheckedOut'] + $profile['numOverDriveCheckedOut'] + $eContentAccountSummary['numEContentCheckedOut'];
     $profile['numHoldsAvailableTotal'] = $profile['numHoldsAvailable'] + $profile['numOverDriveHoldsAvailable'] + $eContentAccountSummary['numEContentAvailableHolds'];
     $profile['numHoldsRequestedTotal'] = $profile['numHoldsRequested'] + $profile['numOverDriveHoldsRequested'] + $eContentAccountSummary['numEContentUnavailableHolds'];
     $profile['numHoldsTotal'] = $profile['numHoldsAvailableTotal'] + $profile['numHoldsRequestedTotal'];
     //Get a count of the materials requests for the user
     if ($user) {
         $materialsRequest = new MaterialsRequest();
         $materialsRequest->createdBy = $user->id;
         $homeLibrary = Library::getPatronHomeLibrary();
         $statusQuery = new MaterialsRequestStatus();
         $statusQuery->isOpen = 1;
         $statusQuery->libraryId = $homeLibrary->libraryId;
         $materialsRequest->joinAdd($statusQuery);
         $materialsRequest->find();
         $profile['numMaterialsRequests'] = $materialsRequest->N;
     }
     $timer->logTime("Got Patron Profile");
     $memCache->set($memCacheProfileKey, $profile, 0, $configArray['Caching']['patron_profile']);
     return $profile;
 }
Esempio n. 12
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     //Make sure that the user is valid
     $processForm = true;
     if (!$user) {
         $user = UserAccount::login();
         if ($user == null) {
             $interface->assign('error', 'Sorry, we could not log you in.  Please enter a valid barcode and pin number submit a materials request.');
             $processForm = false;
         }
     }
     if ($processForm) {
         //Check to see if the user type is ok to submit a request
         $enableMaterialsRequest = true;
         if (isset($configArray['MaterialsRequest']['allowablePatronTypes'])) {
             //Check to see if we need to do additonal restrictions by patron type
             $allowablePatronTypes = $configArray['MaterialsRequest']['allowablePatronTypes'];
             if (strlen($allowablePatronTypes) > 0 && $user) {
                 if (!preg_match("/^{$allowablePatronTypes}\$/i", $user->patronType)) {
                     $enableMaterialsRequest = false;
                 }
             }
         }
         if (!$enableMaterialsRequest) {
             $interface->assign('success', false);
             $interface->assign('error', 'Sorry, only residents may submit materials requests at this time.');
         } else {
             if ($_REQUEST['format'] == 'article' && $_REQUEST['acceptCopyright'] != 1) {
                 $interface->assign('success', false);
                 $interface->assign('error', 'Sorry, you must accept the copyright agreement before submitting a materials request.');
             } else {
                 //Check to see how many active materials request results the user has already.
                 $materialsRequest = new MaterialsRequest();
                 $materialsRequest->createdBy = $user->id;
                 $statusQuery = new MaterialsRequestStatus();
                 $homeLibrary = Library::getPatronHomeLibrary();
                 $statusQuery->libraryId = $homeLibrary->libraryId;
                 $statusQuery->isOpen = 1;
                 $materialsRequest->joinAdd($statusQuery);
                 $materialsRequest->selectAdd();
                 $materialsRequest->selectAdd('materials_request.*, description as statusLabel');
                 $materialsRequest->find();
                 if ($materialsRequest->N >= 5) {
                     $interface->assign('success', false);
                     $interface->assign('error', "You\\'ve already reached your maximum limit of five requests open at one time. Once we've processed your existing requests, you'll be able to submit again. To check the status of your current requests, visit your account page [link to account page].");
                 } else {
                     //Materials request can be submitted.
                     $materialsRequest = new MaterialsRequest();
                     $materialsRequest->phone = isset($_REQUEST['phone']) ? strip_tags($_REQUEST['phone']) : '';
                     $materialsRequest->email = strip_tags($_REQUEST['email']);
                     $materialsRequest->title = strip_tags($_REQUEST['title']);
                     $materialsRequest->season = isset($_REQUEST['season']) ? strip_tags($_REQUEST['season']) : '';
                     $materialsRequest->magazineTitle = isset($_REQUEST['magazineTitle']) ? strip_tags($_REQUEST['magazineTitle']) : '';
                     $materialsRequest->magazineDate = isset($_REQUEST['magazineDate']) ? strip_tags($_REQUEST['magazineDate']) : '';
                     $materialsRequest->magazineVolume = isset($_REQUEST['magazineVolume']) ? strip_tags($_REQUEST['magazineVolume']) : '';
                     $materialsRequest->magazineNumber = isset($_REQUEST['magazineNumber']) ? strip_tags($_REQUEST['magazineNumber']) : '';
                     $materialsRequest->magazinePageNumbers = isset($_REQUEST['magazinePageNumbers']) ? strip_tags($_REQUEST['magazinePageNumbers']) : '';
                     $materialsRequest->author = strip_tags($_REQUEST['author']);
                     $materialsRequest->format = strip_tags($_REQUEST['format']);
                     if ($materialsRequest->format == 'ebook' && isset($_REQUEST['ebookFormat'])) {
                         $materialsRequest->subFormat = strip_tags($_REQUEST['ebookFormat']);
                     } elseif ($materialsRequest->format == 'eaudio' && isset($_REQUEST['eaudioFormat'])) {
                         $materialsRequest->subFormat = strip_tags($_REQUEST['eaudioFormat']);
                     }
                     $materialsRequest->subFormat = isset($_REQUEST['subFormat']) ? strip_tags($_REQUEST['subFormat']) : '';
                     $materialsRequest->ageLevel = isset($_REQUEST['ageLevel']) ? strip_tags($_REQUEST['ageLevel']) : '';
                     $materialsRequest->bookType = isset($_REQUEST['bookType']) ? strip_tags($_REQUEST['bookType']) : '';
                     $materialsRequest->isbn = isset($_REQUEST['isbn']) ? strip_tags($_REQUEST['isbn']) : '';
                     $materialsRequest->upc = isset($_REQUEST['upc']) ? strip_tags($_REQUEST['upc']) : '';
                     $materialsRequest->issn = isset($_REQUEST['issn']) ? strip_tags($_REQUEST['issn']) : '';
                     $materialsRequest->oclcNumber = isset($_REQUEST['oclcNumber']) ? strip_tags($_REQUEST['oclcNumber']) : '';
                     $materialsRequest->publisher = strip_tags($_REQUEST['publisher']);
                     $materialsRequest->publicationYear = strip_tags($_REQUEST['publicationYear']);
                     if (isset($_REQUEST['abridged'])) {
                         if ($_REQUEST['abridged'] == 'abridged') {
                             $materialsRequest->abridged = 1;
                         } elseif ($_REQUEST['abridged'] == 'unabridged') {
                             $materialsRequest->abridged = 0;
                         } else {
                             $materialsRequest->abridged = 2;
                             //Not applicable
                         }
                     }
                     $materialsRequest->about = strip_tags($_REQUEST['about']);
                     $materialsRequest->comments = strip_tags($_REQUEST['comments']);
                     if (isset($_REQUEST['placeHoldWhenAvailable'])) {
                         $materialsRequest->placeHoldWhenAvailable = $_REQUEST['placeHoldWhenAvailable'];
                     } else {
                         $materialsRequest->placeHoldWhenAvailable = 0;
                     }
                     if (isset($_REQUEST['holdPickupLocation'])) {
                         $materialsRequest->holdPickupLocation = $_REQUEST['holdPickupLocation'];
                     }
                     if (isset($_REQUEST['bookmobileStop'])) {
                         $materialsRequest->bookmobileStop = $_REQUEST['bookmobileStop'];
                     }
                     if (isset($_REQUEST['illItem'])) {
                         $materialsRequest->illItem = $_REQUEST['illItem'];
                     } else {
                         $materialsRequest->illItem = 0;
                     }
                     $defaultStatus = new MaterialsRequestStatus();
                     $defaultStatus->isDefault = 1;
                     $userLibraryId = Library::getPatronHomeLibrary();
                     $defaultStatus->libraryId = $userLibraryId->libraryId;
                     if (!$defaultStatus->find(true)) {
                         $interface->assign('success', false);
                         $interface->assign('error', 'There was an error submitting your materials request, could not determine the default status.');
                     } else {
                         $materialsRequest->status = $defaultStatus->id;
                         $materialsRequest->dateCreated = time();
                         $materialsRequest->createdBy = $user->id;
                         $materialsRequest->dateUpdated = time();
                         if ($materialsRequest->insert()) {
                             $interface->assign('success', true);
                             $interface->assign('materialsRequest', $materialsRequest);
                         } else {
                             $interface->assign('success', false);
                             $interface->assign('error', 'There was an error submitting your materials request.');
                         }
                     }
                 }
             }
         }
     }
     $interface->setTemplate('submission-result.tpl');
     $interface->setPageTitle('Submission Result');
     $interface->display('layout.tpl');
 }