diff --git a/Controller/AccompanyingPeriodController.php b/Controller/AccompanyingPeriodController.php index edc469718..dac9336f2 100644 --- a/Controller/AccompanyingPeriodController.php +++ b/Controller/AccompanyingPeriodController.php @@ -42,7 +42,7 @@ class AccompanyingPeriodController extends Controller $person = $this->_getPerson($person_id); $accompanyingPeriod = new AccompanyingPeriod(new \DateTime()); - $accompanyingPeriod->setDateClosing(new \DateTime()); + $accompanyingPeriod->setClosingDate(new \DateTime()); $person->addAccompanyingPeriod( $accompanyingPeriod); diff --git a/Entity/AccompanyingPeriod.php b/Entity/AccompanyingPeriod.php index 94c642161..eefcac905 100644 --- a/Entity/AccompanyingPeriod.php +++ b/Entity/AccompanyingPeriod.php @@ -30,47 +30,33 @@ use Symfony\Component\Validator\ExecutionContextInterface; */ class AccompanyingPeriod { - /** - * @var integer - */ + /** @var integer */ private $id; - /** - * @var \DateTime - */ - private $date_opening; + /** @var \DateTime */ + private $openingDate; - /** - * @var \DateTime - */ - private $date_closing; + /** @var \DateTime */ + private $closingDate; - /** - * @var string - */ - private $memo = ''; + /** @var string */ + private $remark = ''; - /** - * @var \Chill\PersonBundle\Entity\Person - */ + /** @var \Chill\PersonBundle\Entity\Person */ private $person; - /** - * - * @var AccompanyingPeriod\ClosingMotive - */ + /** @var AccompanyingPeriod\ClosingMotive */ private $closingMotive = null; /** * * @param \DateTime $dateOpening - * @uses AccompanyingPeriod::setDateClosing() + * @uses AccompanyingPeriod::setClosingDate() */ public function __construct(\DateTime $dateOpening) { - $this->setDateOpening($dateOpening); + $this->setOpeningDate($dateOpening); } - /** * Get id * @@ -82,30 +68,30 @@ class AccompanyingPeriod } /** - * Set date_opening + * Set openingDate * * @param \DateTime $dateOpening * @return AccompanyingPeriod */ - public function setDateOpening($dateOpening) + public function setOpeningDate($openingDate) { - $this->date_opening = $dateOpening; + $this->openingDate = $openingDate; return $this; } /** - * Get date_opening + * Get openingDate * * @return \DateTime */ - public function getDateOpening() + public function getOpeningDate() { - return $this->date_opening; + return $this->openingDate; } /** - * Set date_closing + * Set closingDate * * For closing a Person file, you should use Person::setClosed instead. * @@ -113,21 +99,21 @@ class AccompanyingPeriod * @return AccompanyingPeriod * */ - public function setDateClosing($dateClosing) + public function setClosingDate($closingDate) { - $this->date_closing = $dateClosing; + $this->closingDate = $closingDate; return $this; } /** - * Get date_closing + * Get closingDate * * @return \DateTime */ - public function getDateClosing() + public function getClosingDate() { - return $this->date_closing; + return $this->closingDate; } /** @@ -135,7 +121,7 @@ class AccompanyingPeriod * @return boolean */ public function isOpen() { - if ($this->getDateClosing() === null) { + if ($this->getClosingDate() === null) { return true; } else { return false; @@ -143,30 +129,30 @@ class AccompanyingPeriod } /** - * Set memo + * Set remark * - * @param string $memo + * @param string $remark * @return AccompanyingPeriod */ - public function setMemo($memo) + public function setRemark($remark) { - if ($memo === null) { - $memo = ''; + if ($remark === null) { + $remark = ''; } - $this->memo = $memo; + $this->remark = $remark; return $this; } /** - * Get memo + * Get remark * * @return string */ - public function getMemo() + public function getRemark() { - return $this->memo; + return $this->remark; } /** @@ -225,7 +211,7 @@ class AccompanyingPeriod * @return boolean */ public function isClosingAfterOpening() { - $diff = $this->getDateOpening()->diff($this->getDateClosing()); + $diff = $this->getOpeningDate()->diff($this->getClosingDate()); if ($diff->invert === 0) { return true; diff --git a/Entity/Person.php b/Entity/Person.php index fa3ede22b..f9d8e94f5 100644 --- a/Entity/Person.php +++ b/Entity/Person.php @@ -192,12 +192,12 @@ class Person implements HasCenterInterface { //order by date : usort($periods, function($a, $b) { - $dateA = $a->getDateOpening(); - $dateB = $b->getDateOpening(); + $dateA = $a->getOpeningDate(); + $dateB = $b->getOpeningDate(); if ($dateA == $dateB) { - $dateEA = $a->getDateClosing(); - $dateEB = $b->getDateClosing(); + $dateEA = $a->getClosingDate(); + $dateEB = $b->getClosingDate(); if ($dateEA == $dateEB) { return 0; @@ -647,17 +647,17 @@ class Person implements HasCenterInterface { if($periodI->isOpen()) { return array( 'result' => self::ERROR_ADDIND_PERIOD_AFTER_AN_OPEN_PERIOD, - 'dateOpening' => $periodAfterI->getDateOpening(), - 'dateClosing' => $periodAfterI->getDateClosing(), - 'date' => $periodI->getDateOpening() + 'dateOpening' => $periodAfterI->getOpeningDate(), + 'dateClosing' => $periodAfterI->getClosingDate(), + 'date' => $periodI->getOpeningDate() ); - } elseif ($periodI->getDateClosing() >= $periodAfterI->getDateOpening()) { + } elseif ($periodI->getClosingDate() >= $periodAfterI->getOpeningDate()) { return array( 'result' => self::ERROR_PERIODS_ARE_COLLAPSING, - 'dateOpening' => $periodI->getDateOpening(), + 'dateOpening' => $periodI->getOpeningDate(), - 'dateClosing' => $periodI->getDateClosing(), - 'date' => $periodAfterI->getDateOpening() + 'dateClosing' => $periodI->getClosingDate(), + 'date' => $periodAfterI->getOpeningDate() ); } $i++; diff --git a/Form/AccompanyingPeriodType.php b/Form/AccompanyingPeriodType.php index f27820651..412ad06df 100644 --- a/Form/AccompanyingPeriodType.php +++ b/Form/AccompanyingPeriodType.php @@ -19,7 +19,7 @@ class AccompanyingPeriodType extends AbstractType //if the period_action is close, date opening should not be seen if ($options['period_action'] !== 'close') { $builder - ->add('date_opening', 'date', array( + ->add('openingDate', 'date', array( "required" => true, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy' @@ -40,13 +40,13 @@ class AccompanyingPeriodType extends AbstractType OR ($options['period_action'] === 'update' AND !$accompanyingPeriod->isOpen()) ) { - $form->add('date_closing', 'date', array('required' => true, + $form->add('closingDate', 'date', array('required' => true, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')); $form->add('closingMotive', 'closing_motive'); } }); - $builder->add('memo', 'textarea', array( + $builder->add('remark', 'textarea', array( 'required' => false )) ; diff --git a/Resources/config/doctrine/AccompanyingPeriod.orm.yml b/Resources/config/doctrine/AccompanyingPeriod.orm.yml index f62cfaa53..fa9718c84 100644 --- a/Resources/config/doctrine/AccompanyingPeriod.orm.yml +++ b/Resources/config/doctrine/AccompanyingPeriod.orm.yml @@ -7,13 +7,13 @@ Chill\PersonBundle\Entity\AccompanyingPeriod: id: true generator: { strategy: AUTO } fields: - date_opening: + openingDate: type: date - date_closing: + closingDate: type: date default: null nullable: true - memo: + remark: type: text manyToOne: person: diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 72c6b5d5e..3950eaa2f 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -48,11 +48,11 @@ chill_person_search: chill_person_accompanying_period_list: path: /{_locale}/person/{person_id}/accompanying-period defaults: { _controller: ChillPersonBundle:AccompanyingPeriod:list } -# options: -# menus: -# person: -# order: 100 -# label: menu.person.history + options: + menus: + person: + order: 100 + label: Accompanying period list chill_person_accompanying_period_create: path: /{_locale}/person/{person_id}/accompanying-period/create diff --git a/Resources/config/validation.yml b/Resources/config/validation.yml index ed0ce1527..ccda164ee 100644 --- a/Resources/config/validation.yml +++ b/Resources/config/validation.yml @@ -35,12 +35,12 @@ Chill\PersonBundle\Entity\Person: Chill\PersonBundle\Entity\AccompanyingPeriod: properties: - date_opening: + openingDate: - Date: message: 'Opening date is not valid' - NotNull: message: 'Opening date can not be null' - date_closing: + closingDate: - Date: message: 'Closing date is not valid' - NotNull: diff --git a/Resources/migrations/Version20150820113409.php b/Resources/migrations/Version20150820113409.php new file mode 100644 index 000000000..1c01c0f93 --- /dev/null +++ b/Resources/migrations/Version20150820113409.php @@ -0,0 +1,61 @@ +, + * + * This program 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, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 this program. If not, see . + */ + +namespace Application\Migrations; + +use Doctrine\DBAL\Migrations\AbstractMigration; +use Doctrine\DBAL\Schema\Schema; + +/** + * Migration for adapting the Person Bundle to the 'cahier de charge' : + * - update of accompanyingPerid + */ +class Version20150820113409 extends AbstractMigration +{ + /** + * @param Schema $schema + */ + public function up(Schema $schema) + { + $this->abortIf( + $this->connection->getDatabasePlatform()->getName() != 'postgresql', + 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE accompanying_period RENAME COLUMN date_opening TO openingdate;'); + $this->addSql('ALTER TABLE accompanying_period RENAME COLUMN date_closing TO closingdate;'); + $this->addSql('ALTER TABLE accompanying_period RENAME COLUMN memo TO remark;'); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + $this->abortIf( + $this->connection->getDatabasePlatform()->getName() != 'postgresql', + 'Migration can only be executed safely on \'postgresql\'.'); + + $this->addSql('ALTER TABLE accompanying_period RENAME COLUMN openingdate TO date_opening;'); + $this->addSql('ALTER TABLE accompanying_period RENAME COLUMN closingdate TO date_closing;'); + $this->addSql('ALTER TABLE accompanying_perod RENAME COLUMN remark TO memo;'); + } +} diff --git a/Resources/views/AccompanyingPeriod/form.html.twig b/Resources/views/AccompanyingPeriod/form.html.twig index 94006b2f6..98c538323 100644 --- a/Resources/views/AccompanyingPeriod/form.html.twig +++ b/Resources/views/AccompanyingPeriod/form.html.twig @@ -10,17 +10,17 @@ {{ form_start(form) }} {{ 'Last opening since %last_opening%'|trans( - { '%last_opening%' : accompanying_period.dateOpening|localizeddate('long', 'none', app.request.locale) }) }} + { '%last_opening%' : accompanying_period.openingDate|localizeddate('long', 'none', app.request.locale) }) }} -{% if form.dateClosing is defined %} - {{ form_row(form.dateClosing, {'label' : 'Closing date'} ) }} +{% if form.closingDate is defined %} + {{ form_row(form.closingDate, {'label' : 'Closing date'} ) }} {% endif %} {% if form.closingMotive is defined %} {{ form_row(form.closingMotive, {'label' : 'Closing motive'} ) }} {% endif %} -{{ form_row(form.memo, {'label' : 'Memo' } ) }} +{{ form_row(form.remark, {'label' : 'Remark' } ) }} {{ form_rest(form) }} diff --git a/Resources/views/AccompanyingPeriod/list.html.twig b/Resources/views/AccompanyingPeriod/list.html.twig index 0bf66624a..e416a4351 100644 --- a/Resources/views/AccompanyingPeriod/list.html.twig +++ b/Resources/views/AccompanyingPeriod/list.html.twig @@ -18,13 +18,13 @@ {% set i = 0 %} {% for accompanying_period in accompanying_periods %} - {{ accompanying_period.dateOpening|localizeddate('long', 'none', app.request.locale) }} + {{ accompanying_period.openingDate|localizeddate('long', 'none', app.request.locale) }} {% spaceless %} {% if accompanying_period.isOpen %} {{ 'Still open'|trans }} {% else %} - {{ accompanying_period.dateClosing|localizeddate('long', 'none', app.request.locale) }} + {{ accompanying_period.closingDate|localizeddate('long', 'none', app.request.locale) }} {% endif %} {% endspaceless %} @@ -34,10 +34,10 @@ - {% if accompanying_period.memo is not empty %} + {% if accompanying_period.remark is not empty %} -
{{ accompanying_period.memo }}
+
{{ accompanying_period.remark }}
{% endif %} diff --git a/Tests/Controller/AccompanyingPeriodControllerTest.php b/Tests/Controller/AccompanyingPeriodControllerTest.php index 09be9807e..47b7816be 100644 --- a/Tests/Controller/AccompanyingPeriodControllerTest.php +++ b/Tests/Controller/AccompanyingPeriodControllerTest.php @@ -55,8 +55,8 @@ class AccompanyingPeriodControllerTest extends WebTestCase */ protected static $em; - const OPENING_INPUT = 'chill_personbundle_accompanyingperiod[date_opening]'; - const CLOSING_INPUT = 'chill_personbundle_accompanyingperiod[date_closing]'; + const OPENING_INPUT = 'chill_personbundle_accompanyingperiod[openingDate]'; + const CLOSING_INPUT = 'chill_personbundle_accompanyingperiod[closingDate]'; const CLOSING_MOTIVE_INPUT = 'chill_personbundle_accompanyingperiod[closingMotive]'; /** @@ -114,7 +114,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase . 'motive into your periods fixtures'); } - $period->setDateClosing(new \DateTime($periodDef['closingDate'])) + $period->setClosingDate(new \DateTime($periodDef['closingDate'])) ->setClosingMotive($periodDef['closingMotive']); } diff --git a/Tests/Entity/AccompanyingPeriodTest.php b/Tests/Entity/AccompanyingPeriodTest.php index 99bd24677..26f3c60fc 100644 --- a/Tests/Entity/AccompanyingPeriodTest.php +++ b/Tests/Entity/AccompanyingPeriodTest.php @@ -32,7 +32,7 @@ class AccompanyingPeriodTest extends \PHPUnit_Framework_TestCase $datetime2 = new \DateTime('tomorrow'); $period = new AccompanyingPeriod($datetime1); - $period->setDateClosing($datetime2); + $period->setClosingDate($datetime2); $r = $period->isClosingAfterOpening(); @@ -44,7 +44,7 @@ class AccompanyingPeriodTest extends \PHPUnit_Framework_TestCase $datetime2 = new \DateTime('now'); $period = new AccompanyingPeriod($datetime1); - $period->setDateClosing($datetime2); + $period->setClosingDate($datetime2); $this->assertFalse($period->isClosingAfterOpening()); } @@ -53,7 +53,7 @@ class AccompanyingPeriodTest extends \PHPUnit_Framework_TestCase $datetime = new \DateTime('now'); $period = new AccompanyingPeriod($datetime); - $period->setDateClosing($datetime); + $period->setClosingDate($datetime); $this->assertTrue($period->isClosingAfterOpening()); } @@ -66,7 +66,7 @@ class AccompanyingPeriodTest extends \PHPUnit_Framework_TestCase public function testIsClosed() { $period = new AccompanyingPeriod(new \DateTime()); - $period->setDateClosing(new \DateTime('tomorrow')); + $period->setClosingDate(new \DateTime('tomorrow')); $this->assertFalse($period->isOpen()); } diff --git a/Tests/Entity/PersonTest.php b/Tests/Entity/PersonTest.php index 0e7ef97c5..4e4ff19b8 100644 --- a/Tests/Entity/PersonTest.php +++ b/Tests/Entity/PersonTest.php @@ -44,10 +44,10 @@ class PersonTest extends \PHPUnit_Framework_TestCase $this->assertInstanceOf('Chill\PersonBundle\Entity\AccompanyingPeriod', $period); $this->assertTrue($period->isOpen()); - $this->assertEquals($d, $period->getDateOpening()); + $this->assertEquals($d, $period->getOpeningDate()); //close and test - $period->setDateClosing(new \DateTime('tomorrow')); + $period->setClosingDate(new \DateTime('tomorrow')); $shouldBeNull = $p->getCurrentAccompanyingPeriod(); $this->assertNull($shouldBeNull); @@ -63,19 +63,19 @@ class PersonTest extends \PHPUnit_Framework_TestCase $p = new Person($d); $e = new \DateTime("2013/3/1"); - $period = $p->getCurrentAccompanyingPeriod()->setDateClosing($e); + $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e); $p->close($period); $f = new \DateTime("2013/1/1"); $p->open(new AccompanyingPeriod($f)); $g = new \DateTime("2013/4/1"); - $period = $p->getCurrentAccompanyingPeriod()->setDateClosing($g); + $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g); $p->close($period); $r = $p->getAccompanyingPeriodsOrdered(); - $date = $r[0]->getDateOpening()->format('Y-m-d'); + $date = $r[0]->getOpeningDate()->format('Y-m-d'); $this->assertEquals($date, '2013-01-01'); } @@ -89,19 +89,19 @@ class PersonTest extends \PHPUnit_Framework_TestCase $p = new Person($d); $g = new \DateTime("2013/4/1"); - $period = $p->getCurrentAccompanyingPeriod()->setDateClosing($g); + $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g); $p->close($period); $f = new \DateTime("2013/2/1"); $p->open(new AccompanyingPeriod($f)); $e = new \DateTime("2013/3/1"); - $period = $p->getCurrentAccompanyingPeriod()->setDateClosing($e); + $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e); $p->close($period); $r = $p->getAccompanyingPeriodsOrdered(); - $date = $r[0]->getDateClosing()->format('Y-m-d'); + $date = $r[0]->getClosingDate()->format('Y-m-d'); $this->assertEquals($date, '2013-03-01'); } @@ -116,14 +116,14 @@ class PersonTest extends \PHPUnit_Framework_TestCase $p = new Person($d); $e = new \DateTime("2013/3/1"); - $period = $p->getCurrentAccompanyingPeriod()->setDateClosing($e); + $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e); $p->close($period); $f = new \DateTime("2013/1/1"); $p->open(new AccompanyingPeriod($f)); $g = new \DateTime("2013/4/1"); - $period = $p->getCurrentAccompanyingPeriod()->setDateClosing($g); + $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g); $p->close($period); $r = $p->checkAccompanyingPeriodsAreNotCollapsing(); @@ -141,7 +141,7 @@ class PersonTest extends \PHPUnit_Framework_TestCase $p = new Person($d); $e = new \DateTime("2013/3/1"); - $period = $p->getCurrentAccompanyingPeriod()->setDateClosing($e); + $period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e); $p->close($period); $f = new \DateTime("2013/1/1"); diff --git a/Timeline/AbstractTimelineAccompanyingPeriod.php b/Timeline/AbstractTimelineAccompanyingPeriod.php index 701e1fa41..4f56d7e36 100644 --- a/Timeline/AbstractTimelineAccompanyingPeriod.php +++ b/Timeline/AbstractTimelineAccompanyingPeriod.php @@ -83,7 +83,7 @@ abstract class AbstractTimelineAccompanyingPeriod implements TimelineProviderInt return array( 'id' => $metadata->getColumnName('id'), - 'date' => $metadata->getColumnName('date_opening'), + 'date' => $metadata->getColumnName('openingDate'), 'FROM' => $metadata->getTableName(), ); } diff --git a/Timeline/TimelineAccompanyingPeriodClosing.php b/Timeline/TimelineAccompanyingPeriodClosing.php index 34fa964cc..e09e4d4f9 100644 --- a/Timeline/TimelineAccompanyingPeriodClosing.php +++ b/Timeline/TimelineAccompanyingPeriodClosing.php @@ -56,7 +56,7 @@ class TimelineAccompanyingPeriodClosing extends AbstractTimelineAccompanyingPeri ->getAssociationMapping('person')['joinColumns'][0]['name'], $args['person']->getId(), $metadata - ->getColumnName('date_closing') + ->getColumnName('closingDate') ); return $data;