# get menu items and store

public function getControllersAndMethods()
   {
       $this->db->select('cl.id as controller_id, cl.controller_name, cl.controller_alias, cl.controller_desc, ml.id as method_id, ml.method_name, ml.method_alias, ml.method_desc');
       $this->db->from('controller_list cl');
       $this->db->join('method_list ml', 'ml.controller_id = cl.id', 'left');
       $this->db->order_by('cl.controller_name', 'ASC');
       $this->db->order_by('ml.method_alias', 'ASC');
       return $this->db->get()->result_array();
   }


   public function storeController($params)
   {
       $this->db->insert('menus', $params);
       return $this->db->insert_id();
   }


   public function storeAction($params)
   {
       $this->db->insert('menu_actions', $params);
       return $this->db->insert_id();
   }


   public function updateGroupsAndTitles($params)
   {
       foreach ($params as $controller => $group) {
           // Fetch menu record for this controller
           $row = $this->db->get_where('menus', ['controller' => $controller])->row_array();


           // Only proceed if menu exists
           if (!empty($row) && isset($row['id'])) {
               // Update menu group
               $this->db->where('id', $row['id'])
                   ->update('menus', ['menu_group_id' => $group['group_id'], 'is_visible' => 1]);


               // Update menu action title
               $this->db->where([
                   'menu_id' => $row['id'],
                   'action'  => $group['menus']['action']
               ])
                   ->update('menu_actions', ['title' => $group['menus']['title'], 'is_visible' => 1]);
           }
       }
   }


