From 6829d777308a8f8bba0ce1872d1751b9eacd8a5c Mon Sep 17 00:00:00 2001 From: Babak Alizadeh Date: Sat, 11 Nov 2023 07:46:50 -0800 Subject: [PATCH] some progress --- .../src/Controller/ArchiveController.php | 32 +++ hesabixCore/src/Entity/ArchiveFile.php | 15 ++ hesabixCore/src/Entity/ArchiveOrders.php | 187 ++++++++++++++++++ hesabixCore/src/Entity/Business.php | 34 ++++ hesabixCore/src/Entity/User.php | 34 ++++ .../Repository/ArchiveOrdersRepository.php | 48 +++++ 6 files changed, 350 insertions(+) create mode 100644 hesabixCore/src/Entity/ArchiveOrders.php create mode 100644 hesabixCore/src/Repository/ArchiveOrdersRepository.php diff --git a/hesabixCore/src/Controller/ArchiveController.php b/hesabixCore/src/Controller/ArchiveController.php index 14125ed..8ab2cf8 100644 --- a/hesabixCore/src/Controller/ArchiveController.php +++ b/hesabixCore/src/Controller/ArchiveController.php @@ -2,7 +2,9 @@ namespace App\Controller; +use App\Entity\ArchiveFile; use App\Service\Access; +use App\Service\Jdate; use App\Service\Log; use App\Service\Provider; use Doctrine\ORM\EntityManagerInterface; @@ -24,4 +26,34 @@ class ArchiveController extends AbstractController 'size' => $acc['bid']->getArchiveSize() ]); } + + #[Route('/api/archive/list/{cat}', name: 'app_archive_list')] + public function app_archive_list(string $cat,Jdate $jdate,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager,$code = 0): JsonResponse + { + $acc = $access->hasRole('archiveUpload'); + if(!$acc) + $acc = $access->hasRole('archiveMod'); + if(!$acc) + $acc = $access->hasRole('archiveDelete'); + if(!$acc) + throw $this->createAccessDeniedException(); + if($cat == 'all') + $files = $entityManager->getRepository(ArchiveFile::class)->findBy(['bid'=>$acc['bid']]); + else + $files = $entityManager->getRepository(ArchiveFile::class)->findBy(['bid'=>$acc['bid'],'cat'=>$cat]); + $resp = []; + foreach ($files as $file){ + $temp = []; + $temp['filename']=$file->getFilename(); + $temp['fileType']=$file->getFileType(); + $temp['submitter']=$file->getSubmitter()->getFullName(); + $temp['dateSubmit']=$jdate->jdate('Y/n/d H:i',$file->getDateSubmit()); + $temp['filePublicls']=$file->isPublic(); + $temp['cat']=$file->getCat(); + $temp['filesize']=$file->getFileSize(); + $resp[] = $temp; + } + + return $this->json($resp); + } } diff --git a/hesabixCore/src/Entity/ArchiveFile.php b/hesabixCore/src/Entity/ArchiveFile.php index 4846f50..5d0ec89 100644 --- a/hesabixCore/src/Entity/ArchiveFile.php +++ b/hesabixCore/src/Entity/ArchiveFile.php @@ -48,6 +48,9 @@ class ArchiveFile #[ORM\Column(length: 255, nullable: true)] private ?string $relatedDocCode = null; + #[ORM\Column(length: 255, nullable: true)] + private ?string $fileSize = null; + public function getId(): ?int { return $this->id; @@ -184,4 +187,16 @@ class ArchiveFile return $this; } + + public function getFileSize(): ?string + { + return $this->fileSize; + } + + public function setFileSize(?string $fileSize): static + { + $this->fileSize = $fileSize; + + return $this; + } } diff --git a/hesabixCore/src/Entity/ArchiveOrders.php b/hesabixCore/src/Entity/ArchiveOrders.php new file mode 100644 index 0000000..02e7f4c --- /dev/null +++ b/hesabixCore/src/Entity/ArchiveOrders.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 getSubmitter(): ?User + { + return $this->submitter; + } + + public function setSubmitter(?User $submitter): static + { + $this->submitter = $submitter; + + return $this; + } + + public function getDateSubmit(): ?string + { + return $this->dateSubmit; + } + + public function setDateSubmit(string $dateSubmit): static + { + $this->dateSubmit = $dateSubmit; + + return $this; + } + + public function getOrderSize(): ?string + { + return $this->orderSize; + } + + public function setOrderSize(string $orderSize): static + { + $this->orderSize = $orderSize; + + return $this; + } + + public function getGatePay(): ?string + { + return $this->gatePay; + } + + public function setGatePay(?string $gatePay): static + { + $this->gatePay = $gatePay; + + return $this; + } + + public function getPrice(): ?string + { + return $this->price; + } + + public function setPrice(?string $price): static + { + $this->price = $price; + + return $this; + } + + public function getVerifyCode(): ?string + { + return $this->verifyCode; + } + + public function setVerifyCode(?string $verifyCode): static + { + $this->verifyCode = $verifyCode; + + return $this; + } + + public function getStatus(): ?string + { + return $this->status; + } + + public function setStatus(?string $status): static + { + $this->status = $status; + + return $this; + } + + public function getRefID(): ?string + { + return $this->refID; + } + + public function setRefID(?string $refID): static + { + $this->refID = $refID; + + return $this; + } + + public function getCardPan(): ?string + { + return $this->cardPan; + } + + public function setCardPan(?string $cardPan): static + { + $this->cardPan = $cardPan; + + return $this; + } + + public function getExpireDate(): ?string + { + return $this->ExpireDate; + } + + public function setExpireDate(?string $ExpireDate): static + { + $this->ExpireDate = $ExpireDate; + + return $this; + } +} diff --git a/hesabixCore/src/Entity/Business.php b/hesabixCore/src/Entity/Business.php index 5fe3c15..18ddcae 100644 --- a/hesabixCore/src/Entity/Business.php +++ b/hesabixCore/src/Entity/Business.php @@ -193,6 +193,9 @@ class Business #[ORM\OneToMany(mappedBy: 'bid', targetEntity: ArchiveFile::class, orphanRemoval: true)] private Collection $archiveFiles; + #[ORM\OneToMany(mappedBy: 'bid', targetEntity: ArchiveOrders::class, orphanRemoval: true)] + private Collection $archiveOrders; + public function __construct() { $this->logs = new ArrayCollection(); @@ -215,6 +218,7 @@ class Business $this->storeroomTickets = new ArrayCollection(); $this->storeroomItems = new ArrayCollection(); $this->archiveFiles = new ArrayCollection(); + $this->archiveOrders = new ArrayCollection(); } public function getId(): ?int @@ -1253,4 +1257,34 @@ class Business return $this; } + + /** + * @return Collection + */ + public function getArchiveOrders(): Collection + { + return $this->archiveOrders; + } + + public function addArchiveOrder(ArchiveOrders $archiveOrder): static + { + if (!$this->archiveOrders->contains($archiveOrder)) { + $this->archiveOrders->add($archiveOrder); + $archiveOrder->setBid($this); + } + + return $this; + } + + public function removeArchiveOrder(ArchiveOrders $archiveOrder): static + { + if ($this->archiveOrders->removeElement($archiveOrder)) { + // set the owning side to null (unless already changed) + if ($archiveOrder->getBid() === $this) { + $archiveOrder->setBid(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/User.php b/hesabixCore/src/Entity/User.php index bc17615..5f684f1 100644 --- a/hesabixCore/src/Entity/User.php +++ b/hesabixCore/src/Entity/User.php @@ -95,6 +95,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\OneToMany(mappedBy: 'Submitter', targetEntity: ArchiveFile::class, orphanRemoval: true)] private Collection $archiveFiles; + #[ORM\OneToMany(mappedBy: 'submitter', targetEntity: ArchiveOrders::class, orphanRemoval: true)] + private Collection $archiveOrders; + public function __construct() { $this->userTokens = new ArrayCollection(); @@ -113,6 +116,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface $this->walletTransactions = new ArrayCollection(); $this->storeroomTickets = new ArrayCollection(); $this->archiveFiles = new ArrayCollection(); + $this->archiveOrders = new ArrayCollection(); } public function getId(): ?int @@ -736,4 +740,34 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface return $this; } + + /** + * @return Collection + */ + public function getArchiveOrders(): Collection + { + return $this->archiveOrders; + } + + public function addArchiveOrder(ArchiveOrders $archiveOrder): static + { + if (!$this->archiveOrders->contains($archiveOrder)) { + $this->archiveOrders->add($archiveOrder); + $archiveOrder->setSubmitter($this); + } + + return $this; + } + + public function removeArchiveOrder(ArchiveOrders $archiveOrder): static + { + if ($this->archiveOrders->removeElement($archiveOrder)) { + // set the owning side to null (unless already changed) + if ($archiveOrder->getSubmitter() === $this) { + $archiveOrder->setSubmitter(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Repository/ArchiveOrdersRepository.php b/hesabixCore/src/Repository/ArchiveOrdersRepository.php new file mode 100644 index 0000000..fff4e20 --- /dev/null +++ b/hesabixCore/src/Repository/ArchiveOrdersRepository.php @@ -0,0 +1,48 @@ + + * + * @method ArchiveOrders|null find($id, $lockMode = null, $lockVersion = null) + * @method ArchiveOrders|null findOneBy(array $criteria, array $orderBy = null) + * @method ArchiveOrders[] findAll() + * @method ArchiveOrders[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class ArchiveOrdersRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, ArchiveOrders::class); + } + +// /** +// * @return ArchiveOrders[] Returns an array of ArchiveOrders 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): ?ArchiveOrders +// { +// return $this->createQueryBuilder('a') +// ->andWhere('a.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +}