1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of EC-CUBE |
5
|
|
|
* |
6
|
|
|
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved. |
7
|
|
|
* |
8
|
|
|
* http://www.ec-cube.co.jp/ |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Eccube\Controller\Admin\Setting\Shop; |
15
|
|
|
|
16
|
|
|
use Eccube\Controller\AbstractController; |
17
|
|
|
use Eccube\Form\Type\Admin\OrderStatusSettingType; |
18
|
|
|
use Eccube\Repository\Master\CustomerOrderStatusRepository; |
19
|
|
|
use Eccube\Repository\Master\OrderStatusColorRepository; |
20
|
|
|
use Eccube\Repository\Master\OrderStatusRepository; |
21
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; |
22
|
|
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType; |
23
|
|
|
use Symfony\Component\HttpFoundation\Request; |
24
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
25
|
|
|
|
26
|
|
|
class OrderStatusController extends AbstractController |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var OrderStatusRepository |
30
|
|
|
*/ |
31
|
|
|
protected $orderStatusRepository; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var OrderStatusColorRepository |
35
|
|
|
*/ |
36
|
|
|
protected $orderStatusColorRepository; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var CustomerOrderStatusRepository |
40
|
|
|
*/ |
41
|
|
|
protected $customerOrderStatusRepository; |
42
|
|
|
|
43
|
|
|
public function __construct( |
44
|
|
|
OrderStatusRepository $orderStatusRepository, |
45
|
|
|
OrderStatusColorRepository $orderStatusColorRepository, |
46
|
|
|
CustomerOrderStatusRepository $customerOrderStatusRepository |
47
|
|
|
) { |
48
|
|
|
$this->orderStatusRepository = $orderStatusRepository; |
49
|
|
|
$this->orderStatusColorRepository = $orderStatusColorRepository; |
50
|
|
|
$this->customerOrderStatusRepository = $customerOrderStatusRepository; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* 受注ステータス編集画面. |
55
|
|
|
* |
56
|
|
|
* @Route("/%eccube_admin_route%/setting/shop/order_status", name="admin_setting_shop_order_status") |
57
|
|
|
* @Template("@admin/Setting/Shop/order_status.twig") |
58
|
|
|
*/ |
59
|
|
|
public function index(Request $request) |
60
|
|
|
{ |
61
|
|
|
$OrderStatuses = $this->orderStatusRepository->findBy([], ['sort_no' => 'ASC']); |
62
|
|
|
$builder = $this->formFactory->createBuilder(); |
63
|
|
|
$builder |
64
|
|
|
->add( |
65
|
|
|
'OrderStatuses', |
66
|
|
|
CollectionType::class, |
67
|
|
|
[ |
68
|
|
|
'entry_type' => OrderStatusSettingType::class, |
69
|
|
|
'data' => $OrderStatuses, |
70
|
|
|
] |
71
|
|
|
); |
72
|
|
|
$form = $builder->getForm(); |
73
|
|
|
$form->handleRequest($request); |
74
|
|
|
|
75
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
76
|
|
|
foreach ($form['OrderStatuses'] as $child) { |
77
|
|
|
$OrderStatus = $child->getData(); |
78
|
|
|
$this->entityManager->persist($OrderStatus); |
79
|
|
|
|
80
|
|
|
$CustomerOrderStatus = $this->customerOrderStatusRepository->find($OrderStatus->getId()); |
81
|
|
|
if (null !== $CustomerOrderStatus) { |
82
|
|
|
$CustomerOrderStatus->setName($child['customer_order_status_name']->getData()); |
83
|
|
|
$this->entityManager->persist($CustomerOrderStatus); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
$OrderStatusColor = $this->orderStatusColorRepository->find($OrderStatus->getId()); |
87
|
|
|
if (null !== $OrderStatusColor) { |
88
|
|
|
$OrderStatusColor->setName($child['color']->getData()); |
89
|
|
|
$this->entityManager->persist($OrderStatusColor); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
$this->entityManager->flush(); |
93
|
|
|
|
94
|
|
|
$this->addSuccess('admin.common.save_complete', 'admin'); |
95
|
|
|
|
96
|
|
|
return $this->redirectToRoute('admin_setting_shop_order_status'); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
return [ |
100
|
|
|
'form' => $form->createView(), |
101
|
|
|
]; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|