# Array for existing menu items with group and title
public function role_cm()
    {
        $groups = [
            'user' => '2',
            'role' => '2',
            'department' => '2',
            'center_location' => '2',
            'designation_master' => '2',
            'company_master' => '2',
            'company_bank_account' => '2',
            'user_terminate_reason' => '2',
            'logs' => '3',
            'waiver' => '5',
            'client_permission_requests' => '5',
            'sale_adjustment_permission_requests' => '5',
            'lead_permission_requests' => '5',
            'visa_permission_requests' => '5',
            'visa_tasks' => '6',
            'general_tasks' => '6',
            'reminders' => '6',
            'personal_notes' => '6',
            'client_directory' => '7',
            'client_profile_element_deleted_history' => '7',
            'client_requests' => '7',
            'lead_complaints' => '7',
            'lead_feedbacks' => '7',
            'complaint_subject' => '7',
            'request_subject' => '7',
            'feedback_topic' => '7',
            'direct_lead' => '8',
            'affiliate_lead' => '8',
            'manual_lead' => '8',
            'bulk_leads' => '8',
            'lead_sales_ql_bucket' => '9',
            'lead_created_by_me' => '9',
            'lead_other_ql_bucket' => '9',
            'lead_pre_bucket' => '9',
            'lead_walkin_enquiry' => '9',
            'lead_walkin_enquiry_created_me' => '9',
            'lead_incoming_call_enquiry' => '9',
            'lead_incoming_call_enquiry_created_me' => '9',
            'lead_walkin_logs' => '9',
            'lead_incoming_call_logs' => '9',
            'lead_assigned_to_me' => '10',
            'lead_assigned_to_branch' => '10',
            'lead_assigned_to_department' => '10',
            'lead_assignment_history' => '10',
            'lead_followup_upcoming' => '11',
            'lead_followup_history' => '11',
            'lead_followup_missed' => '11',
            'lead_grouplist' => '12',
            'lead_settings' => '12',
            'groups_master' => '12',
            'lead_list' => '12',
            'tags_master' => '12',
            'purposes_master' => '12',
            'source_master' => '12',
            'lead_campaign_master' => '12',
            'subject_master' => '12',
            'academy_package_sales' => '13',
            'academy_package_transactions' => '13',
            'academy_package_payment_requests' => '13',
            'academy_package_active_dues' => '13',
            'academy_package_irrecoverable_dues' => '13',
            'academy_package_wallet_refunds' => '13',
            'visa_service_package_sales' => '14',
            'visa_service_package_addon_transactions' => '14',
            'visa_service_package_transactions' => '14',
            'visa_service_package_payment_requests' => '14',
            'visa_service_package_active_dues' => '14',
            'visa_service_package_irrecoverable_dues' => '14',
            'visa_service_package_wallet_refunds' => '14',
            'all_exam_bookings' => '15',
            'exam_booking_transactions' => '15',
            'exam_booking_payment_requests' => '15',
            'exam_booking_wallet_refunds' => '15',
            'event_sales' => '16',
            'event_transactions' => '16',
            'event_payment_requests' => '16',
            'event_wallet_refunds' => '16',
            'cancelled_at_checkout' => '17',
            'Logs_payment_gateway' => '17',
            'Logs_payout' => '17',
            'logs_settlement' => '17',
            'transactions' => '17',
            'all_visa_addon_transactions' => '17',
            'classroom' => '18',
            'online_class_schedule' => '18',
            'recorded_lecture' => '18',
            'classroom_documents' => '18',
            'classroom_announcement' => '18',
            'mock_test_registrations' => '18',
            'batch_master' => '18',
            'class_topic_master' => '18',
            'content_type_master' => '18',
            'visa_assessment_cases' => '19',
            'visa_pre_enrolled_cases' => '19',
            'visa_admission_cases' => '19',
            'visa_filing_cases' => '19',
            'visa_sop_cases' => '19',
            'visa_ssa_cases' => '19',
            'visa_case_iteration_request' => '19',
            'visa_case_followups' => '19',
            'visa_case_upcoming_followups' => '19',
            'visa_case_missed_followups' => '19',
            'visa_case_verification_required' => '19',
            'courses_master' => '20',
            'institute' => '20',
            'bulkupload' => '20',
            'bulkupload_update' => '20',
            'country_condition' => '20',
            'academy_master' => '20',
            'academy_proficiency_scoring' => '20',
            'academy_grade' => '20',
            'masteragent' => '21',
            'b2b_affiliate_accounts' => '21',
            'tickets' => '21',
            'b2b_enquiry' => '21',
            'academy_associate_sale_requests' => '21',
            'visa_associate_sale_requests' => '21',
            'liasioning_master' => '21',
            'b2b_account_manager_details_master' => '21',
            'online_package' => '22',
            'offline_package' => '22',
            'practice_packages' => '22',
            'Package_addon' => '22',
            'course_type' => '22',
            'online_reality_test' => '23',
            'offline_reality_test' => '23',
            'reality_test_registrations' => '23',
            'events' => '24',
            'event_type' => '24',
            'visa_service_package_master' => '25',
            'visa_service_master' => '25',
            'visa_sub_category_master' => '25',
            'visa_case_type_master' => '25',
            'test_module' => '26',
            'programe_master' => '26',
            'category_master' => '26',
            'language_proficiency_scoring' => '26',
            'language_grade' => '26',
            'score_explanation' => '26',
            'board_master' => '27',
            'courses_studylevel' => '27',
            'courses_stream' => '27',
            'course_sub_stream' => '27',
            'qualification_master' => '27',
            'subject_master' => '27',
            'grade_master' => '27',
            'profession_master' => '27',
            'industry_type' => '27',
            'invoice_setting' => '28',
            'sales_setting' => '28',
            'tax_master' => '28',
            'promo_codes' => '28',
            'payment_mode_master' => '28',
            'payment_label_master' => '28',
            'visa_enrollment_type_master' => '28',
            'exam_fee_master' => '28',
            'hold_reason' => '28',
            'refund_reason' => '28',
            'terminate_reason' => '28',
            'visa_category_master' => '29',
            'visa_refusal_reason' => '29',
            'gap_reason_master' => '29',
            'source_of_income' => '29',
            'financial_type' => '29',
            'visa_status_change_reason' => '29',
            'application_fee_payment_mode' => '29',
            'offer_letter_response' => '29',
            'custom_data_sets' => '30',
            'custom_fields' => '30',
            'custom_form_sections' => '30',
            'custom_map_forms' => '30',
            'custom_checklists' => '30',
            'visa_pipeline_stages' => '30',
            'custom_pipeline_stages' => '30',
            'custom_pipeline_workflow' => '30',
            'document_category' => '30',
            'document_type' => '30',
            'case_specific_document_set' => '30',
            'visa_case_application_stage_setting' => '30',
            'visa_case_co_applicant_setting' => '30',
            'visa_case_application_stage_optional_sets' => '30',
            'custom_global_checklists' => '30',
            'lead_settings' => '31',
            'assignee_work_resolution' => '32',
            'task_priority_level' => '32',
            'country' => '33',
            'state' => '33',
            'city' => '33',
            'outhouse_locations' => '33',
            'exam_location_master' => '33',
            'offers' => '34',
            'textual_testimonials' => '34',
            'our_products' => '34',
            'accolades_and_associations' => '34',
            'tv_shows' => '34',
            'faq_master' => '34',
            'faq_master_category' => '34',
            'faq_master_topics' => '34',
            'posts' => '34',
            'test_prep_materials' => '34',
            'news' => '34',
            'post_news_prep_category' => '34',
            'post_news_prep_subcategory' => '34',
            'page_tab_contents' => '34',
            'related_content' => '34',
            'page_text' => '34',
            'contacts' => '34',
            'university_logos' => '34',
            'web_media' => '34',
            'web_media_category' => '34',
            'web_banner' => '34',
            'usp_count' => '34',
            'usp' => '34',
            'usp_text_description' => '34',
            'checkout_terms_condition' => '34',
            'marketing_popups' => '34',
            'seo_settings' => '34',
            'document_review_status' => '35',
            'followup_response_master' => '35',
            'language_master' => '35',
            'time_slot_master' => '35',
            'app_splash_banner' => '36',
            'app_splash_company_info' => '36',
            'quote_master' => '37',
            'release_notes' => '37',
            'gallery' => '37',
            'employee_documents' => '37',
        ];

        $array = [
[
                'controller' => 'employee_list',
                'group_id' => '2',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Employees',
                ]
            ],
            [
                'controller' => 'role',
                'group_id' => '2',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Access Role',
                ]
            ],
            [
                'controller' => 'department',
                'group_id' => '2',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Departments',
                ]
            ],
            [
                'controller' => 'center_location',
                'group_id' => '2',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Branches / Independent Bodies',
                ]
            ],
            [
                'controller' => 'designation_master',
                'group_id' => '2',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Designations',
                ]
            ],
            [
                'controller' => 'company_master',
                'group_id' => '2',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Sub-Companies',
                ]
            ],
            [
                'controller' => 'company_bank_account',
                'group_id' => '2',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Company Bank Accounts',
                ]
            ],
            [
                'controller' => 'user_terminate_reason',
                'group_id' => '2',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Employee Terminate Reasons Master',
                ]
            ],
            [
                'controller' => 'user',
                'group_id' => '3',
                'menus' => [
                    'action' => 'user_activity_report',
                    'title' => 'User Activity Logs',
                ]
            ],
            [
                'controller' => 'logs',
                'group_id' => '3',
                'menus' => [
                    'action' => 'sms',
                    'title' => 'SMS Logs',
                ]
            ],
            [
                'controller' => 'logs',
                'group_id' => '3',
                'menus' => [
                    'action' => 'email',
                    'title' => 'Email Logs',
                ]
            ],
            [
                'controller' => 'business_metrics_report',
                'group_id' => '4',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Business Metrics Report',
                ]
            ],
            [
                'controller' => 'live_visa_case_pipeline_summary',
                'group_id' => '4',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Live Pipeline Summary',
                ]
            ],
            [
                'controller' => 'waiver',
                'group_id' => '5',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Waiver Permissions',
                ]
            ],
            [
                'controller' => 'sale_adjustment_permission_requests',
                'group_id' => '5',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Sale Adjustment Permissions',
                ]
            ],
            [
                'controller' => 'lead_permission_requests',
                'group_id' => '5',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Lead Permissions',
                ]
            ],
            [
                'controller' => 'visa_permission_requests',
                'group_id' => '5',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Permissions',
                ]
            ],
            [
                'controller' => 'visa_tasks',
                'group_id' => '6',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Case Tasks',
                ]
            ],
            [
                'controller' => 'general_tasks',
                'group_id' => '6',
                'menus' => [
                    'action' => 'index',
                    'title' => 'General Tasks',
                ]
            ],
            [
                'controller' => 'reminders',
                'group_id' => '6',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Reminders',
                ]
            ],
            [
                'controller' => 'personal_notes',
                'group_id' => '6',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Personal Notes',
                ]
            ],
            [
                'controller' => 'client_directory',
                'group_id' => '7',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Client Directory',
                ]
            ],
            [
                'controller' => 'client_profile_element_deleted_history',
                'group_id' => '7',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Client Profile Element Deleted History',
                ]
            ],
            [
                'controller' => 'client_requests',
                'group_id' => '7',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Client Requests',
                ]
            ],
            [
                'controller' => 'lead_complaints',
                'group_id' => '7',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Client Complaints',
                ]
            ],
            [
                'controller' => 'lead_feedbacks',
                'group_id' => '7',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Client Feedbacks',
                ]
            ],
            [
                'controller' => 'complaint_subject',
                'group_id' => '7',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Complaint Subject Master',
                ]
            ],
            [
                'controller' => 'request_subject',
                'group_id' => '7',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Client Request Subject Master',
                ]
            ],
            [
                'controller' => 'feedback_topic',
                'group_id' => '7',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Feedback Topic Master',
                ]
            ],
            [
                'controller' => 'direct_lead',
                'group_id' => '8',
                'menus' => [
                    'action' => 'add_walkin',
                    'title' => 'Add Walkin',
                ]
            ],
            [
                'controller' => 'direct_lead',
                'group_id' => '8',
                'menus' => [
                    'action' => 'add_incoming_call',
                    'title' => 'Add Incoming Call',
                ]
            ],
            [
                'controller' => 'affiliate_lead',
                'group_id' => '8',
                'menus' => [
                    'action' => 'add_affiliate_lead',
                    'title' => 'Add Affiliate Lead',
                ]
            ],
            [
                'controller' => 'manual_lead',
                'group_id' => '8',
                'menus' => [
                    'action' => 'add_single_lead',
                    'title' => 'Add Reference Lead',
                ]
            ],
            [
                'controller' => 'bulk_leads',
                'group_id' => '8',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Bulk Leads',
                ]
            ],
            [
                'controller' => 'repurpose_lead',
                'group_id' => '8',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Repurpose Leads',
                ]
            ],
            [
                'controller' => 'lead_sales_ql_bucket',
                'group_id' => '9',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Primary Leads Bucket',
                ]
            ],
            [
                'controller' => 'lead_created_by_me',
                'group_id' => '9',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Leads Created by Me',
                ]
            ],
            [
                'controller' => 'lead_other_ql_bucket',
                'group_id' => '9',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Other Leads Bucket',
                ]
            ],
            [
                'controller' => 'lead_pre_bucket',
                'group_id' => '9',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Pre Leads Bucket',
                ]
            ],
            [
                'controller' => 'lead_walkin_enquiry',
                'group_id' => '9',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All Walkin Enquiry List',
                ]
            ],
            [
                'controller' => 'lead_walkin_enquiry_created_me',
                'group_id' => '9',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Walkins Created by Me',
                ]
            ],
            [
                'controller' => 'lead_incoming_call_enquiry',
                'group_id' => '9',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All Incoming Calls Enquiry List',
                ]
            ],
            [
                'controller' => 'lead_incoming_call_enquiry_created_me',
                'group_id' => '9',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Incoming Calls Created by Me',
                ]
            ],
            [
                'controller' => 'lead_walkin_logs',
                'group_id' => '9',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All Walkin Logs',
                ]
            ],
            [
                'controller' => 'lead_incoming_call_logs',
                'group_id' => '9',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All Incoming Call Logs',
                ]
            ],
            [
                'controller' => 'lead_assigned_to_me',
                'group_id' => '10',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All Leads Assigned to Me',
                ]
            ],
            [
                'controller' => 'lead_assigned_to_branch',
                'group_id' => '10',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All Leads Assigned to Branch',
                ]
            ],
            [
                'controller' => 'lead_assigned_to_department',
                'group_id' => '10',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All Leads Assigned to Department',
                ]
            ],
            [
                'controller' => 'lead_assignment_history',
                'group_id' => '10',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Leads Assignment History',
                ]
            ],
            [
                'controller' => 'lead_followup_upcoming',
                'group_id' => '11',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Upcoming Lead Followups',
                ]
            ],
            [
                'controller' => 'lead_followup_missed',
                'group_id' => '11',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Missed Lead Followups',
                ]
            ],
            [
                'controller' => 'lead_followup_history',
                'group_id' => '11',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Leads Followups History',
                ]
            ],
            [
                'controller' => 'lead_grouplist',
                'group_id' => '12',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Lead Multiple Actions',
                ]
            ],
            [
                'controller' => 'lead_settings',
                'group_id' => '12',
                'menus' => [
                    'action' => 'academy_funnel_settings',
                    'title' => 'Academy Leads Funnel Settings',
                ]
            ],
            [
                'controller' => 'lead_settings',
                'group_id' => '12',
                'menus' => [
                    'action' => 'visa_funnel_settings',
                    'title' => 'Visa Leads Funnel Settings',
                ]
            ],
            [
                'controller' => 'groups_master',
                'group_id' => '12',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Lead Group Master',
                ]
            ],
            [
                'controller' => 'lead_list',
                'group_id' => '12',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Lead Lists Master',
                ]
            ],
            [
                'controller' => 'tags_master',
                'group_id' => '12',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Lead Tags Master',
                ]
            ],
            [
                'controller' => 'purposes_master',
                'group_id' => '12',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Lead Purpose Master',
                ]
            ],
            [
                'controller' => 'source_master',
                'group_id' => '12',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Lead Source Master',
                ]
            ],
            [
                'controller' => 'lead_campaign_master',
                'group_id' => '12',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Lead Campaign Master',
                ]
            ],
            [
                'controller' => 'general_assistance_subjects',
                'group_id' => '12',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Lead General Assistance Subject Master',
                ]
            ],
            [
                'controller' => 'academy_package_sales',
                'group_id' => '13',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Academy Package Sales',
                ]
            ],
            [
                'controller' => 'academy_package_transactions',
                'group_id' => '13',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Academy Package Transactions',
                ]
            ],
            [
                'controller' => 'academy_package_payment_requests',
                'group_id' => '13',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Academy Payment Requests',
                ]
            ],
            [
                'controller' => 'academy_package_active_dues',
                'group_id' => '13',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Academy Active Dues',
                ]
            ],
            [
                'controller' => 'academy_package_irrecoverable_dues',
                'group_id' => '13',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Academy Irrecoverable Dues',
                ]
            ],
            [
                'controller' => 'academy_package_wallet_refunds',
                'group_id' => '13',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Academy Wallet Refunds',
                ]
            ],
            [
                'controller' => 'visa_service_package_sales',
                'group_id' => '14',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Services Package Sales',
                ]
            ],
            [
                'controller' => 'visa_service_package_transactions',
                'group_id' => '14',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Services Package Transactions',
                ]
            ],
            [
                'controller' => 'visa_service_package_addon_transactions',
                'group_id' => '14',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Services Package Addon Transactions',
                ]
            ],
            [
                'controller' => 'visa_service_package_payment_requests',
                'group_id' => '14',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Services Payment Requests',
                ]
            ],
            [
                'controller' => 'visa_service_package_active_dues',
                'group_id' => '14',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Services Active Dues',
                ]
            ],
            [
                'controller' => 'visa_service_package_irrecoverable_dues',
                'group_id' => '14',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Services Irrecoverable Dues',
                ]
            ],
            [
                'controller' => 'visa_service_package_wallet_refunds',
                'group_id' => '14',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Services Wallet Refunds',
                ]
            ],
            [
                'controller' => 'all_exam_bookings',
                'group_id' => '15',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All Exam Bookings',
                ]
            ],
            [
                'controller' => 'exam_booking_transactions',
                'group_id' => '15',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Exam Booking Package Transactions',
                ]
            ],
            [
                'controller' => 'exam_booking_payment_requests',
                'group_id' => '15',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Exam Booking Payment Requests',
                ]
            ],
            [
                'controller' => 'exam_booking_wallet_refunds',
                'group_id' => '15',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Exam Booking Wallet Refunds',
                ]
            ],
            [
                'controller' => 'event_sales',
                'group_id' => '16',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All Events Bookings',
                ]
            ],
            [
                'controller' => 'event_transactions',
                'group_id' => '16',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Event Package Transactions',
                ]
            ],
            [
                'controller' => 'event_payment_requests',
                'group_id' => '16',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Event Client Payment Requests',
                ]
            ],
            [
                'controller' => 'event_wallet_refunds',
                'group_id' => '16',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Event Wallet Refunds',
                ]
            ],
            [
                'controller' => 'cancelled_at_checkout',
                'group_id' => '17',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Cancelled At Checkout',
                ]
            ],
            [
                'controller' => 'logs_payment_gateway',
                'group_id' => '17',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Gateway Transactions Logs',
                ]
            ],
            [
                'controller' => 'logs_payout',
                'group_id' => '17',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Gateway Payouts Logs',
                ]
            ],
            [
                'controller' => 'logs_settlement',
                'group_id' => '17',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Gateway Settlements Logs',
                ]
            ],
            [
                'controller' => 'transactions',
                'group_id' => '17',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All ERP Main Sale Transactions',
                ]
            ],
            [
                'controller' => 'all_visa_addon_transactions',
                'group_id' => '17',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All ERP Addon Sale Transactions',
                ]
            ],
            [
                'controller' => 'unprocessed_transactions',
                'group_id' => '17',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Unprocessed Transactions',
                ]
            ],
            [
                'controller' => 'classroom',
                'group_id' => '18',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All Classrooms',
                ]
            ],
            [
                'controller' => 'online_class_schedule',
                'group_id' => '18',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All Classrooms Schedules',
                ]
            ],
            [
                'controller' => 'recorded_lecture',
                'group_id' => '18',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All Recorded Lectures',
                ]
            ],
            [
                'controller' => 'classroom_documents',
                'group_id' => '18',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All Shared Materials',
                ]
            ],
            [
                'controller' => 'classroom_announcement',
                'group_id' => '18',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All Classrooms Announcements',
                ]
            ],
            [
                'controller' => 'mock_test_registrations',
                'group_id' => '18',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Mock Test Reports',
                ]
            ],
            [
                'controller' => 'batch_master',
                'group_id' => '18',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Classroom Batch Master',
                ]
            ],
            [
                'controller' => 'class_topic_master',
                'group_id' => '18',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Classroom Class Topics',
                ]
            ],
            [
                'controller' => 'content_type_master',
                'group_id' => '18',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Shared Material Content Types',
                ]
            ],
            [
                'controller' => 'visa_assessment_cases',
                'group_id' => '19',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Assessment Cases',
                ]
            ],
            [
                'controller' => 'visa_pre_enrolled_cases',
                'group_id' => '19',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Pre-Enrolled Cases',
                ]
            ],
            [
                'controller' => 'visa_admission_cases',
                'group_id' => '19',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Admission Cases',
                ]
            ],
            [
                'controller' => 'visa_filing_cases',
                'group_id' => '19',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Filing Cases',
                ]
            ],
            [
                'controller' => 'visa_sop_cases',
                'group_id' => '19',
                'menus' => [
                    'action' => 'index',
                    'title' => 'SOP Cases',
                ]
            ],
            [
                'controller' => 'visa_ssa_cases',
                'group_id' => '19',
                'menus' => [
                    'action' => 'index',
                    'title' => 'SSA Cases',
                ]
            ],
            [
                'controller' => 'visa_case_iteration_request',
                'group_id' => '19',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Case Iteration Logs',
                ]
            ],
            [
                'controller' => 'visa_case_followups',
                'group_id' => '19',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Case All Followups',
                ]
            ],
            [
                'controller' => 'visa_case_upcoming_followups',
                'group_id' => '19',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Case Upcoming Followups',
                ]
            ],
            [
                'controller' => 'visa_case_missed_followups',
                'group_id' => '19',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Case Missed Followups',
                ]
            ],
            [
                'controller' => 'visa_case_verification_required',
                'group_id' => '19',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Case Verification Required',
                ]
            ],
            [
                'controller' => 'courses_master',
                'group_id' => '20',
                'menus' => [
                    'action' => 'searchdatabase',
                    'title' => 'Search Course Database',
                ]
            ],
            [
                'controller' => 'courses_master',
                'group_id' => '20',
                'menus' => [
                    'action' => 'searchdatabasereview',
                    'title' => 'Review Final Courses',
                ]
            ],
            [
                'controller' => 'courses_master',
                'group_id' => '20',
                'menus' => [
                    'action' => 'index',
                    'title' => 'All Course Listing',
                ]
            ],
            [
                'controller' => 'institute',
                'group_id' => '20',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Institutes Listing',
                ]
            ],
            [
                'controller' => 'bulkupload',
                'group_id' => '20',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Add Bulk Courses',
                ]
            ],
            [
                'controller' => 'bulkupload_update',
                'group_id' => '20',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Bulk Update Courses',
                ]
            ],
            [
                'controller' => 'country_condition',
                'group_id' => '20',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Country Condition',
                ]
            ],
            [
                'controller' => 'academy_master',
                'group_id' => '20',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Academy Criteria Master',
                ]
            ],
            [
                'controller' => 'academy_proficiency_scoring',
                'group_id' => '20',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Academy Criteria Scoring',
                ]
            ],
            [
                'controller' => 'academy_grade',
                'group_id' => '20',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Academy Criteria Grades',
                ]
            ],
            [
                'controller' => 'masteragent',
                'group_id' => '21',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Master Agents',
                ]
            ],
            [
                'controller' => 'b2b_affiliate_accounts',
                'group_id' => '21',
                'menus' => [
                    'action' => 'index',
                    'title' => 'B2B Affiliates',
                ]
            ],
            [
                'controller' => 'tickets',
                'group_id' => '21',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Affiliates Support Tickets',
                ]
            ],
            [
                'controller' => 'b2b_enquiry',
                'group_id' => '21',
                'menus' => [
                    'action' => 'index',
                    'title' => 'B2B Affiliation Enquiries',
                ]
            ],
            [
                'controller' => 'academy_associate_sale_requests',
                'group_id' => '21',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Academy Associate Sale Requests',
                ]
            ],
            [
                'controller' => 'visa_associate_sale_requests',
                'group_id' => '21',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Associate Sale Requests',
                ]
            ],
            [
                'controller' => 'liasioning_master',
                'group_id' => '21',
                'menus' => [
                    'action' => 'index',
                    'title' => 'B2B Updates',
                ]
            ],
            [
                'controller' => 'b2b_account_manager_details_master',
                'group_id' => '21',
                'menus' => [
                    'action' => 'index',
                    'title' => 'B2B Account Manager Details Master',
                ]
            ],
            [
                'controller' => 'online_package',
                'group_id' => '22',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Online Packages',
                ]
            ],
            [
                'controller' => 'offline_package',
                'group_id' => '22',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Inhouse Packages',
                ]
            ],
            [
                'controller' => 'practice_packages',
                'group_id' => '22',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Practice Packs',
                ]
            ],
            [
                'controller' => 'package_addon',
                'group_id' => '22',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Academy Sales Package Addon',
                ]
            ],
            [
                'controller' => 'course_type',
                'group_id' => '22',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Course Type Master',
                ]
            ],
            [
                'controller' => 'online_reality_test',
                'group_id' => '23',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Online Reality Tests',
                ]
            ],
            [
                'controller' => 'offline_reality_test',
                'group_id' => '23',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Offline Reality Tests',
                ]
            ],
            [
                'controller' => 'reality_test_registrations',
                'group_id' => '23',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Reality Tests Scores & Registrations',
                ]
            ],
            [
                'controller' => 'events',
                'group_id' => '24',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Events Listing',
                ]
            ],
            [
                'controller' => 'event_type',
                'group_id' => '24',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Event Type',
                ]
            ],
            [
                'controller' => 'visa_service_package_master',
                'group_id' => '25',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Service Packages',
                ]
            ],
            [
                'controller' => 'visa_service_master',
                'group_id' => '25',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Service Country Mapping',
                ]
            ],
            [
                'controller' => 'visa_sub_category_master',
                'group_id' => '25',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Service Sub-Category',
                ]
            ],
            [
                'controller' => 'visa_case_type_master',
                'group_id' => '25',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Services Case Type',
                ]
            ],
            [
                'controller' => 'visa_sales_package_addons',
                'group_id' => '25',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Sales Package Addon',
                ]
            ],
            [
                'controller' => 'test_module',
                'group_id' => '26',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Language Proficiency Courses',
                ]
            ],
            [
                'controller' => 'programe_master',
                'group_id' => '26',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Language Proficiency Programs',
                ]
            ],
            [
                'controller' => 'category_master',
                'group_id' => '26',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Language Proficiency Category',
                ]
            ],
            [
                'controller' => 'language_proficiency_scoring',
                'group_id' => '26',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Language Proficiency Scoring',
                ]
            ],
            [
                'controller' => 'language_grade',
                'group_id' => '26',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Language Proficiency Grades',
                ]
            ],
            [
                'controller' => 'score_explanation',
                'group_id' => '26',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Language Proficiency Score Explanation',
                ]
            ],
            [
                'controller' => 'board_master',
                'group_id' => '27',
                'menus' => [
                    'action' => 'index',
                    'title' => '10th / 12th Boards',
                ]
            ],
            [
                'controller' => 'courses_studylevel',
                'group_id' => '27',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Study Level',
                ]
            ],
            [
                'controller' => 'courses_stream',
                'group_id' => '27',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Broad Area of Study',
                ]
            ],
            [
                'controller' => 'course_sub_stream',
                'group_id' => '27',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Narrow Area of Study',
                ]
            ],
            [
                'controller' => 'qualification_master',
                'group_id' => '27',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Qualifications Listing',
                ]
            ],
            [
                'controller' => 'subject_master',
                'group_id' => '27',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Qualifications Subject Master',
                ]
            ],
            [
                'controller' => 'grade_master',
                'group_id' => '27',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Qualifications Grade Master',
                ]
            ],
            [
                'controller' => 'study_level_streams',
                'group_id' => '27',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Domestic Study Level Streams',
                ]
            ],
            [
                'controller' => 'profession_master',
                'group_id' => '27',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Profession Master',
                ]
            ],
            [
                'controller' => 'industry_type',
                'group_id' => '27',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Industry Type',
                ]
            ],
            [
                'controller' => 'invoice_setting',
                'group_id' => '28',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Invoice Settings',
                ]
            ],
            [
                'controller' => 'sales_setting',
                'group_id' => '28',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Sales Settings',
                ]
            ],
            [
                'controller' => 'tax_master',
                'group_id' => '28',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Tax Master',
                ]
            ],
            [
                'controller' => 'promo_codes',
                'group_id' => '28',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Discount Promo Master',
                ]
            ],
            [
                'controller' => 'payment_mode_master',
                'group_id' => '28',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Payment Mode Master',
                ]
            ],
            [
                'controller' => 'payment_label_master',
                'group_id' => '28',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Payment Label Master',
                ]
            ],
            [
                'controller' => 'visa_enrollment_type_master',
                'group_id' => '28',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Enrollment Type Master',
                ]
            ],
            [
                'controller' => 'exam_fee_master',
                'group_id' => '28',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Exam Fees Master',
                ]
            ],
            [
                'controller' => 'hold_reason',
                'group_id' => '28',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Sale Adjustment Hold Reason',
                ]
            ],
            [
                'controller' => 'refund_reason',
                'group_id' => '28',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Sale Adjustment Refund Reason',
                ]
            ],
            [
                'controller' => 'terminate_reason',
                'group_id' => '28',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Sale Adjustment Terminate Reason',
                ]
            ],
            [
                'controller' => 'bank_master',
                'group_id' => '28',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Bank Master',
                ]
            ],
            [
                'controller' => 'deduction_type_master',
                'group_id' => '28',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Deduction Type Master',
                ]
            ],
            [
                'controller' => 'vendor_master',
                'group_id' => '28',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Vendor Master',
                ]
            ],
            [
                'controller' => 'payment_transfer_medium_master',
                'group_id' => '28',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Payment Transfer Medium Master',
                ]
            ],
            [
                'controller' => 'visa_category_master',
                'group_id' => '29',
                'menus' => [
                    'action' => 'index',
                    'title' => 'External Visa Categories',
                ]
            ],
            [
                'controller' => 'visa_refusal_reason',
                'group_id' => '29',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Refusal Reasons Master',
                ]
            ],
            [
                'controller' => 'gap_reason_master',
                'group_id' => '29',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Gap Reasons Master',
                ]
            ],
            [
                'controller' => 'source_of_income',
                'group_id' => '29',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Source of Income Master',
                ]
            ],
            [
                'controller' => 'financial_type',
                'group_id' => '29',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Financial Type Master',
                ]
            ],
            [
                'controller' => 'visa_status_change_reason',
                'group_id' => '29',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Case Status Change Reasons',
                ]
            ],
            [
                'controller' => 'application_fee_payment_mode',
                'group_id' => '29',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Application Fee Payment Modes',
                ]
            ],
            [
                'controller' => 'offer_letter_response',
                'group_id' => '29',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Offer Letter Responses Master',
                ]
            ],
            [
                'controller' => 'custom_data_sets',
                'group_id' => '30',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Custom Data Sets',
                ]
            ],
            [
                'controller' => 'custom_fields',
                'group_id' => '30',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Custom Fields',
                ]
            ],
            [
                'controller' => 'custom_form_sections',
                'group_id' => '30',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Custom Form Sections',
                ]
            ],
            [
                'controller' => 'custom_map_forms',
                'group_id' => '30',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Forms and Sections Mapping',
                ]
            ],
            [
                'controller' => 'custom_checklists',
                'group_id' => '30',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Custom Checklists',
                ]
            ],
            [
                'controller' => 'custom_global_checklists',
                'group_id' => '30',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Custom Global Checklists',
                ]
            ],
            [
                'controller' => 'visa_pipeline_stages',
                'group_id' => '30',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Pipeline Master',
                ]
            ],
            [
                'controller' => 'custom_pipeline_stages',
                'group_id' => '30',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Custom Pipeline Stages',
                ]
            ],
            [
                'controller' => 'custom_pipeline_workflow',
                'group_id' => '30',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Custom Pipeline Workflow',
                ]
            ],
            [
                'controller' => 'document_category',
                'group_id' => '30',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Document Categories',
                ]
            ],
            [
                'controller' => 'document_type',
                'group_id' => '30',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Document Types',
                ]
            ],
            [
                'controller' => 'case_specific_document_set',
                'group_id' => '30',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Case Specific Document Sets',
                ]
            ],
            [
                'controller' => 'visa_case_application_stage_setting',
                'group_id' => '30',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Case Application Stage Settings',
                ]
            ],
            [
                'controller' => 'visa_case_co_applicant_setting',
                'group_id' => '30',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Case Co-applicant Settings',
                ]
            ],
            [
                'controller' => 'visa_case_application_stage_optional_sets',
                'group_id' => '30',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Visa Case Application Stage Optional Sets',
                ]
            ],
            [
                'controller' => 'lead_settings',
                'group_id' => '31',
                'menus' => [
                    'action' => 'student_info_tab_setting',
                    'title' => 'Client Info Tab Settings',
                ]
            ],
            [
                'controller' => 'lead_settings',
                'group_id' => '31',
                'menus' => [
                    'action' => 'lead_info_tab_setting',
                    'title' => 'Lead Info Tab Settings',
                ]
            ],
            [
                'controller' => 'assignee_work_resolution',
                'group_id' => '32',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Work Resolution Master',
                ]
            ],
            [
                'controller' => 'task_priority_level',
                'group_id' => '32',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Task Priority Level Master',
                ]
            ],
            [
                'controller' => 'country',
                'group_id' => '33',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Country Listing',
                ]
            ],
            [
                'controller' => 'state',
                'group_id' => '33',
                'menus' => [
                    'action' => 'index',
                    'title' => 'State Listing',
                ]
            ],
            [
                'controller' => 'city',
                'group_id' => '33',
                'menus' => [
                    'action' => 'index',
                    'title' => 'City Listing',
                ]
            ],
            [
                'controller' => 'outhouse_locations',
                'group_id' => '33',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Outhouse Locations',
                ]
            ],
            [
                'controller' => 'exam_location_master',
                'group_id' => '33',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Exam Locations',
                ]
            ],
            [
                'controller' => 'offers',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Updates',
                ]
            ],
            [
                'controller' => 'textual_testimonials',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Textual Testimonials',
                ]
            ],
            [
                'controller' => 'our_products',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Our Associations',
                ]
            ],
            [
                'controller' => 'accolades_and_associations',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Our Accolades',
                ]
            ],
            [
                'controller' => 'tv_shows',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'TV Shows',
                ]
            ],
            [
                'controller' => 'faq_master',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'FAQs',
                ]
            ],
            [
                'controller' => 'faq_master_category',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'FAQ Category',
                ]
            ],
            [
                'controller' => 'faq_master_topics',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'FAQ Topics',
                ]
            ],
            [
                'controller' => 'posts',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Posts',
                ]
            ],
            [
                'controller' => 'test_prep_materials',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Test Prep Materials',
                ]
            ],
            [
                'controller' => 'news',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'News',
                ]
            ],
            [
                'controller' => 'post_news_prep_category',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Blog Category',
                ]
            ],
            [
                'controller' => 'post_news_prep_subcategory',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Blog Sub-Category',
                ]
            ],
            [
                'controller' => 'page_tab_contents',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Page Tab Contents',
                ]
            ],
            [
                'controller' => 'related_content',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Related Page Tab Contents',
                ]
            ],
            [
                'controller' => 'page_text',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Secondary Page Text',
                ]
            ],
            [
                'controller' => 'contacts',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Contacts',
                ]
            ],
            [
                'controller' => 'university_logos',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'University Logos',
                ]
            ],
            [
                'controller' => 'web_media',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Web Media',
                ]
            ],
            [
                'controller' => 'web_media_category',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Web Media Category',
                ]
            ],
            [
                'controller' => 'web_banner',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Web Banner',
                ]
            ],
            [
                'controller' => 'usp_count',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'USP Count',
                ]
            ],
            [
                'controller' => 'usp',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'USP Text',
                ]
            ],
            [
                'controller' => 'usp_text_description',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'USP Text Description',
                ]
            ],
            [
                'controller' => 'checkout_terms_condition',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Checkout Terms & Conditions',
                ]
            ],
            [
                'controller' => 'marketing_popups',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Marketing Popup',
                ]
            ],
            [
                'controller' => 'marketing_popups_setting',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Marketing Popup Settings',
                ]
            ],
            [
                'controller' => 'seo_settings',
                'group_id' => '34',
                'menus' => [
                    'action' => 'index',
                    'title' => 'SEO Settings',
                ]
            ],
            [
                'controller' => 'document_review_status',
                'group_id' => '35',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Review Status Master',
                ]
            ],
            [
                'controller' => 'followup_response_master',
                'group_id' => '35',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Follow up Response Master',
                ]
            ],
            [
                'controller' => 'language_master',
                'group_id' => '35',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Language Master',
                ]
            ],
            [
                'controller' => 'time_slot_master',
                'group_id' => '35',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Time Slots',
                ]
            ],
            [
                'controller' => 'app_splash_banner',
                'group_id' => '36',
                'menus' => [
                    'action' => 'index',
                    'title' => 'App Splash Banner',
                ]
            ],
            [
                'controller' => 'app_splash_company_info',
                'group_id' => '36',
                'menus' => [
                    'action' => 'index',
                    'title' => 'App Splash Company Info',
                ]
            ],
            [
                'controller' => 'gallery',
                'group_id' => '37',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Media Uploads',
                ]
            ],
            [
                'controller' => 'quote_master',
                'group_id' => '37',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Admin Panel Quote Master',
                ]
            ],
            [
                'controller' => 'release_notes',
                'group_id' => '37',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Software Release Notes',
                ]
            ],
            [
                'controller' => 'employee_documents',
                'group_id' => '37',
                'menus' => [
                    'action' => 'index',
                    'title' => 'Branch-Wise Expense Upload',
                ]
            ],
        ];

        $this->load->model('Role_model');
        $list = $this->Role_model->getControllersAndMethods();
        $output = [];

        foreach ($list as $item) {
            $cid = $item['controller_id'];

            // If controller doesn't exist yet, create it
            if (!isset($output[$cid])) {
                $output[$cid] = [
                    'controller_name'  => $item['controller_name'],
                    'controller_alias' => $item['controller_alias'],
                    'controller_desc'  => $item['controller_desc'],
                    'methods'          => []
                ];
            }

            // Add method under methods array
            $output[$cid]['methods'][$item['method_id']] = [
                'method_name'  => $item['method_name'],
                'method_alias' => $item['method_alias'],
                'method_desc'  => $item['method_desc']
            ];
        }
        // pr($list, 1);
        // echo count($output) . ' controllers found.<br>';
        // pr($output, 1);
        $menuOrder = 1;
        foreach ($output as $cid => $controller) {
            $title  = strtolower(str_replace('.php', '', $controller['controller_name']));
            $item = [
                'menu_group_id' => $groups[$title] ?? 0, // Default group ID
                'controller'  => $title,
                'title' => ucwords(str_replace('_', ' ', str_replace('.php', '', $controller['controller_alias']))),
                'order_no'  => $menuOrder++,
                'is_visible' => 0,
            ];
            // pr($item);
            $id = $this->Role_model->storeController($item);
            // $id = 1;
            $actionOrder = 2;
            if (!empty($controller['methods'])) {
                foreach ($controller['methods'] as $method_id => $method) {
                    if (!empty($method['method_name'])) {
                        $methods = [
                            'menu_id' => $id,
                            'action'  => $method['method_name'],
                            'title' => ucwords(str_replace('_', ' ', $method['method_name'])),
                            'order_no'  => $actionOrder++,
                            'is_visible' => 0,
                        ];
                        // pr($methods);
                        $this->Role_model->storeAction($methods);
                    }
                }
            }
            // Sort methods by method_name
            // usort($output[$cid]['methods'], function ($a, $b) {
            //     return strcmp($a['method_name'], $b['method_name']);
            // });
        }
        // pr($output, 1);
        // pr($list, 1);
        // $this->Role_model->updateGroupsAndTitles($array);
        $order = 1;
        foreach ($array as $value) {
            $isAvail = $this->Role_model->getMenuInfo($value['controller']);
            if($isAvail){
                $update = $this->Role_model->updateMenuInfo($isAvail, $value['group_id'], $order);
                if($update){
                    pr($value);
                    $this->Role_model->updateMenuAction($isAvail, $value, $order);
                }
            }
            $order++;
        }
    }





   public function updateGroupsAndTitles($params)
   {
       $order = 0;
       foreach ($params as $controller => $group) {
           // Fetch menu record for this controller
           $query = $this->db->get_where('menus', ['controller' => $controller]);
           $row = $query->row_array();
           unset($query);
           // Only proceed if menu exists
           if (!empty($row) && isset($row['id'])) {
               // Update menu group
               $query1 = $this->db->where('id', $row['id']);
               $query1->update('menus', ['menu_group_id' => $group['group_id'], 'is_visible' => 1]);
               unset($query1);
               // Update menu action title
               $query2 = $this->db->where([
                   'menu_id' => $row['id'],
                   'action'  => $group['menus']['action']
               ]);
               $query2->update('menu_actions', ['title' => $group['menus']['title'], 'is_visible' => 1, 'order_no' => $order++]);
               unset($query2);
           }
       }
   }


   public function getMenuInfo($name)
   {
       return $this->db->get_where('menus', ['controller' => $name])->row_array();
   }


   public function updateMenuInfo($row, $group_id, $order)
   {
       $query1 = $this->db->where('id', $row['id']);
       return $query1->update('menus', ['menu_group_id' => $group_id, 'is_visible' => 1, 'order_no' => $order]);
   }


   public function updateMenuAction($row, $group, $order)
   {
       $query2 = $this->db->where([
           'menu_id' => $row['id'],
           'action'  => $group['menus']['action']
       ]);
       $query2->update('menu_actions', ['title' => $group['menus']['title'], 'is_visible' => 1, 'order_no' => $order]);
   }
