Skip to content
Snippets Groups Projects
Commit 2437e7e6 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev #22654 pnb loan

improve display counters
parent a400e1d3
Branches
Tags
3 merge requests!896Master,!792Dev#22657 pnb display user account,!783Dev#22657 pnb display user account
......@@ -28,6 +28,8 @@ class ZendAfi_View_Helper_TagDilicomWidget extends Zend_View_Helper_HtmlElement
$this->_album = $album;
(new Class_WebService_BibNumerique_Dilicom_Hub())->updateStatus($album);
$infos = $this->view->tag('p', $this->getInfos());
$iframe = $this->view->tag('iframe',
null,
['src' => $this->_album->getExternalURI(),
......@@ -37,7 +39,8 @@ class ZendAfi_View_Helper_TagDilicomWidget extends Zend_View_Helper_HtmlElement
$links = $this->view->tag('p', $this->view->_('Vous devez vous connecter pour accéder à la consultation en ligne.'));
if(($this->_user = Class_Users::getIdentity()) && ($this->_user->hasRightAccessDilicom()))
$links = $this->getConsultBookAnchor()
$links = $infos
. $this->getConsultBookAnchor()
. $this->getLoanBookAnchor()
. $this->getEndLoanBookAnchor();
......@@ -47,23 +50,13 @@ class ZendAfi_View_Helper_TagDilicomWidget extends Zend_View_Helper_HtmlElement
protected function getConsultBookAnchor() {
return $this->getDilicomAnchor('consult-book',
$this->view->_('Consulter le livre en ligne'));
$this->view->_('Consulter le livre en ligne'), ['target' => '_blank']);
}
protected function getLoanBookAnchor() {
$item = Class_Album_Item::findFirstBy(['album_id' => $this->_album->getId()]);
$infos = sprintf('Nombre d\'emprunts total: %d / %d, Nombre d\'emprunts en cours: %d / %d',
$item->getQuantity(),
$this->_album->getUsageConstraints()->getLoanQuantity(),
$item->getLoanCount(),
$this->_album->getUsageConstraints()->getLoanMaxNumberOfUsers());
if(!$this->_album->getUsageConstraints()->isLoanable())
return $infos;
return $infos . $this->getDilicomAnchor('loan-book',
$this->view->_('Emprunter le livre au format EPUB'));
return $this->getDilicomAnchor('loan-book',
$this->view->_('Emprunter le livre au format EPUB'));
}
......@@ -76,13 +69,25 @@ class ZendAfi_View_Helper_TagDilicomWidget extends Zend_View_Helper_HtmlElement
}
protected function getDilicomAnchor($action, $label) {
protected function getInfos() {
$item = Class_Album_Item::findFirstBy(['album_id' => $this->_album->getId()]);
return sprintf('Nombre d\'emprunts total: %d / %d, Nombre d\'emprunts en cours: %d / %d',
$item->getQuantity(),
$this->_album->getUsageConstraints()->getLoanQuantity(),
$item->getLoanCount(),
$this->_album->getUsageConstraints()->getLoanMaxNumberOfUsers());
}
protected function getDilicomAnchor($action, $label, $attribs = []) {
return $this->view->tag('div',
$this->view->tagAnchor(['controller' => 'bib-numerique',
'action' => $action,
'id' => $this->_album->getId()],
$label,
[]));
array_merge(['style' => 'padding: 5px;margin: 5px; border: 1px solid #aaa; border-radius: 3px;display: inline-block;'],
$attribs)));
}
}
?>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment