<?php
namespace App\Entity;
use App\Repository\MaterialRequestDocumentRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* MaterialRequestDocument — bir MaterialRequest'e eklenen tek bir PDF. Sistem PDF'i
* PARSE ETMEZ; Expenses sorumlusu her PDF'i gozle inceler ve PDF SEVIYESINDE karar
* verir (status + review_note). Responsible person durumu bu satirlar uzerinden takip
* eder — madde/kalem detayi gormez.
*
* @ORM\Entity(repositoryClass=MaterialRequestDocumentRepository::class)
* @ORM\Table(name="material_request_documents")
* @ORM\HasLifecycleCallbacks
*/
class MaterialRequestDocument
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "material_request_document@ref",
* "material_request_document@base",
* "material_request_document@core"
* })
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=MaterialRequest::class, inversedBy="documents")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private $material_request;
/**
* Serbest text — talep sahibinin PDF'e verdigi isim (ornegin "Werkstatt vidalar").
* @ORM\Column(type="string", length=255, nullable=false)
* @Groups({
* "material_request_document@base",
* "material_request_document@core"
* })
*/
private $name;
/**
* Kategori — item_groups (eski stock_item_groups, 2026-08-10 rename).
* @ORM\ManyToOne(targetEntity=ItemGroups::class)
* @ORM\JoinColumn(nullable=false)
* @Groups({
* "material_request_document@item_group"
* })
*/
private $item_group;
/**
* Diskteki gercek dosya adi (benzersiz prefix'li — FileUploadContext deseni).
*
* 🪤 NULLABLE (2026-08-25): belge artik PDF YERINE serbest metin de olabilir.
* Dosya yoksa bu alan NULL'dur; `free_text` doludur. Ikisinden EN AZ BIRI dolu
* olmak zorunda — kural `MaterialRequestService::uploadDocument`'te.
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "material_request_document@core"
* })
*/
private $file_name;
/**
* FE'nin dogrudan kullanacagi public fetch yolu (materialRequestFetchDir + dosya adi).
* NULL = bu belge dosya degil serbest metin (bkz. `free_text`).
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "material_request_document@core"
* })
*/
private $file_path;
/**
* Default'un TEK kaynagi burasi (property default).
* @ORM\Column(type="material_request_document_status", nullable=false, options={"default": "pending"})
* @Groups({
* "material_request_document@base",
* "material_request_document@core"
* })
*/
private $status = 'pending';
/**
* PDF YERINE serbest metin (cok satirli).
*
* Kullanici karari 2026-08-25: talep kalemi ARTIK ALTERNATIFLI — icraci ya bir PDF
* yukler ya da ihtiyacini buraya yazar. Inceleyen de ayni sekilde: dosya varsa
* onizler, yoksa metni okur.
*
* 🪤 `review_note` ILE KARISTIRMA: bu TALEP EDENIN yazdigi metin (ne istiyor),
* `review_note` ise INCELEYENIN yazdigi (neden kismi/ret). Ikisi ayri yon.
*
* @ORM\Column(type="text", nullable=true)
* @Groups({
* "material_request_document@core"
* })
*/
private $free_text;
/**
* Parcali siparis aciklamasi (ya da red gerekcesi) — nullable, yalniz karar aninda dolar.
* @ORM\Column(type="text", nullable=true)
* @Groups({
* "material_request_document@core"
* })
*/
private $review_note;
/**
* @ORM\Column(type="datetime_immutable", nullable=false)
* @Groups({
* "material_request_document@core"
* })
*/
private $created_at;
/**
* @ORM\PrePersist
*/
public function onPrePersist(): void
{
if ($this->created_at === null) {
$this->created_at = new \DateTimeImmutable();
}
}
public function getId(): ?int
{
return $this->id;
}
public function getMaterialRequest(): ?MaterialRequest
{
return $this->material_request;
}
public function setMaterialRequest(?MaterialRequest $material_request): self
{
$this->material_request = $material_request;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getItemGroup(): ?ItemGroups
{
return $this->item_group;
}
public function setItemGroup(?ItemGroups $item_group): self
{
$this->item_group = $item_group;
return $this;
}
public function getFileName(): ?string
{
return $this->file_name;
}
public function getFreeText(): ?string
{
return $this->free_text;
}
public function setFreeText(?string $free_text): self
{
$this->free_text = $free_text;
return $this;
}
public function setFileName(?string $file_name): self
{
$this->file_name = $file_name;
return $this;
}
public function getFilePath(): ?string
{
return $this->file_path;
}
public function setFilePath(?string $file_path): self
{
$this->file_path = $file_path;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
public function getReviewNote(): ?string
{
return $this->review_note;
}
public function setReviewNote(?string $review_note): self
{
$this->review_note = $review_note;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->created_at;
}
public function setCreatedAt(?\DateTimeImmutable $created_at): self
{
$this->created_at = $created_at;
return $this;
}
}