<?php
declare(strict_types=1);
namespace App\Entity;
use App\Repository\CashdeskRepository;
use DateTime;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CashdeskRepository::class)
* @ORM\Table(name="cashdesks", indexes={
* @ORM\Index(columns={"club_id"}),
* @ORM\Index(columns={"is_deleted"})
* })
*/
class Cashdesk
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer", options={"unsigned": true})
*/
private ?int $id = null;
/**
* @ORM\Column(type="string", length=255, options={"default": ""})
*/
private string $title = "";
/**
* @ORM\Column(type="integer", nullable=false, options={"default": 0, "unsigned": true})
*/
private int $club_id = 0;
/**
* @ORM\Column(type="bigint", nullable=false, options={"default": 0})
*/
private int $balance = 0;
/**
* @ORM\Column(type="bigint", options={"default": 0})
*/
private int $limit_max = 0;
/**
* @ORM\Column(type="bigint", options={"default": 60})
*/
private int $wcb_borlette_1 = 60;
/**
* @ORM\Column(type="bigint", options={"default": 20})
*/
private int $wcb_borlette_2 = 20;
/**
* @ORM\Column(type="bigint", options={"default": 10})
*/
private int $wcb_borlette_3 = 10;
/**
* @ORM\Column(type="bigint", options={"default": 500})
*/
private int $wcb_3 = 500;
/**
* @ORM\Column(type="bigint", options={"default": 1000})
*/
private int $wcb_maryaj = 1000;
/**
* @ORM\Column(type="bigint", options={"default": 5000})
*/
private int $wcb_4_opt1 = 5000;
/**
* @ORM\Column(type="bigint", options={"default": 5000})
*/
private int $wcb_4_opt2 = 5000;
/**
* @ORM\Column(type="bigint", options={"default": 5000})
*/
private int $wcb_4_opt3 = 5000;
/**
* @ORM\Column(type="bigint", options={"default": 25000})
*/
private int $wcb_5_opt1 = 25000;
/**
* @ORM\Column(type="bigint", options={"default": 25000})
*/
private int $wcb_5_opt2 = 25000;
/**
* @ORM\Column(type="bigint", options={"default": 25000})
*/
private int $wcb_5_opt3 = 25000;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default": false})
*/
private bool $is_deleted = false;
/**
* @ORM\ManyToOne(targetEntity=Club::class, inversedBy="cashdesks")
* @ORM\JoinColumn(nullable=false, columnDefinition="INT(11)")
*/
private ?Club $club;
/**
* @ORM\OneToMany(targetEntity=Payment::class, mappedBy="cashdesk")
*/
private Collection $payments;
/**
* @ORM\OneToOne(targetEntity=User::class, mappedBy="current_cashdesk", cascade={"persist", "remove"})
*/
private ?User $user;
/**
* @ORM\OneToOne(targetEntity=Workshift::class, inversedBy="cashdesk", cascade={"persist", "remove"})
*/
private ?Workshift $current_workshift;
/**
* @ORM\ManyToMany(targetEntity=User::class, mappedBy="cashdesks")
*/
private Collection $users;
/**
* @ORM\Column(type="boolean", nullable=true, options={"unsigned": true, "default": 0})
*/
private ?bool $allow_negative_balance = false;
/**
* @ORM\Column(type="integer", options={"default": 0})
*/
private int $limit_negative_balance = 0;
/**
* @ORM\Column(type="boolean", nullable=true, options={"unsigned": true, "default": 0})
*/
private ?bool $allow_free_maryaj = true;
/**
* @ORM\Column(type="boolean", options={"default": false})
*/
private bool $is_blocked = false;
/**
* @ORM\Column(type="boolean", options={"default": true})
*/
private bool $print_koef = false;
/**
* @ORM\Column(type="boolean", options={"default": false})
*/
private bool $has_jp = false;
/**
* @ORM\Column(type="json", nullable=true)
*/
private ?array $roles = [];
/**
* @ORM\Column(type="string", length=255)
*/
private string $remote_client_token;
/**
* @ORM\Column(type="datetime", nullable=true, columnDefinition="TIMESTAMP DEFAULT NULL")
*/
private ?DateTimeInterface $created_date = null;
public function __construct()
{
$this->payments = new ArrayCollection();
$this->users = new ArrayCollection();
}
public function isHideForAdministrator(string $permission): bool
{
if (is_null($this->getRoles())) {
return false;
}
return in_array($permission, $this->getRoles());
}
public function isGranted(string $permission): bool
{
if (is_null($this->getRoles())) {
return false;
}
return in_array($permission, $this->getRoles());
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getClubId(): ?int
{
return $this->club_id;
}
public function setClubId(int $club_id): self
{
$this->club_id = $club_id;
return $this;
}
public function getBalance(): ?int
{
return $this->balance;
}
public function setBalance(int $balance): self
{
$this->balance = $balance;
return $this;
}
public function getLimitMax(): ?int
{
return $this->limit_max;
}
public function setLimitMax(int $limit_max): self
{
$this->limit_max = $limit_max;
return $this;
}
public function getWcbBorlette1(): ?int
{
return $this->wcb_borlette_1;
}
public function setWcbBorlette1(int $wcb_borlette_1): self
{
$this->wcb_borlette_1 = $wcb_borlette_1;
return $this;
}
public function getWcbBorlette2(): ?int
{
return $this->wcb_borlette_2;
}
public function setWcbBorlette2(int $wcb_borlette_2): self
{
$this->wcb_borlette_2 = $wcb_borlette_2;
return $this;
}
public function getWcbBorlette3(): ?int
{
return $this->wcb_borlette_3;
}
public function setWcbBorlette3(int $wcb_borlette_3): self
{
$this->wcb_borlette_3 = $wcb_borlette_3;
return $this;
}
public function getWcb3(): ?int
{
return $this->wcb_3;
}
public function setWcb3(int $wcb_3): self
{
$this->wcb_3 = $wcb_3;
return $this;
}
public function getWcbMaryaj(): ?int
{
return $this->wcb_maryaj;
}
public function setWcbMaryaj(int $wcb_maryaj): self
{
$this->wcb_maryaj = $wcb_maryaj;
return $this;
}
public function getWcb4Opt1(): ?int
{
return $this->wcb_4_opt1;
}
public function setWcb4Opt1(int $wcb_4_opt1): self
{
$this->wcb_4_opt1 = $wcb_4_opt1;
return $this;
}
public function getWcb4Opt2(): ?int
{
return $this->wcb_4_opt2;
}
public function setWcb4Opt2(int $wcb_4_opt2): self
{
$this->wcb_4_opt2 = $wcb_4_opt2;
return $this;
}
public function getWcb4Opt3(): ?int
{
return $this->wcb_4_opt3;
}
public function setWcb4Opt3(int $wcb_4_opt3): self
{
$this->wcb_4_opt3 = $wcb_4_opt3;
return $this;
}
public function getWcb5Opt1(): ?int
{
return $this->wcb_5_opt1;
}
public function setWcb5Opt1(int $wcb_5_opt1): self
{
$this->wcb_5_opt1 = $wcb_5_opt1;
return $this;
}
public function getWcb5Opt2(): ?int
{
return $this->wcb_5_opt2;
}
public function setWcb5Opt2(int $wcb_5_opt2): self
{
$this->wcb_5_opt2 = $wcb_5_opt2;
return $this;
}
public function getWcb5Opt3(): ?int
{
return $this->wcb_5_opt3;
}
public function setWcb5Opt3(int $wcb_5_opt3): self
{
$this->wcb_5_opt3 = $wcb_5_opt3;
return $this;
}
public function getCreatedDate(): ?DateTimeInterface
{
return $this->created_date;
}
public function setCreatedDate(?DateTimeInterface $created_date): self
{
$this->created_date = $created_date;
return $this;
}
public function getIsDeleted(): ?bool
{
return $this->is_deleted;
}
public function setIsDeleted(bool $is_deleted): self
{
$this->is_deleted = $is_deleted;
return $this;
}
public function getClub(): ?Club
{
return $this->club;
}
public function setClub(?Club $club): self
{
$this->club = $club;
return $this;
}
/**
* @return Collection
*/
public function getPayments(): Collection
{
return $this->payments;
}
public function addPayment(Payment $payment): self
{
if (!$this->payments->contains($payment)) {
$this->payments[] = $payment;
$payment->setCashdesk($this);
}
return $this;
}
public function removePayment(Payment $payment): self
{
if ($this->payments->contains($payment)) {
$this->payments->removeElement($payment);
// set the owning side to null (unless already changed)
if ($payment->getCashdesk() === $this) {
$payment->setCashdesk(null);
}
}
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
// set (or unset) the owning side of the relation if necessary
$newCurrent_cashdesk = null === $user ? null : $this;
if ($user->getCurrentCashdesk() !== $newCurrent_cashdesk) {
$user->setCurrentCashdesk($newCurrent_cashdesk);
}
return $this;
}
public function getCurrentWorkshift(): ?Workshift
{
return $this->current_workshift;
}
public function setCurrentWorkshift(?Workshift $current_workshift): self
{
$this->current_workshift = $current_workshift;
return $this;
}
/**
* @return Collection
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->addCashdesk($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->contains($user)) {
$this->users->removeElement($user);
$user->removeCashdesk($this);
}
return $this;
}
public function getAllowNegativeBalance(): ?bool
{
return $this->allow_negative_balance;
}
public function setAllowNegativeBalance(?bool $allow_negative_balance): self
{
$this->allow_negative_balance = $allow_negative_balance;
return $this;
}
public function getLimitNegativeBalance(): ?int
{
return $this->limit_negative_balance;
}
public function setLimitNegativeBalance(int $limit_negative_balance): self
{
$this->limit_negative_balance = $limit_negative_balance;
return $this;
}
public function getAllowFreeMaryaj(): ?bool
{
return $this->allow_free_maryaj;
}
public function setAllowFreeMaryaj(?bool $allow_free_maryaj): self
{
$this->allow_free_maryaj = $allow_free_maryaj;
return $this;
}
public function getIsBlocked(): ?bool
{
return $this->is_blocked;
}
public function setIsBlocked(bool $is_blocked): self
{
$this->is_blocked = $is_blocked;
return $this;
}
public function getPrintKoef(): ?bool
{
return $this->print_koef;
}
public function setPrintKoef(bool $print_koef): self
{
$this->print_koef = $print_koef;
return $this;
}
public function getHasJP(): ?bool
{
return $this->has_jp;
}
public function setHasJP(bool $has_jp): self
{
$this->has_jp = $has_jp;
return $this;
}
public function getRoles(): ?array
{
return $this->roles;
}
public function setRoles(?array $roles): self
{
$this->roles = $roles;
return $this;
}
public function getRemoteClientToken(): ?string
{
return $this->remote_client_token;
}
public function setRemoteClientToken(string $remote_client_token): self
{
$this->remote_client_token = $remote_client_token;
return $this;
}
public function getAllowWorkshift() {
return $this->isGranted(Roles::ROLE_ONLINE_CASHDESK_WORK_SHIFT);
}
}