src/Entity/Cashdesk.php line 21

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use App\Repository\CashdeskRepository;
  5. use DateTime;
  6. use DateTimeInterface;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. /**
  11.  * @ORM\Entity(repositoryClass=CashdeskRepository::class)
  12.  * @ORM\Table(name="cashdesks", indexes={
  13.  *     @ORM\Index(columns={"club_id"}),
  14.  *     @ORM\Index(columns={"is_deleted"})
  15.  * })
  16.  */
  17. class Cashdesk
  18. {
  19.     /**
  20.      * @ORM\Id()
  21.      * @ORM\GeneratedValue()
  22.      * @ORM\Column(type="integer", options={"unsigned": true})
  23.      */
  24.     private ?int $id null;
  25.     /**
  26.      * @ORM\Column(type="string", length=255, options={"default": ""})
  27.      */
  28.     private string $title "";
  29.     /**
  30.      * @ORM\Column(type="integer", nullable=false, options={"default": 0, "unsigned": true})
  31.      */
  32.     private int $club_id 0;
  33.     /**
  34.      * @ORM\Column(type="bigint", nullable=false, options={"default": 0})
  35.      */
  36.     private int $balance 0;
  37.     /**
  38.      * @ORM\Column(type="bigint", options={"default": 0})
  39.      */
  40.     private int $limit_max 0;
  41.     /**
  42.      * @ORM\Column(type="bigint", options={"default": 60})
  43.      */
  44.     private int $wcb_borlette_1 60;
  45.     /**
  46.      * @ORM\Column(type="bigint", options={"default": 20})
  47.      */
  48.     private int $wcb_borlette_2 20;
  49.     /**
  50.      * @ORM\Column(type="bigint", options={"default": 10})
  51.      */
  52.     private int $wcb_borlette_3 10;
  53.     /**
  54.      * @ORM\Column(type="bigint", options={"default": 500})
  55.      */
  56.     private int $wcb_3 500;
  57.     /**
  58.      * @ORM\Column(type="bigint", options={"default": 1000})
  59.      */
  60.     private int $wcb_maryaj 1000;
  61.     /**
  62.      * @ORM\Column(type="bigint", options={"default": 5000})
  63.      */
  64.     private int $wcb_4_opt1 5000;
  65.     /**
  66.      * @ORM\Column(type="bigint", options={"default": 5000})
  67.      */
  68.     private int $wcb_4_opt2 5000;
  69.     /**
  70.      * @ORM\Column(type="bigint", options={"default": 5000})
  71.      */
  72.     private int $wcb_4_opt3 5000;
  73.     /**
  74.      * @ORM\Column(type="bigint", options={"default": 25000})
  75.      */
  76.     private int $wcb_5_opt1 25000;
  77.     /**
  78.      * @ORM\Column(type="bigint", options={"default": 25000})
  79.      */
  80.     private int $wcb_5_opt2 25000;
  81.     /**
  82.      * @ORM\Column(type="bigint", options={"default": 25000})
  83.      */
  84.     private int $wcb_5_opt3 25000;
  85.     /**
  86.      * @ORM\Column(type="boolean", nullable=false, options={"default": false})
  87.      */
  88.     private bool $is_deleted false;
  89.     /**
  90.      * @ORM\ManyToOne(targetEntity=Club::class, inversedBy="cashdesks")
  91.      * @ORM\JoinColumn(nullable=false, columnDefinition="INT(11)")
  92.      */
  93.     private ?Club $club;
  94.     /**
  95.      * @ORM\OneToMany(targetEntity=Payment::class, mappedBy="cashdesk")
  96.      */
  97.     private Collection $payments;
  98.     /**
  99.      * @ORM\OneToOne(targetEntity=User::class, mappedBy="current_cashdesk", cascade={"persist", "remove"})
  100.      */
  101.     private ?User $user;
  102.     /**
  103.      * @ORM\OneToOne(targetEntity=Workshift::class, inversedBy="cashdesk", cascade={"persist", "remove"})
  104.      */
  105.     private ?Workshift $current_workshift;
  106.     /**
  107.      * @ORM\ManyToMany(targetEntity=User::class, mappedBy="cashdesks")
  108.      */
  109.     private Collection $users;
  110.     /**
  111.      * @ORM\Column(type="boolean", nullable=true, options={"unsigned": true, "default": 0})
  112.      */
  113.     private ?bool $allow_negative_balance false;
  114.     /**
  115.      * @ORM\Column(type="integer", options={"default": 0})
  116.      */
  117.     private int $limit_negative_balance 0;
  118.     /**
  119.      * @ORM\Column(type="boolean", nullable=true, options={"unsigned": true, "default": 0})
  120.      */
  121.     private ?bool $allow_free_maryaj true;
  122.     /**
  123.      * @ORM\Column(type="boolean", options={"default": false})
  124.      */
  125.     private bool $is_blocked false;
  126.     /**
  127.      * @ORM\Column(type="boolean", options={"default": true})
  128.      */
  129.     private bool $print_koef false;
  130.     /**
  131.      * @ORM\Column(type="boolean", options={"default": false})
  132.      */
  133.     private bool $has_jp false;
  134.     /**
  135.      * @ORM\Column(type="json", nullable=true)
  136.      */
  137.     private ?array $roles = [];
  138.     /**
  139.      * @ORM\Column(type="string", length=255)
  140.      */
  141.     private string $remote_client_token;
  142.     /**
  143.      * @ORM\Column(type="datetime", nullable=true, columnDefinition="TIMESTAMP DEFAULT NULL")
  144.      */
  145.     private ?DateTimeInterface $created_date null;
  146.     public function __construct()
  147.     {
  148.         $this->payments = new ArrayCollection();
  149.         $this->users = new ArrayCollection();
  150.     }
  151.     public function isHideForAdministrator(string $permission): bool
  152.     {
  153.         if (is_null($this->getRoles())) {
  154.             return false;
  155.         }
  156.         return in_array($permission$this->getRoles());
  157.     }
  158.     public function isGranted(string $permission): bool
  159.     {
  160.         if (is_null($this->getRoles())) {
  161.             return false;
  162.         }
  163.         return in_array($permission$this->getRoles());
  164.     }
  165.     public function getId(): ?int
  166.     {
  167.         return $this->id;
  168.     }
  169.     public function getTitle(): ?string
  170.     {
  171.         return $this->title;
  172.     }
  173.     public function setTitle(string $title): self
  174.     {
  175.         $this->title $title;
  176.         return $this;
  177.     }
  178.     public function getClubId(): ?int
  179.     {
  180.         return $this->club_id;
  181.     }
  182.     public function setClubId(int $club_id): self
  183.     {
  184.         $this->club_id $club_id;
  185.         return $this;
  186.     }
  187.     public function getBalance(): ?int
  188.     {
  189.         return $this->balance;
  190.     }
  191.     public function setBalance(int $balance): self
  192.     {
  193.         $this->balance $balance;
  194.         return $this;
  195.     }
  196.     public function getLimitMax(): ?int
  197.     {
  198.         return $this->limit_max;
  199.     }
  200.     public function setLimitMax(int $limit_max): self
  201.     {
  202.         $this->limit_max $limit_max;
  203.         return $this;
  204.     }
  205.     public function getWcbBorlette1(): ?int
  206.     {
  207.         return $this->wcb_borlette_1;
  208.     }
  209.     public function setWcbBorlette1(int $wcb_borlette_1): self
  210.     {
  211.         $this->wcb_borlette_1 $wcb_borlette_1;
  212.         return $this;
  213.     }
  214.     public function getWcbBorlette2(): ?int
  215.     {
  216.         return $this->wcb_borlette_2;
  217.     }
  218.     public function setWcbBorlette2(int $wcb_borlette_2): self
  219.     {
  220.         $this->wcb_borlette_2 $wcb_borlette_2;
  221.         return $this;
  222.     }
  223.     public function getWcbBorlette3(): ?int
  224.     {
  225.         return $this->wcb_borlette_3;
  226.     }
  227.     public function setWcbBorlette3(int $wcb_borlette_3): self
  228.     {
  229.         $this->wcb_borlette_3 $wcb_borlette_3;
  230.         return $this;
  231.     }
  232.     public function getWcb3(): ?int
  233.     {
  234.         return $this->wcb_3;
  235.     }
  236.     public function setWcb3(int $wcb_3): self
  237.     {
  238.         $this->wcb_3 $wcb_3;
  239.         return $this;
  240.     }
  241.     public function getWcbMaryaj(): ?int
  242.     {
  243.         return $this->wcb_maryaj;
  244.     }
  245.     public function setWcbMaryaj(int $wcb_maryaj): self
  246.     {
  247.         $this->wcb_maryaj $wcb_maryaj;
  248.         return $this;
  249.     }
  250.     public function getWcb4Opt1(): ?int
  251.     {
  252.         return $this->wcb_4_opt1;
  253.     }
  254.     public function setWcb4Opt1(int $wcb_4_opt1): self
  255.     {
  256.         $this->wcb_4_opt1 $wcb_4_opt1;
  257.         return $this;
  258.     }
  259.     public function getWcb4Opt2(): ?int
  260.     {
  261.         return $this->wcb_4_opt2;
  262.     }
  263.     public function setWcb4Opt2(int $wcb_4_opt2): self
  264.     {
  265.         $this->wcb_4_opt2 $wcb_4_opt2;
  266.         return $this;
  267.     }
  268.     public function getWcb4Opt3(): ?int
  269.     {
  270.         return $this->wcb_4_opt3;
  271.     }
  272.     public function setWcb4Opt3(int $wcb_4_opt3): self
  273.     {
  274.         $this->wcb_4_opt3 $wcb_4_opt3;
  275.         return $this;
  276.     }
  277.     public function getWcb5Opt1(): ?int
  278.     {
  279.         return $this->wcb_5_opt1;
  280.     }
  281.     public function setWcb5Opt1(int $wcb_5_opt1): self
  282.     {
  283.         $this->wcb_5_opt1 $wcb_5_opt1;
  284.         return $this;
  285.     }
  286.     public function getWcb5Opt2(): ?int
  287.     {
  288.         return $this->wcb_5_opt2;
  289.     }
  290.     public function setWcb5Opt2(int $wcb_5_opt2): self
  291.     {
  292.         $this->wcb_5_opt2 $wcb_5_opt2;
  293.         return $this;
  294.     }
  295.     public function getWcb5Opt3(): ?int
  296.     {
  297.         return $this->wcb_5_opt3;
  298.     }
  299.     public function setWcb5Opt3(int $wcb_5_opt3): self
  300.     {
  301.         $this->wcb_5_opt3 $wcb_5_opt3;
  302.         return $this;
  303.     }
  304.     public function getCreatedDate(): ?DateTimeInterface
  305.     {
  306.         return $this->created_date;
  307.     }
  308.     public function setCreatedDate(?DateTimeInterface $created_date): self
  309.     {
  310.         $this->created_date $created_date;
  311.         return $this;
  312.     }
  313.     public function getIsDeleted(): ?bool
  314.     {
  315.         return $this->is_deleted;
  316.     }
  317.     public function setIsDeleted(bool $is_deleted): self
  318.     {
  319.         $this->is_deleted $is_deleted;
  320.         return $this;
  321.     }
  322.     public function getClub(): ?Club
  323.     {
  324.         return $this->club;
  325.     }
  326.     public function setClub(?Club $club): self
  327.     {
  328.         $this->club $club;
  329.         return $this;
  330.     }
  331.     /**
  332.      * @return Collection
  333.      */
  334.     public function getPayments(): Collection
  335.     {
  336.         return $this->payments;
  337.     }
  338.     public function addPayment(Payment $payment): self
  339.     {
  340.         if (!$this->payments->contains($payment)) {
  341.             $this->payments[] = $payment;
  342.             $payment->setCashdesk($this);
  343.         }
  344.         return $this;
  345.     }
  346.     public function removePayment(Payment $payment): self
  347.     {
  348.         if ($this->payments->contains($payment)) {
  349.             $this->payments->removeElement($payment);
  350.             // set the owning side to null (unless already changed)
  351.             if ($payment->getCashdesk() === $this) {
  352.                 $payment->setCashdesk(null);
  353.             }
  354.         }
  355.         return $this;
  356.     }
  357.     public function getUser(): ?User
  358.     {
  359.         return $this->user;
  360.     }
  361.     public function setUser(?User $user): self
  362.     {
  363.         $this->user $user;
  364.         // set (or unset) the owning side of the relation if necessary
  365.         $newCurrent_cashdesk null === $user null $this;
  366.         if ($user->getCurrentCashdesk() !== $newCurrent_cashdesk) {
  367.             $user->setCurrentCashdesk($newCurrent_cashdesk);
  368.         }
  369.         return $this;
  370.     }
  371.     public function getCurrentWorkshift(): ?Workshift
  372.     {
  373.         return $this->current_workshift;
  374.     }
  375.     public function setCurrentWorkshift(?Workshift $current_workshift): self
  376.     {
  377.         $this->current_workshift $current_workshift;
  378.         return $this;
  379.     }
  380.     /**
  381.      * @return Collection
  382.      */
  383.     public function getUsers(): Collection
  384.     {
  385.         return $this->users;
  386.     }
  387.     public function addUser(User $user): self
  388.     {
  389.         if (!$this->users->contains($user)) {
  390.             $this->users[] = $user;
  391.             $user->addCashdesk($this);
  392.         }
  393.         return $this;
  394.     }
  395.     public function removeUser(User $user): self
  396.     {
  397.         if ($this->users->contains($user)) {
  398.             $this->users->removeElement($user);
  399.             $user->removeCashdesk($this);
  400.         }
  401.         return $this;
  402.     }
  403.     public function getAllowNegativeBalance(): ?bool
  404.     {
  405.         return $this->allow_negative_balance;
  406.     }
  407.     public function setAllowNegativeBalance(?bool $allow_negative_balance): self
  408.     {
  409.         $this->allow_negative_balance $allow_negative_balance;
  410.         return $this;
  411.     }
  412.     public function getLimitNegativeBalance(): ?int
  413.     {
  414.         return $this->limit_negative_balance;
  415.     }
  416.     public function setLimitNegativeBalance(int $limit_negative_balance): self
  417.     {
  418.         $this->limit_negative_balance $limit_negative_balance;
  419.         return $this;
  420.     }
  421.     public function getAllowFreeMaryaj(): ?bool
  422.     {
  423.         return $this->allow_free_maryaj;
  424.     }
  425.     public function setAllowFreeMaryaj(?bool $allow_free_maryaj): self
  426.     {
  427.         $this->allow_free_maryaj $allow_free_maryaj;
  428.         return $this;
  429.     }
  430.     public function getIsBlocked(): ?bool
  431.     {
  432.         return $this->is_blocked;
  433.     }
  434.     public function setIsBlocked(bool $is_blocked): self
  435.     {
  436.         $this->is_blocked $is_blocked;
  437.         return $this;
  438.     }
  439.     public function getPrintKoef(): ?bool
  440.     {
  441.         return $this->print_koef;
  442.     }
  443.     public function setPrintKoef(bool $print_koef): self
  444.     {
  445.         $this->print_koef $print_koef;
  446.         return $this;
  447.     }
  448.     public function getHasJP(): ?bool
  449.     {
  450.         return $this->has_jp;
  451.     }
  452.     public function setHasJP(bool $has_jp): self
  453.     {
  454.         $this->has_jp $has_jp;
  455.         return $this;
  456.     }
  457.     public function getRoles(): ?array
  458.     {
  459.         return $this->roles;
  460.     }
  461.     public function setRoles(?array $roles): self
  462.     {
  463.         $this->roles $roles;
  464.         return $this;
  465.     }
  466.     public function getRemoteClientToken(): ?string
  467.     {
  468.         return $this->remote_client_token;
  469.     }
  470.     public function setRemoteClientToken(string $remote_client_token): self
  471.     {
  472.         $this->remote_client_token $remote_client_token;
  473.         return $this;
  474.     }
  475.     public function getAllowWorkshift() {
  476.         return $this->isGranted(Roles::ROLE_ONLINE_CASHDESK_WORK_SHIFT);
  477.     }
  478. }