src/Entity/MaterialRequestDocument.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\MaterialRequestDocumentRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. /**
  7.  * MaterialRequestDocument — bir MaterialRequest'e eklenen tek bir PDF. Sistem PDF'i
  8.  * PARSE ETMEZ; Expenses sorumlusu her PDF'i gozle inceler ve PDF SEVIYESINDE karar
  9.  * verir (status + review_note). Responsible person durumu bu satirlar uzerinden takip
  10.  * eder — madde/kalem detayi gormez.
  11.  *
  12.  * @ORM\Entity(repositoryClass=MaterialRequestDocumentRepository::class)
  13.  * @ORM\Table(name="material_request_documents")
  14.  * @ORM\HasLifecycleCallbacks
  15.  */
  16. class MaterialRequestDocument
  17. {
  18.     /**
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue
  21.      * @ORM\Column(type="integer")
  22.      * @Groups({
  23.      *     "material_request_document@ref",
  24.      *     "material_request_document@base",
  25.      *     "material_request_document@core"
  26.      * })
  27.      */
  28.     private $id;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity=MaterialRequest::class, inversedBy="documents")
  31.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  32.      */
  33.     private $material_request;
  34.     /**
  35.      * Serbest text — talep sahibinin PDF'e verdigi isim (ornegin "Werkstatt vidalar").
  36.      * @ORM\Column(type="string", length=255, nullable=false)
  37.      * @Groups({
  38.      *     "material_request_document@base",
  39.      *     "material_request_document@core"
  40.      * })
  41.      */
  42.     private $name;
  43.     /**
  44.      * Kategori — item_groups (eski stock_item_groups, 2026-08-10 rename).
  45.      * @ORM\ManyToOne(targetEntity=ItemGroups::class)
  46.      * @ORM\JoinColumn(nullable=false)
  47.      * @Groups({
  48.      *     "material_request_document@item_group"
  49.      * })
  50.      */
  51.     private $item_group;
  52.     /**
  53.      * Diskteki gercek dosya adi (benzersiz prefix'li — FileUploadContext deseni).
  54.      *
  55.      * 🪤 NULLABLE (2026-08-25): belge artik PDF YERINE serbest metin de olabilir.
  56.      *    Dosya yoksa bu alan NULL'dur; `free_text` doludur. Ikisinden EN AZ BIRI dolu
  57.      *    olmak zorunda — kural `MaterialRequestService::uploadDocument`'te.
  58.      * @ORM\Column(type="string", length=255, nullable=true)
  59.      * @Groups({
  60.      *     "material_request_document@core"
  61.      * })
  62.      */
  63.     private $file_name;
  64.     /**
  65.      * FE'nin dogrudan kullanacagi public fetch yolu (materialRequestFetchDir + dosya adi).
  66.      * NULL = bu belge dosya degil serbest metin (bkz. `free_text`).
  67.      * @ORM\Column(type="string", length=255, nullable=true)
  68.      * @Groups({
  69.      *     "material_request_document@core"
  70.      * })
  71.      */
  72.     private $file_path;
  73.     /**
  74.      * Default'un TEK kaynagi burasi (property default).
  75.      * @ORM\Column(type="material_request_document_status", nullable=false, options={"default": "pending"})
  76.      * @Groups({
  77.      *     "material_request_document@base",
  78.      *     "material_request_document@core"
  79.      * })
  80.      */
  81.     private $status = 'pending';
  82.     /**
  83.      * PDF YERINE serbest metin (cok satirli).
  84.      *
  85.      * Kullanici karari 2026-08-25: talep kalemi ARTIK ALTERNATIFLI — icraci ya bir PDF
  86.      * yukler ya da ihtiyacini buraya yazar. Inceleyen de ayni sekilde: dosya varsa
  87.      * onizler, yoksa metni okur.
  88.      *
  89.      * 🪤 `review_note` ILE KARISTIRMA: bu TALEP EDENIN yazdigi metin (ne istiyor),
  90.      *    `review_note` ise INCELEYENIN yazdigi (neden kismi/ret). Ikisi ayri yon.
  91.      *
  92.      * @ORM\Column(type="text", nullable=true)
  93.      * @Groups({
  94.      *     "material_request_document@core"
  95.      * })
  96.      */
  97.     private $free_text;
  98.     /**
  99.      * Parcali siparis aciklamasi (ya da red gerekcesi) — nullable, yalniz karar aninda dolar.
  100.      * @ORM\Column(type="text", nullable=true)
  101.      * @Groups({
  102.      *     "material_request_document@core"
  103.      * })
  104.      */
  105.     private $review_note;
  106.     /**
  107.      * @ORM\Column(type="datetime_immutable", nullable=false)
  108.      * @Groups({
  109.      *     "material_request_document@core"
  110.      * })
  111.      */
  112.     private $created_at;
  113.     /**
  114.      * @ORM\PrePersist
  115.      */
  116.     public function onPrePersist(): void
  117.     {
  118.         if ($this->created_at === null) {
  119.             $this->created_at = new \DateTimeImmutable();
  120.         }
  121.     }
  122.     public function getId(): ?int
  123.     {
  124.         return $this->id;
  125.     }
  126.     public function getMaterialRequest(): ?MaterialRequest
  127.     {
  128.         return $this->material_request;
  129.     }
  130.     public function setMaterialRequest(?MaterialRequest $material_request): self
  131.     {
  132.         $this->material_request = $material_request;
  133.         return $this;
  134.     }
  135.     public function getName(): ?string
  136.     {
  137.         return $this->name;
  138.     }
  139.     public function setName(string $name): self
  140.     {
  141.         $this->name = $name;
  142.         return $this;
  143.     }
  144.     public function getItemGroup(): ?ItemGroups
  145.     {
  146.         return $this->item_group;
  147.     }
  148.     public function setItemGroup(?ItemGroups $item_group): self
  149.     {
  150.         $this->item_group = $item_group;
  151.         return $this;
  152.     }
  153.     public function getFileName(): ?string
  154.     {
  155.         return $this->file_name;
  156.     }
  157.     public function getFreeText(): ?string
  158.     {
  159.         return $this->free_text;
  160.     }
  161.     public function setFreeText(?string $free_text): self
  162.     {
  163.         $this->free_text = $free_text;
  164.         return $this;
  165.     }
  166.     public function setFileName(?string $file_name): self
  167.     {
  168.         $this->file_name = $file_name;
  169.         return $this;
  170.     }
  171.     public function getFilePath(): ?string
  172.     {
  173.         return $this->file_path;
  174.     }
  175.     public function setFilePath(?string $file_path): self
  176.     {
  177.         $this->file_path = $file_path;
  178.         return $this;
  179.     }
  180.     public function getStatus(): ?string
  181.     {
  182.         return $this->status;
  183.     }
  184.     public function setStatus(string $status): self
  185.     {
  186.         $this->status = $status;
  187.         return $this;
  188.     }
  189.     public function getReviewNote(): ?string
  190.     {
  191.         return $this->review_note;
  192.     }
  193.     public function setReviewNote(?string $review_note): self
  194.     {
  195.         $this->review_note = $review_note;
  196.         return $this;
  197.     }
  198.     public function getCreatedAt(): ?\DateTimeImmutable
  199.     {
  200.         return $this->created_at;
  201.     }
  202.     public function setCreatedAt(?\DateTimeImmutable $created_at): self
  203.     {
  204.         $this->created_at = $created_at;
  205.         return $this;
  206.     }
  207. }