From 7a799be9aa0b1255df887f67b99d8e67321eb6fc Mon Sep 17 00:00:00 2001 From: Babak Alizadeh Date: Sat, 14 Oct 2023 19:44:22 +0330 Subject: [PATCH] progress and add new options to commodity --- hesabixCore/composer.lock | 12 +- .../src/Controller/BusinessController.php | 6 +- .../src/Controller/CommodityController.php | 267 +++++++++++++- .../Front/Store/StoreController.php | 36 ++ .../src/Controller/HesabdariController.php | 28 ++ hesabixCore/src/Controller/LogController.php | 22 +- hesabixCore/src/Controller/SMSController.php | 213 ++++++++++++ .../src/Controller/StoreroomController.php | 94 +++++ .../src/Controller/SupportController.php | 2 +- .../src/Controller/TransferController.php | 84 +++++ hesabixCore/src/Controller/UserController.php | 17 + hesabixCore/src/Entity/Business.php | 182 ++++++++++ hesabixCore/src/Entity/Commodity.php | 49 +++ hesabixCore/src/Entity/CommodityCat.php | 121 +++++++ hesabixCore/src/Entity/CommodityDrop.php | 135 ++++++++ hesabixCore/src/Entity/CommodityDropLink.php | 67 ++++ hesabixCore/src/Entity/Permission.php | 15 + hesabixCore/src/Entity/SMSPays.php | 172 +++++++++ hesabixCore/src/Entity/SMSSettings.php | 96 +++++ hesabixCore/src/Entity/Storeroom.php | 111 ++++++ hesabixCore/src/Entity/User.php | 34 ++ .../src/Repository/CommodityCatRepository.php | 48 +++ .../CommodityDropLinkRepository.php | 48 +++ .../Repository/CommodityDropRepository.php | 48 +++ .../src/Repository/SMSPaysRepository.php | 48 +++ .../src/Repository/SMSSettingsRepository.php | 48 +++ .../src/Repository/StoreroomRepository.php | 48 +++ hesabixCore/src/Service/Notification.php | 30 ++ hesabixCore/src/Service/Provider.php | 32 +- hesabixCore/templates/general/home.html.twig | 4 + hesabixCore/templates/store/base.html.twig | 327 ++++++++++++++++++ hesabixCore/templates/store/index.html.twig | 20 ++ public_html/index.php | 11 +- 33 files changed, 2442 insertions(+), 33 deletions(-) create mode 100644 hesabixCore/src/Controller/Front/Store/StoreController.php create mode 100644 hesabixCore/src/Controller/SMSController.php create mode 100644 hesabixCore/src/Controller/StoreroomController.php create mode 100644 hesabixCore/src/Controller/TransferController.php create mode 100644 hesabixCore/src/Entity/CommodityCat.php create mode 100644 hesabixCore/src/Entity/CommodityDrop.php create mode 100644 hesabixCore/src/Entity/CommodityDropLink.php create mode 100644 hesabixCore/src/Entity/SMSPays.php create mode 100644 hesabixCore/src/Entity/SMSSettings.php create mode 100644 hesabixCore/src/Entity/Storeroom.php create mode 100644 hesabixCore/src/Repository/CommodityCatRepository.php create mode 100644 hesabixCore/src/Repository/CommodityDropLinkRepository.php create mode 100644 hesabixCore/src/Repository/CommodityDropRepository.php create mode 100644 hesabixCore/src/Repository/SMSPaysRepository.php create mode 100644 hesabixCore/src/Repository/SMSSettingsRepository.php create mode 100644 hesabixCore/src/Repository/StoreroomRepository.php create mode 100644 hesabixCore/src/Service/Notification.php create mode 100644 hesabixCore/templates/store/base.html.twig create mode 100644 hesabixCore/templates/store/index.html.twig diff --git a/hesabixCore/composer.lock b/hesabixCore/composer.lock index e976176..6aed0f7 100644 --- a/hesabixCore/composer.lock +++ b/hesabixCore/composer.lock @@ -354,16 +354,16 @@ }, { "name": "doctrine/dbal", - "version": "3.7.0", + "version": "3.7.1", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "00d03067f07482f025d41ab55e4ba0db5eca2cdf" + "reference": "5b7bd66c9ff58c04c5474ab85edce442f8081cb2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/00d03067f07482f025d41ab55e4ba0db5eca2cdf", - "reference": "00d03067f07482f025d41ab55e4ba0db5eca2cdf", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/5b7bd66c9ff58c04c5474ab85edce442f8081cb2", + "reference": "5b7bd66c9ff58c04c5474ab85edce442f8081cb2", "shasum": "" }, "require": { @@ -447,7 +447,7 @@ ], "support": { "issues": "https://github.com/doctrine/dbal/issues", - "source": "https://github.com/doctrine/dbal/tree/3.7.0" + "source": "https://github.com/doctrine/dbal/tree/3.7.1" }, "funding": [ { @@ -463,7 +463,7 @@ "type": "tidelift" } ], - "time": "2023-09-26T20:56:55+00:00" + "time": "2023-10-06T05:06:20+00:00" }, { "name": "doctrine/deprecations", diff --git a/hesabixCore/src/Controller/BusinessController.php b/hesabixCore/src/Controller/BusinessController.php index 3f6a35a..2898227 100644 --- a/hesabixCore/src/Controller/BusinessController.php +++ b/hesabixCore/src/Controller/BusinessController.php @@ -71,6 +71,7 @@ class BusinessController extends AbstractController $response['arzmain'] = $bus->getMoney()->getName(); $response['type'] = $bus->getType(); $response['zarinpalCode'] = $bus->getZarinpalCode(); + $response['smsCharge'] = $bus->getSmsCharge(); return $this->json($response); } @@ -184,6 +185,7 @@ class BusinessController extends AbstractController $perms->setReport(true); $perms->setAccounting(true); $perms->setLog(true); + $perms->setStore(true); $perms->setSalary(true); $perms->setPermission(true); $perms->setSalary(true); @@ -335,6 +337,7 @@ class BusinessController extends AbstractController 'persons'=>true, 'commodity'=>true, 'getpay'=>true, + 'store'=>true, 'bank'=>true, 'bankTransfer'=>true, 'cost'=>true, @@ -372,6 +375,7 @@ class BusinessController extends AbstractController 'accounting'=>$perm->isAccounting(), 'report'=>$perm->isReport(), 'log'=>$perm->isLog(), + 'store'=>$perm->isStore(), 'permission'=>$perm->isPermission(), 'salary'=>$perm->isSalary(), 'cashdesk'=>$perm->isCashdesk(), @@ -424,6 +428,7 @@ class BusinessController extends AbstractController $perm->setBankTransfer($params['bankTransfer']); $perm->setbuy($params['buy']); $perm->setSell($params['sell']); + $perm->setStore($params['store']); $perm->setCost($params['cost']); $perm->setIncome($params['income']); $perm->setAccounting($params['accounting']); @@ -487,7 +492,6 @@ class BusinessController extends AbstractController 'bid'=>$buss ])) ]; - return $this->json($response); } } diff --git a/hesabixCore/src/Controller/CommodityController.php b/hesabixCore/src/Controller/CommodityController.php index 1ac3a3a..9bd1cc5 100644 --- a/hesabixCore/src/Controller/CommodityController.php +++ b/hesabixCore/src/Controller/CommodityController.php @@ -2,9 +2,13 @@ namespace App\Controller; +use App\Entity\Business; use App\Entity\Commodity; +use App\Entity\CommodityCat; +use App\Entity\CommodityDrop; use App\Entity\CommodityUnit; use App\Service\Access; +use App\Service\Jdate; use App\Service\Log; use App\Service\Provider; use Doctrine\ORM\EntityManagerInterface; @@ -17,17 +21,29 @@ use Symfony\Component\Routing\Annotation\Route; class CommodityController extends AbstractController { #[Route('/api/commodity/list', name: 'app_commodity_list')] - public function app_commodity_list(Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse + public function app_commodity_list(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse { if(!$access->hasRole('commodity')) throw $this->createAccessDeniedException(); $items = $entityManager->getRepository(Commodity::class)->findBy([ 'bid'=>$request->headers->get('activeBid') ]); + $res = []; foreach ($items as $item){ - $item->setUnit($item->getUnit()->getName()); + $temp = []; + $temp['id'] = $item->getId(); + $temp['name'] = $item->getName(); + $temp['unit'] = $item->getUnit()->getName(); + $temp['des'] = $item->getDes(); + $temp['priceBuy'] = $item->getPriceBuy(); + $temp['priceSell'] = $item->getPriceSell(); + $temp['code'] = $item->getCode(); + $temp['cat'] = null; + if($item->getCat()) + $temp['cat'] = $item->getCat()->getName(); + $res[] = $temp; } - return $this->json($items); + return $this->json($res); } #[Route('/api/commodity/list/print', name: 'app_commodity_list_print')] public function app_commodity_list_print(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse @@ -59,7 +75,7 @@ class CommodityController extends AbstractController 'code'=>$code ]); $data->setUnit($data->getUnit()->getName()); - return $this->json($data); + return $this->json($provider->Entity2Array($data,0)); } #[Route('/api/commodity/mod/{code}', name: 'app_commodity_mod')] @@ -105,6 +121,17 @@ class CommodityController extends AbstractController $data->setDes($params['des']); $data->setPriceSell($params['priceSell']); $data->setPriceBuy($params['priceBuy']); + //set cat + if(array_key_exists('cat',$params)){ + if($params['cat'] != null){ + $cat = $entityManager->getRepository(CommodityCat::class)->find($params['cat']); + if($cat){ + if($cat->getBid() == $acc['bid']){ + $data->setCat($cat); + } + } + } + } $entityManager->persist($data); $entityManager->flush(); $log->insert('کالا و خدمات','کالا / خدمات با نام ' . $params['name'] . ' افزوده/ویرایش شد.',$this->getUser(),$request->headers->get('activeBid')); @@ -112,12 +139,242 @@ class CommodityController extends AbstractController } #[Route('/api/commodity/units', name: 'app_commodity_units')] - public function app_commodity_units(Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse + public function app_commodity_units(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse { if(!$access->hasRole('commodity')) throw $this->createAccessDeniedException(); $items = $entityManager->getRepository(CommodityUnit::class)->findAll(); return $this->json($items); } + + #[Route('/api/commodity/drop/list', name: 'app_commodity_drop_list')] + public function app_commodity_drop_list(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse + { + if(!$access->hasRole('commodity')) + throw $this->createAccessDeniedException(); + $items = $entityManager->getRepository(CommodityDrop::class)->findBy([ + 'bid'=>$request->headers->get('activeBid') + ]); + $generalItems = $entityManager->getRepository(CommodityDrop::class)->findBy([ + 'bid'=>null + ]); + + return $this->json($provider->ArrayEntity2Array(array_merge($items,$generalItems),0)); + } + + #[Route('/api/commodity/drop/mod/{code}', name: 'app_commodity_drop_mod')] + public function app_commodity_drop_mod(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager,$code = 0): JsonResponse + { + $acc = $access->hasRole('commodity'); + if(!$acc) + throw $this->createAccessDeniedException(); + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + if(!array_key_exists('name',$params)) + return $this->json(['result'=>-1]); + if(count_chars(trim($params['name'])) == 0) + return $this->json(['result'=>3]); + if($code == 0){ + $data = $entityManager->getRepository(CommodityDrop::class)->findOneBy([ + 'name'=>$params['name'], + 'bid'=>$acc['bid'] + ]); + //check exist before + if($data) + return $this->json(['result'=>2]); + $data = new CommodityDrop(); + } + else{ + $data = $entityManager->getRepository(CommodityDrop::class)->findOneBy([ + 'bid'=>$acc['bid'], + 'id'=>$code + ]); + if(!$data) + throw $this->createNotFoundException(); + } + $data->setName($params['name']); + $data->setBid($acc['bid']); + $data->setCanEdit(true); + $entityManager->persist($data); + $entityManager->flush(); + $log->insert('کالا و خدمات','ویژگی کالا / خدمات با نام ' . $params['name'] . ' افزوده/ویرایش شد.',$this->getUser(),$request->headers->get('activeBid')); + return $this->json(['result' => 1]); + } + + /** + * @throws \ReflectionException + */ + #[Route('/api/commodity/drop/info/{code}', name: 'app_commodity_drop_info')] + public function app_commodity_drop_info($code,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('commodity'); + if(!$acc) + throw $this->createAccessDeniedException(); + $data = $entityManager->getRepository(CommodityDrop::class)->findOneBy([ + 'bid'=>$acc['bid'], + 'id'=>$code + ]); + return $this->json($provider->Entity2Array($data,0)); + } + + #[Route('/api/commodity/cat/get', name: 'app_commodity_cat_get')] + public function app_commodity_cat_get(Jdate $jdate,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse + { + + $acc = $access->hasRole('commodity'); + if(!$acc) + throw $this->createAccessDeniedException(); + $temp =[]; + $nodes = $entityManager->getRepository(CommodityCat::class)->findBy([ + 'bid'=>$acc['bid'] + ]); + if(count($nodes) == 0) + $nodes = $this->createDefaultCat($acc['bid'],$entityManager); + foreach ($nodes as $node){ + if($this->hasChild($entityManager,$node)){ + $temp[$node->getId()]=[ + 'text'=>$node->getName(), + 'children'=>$this->getChildsLabel($entityManager,$node) + ]; + } + else{ + $temp[$node->getId()]=[ + 'text'=>$node->getName(), + ]; + } + } + $root = $entityManager->getRepository(CommodityCat::class)->findOneBy([ + 'bid'=>$acc['bid'], + 'root'=>true + ]); + return $this->json(['items'=>$temp,'root'=>$root->getId()]); + } + + #[Route('/api/commodity/cat/childs', name: 'app_commodity_cat_childs')] + public function app_commodity_cat_childs(Jdate $jdate,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('commodity'); + if(!$acc) + throw $this->createAccessDeniedException(); + + $items= $entityManager->getRepository(CommodityCat::class)->findOneBy([ + 'bid'=>$acc['bid'], + 'root'=>true + ]); + return $this->json($this->getChilds($entityManager,$items)); + } + #[Route('/api/commodity/cat/insert', name: 'app_commodity_cat_insert')] + public function app_commodity_cat_insert(Jdate $jdate,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('commodity'); + if(!$acc) + throw $this->createAccessDeniedException(); + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + if(!array_key_exists('upper',$params) || !array_key_exists('text',$params)) + return $this->json(['result'=>-1]); + $upper = $entityManager->getRepository(CommodityCat::class)->find($params['upper']); + if($upper){ + if($upper->getBid() == $acc['bid']){ + $cat = new CommodityCat(); + $cat->setBid($acc['bid']); + $cat->setRoot(false); + $cat->setName($params['text']); + $cat->setUpper($upper->getId()); + $entityManager->persist($cat); + $entityManager->flush(); + return $this->json(['result'=>1,'id'=>$cat->getId()]); + } + } + return $this->json(['result'=>1]); + } + #[Route('/api/commodity/cat/edit', name: 'app_commodity_cat_edit')] + public function app_commodity_cat_edit(Jdate $jdate,Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('commodity'); + if(!$acc) + throw $this->createAccessDeniedException(); + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + if(!array_key_exists('id',$params) || !array_key_exists('text',$params)) + return $this->json(['result'=>-1]); + $node = $entityManager->getRepository(CommodityCat::class)->find($params['id']); + if($node){ + if($node->getBid() == $acc['bid']){ + $node->setName($params['text']); + $entityManager->persist($node); + $entityManager->flush(); + return $this->json(['result'=>1,'id'=>$node->getId()]); + } + } + return $this->json(['result'=>1]); + } + private function getChildsLabel(EntityManagerInterface $entityManager, mixed $node){ + $childs = $entityManager->getRepository(CommodityCat::class)->findBy([ + 'upper'=>$node + ]); + $temp = []; + foreach ($childs as $child){ + $temp[] = $child->getId(); + } + return $temp; + } + + private function hasChild(EntityManagerInterface $entityManager, mixed $node) + { + if(count($entityManager->getRepository(CommodityCat::class)->findBy([ + 'upper'=>$node + ]))!= 0) + return true; + return false; + } + + private function getChilds(EntityManagerInterface $entityManager, mixed $node){ + $childs = $entityManager->getRepository(CommodityCat::class)->findBy([ + 'upper'=>$node + ]); + $temp = []; + foreach ($childs as $child){ + if($this->hasChild($entityManager,$child)){ + $temp[]=[ + 'id'=>$child->getId(), + 'label'=>$child->getName(), + 'children'=>$this->getChilds($entityManager,$child) + ]; + } + else{ + $temp[]=[ + 'id'=>$child->getId(), + 'label'=>$child->getName(), + ]; + } + } + return $temp; + } + + public function createDefaultCat(Business $bid,EntityManagerInterface $en): array + { + $item = new CommodityCat(); + $item->setName('دسته بندی ها'); + $item->setUpper(null); + $item->setBid($bid); + $item->setRoot(true); + $en->persist($item); + $en->flush(); + + $child = new CommodityCat(); + $child->setUpper($item->getId()); + $child->setBid($bid); + $child->setName('بدون دسته‌بندی'); + $en->persist($child); + $en->flush(); + return [$item,$child]; + } } diff --git a/hesabixCore/src/Controller/Front/Store/StoreController.php b/hesabixCore/src/Controller/Front/Store/StoreController.php new file mode 100644 index 0000000..2c5d75f --- /dev/null +++ b/hesabixCore/src/Controller/Front/Store/StoreController.php @@ -0,0 +1,36 @@ +em = $entityManager; + } + + private function CheckBID($id):bool|Business{ + $bid = $this->em->getRepository(Business::class)->findOneBy(['storeUsername'=>$id]); + if(!$bid) + return false; + return $bid; + } + #[Route('/s/{id}', name: 'app_store')] + public function app_store(String $id,EntityManagerInterface $entityManager): Response + { + $bid = $this->CheckBID($id); + if(!$bid) + throw $this->createNotFoundException(); + + return $this->render('store/index.html.twig', [ + 'bid' => $bid, + ]); + } +} diff --git a/hesabixCore/src/Controller/HesabdariController.php b/hesabixCore/src/Controller/HesabdariController.php index abc7337..3ee7259 100644 --- a/hesabixCore/src/Controller/HesabdariController.php +++ b/hesabixCore/src/Controller/HesabdariController.php @@ -424,6 +424,34 @@ class HesabdariController extends AbstractController 'id'=>'DESC' ]); } + elseif($params['type'] == 'cashdesk'){ + $cashdesk = $entityManager->getRepository(Cashdesk::class)->findOneBy([ + 'bid'=>$acc['bid'], + 'code'=>$params['id'], + ]); + if(!$cashdesk) + throw $this->createNotFoundException(); + + $data = $entityManager->getRepository(HesabdariRow::class)->findBy([ + 'cashdesk'=> $cashdesk, + ],[ + 'id'=>'DESC' + ]); + } + elseif($params['type'] == 'salary'){ + $salary = $entityManager->getRepository(Salary::class)->findOneBy([ + 'bid'=>$acc['bid'], + 'code'=>$params['id'], + ]); + if(!$salary) + throw $this->createNotFoundException(); + + $data = $entityManager->getRepository(HesabdariRow::class)->findBy([ + 'salary'=> $salary, + ],[ + 'id'=>'DESC' + ]); + } $dataTemp =[]; foreach ($data as $item){ $temp = [ diff --git a/hesabixCore/src/Controller/LogController.php b/hesabixCore/src/Controller/LogController.php index 0f03106..904a60a 100644 --- a/hesabixCore/src/Controller/LogController.php +++ b/hesabixCore/src/Controller/LogController.php @@ -9,23 +9,39 @@ use App\Service\Log; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route; class LogController extends AbstractController { #[Route('/api/business/logs/{bid}', name: 'api_business_logs')] - public function api_business_logs(Access $access,String $bid, Jdate $jdate, EntityManagerInterface $entityManager,Log $log): JsonResponse + public function api_business_logs(Request $request,Access $access,String $bid, Jdate $jdate, EntityManagerInterface $entityManager,Log $log): JsonResponse { if(!$access->hasRole('log')) throw $this->createAccessDeniedException(); $business = $entityManager->getRepository(Business::class)->find($bid); if(!$business) throw $this->createNotFoundException(); - $logs = $entityManager->getRepository(\App\Entity\Log::class)->findBy(['bid'=>$business]); + $params = []; + $logs = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + if(array_key_exists('type',$params)){ + if($params['type'] == 'sms') + $logs = $entityManager->getRepository(\App\Entity\Log::class)->findBy(['bid'=>$business,'part'=>'پیامک']); + + } + else{ + $logs = $entityManager->getRepository(\App\Entity\Log::class)->findBy(['bid'=>$business]); + } $temps = []; foreach ($logs as $log){ $temp = []; - $temp['user'] = $log->getUser()->getFullName(); + if($log->getUser()) + $temp['user'] = $log->getUser()->getFullName(); + else + $temp['user'] = ''; $temp['des'] = $log->getDes(); $temp['part'] = $log->getPart(); $temp['date'] = $jdate->jdate('Y/n/d H:i',$log->getDateSubmit()); diff --git a/hesabixCore/src/Controller/SMSController.php b/hesabixCore/src/Controller/SMSController.php new file mode 100644 index 0000000..ab6074c --- /dev/null +++ b/hesabixCore/src/Controller/SMSController.php @@ -0,0 +1,213 @@ +hasRole('owner'); + if(!$acc) + throw $this->createAccessDeniedException(); + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + if(array_key_exists('settings',$params)) + $params = $params['settings']; + $settings = $entityManager->getRepository(SMSSettings::class)->findOneBy([ + 'bid'=>$acc['bid'] + ]); + if(!$settings) + $settings = new SMSSettings(); + $settings->setBid($acc['bid']); + if(array_key_exists('sendAfterSell',$params)) + $settings->setSendAfterSell($params['sendAfterSell']); + if(array_key_exists('sendAfterSellPayOnline',$params)) + $settings->setSendAfterSellPayOnline($params['sendAfterSellPayOnline']); + if(array_key_exists('sendAfterBuy',$params)) + $settings->setSendAfterBuy($params['sendAfterBuy']); + if(array_key_exists('sendAfterBuyToUser',$params)) + $settings->setSendAfterBuyToUser($params['sendAfterBuyToUser']); + $entityManager->persist($settings); + $entityManager->flush(); + $log->insert('سرویس پیامک','به روز رسانی تنظیمات' ,$this->getUser(),$acc['bid']); + + return $this->json(['result'=>1]); + + } + + /** + * @throws \ReflectionException + */ + #[Route('/api/sms/load/pays', name: 'api_sms_load_pays')] + public function api_sms_load_pays(Jdate $jdate,Provider $provider,Access $access,Log $log,Request $request,EntityManagerInterface $entityManager): Response + { + $acc = $access->hasRole('owner'); + if(!$acc) + throw $this->createAccessDeniedException(); + $items = $entityManager->getRepository(SMSPays::class)->findBy([ + 'bid'=>$acc['bid'] + ],['id'=>'DESC']); + $res = []; + foreach ($items as $item){ + $temp = []; + $temp['des']=$item->getDes(); + $temp['submitter']=$item->getSubmitter()->getFullName(); + $temp['dateSubmit']=$jdate->jdate('Y/n/d H:i',$item->getDateSubmit()); + $temp['status'] = $item->getStatus(); + $temp['price'] = number_format($item->getPrice()); + $res[] = $temp; + } + return $this->json($res); + + } + + /** + * @throws \ReflectionException + */ + #[Route('/api/sms/load/settings', name: 'api_sms_load_settings')] + public function api_sms_load_settings(Provider $provider,Access $access,Log $log,Request $request,EntityManagerInterface $entityManager): Response + { + $acc = $access->hasRole('owner'); + if(!$acc) + throw $this->createAccessDeniedException(); + $settings = $entityManager->getRepository(SMSSettings::class)->findOneBy([ + 'bid'=>$acc['bid'] + ]); + if(!$settings) + $settings = new SMSSettings(); + + return $this->json($provider->Entity2Array($settings,0)); + + } + #[Route('/api/sms/charge', name: 'api_sms_charge')] + public function api_sms_charge(Log $log,Notification $notification,Request $request,Access $access,EntityManagerInterface $entityManager): JsonResponse + { + $acc = $access->hasRole('owner'); + if(!$acc) + throw $this->createAccessDeniedException(); + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + if(!array_key_exists('price',$params)) + throw $this->createAccessDeniedException('price not set'); + + $data = array("merchant_id" => "a7804652-1fb9-4b43-911c-0a1046e61be1", + "amount" => $params['price'], + "callback_url" => "http://hesabix.local/api/sms/buy/verify", + "description" => 'افزایش اعتبار سرویس پیامک', + ); + $jsonData = json_encode($data); + $ch = curl_init('https://api.zarinpal.com/pg/v4/payment/request.json'); + curl_setopt($ch, CURLOPT_USERAGENT, 'ZarinPal Rest Api v1'); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); + curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json', + 'Content-Length: ' . strlen($jsonData) + )); + + $result = curl_exec($ch); + $err = curl_error($ch); + $result = json_decode($result, true, JSON_PRETTY_PRINT); + curl_close($ch); + if ($err) { + throw $this->createAccessDeniedException($err); + } else { + if (empty($result['errors'])) { + if ($result['data']['code'] == 100) { + $smsPay = new SMSPays(); + $smsPay->setBid($acc['bid']); + $smsPay->setDateSubmit(time()); + $smsPay->setSubmitter($this->getUser()); + $smsPay->setDes('افزایش اعتبار سرویس پیامک'); + $smsPay->setPrice($params['price']); + $smsPay->setStatus(0); + $smsPay->setVerifyCode($result['data']['authority']); + $smsPay->setGatePay('zarinpal'); + $entityManager->persist($smsPay); + $entityManager->flush(); + $log->insert('سرویس پیامک','صدور فاکتور شارژ سرویس پیامک' ,$this->getUser(),$acc['bid']); + return $this->json([ + 'authority' => $result['data']["authority"] + ]); + } + } + } + throw $this->createAccessDeniedException(); + } + + #[Route('/api/sms/buy/verify', name: 'api_sms_buy_verify')] + public function api_sms_buy_verify(Notification $notification,Request $request,EntityManagerInterface $entityManager,Log $log): Response + { + $Authority = $request->get('Authority'); + $status = $request->get('Status'); + $req = $entityManager->getRepository(SMSPays::class)->findOneBy(['verifyCode'=>$Authority]); + $data = array("merchant_id" => "a7804652-1fb9-4b43-911c-0a1046e61be1", "authority" => $Authority, "amount" => $req->getPrice()); + $jsonData = json_encode($data); + $ch = curl_init('https://api.zarinpal.com/pg/v4/payment/verify.json'); + curl_setopt($ch, CURLOPT_USERAGENT, 'ZarinPal Rest Api v4'); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); + curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + 'Content-Type: application/json', + 'Content-Length: ' . strlen($jsonData) + )); + + $result = curl_exec($ch); + $err = curl_error($ch); + curl_close($ch); + $result = json_decode($result, true); + + //----------------------------------- + + //----------------------------------- + if ($err) { + $log->insert('سرویس پیامک','پرداخت ناموفق شارژ سرویس پیامک' ,$this->getUser(),$req->getBid()); + return $this->render('buy/fail.html.twig', ['results'=>$result]); + } else { + if(array_key_exists('code',$result['data'])){ + if ($result['data']['code'] == 100) { + $req->setStatus(100); + $req->setRefID($result['data']['ref_id']); + $req->setCardPan($result['data']['card_pan']); + $req->getBid()->setSmsCharge($req->getBid()->getSmsCharge() + ($req->getPrice()/1.09)); + $entityManager->persist($req); + $entityManager->flush(); + $log->insert( + 'سرویس پیامک', + 'افزایش اعتبار سرویس پیامک به مبلغ: ' . $req->getPrice() . ' ریال ', + $req->getSubmitter(), + $req->getBid() + ); + $log->insert('سرویس پیامک','پرداخت ناموفق شارژ سرویس پیامک' ,$this->getUser(),$req->getBid()); + $notification->insert(' سرویس پیامک شارژ شد.','/acc/sms/panel',$req->getBid(),$req->getSubmitter()); + return $this->render('buy/success.html.twig',['req'=>$req]); + } + } + $notification->insert('پرداخت فاکتور شارژ سرویس پیامک ناموفق بود','/',$req->getBid(),$req->getSubmitter()); + $log->insert('سرویس پیامک','پرداخت ناموفق شارژ سرویس پیامک' ,$this->getUser(),$req->getBid()); + return $this->render('buy/fail.html.twig', ['results'=>$result]); + } + } +} diff --git a/hesabixCore/src/Controller/StoreroomController.php b/hesabixCore/src/Controller/StoreroomController.php new file mode 100644 index 0000000..a55cdb2 --- /dev/null +++ b/hesabixCore/src/Controller/StoreroomController.php @@ -0,0 +1,94 @@ +hasRole('store'); + if(!$acc) + throw $this->createAccessDeniedException(); + $items = $entityManager->getRepository(Storeroom::class)->findBy([ + 'bid'=>$acc['bid'] + ]); + + return $this->json($provider->ArrayEntity2Array($items,0)); + } + + #[Route('/api/storeroom/mod/{code}', name: 'app_storeroom_mod')] + public function app_storeroom_mod(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager,$code = 0): JsonResponse + { + $acc = $access->hasRole('store'); + if(!$acc) + throw $this->createAccessDeniedException(); + $params = []; + if ($content = $request->getContent()) { + $params = json_decode($content, true); + } + if(!array_key_exists('name',$params)) + return $this->json(['result'=>-1]); + if(count_chars(trim($params['name'])) == 0) + return $this->json(['result'=>3]); + if($code == 0){ + $data = $entityManager->getRepository(Storeroom::class)->findOneBy([ + 'name'=>$params['name'], + 'bid'=>$acc['bid'] + ]); + //check exist before + if($data) + return $this->json(['result'=>2]); + $data = new Storeroom(); + $data->setBid($acc['bid']); + } + else{ + $data = $entityManager->getRepository(Storeroom::class)->findOneBy([ + 'bid'=>$acc['bid'], + 'id'=>$code + ]); + if(!$data) + throw $this->createNotFoundException(); + } + $data->setName($params['name']); + $data->setAdr($params['adr']); + $data->setManager($params['manager']); + $data->setTel($params['tel']); + if($params['active'] == 'true') + $data->setActive(true); + else + $data->setActive(false); + $entityManager->persist($data); + $entityManager->flush(); + $log->insert('انبارداری','انبار ' . $params['name'] . ' افزوده/ویرایش شد.',$this->getUser(),$acc['bid']); + return $this->json(['result' => 1]); + } + + /** + * @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 + { + $acc = $access->hasRole('store'); + if(!$acc) + throw $this->createAccessDeniedException(); + $data = $entityManager->getRepository(Storeroom::class)->findOneBy([ + 'bid'=>$acc['bid'], + 'id'=>$code + ]); + return $this->json($provider->Entity2Array($data,0)); + } + +} diff --git a/hesabixCore/src/Controller/SupportController.php b/hesabixCore/src/Controller/SupportController.php index eac54ff..4f177db 100644 --- a/hesabixCore/src/Controller/SupportController.php +++ b/hesabixCore/src/Controller/SupportController.php @@ -39,7 +39,7 @@ class SupportController extends AbstractController $params = json_decode($content, true); } if($id == ''){ - if(array_key_exists('title',$params) && array_key_exists('body',$params) && array_key_exists('bid',$params)){ + if(array_key_exists('title',$params) && array_key_exists('body',$params)){ $item = new Support(); $item->setBody($params['body']); $item->setTitle($params['title']); diff --git a/hesabixCore/src/Controller/TransferController.php b/hesabixCore/src/Controller/TransferController.php new file mode 100644 index 0000000..fd52c9a --- /dev/null +++ b/hesabixCore/src/Controller/TransferController.php @@ -0,0 +1,84 @@ +hasRole('transfer'); + if(!$acc) + throw $this->createAccessDeniedException(); + $items = $entityManager->getRepository(HesabdariDoc::class)->findBy([ + 'bid'=>$acc['bid'], + 'type'=>'transfer', + 'year'=>$acc['year'] + ]); + $resp = []; + foreach ($items as $item){ + $temp = []; + $temp['submitter']= $item->getSubmitter()->getFullName(); + $temp['code']= $item->getCode(); + $temp['date']= $item->getDate(); + $temp['des']= $item->getDes(); + $temp['amount']= $item->getAmount(); + $rows = $entityManager->getRepository(HesabdariRow::class)->findBy([ + 'doc'=>$item + ]); + $fromType = ''; + $fromObject = ''; + $toType = ''; + $toObject = ''; + foreach ($rows as $row){ + if($row->getBs()!=0){ + //it is from + if($row->getBank()){ + $fromType = 'bank'; + $fromObject = $row->getBank()->getName(); + } + elseif($row->getSalary()){ + $fromType = 'salary'; + $fromObject = $row->getSalary()->getName(); + } + elseif($row->getCashdesk()){ + $fromType = 'cashDesk'; + $fromObject = $row->getCashdesk()->getName(); + } + } + else{ + if($row->getBank()){ + $toType = 'bank'; + $toObject = $row->getBank()->getName(); + } + elseif($row->getSalary()){ + $toType = 'salary'; + $toObject = $row->getSalary()->getName(); + } + elseif($row->getCashdesk()){ + $toType = 'cashDesk'; + $toObject = $row->getCashdesk()->getName(); + } + } + } + $temp['fromType']= $fromType; + $temp['fromObject']= $fromObject; + $temp['toType']= $toType; + $temp['toObject']= $toObject; + $resp[] = $temp; + } + return $this->json($resp); + } +} diff --git a/hesabixCore/src/Controller/UserController.php b/hesabixCore/src/Controller/UserController.php index dbce23e..955920c 100644 --- a/hesabixCore/src/Controller/UserController.php +++ b/hesabixCore/src/Controller/UserController.php @@ -231,6 +231,7 @@ class UserController extends AbstractController $user->setFullName($params['name']); $user->setMobile($params['mobile']); $user->setVerifyCodeTime(time() + 300); + $user->setVerifyCode($this->RandomString(6,true)); $user->setDateRegister(time()); $user->setPassword( $userPasswordHasher->hashPassword( @@ -241,6 +242,22 @@ class UserController extends AbstractController $user->setActive(false); $entityManager->persist($user); $entityManager->flush(); + $SMS->send([$user->getVerifyCode()],'162246',$user->getMobile()); + try { + $email = (new Email()) + ->to($user->getEmail()) + ->priority(Email::PRIORITY_HIGH) + ->subject('تایید ایمیل در حسابیکس') + ->html( + $this->renderView('user/email/confrim-register.html.twig',[ + 'code'=>$user->getVerifyCode() + ]) + ); + + $mailer->send($email); + }catch (Exception $exception){ + + } return $this->json([ 'error'=> 0, 'id'=>$user->getId(), diff --git a/hesabixCore/src/Entity/Business.php b/hesabixCore/src/Entity/Business.php index f3772cb..af3f5d0 100644 --- a/hesabixCore/src/Entity/Business.php +++ b/hesabixCore/src/Entity/Business.php @@ -138,6 +138,27 @@ class Business #[ORM\JoinColumn(nullable: false)] private ?User $owner = null; + #[ORM\Column(nullable: true)] + private ?bool $storeOnline = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $storeUsername = null; + + #[ORM\Column(length: 255, nullable: true)] + private ?string $smsCharge = null; + + #[ORM\OneToMany(mappedBy: 'bid', targetEntity: SMSPays::class, orphanRemoval: true)] + private Collection $sMSPays; + + #[ORM\OneToMany(mappedBy: 'bid', targetEntity: SMSSettings::class, orphanRemoval: true)] + private Collection $sMSSettings; + + #[ORM\OneToMany(mappedBy: 'bid', targetEntity: CommodityDrop::class)] + private Collection $commodityDrops; + + #[ORM\OneToMany(mappedBy: 'bid', targetEntity: Storeroom::class, orphanRemoval: true)] + private Collection $storerooms; + public function __construct() { $this->logs = new ArrayCollection(); @@ -152,6 +173,10 @@ class Business $this->notifications = new ArrayCollection(); $this->plugins = new ArrayCollection(); $this->plugNoghreOrders = new ArrayCollection(); + $this->sMSPays = new ArrayCollection(); + $this->sMSSettings = new ArrayCollection(); + $this->commodityDrops = new ArrayCollection(); + $this->storerooms = new ArrayCollection(); } public function getId(): ?int @@ -852,4 +877,161 @@ class Business return $this; } + + public function isStoreOnline(): ?bool + { + return $this->storeOnline; + } + + public function setStoreOnline(?bool $storeOnline): static + { + $this->storeOnline = $storeOnline; + + return $this; + } + + public function getStoreUsername(): ?string + { + return $this->storeUsername; + } + + public function setStoreUsername(?string $storeUsername): static + { + $this->storeUsername = $storeUsername; + + return $this; + } + + public function getSmsCharge(): ?string + { + if(!$this->smsCharge) return 0; + return $this->smsCharge; + } + + public function setSmsCharge(?string $smsCharge): static + { + $this->smsCharge = $smsCharge; + + return $this; + } + + /** + * @return Collection + */ + public function getSMSPays(): Collection + { + return $this->sMSPays; + } + + public function addSMSPay(SMSPays $sMSPay): static + { + if (!$this->sMSPays->contains($sMSPay)) { + $this->sMSPays->add($sMSPay); + $sMSPay->setBid($this); + } + + return $this; + } + + public function removeSMSPay(SMSPays $sMSPay): static + { + if ($this->sMSPays->removeElement($sMSPay)) { + // set the owning side to null (unless already changed) + if ($sMSPay->getBid() === $this) { + $sMSPay->setBid(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getSMSSettings(): Collection + { + return $this->sMSSettings; + } + + public function addSMSSetting(SMSSettings $sMSSetting): static + { + if (!$this->sMSSettings->contains($sMSSetting)) { + $this->sMSSettings->add($sMSSetting); + $sMSSetting->setBid($this); + } + + return $this; + } + + public function removeSMSSetting(SMSSettings $sMSSetting): static + { + if ($this->sMSSettings->removeElement($sMSSetting)) { + // set the owning side to null (unless already changed) + if ($sMSSetting->getBid() === $this) { + $sMSSetting->setBid(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getCommodityDrops(): Collection + { + return $this->commodityDrops; + } + + public function addCommodityDrop(CommodityDrop $commodityDrop): static + { + if (!$this->commodityDrops->contains($commodityDrop)) { + $this->commodityDrops->add($commodityDrop); + $commodityDrop->setBid($this); + } + + return $this; + } + + public function removeCommodityDrop(CommodityDrop $commodityDrop): static + { + if ($this->commodityDrops->removeElement($commodityDrop)) { + // set the owning side to null (unless already changed) + if ($commodityDrop->getBid() === $this) { + $commodityDrop->setBid(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getStorerooms(): Collection + { + return $this->storerooms; + } + + public function addStoreroom(Storeroom $storeroom): static + { + if (!$this->storerooms->contains($storeroom)) { + $this->storerooms->add($storeroom); + $storeroom->setBid($this); + } + + return $this; + } + + public function removeStoreroom(Storeroom $storeroom): static + { + if ($this->storerooms->removeElement($storeroom)) { + // set the owning side to null (unless already changed) + if ($storeroom->getBid() === $this) { + $storeroom->setBid(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Entity/Commodity.php b/hesabixCore/src/Entity/Commodity.php index 1adf985..897970c 100644 --- a/hesabixCore/src/Entity/Commodity.php +++ b/hesabixCore/src/Entity/Commodity.php @@ -48,11 +48,18 @@ class Commodity #[ORM\Column(nullable: true)] private ?bool $khadamat = null; + #[ORM\OneToMany(mappedBy: 'commodity', targetEntity: CommodityDropLink::class, orphanRemoval: true)] + private Collection $commodityDropLinks; + + #[ORM\ManyToOne(inversedBy: 'commodities')] + private ?CommodityCat $cat = null; + public function __construct() { $this->setPriceBuy(0); $this->setPriceSell(0); $this->hesabdariRows = new ArrayCollection(); + $this->commodityDropLinks = new ArrayCollection(); } public function getId(): ?int @@ -185,4 +192,46 @@ class Commodity return $this; } + + /** + * @return Collection + */ + public function getCommodityDropLinks(): Collection + { + return $this->commodityDropLinks; + } + + public function addCommodityDropLink(CommodityDropLink $commodityDropLink): static + { + if (!$this->commodityDropLinks->contains($commodityDropLink)) { + $this->commodityDropLinks->add($commodityDropLink); + $commodityDropLink->setCommodity($this); + } + + return $this; + } + + public function removeCommodityDropLink(CommodityDropLink $commodityDropLink): static + { + if ($this->commodityDropLinks->removeElement($commodityDropLink)) { + // set the owning side to null (unless already changed) + if ($commodityDropLink->getCommodity() === $this) { + $commodityDropLink->setCommodity(null); + } + } + + return $this; + } + + public function getCat(): ?CommodityCat + { + return $this->cat; + } + + public function setCat(?CommodityCat $cat): static + { + $this->cat = $cat; + + return $this; + } } diff --git a/hesabixCore/src/Entity/CommodityCat.php b/hesabixCore/src/Entity/CommodityCat.php new file mode 100644 index 0000000..3dba1a6 --- /dev/null +++ b/hesabixCore/src/Entity/CommodityCat.php @@ -0,0 +1,121 @@ +commodities = 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 getUpper(): ?string + { + return $this->upper; + } + + public function setUpper(?string $upper): static + { + $this->upper = $upper; + + return $this; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function isRoot(): ?bool + { + return $this->root; + } + + public function setRoot(?bool $root): static + { + $this->root = $root; + + return $this; + } + + /** + * @return Collection + */ + public function getCommodities(): Collection + { + return $this->commodities; + } + + public function addCommodity(Commodity $commodity): static + { + if (!$this->commodities->contains($commodity)) { + $this->commodities->add($commodity); + $commodity->setCat($this); + } + + return $this; + } + + public function removeCommodity(Commodity $commodity): static + { + if ($this->commodities->removeElement($commodity)) { + // set the owning side to null (unless already changed) + if ($commodity->getCat() === $this) { + $commodity->setCat(null); + } + } + + return $this; + } +} diff --git a/hesabixCore/src/Entity/CommodityDrop.php b/hesabixCore/src/Entity/CommodityDrop.php new file mode 100644 index 0000000..7669a5d --- /dev/null +++ b/hesabixCore/src/Entity/CommodityDrop.php @@ -0,0 +1,135 @@ +commodityDropLinks = 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 getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getUDPrice(): ?string + { + return $this->UDPrice; + } + + public function setUDPrice(?string $UDPrice): static + { + $this->UDPrice = $UDPrice; + + return $this; + } + + public function getUDPricePercent(): ?string + { + return $this->UDPricePercent; + } + + public function setUDPricePercent(?string $UDPricePercent): static + { + $this->UDPricePercent = $UDPricePercent; + + return $this; + } + + /** + * @return Collection + */ + public function getCommodityDropLinks(): Collection + { + return $this->commodityDropLinks; + } + + public function addCommodityDropLink(CommodityDropLink $commodityDropLink): static + { + if (!$this->commodityDropLinks->contains($commodityDropLink)) { + $this->commodityDropLinks->add($commodityDropLink); + $commodityDropLink->setCommoditydrop($this); + } + + return $this; + } + + public function removeCommodityDropLink(CommodityDropLink $commodityDropLink): static + { + if ($this->commodityDropLinks->removeElement($commodityDropLink)) { + // set the owning side to null (unless already changed) + if ($commodityDropLink->getCommoditydrop() === $this) { + $commodityDropLink->setCommoditydrop(null); + } + } + + return $this; + } + + public function isCanEdit(): ?bool + { + return $this->canEdit; + } + + public function setCanEdit(?bool $canEdit): static + { + $this->canEdit = $canEdit; + + return $this; + } +} diff --git a/hesabixCore/src/Entity/CommodityDropLink.php b/hesabixCore/src/Entity/CommodityDropLink.php new file mode 100644 index 0000000..4c13551 --- /dev/null +++ b/hesabixCore/src/Entity/CommodityDropLink.php @@ -0,0 +1,67 @@ +id; + } + + public function getCommoditydrop(): ?CommodityDrop + { + return $this->commoditydrop; + } + + public function setCommoditydrop(?CommodityDrop $commoditydrop): static + { + $this->commoditydrop = $commoditydrop; + + return $this; + } + + public function getCommodity(): ?Commodity + { + return $this->commodity; + } + + public function setCommodity(?Commodity $commodity): static + { + $this->commodity = $commodity; + + return $this; + } + + public function getValue(): ?string + { + return $this->value; + } + + public function setValue(string $value): static + { + $this->value = $value; + + return $this; + } +} diff --git a/hesabixCore/src/Entity/Permission.php b/hesabixCore/src/Entity/Permission.php index cbc538b..639b549 100644 --- a/hesabixCore/src/Entity/Permission.php +++ b/hesabixCore/src/Entity/Permission.php @@ -81,6 +81,9 @@ class Permission #[ORM\Column(nullable: true)] private ?bool $plugCCAdmin = null; + #[ORM\Column(nullable: true)] + private ?bool $store = null; + public function getId(): ?int { return $this->id; @@ -349,4 +352,16 @@ class Permission return $this; } + + public function isStore(): ?bool + { + return $this->store; + } + + public function setStore(?bool $store): static + { + $this->store = $store; + + return $this; + } } diff --git a/hesabixCore/src/Entity/SMSPays.php b/hesabixCore/src/Entity/SMSPays.php new file mode 100644 index 0000000..f1204b5 --- /dev/null +++ b/hesabixCore/src/Entity/SMSPays.php @@ -0,0 +1,172 @@ +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 getPrice(): ?string + { + return $this->price; + } + + public function setPrice(string $price): static + { + $this->price = $price; + + return $this; + } + + public function getDes(): ?string + { + return $this->des; + } + + public function setDes(?string $des): static + { + $this->des = $des; + + 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 getVerifyCode(): ?string + { + return $this->verifyCode; + } + + public function setVerifyCode(?string $verifyCode): static + { + $this->verifyCode = $verifyCode; + + return $this; + } + + public function getGatePay(): ?string + { + return $this->gatePay; + } + + public function setGatePay(string $gatePay): static + { + $this->gatePay = $gatePay; + + return $this; + } +} diff --git a/hesabixCore/src/Entity/SMSSettings.php b/hesabixCore/src/Entity/SMSSettings.php new file mode 100644 index 0000000..f0eef78 --- /dev/null +++ b/hesabixCore/src/Entity/SMSSettings.php @@ -0,0 +1,96 @@ +id; + } + + public function getBid(): ?Business + { + return $this->bid; + } + + public function setBid(?Business $bid): static + { + $this->bid = $bid; + + return $this; + } + + public function isSendAfterSell(): ?bool + { + return $this->sendAfterSell; + } + + public function setSendAfterSell(?bool $sendAfterSell): static + { + $this->sendAfterSell = $sendAfterSell; + + return $this; + } + + public function isSendAfterSellPayOnline(): ?bool + { + return $this->sendAfterSellPayOnline; + } + + public function setSendAfterSellPayOnline(?bool $sendAfterSellPayOnline): static + { + $this->sendAfterSellPayOnline = $sendAfterSellPayOnline; + + return $this; + } + + public function isSendAfterBuy(): ?bool + { + return $this->sendAfterBuy; + } + + public function setSendAfterBuy(?bool $sendAfterBuy): static + { + $this->sendAfterBuy = $sendAfterBuy; + + return $this; + } + + public function isSendAfterBuyToUser(): ?bool + { + return $this->sendAfterBuyToUser; + } + + public function setSendAfterBuyToUser(?bool $sendAfterBuyToUser): static + { + $this->sendAfterBuyToUser = $sendAfterBuyToUser; + + return $this; + } +} diff --git a/hesabixCore/src/Entity/Storeroom.php b/hesabixCore/src/Entity/Storeroom.php new file mode 100644 index 0000000..7609f1a --- /dev/null +++ b/hesabixCore/src/Entity/Storeroom.php @@ -0,0 +1,111 @@ +id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function setName(string $name): static + { + $this->name = $name; + + return $this; + } + + public function getBid(): ?Business + { + return $this->bid; + } + + public function setBid(?Business $bid): static + { + $this->bid = $bid; + + return $this; + } + + public function getManager(): ?string + { + return $this->manager; + } + + public function setManager(?string $manager): static + { + $this->manager = $manager; + + return $this; + } + + public function getAdr(): ?string + { + return $this->adr; + } + + public function setAdr(?string $adr): static + { + $this->adr = $adr; + + return $this; + } + + public function getTel(): ?string + { + return $this->tel; + } + + public function setTel(?string $tel): static + { + $this->tel = $tel; + + return $this; + } + + public function isActive(): ?bool + { + return $this->active; + } + + public function setActive(?bool $active): static + { + $this->active = $active; + + return $this; + } +} diff --git a/hesabixCore/src/Entity/User.php b/hesabixCore/src/Entity/User.php index 3e41060..cdbe8d0 100644 --- a/hesabixCore/src/Entity/User.php +++ b/hesabixCore/src/Entity/User.php @@ -83,6 +83,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\Column(length: 255, nullable: true)] private ?string $verifyCodeTime = null; + #[ORM\OneToMany(mappedBy: 'submitter', targetEntity: SMSPays::class, orphanRemoval: true)] + private Collection $sMSPays; + public function __construct() { $this->userTokens = new ArrayCollection(); @@ -97,6 +100,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface $this->supports = new ArrayCollection(); $this->notifications = new ArrayCollection(); $this->emailHistories = new ArrayCollection(); + $this->sMSPays = new ArrayCollection(); } public function getId(): ?int @@ -600,4 +604,34 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface return $this; } + + /** + * @return Collection + */ + public function getSMSPays(): Collection + { + return $this->sMSPays; + } + + public function addSMSPay(SMSPays $sMSPay): static + { + if (!$this->sMSPays->contains($sMSPay)) { + $this->sMSPays->add($sMSPay); + $sMSPay->setSubmitter($this); + } + + return $this; + } + + public function removeSMSPay(SMSPays $sMSPay): static + { + if ($this->sMSPays->removeElement($sMSPay)) { + // set the owning side to null (unless already changed) + if ($sMSPay->getSubmitter() === $this) { + $sMSPay->setSubmitter(null); + } + } + + return $this; + } } diff --git a/hesabixCore/src/Repository/CommodityCatRepository.php b/hesabixCore/src/Repository/CommodityCatRepository.php new file mode 100644 index 0000000..0419168 --- /dev/null +++ b/hesabixCore/src/Repository/CommodityCatRepository.php @@ -0,0 +1,48 @@ + + * + * @method CommodityCat|null find($id, $lockMode = null, $lockVersion = null) + * @method CommodityCat|null findOneBy(array $criteria, array $orderBy = null) + * @method CommodityCat[] findAll() + * @method CommodityCat[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class CommodityCatRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, CommodityCat::class); + } + +// /** +// * @return CommodityCat[] Returns an array of CommodityCat objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('c') +// ->andWhere('c.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('c.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?CommodityCat +// { +// return $this->createQueryBuilder('c') +// ->andWhere('c.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/hesabixCore/src/Repository/CommodityDropLinkRepository.php b/hesabixCore/src/Repository/CommodityDropLinkRepository.php new file mode 100644 index 0000000..60cf232 --- /dev/null +++ b/hesabixCore/src/Repository/CommodityDropLinkRepository.php @@ -0,0 +1,48 @@ + + * + * @method CommodityDropLink|null find($id, $lockMode = null, $lockVersion = null) + * @method CommodityDropLink|null findOneBy(array $criteria, array $orderBy = null) + * @method CommodityDropLink[] findAll() + * @method CommodityDropLink[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class CommodityDropLinkRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, CommodityDropLink::class); + } + +// /** +// * @return CommodityDropLink[] Returns an array of CommodityDropLink objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('c') +// ->andWhere('c.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('c.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?CommodityDropLink +// { +// return $this->createQueryBuilder('c') +// ->andWhere('c.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/hesabixCore/src/Repository/CommodityDropRepository.php b/hesabixCore/src/Repository/CommodityDropRepository.php new file mode 100644 index 0000000..8152a79 --- /dev/null +++ b/hesabixCore/src/Repository/CommodityDropRepository.php @@ -0,0 +1,48 @@ + + * + * @method CommodityDrop|null find($id, $lockMode = null, $lockVersion = null) + * @method CommodityDrop|null findOneBy(array $criteria, array $orderBy = null) + * @method CommodityDrop[] findAll() + * @method CommodityDrop[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class CommodityDropRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, CommodityDrop::class); + } + +// /** +// * @return CommodityDrop[] Returns an array of CommodityDrop objects +// */ +// public function findByExampleField($value): array +// { +// return $this->createQueryBuilder('c') +// ->andWhere('c.exampleField = :val') +// ->setParameter('val', $value) +// ->orderBy('c.id', 'ASC') +// ->setMaxResults(10) +// ->getQuery() +// ->getResult() +// ; +// } + +// public function findOneBySomeField($value): ?CommodityDrop +// { +// return $this->createQueryBuilder('c') +// ->andWhere('c.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/hesabixCore/src/Repository/SMSPaysRepository.php b/hesabixCore/src/Repository/SMSPaysRepository.php new file mode 100644 index 0000000..9d99fa0 --- /dev/null +++ b/hesabixCore/src/Repository/SMSPaysRepository.php @@ -0,0 +1,48 @@ + + * + * @method SMSPays|null find($id, $lockMode = null, $lockVersion = null) + * @method SMSPays|null findOneBy(array $criteria, array $orderBy = null) + * @method SMSPays[] findAll() + * @method SMSPays[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class SMSPaysRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, SMSPays::class); + } + +// /** +// * @return SMSPays[] Returns an array of SMSPays 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): ?SMSPays +// { +// return $this->createQueryBuilder('s') +// ->andWhere('s.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/hesabixCore/src/Repository/SMSSettingsRepository.php b/hesabixCore/src/Repository/SMSSettingsRepository.php new file mode 100644 index 0000000..1bee00f --- /dev/null +++ b/hesabixCore/src/Repository/SMSSettingsRepository.php @@ -0,0 +1,48 @@ + + * + * @method SMSSettings|null find($id, $lockMode = null, $lockVersion = null) + * @method SMSSettings|null findOneBy(array $criteria, array $orderBy = null) + * @method SMSSettings[] findAll() + * @method SMSSettings[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class SMSSettingsRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, SMSSettings::class); + } + +// /** +// * @return SMSSettings[] Returns an array of SMSSettings 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): ?SMSSettings +// { +// return $this->createQueryBuilder('s') +// ->andWhere('s.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/hesabixCore/src/Repository/StoreroomRepository.php b/hesabixCore/src/Repository/StoreroomRepository.php new file mode 100644 index 0000000..95e50d3 --- /dev/null +++ b/hesabixCore/src/Repository/StoreroomRepository.php @@ -0,0 +1,48 @@ + + * + * @method Storeroom|null find($id, $lockMode = null, $lockVersion = null) + * @method Storeroom|null findOneBy(array $criteria, array $orderBy = null) + * @method Storeroom[] findAll() + * @method Storeroom[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class StoreroomRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Storeroom::class); + } + +// /** +// * @return Storeroom[] Returns an array of Storeroom 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): ?Storeroom +// { +// return $this->createQueryBuilder('s') +// ->andWhere('s.exampleField = :val') +// ->setParameter('val', $value) +// ->getQuery() +// ->getOneOrNullResult() +// ; +// } +} diff --git a/hesabixCore/src/Service/Notification.php b/hesabixCore/src/Service/Notification.php new file mode 100644 index 0000000..2a6c826 --- /dev/null +++ b/hesabixCore/src/Service/Notification.php @@ -0,0 +1,30 @@ +em = $entityManager; + } + public function insert(string $message,string $url,Business $business,User $user): bool + { + $item = new \App\Entity\Notification(); + $item->setBid($business); + $item->setDateSubmit(time()); + $item->setViewed(false); + $item->setUser($user); + $item->setMessage($message); + $item->setUrl($url); + $this->em->persist($item); + $this->em->flush(); + return true; + } +} \ No newline at end of file diff --git a/hesabixCore/src/Service/Provider.php b/hesabixCore/src/Service/Provider.php index a57c9b3..ec4ed37 100644 --- a/hesabixCore/src/Service/Provider.php +++ b/hesabixCore/src/Service/Provider.php @@ -100,32 +100,32 @@ class Provider if(str_starts_with($method, 'get')){ $getMethods[] = trim(trim($method)); } + elseif(str_starts_with($method, 'is')){ + $getMethods[] = trim(trim($method)); + } } //var_dump($getMethods); foreach ($getMethods as $method){ - if(!is_int(array_search(lcfirst(trim(str_replace('get', '', $method))), $ignores))){ - if(method_exists($entity,$method) && $method != 'get'){ + 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)) { - $value = $entity->$method(); - } - else + if ($reflection->isPublic() && !str_starts_with('\\0', $method)) { + $value = $entity->$method(); + } else $canProced = false; - if($canProced){ - if(!is_object($value)){ - $result[lcfirst(str_replace('get','',$method))] = $value; - } - else{ - if($deep != 0){ - $result[lcfirst(str_replace('get','',$method))] = $this->Entity2Array($value,$deep - 1); + if ($canProced) { + if (!is_object($value)) { + $result[lcfirst(str_replace(['get','is'], '', $method))] = $value; + } else { + if ($deep != 0) { + $result[lcfirst(str_replace(['get','is'], '', $method))] = $this->Entity2Array($value, $deep - 1); } - } + } } - - } + } } } return $result; diff --git a/hesabixCore/templates/general/home.html.twig b/hesabixCore/templates/general/home.html.twig index 660ccc9..10dbe65 100644 --- a/hesabixCore/templates/general/home.html.twig +++ b/hesabixCore/templates/general/home.html.twig @@ -16,6 +16,10 @@ ورود | عضویت رایگان + + + دمو (نسخه در حال توسعه) + {% if is_granted('ROLE_ADMIN')%} diff --git a/hesabixCore/templates/store/base.html.twig b/hesabixCore/templates/store/base.html.twig new file mode 100644 index 0000000..47d1aed --- /dev/null +++ b/hesabixCore/templates/store/base.html.twig @@ -0,0 +1,327 @@ + + + + + + {% block title %}{% endblock %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ +
+
+ + + +
+
+ + +
+ +
+
+
+

داشبورد

+

به برنامه خود خوش آمدید، همه چیز عالی به نظر می رسد!

+
+
+
+ + + +
+
+
+
+

...

+
+
+
+
+
+
+

...

+
+
+
+
+
+
+

...

+
+
+
+
+
+
+

...

+
+
+
+
+
+
+

...

+
+
+
+
+
+
+

...

+
+
+
+
+
+
+

...

+
+
+
+
+ +
+ +
+ + + + + +
+ + + + + + + \ No newline at end of file diff --git a/hesabixCore/templates/store/index.html.twig b/hesabixCore/templates/store/index.html.twig new file mode 100644 index 0000000..8fc5fa8 --- /dev/null +++ b/hesabixCore/templates/store/index.html.twig @@ -0,0 +1,20 @@ +{% extends 'store/base.html.twig' %} + +{% block title %} فروشگاه {{ bid.name }}{% endblock %} + +{% block body %} + + +
+

Hello {{ controller_name }}! ✅

+ + This friendly message is coming from: + +
+{% endblock %} diff --git a/public_html/index.php b/public_html/index.php index 708c23c..0f49629 100644 --- a/public_html/index.php +++ b/public_html/index.php @@ -1,8 +1,17 @@