1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* part-db version 0.1 |
4
|
|
|
* Copyright (C) 2005 Christoph Lechner |
5
|
|
|
* http://www.cl-projects.de/. |
6
|
|
|
* |
7
|
|
|
* part-db version 0.2+ |
8
|
|
|
* Copyright (C) 2009 K. Jacobs and others (see authors.php) |
9
|
|
|
* http://code.google.com/p/part-db/ |
10
|
|
|
* |
11
|
|
|
* Part-DB Version 0.4+ |
12
|
|
|
* Copyright (C) 2016 - 2019 Jan Böhmer |
13
|
|
|
* https://github.com/jbtronics |
14
|
|
|
* |
15
|
|
|
* This program is free software; you can redistribute it and/or |
16
|
|
|
* modify it under the terms of the GNU General Public License |
17
|
|
|
* as published by the Free Software Foundation; either version 2 |
18
|
|
|
* of the License, or (at your option) any later version. |
19
|
|
|
* |
20
|
|
|
* This program is distributed in the hope that it will be useful, |
21
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
22
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
23
|
|
|
* GNU General Public License for more details. |
24
|
|
|
* |
25
|
|
|
* You should have received a copy of the GNU General Public License |
26
|
|
|
* along with this program; if not, write to the Free Software |
27
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
28
|
|
|
*/ |
29
|
|
|
|
30
|
|
|
namespace App\Controller; |
31
|
|
|
|
32
|
|
|
use App\DataTables\PartsDataTable; |
33
|
|
|
use App\Entity\Parts\Category; |
34
|
|
|
use App\Entity\Parts\Footprint; |
35
|
|
|
use App\Entity\Parts\Manufacturer; |
36
|
|
|
use App\Entity\Parts\Storelocation; |
37
|
|
|
use App\Entity\Parts\Supplier; |
38
|
|
|
use Omines\DataTablesBundle\DataTableFactory; |
39
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
40
|
|
|
use Symfony\Component\HttpFoundation\Request; |
41
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
42
|
|
|
|
43
|
|
|
class PartListsController extends AbstractController |
44
|
|
|
{ |
45
|
|
|
/** |
46
|
|
|
* @Route("/category/{id}/parts", name="part_list_category") |
47
|
|
|
* |
48
|
|
|
* @param $id int The id of the category |
49
|
|
|
* |
50
|
|
|
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response |
51
|
|
|
*/ |
52
|
|
|
public function showCategory(Category $category, Request $request, DataTableFactory $dataTable) |
53
|
|
|
{ |
54
|
|
|
$table = $dataTable->createFromType(PartsDataTable::class, ['category' => $category]) |
55
|
|
|
->handleRequest($request); |
56
|
|
|
|
57
|
|
|
if ($table->isCallback()) { |
58
|
|
|
return $table->getResponse(); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
return $this->render('Parts/lists/category_list.html.twig', [ |
62
|
|
|
'datatable' => $table, |
63
|
|
|
'entity' => $category |
64
|
|
|
]); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @Route("/footprint/{id}/parts", name="part_list_footprint") |
69
|
|
|
* |
70
|
|
|
* @param $id int The id of the category |
71
|
|
|
* |
72
|
|
|
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response |
73
|
|
|
*/ |
74
|
|
|
public function showFootprint(Footprint $footprint, Request $request, DataTableFactory $dataTable) |
75
|
|
|
{ |
76
|
|
|
$table = $dataTable->createFromType(PartsDataTable::class, ['footprint' => $footprint]) |
77
|
|
|
->handleRequest($request); |
78
|
|
|
|
79
|
|
|
if ($table->isCallback()) { |
80
|
|
|
return $table->getResponse(); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
return $this->render('Parts/lists/footprint_list.html.twig', [ |
84
|
|
|
'datatable' => $table, |
85
|
|
|
'entity' => $footprint |
86
|
|
|
]); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @Route("/manufacturer/{id}/parts", name="part_list_manufacturer") |
91
|
|
|
* |
92
|
|
|
* @param $id int The id of the category |
93
|
|
|
* |
94
|
|
|
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response |
95
|
|
|
*/ |
96
|
|
|
public function showManufacturer(Manufacturer $manufacturer, Request $request, DataTableFactory $dataTable) |
97
|
|
|
{ |
98
|
|
|
$table = $dataTable->createFromType(PartsDataTable::class, ['manufacturer' => $manufacturer]) |
99
|
|
|
->handleRequest($request); |
100
|
|
|
|
101
|
|
|
if ($table->isCallback()) { |
102
|
|
|
return $table->getResponse(); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
return $this->render('Parts/lists/manufacturer_list.html.twig', [ |
106
|
|
|
'datatable' => $table, |
107
|
|
|
'entity' => $manufacturer |
108
|
|
|
]); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @Route("/store_location/{id}/parts", name="part_list_store_location") |
113
|
|
|
* |
114
|
|
|
* @param $id int The id of the category |
115
|
|
|
* |
116
|
|
|
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response |
117
|
|
|
*/ |
118
|
|
|
public function showStorelocation(Storelocation $storelocation, Request $request, DataTableFactory $dataTable) |
119
|
|
|
{ |
120
|
|
|
$table = $dataTable->createFromType(PartsDataTable::class, ['storelocation' => $storelocation]) |
121
|
|
|
->handleRequest($request); |
122
|
|
|
|
123
|
|
|
if ($table->isCallback()) { |
124
|
|
|
return $table->getResponse(); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
return $this->render('Parts/lists/store_location_list.html.twig', [ |
128
|
|
|
'datatable' => $table, |
129
|
|
|
'entity' => $storelocation |
130
|
|
|
]); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* @Route("/supplier/{id}/parts", name="part_list_supplier") |
135
|
|
|
* |
136
|
|
|
* @param $id int The id of the category |
137
|
|
|
* |
138
|
|
|
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response |
139
|
|
|
*/ |
140
|
|
|
public function showSupplier(Supplier $supplier, Request $request, DataTableFactory $dataTable) |
141
|
|
|
{ |
142
|
|
|
$table = $dataTable->createFromType(PartsDataTable::class, ['supplier' => $supplier]) |
143
|
|
|
->handleRequest($request); |
144
|
|
|
|
145
|
|
|
if ($table->isCallback()) { |
146
|
|
|
return $table->getResponse(); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
return $this->render('Parts/lists/supplier_list.html.twig', [ |
150
|
|
|
'datatable' => $table, |
151
|
|
|
'entity' => $supplier |
152
|
|
|
]); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @Route("/parts/by_tag/{tag}", name="part_list_tags") |
158
|
|
|
* @param string $tag |
159
|
|
|
* @param Request $request |
160
|
|
|
* @param DataTableFactory $dataTable |
161
|
|
|
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response |
162
|
|
|
*/ |
163
|
|
|
public function showTag(string $tag, Request $request, DataTableFactory $dataTable) |
164
|
|
|
{ |
165
|
|
|
$table = $dataTable->createFromType(PartsDataTable::class, ['tag' => $tag]) |
166
|
|
|
->handleRequest($request); |
167
|
|
|
|
168
|
|
|
if ($table->isCallback()) { |
169
|
|
|
return $table->getResponse(); |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
return $this->render('Parts/lists/tags_list.html.twig', [ |
173
|
|
|
'tag' => $tag, |
174
|
|
|
'datatable' => $table |
175
|
|
|
]); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @Route("/parts/search/{keyword}", name="parts_search") |
180
|
|
|
*/ |
181
|
|
|
public function showSearch(Request $request, DataTableFactory $dataTable, string $keyword = "") |
182
|
|
|
{ |
183
|
|
|
$search = $keyword; |
184
|
|
|
|
185
|
|
|
$table = $dataTable->createFromType(PartsDataTable::class, ['search' => $search]) |
186
|
|
|
->handleRequest($request); |
187
|
|
|
|
188
|
|
|
if ($table->isCallback()) { |
189
|
|
|
return $table->getResponse(); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
return $this->render('Parts/lists/search_list.html.twig', [ |
193
|
|
|
'datatable' => $table, |
194
|
|
|
'keyword' => $keyword |
195
|
|
|
]); |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @Route("/parts", name="parts_show_all") |
200
|
|
|
* |
201
|
|
|
* @param Request $request |
202
|
|
|
* @param DataTableFactory $dataTable |
203
|
|
|
* |
204
|
|
|
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response |
205
|
|
|
*/ |
206
|
|
|
public function showAll(Request $request, DataTableFactory $dataTable) |
207
|
|
|
{ |
208
|
|
|
$table = $dataTable->createFromType(PartsDataTable::class) |
209
|
|
|
->handleRequest($request); |
210
|
|
|
|
211
|
|
|
if ($table->isCallback()) { |
212
|
|
|
return $table->getResponse(); |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
return $this->render('Parts/lists/all_list.html.twig', ['datatable' => $table]); |
216
|
|
|
} |
217
|
|
|
} |
218
|
|
|
|