sync with new ui of hesabiUI
This commit is contained in:
parent
5dd4818f63
commit
d1510f5cae
|
@ -13,6 +13,7 @@ use App\Entity\Settings;
|
|||
use App\Entity\StoreroomTicket;
|
||||
use App\Entity\User;
|
||||
use App\Entity\WalletTransaction;
|
||||
use App\Service\Extractor;
|
||||
use App\Service\Jdate;
|
||||
use App\Service\JsonResp;
|
||||
use App\Service\Notification;
|
||||
|
@ -63,22 +64,6 @@ class AdminController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
#[Route('/api/admin/has/role/{role}', name: 'app_admin_has_role')]
|
||||
public function app_admin_has_role($role): JsonResponse
|
||||
{
|
||||
if (!is_bool(array_search($role, $this->getUser()->getRoles()))) {
|
||||
return $this->json([
|
||||
'result' => true,
|
||||
]);
|
||||
}
|
||||
return $this->json([
|
||||
'result' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
#[Route('/api/admin/users/list', name: 'admin_users_list')]
|
||||
public function admin_users_list(Jdate $jdate, #[CurrentUser] ?User $user, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
{
|
||||
|
@ -153,8 +138,14 @@ class AdminController extends AbstractController
|
|||
return $this->json($entityManager->getRepository(Business::class)->countAll());
|
||||
}
|
||||
|
||||
#[Route('/api/admin/users/count', name: 'admin_users_count')]
|
||||
public function admin_users_count(Extractor $extractor, #[CurrentUser] ?User $user, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
{
|
||||
return $this->json($extractor->operationSuccess($entityManager->getRepository(User::class)->countAll()));
|
||||
}
|
||||
|
||||
#[Route('/api/admin/business/search', name: 'admin_business_list_search')]
|
||||
public function admin_business_list_search(Jdate $jdate, #[CurrentUser] ?User $user, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
public function admin_business_list_search(Extractor $extractor,Jdate $jdate, #[CurrentUser] ?User $user, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
|
@ -175,7 +166,30 @@ class AdminController extends AbstractController
|
|||
$temp['StoreroomDocsCount'] = count($entityManager->getRepository(StoreroomTicket::class)->findBy(['bid' => $item]));
|
||||
$resp[] = $temp;
|
||||
}
|
||||
return $this->json($resp);
|
||||
return $this->json($extractor->operationSuccess($resp));
|
||||
}
|
||||
|
||||
#[Route('/api/admin/users/search', name: 'admin_users_list_search')]
|
||||
public function admin_users_list_search(Extractor $extractor,Jdate $jdate, #[CurrentUser] ?User $user, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
$items = $entityManager->getRepository(User::class)->findByPage($params['options']['page'],$params['options']['rowsPerPage'],$params['search']);
|
||||
$resp = [];
|
||||
foreach ($items as $item) {
|
||||
$temp = [];
|
||||
$temp['id'] = $item->getId();
|
||||
$temp['email'] = $item->getEmail();
|
||||
$temp['mobile'] = $item->getMobile();
|
||||
$temp['fullname'] = $item->getFullName();
|
||||
$temp['status'] = $item->isActive();
|
||||
$temp['dateRegister'] = $jdate->jdate('Y/n/d', $item->getDateRegister());
|
||||
$temp['bidCount'] = count($entityManager->getRepository(Business::class)->findBy(['owner' => $item]));
|
||||
$resp[] = $temp;
|
||||
}
|
||||
return $this->json($extractor->operationSuccess($resp));
|
||||
}
|
||||
|
||||
#[Route('/api/admin/settings/sms/info', name: 'admin_settings_sms_info')]
|
||||
|
@ -544,7 +558,7 @@ class AdminController extends AbstractController
|
|||
]);
|
||||
}
|
||||
#[Route('/api/admin/logs/last', name: 'api_admin_logs_last')]
|
||||
public function api_admin_logs_last(Jdate $jdate, EntityManagerInterface $entityManager): JsonResponse
|
||||
public function api_admin_logs_last(Extractor $extractor,Jdate $jdate, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$logs = $entityManager->getRepository(\App\Entity\Log::class)->findBy([], ['id' => 'DESC'], 250);
|
||||
$temps = [];
|
||||
|
@ -562,7 +576,7 @@ class AdminController extends AbstractController
|
|||
$temp['ipaddress'] = $log->getIpaddress();
|
||||
$temps[] = $temp;
|
||||
}
|
||||
return $this->json(array_reverse($temps));
|
||||
return $this->json($extractor->operationSuccess(array_reverse($temps)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,13 +18,14 @@ use Symfony\Component\String\Slugger\SluggerInterface;
|
|||
class AvatarController extends AbstractController
|
||||
{
|
||||
#[Route('/front/avatar/file/get/{id}', name: 'front_avatar_file_get')]
|
||||
public function front_avatar_file_get(string $id,EntityManagerInterface $entityManager,$code = 0): BinaryFileResponse
|
||||
public function front_avatar_file_get(EntityManagerInterface $entityManager, string $id = '0'): BinaryFileResponse
|
||||
{
|
||||
$bid = $entityManager->getRepository(Business::class)->find($id);
|
||||
if (!$bid)
|
||||
throw $this->createNotFoundException();
|
||||
return new BinaryFileResponse(dirname(__DIR__, 3) . '/hesabixArchive/avatars/default.png');
|
||||
$fileAdr = dirname(__DIR__, 3) . '/hesabixArchive/avatars/' . $bid->getAvatar();
|
||||
if(!$bid->getAvatar()) return new BinaryFileResponse(dirname(__DIR__,3) . '/hesabixArchive/avatars/default.png');
|
||||
if (!$bid->getAvatar())
|
||||
return new BinaryFileResponse(dirname(__DIR__, 3) . '/hesabixArchive/avatars/default.png');
|
||||
$response = new BinaryFileResponse($fileAdr);
|
||||
return $response;
|
||||
}
|
||||
|
@ -33,7 +34,8 @@ class AvatarController extends AbstractController
|
|||
public function api_avatar_get(Access $access): Response
|
||||
{
|
||||
$acc = $access->hasRole('settings');
|
||||
if (!$acc) throw $this->createAccessDeniedException();
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
if ($acc['bid']->getAvatar()) {
|
||||
return new Response($acc['bid']->getAvatar());
|
||||
}
|
||||
|
@ -54,7 +56,8 @@ class AvatarController extends AbstractController
|
|||
public function api_avatar_post(Log $log, SluggerInterface $slugger, Request $request, Access $access, EntityManagerInterface $entityManagerInterface): Response
|
||||
{
|
||||
$acc = $access->hasRole('owner');
|
||||
if (!$acc) throw $this->createAccessDeniedException();
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
|
||||
$uploadedFile = $request->files->get('bytes');
|
||||
if ($uploadedFile) {
|
||||
|
@ -66,15 +69,13 @@ class AvatarController extends AbstractController
|
|||
$extOK = false;
|
||||
if ($ext == 'png' || $ext == 'jpg' || $ext == 'jpeg') {
|
||||
$extOK = true;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return new Response('e');
|
||||
}
|
||||
$sizeOK = false;
|
||||
if ($uploadedFile->getSize() < 1000000) {
|
||||
$sizeOK = true;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return new Response('s');
|
||||
}
|
||||
$imgSizeOK = false;
|
||||
|
@ -82,8 +83,7 @@ class AvatarController extends AbstractController
|
|||
list($x, $y) = $info;
|
||||
if ($x < 513 && $y < 513) {
|
||||
$imgSizeOK = true;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return new Response('is');
|
||||
}
|
||||
if ($extOK && $sizeOK && $imgSizeOK) {
|
||||
|
|
|
@ -70,14 +70,20 @@ class BusinessController extends AbstractController
|
|||
return $this->json($extractor->operationSuccess());
|
||||
}
|
||||
#[Route('/api/business/list', name: 'api_bussiness_list')]
|
||||
public function api_bussiness_list(#[CurrentUser] ?User $user, Access $access, Explore $explore, EntityManagerInterface $entityManager, Provider $provider): Response
|
||||
public function api_bussiness_list(Extractor $extractor, Request $request, #[CurrentUser] ?User $user, Access $access, Explore $explore, EntityManagerInterface $entityManager, Provider $provider): Response
|
||||
{
|
||||
|
||||
$buss = $entityManager->getRepository(Permission::class)->findBy(['user' => $user]);
|
||||
$buss = $entityManager->getRepository(Permission::class)->findBy([
|
||||
'user' => $user
|
||||
]);
|
||||
$response = [];
|
||||
foreach ($buss as $bus) {
|
||||
$response[] = Explore::ExploreBusiness($bus->getBid());
|
||||
}
|
||||
$params = $request->getPayload()->all();
|
||||
if (array_key_exists('standard', $params)) {
|
||||
return $this->json($extractor->operationSuccess($response));
|
||||
}
|
||||
return $this->json($response);
|
||||
}
|
||||
|
||||
|
@ -202,8 +208,7 @@ class BusinessController extends AbstractController
|
|||
}
|
||||
if (array_key_exists('commodityUpdateSellPriceAuto', $params)) {
|
||||
$business->setCommodityUpdateSellPriceAuto($params['commodityUpdateSellPriceAuto']);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$business->setCommodityUpdateSellPriceAuto(true);
|
||||
}
|
||||
if (array_key_exists('walletEnabled', $params)) {
|
||||
|
@ -441,18 +446,18 @@ class BusinessController extends AbstractController
|
|||
return $this->json(['state' => false]);
|
||||
}
|
||||
#[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(Access $access, Request $request, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$acc = $access->hasRole('join');
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
//check for that data is set
|
||||
if (
|
||||
trim($params['bid']) != '' &&
|
||||
trim($params['email']) != ''
|
||||
) {
|
||||
if (array_key_exists('bid', $params) && array_key_exists('email', $params)) {
|
||||
$business = $entityManager->getRepository(Business::class)->find($params['bid']);
|
||||
if (is_null($business)) {
|
||||
return $this->json(['result' => -1]);
|
||||
|
@ -463,6 +468,13 @@ class BusinessController extends AbstractController
|
|||
if (is_null($user)) {
|
||||
return $this->json(['result' => -1]);
|
||||
}
|
||||
} else {
|
||||
$business = $entityManager->getRepository(Business::class)->find($acc['bid']);
|
||||
if (is_null($business)) {
|
||||
return $this->json(['result' => -1]);
|
||||
}
|
||||
$user = $this->getUser();
|
||||
}
|
||||
$perm = $entityManager->getRepository(Permission::class)->findOneBy([
|
||||
'bid' => $business,
|
||||
'user' => $user
|
||||
|
@ -550,7 +562,6 @@ class BusinessController extends AbstractController
|
|||
];
|
||||
}
|
||||
return $this->json($result);
|
||||
}
|
||||
return $this->json(['result' => -1]);
|
||||
}
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ class UiGeneralController extends AbstractController
|
|||
return $this->render('general/hesabixbox.html.twig',);
|
||||
}
|
||||
|
||||
#[Route('/api/system/get/data', name: 'general_apps_get_data')]
|
||||
#[Route('/front/system/get/data', name: 'general_apps_get_data')]
|
||||
public function general_apps_get_data(EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$settings = $entityManager->getRepository(Settings::class)->findAll()[0];
|
||||
|
|
|
@ -18,7 +18,7 @@ use Symfony\Component\Routing\Annotation\Route;
|
|||
class MoneyController extends AbstractController
|
||||
{
|
||||
#[Route('/api/money/get/all', name: 'app_money_get_all')]
|
||||
public function app_money_get_all(EntityManagerInterface $entityManager): JsonResponse
|
||||
public function app_money_get_all(Extractor $extractor,EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$result = $entityManager->getRepository(Money::class)->findAll();
|
||||
$out = [];
|
||||
|
@ -28,11 +28,11 @@ class MoneyController extends AbstractController
|
|||
$temp['label'] = $item->getLabel();
|
||||
$out[] = $temp;
|
||||
}
|
||||
return $this->json($out);
|
||||
return $this->json($extractor->operationSuccess($out));
|
||||
}
|
||||
|
||||
#[Route('/api/money/get/info', name: 'app_money_get_info')]
|
||||
public function app_money_get_info(Log $log, Request $request, Extractor $extractor, EntityManagerInterface $entityManager, Access $access): JsonResponse
|
||||
public function app_money_get_info(Request $request, Extractor $extractor, EntityManagerInterface $entityManager, Access $access): JsonResponse
|
||||
{
|
||||
$acc = $access->hasRole('join');
|
||||
if (!$acc)
|
||||
|
@ -48,7 +48,7 @@ class MoneyController extends AbstractController
|
|||
]);
|
||||
if (!$money)
|
||||
throw $this->createNotFoundException();
|
||||
return $this->json(Explore::ExploreMoney($money));
|
||||
return $this->json($extractor->operationSuccess(Explore::ExploreMoney($money)));
|
||||
|
||||
}
|
||||
#[Route('/api/money/remove', name: 'app_money_remove')]
|
||||
|
|
|
@ -5,6 +5,8 @@ namespace App\Controller;
|
|||
use App\Entity\Settings;
|
||||
use App\Entity\Support;
|
||||
use App\Entity\User;
|
||||
use App\Service\Explore;
|
||||
use App\Service\Extractor;
|
||||
use App\Service\Jdate;
|
||||
use App\Service\Notification;
|
||||
use App\Service\Provider;
|
||||
|
@ -20,34 +22,47 @@ use Symfony\Component\Serializer\SerializerInterface;
|
|||
|
||||
class SupportController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* function to generate random strings
|
||||
* @param int $length number of characters in the generated string
|
||||
* @return string a new string is created with random characters of the desired length
|
||||
*/
|
||||
private function RandomString($length = 32)
|
||||
{
|
||||
return substr(str_shuffle(str_repeat($x = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
|
||||
}
|
||||
|
||||
#[Route('/api/admin/support/list', name: 'app_admin_support_list')]
|
||||
public function app_admin_support_list(Provider $provider, Jdate $jdate, EntityManagerInterface $entityManager): JsonResponse
|
||||
public function app_admin_support_list(Extractor $extractor, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$items = $entityManager->getRepository(Support::class)->findBy(['main' => 0], ['id' => 'DESC']);
|
||||
$res = [];
|
||||
foreach ($items as $item) {
|
||||
$item->setDateSubmit($jdate->jdate('Y/n/d H:i', $item->getDateSubmit()));
|
||||
$res[] = Explore::ExploreSupportTicket($item, $this->getUser());
|
||||
}
|
||||
return $this->json($provider->ArrayEntity2Array($items, 1));
|
||||
return $this->json($extractor->operationSuccess($res));
|
||||
}
|
||||
#[Route('/api/admin/support/view/{id}', name: 'app_admin_support_view')]
|
||||
public function app_admin_support_view(Jdate $jdate, EntityManagerInterface $entityManager, string $id = ''): JsonResponse
|
||||
public function app_admin_support_view(Extractor $extractor, Jdate $jdate, EntityManagerInterface $entityManager, string $id = ''): JsonResponse
|
||||
{
|
||||
$item = $entityManager->getRepository(Support::class)->find($id);
|
||||
if (!$item) throw $this->createNotFoundException();
|
||||
if (!$item)
|
||||
throw $this->createNotFoundException();
|
||||
$replays = $entityManager->getRepository(Support::class)->findBy(['main' => $item->getId()]);
|
||||
$res = [];
|
||||
foreach ($replays as $replay) {
|
||||
$replay->setDateSubmit($jdate->jdate('Y/n/d H:i', $replay->getDateSubmit()));
|
||||
$replay->setTitle($replay->getSubmitter()->getFullname());
|
||||
if ($replay->getSubmitter() == $this->getUser())
|
||||
$replay->setState(1);
|
||||
else
|
||||
$replay->setState(0);
|
||||
$res[] = Explore::ExploreSupportTicket($replay, $this->getUser());
|
||||
}
|
||||
$item->setDateSubmit($jdate->jdate('Y/n/d H:i', $item->getDateSubmit()));
|
||||
return $this->json([
|
||||
'item' => $item,
|
||||
'replays' => $replays
|
||||
]);
|
||||
return $this->json(
|
||||
$extractor->operationSuccess([
|
||||
'item' => Explore::ExploreSupportTicket($item, $this->getUser()),
|
||||
'replays' => $res
|
||||
])
|
||||
);
|
||||
}
|
||||
#[Route('/api/admin/support/mod/{id}', name: 'app_admin_support_mod')]
|
||||
public function app_admin_support_mod(registryMGR $registryMGR, SMS $SMS, Request $request, EntityManagerInterface $entityManager, Notification $notifi, string $id = ''): JsonResponse
|
||||
|
@ -58,7 +73,8 @@ class SupportController extends AbstractController
|
|||
}
|
||||
|
||||
$item = $entityManager->getRepository(Support::class)->find($id);
|
||||
if (!$item) $this->createNotFoundException();
|
||||
if (!$item)
|
||||
$this->createNotFoundException();
|
||||
if (array_key_exists('body', $params)) {
|
||||
$support = new Support();
|
||||
$support->setDateSubmit(time());
|
||||
|
@ -82,7 +98,7 @@ class SupportController extends AbstractController
|
|||
}
|
||||
//send notification to user
|
||||
$settings = $entityManager->getRepository(Settings::class)->findAll()[0];
|
||||
$url = $settings->getAppSite() . '/profile/support-view/' . $item->getId();
|
||||
$url = '/profile/support-view/' . $item->getId();
|
||||
$notifi->insert("به درخواست پشتیبانی پاسخ داده شد", $url, null, $item->getSubmitter());
|
||||
return $this->json([
|
||||
'error' => 0,
|
||||
|
@ -107,7 +123,7 @@ class SupportController extends AbstractController
|
|||
]
|
||||
);
|
||||
foreach ($items as $item) {
|
||||
$item->setDateSubmit($jdate->jdate('Y/n/d H:i', $item->getDateSubmit()));
|
||||
$item->setDateSubmit($jdate->jdate('Y/n/d', $item->getDateSubmit()));
|
||||
}
|
||||
return $this->json($items);
|
||||
}
|
||||
|
@ -127,6 +143,7 @@ class SupportController extends AbstractController
|
|||
$item->setDateSubmit(time());
|
||||
$item->setSubmitter($this->getUser());
|
||||
$item->setMain(0);
|
||||
$item->setCode($this->RandomString(8));
|
||||
$item->setState('در حال پیگیری');
|
||||
$entityManager->persist($item);
|
||||
$entityManager->flush();
|
||||
|
@ -149,6 +166,7 @@ class SupportController extends AbstractController
|
|||
$upper = $entityManager->getRepository(Support::class)->find($id);
|
||||
if ($upper)
|
||||
$item->setMain($upper->getid());
|
||||
|
||||
$item->setBody($params['body']);
|
||||
$item->setTitle($upper->getTitle());
|
||||
$item->setDateSubmit(time());
|
||||
|
@ -183,21 +201,18 @@ class SupportController extends AbstractController
|
|||
public function app_support_view(Jdate $jdate, EntityManagerInterface $entityManager, string $id = ''): JsonResponse
|
||||
{
|
||||
$item = $entityManager->getRepository(Support::class)->find($id);
|
||||
if (!$item) throw $this->createNotFoundException();
|
||||
if ($item->getSubmitter() != $this->getUser()) throw $this->createAccessDeniedException();
|
||||
if (!$item)
|
||||
throw $this->createNotFoundException();
|
||||
if ($item->getSubmitter() != $this->getUser())
|
||||
throw $this->createAccessDeniedException();
|
||||
$replays = $entityManager->getRepository(Support::class)->findBy(['main' => $item->getId()]);
|
||||
$replaysArray = [];
|
||||
foreach ($replays as $replay) {
|
||||
$replay->setDateSubmit($jdate->jdate('Y/n/d H:i', $replay->getDateSubmit()));
|
||||
$replay->setTitle($replay->getSubmitter()->getFullname());
|
||||
if ($replay->getSubmitter() == $this->getUser())
|
||||
$replay->setState(1);
|
||||
else
|
||||
$replay->setState(0);
|
||||
$replaysArray[] = Explore::ExploreSupportTicket($replay, $this->getUser());
|
||||
}
|
||||
$item->setDateSubmit($jdate->jdate('Y/n/d H:i', $item->getDateSubmit()));
|
||||
return $this->json([
|
||||
'item' => $item,
|
||||
'replays' => $replays
|
||||
'item' => Explore::ExploreSupportTicket($item, $this->getUser()),
|
||||
'replays' => $replaysArray
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Controller;
|
|||
use App\Entity\Business;
|
||||
use App\Entity\EmailHistory;
|
||||
use App\Entity\Permission;
|
||||
use App\Service\Extractor;
|
||||
use App\Service\Provider;
|
||||
use App\Service\SMS;
|
||||
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
|
||||
|
@ -28,6 +29,7 @@ use Symfony\Component\Form\FormError;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Mime\Address;
|
||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use SymfonyCasts\Bundle\VerifyEmail\Exception\VerifyEmailExceptionInterface;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher,
|
||||
|
@ -51,8 +53,27 @@ class UserController extends AbstractController
|
|||
}
|
||||
|
||||
#[Route('/api/user/login', name: 'api_login')]
|
||||
public function api_login(#[CurrentUser] ?User $user, EntityManagerInterface $entityManager): Response
|
||||
public function api_login(TranslatorInterface $translatorInterface, Extractor $extractor, Request $request, #[CurrentUser] ?User $user, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$params = $request->getPayload()->all();
|
||||
if (array_key_exists('standard', $params)) {
|
||||
if (null === $user) {
|
||||
return $this->json($extractor->operationFail(
|
||||
$translatorInterface->trans('login_fail'),
|
||||
));
|
||||
}
|
||||
$token = new UserToken();
|
||||
$token->setUser($user);
|
||||
$token->setToken($this->RandomString(254));
|
||||
$token->setTokenID($this->RandomString(254));
|
||||
$entityManager->persist($token);
|
||||
$entityManager->flush();
|
||||
return $this->json($extractor->operationSuccess([
|
||||
'user' => $user->getUserIdentifier(),
|
||||
'token' => $token->getToken(),
|
||||
'tokenID' => $token->getTokenID()
|
||||
]));
|
||||
} else {
|
||||
if (null === $user) {
|
||||
return $this->json([
|
||||
'message' => 'missing credentials',
|
||||
|
@ -71,32 +92,53 @@ class UserController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[Route('/api/user/has/role/{id}', name: 'api_user_has_role')]
|
||||
public function api_user_has_role(#[CurrentUser] ?User $user, EntityManagerInterface $entityManager, $id): Response
|
||||
public function api_user_has_role(Extractor $extractor,#[CurrentUser] ?User $user, EntityManagerInterface $entityManager, $id): Response
|
||||
{
|
||||
if ($this->isGranted($id)) {
|
||||
return $this->json(
|
||||
['result' => true]
|
||||
$extractor->operationSuccess()
|
||||
);
|
||||
}
|
||||
return $this->json(
|
||||
['result' => false]
|
||||
$extractor->operationFail()
|
||||
);
|
||||
}
|
||||
#[Route('/api2/user/check/login', name: 'api2_user_check_login')]
|
||||
public function api2_user_check_login(Extractor $extractor, TranslatorInterface $translatorInterface, #[CurrentUser] ?User $user, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if (null === $user) {
|
||||
return $this->json($extractor->operationFail(
|
||||
$translatorInterface->trans('not_loged_in')
|
||||
));
|
||||
}
|
||||
return $this->json($extractor->operationSuccess([
|
||||
[
|
||||
'id' => $user->getId(),
|
||||
'email' => $user->getEmail(),
|
||||
'active' => $user->isActive(),
|
||||
'name' => $user->getFullName(),
|
||||
'mobile' => $user->getMobile()
|
||||
]
|
||||
]));
|
||||
}
|
||||
#[Route('/api/user/check/login', name: 'api_user_check_login')]
|
||||
public function api_user_check_login(#[CurrentUser] ?User $user, EntityManagerInterface $entityManager): Response
|
||||
public function api_user_check_login(Extractor $extractor, #[CurrentUser] ?User $user, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if (null === $user) {
|
||||
return $this->json(
|
||||
['result' => false]
|
||||
$extractor->operationFail('user not loged in')
|
||||
);
|
||||
}
|
||||
return $this->json(
|
||||
$extractor->operationSuccess(
|
||||
[
|
||||
'result' => true,
|
||||
'email' => $user->getEmail(),
|
||||
'active' => $user->isActive()
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -144,6 +186,21 @@ class UserController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
#[Route('/api2/user/current/info', name: 'api2_user_current_info')]
|
||||
public function api2_user_current_info(#[CurrentUser] ?User $user, Extractor $extractor, Provider $provider, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
if ($user) {
|
||||
return $this->json($extractor->operationSuccess([
|
||||
'id' => $user->getId(),
|
||||
'email' => $user->getEmail(),
|
||||
'name' => $user->getFullName(),
|
||||
'businessCount' => count($user->getBusinesses()),
|
||||
'hash_email' => $provider->gravatarHash($user->getEmail()),
|
||||
'mobile' => $user->getMobile(),
|
||||
]));
|
||||
}
|
||||
return $this->json($extractor->operationFail('not loged in user'));
|
||||
}
|
||||
|
||||
#[Route('/api/user/logout', name: 'api_user_logout')]
|
||||
public function api_user_logout(Security $security, EntityManagerInterface $entityManager, Request $request): Response
|
||||
|
@ -187,7 +244,7 @@ class UserController extends AbstractController
|
|||
}
|
||||
|
||||
#[Route('/api/user/change/password', name: 'api_user_change_password')]
|
||||
public function api_user_change_password(#[CurrentUser] ?User $user, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
public function api_user_change_password(Extractor $extractor,#[CurrentUser] ?User $user, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
|
@ -202,13 +259,15 @@ class UserController extends AbstractController
|
|||
);
|
||||
$entityManager->persist($user);
|
||||
$entityManager->flush();
|
||||
return $this->json(['result' => true]);
|
||||
return $this->json($extractor->operationSuccess());
|
||||
}
|
||||
return $this->json(['result' => false]);
|
||||
return $this->json($extractor->operationFail(
|
||||
'کلمات عبور یکسان نیست'
|
||||
));
|
||||
}
|
||||
|
||||
#[Route('/api/user/register', name: 'api_user_register')]
|
||||
public function api_user_register(registryMGR $registryMGR, SMS $SMS, MailerInterface $mailer, Request $request, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager): Response
|
||||
public function api_user_register(Extractor $extractor, registryMGR $registryMGR, SMS $SMS, MailerInterface $mailer, Request $request, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
|
@ -216,15 +275,13 @@ class UserController extends AbstractController
|
|||
}
|
||||
if (array_key_exists('name', $params) && array_key_exists('email', $params) && array_key_exists('mobile', $params) && array_key_exists('password', $params)) {
|
||||
if ($entityManager->getRepository(User::class)->findOneBy(['email' => trim($params['email'])])) {
|
||||
return $this->json([
|
||||
'error' => 1,
|
||||
'message' => 'این پست الکترونیکی قبلا ثبت شده است.'
|
||||
]);
|
||||
return $this->json($extractor->operationFail(
|
||||
'پست الکترونیکی وارد شده قبلا ثبت شده است'
|
||||
));
|
||||
} elseif ($entityManager->getRepository(User::class)->findOneBy(['mobile' => trim($params['mobile'])])) {
|
||||
return $this->json([
|
||||
'error' => 2,
|
||||
'message' => 'این شماره تلفن قبلا ثبت شده است.'
|
||||
]);
|
||||
return $this->json($extractor->operationFail(
|
||||
'شماره تلفن وارد شده قبلا ثبت شده است'
|
||||
));
|
||||
}
|
||||
$user = new User();
|
||||
$user->setEmail($params['email']);
|
||||
|
@ -262,22 +319,17 @@ class UserController extends AbstractController
|
|||
$mailer->send($email);
|
||||
} catch (Exception $exception) {
|
||||
}
|
||||
return $this->json([
|
||||
'error' => 0,
|
||||
'id' => $user->getId(),
|
||||
'message' => 'ok',
|
||||
]);
|
||||
return $this->json($extractor->operationSuccess([
|
||||
'id' => $user->getId()
|
||||
]));
|
||||
}
|
||||
return $this->json([
|
||||
'error' => 999,
|
||||
'message' => 'تمام موارد لازم را وارد کنید.'
|
||||
]);
|
||||
|
||||
return $this->json(['ok']);
|
||||
return $this->json($extractor->operationFail(
|
||||
'تمام موارد لازم را وارد کنید.'
|
||||
));
|
||||
}
|
||||
|
||||
#[Route('/api/user/active/code/info/{id}', name: 'api_user_active_code_info')]
|
||||
public function api_user_active_code_info(registryMGR $registryMGR, MailerInterface $mailer, SMS $SMS, String $id, #[CurrentUser] ?User $user, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
public function api_user_active_code_info(registryMGR $registryMGR, MailerInterface $mailer, SMS $SMS, string $id, #[CurrentUser] ?User $user, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
{
|
||||
$send = false;
|
||||
$user = $entityManager->getRepository(User::class)->find($id);
|
||||
|
@ -331,18 +383,18 @@ class UserController extends AbstractController
|
|||
return $this->json($res);
|
||||
}
|
||||
|
||||
#[Route('/api/user/reset/password/send-to-sms/{id}', name: 'api_user_forget_reset_password')]
|
||||
public function api_user_forget_reset_password(registryMGR $registryMGR, MailerInterface $mailer, SMS $SMS, String $id, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
#[Route('/api/user/reset/password/send-to-sms', name: 'api_user_forget_reset_password')]
|
||||
public function api_user_forget_reset_password(Extractor $extractor, registryMGR $registryMGR, MailerInterface $mailer, SMS $SMS, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
if (array_key_exists('code', $params)) {
|
||||
$obj = $entityManager->getRepository(User::class)->find($id);
|
||||
if (array_key_exists('code', $params) && array_key_exists('id', $params)) {
|
||||
$obj = $entityManager->getRepository(User::class)->find($params['id']);
|
||||
if ($obj) {
|
||||
if ($obj->getVerifyCodeTime() > time()) {
|
||||
$obj = $entityManager->getRepository(User::class)->findOneBy(['id' => $id, 'verifyCode' => $params['code']]);
|
||||
$obj = $entityManager->getRepository(User::class)->findOneBy(['id' => $params['id'], 'verifyCode' => $params['code']]);
|
||||
if ($obj) {
|
||||
//reset password
|
||||
$password = $this->RandomString(12, true);
|
||||
|
@ -370,58 +422,74 @@ class UserController extends AbstractController
|
|||
])
|
||||
);
|
||||
$mailer->send($email);
|
||||
return $this->json(['result' => 'ok']);
|
||||
return $this->json($extractor->operationSuccess(
|
||||
[],
|
||||
'کلمه عبور جدید از طریق پیامک و پست الکترونیکی ارسال شد.'
|
||||
));
|
||||
}
|
||||
//code is incorrect
|
||||
return $this->json(['result' => 'false']);
|
||||
return $this->json($extractor->operationFail('کد احزار هویت اشتباه است!', 1));
|
||||
} else
|
||||
return $this->json(['result' => 'expired']);
|
||||
return $this->json($extractor->operationFail(
|
||||
'کد احراز هویت منقضی شده است لطفا مجددا درخواست خود را ارسال نمایید.',
|
||||
2
|
||||
));
|
||||
}
|
||||
}
|
||||
throw $this->createAccessDeniedException();
|
||||
}
|
||||
|
||||
#[Route('/api/user/active/account/{id}', name: 'api_user_active_account')]
|
||||
public function api_user_active_account(MailerInterface $mailer, SMS $SMS, String $id, #[CurrentUser] ?User $user, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
#[Route('/api/user/active/account', name: 'api_user_active_account')]
|
||||
public function api_user_active_account(Extractor $extractor, MailerInterface $mailer, SMS $SMS, #[CurrentUser] ?User $user, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
{
|
||||
$send = false;
|
||||
$user = $entityManager->getRepository(User::class)->find($id);
|
||||
if (!$user)
|
||||
throw $this->createNotFoundException('user not exist');
|
||||
if ($user->isActive())
|
||||
return $this->json(['result' => 'active before', 'id' => $user->getId(), 'active' => true]);
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
if (!array_key_exists('code', $params))
|
||||
throw $this->createNotFoundException('code not exist');
|
||||
if (!array_key_exists('code', $params) || !array_key_exists('mobile', $params))
|
||||
return $this->json($extractor->paramsNotSend());
|
||||
|
||||
$user = $entityManager->getRepository(User::class)->findOneBy(['mobile' => $params['mobile']]);
|
||||
if (!$user)
|
||||
return $this->json($extractor->operationFail('کاربری با این شماره تلفن یافت نشد'));
|
||||
if ($user->isActive())
|
||||
return $this->json($extractor->operationFail('این کاربر قبلا تایید هویت شده است.'));
|
||||
|
||||
if ($user->getVerifyCode() == $params['code']) {
|
||||
$user->setActive(true);
|
||||
$entityManager->persist($user);
|
||||
$entityManager->flush();
|
||||
return $this->json(['result' => 'ok', 'id' => $user->getId(), 'active' => true]);
|
||||
return $this->json($extractor->operationSuccess(
|
||||
['id'=>$user->getId()],
|
||||
'حساب کاربری شما فعال شد.هماکنون میتوانید با اطلاعات ثبت نام خود به حساب کاربری وارد شوید.'
|
||||
));
|
||||
}
|
||||
return $this->json(['result' => 'not correct', 'id' => $user->getId(), 'active' => false]);
|
||||
return $this->json($extractor->operationFail('کد ارسالی اشتباه است.'));
|
||||
}
|
||||
#[Route('/api/user/forget/password/send-code', name: 'api_user_forget_password_send_code')]
|
||||
public function api_user_forget_password_send_code(registryMGR $registryMGR, #[CurrentUser] ?User $user, SMS $SMS, MailerInterface $mailer, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
public function api_user_forget_password_send_code(Extractor $extractor, registryMGR $registryMGR, #[CurrentUser] ?User $user, SMS $SMS, MailerInterface $mailer, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
if (!array_key_exists('email', $params))
|
||||
throw $this->createAccessDeniedException('email not send');
|
||||
$user = $entityManager->getRepository(User::class)->findOneBy(['email' => $params['email']]);
|
||||
if (!$user) {
|
||||
$user = $entityManager->getRepository(User::class)->findOneBy(['mobile' => $params['email']]);
|
||||
if (!$user)
|
||||
return $this->json(['result' => 404]);
|
||||
if (!array_key_exists('mobile', $params)) {
|
||||
return $this->json($extractor->paramsNotSend());
|
||||
}
|
||||
|
||||
$user = $entityManager->getRepository(User::class)->findOneBy(['mobile' => $params['mobile']]);
|
||||
if (!$user) {
|
||||
return $this->json(data: $extractor->operationFail(
|
||||
'کاربری با شماره تلفن وارد شده یافت نشد.',
|
||||
404
|
||||
));
|
||||
}
|
||||
if ($user->getVerifyCodeTime() > time()) {
|
||||
return $this->json(data: $extractor->operationFail(
|
||||
'کد بازیابی رمز عبور اخیرا ارسال شده است.لطفا چند دقیقه دیگر مجددا درخواست خود را ارسال نمایید.',
|
||||
600
|
||||
));
|
||||
}
|
||||
if ($user->getVerifyCodeTime() > time())
|
||||
return $this->json(['result' => 'send before']);
|
||||
$user->setVerifyCode($this->RandomString(6, true));
|
||||
$user->setVerifyCodeTime(time() + 300);
|
||||
$entityManager->persist($user);
|
||||
|
@ -443,7 +511,9 @@ class UserController extends AbstractController
|
|||
);
|
||||
|
||||
$mailer->send($email);
|
||||
return $this->json(['result' => true, 'id' => $user->getId()]);
|
||||
return $this->json($extractor->operationSuccess([
|
||||
'id' => $user->getId(),
|
||||
]));
|
||||
}
|
||||
#[Route('/api/user/save/mobile-number', name: 'api_user_save_mobile_number')]
|
||||
public function api_user_save_mobile_number(MailerInterface $mailer, SMS $SMS, #[CurrentUser] ?User $user, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
|
@ -463,4 +533,63 @@ class UserController extends AbstractController
|
|||
}
|
||||
return $this->json(['result' => 'exist-before']);
|
||||
}
|
||||
|
||||
#[Route('/api/user/register/resend-active-code', name: 'api_user_register_resend_code')]
|
||||
public function api_user_register_resend_code(Extractor $extractor, registryMGR $registryMGR, #[CurrentUser] ?User $user, SMS $SMS, MailerInterface $mailer, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager, Request $request): Response
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
$params = json_decode($content, true);
|
||||
}
|
||||
if (!array_key_exists('mobile', $params)) {
|
||||
return $this->json($extractor->paramsNotSend());
|
||||
}
|
||||
|
||||
$user = $entityManager->getRepository(User::class)->findOneBy(['mobile' => $params['mobile']]);
|
||||
if (!$user) {
|
||||
return $this->json(data: $extractor->operationFail(
|
||||
'کاربری با شماره تلفن وارد شده یافت نشد.',
|
||||
404
|
||||
));
|
||||
}
|
||||
if (!$user->isActive()) {
|
||||
return $this->json(data: $extractor->operationFail(
|
||||
'حساب کاربری شما قبلا فعال شده است.میتوانید به حساب کاربری خود وارد شوید.',
|
||||
404
|
||||
));
|
||||
}
|
||||
if ($user->getVerifyCodeTime() > time()) {
|
||||
return $this->json(data: $extractor->operationFail(
|
||||
'کد بازیابی رمز عبور اخیرا ارسال شده است.لطفا دو دقیقه دیگر مجددا درخواست خود را ارسال نمایید.',
|
||||
$user->getVerifyCodeTime()
|
||||
));
|
||||
}
|
||||
$user->setVerifyCode($this->RandomString(6, true));
|
||||
$user->setVerifyCodeTime(time() + 300);
|
||||
$entityManager->persist($user);
|
||||
$entityManager->flush();
|
||||
//send sms and email
|
||||
$SMS->send(
|
||||
[$user->getVerifyCode()],
|
||||
$registryMGR->get('sms', 'f2a'),
|
||||
$user->getMobile()
|
||||
);
|
||||
try {
|
||||
$email = (new Email())
|
||||
->to($user->getEmail())
|
||||
->priority(Email::PRIORITY_HIGH)
|
||||
->subject('تایید ایمیل در حسابیکس')
|
||||
->html(
|
||||
$this->renderView('user/email/confrim-register.html.twig', [
|
||||
'code' => $user->getVerifyCode()
|
||||
])
|
||||
);
|
||||
|
||||
$mailer->send($email);
|
||||
} catch (Exception $exception) {
|
||||
}
|
||||
return $this->json($extractor->operationSuccess([
|
||||
'id' => $user->getId(),
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,9 @@ class Support
|
|||
#[ORM\Column(length: 255)]
|
||||
private ?string $state = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
private ?string $code = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
|
@ -111,4 +114,16 @@ class Support
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCode(): ?string
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function setCode(?string $code): static
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class BusinessRepository extends ServiceEntityRepository
|
|||
public function findByPage($page = 0, $take = 25, $search = ''): array
|
||||
{
|
||||
$query = $this->createQueryBuilder('b')
|
||||
->setFirstResult($page * $take)
|
||||
->setFirstResult(($page -1) * $take)
|
||||
->orderBy('b.id', 'DESC')
|
||||
->setMaxResults($take);
|
||||
|
||||
|
|
|
@ -70,6 +70,35 @@ class UserRepository extends ServiceEntityRepository implements PasswordUpgrader
|
|||
->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User[] Returns an array of Business objects
|
||||
*/
|
||||
public function findByPage($page = 0, $take = 25, $search = ''): array
|
||||
{
|
||||
$query = $this->createQueryBuilder('b')
|
||||
->setFirstResult(($page -1) * $take)
|
||||
->orderBy('b.id', 'DESC')
|
||||
->setMaxResults($take);
|
||||
|
||||
if ($search != '') {
|
||||
$query->andWhere("b.fullName LIKE :search ")
|
||||
->setParameter('search', '%' . $search . '%');
|
||||
}
|
||||
return $query->getQuery()->getResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer Returns an integer of Business objects
|
||||
*/
|
||||
public function countAll(): int
|
||||
{
|
||||
return $this->createQueryBuilder('b')
|
||||
->select('count(b.id)')
|
||||
->getQuery()
|
||||
->getSingleScalarResult()
|
||||
;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return User[] Returns an array of User objects
|
||||
// */
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace App\Service;
|
|||
use App\Entity\BankAccount;
|
||||
use App\Entity\Project;
|
||||
use App\Entity\Storeroom;
|
||||
use App\Entity\Support;
|
||||
use App\Entity\User;
|
||||
use App\Entity\Year;
|
||||
use App\Entity\Business;
|
||||
|
@ -385,7 +386,8 @@ class Explore
|
|||
{
|
||||
return [
|
||||
'id' => $user->getId(),
|
||||
'name' => $user->getFullName()
|
||||
'name' => $user->getFullName(),
|
||||
'fullName'=>$user->getFullName()
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -535,4 +537,21 @@ class Explore
|
|||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public static function ExploreSupportTicket(Support $support,User | null $user):array{
|
||||
$jdate = new Jdate();
|
||||
$res = [];
|
||||
$res['id'] = $support->getId();
|
||||
$res['title'] = $support->getTitle();
|
||||
$res['body'] = $support->getBody();
|
||||
$res['state'] = $support->getState();
|
||||
$res['dateSubmit'] = $jdate->jdate('Y/n/d H:i',$support->getDateSubmit());
|
||||
$res['submitter'] = self::ExploreUser($support->getSubmitter());
|
||||
$res['main'] = $support->getMain();
|
||||
$res['owner'] = true;
|
||||
if($user->getId() != $support->getSubmitter()->getId()){
|
||||
$res['owner'] = false;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@ use App\Entity\Salary;
|
|||
|
||||
class Extractor
|
||||
{
|
||||
public function operationSuccess($data = ''){
|
||||
public function operationSuccess($data = '', $message = '')
|
||||
{
|
||||
if ($message == '') {
|
||||
return [
|
||||
'Success' => true,
|
||||
'code' => 0,
|
||||
|
@ -28,16 +30,25 @@ class Extractor
|
|||
|
||||
];
|
||||
}
|
||||
public function operationFail($message='operaition fail',$code=404, $data = ''){
|
||||
return [
|
||||
'Success' => true,
|
||||
'code' => 0,
|
||||
'data' => $data,
|
||||
'message' => $message,
|
||||
];
|
||||
|
||||
}
|
||||
public function operationFail($message = 'operaition fail', $code = 404, $data = '')
|
||||
{
|
||||
return [
|
||||
'Success' => false,
|
||||
'code' => $code,
|
||||
'data' => $data,
|
||||
'message' => $message,
|
||||
|
||||
];
|
||||
}
|
||||
public function notFound($data = ''){
|
||||
public function notFound($data = '')
|
||||
{
|
||||
return [
|
||||
'code' => 404,
|
||||
'data' => $data,
|
||||
|
@ -45,7 +56,8 @@ class Extractor
|
|||
];
|
||||
}
|
||||
|
||||
public function paramsNotSend(){
|
||||
public function paramsNotSend()
|
||||
{
|
||||
return [
|
||||
'code' => 101,
|
||||
'data' => '',
|
||||
|
|
|
@ -60,9 +60,16 @@ class pdfMGR
|
|||
|
||||
public function streamTwig2PDFInvoiceType(PrinterQueue $printQueue, $configs = [])
|
||||
{
|
||||
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
|
||||
$fontDirs = $defaultConfig['fontDir'];
|
||||
|
||||
$defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults();
|
||||
$fontData = $defaultFontConfig['fontdata'];
|
||||
$mpdf = new \Mpdf\Mpdf([
|
||||
'mode' => 'utf-8', 'format' => [80, 300],
|
||||
'fontDir' => array_merge($fontDirs, [
|
||||
dirname(__DIR__) . '/Fonts',
|
||||
]),
|
||||
'fontdata' => [
|
||||
'vazirmatn' => [
|
||||
'R' => 'Vazir-Regular-FD.ttf',
|
||||
|
@ -83,7 +90,6 @@ class pdfMGR
|
|||
'margin-top' => 0,
|
||||
'margin-bottom' => 0,
|
||||
]);
|
||||
$mpdf->AddFontDirectory(__DIR__ . '../Fonts');
|
||||
$mpdf->WriteHTML($printQueue->getView());
|
||||
|
||||
$mpdf->Output();
|
||||
|
|
Loading…
Reference in a new issue