Skip to content

Commit

Permalink
not entirely working
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrodevog committed Oct 15, 2023
1 parent 57c6757 commit 91b3a62
Show file tree
Hide file tree
Showing 26 changed files with 1,337 additions and 8 deletions.
41 changes: 41 additions & 0 deletions migrations/Version20231015200531.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);

namespace Migrations;

use Doctrine\DBAL\Schema\Schema;

/**
* Version 20231015200531
*/
class Version20231015200531 extends \Doctrine\Migrations\AbstractMigration
{
/**
* @param \Doctrine\DBAL\Schema\Schema $schema
* @return void
*/
public function up(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

$this->addSql('CREATE SEQUENCE shop_sessions_opening_hours_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE SEQUENCE shop_sessions_opening_hours_translations_id_seq INCREMENT BY 1 MINVALUE 1 START 1');
$this->addSql('CREATE TABLE shop_sessions_opening_hours (id BIGINT NOT NULL, person BIGINT DEFAULT NULL, start_date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, end_date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, creation_time TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_B036599134DCD176 ON shop_sessions_opening_hours (person)');
$this->addSql('CREATE TABLE shop_sessions_opening_hours_translations (id BIGINT NOT NULL, opening_hour BIGINT DEFAULT NULL, language BIGINT DEFAULT NULL, comment VARCHAR(255) NOT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE INDEX IDX_BAEC889D969BD765 ON shop_sessions_opening_hours_translations (opening_hour)');
$this->addSql('CREATE INDEX IDX_BAEC889DD4DB71B5 ON shop_sessions_opening_hours_translations (language)');
$this->addSql('ALTER TABLE shop_sessions_opening_hours ADD CONSTRAINT FK_B036599134DCD176 FOREIGN KEY (person) REFERENCES users_people (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE shop_sessions_opening_hours_translations ADD CONSTRAINT FK_BAEC889D969BD765 FOREIGN KEY (opening_hour) REFERENCES shop_sessions_opening_hours (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE shop_sessions_opening_hours_translations ADD CONSTRAINT FK_BAEC889DD4DB71B5 FOREIGN KEY (language) REFERENCES general_languages (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}

/**
* @param \Doctrine\DBAL\Schema\Schema $schema
* @return void
*/
public function down(Schema $schema) : void
{
$this->throwIrreversibleMigrationException();
}
}
9 changes: 5 additions & 4 deletions module/CommonBundle/Controller/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,10 @@ private function getCudiInfo()
->getRepository('CudiBundle\Entity\Sale\Session\OpeningHour')
->findPeriodFromNow('P14D');

$messages = $this->getEntityManager()
$cudi['messages'] = $this->getEntityManager()
->getRepository('CudiBundle\Entity\Sale\Session\Message')
->findAllActive();

$cudi['messages'] = $messages;

return $cudi;
}

Expand Down Expand Up @@ -278,7 +276,10 @@ private function getShopInfo()
->getConfigValue('shop.url_reservations'),
'messages' => $this->getEntityManager()
->getRepository('ShopBundle\Entity\Session\Message')
->findAllActive()
->findAllActive(),
'openingHours' => $this->getEntityManager()
->getRepository('ShopBundle\Entity\Session\OpeningHour')
->findPeriodFromNow('P14D'),
);
}

Expand Down
8 changes: 7 additions & 1 deletion module/CommonBundle/Resources/views/common/index/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
<div>
<p style="display:inline-block">{{ dateLocalized(opening.getStart(), 'EEEE (d/M)')|capitalize }}</p>
<p style="float:right">{{ opening.getStart().format('H:i') }}
-{{ opening.getEnd().format('H:i') }}</p></div>
- {{ opening.getEnd().format('H:i') }}</p></div>
{% endfor %}
</div>
</div>
Expand All @@ -174,6 +174,12 @@
<div style="white-space: pre-wrap;">{{ message.getContent(language) }}
</div>
{% endfor %}
{% for opening in shop.openingHours %}
<div>
<p style="display:inline-block">{{ dateLocalized(opening.getStartDate(), 'EEEE (d/M)')|capitalize }}</p>
<p style="float:right">{{ opening.getStartDate().format('H:i') }}
- {{ opening.getEndDate().format('H:i') }}</p></div>
{% endfor %}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
use DateTime;
use CudiBundle\Entity\Sale\Session\OpeningHour;
use Laminas\View\Model\ViewModel;
use ShiftBundle\Hydrator;

/**
* OpeningHourController
*
* @author Kristof Mariën <[email protected]>
* @author Pedro Devogelaere <[email protected]>
*/
class OpeningHourController extends \CudiBundle\Component\Controller\ActionController
{
Expand Down Expand Up @@ -56,7 +56,6 @@ public function addAction()
$form->setData($this->getRequest()->getPost());

if ($form->isValid()) {
error_log(json_encode($form->getData()));
$this->getEntityManager()->persist(
$form->hydrateObject()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class Translation
{
/**
* @var integer The ID of this tanslation
* @var integer The ID of this translation
*
* @ORM\Id
* @ORM\GeneratedValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
'logistics_catalog' => array(
'overview',
),
'logistics_inventory' => array(
'index',
),
),
),
);
Loading

0 comments on commit 91b3a62

Please sign in to comment.