1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* |
4
|
|
|
* part-db version 0.1 |
5
|
|
|
* Copyright (C) 2005 Christoph Lechner |
6
|
|
|
* http://www.cl-projects.de/ |
7
|
|
|
* |
8
|
|
|
* part-db version 0.2+ |
9
|
|
|
* Copyright (C) 2009 K. Jacobs and others (see authors.php) |
10
|
|
|
* http://code.google.com/p/part-db/ |
11
|
|
|
* |
12
|
|
|
* Part-DB Version 0.4+ |
13
|
|
|
* Copyright (C) 2016 - 2019 Jan Böhmer |
14
|
|
|
* https://github.com/jbtronics |
15
|
|
|
* |
16
|
|
|
* This program is free software; you can redistribute it and/or |
17
|
|
|
* modify it under the terms of the GNU General Public License |
18
|
|
|
* as published by the Free Software Foundation; either version 2 |
19
|
|
|
* of the License, or (at your option) any later version. |
20
|
|
|
* |
21
|
|
|
* This program is distributed in the hope that it will be useful, |
22
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
23
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
24
|
|
|
* GNU General Public License for more details. |
25
|
|
|
* |
26
|
|
|
* You should have received a copy of the GNU General Public License |
27
|
|
|
* along with this program; if not, write to the Free Software |
28
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
29
|
|
|
* |
30
|
|
|
*/ |
31
|
|
|
|
32
|
|
|
declare(strict_types=1); |
33
|
|
|
/** |
34
|
|
|
* Part-DB Version 0.4+ "nextgen" |
35
|
|
|
* Copyright (C) 2016 - 2019 Jan Böhmer |
36
|
|
|
* https://github.com/jbtronics. |
37
|
|
|
* |
38
|
|
|
* This program is free software; you can redistribute it and/or |
39
|
|
|
* modify it under the terms of the GNU General Public License |
40
|
|
|
* as published by the Free Software Foundation; either version 2 |
41
|
|
|
* of the License, or (at your option) any later version. |
42
|
|
|
* |
43
|
|
|
* This program is distributed in the hope that it will be useful, |
44
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
45
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
46
|
|
|
* GNU General Public License for more details. |
47
|
|
|
* |
48
|
|
|
* You should have received a copy of the GNU General Public License |
49
|
|
|
* along with this program; if not, write to the Free Software |
50
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
51
|
|
|
*/ |
52
|
|
|
|
53
|
|
|
namespace App\Entity\Base; |
54
|
|
|
|
55
|
|
|
use App\Entity\Base\StructuralDBElement; |
56
|
|
|
use Doctrine\ORM\Mapping as ORM; |
57
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* This abstract class is used for companies like suppliers or manufacturers. |
61
|
|
|
* |
62
|
|
|
* @ORM\MappedSuperclass() |
63
|
|
|
*/ |
64
|
|
|
abstract class Company extends StructuralDBElement |
65
|
|
|
{ |
66
|
|
|
/** |
67
|
|
|
* @var string The address of the company |
68
|
|
|
* @ORM\Column(type="string") |
69
|
|
|
*/ |
70
|
|
|
protected $address = ""; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @var string The phone number of the company |
74
|
|
|
* @ORM\Column(type="string") |
75
|
|
|
*/ |
76
|
|
|
protected $phone_number = ""; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @var string The fax number of the company |
80
|
|
|
* @ORM\Column(type="string") |
81
|
|
|
*/ |
82
|
|
|
protected $fax_number = ""; |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @var string The email address of the company |
86
|
|
|
* @ORM\Column(type="string") |
87
|
|
|
* @Assert\Email() |
88
|
|
|
*/ |
89
|
|
|
protected $email_address = ""; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @var string The website of the company |
93
|
|
|
* @ORM\Column(type="string") |
94
|
|
|
* @Assert\Url() |
95
|
|
|
*/ |
96
|
|
|
protected $website = ""; |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @var string |
100
|
|
|
* @ORM\Column(type="string") |
101
|
|
|
*/ |
102
|
|
|
protected $auto_product_url = ""; |
103
|
|
|
|
104
|
|
|
/******************************************************************************** |
105
|
|
|
* |
106
|
|
|
* Getters |
107
|
|
|
* |
108
|
|
|
*********************************************************************************/ |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* Get the address. |
112
|
|
|
* |
113
|
|
|
* @return string the address of the company (with "\n" as line break) |
114
|
|
|
*/ |
115
|
|
|
public function getAddress(): string |
116
|
|
|
{ |
117
|
|
|
return $this->address; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Get the phone number. |
122
|
|
|
* |
123
|
|
|
* @return string the phone number of the company |
124
|
|
|
*/ |
125
|
|
|
public function getPhoneNumber(): string |
126
|
|
|
{ |
127
|
|
|
return $this->phone_number; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* Get the fax number. |
132
|
|
|
* |
133
|
|
|
* @return string the fax number of the company |
134
|
|
|
*/ |
135
|
|
|
public function getFaxNumber(): string |
136
|
|
|
{ |
137
|
|
|
return $this->fax_number; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* Get the e-mail address. |
142
|
|
|
* |
143
|
|
|
* @return string the e-mail address of the company |
144
|
|
|
*/ |
145
|
|
|
public function getEmailAddress(): string |
146
|
|
|
{ |
147
|
|
|
return $this->email_address; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* Get the website. |
152
|
|
|
* |
153
|
|
|
* @return string the website of the company |
154
|
|
|
*/ |
155
|
|
|
public function getWebsite(): string |
156
|
|
|
{ |
157
|
|
|
return $this->website; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Get the link to the website of an article. |
162
|
|
|
* |
163
|
|
|
* @param string $partnr * NULL for returning the URL with a placeholder for the part number |
164
|
|
|
* * or the part number for returning the direct URL to the article |
165
|
|
|
* |
166
|
|
|
* @return string the link to the article |
167
|
|
|
*/ |
168
|
|
|
public function getAutoProductUrl($partnr = null): string |
169
|
|
|
{ |
170
|
|
|
if (\is_string($partnr)) { |
171
|
|
|
return str_replace('%PARTNUMBER%', $partnr, $this->auto_product_url); |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
return $this->auto_product_url; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/******************************************************************************** |
178
|
|
|
* |
179
|
|
|
* Setters |
180
|
|
|
* |
181
|
|
|
*********************************************************************************/ |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* Set the addres. |
185
|
|
|
* |
186
|
|
|
* @param string $new_address the new address (with "\n" as line break) |
187
|
|
|
* |
188
|
|
|
* @return self |
189
|
|
|
*/ |
190
|
|
|
public function setAddress(string $new_address): self |
191
|
|
|
{ |
192
|
|
|
$this->address = $new_address; |
193
|
|
|
|
194
|
|
|
return $this; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* Set the phone number. |
199
|
|
|
* |
200
|
|
|
* @param string $new_phone_number the new phone number |
201
|
|
|
* |
202
|
|
|
* @return self |
203
|
|
|
*/ |
204
|
|
|
public function setPhoneNumber(string $new_phone_number): self |
205
|
|
|
{ |
206
|
|
|
$this->phone_number = $new_phone_number; |
207
|
|
|
|
208
|
|
|
return $this; |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Set the fax number. |
213
|
|
|
* |
214
|
|
|
* @param string $new_fax_number the new fax number |
215
|
|
|
* |
216
|
|
|
* @return self |
217
|
|
|
*/ |
218
|
|
|
public function setFaxNumber(string $new_fax_number): self |
219
|
|
|
{ |
220
|
|
|
$this->fax_number = $new_fax_number; |
221
|
|
|
|
222
|
|
|
return $this; |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* Set the e-mail address. |
227
|
|
|
* |
228
|
|
|
* @param string $new_email_address the new e-mail address |
229
|
|
|
* |
230
|
|
|
* @return self |
231
|
|
|
*/ |
232
|
|
|
public function setEmailAddress(string $new_email_address): self |
233
|
|
|
{ |
234
|
|
|
$this->email_address = $new_email_address; |
235
|
|
|
|
236
|
|
|
return $this; |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
/** |
240
|
|
|
* Set the website. |
241
|
|
|
* |
242
|
|
|
* @param string $new_website the new website |
243
|
|
|
* |
244
|
|
|
* @return self |
245
|
|
|
*/ |
246
|
|
|
public function setWebsite(string $new_website): self |
247
|
|
|
{ |
248
|
|
|
$this->website = $new_website; |
249
|
|
|
|
250
|
|
|
return $this; |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* Set the link to the website of an article. |
255
|
|
|
* |
256
|
|
|
* @param string $new_url the new URL with the placeholder %PARTNUMBER% for the part number |
257
|
|
|
* |
258
|
|
|
* @return self |
259
|
|
|
*/ |
260
|
|
|
public function setAutoProductUrl(string $new_url): self |
261
|
|
|
{ |
262
|
|
|
$this->auto_product_url = $new_url; |
263
|
|
|
|
264
|
|
|
return $this; |
265
|
|
|
} |
266
|
|
|
} |
267
|
|
|
|