src/Entity/Training/Trashfpayment.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Training;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\Training\FpaymentRepository;
  5. use App\Repository\Training\TrashfpaymentRepository;
  6. use App\Traits\Actions;
  7. use App\Entity\User;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\EntityNotFoundException;
  11. use Doctrine\ORM\Mapping as ORM;
  12. #[ORM\Entity(repositoryClassTrashfpaymentRepository::class)]
  13. #[ORM\Table(name'hs_tc_training_trashfpayment')]
  14. #[ApiResource]
  15. class Trashfpayment implements \Stringable
  16. {
  17.     use Actions;
  18.     #[ORM\Column]
  19.     private ?int $traineeId null;
  20.     #[ORM\Column]
  21.     private ?int $groupeId null;
  22.     #[ORM\Column]
  23.     private ?string $groupeName null;
  24.     #[ORM\Column]
  25.     private ?string $traineeFirstName null;
  26.     #[ORM\Column]
  27.     private ?string $traineeLastName null;
  28.     #[ORM\ManyToOne(targetEntityUser::class)]
  29.     #[ORM\JoinColumn(nullabletrue)]
  30.     private User $initie;
  31.     #[ORM\ManyToOne(targetEntityUser::class)]
  32.     #[ORM\JoinColumn(nullabletrue)]
  33.     private User $suppressor;
  34.     #[ORM\Column(name"fees"type"string"length255)]
  35.     private string $fees;
  36.     #[ORM\Column(name"way"type"string"length255nullabletrue)]
  37.     private ?string $way;
  38.     #[ORM\Column(name"amount"type"float")]
  39.     private float $amount;
  40.     #[ORM\Column(name"doc_number"type"string"length255)]
  41.     private string $docNumber '11';
  42. //    #[ORM\Column(name: "cached", type: "boolean")]
  43. //    private bool $cached;
  44.     #[ORM\Column(type'string'length255)]
  45.     private string $moyen;
  46.     #[ORM\OneToMany(mappedBy"payment"targetEntityTrashfpayline::class, cascade: ["all"], orphanRemovaltrue)]
  47.     private Collection $items;
  48.     #[ORM\Column(type'datetime'nullabletrue)]
  49.     private ?\DateTime $trashedAt null;
  50.     public function __construct(Fpayment $fpayment)
  51.     {
  52.         // date_default_timezone_set('Africa/Casablanca');
  53.         $this->way $fpayment->getWay();
  54.         $this->amount $fpayment->getAmount();
  55.         $this->fees $fpayment->getFees();
  56.         $this->initie $fpayment->getInitie();
  57.         $this->createAt=$fpayment->getCreateAt();
  58.         $this->publishedAt=$fpayment->getPublishedAt();
  59.         $this->published=$fpayment->isPublished();
  60.         $this->traineeId=$fpayment->getTrainee()->getId();
  61.         $this->traineeFirstName=$fpayment->getTrainee()->getFirstName();
  62.         $this->traineeLastName=$fpayment->getTrainee()->getLastName();
  63.         $this->groupeId=$fpayment->getTrainee()->getGroupe()->getId();
  64.         $this->groupeName=$fpayment->getTrainee()->getGroupe();
  65.         $this->moyen=$fpayment->getMoyen();
  66.         $this->trashedAt=new \DateTime('now');
  67.         $this->items = new ArrayCollection();
  68.         foreach ($fpayment->getItems() as $fpayline) {
  69.             $item=new Trashfpayline($fpayline);
  70.             $item->setPayment($this);
  71.             $this->items->add($item);
  72.         }
  73.     }
  74.     public function restore(Trainee $trainee, array $fees)
  75.     {
  76.         $fpayment = new Fpayment();
  77.         // date_default_timezone_set('Africa/Casablanca');
  78.         $fpayment->setWay($this->getWay());
  79.         $fpayment->setAmount($this->getAmount());
  80.         $fpayment->setFees($this->getFees());
  81.         $fpayment->setInitie($this->getInitie());
  82.         $fpayment->setCreateAt2($this->getCreateAt());
  83.         $fpayment->setPublishedAt($this->publishedAt);
  84.         $fpayment->setPublished($this->isPublished());
  85.         $fpayment->setTrainee($trainee);
  86.         $fpayment->setMoyen($this->getMoyen());
  87.         foreach ($fees as $feeItem) {
  88.             $fpayline $feeItem['trashfpayline']->restore($feeItem['fee']);
  89.             $fpayment->addItem($fpayline);
  90.         }
  91.         return $fpayment;
  92.     }
  93.     /**
  94.      * @return string
  95.      */
  96.     public function getFees(): ?string
  97.     {
  98.         return $this->fees;
  99.     }
  100.     /**
  101.      * @param string $fees
  102.      */
  103.     public function setFees(?string $fees): Trashfpayment
  104.     {
  105.         $this->fees $fees;
  106.         return $this;
  107.     }
  108.     /**
  109.      * Set way
  110.      *
  111.      * @param string $way
  112.      *
  113.      * @return Trashfpayment
  114.      */
  115.     public function setWay($way)
  116.     {
  117.         $this->way $way;
  118.         return $this;
  119.     }
  120.     /**
  121.      * Get way
  122.      *
  123.      * @return string
  124.      */
  125.     public function getWay()
  126.     {
  127.         return $this->way;
  128.     }
  129.     public function getMoyen(): string
  130.     {
  131.         return $this->moyen;
  132.     }
  133.     public function setMoyen(string $moyen): Trashfpayment
  134.     {
  135.         $this->moyen $moyen;
  136.         return $this;
  137.     }
  138.     /**
  139.      * Set amount
  140.      *
  141.      * @param float $amount
  142.      *
  143.      * @return Trashfpayment
  144.      */
  145.     public function setAmount($amount)
  146.     {
  147.         $this->amount $amount;
  148.         return $this;
  149.     }
  150.     /**
  151.      * Get amount
  152.      *
  153.      * @return float
  154.      */
  155.     public function getAmount()
  156.     {
  157.         return $this->amount;
  158.     }
  159.     /**
  160.      * Set docNumber
  161.      *
  162.      * @param string $docNumber
  163.      *
  164.      * @return Trashfpayment
  165.      */
  166.     public function setDocNumber($docNumber)
  167.     {
  168.         $this->docNumber $docNumber;
  169.         return $this;
  170.     }
  171.     /**
  172.      * Get docNumber
  173.      *
  174.      * @return string
  175.      */
  176.     public function getDocNumber()
  177.     {
  178.         return $this->docNumber;
  179.     }
  180.     public function getTraineeId(): ?int
  181.     {
  182.         return $this->traineeId;
  183.     }
  184.     public function setTraineeId(?int $traineeId): void
  185.     {
  186.         $this->traineeId $traineeId;
  187.     }
  188.     public function getGroupeId(): ?int
  189.     {
  190.         return $this->groupeId;
  191.     }
  192.     public function setGroupeId(?int $groupeId): void
  193.     {
  194.         $this->groupeId $groupeId;
  195.     }
  196.     public function getGroupeName(): ?string
  197.     {
  198.         return $this->groupeName;
  199.     }
  200.     public function setGroupeName(?string $groupeName): void
  201.     {
  202.         $this->groupeName $groupeName;
  203.     }
  204.     public function getTraineeFirstName(): ?string
  205.     {
  206.         return $this->traineeFirstName;
  207.     }
  208.     public function setTraineeFirstName(?string $traineeFirstName): void
  209.     {
  210.         $this->traineeFirstName $traineeFirstName;
  211.     }
  212.     public function getTraineeLastName(): ?string
  213.     {
  214.         return $this->traineeLastName;
  215.     }
  216.     public function setTraineeLastName(?string $traineeLastName): void
  217.     {
  218.         $this->traineeLastName $traineeLastName;
  219.     }
  220.     /**
  221.      * Set initie
  222.      *
  223.      *
  224.      * @return Trashfpayment
  225.      */
  226.     public function setInitie(User $initie)
  227.     {
  228.         $this->initie $initie;
  229.         return $this;
  230.     }
  231.     /**
  232.      * Get initie
  233.      *
  234.      * @return User
  235.      */
  236.     public function getInitie()
  237.     {
  238.         return $this->initie;
  239.     }
  240.     /**
  241.      * Add item
  242.      *
  243.      *
  244.      * @return Trashfpayment
  245.      */
  246.     public function addItem(Trashfpayline $item)
  247.     {
  248.         $item->setPayment($this);
  249.         $this->items->add($item);
  250.         return $this;
  251.     }
  252.     /**
  253.      * Remove item
  254.      */
  255.     public function removeItem(Trashfpayline $item)
  256.     {
  257.         $this->items->removeElement($item);
  258.     }
  259.     /**
  260.      * Get items
  261.      *
  262.      * @return Collection
  263.      */
  264.     public function getItems()
  265.     {
  266.         return $this->items;
  267.     }
  268.     public function getMonths(){
  269.         return $this->way;
  270.     }
  271.     public function __toString(): string
  272.     {
  273.         return
  274.             'Id:'.$this->id.'<br>'.
  275.             'Date:'.$this->getCreateAt()->format('d-m-Y').'<br>'.
  276.             'Stagiaire: '.$this->trainee->getCompletName().'<br>'.
  277.             'Raison:'.'<br>'.
  278.             'Montant: '.$this->getAmount().' DH<br>'
  279.             ;
  280.     }
  281.     public function getSuppressor(): User
  282.     {
  283.         return $this->suppressor;
  284.     }
  285.     public function setSuppressor(User $suppressor): Trashfpayment
  286.     {
  287.         $this->suppressor $suppressor;
  288.         return $this;
  289.     }
  290.     public function getTrashedAt(): ?\DateTime
  291.     {
  292.         return $this->trashedAt;
  293.     }
  294.     public function setTrashedAt(?\DateTime $trashedAt): Trashfpayment
  295.     {
  296.         $this->trashedAt $trashedAt;
  297.         return $this;
  298.     }
  299.     public function setCreateAt2(\DateTime $dateTime): Trashfpayment
  300.     {
  301.         $this->createAt=$dateTime;
  302.         return $this;
  303.     }
  304. }