From ea899a2022ef53aa954b933ad05919bb43b30985 Mon Sep 17 00:00:00 2001 From: Babak Alizadeh Date: Fri, 1 Dec 2023 16:53:48 -0500 Subject: [PATCH] bug fix in commodity and add script part to api --- hesabixCore/src/Controller/AdminController.php | 2 ++ .../src/Controller/CommodityController.php | 2 +- hesabixCore/src/Entity/Settings.php | 15 +++++++++++++++ hesabixCore/templates/base.html.twig | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/hesabixCore/src/Controller/AdminController.php b/hesabixCore/src/Controller/AdminController.php index f78da2b..907f71d 100644 --- a/hesabixCore/src/Controller/AdminController.php +++ b/hesabixCore/src/Controller/AdminController.php @@ -184,6 +184,7 @@ class AdminController extends AbstractController $resp = []; $resp['keywords'] = $item->getSiteKeywords(); $resp['description'] = $item->getDiscription(); + $resp['scripts'] = $item->getScripts(); return $this->json($resp); } @@ -198,6 +199,7 @@ class AdminController extends AbstractController $item = $entityManager->getRepository(Settings::class)->findAll()[0]; $item->setSiteKeywords($params['keywords']); $item->setDiscription($params['description']); + $item->setScripts($params['scripts']); $entityManager->persist($item); $entityManager->flush(); return $this->json(['result' => 1]); diff --git a/hesabixCore/src/Controller/CommodityController.php b/hesabixCore/src/Controller/CommodityController.php index 2201062..577a65f 100644 --- a/hesabixCore/src/Controller/CommodityController.php +++ b/hesabixCore/src/Controller/CommodityController.php @@ -153,7 +153,7 @@ class CommodityController extends AbstractController $data->setOrderPoint($params['orderPoint']); //set cat if(array_key_exists('cat',$params)){ - if($params['cat'] != null){ + if($params['cat'] != ''){ $cat = $entityManager->getRepository(CommodityCat::class)->find($params['cat']); if($cat){ if($cat->getBid() == $acc['bid']){ diff --git a/hesabixCore/src/Entity/Settings.php b/hesabixCore/src/Entity/Settings.php index 5fb2648..b3b120e 100644 --- a/hesabixCore/src/Entity/Settings.php +++ b/hesabixCore/src/Entity/Settings.php @@ -41,6 +41,9 @@ class Settings #[ORM\Column(length: 255, nullable: true)] private ?string $discription = null; + #[ORM\Column(type: Types::TEXT, nullable: true)] + private ?string $scripts = null; + public function getId(): ?int { return $this->id; @@ -153,4 +156,16 @@ class Settings return $this; } + + public function getScripts(): ?string + { + return $this->scripts; + } + + public function setScripts(?string $scripts): static + { + $this->scripts = $scripts; + + return $this; + } } diff --git a/hesabixCore/templates/base.html.twig b/hesabixCore/templates/base.html.twig index 8aca6cb..cddbd2e 100644 --- a/hesabixCore/templates/base.html.twig +++ b/hesabixCore/templates/base.html.twig @@ -285,5 +285,6 @@ + {{ settings.scripts | raw }}