src/AtechNet/CoreBundle/Controller/BaseController.php line 123

Open in your IDE?
  1. <?php
  2. namespace App\AtechNet\CoreBundle\Controller;
  3. use App\AtechNet\CoreBundle\Entity\Claim;
  4. use App\AtechNet\CoreBundle\Entity\Customer;
  5. use App\AtechNet\CoreBundle\Entity\DocumentGroup;
  6. use App\AtechNet\CoreBundle\Entity\Domain;
  7. use App\AtechNet\CoreBundle\Entity\ErrorCode;
  8. use App\AtechNet\CoreBundle\Entity\Language;
  9. use App\AtechNet\CoreBundle\Entity\Order;
  10. use App\AtechNet\CoreBundle\Entity\OrderPackage;
  11. use App\AtechNet\CoreBundle\Entity\Product;
  12. use App\AtechNet\CoreBundle\Entity\ProductCommission;
  13. use App\AtechNet\CoreBundle\Entity\ProductCommissionAccessory;
  14. use App\AtechNet\CoreBundle\Entity\SeoUrl;
  15. use App\AtechNet\CoreBundle\Entity\Settings;
  16. use App\AtechNet\CoreBundle\Entity\StockItem;
  17. use App\AtechNet\CoreBundle\Entity\StockMovement;
  18. use App\AtechNet\CoreBundle\Entity\User;
  19. use App\AtechNet\CoreBundle\Helper\ActiveCampaignConnect;
  20. use App\AtechNet\CoreBundle\Helper\AmazonSP;
  21. use App\AtechNet\CoreBundle\Helper\BaseLinker;
  22. use App\AtechNet\CoreBundle\Helper\Billingo;
  23. use App\AtechNet\CoreBundle\Helper\Blancco;
  24. use App\AtechNet\CoreBundle\Helper\ClearCache;
  25. use App\AtechNet\CoreBundle\Helper\CloudflareImage;
  26. use App\AtechNet\CoreBundle\Helper\Daktela;
  27. use App\AtechNet\CoreBundle\Helper\DHL;
  28. use App\AtechNet\CoreBundle\Helper\DHL_At;
  29. use App\AtechNet\CoreBundle\Helper\DigitalOceanSpaces;
  30. use App\AtechNet\CoreBundle\Helper\Erste\ErsteHelper;
  31. use App\AtechNet\CoreBundle\Helper\FedEx;
  32. use App\AtechNet\CoreBundle\Helper\Fingera;
  33. use App\AtechNet\CoreBundle\Helper\Furbify\SeoUrlHelper;
  34. use App\AtechNet\CoreBundle\Helper\GLS;
  35. use App\AtechNet\CoreBundle\Helper\GLSDeprecated;
  36. use App\AtechNet\CoreBundle\Helper\Instacash;
  37. use App\AtechNet\CoreBundle\Helper\KlaviyoConnect;
  38. use App\AtechNet\CoreBundle\Helper\LuigisBox;
  39. use App\AtechNet\CoreBundle\Helper\Milpay;
  40. use App\AtechNet\CoreBundle\Helper\OpenAi\ChatGptTranslator;
  41. use App\AtechNet\CoreBundle\Helper\Packeta;
  42. use App\AtechNet\CoreBundle\Helper\PastPay;
  43. use App\AtechNet\CoreBundle\Helper\Paypal;
  44. use App\AtechNet\CoreBundle\Helper\PBH;
  45. use App\AtechNet\CoreBundle\Helper\SquarePay;
  46. use App\AtechNet\CoreBundle\Helper\TatraBanka\TatraBankaHelper;
  47. use App\AtechNet\CoreBundle\Helper\Unas;
  48. use App\AtechNet\CoreBundle\Helper\VUB\VubHelper;
  49. use App\AtechNet\CoreBundle\Service\HistoricalEuroRate;
  50. use App\AtechNet\CoreBundle\Translation\DatabaseTranslator;
  51. use Doctrine\ORM\EntityManager;
  52. use Doctrine\Persistence\ManagerRegistry;
  53. use Doctrine\Persistence\ObjectManager;
  54. use Psr\Cache\CacheItemPoolInterface;
  55. use Symfony\Bridge\Twig\Mime\TemplatedEmail;
  56. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  57. use Symfony\Component\HttpFoundation\File\UploadedFile;
  58. use Symfony\Component\HttpFoundation\Request;
  59. use Symfony\Component\HttpFoundation\RequestStack;
  60. use Symfony\Component\HttpFoundation\Response;
  61. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  62. use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
  63. use Symfony\Component\HttpKernel\Exception\HttpException;
  64. use Symfony\Component\HttpKernel\KernelInterface;
  65. use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
  66. use Symfony\Component\Mailer\MailerInterface;
  67. use Symfony\Component\Messenger\MessageBusInterface;
  68. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  69. use Symfony\Component\Security\Core\Exception\AccessDeniedException;
  70. use Symfony\Component\Security\Core\Security;
  71. use Symfony\Component\Security\Core\User\UserInterface;
  72. use Symfony\Component\String\Slugger\SluggerInterface;
  73. use Symfony\Contracts\Translation\TranslatorInterface;
  74. use WhiteOctober\BreadcrumbsBundle\Model\Breadcrumbs;
  75. class BaseController extends AbstractController
  76. {
  77. private $requiredRole = null;
  78. public const int CACHE_LIFETIME_1_MINUTE = 60;
  79. public const int CACHE_LIFETIME_2_MINUTES = 120;
  80. public const int CACHE_LIFETIME_3_MINUTES = 180;
  81. public const int CACHE_LIFETIME_15_MINUTES = 900;
  82. public const int CACHE_LIFETIME_30_MINUTES = 1800;
  83. public const int CACHE_LIFETIME_1_HOUR = 3600;
  84. public const int CACHE_LIFETIME_2_HOUR = 7200;
  85. public const int CACHE_LIFETIME_4_HOUR = 14400;
  86. public const int CACHE_LIFTETIME_6_HOURS = 21600;
  87. public const int CACHE_LIFETIME_12_HOURS = 43200;
  88. public const int CACHE_LIFETIME_1_DAY = 86400;
  89. public const int CACHE_LIFETIME_7_DAYS = 604800;
  90. public const int CACHE_LIFETIME_1_MONTH = 2629800;
  91. private string $apiToken = '423235h54gf42154132g541tf45rer4832r24364yrd231rf4tgtf432r3246h324rf36y4fde3r432';
  92. protected ManagerRegistry $doctrine;
  93. protected TranslatorInterface $translator;
  94. protected UrlGeneratorInterface $router;
  95. protected MailerInterface $mailer;
  96. protected HistoricalEuroRate $historicalEuroRate;
  97. protected KernelInterface $kernel;
  98. public function __construct(
  99. ManagerRegistry $doctrine,
  100. TranslatorInterface $translator,
  101. UrlGeneratorInterface $router,
  102. MailerInterface $mailer,
  103. RequestStack $requestStack,
  104. Security $security,
  105. HistoricalEuroRate $historicalEuroRate,
  106. KernelInterface $kernel,
  107. protected readonly CacheItemPoolInterface $cache,
  108. protected readonly MessageBusInterface $messageBus,
  109. private readonly SluggerInterface $sluggerInterface
  110. )
  111. {
  112. $this->doctrine = $doctrine;
  113. $this->translator = $translator;
  114. $this->router = $router;
  115. $this->mailer = $mailer;
  116. $this->requestStack = $requestStack;
  117. $this->security = $security;
  118. $this->historicalEuroRate = $historicalEuroRate;
  119. $this->kernel = $kernel;
  120. }
  121. /**
  122. * @param null $requiredRole
  123. */
  124. final protected function setRequiredRole($requiredRole = null)
  125. {
  126. $this->requiredRole = $requiredRole;
  127. }
  128. /**
  129. * @return mixed
  130. */
  131. protected function getSettings()
  132. {
  133. $settings = $this->doctrine->getRepository(Settings::class)->findBy(null, null, 1);
  134. if (count($settings) != 1) {
  135. throw new HttpException('Settings not found!');
  136. }
  137. return $settings[0];
  138. }
  139. /**
  140. * @param $customRole
  141. * @return bool
  142. */
  143. protected function isAccessGranted($customRole = null): bool
  144. {
  145. if (is_null($customRole)) {
  146. if (is_null($this->requiredRole)) {
  147. return true;
  148. } else {
  149. if ($this->isGranted($this->requiredRole)) {
  150. return true;
  151. }
  152. }
  153. } else {
  154. if ($this->isGranted($customRole)) {
  155. return true;
  156. }
  157. }
  158. throw new AccessDeniedHttpException();
  159. }
  160. /**
  161. * @return void
  162. */
  163. protected function adminRequired()
  164. {
  165. if (!$this->isAdmin()) {
  166. throw $this->createAccessDeniedException('Only admin can delete this data');
  167. }
  168. }
  169. /**
  170. * @return bool
  171. */
  172. protected function isAdmin(): bool
  173. {
  174. return $this->isGranted('ROLE_ADMIN');
  175. }
  176. /**
  177. * @return bool
  178. */
  179. protected function isEmployee(): bool
  180. {
  181. return $this->isGranted('ROLE_EMPLOYEE');
  182. }
  183. /**
  184. * @param Breadcrumbs $breadcrumbs
  185. * @return Breadcrumbs
  186. */
  187. protected function getBreadcrumbs(Breadcrumbs $breadcrumbs): Breadcrumbs
  188. {
  189. return $breadcrumbs->addItem('Home');
  190. }
  191. /**
  192. * @param int $resultCode
  193. * @param null $content
  194. * @param string $message
  195. * @param array $extraFields
  196. * @return Response
  197. */
  198. protected function createAjaxResponse(int $resultCode = 0, $content = null, string $message = 'Success!', array $extraFields = []): Response
  199. {
  200. return new Response(json_encode([
  201. 'resultCode' => $resultCode,
  202. 'message' => $message,
  203. 'content' => $content,
  204. ] + $extraFields), 200, [
  205. 'Content-Type' => 'application/json',
  206. ]);
  207. }
  208. /**
  209. * @param array $array
  210. * @param string $method
  211. * @param string $subMethod
  212. * @param mixed $value
  213. * @return bool
  214. * @throws \Exception
  215. */
  216. protected function checkArrayForEntityWithValue(array $array, string $method, string $subMethod, $value): bool
  217. {
  218. foreach ($array as $entity) {
  219. if (!method_exists($entity, $method)) {
  220. throw new \Exception($method);
  221. };
  222. if ($entity->{$method}() != null) {
  223. if (!method_exists($entity->{$method}(), $subMethod)) {
  224. throw new \Exception($method);
  225. };
  226. }
  227. if ($entity->{$method}() != null) {
  228. if ($entity->{$method}()->{$subMethod}() == $value) {
  229. return true;
  230. }
  231. }
  232. }
  233. return false;
  234. }
  235. /**
  236. * @param $requestArray
  237. * @return string
  238. */
  239. protected function getAllUrlParameters($requestArray): string
  240. {
  241. $urlParametersString = '';
  242. if (count($requestArray) > 0) {
  243. foreach ($requestArray as $name => $value) {
  244. if ($urlParametersString == '') {
  245. $urlParametersString = '?' . $name . '=' . $value;
  246. } else {
  247. $urlParametersString .= '&' . $name . '=' . $value;
  248. }
  249. }
  250. }
  251. return $urlParametersString;
  252. }
  253. /**
  254. * @return Billingo
  255. */
  256. protected function getBillingo(): Billingo
  257. {
  258. return new Billingo(
  259. $this->getEntityManager()
  260. );
  261. }
  262. /**
  263. * @return string
  264. */
  265. public function generateUniqueFileName(): string
  266. {
  267. return md5(uniqid());
  268. }
  269. /**
  270. * @param UploadedFile $file
  271. * @param string $uploadDirectory
  272. * @param array $allowedFileTypes
  273. * @param bool $generateUniqueName
  274. * @return array|false
  275. */
  276. public function uploadFile(UploadedFile $file, string $uploadDirectory, array $allowedFileTypes = [], bool $generateUniqueName = true)
  277. {
  278. if (count($allowedFileTypes) > 0 && array_search($file->getMimeType(), $allowedFileTypes) === false) {
  279. return false;
  280. }
  281. if ($generateUniqueName) {
  282. $response['filename'] = $this->generateUniqueFileName() . '.' . $file->guessExtension();
  283. } else {
  284. $response['filename'] = $file->getClientOriginalName();
  285. }
  286. $response['originalName'] = $file->getClientOriginalName();
  287. $response['mimeType'] = $file->getMimeType();
  288. $file->move(
  289. 'uploads/' . $uploadDirectory,
  290. $response['filename']
  291. );
  292. return $response;
  293. }
  294. /**
  295. * @param array $options
  296. * @param string|null $attachment
  297. * @return void
  298. * @throws TransportExceptionInterface
  299. */
  300. protected function sendEmail(array $options, ?string $attachment = null)
  301. {
  302. $mailer = $this->getMailer();
  303. $email = (new TemplatedEmail())
  304. ->to($options['to'])
  305. ->subject($options['subject'])
  306. ->html($options['body']);
  307. if (isset($options['bcc'])) {
  308. $email->bcc($options['bcc']);
  309. }
  310. if (isset($options['replyTo'])) {
  311. $email->replyTo($options['replyTo']);
  312. }
  313. if (!is_null($attachment)) {
  314. $email->attachFromPath($options['attachment']);
  315. }
  316. $mailer->send($email);
  317. }
  318. public const string STATISTICS_MANAGER = 'statistics';
  319. public const string CATALOG_MANAGER = 'catalog';
  320. /**
  321. * @param string $connection
  322. *
  323. * @return ObjectManager
  324. */
  325. protected function getEntityManager(string $connection = 'default'): ObjectManager
  326. {
  327. return $this->doctrine->getManager($connection);
  328. }
  329. /**
  330. * @return ActiveCampaignConnect
  331. */
  332. protected function getActiveCampaign(): ActiveCampaignConnect
  333. {
  334. $accParameters = $this->getParameter('active_campaign');
  335. return new ActiveCampaignConnect(
  336. $this->getEntityManager(),
  337. $accParameters['url'],
  338. $accParameters['api_key']
  339. );
  340. }
  341. /**
  342. * DigitalOcean Space Connection
  343. *
  344. * @return DigitalOceanSpaces
  345. */
  346. public function getDigitalOceanSpace(): DigitalOceanSpaces
  347. {
  348. $config = $this->getParameter('digital_ocean_space');
  349. return (new DigitalOceanSpaces($config['access_key'], $config['secret_key']));
  350. }
  351. /**
  352. * @return GLS
  353. * @throws \Exception
  354. * @var Order|Claim $entity
  355. */
  356. public function getGls($entity): GLS
  357. {
  358. $glsCredentials = $this->getParameter('gls');
  359. return new GLS(
  360. $entity,
  361. $glsCredentials,
  362. $this->getEntityManager(),
  363. $this->kernel->getEnvironment()
  364. );
  365. }
  366. /**
  367. * @param Order $order
  368. * @return GLSDeprecated
  369. * @throws \Exception
  370. */
  371. public function getGlsDeprecated(Order $order): GLSDeprecated
  372. {
  373. $glsCredentials = $this->getParameter('gls');
  374. return new GLSDeprecated($order, $glsCredentials['pass_ac_sk_deprecated'], $glsCredentials['pass_ac_hu_deprecated'], $glsCredentials['pass_bazos_deprecated']);
  375. }
  376. /**
  377. * @param int $type
  378. * @return DHL
  379. */
  380. public function getDhl(int $type = OrderPackage::CARRIER_DHL_AIR): DHL
  381. {
  382. $dhlCredentials = $this->getParameter('dhl');
  383. return new DHL(
  384. $dhlCredentials['username'],
  385. $dhlCredentials['pass'],
  386. $dhlCredentials['account_number'][$type],
  387. $this->getEntityManager(),
  388. $this->kernel->getEnvironment()
  389. );
  390. }
  391. /**
  392. * @param int $type
  393. * @return FedEx
  394. * @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
  395. */
  396. public function getFedEx(int $type = OrderPackage::CARRIER_FEDEX_AIR): FedEx
  397. {
  398. $fedExCredentials = $this->getParameter('fedex');
  399. return new FedEx(
  400. $fedExCredentials['client_id'],
  401. $fedExCredentials['client_secret'],
  402. $fedExCredentials['account_number'],
  403. $this->getEntityManager(),
  404. $this->kernel->getEnvironment()
  405. );
  406. }
  407. protected function getDhlAt()
  408. {
  409. $credentials = $this->getParameter('dhl_at')[$this->kernel->getEnvironment()];
  410. $trackingKey = $this->getParameter('dhl_tracking')['key'];
  411. return new DHL_At($credentials, $trackingKey, $this->getEntityManager(), $this->kernel->getEnvironment());
  412. }
  413. /**
  414. * @param Request $request
  415. * @param string $pageTitle
  416. * @param string $query
  417. * @param int $languageId
  418. * @param Domain|null $domain
  419. * @param bool $flush
  420. * @return SeoUrl
  421. */
  422. public function createSeoUrl(Request $request, string $pageTitle, string $query, int $languageId, Domain $domain = null, bool $flush = true): ?SeoUrl
  423. {
  424. $entityManager = $this->getEntityManager();
  425. $seoUrlHelper = new SeoUrlHelper($entityManager, $request);
  426. $domainId = 1;
  427. if ($domain) {
  428. $domainId = $domain->getId();
  429. }
  430. $keyword = $seoUrlHelper->createUniqueSlug($pageTitle, $query, $languageId, $domainId);
  431. $findOneByArray = [
  432. 'language' => $languageId,
  433. 'keyword' => $keyword,
  434. ];
  435. if (strpos($query, 'product_id=') === false) {
  436. $findOneByArray['domain'] = $domainId;
  437. }
  438. $duplicateLangKeywordUrl = $entityManager->getRepository(SeoUrl::class)->findOneBy($findOneByArray);
  439. $seoUrl = null;
  440. if (!$duplicateLangKeywordUrl) { // if lang + keyword pair exists, dont continue
  441. $findOneByArray = [
  442. 'language' => $languageId,
  443. 'query' => $query,
  444. ];
  445. if (strpos($query, 'product_id=') === false) {
  446. $findOneByArray['domain'] = $domainId;
  447. $findOneByArray['archived'] = 0;
  448. } else {
  449. $findOneByArray['archived'] = 0;
  450. }
  451. $duplicateLangQueryUrl = $entityManager->getRepository(SeoUrl::class)->findOneBy($findOneByArray);
  452. if ($duplicateLangQueryUrl) { // if lang + query pair exists, remove it
  453. $entityManager->remove($duplicateLangQueryUrl);
  454. }
  455. $language = $entityManager->getRepository(Language::class)->findOneById($languageId);
  456. $seoUrl = new SeoUrl();
  457. $seoUrl->setLanguage($language);
  458. $seoUrl->setQuery($query);
  459. $seoUrl->setKeyword($keyword);
  460. if ($domain) {
  461. $seoUrl->setDomain($domain);
  462. }
  463. $entityManager->persist($seoUrl);
  464. if ($flush) {
  465. $entityManager->flush();
  466. }
  467. } elseif (strpos($query, 'product_id=') !== false || strpos($query, 'category_id=') !== false || strpos($query, 'blog_id=') !== false || strpos($query, 'static_id=') !== false) {
  468. if ($duplicateLangKeywordUrl->getQuery() == $query) {
  469. $duplicateLangKeywordUrl->setArchived(false);
  470. }
  471. }
  472. return $seoUrl;
  473. }
  474. /**
  475. * @return array
  476. */
  477. public function getAvailableDomainLanguageIdsForWeb(): array
  478. {
  479. // Domain ID => Language ID
  480. return [
  481. 1 => 1,
  482. 3 => 2,
  483. 9 => 3,
  484. 7 => 4,
  485. 11 => 4,
  486. ];
  487. }
  488. /**
  489. * @param string $stringDateTime
  490. * @return \DateTime
  491. */
  492. protected function stringToDateTime(string $stringDateTime): \DateTime
  493. {
  494. $stringDateTime = explode('-', $stringDateTime);
  495. return (new \DateTime())->setDate($stringDateTime[0], $stringDateTime[1], $stringDateTime[2]);
  496. }
  497. /**
  498. * @param Product $product
  499. * @return bool
  500. */
  501. protected function clearFurbifyProductCache(Product $product): bool
  502. {
  503. return ClearCache::furbifyProduct($product);
  504. }
  505. /**
  506. * @param array $productIds
  507. * @return void
  508. */
  509. protected function clearFurbifyProductsCache(array $productIds): void
  510. {
  511. ClearCache::furbifyProducts($productIds);
  512. }
  513. /**
  514. * @param string $cacheKey
  515. * @return bool
  516. * @throws \Psr\Cache\InvalidArgumentException
  517. */
  518. protected function removeCacheByKey(string $cacheKey): bool
  519. {
  520. return $this->cache->deleteItem($cacheKey);
  521. }
  522. public function removeMenuCacheForUser(User $user): void
  523. {
  524. $this->cache->deleteItem($user->getMenuCacheKey());
  525. }
  526. /**
  527. * @return mixed
  528. */
  529. protected function getWebsiteDomains()
  530. {
  531. return $this->getCreateQuery("SELECT d FROM AtechNetCoreBundle:Domain d WHERE d.id IN (" . implode(',', Domain::DOMAINS_WITH_WEBSITE) . ")")->getResult();
  532. }
  533. /**
  534. * @return array
  535. */
  536. protected function getPriceChangeStepsByCurrency(): array
  537. {
  538. return [
  539. '€' => 0.01,
  540. 'Ft' => 10,
  541. 'Kč' => 1,
  542. ];
  543. }
  544. /**
  545. * @param $errorCodes
  546. * @param string $lang
  547. * @return array
  548. */
  549. protected function errorCodesToErrorText($errorCodes, string $lang = 'HU'): array
  550. {
  551. $errorCodeRepo = $this->getEntityManager()->getRepository(ErrorCode::class);
  552. $errorCodeTexts = [];
  553. $errorCodes = explode(' ', $errorCodes);
  554. foreach ($errorCodes as $errorCode) {
  555. $errorCodeEntity = $errorCodeRepo->findOneByCode($errorCode);
  556. if ($errorCodeEntity) {
  557. $errorCodeTexts[] = $errorCodeEntity->getTextForLanguage($lang);
  558. } else {
  559. $errorCodeTexts[] = $errorCode;
  560. }
  561. }
  562. return $errorCodeTexts;
  563. }
  564. /**
  565. * @param Order $order
  566. * @param Product $product
  567. * @param StockItem|null $si
  568. * @param StockMovement|null $sm
  569. * @param ProductCommission|null $parenCommission
  570. * @param bool $isContainer
  571. * @return ProductCommission
  572. */
  573. protected function createProductCommission(
  574. Order $order,
  575. Product $product,
  576. StockItem $si = null,
  577. StockMovement $sm = null,
  578. ProductCommission $parenCommission = null,
  579. bool $isContainer = false
  580. ): ProductCommission {
  581. $productCommission = new ProductCommission();
  582. $productCommission->setProduct($product);
  583. $productCommission->setParent($parenCommission);
  584. $productCommission->setCustomer($order->getCustomer());
  585. $productCommission->setSerialNumber(!is_null($si) ? $si->getSerialNumber() : '');
  586. $productCommission->setAikenCode(!is_null($si) ? $si->getAikenCode() : '');
  587. $productCommission->setStatus(ProductCommission::Status_AtPartner);
  588. $productCommission->setStockMovement($sm);
  589. $productCommission->setCreatedBy($this->getUser());
  590. $productCommission->setContainer($isContainer);
  591. $this->getEntityManager()->persist($productCommission);
  592. return $productCommission;
  593. }
  594. /**
  595. * @param ProductCommission $productCommission
  596. * @param Product $product
  597. * @param StockMovement $stockMovement
  598. */
  599. public function createProductCommissionAccessory(ProductCommission $productCommission, Product $product, StockMovement $stockMovement)
  600. {
  601. $productCommissionAccessory = new ProductCommissionAccessory();
  602. $productCommissionAccessory->setProductCommission($productCommission);
  603. $productCommissionAccessory->setProduct($product);
  604. $productCommissionAccessory->setStockMovement($stockMovement);
  605. $this->getEntityManager()->persist($productCommissionAccessory);
  606. }
  607. /**
  608. * @return mixed
  609. */
  610. protected function getCentralisUser()
  611. {
  612. return $this->getEntityManager()->getRepository(User::class)->findOneById(40);
  613. }
  614. /**
  615. * @return mixed
  616. */
  617. protected function getPaymentApproverUsers()
  618. {
  619. return $this->getEntityManager()
  620. ->createQuery("SELECT u
  621. FROM AtechNetCoreBundle:User u
  622. LEFT JOIN AtechNetCoreBundle:Customer c WITH c.paymentApprover = u
  623. WHERE c.paymentApprover IS NOT NULL
  624. GROUP BY u.id")
  625. ->getResult();
  626. }
  627. /**
  628. * @return array
  629. */
  630. protected function getPaymentApproverUserIDs(): array
  631. {
  632. $paymentApproverUserIDs = [];
  633. foreach ($this->getPaymentApproverUsers() as $user) {
  634. $paymentApproverUserIDs[] = $user->getId();
  635. }
  636. return $paymentApproverUserIDs;
  637. }
  638. /**
  639. * To refresh menu cache manually, add "refresh-menu-cache" url parameter to the request
  640. * @param Request $request
  641. * @return Response
  642. * @throws \Psr\Cache\InvalidArgumentException
  643. */
  644. public function getMenuAction(Request $request): Response
  645. {
  646. $currentRoute = $request->get('_route');
  647. $currentUser = $this->getUser();
  648. if (!$currentUser instanceof User) {
  649. throw new HttpException('Please log in!');
  650. }
  651. $userId = $currentUser->getId();
  652. $navigation = [];
  653. $cacheKey = $currentUser->getMenuCacheKey();
  654. $cacheItem = $this->cache->getItem($cacheKey);
  655. if ( $cacheItem->isHit() && !$request->query->has('refresh-menu-cache') ) {
  656. return $this->render('AtechNetCoreBundle/Default/menu.html.twig', [
  657. 'current_route' => $currentRoute,
  658. 'navigation' => $cacheItem->get(),
  659. ]);
  660. }
  661. //Orders
  662. if ($this->checkPermission(User::PERMISSION_LIST, User::MODULE_ORDER)) {
  663. $navigation['order'] = [
  664. 'name' => 'Orders',
  665. 'route' => 'atech_net_core_order_list',
  666. 'icon' => 'glyphicon glyphicon-eur',
  667. ];
  668. $navigation['order']['menu'][] = [
  669. 'name' => 'Orders',
  670. 'route' => 'atech_net_core_order_list',
  671. 'icon' => 'glyphicon glyphicon-eur',
  672. 'submenu' => [
  673. [
  674. 'name' => 'Open',
  675. 'route' => 'atech_net_core_order_list',
  676. 'params' => [
  677. 'status' => Order::STATUS_OPEN,
  678. ],
  679. ],
  680. [
  681. 'name' => 'Triage',
  682. 'route' => 'atech_net_core_order_list',
  683. 'params' => [
  684. 'status' => Order::STATUS_TRIAGE,
  685. ],
  686. ],
  687. [
  688. 'name' => 'Waiting for partner',
  689. 'route' => 'atech_net_core_order_list',
  690. 'params' => [
  691. 'status' => Order::STATUS_WAITING_FOR_PARTNER,
  692. ],
  693. ],
  694. [
  695. 'name' => 'Waiting for production',
  696. 'route' => 'atech_net_core_order_list',
  697. 'params' => [
  698. 'status' => Order::STATUS_WAITING_FOR_PRODUCTION,
  699. ],
  700. ],
  701. [
  702. 'name' => 'Processable',
  703. 'route' => 'atech_net_core_order_list',
  704. 'params' => [
  705. 'status' => Order::STATUS_PROCESSABLE,
  706. ],
  707. ],
  708. [
  709. 'name' => 'Waiting for answer',
  710. 'route' => 'atech_net_core_order_list',
  711. 'params' => [
  712. 'status' => Order::STATUS_WAITING_FOR_ANSWER,
  713. ],
  714. ],
  715. [
  716. 'name' => 'Processing',
  717. 'route' => 'atech_net_core_order_list',
  718. 'params' => [
  719. 'status' => Order::STATUS_PROCESSING,
  720. ],
  721. ],
  722. [
  723. 'name' => 'Ready to pack',
  724. 'route' => 'atech_net_core_order_list',
  725. 'params' => [
  726. 'status' => Order::STATUS_READY_TO_PACK,
  727. ],
  728. ],
  729. [
  730. 'name' => 'Ready to ship',
  731. 'route' => 'atech_net_core_order_list',
  732. 'params' => [
  733. 'status' => Order::STATUS_READY_TO_SHIP,
  734. ],
  735. ],
  736. [
  737. 'name' => 'Finished',
  738. 'route' => 'atech_net_core_order_list',
  739. 'params' => [
  740. 'status' => Order::STATUS_FINISHED,
  741. ],
  742. ],
  743. [
  744. 'name' => 'Canceled',
  745. 'route' => 'atech_net_core_order_list',
  746. 'params' => [
  747. 'status' => Order::STATUS_CANCELED,
  748. ],
  749. ],
  750. ],
  751. ];
  752. if ($this->checkPermission(User::PERMISSION_CREATE, User::MODULE_ORDER)) {
  753. $navigation['order']['menu'][] = [
  754. 'name' => 'Add new order',
  755. 'route' => 'atech_net_core_order_new',
  756. 'icon' => 'glyphicon glyphicon-plus',
  757. ];
  758. }
  759. if ($this->checkPermission(User::PERMISSION_STATS, User::MODULE_ORDER)) {
  760. $navigation['order']['menu'][] = [
  761. 'name' => 'Stats',
  762. 'route' => 'atech_net_core_order_stats',
  763. 'icon' => 'glyphicon glyphicon-signal',
  764. ];
  765. }
  766. if ($this->checkPermission(User::PERMISSION_BASKET, User::MODULE_ORDER)) {
  767. $navigation['order']['menu'][] = [
  768. 'name' => 'Baskets',
  769. 'route' => 'atech_net_core_basket_list',
  770. 'icon' => 'glyphicon glyphicon-shopping-cart',
  771. ];
  772. }
  773. if ($this->checkPermission(User::PERMISSION_PACKAGE_HANDOVER, User::MODULE_ORDER)) {
  774. $navigation['order']['menu'][] = [
  775. 'name' => 'Handover',
  776. 'route' => 'atech_net_core_order_package_handover',
  777. 'icon' => 'glyphicon glyphicon-check',
  778. ];
  779. }
  780. }
  781. //Products
  782. if ($this->checkPermission(User::PERMISSION_LIST, User::MODULE_PRODUCT)) {
  783. $navigation['products'] = [
  784. 'name' => 'Products',
  785. 'route' => 'atech_net_core_product_search',
  786. 'icon' => 'glyphicon glyphicon-hdd',
  787. ];
  788. $navigation['products']['menu'][] = [
  789. 'name' => 'All PCs in stock',
  790. 'route' => 'atech_net_core_product_all_list',
  791. 'params' => [
  792. 'product_type[]' => 60,
  793. 'in_stock' => 1,
  794. ],
  795. ];
  796. $navigation['products']['menu'][] = [
  797. 'name' => 'All notebooks in stock',
  798. 'route' => 'atech_net_core_product_all_list',
  799. 'params' => [
  800. 'product_type[]' => 52,
  801. 'in_stock' => 1,
  802. ],
  803. ];
  804. $navigation['products']['menu'][] = [
  805. 'name' => 'All monitors in stock',
  806. 'route' => 'atech_net_core_product_all_list',
  807. 'params' => [
  808. 'product_type[]' => 44,
  809. 'in_stock' => 1,
  810. ],
  811. ];
  812. $navigation['products']['menu'][] = [
  813. 'name' => 'All smartphones',
  814. 'route' => 'atech_net_core_product_all_list',
  815. 'params' => [
  816. 'product_type[]' => 41,
  817. 'in_stock' => 1,
  818. ],
  819. ];
  820. $navigation['products']['menu'][] = [
  821. 'name' => 'All AIO in stock',
  822. 'route' => 'atech_net_core_product_all_list',
  823. 'params' => [
  824. 'product_type[]' => 116,
  825. 'in_stock' => 1,
  826. ],
  827. ];
  828. $navigation['products']['menu'][] = [
  829. 'name' => 'All SSD in stock',
  830. 'route' => 'atech_net_core_product_all_list',
  831. 'params' => [
  832. 'product_type[]' => 85,
  833. 'in_stock' => 1,
  834. ],
  835. ];
  836. if ($this->checkPermission(User::PERMISSION_CREATE, User::MODULE_PRODUCT)) {
  837. $navigation['products']['menu'][] = [
  838. 'name' => 'Add new product',
  839. 'route' => 'atech_net_core_product_new',
  840. ];
  841. }
  842. $navigation['products']['menu'][] = [
  843. 'name' => 'Search',
  844. 'route' => 'atech_net_core_product_search',
  845. 'icon' => 'glyphicon glyphicon-search',
  846. ];
  847. if ($this->checkPermission(User::PERMISSION_PRODUCT_MODEL, User::MODULE_PRODUCT)) {
  848. $navigation['products']['menu'][] = [
  849. 'name' => 'Product models',
  850. 'route' => 'product_model',
  851. ];
  852. }
  853. if ($this->checkPermission(User::PERMISSION_PRODUCT_VARIATION, User::MODULE_PRODUCT)) {
  854. $navigation['products']['menu'][] = [
  855. 'name' => 'Product variations',
  856. 'route' => 'atech_net_core_product_variations',
  857. ];
  858. }
  859. $navigation['products']['menu'][] = [
  860. 'name' => 'Product types',
  861. 'route' => 'product_type',
  862. ];
  863. if ($this->checkPermission(User::PERMISSION_OLD_ITEMS, User::MODULE_PRODUCT)) {
  864. $navigation['products']['menu'][] = [
  865. 'name' => 'Old items on stock',
  866. 'route' => 'atech_net_core_product_stock_item_age',
  867. ];
  868. }
  869. if ($this->checkPermission(User::PERMISSION_VENDOR, User::MODULE_PRODUCT)) {
  870. $navigation['products']['menu'][] = [
  871. 'name' => 'Vendor',
  872. 'route' => 'atech_net_core_vendor',
  873. ];
  874. }
  875. if ($this->checkPermission(User::PERMISSION_PRODUCT_PRICE_MONITOR, User::MODULE_PRODUCT)) {
  876. $navigation['products']['menu'][] = [
  877. 'name' => 'Price monitor',
  878. 'route' => 'atech_net_core_price_monitor',
  879. ];
  880. }
  881. if ($this->checkPermission(User::PERMISSION_GENERATE_PRODUCT_OFFER_EMAIL, User::MODULE_PRODUCT)) {
  882. $navigation['products']['menu'][] = [
  883. 'name' => 'Offer email create',
  884. 'route' => 'atech_net_core_product_create_offer_email',
  885. ];
  886. }
  887. if ($this->checkPermission(User::PERMISSION_PRODUCT_LAST_SALE, User::MODULE_PRODUCT)) {
  888. $navigation['products']['menu'][] = [
  889. 'name' => 'Last sales',
  890. 'route' => 'list_products_recent_sales',
  891. ];
  892. }
  893. if ($this->checkPermission(User::PERMISSION_PRODUCT_SPARE_PARTS, User::MODULE_PRODUCT)) {
  894. $navigation['products']['menu'][] = [
  895. 'name' => 'Spare part prices',
  896. 'route' => 'product_spare_parts',
  897. ];
  898. }
  899. $productExportSubMenu = [];
  900. if ($this->checkPermission(User::PERMISSION_PRODUCT_EXPORT, User::MODULE_PRODUCT)) {
  901. $productExportSubMenu[] = [
  902. 'name' => 'Products',
  903. 'route' => 'atech_net_core_product_export',
  904. 'params' => [
  905. 'type' => 'normal',
  906. ],
  907. ];
  908. $productExportSubMenu[] = [
  909. 'name' => 'Stock items with new battery',
  910. 'route' => 'atech_net_core_stock_items_new_battery_export',
  911. 'params' => [
  912. 'type' => 'normal',
  913. ],
  914. ];
  915. $productExportSubMenu[] = [
  916. 'name' => 'Connected products',
  917. 'route' => 'connected_products_csv_export',
  918. 'params' => [
  919. 'type' => 'normal',
  920. ],
  921. ];
  922. $productExportSubMenu[] = [
  923. 'name' => 'Product model connected products' ,
  924. 'route' => 'export_product_model_connected_products',
  925. 'params' => [
  926. 'type' => 'normal',
  927. ],
  928. ];
  929. $productExportSubMenu[] = [
  930. 'name' => 'Available main products',
  931. 'route' => 'atech_net_core_product_list_export',
  932. 'params' => [
  933. 'exportable' => 'all-main-products',
  934. ],
  935. ];
  936. }
  937. if ($this->checkPermission(User::PERMISSION_EXPORT_NOTEBOOK_PARTS_FROM_SHIPMENTS, User::MODULE_PRODUCT)) {
  938. $productExportSubMenu[] = [
  939. 'name' => 'Notebook parts from shipments',
  940. 'route' => 'atech_net_core_product_and_parts_export',
  941. 'params' => [
  942. 'type' => 'normal',
  943. ],
  944. ];
  945. }
  946. if ($this->checkPermission( User::PERMISSION_EXPORT_SHIPMENTS, User::MODULE_STOCK_MOVEMENT)) {
  947. $productExportSubMenu[] = [
  948. 'name' => 'Export shipments',
  949. 'route' => 'atech_net_core_shipment_export',
  950. 'params' => [
  951. 'type' => 'normal',
  952. ],
  953. ];
  954. }
  955. if ($this->checkPermission(User::PERMISSION_PRODUCT_EXPORT_PAYMENT_STATS, User::MODULE_PRODUCT)) {
  956. $productExportSubMenu[] = [
  957. 'name' => 'Export payment type stats',
  958. 'route' => 'atech_net_core_product_export_payment_stats',
  959. ];
  960. }
  961. if ($this->checkPermission(User::PERMISSION_PRODUCT_EXPORT_VIEW, User::MODULE_PRODUCT)) {
  962. $productExportSubMenu[] = [
  963. 'name' => 'by centralis codes',
  964. 'route' => 'atech_net_core_product_export_by_codes',
  965. ];
  966. }
  967. if ($this->checkPermission(User::PERMISSION_EXPORT_NOT_LISTED_PRODUCT, User::MODULE_PRODUCT)) {
  968. $productExportSubMenu[] = [
  969. 'name' => 'Not listed products',
  970. 'route' => 'atech_net_core_export_not_listed_product',
  971. ];
  972. }
  973. if ($this->checkPermission(User::PERMISSION_EXPORT_QUARANTINE_SERIALS, User::MODULE_PRODUCT)) {
  974. $productExportSubMenu[] = [
  975. 'name' => 'Quarantine serial numbers',
  976. 'route' => 'atech_net_core_product_export_quarantine_serial_numbers',
  977. ];
  978. }
  979. if (\count($productExportSubMenu) > 0) {
  980. $navigation['products']['menu'][] = [
  981. 'name' => 'Export',
  982. 'link' => '#',
  983. 'icon' => 'glyphicon glyphicon-export',
  984. 'submenu' => $productExportSubMenu,
  985. ];
  986. }
  987. $productImportSubMenu = [];
  988. if ($this->checkPermission(User::PERMISSION_PRICE_IMPORT, User::MODULE_PRODUCT)) {
  989. $productImportSubMenu[] = [
  990. 'name' => 'Product price import',
  991. 'route' => 'import_product_prices',
  992. ];
  993. }
  994. if ($this->checkPermission(User::PERMISSION_PRODUCT_MODEL_CONNECTED_PRODUCT_IMPORT, User::MODULE_PRODUCT)) {
  995. $productImportSubMenu[] = [
  996. 'name' => 'Product model connection import',
  997. 'route' => 'import_product_model_connected_products',
  998. ];
  999. }
  1000. if ($this->checkPermission(User::PERMISSION_MARGIN_IMPORT, User::MODULE_PRODUCT)) {
  1001. $productImportSubMenu[] = [
  1002. 'name' => 'Margin level import',
  1003. 'route' => 'import_product_margin',
  1004. ];
  1005. }
  1006. if (\count($productImportSubMenu) > 0) {
  1007. $navigation['products']['menu'][] = [
  1008. 'name' => 'Import',
  1009. 'link' => '#',
  1010. 'icon' => 'glyphicon glyphicon-import',
  1011. 'submenu' => $productImportSubMenu,
  1012. ];
  1013. }
  1014. }
  1015. // Customers
  1016. if ($this->checkPermission(User::PERMISSION_LIST, User::MODULE_CUSTOMER)) {
  1017. $navigation['customers'] = [
  1018. 'name' => 'Customers',
  1019. 'route' => 'atech_net_core_customer',
  1020. 'icon' => 'glyphicon glyphicon-sunglasses',
  1021. ];
  1022. }
  1023. if ($this->checkPermission(User::PERMISSION_CUSTOMER_FEED_LIST, User::MODULE_CUSTOMER)) {
  1024. $navigation['customers']['menu'][] = [
  1025. 'name' => 'Customer feed list',
  1026. 'route' => 'atech_net_core_customer_feed_list',
  1027. ];
  1028. }
  1029. if ($this->checkPermission(User::PERMISSION_ROUTE_PLANNER, User::MODULE_CUSTOMER)) {
  1030. $navigation['customers']['menu'][] = [
  1031. 'name' => 'Route planner',
  1032. 'route' => 'atech_net_core_customer_route_planner',
  1033. ];
  1034. }
  1035. if ($this->checkPermission(User::PERMISSION_CUSTOMER_CALLBACK, User::MODULE_CUSTOMER)) {
  1036. $navigation['customers']['menu'][] = [
  1037. 'name' => 'Callbacks',
  1038. 'route' => 'atech_net_core_customer_callbacks',
  1039. ];
  1040. }
  1041. //> Statistics
  1042. // Sales Manager's Statistics
  1043. if (
  1044. $this->checkPermission(User::PERMISSION_SALES_MANAGER_STATISTIC, User::MODULE_STATISTIC)
  1045. && !$this->checkPermission(User::PERMISSION_INCOME_STATISTIC, User::MODULE_STATISTIC)
  1046. && !$this->checkPermission(User::PERMISSION_STOCK_MOVEMENTS_STATISTIC, User::MODULE_STATISTIC)
  1047. && !$this->checkPermission(User::PERMISSION_STOCK_STATUS_STATISTIC, User::MODULE_STATISTIC)
  1048. && !$this->checkPermission(User::PERMISSION_COMMITMENTS_RECEIVABLES_STATISTIC, User::MODULE_STATISTIC)
  1049. && !$this->checkPermission(User::PERMISSION_DAYS_IN_STOCK_STATISTIC, User::MODULE_STATISTIC)
  1050. && !$this->checkPermission(User::PERMISSION_QUALITY_STATUS_STATISTIC, User::MODULE_STATISTIC)
  1051. && !$this->checkPermission(User::PERMISSION_PRODUCTS_STATISTIC, User::MODULE_STATISTIC)
  1052. && !$this->checkPermission(User::PERMISSION_PRODUCT_SALES_STATISTIC, User::MODULE_STATISTIC)
  1053. && !$this->checkPermission(User::PERMISSION_CUSTOMERS_STATISTIC, User::MODULE_STATISTIC)
  1054. && !$this->checkPermission(User::PERMISSION_ONLINE_STOCK_STATISTIC, User::MODULE_STATISTIC)
  1055. && !$this->checkPermission(User::PERMISSION_GUESTS_STATISTIC, User::MODULE_STATISTIC)
  1056. && !$this->checkPermission(User::PERMISSION_OLD_STOCK_ITEM_STATISTIC, User::MODULE_STATISTIC)
  1057. && !$this->checkPermission(User::PERMISSION_STATISTIC_CREDIT_NOTE_VALUES, User::MODULE_STATISTIC)
  1058. && !$this->checkPermission(User::PERMISSION_CLAIM_STATISTIC, User::MODULE_STATISTIC)
  1059. && !$this->checkPermission(User::PERMISSION_PACKAGES, User::MODULE_STATISTIC)
  1060. && !$this->checkPermission(User::PERMISSION_STATISTIC_STOCK_POSITION, User::MODULE_STATISTIC)
  1061. && !$this->checkPermission(User::PERMISSION_STATISTIC_STOCK_REQUEST_TIMES, User::MODULE_STATISTIC)
  1062. ) {
  1063. $navigation['statistics'] = [
  1064. 'name' => 'Statistics',
  1065. 'route' => 'stock_movement_statistics',
  1066. 'icon' => 'glyphicon glyphicon-signal',
  1067. 'params' => [
  1068. 'tab' => 'salesManagers',
  1069. ],
  1070. ];
  1071. } else {
  1072. $statisticsSubmenu = [];
  1073. if ( $this->checkPermission(User::PERMISSION_INCOME_STATISTIC, User::MODULE_STATISTIC) ) {
  1074. $statisticsSubmenu[] = [
  1075. 'name' => 'Income',
  1076. 'route' => 'stock_movement_statistics',
  1077. 'params' => [
  1078. 'tab' => 'income',
  1079. ],
  1080. ];
  1081. }
  1082. if ( $this->checkPermission(User::PERMISSION_SALES_MANAGER_STATISTIC, User::MODULE_STATISTIC) ) {
  1083. $statisticsSubmenu[] = [
  1084. 'name' => 'Sales manager',
  1085. 'route' => 'stock_movement_statistics',
  1086. 'params' => [
  1087. 'tab' => 'salesManagers',
  1088. ],
  1089. ];
  1090. }
  1091. if ( $this->checkPermission(User::PERMISSION_SALES_MANAGER_PARTNER_STATISTIC, User::MODULE_STATISTIC) ) {
  1092. $statisticsSubmenu[] = [
  1093. 'name' => 'Sales manager partner',
  1094. 'route' => 'stock_movement_statistics',
  1095. 'params' => [
  1096. 'tab' => 'salesManagerPartners',
  1097. ],
  1098. ];
  1099. }
  1100. if ( $this->checkPermission(User::PERMISSION_STOCK_MOVEMENTS_STATISTIC, User::MODULE_STATISTIC) ) {
  1101. $statisticsSubmenu[] = [
  1102. 'name' => 'Stock movements',
  1103. 'route' => 'stock_movement_statistics',
  1104. 'params' => [
  1105. 'tab' => 'stockMovements',
  1106. ],
  1107. ];
  1108. $statisticsSubmenu[] = [
  1109. 'name' => 'Single Position Statistics',
  1110. 'route' => 'stock_movement_statistics',
  1111. 'params' => [
  1112. 'tab' => 'positionStatistics',
  1113. ],
  1114. ];
  1115. }
  1116. if ( $this->checkPermission(User::PERMISSION_STOCK_STATUS_STATISTIC, User::MODULE_STATISTIC) ) {
  1117. $statisticsSubmenu[] = [
  1118. 'name' => 'Stock status',
  1119. 'route' => 'stock_movement_statistics',
  1120. 'params' => [
  1121. 'tab' => 'stockStatus',
  1122. ],
  1123. ];
  1124. }
  1125. if ( $this->checkPermission(User::PERMISSION_COMMITMENTS_RECEIVABLES_STATISTIC, User::MODULE_STATISTIC) ) {
  1126. $statisticsSubmenu[] = [
  1127. 'name' => 'Commitments',
  1128. 'route' => 'stock_movement_statistics',
  1129. 'params' => [
  1130. 'tab' => 'commitmentsReceivables',
  1131. ],
  1132. ];
  1133. }
  1134. if ( $this->checkPermission(User::PERMISSION_DAYS_IN_STOCK_STATISTIC, User::MODULE_STATISTIC) ) {
  1135. $statisticsSubmenu[] = [
  1136. 'name' => 'Days in stock',
  1137. 'route' => 'stock_movement_statistics',
  1138. 'params' => [
  1139. 'tab' => 'daysInStock',
  1140. ],
  1141. ];
  1142. $statisticsSubmenu[] = [
  1143. 'name' => 'Stock position stats',
  1144. 'route' => 'stock_movement_statistics',
  1145. 'params' => [
  1146. 'tab' => 'positionStatistics',
  1147. ],
  1148. ];
  1149. }
  1150. if ( $this->checkPermission(User::PERMISSION_QUALITY_STATUS_STATISTIC, User::MODULE_STATISTIC) ) {
  1151. $statisticsSubmenu[] = [
  1152. 'name' => 'Quality status',
  1153. 'route' => 'stock_movement_statistics',
  1154. 'params' => [
  1155. 'tab' => 'qualityStatus',
  1156. ],
  1157. ];
  1158. }
  1159. if ( $this->checkPermission(User::PERMISSION_PRODUCTS_STATISTIC, User::MODULE_STATISTIC) ) {
  1160. $statisticsSubmenu[] = [
  1161. 'name' => 'Products',
  1162. 'route' => 'stock_movement_statistics',
  1163. 'params' => [
  1164. 'tab' => 'products',
  1165. ],
  1166. ];
  1167. }
  1168. if ( $this->checkPermission(User::PERMISSION_PRODUCT_SALES_STATISTIC, User::MODULE_STATISTIC) ) {
  1169. $statisticsSubmenu[] = [
  1170. 'name' => 'Product sales',
  1171. 'route' => 'stock_movement_statistics',
  1172. 'params' => [
  1173. 'tab' => 'productSales',
  1174. ],
  1175. ];
  1176. }
  1177. if ( $this->checkPermission(User::PERMISSION_CUSTOMERS_STATISTIC, User::MODULE_STATISTIC) ) {
  1178. $statisticsSubmenu[] = [
  1179. 'name' => 'Customers',
  1180. 'route' => 'stock_movement_statistics',
  1181. 'params' => [
  1182. 'tab' => 'customers',
  1183. ],
  1184. ];
  1185. }
  1186. if ( $this->checkPermission(User::PERMISSION_ONLINE_STOCK_STATISTIC, User::MODULE_STATISTIC) ) {
  1187. $statisticsSubmenu[] = [
  1188. 'name' => 'Online stock',
  1189. 'route' => 'stock_movement_statistics',
  1190. 'params' => [
  1191. 'tab' => 'onlineStock',
  1192. ],
  1193. ];
  1194. }
  1195. if ( $this->checkPermission(User::PERMISSION_GUESTS_STATISTIC, User::MODULE_STATISTIC) ) {
  1196. $statisticsSubmenu[] = [
  1197. 'name' => 'Guests',
  1198. 'route' => 'stock_movement_statistics',
  1199. 'params' => [
  1200. 'tab' => 'guests',
  1201. ],
  1202. ];
  1203. }
  1204. if ( $this->checkPermission(User::PERMISSION_OLD_STOCK_ITEM_STATISTIC, User::MODULE_STATISTIC) ) {
  1205. $statisticsSubmenu[] = [
  1206. 'name' => 'Old stock items',
  1207. 'route' => 'stock_movement_statistics',
  1208. 'params' => [
  1209. 'tab' => 'oldStockItems',
  1210. ],
  1211. ];
  1212. }
  1213. if ( $this->checkPermission(User::PERMISSION_CLAIM_STATISTIC, User::MODULE_STATISTIC) ) {
  1214. $statisticsSubmenu[] = [
  1215. 'name' => 'Claim basic',
  1216. 'route' => 'stock_movement_statistics',
  1217. 'params' => [
  1218. 'tab' => 'claimBasic',
  1219. ],
  1220. ];
  1221. }
  1222. if ( $this->checkPermission(User::PERMISSION_CLAIM_STATISTIC, User::MODULE_STATISTIC) ) {
  1223. $statisticsSubmenu[] = [
  1224. 'name' => 'Claim',
  1225. 'route' => 'stock_movement_statistics',
  1226. 'params' => [
  1227. 'tab' => 'claim',
  1228. ],
  1229. ];
  1230. }
  1231. if ( $this->checkPermission(User::PERMISSION_STATISTIC_CREDIT_NOTE_VALUES, User::MODULE_STATISTIC) ) {
  1232. $statisticsSubmenu[] = [
  1233. 'name' => 'Credit note values',
  1234. 'route' => 'statistics_credit_note_value',
  1235. ];
  1236. }
  1237. if ( $this->checkPermission(User::PERMISSION_ORDER_STATUS_CHANGELOG_STATISTIC, User::MODULE_STATISTIC) ) {
  1238. $statisticsSubmenu[] = [
  1239. 'name' => 'Order status changelog',
  1240. 'route' => 'stock_movement_statistics',
  1241. 'params' => [
  1242. 'tab' => 'orderStatusChangelog',
  1243. ],
  1244. ];
  1245. }
  1246. if ( $this->checkPermission(User::PERMISSION_ORDER_PRODUCT_CHANGELOG_STATISTIC, User::MODULE_STATISTIC) ) {
  1247. $statisticsSubmenu[] = [
  1248. 'name' => 'Order product changelog',
  1249. 'route' => 'stock_movement_statistics',
  1250. 'params' => [
  1251. 'tab' => 'orderProductChangelog',
  1252. ],
  1253. ];
  1254. }
  1255. if ( $this->checkPermission(User::PERMISSION_ORDER_ERROR_COMMENT_STATISTIC, User::MODULE_STATISTIC) ) {
  1256. $statisticsSubmenu[] = [
  1257. 'name' => 'Order error comment list',
  1258. 'route' => 'stock_movement_statistics',
  1259. 'params' => [
  1260. 'tab' => 'orderErrorCommentList',
  1261. ],
  1262. ];
  1263. }
  1264. if ( $this->checkPermission(User::PERMISSION_PACKAGES, User::MODULE_STATISTIC) ) {
  1265. $statisticsSubmenu[] = [
  1266. 'name' => 'Packages',
  1267. 'route' => 'stock_movement_statistics',
  1268. 'params' => [
  1269. 'tab' => 'packages',
  1270. ],
  1271. ];
  1272. }
  1273. if ( $this->checkPermission(User::PERMISSION_STATISTIC_STOCK_POSITION, User::MODULE_STATISTIC) ) {
  1274. $statisticsSubmenu[] = [
  1275. 'name' => 'Stock Position',
  1276. 'route' => 'stock_movement_statistics',
  1277. 'params' => [
  1278. 'tab' => 'stockPosition',
  1279. ],
  1280. ];
  1281. }
  1282. if ( $this->checkPermission(User::PERMISSION_STATISTIC_STOCK_REQUEST_TIMES, User::MODULE_STATISTIC) ) {
  1283. $statisticsSubmenu[] = [
  1284. 'name' => 'Stock request times',
  1285. 'route' => 'stock_movement_statistics',
  1286. 'params' => [
  1287. 'tab' => 'stockRequestTimes',
  1288. ],
  1289. ];
  1290. }
  1291. if ( $this->checkPermission(User::PERMISSION_RAKTAR_AND_KALODA_STATISTIC, User::MODULE_STATISTIC) ) {
  1292. $statisticsSubmenu[] = [
  1293. 'name' => 'Raktar & Kaloda positioning',
  1294. 'route' => 'stock_movement_statistics',
  1295. 'params' => [
  1296. 'tab' => 'raktarAndKaloda',
  1297. ],
  1298. ];
  1299. }
  1300. if ( $this->checkPermission(User::PERMISSION_MARKETPLACE_LISTINGS, User::MODULE_STATISTIC) ) {
  1301. $statisticsSubmenu[] = [
  1302. 'name' => 'Marketplace listings',
  1303. 'route' => 'stock_movement_statistics',
  1304. 'params' => [
  1305. 'tab' => 'marketplaceListings',
  1306. ],
  1307. ];
  1308. }
  1309. if ( $this->checkPermission(User::PERMISSION_NOTEBOOK_BATTERY_SKIN_STATISTICS, User::MODULE_STATISTIC) ) {
  1310. $statisticsSubmenu[] = [
  1311. 'name' => 'Notebook Battery Skin Statistics',
  1312. 'route' => 'stock_movement_statistics',
  1313. 'params' => [
  1314. 'tab' => 'notebookBatterySkinStats',
  1315. ],
  1316. ];
  1317. }
  1318. if ( $this->checkPermission(User::PERMISSION_PROCESSING_STATISTIC, User::MODULE_STATISTIC) ) {
  1319. $statisticsSubmenu[] = [
  1320. 'name' => 'Avg time on position',
  1321. 'route' => 'stock_movement_statistics',
  1322. 'params' => [
  1323. 'tab' => 'avgTimeOnPosition',
  1324. ],
  1325. ];
  1326. $statisticsSubmenu[] = [
  1327. 'name' => 'Product time on position',
  1328. 'route' => 'stock_movement_statistics',
  1329. 'params' => [
  1330. 'tab' => 'productTimeOnPosition',
  1331. ],
  1332. ];
  1333. $statisticsSubmenu[] = [
  1334. 'name' => 'Avg time by user on position',
  1335. 'route' => 'stock_movement_statistics',
  1336. 'params' => [
  1337. 'tab' => 'avgTimeByUsersOnPosition',
  1338. ],
  1339. ];
  1340. }
  1341. if ( $statisticsSubmenu ) {
  1342. $navigation['statistics'] = [
  1343. 'name' => 'Statistics',
  1344. 'link' => '#',
  1345. 'icon' => 'glyphicon glyphicon-signal',
  1346. 'menu' => $statisticsSubmenu,
  1347. ];
  1348. }
  1349. }
  1350. //< Statistics
  1351. //Documents
  1352. if ($userId == User::HUN_ACCOUNTANT_ID) { // Wildcard check
  1353. $navigation['documents'] = [
  1354. 'name' => 'Documents',
  1355. 'route' => 'document',
  1356. 'params' => [
  1357. 'type' => DocumentGroup::TYPE_INVOICE_OUT,
  1358. ],
  1359. 'icon' => 'glyphicon glyphicon-duplicate',
  1360. ];
  1361. $navigation['documents']['menu'][] = [
  1362. 'name' => 'Billingo documents',
  1363. 'route' => 'billingo_document_list',
  1364. ];
  1365. }
  1366. else if ($this->checkPermission(User::PERMISSION_LIST, User::MODULE_DOCUMENT)) {
  1367. $navigation['documents'] = [
  1368. 'name' => 'Documents',
  1369. 'route' => 'document',
  1370. 'params' => [
  1371. 'type' => DocumentGroup::TYPE_INVOICE_OUT,
  1372. ],
  1373. 'icon' => 'glyphicon glyphicon-duplicate',
  1374. ];
  1375. $navigation['documents']['menu'][] = [
  1376. 'name' => 'Pre invoices',
  1377. 'route' => 'document',
  1378. 'params' => [
  1379. 'type' => DocumentGroup::TYPE_INVOICE_PRE,
  1380. ],
  1381. ];
  1382. if ($this->checkPermission(User::PERMISSION_INVOICE_IN_TYPE, User::MODULE_DOCUMENT) || in_array($userId, $this->getPaymentApproverUserIDs())) {
  1383. $navigation['documents']['menu'][] = [
  1384. 'name' => 'In invoices',
  1385. 'route' => 'document',
  1386. 'params' => [
  1387. 'type' => DocumentGroup::TYPE_INVOICE_IN,
  1388. ],
  1389. ];
  1390. }
  1391. $navigation['documents']['menu'][] = [
  1392. 'name' => 'Out invoices',
  1393. 'route' => 'document',
  1394. 'params' => [
  1395. 'type' => DocumentGroup::TYPE_INVOICE_OUT,
  1396. ],
  1397. ];
  1398. $navigation['documents']['menu'][] = [
  1399. 'name' => 'Credit notes',
  1400. 'route' => 'document',
  1401. 'params' => [
  1402. 'type' => DocumentGroup::TYPE_INVOICE_CREDIT_NOTE,
  1403. ],
  1404. ];
  1405. $navigation['documents']['menu'][] = [
  1406. 'name' => 'Bills of delivery',
  1407. 'route' => 'document',
  1408. 'params' => [
  1409. 'type' => DocumentGroup::TYPE_BILL_OF_DELIVERY,
  1410. ],
  1411. ];
  1412. $navigation['documents']['menu'][] = [
  1413. 'name' => 'Price offers',
  1414. 'route' => 'document',
  1415. 'params' => [
  1416. 'type' => DocumentGroup::TYPE_PRICE_OFFER,
  1417. ],
  1418. ];
  1419. if ($this->checkPermission(User::PERMISSION_PAYMENTS, User::MODULE_DOCUMENT)) {
  1420. $navigation['documents']['menu'][] = [
  1421. 'name' => 'Payments',
  1422. 'route' => 'payment',
  1423. 'icon' => 'glyphicon glyphicon-import',
  1424. ];
  1425. }
  1426. $navigation['documents']['menu'][] = [
  1427. 'name' => 'Document Groups',
  1428. 'route' => 'document_groups',
  1429. ];
  1430. if ($this->checkPermission(User::PERMISSION_BILLINGO_DOCUMENTS, User::MODULE_DOCUMENT)) {
  1431. $navigation['documents']['menu'][] = [
  1432. 'name' => 'Billingo documents',
  1433. 'route' => 'billingo_document_list',
  1434. ];
  1435. }
  1436. if ($this->checkPermission(User::PERMISSION_SOLD_GOODS_FROM_SK_TO_HU, User::MODULE_DOCUMENT)) {
  1437. $navigation['documents']['menu'][] = [
  1438. 'name' => 'Sold goods SK to HU',
  1439. 'route' => 'document_filter_sold_goods_from_sk_to_hu',
  1440. ];
  1441. }
  1442. if ($this->checkPermission(User::PERMISSION_EXCHANGE_RATES, User::MODULE_DOCUMENT)) {
  1443. $navigation['documents']['menu'][] = [
  1444. 'name' => 'Exchange rates',
  1445. 'route' => 'document_exchange_rates',
  1446. ];
  1447. }
  1448. $documentExportSubMenu = [];
  1449. $documentExportSubMenu[] = [
  1450. 'name' => 'Artisjus product export',
  1451. 'route' => 'document_artisjus',
  1452. 'icon' => 'glyphicon glyphicon-equalizer',
  1453. ];
  1454. $documentExportSubMenu[] = [
  1455. 'name' => 'EPR product export',
  1456. 'route' => 'document_epr',
  1457. 'icon' => 'glyphicon glyphicon-equalizer',
  1458. ];
  1459. $documentExportSubMenu[] = [
  1460. 'name' => 'KSH product export',
  1461. 'route' => 'document_ksh',
  1462. 'icon' => 'glyphicon glyphicon-equalizer',
  1463. ];
  1464. $documentExportSubMenu[] = [
  1465. 'name' => 'Adattörlő XML',
  1466. 'route' => 'document_adattorlo_xml_export',
  1467. 'icon' => 'glyphicon glyphicon-equalizer',
  1468. ];
  1469. $documentExportSubMenu[] = [
  1470. 'name' => 'Data erase code export',
  1471. 'route' => 'document_data_erase_code_export',
  1472. 'icon' => 'glyphicon glyphicon-equalizer',
  1473. ];
  1474. if ($this->checkPermission(User::PERMISSION_DOCUMENT_EXPORT, User::MODULE_DOCUMENT)) {
  1475. $documentExportSubMenu[] = [
  1476. 'name' => 'Document export',
  1477. 'route' => 'document_export',
  1478. 'icon' => 'glyphicon glyphicon-save-file',
  1479. ];
  1480. }
  1481. if ($this->checkPermission(User::PERMISSION_POHODA_EXPORT, User::MODULE_DOCUMENT)) {
  1482. $documentExportSubMenu[] = [
  1483. 'name' => 'Pohoda export',
  1484. 'route' => 'document_export_xml_to_pohoda_admin',
  1485. ];
  1486. }
  1487. if ($this->checkPermission(User::PERMISSION_DEBIT_CARD_EXPORT, User::MODULE_ORDER)) {
  1488. $documentExportSubMenu[] = [
  1489. 'name' => 'Debit card orders',
  1490. 'route' => 'atech_net_core_order_debit_card_export',
  1491. ];
  1492. }
  1493. if ($this->checkPermission(User::PERMISSION_ARTISJUS_LABEL_EXPORT, User::MODULE_ORDER)) {
  1494. $documentExportSubMenu[] = [
  1495. 'name' => 'Artisjus label export',
  1496. 'route' => 'atech_net_core_artisjus_label_export',
  1497. ];
  1498. }
  1499. if ($this->checkPermission(User::PERMISSION_FOREIGN_SALES_EXPORT, User::MODULE_DOCUMENT)) {
  1500. $documentExportSubMenu[] = [
  1501. 'name' => 'Foreign sales export',
  1502. 'route' => 'document_export_foreign_sales_admin',
  1503. ];
  1504. }
  1505. if ($this->checkPermission(User::PERMISSION_POHODA_EXPORT, User::MODULE_DOCUMENT)) {
  1506. $documentExportSubMenu[] = [
  1507. 'name' => 'Convert Raiffeisen to Pohoda',
  1508. 'route' => 'document_convert_raiffeisen_to_pohoda_admin',
  1509. ];
  1510. }
  1511. if (count($documentExportSubMenu) > 0) {
  1512. $navigation['documents']['menu'][] = [
  1513. 'name' => 'Export',
  1514. 'link' => '#',
  1515. 'icon' => 'glyphicon glyphicon-export',
  1516. 'submenu' => $documentExportSubMenu,
  1517. ];
  1518. }
  1519. $documentImportSubMenu = [];
  1520. if ($this->checkPermission(User::PERMISSION_STATISTIC_CREDIT_NOTE_VALUES, User::MODULE_STATISTIC)) {
  1521. $documentImportSubMenu[] = [
  1522. 'name' => 'Import Amazon CN',
  1523. 'route' => 'statistics_credit_note_value_import',
  1524. 'icon' => 'glyphicon glyphicon-import',
  1525. ];
  1526. }
  1527. if (count($documentImportSubMenu) > 0) {
  1528. $navigation['documents']['menu'][] = [
  1529. 'name' => 'Import',
  1530. 'link' => '#',
  1531. 'icon' => 'glyphicon glyphicon-import',
  1532. 'submenu' => $documentImportSubMenu,
  1533. ];
  1534. }
  1535. }
  1536. //Other
  1537. $otherMenu = [];
  1538. if ($this->checkPermission(User::PERMISSION_ACCESS_LOG, User::MODULE_OTHER)) {
  1539. $otherMenu[] = [
  1540. 'name' => 'Access log',
  1541. 'route' => 'atech_net_core_access_log',
  1542. 'icon' => 'glyphicon glyphicon-lock',
  1543. ];
  1544. }
  1545. if ($this->checkPermission(User::PERMISSION_ERROR_CODES, User::MODULE_OTHER)) {
  1546. $otherMenu[] = [
  1547. 'name' => 'Aiken error codes',
  1548. 'route' => 'error_codes_index',
  1549. ];
  1550. }
  1551. if ($this->checkPermission(User::PERMISSION_ATTRIBUTES, User::MODULE_PRODUCT)) {
  1552. $otherMenu[] = [
  1553. 'name' => 'Attribute Options',
  1554. 'route' => 'atech_net_core_attribute_option_list',
  1555. ];
  1556. }
  1557. if ($this->checkPermission(User::PERMISSION_AUTOMATIZATIONS, User::MODULE_OTHER)) {
  1558. $otherMenu[] = [
  1559. 'name' => 'Automatizations',
  1560. 'route' => 'atech_net_core_automatizations',
  1561. ];
  1562. }
  1563. $otherMenu[] = [
  1564. 'name' => 'Gallery',
  1565. 'route' => 'atech_net_core_gallery',
  1566. ];
  1567. if (
  1568. ($this->checkPermission(User::PERMISSION_COMMISSION, User::MODULE_ORDER) ||
  1569. $this->checkPermission(User::PERMISSION_QUANTITY, User::MODULE_ORDER) ||
  1570. $this->checkPermission(User::PERMISSION_SHIPPING_METHOD, User::MODULE_ORDER) ||
  1571. $this->checkPermission(User::PERMISSION_PAYMENT_METHOD, User::MODULE_ORDER) ||
  1572. $this->checkPermission(User::PERMISSION_PICKUP_POINT, User::MODULE_ORDER) ||
  1573. $this->checkPermission(User::PERMISSION_MARKETPLACE_API, User::MODULE_ORDER) ||
  1574. $this->checkPermission(User::PERMISSION_ORDER_EXPORT, User::MODULE_ORDER)) &&
  1575. !array_key_exists('order', $navigation)
  1576. ) {
  1577. $navigation['order'] = [
  1578. 'name' => 'Orders',
  1579. 'route' => 'atech_net_core_order_list',
  1580. 'icon' => 'glyphicon glyphicon-eur',
  1581. ];
  1582. }
  1583. if ($this->checkPermission(User::PERMISSION_COMMISSION, User::MODULE_ORDER)) {
  1584. $navigation['order']['menu'][] = [
  1585. 'name' => 'Commissions',
  1586. 'route' => 'atech_net_core_product_commission',
  1587. 'icon' => 'glyphicon glyphicon-transfer',
  1588. ];
  1589. }
  1590. if ($this->checkPermission(User::PERMISSION_QUANTITY, User::MODULE_ORDER)) {
  1591. $navigation['order']['menu'][] = [
  1592. 'name' => 'Sold quantity',
  1593. 'route' => 'atech_net_core_order_sold_quantity',
  1594. ];
  1595. }
  1596. if ($this->checkPermission(User::PERMISSION_SHIPPING_METHOD, User::MODULE_ORDER)) {
  1597. $navigation['order']['menu'][] = [
  1598. 'name' => 'Shipping methods',
  1599. 'route' => 'module_shipping_methods',
  1600. 'icon' => 'glyphicon glyphicon-road',
  1601. ];
  1602. }
  1603. if ($this->checkPermission(User::PERMISSION_PAYMENT_METHOD, User::MODULE_ORDER)) {
  1604. $navigation['order']['menu'][] = [
  1605. 'name' => 'Payment methods',
  1606. 'route' => 'module_payment_methods',
  1607. 'icon' => 'glyphicon glyphicon-credit-card',
  1608. ];
  1609. }
  1610. if ($this->checkPermission(User::PERMISSION_PICKUP_POINT, User::MODULE_ORDER)) {
  1611. $navigation['order']['menu'][] = [
  1612. 'name' => 'Pickup point',
  1613. 'route' => 'atech_net_core_pickup_point',
  1614. 'icon' => 'glyphicon glyphicon-map-marker',
  1615. ];
  1616. }
  1617. if ($this->checkPermission(User::PERMISSION_PROCESSING_DASHBOARD, User::MODULE_ORDER)) {
  1618. $navigation['order']['menu'][] = [
  1619. 'name' => 'Processing Dashboard',
  1620. 'route' => 'atech_net_core_order_processing_dashboard',
  1621. ];
  1622. }
  1623. if ($this->checkPermission(User::PERMISSION_PRODUCTION_STATION_EDITOR, User::MODULE_ORDER)) {
  1624. $navigation['order']['menu'][] = [
  1625. 'name' => 'Production Station editor',
  1626. 'route' => 'atech_net_core_production_stations',
  1627. ];
  1628. }
  1629. if ( $this->checkPermission(User::PERMISSION_ORDER_MANAGE_ORDER_BY, User::MODULE_ORDER) ) {
  1630. $navigation['order']['menu'][] = [
  1631. 'name' => 'Order list settings',
  1632. 'route' => 'atech_net_core_order_manage_order_by',
  1633. 'icon' => 'glyphicon glyphicon-sort-by-alphabet',
  1634. ];
  1635. }
  1636. if ($this->checkPermission(User::PERMISSION_MARKETPLACE_API, User::MODULE_ORDER)) {
  1637. /*$listingListSubMenus = [
  1638. [
  1639. 'name' => 'Refurbed',
  1640. 'route' => 'atech_net_core_marketplace_listings',
  1641. 'params' => ['marketplace' => Customer::REFURBED_ID]
  1642. ],
  1643. [
  1644. 'name' => 'Backmarket',
  1645. 'route' => 'atech_net_core_marketplace_listings',
  1646. 'params' => ['marketplace' => Customer::BACKMARKET_ID]
  1647. ],
  1648. [
  1649. 'name' => 'Amazon',
  1650. 'route' => 'atech_net_core_marketplace_listings',
  1651. 'params' => ['marketplace' => Customer::AMAZON_ID]
  1652. ]
  1653. ];*/
  1654. $subMenus = [
  1655. /*[
  1656. 'name' => 'Listings',
  1657. 'route' => 'atech_net_core_marketplace_listings',
  1658. 'submenu' => $listingListSubMenus
  1659. ],*/
  1660. [
  1661. 'name' => 'Finalizing',
  1662. 'route' => 'atech_net_core_order_marketplace_orders',
  1663. ],
  1664. [
  1665. 'name' => 'Import listing CSV',
  1666. 'route' => 'import_listing_data',
  1667. ],
  1668. [
  1669. 'name' => 'Internal Jobs',
  1670. 'route' => 'atech_net_core_internal_job_list',
  1671. ],
  1672. [
  1673. 'name' => 'Listings',
  1674. 'route' => 'atech_net_core_marketplace_listings',
  1675. ],
  1676. ];
  1677. $navigation['order']['menu'][] = [
  1678. 'name' => 'Marketplace',
  1679. 'link' => '#',
  1680. 'icon' => 'glyphicon glyphicon-th',
  1681. 'submenu' => $subMenus,
  1682. ];
  1683. }
  1684. if ($this->checkPermission(User::PERMISSION_ORDER_EXPORT, User::MODULE_ORDER)) {
  1685. $subMenus = [
  1686. [
  1687. 'name' => 'Orders',
  1688. 'route' => 'atech_net_core_order_export',
  1689. ],
  1690. [
  1691. 'name' => 'Order status',
  1692. 'route' => 'atech_net_core_order_status_export',
  1693. ],
  1694. [
  1695. 'name' => 'Orders with out invoices',
  1696. 'route' => 'atech_net_core_orders_with_out_invoices_export',
  1697. ],
  1698. [
  1699. 'name' => 'DHL labels',
  1700. 'route' => 'atech_net_core_export_dhl_labels_by_date',
  1701. ],
  1702. ];
  1703. $navigation['order']['menu'][] = [
  1704. 'name' => 'Export',
  1705. 'link' => '#',
  1706. 'icon' => 'glyphicon glyphicon-export',
  1707. 'submenu' => $subMenus,
  1708. ];
  1709. }
  1710. //Stock management
  1711. if (
  1712. $this->checkPermission(User::PERMISSION_LIST, User::MODULE_STOCK) ||
  1713. $this->checkPermission(User::PERMISSION_LIST, User::MODULE_STOCK_MOVEMENT) ||
  1714. $this->checkPermission(User::PERMISSION_LIST, User::MODULE_STOCK_ITEM) ||
  1715. in_array($currentUser->getId(), [132, 217])
  1716. ) {
  1717. $navigation['stock_movements'] = [
  1718. 'name' => 'Stock management',
  1719. 'route' => 'stock_movement',
  1720. 'icon' => 'glyphicon glyphicon-th-list',
  1721. ];
  1722. if ($this->checkPermission(User::PERMISSION_CREATE, User::MODULE_STOCK_MOVEMENT)) {
  1723. $navigation['stock_movements']['menu'][] = [
  1724. 'name' => 'Add',
  1725. 'link' => '#',
  1726. 'submenu' => [
  1727. [
  1728. 'name' => 'Ins',
  1729. 'route' => 'stock_movement_new',
  1730. 'params' => [
  1731. 'type' => StockMovement::TYPE_IN,
  1732. ],
  1733. 'icon' => 'glyphicon glyphicon-plus',
  1734. ], [
  1735. 'name' => 'Outs',
  1736. 'route' => 'stock_movement_new',
  1737. 'params' => [
  1738. 'type' => StockMovement::TYPE_OUT,
  1739. ],
  1740. 'icon' => 'glyphicon glyphicon-minus',
  1741. ], [
  1742. 'name' => 'Neutrals',
  1743. 'route' => 'stock_movement_new',
  1744. 'params' => [
  1745. 'type' => StockMovement::TYPE_NEUTRAL,
  1746. ],
  1747. 'icon' => 'glyphicon glyphicon-asterisk',
  1748. ], [
  1749. 'name' => 'Config change',
  1750. 'route' => 'stock_movement_new_config_change',
  1751. 'icon' => 'glyphicon glyphicon-transfer',
  1752. ], [
  1753. 'name' => 'Config change (service)',
  1754. 'route' => 'stock_movement_new_config_change',
  1755. 'params' => [
  1756. 'method' => 'servicing',
  1757. ],
  1758. 'permission' => $this->checkPermission(User::PERMISSION_STOCK_MOVEMENT_SERVICE_CONFIG_CHANGE, User::MODULE_STOCK_MOVEMENT),
  1759. 'icon' => 'glyphicon glyphicon-transfer',
  1760. ], [
  1761. 'name' => 'Quarantine',
  1762. 'route' => 'stock_movement_new',
  1763. 'params' => [
  1764. 'type' => StockMovement::TYPE_NEUTRAL,
  1765. 'sub-type' => StockMovement::SUB_TYPE_NEUTRAL_QUARANTINE,
  1766. ],
  1767. 'icon' => 'glyphicon glyphicon-warning-sign',
  1768. ], [
  1769. 'name' => 'Consumption',
  1770. 'route' => 'stock_movement_new',
  1771. 'params' => [
  1772. 'type' => StockMovement::TYPE_OUT,
  1773. 'sub-type' => StockMovement::SUB_TYPE_OUT_CONSUMPTION,
  1774. ],
  1775. 'icon' => 'glyphicon glyphicon-refresh',
  1776. ], [
  1777. 'name' => 'Re aiken',
  1778. 'route' => 'stock_movement_new',
  1779. 'params' => [
  1780. 'type' => StockMovement::TYPE_NEUTRAL,
  1781. 'sub-type' => StockMovement::SUB_TYPE_NEUTRAL_RE_AIKEN,
  1782. ],
  1783. 'icon' => 'glyphicon glyphicon-leaf',
  1784. ],
  1785. ],
  1786. ];
  1787. }
  1788. if ($this->checkPermission(User::PERMISSION_LIST, User::MODULE_STOCK_MOVEMENT)) {
  1789. $navigation['stock_movements']['menu'][] = [
  1790. 'name' => 'Ins',
  1791. 'route' => 'stock_movement',
  1792. 'params' => [
  1793. 'type' => 1,
  1794. ],
  1795. 'icon' => 'glyphicon glyphicon-plus',
  1796. ];
  1797. }
  1798. if ($this->checkPermission(User::PERMISSION_LIST, User::MODULE_STOCK_MOVEMENT)) {
  1799. $navigation['stock_movements']['menu'][] = [
  1800. 'name' => 'Outs',
  1801. 'route' => 'stock_movement',
  1802. 'params' => [
  1803. 'type' => 2,
  1804. ],
  1805. 'icon' => 'glyphicon glyphicon-minus',
  1806. ];
  1807. }
  1808. if ($this->checkPermission(User::PERMISSION_LIST, User::MODULE_STOCK_MOVEMENT)) {
  1809. $navigation['stock_movements']['menu'][] = [
  1810. 'name' => 'Neutrals',
  1811. 'route' => 'stock_movement',
  1812. 'params' => [
  1813. 'type' => 3,
  1814. ],
  1815. 'icon' => 'glyphicon glyphicon-asterisk',
  1816. ];
  1817. }
  1818. $navigation['stock_movements']['menu'][] = [
  1819. 'name' => 'Stock items',
  1820. 'route' => 'stock_item',
  1821. 'icon' => 'glyphicon glyphicon-search',
  1822. ];
  1823. $navigation['stock_movements']['menu'][] = [
  1824. 'name' => 'Latest stock items',
  1825. 'route' => 'stock_item_latest',
  1826. 'icon' => 'glyphicon glyphicon-baby-formula',
  1827. ];
  1828. $navigation['stock_movements']['menu'][] = [
  1829. 'name' => 'Stock item quality results',
  1830. 'route' => 'stock_item_quality_result',
  1831. 'icon' => 'glyphicon glyphicon-check',
  1832. ];
  1833. $navigation['stock_movements']['menu'][] = [
  1834. 'name' => 'Stock request',
  1835. 'route' => 'stock_request_list',
  1836. 'icon' => 'glyphicon glyphicon-hand-down',
  1837. ];
  1838. $navigation['stock_movements']['menu'][] = [
  1839. 'name' => 'Blancco import',
  1840. 'route' => 'blancco_import',
  1841. 'icon' => 'glyphicon glyphicon-bold',
  1842. ];
  1843. if ($this->checkPermission(User::PERMISSION_POSITIONING, User::MODULE_STOCK_ITEM)) {
  1844. $navigation['stock_movements']['menu'][] = [
  1845. 'name' => 'Group label print',
  1846. 'route' => 'atech_net_core_stock_item_group_label_collect',
  1847. 'icon' => 'glyphicon glyphicon-barcode',
  1848. ];
  1849. }
  1850. if ($this->checkPermission(User::PERMISSION_STOCK_REVIEW, User::MODULE_STOCK_MOVEMENT)) {
  1851. $navigation['stock_movements']['menu'][] = [
  1852. 'name' => 'Stock review',
  1853. 'route' => 'stock_review',
  1854. 'params' => [
  1855. 'type' => 1,
  1856. ],
  1857. 'icon' => 'glyphicon glyphicon-list',
  1858. ];
  1859. }
  1860. $navigation['stock_movements']['menu'][] = [
  1861. 'name' => 'Mobil scanning',
  1862. 'route' => 'atech_net_core_order_mobil_scanning_page',
  1863. 'icon' => 'glyphicon glyphicon-phone',
  1864. ];
  1865. if ($this->checkPermission(User::PERMISSION_POSITIONING, User::MODULE_STOCK_ITEM)) {
  1866. $navigation['stock_movements']['menu'][] = [
  1867. 'name' => 'Positioning',
  1868. 'route' => 'stock_item_positioning',
  1869. 'icon' => 'glyphicon glyphicon-bookmark',
  1870. ];
  1871. }
  1872. if ($this->checkPermission(User::PERMISSION_POSITIONING, User::MODULE_STOCK_ITEM)) {
  1873. $navigation['stock_movements']['menu'][] = [
  1874. 'name' => 'By stock position',
  1875. 'route' => 'stock_item_position_search',
  1876. 'icon' => 'glyphicon glyphicon-search',
  1877. ];
  1878. }
  1879. if ($this->checkPermission(User::PERMISSION_STOCK_MOVEMENT_SHIPMENTS, User::MODULE_STOCK_MOVEMENT)) {
  1880. $navigation['stock_movements']['menu'][] = [
  1881. 'name' => 'Shipments',
  1882. // 'route' => 'shipment',
  1883. 'icon' => 'fa-solid fa-cubes',
  1884. 'link' => '#',
  1885. 'submenu' => [
  1886. [
  1887. 'name' => 'Shipments - list',
  1888. 'route' => 'shipment',
  1889. 'icon' => 'fa-solid fa-cubes',
  1890. ], [
  1891. 'name' => 'Shipments - expected summary',
  1892. 'route' => 'expected_item_index',
  1893. 'icon' => 'fa-solid fa-cubes',
  1894. ]
  1895. ]
  1896. ];
  1897. $navigation['stock_movements']['menu'][] = [
  1898. 'name' => 'Shipment statistics',
  1899. 'route' => 'shipment_statistics',
  1900. 'params' => [],
  1901. ];
  1902. }
  1903. if ($this->checkPermission(User::PERMISSION_WANTED_ITEMS_LIST, User::MODULE_STOCK_MOVEMENT)) {
  1904. $navigation['stock_movements']['menu'][] = [
  1905. 'name' => 'Wanted items',
  1906. 'route' => 'wanted_items',
  1907. 'icon' => 'glyphicon glyphicon-star-empty',
  1908. ];
  1909. }
  1910. if ($this->isAdmin()) {
  1911. $navigation['stock_movements']['menu'][] = [
  1912. 'name' => 'Statistics milestones',
  1913. 'route' => 'statistics_milestone',
  1914. ];
  1915. }
  1916. if ($this->checkPermission(User::PERMISSION_LIST, User::MODULE_STOCK)) {
  1917. $navigation['stock_movements']['menu'][] = [
  1918. 'name' => 'Stocks',
  1919. 'route' => 'stock',
  1920. ];
  1921. }
  1922. if ($this->checkPermission(User::PERMISSION_STOCK_POSITION, User::MODULE_STOCK)) {
  1923. $navigation['stock_movements']['menu'][] = [
  1924. 'name' => 'Stock positions',
  1925. 'route' => 'stock_position',
  1926. ];
  1927. }
  1928. if ($this->checkPermission(User::PERMISSION_TEMPORARY_STOCK_POSITIONS, User::MODULE_STOCK_ITEM)) {
  1929. $navigation['stock_movements']['menu'][] = [
  1930. 'name' => 'Temporary stock positions of users',
  1931. 'route' => 'user_temporary_stock_position',
  1932. ];
  1933. }
  1934. if ($this->checkPermission(User::PERMISSION_STOCK_POSITION_LABEL_PRINT, User::MODULE_STOCK_MOVEMENT)) {
  1935. $navigation['stock_movements']['menu'][] = [
  1936. 'name' => 'Stock position label print',
  1937. 'route' => 'stock_position_label_print',
  1938. 'icon' => 'glyphicon glyphicon-barcode',
  1939. ];
  1940. }
  1941. $stockMovementExportSubMenu = [];
  1942. if ($this->checkPermission(User::PERMISSION_IN_PRODUCTION_EXPORT, User::MODULE_STOCK_MOVEMENT)) {
  1943. $stockMovementExportSubMenu[] = [
  1944. 'name' => 'In prod products',
  1945. 'route' => 'stock_movement_in_production_export',
  1946. ];
  1947. }
  1948. if ($this->checkPermission(User::PERMISSION_STOCK_MOVEMENT_EXPORT_ALL, User::MODULE_STOCK_MOVEMENT)) {
  1949. $stockMovementExportSubMenu[] = [
  1950. 'name' => 'Export all & email',
  1951. 'route' => 'stock_movement_export_all_movement_and_send_email_page',
  1952. ];
  1953. }
  1954. if ( $this->checkPermission(User::PERMISSION_STOCK_MOVEMENT_EXPORT_SHIPMENT_ITEM, User::MODULE_STOCK_MOVEMENT) ) {
  1955. $stockMovementExportSubMenu[] = [
  1956. 'name' => 'Export shipment items',
  1957. 'route' => 'stock_movement_export_shipment_items_page',
  1958. ];
  1959. }
  1960. $stockMovementExportSubMenu[] = [
  1961. 'name' => 'Multiple times returned items',
  1962. 'route' => 'atech_net_core_order_stock_item_export_multiple_times_returned_items',
  1963. ];
  1964. if (\count($stockMovementExportSubMenu) > 0) {
  1965. $navigation['stock_movements']['menu'][] = [
  1966. 'name' => 'Export',
  1967. 'link' => '#',
  1968. 'icon' => 'glyphicon glyphicon-export',
  1969. 'submenu' => $stockMovementExportSubMenu,
  1970. ];
  1971. }
  1972. }
  1973. //Tasks
  1974. if ($this->checkPermission(User::PERMISSION_LIST, User::MODULE_TASK)) {
  1975. $navigation['tasks'] = [
  1976. 'name' => 'Tasks',
  1977. 'route' => 'atech_net_core_task_index',
  1978. 'icon' => 'glyphicon glyphicon-tasks',
  1979. ];
  1980. }
  1981. //FAQ
  1982. if ( false && $this->checkPermission(User::PERMISSION_LIST, User::MODULE_FAQ) ) {
  1983. $navigation['knowledge_base'] = [
  1984. 'name' => 'Knowledge Base',
  1985. 'route' => 'atech_net_core_knowledge_base_index',
  1986. 'icon' => 'glyphicon glyphicon-question-sign',
  1987. ];
  1988. }
  1989. //Claims
  1990. if ($this->checkPermission(User::PERMISSION_LIST, User::MODULE_CLAIM)) {
  1991. $navigation['claims'] = [
  1992. 'name' => 'Claim',
  1993. 'route' => 'atech_net_core_claim',
  1994. 'icon' => 'glyphicon glyphicon-wrench',
  1995. ];
  1996. }
  1997. //Other
  1998. $otherMenu = [];
  1999. if ($this->checkPermission(User::PERMISSION_ACCESS_LOG, User::MODULE_OTHER)) {
  2000. $otherMenu[] = [
  2001. 'name' => 'Access log',
  2002. 'route' => 'atech_net_core_access_log',
  2003. 'icon' => 'glyphicon glyphicon-lock',
  2004. ];
  2005. }
  2006. if ($this->checkPermission(User::PERMISSION_ERROR_CODES, User::MODULE_OTHER)) {
  2007. $otherMenu[] = [
  2008. 'name' => 'Aiken error codes',
  2009. 'route' => 'error_codes_index',
  2010. ];
  2011. }
  2012. if ($this->checkPermission(User::PERMISSION_ATTRIBUTES, User::MODULE_PRODUCT)) {
  2013. $otherMenu[] = [
  2014. 'name' => 'Attribute Options',
  2015. 'route' => 'atech_net_core_attribute_option_list',
  2016. ];
  2017. }
  2018. if ($this->checkPermission(User::PERMISSION_AUTOMATIZATIONS, User::MODULE_OTHER)) {
  2019. $otherMenu[] = [
  2020. 'name' => 'Automatizations',
  2021. 'route' => 'atech_net_core_automatizations',
  2022. ];
  2023. }
  2024. $otherMenu[] = [
  2025. 'name' => 'Gallery',
  2026. 'route' => 'atech_net_core_gallery',
  2027. ];
  2028. if ($this->checkPermission(User::PERMISSION_INTERNAL_NEWS, User::MODULE_OTHER)) {
  2029. $otherMenu[] = [
  2030. 'name' => 'Internal news',
  2031. 'route' => 'atech_net_core_internal_news',
  2032. ];
  2033. }
  2034. if ($this->checkPermission(User::PERMISSION_PERMISSION_GROUPS, User::MODULE_USER)) {
  2035. $otherMenu[] = [
  2036. 'name' => 'Permission groups',
  2037. 'route' => 'user_permission_group',
  2038. 'icon' => 'glyphicon glyphicon-eye-open',
  2039. ];
  2040. }
  2041. if ($this->checkPermission(User::PERMISSION_PERMISSION_LIST, User::MODULE_USER)) {
  2042. $otherMenu[] = [
  2043. 'name' => 'Permission list',
  2044. 'route' => 'atech_net_core_user_permission_list',
  2045. 'icon' => 'glyphicon glyphicon-list',
  2046. ];
  2047. }
  2048. if ($this->checkPermission(User::PERMISSION_PERMISSION_CHANGELOG, User::MODULE_USER)) {
  2049. $otherMenu[] = [
  2050. 'name' => 'Permission changelog',
  2051. 'route' => 'atech_net_core_user_permission_changelog',
  2052. ];
  2053. }
  2054. if ($this->checkPermission(User::PERMISSION_ATTRIBUTES, User::MODULE_PRODUCT)) {
  2055. $otherMenu[] = [
  2056. 'name' => 'Product Attributes',
  2057. 'route' => 'atech_net_core_attribute_list',
  2058. ];
  2059. }
  2060. if ($this->checkPermission(User::PERMISSION_TRANSLATIONS, User::MODULE_OTHER)) {
  2061. $otherMenu[] = [
  2062. 'name' => 'Translations',
  2063. 'route' => 'atech_net_core_translation_list',
  2064. ];
  2065. }
  2066. if ($this->checkPermission(User::PERMISSION_UPLOAD_FILE, User::MODULE_OTHER)) {
  2067. $otherMenu[] = [
  2068. 'name' => 'Upload file',
  2069. 'link' => 'https://www.atechnet.sk/upload/',
  2070. 'target' => '_blank',
  2071. ];
  2072. }
  2073. if ($this->checkPermission(User::PERMISSION_LIST, User::MODULE_USER)) {
  2074. $otherMenu[] = [
  2075. 'name' => 'Users',
  2076. 'route' => 'atech_net_core_user_list',
  2077. 'icon' => 'glyphicon glyphicon-user',
  2078. ];
  2079. }
  2080. if ($this->checkPermission(User::PERMISSION_TRANSLATIONS, User::MODULE_OTHER)) {
  2081. $otherMenu[] = [
  2082. 'name' => 'Web translations',
  2083. 'route' => 'file_translations_index',
  2084. 'params' => [
  2085. 'token' => 'fasdgasghawrge547547654wrreg56936yh98gjfv4q2ghj9340yhg24',
  2086. ],
  2087. ];
  2088. }
  2089. if ($this->checkPermission(User::PERMISSION_SHORTCUT, User::MODULE_OTHER)) {
  2090. $otherMenu[] = [
  2091. 'name' => 'Shortcuts',
  2092. 'route' => 'shortcut_index',
  2093. 'icon' => 'glyphicon glyphicon-new-window',
  2094. ];
  2095. }
  2096. if ($this->checkPermission(User::PERMISSION_LIST, User::MODULE_PRODUCT)) {
  2097. $otherMenu[] = [
  2098. 'name' => 'Search by hidden configuration',
  2099. 'route' => 'atech_net_core_search_by_product_tags',
  2100. ];
  2101. }
  2102. if ($otherMenu) {
  2103. $navigation['other'] = [
  2104. 'name' => 'Other',
  2105. 'route' => 'atech_net_core_attribute_list',
  2106. 'icon' => 'glyphicon glyphicon-cog',
  2107. 'menu' => $otherMenu,
  2108. ];
  2109. }
  2110. //Marketing tools
  2111. $marketingToolsMenu = [];
  2112. if ($this->checkPermission(User::PERMISSION_EDITING_PAGES, User::MODULE_MARKETING_TOOLS)) {
  2113. $marketingToolsMenu[] = [
  2114. 'name' => 'Static pages',
  2115. 'route' => 'pages',
  2116. 'params' => [
  2117. 'type' => 'static',
  2118. ],
  2119. 'icon' => 'glyphicon glyphicon-file',
  2120. ];
  2121. $marketingToolsMenu[] = [
  2122. 'name' => 'Blog',
  2123. 'route' => 'pages',
  2124. 'params' => [
  2125. 'type' => 'blog',
  2126. ],
  2127. 'icon' => 'glyphicon glyphicon-education',
  2128. ];
  2129. $marketingToolsMenu[] = [
  2130. 'name' => 'Categories',
  2131. 'route' => 'pages',
  2132. 'params' => [
  2133. 'type' => 'category',
  2134. ],
  2135. 'icon' => 'glyphicon glyphicon-list-alt',
  2136. ];
  2137. }
  2138. if ($this->checkPermission(User::PERMISSION_NAVIGATION, User::MODULE_MARKETING_TOOLS)) {
  2139. $marketingToolsMenu[] = [
  2140. 'name' => 'Navigation',
  2141. 'route' => 'atech_net_core_web_navigation_index',
  2142. 'icon' => 'glyphicon glyphicon-menu-hamburger',
  2143. ];
  2144. }
  2145. if ($this->checkPermission(User::PERMISSION_SEARCH_ENGINE, User::MODULE_MARKETING_TOOLS)) {
  2146. $marketingToolsMenu[] = [
  2147. 'name' => 'Search engine',
  2148. 'route' => 'search_engine_dashboard',
  2149. 'icon' => 'glyphicon glyphicon-search',
  2150. ];
  2151. }
  2152. if ($this->checkPermission(User::PERMISSION_BANNER, User::MODULE_MARKETING_TOOLS)) {
  2153. $marketingToolsMenu[] = [
  2154. 'name' => 'Banner',
  2155. 'route' => 'atech_net_core_banner',
  2156. 'icon' => 'glyphicon glyphicon-blackboard',
  2157. ];
  2158. }
  2159. if ($this->checkPermission(User::PERMISSION_NANOBAR, User::MODULE_MARKETING_TOOLS)) {
  2160. $marketingToolsMenu[] = [
  2161. 'name' => 'Nanobar',
  2162. 'route' => 'nanobar',
  2163. 'icon' => 'glyphicon glyphicon-bullhorn',
  2164. ];
  2165. }
  2166. if ($this->checkPermission(User::PERMISSION_PRODUCT_GROUPS, User::MODULE_MARKETING_TOOLS)) {
  2167. $marketingToolsMenu[] = [
  2168. 'name' => 'Product groups',
  2169. 'route' => 'product_groups',
  2170. 'icon' => 'glyphicon glyphicon-compressed',
  2171. ];
  2172. $marketingToolsMenu[] = [
  2173. 'name' => 'Category groups',
  2174. 'route' => 'category_groups',
  2175. 'icon' => 'glyphicon glyphicon-compressed',
  2176. ];
  2177. }
  2178. if ($this->checkPermission(User::PERMISSION_PRODUCT_TAGS, User::MODULE_MARKETING_TOOLS)) {
  2179. $marketingToolsMenu[] = [
  2180. 'name' => 'Product tags',
  2181. 'route' => 'product_tag',
  2182. 'icon' => 'glyphicon glyphicon-tags',
  2183. ];
  2184. }
  2185. if ($this->checkPermission(User::PERMISSION_EDITING_PAGES, User::MODULE_MARKETING_TOOLS)) {
  2186. $marketingToolsMenu[] = [
  2187. 'name' => 'Media',
  2188. 'route' => 'media_list',
  2189. 'icon' => 'glyphicon glyphicon-folder-open',
  2190. ];
  2191. }
  2192. if ($this->checkPermission(User::PERMISSION_JOBS, User::MODULE_MARKETING_TOOLS)) {
  2193. $marketingToolsMenu[] = [
  2194. 'name' => 'Jobs',
  2195. 'route' => 'jobs',
  2196. 'icon' => 'glyphicon glyphicon-sunglasses',
  2197. ];
  2198. }
  2199. if ($this->checkPermission(User::PERMISSION_REVIEWS, User::MODULE_MARKETING_TOOLS)) {
  2200. $marketingToolsMenu[] = [
  2201. 'name' => 'Reviews',
  2202. 'route' => 'reviews',
  2203. 'icon' => 'glyphicon glyphicon-heart-empty',
  2204. ];
  2205. }
  2206. if ($this->checkPermission(User::PERMISSION_SURVEYS, User::MODULE_MARKETING_TOOLS)) {
  2207. $marketingToolsMenu[] = [
  2208. 'name' => 'Surveys',
  2209. 'route' => 'survey_index',
  2210. 'icon' => 'glyphicon glyphicon-list-alt',
  2211. ];
  2212. $marketingToolsMenu[] = [
  2213. 'name' => 'Survey media list',
  2214. 'route' => 'survey_media_list',
  2215. 'icon' => 'glyphicon glyphicon-picture',
  2216. ];
  2217. }
  2218. if ($this->checkPermission(User::PERMISSION_COUPONS, User::MODULE_MARKETING_TOOLS)) {
  2219. $marketingToolsMenu[] = [
  2220. 'name' => 'Coupons',
  2221. 'route' => 'coupons',
  2222. 'icon' => 'glyphicon glyphicon-gift',
  2223. ];
  2224. }
  2225. if ($this->checkPermission(User::PERMISSION_UNAS_CHATGPT_TRANSLATION, User::MODULE_MARKETING_TOOLS)) {
  2226. $marketingToolsMenu[] = [
  2227. 'name' => 'Unas translations',
  2228. 'route' => 'atech_net_core_unas_translation',
  2229. 'icon' => 'glyphicon glyphicon-folder-open',
  2230. ];
  2231. }
  2232. if ($marketingToolsMenu) {
  2233. $navigation['static'] = [
  2234. 'name' => '',
  2235. 'route' => 'pages',
  2236. 'params' => [
  2237. 'type' => 'static',
  2238. ],
  2239. 'title' => 'Marketing tools',
  2240. 'icon' => 'glyphicon glyphicon-screenshot',
  2241. 'menu' => $marketingToolsMenu,
  2242. ];
  2243. }
  2244. if ($userId != User::HUN_ACCOUNTANT_ID) {
  2245. //Wiki
  2246. $navigation['wiki'] = [
  2247. 'name' => 'WIKI',
  2248. 'link' => 'https://www.atechcomp.eu/furbify-wiki/public',
  2249. 'target' => '_blank',
  2250. 'title' => 'Furbify WIKI',
  2251. 'icon' => 'glyphicon glyphicon-education',
  2252. ];
  2253. //Meal
  2254. $navigation['meal'] = [
  2255. 'name' => '',
  2256. 'route' => 'atech_net_core_meal',
  2257. 'title' => 'Meal',
  2258. 'image' => 'bundles/atechnetcore/images/chicken.svg',
  2259. 'warning_sign' => true,
  2260. ];
  2261. }
  2262. $cacheItem->set($navigation);
  2263. $cacheItem->expiresAfter(self::CACHE_LIFETIME_7_DAYS);
  2264. $this->cache->save($cacheItem);
  2265. return $this->render('AtechNetCoreBundle/Default/menu.html.twig', [
  2266. 'current_route' => $currentRoute,
  2267. 'navigation' => $navigation,
  2268. ]);
  2269. }
  2270. /**
  2271. * @param array $ids
  2272. * @return bool
  2273. */
  2274. private function allowForUsersWithId(array $ids): bool
  2275. {
  2276. return in_array($this->getUser()->getId(), $ids);
  2277. }
  2278. /**
  2279. * @return string
  2280. */
  2281. public function getApiToken(): string
  2282. {
  2283. return $this->apiToken;
  2284. }
  2285. /**
  2286. * @param string $moduleTitle
  2287. * @param int $userId
  2288. * @param int $cacheVersion
  2289. * @return string
  2290. */
  2291. public function getCacheKey(string $moduleTitle, int $userId = 0, int $cacheVersion = 0): string
  2292. {
  2293. return 'cntrls.' . $moduleTitle . ($userId != 0 ? '.' . $userId : '') . ($cacheVersion != 0 ? '.' . $cacheVersion : '');
  2294. }
  2295. /**
  2296. * @param int $userId
  2297. * @return string
  2298. */
  2299. public function getNotificationCacheKey(int $userId): string
  2300. {
  2301. return $this->getCacheKey('notification', $userId, 1);
  2302. }
  2303. /**
  2304. * @param string $permission
  2305. * @param string $module
  2306. */
  2307. protected function hasPermission(string $permission, string $module)
  2308. {
  2309. if (!in_array($permission, $this->getUser()->getPermissionsByModule($module))) {
  2310. throw new AccessDeniedHttpException(
  2311. $this->translator->trans('You do not have permission to access this page!')
  2312. );
  2313. }
  2314. }
  2315. /**
  2316. * @param string $permission
  2317. * @param string $module
  2318. * @return bool
  2319. */
  2320. protected function checkPermission(string $permission, string $module): bool
  2321. {
  2322. if (!in_array($permission, $this->getUser()->getPermissionsByModule($module))) {
  2323. return false;
  2324. }
  2325. return true;
  2326. }
  2327. /**
  2328. * @param string $permission
  2329. * @return array
  2330. */
  2331. protected function getPermissionValues(string $permission): array
  2332. {
  2333. return (array)$this->getUser()->getPermissionsByModule($permission);
  2334. }
  2335. /**
  2336. * @return mixed
  2337. */
  2338. protected function getLastAndAveragePricesFromCache()
  2339. {
  2340. return $this->getEntityManager()->getRepository(Product::class)->getLastAndAveragePricesFromCache();
  2341. }
  2342. /**
  2343. * @return LuigisBox
  2344. */
  2345. protected function getLuigisBox(): LuigisBox
  2346. {
  2347. $entityManager = $this->getEntityManager();
  2348. $domain = $entityManager->getRepository(Domain::class)->findOneById(1);
  2349. return new LuigisBox($entityManager, $domain);
  2350. }
  2351. /**
  2352. * @param string $string
  2353. * @return false|string
  2354. */
  2355. protected function replaceSpecialCharactersInString(string $string)
  2356. {
  2357. return transliterator_transliterate('Any-Latin; Latin-ASCII; [\u0080-\u7fff] remove', $string);
  2358. }
  2359. /**
  2360. * @return CloudflareImage
  2361. */
  2362. protected function getCloudflareImage(): CloudflareImage
  2363. {
  2364. $config = $this->getParameter('cloudflare_image');
  2365. return new CloudflareImage((int)$config['active'], $config['token']);
  2366. }
  2367. /**
  2368. * @param Domain $domain
  2369. * @return mixed
  2370. */
  2371. protected function getCurrentExchangeRateByDomain(Domain $domain)
  2372. {
  2373. switch ($domain->getLanguage()->getCode()) {
  2374. case 'sk':
  2375. case 'en':
  2376. $currency = 'EUR';
  2377. break;
  2378. case 'hu':
  2379. $currency = 'HUF';
  2380. break;
  2381. case 'cz':
  2382. $currency = 'CZK';
  2383. break;
  2384. default:
  2385. $currency = 'EUR';
  2386. }
  2387. if ($currency == 'EUR') {
  2388. return 1;
  2389. }
  2390. $date1DayBefore = (new \DateTime())->sub(new \DateInterval('P1D'))->format('Y-m-d');
  2391. return $this->getHistoricalEuroRate()->getRate($currency, $date1DayBefore);
  2392. }
  2393. /**
  2394. * @return Packeta
  2395. */
  2396. protected function getPacketa(): Packeta
  2397. {
  2398. $config = $this->getParameter('packeta');
  2399. return new Packeta($config['api_key'], $config['api_password'], $this->getEntityManager());
  2400. }
  2401. /**
  2402. * @return SquarePay
  2403. */
  2404. protected function getSquarePay(): SquarePay
  2405. {
  2406. $config = $this->getParameter('square_pay');
  2407. return new SquarePay($this->getParameter('kernel.project_dir'), $config['username'], $config['password']);
  2408. }
  2409. /**
  2410. * @return array
  2411. * @throws \Psr\Cache\InvalidArgumentException
  2412. */
  2413. protected function getSalesManagerList(): array
  2414. {
  2415. $cacheKey = 'salesmanagersList.v1';
  2416. $cacheItem = $this->cache->getItem($cacheKey);
  2417. if ($cacheItem->isHit()) {
  2418. $salesManagers = $cacheItem->get();
  2419. } else {
  2420. $data = $this->getEntityManager()->createQuery('SELECT DISTINCT IDENTITY(c.salesManager) as salesManager
  2421. FROM AtechNetCoreBundle:Customer c
  2422. ORDER BY c.id')
  2423. ->getScalarResult();
  2424. $salesManagers = [];
  2425. foreach ($data as $salesManager) {
  2426. if (empty($salesManager['salesManager'])) {
  2427. continue;
  2428. }
  2429. $salesManagers[$salesManager['salesManager']] = $salesManager['salesManager'];
  2430. }
  2431. $cacheItem->set($salesManagers);
  2432. $cacheItem->expiresAfter(self::CACHE_LIFETIME_1_HOUR);
  2433. $this->cache->save($cacheItem);
  2434. }
  2435. return $salesManagers;
  2436. }
  2437. /**
  2438. * @return TranslatorInterface
  2439. */
  2440. protected function getTranslator(): TranslatorInterface
  2441. {
  2442. return $this->translator;
  2443. }
  2444. /**
  2445. * @return UrlGeneratorInterface
  2446. */
  2447. protected function getRouter(): UrlGeneratorInterface
  2448. {
  2449. return $this->router;
  2450. }
  2451. /**
  2452. * @return MailerInterface
  2453. */
  2454. protected function getMailer(): MailerInterface
  2455. {
  2456. return $this->mailer;
  2457. }
  2458. /**
  2459. * @return RequestStack
  2460. */
  2461. protected function getRequestStack(): RequestStack
  2462. {
  2463. return $this->requestStack;
  2464. }
  2465. /**
  2466. * @return SessionInterface
  2467. */
  2468. protected function getSession(): SessionInterface
  2469. {
  2470. return $this->requestStack->getSession();
  2471. }
  2472. /**
  2473. * @return Security
  2474. */
  2475. protected function getSecurity(): Security
  2476. {
  2477. return $this->security;
  2478. }
  2479. /**
  2480. * @return object|UserInterface|null
  2481. */
  2482. protected function getUser()
  2483. {
  2484. return $this->security->getUser();
  2485. }
  2486. /**
  2487. * @return HistoricalEuroRate
  2488. */
  2489. protected function getHistoricalEuroRate(): HistoricalEuroRate
  2490. {
  2491. return $this->historicalEuroRate;
  2492. }
  2493. /**
  2494. * @return PBH
  2495. * @var string $moduleName
  2496. *
  2497. */
  2498. protected function getPostaBezHranic(): PBH
  2499. {
  2500. $config = $this->getParameter('posta_bez_hranic');
  2501. return new PBH($config['user_id'], $config['api_key'], $this->getEntityManager());
  2502. }
  2503. /**
  2504. * @return ErsteHelper
  2505. */
  2506. protected function getErsteHelper(string $bankName): ErsteHelper
  2507. {
  2508. $config = $this->getParameter('erste');
  2509. return new ErsteHelper(
  2510. $config['webApiKey'],
  2511. $config['clientId'],
  2512. $config['clientSecret'],
  2513. $config['walletId'],
  2514. $config['walletSecret'],
  2515. $config['accountId'][$bankName]
  2516. );
  2517. }
  2518. /**
  2519. * @return TatraBankaHelper
  2520. */
  2521. protected function getTatraBankaApi(): TatraBankaHelper
  2522. {
  2523. $tatraParams = $this->getParameter('tatra_banka');
  2524. return new TatraBankaHelper(
  2525. $tatraParams['client_id'],
  2526. $tatraParams['client_secret'],
  2527. $tatraParams['code_challenge'],
  2528. $tatraParams['code_verifier'],
  2529. $this->kernel->getEnvironment()
  2530. );
  2531. }
  2532. /**
  2533. * @param string $languageCode
  2534. * @return Instacash
  2535. */
  2536. protected function getInstacash(string $languageCode): Instacash
  2537. {
  2538. $config = $this->getParameter('instacash')[$languageCode];
  2539. return new Instacash($config['api_key'], $config['financier'], $this->getEntityManager(), $this->kernel->getEnvironment(), $this->cache, $languageCode);
  2540. }
  2541. /**
  2542. * @param string $languageCode
  2543. *
  2544. * @return Milpay
  2545. */
  2546. protected function getMilpay(string $languageCode): Milpay
  2547. {
  2548. $config = $this->getParameter('milpay')[$languageCode][$this->kernel->getEnvironment()];;
  2549. return new Milpay($config['api_key'], $config['offerId'], $this->getEntityManager(), $this->kernel->getEnvironment(), $this->cache, $languageCode);
  2550. }
  2551. protected function getAmazonSPApi(): AmazonSP
  2552. {
  2553. $config = $this->getParameter('amazon');
  2554. return new AmazonSP($config['client_id'], $config['client_secret']);
  2555. }
  2556. /**
  2557. * @param string $webshopCountry
  2558. * @return PastPay
  2559. */
  2560. protected function getPastPay(): PastPay
  2561. {
  2562. $serviceName = $this->kernel->getEnvironment() == 'prod' ? 'past_pay' : 'past_pay_demo';
  2563. $config = $this->getParameter($serviceName);
  2564. return new PastPay($config["api_key_sk"], $this->getEntityManager(), $this->kernel->getEnvironment());
  2565. }
  2566. protected function getFingera()
  2567. {
  2568. return new Fingera($this->getParameter('fingera'), $this->getEntityManager(), $this->cache);
  2569. }
  2570. protected function getKlaviyoConnect(): KlaviyoConnect
  2571. {
  2572. $env = $this->kernel->getEnvironment();
  2573. $config = $this->getParameter('klaviyo')[$env];
  2574. return new KlaviyoConnect($config, $this->getEntityManager(), $env, $this->getRouter(), null);
  2575. }
  2576. /**
  2577. * @throws \Exception
  2578. */
  2579. protected function getUnas(): Unas
  2580. {
  2581. $config = $this->getParameter('unas');
  2582. /** @var EntityManager $entityManager */
  2583. $entityManager = $this->getEntityManager();
  2584. $env = $this->kernel->getEnvironment();
  2585. $translator = new DatabaseTranslator($entityManager, Domain::DOMAIN_ID_RT_EU);
  2586. return new Unas($config['key'], $entityManager, $translator, $this->getRouter(), $this->cache, $env, $this->sluggerInterface);
  2587. }
  2588. protected function getChatGptTranslator(): ChatGPTTranslator
  2589. {
  2590. $apiKey = $this->getParameter('chatgpt')['translator'];
  2591. $entityManager = $this->getEntityManager();
  2592. return new ChatGptTranslator($apiKey, $entityManager);
  2593. }
  2594. protected function getBlancco(): Blancco
  2595. {
  2596. $config = $this->getParameter('blancco');
  2597. return new Blancco($config['api_key'], $this->getEntityManager(), $this->getUser());
  2598. }
  2599. protected function getVubHelper(): VubHelper
  2600. {
  2601. $config = $this->getParameter('vub');
  2602. return new VubHelper(
  2603. $this->kernel->getEnvironment(),
  2604. $this->getEntityManager(),
  2605. $config['iban'],
  2606. $config['SN'],
  2607. $config['CA'],
  2608. $config['certPass']
  2609. );
  2610. }
  2611. protected function getDaktela(): Daktela
  2612. {
  2613. $accessToken = $this->getParameter('daktela')['access_token'];
  2614. return new Daktela($accessToken);
  2615. }
  2616. protected function getPaypal(): Paypal
  2617. {
  2618. $env = $this->kernel->getEnvironment();
  2619. $env = 'prod';
  2620. $credentials = $env == 'prod'
  2621. ? $this->getParameter('paypal')['live']
  2622. : $this->getParameter('paypal')['sandbox'];
  2623. return new Paypal($env, $credentials);
  2624. }
  2625. }