src/Entity/Slave/ProductTransfer.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_transfer")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Slave\ProductTransferRepository")
  10.  */
  11. class ProductTransfer
  12. {        
  13.     public function isEditable($warehouseId){
  14.         if(
  15.             ($this->getWarehouseFrom()->getId() == $warehouseId || ($this->getType() == 'destination' and $this->getWarehouseTo()->getId()))
  16.             && ($this->getPhase() == 'inserted' || $this->getPhase() == 'product_insert' || $this->getPhase() == 'inserted_editable')
  17.         )
  18.             return true;
  19.         return false;
  20.     }
  21.     public function hasProductsTransfered(){
  22.         foreach($this->products as $jtppt){
  23.             if($jtppt->isTransferOk())
  24.                 return true;
  25.         }
  26.         return false;
  27.     }
  28.     public function displayPhase($type){
  29.         switch($this->getPhase()){
  30.             case 'inserted'$color 'color_r'$title 'Inserito'; break;
  31.             case 'product_insert'$color 'color_am'$title 'Prodotti da inserire'; break;
  32.             case 'inserted_editable'$color 'color_am'$title 'In attesa di invio'; break;
  33.             case 'waiting_receiver'$color 'color_gr'$title 'In attesa di consegna'; break;
  34.             case 'to_download'$color 'color_am'$title 'Da scaricare'; break;
  35.             case 'completed'$color 'color_gr'$title 'Completato'; break;
  36.             default: break;
  37.         }
  38.         switch($type){
  39.             case 'icon'$html '<i class="icon-circle cursor_p '.$color.'" data-bs-toggle="tooltip" title="'.$title.'"></i>'; break;
  40.             case 'string'$html '<i class="icon-circle cursor_p '.$color.'"></i> '.$title; break;
  41.             default: break;
  42.         }
  43.         return $html;
  44.     }
  45.     public function displayPhaseDdt($type){
  46.         switch($this->getPhaseDdt()){
  47.             case 'create'$color 'color_r'$title 'Da fare'; break;
  48.             case 'prepared'$color 'color_am'$title 'Preparato'; break;
  49.             case 'signed_missing'$color 'color_sc'$title 'DDT firmato mancante'; break;
  50.             case 'completed'$color 'color_gr'$title 'Caricato'; break;
  51.             default: break;
  52.         }
  53.         switch($type){
  54.             case 'icon': return '<i class="icon-circle cursor_p '.$color.'" data-bs-toggle="tooltip" title="'.$title.'"></i>'; break;
  55.             case 'string': return '<i class="icon-circle cursor_p '.$color.'"></i> '.$title; break;
  56.             default: break;
  57.         }
  58.     }
  59.     public function canMakeActionsByType($action$user$transferWarehouseId$transferInternalDdtActive){
  60.         $canContinue false;
  61.         foreach($user->getWarehouses() as $jtuw){
  62.             if($jtuw->getWarehouse()->getId() == $transferWarehouseId)
  63.                 $canContinue true;
  64.         }
  65.         foreach($user->getAccountType()->getPermissions() as $jtatp){
  66.             if($jtatp->getPermission()->getSlug() == 'warehouse')
  67.                 $perm $jtatp;
  68.         }
  69.         if($canContinue || $perm->getRw() == 'RW'){
  70.             switch($this->getType()){
  71.                 case 'destination'// Verso destinazione esterna -> Lo vede solo sede centrale
  72.                     switch($action){
  73.                         case 'resume': if($this->getPhase() == 'inserted' || $this->getPhase() == 'product_insert' || $this->getPhase() == 'inserted_editable') return true; break;
  74.                         case 'prepare_ddt': if(($this->getPhase() == 'inserted' || $this->getPhase() == 'inserted_editable') && sizeof($this->getProducts()) > && $this->getPhaseDdt() == 'create') return true; break;
  75.                         case 'complete': if($this->getPhase() == 'waiting_receiver' && $this->getPhaseDdt() == 'prepared' && sizeof($this->getProducts()) > 0) return true; break;
  76.                         default: break;
  77.                     }
  78.                     break;
  79.                 case 'main'// Verso sede centrale
  80.                     switch($action){
  81.                         case 'resume': if(($this->getPhase() == 'inserted' || $this->getPhase() == 'inserted_editable')) return true; break;
  82.                         case 'prepare_ddt'
  83.                             if(($this->getPhase() == 'inserted' || $this->getPhase() == 'inserted_editable') && sizeof($this->getProducts()) > 0){
  84.                                 if($transferInternalDdtActive){
  85.                                     if($this->getPhaseDdt() == 'create')
  86.                                         return true;
  87.                                 }
  88.                                 else
  89.                                     return true;
  90.                             }
  91.                             break;
  92.                         case 'complete'
  93.                             if(sizeof($this->getProducts()) > && $this->getPhase() == 'waiting_receiver'){
  94.                                 if($transferInternalDdtActive){
  95.                                     if($this->getPhaseDdt() == 'prepared')
  96.                                         return true;
  97.                                 }
  98.                                 else
  99.                                     return true;
  100.                             }
  101.                             break;
  102.                         case 'download': if(sizeof($this->getProducts()) > && $this->getPhase() == 'to_download' && $user->getAccountTypology() != 'technician') return true; break;
  103.                         default: break;
  104.                     }
  105.                     break;
  106.                 case 'technician'// Verso tecnico
  107.                     switch($action){
  108.                         case 'resume': if($this->getPhase() == 'inserted' || $this->getPhase() == 'inserted_editable') return true; break;
  109.                         case 'prepare_ddt'
  110.                             if(($this->getPhase() == 'inserted' || $this->getPhase() == 'inserted_editable') && sizeof($this->getProducts()) > 0){
  111.                                 if($transferInternalDdtActive){
  112.                                     if($this->getPhaseDdt() == 'create')
  113.                                         return true;
  114.                                 }
  115.                                 else
  116.                                     return true;
  117.                             }
  118.                             break;
  119.                         case 'complete'
  120.                             if(sizeof($this->getProducts()) > && $this->getPhase() == 'waiting_receiver'){
  121.                                 if($transferInternalDdtActive){
  122.                                     if($this->getPhaseDdt() == 'prepared')
  123.                                         return true;
  124.                                 }
  125.                                 else
  126.                                     return true;
  127.                             }
  128.                             break;
  129.                         case 'download': if(sizeof($this->getProducts()) > && $this->getPhase() == 'to_download') return true; break;
  130.                         default: break;
  131.                     }
  132.                     break;
  133.                 default: break;
  134.             }
  135.         }
  136.         return false;
  137.     }
  138.     /**
  139.      * @ORM\Column(name="id", type="bigint")
  140.      * @ORM\Id
  141.      * @ORM\GeneratedValue(strategy="AUTO")
  142.      */
  143.     protected $id;
  144.     /**
  145.      * @ORM\Column(name="date", type="datetime", nullable=true)
  146.      */
  147.     protected $date;
  148.     /**
  149.      * @ORM\Column(name="phase", type="string", nullable=true)
  150.      */
  151.     protected $phase;
  152.     
  153.     /**
  154.      * @ORM\Column(name="phase_ddt", type="string", nullable=true)
  155.      */
  156.     protected $phaseDdt;
  157.     /**
  158.      * @ORM\Column(name="datetime_creation", type="datetime", nullable=true)
  159.      */
  160.     protected $datetimeCreation;
  161.     
  162.     /**
  163.      * @ORM\Column(name="datetime_send", type="datetime", nullable=true)
  164.      */
  165.     protected $datetimeSend;
  166.     
  167.     /**
  168.      * @ORM\Column(name="datetime_completion", type="datetime", nullable=true)
  169.      */
  170.     protected $datetimeCompletion;
  171.     
  172.     /**
  173.      * @ORM\Column(name="stock_order", type="string", nullable=true)
  174.      */
  175.     protected $stockOrder;
  176.     
  177.     /**
  178.      * @ORM\Column(name="ddt", type="string", nullable=true)
  179.      */
  180.     protected $ddt;
  181.     
  182.     /**
  183.      * @ORM\Column(name="ddt_path", type="string", nullable=true)
  184.      */
  185.     protected $ddtPath;
  186.     
  187.     /**
  188.      * @ORM\Column(name="signed_ddt_path", type="string", nullable=true)
  189.      */
  190.     protected $signedDdtPath;
  191.     /**
  192.      * @ORM\Column(name="type", type="string", length=191)
  193.      */
  194.     protected $type;
  195.     /**
  196.      * @ORM\Column(name="is_ddt_mandatory", type="boolean")
  197.      */
  198.     protected $ddtMandatory false;
  199.     /**
  200.      * @ORM\Column(name="is_divestment", type="boolean")
  201.      */
  202.     protected $divestment false;
  203.     // ManyToOne
  204.         /**
  205.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\Warehouse", inversedBy="transfersFrom")
  206.          * @ORM\JoinColumn(name="warehouse_from_id", referencedColumnName="id")
  207.          */
  208.         private $warehouseFrom;
  209.         /**
  210.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\Warehouse", inversedBy="transfersTo")
  211.          * @ORM\JoinColumn(name="warehouse_to_id", referencedColumnName="id")
  212.          */
  213.         private $warehouseTo;
  214.         /**
  215.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\User", inversedBy="transfersUserFrom")
  216.          * @ORM\JoinColumn(name="user_from_id", referencedColumnName="id")
  217.          */
  218.         private $userFrom;
  219.         /**
  220.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\User", inversedBy="transfersUserTo")
  221.          * @ORM\JoinColumn(name="user_to_id", referencedColumnName="id")
  222.          */
  223.         private $userTo;
  224.         
  225.         /**
  226.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\Supplier", inversedBy="transfers")
  227.          * @ORM\JoinColumn(name="supplier_id", referencedColumnName="id")
  228.          */
  229.         private $supplier;
  230.         
  231.         /**
  232.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\DdtHeader", inversedBy="transfers")
  233.          * @ORM\JoinColumn(name="ddt_header_id", referencedColumnName="id")
  234.          */
  235.         private $ddtHeader;
  236.     //
  237.     // OneToMany
  238.         /**
  239.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\JoinTableProductProductTransfer", mappedBy="transfer")
  240.          */
  241.         private $products;
  242.         /**
  243.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\ProductTransferLog", mappedBy="transfer")
  244.          */
  245.         private $logs;
  246.         public function __construct()
  247.         {
  248.             $this->products = new ArrayCollection();
  249.             $this->imports = new ArrayCollection();
  250.             $this->logs = new ArrayCollection();
  251.         }
  252.     //
  253.     public function getId(): ?string
  254.     {
  255.         return $this->id;
  256.     }
  257.     public function getDate(): ?\DateTimeInterface
  258.     {
  259.         return $this->date;
  260.     }
  261.     public function setDate(?\DateTimeInterface $date): static
  262.     {
  263.         $this->date $date;
  264.         return $this;
  265.     }
  266.     public function getPhase(): ?string
  267.     {
  268.         return $this->phase;
  269.     }
  270.     public function setPhase(?string $phase): static
  271.     {
  272.         $this->phase $phase;
  273.         return $this;
  274.     }
  275.     public function getPhaseDdt(): ?string
  276.     {
  277.         return $this->phaseDdt;
  278.     }
  279.     public function setPhaseDdt(?string $phaseDdt): static
  280.     {
  281.         $this->phaseDdt $phaseDdt;
  282.         return $this;
  283.     }
  284.     public function getDatetimeCreation(): ?\DateTimeInterface
  285.     {
  286.         return $this->datetimeCreation;
  287.     }
  288.     public function setDatetimeCreation(?\DateTimeInterface $datetimeCreation): static
  289.     {
  290.         $this->datetimeCreation $datetimeCreation;
  291.         return $this;
  292.     }
  293.     public function getDatetimeSend(): ?\DateTimeInterface
  294.     {
  295.         return $this->datetimeSend;
  296.     }
  297.     public function setDatetimeSend(?\DateTimeInterface $datetimeSend): static
  298.     {
  299.         $this->datetimeSend $datetimeSend;
  300.         return $this;
  301.     }
  302.     public function getDatetimeCompletion(): ?\DateTimeInterface
  303.     {
  304.         return $this->datetimeCompletion;
  305.     }
  306.     public function setDatetimeCompletion(?\DateTimeInterface $datetimeCompletion): static
  307.     {
  308.         $this->datetimeCompletion $datetimeCompletion;
  309.         return $this;
  310.     }
  311.     public function getStockOrder(): ?string
  312.     {
  313.         return $this->stockOrder;
  314.     }
  315.     public function setStockOrder(?string $stockOrder): static
  316.     {
  317.         $this->stockOrder $stockOrder;
  318.         return $this;
  319.     }
  320.     public function getDdt(): ?string
  321.     {
  322.         return $this->ddt;
  323.     }
  324.     public function setDdt(?string $ddt): static
  325.     {
  326.         $this->ddt $ddt;
  327.         return $this;
  328.     }
  329.     public function getDdtPath(): ?string
  330.     {
  331.         return $this->ddtPath;
  332.     }
  333.     public function setDdtPath(?string $ddtPath): static
  334.     {
  335.         $this->ddtPath $ddtPath;
  336.         return $this;
  337.     }
  338.     public function getSignedDdtPath(): ?string
  339.     {
  340.         return $this->signedDdtPath;
  341.     }
  342.     public function setSignedDdtPath(?string $signedDdtPath): static
  343.     {
  344.         $this->signedDdtPath $signedDdtPath;
  345.         return $this;
  346.     }
  347.     public function getType(): ?string
  348.     {
  349.         return $this->type;
  350.     }
  351.     public function setType(string $type): static
  352.     {
  353.         $this->type $type;
  354.         return $this;
  355.     }
  356.     public function isDdtMandatory(): ?bool
  357.     {
  358.         return $this->ddtMandatory;
  359.     }
  360.     public function setDdtMandatory(bool $ddtMandatory): static
  361.     {
  362.         $this->ddtMandatory $ddtMandatory;
  363.         return $this;
  364.     }
  365.     public function isDivestment(): ?bool
  366.     {
  367.         return $this->divestment;
  368.     }
  369.     public function setDivestment(bool $divestment): static
  370.     {
  371.         $this->divestment $divestment;
  372.         return $this;
  373.     }
  374.     public function getWarehouseFrom(): ?Warehouse
  375.     {
  376.         return $this->warehouseFrom;
  377.     }
  378.     public function setWarehouseFrom(?Warehouse $warehouseFrom): static
  379.     {
  380.         $this->warehouseFrom $warehouseFrom;
  381.         return $this;
  382.     }
  383.     public function getWarehouseTo(): ?Warehouse
  384.     {
  385.         return $this->warehouseTo;
  386.     }
  387.     public function setWarehouseTo(?Warehouse $warehouseTo): static
  388.     {
  389.         $this->warehouseTo $warehouseTo;
  390.         return $this;
  391.     }
  392.     public function getUserFrom(): ?User
  393.     {
  394.         return $this->userFrom;
  395.     }
  396.     public function setUserFrom(?User $userFrom): static
  397.     {
  398.         $this->userFrom $userFrom;
  399.         return $this;
  400.     }
  401.     public function getUserTo(): ?User
  402.     {
  403.         return $this->userTo;
  404.     }
  405.     public function setUserTo(?User $userTo): static
  406.     {
  407.         $this->userTo $userTo;
  408.         return $this;
  409.     }
  410.     public function getSupplier(): ?Supplier
  411.     {
  412.         return $this->supplier;
  413.     }
  414.     public function setSupplier(?Supplier $supplier): static
  415.     {
  416.         $this->supplier $supplier;
  417.         return $this;
  418.     }
  419.     public function getDdtHeader(): ?DdtHeader
  420.     {
  421.         return $this->ddtHeader;
  422.     }
  423.     public function setDdtHeader(?DdtHeader $ddtHeader): static
  424.     {
  425.         $this->ddtHeader $ddtHeader;
  426.         return $this;
  427.     }
  428.     /**
  429.      * @return Collection<int, JoinTableProductProductTransfer>
  430.      */
  431.     public function getProducts(): Collection
  432.     {
  433.         return $this->products;
  434.     }
  435.     public function addProduct(JoinTableProductProductTransfer $product): static
  436.     {
  437.         if (!$this->products->contains($product)) {
  438.             $this->products->add($product);
  439.             $product->setTransfer($this);
  440.         }
  441.         return $this;
  442.     }
  443.     public function removeProduct(JoinTableProductProductTransfer $product): static
  444.     {
  445.         if ($this->products->removeElement($product)) {
  446.             // set the owning side to null (unless already changed)
  447.             if ($product->getTransfer() === $this) {
  448.                 $product->setTransfer(null);
  449.             }
  450.         }
  451.         return $this;
  452.     }
  453.     /**
  454.      * @return Collection<int, ProductTransferLog>
  455.      */
  456.     public function getLogs(): Collection
  457.     {
  458.         return $this->logs;
  459.     }
  460.     public function addLog(ProductTransferLog $log): static
  461.     {
  462.         if (!$this->logs->contains($log)) {
  463.             $this->logs->add($log);
  464.             $log->setTransfer($this);
  465.         }
  466.         return $this;
  467.     }
  468.     public function removeLog(ProductTransferLog $log): static
  469.     {
  470.         if ($this->logs->removeElement($log)) {
  471.             // set the owning side to null (unless already changed)
  472.             if ($log->getTransfer() === $this) {
  473.                 $log->setTransfer(null);
  474.             }
  475.         }
  476.         return $this;
  477.     }
  478. }