Part-DB.Part-DB-server/src/Entity/Base/AbstractCompany.php

237 lines
5.6 KiB
PHP
Raw Normal View History

<?php
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
2022-11-29 22:28:53 +01:00
* Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics)
*
2020-02-22 18:14:36 +01:00
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2020-02-22 18:14:36 +01:00
* GNU Affero General Public License for more details.
*
2020-02-22 18:14:36 +01:00
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
2020-01-05 15:46:58 +01:00
namespace App\Entity\Base;
2019-02-23 22:41:13 +01:00
use Doctrine\ORM\Mapping as ORM;
2020-01-05 22:49:00 +01:00
use function is_string;
use Symfony\Component\Validator\Constraints as Assert;
2019-02-23 22:41:13 +01:00
/**
* This abstract class is used for companies like suppliers or manufacturers.
*
2019-02-23 22:41:13 +01:00
* @ORM\MappedSuperclass()
*/
abstract class AbstractCompany extends AbstractPartsContainingDBElement
2019-02-23 22:41:13 +01:00
{
/**
* @var string The address of the company
* @ORM\Column(type="string")
*/
2022-09-18 22:59:31 +02:00
protected string $address = '';
2019-02-23 22:41:13 +01:00
/**
* @var string The phone number of the company
* @ORM\Column(type="string")
*/
2022-09-18 22:59:31 +02:00
protected string $phone_number = '';
2019-02-23 22:41:13 +01:00
/**
* @var string The fax number of the company
* @ORM\Column(type="string")
*/
2022-09-18 22:59:31 +02:00
protected string $fax_number = '';
2019-02-23 22:41:13 +01:00
/**
* @var string The email address of the company
* @ORM\Column(type="string")
* @Assert\Email()
2019-02-23 22:41:13 +01:00
*/
2022-09-18 22:59:31 +02:00
protected string $email_address = '';
2019-02-23 22:41:13 +01:00
/**
* @var string The website of the company
* @ORM\Column(type="string")
* @Assert\Url()
2019-02-23 22:41:13 +01:00
*/
2022-09-18 22:59:31 +02:00
protected string $website = '';
2019-02-23 22:41:13 +01:00
/**
* @var string
* @ORM\Column(type="string")
*/
2022-09-18 22:59:31 +02:00
protected string $auto_product_url = '';
2019-02-23 22:41:13 +01:00
/********************************************************************************
*
* Getters
*
*********************************************************************************/
/**
* Get the address.
2019-02-23 22:41:13 +01:00
*
* @return string the address of the company (with "\n" as line break)
2019-02-23 22:41:13 +01:00
*/
public function getAddress(): string
2019-02-23 22:41:13 +01:00
{
return $this->address;
}
/**
* Get the phone number.
2019-02-23 22:41:13 +01:00
*
* @return string the phone number of the company
2019-02-23 22:41:13 +01:00
*/
public function getPhoneNumber(): string
2019-02-23 22:41:13 +01:00
{
return $this->phone_number;
}
/**
* Get the fax number.
2019-02-23 22:41:13 +01:00
*
* @return string the fax number of the company
2019-02-23 22:41:13 +01:00
*/
public function getFaxNumber(): string
2019-02-23 22:41:13 +01:00
{
return $this->fax_number;
}
/**
* Get the e-mail address.
2019-02-23 22:41:13 +01:00
*
* @return string the e-mail address of the company
2019-02-23 22:41:13 +01:00
*/
public function getEmailAddress(): string
2019-02-23 22:41:13 +01:00
{
return $this->email_address;
}
/**
* Get the website.
2019-02-23 22:41:13 +01:00
*
* @return string the website of the company
2019-02-23 22:41:13 +01:00
*/
public function getWebsite(): string
2019-02-23 22:41:13 +01:00
{
return $this->website;
}
/**
* Get the link to the website of an article.
2019-02-23 22:41:13 +01:00
*
2022-08-14 19:09:07 +02:00
* @param string|null $partnr * NULL for returning the URL with a placeholder for the part number
* * or the part number for returning the direct URL to the article
2019-02-23 22:41:13 +01:00
*
* @return string the link to the article
2019-02-23 22:41:13 +01:00
*/
2022-08-14 19:09:07 +02:00
public function getAutoProductUrl(string $partnr = null): string
2019-02-23 22:41:13 +01:00
{
2020-01-05 22:49:00 +01:00
if (is_string($partnr)) {
2019-02-23 22:41:13 +01:00
return str_replace('%PARTNUMBER%', $partnr, $this->auto_product_url);
}
2019-02-23 22:41:13 +01:00
return $this->auto_product_url;
}
/********************************************************************************
*
* Setters
*
*********************************************************************************/
/**
* Set the addres.
*
2020-03-15 13:56:31 +01:00
* @param string $new_address the new address (with "\n" as line break)
2020-02-02 14:05:36 +01:00
*
* @return $this
2019-02-23 22:41:13 +01:00
*/
public function setAddress(string $new_address): self
2019-02-23 22:41:13 +01:00
{
$this->address = $new_address;
return $this;
2019-02-23 22:41:13 +01:00
}
/**
* Set the phone number.
2019-02-23 22:41:13 +01:00
*
* @param string $new_phone_number the new phone number
2020-03-15 13:56:31 +01:00
*
2020-02-02 14:05:36 +01:00
* @return $this
2019-02-23 22:41:13 +01:00
*/
public function setPhoneNumber(string $new_phone_number): self
2019-02-23 22:41:13 +01:00
{
$this->phone_number = $new_phone_number;
return $this;
2019-02-23 22:41:13 +01:00
}
/**
* Set the fax number.
2019-02-23 22:41:13 +01:00
*
* @param string $new_fax_number the new fax number
2020-03-15 13:56:31 +01:00
*
2020-02-02 14:05:36 +01:00
* @return $this
2019-02-23 22:41:13 +01:00
*/
public function setFaxNumber(string $new_fax_number): self
2019-02-23 22:41:13 +01:00
{
$this->fax_number = $new_fax_number;
return $this;
2019-02-23 22:41:13 +01:00
}
/**
* Set the e-mail address.
2019-02-23 22:41:13 +01:00
*
* @param string $new_email_address the new e-mail address
2020-03-15 13:56:31 +01:00
*
2020-02-02 14:05:36 +01:00
* @return $this
2019-02-23 22:41:13 +01:00
*/
public function setEmailAddress(string $new_email_address): self
2019-02-23 22:41:13 +01:00
{
$this->email_address = $new_email_address;
return $this;
2019-02-23 22:41:13 +01:00
}
/**
* Set the website.
2019-02-23 22:41:13 +01:00
*
* @param string $new_website the new website
2020-03-15 13:56:31 +01:00
*
2020-02-02 14:05:36 +01:00
* @return $this
2019-02-23 22:41:13 +01:00
*/
public function setWebsite(string $new_website): self
2019-02-23 22:41:13 +01:00
{
$this->website = $new_website;
return $this;
2019-02-23 22:41:13 +01:00
}
/**
* Set the link to the website of an article.
2019-02-23 22:41:13 +01:00
*
* @param string $new_url the new URL with the placeholder %PARTNUMBER% for the part number
2020-03-15 13:56:31 +01:00
*
2020-02-02 14:05:36 +01:00
* @return $this
2019-02-23 22:41:13 +01:00
*/
public function setAutoProductUrl(string $new_url): self
2019-02-23 22:41:13 +01:00
{
$this->auto_product_url = $new_url;
return $this;
2019-02-23 22:41:13 +01:00
}
}