private function invDataFetch($barcodeStr) { try { $bookHelper = new \Babesk\Schbas\Book($this->_dataContainer); $barcode = $bookHelper->barcodeParseToArray($barcodeStr); unset($barcode['delimiter']); //Not used in query $query = $this->_em->createQuery('SELECT i, b, s, u FROM DM:SchbasInventory i INNER JOIN i.book b WITH b.class = :class AND b.bundle = :bundle INNER JOIN b.subject s WITH s.abbreviation = :subject LEFT JOIN i.usersLent u WHERE i.yearOfPurchase = :purchaseYear AND i.exemplar = :exemplar ')->setParameters($barcode); return $query->getOneOrNullResult(); } catch (Exception $e) { $this->_logger->log('Error fetching the bookinfo', 'Notice', Null, json_encode(array('barcode' => $barcode, 'msg' => $e->getMessage(), 'type' => get_class($e)))); $this->_interface->dieError('Fehler beim Abrufen des Buches.'); } }
/** * Checks if the book-exemplar is already lent to a user * @param string $barcode The Barcode of the exemplar * @return bool true if it is lent */ private function exemplarByBarcodeGet($barcodeStr) { $bookHelper = new \Babesk\Schbas\Book($this->_dataContainer); $barcode = $bookHelper->barcodeParseToArray($barcodeStr); //$barcodeStr = $this->barcodeNormalize($barcodeStr); //$barcode = $this->barcodeParseToArray($barcodeStr); //Delimiter not used in Query unset($barcode['delimiter']); $query = $this->_em->createQuery('SELECT i, b FROM DM:SchbasInventory i INNER JOIN i.book b WITH b.class = :class AND b.bundle = :bundle INNER JOIN b.subject s WITH s.abbreviation = :subject WHERE i.yearOfPurchase = :purchaseYear AND i.exemplar = :exemplar ')->setParameters($barcode); try { $lent = $query->getSingleResult(); } catch (\Doctrine\ORM\NoResultException $e) { return false; } return $lent; }