update for Moadian plugin
This commit is contained in:
parent
ac49a0229e
commit
e775de8f77
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
namespace App\Controller\Plugins;
|
namespace App\Controller\Plugins;
|
||||||
|
|
||||||
|
use App\Entity\Business;
|
||||||
|
use App\Entity\Permission;
|
||||||
use App\Service\Access;
|
use App\Service\Access;
|
||||||
use App\Service\Extractor;
|
use App\Service\Extractor;
|
||||||
use App\Service\Log;
|
use App\Service\Log;
|
||||||
|
@ -42,16 +44,41 @@ class TaxSettingsController extends AbstractController
|
||||||
|
|
||||||
$businessId = is_object($acc['bid']) ? $acc['bid']->getId() : $acc['bid'];
|
$businessId = is_object($acc['bid']) ? $acc['bid']->getId() : $acc['bid'];
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
$userId = $user instanceof \App\Entity\User ? $user->getId() : null;
|
|
||||||
|
|
||||||
$repo = $em->getRepository(PluginTaxsettingsKey::class);
|
$perm = $em->getRepository(Permission::class)->findOneBy([
|
||||||
$entity = $repo->findOneBy(['business_id' => $businessId, 'user_id' => $userId]);
|
'bid' => $businessId,
|
||||||
|
'user' => $user
|
||||||
|
]);
|
||||||
|
|
||||||
|
$business = $em->getRepository(Business::class)->find($businessId);
|
||||||
|
|
||||||
|
if ($business->getOwner() == $user) {
|
||||||
|
$repo = $em->getRepository(PluginTaxsettingsKey::class);
|
||||||
|
$entity = $repo->findOneBy(['business_id' => $businessId]);
|
||||||
|
|
||||||
|
$settings = [
|
||||||
|
'taxMemoryId' => $entity ? $entity->getTaxMemoryId() : '',
|
||||||
|
'economicCode' => $entity ? $entity->getEconomicCode() : '',
|
||||||
|
'privateKey' => $entity ? $entity->getPrivateKey() : '',
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
if (!$perm || !$perm->isPlugTaxSettings()) {
|
||||||
|
return $this->json([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'شما دسترسی لازم را ندارید.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$repo = $em->getRepository(PluginTaxsettingsKey::class);
|
||||||
|
$entity = $repo->findOneBy(['business_id' => $businessId]);
|
||||||
|
|
||||||
|
$settings = [
|
||||||
|
'taxMemoryId' => $entity ? $entity->getTaxMemoryId() : '',
|
||||||
|
'economicCode' => $entity ? $entity->getEconomicCode() : '',
|
||||||
|
'privateKey' => $entity ? $entity->getPrivateKey() : '',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
$settings = [
|
|
||||||
'taxMemoryId' => $entity ? $entity->getTaxMemoryId() : '',
|
|
||||||
'economicCode' => $entity ? $entity->getEconomicCode() : '',
|
|
||||||
'privateKey' => $entity ? $entity->getPrivateKey() : '',
|
|
||||||
];
|
|
||||||
|
|
||||||
return $this->json($settings);
|
return $this->json($settings);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue