Skip to content

Commit

Permalink
Merge pull request #4974 from yKazihara/feature/calendar
Browse files Browse the repository at this point in the history
定休日カレンダー機能を実装
  • Loading branch information
carkn authored Nov 30, 2021
2 parents 75235c6 + 706fa42 commit a0e7400
Show file tree
Hide file tree
Showing 23 changed files with 1,823 additions and 3 deletions.
32 changes: 32 additions & 0 deletions app/DoctrineMigrations/Version20210316120000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210316120000 extends AbstractMigration
{
public function up(Schema $schema): void
{
// データ存在チェック
$count = $this->connection->fetchColumn("SELECT COUNT(*) FROM dtb_block WHERE block_name = 'カレンダー'");
if ($count > 0) {
return;
}

// idを取得する
$id = $this->connection->fetchColumn('SELECT MAX(id) FROM dtb_block');
$id++;

$this->addSql("INSERT INTO dtb_block (id, block_name, file_name, use_controller, deletable, create_date, update_date, device_type_id, discriminator_type) VALUES ($id, 'カレンダー', 'calendar', true, false, '2021-03-16 12:00:00', '2021-03-16 12:00:00', 10, 'block')");
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
}
}
3 changes: 3 additions & 0 deletions app/config/eccube/packages/eccube_nav.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ parameters:
shop_order_status:
name: admin.setting.shop.order_status_setting
url: admin_setting_shop_order_status
shop_calendar:
name: admin.setting.shop.calendar_setting
url: admin_setting_shop_calendar
system:
name: admin.setting.system
children:
Expand Down
78 changes: 78 additions & 0 deletions html/template/default/assets/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion html/template/default/assets/css/style.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion html/template/default/assets/css/style.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion html/template/default/assets/css/style.min.css.map

Large diffs are not rendered by default.

113 changes: 113 additions & 0 deletions html/template/default/assets/scss/project/_12.9.calendar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
@import "../mixins/media";
@import "../mixins/clearfix";

/*
見出し
トップページで使用されているカレンダーのスタイルです。
ex [トップページ](http://demo3.ec-cube.net/)
Markup:
sg-wrapper:
<div class="ec-role">
<sg-wrapper-content/>
</div>
Styleguide 12.9.1
*/

/* 背景や文字の色調整 */
$calander-default-bg: #F8F8F8;//月〜金までの背景色
$calander-default-color: #333;//月〜金までの文字色
$calander-sun-bg: #F8F8F8;//日曜の背景色
$calander-sun-color: #DE5D50;//日曜の文字色
$calander-sat-bg: #F8F8F8;//土曜の背景色
$calander-sat-color: #5CB1B1;//土曜の文字色

$calander-day-bg: #FFF;//日付の背景色
$calander-day-color: #333;//日付の文字色
$calander-holiday-bg: #FFF;//休日の背景色
$calander-holiday-color: #DE5D50;//休日の文字色
$calander-today-bg: #FFFDE7;//本日の背景色
$calander-today-color: #333;//本日の文字色

$calander-padding: 8px;//カレンダーの数字周りの余白

$calander-border: #f3f3f3;//カレンダーの線の色



