-
Notifications
You must be signed in to change notification settings - Fork 647
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4974 from yKazihara/feature/calendar
定休日カレンダー機能を実装
- Loading branch information
Showing
23 changed files
with
1,823 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
113 changes: 113 additions & 0 deletions
113
html/template/default/assets/scss/project/_12.9.calendar.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
src/Eccube/Controller/Admin/Setting/Shop/CalendarController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
Oops, something went wrong.