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

Planning d'ouvertures: choix du jour avec date picker

parent 19899b40
Branches
Tags
No related merge requests found
......@@ -23,17 +23,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'));
$fields = ['id_site' => ['element' => 'hidden'],
'jour' => ['element' => 'datePicker',
'options' => ['label' => $this->view->_('Jour')]]];
$field_labels = ['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));
$fields['id_site'] = array('element' => 'hidden');
$fields[$field] = ['element' => 'select', 'options' => ['label' => $label,
'multiOptions' => $hours_select]];
return [
'model' => ['class' => 'Class_Ouverture',
......
......@@ -8,12 +8,20 @@
);
echo $this->tagModelTable($this->ouvertures,
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'))),
[$this->_('Jour'),
$this->_('Matin'),
$this->_(''),
$this->_('Après-midi'),
$this->_('')],
['formatted_jour',
'debut_matin',
'fin_matin',
'debut_apres_midi',
'fin_apres_midi'],
[ ['action' => 'edit', 'content' => $this->boutonIco('type=edit')],
['action' => 'delete', 'content' => $this->boutonIco('type=del')] ],
'ouvertures');
?>
\ No newline at end of file
......@@ -43,3 +43,34 @@
* doc
** [[https://gist.github.com/3126866][Basic Meta Programming with PHP5.4]]
** Histoire de faire un canvas:
#+BEGIN_SRC php
function html ($code , $id="", $class=""){
if ($id !== "") $id = " id = \"$id\"" ;
$class = ($class !== "")? " class =\"$class\"":">";
$open = "<$code$id$class";
$close = "</$code>";
return function ($inner = "") use ($open, $close){
return "$open$inner$close";};
}
$layout = array('container','header','pmain','lsidebar','rsidebar','footer');
foreach ($layout as $element)
$$element = html ("div", $element);
$div = html("div", "test");
$bold = html('strong');
$italic = html('i');
$msg= $div($bold($italic("hello from the left sidebar")));
echo $container(
$header(
"This is the header").$pmain(
$lsidebar(
$msg).$rsidebar(
"This is the right sidebar")).$footer(
));
#+END_SRC
......@@ -54,6 +54,16 @@ class Class_Ouverture extends Storm_Model_Abstract {
public function getHourAttributeNamed($name) {
return substr($this->_get($name), 0, 5);
}
public function getFormattedJour() {
return Class_Date::humanDate($this->getJour(), 'dd/MM/yyyy');
}
public function setJour($jour) {
return $this->_set('jour', Class_Date::humanDate($jour, 'yyyy-MM-dd'));
}
}
?>
\ No newline at end of file
......@@ -32,8 +32,8 @@ abstract class OuverturesControllerTestCase extends Admin_AbstractControllerTest
->whenCalled('findAllBy')->with(['order' => 'debut_matin', 'id_site' => 1])
->answers([
$this->_ouverture_mardi_cran = Class_Ouverture::getLoader()
->newInstanceWithId(2)
$this->_ouverture_mardi_cran = Class_Ouverture::newInstanceWithId(2)
->setJour('2012-07-23')
->setDebutMatin('08:00:00')
->setFinMatin('12:00:00')
->setDebutApresMidi('13:30:00')
......@@ -42,8 +42,8 @@ abstract class OuverturesControllerTestCase extends Admin_AbstractControllerTest
->whenCalled('findAllBy')->with(['order' => 'debut_matin', 'id_site' => 3])
->answers([
$this->_ouverture_jeudi_annecy = Class_Ouverture::getLoader()
->newInstanceWithId(45)
$this->_ouverture_jeudi_annecy = Class_Ouverture::newInstanceWithId(45)
->setJour('2012-07-26')
->setDebutMatin('08:30')
->setFinApresMidi('17:00:00')]);
}
......@@ -60,7 +60,7 @@ class OuverturesControllerIndexActionSiteCranTest extends OuverturesControllerTe
/** @test */
public function ouvertureAtHeightShouldBeVisible() {
public function ouvertureHoursShouldBeVisible() {
$this->assertXPathContentContains('//td', '08:00');
$this->assertXPathContentContains('//td', '12:00');
$this->assertXPathContentContains('//td', '13:30');
......@@ -68,6 +68,12 @@ class OuverturesControllerIndexActionSiteCranTest extends OuverturesControllerTe
}
/** @test */
public function jourShouldBeVisible() {
$this->assertXPathContentContains('//td', '23/07/2012');
}
/** @test */
function pageShouldContainsButtonToCreateOuverture() {
$this->assertXPathContentContains('//div[contains(@onclick, "ouvertures/add/id_site/1")]//td', 'Ajouter une plage d\'ouverture');
......@@ -86,10 +92,10 @@ class OuverturesControllerIndexActionSiteAnnecyTest extends OuverturesController
/** @test */
public function ouvertureAtHeightHalfShouldBeVisible() {
$this->assertXPathContentContains('//td[1]', '08:30');
$this->assertXPathContentContains('//td[2]', '12:00');
$this->assertXPathContentContains('//td[2]', '08:30');
$this->assertXPathContentContains('//td[3]', '12:00');
$this->assertXPathContentContains('//td[4]', '17:00');
$this->assertXPathContentContains('//td[4]', '12:00');
$this->assertXPathContentContains('//td[5]', '17:00');
}
......@@ -125,7 +131,13 @@ class OuverturesControllerEditOuvertureMardiTest extends OuverturesControllerTes
$this->dispatch('/admin/ouvertures/edit/id_site/1/id/2', true);
}
/** @test */
public function formShouldContainsSelectForJour() {
$this->assertXPath('//form//input[@name="jour"][@value="23/07/2012"]');
}
/** @test */
public function formShouldContainsSelectForDebutMatinWithHours() {
$this->assertXPath('//form//select[@name="debut_matin"]//option[@value="07:30"]');
......@@ -160,7 +172,8 @@ class OuverturesControllerPostEditOuvertureMardiCranTest extends OuverturesContr
parent::setUp();
$this->postDispatch('/admin/ouvertures/edit/id/2',
['debut_matin' => '10:30',
'id_site' => 1]);
'id_site' => 1,
'jour' => '23/07/2012']);
}
/** @test */
......@@ -173,6 +186,12 @@ class OuverturesControllerPostEditOuvertureMardiCranTest extends OuverturesContr
public function responseShouldRedirectToOuverturesIndexSiteOne() {
$this->assertRedirectTo('/admin/ouvertures/index/id_site/1');
}
/** @test */
public function jourShouldBe2012_07_23() {
$this->assertEquals('2012-07-23', $this->_ouverture_mardi_cran->getJour());
}
}
......
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