diff --git a/hesabixCore/src/Controller/BusinessController.php b/hesabixCore/src/Controller/BusinessController.php index 9b8fc31..8b2e882 100644 --- a/hesabixCore/src/Controller/BusinessController.php +++ b/hesabixCore/src/Controller/BusinessController.php @@ -31,7 +31,7 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser; class BusinessController extends AbstractController { #[Route('/api/business/list', name: 'api_bussiness_list')] - public function api_bussiness_list(#[CurrentUser] ?User $user,EntityManagerInterface $entityManager): Response + public function api_bussiness_list(#[CurrentUser] ?User $user,EntityManagerInterface $entityManager,Provider $provider): Response { $buss = $entityManager->getRepository(Permission::class)->findBy(['user'=>$user]); $response = []; @@ -43,7 +43,6 @@ class BusinessController extends AbstractController $temp['legal_name'] = $bus->getBid()->getLegalName(); $response[] = $temp; } - return $this->json($response); } diff --git a/hesabixCore/src/Controller/Front/AppController.php b/hesabixCore/src/Controller/Front/AppController.php index 93a5372..66fac5c 100644 --- a/hesabixCore/src/Controller/Front/AppController.php +++ b/hesabixCore/src/Controller/Front/AppController.php @@ -253,55 +253,4 @@ class AppController extends AbstractController 'content'=>$content ]); } - - /** - * @Route("/app/support/list", name="app_front_support_list") - */ - public function app_front_support_list(EntityManagerInterface $entityManager): Response - { - return $this->render('/app/support/list.html.twig',[ - 'items'=>$entityManager->getRepository(Support::class)->findBy([ - 'main' => 0 - ],[ - 'id'=>'DESC' - ]) - ]); - } - - /** - * @Route("/app/support/view/{id}", name="app_front_support_view") - */ - public function app_front_support_view(string $id,SMS $SMS,Request $request,EntityManagerInterface $entityManager): Response - { - $item = $entityManager->getRepository(Support::class)->find($id); - if(!$item) $this->createNotFoundException(); - - $support = new Support(); - $form = $this->createForm(SupportType::class,$support,[]); - - $form->handleRequest($request); - if ($form->isSubmitted() && $form->isValid()) { - $support->setDateSubmit(time()); - $support->setTitle('0'); - $support->setState('0'); - $support->setMain($item->getId()); - $support->setSubmitter($this->getUser()); - $entityManager->persist($support); - $entityManager->flush(); - $item->setState('پاسخ داده شده'); - $entityManager->persist($support); - $entityManager->flush(); - //send sms to customer - if($item->getSubmitter()->getMobile()) - $SMS->send([$item->getId()],'162251',$item->getSubmitter()->getMobile()); - } - - return $this->render('/app/support/view.html.twig',[ - 'item'=>$item, - 'replays'=>$entityManager->getRepository(Support::class)->findBy([ - 'main'=>$item->getId() - ]), - 'form'=>$form->createView() - ]); - } } diff --git a/hesabixCore/src/Controller/Front/BlogController.php b/hesabixCore/src/Controller/Front/BlogController.php index 39589a7..a088304 100644 --- a/hesabixCore/src/Controller/Front/BlogController.php +++ b/hesabixCore/src/Controller/Front/BlogController.php @@ -37,7 +37,7 @@ class BlogController extends AbstractController public function general_blog_post(Request $request,EntityManagerInterface $entityManager, String $url): Response { $item = $entityManager->getRepository(BlogPost::class)->findOneBy(['url'=>$url]); - if(!$item) $this->createNotFoundException(); + if(!$item) throw $this->createNotFoundException(); $comment = new BlogComment(); $form = $this->createForm(CommentType::class,$comment); @@ -127,7 +127,7 @@ class BlogController extends AbstractController $item->setImg($newFilename); } $item->setDateSubmit(time()); - $url = str_replace(' ','_',$item->getTitle()); + $url = str_replace(' ','-',$item->getTitle()); $check = $entityManager->getRepository(BlogPost::class)->findOneBy(['url'=>$url]); $item->setUrl($url); if($check){ diff --git a/hesabixCore/src/Controller/Front/UiGeneralController.php b/hesabixCore/src/Controller/Front/UiGeneralController.php index 5ffe787..9eb7dc7 100644 --- a/hesabixCore/src/Controller/Front/UiGeneralController.php +++ b/hesabixCore/src/Controller/Front/UiGeneralController.php @@ -102,9 +102,12 @@ class UiGeneralController extends AbstractController #[Route('/sitemap.xml', name: 'general_sitemap')] public function general_sitemap(EntityManagerInterface $entityManager): Response { + $response = new Response('',200,['Content-Type'=>'text/xml']); return $this->render('general/sitemap.html.twig',[ - - ]); + 'timeNow'=>$dateTime = date('c', time()), + 'blogs'=>$entityManager->getRepository(BlogPost::class)->findAll(), + 'docs'=>$entityManager->getRepository(APIDocument::class)->findAll() + ],$response); } #[Route('/test', name: 'general_test')] public function general_test(Provider $provider,pdfMGR $pdfMGR,EntityManagerInterface $entityManager): Response diff --git a/hesabixCore/src/Controller/GeneralController.php b/hesabixCore/src/Controller/GeneralController.php index 3a6919c..5be2a3c 100644 --- a/hesabixCore/src/Controller/GeneralController.php +++ b/hesabixCore/src/Controller/GeneralController.php @@ -55,6 +55,12 @@ class GeneralController extends AbstractController { return $this->json($entityManager->getRepository(Statment::class)->findBy([],['id'=>'DESC'])); } + + #[Route('/api/general/get/time', name: 'general_get_time')] + public function general_get_time(Jdate $jdate): JsonResponse + { + return $this->json(['timeNow'=>$jdate->jdate('Y/n/d',time())]); + } #[Route('/front/print/{id}', name: 'app_front_print')] public function app_front_print(Provider $provider,EntityManagerInterface $entityManager,pdfMGR $pdfMGR,String $id) { diff --git a/hesabixCore/src/Controller/HesabdariController.php b/hesabixCore/src/Controller/HesabdariController.php index cc4e5a2..f50ee89 100644 --- a/hesabixCore/src/Controller/HesabdariController.php +++ b/hesabixCore/src/Controller/HesabdariController.php @@ -9,6 +9,7 @@ use App\Entity\HesabdariDoc; use App\Entity\HesabdariRow; use App\Entity\HesabdariTable; use App\Entity\Money; +use App\Entity\PayInfoTemp; use App\Entity\Person; use App\Entity\PlugNoghreOrder; use App\Entity\Salary; @@ -386,7 +387,7 @@ class HesabdariController extends AbstractController } #[Route('/api/accounting/remove', name: 'app_accounting_remove_doc')] - public function app_accounting_remove_doc(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse + public function app_accounting_remove_doc(Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse { $params = []; if ($content = $request->getContent()) { @@ -395,7 +396,8 @@ class HesabdariController extends AbstractController if(! array_key_exists('code',$params)) $this->createNotFoundException(); $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ - 'code'=>$params['code'] + 'code'=>$params['code'], + 'bid'=>$request->headers->get('activeBid') ]); if(!$doc) throw $this->createNotFoundException(); $roll = ''; @@ -416,6 +418,15 @@ class HesabdariController extends AbstractController if($order) $entityManager->remove($order); } + //check wallet online transactions + $tempPays = $entityManager->getRepository(PayInfoTemp::class)->findOneBy(['doc'=>$doc]); + if($tempPays){ + //doc has transaction + return $this->json([ + 'result'=>2, + 'message'=>'سند به دلیل داشتن تراکنش پرداخت آنلاین قابل حذف نیست.' + ]); + } foreach ($rows as $row) $entityManager->remove($row); foreach ($doc->getRelatedDocs() as $relatedDoc){ @@ -430,7 +441,6 @@ class HesabdariController extends AbstractController $entityManager->remove($doc); $entityManager->flush(); $log->insert('حسابداری','سند حسابداری شماره ' . $doc->getCode() . ' حذف شد.',$this->getUser(),$request->headers->get('activeBid')); - return $this->json(['result'=>1]); } diff --git a/hesabixCore/src/Controller/StoreroomController.php b/hesabixCore/src/Controller/StoreroomController.php index a55cdb2..80aa9f9 100644 --- a/hesabixCore/src/Controller/StoreroomController.php +++ b/hesabixCore/src/Controller/StoreroomController.php @@ -2,11 +2,18 @@ namespace App\Controller; +use App\Entity\HesabdariDoc; +use App\Entity\HesabdariRow; +use App\Entity\Person; use App\Entity\Storeroom; +use App\Entity\StoreroomItem; +use App\Entity\StoreroomTicket; +use App\Entity\StoreroomTransferType; use App\Service\Access; use App\Service\Log; use App\Service\Provider; use Doctrine\ORM\EntityManagerInterface; +use ReflectionException; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; @@ -76,7 +83,7 @@ class StoreroomController extends AbstractController } /** - * @throws \ReflectionException + * @throws ReflectionException */ #[Route('/api/storeroom/info/{code}', name: 'app_storeroom_info')] public function app_storeroom_info($code,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse @@ -91,4 +98,206 @@ class StoreroomController extends AbstractController return $this->json($provider->Entity2Array($data,0)); } + #[Route('/api/storeroom/docs/get', name: 'app_storeroom_get_docs')] + public function app_storeroom_get_docs(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('store'); + if(!$acc) + throw $this->createAccessDeniedException(); + $buys = $entityManager->getRepository(HesabdariDoc::class)->findBy([ + 'bid'=>$acc['bid'], + 'type'=>'buy' + ]); + foreach ($buys as $buy) + $buy->setDes('فاکتور خرید شماره # ' . $buy->getCode()); + $sells = $entityManager->getRepository(HesabdariDoc::class)->findBy([ + 'bid'=>$acc['bid'], + 'type'=>'sell' + ]); + foreach ($sells as $sell) + $sell->setDes('فاکتور فروش شماره # ' . $sell->getCode()); + return $this->json([ + 'buys'=> $provider->ArrayEntity2Array($buys,0), + 'sells'=> $provider->ArrayEntity2Array($sells,0) + ]); + } + + /** + * @throws ReflectionException + */ + #[Route('/api/storeroom/doc/get/info/{id}', name: 'app_storeroom_get_doc_info')] + public function app_storeroom_get_doc_info(String $id,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('store'); + if(!$acc) + throw $this->createAccessDeniedException(); + $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ + 'bid'=>$acc['bid'], + 'code'=>$id + ]); + if(!$doc) + throw $this->createNotFoundException('سند یافت نشد.'); + if($doc->getType() == 'buy') + $doc->setDes('فاکتور خرید شماره #' . $doc->getCode()); + elseif($doc->getType() == 'sell') + $doc->setDes('فاکتور فروش شماره #' . $doc->getCode()); + + //find person + $rows = $entityManager->getRepository(HesabdariRow::class)->findBy([ + 'doc'=>$doc + ]); + $person = null; + $commodities = []; + foreach ($rows as $row){ + if($row->getPerson()){ + $person = $row->getPerson(); + break; + } + elseif ($row->getCommodity()){ + if(!$row->getCommodity()->isKhadamat()) + $commodities[] = $row; + } + } + foreach ($commodities as $commodity){ + $commodity->getCommodity()->setUnit($commodity->getCommodity()->getUnit()->getName()); + } + $res = $provider->Entity2Array($doc,0); + $res['person'] = $provider->Entity2Array($person,0); + $res['person']['des'] =' # ' . $person->getCode() . ' ' . $person->getNikename(); + $res['commodities'] = $provider->ArrayEntity2Array($commodities,1,['doc','bid','year']); + return $this->json($res); + } + + #[Route('/api/storeroom/transfertype/list', name: 'app_storeroom_get_transfertype_list')] + public function app_storeroom_get_transfertype_list(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('store'); + if(!$acc) + throw $this->createAccessDeniedException(); + return $this->json($entityManager->getRepository(StoreroomTransferType::class)->findAll()); + } + + #[Route('/api/storeroom/ticket/insert', name: 'app_storeroom_ticket_insert')] + public function app_storeroom_ticket_insert(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('store'); + if(!$acc) + throw $this->createAccessDeniedException(); + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + //check parameters exist + if((!array_key_exists('ticket',$params)) || (!array_key_exists('items',$params)) || (!array_key_exists('doc',$params))) + $this->createNotFoundException(); + //going to save + $doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([ + 'id'=>$params['doc']['id'], + 'bid'=>$acc['bid'] + ]); + if(!$doc) + throw $this->createNotFoundException('سند یافت نشد'); + if($doc->getBid()->getId() != $acc['bid']->getId()) + throw $this->createAccessDeniedException('دسترسی به این سند را ندارید.'); + //find transfer type + if(!array_key_exists('transferType',$params['ticket'])) + throw $this->createNotFoundException('نوع انتقال یافت نشد'); + $transferType = $entityManager->getRepository(StoreroomTransferType::class)->find($params['ticket']['transferType']['id']); + if(!$transferType) + throw $this->createNotFoundException('نوع انتقال یافت نشد'); + + //find storeroom + if(!array_key_exists('store',$params['ticket'])) + throw $this->createNotFoundException('انبار یافت نشد'); + $storeroom = $entityManager->getRepository(Storeroom::class)->find($params['ticket']['store']['id']); + if(!$storeroom) + throw $this->createNotFoundException('انبار یافت نشد'); + elseif ($storeroom->getBid()->getId() != $acc['bid']->getId()) + throw $this->createAccessDeniedException('دسترسی به این انبار ممکن نیست!'); + //find person + if(!array_key_exists('person',$params['ticket'])) + throw $this->createNotFoundException('طرف حساب یافت نشد'); + $person = $entityManager->getRepository(Person::class)->find($params['ticket']['person']['id']); + if(!$person) + throw $this->createNotFoundException('طرف حساب یافت نشد'); + elseif ($person->getBid()->getId() != $acc['bid']->getId()) + throw $this->createAccessDeniedException('دسترسی به این طرف حساب ممکن نیست!'); + + $ticket = new StoreroomTicket(); + $ticket->setSubmitter($this->getUser()); + $ticket->setDate($params['ticket']['date']); + $ticket->setBid($acc['bid']); + $ticket->setDateSubmit(time()); + $ticket->setDoc($doc); + $ticket->setTransfer($params['ticket']['transfer']); + $ticket->setYear($acc['year']); + $ticket->setCode($provider->getAccountingCode($acc['bid'],'storeroom')); + $ticket->setReceiver($params['ticket']['receiver']); + $ticket->setTransferType($transferType); + $ticket->setReferral($params['ticket']['referral']); + $ticket->setStoreroom($storeroom); + $ticket->setPerson($person); + $ticket->setType($params['ticket']['type']); + $ticket->setTypeString($params['ticket']['typeString']); + $ticket->setDes($params['ticket']['des']); + $entityManager->persist($ticket); + //$entityManager->flush(); + + //going to save rows + $docRows = $entityManager->getRepository(HesabdariRow::class)->findBy([ + 'doc'=>$doc + ]); + foreach ($params['items'] as $item){ + $row = $entityManager->getRepository(HesabdariRow::class)->findOneBy([ + 'bid'=>$acc['bid'], + 'doc'=>$doc, + 'id'=>$item['id'], + ]); + if(!$row) + throw $this->createNotFoundException('کالا یافت نشد!'); + if(!$row->getCommodity()) + throw $this->createNotFoundException('کالا یافت نشد!'); + //check row count not upper ticket count + if($row->getCommdityCount() < $item['ticketCount']) + throw $this->createNotFoundException('تعداد کالای اضافه شده بیشتر از تعداد کالا در فاکتور است.'); + $ticketItem = new StoreroomItem(); + $ticketItem->setBid($acc['bid']); + $ticketItem->setStoreroom($storeroom); + $ticketItem->setTicket($ticket); + $ticketItem->setCount($item['ticketCount']); + $ticketItem->setReferal($item['referral']); + $ticketItem->setDes($item['des']); + $ticketItem->setCommodity($row->getCommodity()); + $ticketItem->setType($item['type']); + $entityManager->persist($ticketItem); + } + $entityManager->flush(); + //save logs + $log->insert('انبارداری','حواله انبار با شماره '. $ticket->getCode() . ' اضافه / ویرایش شد.',$this->getUser(),$acc['bid']); + return $this->json([ + 'result'=>0 + ]); + } + + #[Route('/api/storeroom/tickets/list/{type}', name: 'app_storeroom_tickets_list')] + public function app_storeroom_tickets_list(String $type,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('store'); + if(!$acc) + throw $this->createAccessDeniedException(); + $tickets = $entityManager->getRepository(StoreroomTicket::class)->findBy([ + 'bid'=>$acc['bid'], + 'year'=>$acc['year'], + 'type'=>$type + ]); + return $this->json($provider->ArrayEntity2ArrayJustIncludes($tickets,[ + 'getDes', + 'getCode', + 'getDate', + 'getPerson', + 'getNikename', + 'getDoc', + 'getTypeString' + ],1)); + } } diff --git a/hesabixCore/src/Controller/SupportController.php b/hesabixCore/src/Controller/SupportController.php index f781cab..6718700 100644 --- a/hesabixCore/src/Controller/SupportController.php +++ b/hesabixCore/src/Controller/SupportController.php @@ -25,7 +25,62 @@ class SupportController extends AbstractController } return $this->json($provider->ArrayEntity2Array($items,1)); } + #[Route('/api/admin/support/view/{id}', name: 'app_admin_support_view')] + public function app_admin_support_view(Jdate $jdate, EntityManagerInterface $entityManager,string $id = ''): JsonResponse + { + $item = $entityManager->getRepository(Support::class)->find($id); + if(!$item) throw $this->createNotFoundException(); + $replays = $entityManager->getRepository(Support::class)->findBy(['main'=>$item->getId()]); + foreach ($replays as $replay){ + $replay->setDateSubmit($jdate->jdate('Y/n/d H:i',$replay->getDateSubmit())); + $replay->setTitle($replay->getSubmitter()->getFullname()); + if($replay->getSubmitter() == $this->getUser()) + $replay->setState(1); + else + $replay->setState(0); + } + $item->setDateSubmit($jdate->jdate('Y/n/d H:i',$item->getDateSubmit())); + return $this->json([ + 'item'=> $item, + 'replays'=> $replays + ]); + } + #[Route('/api/admin/support/mod/{id}', name: 'app_admin_support_mod')] + public function app_admin_support_mod(SMS $SMS,Request $request, EntityManagerInterface $entityManager,string $id = ''): JsonResponse + { + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + $item = $entityManager->getRepository(Support::class)->find($id); + if(!$item) $this->createNotFoundException(); + if(array_key_exists('body',$params)){ + $support = new Support(); + $support->setDateSubmit(time()); + $support->setTitle('0'); + $support->setBody($params['body']); + $support->setState('0'); + $support->setMain($item->getId()); + $support->setSubmitter($this->getUser()); + $entityManager->persist($support); + $entityManager->flush(); + $item->setState('پاسخ داده شده'); + $entityManager->persist($support); + $entityManager->flush(); + //send sms to customer + if($item->getSubmitter()->getMobile()) + $SMS->send([$item->getId()],'162251',$item->getSubmitter()->getMobile()); + return $this->json([ + 'error'=> 0, + 'message'=> 'successful' + ]); + } + return $this->json([ + 'error'=> 999, + 'message'=> 'تمام موارد لازم را وارد کنید.' + ]); + } #[Route('/api/support/list', name: 'app_support_list')] public function app_support_list(Jdate $jdate,EntityManagerInterface $entityManager): JsonResponse { diff --git a/hesabixCore/src/Entity/APIDocument.php b/hesabixCore/src/Entity/APIDocument.php index 75dc7b4..1d7da49 100644 --- a/hesabixCore/src/Entity/APIDocument.php +++ b/hesabixCore/src/Entity/APIDocument.php @@ -20,6 +20,9 @@ class APIDocument #[ORM\Column(type: Types::TEXT)] private ?string $body = null; + #[ORM\Column(length: 255, nullable: true)] + private ?string $dateSubmit = null; + public function getId(): ?int { return $this->id; @@ -48,4 +51,16 @@ class APIDocument return $this; } + + public function getDateSubmit(): ?string + { + return $this->dateSubmit; + } + + public function setDateSubmit(?string $dateSubmit): static + { + $this->dateSubmit = $dateSubmit; + + return $this; + } } diff --git a/hesabixCore/src/Entity/Business.php b/hesabixCore/src/Entity/Business.php index f6643e0..686d49c 100644 --- a/hesabixCore/src/Entity/Business.php +++ b/hesabixCore/src/Entity/Business.php @@ -176,6 +176,17 @@ class Business #[Ignore] private ?bool $walletEnable = null; + #[ORM\OneToMany(mappedBy: 'bid', targetEntity: StoreroomTicket::class, orphanRemoval: true)] + #[Ignore] + private Collection $storeroomTickets; + + #[ORM\OneToMany(mappedBy: 'bid', targetEntity: StoreroomItem::class, orphanRemoval: true)] + #[Ignore] + private Collection $storeroomItems; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $storeroomCode = '1000'; + public function __construct() { $this->logs = new ArrayCollection(); @@ -195,6 +206,8 @@ class Business $this->commodityDrops = new ArrayCollection(); $this->storerooms = new ArrayCollection(); $this->walletTransactions = new ArrayCollection(); + $this->storeroomTickets = new ArrayCollection(); + $this->storeroomItems = new ArrayCollection(); } public function getId(): ?int @@ -1119,4 +1132,76 @@ class Business return $this; } + + /** + * @return Collection + */ + public function getStoreroomTickets(): Collection + { + return $this->storeroomTickets; + } + + public function addStoreroomTicket(StoreroomTicket $storeroomTicket): static + { + if (!$this->storeroomTickets->contains($storeroomTicket)) { + $this->storeroomTickets->add($storeroomTicket); + $storeroomTicket->setBid($this); + } + + return $this; + } + + public function removeStoreroomTicket(StoreroomTicket $storeroomTicket): static + { + if ($this->storeroomTickets->removeElement($storeroomTicket)) { + // set the owning side to null (unless already changed) + if ($storeroomTicket->getBid() === $this) { + $storeroomTicket->setBid(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getStoreroomItems(): Collection + { + return $this->storeroomItems; + } + + public function addStoreroomItem(StoreroomItem $storeroomItem): static + { + if (!$this->storeroomItems->contains($storeroomItem)) { + $this->storeroomItems->add($storeroomItem); + $storeroomItem->setBid($this); + } + + return $this; + } + + public function removeStoreroomItem(StoreroomItem $storeroomItem): static + { + if ($this->storeroomItems->removeElement($storeroomItem)) { + // set the owning side to null (unless already changed) + if ($storeroomItem->getBid() === $this) { + $storeroomItem->setBid(null); + } + } + + return $this; + } + + public function getStoreroomCode(): ?string + { + return $this->storeroomCode; + } + + public function setStoreroomCode(?string $storeroomCode): static + { + $this->storeroomCode = $storeroomCode; + + return $this; + } } diff --git a/hesabixCore/src/Entity/Commodity.php b/hesabixCore/src/Entity/Commodity.php index 897970c..fb422d7 100644 --- a/hesabixCore/src/Entity/Commodity.php +++ b/hesabixCore/src/Entity/Commodity.php @@ -54,12 +54,16 @@ class Commodity #[ORM\ManyToOne(inversedBy: 'commodities')] private ?CommodityCat $cat = null; + #[ORM\OneToMany(mappedBy: 'commodity', targetEntity: StoreroomItem::class, orphanRemoval: true)] + private Collection $storeroomItems; + public function __construct() { $this->setPriceBuy(0); $this->setPriceSell(0); $this->hesabdariRows = new ArrayCollection(); $this->commodityDropLinks = new ArrayCollection(); + $this->storeroomItems = new ArrayCollection(); } public function getId(): ?int @@ -234,4 +238,34 @@ class Commodity return $this; } + + /** + * @return Collection + */ + public function getStoreroomItems(): Collection + { + return $this->storeroomItems; + } + + public function addStoreroomItem(StoreroomItem $storeroomItem): static + { + if (!$this->storeroomItems->contains($storeroomItem)) { + $this->storeroomItems->add($storeroomItem); + $storeroomItem->setCommodity($this); + } + + return $this; + } + + public function removeStoreroomItem(StoreroomItem $storeroomItem): static + { + if ($this->storeroomItems->removeElement($storeroomItem)) { + // set the owning side to null (unless already changed) + if ($storeroomItem->getCommodity() === $this) { + $storeroomItem->setCommodity(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/HesabdariDoc.php b/hesabixCore/src/Entity/HesabdariDoc.php index 4f7c2ec..84abd30 100644 --- a/hesabixCore/src/Entity/HesabdariDoc.php +++ b/hesabixCore/src/Entity/HesabdariDoc.php @@ -85,11 +85,15 @@ class HesabdariDoc #[ORM\Column(length: 255, nullable: true)] private ?string $status = null; + #[ORM\OneToMany(mappedBy: 'doc', targetEntity: StoreroomTicket::class)] + private Collection $storeroomTickets; + public function __construct() { $this->hesabdariRows = new ArrayCollection(); $this->plugNoghreOrders = new ArrayCollection(); $this->relatedDocs = new ArrayCollection(); + $this->storeroomTickets = new ArrayCollection(); } public function getId(): ?int @@ -372,4 +376,34 @@ class HesabdariDoc return $this; } + + /** + * @return Collection + */ + public function getStoreroomTickets(): Collection + { + return $this->storeroomTickets; + } + + public function addStoreroomTicket(StoreroomTicket $storeroomTicket): static + { + if (!$this->storeroomTickets->contains($storeroomTicket)) { + $this->storeroomTickets->add($storeroomTicket); + $storeroomTicket->setDoc($this); + } + + return $this; + } + + public function removeStoreroomTicket(StoreroomTicket $storeroomTicket): static + { + if ($this->storeroomTickets->removeElement($storeroomTicket)) { + // set the owning side to null (unless already changed) + if ($storeroomTicket->getDoc() === $this) { + $storeroomTicket->setDoc(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/Person.php b/hesabixCore/src/Entity/Person.php index dce64f5..d9d76ae 100644 --- a/hesabixCore/src/Entity/Person.php +++ b/hesabixCore/src/Entity/Person.php @@ -103,11 +103,16 @@ class Person #[ORM\Column(length: 255, nullable: true)] private ?string $fax = null; + #[Ignore] + #[ORM\OneToMany(mappedBy: 'Person', targetEntity: StoreroomTicket::class)] + private Collection $storeroomTickets; + public function __construct() { $this->hesabdariRows = new ArrayCollection(); $this->plugNoghreOrders = new ArrayCollection(); $this->ordersFromCustomer = new ArrayCollection(); + $this->storeroomTickets = new ArrayCollection(); } public function getId(): ?int @@ -492,4 +497,34 @@ class Person return $this; } + + /** + * @return Collection + */ + public function getStoreroomTickets(): Collection + { + return $this->storeroomTickets; + } + + public function addStoreroomTicket(StoreroomTicket $storeroomTicket): static + { + if (!$this->storeroomTickets->contains($storeroomTicket)) { + $this->storeroomTickets->add($storeroomTicket); + $storeroomTicket->setPerson($this); + } + + return $this; + } + + public function removeStoreroomTicket(StoreroomTicket $storeroomTicket): static + { + if ($this->storeroomTickets->removeElement($storeroomTicket)) { + // set the owning side to null (unless already changed) + if ($storeroomTicket->getPerson() === $this) { + $storeroomTicket->setPerson(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/Storeroom.php b/hesabixCore/src/Entity/Storeroom.php index 7609f1a..2691012 100644 --- a/hesabixCore/src/Entity/Storeroom.php +++ b/hesabixCore/src/Entity/Storeroom.php @@ -3,6 +3,8 @@ namespace App\Entity; use App\Repository\StoreroomRepository; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: StoreroomRepository::class)] @@ -32,6 +34,18 @@ class Storeroom #[ORM\Column(nullable: true)] private ?bool $active = null; + #[ORM\OneToMany(mappedBy: 'Storeroom', targetEntity: StoreroomItem::class, orphanRemoval: true)] + private Collection $storeroomItems; + + #[ORM\OneToMany(mappedBy: 'storeroom', targetEntity: StoreroomTicket::class, orphanRemoval: true)] + private Collection $storeroomTickets; + + public function __construct() + { + $this->storeroomItems = new ArrayCollection(); + $this->storeroomTickets = new ArrayCollection(); + } + public function getId(): ?int { return $this->id; @@ -108,4 +122,64 @@ class Storeroom return $this; } + + /** + * @return Collection + */ + public function getStoreroomItems(): Collection + { + return $this->storeroomItems; + } + + public function addStoreroomItem(StoreroomItem $storeroomItem): static + { + if (!$this->storeroomItems->contains($storeroomItem)) { + $this->storeroomItems->add($storeroomItem); + $storeroomItem->setStoreroom($this); + } + + return $this; + } + + public function removeStoreroomItem(StoreroomItem $storeroomItem): static + { + if ($this->storeroomItems->removeElement($storeroomItem)) { + // set the owning side to null (unless already changed) + if ($storeroomItem->getStoreroom() === $this) { + $storeroomItem->setStoreroom(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getStoreroomTickets(): Collection + { + return $this->storeroomTickets; + } + + public function addStoreroomTicket(StoreroomTicket $storeroomTicket): static + { + if (!$this->storeroomTickets->contains($storeroomTicket)) { + $this->storeroomTickets->add($storeroomTicket); + $storeroomTicket->setStoreroom($this); + } + + return $this; + } + + public function removeStoreroomTicket(StoreroomTicket $storeroomTicket): static + { + if ($this->storeroomTickets->removeElement($storeroomTicket)) { + // set the owning side to null (unless already changed) + if ($storeroomTicket->getStoreroom() === $this) { + $storeroomTicket->setStoreroom(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/StoreroomItem.php b/hesabixCore/src/Entity/StoreroomItem.php new file mode 100644 index 0000000..d1cf71f --- /dev/null +++ b/hesabixCore/src/Entity/StoreroomItem.php @@ -0,0 +1,144 @@ +id; + } + + public function getTicket(): ?StoreroomTicket + { + return $this->ticket; + } + + public function setTicket(?StoreroomTicket $ticket): static + { + $this->ticket = $ticket; + + return $this; + } + + public function getCommodity(): ?Commodity + { + return $this->commodity; + } + + public function setCommodity(?Commodity $commodity): static + { + $this->commodity = $commodity; + + return $this; + } + + public function getType(): ?string + { + return $this->type; + } + + public function setType(string $type): static + { + $this->type = $type; + + return $this; + } + + public function getCount(): ?string + { + return $this->count; + } + + public function setCount(string $count): static + { + $this->count = $count; + + return $this; + } + + public function getDes(): ?string + { + return $this->des; + } + + public function setDes(?string $des): static + { + $this->des = $des; + + return $this; + } + + public function getReferal(): ?string + { + return $this->referal; + } + + public function setReferal(?string $referal): static + { + $this->referal = $referal; + + return $this; + } + + public function getBid(): ?Business + { + return $this->bid; + } + + public function setBid(?Business $bid): static + { + $this->bid = $bid; + + return $this; + } + + public function getStoreroom(): ?Storeroom + { + return $this->Storeroom; + } + + public function setStoreroom(?Storeroom $Storeroom): static + { + $this->Storeroom = $Storeroom; + + return $this; + } +} diff --git a/hesabixCore/src/Entity/StoreroomTicket.php b/hesabixCore/src/Entity/StoreroomTicket.php new file mode 100644 index 0000000..7e361a1 --- /dev/null +++ b/hesabixCore/src/Entity/StoreroomTicket.php @@ -0,0 +1,305 @@ +storeroomItems = new ArrayCollection(); + } + + public function getId(): ?int + { + return $this->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 getDate(): ?string + { + return $this->date; + } + + public function setDate(string $date): static + { + $this->date = $date; + + return $this; + } + + public function getDateSubmit(): ?string + { + return $this->dateSubmit; + } + + public function setDateSubmit(string $dateSubmit): static + { + $this->dateSubmit = $dateSubmit; + + return $this; + } + + public function getTransfer(): ?string + { + return $this->transfer; + } + + public function setTransfer(?string $transfer): static + { + $this->transfer = $transfer; + + return $this; + } + + public function getReceiver(): ?string + { + return $this->receiver; + } + + public function setReceiver(?string $receiver): static + { + $this->receiver = $receiver; + + return $this; + } + + public function getCode(): ?string + { + return $this->code; + } + + public function setCode(string $code): static + { + $this->code = $code; + + return $this; + } + + public function getType(): ?string + { + return $this->type; + } + + public function setType(string $type): static + { + $this->type = $type; + + return $this; + } + + public function getPerson(): ?Person + { + return $this->Person; + } + + public function setPerson(?Person $Person): static + { + $this->Person = $Person; + + return $this; + } + + public function getDoc(): ?HesabdariDoc + { + return $this->doc; + } + + public function setDoc(?HesabdariDoc $doc): static + { + $this->doc = $doc; + + return $this; + } + + public function getYear(): ?Year + { + return $this->year; + } + + public function setYear(?Year $year): static + { + $this->year = $year; + + return $this; + } + + /** + * @return Collection + */ + public function getStoreroomItems(): Collection + { + return $this->storeroomItems; + } + + public function addStoreroomItem(StoreroomItem $storeroomItem): static + { + if (!$this->storeroomItems->contains($storeroomItem)) { + $this->storeroomItems->add($storeroomItem); + $storeroomItem->setTicket($this); + } + + return $this; + } + + public function removeStoreroomItem(StoreroomItem $storeroomItem): static + { + if ($this->storeroomItems->removeElement($storeroomItem)) { + // set the owning side to null (unless already changed) + if ($storeroomItem->getTicket() === $this) { + $storeroomItem->setTicket(null); + } + } + + return $this; + } + + public function getStoreroom(): ?Storeroom + { + return $this->storeroom; + } + + public function setStoreroom(?Storeroom $storeroom): static + { + $this->storeroom = $storeroom; + + return $this; + } + + public function getTransferType(): ?StoreroomTransferType + { + return $this->transferType; + } + + public function setTransferType(?StoreroomTransferType $transferType): static + { + $this->transferType = $transferType; + + return $this; + } + + public function getReferral(): ?string + { + return $this->referral; + } + + public function setReferral(?string $referral): static + { + $this->referral = $referral; + + return $this; + } + + public function getTypeString(): ?string + { + return $this->typeString; + } + + public function setTypeString(string $typeString): static + { + $this->typeString = $typeString; + + return $this; + } + + public function getDes(): ?string + { + return $this->des; + } + + public function setDes(?string $des): static + { + $this->des = $des; + + return $this; + } +} diff --git a/hesabixCore/src/Entity/StoreroomTransferType.php b/hesabixCore/src/Entity/StoreroomTransferType.php new file mode 100644 index 0000000..6a608f4 --- /dev/null +++ b/hesabixCore/src/Entity/StoreroomTransferType.php @@ -0,0 +1,35 @@ +id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } +} diff --git a/hesabixCore/src/Entity/User.php b/hesabixCore/src/Entity/User.php index 9e85624..5b51cb3 100644 --- a/hesabixCore/src/Entity/User.php +++ b/hesabixCore/src/Entity/User.php @@ -89,6 +89,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\OneToMany(mappedBy: 'submitter', targetEntity: WalletTransaction::class)] private Collection $walletTransactions; + #[ORM\OneToMany(mappedBy: 'submitter', targetEntity: StoreroomTicket::class, orphanRemoval: true)] + private Collection $storeroomTickets; + public function __construct() { $this->userTokens = new ArrayCollection(); @@ -105,6 +108,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface $this->emailHistories = new ArrayCollection(); $this->sMSPays = new ArrayCollection(); $this->walletTransactions = new ArrayCollection(); + $this->storeroomTickets = new ArrayCollection(); } public function getId(): ?int @@ -668,4 +672,34 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface return $this; } + + /** + * @return Collection + */ + public function getStoreroomTickets(): Collection + { + return $this->storeroomTickets; + } + + public function addStoreroomTicket(StoreroomTicket $storeroomTicket): static + { + if (!$this->storeroomTickets->contains($storeroomTicket)) { + $this->storeroomTickets->add($storeroomTicket); + $storeroomTicket->setSubmitter($this); + } + + return $this; + } + + public function removeStoreroomTicket(StoreroomTicket $storeroomTicket): static + { + if ($this->storeroomTickets->removeElement($storeroomTicket)) { + // set the owning side to null (unless already changed) + if ($storeroomTicket->getSubmitter() === $this) { + $storeroomTicket->setSubmitter(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/Year.php b/hesabixCore/src/Entity/Year.php index bc6a181..0d5d10a 100644 --- a/hesabixCore/src/Entity/Year.php +++ b/hesabixCore/src/Entity/Year.php @@ -44,10 +44,15 @@ class Year #[Ignore] private Collection $hesabdariRows; + #[ORM\OneToMany(mappedBy: 'year', targetEntity: StoreroomTicket::class, orphanRemoval: true)] + #[Ignore] + private Collection $storeroomTickets; + public function __construct() { $this->hesabdariDocs = new ArrayCollection(); $this->hesabdariRows = new ArrayCollection(); + $this->storeroomTickets = new ArrayCollection(); } public function getId(): ?int @@ -186,4 +191,34 @@ class Year return $this; } + + /** + * @return Collection + */ + public function getStoreroomTickets(): Collection + { + return $this->storeroomTickets; + } + + public function addStoreroomTicket(StoreroomTicket $storeroomTicket): static + { + if (!$this->storeroomTickets->contains($storeroomTicket)) { + $this->storeroomTickets->add($storeroomTicket); + $storeroomTicket->setYear($this); + } + + return $this; + } + + public function removeStoreroomTicket(StoreroomTicket $storeroomTicket): static + { + if ($this->storeroomTickets->removeElement($storeroomTicket)) { + // set the owning side to null (unless already changed) + if ($storeroomTicket->getYear() === $this) { + $storeroomTicket->setYear(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Repository/StoreroomItemRepository.php b/hesabixCore/src/Repository/StoreroomItemRepository.php new file mode 100644 index 0000000..6c6a7d5 --- /dev/null +++ b/hesabixCore/src/Repository/StoreroomItemRepository.php @@ -0,0 +1,48 @@ + + * + * @method StoreroomItem|null find($id, $lockMode = null, $lockVersion = null) + * @method StoreroomItem|null findOneBy(array $criteria, array $orderBy = null) + * @method StoreroomItem[] findAll() + * @method StoreroomItem[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class StoreroomItemRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, StoreroomItem::class); + } + +// /** +// * @return StoreroomItem[] Returns an array of StoreroomItem objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('s') +// ->andWhere('s.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('s.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?StoreroomItem +// { +// return $this->createQueryBuilder('s') +// ->andWhere('s.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/hesabixCore/src/Repository/StoreroomTicketRepository.php b/hesabixCore/src/Repository/StoreroomTicketRepository.php new file mode 100644 index 0000000..7b5867b --- /dev/null +++ b/hesabixCore/src/Repository/StoreroomTicketRepository.php @@ -0,0 +1,48 @@ + + * + * @method StoreroomTicket|null find($id, $lockMode = null, $lockVersion = null) + * @method StoreroomTicket|null findOneBy(array $criteria, array $orderBy = null) + * @method StoreroomTicket[] findAll() + * @method StoreroomTicket[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class StoreroomTicketRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, StoreroomTicket::class); + } + +// /** +// * @return StoreroomTicket[] Returns an array of StoreroomTicket objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('s') +// ->andWhere('s.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('s.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?StoreroomTicket +// { +// return $this->createQueryBuilder('s') +// ->andWhere('s.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/hesabixCore/src/Repository/StoreroomTransferTypeRepository.php b/hesabixCore/src/Repository/StoreroomTransferTypeRepository.php new file mode 100644 index 0000000..93bfd4b --- /dev/null +++ b/hesabixCore/src/Repository/StoreroomTransferTypeRepository.php @@ -0,0 +1,48 @@ + + * + * @method StoreroomTransferType|null find($id, $lockMode = null, $lockVersion = null) + * @method StoreroomTransferType|null findOneBy(array $criteria, array $orderBy = null) + * @method StoreroomTransferType[] findAll() + * @method StoreroomTransferType[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class StoreroomTransferTypeRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, StoreroomTransferType::class); + } + +// /** +// * @return StoreroomTransferType[] Returns an array of StoreroomTransferType objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('s') +// ->andWhere('s.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('s.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?StoreroomTransferType +// { +// return $this->createQueryBuilder('s') +// ->andWhere('s.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/hesabixCore/src/Service/Provider.php b/hesabixCore/src/Service/Provider.php index ec4ed37..24aec1c 100644 --- a/hesabixCore/src/Service/Provider.php +++ b/hesabixCore/src/Service/Provider.php @@ -8,7 +8,10 @@ use App\Entity\PrinterQueue; use App\Entity\User; use Doctrine\ORM\EntityManagerInterface; use PhpOffice\PhpSpreadsheet\Writer\Exception; +use ReflectionClass; +use ReflectionException; use ReflectionFunction; +use ReflectionMethod; use Symfony\Component\HttpFoundation\Request; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; @@ -88,7 +91,7 @@ class Provider } /** - * @throws \ReflectionException + * @throws ReflectionException */ public function Entity2Array($entity, int $deep = 1, array $ignores = []): null|array{ if(is_null($entity)) return []; @@ -104,14 +107,13 @@ class Provider $getMethods[] = trim(trim($method)); } } - //var_dump($getMethods); foreach ($getMethods as $method){ if(!is_int(array_search(lcfirst(trim(str_replace(['get','is'], '', $method))), $ignores))) { if (method_exists($entity, $method)) { $method = trim(trim($method)); $canProced = true; $reflection = new \ReflectionMethod($entity, $method); - if ($reflection->isPublic() && !str_starts_with('\\0', $method)) { + if ($reflection->isPublic() && $method != 'get' && !str_starts_with('\\0', $method)) { $value = $entity->$method(); } else $canProced = false; @@ -120,7 +122,7 @@ class Provider $result[lcfirst(str_replace(['get','is'], '', $method))] = $value; } else { if ($deep != 0) { - $result[lcfirst(str_replace(['get','is'], '', $method))] = $this->Entity2Array($value, $deep - 1); + $result[lcfirst(str_replace(['get','is'], '', $method))] = $this->Entity2Array($value, $deep - 1,$ignores); } } } @@ -176,4 +178,38 @@ class Provider private function RandomString($length = 32) { return substr(str_shuffle(str_repeat($x='23456789ABCDEFGHJKLMNPQRSTUVWXYZ', ceil($length/strlen($x)) )),1,$length); } + + /** + * @throws ReflectionException + */ + public function Entity2ArrayJustIncludes($entity, array $includes, int $deep = 1): null|array{ + if(is_null($entity)) return []; + $result = []; + foreach ($includes as $method){ + if (method_exists($entity, $method)) { + $method = trim(trim($method)); + $value = $entity->$method(); + if (!is_object($value)) { + $result[lcfirst(str_replace(['get','is'], '', $method))] = $value; + } else { + if ($deep != 0) { + $result[lcfirst(str_replace(['get','is'], '', $method))] = $this->Entity2ArrayJustIncludes($value,$includes, $deep - 1); + } + } + } + } + return $result; + } + + /** + * @throws ReflectionException + */ + public function ArrayEntity2ArrayJustIncludes(array $entity, array $includes, int $deep = 1): null|array{ + if(count($entity) == 0) return []; + $result = []; + foreach ($entity as $item){ + $result[] = $this->Entity2ArrayJustIncludes($item,$includes,$deep); + } + return $result; + } } \ No newline at end of file diff --git a/hesabixCore/templates/app/base.html.twig b/hesabixCore/templates/app/base.html.twig index 755f8c7..c1485d0 100644 --- a/hesabixCore/templates/app/base.html.twig +++ b/hesabixCore/templates/app/base.html.twig @@ -100,12 +100,6 @@ راهنمای استفاده -