bug fixes
This commit is contained in:
parent
694a06b090
commit
a84bc451b8
|
@ -241,8 +241,7 @@ class BusinessController extends AbstractController
|
|||
$year->setLabel($params['year']['label']);
|
||||
$entityManager->persist($year);
|
||||
$entityManager->flush();
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
//not new business update business year
|
||||
$year = $entityManager->getRepository(Year::class)->findOneBy([
|
||||
'bid' => $business,
|
||||
|
@ -357,6 +356,31 @@ class BusinessController extends AbstractController
|
|||
return $this->json(['result' => -1]);
|
||||
}
|
||||
|
||||
#[Route('/api/business/removeuser/me', name: 'api_business_remove_user_me')]
|
||||
public function api_business_remove_user_me(Access $access, Log $log, Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$acc = $access->hasRole('join');
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
if ($this->getUser()->getId() == $acc['bid']->getOwner()->getId()) {
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
$perm = $entityManager->getRepository(Permission::class)->findOneBy([
|
||||
'user' => $this->getUser(),
|
||||
'bid' => $acc['bid']
|
||||
]);
|
||||
if ($perm && !$perm->isOwner()) {
|
||||
$entityManager->remove($perm);
|
||||
$entityManager->flush();
|
||||
//add log to system
|
||||
$log->insert('تنظیمات پایه', 'کاربر با پست الکترونیکی ' . $this->getUser()->getEmail() . ' کسب و کار را ترک کرد..', $this->getUser(), $acc['bid']);
|
||||
return $this->json(['result' => 1]);
|
||||
}
|
||||
|
||||
return $this->json(['result' => -1]);
|
||||
}
|
||||
|
||||
#[Route('/api/business/my/permission/state', name: 'api_business_my_permission_state')]
|
||||
public function api_business_my_permission_state(Request $request, Access $access): Response
|
||||
{
|
||||
|
|
|
@ -54,6 +54,6 @@ class RfbuyController extends AbstractController
|
|||
if(!$doc)
|
||||
throw $this->createNotFoundException();
|
||||
|
||||
return $this->json(Explore::ExploreSellDoc($doc));
|
||||
return $this->json(Explore::ExploreRfbuyDoc($doc));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,17 +2,59 @@
|
|||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use App\Service\Log;
|
||||
use App\Service\Access;
|
||||
use App\Entity\HesabdariDoc;
|
||||
use App\Entity\StoreroomTicket;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use App\Service\Explore as ServiceExplore;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
|
||||
class RfsellController extends AbstractController
|
||||
{
|
||||
#[Route('/rfsell', name: 'app_rfsell')]
|
||||
public function index(): Response
|
||||
#[Route('/api/rfsell/edit/can/{code}', name: 'app_rfsell_can_edit')]
|
||||
public function app_rfsell_can_edit(Request $request,Access $access,Log $log,EntityManagerInterface $entityManager, string $code): JsonResponse
|
||||
{
|
||||
return $this->render('rfsell/index.html.twig', [
|
||||
'controller_name' => 'RfsellController',
|
||||
$canEdit = true;
|
||||
$acc = $access->hasRole('plugAccproRfsell');
|
||||
if(!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
|
||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||
'bid'=>$acc['bid'],
|
||||
'code'=>$code
|
||||
]);
|
||||
//check related documents
|
||||
if(count($doc->getRelatedDocs()) != 0)
|
||||
$canEdit = false;
|
||||
|
||||
//check storeroom tickets
|
||||
$tickets = $entityManager->getRepository(StoreroomTicket::class)->findBy(['doc'=>$doc]);
|
||||
if(count($tickets) != 0)
|
||||
$canEdit = false;
|
||||
return $this->json([
|
||||
'result'=> $canEdit
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/api/rfsell/get/info/{code}', name: 'app_rfsell_get_info')]
|
||||
public function app_rfsell_get_info(Request $request,Access $access,Log $log,EntityManagerInterface $entityManager, string $code): JsonResponse
|
||||
{
|
||||
$acc = $access->hasRole('plugAccproRfsell');
|
||||
if(!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||
'bid'=>$acc['bid'],
|
||||
'code'=>$code
|
||||
]);
|
||||
if(!$doc)
|
||||
throw $this->createNotFoundException();
|
||||
|
||||
return $this->json(ServiceExplore::ExploreRfsellDoc($doc));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,22 @@ class Explore
|
|||
return $result;
|
||||
}
|
||||
|
||||
public static function ExploreRfbuyDoc(HesabdariDoc $hesabdariDoc)
|
||||
{
|
||||
$result = self::ExploreHesabdariDoc($hesabdariDoc);
|
||||
$person = [];
|
||||
$commodities = [];
|
||||
foreach ($hesabdariDoc->getHesabdariRows() as $item) {
|
||||
if ($item->getPerson()) {
|
||||
$person = self::ExplorePerson($item->getPerson());
|
||||
} elseif ($item->getCommodity()) {
|
||||
$commodities[] = Explore::ExploreCommodity($item->getCommodity(), $item->getCommdityCount(), $item->getDes());
|
||||
}
|
||||
}
|
||||
$result['person'] = $person;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function ExploreBuyDoc(HesabdariDoc $hesabdariDoc)
|
||||
{
|
||||
$result = self::ExploreHesabdariDoc($hesabdariDoc);
|
||||
|
@ -66,6 +82,21 @@ class Explore
|
|||
$result['person'] = $person;
|
||||
return $result;
|
||||
}
|
||||
public static function ExploreRfsellDoc(HesabdariDoc $hesabdariDoc)
|
||||
{
|
||||
$result = self::ExploreHesabdariDoc($hesabdariDoc);
|
||||
$person = [];
|
||||
$commodities = [];
|
||||
foreach ($hesabdariDoc->getHesabdariRows() as $item) {
|
||||
if ($item->getPerson()) {
|
||||
$person = self::ExplorePerson($item->getPerson());
|
||||
} elseif ($item->getCommodity()) {
|
||||
$commodities[] = Explore::ExploreCommodity($item->getCommodity(), $item->getCommdityCount(), $item->getDes());
|
||||
}
|
||||
}
|
||||
$result['person'] = $person;
|
||||
return $result;
|
||||
}
|
||||
public static function ExploreHesabdariDoc(HesabdariDoc $doc)
|
||||
{
|
||||
return [
|
||||
|
|
|
@ -13,7 +13,7 @@ class SMS
|
|||
private Settings $settings;
|
||||
private registryMGR $registryMGR;
|
||||
|
||||
private int $smsPrice = 1250;
|
||||
private int $smsPrice = 900;
|
||||
|
||||
/**
|
||||
* @param EntityManagerInterface $entityManager
|
||||
|
|
Loading…
Reference in a new issue