add year select to new business and some reports
This commit is contained in:
parent
267b28cf87
commit
5f7e68dfb1
|
@ -1,17 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Controller;
|
|
||||||
|
|
||||||
use App\Service\pdfMGR;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
|
||||||
|
|
||||||
class AdsBanController extends AbstractController
|
|
||||||
{
|
|
||||||
#[Route('/ads/ban', name: 'app_ads_ban')]
|
|
||||||
public function index(pdfMGR $pdfMGR): JsonResponse
|
|
||||||
{
|
|
||||||
$pdfMGR->streamTwig2PDF('test.html.twig');
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -33,11 +33,11 @@ use Symfony\Component\Security\Http\Attribute\CurrentUser;
|
||||||
class BusinessController extends AbstractController
|
class BusinessController extends AbstractController
|
||||||
{
|
{
|
||||||
#[Route('/api/business/list', name: 'api_bussiness_list')]
|
#[Route('/api/business/list', name: 'api_bussiness_list')]
|
||||||
public function api_bussiness_list(#[CurrentUser] ?User $user,EntityManagerInterface $entityManager,Provider $provider): Response
|
public function api_bussiness_list(#[CurrentUser] ?User $user, EntityManagerInterface $entityManager, Provider $provider): Response
|
||||||
{
|
{
|
||||||
$buss = $entityManager->getRepository(Permission::class)->findBy(['user'=>$user]);
|
$buss = $entityManager->getRepository(Permission::class)->findBy(['user' => $user]);
|
||||||
$response = [];
|
$response = [];
|
||||||
foreach ($buss as $bus){
|
foreach ($buss as $bus) {
|
||||||
$temp = [];
|
$temp = [];
|
||||||
$temp['id'] = $bus->getBid()->getId();
|
$temp['id'] = $bus->getBid()->getId();
|
||||||
$temp['owner'] = $bus->getBid()->getOwner()->getFullName();
|
$temp['owner'] = $bus->getBid()->getOwner()->getFullName();
|
||||||
|
@ -52,9 +52,9 @@ class BusinessController extends AbstractController
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
#[Route('/api/business/get/info/{bid}', name: 'api_business_get_info')]
|
#[Route('/api/business/get/info/{bid}', name: 'api_business_get_info')]
|
||||||
public function api_business_get_info($bid,#[CurrentUser] ?User $user,Provider $provider,EntityManagerInterface $entityManager): Response
|
public function api_business_get_info($bid, #[CurrentUser] ?User $user, Provider $provider, EntityManagerInterface $entityManager): Response
|
||||||
{
|
{
|
||||||
$bus = $entityManager->getRepository(Business::class)->findOneBy(['id'=>$bid]);
|
$bus = $entityManager->getRepository(Business::class)->findOneBy(['id' => $bid]);
|
||||||
$response = [];
|
$response = [];
|
||||||
$response['id'] = $bus->getId();
|
$response['id'] = $bus->getId();
|
||||||
$response['name'] = $bus->getName();
|
$response['name'] = $bus->getName();
|
||||||
|
@ -81,28 +81,28 @@ class BusinessController extends AbstractController
|
||||||
$response['shortlinks'] = $bus->isShortLinks();
|
$response['shortlinks'] = $bus->isShortLinks();
|
||||||
$response['walletEnabled'] = $bus->isWalletEnable();
|
$response['walletEnabled'] = $bus->isWalletEnable();
|
||||||
$response['walletMatchBank'] = null;
|
$response['walletMatchBank'] = null;
|
||||||
if($bus->isWalletEnable())
|
if ($bus->isWalletEnable())
|
||||||
$response['walletMatchBank'] = $provider->Entity2Array($bus->getWalletMatchBank(),0);
|
$response['walletMatchBank'] = $provider->Entity2Array($bus->getWalletMatchBank(), 0);
|
||||||
return $this->json($response);
|
return $this->json($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/business/list/count', name: 'api_bussiness_list_count')]
|
#[Route('/api/business/list/count', name: 'api_bussiness_list_count')]
|
||||||
public function api_bussiness_list_count(#[CurrentUser] ?User $user,EntityManagerInterface $entityManager): Response
|
public function api_bussiness_list_count(#[CurrentUser] ?User $user, EntityManagerInterface $entityManager): Response
|
||||||
{
|
{
|
||||||
$buss = $entityManager->getRepository(Permission::class)->findBy(['user'=>$user]);
|
$buss = $entityManager->getRepository(Permission::class)->findBy(['user' => $user]);
|
||||||
$response = ['count'=>count($buss)];
|
$response = ['count' => count($buss)];
|
||||||
return $this->json($response);
|
return $this->json($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/business/insert', name: 'api_bussiness_insert')]
|
#[Route('/api/business/insert', name: 'api_bussiness_insert')]
|
||||||
public function api_bussiness_insert(Jdate $jdate, Access $access,Log $log,Request $request,EntityManagerInterface $entityManager): Response
|
public function api_bussiness_insert(Jdate $jdate, Access $access, Log $log, Request $request, EntityManagerInterface $entityManager): Response
|
||||||
{
|
{
|
||||||
$params = [];
|
$params = [];
|
||||||
if ($content = $request->getContent()) {
|
if ($content = $request->getContent()) {
|
||||||
$params = json_decode($content, true);
|
$params = json_decode($content, true);
|
||||||
}
|
}
|
||||||
//check for that data is set
|
//check for that data is set
|
||||||
if(
|
if (
|
||||||
trim($params['name']) != '' &&
|
trim($params['name']) != '' &&
|
||||||
trim($params['legal_name']) != '' &&
|
trim($params['legal_name']) != '' &&
|
||||||
trim($params['maliyatafzode']) != ''
|
trim($params['maliyatafzode']) != ''
|
||||||
|
@ -167,7 +167,7 @@ class BusinessController extends AbstractController
|
||||||
if ($params['email'])
|
if ($params['email'])
|
||||||
$business->setEmail($params['email']);
|
$business->setEmail($params['email']);
|
||||||
|
|
||||||
if (array_key_exists('walletEnabled', $params)){
|
if (array_key_exists('walletEnabled', $params)) {
|
||||||
if ($params['walletEnabled']) {
|
if ($params['walletEnabled']) {
|
||||||
if (array_key_exists('walletMatchBank', $params)) {
|
if (array_key_exists('walletMatchBank', $params)) {
|
||||||
$bank = $entityManager->getRepository(BankAccount::class)->findOneBy([
|
$bank = $entityManager->getRepository(BankAccount::class)->findOneBy([
|
||||||
|
@ -179,26 +179,24 @@ class BusinessController extends AbstractController
|
||||||
$business->setWalletMatchBank($bank);
|
$business->setWalletMatchBank($bank);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
$business->setWalletEnable(false);
|
$business->setWalletEnable(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//get Money type
|
//get Money type
|
||||||
if($params['arzmain']){
|
if ($params['arzmain']) {
|
||||||
$Arzmain = $entityManager->getRepository(Money::class)->findOneBy(['name'=>$params['arzmain']]);
|
$Arzmain = $entityManager->getRepository(Money::class)->findOneBy(['name' => $params['arzmain']]);
|
||||||
if($Arzmain)
|
if ($Arzmain)
|
||||||
$business->setMoney($Arzmain);
|
$business->setMoney($Arzmain);
|
||||||
else
|
else
|
||||||
return $this->json(['result'=>2]);
|
return $this->json(['result' => 2]);
|
||||||
}
|
} else
|
||||||
else
|
return $this->json(['result' => 2]);
|
||||||
return $this->json(['result'=>2]);
|
if (!$business->getDateSubmit()) $business->setDateSubmit(time());
|
||||||
if(! $business->getDateSubmit()) $business->setDateSubmit(time());
|
|
||||||
$entityManager->persist($business);
|
$entityManager->persist($business);
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
if($isNew){
|
if ($isNew) {
|
||||||
$perms = new Permission();
|
$perms = new Permission();
|
||||||
$perms->setBid($business);
|
$perms->setBid($business);
|
||||||
$perms->setUser($this->getUser());
|
$perms->setUser($this->getUser());
|
||||||
|
@ -229,50 +227,52 @@ class BusinessController extends AbstractController
|
||||||
$year = new Year();
|
$year = new Year();
|
||||||
$year->setBid($business);
|
$year->setBid($business);
|
||||||
$year->setHead(true);
|
$year->setHead(true);
|
||||||
$year->setStart(time());
|
$startYearArray = explode('-', $params['year']['start']);
|
||||||
$year->setEnd(time() + 31536000);
|
$year->setStart($jdate->jmktime(0, 0, 0, $startYearArray[1], $startYearArray[2], $startYearArray[0]));
|
||||||
$year->setLabel('سال مالی منتهی به ' . $jdate->jdate('Y/n/d',time() + 31536000));
|
$endYearArray = explode('-', $params['year']['end']);
|
||||||
|
$year->setEnd($jdate->jmktime(0, 0, 0, $endYearArray[1], $endYearArray[2], $endYearArray[0]));
|
||||||
|
$year->setLabel($params['year']['label']);
|
||||||
$entityManager->persist($year);
|
$entityManager->persist($year);
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
}
|
}
|
||||||
//add log to system
|
//add log to system
|
||||||
$log->insert('تنظیمات پایه','اطلاعات کسب و کار ایجاد/ویرایش شد.',$this->getUser(),$business);
|
$log->insert('تنظیمات پایه', 'اطلاعات کسب و کار ایجاد/ویرایش شد.', $this->getUser(), $business);
|
||||||
}
|
}
|
||||||
return $this->json(['result'=>1]);
|
return $this->json(['result' => 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/business/add/user', name: 'api_business_add_user')]
|
#[Route('/api/business/add/user', name: 'api_business_add_user')]
|
||||||
public function api_business_add_user(Access $access,Log $log,Request $request,EntityManagerInterface $entityManager): Response
|
public function api_business_add_user(Access $access, Log $log, Request $request, EntityManagerInterface $entityManager): Response
|
||||||
{
|
{
|
||||||
if(!$access->hasRole('permission'))
|
if (!$access->hasRole('permission'))
|
||||||
throw $this->createAccessDeniedException();
|
throw $this->createAccessDeniedException();
|
||||||
$params = [];
|
$params = [];
|
||||||
if ($content = $request->getContent()) {
|
if ($content = $request->getContent()) {
|
||||||
$params = json_decode($content, true);
|
$params = json_decode($content, true);
|
||||||
}
|
}
|
||||||
//check for that data is set
|
//check for that data is set
|
||||||
if(
|
if (
|
||||||
trim($params['bid']) != '' &&
|
trim($params['bid']) != '' &&
|
||||||
trim($params['email']) != ''
|
trim($params['email']) != ''
|
||||||
){
|
) {
|
||||||
$business = $entityManager->getRepository(Business::class)->find($params['bid']);
|
$business = $entityManager->getRepository(Business::class)->find($params['bid']);
|
||||||
if(is_null($business)){
|
if (is_null($business)) {
|
||||||
return $this->json(['result'=>-1]);
|
return $this->json(['result' => -1]);
|
||||||
}
|
}
|
||||||
//echo $params['email'];
|
//echo $params['email'];
|
||||||
$user = $entityManager->getRepository(User::class)->findOneBy([
|
$user = $entityManager->getRepository(User::class)->findOneBy([
|
||||||
'email' => $params['email']
|
'email' => $params['email']
|
||||||
]);
|
]);
|
||||||
if(is_null($user)){
|
if (is_null($user)) {
|
||||||
return $this->json(['result'=>0]);
|
return $this->json(['result' => 0]);
|
||||||
}
|
}
|
||||||
$perm = $entityManager->getRepository(Permission::class)->findOneBy([
|
$perm = $entityManager->getRepository(Permission::class)->findOneBy([
|
||||||
'user'=>$user,
|
'user' => $user,
|
||||||
'bid'=>$business
|
'bid' => $business
|
||||||
]);
|
]);
|
||||||
if($perm){
|
if ($perm) {
|
||||||
//already added
|
//already added
|
||||||
return $this->json(['result'=>1]);
|
return $this->json(['result' => 1]);
|
||||||
}
|
}
|
||||||
$perm = new Permission();
|
$perm = new Permission();
|
||||||
$perm->setBid($business);
|
$perm->setBid($business);
|
||||||
|
@ -281,74 +281,75 @@ class BusinessController extends AbstractController
|
||||||
$entityManager->persist($perm);
|
$entityManager->persist($perm);
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
//add log to system
|
//add log to system
|
||||||
$log->insert('تنظیمات پایه','کاربر با پست الکترونیکی ' . $params['email'] .' به کسب و کار اضافه شد.',$this->getUser(),$business);
|
$log->insert('تنظیمات پایه', 'کاربر با پست الکترونیکی ' . $params['email'] . ' به کسب و کار اضافه شد.', $this->getUser(), $business);
|
||||||
return $this->json(
|
return $this->json(
|
||||||
[
|
[
|
||||||
'result'=>2,
|
'result' => 2,
|
||||||
'data'=>[
|
'data' => [
|
||||||
'email'=>$user->getEmail(),
|
'email' => $user->getEmail(),
|
||||||
'name'=>$user->getFullName(),
|
'name' => $user->getFullName(),
|
||||||
'owner'=>false
|
'owner' => false
|
||||||
]
|
]
|
||||||
]);
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return $this->json(['result'=>-1]);
|
return $this->json(['result' => -1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/business/delete/user', name: 'api_business_delete_user')]
|
#[Route('/api/business/delete/user', name: 'api_business_delete_user')]
|
||||||
public function api_business_delete_user(Access $access,Log $log,Request $request,EntityManagerInterface $entityManager): Response
|
public function api_business_delete_user(Access $access, Log $log, Request $request, EntityManagerInterface $entityManager): Response
|
||||||
{
|
{
|
||||||
if(!$access->hasRole('permission'))
|
if (!$access->hasRole('permission'))
|
||||||
throw $this->createAccessDeniedException();
|
throw $this->createAccessDeniedException();
|
||||||
$params = [];
|
$params = [];
|
||||||
if ($content = $request->getContent()) {
|
if ($content = $request->getContent()) {
|
||||||
$params = json_decode($content, true);
|
$params = json_decode($content, true);
|
||||||
}
|
}
|
||||||
//check for that data is set
|
//check for that data is set
|
||||||
if(
|
if (
|
||||||
trim($params['bid']) != '' &&
|
trim($params['bid']) != '' &&
|
||||||
trim($params['email']) != ''
|
trim($params['email']) != ''
|
||||||
){
|
) {
|
||||||
$business = $entityManager->getRepository(Business::class)->find($params['bid']);
|
$business = $entityManager->getRepository(Business::class)->find($params['bid']);
|
||||||
if(is_null($business)){
|
if (is_null($business)) {
|
||||||
return $this->json(['result'=>-1]);
|
return $this->json(['result' => -1]);
|
||||||
}
|
}
|
||||||
//echo $params['email'];
|
//echo $params['email'];
|
||||||
$user = $entityManager->getRepository(User::class)->findOneBy([
|
$user = $entityManager->getRepository(User::class)->findOneBy([
|
||||||
'email' => $params['email']
|
'email' => $params['email']
|
||||||
]);
|
]);
|
||||||
if(is_null($user)){
|
if (is_null($user)) {
|
||||||
return $this->json(['result'=>-1]);
|
return $this->json(['result' => -1]);
|
||||||
}
|
}
|
||||||
$perm = $entityManager->getRepository(Permission::class)->findOneBy([
|
$perm = $entityManager->getRepository(Permission::class)->findOneBy([
|
||||||
'user'=>$user,
|
'user' => $user,
|
||||||
'bid'=>$business
|
'bid' => $business
|
||||||
]);
|
]);
|
||||||
if($perm && ! $perm->isOwner()){
|
if ($perm && !$perm->isOwner()) {
|
||||||
$entityManager->remove($perm);
|
$entityManager->remove($perm);
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
//add log to system
|
//add log to system
|
||||||
$log->insert('تنظیمات پایه','کاربر با پست الکترونیکی ' . $params['email'] .' از کسب و کار حذف شد.',$this->getUser(),$business);
|
$log->insert('تنظیمات پایه', 'کاربر با پست الکترونیکی ' . $params['email'] . ' از کسب و کار حذف شد.', $this->getUser(), $business);
|
||||||
return $this->json(['result'=>1]);
|
return $this->json(['result' => 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->json(['result'=>-1]);
|
return $this->json(['result' => -1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/business/my/permission/state', name: 'api_business_my_permission_state')]
|
#[Route('/api/business/my/permission/state', name: 'api_business_my_permission_state')]
|
||||||
public function api_business_my_permission_state(Request $request,Access $access): Response
|
public function api_business_my_permission_state(Request $request, Access $access): Response
|
||||||
{
|
{
|
||||||
$reqdata = json_decode($request->getContent(), true);
|
$reqdata = json_decode($request->getContent(), true);
|
||||||
if(!array_key_exists('permission',$reqdata)){
|
if (!array_key_exists('permission', $reqdata)) {
|
||||||
throw $this->createNotFoundException();
|
throw $this->createNotFoundException();
|
||||||
}
|
}
|
||||||
$acc = $access->hasRole($reqdata['permission']);
|
$acc = $access->hasRole($reqdata['permission']);
|
||||||
if($acc)
|
if ($acc)
|
||||||
return $this->json(['state'=>true]);
|
return $this->json(['state' => true]);
|
||||||
return $this->json(['state'=>false]);
|
return $this->json(['state' => false]);
|
||||||
}
|
}
|
||||||
#[Route('/api/business/get/user/permissions', name: 'api_business_get_user_permission')]
|
#[Route('/api/business/get/user/permissions', name: 'api_business_get_user_permission')]
|
||||||
public function api_business_get_user_permission(Request $request,EntityManagerInterface $entityManager): Response
|
public function api_business_get_user_permission(Request $request, EntityManagerInterface $entityManager): Response
|
||||||
{
|
{
|
||||||
|
|
||||||
$params = [];
|
$params = [];
|
||||||
|
@ -356,131 +357,130 @@ class BusinessController extends AbstractController
|
||||||
$params = json_decode($content, true);
|
$params = json_decode($content, true);
|
||||||
}
|
}
|
||||||
//check for that data is set
|
//check for that data is set
|
||||||
if(
|
if (
|
||||||
trim($params['bid']) != '' &&
|
trim($params['bid']) != '' &&
|
||||||
trim($params['email']) != ''
|
trim($params['email']) != ''
|
||||||
){
|
) {
|
||||||
$business = $entityManager->getRepository(Business::class)->find($params['bid']);
|
$business = $entityManager->getRepository(Business::class)->find($params['bid']);
|
||||||
if(is_null($business)){
|
if (is_null($business)) {
|
||||||
return $this->json(['result'=>-1]);
|
return $this->json(['result' => -1]);
|
||||||
}
|
}
|
||||||
$user = $entityManager->getRepository(User::class)->findOneBy([
|
$user = $entityManager->getRepository(User::class)->findOneBy([
|
||||||
'email' => $params['email']
|
'email' => $params['email']
|
||||||
]);
|
]);
|
||||||
if(is_null($user)){
|
if (is_null($user)) {
|
||||||
return $this->json(['result'=>-1]);
|
return $this->json(['result' => -1]);
|
||||||
}
|
}
|
||||||
$perm = $entityManager->getRepository(Permission::class)->findOneBy([
|
$perm = $entityManager->getRepository(Permission::class)->findOneBy([
|
||||||
'bid'=>$business,
|
'bid' => $business,
|
||||||
'user'=>$user
|
'user' => $user
|
||||||
]);
|
]);
|
||||||
$result = [];
|
$result = [];
|
||||||
if($business->getOwner() == $user){
|
if ($business->getOwner() == $user) {
|
||||||
$result = [
|
$result = [
|
||||||
'id'=>$perm->getUser()->getId(),
|
'id' => $perm->getUser()->getId(),
|
||||||
'user'=>$perm->getUser()->getFullName(),
|
'user' => $perm->getUser()->getFullName(),
|
||||||
'email'=>$perm->getUser()->getEmail(),
|
'email' => $perm->getUser()->getEmail(),
|
||||||
'settings'=>true,
|
'settings' => true,
|
||||||
'persons'=>true,
|
'persons' => true,
|
||||||
'commodity'=>true,
|
'commodity' => true,
|
||||||
'cheque'=>true,
|
'cheque' => true,
|
||||||
'getpay'=>true,
|
'getpay' => true,
|
||||||
'store'=>true,
|
'store' => true,
|
||||||
'bank'=>true,
|
'bank' => true,
|
||||||
'bankTransfer'=>true,
|
'bankTransfer' => true,
|
||||||
'cost'=>true,
|
'cost' => true,
|
||||||
'income'=>true,
|
'income' => true,
|
||||||
'buy'=>true,
|
'buy' => true,
|
||||||
'sell'=>true,
|
'sell' => true,
|
||||||
'accounting'=>true,
|
'accounting' => true,
|
||||||
'report'=>true,
|
'report' => true,
|
||||||
'log'=>true,
|
'log' => true,
|
||||||
'permission'=>true,
|
'permission' => true,
|
||||||
'salary'=>true,
|
'salary' => true,
|
||||||
'cashdesk'=>true,
|
'cashdesk' => true,
|
||||||
'plugNoghreAdmin'=>true,
|
'plugNoghreAdmin' => true,
|
||||||
'plugNoghreSell'=>true,
|
'plugNoghreSell' => true,
|
||||||
'plugCCAdmin'=>true,
|
'plugCCAdmin' => true,
|
||||||
'wallet'=>true,
|
'wallet' => true,
|
||||||
'owner'=> true,
|
'owner' => true,
|
||||||
'archiveUpload'=>true,
|
'archiveUpload' => true,
|
||||||
'archiveMod'=>true,
|
'archiveMod' => true,
|
||||||
'archiveDelete'=>true,
|
'archiveDelete' => true,
|
||||||
'archiveView'=>true,
|
'archiveView' => true,
|
||||||
'active'=> $perm->getUser()->isActive(),
|
'active' => $perm->getUser()->isActive(),
|
||||||
'shareholder'=>true,
|
'shareholder' => true,
|
||||||
];
|
];
|
||||||
}
|
} elseif ($perm) {
|
||||||
elseif($perm){
|
|
||||||
$result = [
|
$result = [
|
||||||
'id'=>$perm->getUser()->getId(),
|
'id' => $perm->getUser()->getId(),
|
||||||
'user'=>$perm->getUser()->getFullName(),
|
'user' => $perm->getUser()->getFullName(),
|
||||||
'email'=>$perm->getUser()->getEmail(),
|
'email' => $perm->getUser()->getEmail(),
|
||||||
'settings'=>$perm->isSettings(),
|
'settings' => $perm->isSettings(),
|
||||||
'persons'=>$perm->isPerson(),
|
'persons' => $perm->isPerson(),
|
||||||
'commodity'=>$perm->isCommodity(),
|
'commodity' => $perm->isCommodity(),
|
||||||
'getpay'=>$perm->isGetpay(),
|
'getpay' => $perm->isGetpay(),
|
||||||
'bank'=>$perm->isBanks(),
|
'bank' => $perm->isBanks(),
|
||||||
'bankTransfer'=>$perm->isBankTransfer(),
|
'bankTransfer' => $perm->isBankTransfer(),
|
||||||
'cost'=>$perm->isCost(),
|
'cost' => $perm->isCost(),
|
||||||
'income'=>$perm->isIncome(),
|
'income' => $perm->isIncome(),
|
||||||
'buy'=>$perm->isBuy(),
|
'buy' => $perm->isBuy(),
|
||||||
'cheque'=>$perm->isCheque(),
|
'cheque' => $perm->isCheque(),
|
||||||
'sell'=>$perm->isSell(),
|
'sell' => $perm->isSell(),
|
||||||
'accounting'=>$perm->isAccounting(),
|
'accounting' => $perm->isAccounting(),
|
||||||
'report'=>$perm->isReport(),
|
'report' => $perm->isReport(),
|
||||||
'log'=>$perm->isLog(),
|
'log' => $perm->isLog(),
|
||||||
'store'=>$perm->isStore(),
|
'store' => $perm->isStore(),
|
||||||
'permission'=>$perm->isPermission(),
|
'permission' => $perm->isPermission(),
|
||||||
'salary'=>$perm->isSalary(),
|
'salary' => $perm->isSalary(),
|
||||||
'cashdesk'=>$perm->isCashdesk(),
|
'cashdesk' => $perm->isCashdesk(),
|
||||||
'plugNoghreAdmin'=>$perm->isPlugNoghreAdmin(),
|
'plugNoghreAdmin' => $perm->isPlugNoghreAdmin(),
|
||||||
'plugNoghreSell'=>$perm->isPlugNoghreSell(),
|
'plugNoghreSell' => $perm->isPlugNoghreSell(),
|
||||||
'plugCCAdmin'=>$perm->isPlugCCAdmin(),
|
'plugCCAdmin' => $perm->isPlugCCAdmin(),
|
||||||
'wallet'=>$perm->isWallet(),
|
'wallet' => $perm->isWallet(),
|
||||||
'owner'=> false,
|
'owner' => false,
|
||||||
'archiveUpload'=>$perm->isArchiveUpload(),
|
'archiveUpload' => $perm->isArchiveUpload(),
|
||||||
'archiveMod'=>$perm->isArchiveMod(),
|
'archiveMod' => $perm->isArchiveMod(),
|
||||||
'archiveDelete'=>$perm->isArchiveDelete(),
|
'archiveDelete' => $perm->isArchiveDelete(),
|
||||||
'archiveView'=>$perm->isArchiveView(),
|
'archiveView' => $perm->isArchiveView(),
|
||||||
'active'=> $perm->getUser()->isActive(),
|
'active' => $perm->getUser()->isActive(),
|
||||||
'shareholder'=> $perm->isShareholder(),
|
'shareholder' => $perm->isShareholder(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return $this->json($result);
|
return $this->json($result);
|
||||||
}
|
}
|
||||||
return $this->json(['result'=>-1]);
|
return $this->json(['result' => -1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/business/save/user/permissions', name: 'api_business_save_user_permission')]
|
#[Route('/api/business/save/user/permissions', name: 'api_business_save_user_permission')]
|
||||||
public function api_business_save_user_permission(Access $access,Log $log,Request $request,EntityManagerInterface $entityManager): Response
|
public function api_business_save_user_permission(Access $access, Log $log, Request $request, EntityManagerInterface $entityManager): Response
|
||||||
{
|
{
|
||||||
if(!$access->hasRole('permission'))
|
if (!$access->hasRole('permission'))
|
||||||
throw $this->createAccessDeniedException();
|
throw $this->createAccessDeniedException();
|
||||||
$params = [];
|
$params = [];
|
||||||
if ($content = $request->getContent()) {
|
if ($content = $request->getContent()) {
|
||||||
$params = json_decode($content, true);
|
$params = json_decode($content, true);
|
||||||
}
|
}
|
||||||
//check for that data is set
|
//check for that data is set
|
||||||
if(
|
if (
|
||||||
trim($params['bid']) != '' &&
|
trim($params['bid']) != '' &&
|
||||||
trim($params['email']) != ''
|
trim($params['email']) != ''
|
||||||
){
|
) {
|
||||||
$business = $entityManager->getRepository(Business::class)->find($params['bid']);
|
$business = $entityManager->getRepository(Business::class)->find($params['bid']);
|
||||||
if(is_null($business)){
|
if (is_null($business)) {
|
||||||
return $this->json(['result'=>-1]);
|
return $this->json(['result' => -1]);
|
||||||
}
|
}
|
||||||
$user = $entityManager->getRepository(User::class)->findOneBy([
|
$user = $entityManager->getRepository(User::class)->findOneBy([
|
||||||
'email' => $params['email']
|
'email' => $params['email']
|
||||||
]);
|
]);
|
||||||
if(is_null($user)){
|
if (is_null($user)) {
|
||||||
return $this->json(['result'=>-1]);
|
return $this->json(['result' => -1]);
|
||||||
}
|
}
|
||||||
$perm = $entityManager->getRepository(Permission::class)->findOneBy([
|
$perm = $entityManager->getRepository(Permission::class)->findOneBy([
|
||||||
'bid'=>$business,
|
'bid' => $business,
|
||||||
'user'=>$user
|
'user' => $user
|
||||||
]);
|
]);
|
||||||
if($perm){
|
if ($perm) {
|
||||||
$perm->setSettings($params['settings']);
|
$perm->setSettings($params['settings']);
|
||||||
$perm->setPerson($params['persons']);
|
$perm->setPerson($params['persons']);
|
||||||
$perm->setGetpay($params['getpay']);
|
$perm->setGetpay($params['getpay']);
|
||||||
|
@ -510,74 +510,74 @@ class BusinessController extends AbstractController
|
||||||
$perm->setShareholder($params['shareholder']);
|
$perm->setShareholder($params['shareholder']);
|
||||||
$entityManager->persist($perm);
|
$entityManager->persist($perm);
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
$log->insert('تنظیمات پایه','ویرایش دسترسیهای کاربر با پست الکترونیکی ' . $user->getEmail() ,$this->getUser(),$business);
|
$log->insert('تنظیمات پایه', 'ویرایش دسترسیهای کاربر با پست الکترونیکی ' . $user->getEmail(), $this->getUser(), $business);
|
||||||
|
|
||||||
return $this->json(['result'=>1]);
|
return $this->json(['result' => 1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->json(['result'=>-1]);
|
return $this->json(['result' => -1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/business/stat', name: 'api_business_stat')]
|
#[Route('/api/business/stat', name: 'api_business_stat')]
|
||||||
public function api_business_stat(Request $request,#[CurrentUser] ?User $user,EntityManagerInterface $entityManager): Response
|
public function api_business_stat(Request $request, #[CurrentUser] ?User $user, EntityManagerInterface $entityManager): Response
|
||||||
{
|
{
|
||||||
$buss = $entityManager->getRepository(Business::class)->find(
|
$buss = $entityManager->getRepository(Business::class)->find(
|
||||||
$request->headers->get('activeBid')
|
$request->headers->get('activeBid')
|
||||||
);
|
);
|
||||||
if(!$buss)
|
if (!$buss)
|
||||||
throw $this->createNotFoundException();
|
throw $this->createNotFoundException();
|
||||||
|
|
||||||
$year = $entityManager->getRepository(Year::class)->find(
|
$year = $entityManager->getRepository(Year::class)->find(
|
||||||
$request->headers->get('activeYear')
|
$request->headers->get('activeYear')
|
||||||
);
|
);
|
||||||
if(!$year)
|
if (!$year)
|
||||||
throw $this->createNotFoundException();
|
throw $this->createNotFoundException();
|
||||||
$persons = $entityManager->getRepository(Person::class)->findBy([
|
$persons = $entityManager->getRepository(Person::class)->findBy([
|
||||||
'bid'=>$buss
|
'bid' => $buss
|
||||||
]);
|
]);
|
||||||
$banks = $entityManager->getRepository(BankAccount::class)->findBy([
|
$banks = $entityManager->getRepository(BankAccount::class)->findBy([
|
||||||
'bid'=>$buss
|
'bid' => $buss
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$docs = $entityManager->getRepository(HesabdariDoc::class)->findBy([
|
$docs = $entityManager->getRepository(HesabdariDoc::class)->findBy([
|
||||||
'bid'=>$buss,
|
'bid' => $buss,
|
||||||
'year'=>$year,
|
'year' => $year,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$rows = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
$rows = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||||
'bid'=>$buss,
|
'bid' => $buss,
|
||||||
'year'=>$year
|
'year' => $year
|
||||||
]);
|
]);
|
||||||
$bssum = 0;
|
$bssum = 0;
|
||||||
foreach ($rows as $row)
|
foreach ($rows as $row)
|
||||||
$bssum += $row->getBs();
|
$bssum += $row->getBs();
|
||||||
$buys = $entityManager->getRepository(HesabdariDoc::class)->findBy([
|
$buys = $entityManager->getRepository(HesabdariDoc::class)->findBy([
|
||||||
'bid'=>$buss,
|
'bid' => $buss,
|
||||||
'year'=>$year,
|
'year' => $year,
|
||||||
'type'=>'buy',
|
'type' => 'buy',
|
||||||
]);
|
]);
|
||||||
$buysTotal = 0;
|
$buysTotal = 0;
|
||||||
foreach($buys as $item)
|
foreach ($buys as $item)
|
||||||
$buysTotal += $item->getAmount();
|
$buysTotal += $item->getAmount();
|
||||||
|
|
||||||
$sells = $entityManager->getRepository(HesabdariDoc::class)->findBy([
|
$sells = $entityManager->getRepository(HesabdariDoc::class)->findBy([
|
||||||
'bid'=>$buss,
|
'bid' => $buss,
|
||||||
'year'=>$year,
|
'year' => $year,
|
||||||
'type'=>'sell',
|
'type' => 'sell',
|
||||||
]);
|
]);
|
||||||
$sellsTotal = 0;
|
$sellsTotal = 0;
|
||||||
foreach($sells as $item)
|
foreach ($sells as $item)
|
||||||
$sellsTotal += $item->getAmount();
|
$sellsTotal += $item->getAmount();
|
||||||
$response = [
|
$response = [
|
||||||
'personCount'=>count($persons),
|
'personCount' => count($persons),
|
||||||
'bankCount'=>count($banks),
|
'bankCount' => count($banks),
|
||||||
'docCount'=>count($docs),
|
'docCount' => count($docs),
|
||||||
'income'=> $bssum,
|
'income' => $bssum,
|
||||||
'commodity'=>count($entityManager->getRepository(Commodity::class)->findby([
|
'commodity' => count($entityManager->getRepository(Commodity::class)->findby([
|
||||||
'bid'=>$buss
|
'bid' => $buss
|
||||||
])),
|
])),
|
||||||
'buys_total'=>$buysTotal,
|
'buys_total' => $buysTotal,
|
||||||
'sells_total'=>$sellsTotal,
|
'sells_total' => $sellsTotal,
|
||||||
];
|
];
|
||||||
return $this->json($response);
|
return $this->json($response);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ use Symfony\Component\Serializer\SerializerInterface;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class PersonsController extends AbstractController
|
class PersonsController extends AbstractController
|
||||||
{
|
{
|
||||||
|
@ -208,8 +209,8 @@ class PersonsController extends AbstractController
|
||||||
return $this->json(['result' => 1]);
|
return $this->json(['result' => 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/person/list', name: 'app_persons_list')]
|
#[Route('/api/person/list/limit', name: 'app_persons_list_limit')]
|
||||||
public function app_persons_list(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse
|
public function app_persons_list_limit(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): JsonResponse
|
||||||
{
|
{
|
||||||
if(!$access->hasRole('person'))
|
if(!$access->hasRole('person'))
|
||||||
throw $this->createAccessDeniedException();
|
throw $this->createAccessDeniedException();
|
||||||
|
@ -228,7 +229,38 @@ class PersonsController extends AbstractController
|
||||||
'bid'=>$request->headers->get('activeBid')
|
'bid'=>$request->headers->get('activeBid')
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$response = $provider->ArrayEntity2Array($persons,0);
|
$response = [];
|
||||||
|
foreach ($persons as $key =>$person){
|
||||||
|
$response[] = [
|
||||||
|
'id' => $person->getId(),
|
||||||
|
'nikename'=>$person->getNikename(),
|
||||||
|
'code' =>$person->getCode(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return $this->json($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/api/person/list', name: 'app_persons_list')]
|
||||||
|
public function app_persons_list(Provider $provider,Request $request,Access $access,Log $log,EntityManagerInterface $entityManager): Response
|
||||||
|
{
|
||||||
|
if(!$access->hasRole('person'))
|
||||||
|
throw $this->createAccessDeniedException();
|
||||||
|
$params = [];
|
||||||
|
if ($content = $request->getContent()) {
|
||||||
|
$params = json_decode($content, true);
|
||||||
|
}
|
||||||
|
if(array_key_exists('speedAccess',$params)){
|
||||||
|
$persons = $entityManager->getRepository(Person::class)->findBy([
|
||||||
|
'bid'=>$request->headers->get('activeBid'),
|
||||||
|
'speedAccess'=>true
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$persons = $entityManager->getRepository(Person::class)->findBy([
|
||||||
|
'bid'=>$request->headers->get('activeBid')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
$response = Explore::ExplorePersons($persons,$entityManager->getRepository(PersonType::class)->findAll());
|
||||||
foreach ($persons as $key =>$person){
|
foreach ($persons as $key =>$person){
|
||||||
$rows = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
$rows = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||||
'person'=>$person
|
'person'=>$person
|
||||||
|
@ -243,7 +275,7 @@ class PersonsController extends AbstractController
|
||||||
$response[$key]['bd'] = $bd;
|
$response[$key]['bd'] = $bd;
|
||||||
$response[$key]['balance'] = $bs - $bd;
|
$response[$key]['balance'] = $bs - $bd;
|
||||||
}
|
}
|
||||||
return $this->json($response);
|
return new Response(json_encode($response));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/person/list/debtors/{amount}', name: 'app_persons_list_debtors')]
|
#[Route('/api/person/list/debtors/{amount}', name: 'app_persons_list_debtors')]
|
||||||
|
|
86
hesabixCore/src/Controller/ReportController.php
Normal file
86
hesabixCore/src/Controller/ReportController.php
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Entity\HesabdariDoc;
|
||||||
|
use App\Entity\HesabdariRow;
|
||||||
|
use App\Entity\Person;
|
||||||
|
use App\Service\Access;
|
||||||
|
use App\Service\pdfMGR;
|
||||||
|
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 ReportController extends AbstractController
|
||||||
|
{
|
||||||
|
#[Route('/api/report/person/buysell', name: 'app_report_person_buysell')]
|
||||||
|
public function app_report_person_buysell(Access $access, Request $request, EntityManagerInterface $entityManagerInterface): JsonResponse
|
||||||
|
{
|
||||||
|
$acc = $access->hasRole('reports');
|
||||||
|
if (!$acc) {
|
||||||
|
throw $this->createAccessDeniedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = [];
|
||||||
|
if ($content = $request->getContent()) {
|
||||||
|
$params = json_decode($content, true);
|
||||||
|
}
|
||||||
|
$docs = $entityManagerInterface->getRepository(HesabdariDoc::class)->findBy([
|
||||||
|
'year' => $acc['year'],
|
||||||
|
'bid' => $acc['bid'],
|
||||||
|
'type' => $params['type'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$person = $entityManagerInterface->getRepository(Person::class)->findOneBy([
|
||||||
|
'bid' => $acc['bid']->getId(),
|
||||||
|
'code' => $params['person'],
|
||||||
|
]);
|
||||||
|
$result = [];
|
||||||
|
foreach ($docs as $doc) {
|
||||||
|
$rows = $doc->getHesabdariRows();
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
if ($row->getPerson()) {
|
||||||
|
if ($person->getId() == $row->getPerson()->getId()) {
|
||||||
|
$result[] = $doc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$docs = $result;
|
||||||
|
$result = [];
|
||||||
|
foreach ($docs as $doc) {
|
||||||
|
$rows = $doc->getHesabdariRows();
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
if ($row->getCommodity()) {
|
||||||
|
$result[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$response = [];
|
||||||
|
foreach ($result as $item) {
|
||||||
|
$temp = [
|
||||||
|
'id' => $item->getCommodity()->getId(),
|
||||||
|
'code' => $item->getCommodity()->getCode(),
|
||||||
|
'khadamat' => $item->getCommodity()->isKhadamat(),
|
||||||
|
'name' => $item->getCommodity()->getName(),
|
||||||
|
'unit' => $item->getCommodity()->getUnit()->getName(),
|
||||||
|
'count' => $item->getCommdityCount(),
|
||||||
|
];
|
||||||
|
if ($params['type'] == 'buy') {
|
||||||
|
$temp['priceAll'] = $item->getBd();
|
||||||
|
} elseif ($params['type'] == 'sell') {
|
||||||
|
$temp['priceAll'] = $item->getBs();
|
||||||
|
}
|
||||||
|
if ($temp['count'] != 0) {
|
||||||
|
$temp['priceOne'] = $temp['priceAll'] / $temp['count'];
|
||||||
|
$temp['priceAll'] = number_format($temp['priceAll']);
|
||||||
|
$temp['priceOne'] = number_format($temp['priceOne']);
|
||||||
|
$temp['count'] = number_format($temp['count']);
|
||||||
|
$response[] = $temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->json($response);
|
||||||
|
}
|
||||||
|
}
|
|
@ -181,7 +181,6 @@ class Explore{
|
||||||
'fax' => $person->getFax(),
|
'fax' => $person->getFax(),
|
||||||
'birthday' => $person->getBirthday(),
|
'birthday' => $person->getBirthday(),
|
||||||
'speedAccess'=>$person->isSpeedAccess(),
|
'speedAccess'=>$person->isSpeedAccess(),
|
||||||
|
|
||||||
];
|
];
|
||||||
$res['accounts'] = self::ExplorePersonCards($person);
|
$res['accounts'] = self::ExplorePersonCards($person);
|
||||||
$res['types'] = self::ExplorePersonTypes($typesAll);
|
$res['types'] = self::ExplorePersonTypes($typesAll);
|
||||||
|
@ -196,12 +195,13 @@ class Explore{
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public static function ExplorePersons($items){
|
public static function ExplorePersons($items,$types){
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach($items as $item)
|
foreach($items as $item)
|
||||||
$result[] = self::ExplorePerson($item);
|
$result[] = self::ExplorePerson($item,$types);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function ExplorePersonCards(Person $person){
|
public static function ExplorePersonCards(Person $person){
|
||||||
$res = [];
|
$res = [];
|
||||||
foreach($person->getPersonCards() as $item){
|
foreach($person->getPersonCards() as $item){
|
||||||
|
|
Loading…
Reference in a new issue