Skip to content
Snippets Groups Projects
Commit 826da6c8 authored by llaffont's avatar llaffont
Browse files

Ajout + modification plages d'ouverture: matin + apres midi

parent 8272c76d
Branches
Tags
No related merge requests found
......@@ -21,6 +21,18 @@
class Admin_OuverturesController extends ZendAfi_Controller_Action {
public function getRessourceDefinitions() {
$hours_select = Class_Multimedia_Location::getLoader()->getPossibleHours(30);
$fields = array();
$field_labels = array('debut_matin' => $this->view->_('Début matinée'),
'fin_matin' => $this->view->_('Fin matinée'),
'debut_apres_midi' => $this->view->_('Début après-midi'),
'fin_apres_midi' => $this->view->_('Fin après-midi'));
foreach ($field_labels as $field => $label)
$fields[$field] = array('element' => 'select',
'options' => array('label' => $label,
'multiOptions' => $hours_select));
return array(
'model' => array('class' => 'Class_Ouverture',
'name' => 'ouverture',
......@@ -34,12 +46,7 @@ class Admin_OuverturesController extends ZendAfi_Controller_Action {
'index' => array('title' => 'Plages d\'ouverture')),
'display_groups' => array('plage_ouverture' => array('legend' => 'Plage d\'ouverture',
'elements' => array(
'debut_matin' => array('element' => 'select',
'options' => array('label' => 'Début matinée',
'multiOptions' => Class_Multimedia_Location::getLoader()->getPossibleHours(30))
)
)
'elements' => $fields
)
)
);
......
<?php
echo $this->bouton('id=add_category',
'picto=add.gif',
'texte=' . $this->traduire('Ajouter une plage d\'ouverture'),
'url=' . $this->url(array('action' => 'add',
'id' => null,
'site_id' => 1))
);
echo $this->tagModelTable($this->ouvertures,
array($this->_('Début matin')),
array('debut_matin'),
array($this->_('Matin'),
$this->_(''),
$this->_('Après-midi'),
$this->_('')),
array('debut_matin', 'fin_matin', 'debut_apres_midi', 'fin_apres_midi'),
array(array('action' => 'edit', 'content' => $this->boutonIco('type=edit')),
array('action' => 'delete', 'content' => $this->boutonIco('type=del'))),
'ouvertures');
......
......@@ -3,9 +3,10 @@
* AFI Multimedia
** Planning des ouvertures
[[file:library/Class/Ouverture.php::class%20Class_Ouverture%20extends%20Storm_Model_Abstract%20{][Modele Ouverture]]
[[file:application/modules/admin/views/scripts/ouvertures/edit.phtml::<?php%20echo%20$this->renderForm($this->form)%3B%20?][Vue edit ouverture]] - [[http://localhost/afi-opac3/admin/ouvertures/edit/site_id/1/id/2][Page édition d'une ouverture]]
[[file:tests/application/modules/admin/controllers/OuverturesControllerTest.php::abstract%20class%20OuverturesControllerTestCase%20extends%20Admin_AbstractControllerTestCase%20{][Tests Controller Ouvertures]]
[[file:application/modules/admin/controllers/OuverturesController.php::class%20Admin_OuverturesController%20extends%20ZendAfi_Controller_Action%20{][Controller Ouvertures]]
[[file:application/modules/admin/views/scripts/ouvertures/edit.phtml::<?php%20echo%20$this->renderForm($this->form)%3B%20?][Vue edit ouverture]] - [[http://localhost/afi-opac3/admin/ouvertures/edit/site_id/1/id/2][Page édition d'une ouverture]]
** Skin réservation timeline
[[http://localhost/afi-opac3/abonne/multimedia-hold-location][url page réservation]]
[[file:public/opac/css/global.css::.timeline%20{][CSS .timeline]]
......@@ -36,3 +37,7 @@
* A refactorer [0/1]
** TODO [#A] [[file:library/Class/Multimedia/Location.php::public%20function%20getPossibleHours($increment,%20$from%20%3D%20null,%20$to%20%3D%20null)%20{][::getPossibleHours à mettre dans une classe Date ou Time ...]]
* doc
** [[https://gist.github.com/3126866][Basic Meta Programming with PHP5.4]]
......@@ -25,6 +25,31 @@ class Class_Ouverture extends Storm_Model_Abstract {
public function getLibelle() {
return '';
}
public function getDebutMatin() {
return $this->getHourAttributeNamed('debut_matin');
}
public function getFinMatin() {
return $this->getHourAttributeNamed('fin_matin');
}
public function getDebutApresMidi() {
return $this->getHourAttributeNamed('debut_apres_midi');
}
public function getFinApresMidi() {
return $this->getHourAttributeNamed('fin_apres_midi');
}
public function getHourAttributeNamed($name) {
return substr($this->_get($name), 0, 5);
}
}
?>
\ No newline at end of file
......@@ -21,28 +21,47 @@
require_once 'AdminAbstractControllerTestCase.php';
abstract class OuverturesControllerTestCase extends Admin_AbstractControllerTestCase {
protected $_ouverture_mardi;
public function setUp() {
parent::setUp();
Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Ouverture')
->whenCalled('findAll')
->whenCalled('save')
->answers(true)
->whenCalled('findAllBy')
->answers(array(
Class_Ouverture::getLoader()
$this->_ouverture_mardi = Class_Ouverture::getLoader()
->newInstanceWithId(2)
->setDebutMatin('08h00')));
->setDebutMatin('08:00:00')
->setFinMatin('12:00:00')
->setDebutApresMidi('13:30:00')
->setFinApresMidi('17:00:00')));
}
}
class OuverturesControllerIndexActionTest extends OuverturesControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/admin/ouvertures', true);
$this->dispatch('/admin/ouvertures/index/site_id/1', true);
}
/** @test */
public function ouvertureAtHeightShouldBeVisible() {
$this->assertXPath('//td', '08h00');
$this->assertXPathContentContains('//td', '08:00', $this->_response->getBody());
$this->assertXPathContentContains('//td', '12:00');
$this->assertXPathContentContains('//td', '13:30');
$this->assertXPathContentContains('//td', '17:00');
}
/** @test */
function pageShouldContainsButtonToCreateOuverture() {
$this->assertXPathContentContains('//div[contains(@onclick, "ouvertures/add/site_id/1")]//td', 'Ajouter une plage d\'ouverture');
}
}
......@@ -57,8 +76,44 @@ class OuverturesControllerEditOuvertureMardiTest extends OuverturesControllerTes
/** @test */
public function formShouldContainsSelectForDebutMatin() {
$this->assertXPath('//form//select');
public function formShouldContainsSelectForDebutMatinWithHours() {
$this->assertXPath('//form//select[@name="debut_matin"]//option[@value="07:30"]');
$this->assertXPath('//form//select[@name="debut_matin"]//option[@value="08:00"][@selected="selected"]');
$this->assertXPath('//form//select[@name="debut_matin"]//option[@value="16:00"]');
}
/** @test */
public function formShouldContainsSelectForFinMatin() {
$this->assertXPath('//form//select[@name="fin_matin"]//option[@value="12:00"][@selected="selected"]');
}
/** @test */
public function formShouldContainsSelectForDebutApresMidi() {
$this->assertXPath('//form//select[@name="debut_apres_midi"]//option[@value="13:30"][@selected="selected"]');
}
/** @test */
public function formShouldContainsSelectForFinApresMidi() {
$this->assertXPath('//form//select[@name="fin_apres_midi"]//option[@value="17:00"][@selected="selected"]');
}
}
class OuverturesControllerPostEditOuvertureMardiTest extends OuverturesControllerTestCase {
public function setUp() {
parent::setUp();
$this->postDispatch('/admin/ouvertures/edit/site_id/1/id/2',
array('debut_matin' => '10:30'));
}
/** @test */
public function heureDebutMatinShouldBe_10_30() {
$this->assertEquals('10:30', $this->_ouverture_mardi->getDebutMatin());
}
}
......
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