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