<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
use App\Entity\Behaviors\TranslatableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
/**
* @ORM\Entity(repositoryClass="App\Repository\PaymentRepository")
* @ORM\EntityListeners({"App\Listener\EntityListener"})
* @Vich\Uploadable()
*/
class Payment implements TranslatableInterface
{
use TranslatableTrait;
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @Vich\UploadableField(mapping="transport_logo", fileNameProperty="image")
* @Assert\Image(mimeTypes={"image/png", "image/jpeg", "image/jpg", "image/gif"})
* @var File|null
*/
private $imageFile;
/**
* @ORM\Column(type="string", length=199, nullable=true)
*/
private $image;
/**
* @ORM\Column(type="integer", nullable=false)
*/
private $type;
/**
* @ORM\Column(type="integer", nullable=false)
*/
private $priority = 9;
/**
* @ORM\Column(type="boolean")
*/
private $isActive = true;
/**
* @ORM\Column(type="string", length=190)
*/
private $code;
/**
* @ORM\Column(type="datetime")
*/
private $createts;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User")
* @ORM\JoinColumn(nullable=false)
*/
private $createUser;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $editts;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User")
*/
private $editUser;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Transport", mappedBy="payments")
*/
private $transports;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Pricelist", mappedBy="payment", cascade={"persist", "remove"}, orphanRemoval=true, indexBy="currency")
*/
private $pricelists;
/**
* @Vich\UploadableField(mapping="cert_files", fileNameProperty="privateKey")
* @var File|null
*/
private $privateKeyFile;
/**
* @ORM\Column(type="string", length=199, nullable=true)
*/
private $privateKey;
/**
* @ORM\Column(type="string", length=199, nullable=true)
*/
private $onlineType;
/**
* @ORM\Column(type="string", length=199, nullable=true)
*/
private $privateKeyPassword;
/**
* @ORM\Column(type="string", length=199, nullable=true)
*/
private $merchantNumber;
/**
* @Vich\UploadableField(mapping="cert_files", fileNameProperty="publicKey")
* @var File|null
*/
private $publicKeyFile;
/**
* @ORM\Column(type="string", length=199, nullable=true)
*/
private $publicKey;
/**
* @ORM\Column(type="boolean")
*/
private $production = false;
public function __construct()
{
$this->transports = new ArrayCollection();
$this->pricelists = new ArrayCollection();
}
public function checkPricelists($currencies){
$diff = array_diff($currencies,array_keys($this->getPricelists()->toArray()));
if(count($diff)>0){
foreach ($diff as $curr){
$price = new Pricelist($curr);
$this->addPricelist($price);
}
}
}
public function getId(): ?int
{
return $this->id;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
public function getCreatets(): ?\DateTimeInterface
{
return $this->createts;
}
public function setCreatets(\DateTimeInterface $createts): self
{
$this->createts = $createts;
return $this;
}
public function getCreateUser(): ?User
{
return $this->createUser;
}
public function setCreateUser(?User $createUser): self
{
$this->createUser = $createUser;
return $this;
}
public function getEditts(): ?\DateTimeInterface
{
return $this->editts;
}
public function setEditts(?\DateTimeInterface $editts): self
{
$this->editts = $editts;
return $this;
}
public function getEditUser(): ?User
{
return $this->editUser;
}
public function setEditUser(?User $editUser): self
{
$this->editUser = $editUser;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
/**
* Get ImageFile
*
* @return null|File
*/
public function getImageFile()
{
return $this->imageFile;
}
/**
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
*/
public function setImageFile(?File $imageFile = null): void
{
$this->imageFile = $imageFile;
if (null !== $imageFile) {
$this->editts = new \DateTime();
}
}
/**
* @return Collection|Transport[]
*/
public function getTransports(): Collection
{
return $this->transports;
}
public function addTransport(Transport $transport): self
{
if (!$this->transports->contains($transport)) {
$this->transports[] = $transport;
}
return $this;
}
public function removeTransport(Transport $transport): self
{
if ($this->transports->contains($transport)) {
$this->transports->removeElement($transport);
}
return $this;
}
/**
* @return Collection|Pricelist[]
*/
public function getPricelists(): Collection
{
return $this->pricelists;
}
public function addPricelist(Pricelist $pricelist): self
{
if (!$this->pricelists->contains($pricelist)) {
$this->pricelists[] = $pricelist;
$pricelist->setPayment($this);
}
return $this;
}
public function removePricelist(Pricelist $pricelist): self
{
if ($this->pricelists->contains($pricelist)) {
$this->pricelists->removeElement($pricelist);
// set the owning side to null (unless already changed)
if ($pricelist->getPayment() === $this) {
$pricelist->setPayment(null);
}
}
return $this;
}
public function __call($method, $arguments)
{
$ret = $this->proxyCurrentLocaleTranslation($method, $arguments);
if(empty($ret)) {
$ret = call_user_func_array( [ $this->translate( \Locale::getDefault() ), $method ], $arguments );
}
return $ret;
}
/**
* Get Type
*
* @return mixed
*/
public function getType()
{
return $this->type;
}
/**
* Set Type
*
* @param mixed $type
*/
public function setType( $type )
{
$this->type = $type;
}
/**
* Get getPrivateKeyFile
*
* @return null|File
*/
public function getPrivateKeyFile()
{
return $this->privateKeyFile;
}
/**
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $privateKeyFile
*/
public function setPrivateKeyFile(?File $privateKeyFile = null): void
{
$this->privateKeyFile = $privateKeyFile;
if (null !== $privateKeyFile) {
$this->editts = new \DateTime();
}
}
/**
* Get PrivateKey
*
* @return mixed
*/
public function getPrivateKey()
{
return $this->privateKey;
}
/**
* Set PrivateKey
*
* @param mixed $privateKey
*/
public function setPrivateKey( $privateKey )
{
$this->privateKey = $privateKey;
}
/**
* Get PublicKey
*
* @return mixed
*/
public function getPublicKey()
{
return $this->publicKey;
}
/**
* Set PublicKey
*
* @param mixed $publicKey
*/
public function setPublicKey( $publicKey )
{
$this->publicKey = $publicKey;
}
/**
* Get getPublicKeyFile
*
* @return null|File
*/
public function getPublicKeyFile()
{
return $this->publicKeyFile;
}
/**
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $publicKeyFile
*/
public function setPublicKeyFile(?File $publicKeyFile = null): void
{
$this->publicKeyFile = $publicKeyFile;
if (null !== $publicKeyFile) {
$this->editts = new \DateTime();
}
}
/**
* Get PrivateKeyPassword
*
* @return mixed
*/
public function getPrivateKeyPassword()
{
return $this->privateKeyPassword;
}
/**
* Set PrivateKeyPassword
*
* @param mixed $privateKeyPassword
*/
public function setPrivateKeyPassword( $privateKeyPassword )
{
$this->privateKeyPassword = $privateKeyPassword;
}
/**
* Get MerchantNumber
*
* @return mixed
*/
public function getMerchantNumber()
{
return $this->merchantNumber;
}
/**
* Set MerchantNumber
*
* @param mixed $merchantNumber
*/
public function setMerchantNumber( $merchantNumber )
{
$this->merchantNumber = $merchantNumber;
}
/**
* Get OnlineType
*
* @return mixed
*/
public function getOnlineType()
{
return $this->onlineType;
}
/**
* Set OnlineType
*
* @param mixed $onlineType
*/
public function setOnlineType( $onlineType )
{
$this->onlineType = $onlineType;
}
/**
* Get Production
*
* @return mixed
*/
public function getProduction()
{
return $this->production;
}
/**
* Set Production
*
* @param mixed $production
*/
public function setProduction( $production )
{
$this->production = $production;
}
/**
* @return int
*/
public function getPriority(): int
{
return $this->priority;
}
/**
* @param int $priority
*/
public function setPriority(int $priority): void
{
$this->priority = $priority;
}
}