add notification response for ticket replay and bug fix in send sms to admins for replay tickets.now each user has role_admin resicive sms message.

This commit is contained in:
Hesabix 2024-01-20 16:33:27 +00:00
parent c349945f29
commit 96b9ad4baa
5 changed files with 38 additions and 6 deletions

View file

@ -32,14 +32,23 @@ class NotificationsController extends AbstractController
$items = $entityManager->getRepository(\App\Entity\Notification::class)->findBy([
'bid'=>$business,
'user'=>$this->getUser()
]);
],['id'=>'DESC']);
$userItems = $entityManager->getRepository(\App\Entity\Notification::class)->findBy([
'user'=>$this->getUser()
],['id'=>'DESC']);
$items = array_merge($items,$userItems);
}
elseif ($type = 'new'){
$items = $entityManager->getRepository(\App\Entity\Notification::class)->findBy([
'bid'=>$business,
'user'=>$this->getUser(),
'viewed' => false
]);
],['id'=>'DESC']);
$userItems = $entityManager->getRepository(\App\Entity\Notification::class)->findBy([
'user'=>$this->getUser(),
'viewed' => false
],['id'=>'DESC']);
$items = array_merge($items,$userItems);
}
$temps = [];

View file

@ -2,8 +2,11 @@
namespace App\Controller;
use App\Entity\Settings;
use App\Entity\Support;
use App\Entity\User;
use App\Service\Jdate;
use App\Service\Notification;
use App\Service\Provider;
use App\Service\SMS;
use Doctrine\ORM\EntityManagerInterface;
@ -46,7 +49,7 @@ class SupportController extends AbstractController
]);
}
#[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
public function app_admin_support_mod(SMS $SMS,Request $request, EntityManagerInterface $entityManager,string $id = '',Notification $notifi): JsonResponse
{
$params = [];
if ($content = $request->getContent()) {
@ -71,6 +74,10 @@ class SupportController extends AbstractController
//send sms to customer
if($item->getSubmitter()->getMobile())
$SMS->send([$item->getId()],'162251',$item->getSubmitter()->getMobile());
//send notification to user
$settings = $entityManager->getRepository(Settings::class)->findAll()[0];
$url = $settings->getAppSite() . '/profile/support-view/' . $item->getId();
$notifi->insert("به درخواست پشتیبانی پاسخ داده شد",$url,null,$item->getSubmitter());
return $this->json([
'error'=> 0,
'message'=> 'successful'
@ -141,7 +148,9 @@ class SupportController extends AbstractController
$entityManager->persist($upper);
$entityManager->flush();
//send sms to manager
$SMS->send([$item->getId()],'162214','09183282405');
$admins = $entityManager->getRepository(User::class)->findByRole('ROLE_ADMIN');
foreach($admins as $admin)
$SMS->send([$item->getId()],'162214',$admin->getMobile());
return $this->json([
'error'=> 0,
'message'=> 'ok',

View file

@ -19,7 +19,7 @@ class Notification
private ?User $user = null;
#[ORM\ManyToOne(inversedBy: 'notifications')]
#[ORM\JoinColumn(nullable: false)]
#[ORM\JoinColumn(nullable: true)]
private ?Business $bid = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]

View file

@ -56,6 +56,20 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
$this->save($user, true);
}
public function findByRole($role)
{
$qb = $this->createQueryBuilder('u');
$qb
->andWhere($qb->expr()->like('u.roles', ':role'))
->setParameter('role', '%'.$role.'%')
->orderBy('u.email', 'DESC');
return $qb
->getQuery()
->getResult();
}
// /**
// * @return User[] Returns an array of User objects
// */

View file

@ -14,7 +14,7 @@ class Notification
{
$this->em = $entityManager;
}
public function insert(string $message,string $url,Business $business,User $user): bool
public function insert(string $message,string $url,Business | null $business,User $user): bool
{
$item = new \App\Entity\Notification();
$item->setBid($business);