# store permission for existing roles

function license_error()
   {
       $this->load->model('Role_model');
       $items = $this->Role_model->accessByRoleId(2);
       $array = [];
       foreach ($items as $item) {
           $controller = $this->Role_model->controller($item['controller_id']);
           $_item = [$controller['controller_name'] => $controller, 'methods' => $this->Role_model->methods($item['method_id'])];
           $method = $this->Role_model->methods($item['method_id']);
           $array[str_replace('.php', '', $controller['controller_name'])][] = $method['method_name'];
       }
       echo json_encode($array);
       pr($array, 1);
       pr($items, 1);
   }






   public function accessByRoleId($role_id){
       $this->db->select('*');
       $this->db->from('role_access');
       $this->db->where(['role_id'=>$role_id]);
       return $this->db->get()->result_array();
   }


   public function controller($controller_id){
       $this->db->select('*');
       $this->db->from('controller_list');
       $this->db->where(['id'=>$controller_id]);
       return $this->db->get()->row_array();
   }


   public function methods($method_id){
       $this->db->select('*');
       $this->db->from('method_list');
       $this->db->where(['id'=>$method_id]);
       return $this->db->get()->row_array();
   }



function license_error()
   {
       $this->load->model('Role_model');
       $roles = $this->Role_model->get_all_roles();
       foreach ($roles as $role) {
           $items = $this->Role_model->accessByRoleId($role['id']);
           $array = [];
           foreach ($items as $item) {
               $controller = $this->Role_model->controller($item['controller_id']);
               $method = $this->Role_model->methods($item['method_id']);
               $array[str_replace('.php', '', $controller['controller_name'])][] = $method['method_name'];
           }
           echo json_encode($array);
       }
       die('done');
   }
