diff --git a/application/modules/admin/controllers/OuverturesController.php b/application/modules/admin/controllers/OuverturesController.php index aebef99f263f3e11b6b3cbe978c59a31837da7f1..41012cb1107c16776f0e4328615ac5efb81faafa 100644 --- a/application/modules/admin/controllers/OuverturesController.php +++ b/application/modules/admin/controllers/OuverturesController.php @@ -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', diff --git a/application/modules/admin/views/scripts/ouvertures/index.phtml b/application/modules/admin/views/scripts/ouvertures/index.phtml index 9ee0b431a6e24207d835603eb3e21ebd4f1f73a5..4aff1483d5b39f85f479fa7cf2a9fe968a161e23 100644 --- a/application/modules/admin/views/scripts/ouvertures/index.phtml +++ b/application/modules/admin/views/scripts/ouvertures/index.phtml @@ -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 diff --git a/categories.org b/categories.org index e0c13600fc9e235304ef1487d5a4af1903bb4667..f2007f5d9d11f6006910bc97f0d1a58c00b9ca62 100644 --- a/categories.org +++ b/categories.org @@ -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 diff --git a/library/Class/Ouverture.php b/library/Class/Ouverture.php index 121b4bf16925b7dc4942dcb1df7bf15e4daa0590..563a80315e0458a226038eea64cb34ca3afcf5f2 100644 --- a/library/Class/Ouverture.php +++ b/library/Class/Ouverture.php @@ -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 diff --git a/tests/application/modules/admin/controllers/OuverturesControllerTest.php b/tests/application/modules/admin/controllers/OuverturesControllerTest.php index e1a3969d2ea8fe054bc4ec34267bebff8abf84b8..0b3daab83972f6a68d9d129c6f7f69f48a04a1ad 100644 --- a/tests/application/modules/admin/controllers/OuverturesControllerTest.php +++ b/tests/application/modules/admin/controllers/OuverturesControllerTest.php @@ -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()); + } }