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

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