diff --git a/application/modules/opac/views/scripts/abonne/prets.phtml b/application/modules/opac/views/scripts/abonne/prets.phtml index 80cb8ad610ea692746955d5582e84a4afcb04a31..fb37993f4dbf65b12d4beb1c2de999e7a2d26e41 100644 --- a/application/modules/opac/views/scripts/abonne/prets.phtml +++ b/application/modules/opac/views/scripts/abonne/prets.phtml @@ -7,11 +7,10 @@ foreach (['message', 'error'] as $type) echo '<p class="error">' . $this->fiche[$type] . '</p>'; ?> -<?php if (isset($this->fiche['fiche']) - && ($emprunts = $this->fiche['fiche']->getEmprunts()) - && !empty($emprunts)) { - echo $this->abonne_LoanExport(); - } +<?php +if ($emprunts = $this->user->getEmprunts()) { + echo $this->abonne_LoanExport(); +} ?> <table width="100%" class="tablesorter"> @@ -28,9 +27,8 @@ foreach (['message', 'error'] as $type) <tbody> <?php $num = 1; - if (isset($this->fiche['fiche'])) { - foreach ($this->fiche["fiche"]->getEmprunts() as $emprunt) { - $class_retard = $emprunt->enRetard() ? 'class="pret_en_retard"' : '';?> + foreach ($this->user->getEmprunts() as $emprunt) { + $class_retard = $emprunt->enRetard() ? 'class="pret_en_retard"' : '';?> <tr <?php echo $class_retard;?>> <td width="15px" align="center"><b><?php echo $num++;?></b></td> <td> @@ -50,20 +48,19 @@ foreach (['message', 'error'] as $type) <?php if ($emprunt->isRenewable()) $url = $this->url([ - 'action' => 'prolongerPret', - 'id_pret' => $emprunt->getId() - ]); - $attrs = [ - 'data-popup' => 'true', - 'data-popup-refresh' => 'true', - ]; - echo $this->tagAnchor($url, $this->_('Prolonger'), $attrs); + 'action' => 'prolongerPret', + 'id_pret' => $emprunt->getId() + ]); + $attrs = [ + 'data-popup' => 'true', + 'data-popup-refresh' => 'true', + ]; + echo $this->tagAnchor($url, $this->_('Prolonger'), $attrs); ?> </td> <td><?php echo $emprunt->getType();?></td> </tr> - <?php } - } ?> + <?php } ?> </tbody> </table> diff --git a/application/modules/opac/views/scripts/abonne/reservations.phtml b/application/modules/opac/views/scripts/abonne/reservations.phtml index 4d5427ccb582deae8156e363db5eb871c046d0d9..cd657ef8956ef2d5fc9753969ca51e866dc39722 100644 --- a/application/modules/opac/views/scripts/abonne/reservations.phtml +++ b/application/modules/opac/views/scripts/abonne/reservations.phtml @@ -1,6 +1,8 @@ <?php $this->openBoite($this->_('Réservations en cours'));?> -<div class="abonneTitre"><?php echo $this->escape($this->fiche["nom_aff"]);?></div> +<div class="abonneTitre"> + <?php echo $this->escape($this->user->getNomAff());?> +</div> <table width="100%" class="tablesorter"> <thead> @@ -26,8 +28,7 @@ </tr> <?php } ?> <?php - if ($this->fiche["fiche"]) { - $resas = $this->fiche["fiche"]->getReservations(); + $resas = $this->user->getReservations(); $num=1; foreach($resas as $resa) { ?> <tr> @@ -54,7 +55,7 @@ ?> </td> </tr> - <?php }} ?> + <?php } ?> </tbody> </table> diff --git a/application/modules/telephone/controllers/AbonneController.php b/application/modules/telephone/controllers/AbonneController.php index d96639cb8b901cef2c7d8650408f51a9eec97ca0..c5489af89f5aaeda7536d3ededae1ed549287ac0 100644 --- a/application/modules/telephone/controllers/AbonneController.php +++ b/application/modules/telephone/controllers/AbonneController.php @@ -16,7 +16,7 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require_once ROOT_PATH.'application/modules/opac/controllers/AbonneController.php'; @@ -46,9 +46,9 @@ class Telephone_AbonneController extends AbonneController { return; } - $this->_detectReservation($fiche_sigb['fiche']->getReservations()); + $this->_detectReservation($this->_user->getReservations()); - if ($this->view->resa + if ($this->view->resa && $this->_getParam('confirmed')) { $sigb = new Class_CommSigb(); $sigb->supprimerReservation($this->_user, $this->view->resa->getId()); diff --git a/application/modules/telephone/views/scripts/abonne/fiche.phtml b/application/modules/telephone/views/scripts/abonne/fiche.phtml index 2a5e9f6ca4858d2e19935f29659ef80c39e527f2..edeb871e1d2402cf4f19c94d93fc062a8e92278a 100644 --- a/application/modules/telephone/views/scripts/abonne/fiche.phtml +++ b/application/modules/telephone/views/scripts/abonne/fiche.phtml @@ -2,106 +2,104 @@ <?php echo $this->partial('abonne/identity.phtml', array('user' => $this->user));?> <?php if ($this->messages) { ?> -<div data-role="navbar" data-iconpos="left"> - <ul> - <?php foreach($this->messages as $message) { ?> - <li><a href="#" data-icon="info" data-theme="a"><?php echo $this->escape($message);?></a></li> - <?php } ?> - </ul> -</div> + <div data-role="navbar" data-iconpos="left"> + <ul> + <?php foreach($this->messages as $message) { ?> + <li><a href="#" data-icon="info" data-theme="a"><?php echo $this->escape($message);?></a></li> + <?php } ?> + </ul> + </div> <?php } ?> -<?php +<?php if ($this->user->isAbonne()) { $date_fin = formatDate($this->user->getDateFin(), '1'); $message = ($this->user->isAbonnementValid()) ? - "Votre abonnement est valide jusqu'au %s." : - "Votre abonnement est terminé depuis le %s."; + "Votre abonnement est valide jusqu'au %s." : + "Votre abonnement est terminé depuis le %s."; ?> -<ul data-role="listview"> - <li data-role="list-divider"><?php echo $this->_('Abonnement');?></li> - <li><?php echo $this->_($message, $date_fin);?></li> -</ul> + <ul data-role="listview"> + <li data-role="list-divider"><?php echo $this->_('Abonnement');?></li> + <li><?php echo $this->_($message, $date_fin);?></li> + </ul> <?php } ?> -<?php +<?php $fiche_sigb = $this->user->getFicheSigb(); if (array_key_exists("erreur", $fiche_sigb)) { ?> -<div data-role="navbar" data-iconpos="left"> - <ul> - <li><a href="#" data-icon="alert" data-theme="a"><?php echo $this->escape($fiche_sigb["erreur"]);?></a></li> - </ul> -</div> + <div data-role="navbar" data-iconpos="left"> + <ul> + <li><a href="#" data-icon="alert" data-theme="a"><?php echo $this->escape($fiche_sigb["erreur"]);?></a></li> + </ul> + </div> <?php } ?> <?php if (array_key_exists("message", $fiche_sigb)) { ?> -<div data-role="navbar" data-iconpos="left"> - <ul> - <li><a href="#" data-icon="info" data-theme="a"><?php echo $this->escape($fiche_sigb["message"]);?></a></li> - </ul> -</div> + <div data-role="navbar" data-iconpos="left"> + <ul> + <li><a href="#" data-icon="info" data-theme="a"><?php echo $this->escape($fiche_sigb["message"]);?></a></li> + </ul> + </div> <?php } ?> -<?php -if (array_key_exists("fiche", $fiche_sigb)) { - $nb_retards = $fiche_sigb["fiche"]->getNbPretsEnRetard(); - $nb_prets = $fiche_sigb["fiche"]->getNbEmprunts(); - $nb_resas = $fiche_sigb["fiche"]->getNbReservations(); +<?php +$nb_retards = $this->user->getNbEmpruntsRetard(); +$nb_prets = $this->user->getNbEmprunts(); +$nb_resas = $this->user->getNbReservations(); ?> <ul data-role="listview" data-split-icon="forward"> <li data-role="list-divider"><?php echo $this->_('Prêts');?> - <span class="ui-li-count"><?php echo $nb_prets;?></span></li> -<?php if (0 < $nb_prets) { ?> - <?php foreach($fiche_sigb['fiche']->getEmprunts() as $emprunt) { - $class_retard = $emprunt->enRetard() ? 'pret_en_retard"' : '';?> - <li data-icon="false"> - <a <?php echo $emprunt->enRetard() ? 'style="color:red;"' : '';?> - href="<?php echo $this->url(array('controller' => 'recherche', - 'action' => 'viewnotice', - 'id' => $emprunt->getNoticeOPACId()));?>"> - <h3><?php echo $emprunt->getTitre();?></h3> - <p><strong><?php echo $this->escape($emprunt->getAuteur());?></strong></p> - <p><strong><?php echo $this->escape($emprunt->getBibliotheque());?></strong></p> - <p><strong><?php echo $this->_('Retour prévu');?> <?php echo $emprunt->getDateRetour();?></strong></p> - </a> - <?php if ($emprunt->isRenewable()) { ?> - <a href="<?php echo $this->url(array('action' => 'prolongerpret', - 'id_pret' => $emprunt->getId()));?>" - data-theme="c"><?php echo $this->_('Prolonger');?></a> + <span class="ui-li-count"><?php echo $nb_prets;?></span></li> + <?php if (0 < $nb_prets) { ?> + <?php foreach($this->user->getEmprunts() as $emprunt) { + $class_retard = $emprunt->enRetard() ? 'pret_en_retard"' : '';?> + <li data-icon="false"> + <a <?php echo $emprunt->enRetard() ? 'style="color:red;"' : '';?> + href="<?php echo $this->url(array('controller' => 'recherche', + 'action' => 'viewnotice', + 'id' => $emprunt->getNoticeOPACId()));?>"> + <h3><?php echo $emprunt->getTitre();?></h3> + <p><strong><?php echo $this->escape($emprunt->getAuteur());?></strong></p> + <p><strong><?php echo $this->escape($emprunt->getBibliotheque());?></strong></p> + <p><strong><?php echo $this->_('Retour prévu');?> <?php echo $emprunt->getDateRetour();?></strong></p> + </a> + <?php if ($emprunt->isRenewable()) { ?> + <a href="<?php echo $this->url(array('action' => 'prolongerpret', + 'id_pret' => $emprunt->getId()));?>" + data-theme="c"><?php echo $this->_('Prolonger');?></a> + <?php } ?> + </li> <?php } ?> - </li> + <?php } else { ?> + <li><?php echo $this->_('Vous n\'avez aucun prêt en cours');?></li> <?php } ?> -<?php } else { ?> - <li><?php echo $this->_('Vous n\'avez aucun prêt en cours');?></li> -<?php } ?> </ul> <ul data-role="listview" data-split-icon="delete"> <li data-role="list-divider"><?php echo $this->_('Réservations');?> - <span class="ui-li-count"><?php echo $nb_resas;?></span></li> -<?php if (0 < $nb_resas) { ?> - <?php foreach($fiche_sigb['fiche']->getReservations() as $reservation) { ?> - <li data-icon="false"> - <a href="<?php echo $this->url(array('controller' => 'recherche', - 'action' => 'viewnotice', - 'id' => $reservation->getNoticeOPACId()));?>"> - <h3><?php echo $reservation->getTitre();?></h3> - <p><strong><?php echo $this->escape($reservation->getAuteur());?></strong></p> - <p><strong><?php echo $this->escape($reservation->getBibliotheque());?></strong></p> - <p><?php echo $this->_('Etat') . ' : ' . $this->escape($reservation->getEtat());?>, - <?php echo $this->_('Rang') . ' : ' . $this->escape($reservation->getRang());?></p> - </a> - <a href="<?php echo $this->url(array('action' => 'cancel-hold', - 'id' => $reservation->getId()));?>" - data-rel="dialog" data-theme="c" data-position="notext"> - <?php echo $this->_('Supprimer cette réservation');?></a> - </li> + <span class="ui-li-count"><?php echo $nb_resas;?></span></li> + <?php if (0 < $nb_resas) { ?> + <?php foreach($this->user->getReservations() as $reservation) { ?> + <li data-icon="false"> + <a href="<?php echo $this->url(array('controller' => 'recherche', + 'action' => 'viewnotice', + 'id' => $reservation->getNoticeOPACId()));?>"> + <h3><?php echo $reservation->getTitre();?></h3> + <p><strong><?php echo $this->escape($reservation->getAuteur());?></strong></p> + <p><strong><?php echo $this->escape($reservation->getBibliotheque());?></strong></p> + <p><?php echo $this->_('Etat') . ' : ' . $this->escape($reservation->getEtat());?>, + <?php echo $this->_('Rang') . ' : ' . $this->escape($reservation->getRang());?></p> + </a> + <a href="<?php echo $this->url(array('action' => 'cancel-hold', + 'id' => $reservation->getId()));?>" + data-rel="dialog" data-theme="c" data-position="notext"> + <?php echo $this->_('Supprimer cette réservation');?></a> + </li> + <?php } ?> + <?php } else { ?> + <li><?php echo $this->_('Vous n\'avez aucune réservation en cours');?></li> <?php } ?> -<?php } else { ?> - <li><?php echo $this->_('Vous n\'avez aucune réservation en cours');?></li> -<?php } ?> </ul> -<?php } ?> \ No newline at end of file diff --git a/application/modules/telephone/views/scripts/abonne/prets.phtml b/application/modules/telephone/views/scripts/abonne/prets.phtml index c7677ee8b24a0b70c1a13965939e4f7ded2816d3..439bdfefb3c861ce310761aee01fda5de4f7eb7e 100644 --- a/application/modules/telephone/views/scripts/abonne/prets.phtml +++ b/application/modules/telephone/views/scripts/abonne/prets.phtml @@ -1,11 +1,11 @@ <?php echo $this->toolbar($this->_('Prêts'));?> <?php echo $this->partial('abonne/identity.phtml', array('user' => $this->user));?> <ul data-role="listview" data-inset="true"> -<?php -foreach ($this->fiche["fiche"]->getEmprunts() as $emprunt) { +<?php +foreach ($this->user->getEmprunts() as $emprunt) { echo sprintf('<li>%s</li>', $emprunt->getTitre()); } ?> -</ul> \ No newline at end of file +</ul> diff --git a/application/modules/telephone/views/scripts/abonne/reservations.phtml b/application/modules/telephone/views/scripts/abonne/reservations.phtml index 15535d55891158fa8876f2056d60cbb2e752e846..98b3b37ec092da3c0a11ae49071d8f40aaf3c2af 100644 --- a/application/modules/telephone/views/scripts/abonne/reservations.phtml +++ b/application/modules/telephone/views/scripts/abonne/reservations.phtml @@ -1,10 +1,10 @@ <?php echo $this->toolbar($this->_('Réservations'));?> <?php echo $this->partial('abonne/identity.phtml', array('user' => $this->user));?> <ul data-role="listview" data-inset="true"> -<?php -foreach ($this->fiche["fiche"]->getReservations() as $reservation) { +<?php +foreach ($this->user->getReservations() as $reservation) { echo sprintf('<li>%s</li>', $reservation->getTitre()); } ?> -</ul> \ No newline at end of file +</ul> diff --git a/library/ZendAfi/View/Helper/Abonne/Prets.php b/library/ZendAfi/View/Helper/Abonne/Prets.php index 0e4a3c9bb56b8a2df5405af78dba8822b788423f..f0f7ee7f0e28fb356f0716fd1241ad3e11011834 100644 --- a/library/ZendAfi/View/Helper/Abonne/Prets.php +++ b/library/ZendAfi/View/Helper/Abonne/Prets.php @@ -16,32 +16,28 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ZendAfi_View_Helper_Abonne_Prets extends ZendAfi_View_Helper_Abonne_Abstract { public function abonne_prets($user) { if (!$user->isAbonne()) return ''; - $fiche_sigb = $user->getFicheSigb(); - if (!isset($fiche_sigb['fiche'])) - return ''; - - $nb_prets = $fiche_sigb["fiche"]->getNbEmprunts(); + $nb_prets = $user->getNbEmprunts(); $str_prets = $this->view->_plural($nb_prets, "Vous n'avez aucun prêt en cours.", "Vous avez %d prêt en cours", "Vous avez %d prêts en cours", $nb_prets); - $nb_retards = $fiche_sigb["fiche"]->getNbPretsEnRetard(); + $nb_retards = $user->getNbEmpruntsRetard(); $str_retards = $nb_retards ? $this->view->_('(%d en retard)', $nb_retards) : ''; $action_url = $this->view->url(['controller' => 'abonne', 'action' => 'prets']); - return $this->tagFicheAbonne(sprintf('<a href=\'%s\'>%s %s</a>', - $action_url, - $str_prets, + return $this->tagFicheAbonne(sprintf('<a href=\'%s\'>%s %s</a>', + $action_url, + $str_prets, $str_retards), 'prets', $action_url); diff --git a/library/ZendAfi/View/Helper/Abonne/Reservations.php b/library/ZendAfi/View/Helper/Abonne/Reservations.php index 34bac2fe6e8c54636135247dcf7a8753a7ae6342..508137a7e2dfe75a1af54ad1a9fb1ceed66b1274 100644 --- a/library/ZendAfi/View/Helper/Abonne/Reservations.php +++ b/library/ZendAfi/View/Helper/Abonne/Reservations.php @@ -16,27 +16,23 @@ * * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ZendAfi_View_Helper_Abonne_Reservations extends ZendAfi_View_Helper_Abonne_Abstract { public function abonne_reservations($user) { if (!$user->isAbonne()) return ''; - $fiche_sigb = $user->getFicheSigb(); - if (!isset($fiche_sigb['fiche'])) - return ''; - - $nb_resas = $fiche_sigb["fiche"]->getNbReservations(); + $nb_resas = $user->getNbReservations(); $str_resas = $this->view->_plural($nb_resas, "Vous n'avez aucune réservation en cours.", "Vous avez %d réservation en cours", "Vous avez %d réservations en cours", $nb_resas); - + $action_url = $this->view->url(['controller' => 'abonne', 'action' => 'reservations']); - return $this->tagFicheAbonne(sprintf("<a href='%s'>%s</a>", + return $this->tagFicheAbonne(sprintf("<a href='%s'>%s</a>", $action_url, $str_resas), 'reservations', diff --git a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php index c18f4296cf90cf42cc776627447823a29f611cd1..d0eb2ed331628fcae78de1ae2e0afe1226616a7e 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php @@ -333,12 +333,12 @@ class AbonneControllerPretsListReservationTest extends AbstractAbonneControllerP 'zone995' => '']); $this->florence + ->setPseudo('FloFlo') ->setFicheSigb(['type_comm' => Class_IntBib::COM_OPSYS, 'fiche' => (new Class_WebService_SIGB_Emprunteur('1234', 'Florence')) ->reservationsAddAll([$potter, $dobby]), 'message' => '', - 'erreur' => '', - 'nom_aff' => 'FloFlo']); + 'erreur' => '']); $this->dispatch('/opac/abonne/reservations'); }