src/Entity/IctoMouvement.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\IctoMouvementRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Entity(repositoryClass=IctoMouvementRepository::class)
  7.  */
  8. class IctoMouvement
  9. {
  10.     /**
  11.      * @ORM\Id
  12.      * @ORM\GeneratedValue
  13.      * @ORM\Column(type="integer")
  14.      */
  15.     private $id;
  16.     /**
  17.      * @ORM\Column(type="float")
  18.      */
  19.     private $montant;
  20.     /**
  21.      * @ORM\Column(type="text")
  22.      */
  23.     private $raison;
  24.     /**
  25.      * @ORM\Column(type="datetime_immutable")
  26.      */
  27.     private $created_at;
  28.     /**
  29.      * @ORM\ManyToOne(targetEntity=IctusPharmacie::class, inversedBy="ictoMouvements")
  30.      * @ORM\JoinColumn(nullable=true)
  31.      */
  32.     private $pharmacie;
  33.     /**
  34.      * @ORM\ManyToOne(targetEntity=IctoTypemouvement::class, inversedBy="ictoMouvements")
  35.      * @ORM\JoinColumn(nullable=false)
  36.      */
  37.     private $typemouvement;
  38.     /**
  39.      * @ORM\ManyToOne(targetEntity=SocieteLivraison::class, inversedBy="ictoMouvements")
  40.      * @ORM\JoinColumn(nullable=true)
  41.      */
  42.     private $societeLivraison;
  43.     /**
  44.      * @ORM\ManyToOne(targetEntity=FacturePharmacie::class, inversedBy="ictoMouvements")
  45.      */
  46.     private $facture;
  47.     /**
  48.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="ictoMouvements")
  49.      */
  50.     private $user;
  51.     public function __construct()
  52.     {
  53.         $this->created_at = new \DateTimeImmutable();
  54.     }
  55.     public function getId(): ?int
  56.     {
  57.         return $this->id;
  58.     }
  59.     public function getMontant(): ?float
  60.     {
  61.         return $this->montant;
  62.     }
  63.     public function setMontant(float $montant): self
  64.     {
  65.         $this->montant $montant;
  66.         return $this;
  67.     }
  68.     public function getRaison(): ?string
  69.     {
  70.         $raison $this->raison;
  71.         if (strpos($raison":/cmd")) {
  72.             $raison $this->transformerCommande($raison);
  73.         }
  74.         if (strpos($raison":/pmt")) {
  75.             $raison $this->transformerPaiement($raison);
  76.         }
  77.         if (strpos($raison":/rmb")) {
  78.             $raison $this->transformerRemboursement($raison);
  79.         }
  80.         if (strpos($raison":/ach")) {
  81.             $raison $this->transformerAchat($raison);
  82.         }
  83.         return $raison;
  84.     }
  85.     public function setRaison(string $raison): self
  86.     {
  87.         $this->raison $raison;
  88.         return $this;
  89.     }
  90.     public function getCreatedAt(): ?\DateTimeImmutable
  91.     {
  92.         return $this->created_at;
  93.     }
  94.     public function setCreatedAt(\DateTimeImmutable $created_at): self
  95.     {
  96.         $this->created_at $created_at;
  97.         return $this;
  98.     }
  99.     public function getPharmacie(): ?IctusPharmacie
  100.     {
  101.         return $this->pharmacie;
  102.     }
  103.     public function setPharmacie(?IctusPharmacie $pharmacie): self
  104.     {
  105.         $this->pharmacie $pharmacie;
  106.         return $this;
  107.     }
  108.     public function getTypemouvement(): ?IctoTypemouvement
  109.     {
  110.         return $this->typemouvement;
  111.     }
  112.     public function setTypemouvement(?IctoTypemouvement $typemouvement): self
  113.     {
  114.         $this->typemouvement $typemouvement;
  115.         return $this;
  116.     }
  117.     private function transformerCommande($inputText)
  118.     {
  119.         $regexPattern '/:\/cmd\s*{{(\d+)}}/';
  120.         $outputText preg_replace_callback($regexPattern, function ($matches) {
  121.             $number $matches[1];
  122.             $newText ": <a href='https://www.pharmadexi.com/ictus/commande/patient/detail/{$number}'>{$number}</a>";
  123.             return $newText;
  124.         }, $inputText);
  125.         return $outputText;
  126.     }
  127.     private function transformerPaiement($inputText)
  128.     {
  129.         $regexPattern '/:\/pmt\s*{{(\d+)}}/';
  130.         $outputText preg_replace_callback($regexPattern, function ($matches) {
  131.             $number $matches[1];
  132.             $newText ": <a href='https://www.pharmadexi.com/ictus/paiement/{$number}'>{$number}</a>";
  133.             return $newText;
  134.         }, $inputText);
  135.         return $outputText;
  136.     }
  137.     private function transformerRemboursement($inputText)
  138.     {
  139.         $regexPattern '/:\/rmb\s*{{(\d+)}}/';
  140.         $outputText preg_replace_callback($regexPattern, function ($matches) {
  141.             $number $matches[1];
  142.             $newText ": <a href='https://www.pharmadexi.com/wallet/refund/{$number}'>{$number}</a>";
  143.             return $newText;
  144.         }, $inputText);
  145.         return $outputText;
  146.     }
  147.     private function transformerAchat($inputText)
  148.     {
  149.         $regexPattern '/:\/ach\s*{{(\d+)}}/';
  150.         $outputText preg_replace_callback($regexPattern, function ($matches) {
  151.             $number $matches[1];
  152.             $newText ": <a href='https://www.pharmadexi.com/wallet/buy-ictocoin/{$number}'>{$number}</a>";
  153.             return $newText;
  154.         }, $inputText);
  155.         return $outputText;
  156.     }
  157.     public function getSocieteLivraison(): ?SocieteLivraison
  158.     {
  159.         return $this->societeLivraison;
  160.     }
  161.     public function setSocieteLivraison(?SocieteLivraison $societeLivraison): self
  162.     {
  163.         $this->societeLivraison $societeLivraison;
  164.         return $this;
  165.     }
  166.     public function getFacture(): ?FacturePharmacie
  167.     {
  168.         return $this->facture;
  169.     }
  170.     public function setFacture(?FacturePharmacie $facture): self
  171.     {
  172.         $this->facture $facture;
  173.         return $this;
  174.     }
  175.     public function getUser(): ?User
  176.     {
  177.         return $this->user;
  178.     }
  179.     public function setUser(?User $user): self
  180.     {
  181.         $this->user $user;
  182.         return $this;
  183.     }
  184. }