src/ApplicationBundle/Modules/System/System.php line 991

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: ehsan_pc
  5.  * Date: 3/14/2016
  6.  * Time: 4:22 PM
  7.  */
  8. namespace ApplicationBundle\Modules\System;
  9. use ApplicationBundle\Constants\AccountsConstant;
  10. use ApplicationBundle\Constants\ApprovalConstant;
  11. use ApplicationBundle\Constants\GeneralConstant;
  12. use ApplicationBundle\Entity\Approval;
  13. use ApplicationBundle\Entity\Employee;
  14. use ApplicationBundle\Entity\EmployeeDetails;
  15. use ApplicationBundle\Entity\EmployeeLeaveApplication;
  16. use ApplicationBundle\Entity\EntityApprovalActionLog;
  17. use ApplicationBundle\Entity\NocApproval;
  18. use ApplicationBundle\Entity\Signature;
  19. use ApplicationBundle\Entity\SystemNotice;
  20. use ApplicationBundle\Entity\SysUser;
  21. use ApplicationBundle\Helper\Generic;
  22. use ApplicationBundle\Modules\Accounts\Accounts;
  23. use ApplicationBundle\Modules\Authentication\Constants\UserConstants;
  24. use ApplicationBundle\Modules\Api\Constants\ApiConstants;
  25. use ApplicationBundle\Modules\Buddybee\Buddybee;
  26. use ApplicationBundle\Modules\User\Users;
  27. use CompanyGroupBundle\Entity\EntityApplicantDetails;
  28. use CompanyGroupBundle\Entity\EntityInvoice;
  29. use CompanyGroupBundle\Entity\EntityNotification;
  30. use Google_Client;
  31. use Symfony\Component\HttpFoundation\JsonResponse;
  32. use Symfony\Component\Routing\Generator\UrlGenerator;
  33. class System
  34. {
  35.     public static function strtohex($x)
  36.     {
  37.         $s '';
  38.         foreach (str_split($x) as $c)
  39.             $s .= sprintf("%02X"ord($c));
  40.         return ($s);
  41.     }
  42.     public static function initiateDatabaseLocal($em)
  43.     {
  44.     }
  45.     public static function initiateAdminLocal($em)
  46.     {
  47.     }
  48.     public static function prePopulateDatabase($em)
  49.     {
  50.         $get_kids_sql "
  51.         INSERT INTO `acc_accounts_head` (`accounts_head_id`, `parent_id`, `replication_head_id`, `replicate`, `advance_tagged`, `advance_of`, `name`, `path_tree`, `head_level`, `type`, `head_nature`, `cc_enabled`, `opening_balance`, `current_balance`, `current_balance_reconciled`, `company_id`, `ledger_head_code`, `edit_flag`, `delete_flag`, `lock_flag`, `refresh_flag`, `disabled_flag`, `marker_hash`, `cost_centre_types`, `narration_on_check`, `created_login_id`, `edited_login_id`, `created_user_id`, `edited_user_id`, `created_sig_id`, `edited_sig_id`) VALUES
  52.         (1, 0, NULL, NULL, NULL, NULL, 'Assets', '/', 1, 'ast', 'dr', 0, '9000', '17827926.411478', '16737911.591478', 1, '1474723560', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  53.         (3, 0, NULL, NULL, NULL, NULL, 'Equity and Liability', '/', 1, 'ast', 'cr', 0, '9000', '11642357.01', '9206052.99', 1, '1474723546', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  54.         (4, 0, NULL, NULL, NULL, NULL, 'Revenue', '/', 1, 'inc', 'cr', 0, '0', '16671219.403', '16479448.603', 1, '1474723566', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  55.         (5, 0, NULL, NULL, NULL, NULL, 'Expense', '/', 1, 'exp', 'dr', 0, '0', '10748850.546522', '9180790.5465217', 1, '1474723583', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  56.         (89, 1, NULL, NULL, NULL, NULL, 'Fixed Assets', '/1/', 2, 'ast', 'dr', 0, '0', '73750', '72000', 1, '1474879117', NULL, NULL, NULL, NULL, NULL, '_NCASP_', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  57.         (90, 1, NULL, NULL, NULL, NULL, 'Current Assets', '/1/', 2, 'ast', 'dr', 0, '9000', '17754176.411478', '16665911.591478', 1, '1474879099', NULL, NULL, NULL, NULL, NULL, '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  58.         (94, 3, NULL, NULL, NULL, NULL, 'Equity', '/3/', 2, 'lib', 'cr', 0, '9000', '13085', '13095', 1, '1474879330', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  59.         (95, 3, NULL, NULL, NULL, NULL, 'Liabilities', '/3/', 2, 'lib', 'cr', 0, '0', '11629272.01', '9192957.99', 1, '1474879294', NULL, NULL, NULL, NULL, NULL, '_CASP_', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  60.         (96, 94, NULL, NULL, NULL, NULL, 'Capital', '/3/94/', 3, 'lib', 'cr', 0, '9000', '13095', '13095', 1, '1474879440', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  61.         (97, 94, NULL, NULL, NULL, NULL, 'Reserves', '/3/94/', 3, 'lib', 'cr', 0, '0', '-10', '0', 1, '1474879493', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  62.         (98, 94, NULL, NULL, NULL, NULL, 'Retained earnings', '/3/94/', 3, 'lib', 'cr', 0, '0', '0', '0', 1, '1474879433', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  63.         (99, 95, NULL, NULL, NULL, NULL, 'Non-Current Liabilities', '/3/95/', 3, 'lib', 'cr', 0, '0', '1800000', '0', 1, '1474879470', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  64.         (100, 95, NULL, NULL, NULL, NULL, 'Current Liabilities', '/3/95/', 3, 'lib', 'cr', 0, '0', '9829272.01', '9192957.99', 1, '1474879541', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  65.         (101, 4, NULL, NULL, NULL, NULL, 'Operating Revenue', '/4/', 2, 'inc', 'cr', 0, '0', '16411448.603', '16411448.603', 1, '1474880972', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  66.         (102, 4, NULL, NULL, NULL, NULL, 'Non Operating Revenue', '/4/', 2, 'inc', 'cr', 0, '0', '0', '0', 1, '1474881043', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  67.         (103, 5, NULL, NULL, NULL, NULL, 'Direct Expenses', '/5/', 2, 'exp', 'dr', 0, '0', '158776.95652174', '158776.95652174', 1, '1474881081', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  68.         (104, 5, NULL, NULL, NULL, NULL, 'Operating Expenses', '/5/', 2, 'exp', 'dr', 0, '0', '10541802.58', '8973742.58', 1, '1474881107', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  69.         (105, 5, NULL, NULL, NULL, NULL, 'Non-Operating Expenses', '/5/', 2, 'exp', 'dr', 0, '0', '5997.01', '5997.01', 1, '1474881114', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  70.         (106, 89, NULL, NULL, NULL, NULL, 'Property, Plant and Equipment', '/1/89/', 3, 'ast', 'dr', 0, '0', '73750', '72000', 1, '1474881203', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  71.         (107, 89, NULL, NULL, NULL, NULL, ' Intangible Assets', '/1/89/', 3, 'ast', 'dr', 0, '0', '0', '0', 1, '1474881295', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  72.         (108, 89, NULL, NULL, NULL, NULL, ' Investments', '/1/89/', 3, 'ast', 'dr', 0, '0', '0', '0', 1, '1474881252', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  73.         (109, 90, NULL, NULL, NULL, NULL, ' Inventories', '/1/90/', 3, 'ast', 'dr', 0, '9000', '1553042.3334783', '1553042.3334783', 1, '1474881318', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  74.         (110, 90, NULL, NULL, NULL, NULL, 'Accounts Receivable', '/1/90/', 3, 'ast', 'dr', 0, '0', '17691572.108', '16575365.108', 1, '1474881341', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  75.         (111, 110, NULL, NULL, NULL, NULL, 'Receivable from Inter Company', '/1/90/110/', 4, 'ast', 'dr', 0, '0', '9721620.763', '8040127.763', 1, '1474881424', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  76.         (112, 90, NULL, NULL, NULL, NULL, 'Advance, Deposit & Prepayments', '/1/90/', 3, 'ast', 'dr', 0, '0', '812127.51', '-655050.49', 1, '1474881393', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  77.         (113, 90, NULL, NULL, NULL, NULL, 'Project in Progress', '/1/90/', 3, 'ast', 'dr', 0, '0', '0', '0', 1, '1474881442', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  78.         (114, 90, NULL, NULL, NULL, NULL, 'Cash and Cash Equivalent', '/1/90/', 3, 'ast', 'dr', 0, '0', '-2302565.54', '-807445.36', 1, '1474881706', NULL, NULL, NULL, NULL, NULL, '_CACEP_', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  79.         (115, 99, NULL, NULL, NULL, NULL, 'Long Term Loan', '/3/95/99/', 4, 'lib', 'cr', 0, '0', '1800000', '0', 1, '1474882238', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  80.         (116, 99, NULL, NULL, NULL, NULL, 'Finance Lease', '/3/95/99/', 4, 'lib', 'cr', 0, '0', '0', '0', 1, '1474882259', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  81.         (117, 100, NULL, NULL, NULL, NULL, 'Provision for GRN', '/3/95/100/', 4, 'lib', 'cr', 0, '0', '2000', '2000', 1, '1474882395', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  82.         (118, 100, NULL, NULL, NULL, NULL, 'Advance & Deposit Received', '/3/95/100/', 4, 'lib', 'cr', 0, '0', '0', '0', 1, '1474882358', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  83.         (119, 100, NULL, NULL, NULL, NULL, 'Short Term Loan', '/3/95/100/', 4, 'lib', 'cr', 0, '0', '11563241.5', '1506112.5', 1, '1474882892', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  84.         (120, 100, NULL, NULL, NULL, NULL, ' Intercompany Loan', '/3/95/100/', 4, 'lib', 'cr', 0, '0', '0', '0', 1, '1474882954', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  85.         (121, 100, NULL, NULL, NULL, NULL, 'Accounts Payable', '/3/95/100/', 4, 'lib', 'cr', 0, '0', '-1623546.98', '479488', 1, '1474882966', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  86.         (122, 100, NULL, NULL, NULL, NULL, '  Accu. Depreciation of Fixed Assets', '/3/95/100/', 4, 'lib', 'cr', 0, '0', '0', '0', 1, '1474883099', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  87.         (123, 101, NULL, NULL, NULL, NULL, 'Sales', '/4/101/', 3, 'inc', 'cr', 0, '0', '16411448.603', '16411448.603', 1, '1474883105', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  88.         (124, 102, NULL, NULL, NULL, NULL, 'Interest Income', '/4/102/', 3, 'inc', 'cr', 0, '0', '0', '0', 1, '1474883143', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  89.         (125, 102, NULL, NULL, NULL, NULL, ' Other income', '/4/102/', 3, 'inc', 'cr', 0, '0', '0', '0', 1, '1474883153', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  90.         (126, 103, NULL, NULL, NULL, NULL, 'Cost of Goods Sold', '/5/103/', 3, 'exp', 'dr', 0, '0', '158776.95652174', '158776.95652174', 1, '1474883307', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  91.         (127, 103, NULL, NULL, NULL, NULL, 'Project Expense', '/5/103/', 3, 'exp', 'dr', 0, '0', '0', '0', 1, '1474883290', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  92.         (129, 104, NULL, NULL, NULL, NULL, 'Administrative Expenses', '/5/104/', 3, 'exp', 'dr', 0, '0', '10118765.58', '8550705.58', 1, '1474884817', NULL, NULL, NULL, NULL, NULL, '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  93.         (130, 104, NULL, NULL, NULL, NULL, 'Selling and Distribution Expenses', '/5/104/', 3, 'exp', 'dr', 0, '0', '366667', '366667', 1, '1474884882', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  94.         (131, 104, NULL, NULL, NULL, NULL, 'Marketing and Promotional Expenses', '/5/104/', 3, 'exp', 'dr', 0, '0', '26490', '26490', 1, '1474884916', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  95.         (132, 105, NULL, NULL, NULL, NULL, ' Financial Expenses', '/5/105/', 3, 'exp', 'dr', 0, '0', '5997.01', '5997.01', 1, '1474884919', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  96.         (133, 105, NULL, NULL, NULL, NULL, 'Tax Expenses', '/5/105/', 3, 'exp', 'dr', 0, '0', '0', '0', 1, '1474884969', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  97.         (134, 106, NULL, NULL, NULL, NULL, ' Computer and Accessories', '/1/89/106/', 4, 'ast', 'dr', 0, '0', '73750', '72000', 1, '1474885108', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  98.         (135, 106, NULL, NULL, NULL, NULL, 'Office Equipments', '/1/89/106/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1474885080', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  99.         (136, 106, NULL, NULL, NULL, NULL, 'Furnitures & Fixtures', '/1/89/106/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1474885135', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  100.         (137, 106, NULL, NULL, NULL, NULL, 'Office Vehicles', '/1/89/106/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1474885189', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  101.         (138, 107, NULL, NULL, NULL, NULL, 'Computer Software', '/1/89/107/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1474885232', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  102.         (139, 108, NULL, NULL, NULL, NULL, 'Fixed Deposit Receipts (FDR)', '/1/89/108/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1474885286', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  103.         (140, 139, NULL, NULL, NULL, NULL, 'FDR With Bank', '/1/89/108/139/', 5, 'ast', 'dr', 0, '0', '0', '0', 1, '1474885383', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  104.         (141, 139, NULL, NULL, NULL, NULL, 'FDR With Leasing', '/1/89/108/139/', 5, 'ast', 'dr', 0, '0', '0', '0', 1, '1474885435', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  105.         (142, 108, NULL, NULL, NULL, NULL, ' Investment In  Share', '/1/89/108/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1474885502', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  106.         (144, 108, NULL, NULL, NULL, NULL, ' Investment In Inter Company', '/1/89/108/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1474885550', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  107.         (148, 109, NULL, NULL, NULL, NULL, 'Stock of Goods', '/1/90/109/', 4, 'ast', 'dr', 0, '9000', '518584.00347826', '518584.00347826', 1, '1474885933', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  108.         (149, 109, NULL, NULL, NULL, NULL, 'Stock of Customer Return Goods', '/1/90/109/', 4, 'ast', 'dr', 0, '0', '450', '450', 1, '1474885969', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  109.         (150, 109, NULL, NULL, NULL, NULL, 'Stock of Repirable Goods', '/1/90/109/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1474885988', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  110.         (151, 109, NULL, NULL, NULL, NULL, ' Stock at Vendors', '/1/90/109/', 4, 'ast', 'dr', 0, '0', '1800', '1800', 1, '1474885966', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  111.         (152, 109, NULL, NULL, NULL, NULL, 'Stock of Damage Goods', '/1/90/109/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1474886046', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  112.         (153, 109, NULL, NULL, NULL, NULL, ' Stock of Repired Goods', '/1/90/109/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1474886077', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  113.         (154, 109, NULL, NULL, NULL, NULL, 'Stock of Warranty & Support Goods', '/1/90/109/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1474886072', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  114.         (155, 109, NULL, NULL, NULL, NULL, ' Stock of Customer Goods', '/1/90/109/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1474886154', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  115.         (170, 110, NULL, NULL, NULL, NULL, 'Receivable From Corporate', '/1/90/110/', 4, 'ast', 'dr', 0, '0', '7825182.48', '8389738.48', 1, '1474952183', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  116.         (173, 90, NULL, NULL, NULL, NULL, 'Interest Receivable', '/1/90/', 3, 'ast', 'dr', 0, '0', '0', '0', 1, '1474953107', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  117.         (176, 112, NULL, NULL, NULL, NULL, 'Advances', '/1/90/112/', 4, 'ast', 'dr', 0, '0', '463837.25', '-376892.75', 1, '1474953394', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  118.         (177, 112, NULL, NULL, NULL, NULL, 'Deposits', '/1/90/112/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1474953445', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  119.         (178, 112, NULL, NULL, NULL, NULL, 'Prepayments', '/1/90/112/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1474953491', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  120.         (179, 176, NULL, NULL, NULL, NULL, 'Advance Against Expenses', '/1/90/112/176/', 5, 'ast', 'dr', 0, '0', '0', '0', 1, '1474960927', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  121.         (180, 176, NULL, NULL, NULL, NULL, ' Advance for L/C', '/1/90/112/176/', 5, 'ast', 'dr', 0, '0', '0', '0', 1, '1474960968', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  122.         (181, 176, NULL, NULL, NULL, NULL, ' Advance to Supplier', '/1/90/112/176/', 5, 'ast', 'dr', 0, '0', '408980', '-431750', 1, '1474960978', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  123.         (182, 176, NULL, NULL, NULL, NULL, 'Advances To Directors', '/1/90/112/176/', 5, 'ast', 'dr', 0, '0', '0', '0', 1, '1474961047', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  124.         (183, 177, NULL, NULL, NULL, NULL, 'Tender Security By Pay Order', '/1/90/112/177/', 5, 'ast', 'dr', 0, '0', '0', '0', 1, '1474961113', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  125.         (184, 177, NULL, NULL, NULL, NULL, 'Tender Security By Bank Guarantee', '/1/90/112/177/', 5, 'ast', 'dr', 0, '0', '0', '0', 1, '1474961091', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  126.         (185, 177, NULL, NULL, NULL, NULL, ' Performance Guarantee', '/1/90/112/177/', 5, 'ast', 'dr', 0, '0', '0', '0', 1, '1474961164', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  127.         (204, 114, NULL, NULL, NULL, NULL, 'Cash in Hand', '/1/90/114/', 4, 'ast', 'dr', 0, '0', '2253486.15', '-731448.35', 1, '1474962963', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  128.         (205, 114, NULL, NULL, NULL, NULL, 'Cash at Bank', '/1/90/114/', 4, 'ast', 'dr', 0, '0', '-4556051.69', '-75997.01', 1, '1474962998', NULL, NULL, NULL, NULL, NULL, '_BP_', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  129.         (214, 114, NULL, NULL, NULL, NULL, 'Project Bank A/C', '/1/90/114/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1474963658', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  130.         (218, 129, NULL, NULL, NULL, NULL, 'Office Rent', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '1340000', '200000', 1, '1474972068', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  131.         (219, 129, NULL, NULL, NULL, NULL, 'Conveyance Expenses', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '14697.13', '14697.13', 1, '1474972085', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  132.         (220, 129, NULL, NULL, NULL, NULL, 'Office Maintenance', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '11074', '11074', 1, '1474972142', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  133.         (221, 129, NULL, NULL, NULL, NULL, 'Entertainment', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '1050', '1050', 1, '1474972204', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  134.         (222, 130, NULL, NULL, NULL, NULL, 'Tour & Travell-Local (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '5250', '5250', 1, '1474972290', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  135.         (223, 130, NULL, NULL, NULL, NULL, 'Entertainment Expense (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '12540', '12540', 1, '1474972284', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  136.         (224, 130, NULL, NULL, NULL, NULL, 'Office Maintenance Expense (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '2995', '2995', 1, '1474972311', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  137.         (225, 130, NULL, NULL, NULL, NULL, 'Vehicle Fuel & Oil Expense (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1474972366', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  138.         (226, 130, NULL, NULL, NULL, NULL, 'Vehicle Repair & Maintenance Expense (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1474972488', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  139.         (234, 123, NULL, NULL, NULL, NULL, 'Credit Sales', '/4/101/123/', 4, 'inc', 'cr', 0, '0', '5784511.53', '5784511.53', 1, '1474973021', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  140.         (235, 123, NULL, NULL, NULL, NULL, 'Cash Sales', '/4/101/123/', 4, 'inc', 'cr', 0, '0', '10626937.073', '10626937.073', 1, '1474973040', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  141.         (236, 234, NULL, NULL, NULL, NULL, 'Project Sales', '/4/101/123/234/', 5, 'inc', 'cr', 0, '0', '2219253.86', '2219253.86', 1, '1474973224', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  142.         (237, 236, NULL, NULL, NULL, NULL, ' Packages Sales', '/4/101/123/234/236/', 6, 'inc', 'cr', 0, '0', '0', '0', 1, '1474973231', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  143.         (238, 236, NULL, NULL, NULL, NULL, 'Product Sales', '/4/101/123/234/236/', 6, 'inc', 'cr', 0, '0', '546428.86', '546428.86', 1, '1474973281', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  144.         (239, 236, NULL, NULL, NULL, NULL, ' Subscription Fee', '/4/101/123/234/236/', 6, 'inc', 'cr', 0, '0', '1672825', '1672825', 1, '1474973361', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  145.         (240, 236, NULL, NULL, NULL, NULL, 'Grant Income', '/4/101/123/234/236/', 6, 'inc', 'cr', 0, '0', '0', '0', 1, '1474973356', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  146.         (241, 234, NULL, NULL, NULL, NULL, ' Corporate Sales', '/4/101/123/234/', 5, 'inc', 'cr', 0, '0', '1047138.63', '1047138.63', 1, '1474973425', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  147.         (242, 234, NULL, NULL, NULL, NULL, 'Tender Sales', '/4/101/123/234/', 5, 'inc', 'cr', 0, '0', '0', '0', 1, '1474973480', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  148.         (243, 234, NULL, NULL, NULL, NULL, ' Retails Sales', '/4/101/123/234/', 5, 'inc', 'cr', 0, '0', '2518119.04', '2518119.04', 1, '1474973532', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  149.         (244, 123, NULL, NULL, NULL, NULL, 'Inter-company Sales', '/4/101/123/', 4, 'inc', 'cr', 0, '0', '0', '0', 1, '1474973626', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  150.         (245, 235, NULL, NULL, NULL, NULL, 'Corporate Sales', '/4/101/123/235/', 5, 'inc', 'cr', 0, '0', '5143484.85', '5143484.85', 1, '1474973755', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  151.         (246, 235, NULL, NULL, NULL, NULL, 'Retails Sales', '/4/101/123/235/', 5, 'inc', 'cr', 0, '0', '5483452.223', '5483452.223', 1, '1474973789', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  152.         (247, 245, NULL, NULL, NULL, NULL, 'Package Sales', '/4/101/123/235/245/', 6, 'inc', 'cr', 0, '0', '0', '0', 1, '1474974013', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  153.         (248, 241, NULL, NULL, NULL, NULL, 'Package Sales', '/4/101/123/234/241/', 6, 'inc', 'cr', 0, '0', '0', '0', 1, '1474974078', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  154.         (249, 245, NULL, NULL, NULL, NULL, 'Product Sales', '/4/101/123/235/245/', 6, 'inc', 'cr', 0, '0', '0', '0', 1, '1474974051', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  155.         (250, 241, NULL, NULL, NULL, NULL, 'Product Sales', '/4/101/123/234/241/', 6, 'inc', 'cr', 0, '0', '0', '0', 1, '1474974091', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  156.         (251, 245, NULL, NULL, NULL, NULL, 'Servicing Fee', '/4/101/123/235/245/', 6, 'inc', 'cr', 0, '0', '5143484.85', '5143484.85', 1, '1474974159', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  157.         (252, 241, NULL, NULL, NULL, NULL, 'Subscription Fee', '/4/101/123/234/241/', 6, 'inc', 'cr', 0, '0', '1047138.63', '1047138.63', 1, '1474974167', NULL, NULL, NULL, NULL, NULL, NULL, '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  158.         (253, 246, NULL, NULL, NULL, NULL, 'Package Sales', '/4/101/123/235/246/', 6, 'inc', 'cr', 0, '0', '0', '0', 1, '1474974209', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  159.         (254, 243, NULL, NULL, NULL, NULL, 'Package Sales', '/4/101/123/234/243/', 6, 'inc', 'cr', 0, '0', '0', '0', 1, '1474974276', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  160.         (255, 246, NULL, NULL, NULL, NULL, 'Product Sales', '/4/101/123/235/246/', 6, 'inc', 'cr', 0, '0', '0', '0', 1, '1474974319', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  161.         (256, 243, NULL, NULL, NULL, NULL, 'Product Sales', '/4/101/123/234/243/', 6, 'inc', 'cr', 0, '0', '0', '0', 1, '1474974330', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  162.         (257, 246, NULL, NULL, NULL, NULL, 'Servicing Fee', '/4/101/123/235/246/', 6, 'inc', 'cr', 0, '0', '5483452.223', '5483452.223', 1, '1474974374', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  163.         (258, 243, NULL, NULL, NULL, NULL, 'Servicing Fee', '/4/101/123/234/243/', 6, 'inc', 'cr', 0, '0', '2518119.04', '2518119.04', 1, '1474974384', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  164.         (259, 242, NULL, NULL, NULL, NULL, 'Package Sales', '/4/101/123/234/242/', 6, 'inc', 'cr', 0, '0', '0', '0', 1, '1474974473', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  165.         (260, 242, NULL, NULL, NULL, NULL, 'Product Sales', '/4/101/123/234/242/', 6, 'inc', 'cr', 0, '0', '0', '0', 1, '1474974414', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  166.         (261, 242, NULL, NULL, NULL, NULL, 'Servicing Fee', '/4/101/123/234/242/', 6, 'inc', 'cr', 0, '0', '0', '0', 1, '1474974435', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  167.         (262, 244, NULL, NULL, NULL, NULL, 'Package Sales', '/4/101/123/244/', 5, 'inc', 'cr', 0, '0', '0', '0', 1, '1474974547', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  168.         (263, 244, NULL, NULL, NULL, NULL, 'Product Sales', '/4/101/123/244/', 5, 'inc', 'cr', 0, '0', '0', '0', 1, '1474974576', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  169.         (264, 244, NULL, NULL, NULL, NULL, 'Servicing Fee', '/4/101/123/244/', 5, 'inc', 'cr', 0, '0', '0', '0', 1, '1474974532', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  170.         (289, 5, 128, 1, NULL, 128, 'Salary Advance', '/5/', 2, 'exp', 'dr', 0, '0', '0', '0', 1, 'ada aa dada', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  171.         (308, 117, 0, 0, NULL, NULL, 'Rawmaterial Pending GRN', '/3/95/100/117/', 5, 'lib', 'cr', 0, '0', '2000', '2000', 1, '1483954140', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  172.         (309, 176, 0, 0, NULL, NULL, 'VAT Current A/C (MF)', '/1/90/112/176/', 5, 'ast', 'dr', 0, '0', '54857.25', '54857.25', 1, '1483957165', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  173.         (310, 176, 0, 0, NULL, NULL, 'Advance Income Tax (AIT)', '/1/90/112/176/', 5, 'ast', 'dr', 0, '0', '0', '0', 1, '1483957539', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  174.         (311, 130, 0, 0, NULL, NULL, 'VAT Expense (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1483957576', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  175.         (312, 337, 0, 0, NULL, NULL, 'Supplier TDS Payable', '/3/95/100/337/', 5, 'lib', 'cr', 0, '0', '0', '0', 1, '1485159266', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  176.         (313, 337, 0, 0, NULL, NULL, 'Supplier VDS Payable', '/3/95/100/337/', 5, 'lib', 'cr', 0, '0', '0', '0', 1, '1485161220', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  177.         (314, 132, 0, 0, NULL, NULL, 'Interest Expense', '/5/105/132/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1486324461', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  178.         (337, 100, 0, 0, NULL, NULL, 'Provisions For Expense', '/3/95/100/', 4, 'lib', 'cr', 0, '0', '-88026.51', '6948015.49', 1, '1489316998', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  179.         (339, 117, 0, 0, NULL, NULL, 'Fixed Asset Pending GRN', '/3/95/100/117/', 5, 'lib', 'cr', 0, '0', '0', '0', 1, '12544545', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  180.         (340, 337, 0, 0, NULL, NULL, 'Salary Payable', '/3/95/100/337/', 5, 'lib', 'cr', 0, '0', '590659', '7320897', 1, '145445454', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  181.         (341, 337, 0, 0, NULL, NULL, 'TA/DA Payable', '/3/95/100/337/', 5, 'lib', 'cr', 0, '0', '0', '0', 1, '1255444', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  182.         (342, 337, 0, 0, NULL, NULL, 'Subsidies Fooding Bill Payble', '/3/95/100/337/', 5, 'lib', 'cr', 0, '0', '-3500', '-3500', 1, '011455', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  183.         (343, 337, 0, 0, NULL, NULL, 'Employee TDS Payable', '/3/95/100/337/', 5, 'lib', 'cr', 0, '0', '0', '0', 1, '45454575', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  184.         (344, 337, 0, 0, NULL, NULL, 'Administrative Expense Payable', '/3/95/100/337/', 5, 'lib', 'cr', 0, '0', '0', '0', 1, '455222', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  185.         (345, 337, 0, 0, NULL, NULL, 'Marketing Expense Payable', '/3/95/100/337/', 5, 'lib', 'cr', 0, '0', '0', '0', 1, '4545574575', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  186.         (346, 337, 0, 0, NULL, NULL, 'Transportation-In Expense Payable', '/3/95/100/337/', 5, 'lib', 'cr', 0, '0', '0', '0', 1, '17575', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  187.         (347, 337, 0, 0, NULL, NULL, 'Loading Unloading Expense Payable', '/3/95/100/337/', 5, 'lib', 'cr', 0, '0', '0', '0', 1, '5454545', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  188.         (414, 109, 0, 0, NULL, NULL, 'Fixed Asset Godown', '/1/90/109/', 4, 'ast', 'dr', 0, '0', '196000', '196000', 1, '1491135287', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  189.         (417, 109, 0, 0, NULL, NULL, 'Non store Item Godown', '/1/90/109/', 4, 'ast', 'dr', 0, '0', '868948.33', '868948.33', 1, '1491135425', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  190.         (418, 117, 0, 0, NULL, NULL, 'Non Store Pending GRN', '/3/95/100/117/', 5, 'lib', 'cr', 0, '0', '0', '0', 1, '1491135629', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  191.         (679, 109, 0, 0, NULL, NULL, 'Stock In Transit', '/1/90/109/', 4, 'ast', 'dr', 0, '0', '-32740', '-32740', 1, '1495287836', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  192.         (680, 5, 0, 0, NULL, NULL, 'Accrued Expenses', '/5/', 2, 'exp', 'dr', 0, '0', '0', '0', 1, '1495288073', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  193.         (681, 680, 0, 0, NULL, NULL, 'Sales Tax Payable', '/5/680/', 3, 'exp', 'dr', 0, '0', '0', '0', 1, '1495288099', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  194.         (772, 130, NULL, 0, NULL, NULL, 'Sales Commission (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1499765363', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  195.         (845, 130, 0, 0, NULL, NULL, 'Conveyance Expenses (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '33098', '33098', 1, '1501404005', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  196.         (847, 130, 0, 0, NULL, NULL, 'Food Expenses (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '35300', '35300', 1, '1501404068', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  197.         (849, 130, 0, 0, NULL, NULL, 'Labour Expenses (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '1300', '1300', 1, '1501404317', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  198.         (851, 130, 0, 0, NULL, NULL, 'Postage & Courier Expenses (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '2500', '2500', 1, '1501405173', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  199.         (856, 129, 0, 0, NULL, NULL, 'Food Expenses', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '-1751', '-1751', 1, '1501408664', NULL, NULL, NULL, NULL, NULL, '_FEG_', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  200.         (892, 100, 0, 0, NULL, NULL, 'Liability for Expenses', '/3/95/100/', 4, 'lib', 'cr', 0, '0', '0', '0', 1, '1502178186', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  201.         (893, 892, 0, 0, NULL, NULL, 'Group Common Service Payable', '/3/95/100/892/', 5, 'lib', 'cr', 0, '0', '0', '0', 1, '1502178440', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  202.         (895, 129, 0, 0, NULL, NULL, 'Salary & Wages ', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '7748057', '7748057', 1, '1502272810', NULL, NULL, NULL, NULL, NULL, '_WPH_', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  203.         (905, 129, 0, 0, NULL, NULL, 'Mobile Expenses', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '18619', '18619', 1, '1502599240', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  204.         (906, 130, 0, 0, NULL, NULL, 'Mobile Expenses (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '4912', '4912', 1, '1502599306', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  205.         (907, 100, 0, 0, NULL, NULL, 'Liabilities for Service Provider', '/3/95/100/', 4, 'lib', 'cr', 0, '0', '-24396', '257342', 1, '1502601087', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  206.         (911, 130, 0, 0, NULL, NULL, 'Consultant Salary (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1502604435', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  207.         (912, 129, 0, 0, NULL, NULL, 'PF-Contribution Expenses', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1502607756', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  208.         (913, 130, 0, 0, NULL, NULL, 'Contribution Expenses (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1502607855', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  209.         (915, 337, 0, 0, NULL, NULL, 'PF-Contribution Payable (Company)', '/3/95/100/337/', 5, 'lib', 'cr', 0, '0', '0', '0', 1, '1502607953', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  210.         (916, 337, 0, 0, NULL, NULL, 'PF-Employee Payable', '/3/95/100/337/', 5, 'lib', 'cr', 0, '0', '0', '0', 1, '1502608009', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  211.         (917, 130, 0, 0, NULL, NULL, 'PF-Contribution Expenses (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1502608053', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  212.         (918, 129, 0, 0, NULL, NULL, 'Canteen Subsidies Expenses', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '42000', '42000', 1, '1502689276', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  213.         (921, 129, 0, 0, NULL, NULL, 'Registration & Renewal Expenses', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1502954287', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  214.         (928, 129, 0, 0, NULL, NULL, 'Drinking Water Expenses', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '400', '400', 1, '1503122230', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  215.         (931, 130, 0, 0, NULL, NULL, 'TA/DA Expenses (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1503215565', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  216.         (934, 129, 0, 0, NULL, NULL, 'Festival Bonus.', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '3500', '0', 1, '1503298990', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  217.         (956, 112, 0, 0, NULL, NULL, 'Loan', '/1/90/112/', 4, 'ast', 'dr', 0, '0', '-110391.62', '-150391.62', 1, '1503396565', NULL, NULL, NULL, NULL, NULL, '_GEMP_', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  218.         (993, 112, 0, 0, NULL, NULL, 'Advance Salary', '/1/90/112/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1505190219', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  219.         (994, 130, 0, 0, NULL, NULL, 'Tender Expenses (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '11150', '11150', 1, '1505630436', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  220.         (996, 129, 0, 0, NULL, NULL, 'Internet Expenses ', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '81000', '72000', 1, '1505635549', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  221.         (1013, 130, 0, 0, NULL, NULL, 'Transport Expenses            (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '246517', '246517', 1, '1506408181', NULL, NULL, NULL, NULL, NULL, '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  222.         (1014, 130, 0, 0, NULL, NULL, 'Registration & Renewal Fees (S&D) ', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1507102173', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  223.         (1069, 100, 0, 0, NULL, NULL, 'Pending Expense For Inventory', '/3/95/100/', 4, 'lib', 'cr', 0, '0', '0', '0', 1, '1507550703', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  224.         (1087, 129, 0, 0, NULL, NULL, 'VAT Expenses (AMD)', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1508321476', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  225.         (1088, 129, 0, 0, NULL, NULL, 'Consultant Fees (AMD)', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '88722', '57722', 1, '1508322053', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  226.         (1089, 129, 0, 0, NULL, NULL, 'Printing & Stationary Expenses (AMD)', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '57271', '57271', 1, '1508834858', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  227.         (1110, 110, 0, 0, NULL, NULL, 'Receivable From Individual', '/1/90/110/', 4, 'ast', 'dr', 0, '0', '107768.865', '77498.865', 1, '1510125610', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  228.         (1122, 129, 0, 0, NULL, NULL, 'Vehicle Repair & Maintenance ', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1511073959', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  229.         (1131, 110, 0, 0, NULL, NULL, 'Receivable From Tender', '/1/90/110/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1511542271', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  230.         (1132, 112, 0, 0, NULL, NULL, 'Advance for Inventorial Cost', '/1/90/112/', 4, 'ast', 'dr', 0, '0', '0', '0', 1, '1511763758', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  231.         (1133, 180, 0, 0, NULL, NULL, 'T.T. Expenses', '/1/90/112/176/180/', 6, 'ast', 'dr', 0, '0', '0', '0', 1, '1511763968', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  232.         (1136, 132, 0, 0, NULL, NULL, 'Bank Guarantee Expenses', '/5/105/132/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1512294061', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  233.         (1138, 129, 0, 0, NULL, NULL, 'Lab Test (ADM)', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1512541050', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  234.         (1139, 129, 0, 0, NULL, NULL, 'Vehicle Penalty', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1512541535', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  235.         (1145, 130, 0, 0, NULL, NULL, 'Business Promotion Expenses (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '9805', '9805', 1, '1513148571', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  236.         (1163, 130, 0, 0, NULL, NULL, 'Claim without Receipt (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1514098764', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  237.         (1164, 337, 0, 0, NULL, NULL, 'Employee Expenses Payable', '/3/95/100/337/', 5, 'lib', 'cr', 0, '0', '0', '0', 1, '1514349089', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  238.         (1173, 176, 0, 0, NULL, NULL, 'Advance to Service Provider', '/1/90/112/176/', 5, 'ast', 'dr', 0, '0', '0', '0', 1, '1514874298', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  239.         (1249, 112, 0, 0, NULL, NULL, 'Margin on LC / T.T', '/1/90/112/', 4, 'ast', 'dr', 1, '0', '0', '0', 1, '1516097390', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  240.         (1260, 130, 0, 0, NULL, NULL, 'Servicing Expense (S&D)', '/5/104/130/', 4, 'exp', 'dr', 0, '0', '1300', '1300', 1, '1516776147', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  241.         (1263, 121, 0, 0, NULL, NULL, 'Inter-company Supplier', '/3/95/100/121/', 5, 'lib', 'cr', 0, '0', '0', '0', 1, '1517204757', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  242.         (1268, 132, 0, 0, NULL, NULL, 'Bank Charge & Others', '/5/105/132/', 4, 'exp', 'dr', 0, '0', '5997.01', '5997.01', 1, '1517382637', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  243.         (1286, 129, 0, 0, NULL, NULL, 'Circular & Notice Expense', '/5/104/129/', 4, 'exp', 'dr', 1, '0', '4095', '4095', 1, '1581181251', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  244.         (1287, 337, 0, 0, NULL, NULL, 'Provision for Expert Fee - Khandoker Mozibul Yasser', '/3/95/100/337/', 5, 'ast', 'cr', 0, '0', '-617900', '-417900', 1, '1604220268', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  245.         (1300, 129, 0, 1, NULL, NULL, 'Office Expenses', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '-39526.01', '-64526.01', 1, '1652095445', NULL, NULL, NULL, NULL, NULL, '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  246.         (1303, 129, 0, 1, NULL, NULL, 'Utility Bill Expense', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '208334.5', '20374.5', 1, '1654154843', NULL, NULL, NULL, NULL, NULL, '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  247.         (1304, 129, 0, 1, NULL, NULL, 'Office Rent Service Charge Expense', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '183000', '21000', 1, '1654154865', NULL, NULL, NULL, NULL, NULL, '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  248.         (1305, 129, 0, 1, NULL, NULL, 'Housekeeper Expense', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '4050', '-4050', 1, '1654154934', NULL, NULL, NULL, NULL, NULL, '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  249.         (1310, 104, 0, 0, NULL, NULL, 'Branding and Advertisement Expenses', '/5/104/', 3, 'exp', 'dr', 0, '0', '29880', '29880', 1, '1670326353', NULL, NULL, NULL, NULL, NULL, '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  250.         (1317, 129, 0, 1, NULL, NULL, 'Travel Expenses', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '48266.85', '48266.85', 1, '1673956150', NULL, NULL, NULL, NULL, NULL, '_TREG_', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  251.         (1318, 129, 0, 1, NULL, NULL, 'Transport Expenses', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '42932.62', '42932.62', 1, '1673956195', NULL, NULL, NULL, NULL, NULL, '_TEG_', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  252.         (1319, 129, 0, 1, NULL, NULL, 'Medical Expenses', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '22801.49', '22801.49', 1, '1673956207', NULL, NULL, NULL, NULL, NULL, '_MEG_', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  253.         (1321, 129, 0, 1, NULL, NULL, 'Hosting Cost of Raach Solar', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '119552', '119552', 1, '1684990909', NULL, NULL, NULL, NULL, NULL, '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  254.         (1328, 1310, 0, 1, NULL, NULL, 'Fair Booking and Other Charges', '/5/104/1310/', 4, 'exp', 'dr', 0, '0', '29880', '29880', 1, '1699183420', NULL, NULL, NULL, NULL, NULL, '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  255.         (1329, 129, 0, 1, NULL, NULL, 'House Rent', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1704705446', NULL, NULL, NULL, NULL, NULL, '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  256.         (1352, 337, 0, 0, NULL, NULL, 'Provisions For Medical Expenses', '/3/95/100/337/', 5, 'lib', 'cr', 0, '0', '22801.49', '22801.49', 1, '1716620751', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  257.         (1354, 129, 0, 1, NULL, NULL, 'Design and Development', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '73420', '73420', 1, '1716627877', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  258.         (1355, 129, 0, 1, NULL, NULL, 'Expert Fees', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '30000', '30000', 1, '1716635104', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  259.         (1370, 5, 0, 1, NULL, NULL, 'Advertisement', '/5/', 2, 'exp', 'dr', 0, '0', '3860', '3860', 1, '1717912947', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  260.         (1378, 5, 0, 1, NULL, NULL, 'Miscellaneous Expenses', '/5/', 2, 'exp', 'dr', 0, '0', '11170', '11170', 1, '1718870543', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  261.         (1383, 5, 0, 1, NULL, NULL, 'Kitchen Items', '/5/', 2, 'exp', 'dr', 0, '0', '27244', '27244', 1, '1719491722', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  262.         (1387, 129, 0, 1, NULL, NULL, 'Office Decoration and Interior', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1724329508', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  263.         (1399, 131, 0, 1, NULL, NULL, 'Seminar Expenses', '/5/104/131/', 4, 'exp', 'dr', 0, '0', '26490', '26490', 1, '1728195213', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  264.         (1436, 129, 0, 1, NULL, NULL, 'Online Services Fee', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '3988', '3988', 1, '1731823696', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  265.         (1440, 129, 0, 1, NULL, NULL, 'Device Expense', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '1500', '0', 1, '1732787677', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  266.         (1441, 129, 0, 1, NULL, NULL, 'Overtime Wages', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '11712', '11712', 1, '1732805507', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  267.         (1442, 337, 0, 0, NULL, NULL, 'Overtime Wages Payable ', '/3/95/100/337/', 5, 'lib', 'cr', 0, '0', '0', '11712', 1, '1732805579', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  268.         (1461, 337, 0, 0, NULL, NULL, 'Festival Bonus Payable', '/3/95/100/337/', 5, 'lib', 'cr', 0, '0', '-80087', '2000', 1, '1734418459', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  269.         (1465, 129, 0, 1, NULL, NULL, 'B-Kash Charge', '/5/104/129/', 4, 'exp', 'dr', 0, '0', '0', '0', 1, '1734595091', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL),
  270.         (1478, 121, 0, 1, NULL, NULL, 'Local Supplier', '/3/95/100/121/', 5, 'lib', 'cr', 0, '0', '-81010', '302000', NULL, '1737279954', NULL, NULL, NULL, NULL, NULL, '', '', '', NULL, NULL, NULL, NULL, NULL, NULL);
  271.         
  272.         
  273.         INSERT INTO `acc_prefix` (`prefix_id`, `name`, `type`, `company_id`, `details`, `doc_booked_flag`, `time_stamp_of_form`, `created_login_id`, `edited_login_id`, `created_user_id`, `edited_user_id`, `created_sig_id`, `edited_sig_id`) VALUES
  274.         (1, 'GN', 'jv', NULL, '[{\"head_id\":\"\",\"cost_centre\":\"\",\"type\":\"dr\"}]', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  275.         (2, 'GN', 'pv', NULL, '[{\"head_id\":\"\",\"cost_centre\":\"\",\"type\":\"dr\"}]', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  276.         (3, 'GN', 'rv', NULL, '[{\"head_id\":\"\",\"cost_centre\":\"\",\"type\":\"dr\"}]', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  277.         (4, 'GN', 'cv', NULL, '[{\"head_id\":\"\",\"cost_centre\":\"\",\"type\":\"dr\"}]', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
  278.         
  279.         
  280.         
  281.         INSERT INTO `acc_setting` (`id`, `name`, `data`, `company_id`, `create_login_id`, `edit_login_id`, `lock_flag`, `created_at`, `updated_at`, `doc_booked_flag`, `time_stamp_of_form`) VALUES
  282.         (1, 'contra_voucher_credit_parents', '[\"114\"]', NULL, NULL, 12, NULL, '2025-01-19 15:51:34', '2025-02-20 18:08:16', NULL, NULL),
  283.         (2, 'accounting_year_start', 'January 19, 2025', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  284.         (3, 'ledger_balance_display_method', '0', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  285.         (4, 'profit_loss_parent', '98', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  286.         (5, 'cash_parents', '[\"204\"]', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  287.         (6, 'branch_cash_parent', '204', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  288.         (7, 'branch_bank_parent', '205', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  289.         (8, 'acc_dep_head_fa', '122', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  290.         (9, 'bank_parents', '[\"205\"]', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  291.         (10, 'purchase_vat_head', '309', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  292.         (11, 'purchase_ait_head', '681', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  293.         (12, 'purchase_tds_head', '312', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  294.         (13, 'purchase_vds_head', '313', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  295.         (14, 'sales_tax_head', '681', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  296.         (15, 'sales_vat_head', '309', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  297.         (16, 'sales_ait_head', '310', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  298.         (17, 'lc_ac_parent', '1249', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  299.         (18, 'expense_parent', '5', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  300.         (19, 'free_item_expense_head', '', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  301.         (20, 'transport_onsite_head', '346', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  302.         (21, 'lul_onsite_head', '347', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  303.         (22, 'supplier_parent_1_1', '1478', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  304.         (23, 'supplier_parent_1_2', '1478', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  305.         (24, 'supplier_parent_2_1', '1478', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  306.         (25, 'supplier_parent_2_2', '1478', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  307.         (26, 'cogs', '126', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  308.         (27, 'credit_note_price_type', '1', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  309.         (28, 'sales_replacement_cost_head', '126', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  310.         (29, 'project_receivable_parent', '1', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  311.         (30, 'internal_project_capital_parent', '1', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  312.         (31, 'sales_project_capital_parent', '1', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  313.         (32, 'project_receivable_parent_advance', '1', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  314.         (33, 'revenue_parent_99_99_99', '', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  315.         (34, 'product_name_display_method', '0', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  316.         (35, 'inventory_parent', '109', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  317.         (36, 'seperate_inventory_by_item_group', '0', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  318.         (37, 'fa_head', '414', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  319.         (38, 'non_store_head', '417', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  320.         (39, 'inv_on_transit_head', '679', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  321.         (40, 'pending_inventory_expense_head', '1069', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  322.         (41, 'pending_grn_head', '308', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  323.         (42, 'pending_grn_head_fa', '339', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  324.         (43, 'warehouse_action_1', '148', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  325.         (44, 'warehouse_action_2', '149', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  326.         (45, 'warehouse_action_3', '150', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  327.         (46, 'warehouse_action_4', '151', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  328.         (47, 'warehouse_action_5', '152', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  329.         (48, 'warehouse_action_6', '153', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  330.         (49, 'warehouse_action_7', '154', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  331.         (50, 'warehouse_action_8', '155', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  332.         (51, 'warehouse_action_9', '414', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  333.         (52, 'warehouse_action_10', '417', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  334.         (53, 'warehouse_action_11', '', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  335.         (54, 'warehouse_action_12', '', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  336.         (55, 'warehouse_action_13', '', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  337.         (56, 'warehouse_action_14', '', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  338.         (57, 'warehouse_action_15', '', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  339.         (58, 'warehouse_action_16', '', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  340.         (59, 'warehouse_action_17', '', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  341.         (60, 'warehouse_action_18', '', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  342.         (61, 'warehouse_action_19', '', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  343.         (62, 'warehouse_action_20', '', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  344.         (63, 'contra_voucher_debit_parents', '[\"114\"]', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  345.         (64, 'payment_voucher_credit_parents', '[\"114\"]', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  346.         (65, 'receipt_voucher_credit_parents', '[\"3\",\"4\",\"90\",\"94\"]', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  347.         (66, 'receipt_voucher_debit_parents', '[\"114\"]', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  348.         (67, 'expense_party_parents', '[\"121\"]', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  349.         (68, 'timeStampOfForm', '1740053249', NULL, 3, 12, NULL, '2025-01-19 15:53:18', '2025-02-20 18:08:16', NULL, NULL),
  350.         (69, 'client_parent_1_1', '1110', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  351.         (70, 'client_parent_1_2', '118', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  352.         (71, 'client_parent_2_1', '170', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  353.         (72, 'client_parent_2_2', '118', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  354.         (73, 'revenue_parent_1_1_1', '253', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  355.         (74, 'revenue_parent_1_1_2', '253', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  356.         (75, 'revenue_parent_1_2_1', '238', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  357.         (76, 'revenue_parent_1_2_2', '238', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  358.         (77, 'revenue_parent_1_3_1', '255', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  359.         (78, 'revenue_parent_1_3_2', '256', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  360.         (79, 'revenue_parent_2_1_1', '247', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  361.         (80, 'revenue_parent_2_1_2', '248', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  362.         (81, 'revenue_parent_2_2_1', '249', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  363.         (82, 'revenue_parent_2_2_2', '238', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  364.         (83, 'revenue_parent_2_3_1', '249', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  365.         (84, 'revenue_parent_2_3_2', '250', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  366.         (85, 'revenue_parent_1_1_1_2', '', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  367.         (86, 'revenue_parent_1_1_2_2', '', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  368.         (87, 'revenue_parent_1_2_1_2', '', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  369.         (88, 'revenue_parent_1_2_2_2', '', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  370.         (89, 'revenue_parent_1_3_1_2', '', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  371.         (90, 'revenue_parent_1_3_2_2', '', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  372.         (91, 'revenue_parent_2_1_1_2', '', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  373.         (92, 'revenue_parent_2_1_2_2', '', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  374.         (93, 'revenue_parent_2_2_1_2', '', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  375.         (94, 'revenue_parent_2_2_2_2', '', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  376.         (95, 'revenue_parent_2_3_1_2', '', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL),
  377.         (96, 'revenue_parent_2_3_2_2', '', NULL, 3, 12, NULL, '2025-01-19 16:13:47', '2025-02-20 18:08:16', NULL, NULL);
  378.         
  379.         
  380.         
  381.         INSERT INTO `client_type` (`client_type_id`, `name`, `company_id`, `default_revenue_flag`, `secondary_sales_enabled_flag`, `no_branching`, `warranty_grace_mon`, `doc_booked_flag`, `time_stamp_of_form`, `created_login_id`, `edited_login_id`, `created_user_id`, `edited_user_id`, `created_sig_id`, `edited_sig_id`) VALUES
  382.         (1, 'Retail', 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  383.         (2, 'Corporate', 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
  384.         
  385.         
  386.         INSERT INTO `currencies` (`currency_id`, `code`, `name`, `symbol`, `global_id`, `sync_flag`, `multiplier`, `cent_text`, `is_default_currency`, `locale`) VALUES
  387.         (1, 'BDT', 'Taka', '৳', NULL, NULL, '1', 'paisa', 1, NULL),
  388.         (2, 'USD', 'Dollars', '$', NULL, NULL, '117.09', 'cent', NULL, NULL),
  389.         (3, 'EUR', 'Euro', '€', NULL, NULL, '127.14', 'cent', NULL, NULL),
  390.         (4, 'GBP', 'Pounds', '£', NULL, NULL, '148.02', 'cent', NULL, NULL),
  391.         (5, 'CNY', 'RMB/YUAN', 'CNY', NULL, NULL, '17.65', 'cent', NULL, NULL);
  392.         
  393.         
  394.         INSERT INTO `planning_item` (`id`, `item_alias`, `item_desc`, `data`, `reference_type`, `entry_type`, `project_id`, `production_schedule_id`, `production_id`, `estimated_start_time_ts`, `actual_start_time_ts`, `estimated_completion_time_ts`, `actual_completion_time_ts`, `urgency`, `dependency_planning_ids`, `dependency_planning_data`, `company_id`, `status`, `stage`, `edit_flag`, `delete_flag`, `lock_flag`, `refresh_flag`, `disabled_flag`, `description`, `created_login_id`, `edited_login_id`, `created_at`, `updated_at`, `doc_booked_flag`, `time_stamp_of_form`, `parent_id`, `boq_ref_id`, `production_schedule_entry_item_id`, `target_type`, `target_value`, `break_down_data`, `has_child`, `recurring`, `product_id`, `product_fdm`, `service_id`, `service_fdm`, `head_id`, `completion_percentage`, `tags`, `assigned_to`, `entry_sub_type`, `projected_cost`, `actual_cost`, `files`, `chat_history`, `sequence`, `assigned_to_type`, `assigned_to_ids`, `projected_cost_breakdown`, `actual_cost_breakdown`, `accountable_to_type`, `accountable_to`, `accountable_to_ids`, `consult_to_type`, `consult_to`, `consult_to_ids`, `inform_to_type`, `inform_to`, `inform_to_ids`, `created_user_id`, `edited_user_id`) VALUES
  395.         (11, 'General Attendance', NULL, NULL, 1, 0, 0, NULL, NULL, 0, NULL, 0, NULL, 0, NULL, '', 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, '', 378, NULL, '2025-06-02 15:19:41', '2025-06-02 15:19:41', NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1, NULL, '0.000', '0.000', NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
  396.         
  397.         
  398.         INSERT INTO `supplier_type` (`supplier_type_id`, `name`, `company_id`, `doc_booked_flag`, `time_stamp_of_form`, `created_login_id`, `edited_login_id`, `created_user_id`, `edited_user_id`, `created_sig_id`, `edited_sig_id`) VALUES
  399.         (1, 'Local', 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
  400.         (2, 'Foreign', 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
  401.         
  402.         
  403.         INSERT INTO `sys_department` (`department_id`, `department_name`, `company_id`, `level`, `status`, `last_edit_login_id`, `last_mongolog_id`, `created_at`, `updated_at`, `doc_booked_flag`, `time_stamp_of_form`) VALUES
  404.         (1, 'Accounts', NULL, 0, 1, 0, '0', '0000-00-00 00:00:00', NULL, NULL, NULL),
  405.         (2, 'Sales', NULL, 0, 1, 0, '0', '0000-00-00 00:00:00', NULL, NULL, NULL),
  406.         (3, 'Warehouse', NULL, 0, 1, 0, '0', '0000-00-00 00:00:00', NULL, NULL, NULL),
  407.         (4, 'Inventory', NULL, 0, 1, 0, '0', '2016-12-10 00:00:00', NULL, NULL, NULL),
  408.         (5, 'Purchase', NULL, 0, 1, NULL, NULL, '2016-12-10 00:00:00', NULL, NULL, NULL),
  409.         (6, 'Information Technology', NULL, 0, 1, NULL, NULL, '2017-03-04 00:00:00', NULL, NULL, NULL),
  410.         (7, 'Implementation', 1, 0, 1, NULL, NULL, '2017-07-22 00:00:00', NULL, NULL, NULL),
  411.         (8, 'Import', NULL, 0, 1, NULL, NULL, '2017-07-29 00:00:00', NULL, NULL, NULL),
  412.         (9, 'Administration', NULL, 0, 1, NULL, NULL, '2017-07-29 00:00:00', NULL, NULL, NULL),
  413.         (10, 'Project', NULL, 0, 1, NULL, NULL, '2017-07-29 00:00:00', NULL, NULL, NULL),
  414.         (11, 'Management', NULL, 0, 1, NULL, NULL, '2017-07-29 00:00:00', NULL, NULL, NULL);
  415.         
  416.         
  417.         INSERT INTO `sys_module` (`module_id`, `module_name`, `module_route`, `parent_id`, `level`, `status`, `enabled_for_all`, `company_id`, `created_at`, `updated_at`, `doc_booked_flag`, `time_stamp_of_form`) VALUES
  418.         (3, 'Purchase Bill Entry', 'create_purchase_invoice', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  419.         (4, 'Pending Invoice List', 'pending_invoices', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  420.         (5, 'Sales Invoice List', 'sales_invoices', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  421.         (6, 'Purchase Invoice List', 'purchase_invoices', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  422.         (7, 'Journal Voucher Entry', 'create_journal_voucher', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  423.         (8, 'Receipt Voucher Entry', 'create_receipt_voucher', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  424.         (9, 'Payment Voucher Entry', 'create_payment_voucher', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  425.         (10, 'Contra Voucher Entry', 'create_contra_voucher', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  426.         (11, 'Payment/Fund Requisition Entry', 'create_fund_requisition', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  427.         (12, 'Vat Deposit Form Entry', 'create_vat_deposit_form', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  428.         (14, 'Sales Order Entry', 'create_sales_order', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  429.         (15, 'Delivery Order Entry', 'create_delivery_note', 9, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  430.         (16, 'Transport Bill Entry', 'create_transport_bill', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  431.         (17, 'Sales Bill Entry', 'create_sales_bill', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  432.         (18, 'Customer Types', 'client_type', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  433.         (22, 'Create New Task', 'create_new_todo', 15, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  434.         (23, 'Show Assigned Tasks', 'show_assigned_todo', 15, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  435.         (24, 'Assigned Task Details', 'assigned_todo_details', 15, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  436.         (27, 'GRN Entry', 'create_received_note', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  437.         (28, 'Stock Transfer Entry', 'create_stock_transfer_note', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  438.         (29, 'Item Requisition Entry ', 'create_stock_requisition_slip', 7, 1, 1, 1, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  439.         (30, 'Stock Return Entry', 'create_stock_return', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  440.         (32, 'Purchase Order Entry', 'create_purchase_order', 6, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  441.         (35, 'Asset Disposal Order Entry', 'create_fixed_asset_disposal_order', 2, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  442.         (37, 'Project Entry', 'create_new_project', 12, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  443.         (38, 'Add Project Details', 'add_project_details', 12, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  444.         (39, 'Project List', 'project_list', 12, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  445.         (40, 'Customer Entry', 'create_client', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  446.         (41, 'Supplier Entry', 'create_supplier', 6, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  447.         (42, 'Supplier List', 'supplier_list', 6, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  448.         (43, 'Customer List', 'client_list', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  449.         (44, 'Customer Profile', 'client_profile', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  450.         (45, 'Supplier Profile', 'supplier_profile', 6, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  451.         (47, 'Accounts Prefix Settings', 'create_prefix', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  452.         (48, 'Transactions list', 'voucher_list', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  453.         (49, 'Item Group Settings', 'item_group', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  454.         (50, 'Register Product', 'register_product', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  455.         (51, 'Ledger Report', 'view_ledger_head', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  456.         (52, 'Supplier list', 'supplier_list', 6, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  457.         (54, 'view balance sheet', 'view_balance_sheet', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  458.         (55, 'view trial balance', 'view_trial_balance', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  459.         (56, 'Accounts head Entry', 'create_ledger_head', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  460.         (57, 'Accounts head Edit', 'edit_ledger_head', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  461.         (58, 'Cost centre Entry', 'add_cost_centre', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  462.         (59, 'Accounts Settings', 'acc_settings', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  463.         (60, 'Product Entry', 'create_product', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  464.         (61, 'Service Entry', 'create_service', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  465.         (62, 'Inventory Transactions', 'inventory_transaction_view', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  466.         (63, 'Inventory Status', 'inventory_view', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  467.         (66, 'Product Details', 'product_view', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  468.         (68, 'Material Inward Entry', 'material_inward', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  469.         (69, 'Quality Control Entry', 'quality_control', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  470.         (70, 'Purchase Order list', 'purchase_orders', 6, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  471.         (71, 'Cheque Management', 'check_management', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  472.         (72, 'Check Format', 'check_format', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  473.         (74, 'My Signature', 'update_signature', 15, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  474.         (75, 'GRN (Goods Receipt Note) List', 'grn_list', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  475.         (76, 'Expense Entry', 'create_expense_invoice', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  476.         (77, 'Expense Bill List', 'expense_invoices', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  477.         (79, 'Store Indent Entry', 'create_store_requisition_slip', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  478.         (80, 'Bank Reconciliation', 'bank_recon', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  479.         (81, 'Purchase Requisition Entry', 'create_purchase_requisition_slip', 6, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  480.         (82, 'Sales Package Entry', 'create_sales_package', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  481.         (83, 'sales Order list', 'sales_orders', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  482.         (85, 'Delivery Confirmation Entry', 'create_delivery_confirmation', 9, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  483.         (86, 'Delivery Order list', 'delivery_orders', 9, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  484.         (87, 'Delivery Confirmation List', 'delivery_confirmations', 9, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  485.         (88, 'Delivery Receipt Entry', 'create_delivery_receipt', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  486.         (89, 'Delivery Receipt List', 'delivery_receipts', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  487.         (92, 'Sales Package List', 'product_package_list', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  488.         (93, 'Cheque Register', 'check_register', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  489.         (94, 'Fiscal Closing Entry', 'fiscal_closing', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  490.         (95, 'Financial Report', 'view_financial_report', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  491.         (96, 'View Company Sales Amount', 'view_company_sales_amount', 20, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  492.         (97, 'View Company Net Worth', 'view_company_net_worth', 20, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  493.         (98, 'View Company Monthly Growth', 'view_company_monthly_growth', 20, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  494.         (100, 'stock consumption Report', 'stock_consumption_view', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  495.         (101, 'stock requisition list', 'sr_list', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  496.         (102, 'Store Indent list', 'ir_list', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  497.         (103, 'purchase requisition list', 'pr_list', 6, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  498.         (104, 'Project Category Settings', 'create_project_category', 12, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  499.         (105, 'Supplier Category Settings', 'add_supplier_category', 6, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  500.         (106, 'Project Work Stage Settings', 'create_project_work_stage', 12, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  501.         (107, 'project BOQ Entry', 'create_project_boq', 12, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  502.         (108, 'Project Work Plan Entry', 'create_project_wp', 12, 1, 1, 1, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  503.         (109, 'Project Offer Entry', 'create_project_offer', 12, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  504.         (110, 'Project BOM Entry', 'create_project_material', 12, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  505.         (111, 'Service Receipt Entry', 'create_service_challan', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  506.         (112, 'Service Receipt List', 'service_challans', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  507.         (113, 'Stock Receive Entry', 'create_stock_received_note', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  508.         (114, 'Stock Receive Document List', 'srcv_list', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  509.         (115, 'Stock Transfer Document List', 'st_list', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  510.         (116, 'Product List', 'product_list', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  511.         (118, 'project Proposal entry', 'create_project_proposal', 12, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  512.         (119, 'Item Received and Replacement For Sales Entry', 'create_irr', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  513.         (120, 'Item Received and replacement List', 'irr_list', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  514.         (121, 'Sales Return Entry', 'create_sales_return', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  515.         (122, 'Sales Return List', 'sales_return_list', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  516.         (123, 'Sales Order amendment', 'create_so_amendment', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  517.         (124, 'SO Amendment List', 'so_amendment_list', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  518.         (126, 'Proforma Invoice Entry', 'create_proforma_invoice', 10, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  519.         (127, 'Insurance Pay Request Entry', 'create_insurance_pay_request', 10, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  520.         (128, 'LC Opening request Entry', 'create_lc_opening_request', 10, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  521.         (129, 'LC Entry', 'create_lc_entry', 10, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  522.         (130, 'Bill of Lading Entry', 'create_bill_of_lading', 10, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  523.         (131, 'Bill of Entry', 'create_bill_of_entry', 10, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  524.         (132, 'Landed Cost Sheet Entry', 'create_landed_cost_sheet', 10, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  525.         (133, 'Proforma Invoice List', 'proforma_invoice_list', 10, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  526.         (134, 'Insurance Pay Request List', 'insurance_pay_request_list', 10, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  527.         (135, 'LC Opening Request List', 'lc_opening_request_list', 10, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  528.         (136, 'LC List', 'lc_entry_list', 10, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  529.         (137, 'Bill of Lading List', 'bill_of_lading_list', 10, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  530.         (138, 'Bill of Entry List', 'bill_of_entry_list', 10, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  531.         (139, 'Landed Cost Sheet List', 'landed_cost_sheet_list', 10, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  532.         (140, 'Enforce Edit Project BOQ', 'force_edit_project_boq', 12, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  533.         (141, 'Security check', 'security_check', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  534.         (142, 'Bank Recon. Statement List', 'brs_list', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  535.         (143, 'Stock Consumption Entry', 'create_stock_consumption_note', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  536.         (144, 'Stock Consumption Entry list', 'stock_consumption_note_list', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  537.         (145, 'Service Purchase Bill Entry', 'create_service_purchase_invoice', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  538.         (146, 'Service Requisition Entry', 'create_service_requisition_slip', 6, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  539.         (147, 'Service Requisition List', 'service_requisition_list', 6, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  540.         (148, 'Fixed Asset Conversion Entry', 'create_fixed_asset_conversion_note', 2, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  541.         (149, 'Fixed Asset Conversion Entry List', 'fixed_asset_conversion_note_list', 2, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  542.         (150, 'Fixed Asset List', 'fixed_asset_list', 2, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  543.         (151, 'Add Fixed Asset', 'add_fixed_asset', 2, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  544.         (152, 'Fixed Asset Category Settings', 'add_fixed_asset_category', 2, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  545.         (153, 'Sales Report', 'sales_report', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  546.         (154, 'Finance Dashboard', 'finance_dashboard', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  547.         (155, 'Financial Budget Entry', 'create_financial_budget', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  548.         (156, 'Financial Budget List', 'financial_budget_list', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  549.         (157, 'Purchase report', 'purchase_report', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  550.         (158, 'sales Region Settings', 'sales_region', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  551.         (159, 'Sales Representative Entry', 'sales_person', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  552.         (160, 'Branch Settings', 'branch', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  553.         (161, 'Brand Settings', 'brand_company', 6, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  554.         (162, 'Trade Offer Entry', 'create_trade_offer', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  555.         (163, 'Trade Offer List', 'trade_offer_list', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  556.         (164, 'Set Product Price ', 'create_product_mrp_document', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  557.         (165, 'Price Settings Document List', 'product_mrp_document_list', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  558.         (166, 'Product Price List', 'product_price_list', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  559.         (168, 'Production Process Settings', 'create_production_process_settings', 8, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  560.         (169, 'Production BOM Settings', 'create_production_bom', 8, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  561.         (170, 'Production Entry', 'create_production_entry', 8, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  562.         (171, 'Sales Dashboard', 'sales_dashboard', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  563.         (172, 'Purchase Dashboard', 'purchase_dashboard', 6, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  564.         (173, 'Production Dashboard', 'production_dashboard', 8, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  565.         (175, 'Distribution Dashboard', 'distribution_dashboard', 9, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  566.         (176, 'Inventory Dashboard', 'inventory_dashboard', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  567.         (178, 'Service Dashboard', 'service_dashboard', 16, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  568.         (179, 'Production View', 'production_view', 8, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  569.         (180, 'Customer Ledger', 'view_client_ledger', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  570.         (181, 'Order vs Disperse', 'sales_vs_delivery_list', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  571.         (182, 'Project Costing Report', 'view_project_costing_report', 12, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  572.         (183, 'Client Pending Order List', 'client_pending_sales_orders', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  573.         (184, 'Register Product ', 'register_product', 9, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  574.         (185, 'Employee Entry', 'add_employee', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  575.         (186, 'Leave Application Entry', 'employee_leave', 14, 1, 1, 1, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  576.         (187, 'Leave Application List', 'leave_application_list', 14, 1, 1, 1, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  577.         (188, 'Employee List', 'employee_list', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  578.         (189, 'Attendance Report', 'attendance_report', 14, 1, 1, 1, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  579.         (190, 'Organization Chart', 'organization_chart', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  580.         (191, 'Salary Disbursement', 'disburse_salary', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  581.         (192, 'Attendance Entry', 'manual_attendance', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  582.         (193, 'Meeting Scheduling', 'meeting_scheduling', 14, 1, 1, 1, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  583.         (194, 'Payroll Policy Setting', 'payroll_policy_settings', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  584.         (195, 'Resignation Application', 'resign_application', 14, 1, 1, 1, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  585.         (196, 'Resignation Application List', 'resign_application_list', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  586.         (197, 'Payslip List', 'payslip_list', 14, 1, 1, 1, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  587.         (198, 'Scheduled Meeting List', 'scheduled_meeting_list', 14, 1, 1, 1, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  588.         (199, 'Salary Segregation Settings', 'salary_segregation_policy', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  589.         (200, 'Workplace Settings', 'set_workplace', 14, 1, 1, 1, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  590.         (201, 'Work Hour Settings', 'work_hour_policy', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  591.         (202, 'Holiday Calendar Settings', 'create_holiday', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  592.         (203, 'Payroll Policy List', 'payroll_policy_list', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  593.         (204, 'Salary Segregation Policy List', 'salary_segregation_policy_list', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  594.         (205, 'Work Hour Policy List', 'work_hour_policy_list', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  595.         (206, 'Human Resource Management Dashboard', 'human_resource_dashboard', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  596.         (207, 'Attendance Status', 'current_attendance', 14, 1, 1, 1, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  597.         (208, 'Holiday Calendar List', 'holiday_calendar_list', 14, 1, 1, 1, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  598.         (209, 'New Recruitment Post', 'create_new_job_post', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  599.         (210, 'Recruitment Post List', 'list_job_recruitment', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  600.         (211, 'Create Training Schedule', 'create_training_schedule', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  601.         (212, 'Employee List By Skill & Performance', 'employee_list_by_skill_performance', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  602.         (213, 'Recruitment Post List', 'list_job_recruitment', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  603.         (214, 'Employee Expense Allowance Settings', 'create_employee_expense_allowance_settings', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  604.         (215, 'Scheduled Interview', 'view_applicant_schedule', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  605.         (216, 'Add Skills', 'create_skill', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  606.         (217, 'Add Question', 'create_question', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  607.         (218, 'Add Education Qualification', 'create_education_qualification', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  608.         (219, 'Scheduled Training List', 'scheduled_training_list', 14, 1, 1, 1, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  609.         (220, 'Scheduled Interview List', 'scheduled_interview_list', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  610.         (221, 'Training Course', 'create_training_course', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  611.         (222, 'Performance Review Dashboard', 'performance_review_dashboard', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  612.         (223, 'Recruitment Dashboard', 'recruitment_dashboard', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  613.         (224, 'Talent Management Dashboard', 'talent_management_dashboard', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  614.         (225, 'Employee Evaluation Categories', 'create_evaluation_category', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  615.         (226, 'Harassment Complaint', 'create_workplace_harassment', 14, 1, 1, 1, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  616.         (227, 'Workplace Violence Complaint', 'register_workplace_complaint', 14, 1, 1, 1, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  617.         (228, 'Employee List', 'employee_list', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  618.         (229, 'Expense Allowance Settings List', 'employee_expense_allowance_settings_list', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  619.         (230, 'Leave Policy Settings List', 'leave_policy_settings_list', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  620.         (231, 'Create Leave Policy Settings', 'create_leave_policy_settings', 14, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  621.         (232, 'Create Project Site', 'project_site', 12, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  622.         (233, 'Serial Product List', 'product_by_code_list', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  623.         (234, 'Product Tracking', 'product_tracking', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  624.         (235, 'IMEI Check', 'mobile_imei_check', 21, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  625.         (236, 'Gift Box Label Print', 'mobile_gb_label_print', 21, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  626.         (237, 'IMEI Cross Check', 'mobile_imei_cross_check', 21, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  627.         (238, 'Gift Box Weight Check', 'mobile_gb_weight_check', 21, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  628.         (239, 'Gift Box Carton Assign', 'mobile_gb_carton_assign', 21, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  629.         (240, 'Carton Weight Check', 'mobile_carton_weight_check', 21, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  630.         (241, 'Carton Label Print', 'mobile_carton_label_print', 21, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  631.         (242, 'IMEI Label Print', 'mobile_device_imei_label_print', 21, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  632.         (243, 'Device IMEI List', 'mobile_imei_list', 21, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  633.         (244, 'Create Production Schedule', 'create_production_schedule', 8, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  634.         (245, 'Consumption Settings', 'consumption_settings', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  635.         (246, 'Label Format', 'label_format', 7, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  636.         (247, 'Replacement Report', 'replacement_report', 9, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  637.         (248, 'Production Schedule List', 'production_schedule_list', 8, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  638.         (249, 'Production Entry List', 'production_entry_document_list', 8, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  639.         (250, 'Attendance Amendment Entry', 'create_attendance_amendment', 14, 1, 1, 1, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  640.         (251, 'Sales Proposal Entry', 'create_sales_proposal', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  641.         (252, 'Sales Proposal List', 'sales_proposal_list', 4, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  642.         (253, 'Chart of Accounts', 'chart_of_accounts', 1, 1, 1, NULL, NULL, '2025-05-28 09:25:17', NULL, NULL, NULL),
  643.         (356, 'File Management', 'file_management_list', 15, 1, 1, NULL, NULL, '2026-05-04 00:00:00', NULL, NULL, NULL);
  644. ";
  645.         if ($get_kids_sql != "") {
  646.             $stmt $em->getConnection()->executeStatement($get_kids_sql);
  647.         }
  648.     }
  649.     public static function rectifyDatabase($em)
  650.     {
  651.     }
  652.     public static function updatePlanningItemSequence($em$planningItemId$assignType '_ASSIGN_')
  653.     {
  654.         $primaryOne $em->getRepository('ApplicationBundle\\Entity\\PlanningItem')
  655.             ->findOneBy(
  656.                 array(
  657.                     'id' => $planningItemId,
  658.                 )
  659.             );
  660.         $prevOne null;
  661.         if ($assignType == '_ASSIGN_') {
  662.             $seq 0;
  663.             ///find a similar one and get its sequence
  664.             $prevOneQry $em->getRepository('ApplicationBundle\\Entity\\PlanningItem')
  665.                 ->createQueryBuilder('m')
  666.                 ->where("m.parentId = :parentId")
  667.                 ->andWhere("m.id != " $primaryOne->getId())
  668.                 ->andWhere("m.referenceType = " $primaryOne->getReferenceType())
  669.                 ->setParameter('parentId'$primaryOne->getParentId());
  670.             if ($primaryOne->getParentId() == 0) {
  671.                 if ($primaryOne->getProjectId() != null && $primaryOne->getProjectId() != '')
  672.                     $prevOneQry->andWhere("m.projectId = " $primaryOne->getProjectId());
  673.                 if ($primaryOne->getBoqRefId() != null && $primaryOne->getBoqRefId() != '')
  674.                     $prevOneQry->andWhere("m.boqRefId = " $primaryOne->getBoqRefId());
  675.                 if ($primaryOne->getProductionScheduleId() != null && $primaryOne->getProductionScheduleId() != '')
  676.                     $prevOneQry->andWhere("m.productionScheduleId = " $primaryOne->getProductionScheduleId());
  677.                 if ($primaryOne->getProductionId() != null && $primaryOne->getProductionId() != '')
  678.                     $prevOneQry->andWhere("m.productionId = " $primaryOne->getProductionId());
  679.             }
  680.             $prevOneDataList $prevOneQry
  681.                 ->orderBy('m.sequence''DESC')
  682.                 ->getQuery()
  683.                 ->setMaxResults(1)
  684.                 ->getResult();
  685.             if (isset($prevOneDataList[0]))
  686.                 $prevOne $prevOneDataList[0];
  687.             if ($prevOne)
  688.                 $seq $prevOne->getSequence();
  689.             if ($seq == null or $seq == '')
  690.                 $seq 0;
  691.             $primarySeq $seq 1;
  692.             if ($primaryOne->getSequence() == null || $primaryOne->getSequence() == 0) {
  693.                 $primaryOne->setSequence($primarySeq);
  694.                 if ($prevOne) {
  695.                     $prevOne->setSequence($seq);
  696.                 }
  697.                 $em->flush();
  698.             }
  699.         }
  700.         if ($assignType == '_MOVE_DOWN_') {
  701.             $seq 0;
  702.             $prevOne null;
  703.             $primarySeq $primaryOne->getSequence();
  704.             ///find a similar one and get its sequence
  705.             $prevOneQry $em->getRepository('ApplicationBundle\\Entity\\PlanningItem')
  706.                 ->createQueryBuilder('m')
  707.                 ->where("m.parentId = :parentId")
  708.                 ->andWhere("m.id != " $primaryOne->getId())
  709.                 ->andWhere("m.referenceType = " $primaryOne->getReferenceType())
  710.                 ->andWhere("m.sequence > " $primaryOne->getSequence())
  711.                 ->setParameter('parentId'$primaryOne->getParentId());
  712.             //                ->andWhere("m.projectId = " .$primaryOne->getProjectId())
  713. //                ->andWhere("m.boqRefId = " .$primaryOne->getBoqRefId());
  714.             if ($primaryOne->getParentId() == 0) {
  715.                 if ($primaryOne->getProjectId() != null && $primaryOne->getProjectId() != '')
  716.                     $prevOneQry->andWhere("m.projectId = " $primaryOne->getProjectId());
  717.                 if ($primaryOne->getBoqRefId() != null && $primaryOne->getBoqRefId() != '')
  718.                     $prevOneQry->andWhere("m.boqRefId = " $primaryOne->getBoqRefId());
  719.                 if ($primaryOne->getProductionScheduleId() != null && $primaryOne->getProductionScheduleId() != '')
  720.                     $prevOneQry->andWhere("m.productionScheduleId = " $primaryOne->getProductionScheduleId());
  721.                 if ($primaryOne->getProductionId() != null && $primaryOne->getProductionId() != '')
  722.                     $prevOneQry->andWhere("m.productionId = " $primaryOne->getProductionId());
  723.             }
  724.             $prevOneDataList $prevOneQry
  725.                 ->orderBy('m.sequence''ASC')
  726.                 ->getQuery()
  727.                 ->setMaxResults(1)
  728.                 ->getResult();
  729.             if (isset($prevOneDataList[0]))
  730.                 $prevOne $prevOneDataList[0];
  731.             if ($prevOne)
  732.                 $seq $prevOne->getSequence();
  733.             if ($seq == null or $seq == '')
  734.                 $seq 0;
  735.             if ($seq && $prevOne != null) {
  736.                 $primaryOne->setSequence($seq);
  737.                 if ($prevOne) {
  738.                     $prevOne->setSequence($primarySeq);
  739.                 }
  740.             }
  741.             $em->flush();
  742.         }
  743.         if ($assignType == '_MOVE_UP_') {
  744.             $seq 0;
  745.             $prevOne null;
  746.             $primarySeq $primaryOne->getSequence();
  747.             if ($primarySeq 0) {
  748.                 ///find a similar one and get its sequence
  749.                 $prevOneQry $em->getRepository('ApplicationBundle\\Entity\\PlanningItem')
  750.                     ->createQueryBuilder('m')
  751.                     ->where("m.parentId = :parentId")
  752.                     ->andWhere("m.id != " $primaryOne->getId())
  753.                     ->andWhere("m.referenceType = " $primaryOne->getReferenceType())
  754.                     ->andWhere("m.sequence < " $primaryOne->getSequence())
  755.                     ->setParameter('parentId'$primaryOne->getParentId());
  756.                 //                ->andWhere("m.projectId = " .$primaryOne->getProjectId())
  757. //                ->andWhere("m.boqRefId = " .$primaryOne->getBoqRefId());
  758.                 if ($primaryOne->getParentId() == 0) {
  759.                     if ($primaryOne->getProjectId() != null && $primaryOne->getProjectId() != '')
  760.                         $prevOneQry->andWhere("m.projectId = " $primaryOne->getProjectId());
  761.                     if ($primaryOne->getBoqRefId() != null && $primaryOne->getBoqRefId() != '')
  762.                         $prevOneQry->andWhere("m.boqRefId = " $primaryOne->getBoqRefId());
  763.                     if ($primaryOne->getProductionScheduleId() != null && $primaryOne->getProductionScheduleId() != '')
  764.                         $prevOneQry->andWhere("m.productionScheduleId = " $primaryOne->getProductionScheduleId());
  765.                     if ($primaryOne->getProductionId() != null && $primaryOne->getProductionId() != '')
  766.                         $prevOneQry->andWhere("m.productionId = " $primaryOne->getProductionId());
  767.                 }
  768.                 $prevOneDataList $prevOneQry
  769.                     ->orderBy('m.sequence''DESC')
  770.                     ->getQuery()
  771.                     ->setMaxResults(1)
  772.                     ->getResult();
  773.                 if (isset($prevOneDataList[0]))
  774.                     $prevOne $prevOneDataList[0];
  775.                 if ($prevOne)
  776.                     $seq $prevOne->getSequence();
  777.                 if ($seq == null or $seq == '')
  778.                     $seq 0;
  779.                 if ($seq >= && $prevOne != null) {
  780.                     $primaryOne->setSequence($seq);
  781.                     if ($prevOne) {
  782.                         $prevOne->setSequence($primarySeq);
  783.                     }
  784.                 }
  785.                 $em->flush();
  786.             }
  787.         }
  788.         return array(
  789.             'primaryOne' => $primaryOne,
  790.             'otherOne' => $prevOne,
  791.         );
  792.     }
  793.     public static function getAppDataByCurl()
  794.     {
  795.         $urlToCall GeneralConstant::HONEYBEE_API_SERVER '/appData.json';
  796.         $curl curl_init();
  797.         curl_setopt_array($curl, array(
  798.             CURLOPT_RETURNTRANSFER => 1,
  799.             CURLOPT_URL => $urlToCall,
  800.             CURLOPT_CONNECTTIMEOUT => 10,
  801.             CURLOPT_SSL_VERIFYPEER => false,
  802.             CURLOPT_SSL_VERIFYHOST => false,
  803.             CURLOPT_HTTPHEADER => array(
  804.                 "Accept: application/json",
  805.             ),
  806.             //                        CURLOPT_USERAGENT => 'InnoPM',
  807.             //                        CURLOPT_POSTFIELDS => $post_fields
  808.         ));
  809.         //        $headers = array(
  810. //            "Accept: application/json",
  811. //        );
  812. //        curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  813. ////for debug only!
  814. //        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  815. //        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  816.         $retData curl_exec($curl);
  817.         $errData curl_error($curl);
  818.         curl_close($curl);
  819.         return $retData;
  820.     }
  821.     public static function setSessionForUser(
  822.         $em,
  823.         $session,
  824.         $sessionData = [],
  825.         $config = [],
  826.         $userId 0,
  827.         $loginId 0,
  828.         $userType 1,
  829.         $userData = []
  830.     ) {
  831.         if (empty($sessionData)) {
  832.             if (empty($config))
  833.                 $config = array();
  834.             if (!isset($config['firstLogin']))
  835.                 $config['firstLogin'] = 1;
  836.             if (!isset($config['rememberMe']))
  837.                 $config['rememberMe'] = 0;
  838.             if (!isset($config['notificationEnabled']))
  839.                 $config['notificationEnabled'] = 0;
  840.             if (!isset($config['notificationServer']))
  841.                 $config['notificationServer'] = '';
  842.             if (!isset($config['applicationSecret']))
  843.                 $config['applicationSecret'] = '';
  844.             if (!isset($config['gocId']))
  845.                 $config['gocId'] = '';
  846.             if (!isset($config['appId']))
  847.                 $config['appId'] = '';
  848.             if (!isset($config['gocDbName']))
  849.                 $config['gocDbName'] = '';
  850.             if (!isset($config['gocDbUser']))
  851.                 $config['gocDbUser'] = '';
  852.             if (!isset($config['gocDbHost']))
  853.                 $config['gocDbHost'] = '';
  854.             if (!isset($config['gocDbPass']))
  855.                 $config['gocDbPass'] = '';
  856.             $sessionData = array(
  857.                 UserConstants::USER_ID => $userId,
  858.                 UserConstants::USER_LOGIN_ID => $loginId,
  859.                 UserConstants::USER_TYPE => $userType,
  860.                 UserConstants::FIRST_LOGIN_FLAG => $config['firstLogin'],
  861.                 UserConstants::APPLICATION_SECRET => $config['applicationSecret'],
  862.                 UserConstants::USER_NOTIFICATION_ENABLED => $config['notificationEnabled'],
  863.                 UserConstants::USER_NOTIFICATION_SERVER => $config['notificationServer'],
  864.                 UserConstants::USER_GOC_ID => $config['gocId'],
  865.                 UserConstants::USER_DB_NAME => $config['gocDbName'],
  866.                 UserConstants::USER_DB_USER => $config['gocDbUser'],
  867.                 UserConstants::USER_DB_HOST => $config['gocDbHost'],
  868.                 UserConstants::USER_DB_PASS => $config['gocDbPass'],
  869.                 UserConstants::USER_APP_ID => $config['appId'],
  870.                 UserConstants::USER_EMAIL => $session->get(UserConstants::USER_EMAIL),
  871.                 UserConstants::USER_IMAGE => $session->get(UserConstants::USER_IMAGE),
  872.                 UserConstants::USER_OAUTH_IMAGE => $session->get(UserConstants::USER_OAUTH_IMAGE),
  873.                 UserConstants::USER_DEFAULT_ROUTE => $session->get(UserConstants::USER_DEFAULT_ROUTE),
  874.                 UserConstants::USER_NAME => $session->get(UserConstants::USER_NAME),
  875.                 UserConstants::USER_COMPANY_ID => $session->get(UserConstants::USER_COMPANY_ID),
  876.                 UserConstants::USER_COMPANY_ID_LIST => $session->get(UserConstants::USER_COMPANY_ID_LIST),
  877.                 UserConstants::USER_COMPANY_NAME_LIST => $session->get(UserConstants::USER_COMPANY_NAME_LIST),
  878.                 UserConstants::USER_COMPANY_IMAGE_LIST => $session->get(UserConstants::USER_COMPANY_IMAGE_LIST),
  879.                 UserConstants::USER_CURRENT_POSITION => $session->get(UserConstants::USER_CURRENT_POSITION),
  880.                 UserConstants::SESSION_SALT => $session->get(UserConstants::SESSION_SALT),
  881.                 UserConstants::USER_POSITION_LIST => $session->get(UserConstants::USER_POSITION_LIST),
  882.                 UserConstants::USER_COMPANY_DARK_VIBRANT_LIST => $session->get('userCompanyDarkVibrantList', []),
  883.                 UserConstants::USER_COMPANY_VIBRANT_LIST => $session->get('userCompanyVibrantList', []),
  884.                 UserConstants::USER_COMPANY_LIGHT_VIBRANT_LIST => $session->get('userCompanyLightVibrantList', []),
  885.                 UserConstants::ALL_MODULE_ACCESS_FLAG => $session->get(UserConstants::ALL_MODULE_ACCESS_FLAG),
  886.                 UserConstants::PRODUCT_NAME_DISPLAY_TYPE => $session->get(UserConstants::PRODUCT_NAME_DISPLAY_TYPE),
  887.                 //new
  888.                 'appIdList' => $session->get('appIdList'),
  889.                 'branchIdList' => $session->get('branchIdList'null),
  890.                 'branchId' => $session->get('branchId'null),
  891.                 'companyIdListByAppId' => $session->get('companyIdListByAppId'),
  892.                 'companyNameListByAppId' => $session->get('companyNameListByAppId'),
  893.                 'companyImageListByAppId' => $session->get('companyImageListByAppId'),
  894.             );
  895.             if ($userType == UserConstants::USER_TYPE_GENERAL) {
  896.             }
  897.         }
  898.         foreach ($sessionData as $key => $val) {
  899.             $session->set($key$val);
  900.         }
  901.         $tokenData MiscActions::CreateTokenFromSessionData($em$sessionData);
  902.         $sessionData $tokenData['sessionData'];
  903.         $token $tokenData['token'];
  904.         $session->set('token'$token);
  905.         return [
  906.             'session' => $session,
  907.             'sessionData' => $sessionData,
  908.             'tokenData' => $tokenData,
  909.             'token' => $token,
  910.         ];
  911.     }
  912.     public static function changeDoctrineManagerByAppId($em_goc$gocEnabled$appId)
  913.     {
  914.         $gocList = [];
  915.         $em_goc->getConnection()->connect();
  916.         $gocEnabled 1//OVERRIDE
  917.         if ($gocEnabled == 1)
  918.             $connected $em_goc->getConnection()->isConnected();
  919.         else
  920.             $connected false;
  921.         $goc null;
  922.         if ($connected)
  923.             $goc $em_goc
  924.                 ->getRepository("CompanyGroupBundle\\Entity\\CompanyGroup")
  925.                 ->findOneBy(
  926.                     array(
  927.                         'active' => 1,
  928.                         'appId' => $appId
  929.                     )
  930.                 );
  931.         $gocDataList = [];
  932.         $gocDataListByAppId = [];
  933.         $dataToConnect = [];
  934.         if ($goc)
  935.             $dataToConnect = array(
  936.                 'dbName' => $goc->getDbName(),
  937.                 'dbUser' => $goc->getDbUser(),
  938.                 'dbPass' => $goc->getDbPass(),
  939.                 'dbHost' => $goc->getDbHost()
  940.             );
  941.         return $dataToConnect;
  942.     }
  943.     public static function array_utf8_encode($dat)
  944.     {
  945.         if (is_string($dat))
  946.             return utf8_encode($dat);
  947.         if (!is_array($dat))
  948.             return $dat;
  949.         $ret = array();
  950.         foreach ($dat as $i => $d)
  951.             $ret[$i] = self::array_utf8_encode($d);
  952.         return $ret;
  953.     }
  954.     public static function encryptSignature($str$hash 'monada')
  955.     {
  956.         $iv '1234567812345678';
  957.         $pass $hash;
  958.         //        $method = 'aes-256-cbc';
  959.         //        $new_data = $str;
  960.         $str $str 'YmLRocksLikeABoss';
  961.         $data openssl_encrypt($str"AES-128-CBC"$passOPENSSL_RAW_DATA$iv);
  962.         //        $data=$str;
  963.         $decrypted openssl_decrypt(base64_decode(base64_encode($data)), "AES-128-CBC"$hashOPENSSL_RAW_DATA$iv);
  964.         if ($data != false)
  965.             $encoded base64_encode($data);
  966.         else
  967.             $encoded false;
  968.         //        $decrypted = openssl_decrypt(base64_decode($base64), "AES-128-CBC", "some password", OPENSSL_RAW_DATA, $iv);
  969.         //        $data=openssl_encrypt ($string, $method, $pass,OPENSSL_RAW_DATA|OPENSSL_ZERO_PADDING, $iv);
  970.         //        return [$decrypted,$iv,$base64,$str,$new_data];
  971.         //        return [$encoded,$decrypted];
  972.         return $encoded;
  973.     }
  974.     public static function getPendingApprovalListByUserLoginId($em$login_id$includeAbsoluteUrl 0$absoluteUrlList = [], $tvp ''$filterApprovalEntityId '_all_')
  975.     {
  976.         $user_data Users::getUserInfoByLoginId($em$login_id);
  977.         //1st get only currently pendings
  978.         $pending_approval_list = [];
  979.         $override_approval_list = [];
  980.         $grouped_approval_list = [
  981.         ];
  982.         $applicableEntities = [];
  983.         $total_pending_task_count 0;
  984.         $generalFilter = ($filterApprovalEntityId == '_all_' || $filterApprovalEntityId == '') ? [] : array(
  985.             'entity' => $filterApprovalEntityId
  986.         );
  987.         $dt $em->getRepository('ApplicationBundle\\Entity\\Approval')
  988.             ->findBy(
  989.                 array_merge(
  990.                     $generalFilter,
  991.                     array(
  992.                         //                    'entity' => $entity,
  993.                         //                    'entityId' => $entity_id,
  994.                         'required' => [1],
  995.                         'action' => [3],
  996.                         'current' => GeneralConstant::CURRENTLY_PENDING_APPROVAL
  997.                     )
  998.                 ),
  999.                 array(
  1000.                     'createdAt' => 'DESC'
  1001.                 )
  1002.             );
  1003.         $rl_type GeneralConstant::$approvalRole;
  1004.         $amount_methods ApprovalConstant::$Entity_amount_method;
  1005.         $note_methods ApprovalConstant::$Entity_note_method;
  1006.         //        $date_methods = ApprovalConstant::$Entity_date_method;
  1007.         foreach ($dt as $entry) {
  1008.             if (in_array($user_data['id'], json_decode($entry->getUserIds(), true) ?? [])) {
  1009.                 $approval_data = [];
  1010.                 $approval_data['createdBy'] = '';
  1011.                 $approval_data['createdUserImage'] = '';
  1012.                 $approval_data['documentHash'] = $entry->getDocumentHash();
  1013.                 $approval_data['approvalId'] = $entry->getId();
  1014.                 $approval_data['roleType'] = $rl_type[$entry->getRoleType()];
  1015.                 $approval_data['roleTypeId'] = $entry->getRoleType();
  1016.                 $approval_data['createdAt'] = $entry->getCreatedAt()->format('U');
  1017.                 $approval_data['amount'] = '';
  1018.                 $approval_data['note'] = '';
  1019.                 $approval_data['specialType'] = '';
  1020.                 if ($includeAbsoluteUrl == && isset($absoluteUrlList[$entry->getEntity()])) {
  1021.                     //                    $approval_data['viewPathAbs'] = $absoluteUrlList[$entry->getEntity()];
  1022. //                    $approval_data['viewPathAbs'] = $absoluteUrlList[$entry->getEntity()].'/'.$entry->getEntityId().'?tvp='.$tvp;
  1023.                     $approval_data['viewPathAbs'] = $absoluteUrlList[$entry->getEntity()] . '/' $entry->getEntityId();
  1024.                 }
  1025.                 //                $approval_data['viewPath'] = GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_view_route_path_name'];
  1026.                 $approval_data['viewPath'] = isset(GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_view_route_path_name']) ? GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_view_route_path_name'] : '';
  1027.                 $approval_data['printPath'] = isset(GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_print_route_path_name']) ? GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_print_route_path_name'] : $approval_data['viewPath'];
  1028.                 $approval_data['entityAlias'] = GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_alias'];
  1029.                 $doc $em->getRepository('ApplicationBundle\\Entity\\' GeneralConstant::$Entity_list[$entry->getEntity()])
  1030.                     ->findOneBy(
  1031.                         array(
  1032.                             //                    'entity' => $entity,
  1033.                             //                    'entityId' => $entity_id,
  1034. //                                    'required' => [1, 2],
  1035.                             GeneralConstant::$Entity_id_field_list[$entry->getEntity()] => $entry->getEntityId()
  1036.                         ),
  1037.                         array(//                                    'createdAt' => 'DESC'
  1038.                         )
  1039.                     );
  1040.                 if ($doc) {
  1041.                     if ($doc->getCreatedLoginId() && $doc->getCreatedLoginId() != && $doc->getCreatedLoginId() != null) {
  1042.                         $approval_data['createdBy'] = Users::getUserInfoByLoginId($em$doc->getCreatedLoginId())['name'];
  1043.                         $approval_data['createdUserImage'] = Users::getUserInfoByLoginId($em$doc->getCreatedLoginId())['image'];
  1044.                     }
  1045.                     if (isset($amount_methods[$entry->getEntity()]))
  1046.                         $approval_data['amount'] = $doc->{$amount_methods[$entry->getEntity()]}();
  1047.                     if (isset($note_methods[$entry->getEntity()])) {
  1048.                         if ($doc)
  1049.                             $approval_data['note'] = $doc->{$note_methods[$entry->getEntity()]}();
  1050.                         else
  1051.                             $approval_data['note'] = '';
  1052.                     } else if (method_exists($doc'getNote'))
  1053.                         $approval_data['note'] = $doc->getNote();
  1054.                     else if (method_exists($doc'getDescription'))
  1055.                         $approval_data['note'] = $doc->getDescription();
  1056.                     else if (method_exists($doc'getDesc'))
  1057.                         $approval_data['note'] = $doc->getDesc();
  1058.                     else
  1059.                         $approval_data['note'] = '';
  1060.                     $filePath '';
  1061.                     if (method_exists($doc'getFiles')) {
  1062.                         $filePath $doc->getFiles() ?: '';
  1063.                     }
  1064.                     $fileEntityName = isset(GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_name']) ? GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_name'] : '';
  1065.                     $approval_data['attachment'] = '';
  1066.                     if ($filePath) {
  1067.                         $approval_data['attachment'] = strpos($filePath'/') !== false $filePath "uploads/$fileEntityName/" $filePath;
  1068.                     }
  1069.                 }
  1070.                 $approval_data['entity'] = $entry->getEntity();
  1071.                 $approval_data['entityId'] = $entry->getEntityId();
  1072.                 $approval_data['entityIdPadded'] = str_pad($entry->getEntityId(), 8'0'STR_PAD_LEFT);
  1073.                 $approval_data['required'] = $entry->getRequired();
  1074.                 $pending_approval_list[] = $approval_data;
  1075.                 if (!isset($grouped_approval_list[$entry->getEntity()])) {
  1076.                     $applicableEntities[] = $entry->getEntity();
  1077.                     $grouped_approval_list[$entry->getEntity()] = array();
  1078.                 }
  1079.                 $grouped_approval_list[$entry->getEntity()][] = $approval_data;
  1080.                 $total_pending_task_count++;
  1081.                 //                $approval_data['acted']=1;
  1082.             }
  1083.         }
  1084.         //now optionals
  1085.         $dt $em->getRepository('ApplicationBundle\\Entity\\Approval')
  1086.             ->findBy(
  1087.                 array_merge(
  1088.                     $generalFilter,
  1089.                     array(
  1090.                         //                    'entity' => $entity,
  1091.                         //                    'entityId' => $entity_id,
  1092.                         'required' => [0],
  1093.                         'action' => [3],
  1094.                         'current' => GeneralConstant::CURRENTLY_PENDING_APPROVAL
  1095.                     )
  1096.                 ),
  1097.                 array(
  1098.                     'createdAt' => 'DESC'
  1099.                 )
  1100.             );
  1101.         foreach ($dt as $entry) {
  1102.             $entry_user_ids json_decode($entry->getUserIds(), true);
  1103.             $entry_user_ids is_array($entry_user_ids) ? $entry_user_ids : [];
  1104.             if (in_array($user_data['id'], $entry_user_ids)) {
  1105.                 $approval_data = [];
  1106.                 $approval_data['documentHash'] = $entry->getDocumentHash();
  1107.                 $approval_data['approvalId'] = $entry->getId();
  1108.                 $approval_data['roleType'] = $rl_type[$entry->getRoleType()];
  1109.                 $approval_data['roleTypeId'] = $entry->getRoleType();
  1110.                 $approval_data['createdAt'] = $entry->getCreatedAt()->format('U');
  1111.                 if ($includeAbsoluteUrl == 1) {
  1112.                     $approval_data['viewPathAbs'] = $absoluteUrlList[$entry->getEntity()] . '/' $entry->getEntityId();
  1113.                 }
  1114.                 $approval_data['viewPath'] = GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_view_route_path_name'];
  1115.                 $approval_data['printPath'] = isset(GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_print_route_path_name']) ? GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_print_route_path_name'] : GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_view_route_path_name'];
  1116.                 $approval_data['entityAlias'] = GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_alias'];
  1117.                 $approval_data['entityId'] = $entry->getEntityId();
  1118.                 $approval_data['entityIdPadded'] = str_pad($entry->getEntityId(), 8'0'STR_PAD_LEFT);
  1119.                 $approval_data['createdBy'] = '';
  1120.                 $approval_data['createdUserImage'] = '';
  1121.                 $approval_data['amount'] = '';
  1122.                 $approval_data['note'] = '';
  1123.                 $approval_data['specialType'] = '';
  1124.                 $doc $em->getRepository('ApplicationBundle\\Entity\\' GeneralConstant::$Entity_list[$entry->getEntity()])
  1125.                     ->findOneBy(
  1126.                         array(
  1127.                             //                    'entity' => $entity,
  1128.                             //                    'entityId' => $entity_id,
  1129. //                                    'required' => [1, 2],
  1130.                             GeneralConstant::$Entity_id_field_list[$entry->getEntity()] => $entry->getEntityId()
  1131.                         ),
  1132.                         array(//                                    'createdAt' => 'DESC'
  1133.                         )
  1134.                     );
  1135.                 if ($doc) {
  1136.                     if ($doc->getCreatedLoginId() && $doc->getCreatedLoginId() != && $doc->getCreatedLoginId() != null) {
  1137.                         $approval_data['createdBy'] = Users::getUserInfoByLoginId($em$doc->getCreatedLoginId())['name'];
  1138.                         $approval_data['createdUserImage'] = Users::getUserInfoByLoginId($em$doc->getCreatedLoginId())['image'];
  1139.                     }
  1140.                     if (isset($amount_methods[$entry->getEntity()]))
  1141.                         $approval_data['amount'] = $doc->{$amount_methods[$entry->getEntity()]}();
  1142.                     if (isset($note_methods[$entry->getEntity()])) {
  1143.                         if ($doc)
  1144.                             $approval_data['note'] = $doc->{$note_methods[$entry->getEntity()]}();
  1145.                         else
  1146.                             $approval_data['note'] = '';
  1147.                     } else if (method_exists($doc'getNote'))
  1148.                         $approval_data['note'] = $doc->getNote();
  1149.                     else if (method_exists($doc'getDescription'))
  1150.                         $approval_data['note'] = $doc->getDescription();
  1151.                     else if (method_exists($doc'getDesc'))
  1152.                         $approval_data['note'] = $doc->getDesc();
  1153.                     else
  1154.                         $approval_data['note'] = '';
  1155.                 }
  1156.                 //                $approval_data['amount'] = isset($amount_methods[$entry->getEntity()])?$entry->{$amount_methods[$entry->getEntity()]}():'';
  1157.                 $approval_data['entity'] = $entry->getEntity();
  1158.                 $approval_data['required'] = $entry->getRequired();
  1159.                 $pending_approval_list[] = $approval_data;
  1160.                 if (!isset($grouped_approval_list[$entry->getEntity()])) {
  1161.                     $applicableEntities[] = $entry->getEntity();
  1162.                     $grouped_approval_list[$entry->getEntity()] = array();
  1163.                 }
  1164.                 $grouped_approval_list[$entry->getEntity()][] = $approval_data;
  1165.                 $total_pending_task_count++;
  1166.                 //                $approval_data['acted']=1;
  1167.             }
  1168.         }
  1169.         //now override
  1170.         $dt $em->getRepository('ApplicationBundle\\Entity\\Approval')
  1171.             ->findBy(
  1172.                 array_merge(
  1173.                     $generalFilter,
  1174.                     array(
  1175.                         'required' => 2,
  1176.                         'action' => 3
  1177.                     )
  1178.                 )
  1179.             );
  1180.         foreach ($dt as $entry) {
  1181.             if (in_array($user_data['id'], json_decode($entry->getUserIds(), true) ?? [])) {
  1182.                 $approval_data = [];
  1183.                 $approval_data['documentHash'] = $entry->getDocumentHash();
  1184.                 $approval_data['approvalId'] = $entry->getId();
  1185.                 $approval_data['roleType'] = $rl_type[$entry->getRoleType()];
  1186.                 $approval_data['roleTypeId'] = $entry->getRoleType();
  1187.                 $approval_data['required'] = $entry->getRequired();
  1188.                 $approval_data['createdAt'] = $entry->getCreatedAt()->format('U');
  1189.                 if ($includeAbsoluteUrl == 1) {
  1190.                     $approval_data['viewPathAbs'] = $absoluteUrlList[$entry->getEntity()];
  1191.                 }
  1192.                 $approval_data['viewPath'] = GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_view_route_path_name'];
  1193.                 $approval_data['printPath'] = isset(GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_print_route_path_name']) ? GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_print_route_path_name'] : GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_view_route_path_name'];
  1194.                 $approval_data['entityAlias'] = GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_alias'];
  1195.                 $approval_data['entityId'] = $entry->getEntityId();
  1196.                 $approval_data['entity'] = $entry->getEntity();
  1197.                 $approval_data['createdBy'] = '';
  1198.                 $approval_data['createdUserImage'] = '';
  1199.                 $approval_data['amount'] = '';
  1200.                 $approval_data['note'] = '';
  1201.                 $approval_data['specialType'] = '';
  1202.                 $doc $em->getRepository('ApplicationBundle\\Entity\\' GeneralConstant::$Entity_list[$entry->getEntity()])
  1203.                     ->findOneBy(
  1204.                         array(
  1205.                             //                    'entity' => $entity,
  1206.                             //                    'entityId' => $entity_id,
  1207. //                                    'required' => [1, 2],
  1208.                             GeneralConstant::$Entity_id_field_list[$entry->getEntity()] => $entry->getEntityId()
  1209.                         ),
  1210.                         array(//                                    'createdAt' => 'DESC'
  1211.                         )
  1212.                     );
  1213.                 if ($doc) {
  1214.                     if ($doc->getCreatedLoginId() && $doc->getCreatedLoginId() != && $doc->getCreatedLoginId() != null) {
  1215.                         $approval_data['createdBy'] = Users::getUserInfoByLoginId($em$doc->getCreatedLoginId())['name'];
  1216.                         $approval_data['createdUserImage'] = Users::getUserInfoByLoginId($em$doc->getCreatedLoginId())['image'];
  1217.                     }
  1218.                     if (isset($amount_methods[$entry->getEntity()]))
  1219.                         $approval_data['amount'] = $doc->{$amount_methods[$entry->getEntity()]}();
  1220.                     if (isset($note_methods[$entry->getEntity()])) {
  1221.                         if ($doc)
  1222.                             $approval_data['note'] = $doc->{$note_methods[$entry->getEntity()]}();
  1223.                         else
  1224.                             $approval_data['note'] = '';
  1225.                     } else if (method_exists($doc'getNote'))
  1226.                         $approval_data['note'] = $doc->getNote();
  1227.                     else if (method_exists($doc'getDescription'))
  1228.                         $approval_data['note'] = $doc->getDescription();
  1229.                     else if (method_exists($doc'getDesc'))
  1230.                         $approval_data['note'] = $doc->getDesc();
  1231.                     else
  1232.                         $approval_data['note'] = '';
  1233.                 }
  1234.                 $override_approval_list[] = $approval_data;
  1235.                 if (!isset($grouped_approval_list[$entry->getEntity()])) {
  1236.                     $applicableEntities[] = $entry->getEntity();
  1237.                     $grouped_approval_list[$entry->getEntity()] = array();
  1238.                 }
  1239.                 $grouped_approval_list[$entry->getEntity()][] = $approval_data;
  1240.                 $total_pending_task_count++;
  1241.                 //                $approval_data['acted']=1;
  1242.             }
  1243.         }
  1244.         return array(
  1245.             "pending_approval_list" => $pending_approval_list,
  1246.             "override_approval_list" => $override_approval_list,
  1247.             "applicable_entities" => $applicableEntities,
  1248.             "grouped_approval_list" => $grouped_approval_list,
  1249.             "total_pending_task_count" => $total_pending_task_count,
  1250.             "entity_list_details" => GeneralConstant::$Entity_list_details,
  1251.         );
  1252.     }
  1253.     public static function getPendinDocumentListForAppByUserLoginId(
  1254.         $em,
  1255.         $login_id,
  1256.         $includeAbsoluteUrl 0,
  1257.         $absoluteUrlList = [],
  1258.         $tvp '',
  1259.         $filterApprovalEntityId '_all_',
  1260.         $page 1,
  1261.         $offset 0,
  1262.         $limit 10,
  1263.         $absoluteUrl ''
  1264.     ) {
  1265.         $user_data Users::getUserInfoByLoginId($em$login_id);
  1266.         $pending_approval_list = [];
  1267.         $grouped_approval_list = [];
  1268.         $applicableEntities = [];
  1269.         $total_pending_task_count 0;
  1270.         $generalFilter = ($filterApprovalEntityId == '_all_' || $filterApprovalEntityId == '') ? [] : [
  1271.             'entity' => $filterApprovalEntityId
  1272.         ];
  1273.         // Define reusable role and amount constants
  1274.         $rl_type GeneralConstant::$approvalRole;
  1275.         $amount_methods ApprovalConstant::$Entity_amount_method;
  1276.         $qb $em->createQueryBuilder()
  1277.             ->select('a')
  1278.             ->from('ApplicationBundle\\Entity\\Approval''a')
  1279.             ->where('a.action = :action')
  1280.             ->andWhere('a.current = :current')
  1281.             ->andWhere('a.userIds like \'%"' $user_data['id'] . '"%\'  ')
  1282.             ->setParameter('action'3)
  1283.             ->setParameter('current'GeneralConstant::CURRENTLY_PENDING_APPROVAL)
  1284.             ->orderBy('a.createdAt''DESC');
  1285.         if (!empty($generalFilter['entity'])) {
  1286.             $qb->andWhere('a.entity = :entity')->setParameter('entity'$generalFilter['entity']);
  1287.         }
  1288.         $limit max(1$limit);
  1289.         if ($page != '_UNSET_') {
  1290.             $page max(1$page);
  1291.             $offset = ($page 1) * $limit;
  1292.         } else {
  1293.             $page ceil(($offset $limit) + 1);
  1294.         }
  1295.         $countQb = clone $qb;
  1296.         $countQb->select('COUNT(a.id)');
  1297.         $total_pending_task_count $countQb->getQuery()->getSingleScalarResult();
  1298.         $dt $qb->setFirstResult($offset)->setMaxResults($limit)->getQuery()->getResult();
  1299.         foreach ($dt as $entry) {
  1300.             if (!in_array($user_data['id'], json_decode($entry->getUserIds(), true) ?? [])) {
  1301.                 continue;
  1302.             }
  1303.             $approval_data = [];
  1304.             $approval_data['createdBy'] = '';
  1305.             $approval_data['createdUserImage'] = '';
  1306.             $approval_data['documentHash'] = $entry->getDocumentHash();
  1307.             $approval_data['approvalId'] = $entry->getId();
  1308.             $approval_data['roleType'] = $rl_type[$entry->getRoleType()];
  1309.             $approval_data['roleTypeId'] = $entry->getRoleType();
  1310.             $approval_data['createdAt'] = (int) $entry->getCreatedAt()->format('U');
  1311.             $approval_data['amount'] = '';
  1312.             if ($includeAbsoluteUrl == && isset($absoluteUrlList[$entry->getEntity()])) {
  1313.                 $approval_data['viewPathAbs'] = $absoluteUrlList[$entry->getEntity()] . '/' $entry->getEntityId() . '?tvp=' $tvp;
  1314.             }
  1315.             $approval_data['viewPath'] = GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_view_route_path_name'] ?? '';
  1316.             $approval_data['printPath'] = GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_print_route_path_name'] ?? $approval_data['viewPath'];
  1317.             $approval_data['entityAlias'] = GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_alias'];
  1318.             // Fetch document data
  1319.             $doc $em->getRepository('ApplicationBundle\\Entity\\' GeneralConstant::$Entity_list[$entry->getEntity()])
  1320.                 ->findOneBy([
  1321.                     GeneralConstant::$Entity_id_field_list[$entry->getEntity()] => $entry->getEntityId()
  1322.                 ]);
  1323.             if ($doc) {
  1324.                 if ($doc->getCreatedLoginId() && $doc->getCreatedLoginId() != 0) {
  1325.                     $user_info Users::getUserInfoByLoginId($em$doc->getCreatedLoginId());
  1326.                     $approval_data['createdBy'] = $user_info['name'] ?? '';
  1327.                     $approval_data['createdUserImage'] = $user_info['image'] ?? '';
  1328.                 }
  1329.                 if (isset($amount_methods[$entry->getEntity()])) {
  1330.                     $approval_data['amount'] = $doc->{$amount_methods[$entry->getEntity()]}();
  1331.                 }
  1332.             }
  1333.             //            $filePath = $doc->getFiles() ??  '';
  1334.             $filePath '';
  1335.             if (method_exists($doc'getFiles')) {
  1336.                 $filePath $doc->getFiles() ?: '';
  1337.             }
  1338.             $fileEntityName GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_name'];
  1339.             $approval_data['entity'] = $entry->getEntity();
  1340.             $approval_data['entityId'] = $entry->getEntityId();
  1341.             $approval_data['entityIdPadded'] = str_pad($entry->getEntityId(), 8'0'STR_PAD_LEFT);
  1342.             $approval_data['required'] = $entry->getRequired();
  1343.             // Real "From the document" key-facts for the mobile app (replaces the
  1344.             // Lorem-Ipsum placeholder). See APPROVAL_SUMMARY_FIX.md.
  1345.             $approval_data['summary'] = \ApplicationBundle\Modules\System\MiscActions::buildApprovalSummaryRows(
  1346.                 \ApplicationBundle\Modules\System\MiscActions::resolveApprovalPartyName($em$entry->getEntity(), $doc),
  1347.                 isset($approval_data['amount']) ? $approval_data['amount'] : null,
  1348.                 isset($approval_data['entityIdPadded']) ? $approval_data['entityIdPadded'] : ''
  1349.             );
  1350.             // Project / cost-centre for the mobile grouped-approval view.
  1351.             $approval_project = \ApplicationBundle\Modules\System\MiscActions::resolveApprovalProject($em$doc);
  1352.             $approval_cc = \ApplicationBundle\Modules\System\MiscActions::resolveApprovalCostCentre($em$doc);
  1353.             $approval_data['projectId'] = $approval_project['id'];
  1354.             $approval_data['projectName'] = $approval_project['name'];
  1355.             $approval_data['costCentreId'] = $approval_cc['id'];
  1356.             $approval_data['costCentreName'] = $approval_cc['name'];
  1357.             $approval_data['relatedDoc'] = strpos($filePath'/') !== false $absoluteUrl $filePath $absoluteUrl "uploads/$fileEntityName/" $filePath;
  1358.             $approval_data['url'] = $absoluteUrl;
  1359.             $approval_data['documentImage'] = GeneralConstant::$Entity_list_details[$entry->getEntity()]['image_url']
  1360.                 ?? $absoluteUrl "app_asset/default_document.svg";
  1361.             $pending_approval_list[] = $approval_data;
  1362.             // Group by entity
  1363.             if (!isset($grouped_approval_list[$entry->getEntity()])) {
  1364.                 $applicableEntities[] = [
  1365.                     'id' => $entry->getEntity(),
  1366.                     'alias' => GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_alias'],
  1367.                     'imageUrl' => GeneralConstant::$Entity_list_details[$entry->getEntity()]['image_url']
  1368.                         ?? 'https://img.freepik.com/free-vector/file-searching-concept-landing-page_52683-18202.jpg',
  1369.                     'documentImage' => GeneralConstant::$Entity_list_details[$entry->getEntity()]['image_url']
  1370.                         ?? $absoluteUrl "app_asset/default_document.svg",
  1371.                     'icon' => GeneralConstant::$Entity_list_details[$entry->getEntity()]['icon']
  1372.                         ?? $absoluteUrl "app_asset/icon/default.svg",
  1373.                     'color' => GeneralConstant::$Entity_list_details[$entry->getEntity()]['color'] ?? '#0000FF'
  1374.                 ];
  1375.                 $grouped_approval_list[$entry->getEntity()] = [];
  1376.             }
  1377.             $grouped_approval_list[$entry->getEntity()][] = $approval_data;
  1378.         }
  1379.         return [
  1380.             "pending_approval_list" => $pending_approval_list,
  1381.             "applicable_entities" => $applicableEntities,
  1382.             "pagination" => [
  1383.                 "current_page" => $page,
  1384.                 "per_page" => $limit,
  1385.                 "total_items" => $total_pending_task_count,
  1386.                 "total_pages" => ceil($total_pending_task_count $limit)
  1387.             ]
  1388.         ];
  1389.     }
  1390.     public static function getMyDocumentListForAppByUserLoginId(
  1391.         $em,
  1392.         $login_id,
  1393.         $absoluteUrl,
  1394.         $includeAbsoluteUrl 0,
  1395.         $absoluteUrlList = [],
  1396.         $tvp '',
  1397.         $filterApprovalEntityId '_all_',
  1398.         $page 1,
  1399.         $limit 10
  1400.     ) {
  1401.         $user_data Users::getUserInfoByLoginId($em$login_id);
  1402.         $pending_approval_list = [];
  1403.         $grouped_approval_list = [];
  1404.         $applicableEntities = [];
  1405.         $total_pending_task_count 0;
  1406.         $generalFilter = ($filterApprovalEntityId == '_all_' || $filterApprovalEntityId == '') ? [] : [
  1407.             'entity' => $filterApprovalEntityId
  1408.         ];
  1409.         // Define reusable role and amount constants
  1410.         $rl_type GeneralConstant::$approvalRole;
  1411.         $amount_methods ApprovalConstant::$Entity_amount_method;
  1412.         $qb $em->createQueryBuilder()
  1413.             ->select('a')
  1414.             ->from('ApplicationBundle\\Entity\\Approval''a')
  1415.             ->where('a.action = :action')
  1416.             //            ->andWhere('a.current = :current')
  1417.             ->setParameter('action'1)
  1418.             //            ->setParameter('current', GeneralConstant::CURRENTLY_PENDING_APPROVAL)
  1419.             ->orderBy('a.createdAt''DESC');
  1420.         if (!empty($generalFilter['entity'])) {
  1421.             $qb->andWhere('a.entity = :entity')->setParameter('entity'$generalFilter['entity']);
  1422.         }
  1423.         $page max(1$page);
  1424.         $limit max(1$limit);
  1425.         $offset = ($page 1) * $limit;
  1426.         $countQb = clone $qb;
  1427.         $countQb->select('COUNT(a.id)');
  1428.         $total_pending_task_count $countQb->getQuery()->getSingleScalarResult();
  1429.         $dt $qb->setFirstResult($offset)->setMaxResults($limit)->getQuery()->getResult();
  1430.         foreach ($dt as $entry) {
  1431.             if (!in_array($user_data['id'], json_decode($entry->getUserIds(), true) ?? [])) {
  1432.                 continue;
  1433.             }
  1434.             $approval_data = [];
  1435.             $approval_data['createdBy'] = '';
  1436.             $approval_data['createdUserImage'] = '';
  1437.             $approval_data['documentHash'] = $entry->getDocumentHash();
  1438.             $approval_data['approvalId'] = $entry->getId();
  1439.             $approval_data['roleType'] = $rl_type[$entry->getRoleType()];
  1440.             $approval_data['roleTypeId'] = $entry->getRoleType();
  1441.             $approval_data['createdAt'] = (int) $entry->getCreatedAt()->format('U');
  1442.             $approval_data['amount'] = '';
  1443.             if ($includeAbsoluteUrl == && isset($absoluteUrlList[$entry->getEntity()])) {
  1444.                 $approval_data['viewPathAbs'] = $absoluteUrlList[$entry->getEntity()] . '/' $entry->getEntityId() . '?tvp=' $tvp;
  1445.             }
  1446.             $approval_data['viewPath'] = GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_view_route_path_name'] ?? '';
  1447.             $approval_data['printPath'] = GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_print_route_path_name'] ?? $approval_data['viewPath'];
  1448.             $approval_data['entityAlias'] = GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_alias'];
  1449.             // Fetch document data
  1450.             $doc $em->getRepository('ApplicationBundle\\Entity\\' GeneralConstant::$Entity_list[$entry->getEntity()])
  1451.                 ->findOneBy([
  1452.                     GeneralConstant::$Entity_id_field_list[$entry->getEntity()] => $entry->getEntityId()
  1453.                 ]);
  1454.             if ($doc) {
  1455.                 if ($doc->getCreatedLoginId() && $doc->getCreatedLoginId() != 0) {
  1456.                     $user_info Users::getUserInfoByLoginId($em$doc->getCreatedLoginId());
  1457.                     $approval_data['createdBy'] = $user_info['name'] ?? '';
  1458.                     $approval_data['createdUserImage'] = $user_info['image'] ?? '';
  1459.                 }
  1460.                 if (isset($amount_methods[$entry->getEntity()])) {
  1461.                     $approval_data['amount'] = $doc->{$amount_methods[$entry->getEntity()]}();
  1462.                 }
  1463.             }
  1464.             $filePath $doc->getFiles();
  1465.             $fileEntityName GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_name'];
  1466.             $approval_data['entity'] = $entry->getEntity();
  1467.             $approval_data['entityId'] = $entry->getEntityId();
  1468.             $approval_data['entityIdPadded'] = str_pad($entry->getEntityId(), 8'0'STR_PAD_LEFT);
  1469.             $approval_data['required'] = $entry->getRequired();
  1470.             // Real "From the document" key-facts for the mobile app (replaces the
  1471.             // Lorem-Ipsum placeholder). See APPROVAL_SUMMARY_FIX.md.
  1472.             $approval_data['summary'] = \ApplicationBundle\Modules\System\MiscActions::buildApprovalSummaryRows(
  1473.                 \ApplicationBundle\Modules\System\MiscActions::resolveApprovalPartyName($em$entry->getEntity(), $doc),
  1474.                 isset($approval_data['amount']) ? $approval_data['amount'] : null,
  1475.                 isset($approval_data['entityIdPadded']) ? $approval_data['entityIdPadded'] : ''
  1476.             );
  1477.             // Project / cost-centre for the mobile grouped-approval view.
  1478.             $approval_project = \ApplicationBundle\Modules\System\MiscActions::resolveApprovalProject($em$doc);
  1479.             $approval_cc = \ApplicationBundle\Modules\System\MiscActions::resolveApprovalCostCentre($em$doc);
  1480.             $approval_data['projectId'] = $approval_project['id'];
  1481.             $approval_data['projectName'] = $approval_project['name'];
  1482.             $approval_data['costCentreId'] = $approval_cc['id'];
  1483.             $approval_data['costCentreName'] = $approval_cc['name'];
  1484.             $approval_data['relatedDoc'] = strpos($filePath'/') !== false $absoluteUrl $filePath $absoluteUrl "uploads/$fileEntityName/" $filePath;
  1485.             $approval_data['url'] = $absoluteUrl;
  1486.             $approval_data['documentImage'] = GeneralConstant::$Entity_list_details[$entry->getEntity()]['image_url']
  1487.                 ?? $absoluteUrl "app_asset/default_document.svg";
  1488.             $pending_approval_list[] = $approval_data;
  1489.             // Group by entity
  1490.             if (!isset($grouped_approval_list[$entry->getEntity()])) {
  1491.                 $applicableEntities[] = [
  1492.                     'id' => $entry->getEntity(),
  1493.                     'alias' => GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_alias'],
  1494.                     'imageUrl' => GeneralConstant::$Entity_list_details[$entry->getEntity()]['image_url']
  1495.                         ?? 'https://img.freepik.com/free-vector/file-searching-concept-landing-page_52683-18202.jpg',
  1496.                     'documentImage' => GeneralConstant::$Entity_list_details[$entry->getEntity()]['image_url']
  1497.                         ?? $absoluteUrl "app_asset/default_document.svg",
  1498.                     'icon' => GeneralConstant::$Entity_list_details[$entry->getEntity()]['icon']
  1499.                         ?? $absoluteUrl "app_asset/icon/default.svg",
  1500.                     'color' => GeneralConstant::$Entity_list_details[$entry->getEntity()]['color'] ?? '#0000FF'
  1501.                 ];
  1502.                 $grouped_approval_list[$entry->getEntity()] = [];
  1503.             }
  1504.             $grouped_approval_list[$entry->getEntity()][] = $approval_data;
  1505.         }
  1506.         return [
  1507.             "document_list" => $pending_approval_list,
  1508.             "applicable_entities" => $applicableEntities,
  1509.             "pagination" => [
  1510.                 "current_page" => $page,
  1511.                 "per_page" => $limit,
  1512.                 "total_items" => $total_pending_task_count,
  1513.                 "total_pages" => ceil($total_pending_task_count $limit)
  1514.             ]
  1515.         ];
  1516.     }
  1517.     //    public static function getPendinDocumentListForAppByUserLoginId($em, $login_id, $includeAbsoluteUrl = 0, $absoluteUrlList = [], $tvp = '', $page = '_UNSET_', $offset = 0, $limit = 9999)
  1518. //    {
  1519. //        $user_data = Users::getUserInfoByLoginId($em, $login_id);
  1520. //        $pending_approval_list = [];
  1521. //        $override_approval_list = [];
  1522. //        $grouped_approval_list = [];
  1523. //        $applicableEntities = [];
  1524. //        $applicableEntitiesDetails = [];
  1525. //        $total_pending_task_count = 0;
  1526. //
  1527. //        if ($page != '_UNSET_')
  1528. //            $offset = ($page - 1) * $limit;
  1529. //
  1530. //        // 1. Get total count (without LIMIT & OFFSET)
  1531. //        $countQueryBuilder = $em->getRepository('ApplicationBundle\\Entity\\Approval')
  1532. //            ->createQueryBuilder('w')
  1533. //            ->select('COUNT(w.id)')
  1534. //            ->where('(w.required =1 and  w.action = 3 and   w.current = 1) or (w.required =0  and    w.action = 3) or (w.required =2   and  w.action = 3)')
  1535. //            ->andWhere('w.current =1')
  1536. //            ->andWhere('w.userIds like  \'%"' . $user_data['id'] . '"%\'');
  1537. //
  1538. //        $totalRecords = (int)$countQueryBuilder->getQuery()->getSingleScalarResult();
  1539. //
  1540. //        // 2. Calculate total pages
  1541. //        $totalPages = $limit > 0 ? ceil($totalRecords / $limit) : 1;
  1542. //        $currentPage = $page != '_UNSET_' ? (int)$page : 1;
  1543. //
  1544. //        // 3. Fetch paginated data
  1545. //        $dt = $em->getRepository('ApplicationBundle\\Entity\\Approval')
  1546. //            ->createQueryBuilder('w')
  1547. //            ->where('(w.required =1 and  w.action = 3 and   w.current = 1) or (w.required =0  and    w.action = 3) or (w.required =2   and  w.action = 3)')
  1548. //            ->andWhere('w.current =1')
  1549. //            ->andWhere('w.userIds like  \'%"' . $user_data['id'] . '"%\'')
  1550. //            ->orderBy('w.createdAt', 'DESC')
  1551. //            ->setFirstResult($offset)
  1552. //            ->setMaxResults($limit)
  1553. //            ->getQuery()
  1554. //            ->getResult();
  1555. //
  1556. //        $rl_type = GeneralConstant::$approvalRole;
  1557. //        $amount_methods = ApprovalConstant::$Entity_amount_method;
  1558. //
  1559. //        foreach ($dt as $entry) {
  1560. //            if (in_array($user_data['id'], json_decode($entry->getUserIds(), true))) {
  1561. //                $approval_data = [];
  1562. //                $approval_data['createdBy'] = '';
  1563. //                $approval_data['createdUserImage'] = '';
  1564. //                $approval_data['documentHash'] = $entry->getDocumentHash();
  1565. //                $approval_data['approvalId'] = $entry->getId();
  1566. //                $approval_data['roleType'] = $rl_type[$entry->getRoleType()];
  1567. //                $approval_data['roleTypeId'] = $entry->getRoleType();
  1568. //                $approval_data['createdAt'] = 1 * $entry->getCreatedAt()->format('U');
  1569. //                $approval_data['amount'] = '';
  1570. //
  1571. //                if ($includeAbsoluteUrl == 1 && isset($absoluteUrlList[$entry->getEntity()])) {
  1572. //                    $approval_data['viewPathAbs'] = $absoluteUrlList[$entry->getEntity()] . '/' . $entry->getEntityId() . '?tvp=' . $tvp;
  1573. //                }
  1574. //
  1575. //                $approval_data['viewPath'] = isset(GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_view_route_path_name']) ? GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_view_route_path_name'] : '';
  1576. //                $approval_data['printPath'] = isset(GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_print_route_path_name']) ? GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_print_route_path_name'] : $approval_data['viewPath'];
  1577. //                $approval_data['entityAlias'] = GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_alias'];
  1578. //
  1579. //                $doc = $em->getRepository('ApplicationBundle\\Entity\\' . GeneralConstant::$Entity_list[$entry->getEntity()])
  1580. //                    ->findOneBy(
  1581. //                        array(
  1582. //                            GeneralConstant::$Entity_id_field_list[$entry->getEntity()] => $entry->getEntityId()
  1583. //                        )
  1584. //                    );
  1585. //
  1586. //                if ($doc) {
  1587. //                    if ($doc->getCreatedLoginId() && $doc->getCreatedLoginId() != 0 && $doc->getCreatedLoginId() != null) {
  1588. //                        $approval_data['createdBy'] = Users::getUserInfoByLoginId($em, $doc->getCreatedLoginId())['name'];
  1589. //                        $approval_data['createdUserImage'] = Users::getUserInfoByLoginId($em, $doc->getCreatedLoginId())['image'];
  1590. //                    }
  1591. //
  1592. //                    if (isset($amount_methods[$entry->getEntity()])) {
  1593. //                        $approval_data['amount'] = $doc->{$amount_methods[$entry->getEntity()]}();
  1594. //                    }
  1595. //                }
  1596. //
  1597. //                $approval_data['entity'] = $entry->getEntity();
  1598. //                $approval_data['entityId'] = $entry->getEntityId();
  1599. //                $approval_data['entityIdPadded'] = str_pad($entry->getEntityId(), 8, '0', STR_PAD_LEFT);
  1600. //                $approval_data['required'] = $entry->getRequired();
  1601. //                $approval_data['summary'] = GeneralConstant::$documentSummaryList;
  1602. //                $approval_data['relatedDoc'] = "";
  1603. //                $approval_data['documentImage'] = isset(GeneralConstant::$Entity_list_details[$entry->getEntity()]['image_url']) ?
  1604. //                    GeneralConstant::$Entity_list_details[$entry->getEntity()]['image_url'] : 'https://img.freepik.com/free-vector/file-searching-concept-landing-page_52683-18202.jpg';
  1605. //
  1606. //                $pending_approval_list[] = $approval_data;
  1607. //
  1608. //                if (!isset($grouped_approval_list[$entry->getEntity()])) {
  1609. //                    $applicableEntities[] = array(
  1610. //                        'id' => $entry->getEntity(),
  1611. //                        'alias' => GeneralConstant::$Entity_list_details[$entry->getEntity()]['entity_alias'],
  1612. //                        'imageUrl' => isset(GeneralConstant::$Entity_list_details[$entry->getEntity()]['image_url']) ?
  1613. //                            GeneralConstant::$Entity_list_details[$entry->getEntity()]['image_url'] : 'https://img.freepik.com/free-vector/file-searching-concept-landing-page_52683-18202.jpg',
  1614. //                        'documentImage' => isset(GeneralConstant::$Entity_list_details[$entry->getEntity()]['image_url']) ?
  1615. //                            GeneralConstant::$Entity_list_details[$entry->getEntity()]['image_url'] : 'https://img.freepik.com/free-vector/file-searching-concept-landing-page_52683-18202.jpg',
  1616. //                        'color' => isset(GeneralConstant::$Entity_list_details[$entry->getEntity()]['color']) ?
  1617. //                            GeneralConstant::$Entity_list_details[$entry->getEntity()]['color'] : '#0000FF'
  1618. //                    );
  1619. //                    $grouped_approval_list[$entry->getEntity()] = array();
  1620. //                }
  1621. //
  1622. //                $grouped_approval_list[$entry->getEntity()][] = $approval_data;
  1623. //                $total_pending_task_count++;
  1624. //            }
  1625. //        }
  1626. //
  1627. //        return array(
  1628. //            "pending_approval_list" => $pending_approval_list,
  1629. //            "applicable_entities" => $applicableEntities,
  1630. //            "pagination" => array(
  1631. //                "total_records" => $totalRecords,
  1632. //                "total_pages" => $totalPages,
  1633. //                "current_page" => $currentPage,
  1634. //                "limit" => $limit,
  1635. //            )
  1636. //        );
  1637. //    }
  1638.     public static function decodeSignature($em$UserId$approveHash$skipSig 0)
  1639.     {
  1640.         //        $masterAction=0;
  1641. //
  1642. //        if ($approveHash=='_eco_')
  1643. //            $masterAction=1;
  1644.         $query_here $em->getRepository('ApplicationBundle\\Entity\\EncryptedSignature')
  1645.             ->findOneBy(
  1646.                 array(
  1647.                     'userId' => $UserId
  1648.                 )
  1649.             );
  1650.         $dt '';
  1651.         if ($query_here) {
  1652.             $dt $query_here->getData();
  1653.             //            return 'mybad';
  1654.         } else {
  1655.             return false;
  1656.         }
  1657.         $iv '1234567812345678';
  1658.         //special use
  1659.         if ($approveHash == '_eco_')
  1660.             $decrypted 'GGYmLRocksLikeABoss'//so that it will be passed on next check
  1661.         else
  1662.             $decrypted openssl_decrypt(base64_decode($dt), "AES-128-CBC"$approveHashOPENSSL_RAW_DATA$iv);
  1663.         //        return $iv;
  1664.         if ($decrypted != false) {
  1665.             //remove the compare code
  1666.             $passed_data '';
  1667.             if (!strpos($decrypted'YmLRocksLikeABoss'))
  1668.                 return false;
  1669.             //                return $decrypted;
  1670.             $passed_data str_replace('YmLRocksLikeABoss'''$decrypted);
  1671.             if ($query_here->getSigExists() == 1) {
  1672.                 $new $em->getRepository('ApplicationBundle\\Entity\\Signature')
  1673.                     ->findOneBy(
  1674.                         array(
  1675.                             'id' => $query_here->getLastDecryptedSigId()
  1676.                         )
  1677.                     );
  1678.                 if ($new) {
  1679.                     return $new->getId();
  1680.                 } else {
  1681.                     $new = new Signature();
  1682.                     $new->setData($passed_data);
  1683.                     $em->persist($new);
  1684.                     $em->flush();
  1685.                     $query_here->setSigExists(1);
  1686.                     $query_here->setLastDecryptedSigId($new->getId());
  1687.                     $em->flush();
  1688.                     return $new->getId();
  1689.                 }
  1690.             } else {
  1691.                 $new = new Signature();
  1692.                 $new->setData($passed_data);
  1693.                 $em->persist($new);
  1694.                 $em->flush();
  1695.                 $query_here->setSigExists(1);
  1696.                 $query_here->setLastDecryptedSigId($new->getId());
  1697.                 $em->flush();
  1698.                 return $new->getId();
  1699.             }
  1700.         }
  1701.         //        return $dt.$approveHash;
  1702.         return $decrypted;
  1703.     }
  1704.     public static function setApprovalInfo($em$options = [], $entity$entity_id$loginId$subcat ''$skipApprovalAction 0$mailModule = [])
  1705.     {
  1706.         if ($subcat !== '')
  1707.             //        if (1)
  1708.             $set $em->getRepository('ApplicationBundle\\Entity\\ApprovalSettings')
  1709.                 ->findBy(
  1710.                     array(
  1711.                         'entity' => $entity,
  1712.                         'entitySub' => $subcat
  1713.                     )
  1714.                 );
  1715.         else
  1716.             $set $em->getRepository('ApplicationBundle\\Entity\\ApprovalSettings')
  1717.                 ->findBy(
  1718.                     array(
  1719.                         'entity' => $entity
  1720.                     )
  1721.                 );
  1722.         $entityClassName GeneralConstant::$Entity_fqcn_by_id[$entity] ?? GeneralConstant::$Entity_list[$entity];
  1723.         $className class_exists($entityClassName)
  1724.             ? $entityClassName
  1725.             'ApplicationBundle\\Entity\\' $entityClassName;
  1726.         $lowest_seq 9999;
  1727.         $lowest_data = [];
  1728.         $doc $em->getRepository($className)
  1729.             ->findOneBy(
  1730.                 array(
  1731.                     GeneralConstant::$Entity_id_field_list[$entity] => $entity_id,
  1732.                 )
  1733.             );
  1734.         $document_hash $doc->getDocumentHash();
  1735.         $auto_created method_exists($doc'getAutoCreated') ? ($doc->getAutoCreated() != 1) : 0;
  1736.         $draftFlag method_exists($doc'getDraftFlag') ? ($doc->getDraftFlag() != 1) : 0;
  1737.         $currentApprovalData = array(
  1738.             'userIdList' => [],
  1739.             'inProcess' => 0
  1740.         );
  1741.         if ($draftFlag == 1)
  1742.             return $currentApprovalData;
  1743.         if ($auto_created == 0) {
  1744.             //1st of all check if already exists and if present remove all approvals which are pending before adding the new ones
  1745.             $qry $em->getRepository('ApplicationBundle\\Entity\\Approval')->findBy(array(
  1746.                 'entity' => $entity,
  1747.                 'entityId' => $entity_id,
  1748.                 'action' => [32]    ///recently changed. was only 3 before
  1749.             ));
  1750.             foreach ($qry as $existing) {
  1751.                 $em->remove($existing);
  1752.             }
  1753.             $em->flush();
  1754.             $curr_user_id Users::getUserFromLogin($em$loginId)['id'];
  1755.             $last_added_user_ids_for_approval = [$curr_user_id];
  1756.             //now add the new ones
  1757.             foreach ($set as $key => $value) {
  1758.                 //            $expire_time=date("Y-m-d", strtotime( date( "Y-m-d", strtotime( date("Y-m-d") ) ) . "-1 month" ) )
  1759.                 $sto $value->getSuccessionTimeout();
  1760.                 $skip 0;
  1761.                 // Conditional approval layers (TODO-C): skip this layer when its
  1762.                 // condition is not met by the document. Fail-safe = include.
  1763.                 if (!ApprovalConditionEvaluator::passes($em$entity$doc$value)) {
  1764.                     continue;
  1765.                 }
  1766.                 $new = new Approval();
  1767.                 $new->setEntity($value->getEntity());
  1768.                 $new->setEntityId($entity_id);
  1769.                 $new->setPositionId($value->getPositionId());
  1770.                 $new->setSequence($value->getSequence());
  1771.                 $new->setSkipPrintFlag($value->getSkipPrintFlag());
  1772.                 $new->setUserAssignType($value->getUserAssignType());
  1773.                 $new->setDocumentHash($document_hash);
  1774.                 //            $new->setUserIds($value->getUserId()); //<-----
  1775.                 $new->setRoleType($value->getRoleType());
  1776.                 $new->setRequired($value->getRequired());
  1777.                 $new->setSuccession($value->getSuccession());
  1778.                 $new->setAction(3); //pending status
  1779.                 $new->setCurrent(GeneralConstant::CURRENTLY_NON_PENDING_APPROVAL);
  1780.                 $new->setSuccessionTimeout($sto);
  1781.                 //now get the user id/s
  1782.                 $assign_type $value->getUserAssignType();
  1783.                 $assign_type_list GeneralConstant::$positionAssignType;
  1784.                 $userList = [];
  1785.                 if ($assign_type_list[$assign_type] == 'position') {
  1786.                     //get users with same positions
  1787.                     $userList Users::UserListByPositionForApprovalAssign(''$value->getPositionId(), $em);
  1788.                     $userList array_diff($userList$last_added_user_ids_for_approval);
  1789.                     $new->setUserIds(json_encode($userList)); //<-----
  1790.                 }
  1791.                 if ($assign_type_list[$assign_type] == 'user') {
  1792.                     //get users with same positions
  1793. //                    $userList = [1 * $value->getUserId()];
  1794.                     $userList explode(','$value->getUserId());
  1795.                     $userList array_diff($userList$last_added_user_ids_for_approval);
  1796.                     $new->setUserIds(json_encode($userList)); //<-----
  1797.                 }
  1798.                 if ($assign_type_list[$assign_type] == 'supervisor' && !empty($last_added_user_ids_for_approval)) {
  1799.                     //get users with same positions
  1800. //                    $userList = Users::UserListBySupervisorForApprovalAssign('', $curr_user_id, $em);
  1801.                     $userList Users::UserListBySupervisorForApprovalAssign(
  1802.                         '',
  1803.                         $last_added_user_ids_for_approval[0],
  1804.                         $em
  1805.                     );
  1806.                     $userList array_diff($userList$last_added_user_ids_for_approval);
  1807.                     $new->setUserIds(json_encode($userList)); //<-----
  1808.                 }
  1809.                 //now lets see if this should be skipped
  1810.                 if ($value->getRequired() != 3) { //we will not skip manual sig
  1811.                     if (in_array($curr_user_id$userList))
  1812.                         $skip 1;
  1813.                     if (empty($userList))
  1814.                         $skip 1;
  1815.                 }
  1816.                 //now flushing
  1817.                 if ($skip == 0) {
  1818.                     $em->persist($new);
  1819.                     $em->flush();
  1820.                     $last_added_user_ids_for_approval $userList;
  1821.                     if ($value->getSequence() < $lowest_seq && in_array($value->getRequired(), [12])) {
  1822.                         $lowest_seq $value->getSequence();
  1823.                         $lowest_data $new;
  1824.                     }
  1825.                 } else
  1826.                     $last_added_user_ids_for_approval = [];
  1827.             }
  1828.         }
  1829.         $fully_approved self::fullyApproved($em$entity$entity_id$skipApprovalAction$mailModule);
  1830.         //now set the lowest sequence as current
  1831.         $currentApprovalData = array(
  1832.             'userIdList' => [],
  1833.             'inProcess' => 1
  1834.         );
  1835.         if ($fully_approved == 0) {
  1836.             $lowest_data->setCurrent(GeneralConstant::CURRENTLY_PENDING_APPROVAL);
  1837.             $sto $lowest_data->getSuccessionTimeout();
  1838.             if ($sto != '' && $sto != null) {
  1839.                 $expire_time = new \DateTimeImmutable();
  1840.                 $expire_time $expire_time->modify('+' $sto ' hour');
  1841.                 $lowest_data->setSuccessionExpire($expire_time);
  1842.             }
  1843.             $em->flush();
  1844.             $currentApprovalData['userIdList'] = json_decode($lowest_data->getUserIds(), true);
  1845.             $notification_enabled 0;
  1846.             $notification_server '';
  1847.             $appId 0;
  1848.             $url '';
  1849.             if (!empty($options)) {
  1850.                 $notification_enabled $options['notification_enabled'];
  1851.                 $notification_server $options['notification_server'];
  1852.                 $appId $options['appId'];
  1853.                 $url $options['url'];
  1854.             }
  1855.             if (!empty($currentApprovalData['UserIdList']) && $notification_enabled == 1)
  1856.                 System::AddNewNotification(
  1857.                     $notification_enabled,
  1858.                     $notification_server,
  1859.                     $appId,
  1860.                     $doc->getCompanyId(),
  1861.                     "Approval: " GeneralConstant::$Entity_list_details[$entity_id]['entity_alias'] . ": " $document_hash " is pending Your approval",
  1862.                     'user',
  1863.                     $currentApprovalData['UserIdList'],
  1864.                     'information',
  1865.                     //                GeneralConstant::$Entity_list_details[$entity_id]."/".$projectId,
  1866.                     $url "/" $entity_id,
  1867.                     "Approval Pending"
  1868.                 );
  1869.         }
  1870.         return $currentApprovalData;
  1871.     }
  1872.     public static function checkIfApprovalExists($em$entity$entity_id$loginId)
  1873.     {
  1874.         $approval_data = array(
  1875.             'exists' => 0,
  1876.             'approvalId' => 0,
  1877.             'roleType' => 0,
  1878.             'required' => 0,
  1879.             'acted' => 0,
  1880.             'entity' => $entity,
  1881.             'entityId' => $entity_id,
  1882.             //            'debug_data'=>[]
  1883.         );
  1884.         ///if the doc is approved then skip everything
  1885.         $qry_array = array(
  1886.             //            'documentHash' => $entity_name,
  1887.             //            'lockFlag' => 1,
  1888.             //            'CompanyId' => $user_data['company']
  1889.         );
  1890.         $entityClassName GeneralConstant::$Entity_fqcn_by_id[$entity] ?? GeneralConstant::$Entity_list[$entity];
  1891.         $className class_exists($entityClassName)
  1892.             ? $entityClassName
  1893.             'ApplicationBundle\\Entity\\' $entityClassName;
  1894.         if ($entity_id != 0) {
  1895.             $qry_array[GeneralConstant::$Entity_id_field_list[$entity]] = $entity_id;
  1896.             //                $qry_array['editFlag'] =[0, null]; //has to be  editable so if non editable or approved then bye bye
  1897.         }
  1898.         $doc $em->getRepository($className)
  1899.             ->findOneBy(
  1900.                 $qry_array
  1901.             );
  1902.         if ($doc) {
  1903.             if ($doc->getApproved() == GeneralConstant::APPROVED) {
  1904.                 //now check if aany pending ones exists as doc is approved
  1905.                 $set $em->getRepository('ApplicationBundle\\Entity\\Approval')
  1906.                     ->findBy(
  1907.                         array(
  1908.                             'entity' => $entity,
  1909.                             'entityId' => $entity_id,
  1910.                             'required' => 0,
  1911.                         )
  1912.                     );
  1913.                 if (!empty($set)) {
  1914.                     $user_data Users::getUserInfoByLoginId($em$loginId);
  1915.                     $userList Users::getUserListById($em$user_data['id']);
  1916.                     foreach ($set as $entry) {
  1917.                         if ($entry->getRoleType() == || $entry->getRoleType() == 2)
  1918.                             continue;
  1919.                         if (in_array($user_data['id'], json_decode($entry->getUserIds(), true) ?? [])) {
  1920.                             $approval_data['exists'] = 1;
  1921.                             $approval_data['approvalId'] = $entry->getId();
  1922.                             $approval_data['roleType'] = $entry->getRoleType();
  1923.                             $approval_data['required'] = $entry->getRequired();
  1924.                             $approval_data['acted'] = 1;
  1925.                             $approval_data['userList'] = $userList;
  1926.                         }
  1927.                     }
  1928.                 }
  1929.                 return $approval_data// doc is approved so who cares!!!
  1930.             }
  1931.             else {
  1932.                 //else!! check for approval
  1933.                 $user_data Users::getUserInfoByLoginId($em$loginId);
  1934.                 $userList Users::getUserListById($em$user_data['id']);
  1935.                 $set $em->getRepository('ApplicationBundle\\Entity\\Approval')
  1936.                     ->findBy(
  1937.                         array(
  1938.                             'entity' => $entity,
  1939.                             'entityId' => $entity_id,
  1940.                         )
  1941.                     );
  1942.                 foreach ($set as $entry) {
  1943.                     if ($entry->getRoleType() == || $entry->getRoleType() == 2)
  1944.                         continue;
  1945.                     if ($entry->getRequired() == || $entry->getRequired() == || $entry->getCurrent() == GeneralConstant::CURRENTLY_PENDING_APPROVAL//override
  1946.                     {
  1947.                         $positionsArray json_decode($entry->getUserIds(), true);
  1948.                         if ($positionsArray == null)
  1949.                             $positionsArray = [];
  1950.                         if (in_array($user_data['id'], $positionsArray)) {
  1951.                             $approval_data['exists'] = 1;
  1952.                             $approval_data['approvalId'] = $entry->getId();
  1953.                             $approval_data['roleType'] = $entry->getRoleType();
  1954.                             $approval_data['required'] = $entry->getRequired();
  1955.                             $approval_data['acted'] = 1;
  1956.                             $approval_data['userList'] = $userList;
  1957.                         }
  1958.                     }
  1959.                     //            else
  1960.                     //            if($entry->getAction()==1)//override
  1961.                     //            {
  1962.                     //                if(in_array($user_data['id'],json_decode($entry->getUserIds())))
  1963.                     //                {
  1964.                     //                    $approval_data['exists']=1;
  1965.                     //                    $approval_data['approvalId']=$entry->getId();
  1966.                     //                    $approval_data['roleType']=$entry->getRoleType();
  1967.                     //                    $approval_data['required']=$entry->getRequired();
  1968.                     //                    $approval_data['acted']=1;
  1969.                     //                }
  1970.                     //            }
  1971.                 }
  1972.                 //        $approval_data['debug_data']=[$set,$user_data];
  1973.                 return $approval_data;
  1974.             }
  1975.         }
  1976.         return $approval_data;
  1977.     }
  1978.     public static function fullyApproved($em$entity$entity_id$skipApprovalAction 0$mailModule = [])
  1979.     {
  1980.         $set $em->getRepository('ApplicationBundle\\Entity\\Approval')
  1981.             ->findBy(
  1982.                 array(
  1983.                     'entity' => $entity,
  1984.                     'entityId' => $entity_id
  1985.                 )
  1986.             );
  1987.         $entityClassName GeneralConstant::$Entity_fqcn_by_id[$entity] ?? GeneralConstant::$Entity_list[$entity];
  1988.         $className class_exists($entityClassName)
  1989.             ? $entityClassName
  1990.             'ApplicationBundle\\Entity\\' $entityClassName;
  1991.         $doc $em->getRepository($className)
  1992.             ->findOneBy(
  1993.                 array(
  1994.                     GeneralConstant::$Entity_id_field_list[$entity] => $entity_id,
  1995.                 )
  1996.             );
  1997.         $auto_created method_exists($doc'getAutoCreated') ? ($doc->getAutoCreated() != 1) : 0;
  1998.         $approved method_exists($doc'getApproved') ? ($doc->getApproved() != 1) : 0;
  1999.         //        if($approved!=GeneralConstant::APPROVAL_STATUS_PENDING) {
  2000.         //            return 0;
  2001.         //        }
  2002.         if ($auto_created == 1) {
  2003.             if ($skipApprovalAction == 0)
  2004.                 self::takeFullApproveActions($em$entity$entity_id$mailModule);
  2005.             return 1;
  2006.         } else {
  2007.             $fully_approved 1;
  2008.             $override 0;
  2009.             foreach ($set as $entry) {
  2010.                 if ($entry->getRequired() == 1//required
  2011.                 {
  2012.                     if ($entry->getAction() == 1)
  2013.                         $fully_approved $fully_approved 1;
  2014.                     else
  2015.                         $fully_approved $fully_approved 0;
  2016.                 }
  2017.                 if ($entry->getRequired() == 2//override
  2018.                 {
  2019.                     if ($entry->getAction() == 1)
  2020.                         $override 1;
  2021.                 }
  2022.             }
  2023.             if ($fully_approved == || $override == 1) {
  2024.                 if ($skipApprovalAction == 0)
  2025.                     self::takeFullApproveActions($em$entity$entity_id$mailModule);
  2026.                 return 1;
  2027.             } else
  2028.                 return 0;
  2029.         }
  2030.     }
  2031.     public static function UpdateSuccession($em)
  2032.     {
  2033.         $set $em->getRepository('ApplicationBundle\\Entity\\Approval')
  2034.             ->findBy(
  2035.                 array(
  2036.                     'current' => GeneralConstant::CURRENTLY_PENDING_APPROVAL,
  2037.                     'succession' => 1
  2038.                 )
  2039.             );
  2040.         $fully_approved 1;
  2041.         $override 0;
  2042.         $changed_data = [];
  2043.         foreach ($set as $entry) {
  2044.             //            $entry->setCurrent(GeneralConstant::CURRENTLY_PENDING_APPROVAL);
  2045.             $sto $entry->getSuccessionTimeout();
  2046.             if ($sto != '' && $sto != null) {
  2047.                 $expire_time $entry->getSuccessionExpire();
  2048.                 $current_time = new \DateTimeImmutable();
  2049.                 if ($expire_time $current_time && $expire_time != null) {
  2050.                     $new_time = new \DateTimeImmutable();
  2051.                     $new_time $new_time->modify('+' $sto ' hour');
  2052.                     $entry->setSuccessionExpire($new_time);
  2053.                     //time is set now lets set the id
  2054.                     $userList Users::UserListBySupervisorForApprovalAssign(''json_decode($entry->getUserIds(), true), $em);
  2055.                     $entry->setUserIds(json_encode($userList)); //<-----
  2056.                     $exp date_format($expire_time"Y/m/d H:i:s");
  2057.                     $changed_data[] = 'Approval Id ' $entry->getDocumentHash() . ' current Time=' $current_time->format('Y-m-d H:i:s') . ' and the expire time was ' $exp .
  2058.                         ' and was changed to ' $new_time->format('Y-m-d H:i:s');
  2059.                 }
  2060.             }
  2061.         }
  2062.         $em->flush();
  2063.         return $changed_data;
  2064.     }
  2065.     public static function approveDocument($em$options = [], $entity$entity_id$approvalId$loginId$approveAction$approveNote$approveHash$url ''$forwardTo ''$mailModule = [])
  2066.     {
  2067.         $user_data Users::getUserInfoByLoginId($em$loginId);
  2068.         $appId $user_data['appId'];
  2069.         $companyId $user_data['companyId'];
  2070.         $dt $em->getRepository('ApplicationBundle\\Entity\\Approval')
  2071.             ->findOneBy(
  2072.                 array(
  2073.                     //                    'entity' => $entity,
  2074.                     //                    'entityId' => $entity_id,
  2075.                     'id' => $approvalId,
  2076.                     'action' => //pending
  2077.                 )
  2078.             );
  2079.         $message = array(
  2080.             'success' => true,
  2081.             'userIdList' => [],
  2082.             'docHash' => '',
  2083.         );
  2084.         if (!$dt) {
  2085.             $message['success'] = false;
  2086.             return $message;
  2087.         }
  2088.         $notification_enabled 0;
  2089.         $notification_server '';
  2090.         //        $appId =0;
  2091.         //        $url = '';
  2092.         if (!empty($options)) {
  2093.             $notification_enabled $options['notification_enabled'];
  2094.             $notification_server $options['notification_server'];
  2095.             //            $appId =$options['appId'];
  2096.             //            $url = $options['url'];
  2097.         }
  2098.         //if its approval decode signature and add it to dbase and pass the id
  2099.         $sigId 0;
  2100.         //        if($approveAction==1)
  2101.         {
  2102.             $sigId self::decodeSignature($em$user_data['id'], $approveHash);
  2103.         }
  2104.         if (!$sigId) {
  2105.             $message['success'] = false;
  2106.             return $message;
  2107.         }
  2108.         //            return $approveHash;
  2109.         //now setting the necessary data
  2110.         if ($approveAction != 3) {
  2111.             $dt->setSigId($sigId);
  2112.             $dt->setLoginId($loginId);
  2113.             $dt->setAction($approveAction);
  2114.             $dt->setNote($approveNote);
  2115.             $dt->setCurrent(GeneralConstant::CURRENTLY_NON_PENDING_APPROVAL);
  2116.             $em->flush();
  2117.             $same_seq_list $em->getRepository('ApplicationBundle\\Entity\\Approval')
  2118.                 ->findBy(
  2119.                     array(
  2120.                         'entity' => $dt->getEntity(),
  2121.                         'entityId' => $dt->getEntityId(),
  2122.                         'sequence' => $dt->getSequence()
  2123.                     )
  2124.                 );
  2125.             foreach ($same_seq_list as $useless_data) {
  2126.                 if ($useless_data->getId() != $approvalId) {
  2127.                     $em->remove($useless_data);
  2128.                     $em->flush();
  2129.                 }
  2130.             }
  2131.         }
  2132.         //now remove similar sequesnce
  2133.         //now check if fully approved
  2134.         //now the action part the prioroty is decline over all then revert and then approve
  2135.         $doc $em->getRepository('ApplicationBundle\\Entity\\' GeneralConstant::$Entity_list[$entity])
  2136.             ->findOneBy(
  2137.                 array(
  2138.                     GeneralConstant::$Entity_id_field_list[$entity] => $entity_id,
  2139.                 )
  2140.             );
  2141.         //        method_exists($doc, 'getAutoCreated');
  2142.         $doc->setEditFlag(0);  //will get locked for edit by default after 1st approval revert will open this again
  2143.         $em->flush();
  2144.         //decline
  2145.         if ($approveAction == 0///if declined
  2146.         {
  2147.             //1st of all you cant decline a doc which is already approved and locked
  2148.             if ($doc->getApproved() == && $doc->getLockFlag() == 1) {
  2149.                 return 0;
  2150.             }
  2151.             //
  2152.             //now notify the created  and edited login id holder that doc is declined
  2153.             {
  2154.                 System::AddNewNotification(
  2155.                     $notification_enabled,
  2156.                     $notification_server,
  2157.                     $appId,
  2158.                     $companyId,
  2159.                     "Your Document " $doc->getDocumentHash() . " Has been Declined By - " $user_data['name'],
  2160.                     'user',
  2161.                     [Users::getUserInfoByLoginId($em$doc->getCreatedLoginId())['id']],
  2162.                     'error',
  2163.                     $url "/" $entity_id,
  2164.                     "Document Declined"
  2165.                 );
  2166.             }
  2167.             if ($doc->getEditedLoginId() != null && $doc->getEditedLoginId() != '') { {
  2168.                     System::AddNewNotification(
  2169.                         $notification_enabled,
  2170.                         $notification_server,
  2171.                         $appId,
  2172.                         $companyId,
  2173.                         "Your Document " $doc->getDocumentHash() . " Has been Declined By - " $user_data['name'],
  2174.                         'user',
  2175.                         [Users::getUserInfoByLoginId($em$doc->getEditedLoginId())['id']],
  2176.                         'error',
  2177.                         $url "/" $entity_id,
  2178.                         "Document Declined"
  2179.                     );
  2180.                 }
  2181.             }
  2182.             //ok if not then remove all other next approvals for it
  2183.             $all_seq_list $em->getRepository('ApplicationBundle\\Entity\\Approval')
  2184.                 ->findBy(
  2185.                     array(
  2186.                         'entity' => $dt->getEntity(),
  2187.                         'entityId' => $dt->getEntityId(),
  2188.                         //                        'sequence' => $dt->getSequence()
  2189.                     )
  2190.                 );
  2191.             foreach ($all_seq_list as $useless_data) {
  2192.                 if ($useless_data->getSequence() > $dt->getSequence()) {
  2193.                     $em->remove($useless_data);
  2194.                     $em->flush();
  2195.                 } else {
  2196.                     System::AddNewNotification(
  2197.                         $notification_enabled,
  2198.                         $notification_server,
  2199.                         $appId,
  2200.                         $companyId,
  2201.                         "The Document " $doc->getDocumentHash() . " Has been Declined By - " $user_data['name'],
  2202.                         'user',
  2203.                         $useless_data->getUserIds(),
  2204.                         'error',
  2205.                         $url "/" $entity_id,
  2206.                         "Document Declined"
  2207.                     );
  2208.                 }
  2209.             }
  2210.             //now take decline action
  2211.             $decline_doc self::takeFullDeclineActions($em$entity$entity_id$mailModule);
  2212.         } else if ($approveAction == 2///if reverted
  2213.         {
  2214.             //1st of all you cant edit a doc which is already approved and locked
  2215.             if ($doc->getApproved() == && $doc->getLockFlag() == 1) {
  2216.                 return 0;
  2217.             }
  2218.             //            //also u cant edit a doc without edit flag
  2219.             //            if($doc->getEditFlag()==0)
  2220.             //            {
  2221.             //                return 0;
  2222.             //            }
  2223.             {
  2224.                 System::AddNewNotification(
  2225.                     $notification_enabled,
  2226.                     $notification_server,
  2227.                     $appId,
  2228.                     $companyId,
  2229.                     "Your Document " $doc->getDocumentHash() . " Has been Reverted For edit By - " $user_data['name'],
  2230.                     'user',
  2231.                     [Users::getUserInfoByLoginId($em$doc->getCreatedLoginId())['id']],
  2232.                     'error',
  2233.                     $url "/" $entity_id,
  2234.                     "Document Reverted"
  2235.                 );
  2236.             }
  2237.             if ($doc->getEditedLoginId() != null && $doc->getEditedLoginId() != '') { {
  2238.                     System::AddNewNotification(
  2239.                         $notification_enabled,
  2240.                         $notification_server,
  2241.                         $appId,
  2242.                         $companyId,
  2243.                         "Your Document " $doc->getDocumentHash() . " Has been Reverted For edit By - " $user_data['name'],
  2244.                         'user',
  2245.                         [Users::getUserInfoByLoginId($em$doc->getEditedLoginId())['id']],
  2246.                         'error',
  2247.                         $url "/" $entity_id,
  2248.                         "Document Reverted"
  2249.                     );
  2250.                 }
  2251.             }
  2252.             $all_seq_list $em->getRepository('ApplicationBundle\\Entity\\Approval')
  2253.                 ->findBy(
  2254.                     array(
  2255.                         'entity' => $dt->getEntity(),
  2256.                         'entityId' => $dt->getEntityId(),
  2257.                         //                        'sequence' => $dt->getSequence()
  2258.                     )
  2259.                 );
  2260.             foreach ($all_seq_list as $useless_data) {
  2261.                 if ($useless_data->getSequence() > $dt->getSequence()) {
  2262.                     $em->remove($useless_data);
  2263.                     $em->flush();
  2264.                 }
  2265.             }
  2266.             //now take revert action
  2267.             $revert_doc self::takeRevertForEditActions($em$entity$entity_id$mailModule);
  2268.         } else if ($approveAction == 3///if forwarded
  2269.         {
  2270.             //1st of all you cant edit a doc which is already approved and locked
  2271.             if ($doc->getApproved() == 1) {
  2272.                 return 0;
  2273.             }
  2274.             //            //also u cant edit a doc without edit flag
  2275.             //            if($doc->getEditFlag()==0)
  2276.             //            {
  2277.             //                return 0;
  2278.             //            }
  2279.             $user_ids json_decode($dt->getUserIds(), true);
  2280.             $new_array = [];
  2281.             if (in_array($user_data['id'], $user_ids)) {
  2282.                 $new_array array_diff($user_ids, [$user_data['id']]);
  2283.                 $new_array[] = $forwardTo;
  2284.                 $dt->setUserIds(json_encode($new_array));
  2285.                 $em->flush();
  2286.                 //                $em->remove($data_to_check);
  2287.             }
  2288.             System::AddNewNotification(
  2289.                 $notification_enabled,
  2290.                 $notification_server,
  2291.                 $appId,
  2292.                 $companyId,
  2293.                 $user_data['name'] . " Has forwarded the Document: " $doc->getDocumentHash() . " To You for Your Approval . ",
  2294.                 'user',
  2295.                 [$forwardTo],
  2296.                 'information',
  2297.                 $url "/" $entity_id,
  2298.                 "Pending Approval"
  2299.             );
  2300.         } else if ($approveAction == 1///if approved
  2301.         {
  2302.             $all_seq_list $em->getRepository('ApplicationBundle\\Entity\\Approval')
  2303.                 ->findBy(
  2304.                     array(
  2305.                         'entity' => $dt->getEntity(),
  2306.                         'entityId' => $dt->getEntityId(),
  2307.                         //                        'sequence' => $dt->getSequence()
  2308.                     )
  2309.                 );
  2310.             foreach ($all_seq_list as $data_to_check) {
  2311.                 $added_next 0;
  2312.                 if ($data_to_check->getSequence() > $dt->getSequence()) {
  2313.                     $user_ids json_decode($data_to_check->getUserIds(), true);
  2314.                     $user_ids is_array($user_ids) ? $user_ids : [];
  2315.                     if (in_array($user_data['id'], $user_ids) && $data_to_check->getRequired() != && $data_to_check->getRequired() != 0// not manual or optional signature
  2316.                     {
  2317.                         $new_array array_diff($user_ids, [$user_data['id']]);
  2318.                         $em->remove($data_to_check);
  2319.                     }
  2320.                     //                        if(empty($new_array)) {
  2321.                     //                            $em->remove($data_to_check);
  2322.                     //                        }
  2323.                     //                        else
  2324.                     //                        {
  2325.                     //                            $data_to_check->setUserIds(json_encode($new_array));
  2326.                     //                        }
  2327.                     $em->flush();
  2328.                 }
  2329.             }
  2330.             $fully_approved self::fullyApproved($em$entity$entity_id0$mailModule);
  2331.             if ($fully_approved) {
  2332.                 //now notify the created  and edited login id holder that doc is declined
  2333.                 {
  2334.                     System::AddNewNotification(
  2335.                         $notification_enabled,
  2336.                         $notification_server,
  2337.                         $appId,
  2338.                         $companyId,
  2339.                         "Your Document " $doc->getDocumentHash() . " Has Been fully Approved",
  2340.                         'user',
  2341.                         [Users::getUserInfoByLoginId($em$doc->getCreatedLoginId())['id']],
  2342.                         'information',
  2343.                         $url "/" $entity_id,
  2344.                         "Document Fully Approved"
  2345.                     );
  2346.                 }
  2347.                 if ($doc->getEditedLoginId() != null && $doc->getEditedLoginId() != '') { {
  2348.                         System::AddNewNotification(
  2349.                             $notification_enabled,
  2350.                             $notification_server,
  2351.                             $appId,
  2352.                             $companyId,
  2353.                             "Your Document " $doc->getDocumentHash() . " Has Been fully Approved.",
  2354.                             'user',
  2355.                             [Users::getUserInfoByLoginId($em$doc->getEditedLoginId())['id']],
  2356.                             'information',
  2357.                             $url "/" $entity_id,
  2358.                             "Document Fully Approved"
  2359.                         );
  2360.                     }
  2361.                 }
  2362.                 //setting the next seq active
  2363.                 $next $em->getRepository('ApplicationBundle\\Entity\\Approval')
  2364.                     ->findBy(
  2365.                         array(
  2366.                             'entity' => $entity,
  2367.                             'entityId' => $entity_id,
  2368.                             'current' => 0,
  2369.                             'action' => [3null],
  2370.                             'required' => [0]
  2371.                         ),
  2372.                         array(
  2373.                             'sequence' => 'ASC',
  2374.                         )
  2375.                     );
  2376.                 if ($next) {
  2377.                     $next[0]->setCurrent(GeneralConstant::CURRENTLY_PENDING_APPROVAL);
  2378.                     if ($next[0]->getSuccession() == 1) {
  2379.                         $sto $next[0]->getSuccessionTimeout();
  2380.                         if ($sto != '' && $sto != null) {
  2381.                             //                            $expire_time = $next[0]->getSuccessionExpire();
  2382.                             $current_time = new \DateTimeImmutable();
  2383.                             $new_time $current_time->modify('+' $sto ' hour');
  2384.                             $next[0]->setSuccessionExpire($new_time);
  2385.                         }
  2386.                     }
  2387.                     System::AddNewNotification(
  2388.                         $notification_enabled,
  2389.                         $notification_server,
  2390.                         $appId,
  2391.                         $companyId,
  2392.                         "" $doc->getDocumentHash() . " Needs Your Approval . ",
  2393.                         'user',
  2394.                         json_decode($next[0]->getUserIds(), true),
  2395.                         'information',
  2396.                         $url "/" $entity_id,
  2397.                         "Pending Approval"
  2398.                     );
  2399.                 }
  2400.                 $em->flush();
  2401.             } else {
  2402.                 //now notify the created  and edited login id holder that doc is declined
  2403.                 {
  2404.                     System::AddNewNotification(
  2405.                         $notification_enabled,
  2406.                         $notification_server,
  2407.                         $appId,
  2408.                         $companyId,
  2409.                         "Your Document " $doc->getDocumentHash() . " Has Passed Approval From - " $user_data['name'],
  2410.                         'user',
  2411.                         [Users::getUserInfoByLoginId($em$doc->getCreatedLoginId())['id']],
  2412.                         'information',
  2413.                         $url "/" $entity_id,
  2414.                         "Document Approved"
  2415.                     );
  2416.                 }
  2417.                 if ($doc->getEditedLoginId() != null && $doc->getEditedLoginId() != '') { {
  2418.                         System::AddNewNotification(
  2419.                             $notification_enabled,
  2420.                             $notification_server,
  2421.                             $appId,
  2422.                             $companyId,
  2423.                             "Your Document " $doc->getDocumentHash() . " Has Passed Approval From - " $user_data['name'],
  2424.                             'user',
  2425.                             [Users::getUserInfoByLoginId($em$doc->getEditedLoginId())['id']],
  2426.                             'information',
  2427.                             $url "/" $entity_id,
  2428.                             "Document Approved"
  2429.                         );
  2430.                     }
  2431.                 }
  2432.                 //setting the next seq active
  2433.                 $next $em->getRepository('ApplicationBundle\\Entity\\Approval')
  2434.                     ->findBy(
  2435.                         array(
  2436.                             'entity' => $entity,
  2437.                             'entityId' => $entity_id,
  2438.                             'current' => 0,
  2439.                             'action' => [3null],
  2440.                             'required' => [12]
  2441.                         ),
  2442.                         array(
  2443.                             'sequence' => 'ASC',
  2444.                         )
  2445.                     );
  2446.                 if ($next) {
  2447.                     $next[0]->setCurrent(GeneralConstant::CURRENTLY_PENDING_APPROVAL);
  2448.                     if ($next[0]->getSuccession() == 1) {
  2449.                         $sto $next[0]->getSuccessionTimeout();
  2450.                         if ($sto != '' && $sto != null) {
  2451.                             //                            $expire_time = $next[0]->getSuccessionExpire();
  2452.                             $current_time = new \DateTimeImmutable();
  2453.                             $new_time $current_time->modify('+' $sto ' hour');
  2454.                             $next[0]->setSuccessionExpire($new_time);
  2455.                         }
  2456.                     }
  2457.                     System::AddNewNotification(
  2458.                         $notification_enabled,
  2459.                         $notification_server,
  2460.                         $appId,
  2461.                         $companyId,
  2462.                         "" $doc->getDocumentHash() . " Needs Your Approval . ",
  2463.                         'user',
  2464.                         json_decode($next[0]->getUserIds(), true),
  2465.                         'information',
  2466.                         $url "/" $entity_id,
  2467.                         "Pending Approval"
  2468.                     );
  2469.                 }
  2470.                 $em->flush();
  2471.             }
  2472.         }
  2473.         return $message;
  2474.     }
  2475.     public static function createEditSignatureHash($em$entity$entity_id$loginId$approveRole$approveHash)
  2476.     {
  2477.         $user_data Users::getUserInfoByLoginId($em$loginId);
  2478.         //if its approval decode signature and add it to dbase and pass the id
  2479.         $sigId 0;
  2480.         if (isset($user_data['id']))
  2481.             $sigId self::decodeSignature($em$user_data['id'], $approveHash);
  2482.         else
  2483.             $sigId null;
  2484.         $doc null;
  2485.         $entityClassName GeneralConstant::$Entity_fqcn_by_id[$entity] ?? GeneralConstant::$Entity_list[$entity];
  2486.         $className class_exists($entityClassName)
  2487.             ? $entityClassName
  2488.             'ApplicationBundle\\Entity\\' $entityClassName;
  2489.         if ($approveRole == 1//created
  2490.         {
  2491.             $doc $em->getRepository($className)
  2492.                 ->findOneBy(
  2493.                     array(
  2494.                         GeneralConstant::$Entity_id_field_list[$entity] => $entity_id,
  2495.                     )
  2496.                 );
  2497.             $doc->setCreatedSigId($sigId);
  2498.             $doc->setCreatedLoginId($loginId);
  2499.             $doc->setCreatedUserId($user_data['id']);
  2500.             $em->flush();
  2501.         }
  2502.         if ($approveRole == 2//edited
  2503.         {
  2504.             $doc $em->getRepository($className)
  2505.                 ->findOneBy(
  2506.                     array(
  2507.                         GeneralConstant::$Entity_id_field_list[$entity] => $entity_id,
  2508.                     )
  2509.                 );
  2510.             $doc->setEditedSigId($sigId);
  2511.             $doc->setEditedLoginId($loginId);
  2512.             $doc->setEditedUserId($user_data['id']);
  2513.             $doc->setLastModifiedDate(new \DateTime());
  2514.             $em->flush();
  2515.         }
  2516.         if (isset($user_data['id']) && $sigId != null) {
  2517.             $new $em->getRepository('ApplicationBundle\\Entity\\Approval')
  2518.                 ->findOneBy(
  2519.                     array(
  2520.                         'roleType' => $approveRole,
  2521.                         'entity' => $entity,
  2522.                         'entityId' => $entity_id,
  2523.                     )
  2524.                 );
  2525.             if (!$new)
  2526.                 $new = new Approval();
  2527.             $new->setEntity($entity);
  2528.             $new->setEntityId($entity_id);
  2529.             $new->setPositionId(null);
  2530.             $new->setSequence(0);
  2531.             $new->setSkipPrintFlag(0);
  2532.             $new->setUserAssignType(1);
  2533.             $new->setDocumentHash($doc->getDocumentHash());
  2534.             //            $new->setUserIds($value->getUserId()); //<-----
  2535.             $new->setRoleType($approveRole);
  2536.             $new->setRequired(0);
  2537.             $new->setSuccession(0);
  2538.             $new->setAction(1); //pending status
  2539.             $new->setLoginId($loginId); //pending status
  2540.             $new->setCurrent(GeneralConstant::CURRENTLY_NON_PENDING_APPROVAL);
  2541.             $new->setSuccessionTimeout(0);
  2542.             $new->setSigId($sigId);
  2543.             $new->setNote('');
  2544.             $new->setUserIds(json_encode([$user_data['id']])); //<-----
  2545.             $em->persist($new);
  2546.             $em->flush();
  2547.             return 1;
  2548.         }
  2549.         //now setting the necessary data
  2550.         return 0;
  2551.     }
  2552.     public static function getSignatureListForDocumentPrint($em$entity$entity_id)
  2553.     {
  2554.         //getting authorization lists
  2555.         $authorizations = [];
  2556.         $doc $em->getRepository(isset(GeneralConstant::$Entity_fqcn_by_id[$entity]) ? GeneralConstant::$Entity_fqcn_by_id[$entity] : ('ApplicationBundle\\Entity\\' GeneralConstant::$Entity_list[$entity]))
  2557.             ->findOneBy(
  2558.                 array(
  2559.                     GeneralConstant::$Entity_id_field_list[$entity] => $entity_id,
  2560.                 )
  2561.             );
  2562.         $apps $em
  2563.             ->getRepository('ApplicationBundle\\Entity\\Approval')
  2564.             ->findBy(
  2565.                 array(
  2566.                     'entity' => $entity,
  2567.                     'entityId' => $entity_id,
  2568.                 ),
  2569.                 array(
  2570.                     'sequence' => 'ASC',
  2571.                 )
  2572.             );
  2573.         $approvalRoles GeneralConstant::$approvalRoleForPrint;
  2574.         //now add additional roles form dbase
  2575.         $addRoles $em->getRepository('ApplicationBundle\\Entity\\ApprovalRole')
  2576.             ->findBy(
  2577.                 array( //                    'id' => $v->getSigId()
  2578.                 )
  2579.             );
  2580.         foreach ($addRoles as $addRole) {
  2581.             $approvalRoles[$addRole->getIndexId()] = $addRole->getPrintString();
  2582.         }
  2583.         //first the create edit sig
  2584.         {
  2585.             if ($doc->getCreatedLoginId() && $doc->getCreatedLoginId() != && $doc->getCreatedLoginId() != null) {
  2586.                 $user Users::getUserInfoByLoginId($em$doc->getCreatedLoginId());
  2587.                 $sig $em->getRepository('ApplicationBundle\\Entity\\Signature')
  2588.                     ->findOneBy(
  2589.                         array(
  2590.                             'id' => $doc->getCreatedSigId()
  2591.                         )
  2592.                     );
  2593.                 $q = array(
  2594.                     'name' => $user['name'],
  2595.                     'designation' => in_array($user['manualDepartment'], [null' ''']) ? $user['positions'] : $user['manualDepartment'],
  2596.                     'auth_type' => $approvalRoles[1],
  2597.                     'auth' => 1,
  2598.                     'signature' => $sig $sig->getData() : ""
  2599.                 );
  2600.                 $authorizations[] = $q;
  2601.             }
  2602.             if ($doc->getEditedLoginId() && $doc->getEditedSigId() != null && $doc->getCreatedLoginId() != 0) {
  2603.                 $user Users::getUserInfoByLoginId($em$doc->getEditedLoginId());
  2604.                 $sig $em->getRepository('ApplicationBundle\\Entity\\Signature')
  2605.                     ->findOneBy(
  2606.                         array(
  2607.                             'id' => $doc->getEditedSigId()
  2608.                         )
  2609.                     );
  2610.                 $q = array(
  2611.                     'name' => $user['name'],
  2612.                     'designation' => in_array($user['manualDepartment'], [null' ''']) ? $user['positions'] : $user['manualDepartment'],
  2613.                     'auth_type' => $approvalRoles[2],
  2614.                     'auth' => 1,
  2615.                     'signature' => $sig $sig->getData() : ""
  2616.                 );
  2617.                 $authorizations[] = $q;
  2618.             }
  2619.         }
  2620.         foreach ($apps as $v) {
  2621.             if ($v->getSkipPrintFlag() == 1)
  2622.                 continue;
  2623.             if ($v->getRoleType() == || $v->getRoleType() == 2)
  2624.                 continue;
  2625.             if ($v->getAction() == GeneralConstant::APPROVED) {
  2626.                 $user Users::getUserInfoByLoginId($em$v->getLoginId());
  2627.                 $sig $em->getRepository('ApplicationBundle\\Entity\\Signature')
  2628.                     ->findOneBy(
  2629.                         array(
  2630.                             'id' => $v->getSigId()
  2631.                         )
  2632.                     );
  2633.                 $q = array(
  2634.                     'name' => $user['name'],
  2635.                     'designation' => in_array($user['manualDepartment'], [null' ''']) ? $user['positions'] : $user['manualDepartment'],
  2636.                     'auth_type' => $approvalRoles[$v->getRoleType()],
  2637.                     'auth' => 1,
  2638.                     'signature' => $sig $sig->getData() : ""
  2639.                 );
  2640.                 $authorizations[] = $q;
  2641.             } else {
  2642.                 $q = array(
  2643.                     'name' => '',
  2644.                     'designation' => '',
  2645.                     'auth_type' => $approvalRoles[$v->getRoleType()],
  2646.                     'auth' => in_array($v->getRequired(), [03]) ? 0,
  2647.                     'signature' => '/uploads/Signature/pending.jpg'
  2648.                 );
  2649.                 $authorizations[] = $q;
  2650.             }
  2651.         }
  2652.         return $authorizations;
  2653.     }
  2654.     public static function getDocumentLog($em$entity$entity_id$CreatedloginId 0$EditedloginId 0)
  2655.     {
  2656.         $entityClassName GeneralConstant::$Entity_fqcn_by_id[$entity] ?? GeneralConstant::$Entity_list[$entity];
  2657.         $className class_exists($entityClassName)
  2658.             ? $entityClassName
  2659.             'ApplicationBundle\\Entity\\' $entityClassName;
  2660.         $doc $em->getRepository($className)
  2661.             ->findOneBy(
  2662.                 array(
  2663.                     GeneralConstant::$Entity_id_field_list[$entity] => $entity_id,
  2664.                 )
  2665.             );
  2666.         if(!$doc)
  2667.             return array(
  2668.                 'log_data' => [],
  2669.                 'pending_data' => [],
  2670.                 'remaining_data' => [],
  2671.                 'created_data' => [],
  2672.                 'edited_data' => [],
  2673.                 'set' => [],
  2674.                 'docHash' => ''
  2675.             );
  2676.         $set $em->getRepository('ApplicationBundle\\Entity\\Approval')
  2677.             ->findBy(
  2678.                 array(
  2679.                     'entity' => $entity,
  2680.                     'entityId' => $entity_id,
  2681.                 )
  2682.             );
  2683.         $roleType GeneralConstant::$approvalRole;
  2684.         //        $approvalRoles=GeneralConstant::$approvalRoleForPrint;
  2685.         //now add additional roles form dbase
  2686.         $addRoles $em->getRepository('ApplicationBundle\\Entity\\ApprovalRole')
  2687.             ->findBy(
  2688.                 array( //                    'id' => $v->getSigId()
  2689.                 )
  2690.             );
  2691.         foreach ($addRoles as $addRole) {
  2692.             $roleType[$addRole->getIndexId()] = $addRole->getName();
  2693.         }
  2694.         $log_data = [];
  2695.         $pending_data = [];
  2696.         $remaining_data = [];
  2697.         $created_data = [];
  2698.         $created_data['dt'] = [];
  2699.         $edited_data = [];
  2700.         $edited_data['dt'] = [];
  2701.         if ($doc->getCreatedLoginId() && $doc->getCreatedLoginId() != && $doc->getCreatedLoginId() != null)
  2702.             $created_data['dt'][] = array(
  2703.                 'user_data' => Users::getUserInfoByLoginId($em$doc->getCreatedLoginId()),
  2704.                 'action' => 1,
  2705.                 'date' => $doc->getCreatedAt()
  2706.             );
  2707.         if ($doc->getEditedLoginId() != null && $doc->getEditedLoginId() != 0)
  2708.             $edited_data['dt'][] = array(
  2709.                 'user_data' => Users::getUserInfoByLoginId($em$doc->getEditedLoginId()),
  2710.                 'action' => 1,
  2711.                 'date' => $doc->getLastModifiedDate()
  2712.             );
  2713.         //        $remaining_data=[];
  2714.         foreach ($roleType as $key => $value) {
  2715.             $log_data[$key] = array(
  2716.                 'role_name' => $value,
  2717.                 'dt' => []
  2718.             );
  2719.         }
  2720.         foreach ($set as $entry) {
  2721.             if ($entry->getRoleType() == || $entry->getRoleType() == 2)
  2722.                 continue;
  2723.             if ($entry->getAction() != && $entry->getCurrent() == GeneralConstant::CURRENTLY_NON_PENDING_APPROVAL) {
  2724.                 $log_data[$entry->getRoleType()]['dt'][] = array(
  2725.                     'user_data' => Users::getUserInfoByLoginId($em$entry->getLoginId()),
  2726.                     'action' => GeneralConstant::$approvalAction[$entry->getAction()] ?? 'unknown',
  2727.                     'actionId' => $entry->getAction(),
  2728.                     'actionColTag' => GeneralConstant::$approvalColorTag[$entry->getAction()] ?? 'orange',
  2729.                     'note' => $entry->getNote()
  2730.                 );
  2731.             }
  2732.             if ($entry->getAction() == && $entry->getCurrent() == GeneralConstant::CURRENTLY_PENDING_APPROVAL) {
  2733.                 $theUserIds json_decode($entry->getUserIds(), true);
  2734.                 if ($theUserIds == null)
  2735.                     $theUserIds = [];
  2736.                 foreach ($theUserIds as $item)
  2737.                     if ($item != null)
  2738.                         $pending_data['dt'][] = array(
  2739.                             'user_data' => Users::getUserInfoByUserId($em$item)
  2740.                         );
  2741.             }
  2742.             if ($entry->getAction() == && $entry->getCurrent() == GeneralConstant::CURRENTLY_NON_PENDING_APPROVAL) {
  2743.                 $theUserIds json_decode($entry->getUserIds(), true);
  2744.                 if ($theUserIds == null)
  2745.                     $theUserIds = [];
  2746.                 foreach ($theUserIds as $item)
  2747.                     $remaining_data['dt'][] = array(
  2748.                         'user_data' => Users::getUserInfoByUserId($em$item)
  2749.                     );
  2750.             }
  2751.         }
  2752.         return array(
  2753.             'log_data' => $log_data,
  2754.             'pending_data' => $pending_data,
  2755.             'remaining_data' => $remaining_data,
  2756.             'created_data' => $created_data,
  2757.             'edited_data' => $edited_data,
  2758.             'set' => $set,
  2759.             'docHash' => $doc->getDocumentHash()
  2760.         );
  2761.     }
  2762.     public static function takeFullApproveActions($em$entity$entity_id$mailModule = [])
  2763.     {
  2764.         $entityClassName GeneralConstant::$Entity_fqcn_by_id[$entity] ?? GeneralConstant::$Entity_list[$entity];
  2765.         $className class_exists($entityClassName)
  2766.             ? $entityClassName
  2767.             'ApplicationBundle\\Entity\\' $entityClassName;
  2768.         $doc $em->getRepository($className)
  2769.             ->findOneBy(
  2770.                 array(
  2771.                     GeneralConstant::$Entity_id_field_list[$entity] => $entity_id,
  2772.                 )
  2773.             );
  2774.         $doc->setEditFlag(0);
  2775.         $em->flush();
  2776.         if ($doc->getApproved() == 1) {
  2777.         } else {
  2778.             $doc->setApproved(1);
  2779.             $em->flush();
  2780.             $all_seq_list $em->getRepository('ApplicationBundle\\Entity\\Approval')
  2781.                 ->findBy(
  2782.                     array(
  2783.                         'entity' => $entity,
  2784.                         'entityId' => $entity_id,
  2785.                         //                        'sequence' => $dt->getSequence()
  2786.                     )
  2787.                 );
  2788.             foreach ($all_seq_list as $useless_data) {
  2789.                 if (!in_array($useless_data->getRequired(), [03])) { //not manual sig
  2790.                     if ($useless_data->getAction() != 1) {
  2791.                         $em->remove($useless_data);
  2792.                         $em->flush();
  2793.                     }
  2794.                 }
  2795.             }
  2796.             //now calling necessary function
  2797.             $funcname GeneralConstant::$Entity_list[$entity];
  2798.             $approvalLog = new EntityApprovalActionLog();
  2799.             $approvalLog->setEntity($entity);
  2800.             $approvalLog->setEntityId($entity_id);
  2801.             $approvalLog->setDocumentHash($doc->getDocumentHash());
  2802.             $approvalLog->setApprovalActionStatus(2);  //started
  2803.             $em->persist($approvalLog);
  2804.             $em->flush();
  2805.             // Guard: an entity may be registered for approval (entries created via
  2806.             // setApprovalInfo) without a post-approval apply hook (e.g. LoanAccount,
  2807.             // where side effects happen at creation). Without this check the dynamic
  2808.             // static call fatals on "undefined method". Missing hook = safe no-op.
  2809.             if (method_exists(ApprovalFunction::class, $funcname)) {
  2810.                 ApprovalFunction::$funcname($em$entity_id$mailModule);
  2811.             }
  2812.             $approvalLog->setApprovalActionStatus(1);  //completed
  2813.             $em->flush();
  2814.         }
  2815.         return 1;
  2816.     }
  2817.     public static function takeFullDeclineActions($em$entity$entity_id$mailModule = [])
  2818.     {
  2819.         $entityClassName GeneralConstant::$Entity_fqcn_by_id[$entity] ?? GeneralConstant::$Entity_list[$entity];
  2820.         $className class_exists($entityClassName)
  2821.             ? $entityClassName
  2822.             'ApplicationBundle\\Entity\\' $entityClassName;
  2823.         $doc $em->getRepository($className)
  2824.             ->findOneBy(
  2825.                 array(
  2826.                     GeneralConstant::$Entity_id_field_list[$entity] => $entity_id,
  2827.                 )
  2828.             );
  2829.         $doc->setApproved(0);
  2830.         $doc->setEditFlag(0);
  2831.         $doc->setLockFlag(1);
  2832.         $doc->setDisabledFlag(1);
  2833.         $em->flush();
  2834.         //now calling necessary function
  2835.         $funcname GeneralConstant::$Entity_list[$entity];
  2836.         DeclineFunction::$funcname($em$entity_id);
  2837.         return 1;
  2838.     }
  2839.     public static function takeRevertForEditActions($em$entity$entity_id$mailModule = [])
  2840.     {
  2841.         $entityClassName GeneralConstant::$Entity_fqcn_by_id[$entity] ?? GeneralConstant::$Entity_list[$entity];
  2842.         $className class_exists($entityClassName)
  2843.             ? $entityClassName
  2844.             'ApplicationBundle\\Entity\\' $entityClassName;
  2845.         $doc $em->getRepository($className)
  2846.             ->findOneBy(
  2847.                 array(
  2848.                     GeneralConstant::$Entity_id_field_list[$entity] => $entity_id,
  2849.                 )
  2850.             );
  2851.         $doc->setApproved(2);
  2852.         $doc->setEditFlag(1);
  2853.         $doc->setLockFlag(0);
  2854.         $doc->setDisabledFlag(0);
  2855.         $em->flush();
  2856.         //now calling necessary function
  2857.         $funcname GeneralConstant::$Entity_list[$entity];
  2858.         RevertFunction::$funcname($em$entity_id);
  2859.         return 1;
  2860.     }
  2861.     public static function getCompanyList($em)
  2862.     {
  2863.         $list = array();
  2864.         $companies $em->getRepository('ApplicationBundle\\Entity\\Company')->findBy(array(
  2865.             'active' => GeneralConstant::ACTIVE
  2866.         ));
  2867.         foreach ($companies as $company) {
  2868.             $list[$company->getId()] = $company->getName();
  2869.         }
  2870.         return $list;
  2871.     }
  2872.     public static function UpdatePostDatedTransaction($em)
  2873.     {
  2874.         //1st check if a job is active
  2875.         $company $em->getRepository('ApplicationBundle\\Entity\\Company')->findOneBy(array(
  2876.             'id' => 1
  2877.         ));
  2878.         if ($company) {
  2879.             if ($company->getPostDatedJobActive() == 1)
  2880.                 return 0//dont interrupt
  2881.             else {
  2882.                 $company->setPostDatedJobActive(1);
  2883.                 $em->flush();
  2884.             }
  2885.         }
  2886.         /// ok get the trans
  2887.         //pi
  2888.         //        $Transactions=$em->getRepository('ApplicationBundle\\Entity\\PurchaseInvoice')->findBy(array(
  2889.         //            'approved'=>1,
  2890.         //            'ledgerHit'=>0
  2891.         //        ));
  2892.         //        foreach($Transactions as $Transaction)
  2893.         //        {
  2894.         //            ApprovalFunction::PurchaseInvoice($em,$Transaction->getPurchaseInvoiceId());
  2895.         //
  2896.         //
  2897.         //
  2898.         //        }
  2899.         //        //si
  2900.         //        $Transactions=$em->getRepository('ApplicationBundle\\Entity\\SalesInvoice')->findBy(array(
  2901.         //            'approved'=>1,
  2902.         //            'ledgerHit'=>0
  2903.         //        ));
  2904.         //        foreach($Transactions as $Transaction)
  2905.         //        {
  2906.         //            ApprovalFunction::SalesInvoice($em,$Transaction->getSalesInvoiceId());
  2907.         //
  2908.         //
  2909.         //
  2910.         //        }
  2911.         $noticeList $em->getRepository('ApplicationBundle\\Entity\\SystemNotice')->findBy(array(
  2912.             //            'enabled'=>GeneralConstant::ACTIVE,
  2913.             //            'showAsNotification'=>GeneralConstant::ACTIVE,
  2914.             //            'CompanyId'=>1,
  2915.             //            'appId'=>$session->get(UserConstants::USER_COMPANY_ID),
  2916.         ));
  2917.         foreach ($noticeList as $notice) {
  2918.             $em->remove($notice);
  2919.             $em->flush();
  2920.         }
  2921.         $notice = new SystemNotice();
  2922.         $notice->setEnabled(1);
  2923.         $notice->setShowAsNotification(1);
  2924.         $notice->setDesc("Ledger Refreshing is Active. Until This is done, The Ledgers may not show Correct Data");
  2925.         $em->persist($notice);
  2926.         $em->flush();
  2927.         $Transactions $em->getRepository('ApplicationBundle\\Entity\\AccTransactions')->findBy(
  2928.             array(
  2929.                 'approved' => 1,
  2930.                 'ledgerHit' => 0
  2931.             ),
  2932.             [],
  2933.             1
  2934.         );
  2935.         foreach ($Transactions as $Transaction) {
  2936.             $partNotice = new SystemNotice();
  2937.             $partNotice->setEnabled(1);
  2938.             $partNotice->setShowAsNotification(1);
  2939.             $partNotice->setDesc("Currently Completing Tasks on Voucher" $Transaction->getDocumentHash());
  2940.             $em->persist($partNotice);
  2941.             $em->flush();
  2942.             ApprovalFunction::AccTransactions($em$Transaction->getTransactionId());
  2943.             $em->remove($partNotice);
  2944.             $em->flush();
  2945.         }
  2946.         //
  2947.         //        $Transactions=$em->getRepository('ApplicationBundle\\Entity\\PurchaseRequisition')->findBy(array(
  2948.         //            'approved'=>3,
  2949.         //            'purchaseRequisitionId'=>[40,41,42,43,44,45,46,47,48,49,50,51,52]
  2950.         ////            'ledgerHit'=>0
  2951.         //        ));
  2952.         //        foreach($Transactions as $Transaction)
  2953.         //        {
  2954.         ////            $partNotice =new SystemNotice();
  2955.         ////            $partNotice->setEnabled(1);
  2956.         ////            $partNotice->setShowAsNotification(1);
  2957.         ////            $partNotice->setDesc("Currently Completing Tasks on Voucher".$Transaction->getDocumentHash());
  2958.         ////            $em->persist($partNotice);
  2959.         ////            $em->flush();
  2960.         //
  2961.         //            ApprovalFunction::PurchaseRequisition($em,$Transaction->getPurchaseRequisitionId());
  2962.         //            $Transaction->setApproved(1);
  2963.         ////            $em->remove($partNotice);
  2964.         //            $em->flush();
  2965.         //
  2966.         //
  2967.         //
  2968.         //        }
  2969.         //        $Transactions=$em->getRepository('ApplicationBundle\\Entity\\Grn')->findBy(array(
  2970.         //            'approved'=>1,
  2971.         //            'ledgerHit'=>0
  2972.         //        ));
  2973.         //        foreach($Transactions as $Transaction)
  2974.         //        {
  2975.         //            ApprovalFunction::Grn($em,$Transaction->getGrnId());
  2976.         //
  2977.         //
  2978.         //
  2979.         //        }
  2980.         //
  2981.         //        $Transactions=$em->getRepository('ApplicationBundle\\Entity\\PurchaseInvoice')->findBy(array(
  2982.         //            'approved'=>1,
  2983.         //            'firstHit'=>0
  2984.         //        ));
  2985.         //        foreach($Transactions as $Transaction)
  2986.         //        {
  2987.         //            $partNotice =new SystemNotice();
  2988.         //            $partNotice->setEnabled(1);
  2989.         //            $partNotice->setShowAsNotification(1);
  2990.         //            $partNotice->setDesc("Currently Completing Tasks on Purchase Bill".$Transaction->getDocumentHash());
  2991.         //            $em->persist($partNotice);
  2992.         //            $em->flush();
  2993.         //
  2994.         //            Accounts::modifyAdvanceAndDuePurchaseInvoice($em,$Transaction->getPurchaseInvoiceId());
  2995.         //            $em->remove($partNotice);
  2996.         //            $em->flush();
  2997.         //
  2998.         //
  2999.         //
  3000.         //
  3001.         //        }
  3002.         //
  3003.         //        $Transactions=$em->getRepository('ApplicationBundle\\Entity\\SalesInvoice')->findBy(array(
  3004.         //            'approved'=>1,
  3005.         //            'firstHit'=>0
  3006.         //        ));
  3007.         //        foreach($Transactions as $Transaction)
  3008.         //        {
  3009.         //
  3010.         //            $partNotice =new SystemNotice();
  3011.         //            $partNotice->setEnabled(1);
  3012.         //            $partNotice->setShowAsNotification(1);
  3013.         //            $partNotice->setDesc("Currently Completing Tasks on Purchase Bill".$Transaction->getDocumentHash());
  3014.         //            $em->persist($partNotice);
  3015.         //            $em->flush();
  3016.         //
  3017.         //            Accounts::modifyAdvanceAndDueSalesInvoice($em,$Transaction->getSalesInvoiceId());
  3018.         //            $em->remove($partNotice);
  3019.         //            $em->flush();
  3020.         //
  3021.         //
  3022.         //
  3023.         //        }
  3024.         //
  3025.         //
  3026.         //            $invoices=$em->getRepository('ApplicationBundle\\Entity\\PurchaseInvoice')->findBy(array(
  3027.         //                'approved'=>1,
  3028.         //                'firstHit'=>1,
  3029.         //                'ledgerHit'=>1,
  3030.         //            ));
  3031.         //
  3032.         //
  3033.         //
  3034.         //            foreach($invoices as $invoice)
  3035.         //            {
  3036.         //                $advance_adjusted_amount=0;
  3037.         //                $invoice_advance_amount=$invoice->getAdvanceAmount();
  3038.         //                $voucherList=json_decode($invoice->getVoucherIds(),true);
  3039.         //                $partNotice =new SystemNotice();
  3040.         //                $partNotice->setEnabled(1);
  3041.         //                $partNotice->setShowAsNotification(1);
  3042.         //                $partNotice->setDesc("Currently Completing Tasks on Purchase Bill".$invoice->getDocumentHash());
  3043.         //                $em->persist($partNotice);
  3044.         //                $em->flush();
  3045.         //                $supp=$em->getRepository('ApplicationBundle\\Entity\\AccSuppliers')->findOneBy(array(
  3046.         //                    'supplierId'=>$invoice->getSupplierId(),
  3047.         //
  3048.         //                ));
  3049.         //
  3050.         //
  3051.         //                if($voucherList!=null)
  3052.         //                {
  3053.         //                    $voucherDetails=$em->getRepository('ApplicationBundle\\Entity\\AccTransactionDetails')->findBy(array(
  3054.         //
  3055.         //                        'transactionId'=>$voucherList,
  3056.         //                        'accountsHeadId'=>$supp->getAdvanceHeadId()
  3057.         //                    ));
  3058.         //                    foreach($voucherDetails as $vdet)
  3059.         //                    {
  3060.         //                        if($vdet->getPosition()==AccountsConstant::CREDIT)
  3061.         //                        $advance_adjusted_amount+=$vdet->getAmount();
  3062.         //                        else
  3063.         //                            $advance_adjusted_amount-=$vdet->getAmount();
  3064.         //
  3065.         //                    }
  3066.         //                }
  3067.         //
  3068.         //                if($advance_adjusted_amount!=$invoice_advance_amount)
  3069.         //                {
  3070.         //                    //place adjusting entry
  3071.         //                    if ($invoice_advance_amount- $advance_adjusted_amount != 0) {
  3072.         //                        $adjusting_amount=$invoice_advance_amount- $advance_adjusted_amount;
  3073.         //                        $TransID = Accounts::CreateNewTransaction(0,
  3074.         //                            $em,
  3075.         //                            $invoice->getPurchaseInvoiceDate()->format('Y-m-d'),
  3076.         //                            $adjusting_amount>0?$adjusting_amount:(-1)*$adjusting_amount,
  3077.         //                            AccountsConstant::VOUCHER_JOURNAL,
  3078.         //                            'Journal For Advance balancing for Purchase Invoice ' . $invoice->getDocumentHash(),
  3079.         //                            'JV/GN/1/' . Accounts::GetVNoHash($em,'JV', 'GN', $invoice->getProjectId()),
  3080.         //                            'JV',
  3081.         //                            'GN',
  3082.         //                            $invoice->getProjectId(),
  3083.         //                            Accounts::GetVNoHash($em,'JV', 'GN', $invoice->getProjectId()),
  3084.         //                            0,
  3085.         //                            $invoice->getCreatedLoginId(),
  3086.         //                            $invoice->getCompanyId(),
  3087.         //                            '',
  3088.         //                            0,
  3089.         //                            1
  3090.         //
  3091.         //                        );
  3092.         //
  3093.         //                        $curr_v_ids=json_decode($invoice->getVoucherIds(),true);
  3094.         //                        if($curr_v_ids!=null)
  3095.         //                            $invoice->setVoucherIds(json_encode(array_merge($curr_v_ids,array_diff( [$TransID],$curr_v_ids))));
  3096.         //                        else
  3097.         //                            $invoice->setVoucherIds(json_encode([$TransID]));
  3098.         //
  3099.         //                        $em->flush();
  3100.         //
  3101.         //
  3102.         //                        Accounts::CreateNewTransactionDetails($em,
  3103.         //                            '',
  3104.         //                            $TransID,
  3105.         //                            Generic::CurrToInt($adjusting_amount),
  3106.         //                            $supp->getAccountsHeadId(),
  3107.         //                            'Generated for supplier head balance For advance',
  3108.         //                            AccountsConstant::DEBIT,
  3109.         //                            0,
  3110.         //                            [],
  3111.         //                            [],
  3112.         //                            $invoice->getCreatedLoginId()
  3113.         //                        );
  3114.         //                        Accounts::CreateNewTransactionDetails($em,
  3115.         //                            '',
  3116.         //                            $TransID,
  3117.         //                            Generic::CurrToInt($adjusting_amount),
  3118.         //                            $supp->getAdvanceHeadId(),
  3119.         //                            'supplier Advance Balancing ',
  3120.         //                            AccountsConstant::CREDIT,
  3121.         //                            0,
  3122.         //                            [],
  3123.         //                            [],
  3124.         //                            $invoice->getCreatedLoginId()
  3125.         //                        );
  3126.         //                        System::UpdatePostDatedTransactionById($em,$TransID);
  3127.         //
  3128.         //
  3129.         //                    }
  3130.         //
  3131.         //
  3132.         //                }
  3133.         //
  3134.         //                $em->remove($partNotice);
  3135.         //                $em->flush();
  3136.         //
  3137.         //
  3138.         //            }
  3139.         //
  3140.         //        //now SI
  3141.         //        $invoices=$em->getRepository('ApplicationBundle\\Entity\\SalesInvoice')->findBy(array(
  3142.         //            'approved'=>1,
  3143.         //            'firstHit'=>1,
  3144.         //            'ledgerHit'=>1,
  3145.         //        ));
  3146.         //
  3147.         //
  3148.         //
  3149.         //        foreach($invoices as $invoice)
  3150.         //        {
  3151.         //            $advance_adjusted_amount=0;
  3152.         //            $invoice_advance_amount=$invoice->getAdvanceAmount();
  3153.         //            $voucherList=json_decode($invoice->getVoucherIds(),true);
  3154.         //            $partNotice =new SystemNotice();
  3155.         //            $partNotice->setEnabled(1);
  3156.         //            $partNotice->setShowAsNotification(1);
  3157.         //            $partNotice->setDesc("Currently Completing Tasks on Sales Bill".$invoice->getDocumentHash());
  3158.         //            $em->persist($partNotice);
  3159.         //            $em->flush();
  3160.         //            $supp=$em->getRepository('ApplicationBundle\\Entity\\AccClients')->findOneBy(array(
  3161.         //                'clientId'=>$invoice->getClientId(),
  3162.         //
  3163.         //            ));
  3164.         //
  3165.         //
  3166.         //            if($voucherList!=null)
  3167.         //            {
  3168.         //                $voucherDetails=$em->getRepository('ApplicationBundle\\Entity\\AccTransactionDetails')->findBy(array(
  3169.         //
  3170.         //                    'transactionId'=>$voucherList,
  3171.         //                    'accountsHeadId'=>$supp->getAdvanceHeadId()
  3172.         //                ));
  3173.         //                foreach($voucherDetails as $vdet)
  3174.         //                {
  3175.         //                    if($vdet->getPosition()==AccountsConstant::DEBIT)
  3176.         //                        $advance_adjusted_amount+=$vdet->getAmount();
  3177.         //                    else
  3178.         //                        $advance_adjusted_amount-=$vdet->getAmount();
  3179.         //
  3180.         //                }
  3181.         //            }
  3182.         //
  3183.         //            if($advance_adjusted_amount!=$invoice_advance_amount)
  3184.         //            {
  3185.         //                //place adjusting entry
  3186.         //                if ($invoice_advance_amount- $advance_adjusted_amount != 0) {
  3187.         //                    $adjusting_amount=$invoice_advance_amount- $advance_adjusted_amount;
  3188.         //                    $TransID = Accounts::CreateNewTransaction(0,
  3189.         //                        $em,
  3190.         //                        $invoice->getSalesInvoiceDate()->format('Y-m-d'),
  3191.         //                        $adjusting_amount>0?$adjusting_amount:(-1)*$adjusting_amount,
  3192.         //                        AccountsConstant::VOUCHER_JOURNAL,
  3193.         //                        'Journal For Advance balancing for Sales Invoice ' . $invoice->getDocumentHash(),
  3194.         //                        'JV/GN/1/' . Accounts::GetVNoHash($em,'JV', 'GN', $invoice->getProjectId()),
  3195.         //                        'JV',
  3196.         //                        'GN',
  3197.         //                        $invoice->getProjectId(),
  3198.         //                        Accounts::GetVNoHash($em,'JV', 'GN', $invoice->getProjectId()),
  3199.         //                        0,
  3200.         //                        $invoice->getCreatedLoginId(),
  3201.         //                        $invoice->getCompanyId(),
  3202.         //                        '',
  3203.         //                        0,
  3204.         //                        1
  3205.         //
  3206.         //                    );
  3207.         //
  3208.         //                    $curr_v_ids=json_decode($invoice->getVoucherIds(),true);
  3209.         //                    if($curr_v_ids!=null)
  3210.         //                        $invoice->setVoucherIds(json_encode(array_merge($curr_v_ids,array_diff( [$TransID],$curr_v_ids))));
  3211.         //                    else
  3212.         //                        $invoice->setVoucherIds(json_encode([$TransID]));
  3213.         //
  3214.         //                    $em->flush();
  3215.         //
  3216.         //
  3217.         //                    Accounts::CreateNewTransactionDetails($em,
  3218.         //                        '',
  3219.         //                        $TransID,
  3220.         //                        Generic::CurrToInt($adjusting_amount),
  3221.         //                        $supp->getAccountsHeadId(),
  3222.         //                        'Generated for Client head balance For advance',
  3223.         //                        AccountsConstant::CREDIT,
  3224.         //                        0,
  3225.         //                        [],
  3226.         //                        [],
  3227.         //                        $invoice->getCreatedLoginId()
  3228.         //                    );
  3229.         //                    Accounts::CreateNewTransactionDetails($em,
  3230.         //                        '',
  3231.         //                        $TransID,
  3232.         //                        Generic::CurrToInt($adjusting_amount),
  3233.         //                        $supp->getAdvanceHeadId(),
  3234.         //                        'Client Advance Balancing ',
  3235.         //                        AccountsConstant::DEBIT,
  3236.         //                        0,
  3237.         //                        [],
  3238.         //                        [],
  3239.         //                        $invoice->getCreatedLoginId()
  3240.         //                    );
  3241.         //                    System::UpdatePostDatedTransactionById($em,$TransID);
  3242.         //
  3243.         //
  3244.         //                }
  3245.         //
  3246.         //
  3247.         //            }
  3248.         //
  3249.         //            $em->remove($partNotice);
  3250.         //            $em->flush();
  3251.         //
  3252.         //
  3253.         //        }
  3254.         //
  3255.         //
  3256.         //
  3257.         //
  3258.         $noticeList $em->getRepository('ApplicationBundle\\Entity\\SystemNotice')->findBy(array(
  3259.             //            'enabled'=>GeneralConstant::ACTIVE,
  3260.             //            'showAsNotification'=>GeneralConstant::ACTIVE,
  3261.             //            'CompanyId'=>1,
  3262.             //            'appId'=>$session->get(UserConstants::USER_COMPANY_ID),
  3263.         ));
  3264.         foreach ($noticeList as $notice) {
  3265.             $em->remove($notice);
  3266.             $em->flush();
  3267.         }
  3268.         if ($company) {
  3269.             $company->setPostDatedJobActive(0);
  3270.             $em->flush();
  3271.         }
  3272.         return ['done'];
  3273.     }
  3274.     public static function UpdatePostDatedTransactionById($em$id)
  3275.     {
  3276.         //        $Transactions=$em->getRepository('ApplicationBundle\\Entity\\AccTransactions')->findBy(array(
  3277.         //            'approved'=>1,
  3278.         //            'ledgerHit'=>0
  3279.         //        ));
  3280.         //        foreach($Transactions as $Transaction)
  3281.         //        {
  3282.         ApprovalFunction::AccTransactions($em$id);
  3283.         //        }
  3284.         return ['done'];
  3285.     }
  3286.     public static function UpdateInvoicePayments($em)
  3287.     {
  3288.         $Transactions $em->getRepository('ApplicationBundle\\Entity\\PurchaseInvoice')->findBy(array(
  3289.             'approved' => 1,
  3290.             'firstHit' => 0
  3291.         ));
  3292.         foreach ($Transactions as $Transaction) {
  3293.             $partNotice = new SystemNotice();
  3294.             $partNotice->setEnabled(1);
  3295.             $partNotice->setShowAsNotification(1);
  3296.             $partNotice->setDesc("Currently Completing Tasks on Purchase Bill" $Transaction->getDocumentHash());
  3297.             $em->persist($partNotice);
  3298.             $em->flush();
  3299.             Accounts::modifyAdvanceAndDuePurchaseInvoice($em$Transaction->getPurchaseInvoiceId());
  3300.             $em->remove($partNotice);
  3301.             $em->flush();
  3302.         }
  3303.         $Transactions $em->getRepository('ApplicationBundle\\Entity\\SalesInvoice')->findBy(array(
  3304.             'approved' => 1,
  3305.             'firstHit' => 0
  3306.         ));
  3307.         foreach ($Transactions as $Transaction) {
  3308.             $partNotice = new SystemNotice();
  3309.             $partNotice->setEnabled(1);
  3310.             $partNotice->setShowAsNotification(1);
  3311.             $partNotice->setDesc("Currently Completing Tasks on Purchase Bill" $Transaction->getDocumentHash());
  3312.             $em->persist($partNotice);
  3313.             $em->flush();
  3314.             Accounts::modifyAdvanceAndDueSalesInvoice($em$Transaction->getSalesInvoiceId());
  3315.             $em->remove($partNotice);
  3316.             $em->flush();
  3317.         }
  3318.         $invoices $em->getRepository('ApplicationBundle\\Entity\\PurchaseInvoice')->findBy(array(
  3319.             'approved' => 1,
  3320.             'firstHit' => 1,
  3321.             'ledgerHit' => 1,
  3322.         ));
  3323.         foreach ($invoices as $invoice) {
  3324.             $advance_adjusted_amount 0;
  3325.             $invoice_advance_amount $invoice->getAdvanceAmount();
  3326.             $voucherList json_decode($invoice->getVoucherIds(), true);
  3327.             $partNotice = new SystemNotice();
  3328.             $partNotice->setEnabled(1);
  3329.             $partNotice->setShowAsNotification(1);
  3330.             $partNotice->setDesc("Currently Completing Tasks on Purchase Bill" $invoice->getDocumentHash());
  3331.             $em->persist($partNotice);
  3332.             $em->flush();
  3333.             $supp $em->getRepository('ApplicationBundle\\Entity\\AccSuppliers')->findOneBy(array(
  3334.                 'supplierId' => $invoice->getSupplierId(),
  3335.             ));
  3336.             if ($voucherList != null) {
  3337.                 $voucherDetails $em->getRepository('ApplicationBundle\\Entity\\AccTransactionDetails')->findBy(array(
  3338.                     'transactionId' => $voucherList,
  3339.                     'accountsHeadId' => $supp->getAdvanceHeadId()
  3340.                 ));
  3341.                 foreach ($voucherDetails as $vdet) {
  3342.                     if ($vdet->getPosition() == AccountsConstant::CREDIT)
  3343.                         $advance_adjusted_amount += $vdet->getAmount();
  3344.                     else
  3345.                         $advance_adjusted_amount -= $vdet->getAmount();
  3346.                 }
  3347.             }
  3348.             if ($advance_adjusted_amount != $invoice_advance_amount) {
  3349.                 //place adjusting entry
  3350.                 if ($invoice_advance_amount $advance_adjusted_amount != 0) {
  3351.                     $adjusting_amount $invoice_advance_amount $advance_adjusted_amount;
  3352.                     $TransID Accounts::CreateNewTransaction(
  3353.                         0,
  3354.                         $em,
  3355.                         $invoice->getPurchaseInvoiceDate()->format('Y-m-d'),
  3356.                         $adjusting_amount $adjusting_amount : (-1) * $adjusting_amount,
  3357.                         AccountsConstant::VOUCHER_JOURNAL,
  3358.                         'Journal For Advance balancing for Purchase Invoice ' $invoice->getDocumentHash(),
  3359.                         'JV/GN/1/' Accounts::GetVNoHash($em'JV''GN'$invoice->getProjectId()),
  3360.                         'JV',
  3361.                         'GN',
  3362.                         $invoice->getProjectId(),
  3363.                         Accounts::GetVNoHash($em'JV''GN'$invoice->getProjectId()),
  3364.                         0,
  3365.                         $invoice->getCreatedLoginId(),
  3366.                         $invoice->getCompanyId(),
  3367.                         '',
  3368.                         0,
  3369.                         1
  3370.                     );
  3371.                     $curr_v_ids json_decode($invoice->getVoucherIds(), true);
  3372.                     if ($curr_v_ids != null)
  3373.                         $invoice->setVoucherIds(json_encode(array_merge($curr_v_idsarray_diff([$TransID], $curr_v_ids))));
  3374.                     else
  3375.                         $invoice->setVoucherIds(json_encode([$TransID]));
  3376.                     $em->flush();
  3377.                     Accounts::CreateNewTransactionDetails(
  3378.                         $em,
  3379.                         '',
  3380.                         $TransID,
  3381.                         Generic::CurrToInt($adjusting_amount),
  3382.                         $supp->getAccountsHeadId(),
  3383.                         'Generated for supplier head balance For advance',
  3384.                         AccountsConstant::DEBIT,
  3385.                         0,
  3386.                         [],
  3387.                         [],
  3388.                         $invoice->getCreatedLoginId()
  3389.                     );
  3390.                     Accounts::CreateNewTransactionDetails(
  3391.                         $em,
  3392.                         '',
  3393.                         $TransID,
  3394.                         Generic::CurrToInt($adjusting_amount),
  3395.                         $supp->getAdvanceHeadId(),
  3396.                         'supplier Advance Balancing ',
  3397.                         AccountsConstant::CREDIT,
  3398.                         0,
  3399.                         [],
  3400.                         [],
  3401.                         $invoice->getCreatedLoginId()
  3402.                     );
  3403.                     System::UpdatePostDatedTransactionById($em$TransID);
  3404.                 }
  3405.             }
  3406.             $em->remove($partNotice);
  3407.             $em->flush();
  3408.         }
  3409.         //now SI
  3410.         $invoices $em->getRepository('ApplicationBundle\\Entity\\SalesInvoice')->findBy(array(
  3411.             'approved' => 1,
  3412.             'firstHit' => 1,
  3413.             'ledgerHit' => 1,
  3414.         ));
  3415.         foreach ($invoices as $invoice) {
  3416.             $advance_adjusted_amount 0;
  3417.             $invoice_advance_amount $invoice->getAdvanceAmount();
  3418.             $voucherList json_decode($invoice->getVoucherIds(), true);
  3419.             $partNotice = new SystemNotice();
  3420.             $partNotice->setEnabled(1);
  3421.             $partNotice->setShowAsNotification(1);
  3422.             $partNotice->setDesc("Currently Completing Tasks on Sales Bill" $invoice->getDocumentHash());
  3423.             $em->persist($partNotice);
  3424.             $em->flush();
  3425.             $supp $em->getRepository('ApplicationBundle\\Entity\\AccClients')->findOneBy(array(
  3426.                 'clientId' => $invoice->getClientId(),
  3427.             ));
  3428.             if ($voucherList != null) {
  3429.                 $voucherDetails $em->getRepository('ApplicationBundle\\Entity\\AccTransactionDetails')->findBy(array(
  3430.                     'transactionId' => $voucherList,
  3431.                     'accountsHeadId' => $supp->getAdvanceHeadId()
  3432.                 ));
  3433.                 foreach ($voucherDetails as $vdet) {
  3434.                     if ($vdet->getPosition() == AccountsConstant::DEBIT)
  3435.                         $advance_adjusted_amount += $vdet->getAmount();
  3436.                     else
  3437.                         $advance_adjusted_amount -= $vdet->getAmount();
  3438.                 }
  3439.             }
  3440.             if ($advance_adjusted_amount != $invoice_advance_amount) {
  3441.                 //place adjusting entry
  3442.                 if ($invoice_advance_amount $advance_adjusted_amount != 0) {
  3443.                     $adjusting_amount $invoice_advance_amount $advance_adjusted_amount;
  3444.                     $TransID Accounts::CreateNewTransaction(
  3445.                         0,
  3446.                         $em,
  3447.                         $invoice->getSalesInvoiceDate()->format('Y-m-d'),
  3448.                         $adjusting_amount $adjusting_amount : (-1) * $adjusting_amount,
  3449.                         AccountsConstant::VOUCHER_JOURNAL,
  3450.                         'Journal For Advance balancing for Sales Invoice ' $invoice->getDocumentHash(),
  3451.                         'JV/GN/1/' Accounts::GetVNoHash($em'JV''GN'$invoice->getProjectId()),
  3452.                         'JV',
  3453.                         'GN',
  3454.                         $invoice->getProjectId(),
  3455.                         Accounts::GetVNoHash($em'JV''GN'$invoice->getProjectId()),
  3456.                         0,
  3457.                         $invoice->getCreatedLoginId(),
  3458.                         $invoice->getCompanyId(),
  3459.                         '',
  3460.                         0,
  3461.                         1
  3462.                     );
  3463.                     $curr_v_ids json_decode($invoice->getVoucherIds(), true);
  3464.                     if ($curr_v_ids != null)
  3465.                         $invoice->setVoucherIds(json_encode(array_merge($curr_v_idsarray_diff([$TransID], $curr_v_ids))));
  3466.                     else
  3467.                         $invoice->setVoucherIds(json_encode([$TransID]));
  3468.                     $em->flush();
  3469.                     Accounts::CreateNewTransactionDetails(
  3470.                         $em,
  3471.                         '',
  3472.                         $TransID,
  3473.                         Generic::CurrToInt($adjusting_amount),
  3474.                         $supp->getAccountsHeadId(),
  3475.                         'Generated for Client head balance For advance',
  3476.                         AccountsConstant::CREDIT,
  3477.                         0,
  3478.                         [],
  3479.                         [],
  3480.                         $invoice->getCreatedLoginId()
  3481.                     );
  3482.                     Accounts::CreateNewTransactionDetails(
  3483.                         $em,
  3484.                         '',
  3485.                         $TransID,
  3486.                         Generic::CurrToInt($adjusting_amount),
  3487.                         $supp->getAdvanceHeadId(),
  3488.                         'Client Advance Balancing ',
  3489.                         AccountsConstant::DEBIT,
  3490.                         0,
  3491.                         [],
  3492.                         [],
  3493.                         $invoice->getCreatedLoginId()
  3494.                     );
  3495.                     System::UpdatePostDatedTransactionById($em$TransID);
  3496.                 }
  3497.             }
  3498.             $em->remove($partNotice);
  3499.             $em->flush();
  3500.         }
  3501.     }
  3502.     public static function getPositionIdsByDepartment($em$DepartmentID)
  3503.     {
  3504.         $list = array();
  3505.         $Positions $em->getRepository('ApplicationBundle\\Entity\\SysDepartmentPosition')->findBy(array(
  3506.             'status' => GeneralConstant::ACTIVE,
  3507.             'departmentId' => $DepartmentID
  3508.         ));
  3509.         foreach ($Positions as &$Position) {
  3510.             $list[] = $Position->getPositionId();
  3511.         }
  3512.         return $list;
  3513.     }
  3514.     public static function sendPushNotification($deviceTokens$path ''$notificationTitle "Notification Title"$notificationBody "Notification Body"$additionalData = [])
  3515.     {
  3516.         //
  3517. //        $google_client = new Google_Client();
  3518. ////        $google_client->setClientId('916737688016-l2qfmb9p37cumudkaqpu8s7ndngq9una.apps.googleusercontent.com');
  3519. ////        $google_client->setClientSecret('BEWpEBRvv3-hSoB4cGBrVB3z');
  3520. //
  3521. //        $selector = BuddybeeConstant::$selector;
  3522. //        $url = $this->generateUrl(
  3523. //            'applicant_login', ['refRoute' => $refRoute], UrlGenerator::ABSOLUTE_URL
  3524. //        );
  3525. //
  3526. //
  3527. //
  3528. ////        $this->container->getParameter('kernel.root_dir') . '/../src/ApplicationBundle/Resources/config/client_secret.json';
  3529. //        $google_client->setAuthConfig($this->container->getParameter('kernel.root_dir') . '/../src/ApplicationBundle/Resources/config/client_secret.json');
  3530. ////        $google_client->addScope(Google_Service\Drive::DRIVE_METADATA_READONLY);
  3531. //        $google_client->setRedirectUri($url);
  3532. //        $google_client->setAccessType('offline');        // offline access
  3533. //        $google_client->setIncludeGrantedScopes(true);   // incremental auth
  3534. //
  3535. //        $google_client->addScope('email');
  3536. //        $google_client->addScope('profile');
  3537. //        $google_client->addScope('openid');
  3538. //
  3539. //
  3540. ////    $google_client->setRedirectUri('http://localhost/applicant_login');
  3541. //
  3542. //
  3543. //        //linked in 1st
  3544. //
  3545. //    if (isset($_GET["code"])) {
  3546. //            $token = $google_client->fetchAccessTokenWithAuthCode($_GET["code"]);
  3547. //            if (!isset($token['error'])) {
  3548. //                $google_client->setAccessToken($token['access_token']);
  3549. //                $google_service = new Google_Service_Oauth2($google_client);
  3550. //                $applicantInfo = $google_service->userinfo->get();
  3551. //                $oAuthEmail = $applicantInfo['email'];
  3552. //
  3553. //
  3554. //                $oAuthData = [
  3555. //                    'email' => $applicantInfo['email'],
  3556. //                    'uniqueId' => $applicantInfo['id'],
  3557. //                    'image' => $applicantInfo['picture'],
  3558. //                    'emailVerified' => $applicantInfo['verifiedEmail'],
  3559. //                    'name' => $applicantInfo['givenName'] . ' ' . $applicantInfo['familyName'],
  3560. //                    'firstName' => $applicantInfo['givenName'],
  3561. //                    'lastName' => $applicantInfo['familyName'],
  3562. //                    'type' => $token['token_type'],
  3563. //                    'token' => $token['access_token'],
  3564. //                ];
  3565. //
  3566. //
  3567. //            }
  3568. //        }
  3569.         // FCM credentials loaded from file (key must NOT be committed — see client_secret_fcm.json)
  3570.         $fcmKeyFile $path '/../src/ApplicationBundle/Resources/config/client_secret_fcm.json';
  3571.         if (!file_exists($fcmKeyFile)) {
  3572.             return [];
  3573.         }
  3574.         $data json_decode(file_get_contents($fcmKeyFile), true);
  3575.         $privateKey $data["private_key"];
  3576.         $clientEmail $data["client_email"];
  3577.         $clientId $data["client_id"];
  3578.         $authUri $data["auth_uri"];
  3579.         $tokenUri $data["token_uri"];
  3580.         //        $scopes = array("https://www.googleapis.com/auth/cloud-platform");
  3581.         $scopes = array("https://www.googleapis.com/auth/firebase.messaging""https://www.googleapis.com/auth/firebase.messaging.readonly");
  3582.         $scopesString implode(" "$scopes);
  3583.         $curl curl_init();
  3584.         curl_setopt($curlCURLOPT_URL$authUri);
  3585.         curl_setopt($curlCURLOPT_POST1);
  3586.         curl_setopt($curlCURLOPT_POSTFIELDS"client_id=$clientId&scope=$scopesString&redirect_uri=&response_type=code");
  3587.         curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
  3588.         $response curl_exec($curl);
  3589.         if ($response === false) {
  3590.             echo curl_error($curl);
  3591.         } else {
  3592.             $url parse_url($response);
  3593.             $code $url["fragment"];
  3594.             System::log_it($pathjson_encode($response), 'pika_frag');
  3595.             $curl curl_init();
  3596.             curl_setopt($curlCURLOPT_URL$tokenUri);
  3597.             curl_setopt($curlCURLOPT_POST1);
  3598.             curl_setopt($curlCURLOPT_POSTFIELDS"client_id=$clientId&client_secret=$privateKey&code=$code&grant_type=authorization_code");
  3599.             curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
  3600.             $response curl_exec($curl);
  3601.             if ($response === false) {
  3602.                 echo curl_error($curl);
  3603.             } else {
  3604.                 $data json_decode($responsetrue);
  3605.                 System::log_it($pathjson_encode($response), 'pika_lu');
  3606.                 $accessToken $data["access_token"];
  3607.                 //                echo $accessToken;
  3608. //                $serverKey = "serverKey";
  3609. //                $privateKey = 'c2ec2e4808c6008d31e5d3f6a84c93e0e6dbdf9e';
  3610.                 $projectId "buddybee-337909";
  3611.                 //        $deviceToken = "DEVICE_TOKEN";
  3612. //        $notificationTitle = "Notification Title";
  3613. //        $notificationBody = "Notification Body";
  3614. //        $pageName = "My Page";
  3615.                 //        $data = array(
  3616. //            "page_name" => $pageName,
  3617. //        );
  3618. //        $deviceTokens = array(
  3619. ////            "DEVICE_TOKEN_1",
  3620. ////            "DEVICE_TOKEN_2",
  3621. ////            "DEVICE_TOKEN_3",
  3622. //        );
  3623.                 $data = array(
  3624.                     //            "to" => $deviceToken,
  3625.                     "registration_ids" => $deviceTokens,
  3626.                     "notification" => array(
  3627.                         "title" => $notificationTitle,
  3628.                         "body" => $notificationBody,
  3629.                     ),
  3630.                     "data" => $additionalData,
  3631.                 );
  3632.                 $jsonData json_encode($data);
  3633.                 //                $curl = curl_init();
  3634.                 curl_setopt($curlCURLOPT_URL"https://fcm.googleapis.com/v1/projects/$projectId/messages:send");
  3635.                 curl_setopt($curlCURLOPT_HTTPHEADER, array(
  3636.                     "Authorization: Bearer $accessToken",
  3637.                     "Content-Type: application/json",
  3638.                 ));
  3639.                 curl_setopt($curlCURLOPT_POSTFIELDS$jsonData);
  3640.                 curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
  3641.                 $response curl_exec($curl);
  3642.                 if ($response === false) {
  3643.                     echo curl_error($curl);
  3644.                 } else {
  3645.                     echo $response;
  3646.                 }
  3647.                 //                curl_close($curl);
  3648.             }
  3649.         }
  3650.         curl_close($curl);
  3651.         return 1;
  3652.     }
  3653.     public static function sendSms(
  3654.         $sms_enabled_flag,
  3655.         $method,
  3656.         $destination_url,
  3657.         $user_name_var,
  3658.         $user_name,
  3659.         $password_var,
  3660.         $password,
  3661.         $from_number_var,
  3662.         $from_number,
  3663.         $to_number_var,
  3664.         $to_number,
  3665.         $text_var,
  3666.         $text,
  3667.         $viewlink ""
  3668.     ) {
  3669.         if ($viewlink == null)
  3670.             $viewlink "";
  3671.         $retData '';
  3672.         if (GeneralConstant::SMS_ENABLED == 1) {
  3673.             if ($sms_enabled_flag == 1) {
  3674.                 if (strlen($to_number) == 11)
  3675.                     $to_number '88' $to_number;
  3676.                 if (strlen($to_number) == 10)
  3677.                     $to_number '880' $to_number;
  3678.                 if ($method == 'GET') {
  3679.                     $urlToCall = (strpos($destination_url'http') !== false) ? $destination_url : ('http://' $destination_url);
  3680.                     $getStr '';
  3681.                     $post_fields = array(
  3682.                         $user_name_var => $user_name,
  3683.                         $password_var => $password,
  3684.                         $from_number_var => $from_number,
  3685.                         $to_number_var => $to_number,
  3686.                         $text_var => $text,
  3687.                     );
  3688.                     //                    $to_number
  3689.                     $first_one 1;
  3690.                     $getStr $user_name_var '=' urlencode($user_name);
  3691.                     $getStr .= '&' $password_var '=' urlencode($password);
  3692.                     $getStr .= '&' $from_number_var '=' urlencode($from_number);
  3693.                     $getStr .= '&' $to_number_var '=' urlencode($to_number);
  3694.                     $getStr .= '&' $text_var '=' urlencode($text);
  3695.                     //                    $getStr .= $user_name_var . '=' . urlencode($user_name);
  3696.                     //                    foreach ($post_fields as $key => $val) {
  3697.                     //                        if ($first_one == 0) {
  3698.                     //                            $getStr .= '&';
  3699.                     //                        }
  3700.                     ////                        $getStr .= $key . '=' . urlencode($val);
  3701.                     ////                        if($key==$password_var || $key==$user_name_var)
  3702.                     ////                        if($key==$text_var )
  3703.                     //                        $getStr .= $key . '=' . urlencode($val);
  3704.                     ////                        else
  3705.                     ////                        $getStr .= $key . '=' . $val;
  3706.                     //                        $first_one = 0;
  3707.                     //
  3708.                     //
  3709.                     //                    }
  3710.                     //                    $getStr = http_build_query($post_fields);
  3711.                     //                    $getStr = urlencode($getStr);
  3712.                     $urlToCall $urlToCall '?' $getStr;
  3713.                     //                    $urlToCall = $urlToCall . '?' . 'pika=chu&lie=pie';
  3714.                     //                    $urlToCall= http_build_query($post_fields);
  3715.                     //                    $urlToCall ='pika=chu&lie=pie';
  3716.                     $curl curl_init();
  3717.                     curl_setopt_array($curl, array(
  3718.                         CURLOPT_RETURNTRANSFER => 1,
  3719.                         CURLOPT_URL => $urlToCall,
  3720.                         CURLOPT_SSL_VERIFYPEER => false,
  3721.                         //                        CURLOPT_USERAGENT => 'InnoPM',
  3722.                         //                        CURLOPT_POSTFIELDS => $post_fields
  3723.                     ));
  3724.                     $retData curl_exec($curl);
  3725.                     $errData curl_error($curl);
  3726.                     curl_close($curl);
  3727.                     return array(
  3728.                         'response' => $retData,
  3729.                         'errData' => $errData,
  3730.                         'url' => $urlToCall,
  3731.                         'post_fields' => $post_fields
  3732.                     );
  3733.                 } else if ($method == 'POST') {
  3734.                     $urlToCall = (strpos($destination_url'http') !== false) ? $destination_url : ('http://' $destination_url);
  3735.                     $curl curl_init();
  3736.                     $post_fields = array(
  3737.                         $from_number_var => $from_number,
  3738.                         $to_number_var => $to_number,
  3739.                         $text_var => $text,
  3740.                         $user_name_var => $user_name,
  3741.                         $password_var => $password,
  3742.                     );
  3743.                     curl_setopt_array($curl, array(
  3744.                         CURLOPT_RETURNTRANSFER => 1,
  3745.                         CURLOPT_URL => $urlToCall,
  3746.                         CURLOPT_SSL_VERIFYPEER => false,
  3747.                         //                        CURLOPT_USERAGENT => 'InnoPM',
  3748.                         //                        CURLOPT_POST => 1,
  3749.                         CURLOPT_POSTFIELDS => $post_fields
  3750.                     ));
  3751.                     $retData curl_exec($curl);
  3752.                     curl_close($curl);
  3753.                     return array('response' => $retData'url' => $urlToCall'post_fields' => $post_fields);
  3754.                 }
  3755.             }
  3756.         }
  3757.         return 0;
  3758.     }
  3759.     /**
  3760.      * AddNewNotification — fixed implementation.
  3761.      *
  3762.      * Previously called the non-existent /add_notification endpoint on the Node
  3763.      * server, causing all approval/document notifications to be silently dropped.
  3764.      *
  3765.      * Now: persists to entity_notification (DB-first) AND fires /trigger_socket
  3766.      * so real-time delivery and notification history both work.
  3767.      *
  3768.      * $target_who_of_what must be an array of user IDs when $target_what = 'user'.
  3769.      *
  3770.      * @deprecated  New code should call NotificationDispatcher::dispatch() instead.
  3771.      *              This legacy wrapper is kept for backward compatibility with
  3772.      *              System::approveDocument() and other existing callsites.
  3773.      */
  3774.     public static function AddNewNotification(
  3775.         $config_notification_enabled_flag,
  3776.         $config_notification_server,
  3777.         $appId,
  3778.         $companyId,
  3779.         $text,
  3780.         $target_what,
  3781.         $target_who_of_what,
  3782.         $type,
  3783.         $viewlink "",
  3784.         $title "New Notification",
  3785.         $em null
  3786.     ) {
  3787.         if ($target_who_of_what == '')
  3788.             $target_who_of_what = [];
  3789.         if ($viewlink == null)
  3790.             $viewlink "";
  3791.         $userIds is_array($target_who_of_what) ? $target_who_of_what : [$target_who_of_what];
  3792.         $userIds array_filter(array_map('intval'$userIds), fn($id) => $id 0);
  3793.         if (empty($userIds)) return 0;
  3794.         // ── 1. Persist to DB ──────────────────────────────────────────────────
  3795.         if ($em !== null) {
  3796.             try {
  3797.                 $currTime = new \DateTime();
  3798.                 foreach ($userIds as $uid) {
  3799.                     $notif = new EntityNotification();
  3800.                     $notif->setAppId((int) $appId);
  3801.                     $notif->setCompanyId((int) $companyId);
  3802.                     $notif->setTitle($title);
  3803.                     $notif->setBody($text);
  3804.                     $notif->setUserId($uid);
  3805.                     $notif->setAssignedToUserId($uid);
  3806.                     $notif->setTaggedUserIds(json_encode($userIds));
  3807.                     $notif->setTargetUrl($viewlink);
  3808.                     $notif->setTargetRoute('');
  3809.                     $notif->setTargetId('');
  3810.                     $notif->setTargetPath('');
  3811.                     $notif->setTargetMobileAppPath('');
  3812.                     $notif->setNotificationTs($currTime->format('U'));
  3813.                     $notif->setExpireTs(0);
  3814.                     $notif->setSeenFlag(0);
  3815.                     $notif->setReadFlag(0);
  3816.                     $notif->setType(GeneralConstant::NOTIFICATION_TYPE_SOCKET);
  3817.                     $notif->setIsBuddybee(0);
  3818.                     $em->persist($notif);
  3819.                 }
  3820.                 $em->flush();
  3821.             } catch (\Exception $e) {
  3822.                 // DB failure must not block the socket delivery
  3823.             }
  3824.         }
  3825.         // ── 2. Fire socket server ─────────────────────────────────────────────
  3826.         if (GeneralConstant::NOTIFICATION_ENABLED == && $config_notification_enabled_flag == 1) {
  3827.             $payload json_encode([
  3828.                 'v'            => 2,
  3829.                 'emitMarker'   => '_SOCKET_NOTIFICATION_HERE_',
  3830.                 'sendType'     => 'emit',
  3831.                 'sendToSocket' => 1,
  3832.                 'triggerUserIds' => array_values($userIds),
  3833.                 'dataObj'      => [
  3834.                     'title'   => $title,
  3835.                     'body'    => $text,
  3836.                     'type'    => $type,
  3837.                     'viewlink' => $viewlink,
  3838.                 ],
  3839.             ]);
  3840.             $curl curl_init();
  3841.             curl_setopt_array($curl, [
  3842.                 CURLOPT_RETURNTRANSFER => true,
  3843.                 CURLOPT_URL            => rtrim($config_notification_server'/') . '/trigger_socket',
  3844.                 CURLOPT_POST           => true,
  3845.                 CURLOPT_POSTFIELDS     => $payload,
  3846.                 CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
  3847.                 CURLOPT_TIMEOUT_MS     => 800,
  3848.                 CURLOPT_USERAGENT      => 'InnoPM',
  3849.             ]);
  3850.             curl_exec($curl);
  3851.             curl_close($curl);
  3852.         }
  3853.         return 0;
  3854.     }
  3855.     /**
  3856.      * @deprecated  New code should call NotificationDispatcher::dispatch() instead.
  3857.      *              This legacy wrapper is kept for backward compatibility with
  3858.      *              existing callsites. Fixed 2026-05-27: payload is now sent as
  3859.      *              JSON (was form-encoded, which Node's express.json() rejected).
  3860.      */
  3861.     public static function AddNewNotificationUpdated(
  3862.         $config_notification_enabled_flag,
  3863.         $config_notification_server,
  3864.         $appId,
  3865.         $companyId,
  3866.         $text,
  3867.         $type,
  3868.         $viewlink "",
  3869.         $title "New Notification",
  3870.         $sendType 'emit',
  3871.         $addToDb 0,
  3872.         $sendToSocket 1,
  3873.         $options = [
  3874.             'em' => null,
  3875.             'isBuddybee' => 0,
  3876.             'type' => 0,
  3877.             'expireTs' => 0,
  3878.             'userIdPrefixForSocket' => ''
  3879.         ]
  3880.     ) {
  3881.         if ($viewlink == null)
  3882.             $viewlink "";
  3883.         if ($addToDb == 1) {
  3884.             $currTime = new \DateTime();
  3885.             $em $options['em'];
  3886.             $NOTIFICATION = new EntityNotification();
  3887.             $NOTIFICATION->setAppId($appId);
  3888.             $NOTIFICATION->setCompanyId($companyId);
  3889.             $NOTIFICATION->setCompanyId($companyId);
  3890.             $NOTIFICATION->setBody($text);
  3891.             $NOTIFICATION->setTitle($title);
  3892.             $NOTIFICATION->setTargetRoute(isset($options['targetRoute']) ? $options['targetRoute'] : '');
  3893.             $NOTIFICATION->setTargetUrl(isset($options['targetUrl']) ? $options['targetUrl'] : '');
  3894.             $NOTIFICATION->setTargetPath(isset($options['targetPath']) ? $options['targetPath'] : '');
  3895.             $NOTIFICATION->setTargetId(isset($options['targetId']) ? $options['targetId'] : '');
  3896.             $NOTIFICATION->setMeetingId(isset($options['meetingId']) ? $options['meetingId'] : '');
  3897.             $NOTIFICATION->setUserId(isset($options['userId']) ? $options['userId'] : '');
  3898.             $NOTIFICATION->setApplicantId(isset($options['applicantId']) ? $options['applicantId'] : '');
  3899.             $NOTIFICATION->setAssignedByUserId(isset($options['assignedByUserId']) ? $options['assignedByUserId'] : '');
  3900.             $NOTIFICATION->setAssignedToUserId(isset($options['assignedToUserId']) ? $options['assignedToUserId'] : '');
  3901.             $NOTIFICATION->setTaggedUserIds(isset($options['taggedUserIds']) ? json_encode($options['taggedUserIds']) : '[]');
  3902.             $NOTIFICATION->setTargetMobileAppPath(isset($options['targetRoute']) ?
  3903.                 (isset(GeneralConstant::$MOBILE_APP_PATH_BY_ROUTING[$options['targetRoute']]) ? GeneralConstant::$MOBILE_APP_PATH_BY_ROUTING[$options['targetRoute']] : '')
  3904.                 : '');
  3905.             $NOTIFICATION->setExpireTs(isset($options['expireTs']) ? $options['expireTs'] : 0);
  3906.             $NOTIFICATION->setNotificationTs(isset($options['notificationTs']) ? $options['notificationTs'] : $currTime->format('U'));
  3907.             $NOTIFICATION->setIsBuddybee(isset($options['isBuddybee']) ? $options['isBuddybee'] : 0);
  3908.             $NOTIFICATION->setType(isset($options['type']) ? $options['type'] : 0);
  3909.             $NOTIFICATION->setSeenFlag(0);
  3910.             $NOTIFICATION->setReadFlag(0);
  3911.             $em->persist($NOTIFICATION);
  3912.             $em->flush();
  3913.             if (GeneralConstant::NOTIFICATION_ENABLED == 1) {
  3914.                 if ($config_notification_enabled_flag == 1) {
  3915.                     $curl curl_init();
  3916.                     $arrayToSend = array(
  3917.                         'sendType' => $sendType,
  3918.                         'dataObj' => isset($options['dataObj']) ? $options['dataObj'] : [],
  3919.                         //                        'firebasePushData' => isset($options['firebasePushData']) ? $options['firebasePushData'] :null,
  3920.                         'emitMarker' => isset($options['emitMarker']) ? $options['emitMarker'] : '_NONE_',
  3921.                         'triggerUserIds' => isset($options['taggedUserIds']) ? $options['taggedUserIds'] : [], //'pos', 'all', 'user','none',
  3922.                     );
  3923.                     if (isset($options['firebasePushData']))
  3924.                         $arrayToSend['firebasePushData'] = $options['firebasePushData'];
  3925.                     curl_setopt_array($curl, array(
  3926.                         CURLOPT_RETURNTRANSFER => 1,
  3927.                         CURLOPT_URL           => $config_notification_server '/trigger_socket',
  3928.                         CURLOPT_USERAGENT     => 'InnoPM',
  3929.                         CURLOPT_POST          => 1,
  3930.                         CURLOPT_HTTPHEADER    => ['Content-Type: application/json'],
  3931.                         CURLOPT_POSTFIELDS    => json_encode($arrayToSend),
  3932.                         CURLOPT_TIMEOUT_MS    => 800,
  3933.                     ));
  3934.                     curl_exec($curl);
  3935.                     curl_close($curl);
  3936.                     return 0;
  3937.                 }
  3938.             }
  3939.         }
  3940.         if ($sendToSocket == 1//        if (0)
  3941.         {
  3942.             if (GeneralConstant::NOTIFICATION_ENABLED == 1) {
  3943.                 if ($config_notification_enabled_flag == 1) {
  3944.                     $curl curl_init();
  3945.                     $arrayToSend = array(
  3946.                         'sendType' => $sendType,
  3947.                         'sendToSocket' => $sendType == '' 1,
  3948.                         'dataObj' => isset($options['dataObj']) ? $options['dataObj'] : [],
  3949.                         //                        'firebasePushData' => isset($options['firebasePushData']) ? $options['firebasePushData'] :null,
  3950.                         'emitMarker' => isset($options['emitMarker']) ? $options['emitMarker'] : '_NONE_',
  3951.                         'triggerUserIds' => isset($options['taggedUserIds']) ? $options['taggedUserIds'] : [], //'pos', 'all', 'user','none',
  3952.                     );
  3953.                     if (isset($options['firebasePushData']))
  3954.                         $arrayToSend['firebasePushData'] = $options['firebasePushData'];
  3955.                     curl_setopt_array($curl, array(
  3956.                         CURLOPT_RETURNTRANSFER => 1,
  3957.                         CURLOPT_URL           => $config_notification_server '/trigger_socket',
  3958.                         CURLOPT_TIMEOUT_MS    => 800,
  3959.                         CURLOPT_USERAGENT     => 'InnoPM',
  3960.                         CURLOPT_POST          => 1,
  3961.                         CURLOPT_HTTPHEADER    => ['Content-Type: application/json'],
  3962.                         CURLOPT_POSTFIELDS    => json_encode($arrayToSend),
  3963.                     ));
  3964.                     curl_exec($curl);
  3965.                     curl_close($curl);
  3966.                     return 0;
  3967.                 }
  3968.             }
  3969.         }
  3970.         return 0;
  3971.     }
  3972.     public static function SendSmsBySocket($config_notification_enabled_flag$msg$phoneNumber$emitMarker$sendType$socketUserIds$deviceId "_DEFAULT_")
  3973.     {
  3974.         if (GeneralConstant::NOTIFICATION_ENABLED == 1) {
  3975.             if ($config_notification_enabled_flag == 1) {
  3976.                 $curl curl_init();
  3977.                 curl_setopt_array($curl, array(
  3978.                     CURLOPT_RETURNTRANSFER => 1,
  3979.                     CURLOPT_URL => 'https://www.' GeneralConstant::BUDDYBEE_SOCKET_SERVER '/trigger_socket',
  3980.                     //                CURLOPT_URL => 'http://localhost:5321/trigger_socket',
  3981.                     CURLOPT_USERAGENT => 'InnoPM',
  3982.                     CURLOPT_POST => 1,
  3983.                     CURLOPT_POSTFIELDS => http_build_query(array(
  3984.                         'sendType' => $sendType,
  3985.                         'dataObj' => array(
  3986.                             'message' => $msg,
  3987.                             'phoneNumber' => $phoneNumber,
  3988.                             'deviceId' => $deviceId,
  3989.                         ),
  3990.                         'emitMarker' => $emitMarker,
  3991.                         'triggerUserIds' => $socketUserIds//'pos', 'all', 'user','none',
  3992.                     ))
  3993.                 ));
  3994.                 curl_exec($curl);
  3995.                 curl_close($curl);
  3996.                 return 1;
  3997.             }
  3998.         }
  3999.         return 0;
  4000.     }
  4001.     public static function GetAllNotification($config_notification_enabled_flag$config_notification_server$user_id 0$appId 0$companyId 0)
  4002.     {
  4003.         $ret "";
  4004.         $curl = [];
  4005.         $serverhost '';
  4006.         if (GeneralConstant::NOTIFICATION_ENABLED == 1) {
  4007.             if ($config_notification_enabled_flag == 1) {
  4008.                 $curl curl_init();
  4009.                 curl_setopt_array($curl, array(
  4010.                     CURLOPT_RETURNTRANSFER => 1,
  4011.                     //                    CURLOPT_URL => GeneralConstant::NOTIFICATION_SERVER . '/get_all_notification',
  4012.                     CURLOPT_URL => $config_notification_server '/get_all_notification',
  4013.                     CURLOPT_USERAGENT => 'InnoPM',
  4014.                     CURLOPT_POST => 1,
  4015.                     CURLOPT_POSTFIELDS => array(
  4016.                         'user' => $user_id,
  4017.                         'companyId' => $companyId,
  4018.                         'appId' => $appId,
  4019.                     )
  4020.                 ));
  4021.                 $ret curl_exec($curl);
  4022.                 curl_close($curl);
  4023.                 //                return json_encode([$ret,"http://".($config_notification_server=='localhost:5000'?'localhost:5000':$config_notification_server)]);
  4024.                 return $ret;
  4025.             }
  4026.         }
  4027.         return $ret;
  4028.     }
  4029.     public static function log_it($root_dir$to_write$file_name$append 1)
  4030.     {
  4031.         $upl_dir $root_dir '/../web/mylogs/';
  4032.         //        $upl_dir = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/FileUploads/';
  4033.         if (!file_exists($upl_dir)) {
  4034.             mkdir($upl_dir0777true);
  4035.         }
  4036.         $file $upl_dir $file_name ".txt";
  4037.         //        $file = $uploadedFile->move($upl_dir, $path);
  4038.         if ($append == 1)
  4039.             $write_file file_put_contents($file$to_writeFILE_APPEND);
  4040.         else
  4041.             $write_file file_put_contents($file$to_write);
  4042.     }
  4043.     public static function setNocApprovalInfo($em$entity_id)
  4044.     {
  4045.         $doc $em->getRepository(NocApproval::class)->find($entity_id);
  4046.         $employeeDetailsRepo $em->getRepository(EmployeeDetails::class);
  4047.         $applicant $employeeDetailsRepo->find($doc->getEmployeeId());
  4048.         $nocApprovalSett json_decode($applicant->getNocApproval(), true);
  4049.         $employeeRepo $em->getRepository(Employee::class);
  4050.         $sysUserRepo $em->getRepository(SysUser::class);
  4051.         $usersWhoApprove = [];
  4052.         $entity array_flip(GeneralConstant::$Entity_list)['NocApproval'];
  4053.         $skipApprovalAction 0;
  4054.         $lowest_seq 9999;
  4055.         $lowest_data = [];
  4056.         if ($nocApprovalSett == null)
  4057.             $nocApprovalSett = [];
  4058.         //    foreach ($nocApprovalSett as $nocAppUser) {
  4059. //      $department = $nocAppUser->department;
  4060. //      $designation = $nocAppUser->designation;
  4061. //      $userWhoApprove = $employeeDetailsRepo->findOneBy(['desg' => $designation]);
  4062. //      $usersWhoApprove[] = $userWhoApprove;
  4063. //    }
  4064.         $documentHash $doc->getDocumentHash();
  4065.         $autoCreated method_exists($doc'getAutoCreated') ? ($doc->getAutoCreated() != 1) : 0;
  4066.         //    if ($autoCreated == 0)
  4067.         {
  4068.             $qry $em->getRepository('ApplicationBundle\\Entity\\Approval')->findBy(array(
  4069.                 'entity' => $entity,
  4070.                 'entityId' => $entity_id,
  4071.                 'action' => [32]    ///recently changed. was only 3 before
  4072.             ));
  4073.             foreach ($qry as $existing) {
  4074.                 $em->remove($existing);
  4075.             }
  4076.             $em->flush();
  4077.             foreach ($nocApprovalSett as $key => $nocAppsett) {
  4078.                 if ($nocAppsett['designation'] == "")
  4079.                     continue;
  4080.                 $approval = new Approval();
  4081.                 $approval->setEntity($entity);
  4082.                 $approval->setEntityId($entity_id);
  4083.                 $approval->setPositionId(1);
  4084.                 $approval->setSequence(++$key);
  4085.                 $approval->setSkipPrintFlag(0);
  4086.                 $approval->setUserAssignType(1);
  4087.                 $approval->setDocumentHash($documentHash);
  4088.                 $approval->setRoleType(5);
  4089.                 $approval->setRequired(1);
  4090.                 $approval->setSuccession(0);
  4091.                 $approval->setAction(3);
  4092.                 $approval->setCurrent(GeneralConstant::CURRENTLY_NON_PENDING_APPROVAL);
  4093.                 $approval->setSuccessionTimeout('');
  4094.                 $em->persist($approval);
  4095.                 $em->flush();
  4096.                 $userList Users::UserListByPositionForApprovalAssign(''$nocAppsett['designation'], $em);
  4097.                 $approval->setUserIds(json_encode($userList));
  4098.                 if (++$key $lowest_seq && in_array(1, [12])) {
  4099.                     $lowest_seq = ++$key;
  4100.                     $lowest_data $approval;
  4101.                 }
  4102.             }
  4103.             $fully_approved self::fullyApproved($em$entity$doc->getId(), $skipApprovalAction);
  4104.             $currentApprovalData = array(
  4105.                 'userIdList' => []
  4106.             );
  4107.             if ($fully_approved == 0) {
  4108.                 $lowest_data->setCurrent(GeneralConstant::CURRENTLY_PENDING_APPROVAL);
  4109.                 $sto $lowest_data->getSuccessionTimeout();
  4110.                 if ($sto != '' && $sto != null) {
  4111.                     $expire_time = new \DateTimeImmutable();
  4112.                     $expire_time $expire_time->modify('+' $sto ' hour');
  4113.                     $lowest_data->setSuccessionExpire($expire_time);
  4114.                 }
  4115.                 $em->flush();
  4116.                 $currentApprovalData['userIdList'] = json_decode($lowest_data->getUserIds(), true);
  4117.                 $notification_enabled 0;
  4118.                 $notification_server '';
  4119.                 $appId 0;
  4120.                 $url '';
  4121.                 if (!empty($options)) {
  4122.                     $notification_enabled $options['notification_enabled'];
  4123.                     $notification_server $options['notification_server'];
  4124.                     $appId $options['appId'];
  4125.                     $url $options['url'];
  4126.                 }
  4127.                 if (!empty($currentApprovalData['UserIdList']) && $notification_enabled == 1)
  4128.                     System::AddNewNotification(
  4129.                         $notification_enabled,
  4130.                         $notification_server,
  4131.                         $appId,
  4132.                         $doc->getCompanyId(),
  4133.                         "Approval: " GeneralConstant::$Entity_list_details[$entity]['entity_alias'] . ": " $documentHash " is pending Your approval",
  4134.                         'user',
  4135.                         $currentApprovalData['UserIdList'],
  4136.                         'information',
  4137.                         $url "/" $entity,
  4138.                         "Approval Pending"
  4139.                     );
  4140.             }
  4141.             return $currentApprovalData;
  4142.         }
  4143.     }
  4144. }