src/Entity/Slave/Product.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Slave;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Table(name="eposm_s_product")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Slave\ProductRepository")
  10.  */
  11. class Product
  12. {    
  13.     public function __toString(){
  14.         return $this->getModel()->getName().' --- '.$this->displayCodes();
  15.     }
  16.     public function toStringShort(){
  17.         $result $this->getModel()->getName();
  18.         if($this->codeSupplier != null && $this->codeProducer != null){
  19.             $result.= ' ('.$this->getCodeSupplier().' - '.$this->getCodeProducer().')';
  20.         }
  21.         else{
  22.             if($this->codeSupplier != null$result.= ' ('.$this->getCodeSupplier().')';
  23.             if($this->codeProducer != null$result.= ' ('.$this->getCodeProducer().')';
  24.         }
  25.         return $result;
  26.     }
  27.     public function canDelete(){
  28.         if(sizeof($this->getRegeneratedProducts()) > 0) return false;
  29.         if(sizeof($this->getWithdrawActivities()) > 0) return false;
  30.         if(sizeof($this->getActualActivities()) > 0) return false;
  31.         if(sizeof($this->getInstallationActivities()) > 0) return false;
  32.         if(sizeof($this->getProducts()) > 0) return false;
  33.         return true;
  34.     }
  35.     
  36.     public function canBeTransferredStatus($transfer){
  37.         switch($transfer->getType()){
  38.             case 'technician':
  39.                 if($this->getStatus()->getSlug() != "available")
  40.                     return 'Il prodotto non è nello stato Disponibile';
  41.                 break;
  42.             case 'main':
  43.                 if($this->getStatus()->getSlug() == "transfer")
  44.                     return 'Il prodotto è già in trasferimento';
  45.                 if($this->getCondition()->getSlug() == "lost")
  46.                     return 'Non è possibile trasferire un prodotto smarrito';
  47.                 break;
  48.             case 'destination':
  49.                 if($this->getStatus()->getSlug() == "transfer")
  50.                     return 'Il prodotto è già in trasferimento';
  51.                 if($transfer->getSupplier() != null && !$this->hasSupplier($transfer->getSupplier()))
  52.                     return "Il prodotto non può essere utilizzato per il fornitore ".$transfer->getSupplier();
  53.                 break;
  54.             default: break;
  55.         }
  56.         return "ok";
  57.     }
  58.     
  59.     public function getIsAlreadyInserted($type){
  60.         if(sizeof($this->getTransfers()) > 0) return false;
  61.         if($type == "withdraw" && sizeof($this->getWithdrawActivities()) > 1) return false;
  62.         if($type != "withdraw" && sizeof($this->getWithdrawActivities()) > 0) return false;
  63.         if($type == "actual" && sizeof($this->getActualActivities()) > 1) return false;
  64.         if($type != "actual" && sizeof($this->getActualActivities()) > 0) return false;
  65.         if(sizeof($this->getInstallationActivities()) > 0) return false;
  66.         if(sizeof($this->getProducts()) > 0) return false;
  67.         return true;
  68.     }
  69.     public function getDisplayConflict(){
  70.         $string "<strong>Modello</strong>: ".$this->getModel()->getName()."<br>";
  71.         $string.= "<strong>Matricola produttore</strong>: ".$this->getCodeProducer()."<br>";
  72.         $string.= "<strong>Matricola fornitore</strong>: ".$this->getCodeSupplier()."<br>";
  73.         return $string;
  74.     }
  75.     public function displayActive(){
  76.         if($this->active){
  77.             $color 'color_gr';
  78.             $title 'Attivo';
  79.         }
  80.         else{
  81.             $color 'color_r';
  82.             $title 'Sospeso';
  83.         }
  84.         return '<i class="icon-circle cursor_p '.$color.'" data-bs-toggle="tooltip" title="'.$title.'"></i>';
  85.     }
  86.     public function displayStatus($type){
  87.         switch($this->getStatus()->getSlug()){
  88.             case 'available'$color 'color_gr'; break;
  89.             case 'transfer'$color 'color_am'; break;
  90.             case 'in_use'$color 'color_r'; break;
  91.             case 'not_available'$color 'color_am'; break;
  92.             default: break;
  93.         }
  94.         
  95.         switch($type){
  96.             case 'icon'$string '<i class="icon-circle cursor_p '.$color.'" data-bs-toggle="tooltip" title="'.$this->getStatus()->getValue().'"></i>'; break;
  97.             case 'string'$string $this->getStatus()->getValue(); break;
  98.             default: break;
  99.         }
  100.         return $string;
  101.     }
  102.     
  103.     public function displayCondition($type){
  104.         $string '';
  105.         switch($this->getCondition()->getSlug()){
  106.             case 'new'
  107.             case 'refurbished':
  108.             case 'repaired':
  109.             case 'free':
  110.             case 'regenerated':
  111.                 $color 'color_gr';
  112.                 break;
  113.             case 'retired':
  114.             case 'historic':
  115.                 $color 'color_am';
  116.                 break;
  117.             case 'broken':
  118.             case 'doa':
  119.             case 'lost':
  120.                 $color 'color_r';
  121.                 break;
  122.             default: break;
  123.         }
  124.         switch($type){
  125.             case 'icon'$string '<i class="icon-circle cursor_p '.$color.'" data-bs-toggle="tooltip" title="'.$this->getCondition()->getValue().'"></i>'; break;
  126.             case 'string'$string $this->getCondition()->getValue(); break;
  127.             case 'string-short'$str explode('-'$this->getCondition()->getValue()); $string $str[0]; break;
  128.             default: break;
  129.         }
  130.         return $string;
  131.     }
  132.     public function displayCodes(){
  133.         $result '';
  134.         if($this->codeSupplier != null)
  135.             $result.= 'Matricola fornitore: '.$this->getCodeSupplier();
  136.         if($this->codeProducer != null){
  137.             if($result != ''$result.= ' --- ';
  138.             $result.= 'Matricola produttore: '.$this->getCodeProducer();
  139.         }
  140.         return $result;
  141.     }
  142.         
  143.     public function displayChildrenProducts($type){
  144.         $result '';
  145.         if((sizeof($this->products) > 0)){
  146.             switch($type){
  147.                 case 'table':
  148.                     $result .= '<table class="table table_no_padding b_none m_b_none"><thead><tr><th>Prodotto</th><th>Matr. Prod.</th><th>Matr. Forn.</th></thead>';
  149.                     foreach($this->products as $product){
  150.                         $result .= '<tr><td>'.$product->getModel()->getName().'</td><td>'.$product->getCodeProducer().'</td><td>'.$product->getCodeSupplier().'</td></tr>';
  151.                     }
  152.                     $result.= '</table>';
  153.                     break;
  154.                 case 'string':
  155.                     $first true;
  156.                     foreach($this->products as $product){
  157.                         if($first$first false; else $result.= ' - ';
  158.                         $result .= $product->getModel()->getName();
  159.                     }
  160.                 default: break;
  161.             }            
  162.         }
  163.         return $result;
  164.     }
  165.     
  166.     public function displaySuppliers(){
  167.         $result '---';
  168.         if(sizeof($this->suppliers) > 0){
  169.             $result '<table class="table table_no_padding m_b_none b_none">';
  170.             foreach($this->suppliers as $supplier){
  171.                 $result .= '<tr><td>'.$supplier->getName().'</td></tr>';
  172.             }
  173.             $result.= '</table>';
  174.         }
  175.         return $result;
  176.     }
  177.     
  178.     public function displayStringSuppliers(){
  179.         $result '';
  180.         if(sizeof($this->suppliers) > 0){
  181.             $first true;
  182.             foreach($this->suppliers as $supplier){
  183.                 if($first$first false; else $result.= ', ';
  184.                 $result .= $supplier->getName();
  185.             }
  186.         }
  187.         return $result;
  188.     }
  189.     public function displayTransfersDdts(){
  190.         $result '---';
  191.         if(sizeof($this->transfers) > 0){
  192.             $result '';
  193.             $first true;
  194.             foreach($this->transfers as $jtppt){
  195.                 if($first$first false; else $result.= ', ';
  196.                 $result .= $jtppt->getTransfer()->getDdt();
  197.             }
  198.         }
  199.         return $result;
  200.     }
  201.     
  202.     public function displayLastRefs(){
  203.         $string "";
  204.         if($this->getLastTicket() != null){
  205.             $string.="<br>";
  206.             $string.="Ticket: <u>".$this->getLastTicket()->getNumber()."</u><br>";
  207.             $string.="Operazione: ".$this->getLastOperationGroupType()."<br>";
  208.             $string.="Termid: ".$this->getLastTicket()->getTermid()->getCode();
  209.             $string.="";
  210.         }
  211.         return $string;
  212.     }
  213.     
  214.     public function displayTransfersDdt(){
  215.         $first true;
  216.         $string '';
  217.         if(sizeof($this->getTransfers()) > 3){
  218.             $tooltip '';
  219.             foreach($this->getTransfers() as $jt){
  220.                 if($first$first false; else $tooltip.= ' - ';
  221.                 $tooltip.= $jt->getTransfer()->getDdt();
  222.             }
  223.             $string '<a href="javascript:void(0)" data-bs-toggle="tooltip" data-bs-title="'.$tooltip.'">'.$this->getTransfers()[0]->getTransfer()->getDdt().' - '.$this->getTransfers()[1]->getTransfer()->getDdt().' - '.$this->getTransfers()[2]->getTransfer()->getDdt().' ...</a>';
  224.         }
  225.         else{
  226.             foreach($this->getTransfers() as $jt){
  227.                 if($first$first false; else $string.= ' - ';
  228.                 $string.= $jt->getTransfer()->getDdt();
  229.             }
  230.         }
  231.         return $string;
  232.     }
  233.     
  234.     public function getLastLogWithIntervention(){
  235.         $lastLog null;
  236.         $dateLastLog date_create_from_format('d-m-Y H:i''01-01-2000 00:00');
  237.         foreach($this->logs as $log){
  238.             if($log->getIntervention() != null && $log->getDatetime()->format('YmdHis') > $dateLastLog->format('YmdHis')){
  239.                 $dateLastLog $log->getDatetime();
  240.                 $lastLog $log;
  241.             }
  242.         }
  243.         return $lastLog;
  244.     }
  245.     public function getLastTransfer(){
  246.         $transfer null;
  247.         $dateLastTransfer date_create_from_format('d-m-Y H:i''01-01-2000 00:00');
  248.         foreach($this->transfers as $jt){
  249.             if($jt->getTransfer()->getDatetimeCreation()->format('YmdHi') > $dateLastTransfer->format('YmdHi')){
  250.                 $dateLastTransfer $jt->getTransfer()->getDatetimeCreation();
  251.                 $transfer $jt->getTransfer();
  252.             }
  253.         }
  254.         return $transfer;
  255.     }
  256.     public function getLastTransferFromClient(){
  257.         $transfer null;
  258.         $dateLastTransfer date_create_from_format('d-m-Y H:i''01-01-2000 00:00');
  259.         foreach($this->transfers as $jt){
  260.             if($jt->getTransfer()->getWarehouseFrom()->getClient() != null && $jt->getTransfer()->getDatetimeCreation()->format('YmdHi') > $dateLastTransfer->format('YmdHi')){
  261.                 $dateLastTransfer $jt->getTransfer()->getDatetimeCreation();
  262.                 $transfer $jt->getTransfer();
  263.             }
  264.         }
  265.         return $transfer;
  266.     }
  267.     public function getLastOperationGroupType() {
  268.         return $this->getLastTicket()->getOperation()->getGroup()->getValue();
  269.     }
  270.     public function getLastTicket() {
  271.         $ticket null;
  272.         $log $this->getLastLogWithIntervention();
  273.         if($log != null)
  274.             $ticket $log->getIntervention()->getTicket();
  275.         return $ticket;
  276.     }
  277.     public function hasSupplier($supplier){
  278.         foreach($this->getSuppliers() as $sup){
  279.             if($sup->getId() == $supplier->getId())
  280.                 return true;
  281.         }
  282.         return false;
  283.     }
  284.     public function movedByDS(){
  285.         switch($this->getModel()->getId()){
  286.             case 141:
  287.             case 142:
  288.             case 143:
  289.             case 144:
  290.             case 145:
  291.             case 146:
  292.             case 147:
  293.                 return true;
  294.             default:
  295.                 return false;
  296.         }
  297.         return false;
  298.     }
  299.     public function getLastUserLog(){
  300.         $logs $this->getLogs()->toArray();
  301.         if(empty($logs)) return null;
  302.         usort($logs, function ($a$b) { return $b->getDatetime() <=> $a->getDatetime(); });
  303.         return $logs[0]->getOperator() ?? null;
  304.     }
  305.     /**
  306.      * @ORM\Column(name="id", type="bigint")
  307.      * @ORM\Id
  308.      * @ORM\GeneratedValue(strategy="AUTO")
  309.      */
  310.     protected $id;
  311.     
  312.     /**
  313.      * @ORM\Column(name="code_producer", type="string", length=191, nullable=true)
  314.      */
  315.     protected $codeProducer;
  316.     /**
  317.      * @ORM\Column(name="code_supplier", type="string", length=191, nullable=true)
  318.      */
  319.     protected $codeSupplier;
  320.     /**
  321.      * @ORM\Column(name="date_creation", type="datetime", nullable=true)
  322.      */
  323.     protected $dateCreation;
  324.     /**
  325.      * @ORM\Column(name="date_last_transfer", type="datetime", nullable=true)
  326.      */
  327.     protected $dateLastTransfer;
  328.             
  329.     /**
  330.      * @ORM\Column(name="is_active", type="boolean")
  331.      */
  332.     protected $active true;
  333.     /**
  334.      * @ORM\Column(name="to_manage", type="boolean")
  335.      */
  336.     protected $toManage false;
  337.     /**
  338.      * @ORM\Column(name="to_manage_priority", type="integer")
  339.      */
  340.     protected $toManagePriority 2;
  341.         
  342.     // ManyToOne
  343.         /**
  344.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\ProductModel", inversedBy="products")
  345.          * @ORM\JoinColumn(name="model_id", referencedColumnName="id")
  346.          */
  347.         private $model;
  348.         /**
  349.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\Warehouse", inversedBy="products")
  350.          * @ORM\JoinColumn(name="actual_warehouse_id", referencedColumnName="id")
  351.          */
  352.         private $actualWarehouse;
  353.         /**
  354.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\ProductStatus", inversedBy="products")
  355.          * @ORM\JoinColumn(name="status_id", referencedColumnName="id")
  356.          */
  357.         private $status;
  358.         
  359.         /**
  360.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\ProductCondition", inversedBy="products")
  361.          * @ORM\JoinColumn(name="condition_id", referencedColumnName="id")
  362.          */
  363.         private $condition;
  364.         /**
  365.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\Termid", inversedBy="products")
  366.          * @ORM\JoinColumn(name="termid_id", referencedColumnName="id")
  367.          */
  368.         private $termid;
  369.         
  370.         /**
  371.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\product", inversedBy="products")
  372.          * @ORM\JoinColumn(name="parent_product_id", referencedColumnName="id")
  373.          */
  374.         private $parentProduct;
  375.     //
  376.     // OneToMany
  377.         /**
  378.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\JoinTableProductProductTransfer", mappedBy="product")
  379.          */
  380.         private $transfers;
  381.         /**
  382.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\ProductTransferLog", mappedBy="product")
  383.          */
  384.         private $transferLogs;
  385.         
  386.         /**
  387.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\ProductLog", mappedBy="product")
  388.          */
  389.         private $logs;
  390.         /**
  391.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\ProductRegenerated", mappedBy="product")
  392.          */
  393.         private $regeneratedProducts;
  394.         /**
  395.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\InterventionActivity", mappedBy="productWithdraw")
  396.          */
  397.         private $withdrawActivities;
  398.         
  399.         /**
  400.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\InterventionActivity", mappedBy="productActual")
  401.          */
  402.         private $actualActivities;
  403.         
  404.         /**
  405.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\InterventionActivity", mappedBy="productInstallation")
  406.          */
  407.         private $installationActivities;
  408.         /**
  409.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\Product", mappedBy="parentProduct")
  410.          */
  411.         private $products;
  412.     //
  413.     // ManyToMany
  414.         /**
  415.          * @ORM\ManyToMany(targetEntity="App\Entity\Slave\Supplier", inversedBy="products")
  416.          * @ORM\JoinTable(name="eposm_s_join_table_product_supplier")
  417.          */
  418.         private $suppliers;
  419.         public function __construct()
  420.         {
  421.             $this->transfers = new ArrayCollection();
  422.             $this->transferLogs = new ArrayCollection();
  423.             $this->logs = new ArrayCollection();
  424.             $this->regenerates = new ArrayCollection();
  425.             $this->withdrawActivities = new ArrayCollection();
  426.             $this->actualActivities = new ArrayCollection();
  427.             $this->installationActivities = new ArrayCollection();
  428.             $this->products = new ArrayCollection();
  429.             $this->suppliers = new ArrayCollection();
  430.             $this->regeneratedProducts = new ArrayCollection();
  431.         }
  432.         public function getId(): ?string
  433.         {
  434.             return $this->id;
  435.         }
  436.         public function getCodeProducer(): ?string
  437.         {
  438.             return $this->codeProducer;
  439.         }
  440.         public function setCodeProducer(?string $codeProducer): static
  441.         {
  442.             $this->codeProducer $codeProducer;
  443.             return $this;
  444.         }
  445.         public function getCodeSupplier(): ?string
  446.         {
  447.             return $this->codeSupplier;
  448.         }
  449.         public function setCodeSupplier(?string $codeSupplier): static
  450.         {
  451.             $this->codeSupplier $codeSupplier;
  452.             return $this;
  453.         }
  454.         public function getDateLastTransfer(): ?\DateTimeInterface
  455.         {
  456.             return $this->dateLastTransfer;
  457.         }
  458.         public function setDateLastTransfer(?\DateTimeInterface $dateLastTransfer): static
  459.         {
  460.             $this->dateLastTransfer $dateLastTransfer;
  461.             return $this;
  462.         }
  463.         public function isActive(): ?bool
  464.         {
  465.             return $this->active;
  466.         }
  467.         public function setActive(bool $active): static
  468.         {
  469.             $this->active $active;
  470.             return $this;
  471.         }
  472.         public function isToManage(): ?bool
  473.         {
  474.             return $this->toManage;
  475.         }
  476.         public function setToManage(bool $toManage): static
  477.         {
  478.             $this->toManage $toManage;
  479.             return $this;
  480.         }
  481.         public function getToManagePriority(): ?int
  482.         {
  483.             return $this->toManagePriority;
  484.         }
  485.         public function setToManagePriority(int $toManagePriority): static
  486.         {
  487.             $this->toManagePriority $toManagePriority;
  488.             return $this;
  489.         }
  490.         public function getModel(): ?ProductModel
  491.         {
  492.             return $this->model;
  493.         }
  494.         public function setModel(?ProductModel $model): static
  495.         {
  496.             $this->model $model;
  497.             return $this;
  498.         }
  499.         public function getActualWarehouse(): ?Warehouse
  500.         {
  501.             return $this->actualWarehouse;
  502.         }
  503.         public function setActualWarehouse(?Warehouse $actualWarehouse): static
  504.         {
  505.             $this->actualWarehouse $actualWarehouse;
  506.             return $this;
  507.         }
  508.         public function getStatus(): ?ProductStatus
  509.         {
  510.             return $this->status;
  511.         }
  512.         public function setStatus(?ProductStatus $status): static
  513.         {
  514.             $this->status $status;
  515.             return $this;
  516.         }
  517.         public function getCondition(): ?ProductCondition
  518.         {
  519.             return $this->condition;
  520.         }
  521.         public function setCondition(?ProductCondition $condition): static
  522.         {
  523.             $this->condition $condition;
  524.             return $this;
  525.         }
  526.         public function getTermid(): ?Termid
  527.         {
  528.             return $this->termid;
  529.         }
  530.         public function setTermid(?Termid $termid): static
  531.         {
  532.             $this->termid $termid;
  533.             return $this;
  534.         }
  535.         public function getParentProduct(): ?product
  536.         {
  537.             return $this->parentProduct;
  538.         }
  539.         public function setParentProduct(?product $parentProduct): static
  540.         {
  541.             $this->parentProduct $parentProduct;
  542.             return $this;
  543.         }
  544.         /**
  545.          * @return Collection<int, JoinTableProductProductTransfer>
  546.          */
  547.         public function getTransfers(): Collection
  548.         {
  549.             return $this->transfers;
  550.         }
  551.         public function addTransfer(JoinTableProductProductTransfer $transfer): static
  552.         {
  553.             if (!$this->transfers->contains($transfer)) {
  554.                 $this->transfers->add($transfer);
  555.                 $transfer->setProduct($this);
  556.             }
  557.             return $this;
  558.         }
  559.         public function removeTransfer(JoinTableProductProductTransfer $transfer): static
  560.         {
  561.             if ($this->transfers->removeElement($transfer)) {
  562.                 // set the owning side to null (unless already changed)
  563.                 if ($transfer->getProduct() === $this) {
  564.                     $transfer->setProduct(null);
  565.                 }
  566.             }
  567.             return $this;
  568.         }
  569.         /**
  570.          * @return Collection<int, ProductTransferLog>
  571.          */
  572.         public function getTransferLogs(): Collection
  573.         {
  574.             return $this->transferLogs;
  575.         }
  576.         public function addTransferLog(ProductTransferLog $transferLog): static
  577.         {
  578.             if (!$this->transferLogs->contains($transferLog)) {
  579.                 $this->transferLogs->add($transferLog);
  580.                 $transferLog->setProduct($this);
  581.             }
  582.             return $this;
  583.         }
  584.         public function removeTransferLog(ProductTransferLog $transferLog): static
  585.         {
  586.             if ($this->transferLogs->removeElement($transferLog)) {
  587.                 // set the owning side to null (unless already changed)
  588.                 if ($transferLog->getProduct() === $this) {
  589.                     $transferLog->setProduct(null);
  590.                 }
  591.             }
  592.             return $this;
  593.         }
  594.         /**
  595.          * @return Collection<int, ProductLog>
  596.          */
  597.         public function getLogs(): Collection
  598.         {
  599.             return $this->logs;
  600.         }
  601.         public function addLog(ProductLog $log): static
  602.         {
  603.             if (!$this->logs->contains($log)) {
  604.                 $this->logs->add($log);
  605.                 $log->setProduct($this);
  606.             }
  607.             return $this;
  608.         }
  609.         public function removeLog(ProductLog $log): static
  610.         {
  611.             if ($this->logs->removeElement($log)) {
  612.                 // set the owning side to null (unless already changed)
  613.                 if ($log->getProduct() === $this) {
  614.                     $log->setProduct(null);
  615.                 }
  616.             }
  617.             return $this;
  618.         }
  619.         /**
  620.          * @return Collection<int, InterventionActivity>
  621.          */
  622.         public function getWithdrawActivities(): Collection
  623.         {
  624.             return $this->withdrawActivities;
  625.         }
  626.         public function addWithdrawActivity(InterventionActivity $withdrawActivity): static
  627.         {
  628.             if (!$this->withdrawActivities->contains($withdrawActivity)) {
  629.                 $this->withdrawActivities->add($withdrawActivity);
  630.                 $withdrawActivity->setProductWithdraw($this);
  631.             }
  632.             return $this;
  633.         }
  634.         public function removeWithdrawActivity(InterventionActivity $withdrawActivity): static
  635.         {
  636.             if ($this->withdrawActivities->removeElement($withdrawActivity)) {
  637.                 // set the owning side to null (unless already changed)
  638.                 if ($withdrawActivity->getProductWithdraw() === $this) {
  639.                     $withdrawActivity->setProductWithdraw(null);
  640.                 }
  641.             }
  642.             return $this;
  643.         }
  644.         /**
  645.          * @return Collection<int, InterventionActivity>
  646.          */
  647.         public function getActualActivities(): Collection
  648.         {
  649.             return $this->actualActivities;
  650.         }
  651.         public function addActualActivity(InterventionActivity $actualActivity): static
  652.         {
  653.             if (!$this->actualActivities->contains($actualActivity)) {
  654.                 $this->actualActivities->add($actualActivity);
  655.                 $actualActivity->setProductActual($this);
  656.             }
  657.             return $this;
  658.         }
  659.         public function removeActualActivity(InterventionActivity $actualActivity): static
  660.         {
  661.             if ($this->actualActivities->removeElement($actualActivity)) {
  662.                 // set the owning side to null (unless already changed)
  663.                 if ($actualActivity->getProductActual() === $this) {
  664.                     $actualActivity->setProductActual(null);
  665.                 }
  666.             }
  667.             return $this;
  668.         }
  669.         /**
  670.          * @return Collection<int, InterventionActivity>
  671.          */
  672.         public function getInstallationActivities(): Collection
  673.         {
  674.             return $this->installationActivities;
  675.         }
  676.         public function addInstallationActivity(InterventionActivity $installationActivity): static
  677.         {
  678.             if (!$this->installationActivities->contains($installationActivity)) {
  679.                 $this->installationActivities->add($installationActivity);
  680.                 $installationActivity->setProductInstallation($this);
  681.             }
  682.             return $this;
  683.         }
  684.         public function removeInstallationActivity(InterventionActivity $installationActivity): static
  685.         {
  686.             if ($this->installationActivities->removeElement($installationActivity)) {
  687.                 // set the owning side to null (unless already changed)
  688.                 if ($installationActivity->getProductInstallation() === $this) {
  689.                     $installationActivity->setProductInstallation(null);
  690.                 }
  691.             }
  692.             return $this;
  693.         }
  694.         /**
  695.          * @return Collection<int, Product>
  696.          */
  697.         public function getProducts(): Collection
  698.         {
  699.             return $this->products;
  700.         }
  701.         public function addProduct(Product $product): static
  702.         {
  703.             if (!$this->products->contains($product)) {
  704.                 $this->products->add($product);
  705.                 $product->setParentProduct($this);
  706.             }
  707.             return $this;
  708.         }
  709.         public function removeProduct(Product $product): static
  710.         {
  711.             if ($this->products->removeElement($product)) {
  712.                 // set the owning side to null (unless already changed)
  713.                 if ($product->getParentProduct() === $this) {
  714.                     $product->setParentProduct(null);
  715.                 }
  716.             }
  717.             return $this;
  718.         }
  719.         /**
  720.          * @return Collection<int, Supplier>
  721.          */
  722.         public function getSuppliers(): Collection
  723.         {
  724.             return $this->suppliers;
  725.         }
  726.         public function addSupplier(Supplier $supplier): static
  727.         {
  728.             if (!$this->suppliers->contains($supplier)) {
  729.                 $this->suppliers->add($supplier);
  730.             }
  731.             return $this;
  732.         }
  733.         public function removeSupplier(Supplier $supplier): static
  734.         {
  735.             $this->suppliers->removeElement($supplier);
  736.             return $this;
  737.         }
  738.     public function getDateCreation(): ?\DateTimeInterface
  739.     {
  740.         return $this->dateCreation;
  741.     }
  742.     public function setDateCreation(?\DateTimeInterface $dateCreation): static
  743.     {
  744.         $this->dateCreation $dateCreation;
  745.         return $this;
  746.     }
  747.     /**
  748.      * @return Collection<int, ProductRegenerated>
  749.      */
  750.     public function getRegeneratedProducts(): Collection
  751.     {
  752.         return $this->regeneratedProducts;
  753.     }
  754.     public function addRegeneratedProduct(ProductRegenerated $regeneratedProduct): static
  755.     {
  756.         if (!$this->regeneratedProducts->contains($regeneratedProduct)) {
  757.             $this->regeneratedProducts->add($regeneratedProduct);
  758.             $regeneratedProduct->setProduct($this);
  759.         }
  760.         return $this;
  761.     }
  762.     public function removeRegeneratedProduct(ProductRegenerated $regeneratedProduct): static
  763.     {
  764.         if ($this->regeneratedProducts->removeElement($regeneratedProduct)) {
  765.             // set the owning side to null (unless already changed)
  766.             if ($regeneratedProduct->getProduct() === $this) {
  767.                 $regeneratedProduct->setProduct(null);
  768.             }
  769.         }
  770.         return $this;
  771.     }
  772. }