.ec-calendar{
display: flex;
flex-direction: column;
flex-wrap: wrap;

@media screen and (min-width:768px){
flex-direction: row;
margin-left: -30px;
}

&__month{
border-collapse: collapse;
margin-top: 30px;
@media screen and (min-width:768px){
margin-top: 0;
margin-left: 30px;
}

th,td{
border-top: 1px solid $calander-border;
border-bottom: 1px solid $calander-border;
padding: $calander-padding;
text-align: center;
vertical-align: middle;
}//th,td
}//.ec-calendar__month
& &__title{
border: 0;
}//.ec-calendar__title
& &__sun{
background: $calander-sun-bg;
color: $calander-sun-color;
}//.ec-calendar__sun
& &__mon,
& &__tue,
& &__wed,
& &__thu,
& &__fri{
background: $calander-default-bg;
color: $calander-default-color;
}
& &__sat{
background: $calander-sat-bg;
color: $calander-sat-color;
}//.ec-calendar__sat
& &__day{
background: $calander-day-bg;
color: $calander-day-color;
}//.ec-calendar__day
& &__holiday{
background: $calander-holiday-bg;
color: $calander-holiday-color !important;
}//.ec-calendar__holiday
& &__today{
color: $calander-today-color;
position: relative;
z-index: 1;
&::before{
content:"";
position: absolute;
top: 50%;
left: 50%;
display: block;
width: 30px;
height: 30px;
border-radius: 50%;
background: $calander-today-bg;
transform: translate(-50%,-50%);
z-index: -1;
}
}//.ec-calendar__today

}//.ec-calendar
1 change: 1 addition & 0 deletions html/template/default/assets/scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ p {
@import "project/12.6.newItem";
@import "project/12.7.category";
@import "project/12.8.news";
@import "project/12.9.calendar";
@import "project/13.1.searchnav";
@import "project/13.2.shelf";
@import "project/13.3.pager";
Expand Down
129 changes: 129 additions & 0 deletions src/Eccube/Controller/Admin/Setting/Shop/CalendarController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?php

/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Eccube\Controller\Admin\Setting\Shop;

use Eccube\Controller\AbstractController;
use Eccube\Entity\Calendar;
use Eccube\Form\Type\Admin\CalendarType;
use Eccube\Repository\CalendarRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

/**
* Class CalendarController
*/
class CalendarController extends AbstractController
{
/**
* @var CalendarRepository
*/
protected $calendarRepository;

/**
* CalendarController constructor.
*
* @param CalendarRepository $calendarRepository
*/
public function __construct(CalendarRepository $calendarRepository)
{
$this->calendarRepository = $calendarRepository;
}

/**
* カレンダー設定の初期表示・登録
*
* @Route("/%eccube_admin_route%/setting/shop/calendar", name="admin_setting_shop_calendar", methods={"GET", "POST"})
* @Route("/%eccube_admin_route%/setting/shop/calendar/new", name="admin_setting_shop_calendar_new", methods={"GET", "POST"})
* @Template("@admin/Setting/Shop/calendar.twig")
*/
public function index(Request $request)
{
$Calendar = new Calendar();
$builder = $this->formFactory
->createBuilder(CalendarType::class, $Calendar);

$form = $builder->getForm();

$mode = $request->get('mode');
if ($mode != 'edit_inline') {
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->entityManager->persist($Calendar);
$this->entityManager->flush();

$this->addSuccess('admin.common.save_complete', 'admin');

return $this->redirectToRoute('admin_setting_shop_calendar');
}
}

// カレンダーリスト取得
$Calendars = $this->calendarRepository->getListOrderByIdDesc();

$forms = [];
$errors = [];
/** @var Calendar $Calendar */
foreach ($Calendars as $Calendar) {
$builder = $this->formFactory->createBuilder(CalendarType::class, $Calendar);

$editCalendarForm = $builder->getForm();

// error number
$error = 0;
if ($mode == 'edit_inline'
&& $request->getMethod() === 'POST'
&& (string) $Calendar->getId() === $request->get('calendar_id')
) {
$editCalendarForm->handleRequest($request);
if ($editCalendarForm->isValid()) {
$calendarData = $editCalendarForm->getData();

$this->entityManager->persist($calendarData);
$this->entityManager->flush();

$this->addSuccess('admin.common.save_complete', 'admin');

return $this->redirectToRoute('admin_setting_shop_calendar');
}
$error = count($editCalendarForm->getErrors(true));
}

$forms[$Calendar->getId()] = $editCalendarForm->createView();
$errors[$Calendar->getId()] = $error;
}

return [
'Calendar' => $Calendar,
'Calendars' => $Calendars,
'form' => $form->createView(),
'forms' => $forms,
'errors' => $errors,
];
}

/**
* カレンダー設定の削除
*
* @Route("/%eccube_admin_route%/setting/shop/calendar/{id}/delete", requirements={"id" = "\d+"}, name="admin_setting_shop_calendar_delete", methods={"DELETE"})
*/
public function delete(Request $request, Calendar $Calendar)
{
$this->isTokenValid();
$this->calendarRepository->delete($Calendar);
$this->addSuccess('admin.common.delete_complete', 'admin');

return $this->redirectToRoute('admin_setting_shop_calendar');
}
}
Loading

0 comments on commit a0e7400

Please sign in to comment.