src/Entity/Slave/ProductTransfer.php line 270

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