src/Entity/Training/Fpayline.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Training;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\Training\FpaylineRepository;
  5. use App\Entity\Training\Fee;
  6. use App\Entity\Training\Fpayment;
  7. use App\Traits\Actions;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassFpaylineRepository::class)]
  10. #[ORM\Table(name'hs_tc_training_fpayline')]
  11. #[ApiResource]
  12. class Fpayline
  13. {
  14.     use Actions;
  15.     #[ORM\ManyToOne(targetEntityFpayment::class, inversedBy"items")]
  16.     #[ORM\JoinColumn(nullablefalse)]
  17.     private Fpayment $payment;
  18.     #[ORM\ManyToOne(targetEntity"Fee"inversedBy"items")]
  19.     #[ORM\JoinColumn(nullabletrue)]
  20.     private Fee $fee;
  21.     #[ORM\Column(name"amount"type"float")]
  22.     private float $amount;
  23.     public function __construct()
  24.     {
  25.         // date_default_timezone_set('Africa/Casablanca');
  26.         $this->createAt=new \DateTime('now');
  27.         $this->published=false;
  28.     }
  29.     /**
  30.      * @return Fpayment
  31.      */
  32.     public function getPayment(): ?Fpayment
  33.     {
  34.         return $this->payment;
  35.     }
  36.     /**
  37.      * @param Fpayment $payment
  38.      */
  39.     public function setPayment(?Fpayment $payment): Fpayline
  40.     {
  41.         $this->payment $payment;
  42.         return $this;
  43.     }
  44.     /**
  45.      * @return Fee
  46.      */
  47.     public function getFee(): ?Fee
  48.     {
  49.         return $this->fee;
  50.     }
  51.     /**
  52.      * @param Fee $fee
  53.      */
  54.     public function setFee(?Fee $fee): Fpayline
  55.     {
  56.         $this->fee $fee;
  57.         return $this;
  58.     }
  59.     /**
  60.      * Set amount
  61.      *
  62.      * @param float $amount
  63.      *
  64.      * @return Fpayline
  65.      */
  66.     public function setAmount($amount)
  67.     {
  68.         $this->amount $amount;
  69.         return $this;
  70.     }
  71.     /**
  72.      * Get amount
  73.      *
  74.      * @return float
  75.      */
  76.     public function getAmount()
  77.     {
  78.         return $this->amount;
  79.     }
  80.     public function getPrinterAmount(){
  81.         if($this->getPayment()->getTrainee()->isDiscount() || !$this->fee->isDiscount()) return $this->amount;
  82.         else{
  83.             return $this->amount*$this->fee->getRegularAmount()/$this->fee->getMontant();
  84.         }
  85.     }
  86.     public function getLabel()
  87.     {
  88.         if($this->getFee()->getDatePaie()>$this->getPayment()->getPublishedAt()){
  89.             return "<span class='label label-success' style='margin-left: 5px;'>".$this->getFee()->getDisplayType()." : ".$this->getFee()->getName()." (".number_format($this->getAmount(),2)." DH)"."</span>";
  90.         }
  91.         elseif($this->getFee()->getTerm()<$this->getPayment()->getPublishedAt()){
  92.             return "<span class='label label-danger' style='margin-left: 5px;'>".$this->getFee()->getDisplayType()." : ".$this->getFee()->getName()." (".number_format($this->getAmount(),2)." DH)"."</span>";
  93.         }
  94.         else{
  95.             return "<span class='label label-info' style='margin-left: 5px;'>".$this->getFee()->getDisplayType()." : ".$this->getFee()->getName()." (".number_format($this->getAmount(),2)." DH)"."</span>";
  96.         }
  97.     }
  98. }