Skip to content
Snippets Groups Projects
Commit 27abdd9c authored by lbrun's avatar lbrun
Browse files

dev#25892: add consultation reservation table + tests

parent 3844e180
8 merge requests!1553Master,!1502Master,!1501Stable,!1363Master,!1362Master,!1360Master,!1356Dev#25892 module de demande de consultation sur place,!1342Dev#25892 module de demande de consultation sur place
<?php $this->openBoite($this->_('Réservations en cours'));?>
<div class="abonneTitre"> <?php echo $this->user->getNomAff();?></div>
<?php
<div class="abonneTitre">
<?php echo $this->escape($this->user->getNomAff());?>
</div>
echo $this->abonne_ReservationsTable($this->user->getReservations(), $this->fiche);
<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:left"><?php echo $this->_('Etat');?></th>
<th style="text-align:center"><?php echo $this->_('Rang');?></th>
<th style="text-align:center;width:20px"><?php echo $this->_('Suppr.');?></th>
</tr>
</thead>
<tbody>
<?php if ($this->fiche["message"]) { ?>
<tr>
<td colspan="6"><p class="error"><?php echo $this->fiche["message"];?></p></td>
</tr>
<?php } ?>
<?php if ($this->fiche["erreur"]) { ?>
<tr>
<td colspan="6"><p class="error"><?php echo $this->fiche["erreur"];?></p></td>
</tr>
<?php } ?>
<?php
$resas = $this->user->getReservations();
$num=1;
foreach($resas as $resa) { ?>
<tr>
<td width="15px" align="center"><b><?php echo $num++;?></b></td>
<td>
<?php echo $this->tagAnchor(
$this->url(['controller' => 'recherche',
'action' => 'viewnotice',
'id' => $resa->getNoticeOPACId(),
'retour_abonne' => 'reservations'],
null, true),
$resa->getTitre());?>
</td>
<td><?php echo $this->escape(strip_tags($resa->getAuteur()));?></td>
<td><?php echo $this->escape($resa->getBibliotheque());?></td>
<td style="text-align:left"><?php echo $this->escape($resa->getEtat());?></td>
<td style="text-align:center"><?php echo $this->escape($resa->getRang());?></td>
<td style="text-align:center">
<?php echo $this->tagAnchor(
$this->url(['id_delete' => $resa->getId()]),
$this->tagImg(URL_IMG . 'bouton/cancel.gif',
['onclick' => 'return confirm(\''. str_replace("'", "\\'", $this->_('Etes vous sûr de vouloir supprimer cette réservation ?')) . '\')',
'title' => $this->_('Supprimer cette réservation')]));
?>
</td>
</tr>
<?php } ?>
</tbody>
</table>
echo $this->tag('h2', $this->_('Réservation de consultation sur place'));
echo $this->abonne_ReservationsTable($this->user->getReservations(), $this->fiche);
<?php $this->closeBoite();?>
<?php echo $this->abonne_RetourFiche(); ?>
<br/>
<br/>
$this->closeBoite();
echo $this->abonne_RetourFiche();
?>
<?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_ReservationsTable extends ZendAfi_View_Helper_BaseHelper {
protected $_line_no;
public function abonne_ReservationsTable($reservations, $fiche) {
Class_ScriptLoader::getInstance()->loadTableSorter();
return $this->_tag('table',
$this->_renderHeader() . $this->_renderReservations($reservations, $fiche),
['class' => 'tablesorter reservations']);
}
protected function _renderHeader() {
$headers = array_map(
function($title) {
return $this->_tag('th', $title);
},
[$this->_('n°'),
$this->_('Titre'),
$this->_('Auteur'),
$this->_('Bibliothèque'),
$this->_('État'),
$this->_('Rang'),
$this->_('Suppr.')]);
return $this->_tag('thead',
$this->_tag('tr',
implode('', $headers)));
}
protected function _renderReservations($reservations, $fiche) {
$html = '';
$html .= (isset($fiche['message']) && $fiche['message'] ? $this->_renderError($fiche['message']) : '');
$html .= (isset($fiche['erreur']) && $fiche['erreur'] ? $this->_renderError($fiche['erreur']) : '');
$this->_line_no = 1;
foreach($reservations as $reservation)
$html .= $this->_renderReservation($reservation);
return $this->_tag('tbody', $html);
}
protected function _renderReservation($reservation) {
$notice_url = $reservation->getTitre();
if ($reservation->getNoticeOPACId())
$notice_url = $this->view->tagAnchor($this->view->url(
['controller' => 'recherche',
'action' => 'viewnotice',
'id' => $reservation->getNoticeOPACId(),
'retour_abonne' => 'reservations'],
null, true),
$reservation->getTitre());
$cancel_url = $this->view->tagAnchor($this->view->url(['id_delete' => $reservation->getId()]),
$this->view->tagImg(URL_IMG . 'bouton/cancel.gif',
['onclick' => 'return confirm(\''. str_replace("'", "\\'", $this->_('Etes vous sûr de vouloir supprimer cette réservation ?')) . '\')',
'title' => $this->_('Supprimer cette réservation')]));
return
$this->_tag('tr',
$this->_tag('td',
$this->_line_no++)
. $this->_tag('td',
$notice_url)
. $this->_tag('td',
strip_tags($reservation->getAuteur()))
. $this->_tag('td',
$reservation->getBibliotheque())
. $this->_tag('td',
$reservation->getEtat())
. $this->_tag('td',
$reservation->getRang())
. $this->_tag('td',
$cancel_url));
}
protected function _renderError($content) {
return $this->_tag('tr',
$this->_tag('td',
$this->_tag('p', $content, ['class' => 'error']),
['colspan' => '6']));
}
}
?>
\ No newline at end of file
......@@ -671,6 +671,44 @@ table.loans-history td:first-child {
text-align: center;
}
/* reservations in patron screen */
table.reservations {
margin-bottom: 30px;
width: 100%;
}
table.reservations th {
text-align:left;
}
table.reservations th:first-child {
white-space: nowrap;
}
table.reservations th:last-child {
width: 20px;
}
table.reservations th:nth-child(6),
table.reservations th:nth-child(7) {
text-align: center;
}
table.reservations td:first-child {
width: 15px;
font-weight: bold;
text-align: center;
}
table.reservations td:nth-child(5) {
text-align: left;
}
table.reservations td:nth-child(6),
table.reservations td:nth-child(7) {
text-align: center;
}
/* Formulaires */
.zend_form {
background-color:#F0F0F0;
......
......@@ -811,13 +811,13 @@ class VSmartServiceSuccessPlaceRequestTest extends VSmartServiceTestCase {
/** @test */
public function getResultShouldReturnTrue() {
$this->assertEquals(1, $this->consultation->getResult());
$this->assertEquals(1, $this->consultation['statut']);
}
/** @test */
public function getResultReasonShouldReturnEmpty() {
$this->assertEquals('', $this->consultation->getResultReason());
$this->assertEquals('', $this->consultation['erreur']);
}
}
......@@ -841,14 +841,14 @@ class VSmartServiceFailPlaceRequestTest extends VSmartServiceTestCase {
/** @test */
public function getResultShouldReturnFalse() {
$this->assertEquals(0,$this->consultation->getResult());
$this->assertEquals(0,$this->consultation['statut']);
}
/** @test */
public function getErrorShouldReturnTooMuchDemand() {
$this->assertEquals('Vous avez trop de demandes et n\'êtes pas autorisé à en créer de nouvelles',
$this->consultation->getResultReason());
$this->consultation['erreur']);
}
}
......
<?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 ReservationsTableTest extends ViewHelperTestCase {
protected $_html;
public function setUp() {
parent::setUp();
$harry_potter = new Class_WebService_SIGB_Reservation('10', new Class_WebService_SIGB_Exemplaire(100));
$harry_potter->getExemplaire()
->setTitre('Harry Potter')
->setNoticeOPAC(Class_Notice::newInstanceWithId(100));
$harry_potter->setEtat('Pas disponible');
$le_marche = new Class_WebService_SIGB_Reservation('12', new Class_WebService_SIGB_Exemplaire(120));
$le_marche->getExemplaire()
->setTitre('Le marché couvert')
->setNoticeOPAC(Class_Notice::newInstanceWithId(120));
$le_marche->setEtat('Disponible');
$emprunteur = new Class_WebService_SIGB_Emprunteur('1234', 'Estelle');
$user = Class_Users::newInstanceWithId('123456', ['nom' => 'Estelle'])
->setFicheSigb(['fiche' => $emprunteur]);
ZendAfi_Auth::getInstance()->logUser($user);
$emprunteur->reservationsAddAll([$harry_potter, $le_marche]);
$helper = new ZendAfi_View_Helper_Abonne_ReservationsTable();
$helper->setView(new ZendAfi_Controller_Action_Helper_View());
$this->_html = $helper->abonne_ReservationsTable($emprunteur->getReservations(), $user->getFicheSigb());
}
/** @test */
public function TitleShouldBeHarryPotter() {
$this->assertXPathContentContains($this->_html, '//td', 'Harry Potter');
}
/** @test */
public function HarryPotterTitleShouldBeLinkToNotice() {
$this->assertXPathContentContains($this->_html, '//td/a[contains(@href, "recherche/viewnotice/id/100/retour_abonne/reservations")]', 'Harry Potter');
}
}
?>
\ 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