<?php
namespace App\Entity;
use App\Repository\IctoMouvementRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=IctoMouvementRepository::class)
*/
class IctoMouvement
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="float")
*/
private $montant;
/**
* @ORM\Column(type="text")
*/
private $raison;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $created_at;
/**
* @ORM\ManyToOne(targetEntity=IctusPharmacie::class, inversedBy="ictoMouvements")
* @ORM\JoinColumn(nullable=true)
*/
private $pharmacie;
/**
* @ORM\ManyToOne(targetEntity=IctoTypemouvement::class, inversedBy="ictoMouvements")
* @ORM\JoinColumn(nullable=false)
*/
private $typemouvement;
/**
* @ORM\ManyToOne(targetEntity=SocieteLivraison::class, inversedBy="ictoMouvements")
* @ORM\JoinColumn(nullable=true)
*/
private $societeLivraison;
/**
* @ORM\ManyToOne(targetEntity=FacturePharmacie::class, inversedBy="ictoMouvements")
*/
private $facture;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="ictoMouvements")
*/
private $user;
public function __construct()
{
$this->created_at = new \DateTimeImmutable();
}
public function getId(): ?int
{
return $this->id;
}
public function getMontant(): ?float
{
return $this->montant;
}
public function setMontant(float $montant): self
{
$this->montant = $montant;
return $this;
}
public function getRaison(): ?string
{
$raison = $this->raison;
if (strpos($raison, ":/cmd")) {
$raison = $this->transformerCommande($raison);
}
if (strpos($raison, ":/pmt")) {
$raison = $this->transformerPaiement($raison);
}
if (strpos($raison, ":/rmb")) {
$raison = $this->transformerRemboursement($raison);
}
if (strpos($raison, ":/ach")) {
$raison = $this->transformerAchat($raison);
}
return $raison;
}
public function setRaison(string $raison): self
{
$this->raison = $raison;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeImmutable $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getPharmacie(): ?IctusPharmacie
{
return $this->pharmacie;
}
public function setPharmacie(?IctusPharmacie $pharmacie): self
{
$this->pharmacie = $pharmacie;
return $this;
}
public function getTypemouvement(): ?IctoTypemouvement
{
return $this->typemouvement;
}
public function setTypemouvement(?IctoTypemouvement $typemouvement): self
{
$this->typemouvement = $typemouvement;
return $this;
}
private function transformerCommande($inputText)
{
$regexPattern = '/:\/cmd\s*{{(\d+)}}/';
$outputText = preg_replace_callback($regexPattern, function ($matches) {
$number = $matches[1];
$newText = ": <a href='https://www.pharmadexi.com/ictus/commande/patient/detail/{$number}'>{$number}</a>";
return $newText;
}, $inputText);
return $outputText;
}
private function transformerPaiement($inputText)
{
$regexPattern = '/:\/pmt\s*{{(\d+)}}/';
$outputText = preg_replace_callback($regexPattern, function ($matches) {
$number = $matches[1];
$newText = ": <a href='https://www.pharmadexi.com/ictus/paiement/{$number}'>{$number}</a>";
return $newText;
}, $inputText);
return $outputText;
}
private function transformerRemboursement($inputText)
{
$regexPattern = '/:\/rmb\s*{{(\d+)}}/';
$outputText = preg_replace_callback($regexPattern, function ($matches) {
$number = $matches[1];
$newText = ": <a href='https://www.pharmadexi.com/wallet/refund/{$number}'>{$number}</a>";
return $newText;
}, $inputText);
return $outputText;
}
private function transformerAchat($inputText)
{
$regexPattern = '/:\/ach\s*{{(\d+)}}/';
$outputText = preg_replace_callback($regexPattern, function ($matches) {
$number = $matches[1];
$newText = ": <a href='https://www.pharmadexi.com/wallet/buy-ictocoin/{$number}'>{$number}</a>";
return $newText;
}, $inputText);
return $outputText;
}
public function getSocieteLivraison(): ?SocieteLivraison
{
return $this->societeLivraison;
}
public function setSocieteLivraison(?SocieteLivraison $societeLivraison): self
{
$this->societeLivraison = $societeLivraison;
return $this;
}
public function getFacture(): ?FacturePharmacie
{
return $this->facture;
}
public function setFacture(?FacturePharmacie $facture): self
{
$this->facture = $facture;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
}