From 02488ed35d174b1fe0a85f9d178d10fa6cdb2f95 Mon Sep 17 00:00:00 2001 From: efalcy <efalcy@afi-sa.fr> Date: Wed, 30 Sep 2015 16:57:50 +0200 Subject: [PATCH] dev#25588 compte utilisateur historique de prets provenant de koha refactoring of loans rendering --- .../opac/controllers/AbonneController.php | 1 - .../opac/views/scripts/abonne/prets.phtml | 105 ++---------------- library/ZendAfi/View/Helper/Abonne/Loans.php | 91 +++++++++++++++ public/opac/css/global.css | 26 +++++ 4 files changed, 125 insertions(+), 98 deletions(-) create mode 100644 library/ZendAfi/View/Helper/Abonne/Loans.php diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index 6d514e3f400..4a69fd25849 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -357,7 +357,6 @@ class AbonneController extends ZendAfi_Controller_Action { public function pretsAction() { $this->view->fiche = $this->_user->getFicheSigb(); $this->view->user = $this->_user; - Class_ScriptLoader::getInstance()->loadTableSorter(); } diff --git a/application/modules/opac/views/scripts/abonne/prets.phtml b/application/modules/opac/views/scripts/abonne/prets.phtml index b37308a5d00..55180842709 100644 --- a/application/modules/opac/views/scripts/abonne/prets.phtml +++ b/application/modules/opac/views/scripts/abonne/prets.phtml @@ -1,112 +1,23 @@ <?php $this->openBoite('Prêts en cours');?> <div class="abonneTitre"><?php echo $this->fiche['nom_aff'];?></div> <?php -// messages + foreach (['message', 'error'] as $type) if (isset($this->fiche[$type]) && $this->fiche[$type]) echo '<p class="error">' . $this->fiche[$type] . '</p>'; -?> -<?php + if ($emprunts = $this->user->getEmprunts()) { echo $this->abonne_LoanExport(); } -?> -<table width="100%" class="tablesorter"> - <thead> - <tr> - <th style="text-align:left; white-space:nowrap"><?php echo $this->_('n°'); ?></th> - <th style="text-align:left"><?php echo $this->_('Titre'); ?></th> - <th style="text-align:left"><?php echo $this->_('Auteur'); ?></th> - <th style="text-align:left"><?php echo $this->_('Bibliothèque'); ?></th> - <th style="text-align:center"><?php echo $this->_('Retour prévu'); ?></th> - <th style="text-align:center"><?php echo $this->_('Informations'); ?></th> - </tr> - </thead> - <tbody> - <?php - $num = 1; - foreach ($this->user->getLoansWithOutPNB() as $emprunt) { - $class_retard = $emprunt->isLate() ? 'class="pret_en_retard"' : '';?> - <tr <?php echo $class_retard;?>> - <td width="15px" align="center"><b><?php echo $num++;?></b></td> - <td> - <?php - echo $this->tagAnchor( - $this->url(['controller' => 'recherche', - 'action' => 'viewnotice', - 'id' => $emprunt->getNoticeOPACId(), - 'retour_abonne' => 'prets'], - null, true), - $emprunt->getTitre()); - ?></td> - <td><?php echo $emprunt->getAuteur();?></td> - <td><?php echo $emprunt->getBibliotheque();?></td> - <td class="date_retour"> - <?php - echo $emprunt->getDateRetour() . ' '; - echo $this->abonne_LoanAction($emprunt); - ?> - </td> - <td><?php echo $emprunt->getType();?></td> - </tr> - <?php } ?> - </tbody> -</table> -<br/> -<br/> +echo $this->abonne_Loans($this->user->getLoansWithOutPNB()); -<?php if($this->user->hasPNB()) { -?> -<h2><?php echo $this->_('Prêts numériques en cours'); ?></h2> -<table width="100%" class="tablesorter"> - <thead> - <tr> - <th style="text-align:left; white-space:nowrap"><?php echo $this->_('n°'); ?></th> - <th style="text-align:left"><?php echo $this->_('Titre'); ?></th> - <th style="text-align:left"><?php echo $this->_('Auteur'); ?></th> - <th style="text-align:left"><?php echo $this->_('Bibliothèque'); ?></th> - <th style="text-align:center"><?php echo $this->_('Retour prévu'); ?></th> - <th style="text-align:center"><?php echo $this->_('Informations'); ?></th> - </tr> - </thead> - <tbody> - <?php - $num = 1; - foreach ($this->user->getPNBLoans() as $emprunt) { - $class_retard = $emprunt->isLate() ? 'class="pret_en_retard"' : '';?> - <tr <?php echo $class_retard;?>> - <td width="15px" align="center"><b><?php echo $num++;?></b></td> - <td> - <?php - echo $this->tagAnchor( - $this->url(['controller' => 'recherche', - 'action' => 'viewnotice', - 'id' => $emprunt->getNoticeOPACId(), - 'retour_abonne' => 'prets'], - null, true), - $emprunt->getTitre()); - ?></td> - <td><?php echo $emprunt->getAuteur();?></td> - <td><?php echo $emprunt->getBibliotheque();?></td> - <td class="date_retour"> - <?php - echo $emprunt->getDateRetour() . ' '; - echo $this->abonne_LoanAction($emprunt); - ?> - </td> - <td><?php echo $emprunt->getType();?></td> - </tr> - <?php } ?> - </tbody> -</table> -<?php + echo $this->tag('h2', $this->_('Prêts numériques en cours')); + echo $this->abonne_Loans($this->user->getPNBLoans()); } -?> -<?php $this->closeBoite(); ?> -<?php echo $this->abonne_RetourFiche(); ?> -<br/> -<br/> +$this->closeBoite(); +echo $this->abonne_RetourFiche(); +?> diff --git a/library/ZendAfi/View/Helper/Abonne/Loans.php b/library/ZendAfi/View/Helper/Abonne/Loans.php new file mode 100644 index 00000000000..1694f58c85b --- /dev/null +++ b/library/ZendAfi/View/Helper/Abonne/Loans.php @@ -0,0 +1,91 @@ +<?php +/** + * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +class ZendAfi_View_Helper_Abonne_Loans extends ZendAfi_View_Helper_BaseHelper { + protected + $_line_no; + + public function abonne_Loans($loans) { + Class_ScriptLoader::getInstance()->loadTableSorter(); + return + $this->_tag('table', + $this->renderHeader() + . $this->renderLoans($loans), + ['width' => '100%', + 'class' => 'tablesorter loans']); + } + + + + protected function renderHeader() { + $headers = array_map( + function($title) { + return $this->_tag('th', $title); + }, + + [$this->_('n°'), + $this->_('Titre'), + $this->_('Auteur'), + $this->_('Bibliothèque'), + $this->_('Retour prévu'), + $this->_('Informations')]); + + return $this->_tag('thead', + $this->_tag('tr', + implode('', $headers))); + } + + + protected function renderLoans($loans) { + $this->_line_no = 1; + + $html = ''; + foreach($loans as $loan) + $html .= $this->renderLoan($loan); + + return $this->_tag('tbody', $html); + } + + + protected function renderLoan($loan) { + $class_retard = $loan->isLate() ? 'class="pret_en_retard"' : ''; + return + $this->_tag('tr', + + $this->_tag('td', $this->_line_no++) + . $this->_tag('td', + $this->view->tagAnchor( + $this->view->url(['controller' => 'recherche', + 'action' => 'viewnotice', + 'id' => $loan->getNoticeOPACId(), + 'retour_abonne' => 'prets'], + null, true), + $loan->getTitre())) + . $this->_tag('td', $loan->getAuteur()) + . $this->_tag('td', $loan->getBibliotheque()) + . $this->_tag('td', + $loan->getDateRetour() . ' ' . $this->view->abonne_LoanAction($loan), + ['class' => 'date_retour']) + . $this->_tag('td', $loan->getType()), + $loan->isLate() ? ['class' => 'pret_en_retard'] : []); + } +} \ No newline at end of file diff --git a/public/opac/css/global.css b/public/opac/css/global.css index 664a91ef33b..348487690c1 100644 --- a/public/opac/css/global.css +++ b/public/opac/css/global.css @@ -610,6 +610,32 @@ form#calendar_select_categorie { } +/* loans in patron screen */ +table.loans { + margin-bottom: 30px; +} + +table.loans th { + text-align:left; +} + +table.loans th:first-child { + white-space: nowrap; +} + + +table.loans th:nth-child(5), +table.loans th:nth-child(6) { + text-align: center; +} + + +table.loans td:first-child { + width: 15px; + font-weight: bold; + text-align: center; +} + /* Formulaires */ .zend_form { background-color:#F0F0F0; -- GitLab