<?phpnamespace App\Entity\Training;use ApiPlatform\Core\Annotation\ApiResource;use App\Repository\Training\FpaylineRepository;use App\Entity\Training\Fee;use App\Entity\Training\Fpayment;use App\Traits\Actions;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: FpaylineRepository::class)]#[ORM\Table(name: 'hs_tc_training_fpayline')]#[ApiResource]class Fpayline{ use Actions; #[ORM\ManyToOne(targetEntity: Fpayment::class, inversedBy: "items")] #[ORM\JoinColumn(nullable: false)] private Fpayment $payment; #[ORM\ManyToOne(targetEntity: "Fee", inversedBy: "items")] #[ORM\JoinColumn(nullable: true)] private Fee $fee; #[ORM\Column(name: "amount", type: "float")] private float $amount; public function __construct() { // date_default_timezone_set('Africa/Casablanca'); $this->createAt=new \DateTime('now'); $this->published=false; } /** * @return Fpayment */ public function getPayment(): ?Fpayment { return $this->payment; } /** * @param Fpayment $payment */ public function setPayment(?Fpayment $payment): Fpayline { $this->payment = $payment; return $this; } /** * @return Fee */ public function getFee(): ?Fee { return $this->fee; } /** * @param Fee $fee */ public function setFee(?Fee $fee): Fpayline { $this->fee = $fee; return $this; } /** * Set amount * * @param float $amount * * @return Fpayline */ public function setAmount($amount) { $this->amount = $amount; return $this; } /** * Get amount * * @return float */ public function getAmount() { return $this->amount; } public function getPrinterAmount(){ if($this->getPayment()->getTrainee()->isDiscount() || !$this->fee->isDiscount()) return $this->amount; else{ return $this->amount*$this->fee->getRegularAmount()/$this->fee->getMontant(); } } public function getLabel() { if($this->getFee()->getDatePaie()>$this->getPayment()->getPublishedAt()){ return "<span class='label label-success' style='margin-left: 5px;'>".$this->getFee()->getDisplayType()." : ".$this->getFee()->getName()." (".number_format($this->getAmount(),2)." DH)"."</span>"; } elseif($this->getFee()->getTerm()<$this->getPayment()->getPublishedAt()){ return "<span class='label label-danger' style='margin-left: 5px;'>".$this->getFee()->getDisplayType()." : ".$this->getFee()->getName()." (".number_format($this->getAmount(),2)." DH)"."</span>"; } else{ return "<span class='label label-info' style='margin-left: 5px;'>".$this->getFee()->getDisplayType()." : ".$this->getFee()->getName()." (".number_format($this->getAmount(),2)." DH)"."</span>"; } }}