diff --git a/VERSIONS_WIP/25588 b/VERSIONS_WIP/25588 new file mode 100644 index 0000000000000000000000000000000000000000..3743e03c7120026af1f89c96260c7e660eec63e1 --- /dev/null +++ b/VERSIONS_WIP/25588 @@ -0,0 +1 @@ + - ticket #25588 : Compte utilisateur : historique de prêts provenant de Koha \ No newline at end of file diff --git a/application/modules/opac/controllers/AbonneController.php b/application/modules/opac/controllers/AbonneController.php index a664d36920a7c19a4d0d734e7cd0f7d6d90f2139..0bc78b5d31c4c38d758ebac40d175ffcc2b6e7a5 100644 --- a/application/modules/opac/controllers/AbonneController.php +++ b/application/modules/opac/controllers/AbonneController.php @@ -35,7 +35,10 @@ class AbonneController extends ZendAfi_Controller_Action { protected function clearEmprunteurCache() { - if (in_array($this->getRequest()->getActionName(), array('prets', 'reservations', 'fiche'))) + if (in_array($this->getRequest()->getActionName(), ['prets', + 'reservations', + 'fiche', + 'loans-history'])) Class_WebService_SIGB_EmprunteurCache::newInstance()->remove($this->_user); } @@ -354,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(); } @@ -380,6 +382,18 @@ class AbonneController extends ZendAfi_Controller_Action { } + public function loansHistoryAction() { + try { + $loans = $this->_user->getLoansHistory(); + } catch (Class_WebService_Exception $e) { + $this->view->error = $e->getMessage(); + } + + if (!empty($loans)) + $this->view->loans = $loans; + } + + public function reservationsAction() { // Mode Suppression if (null !== ($delete = $this->_getParam('id_delete'))) { @@ -959,4 +973,6 @@ class AbonneController extends ZendAfi_Controller_Action { $response->setBody(implode('', $datas)); } } + + ?> \ No newline at end of file diff --git a/application/modules/opac/views/scripts/abonne/fiche.phtml b/application/modules/opac/views/scripts/abonne/fiche.phtml index 230177c2279f62da5cf67c553dcf5dce829d59a3..ebafaebf89311e8a3a5d17fb00b1038fddfdbb27 100644 --- a/application/modules/opac/views/scripts/abonne/fiche.phtml +++ b/application/modules/opac/views/scripts/abonne/fiche.phtml @@ -13,9 +13,8 @@ echo $this->abonne_Multimedia($this->user); echo $this->abonne_SuggestionAchat($this->user); echo $this->abonne_Deconnexion($this->user); -if ($this->error) +if ($this->error) echo sprintf('<div class="error">%s</div>', $this->error); $this->closeBoite(); ?> - diff --git a/application/modules/opac/views/scripts/abonne/loans-history.phtml b/application/modules/opac/views/scripts/abonne/loans-history.phtml new file mode 100644 index 0000000000000000000000000000000000000000..3518eba9770f3e9b99d2ef1da7084b6f47d02829 --- /dev/null +++ b/application/modules/opac/views/scripts/abonne/loans-history.phtml @@ -0,0 +1,13 @@ +<?php +$this->openBoite($this->_('Historique de prêts')); + +if ($this->error) + echo $this->tag('div', + $this->error, + ['class' => 'error']); + +echo $this->abonne_Loans(($this->loans ? $this->loans : []), false); + +$this->closeBoite(); +echo $this->abonne_RetourFiche(); +?> diff --git a/application/modules/opac/views/scripts/abonne/prets.phtml b/application/modules/opac/views/scripts/abonne/prets.phtml index b37308a5d00c2ff4dd197a3a38390b815f38e35d..5518084270992787d8b32307a1373970d0eec71f 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/application/modules/opac/views/scripts/abonne/suggestion-achat.phtml b/application/modules/opac/views/scripts/abonne/suggestion-achat.phtml index 61b4119f14923cc0118da1561fc501886ae5fa90..0db42d41471142cb3bbe2c14af65d3cc76f217e2 100644 --- a/application/modules/opac/views/scripts/abonne/suggestion-achat.phtml +++ b/application/modules/opac/views/scripts/abonne/suggestion-achat.phtml @@ -2,7 +2,7 @@ $this->openBoite($this->_('Suggestion d\'achat')); echo $this->tagAnchor($this->url(['controller' => 'abonne', 'action' => 'suggestion-achat-add'],null,true), - + $this->tagImg(URL_ADMIN_IMG . 'ico/add.gif', ['alt' => $this->_('Suggérer un achat'), 'title' => $this->_('Suggérer un achat')]) . diff --git a/library/Class/Users.php b/library/Class/Users.php index cfc608dd4b21474a37fc6ca5fbe68e410402b844..e615379574d5175bfd711ca5f2b22fe7d640e243 100644 --- a/library/Class/Users.php +++ b/library/Class/Users.php @@ -1054,6 +1054,23 @@ class Class_Users extends Storm_Model_Abstract { } + public function providesLoansHistory() { + if (!($emprunteur = $this->getEmprunteur())) + return false; + + return $emprunteur->providesLoansHistory(); + } + + + public function getLoansHistory() { + if (!($emprunteur = $this->getEmprunteur())) + return []; + + return array_filter($emprunteur->getLoansHistory(), + function($loan) {return $loan->getDateRetour();}); + } + + public function hasPNB() { return 0 < count($this->getPNBLoans()); } diff --git a/library/Class/WebService/SIGB/AbstractService.php b/library/Class/WebService/SIGB/AbstractService.php index bdf04883230c6a9c84ba5a3bec039b68e4287211..c0977b1dda1975f6133981b6b39beaf3430bb4df 100644 --- a/library/Class/WebService/SIGB/AbstractService.php +++ b/library/Class/WebService/SIGB/AbstractService.php @@ -139,6 +139,16 @@ abstract class Class_WebService_SIGB_AbstractService { } + public function loansHistory() { + return []; + } + + + public function providesLoansHistory() { + return false; + } + + protected function _success() { return ['statut' => true, 'erreur' => '']; } diff --git a/library/Class/WebService/SIGB/Emprunt.php b/library/Class/WebService/SIGB/Emprunt.php index d3801453b893829b489d2b69af27bcd3e54dc88f..e946729ea042e1c9c401322e220b669e0256df79 100644 --- a/library/Class/WebService/SIGB/Emprunt.php +++ b/library/Class/WebService/SIGB/Emprunt.php @@ -24,7 +24,6 @@ class Class_WebService_SIGB_Emprunt extends Class_WebService_SIGB_ExemplaireOper protected $renewable = true; protected $type = ''; - /** * @return string */ diff --git a/library/Class/WebService/SIGB/Emprunteur.php b/library/Class/WebService/SIGB/Emprunteur.php index 20fd065ec29c1d1c307cc0e5d4da2e729c81ba6b..d0819dbbe4e1d8ebc8b1902b03771630d5e9a93d 100644 --- a/library/Class/WebService/SIGB/Emprunteur.php +++ b/library/Class/WebService/SIGB/Emprunteur.php @@ -446,6 +446,20 @@ class Class_WebService_SIGB_Emprunteur { return $this->_emprunts; } + + public function providesLoansHistory() { + return $this->_service + ? $this->_service->providesLoansHistory() + : false; + } + + + public function getLoansHistory() { + return $this->_service + ? $this->_service->loansHistory($this) + : []; + } + /** * @param int $index * @return Class_WebService_SIGB_Emprunt diff --git a/library/Class/WebService/SIGB/Exemplaire.php b/library/Class/WebService/SIGB/Exemplaire.php index ff0149583b373ab85e1114c953ebd1600ab07ac9..7f687bf4667ecca329e44fe58154447fff1dee57 100644 --- a/library/Class/WebService/SIGB/Exemplaire.php +++ b/library/Class/WebService/SIGB/Exemplaire.php @@ -53,6 +53,7 @@ class Class_WebService_SIGB_Exemplaire { protected $_isEnPret; protected $_cote; protected $_emplacement; + protected $_issue_date; public static function newInstance() { @@ -202,6 +203,7 @@ class Class_WebService_SIGB_Exemplaire { return $this; } + public function getSection(){ return $this->section; } @@ -218,6 +220,17 @@ class Class_WebService_SIGB_Exemplaire { } + public function setIssueDate($date) { + $this->_issue_date = $date; + return $this; + } + + + public function getIssueDate() { + return $this->_issue_date; + } + + public function getCodeBarre(){ if (!$this->code_barre && ($ex_opac = $this->getExemplaireOPAC())) $this->code_barre = $ex_opac->getCodeBarres(); diff --git a/library/Class/WebService/SIGB/ExemplaireOperation.php b/library/Class/WebService/SIGB/ExemplaireOperation.php index 92a53065188d343c187b9e33ebeb7b5e23709ad6..82bedea21782184008096baf432badbef3ad8519 100644 --- a/library/Class/WebService/SIGB/ExemplaireOperation.php +++ b/library/Class/WebService/SIGB/ExemplaireOperation.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 */ abstract class Class_WebService_SIGB_ExemplaireOperation { @@ -126,6 +126,16 @@ abstract class Class_WebService_SIGB_ExemplaireOperation { } + public function getIssueDate() { + return $this->_exemplaire->getIssueDate(); + } + + + public function setIssueDate($data) { + $this->_exemplaire->setIssueDate($data); + return $this; + } + /** * @return string */ @@ -142,7 +152,7 @@ abstract class Class_WebService_SIGB_ExemplaireOperation { $this->_exemplaire->setAuteur($data); return $this; } - + /** * @return string diff --git a/library/Class/WebService/SIGB/Koha/LoansReader.php b/library/Class/WebService/SIGB/Koha/LoansReader.php new file mode 100644 index 0000000000000000000000000000000000000000..7655631fea328ada5ed01b5d2c088c05f67265b6 --- /dev/null +++ b/library/Class/WebService/SIGB/Koha/LoansReader.php @@ -0,0 +1,47 @@ +<?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 Class_WebService_SIGB_Koha_LoansReader { + + public function parse($json) { + return ($datas = json_decode($json)) ? + array_map([$this, '_parseOne'], $datas) : []; + } + + + protected function _parseOne($data) { + $loan = Class_WebService_SIGB_Emprunt::newInstanceWithEmptyExemplaire(); + + $loan->setTitre($data->title) + ->setAuteur($data->author) + ->setCodeBarre($data->barcode) + ->setIssueDate($this->formatDate($data->issuedate)) + ->setDateRetour($data->returndate ? $this->formatDate($data->returndate) : '') + ->beNotRenewable(); + return $loan; + } + + + protected function formatDate($date) { + return date('d/m/Y', strtotime($date)); + } +} \ No newline at end of file diff --git a/library/Class/WebService/SIGB/Koha/RestfulService.php b/library/Class/WebService/SIGB/Koha/RestfulService.php index 44350ea754e0228a541c7895051a791ecd9602bb..65a621de200b7f3e997077d4ad0356834a857692 100644 --- a/library/Class/WebService/SIGB/Koha/RestfulService.php +++ b/library/Class/WebService/SIGB/Koha/RestfulService.php @@ -46,6 +46,11 @@ class Class_WebService_SIGB_Koha_RestfulService } + public function providesLoansHistory() { + return true; + } + + public function suggestionsOf($user) { if (!$patron_id = $this->_authenticate($user)) return $this->_error($this->_('Échec de l\'authentification par le webservice')); @@ -85,7 +90,26 @@ class Class_WebService_SIGB_Koha_RestfulService } + public function getLoansHistoryForUser($emprunteur) { + $content = $this->restfulGet('user/byid/'.$emprunteur->getId().'/issues_history',[]); + + if (null === json_decode($content)) + throw new Class_WebService_Exception($this->_('Échec de la connexion au webservice, le SIGB a répondu "%s"', + trim($content))); + + return (new Class_WebService_SIGB_Koha_LoansReader()) + ->parse($content); + + } + + public function buildQueryURL($options) { + if (empty($options)) + return sprintf('%s/%s', + $this->getServerRoot(), + $this->_current_action); + + return sprintf('%s/%s?%s', $this->getServerRoot(), $this->_current_action, @@ -93,6 +117,8 @@ class Class_WebService_SIGB_Koha_RestfulService } + + public function restfulGet($action, $params=[]) { $this->_current_action = $action; return $this->httpGet($params); diff --git a/library/Class/WebService/SIGB/Koha/Service.php b/library/Class/WebService/SIGB/Koha/Service.php index e53f3cf515204897d17551d52aa081597875c8af..dc9a329a9d9f7b8311d20f9fb1412a349660121b 100644 --- a/library/Class/WebService/SIGB/Koha/Service.php +++ b/library/Class/WebService/SIGB/Koha/Service.php @@ -166,6 +166,11 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR } + public function providesLoansHistory() { + return $this->restful; + } + + public function suggestionsOf($user) { if (!$this->providesSuggestions()) return parent::suggestionsOf($user); @@ -186,6 +191,15 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR } + public function loansHistory($user) { + if (!$this->providesLoansHistory()) + return parent::loansHistory(); + return $this + ->getRestfulService() + ->getLoansHistoryForUser($user); + + } + public function getRestfulService() { return Class_WebService_SIGB_Koha_RestfulService::newFromIlsdi($this); } @@ -198,7 +212,6 @@ class Class_WebService_SIGB_Koha_Service extends Class_WebService_SIGB_AbstractR ->setInterdireResaDocDispo($this->interdire_resa_doc_dispo)); } - public function test() { $validator = new ZendAfi_Validate_Url(); if (!$validator->isValid($this->getServerRoot())) diff --git a/library/ZendAfi/View/Helper/Abonne/Abstract.php b/library/ZendAfi/View/Helper/Abonne/Abstract.php index 34ab7ebb6cf0efc8dac733dadd5600516d8797c8..d4c5bc5f7d493ce708123396c5b481d5d4ff4757 100644 --- a/library/ZendAfi/View/Helper/Abonne/Abstract.php +++ b/library/ZendAfi/View/Helper/Abonne/Abstract.php @@ -16,9 +16,9 @@ * * 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 */ -abstract class ZendAfi_View_Helper_Abonne_Abstract extends Zend_View_Helper_HtmlElement { +abstract class ZendAfi_View_Helper_Abonne_Abstract extends ZendAfi_View_Helper_BaseHelper { public function tagFicheAbonne($html, $icone='', $url='') { if ($icone && $url) { $html = $this->view->tagAnchor($url, diff --git a/library/ZendAfi/View/Helper/Abonne/LoanAction.php b/library/ZendAfi/View/Helper/Abonne/LoanAction.php index 0eca52a1179b7ca3cfdb566c77b0a49ef9d3f47e..2469bfa48f69b70282d12cd110b03066f4ecca82 100644 --- a/library/ZendAfi/View/Helper/Abonne/LoanAction.php +++ b/library/ZendAfi/View/Helper/Abonne/LoanAction.php @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class ZendAfi_View_Helper_Abonne_LoanAction extends ZendAfi_View_Helper_Abonne_Abstract { - use Trait_Translator; public function abonne_LoanAction($emprunt) { if ($emprunt->isRenewable()) diff --git a/library/ZendAfi/View/Helper/Abonne/Loans.php b/library/ZendAfi/View/Helper/Abonne/Loans.php new file mode 100644 index 0000000000000000000000000000000000000000..9785f2a0d878f3867e4fcdbbaaa8fde006f24e70 --- /dev/null +++ b/library/ZendAfi/View/Helper/Abonne/Loans.php @@ -0,0 +1,100 @@ +<?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, + $_in_progress; + + public function abonne_Loans($loans, $in_progress = true) { + $this->_in_progress = $in_progress; + Class_ScriptLoader::getInstance()->loadTableSorter(); + return + $this->_tag('table', + $this->renderHeader() + . $this->renderLoans($loans), + ['class' => $this->_in_progress ? 'tablesorter loans' : 'tablesorter loans-history']); + } + + + + protected function renderHeader() { + $headers = array_map( + function($title) { + return $this->_tag('th', $title); + }, + + [$this->_('n°'), + $this->_('Titre'), + $this->_('Auteur'), + $this->_in_progress ? $this->_('Bibliothèque') : $this->_('Date d\'emprunt'), + $this->_in_progress ? $this->_('Retour prévu') : $this->_('Date de retour'), + $this->_('Informations')]); + + return $this->_tag('thead', + $this->_tag('tr', + implode('', $headers))); + } + + + protected function renderLoans($loans) { + $this->_line_no = 1; + $html = ''; + + if (!$this->_in_progress) + $loans = array_reverse($loans); + + foreach($loans as $loan) + $html .= $this->renderLoan($loan); + + return $this->_tag('tbody', $html); + } + + + protected function renderLoan($loan) { + $notice_url = $loan->getTitre(); + + if ($loan->getNoticeOPACId()) + $notice_url = $this->view->tagAnchor($this->view->url( + ['controller' => 'recherche', + 'action' => 'viewnotice', + 'id' => $loan->getNoticeOPACId(), + 'retour_abonne' => 'prets'], + null, true), + $loan->getTitre()); + return + $this->_tag('tr', + $this->_tag('td', + $this->_line_no++) + . $this->_tag('td', + $notice_url) + . $this->_tag('td', + $loan->getAuteur()) + . $this->_tag('td', + $this->_in_progress ? $loan->getBibliotheque() : $loan->getIssueDate()) + . $this->_tag('td', + $loan->getDateRetour() . ' ' . $this->view->abonne_LoanAction($loan), ['class' => 'date_retour']) + . $this->_tag('td', + $loan->getType()), + ($loan->isLate() && $this->_in_progress) ? ['class' => 'pret_en_retard'] : []); + } +} \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/Abonne/Prets.php b/library/ZendAfi/View/Helper/Abonne/Prets.php index 68745a7bf72bacbd3828c74c1ce6bbd26c027aef..16f1d8454e1a6ec859a72b464d5a3de107b89ad1 100644 --- a/library/ZendAfi/View/Helper/Abonne/Prets.php +++ b/library/ZendAfi/View/Helper/Abonne/Prets.php @@ -31,16 +31,26 @@ class ZendAfi_View_Helper_Abonne_Prets extends ZendAfi_View_Helper_Abonne_Abstra $nb_prets); $nb_retards = $user->getNbEmpruntsRetard(); - $str_retards = $nb_retards ? $this->view->_('(%d en retard)', $nb_retards) : ''; + $str_retards = $nb_retards + ? $this->_('(%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, - $str_retards), + $action_prets_url = $this->view->url(['controller' => 'abonne', + 'action' => 'prets']); + + $action_history_url = $this->view->url(['controller' => 'abonne', + 'action' => 'loans-history']); + + $history_link = $user->providesLoansHistory() + ? '<br/><br/>' . $this->_tag('a', $this->_('Voir mon historique de prêts'), + ['href' => $action_history_url]) + : ''; + + return $this->tagFicheAbonne($this->_tag('a', $str_prets . ' ' . $str_retards, + ['href' => $action_prets_url]) + . $history_link, 'prets', - $action_url); + $action_prets_url); } } diff --git a/public/opac/css/global.css b/public/opac/css/global.css index e74a52e9fd8317db5f1dfeefe23f61662830b6cc..083bc9714d181e8ba0b0f20879bb79ee49709777 100644 --- a/public/opac/css/global.css +++ b/public/opac/css/global.css @@ -610,6 +610,59 @@ form#calendar_select_categorie { } +/* loans in patron screen */ +table.loans { + margin-bottom: 30px; + width: 100%; +} + +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; +} + +table.loans-history { + margin-bottom: 30px; + width:100%; +} + +table.loans-history th { + text-align:left; +} + +table.loans-history th:first-child { + white-space: nowrap; +} + + +table.loans-history th:nth-child(5), +table.loans-history th:nth-child(6) { + text-align: center; +} + + +table.loans-history td:first-child { + width: 15px; + font-weight: bold; + text-align: center; +} + /* Formulaires */ .zend_form { background-color:#F0F0F0; diff --git a/tests/application/modules/opac/controllers/AbonneControllerFicheTest.php b/tests/application/modules/opac/controllers/AbonneControllerFicheTest.php index 6b874ce47df18e9113d2e0852ebc2ea1204e7973..710ab7579075fcc705c0552440a1b820aadd11bd 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerFicheTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerFicheTest.php @@ -58,6 +58,7 @@ class AbonneControllerFicheAsAdminTest extends AbstractAbonneControllerFicheTest $this->assertNotXPath('//a[contains(@href, "/abonne/reservations")]'); } + /** @test */ public function linkToLogoutShouldBePresent() { $this->assertXPath('//a[contains(@href, "/auth/logout")]'); @@ -86,6 +87,7 @@ class AbonneControllerFicheAsAbonneTest extends AbstractAbonneControllerFicheTes $this->assertXPath('//a[contains(@href, "/abonne/reservations")]'); } + /** @test */ public function linkToLogoutShouldBePresent() { $this->assertXPath('//a[contains(@href, "/auth/logout")]'); @@ -98,14 +100,21 @@ class AbonneControllerFicheAsAbonneTest extends AbstractAbonneControllerFicheTes } - /** @test */ + /** @test */ public function marcusLastNameShouldBePresent() { $this->assertXPathContentContains('//div[@class="abonneTitre"]//span[@data-name="last-name"]', 'Miller'); } + + /** @test */ + public function LoansHistoryShouldNotBeDisplayed() { + $this->assertNotXPathContentContains('//a', 'Voir mon historique de prêts'); + } + } + class AbonneControllerFicheNobodyLoggedTest extends AbstractAbonneControllerFicheTest { public function setUp() { parent::setUp(); @@ -129,6 +138,7 @@ class AbonneControllerFicheNobodyLoggedTest extends AbstractAbonneControllerFich public function hiddenInputRedirectShouldContainsAbonneFiche() { $this->assertXPath('//input[@name="redirect"][@value="http://localhost' . BASE_URL . '/abonne/fiche"]'); } + } @@ -148,4 +158,4 @@ class AbonneControllerFicheAsAdminDisableSuggestTest extends AbstractAbonneContr $this->assertNotXPathContentContains('//a[contains(@href, "/abonne/suggestion-achat")]', 'Suggérer un achat'); } -} \ No newline at end of file +} diff --git a/tests/application/modules/opac/controllers/AbonneControllerLoansHistoryTest.php b/tests/application/modules/opac/controllers/AbonneControllerLoansHistoryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..8304dfd88830c348b84a6a5c4ee106272bff1314 --- /dev/null +++ b/tests/application/modules/opac/controllers/AbonneControllerLoansHistoryTest.php @@ -0,0 +1,185 @@ +<?php +/** + * Copyright (c) 2012, 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 + */ + + +abstract class AbonneControllerLoansHistoryTestCase extends AbstractControllerTestCase { + + const BASE_URL = 'http://cat-aficg55.biblibre.com/cgi-bin/koha/'; + + protected + $_emprunteur, + $_storm_default_to_volatile = true, + $mock_web_client; + + + public function setUp() { + parent::setUp(); + $faustine = $this->fixture('Class_Users', ['id' => 12, + 'login' => 'faustine', + 'password' => 'toto']); + $this->_emprunteur = new Class_WebService_SIGB_Emprunteur('34', 'faustine'); + + + $faustine->setFicheSigb(['type_comm' => Class_IntBib::COM_KOHA, + 'fiche' => $this->_emprunteur]); + ZendAfi_Auth::getInstance()->logUser($faustine); + + $this->mock_web_client = $this->mock(); + + Class_AdminVar::set('KOHA_MULTI_SITES', ''); + + $params = ['url_serveur' => static::BASE_URL . 'ilsdi.pl', + 'restful' => '1']; + $service = Class_WebService_SIGB_Koha::getService($params); + $service->setWebClient($this->mock_web_client); + + $this->_emprunteur->setService($service); + + } +} + + + +class AbonneControllerLoansHistoryWithoutServiceTest extends AbonneControllerLoansHistoryTestCase { + public function setUp() { + parent::setUp(); + $this->_emprunteur->setService(null); + $this->dispatch('/abonne/loans-history', true); + } + + + /** @test */ + public function pageTitleShouldBeDisplayed() { + $this->assertXPathContentContains('//h1', 'Historique de prêts'); + } +} + + + +class AbonneControllerLoansHistorySuccessfulTest extends AbonneControllerLoansHistoryTestCase { + + public function setUp() { + parent::setUp(); + + $pomme = $this->fixture('Class_Notice', + ['id' => 1456, + 'clef_alpha' => 'POMME', + 'titre' => 'Tarte au pommes']); + + $this->fixture('Class_Exemplaire', ['id' => 123, + 'notice' => $pomme, + 'code_barres' => '31301009564282']); + + $this->mock_web_client + ->whenCalled('open_url') + ->with(static::BASE_URL . 'rest.pl/user/byid/34/issues_history') + ->answers(file_get_contents(realpath(dirname(__FILE__)) . '/../../../../fixtures/koha_issues_history.json')); + + $this->dispatch('/abonne/loans-history', true); + } + + + /** @test */ + public function controllerAndActionShouldBeAbonneHistorique() { + $this->assertController('abonne'); + $this->assertAction('loans-history'); + } + + /** @test */ + public function titleShouldBeDisplay() { + $this->assertXPathContentContains('//table', 'Cedric :Chaud et froid Vol 6'); + } + + /** @test */ + public function loanNoticeShouldBeLinked() { + $this->assertXPath('//td/a[contains(@href, "/recherche/viewnotice/id/1456/retour_abonne/prets")]'); + } + + /** @test */ + public function loanWithoutReturnDateShouldNotBeDisplayedInHistory() { + $this->assertNotXPathContentContains('//table[contains(@class, "loans-history")]', 'Le secret du pressoir'); + } + + /** @test */ + public function loanWithoutNoticeShouldNotBeLink() { + $this->assertXPath('//td[not(a)][contains(text(), "L\'hôpital")]'); + } + + /** @test */ + public function HopitalShouldBeFirstElement() { + $this->assertXPathContentContains('//tbody/tr[1]', 'L\'hôpital'); + } +} + + + + +class AbonneControllerLoansHistoryWithoutHistoryTest extends AbonneControllerLoansHistoryTestCase { + + public function setUp() { + parent::setUp(); + + $this->mock_web_client + ->whenCalled('open_url') + ->with(static::BASE_URL . 'rest.pl/user/byid/34/issues_history') + ->answers('[]'); + + $this->dispatch('/abonne/loans-history', true); + } + + + /** @test */ + public function boxTitleShouldBeDisplay() { + $this->assertXPathContentContains('//h1', 'Historique de prêts'); + } + + /** @test */ + public function loansTitleShouldNotBeDisplay() { + $this->assertNotXPathContentContains('//table', 'Cedric :Chaud et froid Vol 6'); + } + + /** @test */ + public function tableShouldBeDisplay() { + $this->assertXPathContentContains('//table', 'Titre'); + } +} + + + + +class AbonneControllerLoansHistoryWithErrorTest extends AbonneControllerLoansHistoryTestCase { + + public function setUp() { + parent::setUp(); + + $this->mock_web_client + ->whenCalled('open_url') + ->with(static::BASE_URL . 'rest.pl/user/byid/34/issues_history') + ->answers('error'); + + $this->dispatch('/abonne/loans-history', true); + } + + /** @test */ + public function pageShouldDisplayWebServiceError() { + $this->assertXPathContentContains('//div[@class="error"]', 'Échec de la connexion au webservice, le SIGB a répondu "error"'); + } +} \ No newline at end of file diff --git a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php index 3de174bc81a43cb57854738fd7e1ae9667402ea4..07f102f8b65e69a4e482368ef7a8cedf78e5fe05 100644 --- a/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php +++ b/tests/application/modules/opac/controllers/AbonneControllerPretsTest.php @@ -260,7 +260,7 @@ class AbonneControllerPretsListThreePretsTest extends AbonneControllerPretsListT /** @test */ public function tableShouldHaveClassTableSorter() { - $this->assertXPath('//table[@class="tablesorter"]'); + $this->assertXPath('//table[@class="tablesorter loans"]', $this->_response->getBody()); } diff --git a/tests/fixtures/koha_issues_history.json b/tests/fixtures/koha_issues_history.json new file mode 100644 index 0000000000000000000000000000000000000000..b1c3f18e82d4f7d542121cbd44af6e4b61b7de33 --- /dev/null +++ b/tests/fixtures/koha_issues_history.json @@ -0,0 +1,290 @@ +[ + { + "withdrawn" : "0", + "lastreneweddate" : null, + "auto_renew" : "0", + "coded_location_qualifier" : null, + "marc" : "00813 2200217 4500010003000000090001700030091001900047099000700066101000800073102000700081105001800088106000600106100004000112200008400152210004500236215005300281225001600334700007700350702013900427801002900566\u001e \u001fa2-8001-1990-X\u001fbrel.\u001fd45 F\u001e \u001f953641\u001fa53641\u001e \u001fa2\u001fb20130702\u001fc0\u001e1 \u001ftBD\u001e0 \u001fafre\u001e \u001faFR\u001e \u001faa t 00|a|\u001e \u001far\u001e \u001fa20130630 frey50 \u001e1 \u001faCedric :Chaud et froid Vol 6\u001fbTexte imprimé\u001ffdessin, Laudec\u001fgscénario, Cauvin\u001e \u001fa[Paris]\u001fcDupuis\u001fd1993\u001feImpr. en Belgique\u001e \u001fa46 p.\u001fcill. en coul., couv. ill. en coul.\u001fd30 cm\u001e19\u001faCédric.\u001fv6\u001e \u001f9493096\u001faLaudec\u001ff1948-....\u001f7ba0yba0y\u001f8fre \u001f9 0 \u001faLaudec\u001ff1948-....\u001f4440\u001e \u001f9487403\u001f3http://catalogue.bnf.fr/ark:/12148/cb118956232\u001faCauvin\u001fbRaoul\u001ff1938-....\u001f7ba0yba0y\u001f8fre \u001f9 0 \u001faCauvin\u001fbRaoul\u001ff1938-....\u001f4070\u001e 0\u001faFR\u001fbBNF\u001fc19930527\u001fgAFNOR\u001e\u001d", + "url" : null, + "isbn" : "2-8001-1990-X", + "borrowernumber" : "94541", + "branchcode" : "IST", + "copyrightdate" : null, + "itemnumber" : "85299", + "ccode" : null, + "serial" : null, + "cn_suffix" : null, + "barcode" : "31301009564282", + "date_due" : "2015-07-29 23:59:00", + "uri" : null, + "cn_item" : null, + "marcxml" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<record\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd\"\n xmlns=\"http://www.loc.gov/MARC21/slim\">\n\n <leader>00813 2200217 4500</leader>\n <datafield tag=\"010\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">2-8001-1990-X</subfield>\n <subfield code=\"b\">rel.</subfield>\n <subfield code=\"d\">45 F</subfield>\n </datafield>\n <datafield tag=\"090\" ind1=\" \" ind2=\" \">\n <subfield code=\"9\">53641</subfield>\n <subfield code=\"a\">53641</subfield>\n </datafield>\n <datafield tag=\"091\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">2</subfield>\n <subfield code=\"b\">20130702</subfield>\n <subfield code=\"c\">0</subfield>\n </datafield>\n <datafield tag=\"099\" ind1=\"1\" ind2=\" \">\n <subfield code=\"t\">BD</subfield>\n </datafield>\n <datafield tag=\"101\" ind1=\"0\" ind2=\" \">\n <subfield code=\"a\">fre</subfield>\n </datafield>\n <datafield tag=\"102\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">FR</subfield>\n </datafield>\n <datafield tag=\"105\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">a t 00|a|</subfield>\n </datafield>\n <datafield tag=\"106\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">r</subfield>\n </datafield>\n <datafield tag=\"100\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">20130630 frey50 </subfield>\n </datafield>\n <datafield tag=\"200\" ind1=\"1\" ind2=\" \">\n <subfield code=\"a\">Cedric :Chaud et froid Vol 6</subfield>\n <subfield code=\"b\">Texte imprimé</subfield>\n <subfield code=\"f\">dessin, Laudec</subfield>\n <subfield code=\"g\">scénario, Cauvin</subfield>\n </datafield>\n <datafield tag=\"210\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">[Paris]</subfield>\n <subfield code=\"c\">Dupuis</subfield>\n <subfield code=\"d\">1993</subfield>\n <subfield code=\"e\">Impr. en Belgique</subfield>\n </datafield>\n <datafield tag=\"215\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">46 p.</subfield>\n <subfield code=\"c\">ill. en coul., couv. ill. en coul.</subfield>\n <subfield code=\"d\">30 cm</subfield>\n </datafield>\n <datafield tag=\"225\" ind1=\"1\" ind2=\"9\">\n <subfield code=\"a\">Cédric.</subfield>\n <subfield code=\"v\">6</subfield>\n </datafield>\n <datafield tag=\"700\" ind1=\" \" ind2=\" \">\n <subfield code=\"9\">493096</subfield>\n <subfield code=\"a\">Laudec</subfield>\n <subfield code=\"f\">1948-....</subfield>\n <subfield code=\"7\">ba0yba0y</subfield>\n <subfield code=\"8\">fre </subfield>\n <subfield code=\"9\"> 0 </subfield>\n <subfield code=\"a\">Laudec</subfield>\n <subfield code=\"f\">1948-....</subfield>\n <subfield code=\"4\">440</subfield>\n </datafield>\n <datafield tag=\"702\" ind1=\" \" ind2=\" \">\n <subfield code=\"9\">487403</subfield>\n <subfield code=\"3\">http://catalogue.bnf.fr/ark:/12148/cb118956232</subfield>\n <subfield code=\"a\">Cauvin</subfield>\n <subfield code=\"b\">Raoul</subfield>\n <subfield code=\"f\">1938-....</subfield>\n <subfield code=\"7\">ba0yba0y</subfield>\n <subfield code=\"8\">fre </subfield>\n <subfield code=\"9\"> 0 </subfield>\n <subfield code=\"a\">Cauvin</subfield>\n <subfield code=\"b\">Raoul</subfield>\n <subfield code=\"f\">1938-....</subfield>\n <subfield code=\"4\">070</subfield>\n </datafield>\n <datafield tag=\"801\" ind1=\" \" ind2=\"0\">\n <subfield code=\"a\">FR</subfield>\n <subfield code=\"b\">BNF</subfield>\n <subfield code=\"c\">19930527</subfield>\n <subfield code=\"g\">AFNOR</subfield>\n </datafield>\n</record>\n", + "issuedate" : "2015-07-08 15:54:00", + "datelastseen" : "2015-07-25", + "materials" : null, + "cn_class" : "20130702", + "title" : "Cedric :Chaud et froid Vol 6", + "pages" : "46 p.", + "withdrawn_on" : null, + "number" : null, + "itemtype" : "BD", + "totalissues" : null, + "author" : "dessin, Laudec", + "size" : "30 cm", + "replacementprice" : null, + "seriestitle" : "Cédric.", + "timestamp" : "2013-07-02 22:39:55", + "booksellerid" : null, + "editionstatement" : null, + "stocknumber" : null, + "publishercode" : "Dupuis", + "collectionvolume" : null, + "datecreated" : "2006-12-13", + "totalrenewals" : "3", + "reserves" : null, + "editionresponsibility" : null, + "returndate" : "2015-07-22 09:46:43", + "dateaccessioned" : "2006-12-08", + "enumchron" : null, + "notes" : null, + "permanent_location" : null, + "volumedate" : null, + "onloan" : null, + "itype" : "BD", + "illus" : null, + "ean" : null, + "statisticvalue" : null, + "biblioitemnumber" : "53641", + "restricted" : null, + "issuingbranch" : null, + "agerestriction" : null, + "itemlost_on" : null, + "notforloan" : "0", + "replacementpricedate" : null, + "itemnotes" : null, + "location" : "J", + "itemcallnumber" : "BD CAU", + "stack" : null, + "itemlost" : "0", + "itemstimestamp" : "2015-07-25 09:06:22", + "price" : "8.20", + "abstract" : null, + "collectionissn" : null, + "publicationyear" : "1993", + "collectiontitle" : null, + "issues" : "50", + "homebranch" : "IST", + "place" : null, + "issn" : null, + "issuestimestamp" : "2015-07-22 09:46:43", + "cn_source" : "0", + "more_subfields_xml" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<collection\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd\"\n xmlns=\"http://www.loc.gov/MARC21/slim\">\n\n<record>\n <leader> a </leader>\n <datafield tag=\"999\" ind1=\" \" ind2=\" \">\n <subfield code=\"q\">NL4</subfield>\n </datafield>\n</record>\n\n</collection>", + "renewals" : null, + "biblionumber" : "53641", + "holdingbranch" : "COR", + "damaged" : "0", + "unititle" : null, + "cn_sort" : "20130702_000000000000000", + "onsite_checkout" : "0", + "lccn" : null, + "volume" : null, + "return" : null, + "frameworkcode" : "LIVR", + "datelastborrowed" : "2015-07-08", + "volumedesc" : null, + "copynumber" : null, + "paidfor" : null + }, + { + "withdrawn" : "0", + "lastreneweddate" : null, + "auto_renew" : "0", + "coded_location_qualifier" : null, + "marc" : "01156cam 2200313 4500001002100000010003500021020001700056021002700073033005100100090001900151091001900170099000900189100004100198101000800239102000700247105001800254106000600272200010600278210006600384215006600450225002100516345001800537410005600555700005500611701004200666702004700708801007000755913001700825\u001eFRBNF391781900000007\u001e \u001fa2-07-055211-X\u001fbrel.\u001fd4, 30 EUR\u001e \u001faFR\u001fb00431621\u001e \u001faFR\u001fbDLE-20040514-22949\u001e \u001fahttp://catalogue.bnf.fr/ark:/12148/cb391781907\u001e \u001f9128009\u001fa128009\u001e \u001fa2\u001fb20150828\u001fc1\u001e1 \u001ftLIVR\u001e \u001fa20040514d2004 a y0frey50 ba\u001e0 \u001fafre\u001e \u001faFR\u001e \u001fa||||z 00|y|\u001e \u001far\u001e1 \u001faL'hôpital\u001fbTexte imprimé\u001ffDr Catherine Dolto [et Colline Faure-Poirée]\u001fg[ill. par Joëlle Boucher]\u001e \u001fa[Paris]\u001fcGallimard jeunesse-Giboulées\u001fd2004\u001feimpr. en Italie\u001e \u001faNon paginé [8] p.\u001fcill. en coul., couv. ill. en coul.\u001fd16 cm\u001e \u001faMine de rien\u001fv47\u001e \u001fb9782070552115\u001e 0\u001f038975649\u001ftMine de rien (Paris. 2002)\u001fx1636-8738\u001fv47\u001e \u001f311900333\u001faDolto-Tolitch\u001fbCatherine\u001ff1946-....\u001f4070\u001e \u001f311920118\u001faFaure-Poirée\u001fbColline\u001f4070\u001e \u001f311893155\u001faBoucher\u001fbJoëlle\u001ff1947-....\u001f4440\u001e 0\u001faFR\u001fbFR-751131015\u001fc20040514\u001fgAFNOR\u001fhFRBNF391781900000007\u001f2intermrc\u001e00\u001faDOLHOPI99000\u001e\u001d", + "url" : null, + "isbn" : "2-07-055211-X", + "borrowernumber" : "94541", + "branchcode" : "IST", + "copyrightdate" : null, + "itemnumber" : "199574", + "ccode" : null, + "serial" : null, + "cn_suffix" : null, + "barcode" : "31301009552337", + "date_due" : "2015-07-29 23:59:00", + "uri" : null, + "cn_item" : null, + "marcxml" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<record\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd\"\n xmlns=\"http://www.loc.gov/MARC21/slim\">\n\n <leader>01156cam 2200313 4500</leader>\n <controlfield tag=\"001\">FRBNF391781900000007</controlfield>\n <datafield tag=\"010\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">2-07-055211-X</subfield>\n <subfield code=\"b\">rel.</subfield>\n <subfield code=\"d\">4, 30 EUR</subfield>\n </datafield>\n <datafield tag=\"020\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">FR</subfield>\n <subfield code=\"b\">00431621</subfield>\n </datafield>\n <datafield tag=\"021\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">FR</subfield>\n <subfield code=\"b\">DLE-20040514-22949</subfield>\n </datafield>\n <datafield tag=\"033\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">http://catalogue.bnf.fr/ark:/12148/cb391781907</subfield>\n </datafield>\n <datafield tag=\"090\" ind1=\" \" ind2=\" \">\n <subfield code=\"9\">128009</subfield>\n <subfield code=\"a\">128009</subfield>\n </datafield>\n <datafield tag=\"091\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">2</subfield>\n <subfield code=\"b\">20150828</subfield>\n <subfield code=\"c\">1</subfield>\n </datafield>\n <datafield tag=\"099\" ind1=\"1\" ind2=\" \">\n <subfield code=\"t\">LIVR</subfield>\n </datafield>\n <datafield tag=\"100\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">20040514d2004 a y0frey50 ba</subfield>\n </datafield>\n <datafield tag=\"101\" ind1=\"0\" ind2=\" \">\n <subfield code=\"a\">fre</subfield>\n </datafield>\n <datafield tag=\"102\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">FR</subfield>\n </datafield>\n <datafield tag=\"105\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">||||z 00|y|</subfield>\n </datafield>\n <datafield tag=\"106\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">r</subfield>\n </datafield>\n <datafield tag=\"200\" ind1=\"1\" ind2=\" \">\n <subfield code=\"a\">L'hôpital</subfield>\n <subfield code=\"b\">Texte imprimé</subfield>\n <subfield code=\"f\">Dr Catherine Dolto [et Colline Faure-Poirée]</subfield>\n <subfield code=\"g\">[ill. par Joëlle Boucher]</subfield>\n </datafield>\n <datafield tag=\"210\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">[Paris]</subfield>\n <subfield code=\"c\">Gallimard jeunesse-Giboulées</subfield>\n <subfield code=\"d\">2004</subfield>\n <subfield code=\"e\">impr. en Italie</subfield>\n </datafield>\n <datafield tag=\"215\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">Non paginé [8] p.</subfield>\n <subfield code=\"c\">ill. en coul., couv. ill. en coul.</subfield>\n <subfield code=\"d\">16 cm</subfield>\n </datafield>\n <datafield tag=\"225\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">Mine de rien</subfield>\n <subfield code=\"v\">47</subfield>\n </datafield>\n <datafield tag=\"345\" ind1=\" \" ind2=\" \">\n <subfield code=\"b\">9782070552115</subfield>\n </datafield>\n <datafield tag=\"410\" ind1=\" \" ind2=\"0\">\n <subfield code=\"0\">38975649</subfield>\n <subfield code=\"t\">Mine de rien (Paris. 2002)</subfield>\n <subfield code=\"x\">1636-8738</subfield>\n <subfield code=\"v\">47</subfield>\n </datafield>\n <datafield tag=\"700\" ind1=\" \" ind2=\" \">\n <subfield code=\"3\">11900333</subfield>\n <subfield code=\"a\">Dolto-Tolitch</subfield>\n <subfield code=\"b\">Catherine</subfield>\n <subfield code=\"f\">1946-....</subfield>\n <subfield code=\"4\">070</subfield>\n </datafield>\n <datafield tag=\"701\" ind1=\" \" ind2=\" \">\n <subfield code=\"3\">11920118</subfield>\n <subfield code=\"a\">Faure-Poirée</subfield>\n <subfield code=\"b\">Colline</subfield>\n <subfield code=\"4\">070</subfield>\n </datafield>\n <datafield tag=\"702\" ind1=\" \" ind2=\" \">\n <subfield code=\"3\">11893155</subfield>\n <subfield code=\"a\">Boucher</subfield>\n <subfield code=\"b\">Joëlle</subfield>\n <subfield code=\"f\">1947-....</subfield>\n <subfield code=\"4\">440</subfield>\n </datafield>\n <datafield tag=\"801\" ind1=\" \" ind2=\"0\">\n <subfield code=\"a\">FR</subfield>\n <subfield code=\"b\">FR-751131015</subfield>\n <subfield code=\"c\">20040514</subfield>\n <subfield code=\"g\">AFNOR</subfield>\n <subfield code=\"h\">FRBNF391781900000007</subfield>\n <subfield code=\"2\">intermrc</subfield>\n </datafield>\n <datafield tag=\"913\" ind1=\"0\" ind2=\"0\">\n <subfield code=\"a\">DOLHOPI99000</subfield>\n </datafield>\n</record>\n", + "issuedate" : "2015-07-08 15:55:00", + "datelastseen" : "2015-07-22", + "materials" : null, + "cn_class" : "20150828", + "title" : "L'hôpital", + "pages" : "Non paginé [8] p.", + "withdrawn_on" : null, + "number" : null, + "itemtype" : "LIVR", + "totalissues" : null, + "author" : "Dr Catherine Dolto [et Colline Faure-Poirée]", + "size" : "16 cm", + "replacementprice" : null, + "seriestitle" : "Mine de rien", + "timestamp" : "2015-08-28 06:09:00", + "booksellerid" : null, + "editionstatement" : null, + "stocknumber" : null, + "publishercode" : "Gallimard jeunesse-Giboulées", + "collectionvolume" : null, + "datecreated" : "2006-12-13", + "totalrenewals" : "2", + "reserves" : null, + "editionresponsibility" : null, + "returndate" : "2015-07-22 09:46:46", + "dateaccessioned" : "2006-12-09", + "enumchron" : null, + "notes" : null, + "permanent_location" : null, + "volumedate" : null, + "onloan" : null, + "itype" : "LIVR", + "illus" : null, + "ean" : null, + "statisticvalue" : null, + "biblioitemnumber" : "128009", + "restricted" : null, + "issuingbranch" : null, + "agerestriction" : null, + "itemlost_on" : null, + "notforloan" : "0", + "replacementpricedate" : null, + "itemnotes" : null, + "location" : "J", + "itemcallnumber" : "I 610 DOL", + "stack" : null, + "itemlost" : "0", + "itemstimestamp" : "2015-07-22 09:46:46", + "price" : "4.30", + "abstract" : null, + "collectionissn" : null, + "publicationyear" : "2004", + "collectiontitle" : null, + "issues" : "38", + "homebranch" : "IST", + "place" : null, + "issn" : null, + "issuestimestamp" : "2015-07-22 09:46:46", + "cn_source" : "1", + "more_subfields_xml" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<collection\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd\"\n xmlns=\"http://www.loc.gov/MARC21/slim\">\n\n<record>\n <leader> a </leader>\n <datafield tag=\"999\" ind1=\" \" ind2=\" \">\n <subfield code=\"q\">NL4</subfield>\n </datafield>\n</record>\n\n</collection>", + "renewals" : null, + "biblionumber" : "128009", + "holdingbranch" : "IST", + "damaged" : "0", + "unititle" : null, + "cn_sort" : "20150828_000000000000000", + "onsite_checkout" : "0", + "lccn" : null, + "volume" : null, + "return" : null, + "frameworkcode" : "LIVR", + "datelastborrowed" : "2015-07-08", + "volumedesc" : null, + "copynumber" : null, + "paidfor" : null + }, + { + "withdrawn" : "0", + "lastreneweddate" : "2015-07-08 15:57:57", + "auto_renew" : "0", + "coded_location_qualifier" : null, + "marc" : "00820 2200229 4500010003100000090001900031091001900050101001700069102000700086106000600093100004000099200004700139210003900186215001800225225005600243320001800299345005200317410005600369700012100425801003500546099000900581\u001e \u001fa9782258078123\u001fbbr.\u001fd21 eur\u001e \u001f9192111\u001fa192112\u001e \u001fa2\u001fb20130609\u001fc0\u001e \u001fa fre\u001e \u001faFR\u001e \u001far\u001e \u001fa20130606 frey50 \u001e \u001faLe secret du pressoir\u001fbLIVR\u001ffElise Fischer\u001e \u001fa[Paris]\u001fcPresses de la Cité\u001fd2009\u001e \u001fa325 p.\u001fd23 cm\u001e \u001faProduction Jeannine Balland. Romans Terre de France\u001e \u001faBibliographie\u001e \u001faLibrairie de l'Université\u001fb9782258078123\u001fcLIVR\u001e \u001ftProduction Jeannine Balland. Romans Terre de France\u001e \u001f9514247\u001f3http://catalogue.bnf.fr/ark:/12148/cb120682663\u001faFischer\u001fbÉlise\u001f7ba0yba0y\u001f8fre \u001f9 0 \u001faFischer\u001fbÉlise\u001f4070\u001e \u001faFR\u001fbAmazon.fr\u001fc20060101\u001fgAFNOR\u001e \u001ftLIVR\u001e\u001d", + "url" : null, + "isbn" : "9782258078123", + "borrowernumber" : "94541", + "branchcode" : "IST", + "copyrightdate" : null, + "itemnumber" : "335062", + "ccode" : null, + "serial" : null, + "cn_suffix" : null, + "barcode" : "31301010241953", + "date_due" : "2015-08-19 23:59:00", + "uri" : null, + "cn_item" : null, + "marcxml" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<record\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd\"\n xmlns=\"http://www.loc.gov/MARC21/slim\">\n\n <leader>00820 2200229 4500</leader>\n <datafield tag=\"010\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">9782258078123</subfield>\n <subfield code=\"b\">br.</subfield>\n <subfield code=\"d\">21 eur</subfield>\n </datafield>\n <datafield tag=\"090\" ind1=\" \" ind2=\" \">\n <subfield code=\"9\">192111</subfield>\n <subfield code=\"a\">192112</subfield>\n </datafield>\n <datafield tag=\"091\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">2</subfield>\n <subfield code=\"b\">20130609</subfield>\n <subfield code=\"c\">0</subfield>\n </datafield>\n <datafield tag=\"101\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\"> fre</subfield>\n </datafield>\n <datafield tag=\"102\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">FR</subfield>\n </datafield>\n <datafield tag=\"106\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">r</subfield>\n </datafield>\n <datafield tag=\"100\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">20130606 frey50 </subfield>\n </datafield>\n <datafield tag=\"200\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">Le secret du pressoir</subfield>\n <subfield code=\"b\">LIVR</subfield>\n <subfield code=\"f\">Elise Fischer</subfield>\n </datafield>\n <datafield tag=\"210\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">[Paris]</subfield>\n <subfield code=\"c\">Presses de la Cité</subfield>\n <subfield code=\"d\">2009</subfield>\n </datafield>\n <datafield tag=\"215\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">325 p.</subfield>\n <subfield code=\"d\">23 cm</subfield>\n </datafield>\n <datafield tag=\"225\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">Production Jeannine Balland. Romans Terre de France</subfield>\n </datafield>\n <datafield tag=\"320\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">Bibliographie</subfield>\n </datafield>\n <datafield tag=\"345\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">Librairie de l'Université</subfield>\n <subfield code=\"b\">9782258078123</subfield>\n <subfield code=\"c\">LIVR</subfield>\n </datafield>\n <datafield tag=\"410\" ind1=\" \" ind2=\" \">\n <subfield code=\"t\">Production Jeannine Balland. Romans Terre de France</subfield>\n </datafield>\n <datafield tag=\"700\" ind1=\" \" ind2=\" \">\n <subfield code=\"9\">514247</subfield>\n <subfield code=\"3\">http://catalogue.bnf.fr/ark:/12148/cb120682663</subfield>\n <subfield code=\"a\">Fischer</subfield>\n <subfield code=\"b\">Élise</subfield>\n <subfield code=\"7\">ba0yba0y</subfield>\n <subfield code=\"8\">fre </subfield>\n <subfield code=\"9\"> 0 </subfield>\n <subfield code=\"a\">Fischer</subfield>\n <subfield code=\"b\">Élise</subfield>\n <subfield code=\"4\">070</subfield>\n </datafield>\n <datafield tag=\"801\" ind1=\" \" ind2=\" \">\n <subfield code=\"a\">FR</subfield>\n <subfield code=\"b\">Amazon.fr</subfield>\n <subfield code=\"c\">20060101</subfield>\n <subfield code=\"g\">AFNOR</subfield>\n </datafield>\n <datafield tag=\"099\" ind1=\" \" ind2=\" \">\n <subfield code=\"t\">LIVR</subfield>\n </datafield>\n</record>\n", + "issuedate" : "2015-07-08 15:57:00", + "datelastseen" : "2015-07-24", + "materials" : null, + "cn_class" : "20130609", + "title" : "Le secret du pressoir", + "pages" : "325 p.", + "withdrawn_on" : null, + "number" : null, + "itemtype" : "LIVR", + "totalissues" : null, + "author" : "Elise Fischer", + "size" : "23 cm", + "replacementprice" : null, + "seriestitle" : "Production Jeannine Balland. Romans Terre de France", + "timestamp" : "2013-06-09 08:48:22", + "booksellerid" : null, + "editionstatement" : null, + "stocknumber" : null, + "publishercode" : "Presses de la Cité", + "collectionvolume" : null, + "datecreated" : "2009-06-05", + "totalrenewals" : "6", + "reserves" : null, + "editionresponsibility" : null, + "returndate" : null, + "dateaccessioned" : null, + "enumchron" : null, + "notes" : null, + "permanent_location" : "LL", + "volumedate" : null, + "onloan" : "2015-09-04", + "itype" : "LIVR", + "illus" : null, + "ean" : null, + "statisticvalue" : null, + "biblioitemnumber" : "192112", + "restricted" : null, + "issuingbranch" : null, + "agerestriction" : null, + "itemlost_on" : null, + "notforloan" : "0", + "replacementpricedate" : null, + "itemnotes" : null, + "location" : "LL", + "itemcallnumber" : "R FISC", + "stack" : null, + "itemlost" : "0", + "itemstimestamp" : "2015-07-24 11:21:17", + "price" : "21.00", + "abstract" : null, + "collectionissn" : null, + "publicationyear" : "2009", + "collectiontitle" : null, + "issues" : "61", + "homebranch" : "IST", + "place" : null, + "issn" : null, + "issuestimestamp" : "2015-07-22 09:47:52", + "cn_source" : "0", + "more_subfields_xml" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<collection\n xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n xsi:schemaLocation=\"http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd\"\n xmlns=\"http://www.loc.gov/MARC21/slim\">\n\n<record>\n <leader> a </leader>\n <datafield tag=\"999\" ind1=\" \" ind2=\" \">\n <subfield code=\"e\">L10</subfield>\n <subfield code=\"l\">LL40</subfield>\n <subfield code=\"s\">15</subfield>\n </datafield>\n</record>\n\n</collection>", + "renewals" : "1", + "biblionumber" : "192111", + "holdingbranch" : "IST", + "damaged" : "0", + "unititle" : null, + "cn_sort" : "20130609_000000000000000", + "onsite_checkout" : "0", + "lccn" : null, + "volume" : null, + "return" : null, + "frameworkcode" : "LIVR", + "datelastborrowed" : "2015-07-24", + "volumedesc" : null, + "copynumber" : null, + "paidfor" : null + } +] diff --git a/tests/library/Class/WebService/SIGB/KohaRestfulTest.php b/tests/library/Class/WebService/SIGB/KohaRestfulTest.php index 185d9ec0dc9e91f6a59b31c6d4f84c05da83b20d..5c95665347611cad9a83cdb4203b8b3c1c08a662 100644 --- a/tests/library/Class/WebService/SIGB/KohaRestfulTest.php +++ b/tests/library/Class/WebService/SIGB/KohaRestfulTest.php @@ -254,7 +254,7 @@ abstract class KohaRestfulSuggestTestCase extends KohaRestfulTestCase { ->answers('<id>32007</id>') ->whenCalled('postData') - ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/rest.pl/suggestions?', + ->with('http://cat-aficg55.biblibre.com/cgi-bin/koha/rest.pl/suggestions', ['data' => '{"suggestedby":"32007","title":"CommitStrip - Le Livre","author":"CommitStrip","isbn":"","patronreason":null,"publicationyear":"","branchcode":"IST"}']) ->answers($this->_postAnswer()) @@ -393,4 +393,59 @@ class KohaRestfulJsonErrorSuggestTest extends KohaRestfulSuggestTestCase { $this->assertEquals('Échec de la suggestion, le webservice a répondu "Failed to parse data parameter: malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "(end of string)") at /usr/share/perl5/JSON.pm line 171."', $this->response['erreur']); } +} + + + + +class KohaRestGetUserHistoryTest extends KohaRestfulTestCase { + public function setUp() { + parent::setUp(); + + $emprunteur = new Class_WebService_SIGB_Emprunteur('34', 'harlock'); + + $this->fixture('Class_Notice', + ['id' => 1212, + 'titres' => 'L00 HOPITAL OPITAL', + 'auteurs' => 'DOLTO TOLITCH CATHERINE KATERIN FAURE FOR POIREE POIR COLLINE KOLIN BOUCHER BOUCH JOELLE JOEL', + 'annee' => '2004', + 'isbn' => '2-07-055211-X', + 'titre_principal' => 'L\'hôpital', + 'exemplaires' => [$this->fixture('Class_Exemplaire', + ['id' => 234, + 'code_barres' => '31301009552337'])] + + ]); + $this->mock_web_client + ->whenCalled('open_url') + ->with(static::BASE_URL . 'rest.pl/user/byid/34/issues_history') + ->answers(file_get_contents(realpath(dirname(__FILE__)) . '/../../../../fixtures/koha_issues_history.json')); + + $this->loans = $this->service->loansHistory($emprunteur); + } + + + /** @test */ + public function userShouldHaveThreeLoans() { + $this->assertCount(3, $this->loans); + } + + + /** @test */ + public function oneLoanShouldContainsTitleCedricChaudEtFroid() { + $this->assertEquals("Cedric :Chaud et froid Vol 6", $this->loans[0]->getTitre()); + } + + + /** @test */ + public function loanShouldHaveNoticeHopital() { + $this->assertEquals('2004',$this->loans[1]->getNoticeOPAC()->getAnnee()); + } + + + /** @test */ + public function returnDateShouldBe22_07_2015() { + $this->assertEquals('22/07/2015', $this->loans[1]->getDateRetour()); + } + } \ No newline at end of file diff --git a/tests/library/Class/WebService/SIGB/KohaTest.php b/tests/library/Class/WebService/SIGB/KohaTest.php index 589fb5ca08e3a8fa8c6e1c33480e44b8855712d6..ccf2bbb1cc8f4c31caa5f58d074dd2df7bf4d322 100644 --- a/tests/library/Class/WebService/SIGB/KohaTest.php +++ b/tests/library/Class/WebService/SIGB/KohaTest.php @@ -998,6 +998,7 @@ class KohaServiceGetNoticeJardinEnfantWithItemOnTopTest extends KohaTestCase { + class KohaServicePatroninfoReaderWithNoLibTest extends KohaTestCase { public function setUp() { parent::setUp(); @@ -1023,4 +1024,4 @@ class KohaServicePatroninfoReaderWithNoLibTest extends KohaTestCase { public function laurendShouldNotHaveLibrary() { $this->assertEmpty($this->laurent->getLibraryLabel()); } -} \ No newline at end of file +}