From 1804a01c2a1899aa929dffe7bdd0da6e2c8d7939 Mon Sep 17 00:00:00 2001 From: babak alizadeh Date: Tue, 4 Jun 2024 14:23:07 +0330 Subject: [PATCH] spme progress and bug fix in sell and some other plugins --- .../src/Controller/HesabdariController.php | 3 +- .../src/Controller/PersonsController.php | 82 +++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/hesabixCore/src/Controller/HesabdariController.php b/hesabixCore/src/Controller/HesabdariController.php index ab8091b..59975f8 100644 --- a/hesabixCore/src/Controller/HesabdariController.php +++ b/hesabixCore/src/Controller/HesabdariController.php @@ -17,6 +17,7 @@ use App\Entity\PlugNoghreOrder; use App\Entity\Salary; use App\Entity\StoreroomTicket; use App\Service\Access; +use App\Service\Explore; use App\Service\Jdate; use App\Service\JsonResp; use App\Service\Log; @@ -222,7 +223,7 @@ class HesabdariController extends AbstractController $mainRow = $entityManager->getRepository(HesabdariRow::class)->getNotEqual($item, 'person'); $temp['person'] = ''; if ($mainRow) - $temp['person'] = $mainRow->getPerson()->getNikename(); + $temp['person'] = Explore::ExplorePerson($mainRow->getPerson()); } //get status of doc diff --git a/hesabixCore/src/Controller/PersonsController.php b/hesabixCore/src/Controller/PersonsController.php index ed34b93..b23f445 100644 --- a/hesabixCore/src/Controller/PersonsController.php +++ b/hesabixCore/src/Controller/PersonsController.php @@ -723,6 +723,47 @@ class PersonsController extends AbstractController return $this->json(['id' => $pid]); } + #[Route('/api/person/receive/list/search', name: 'app_persons_receive_list_search')] + public function app_persons_receive_list_search(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('person_receive'); + if (!$acc) + throw $this->createAccessDeniedException(); + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + + $items = $entityManager->getRepository(HesabdariDoc::class)->findBy( + [ + 'bid' => $acc['bid'], + 'type' => 'person_receive', + 'year'=>$acc['year'] + ], + ['id' => 'DESC'] + ); + $res = []; + foreach($items as $item){ + $temp = [ + 'id'=>$item->getId(), + 'date'=>$item->getDate(), + 'code'=>$item->getCode(), + 'des'=>$item->getDes(), + 'amount'=>$item->getAmount() + ]; + $persons = []; + foreach($item->getHesabdariRows() as $row){ + if($row->getPerson()){ + $persons[] = Explore::ExplorePerson($row->getPerson()); + } + } + $temp['persons'] = $persons; + $res[] = $temp; + } + + return $this->json($res); + } + /** * @throws Exception */ @@ -799,6 +840,47 @@ class PersonsController extends AbstractController return $this->json(['id' => $pid]); } + #[Route('/api/person/send/list/search', name: 'app_persons_send_list_search')] + public function app_persons_send_list_search(Provider $provider, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('person_send'); + if (!$acc) + throw $this->createAccessDeniedException(); + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + + $items = $entityManager->getRepository(HesabdariDoc::class)->findBy( + [ + 'bid' => $acc['bid'], + 'type' => 'person_send', + 'year'=>$acc['year'] + ], + ['id' => 'DESC'] + ); + $res = []; + foreach($items as $item){ + $temp = [ + 'id'=>$item->getId(), + 'date'=>$item->getDate(), + 'code'=>$item->getCode(), + 'des'=>$item->getDes(), + 'amount'=>$item->getAmount() + ]; + $persons = []; + foreach($item->getHesabdariRows() as $row){ + if($row->getPerson()){ + $persons[] = Explore::ExplorePerson($row->getPerson()); + } + } + $temp['persons'] = $persons; + $res[] = $temp; + } + + return $this->json($res); + } + /** * @throws Exception */