Пример #1
0
 /**
  * Send list of ill requests to view
  *
  * @return mixed
  */
 public function illRequestsAction()
 {
     // Stop now if the user does not have valid catalog credentials available:
     if (!is_array($patron = $this->catalogLogin())) {
         return $patron;
     }
     $view = $this->createViewIfUnsupported('ILLRequests', true);
     if ($view === false) {
         $view = parent::illRequestsAction();
         $view->recordList = $this->orderAvailability($view->recordList);
         $view->profile = $this->getCatalogProfile();
     }
     return $view;
 }
Пример #2
0
 public function illRequestsAction()
 {
     if (!is_array($patron = $this->catalogLogin())) {
         return $patron;
     }
     if ($type = $this->params()->fromQuery('new')) {
         $fields = array();
         if ($type == 'monography') {
             $fields = $this->getILLRequestFieldsForMonography();
         } else {
             if ($type == 'serial') {
                 $fields = $this->getILLRequestFieldsForSerial();
             }
         }
         $missingValues = false;
         $fromPost = $this->params()->fromPost('placeIll');
         $details = array();
         if ($fromPost) {
             $allFields = array();
             foreach ($fields as $group => &$subfields) {
                 foreach ($subfields as $name => &$attributes) {
                     $attributes['missing'] = false;
                     $attributes['value'] = '';
                     $value = $this->params()->fromPost($name);
                     if ($value && trim($value) != '') {
                         $attributes['value'] = $value;
                         $details[$name] = $value;
                         if ($attributes['type'] == 'date') {
                             $converter = $this->getServiceLocator()->get('VuFind\\DateConverter');
                             try {
                                 $converter->convertFromDisplayDate('Ymd', $value);
                             } catch (\VuFind\Exception\Date $de) {
                                 $attributes['missing'] = true;
                                 $this->flashMessenger()->setNamespace('error')->addMessage('invalid_date_format');
                             }
                         }
                     } else {
                         if ($attributes['required']) {
                             $attributes['missing'] = true;
                             $missingValues = true;
                         }
                     }
                 }
             }
         }
         if ($missingValues) {
             $this->flashMessenger()->setNamespace('error')->addMessage('ill_required_fields_missing_error');
         } else {
             if ($fromPost) {
                 if ($details['hmac'] != $this->getHMAC()) {
                     $this->flashMessenger()->setNamespace('info')->addMessage('ill_request_failed_due_to_hmac');
                 } else {
                     $details['new'] = $type;
                     $result = $this->getILS()->placeILLRequest($patron, $details);
                     if ($result['success']) {
                         $this->flashMessenger()->setNamespace('info')->addMessage('ill_request_successful');
                         return $this->redirect()->toRoute('myresearch-illrequests');
                     } else {
                         $this->flashMessenger()->setNamespace('info')->addMessage('ill_request_failed');
                     }
                 }
             }
         }
         $view = $this->createViewModel(array('fields' => $fields));
         $view->setTemplate('myresearch/illrequest-new');
         $this->flashExceptions($this->flashMessenger());
         return $view;
     } else {
         return parent::illRequestsAction();
     }
 }