src/Entity/Order.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\OrderRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. /**
  10.  * @ORM\Entity(repositoryClass=OrderRepository::class)
  11.  * @ORM\Table(name="`order`")
  12.  */
  13. class Order
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      * @Groups({"order"})
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="integer")
  24.      * @Assert\NotBlank
  25.      * @Groups({"order"})
  26.      */
  27.     private $units;
  28.     /**
  29.      * @ORM\Column(type="text", nullable=true)
  30.      * @Groups({"order"})
  31.      */
  32.     private $observations;
  33.     /**
  34.      * 0: Iniciada : El usuario ha solicitado un presupuesto al proveedor 
  35.      * 1: Presupuestada : El proveedor acepta las condiciones del cliente y formula el presupuesto
  36.      * 2: En cesta : El usuario acepta el presupuesto (también el administrador puede hacerlo)
  37.      * 3: En preparación : El administrador acepta el presupuesto (o el usuario si no requiere confirmación del administrador)
  38.      * 4: En entrega : El proveedor ha fabricado y enviado las piezas
  39.      * 5: Completada : El usaurio ha recibido y comprobado las piezas y la documentación solicitada
  40.      * 6: Rechazada : Rechazada por usuario proveedor, usuario o administrador 
  41.      * 7: Solicitada : El Cliente ha solicitado una orden
  42.      * 
  43.      * @ORM\Column(type="integer")
  44.      * @Groups({"order"})
  45.      */
  46.     private $state false;
  47.     /**
  48.      * @ORM\ManyToOne(targetEntity=Company::class)
  49.      * @ORM\JoinColumn(nullable=false)
  50.      */
  51.     private $company;
  52.     /**
  53.      * @ORM\ManyToOne(targetEntity=Supplier::class)
  54.      * @ORM\JoinColumn(nullable=false)
  55.      */
  56.     private $supplier;
  57.     /**
  58.      * @ORM\ManyToOne(targetEntity=User::class)
  59.      * @ORM\JoinColumn(nullable=false)
  60.      */
  61.     private $user;
  62.     /**
  63.      * @ORM\Column(type="datetime")
  64.      * @Groups({"order"})
  65.      */
  66.     private $created_at;
  67.     /**
  68.      * @ORM\Column(type="datetime")
  69.      * @Groups({"order"})
  70.      */
  71.     private $updated_at;
  72.     /**
  73.      * @ORM\ManyToOne(targetEntity=Part::class, inversedBy="orders", cascade={"persist"})
  74.      * @ORM\JoinColumn(nullable=false)
  75.      * @Groups({"part"})
  76.      */
  77.     private $part;
  78.     /**
  79.      * @ORM\Column(type="datetime", nullable=true)
  80.      * @Groups({"order"})
  81.      */
  82.     private $completed_at;
  83.     /**
  84.      * @ORM\Column(type="string", length=15)
  85.      * @Groups({"order"})
  86.      */
  87.     private $ref;
  88.     /**
  89.      * @ORM\Column(type="string", length=100, nullable=true)
  90.      * @Groups({"order"})
  91.      */
  92.     private $code;
  93.     /**
  94.      * @ORM\Column(type="text", nullable=true)
  95.      * @Groups({"order"})
  96.      */
  97.     private $observations_supplier;
  98.     /**
  99.      * @ORM\Column(type="text", nullable=true)
  100.      * @Groups({"order"})
  101.      */
  102.     private $files_supplier;
  103.     /**
  104.      * @ORM\OneToMany(targetEntity=OrderMachineData::class, mappedBy="orderId")
  105.      */
  106.     private $orderMachineData;
  107.     /**
  108.      * @ORM\ManyToOne(targetEntity=User::class)
  109.      */
  110.     private $reject_user;
  111.     /**
  112.      * @ORM\Column(type="datetime", nullable=true)
  113.      */
  114.     private $reject_date;
  115.     /**
  116.      * @ORM\Column(type="float", nullable=true)
  117.      */
  118.     private $budget;
  119.     /**
  120.      * @ORM\Column(type="string", length=255, nullable=true)
  121.      */
  122.     private $payment_terms;
  123.     /**
  124.      * @ORM\Column(type="string", length=100, nullable=true)
  125.      */
  126.     private $budget_valid_until;
  127.     /**
  128.      * @ORM\Column(type="string", length=100, nullable=true)
  129.      */
  130.     private $delivery_in;
  131.     /**
  132.      * @ORM\Column(type="text", nullable=true)
  133.      */
  134.     private $files_budget;
  135.     /**
  136.      * @ORM\ManyToOne(targetEntity=User::class)
  137.      */
  138.     private $approve_user_user;
  139.     /**
  140.      * @ORM\ManyToOne(targetEntity=User::class)
  141.      */
  142.     private $approve_chief_user;
  143.     /**
  144.      * @ORM\Column(type="datetime", nullable=true)
  145.      */
  146.     private $approve_user_date;
  147.     /**
  148.      * @ORM\Column(type="datetime", nullable=true)
  149.      */
  150.     private $approve_chief_date;
  151.     /**
  152.      * @ORM\ManyToOne(targetEntity=User::class)
  153.      */
  154.     private $send_user;
  155.     /**
  156.      * @ORM\Column(type="datetime", nullable=true)
  157.      */
  158.     private $send_date;
  159.     /**
  160.      * @ORM\ManyToOne(targetEntity=User::class)
  161.      */
  162.     private $complete_user;
  163.     /**
  164.      * @ORM\Column(type="datetime", nullable=true)
  165.      */
  166.     private $complete_date;
  167.     /**
  168.      * @ORM\Column(type="string", length=15, nullable=true)
  169.      */
  170.     private $accept_ref;
  171.     /**
  172.      * @ORM\OneToMany(targetEntity=OrderMessage::class, mappedBy="order_")
  173.      */
  174.     private $orderMessages;
  175.     /**
  176.      * @ORM\ManyToOne(targetEntity=User::class)
  177.      */
  178.     private $approve_supplier_user;
  179.     /**
  180.      * @ORM\Column(type="datetime", nullable=true)
  181.      */
  182.     private $approve_supplier_date;
  183.     /**
  184.      * Requiere doble confirmación (confirmación del administrador (ROLE_CHIEF))
  185.      * 
  186.      * 
  187.      * @ORM\Column(type="boolean")
  188.      */
  189.     private $chief_confirm;
  190.     /**
  191.      * @ORM\Column(type="integer", nullable=true)
  192.      */
  193.     private $payment_terms_id;
  194.     /**
  195.      * @ORM\Column(type="datetime", nullable=true)
  196.      */
  197.     private $budget_date;
  198.     /**
  199.      * @ORM\Column(type="datetime", nullable=true)
  200.      */
  201.     private $approve_date;
  202.     /**
  203.      * @ORM\ManyToOne(targetEntity=CompanyAddress::class)
  204.      * @ORM\JoinColumn(onDelete="SET NULL")
  205.      */
  206.     private $shipping_address;
  207.     /**
  208.      * @ORM\Column(type="boolean", nullable=true)
  209.      */
  210.     private $budget_required;
  211.     /**
  212.      * @ORM\Column(type="integer", nullable=true)
  213.      */
  214.     private $units_decrypted;
  215.     /**
  216.      * @ORM\Column(type="datetime", nullable=true)
  217.      */
  218.     private $units_decrypted_date;
  219.     public function __construct()
  220.     {
  221.         $this->created_at = new \DateTime();
  222.         $this->markAsAproved();
  223.         $this->orderMachineData = new ArrayCollection();
  224.         $this->orderMessages = new ArrayCollection();
  225.     }
  226.     public function getId(): ?int
  227.     {
  228.         return $this->id;
  229.     }
  230.     public function getUnits(): ?int
  231.     {
  232.         return $this->units;
  233.     }
  234.     public function setUnits(int $units): self
  235.     {
  236.         $this->units $units;
  237.         return $this;
  238.     }
  239.     public function getObservations(): ?string
  240.     {
  241.         return $this->observations;
  242.     }
  243.     public function setObservations(?string $observations): self
  244.     {
  245.         $this->observations $observations;
  246.         return $this;
  247.     }
  248.     public function getState(): ?int
  249.     {
  250.         return $this->state;
  251.     }
  252.     public function setState(int $state): self
  253.     {
  254.         $this->state $state;
  255.         return $this;
  256.     }
  257.     public function getCompany(): ?Company
  258.     {
  259.         return $this->company;
  260.     }
  261.     public function setCompany(?Company $company): self
  262.     {
  263.         $this->company $company;
  264.         return $this;
  265.     }
  266.     public function getSupplier(): ?Supplier
  267.     {
  268.         return $this->supplier;
  269.     }
  270.     public function setSupplier(?Supplier $supplier): self
  271.     {
  272.         $this->supplier $supplier;
  273.         return $this;
  274.     }
  275.     public function getUser(): ?User
  276.     {
  277.         return $this->user;
  278.     }
  279.     public function setUser(?User $user): self
  280.     {
  281.         $this->user $user;
  282.         return $this;
  283.     }
  284.     public function getCreatedAt(): ?\DateTimeInterface
  285.     {
  286.         return $this->created_at;
  287.     }
  288.     public function getUpdatedAt(): ?\DateTimeInterface
  289.     {
  290.         return $this->updated_at;
  291.     }
  292.     /**
  293.      * Set the value of updatedAt
  294.      *
  295.      * @param \DateTime $updatedAt
  296.      */
  297.     public function markAsAproved() : void
  298.     {
  299.         $this->updated_at = new \DateTime();
  300.     }
  301.     /**
  302.      * Set the value of completedAt
  303.      *
  304.      * @param \DateTime $completedAt
  305.      */
  306.     public function markAsCompleted() : void
  307.     {
  308.         $this->completed_at = new \DateTime();
  309.     }
  310.     public function getPart(): ?Part
  311.     {
  312.         return $this->part;
  313.     }
  314.     public function setPart(?Part $part): self
  315.     {
  316.         $this->part $part;
  317.         return $this;
  318.     }
  319.     public function getCompletedAt(): ?\DateTimeInterface
  320.     {
  321.         return $this->completed_at;
  322.     }
  323.     public function setCompletedAt(?\DateTimeInterface $completed_at): self
  324.     {
  325.         $this->completed_at $completed_at;
  326.         return $this;
  327.     }
  328.     public function getRef(): ?string
  329.     {
  330.         return $this->ref;
  331.     }
  332.     public function setRef(string $ref): self
  333.     {
  334.         $splits explode("-"$ref);
  335.         $today date("ymd");
  336.         if ($splits[1] == $today)
  337.         {
  338.             $splits[2]++;
  339.             $splits[2] = str_pad$splits[2], 3"0"STR_PAD_LEFT);
  340.             $ref implode("-"$splits);
  341.         }else
  342.         {
  343.             $ref $splits[0] . "-" date("ymd") . "-001";
  344.         }
  345.         $this->ref $ref;
  346.         return $this;
  347.     }
  348.     public function getCode(): ?string
  349.     {
  350.         return $this->code;
  351.     }
  352.     public function setCode(?string $code): self
  353.     {
  354.         $this->code $code;
  355.         return $this;
  356.     }
  357.     public function getObservationsSupplier(): ?string
  358.     {
  359.         return $this->observations_supplier;
  360.     }
  361.     public function setObservationsSupplier(?string $observations_supplier): self
  362.     {
  363.         $this->observations_supplier $observations_supplier;
  364.         return $this;
  365.     }
  366.     public function getFilesSupplier(): ?string
  367.     {
  368.         return $this->files_supplier;
  369.     }
  370.     public function setFilesSupplier(?string $files_supplier): self
  371.     {
  372.         $this->files_supplier $files_supplier;
  373.         return $this;
  374.     }
  375.     /**
  376.      * @return Collection<int, OrderMachineData>
  377.      */
  378.     public function getOrderMachineData(): Collection
  379.     {
  380.         return $this->orderMachineData;
  381.     }
  382.     public function addOrderMachineData(OrderMachineData $orderMachineData): self
  383.     {
  384.         if (!$this->orderMachineData->contains($orderMachineData)) {
  385.             $this->orderMachineData[] = $orderMachineData;
  386.             $orderMachineData->setOrderId($this);
  387.         }
  388.         return $this;
  389.     }
  390.     public function removeOrderMachineData(OrderMachineData $orderMachineData): self
  391.     {
  392.         if ($this->orderMachineData->removeElement($orderMachineData)) {
  393.             // set the owning side to null (unless already changed)
  394.             if ($orderMachineData->getOrderId() === $this) {
  395.                 $orderMachineData->setOrderId(null);
  396.             }
  397.         }
  398.         return $this;
  399.     }
  400.     public function getRejectUser(): ?User
  401.     {
  402.         return $this->reject_user;
  403.     }
  404.     public function setRejectUser(?User $reject_user): self
  405.     {
  406.         $this->reject_user $reject_user;
  407.         return $this;
  408.     }
  409.     public function getRejectDate(): ?\DateTimeInterface
  410.     {
  411.         return $this->reject_date;
  412.     }
  413.     public function setRejectDate(?\DateTimeInterface $reject_date): self
  414.     {
  415.         $this->reject_date $reject_date;
  416.         return $this;
  417.     }
  418.     public function getBudget(): ?float
  419.     {
  420.         return $this->budget;
  421.     }
  422.     public function setBudget(?float $budget): self
  423.     {
  424.         $this->budget $budget;
  425.         return $this;
  426.     }
  427.     public function getPaymentTerms(): ?string
  428.     {
  429.         return $this->payment_terms;
  430.     }
  431.     public function setPaymentTerms(?string $payment_terms): self
  432.     {
  433.         $this->payment_terms $payment_terms;
  434.         return $this;
  435.     }
  436.     public function getBudgetValidUntil(): ?string
  437.     {
  438.         return $this->budget_valid_until;
  439.     }
  440.     public function setBudgetValidUntil(?string $budget_valid_until): self
  441.     {
  442.         $this->budget_valid_until $budget_valid_until;
  443.         return $this;
  444.     }
  445.     public function getDeliveryIn(): ?string
  446.     {
  447.         return $this->delivery_in;
  448.     }
  449.     public function setDeliveryIn(?string $delivery_in): self
  450.     {
  451.         $this->delivery_in $delivery_in;
  452.         return $this;
  453.     }
  454.     public function getFilesBudget(): ?string
  455.     {
  456.         return $this->files_budget;
  457.     }
  458.     public function setFilesBudget(?string $files_budget): self
  459.     {
  460.         $this->files_budget $files_budget;
  461.         return $this;
  462.     }
  463.     public function getApproveUserUser(): ?User
  464.     {
  465.         return $this->approve_user_user;
  466.     }
  467.     public function setApproveUserUser(?User $approve_user_user): self
  468.     {
  469.         $this->approve_user_user $approve_user_user;
  470.         return $this;
  471.     }
  472.     public function getApproveChiefUser(): ?User
  473.     {
  474.         return $this->approve_chief_user;
  475.     }
  476.     public function setApproveChiefUser(?User $approve_chief_user): self
  477.     {
  478.         $this->approve_chief_user $approve_chief_user;
  479.         return $this;
  480.     }
  481.     public function getApproveUserDate(): ?\DateTimeInterface
  482.     {
  483.         return $this->approve_user_date;
  484.     }
  485.     public function setApproveUserDate(?\DateTimeInterface $approve_user_date): self
  486.     {
  487.         $this->approve_user_date $approve_user_date;
  488.         return $this;
  489.     }
  490.     public function getApproveChiefDate(): ?\DateTimeInterface
  491.     {
  492.         return $this->approve_chief_date;
  493.     }
  494.     public function setApproveChiefDate(?\DateTimeInterface $approve_chief_date): self
  495.     {
  496.         $this->approve_chief_date $approve_chief_date;
  497.         return $this;
  498.     }
  499.     public function getSendUser(): ?User
  500.     {
  501.         return $this->send_user;
  502.     }
  503.     public function setSendUser(?User $send_user): self
  504.     {
  505.         $this->send_user $send_user;
  506.         return $this;
  507.     }
  508.     public function getSendDate(): ?\DateTimeInterface
  509.     {
  510.         return $this->send_date;
  511.     }
  512.     public function setSendDate(?\DateTimeInterface $send_date): self
  513.     {
  514.         $this->send_date $send_date;
  515.         return $this;
  516.     }
  517.     public function getCompleteUser(): ?User
  518.     {
  519.         return $this->complete_user;
  520.     }
  521.     public function setCompleteUser(?User $complete_user): self
  522.     {
  523.         $this->complete_user $complete_user;
  524.         return $this;
  525.     }
  526.     public function getCompleteDate(): ?\DateTimeInterface
  527.     {
  528.         return $this->complete_date;
  529.     }
  530.     public function setCompleteDate(?\DateTimeInterface $complete_date): self
  531.     {
  532.         $this->complete_date $complete_date;
  533.         return $this;
  534.     }
  535.     public function getAcceptRef(): ?string
  536.     {
  537.         return $this->accept_ref;
  538.     }
  539.     public function setAcceptRef(?string $accept_ref): self
  540.     {
  541.         $this->accept_ref $accept_ref;
  542.         return $this;
  543.     }
  544.     /**
  545.      * @return Collection<int, OrderMessage>
  546.      */
  547.     public function getOrderMessages(): Collection
  548.     {
  549.         return $this->orderMessages;
  550.     }
  551.     public function addOrderMessage(OrderMessage $orderMessage): self
  552.     {
  553.         if (!$this->orderMessages->contains($orderMessage)) {
  554.             $this->orderMessages[] = $orderMessage;
  555.             $orderMessage->setOrder($this);
  556.         }
  557.         return $this;
  558.     }
  559.     public function removeOrderMessage(OrderMessage $orderMessage): self
  560.     {
  561.         if ($this->orderMessages->removeElement($orderMessage)) {
  562.             // set the owning side to null (unless already changed)
  563.             if ($orderMessage->getOrder() === $this) {
  564.                 $orderMessage->setOrder(null);
  565.             }
  566.         }
  567.         return $this;
  568.     }
  569.     public function getApproveSupplierUser(): ?User
  570.     {
  571.         return $this->approve_supplier_user;
  572.     }
  573.     public function setApproveSupplierUser(?User $approve_supplier_user): self
  574.     {
  575.         $this->approve_supplier_user $approve_supplier_user;
  576.         return $this;
  577.     }
  578.     public function getApproveSupplierDate(): ?\DateTimeInterface
  579.     {
  580.         return $this->approve_supplier_date;
  581.     }
  582.     public function setApproveSupplierDate(?\DateTimeInterface $approve_supplier_date): self
  583.     {
  584.         $this->approve_supplier_date $approve_supplier_date;
  585.         return $this;
  586.     }
  587.     public function getChiefConfirm(): ?bool
  588.     {
  589.         return $this->chief_confirm;
  590.     }
  591.     public function setChiefConfirm(bool $chief_confirm): self
  592.     {
  593.         $this->chief_confirm $chief_confirm;
  594.         return $this;
  595.     }
  596.     public function getPaymentTermsId(): ?int
  597.     {
  598.         return $this->payment_terms_id;
  599.     }
  600.     public function setPaymentTermsId(?int $payment_terms_id): self
  601.     {
  602.         $this->payment_terms_id $payment_terms_id;
  603.         return $this;
  604.     }
  605.     public function getBudgetDate(): ?\DateTimeInterface
  606.     {
  607.         return $this->budget_date;
  608.     }
  609.     public function setBudgetDate(?\DateTimeInterface $budget_date): self
  610.     {
  611.         $this->budget_date $budget_date;
  612.         return $this;
  613.     }
  614.     public function getApproveDate(): ?\DateTimeInterface
  615.     {
  616.         return $this->approve_date;
  617.     }
  618.     public function setApproveDate(?\DateTimeInterface $approve_date): self
  619.     {
  620.         $this->approve_date $approve_date;
  621.         return $this;
  622.     }
  623.     public function getShippingAddress(): ?CompanyAddress
  624.     {
  625.         return $this->shipping_address;
  626.     }
  627.     public function setShippingAddress(?CompanyAddress $shipping_address): self
  628.     {
  629.         $this->shipping_address $shipping_address;
  630.         return $this;
  631.     }
  632.     public function getBudgetRequired(): ?bool
  633.     {
  634.         return $this->budget_required;
  635.     }
  636.     public function setBudgetRequired(?bool $budget_required): self
  637.     {
  638.         $this->budget_required $budget_required;
  639.         return $this;
  640.     }
  641.     public function getUnitsDecrypted(): ?int
  642.     {
  643.         return $this->units_decrypted;
  644.     }
  645.     public function setUnitsDecrypted(?int $units_decrypted): self
  646.     {
  647.         $this->units_decrypted $units_decrypted;
  648.         return $this;
  649.     }
  650.     public function getUnitsDecryptedDate(): ?\DateTimeInterface
  651.     {
  652.         return $this->units_decrypted_date;
  653.     }
  654.     public function setUnitsDecryptedDate(?\DateTimeInterface $units_decrypted_date): self
  655.     {
  656.         $this->units_decrypted_date $units_decrypted_date;
  657.         return $this;
  658.     }
  659. }