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