Skip to content
Snippets Groups Projects
Commit e4fbc64e authored by pbarroca's avatar pbarroca
Browse files

Téléphone: workflow de réservation sauf écran dédié de login intermédiaire

parent 6da548ef
Branches
Tags
No related merge requests found
......@@ -661,7 +661,9 @@ application/modules/telephone/views/scripts/recherche/detail.phtml -text
application/modules/telephone/views/scripts/recherche/exemplaires.phtml -text
application/modules/telephone/views/scripts/recherche/grandeimage.phtml -text
application/modules/telephone/views/scripts/recherche/index.phtml -text
application/modules/telephone/views/scripts/recherche/pickup-location.phtml -text
application/modules/telephone/views/scripts/recherche/rebond.phtml -text
application/modules/telephone/views/scripts/recherche/reservation.phtml -text
application/modules/telephone/views/scripts/recherche/resume.phtml -text
application/modules/telephone/views/scripts/recherche/similaires.phtml -text
application/modules/telephone/views/scripts/recherche/simple.phtml -text
......
......@@ -55,6 +55,51 @@ class Telephone_RechercheController extends RechercheController {
}
public function reservationAction() {
if (!Class_Users::getLoader()->getIdentity()) {
Zend_Registry::get('session')->lastReservationParams = array('b' => $this->_getParam('b'),
'e' => $this->_getParam('e'),
'a' => $this->_getParam('a'));
$this->_redirect('/auth/login-reservation');
return;
}
if (Class_CosmoVar::isSiteRetraitResaEnabled()
&& !$this->_getParam('pickup')) {
$this->_redirect(sprintf('/recherche/pickup-location/b/%s/e/%s/a/%s',
urlencode($this->_getParam('b')),
urlencode($this->_getParam('e')),
urlencode($this->_getParam('a'))));
return;
}
$ret = Class_CommSigb::getInstance()
->reserverExemplaire($this->_getParam('b'),
$this->_getParam('e'),
($this->_getParam('pickup')) ? $this->_getParam('pickup') : $this->_getParam('a'));
if (isset($ret["erreur"])) {
$this->_loadUrlRetourForExemplaire($this->_getParam('e'));
$this->view->message = $ret['erreur'];
return;
}
if (isset($ret["popup"])) {
$this->_loadUrlRetourForExemplaire($this->_getParam('e'));
$this->view->message = $this->view->_('Réservation en ligne non supportée pour cette bibliothèque.');
return;
}
$this->_redirect('/abonne/fiche');
}
public function pickupLocationAction() {
$this->_loadUrlRetourForExemplaire($this->_getParam('e'));
$this->view->annexes = Class_CodifAnnexe::findAllByPickup();
}
public function resumeAction() {
$this->view->notice = Class_Notice::getLoader()->find($this->_getParam('id'));
}
......@@ -72,4 +117,12 @@ class Telephone_RechercheController extends RechercheController {
$this->view->notice = Class_Notice::getLoader()->find($this->_getParam('id'));
}
}
\ No newline at end of file
protected function _loadUrlRetourForExemplaire($id_exemplaire) {
$exemplaire = Class_Exemplaire::getLoader()->find($id_exemplaire);
$this->view->url_retour = $this->view->url(array('controller' => 'recherche',
'action' => 'exemplaires',
'id' => $exemplaire->getNotice()->getId()),
null, true);
}
}
<?php
echo $this->toolbar($this->_("Site de retrait"),
$this->url_retour,
false); ?>
<div class="pave">
<?php foreach ($this->annexes as $annexe) { ?>
<div class="fonction">
<a href="<?php
echo $this->url(array('action' => 'reservation', 'pickup' => $annexe->getCode()));
?>" style="display:block;"><?php echo $this->escape($annexe->getLibelle());?></a>
</div>
<?php } ?>
</div>
\ No newline at end of file
<?php
echo $this->toolbar($this->_("Réservation"),
$this->url_retour,
false);
?>
<div class="pave">
<?php echo $this->escape($this->message);?>
</div>
\ No newline at end of file
......@@ -28,6 +28,8 @@ class Class_CommSigb {
const COM_ORPHEE = 8;
const COM_MICROBIB = 9;
protected static $_instance;
private $COM_CLASSES = array(self::COM_PERGAME => 'Class_WebService_SIGB_Pergame',
self::COM_OPSYS => 'Class_WebService_SIGB_Opsys',
self::COM_VSMART => 'Class_WebService_SIGB_VSmart',
......@@ -42,6 +44,18 @@ class Class_CommSigb {
private $_translate;
public static function getInstance() {
if (null != self::$_instance)
return self::$_instance;
return new self();
}
public static function setInstance($instance) {
self::$_instance = $instance;
}
public function exemplaireFor($exemplaire) {
$mode_comm = $this->getModeComm($exemplaire->getBib()->getId());
if ($sigb = $this->getSIGBComm($mode_comm))
......
......@@ -390,6 +390,200 @@ class Telephone_RechercheControllerHarryPotterExemplaireReservableTest extends T
class Telephone_RechercheControllerHarryPotterReservationNotLogged extends Telephone_RechercheControllerHarryPotterTestCase {
public function setUp() {
parent::setUp();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Users')
->whenCalled('getIdentity')
->answers(false);
$this->dispatch('/recherche/reservation/b/1/e/33/a/MOUL');
}
/** @test */
public function shouldRedirectToAuth() {
$this->assertRedirectTo('/auth/login-reservation');
}
/** @test */
public function shouldHaveSetReservationBibParam() {
$this->assertEquals(1, Zend_Registry::get('session')->lastReservationParams['b']);
}
/** @test */
public function shouldHaveSetReservationExemplaireParam() {
$this->assertEquals(33, Zend_Registry::get('session')->lastReservationParams['e']);
}
/** @test */
public function shouldHaveSetReservationAnnexeParam() {
$this->assertEquals('MOUL', Zend_Registry::get('session')->lastReservationParams['a']);
}
}
class Telephone_RechercheControllerHarryPotterReservationWithEnabledPickup extends Telephone_RechercheControllerHarryPotterTestCase {
public function setUp() {
parent::setUp();
Class_CosmoVar::getLoader()
->newInstanceWithId('site_retrait_resa')
->setValeur(1);
$this->dispatch('/recherche/reservation/b/1/e/33/a/MOUL');
}
/** @test */
public function shouldRedirectToPickupChoice() {
$this->assertRedirectTo('/recherche/pickup-location/b/1/e/33/a/MOUL');
}
}
class Telephone_RechercheControllerHarryPotterExemplairePickupChoiceTest extends Telephone_RechercheControllerHarryPotterTestCase {
public function setUp() {
parent::setUp();
Class_Exemplaire::getLoader()
->newInstanceWithId(33)
->setCote('JRROW')
->setNotice(Class_Notice::getLoader()->find(4));
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_CodifAnnexe')
->whenCalled('findAllBy')
->with(array('no_pickup' => '0',
'order' => 'libelle'))
->answers(array(Class_CodifAnnexe::getLoader()->newInstanceWithId(2)
->setLibelle('Annecy')
->setCode('ANN'),
Class_CodifAnnexe::getLoader()->newInstanceWithId(3)
->setLibelle('Cran')
->setCode('CRN')));
$this->dispatch('/recherche/pickup-location/b/1/e/33/a/MOUL', true);
}
/** @test */
public function titreShouldBeSiteDeRetrait() {
$this->assertXPathContentContains('//h1', 'Site de retrait');
}
/** @test */
public function pageShouldContainsAnnecyChoice() {
$this->assertXPathContentContains('//a[contains(@href, "/recherche/reservation/b/1/e/33/a/MOUL/pickup/ANN")]',
'Annecy');
}
}
class Telephone_RechercheControllerHarryPotterReservationSuccessTest extends Telephone_RechercheControllerHarryPotterTestCase {
public function setUp() {
parent::setUp();
Class_CosmoVar::getLoader()
->newInstanceWithId('site_retrait_resa')
->setValeur(0);
Class_CommSigb::setInstance(Storm_Test_ObjectWrapper::mock()
->whenCalled('reserverExemplaire')
->answers(array()));
$this->dispatch('/recherche/reservation/b/1/e/33/a/MOUL', true);
}
/** @test */
public function shouldRedirectToFicheAbonne() {
$this->assertRedirectTo('/abonne/fiche');
}
}
class Telephone_RechercheControllerHarryPotterReservationErrorTest extends Telephone_RechercheControllerHarryPotterTestCase {
public function setUp() {
parent::setUp();
Class_CosmoVar::getLoader()
->newInstanceWithId('site_retrait_resa')
->setValeur(0);
Class_CommSigb::setInstance(Storm_Test_ObjectWrapper::mock()
->whenCalled('reserverExemplaire')
->answers(array('erreur' => 'A marche pas')));
Class_Exemplaire::getLoader()
->newInstanceWithId(33)
->setCote('JRROW')
->setNotice(Class_Notice::getLoader()->find(4));
$this->dispatch('/recherche/reservation/b/1/e/33/a/MOUL', true);
}
/** @test */
public function titreShouldBeReservation() {
$this->assertXPathContentContains('//h1', 'Réservation');
}
/** @test */
public function pageShouldContainsErrorMessage() {
$this->assertXPathContentContains('//div', 'A marche pas');
}
/** @test */
public function backLinkToExemplairesShouldBePresent() {
$this->assertXPath('//a[contains(@href, "/recherche/exemplaires/id/4")]');
}
}
class Telephone_RechercheControllerHarryPotterReservationWithPopupTest extends Telephone_RechercheControllerHarryPotterTestCase {
public function setUp() {
parent::setUp();
Class_CosmoVar::getLoader()
->newInstanceWithId('site_retrait_resa')
->setValeur(0);
Class_CommSigb::setInstance(Storm_Test_ObjectWrapper::mock()
->whenCalled('reserverExemplaire')
->answers(array('popup' => 'http://url.de/la-popup')));
Class_Exemplaire::getLoader()
->newInstanceWithId(33)
->setCote('JRROW')
->setNotice(Class_Notice::getLoader()->find(4));
$this->dispatch('/recherche/reservation/b/1/e/33/a/MOUL', true);
}
/** @test */
public function titreShouldBeReservation() {
$this->assertXPathContentContains('//h1', 'Réservation');
}
public function pageShouldContainsErrorMessage() {
$this->assertXPathContentContains('//div', 'non supportée');
}
/** @test */
public function backLinkToExemplairesShouldBePresent() {
$this->assertXPath('//a[contains(@href, "/recherche/exemplaires/id/4")]');
}
}
class Telephone_RechercheControllerHarryPotterAvisTest extends Telephone_RechercheControllerHarryPotterTestCase {
public function setUp() {
......
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