diff --git a/hesabixCore/src/Controller/ArchiveController.php b/hesabixCore/src/Controller/ArchiveController.php new file mode 100644 index 0000000..14125ed --- /dev/null +++ b/hesabixCore/src/Controller/ArchiveController.php @@ -0,0 +1,27 @@ +hasRole('archiveInfo'); + if(!$acc) + throw $this->createAccessDeniedException(); + return $this->json([ + 'size' => $acc['bid']->getArchiveSize() + ]); + } +} diff --git a/hesabixCore/src/Controller/BusinessController.php b/hesabixCore/src/Controller/BusinessController.php index 28fc47a..907d39c 100644 --- a/hesabixCore/src/Controller/BusinessController.php +++ b/hesabixCore/src/Controller/BusinessController.php @@ -386,6 +386,9 @@ class BusinessController extends AbstractController 'plugCCAdmin'=>true, 'wallet'=>true, 'owner'=> true, + 'archiveUpload'=>true, + 'archiveMod'=>true, + 'archiveDelete'=>true, 'active'=> $perm->getUser()->isActive() ]; } @@ -416,6 +419,9 @@ class BusinessController extends AbstractController 'plugCCAdmin'=>$perm->isPlugCCAdmin(), 'wallet'=>$perm->isWallet(), 'owner'=> false, + 'archiveUpload'=>$perm->isArchiveUpload(), + 'archiveMod'=>$perm->isArchiveMod(), + 'archiveDelete'=>$perm->isArchiveDelete(), 'active'=> $perm->getUser()->isActive() ]; } @@ -474,6 +480,9 @@ class BusinessController extends AbstractController $perm->setPlugNoghreSell($params['plugNoghreSell']); $perm->setPlugCCAdmin($params['plugCCAdmin']); $perm->setLog($params['log']); + $perm->setArchiveMod($params['archiveMod']); + $perm->setArchiveDelete($params['archiveDelete']); + $perm->setArchiveUpload($params['archiveUpload']); $entityManager->persist($perm); $entityManager->flush(); $log->insert('تنظیمات پایه','ویرایش دسترسی‌های کاربر با پست الکترونیکی ' . $user->getEmail() ,$this->getUser(),$business); diff --git a/hesabixCore/src/Entity/ArchiveFile.php b/hesabixCore/src/Entity/ArchiveFile.php new file mode 100644 index 0000000..4846f50 --- /dev/null +++ b/hesabixCore/src/Entity/ArchiveFile.php @@ -0,0 +1,187 @@ +id; + } + + public function getBid(): ?Business + { + return $this->bid; + } + + public function setBid(?Business $bid): static + { + $this->bid = $bid; + + return $this; + } + + public function getDateSubmit(): ?string + { + return $this->dateSubmit; + } + + public function setDateSubmit(string $dateSubmit): static + { + $this->dateSubmit = $dateSubmit; + + return $this; + } + + public function getDateMod(): ?string + { + return $this->dateMod; + } + + public function setDateMod(?string $dateMod): static + { + $this->dateMod = $dateMod; + + return $this; + } + + public function getSubmitter(): ?User + { + return $this->Submitter; + } + + public function setSubmitter(?User $Submitter): static + { + $this->Submitter = $Submitter; + + return $this; + } + + public function getFilename(): ?string + { + return $this->filename; + } + + public function setFilename(string $filename): static + { + $this->filename = $filename; + + return $this; + } + + public function getCat(): ?string + { + return $this->cat; + } + + public function setCat(string $cat): static + { + $this->cat = $cat; + + return $this; + } + + public function getFileType(): ?string + { + return $this->fileType; + } + + public function setFileType(string $fileType): static + { + $this->fileType = $fileType; + + return $this; + } + + public function isPublic(): ?bool + { + return $this->public; + } + + public function setPublic(?bool $public): static + { + $this->public = $public; + + return $this; + } + + public function getDes(): ?string + { + return $this->des; + } + + public function setDes(?string $des): static + { + $this->des = $des; + + return $this; + } + + public function getRelatedDocType(): ?string + { + return $this->relatedDocType; + } + + public function setRelatedDocType(string $relatedDocType): static + { + $this->relatedDocType = $relatedDocType; + + return $this; + } + + public function getRelatedDocCode(): ?string + { + return $this->relatedDocCode; + } + + public function setRelatedDocCode(?string $relatedDocCode): static + { + $this->relatedDocCode = $relatedDocCode; + + return $this; + } +} diff --git a/hesabixCore/src/Entity/Business.php b/hesabixCore/src/Entity/Business.php index 686d49c..5fe3c15 100644 --- a/hesabixCore/src/Entity/Business.php +++ b/hesabixCore/src/Entity/Business.php @@ -187,6 +187,12 @@ class Business #[ORM\Column(length: 255, nullable: true)] private ?string $storeroomCode = '1000'; + #[ORM\Column(length: 255, nullable: true)] + private ?string $archiveSize = null; + + #[ORM\OneToMany(mappedBy: 'bid', targetEntity: ArchiveFile::class, orphanRemoval: true)] + private Collection $archiveFiles; + public function __construct() { $this->logs = new ArrayCollection(); @@ -208,6 +214,7 @@ class Business $this->walletTransactions = new ArrayCollection(); $this->storeroomTickets = new ArrayCollection(); $this->storeroomItems = new ArrayCollection(); + $this->archiveFiles = new ArrayCollection(); } public function getId(): ?int @@ -1204,4 +1211,46 @@ class Business return $this; } + + public function getArchiveSize(): ?string + { + return $this->archiveSize; + } + + public function setArchiveSize(?string $archiveSize): static + { + $this->archiveSize = $archiveSize; + + return $this; + } + + /** + * @return Collection + */ + public function getArchiveFiles(): Collection + { + return $this->archiveFiles; + } + + public function addArchiveFile(ArchiveFile $archiveFile): static + { + if (!$this->archiveFiles->contains($archiveFile)) { + $this->archiveFiles->add($archiveFile); + $archiveFile->setBid($this); + } + + return $this; + } + + public function removeArchiveFile(ArchiveFile $archiveFile): static + { + if ($this->archiveFiles->removeElement($archiveFile)) { + // set the owning side to null (unless already changed) + if ($archiveFile->getBid() === $this) { + $archiveFile->setBid(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/Permission.php b/hesabixCore/src/Entity/Permission.php index 4985319..5b2508d 100644 --- a/hesabixCore/src/Entity/Permission.php +++ b/hesabixCore/src/Entity/Permission.php @@ -87,6 +87,15 @@ class Permission #[ORM\Column(nullable: true)] private ?bool $wallet = null; + #[ORM\Column(nullable: true)] + private ?bool $archiveUpload = null; + + #[ORM\Column(nullable: true)] + private ?bool $archiveMod = null; + + #[ORM\Column(nullable: true)] + private ?bool $archiveDelete = null; + public function getId(): ?int { return $this->id; @@ -379,4 +388,40 @@ class Permission return $this; } + + public function isArchiveUpload(): ?bool + { + return $this->archiveUpload; + } + + public function setArchiveUpload(?bool $archiveUpload): static + { + $this->archiveUpload = $archiveUpload; + + return $this; + } + + public function isArchiveMod(): ?bool + { + return $this->archiveMod; + } + + public function setArchiveMod(?bool $archiveMod): static + { + $this->archiveMod = $archiveMod; + + return $this; + } + + public function isArchiveDelete(): ?bool + { + return $this->archiveDelete; + } + + public function setArchiveDelete(?bool $archiveDelete): static + { + $this->archiveDelete = $archiveDelete; + + return $this; + } } diff --git a/hesabixCore/src/Entity/User.php b/hesabixCore/src/Entity/User.php index 5b51cb3..bc17615 100644 --- a/hesabixCore/src/Entity/User.php +++ b/hesabixCore/src/Entity/User.php @@ -92,6 +92,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\OneToMany(mappedBy: 'submitter', targetEntity: StoreroomTicket::class, orphanRemoval: true)] private Collection $storeroomTickets; + #[ORM\OneToMany(mappedBy: 'Submitter', targetEntity: ArchiveFile::class, orphanRemoval: true)] + private Collection $archiveFiles; + public function __construct() { $this->userTokens = new ArrayCollection(); @@ -109,6 +112,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface $this->sMSPays = new ArrayCollection(); $this->walletTransactions = new ArrayCollection(); $this->storeroomTickets = new ArrayCollection(); + $this->archiveFiles = new ArrayCollection(); } public function getId(): ?int @@ -702,4 +706,34 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface return $this; } + + /** + * @return Collection + */ + public function getArchiveFiles(): Collection + { + return $this->archiveFiles; + } + + public function addArchiveFile(ArchiveFile $archiveFile): static + { + if (!$this->archiveFiles->contains($archiveFile)) { + $this->archiveFiles->add($archiveFile); + $archiveFile->setSubmitter($this); + } + + return $this; + } + + public function removeArchiveFile(ArchiveFile $archiveFile): static + { + if ($this->archiveFiles->removeElement($archiveFile)) { + // set the owning side to null (unless already changed) + if ($archiveFile->getSubmitter() === $this) { + $archiveFile->setSubmitter(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Repository/ArchiveFileRepository.php b/hesabixCore/src/Repository/ArchiveFileRepository.php new file mode 100644 index 0000000..e5a0682 --- /dev/null +++ b/hesabixCore/src/Repository/ArchiveFileRepository.php @@ -0,0 +1,48 @@ + + * + * @method ArchiveFile|null find($id, $lockMode = null, $lockVersion = null) + * @method ArchiveFile|null findOneBy(array $criteria, array $orderBy = null) + * @method ArchiveFile[] findAll() + * @method ArchiveFile[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class ArchiveFileRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, ArchiveFile::class); + } + +// /** +// * @return ArchiveFile[] Returns an array of ArchiveFile objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('a') +// ->andWhere('a.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('a.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?ArchiveFile +// { +// return $this->createQueryBuilder('a') +// ->andWhere('a.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +}