src/ApplicationBundle/Twig/GeneralExtension.php line 27

Open in your IDE?
  1. <?php
  2. namespace ApplicationBundle\Twig;
  3. use ApplicationBundle\Constants\BuddybeeConstant;
  4. use ApplicationBundle\Constants\GeneralConstant;
  5. use ApplicationBundle\Constants\TaskConstant;
  6. use ApplicationBundle\Modules\Authentication\Constants\UserConstants;
  7. use ApplicationBundle\Modules\Comment\Comment;
  8. use ApplicationBundle\Modules\Inventory\Inventory;
  9. use ApplicationBundle\Modules\Purchase\Purchase;
  10. use ApplicationBundle\Modules\Purchase\Supplier;
  11. use ApplicationBundle\Modules\Sales\Client;
  12. use ApplicationBundle\Modules\Sales\SalesOrderM;
  13. use ApplicationBundle\Modules\System\System;
  14. use ApplicationBundle\Modules\User\Company;
  15. use ApplicationBundle\Modules\User\Department;
  16. use ApplicationBundle\Modules\User\Module;
  17. use ApplicationBundle\Modules\User\Position;
  18. use ApplicationBundle\Modules\User\Users;
  19. use Symfony\Component\HttpFoundation\Session\Session;
  20. use Symfony\Component\Serializer\Encoder\JsonEncoder;
  21. use Symfony\Component\Serializer\Encoder\XmlEncoder;
  22. use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
  23. use Symfony\Component\Serializer\Serializer;
  24. class GeneralExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
  25. {
  26.     protected $em;
  27.     protected $em_goc;
  28.     protected $dm;
  29.     protected $encryptDecrypt;
  30.     public function __construct(\Doctrine\ORM\EntityManager $em, \Doctrine\ORM\EntityManager $em_goc, \ApplicationBundle\Helper\EncryptDecrypt $encryptDecrypt)
  31.     {
  32.         $this->em $em;
  33.         $this->em_goc $em_goc;
  34.         //        $this->dm = $dm;
  35.         $this->encryptDecrypt $encryptDecrypt;
  36.     }
  37.     public function getFilters()
  38.     {
  39.         return array(
  40.             'functionExists' => new \Twig_SimpleFilter('functionExists', array($this'functionExists')),
  41.             'getMicroTime' => new \Twig_SimpleFilter('getMicroTime', array($this'getMicroTime')),
  42.             'isPhpSeven' => new \Twig_SimpleFilter('isPhpSeven', array($this'isPhpSeven')),
  43.             'getGlobalEncryptedDocInfo' => new \Twig_SimpleFilter('getGlobalEncryptedDocInfo', array($this'getGlobalEncryptedDocInfo')),
  44.             'getConvMultFromToWithdrawable' => new \Twig_SimpleFilter('getConvMultFromToWithdrawable', array($this'getConvMultFromToWithdrawable')),
  45.             'getCurrencyListByMarker' => new \Twig_SimpleFilter('getCurrencyListByMarker', array($this'getCurrencyListByMarker')),
  46.             'getDocumentDataDetails' => new \Twig_SimpleFilter('getDocumentDataDetails', array($this'getDocumentDataDetails')),
  47.             'getDocumentDataDetailsForView' => new \Twig_SimpleFilter('getDocumentDataDetailsForView', array($this'getDocumentDataDetailsForView')),
  48.             'getCurrencyList' => new \Twig_SimpleFilter('getCurrencyList', array($this'getCurrencyList')),
  49.             'imageToBase64Encode' => new \Twig_SimpleFilter('imageToBase64Encode', array($this'imageToBase64Encode')),
  50.             'strToHex' => new \Twig_SimpleFilter('strToHex', array($this'strToHex')),
  51.             'toHex' => new \Twig_SimpleFilter('toHex', array($this'toHex')),
  52. //            'getGlobalVars'   => new \Twig_SimpleFilter('getGlobalVars', array($this, 'getGlobals')),
  53.             'jsonDecode' => new \Twig_SimpleFilter('jsonDecode', array($this'jsonDecode')),
  54.             'strpad' => new \Twig_SimpleFilter('strpad', array($this'strpad')),
  55.             'getRandomColor' => new \Twig_SimpleFilter('getRandomColor', array($this'getRandomColor')),
  56.             'getCommentsForDocument' => new \Twig_SimpleFilter('getCommentsForDocument', array($this'getCommentsForDocument')),
  57.             'doSerialize' => new \Twig_SimpleFilter('doSerialize', array($this'doSerialize')),
  58.             'getUsers' => new \Twig_SimpleFilter('getUsers', array($this'getUsers')),
  59.             'getExpSubTypes' => new \Twig_SimpleFilter('getExpSubTypes', array($this'getExpSubTypes')),
  60.             'getUserRestrictions' => new \Twig_SimpleFilter('getUserRestrictions', array($this'getUserRestrictions')),
  61.             'PendingDocList' => new \Twig_SimpleFilter('PendingDocList', array($this'PendingDocList')),
  62.             'getSystemNotice' => new \Twig_SimpleFilter('getSystemNotice', array($this'getSystemNotice')),
  63.             'getProductDataFromFDM' => new \Twig_SimpleFilter('getProductDataFromFDM', array($this'getProductDataFromFDM')),
  64.             'getPositions' => new \Twig_SimpleFilter('getPositions', array($this'getPositions')),
  65.             'getDepartments' => new \Twig_SimpleFilter('getDepartments', array($this'getDepartments')),
  66.             'getCompanies' => new \Twig_SimpleFilter('getCompanies', array($this'getCompanies')),
  67.             'getCountries' => new \Twig_SimpleFilter('getCountries', array($this'getCountries')),
  68.             'getCountriesBuddyBee' => new \Twig_SimpleFilter('getCountriesBuddyBee', array($this'getCountriesBuddyBee')),
  69.             'getLanguagesBuddyBee' => new \Twig_SimpleFilter('getLanguagesBuddyBee', array($this'getLanguagesBuddyBee')),
  70.             'getBranchList' => new \Twig_SimpleFilter('getBranchList', array($this'getBranchList')),
  71.             'getRegionList' => new \Twig_SimpleFilter('getRegionList', array($this'getRegionList')),
  72.             'getGeographicalRegionList' => new \Twig_SimpleFilter('getGeographicalRegionList', array($this'getGeographicalRegionList')),
  73.             'getClientList' => new \Twig_SimpleFilter('getClientList', array($this'getClientList')),
  74.             'getClientTypeList' => new \Twig_SimpleFilter('getClientTypeList', array($this'getClientTypeList')),
  75.             'getSalesPersonList' => new \Twig_SimpleFilter('getSalesPersonList', array($this'getSalesPersonList')),
  76.             'getColors' => new \Twig_SimpleFilter('getColors', array($this'getColors')),
  77.             'getCountriesIndexed' => new \Twig_SimpleFilter('getCountriesIndexed', array($this'getCountriesIndexed')),
  78.             'getUserCompany' => new \Twig_SimpleFilter('getUserCompany', array($this'getUserCompany')),
  79.             'getSupplierDataForSupplierLogin' => new \Twig_SimpleFilter('getSupplierDataForSupplierLogin', array($this'getSupplierDataForSupplierLogin')),
  80.             'getClientDataForClientLogin' => new \Twig_SimpleFilter('getClientDataForClientLogin', array($this'getClientDataForClientLogin')),
  81.             'getMonthlySummary' => new \Twig_SimpleFilter('getMonthlySummary', array($this'getMonthlySummary')),
  82.             'getRecentSales' => new \Twig_SimpleFilter('getRecentSales', array($this'getRecentSales')),
  83.             'getSoCountAndMore' => new \Twig_SimpleFilter('getSoCountAndMore', array($this'getSoCountAndMore')),
  84.             'getRecentPurchase' => new \Twig_SimpleFilter('getRecentPurchase', array($this'getRecentPurchase')),
  85.             'getPositionModuleTree' => new \Twig_SimpleFilter('getPositionModuleTree', array($this'getPositionModuleTree')),
  86.             'showNecessaryMenu' => new \Twig_SimpleFilter('showNecessaryMenu', array($this'showNecessaryMenu')),
  87.             'showMenuIfAdmin' => new \Twig_SimpleFilter('showMenuIfAdmin', array($this'showMenuIfAdmin')),
  88.             'showNecessaryMenuGeneral' => new \Twig_SimpleFilter('showNecessaryMenuGeneral', array($this'showNecessaryMenuGeneral')),
  89.             'showNecessaryCreateBtn' => new \Twig_SimpleFilter('showNecessaryCreateBtn', array($this'showNecessaryCreateBtn')),
  90.             'todoSummaryList' => new \Twig_SimpleFilter('todoSummaryList', array($this'todoSummaryList')),
  91.             'getEntityDetailsByName' => new \Twig_SimpleFilter('getEntityDetailsByName', array($this'getEntityDetailsByName')),
  92.             'inArray' => new \Twig_SimpleFilter('inArray', array($this'inArray')),
  93.             'encryptMe' => new \Twig_SimpleFilter('encryptMe', array($this'encryptMe')),
  94.             'decryptMe' => new \Twig_SimpleFilter('decryptMe', array($this'decryptMe')),
  95.         );
  96.     }
  97. //    function qr_code_data_uri($qr_data, $options){
  98. //        qr_code_data_uri($qr_data, $options);
  99. //    }
  100.     public function isPhpSeven($gg='')
  101.     {
  102.         if (version_compare(PHP_VERSION'7.3.0''>=')) {
  103.             return true;
  104.         } else {
  105.             return false;
  106.         }
  107.     }
  108.     public function isMethodExist($object$method)
  109.     {
  110.         return method_exists($object$method);
  111.     }
  112.     public function functionExists($method)
  113.     {
  114.         return function_exists($method) ? $method 'pika' $method 'chu';
  115.     }
  116.     public function getGlobals()
  117.     {
  118.         $session = new Session();
  119.         $class = new \ReflectionClass('ApplicationBundle\Modules\Authentication\Constants\UserConstants');
  120.         $UserConstants $class->getConstants();
  121.         $class = new \ReflectionClass('ApplicationBundle\Constants\BuddybeeConstant');
  122.         $BuddybeeConstant $class->getConstants();
  123.         $classToDoConstant = new \ReflectionClass('ApplicationBundle\Constants\TaskConstant');
  124.         $ToDoConstant $classToDoConstant->getConstants();
  125.         $classTicketConstant = new \ReflectionClass('ApplicationBundle\Constants\TicketConstant');
  126.         $TicketConstant $classTicketConstant->getConstants();
  127.         //        $classReportConstant = new \ReflectionClass('ApplicationBundle\Constants\ReportConstant');
  128.         $classReportConstant = new \ReflectionClass('ApplicationBundle\Constants\ReportConstant');
  129.         return array(
  130.             'session' => $session->all(),
  131.             'url_get' => $_GET,
  132.             'UserConstants' => $UserConstants,
  133.             'BuddybeeConstant' => $BuddybeeConstant,
  134.             'TaskConstant' => $ToDoConstant,
  135.             'TicketConstant' => $TicketConstant,
  136.             'globalReportTypeList' => $classReportConstant->getStaticPropertyValue('reportTypeList'),
  137.             'enabled_report_types' => ['pika' => 'chu']
  138.         );
  139.     }
  140.     function imageToBase64Encode($imagePath)
  141.     {
  142.         $img file_get_contents(
  143.             $imagePath
  144.         );
  145.         return base64_encode($img);
  146.     }
  147.     function getConvMultFromToWithdrawable()
  148.     {
  149.         return BuddybeeConstant::$convMultFromToWithdrawable;
  150.     }
  151.     function getEntityDetailsByName($entityName)
  152.     {
  153.        return GeneralConstant::$Entity_list_details[array_flip(GeneralConstant::$Entity_list)[$entityName]];
  154.     }
  155.     function getCurrencyListByMarker()
  156.     {
  157.         return BuddybeeConstant::$currency_List_by_marker;
  158.     }
  159.     function strpad($input$padlength$padstring ''$pad_type STR_PAD_LEFT)
  160.     {
  161.         return str_pad($input$padlength$padstring$pad_type);
  162.     }
  163.     function getRandomColor($rmax 200$gmax 200$bmax 200$a 1)
  164.     {
  165.         return '' rand(0$rmax) . ',' rand(0$gmax) . ',' rand(0$bmax);
  166.     }
  167.     public function doSerialize($str)
  168.     {
  169.         $encoders = array(new XmlEncoder(), new JsonEncoder());
  170.         $normalizers = array(new ObjectNormalizer());
  171.         $serializer = new Serializer($normalizers$encoders);
  172.         return $serializer->serialize($str'json');
  173.     }
  174.     public function jsonDecode($str$assoc true$bias JSON_BIGINT_AS_STRING)
  175.     {
  176.         if (version_compare(PHP_VERSION'5.4.0''>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE 4)) {
  177.             $obj json_decode($str$assoc512JSON_BIGINT_AS_STRING);
  178.         } else {
  179.             $max_int_length strlen((string)PHP_INT_MAX) - 1;
  180.             $json_without_bigints preg_replace('/:\s*(-?\d{' $max_int_length ',})/'': "$1"'$str);
  181.             $obj json_decode($json_without_bigints$assoc);
  182.         }
  183.         //        return json_decode($str,$assoc,512,$bias);
  184.         if ($obj == null)
  185.             $obj = [];
  186.         return $obj;
  187.     }
  188.     public function getUserRestrictions()
  189.     {
  190.         $session = new Session();
  191.         return Users::getUserApplicationAccessSettings($this->em$session->get(UserConstants::USER_ID))['options'];
  192.     }
  193.     public function getGlobalEncryptedDocInfo($entityName='',$docId=0,$appId='_auto_')
  194.     {
  195.         $session = new Session();
  196.         $golbalId='';
  197.         $companyHash='';
  198.         if($appId=='_auto_')
  199.             $appId$session->get(UserConstants::USER_APP_ID);
  200.        $companyHereCompany::getCurrentCompanyInfo($this->em,$appId);
  201.        $entityIdentifier=0;
  202.        $entityList=GeneralConstant::$Entity_list;
  203.        if($entityName!='')
  204.            $entityIdentifier=array_flip(GeneralConstant::$Entity_list)[$entityName];
  205.        if(isset($companyHere['id']))
  206.        {
  207.            $golbalId'D'.str_pad($appId50STR_PAD_LEFT).str_pad($entityIdentifier20STR_PAD_LEFT).str_pad($docId80STR_PAD_LEFT);
  208.            $companyHash=$companyHere['companyHash'];
  209.        }
  210.         return array(
  211.             'id'=>$golbalId,
  212.             'companyHash'=>$companyHash,
  213.         );
  214.     }
  215.     public function getCurrencyList()
  216.     {
  217.         $session = new Session();
  218.         return Inventory::CurrencyList($this->em);
  219.     }
  220. public function getDocumentDataDetailsForView($documentDataId,$columnsEnabled=[],$viewType='view')
  221.     {
  222.         $session = new Session();
  223.         return SalesOrderM::GetDocumentDataDetailsForView($this->em,$documentDataId,$columnsEnabled,$viewType);
  224.     }
  225.     public function getDocumentDataDetails($documentDataId,$skipRowData=0)
  226.     {
  227.         $session = new Session();
  228.         return SalesOrderM::GetDocumentDataDetails($this->em,$documentDataId,$skipRowData);
  229.     }
  230.     public function getCountries()
  231.     {
  232.         return Company::getCountryList($this->em);
  233.     }
  234.     public function getCountriesBuddyBee($type ""$returnType '')
  235.     {
  236.         if ($type == '_ALL_')
  237.             return Company::getCountryList($this->em_goc'_BUDDYBEE_ALL_'$returnType);
  238.         else if ($type == '_HAS_CONSULTANT_')
  239.             return Company::getCountryList($this->em_goc'_HAS_CONSULTANT_'$returnType);
  240.         else
  241.             return Company::getCountryList($this->em_goc'_BUDDYBEE_'$returnType);
  242. //        return BuddybeeConstant::$buddybee_country_List;
  243.     }
  244.     public function getLanguagesBuddyBee($type ""$returnType '')
  245.     {
  246.         if ($type == '_ALL_')
  247.             return Company::getLanguageList($this->em_goc'_BUDDYBEE_ALL_'$returnType);
  248.         else
  249.             return Company::getLanguageList($this->em_goc'_BUDDYBEE_'$returnType);
  250. //        return BuddybeeConstant::$buddybee_country_List;
  251.     }
  252.     public function getBranchList($types ''$companyId = [])
  253.     {
  254.         if ($types == ''$types = [];
  255.         return Client::BranchList($this->em$companyId$types);
  256.     }
  257.     public function getRegionList($types '')
  258.     {
  259.         if ($types == ''$types = [];
  260.         $session = new Session();
  261.         return Client::RegionList($this->em$session->get(UserConstants::USER_COMPANY_ID));
  262.     }
  263.     public function getGeographicalRegionList($types '')
  264.     {
  265.         if ($types == ''$types = [];
  266.         $session = new Session();
  267.         return Client::GeographicalRegionList($this->em$session->get(UserConstants::USER_COMPANY_ID));
  268.     }
  269.     public function getClientList($types '')
  270.     {
  271.         if ($types == ''$types = [];
  272.         $session = new Session();
  273.         return Client::GetExistingClientList($this->em$session->get(UserConstants::USER_COMPANY_ID));
  274.     }
  275.     public function getClientTypeList($types '')
  276.     {
  277.         if ($types == ''$types = [];
  278.         $session = new Session();
  279.         return Client::ClientTypeList($this->em$session->get(UserConstants::USER_COMPANY_ID));
  280.     }
  281.     public function getSalesPersonList($types '')
  282.     {
  283.         if ($types == ''$types = [];
  284.         $session = new Session();
  285.         return Client::SalesPersonList($this->em$session->get(UserConstants::USER_COMPANY_ID));
  286.     }
  287.     public function getColors()
  288.     {
  289.         return Inventory::GetColorList($this->em);
  290.     }
  291.     public function getCommentsForDocument($entity$entityId$appId$isEntityComment 0$conversationHash '')
  292.     {
  293.         if ($isEntityComment == 1)
  294.         {
  295.             if ($conversationHash == '')
  296.                 $conversationHash 'D' . (str_pad($appId5'0'STR_PAD_LEFT)) . (str_pad($entity2'0'STR_PAD_LEFT)) . (str_pad($entityId8'0'STR_PAD_LEFT));
  297.             return array(
  298.                 'commentList' => Comment::getCommentsByConversationHash($this->em_goc$conversationHash$isEntityComment),
  299.                 'hash' => $conversationHash
  300.             );
  301.         }
  302.         else {
  303.             if ($conversationHash == '')
  304.                 $conversationHash 'D' . (str_pad($appId5'0'STR_PAD_LEFT)) . (str_pad($entity2'0'STR_PAD_LEFT)) . (str_pad($entityId8'0'STR_PAD_LEFT));
  305.             return array(
  306.                 'commentList' => Comment::getCommentsByConversationHash($this->em$conversationHash$isEntityComment),
  307.                 'hash' => $conversationHash
  308.             );
  309.         }
  310.     }
  311.     public function getCountriesIndexed()
  312.     {
  313.         return Company::getCountryListIndexed($this->em);
  314.     }
  315.     public function getProductDataFromFDM($FDM)
  316.     {
  317.         $ret_data = array(
  318.             'igId' => 0,
  319.             'categoryId' => 0,
  320.             'subCategoryId' => 0,
  321.             'brandId' => 0,
  322.             'productId' => 0,
  323.             'FDM_MODIFIED' => $FDM
  324.         );
  325.         $session = new Session();
  326.         return Inventory::GetProductDataFromFdm($this->em$FDM$session->get(UserConstants::USER_COMPANY_ID));
  327. //        $FDM_ARRAY = explode('_', $FDM);
  328. //
  329. //        $ret_data['igId'] = isset($FDM_ARRAY[0]) ? (1 * $FDM_ARRAY[0]) : 0;
  330. //        $ret_data['categoryId'] = isset($FDM_ARRAY[1]) ? (1 * $FDM_ARRAY[1]) : 0;
  331. //        $ret_data['subCategoryId'] = isset($FDM_ARRAY[2]) ? (1 * $FDM_ARRAY[2]) : 0;
  332. //        $ret_data['brandId'] = isset($FDM_ARRAY[3]) ? (1 * $FDM_ARRAY[3]) : 0;
  333. //        $ret_data['productId'] = isset($FDM_ARRAY[4]) ? (1 * $FDM_ARRAY[4]) : 0;
  334. //
  335. //
  336. //
  337. //
  338. //        return $ret_data;
  339.     }
  340.     public function getPositions($department_id)
  341.     {
  342.         return Position::getPositionByDepartment($this->em$department_id);
  343.     }
  344.     public function getUsers($company_id '')
  345.     {
  346.         return Users::getUserListById($this->em);
  347.     }
  348.     public function getExpSubTypes($company_id '')
  349.     {
  350.         return GeneralConstant::$expenseSubTypes;
  351.     }
  352.     public function PendingDocList()
  353.     {
  354.         $session = new Session();
  355.         //        return $session;
  356.         return System::getPendingApprovalListByUserLoginId($this->em$session->get(UserConstants::USER_LOGIN_ID));
  357.     }
  358.     public function getDepartments($company_id '')
  359.     {
  360.         return Department::getDepartmentList($this->em);
  361.     }
  362.     public function getCompanies()
  363.     {
  364.         return Company::getCompanyList($this->em);
  365.     }
  366.     public function getUserCompany()
  367.     {
  368.         $session = new Session();
  369.         //        return $session;
  370.         return Company::getCompanyData($this->em$session->get(UserConstants::USER_COMPANY_ID1));
  371.         //        return $session->get(UserConstants::USER_COMPANY_ID);
  372.     }
  373.     public function getSupplierDataForSupplierLogin($supplierId 0)
  374.     {
  375.         $session = new Session();
  376.         if ($supplierId == 0)
  377.             $supplierId $session->get('supplierId');
  378.         //        return $session;
  379.         return Supplier::GetSupplierForSupplierLogin($this->em$supplierId);
  380.         //        return Company::getCompanyData($this->em, $session->get(UserConstants::USER_COMPANY_ID, 1));
  381.         //        return $session->get(UserConstants::USER_COMPANY_ID);
  382.     }
  383.     public function getClientDataForClientLogin()
  384.     {
  385.         $session = new Session();
  386.         $clientId $session->get('clientId');
  387.         //        return $session;
  388.         return Client::GetClientForClientLogin($this->em$clientId);
  389.         //        return Company::getCompanyData($this->em, $session->get(UserConstants::USER_COMPANY_ID, 1));
  390.         //        return $session->get(UserConstants::USER_COMPANY_ID);
  391.     }
  392.     public function getMonthlySummary()
  393.     {
  394.         $session = new Session();
  395.         return Company::getMonthlyDataForDashboard($this->em$session->get(UserConstants::USER_COMPANY_ID1));
  396.         //        return $session;
  397.         //        $list_data=
  398.         //        return $session->get(UserConstants::USER_COMPANY_ID);
  399.     }
  400.     public function getRecentSales()
  401.     {
  402.         $session = new Session();
  403.         //        return $session;
  404.         return SalesOrderM::RecentSalesList($this->em$session->get(UserConstants::USER_COMPANY_ID), 5true);
  405.         //        return $session->get(UserConstants::USER_COMPANY_ID);
  406.     }
  407.     public function getSoCountAndMore($limit 5)
  408.     {
  409.         $session = new Session();
  410.         //        return $session;
  411.         return SalesOrderM::getSoCountAndMore($this->em$session->get(UserConstants::USER_COMPANY_ID), $limittrue);
  412.         //        return $session->get(UserConstants::USER_COMPANY_ID);
  413.     }
  414.     public function getRecentPurchase()
  415.     {
  416.         $session = new Session();
  417.         //        return $session;
  418.         return Purchase::RecentPurchaseList($this->em$session->get(UserConstants::USER_COMPANY_ID), 5true);
  419.         //        return $session->get(UserConstants::USER_COMPANY_ID);
  420.     }
  421.     public function getPositionModuleTree($PositionID)
  422.     {
  423.         $list "<ul>";
  424.         $Position $this->em->getRepository('ApplicationBundle:SysDepartmentPosition')->findOneBy(array(
  425.             'status' => GeneralConstant::ACTIVE,
  426.             'positionId' => $PositionID
  427.         ));
  428.         if ($Position) {
  429.             $PositionModules $this->em->getRepository('ApplicationBundle:SysDeptPositionDefaultModule')->findOneBy(array(
  430.                 'status' => GeneralConstant::ACTIVE,
  431.                 'positionId' => $Position->getPositionId()
  432.             ));
  433.             $Modules json_decode($PositionModules->getModuleIds(), true);
  434.             foreach ($Modules as &$ModuleID) {
  435.                 $ModuleInfo Module::getModuleName($this->em$ModuleID);
  436.                 $name $ModuleInfo['name'];
  437.                 self::SeekingLevel($this->em$ModuleInfo['parent_id'], $name);
  438.                 $list .= "<li>" $name "</li>";
  439.             }
  440.         }
  441.         $list .= "</ul>";
  442.         return $list;
  443.     }
  444.     public function getSystemNotice()
  445.     {
  446.         $session = new Session();
  447.         if($session->get('userType')!=8)
  448.             $notice $this->em->getRepository('ApplicationBundle:SystemNotice')->findOneBy(array(
  449.                 'enabled' => GeneralConstant::ACTIVE,
  450.                 'showAsNotification' => GeneralConstant::ACTIVE,
  451.                 //            'CompanyId'=>$session->get(UserConstants::USER_COMPANY_ID),
  452.                 //            'appId'=>$session->get(UserConstants::USER_COMPANY_ID),
  453.             ));
  454.         else
  455.             $notice=null;
  456.         $systemMessage = array();
  457.         if ($notice) {
  458.             $systemMessage[] = array(
  459.                 'title' => $notice->getTitle(),
  460.                 'desc' => $notice->getDesc(),
  461.                 'countDownEnds' => $notice->getCountDownEnds(),
  462.             );
  463.         }
  464.         return $systemMessage;
  465.     }
  466.     private function SeekingLevel($em$module_id, &$name)
  467.     {
  468.         $ModuleInfo Module::getModuleName($em$module_id);
  469.         if (!empty($ModuleInfo)) {
  470.             $name .= " < " $ModuleInfo['name'];
  471.             if ($ModuleInfo['level'] > 0) {
  472.                 self::SeekingLevel($em$ModuleInfo['parent_id'], $name);
  473.             }
  474.         }
  475.         return $name;
  476.     }
  477.     /**
  478.      * This function list all the allowed route for current logged user. I have used this function on left_menu.html.twig.
  479.      *
  480.      * @return string
  481.      */
  482.     public function showNecessaryMenu()
  483.     {
  484.         $session = new Session();
  485.         $list json_decode($session->get(UserConstants::USER_ROUTE_LIST), true);
  486.         //        $list="";
  487.         $r "";
  488.         if ($list) {
  489.             foreach ($list as &$listContent) {
  490.                 $r .= ", .accessible-menu ." $listContent;
  491.             }
  492.         }
  493.         return $r;
  494.     }
  495.     public function strToHex($str)
  496.     {
  497.         return System::strtohex($str);
  498. //        $s = '';
  499. //        foreach (str_split($x) as $c) $s .= sprintf("%02X", ord($c));
  500. //        return ($s);
  501.     }
  502.     public function toHex($number)
  503.     {
  504.         return dechex($number);
  505. //        return $number;
  506. //        $s = '';
  507. //        foreach (str_split($x) as $c) $s .= sprintf("%02X", ord($c));
  508. //        return ($s);
  509.     }
  510.     public function showNecessaryCreateBtn()
  511.     {
  512.         $session = new Session();
  513.         $list json_decode($session->get(UserConstants::USER_ROUTE_LIST), true);
  514.         //        $list="";
  515.         $r "";
  516.         if ($list) {
  517.             foreach ($list as &$listContent) {
  518.                 $r .= ", .btn." $listContent;
  519.             }
  520.         }
  521.         return $r;
  522.     }
  523.     public function showMenuIfAdmin()
  524.     {
  525.         $session = new Session();
  526.         $list Company::getCompanyRouteList($this->em$session->get(UserConstants::USER_COMPANY_ID));
  527.         //        $list=json_decode($session->get(UserConstants::USER_ROUTE_LIST), true);
  528.         //        $list="";
  529.         $r "";
  530.         if ($list) {
  531.             foreach ($list as &$listContent) {
  532.                 $r .= ", .accessible-menu ." $listContent;
  533.             }
  534.         }
  535.         return $r;
  536.     }
  537.     public function showNecessaryMenuGeneral()
  538.     {
  539.         $session = new Session();
  540.         $list json_decode($session->get(UserConstants::USER_ROUTE_LIST), true);
  541.         $r "";
  542.         if ($list) {
  543.             foreach ($list as &$listContent) {
  544.                 $r .= ", ." $listContent;
  545.             }
  546.         }
  547.         return $r;
  548.     }
  549.     public function todoSummaryList($assigned_to$types = [])
  550.     {
  551.         $todoList = array();
  552.         $ToDos $this->em->getRepository('ApplicationBundle:Ticket')->findBy(
  553.             array(
  554.                 'status' => TaskConstant::ACTIVE,
  555.                 'type' => $types,
  556.                 'assignedToUserId' => intval($assigned_to)
  557.             )
  558.         );
  559.         if (count($ToDos) > 0) {
  560.             foreach ($ToDos as &$ToDo) {
  561.                 $todoList[] = array(
  562.                     'id' => $ToDo->getId(),
  563.                     'title' => $ToDo->getTitle(),
  564.                     'type' => $ToDo->getType(),
  565.                     'urgency' => $ToDo->getUrgency()
  566.                 );
  567.             }
  568.         }
  569.         return $todoList;
  570.     }
  571.     public function inArray($key$array)
  572.     {
  573.         if($array==null)
  574.             $array=[];
  575.         return in_array($key$array);
  576.     }
  577.     public function encryptMe($str)
  578.     {
  579.         $session = new Session();
  580.         $allSessionsArray $session->all();
  581.         /*return Crypto::Encrypt($str, $allSessionsArray[ACLConstants::SESSION_SALT]);*/
  582.         return $this->encryptDecrypt->encrypt($str$allSessionsArray[GeneralConstant::SESSION_SALT]);
  583.     }
  584.     public function decryptMe($str)
  585.     {
  586.         $session = new Session();
  587.         $allSessionsArray $session->all();
  588.         /*return Crypto::Decrypt($str, $allSessionsArray[ACLConstants::SESSION_SALT]);*/
  589.         return $this->encryptDecrypt->decrypt($str$allSessionsArray[GeneralConstant::SESSION_SALT]);
  590.     }
  591.     public function getMicroTime($str)
  592.     {
  593.         return floor(microtime(true) * 1000);
  594.     }
  595.     public function getName()
  596.     {
  597.         return 'general_extension';
  598.     }
  599. }