<?php defined('BASEPATH') or exit('No direct script access allowed');

/*
Module Name: Staff External Engagement
Description: INCEIF Staff External Engagement Form (dynamic rows, files, PDF, Excel, notifications)
Version: 1.0.0
Requires at least: 3.4.0
*/

define('STAFF_EXTERNAL_ENGAGEMENT_MODULE_NAME', 'staff_external_engagement');

hooks()->add_action('admin_init', 'see_register_permissions');
hooks()->add_action('admin_init', 'see_init_menu_items');

register_activation_hook(STAFF_EXTERNAL_ENGAGEMENT_MODULE_NAME, 'see_module_activation_hook');
register_uninstall_hook(STAFF_EXTERNAL_ENGAGEMENT_MODULE_NAME, 'see_module_uninstall_hook');

function see_module_activation_hook()
{
    require_once(__DIR__ . '/install.php');
}
function see_module_uninstall_hook()
{
    require_once(__DIR__ . '/uninstall.php');
}

function see_register_permissions()
{
    $capabilities = [];
    $capabilities['capabilities'] = [
        'view'     => _l('permission_view'),
        'view_own' => _l('permission_view_own'),
        'create'   => _l('permission_create'),
        'edit'     => _l('permission_edit'),
        'delete'   => _l('permission_delete'),
    ];

    register_staff_capabilities('staff_external_engagement', $capabilities, _l('staff_external_engagement'));
}

function see_init_menu_items()
{
    $CI = &get_instance();

    if (staff_can('view', 'staff_external_engagement') || staff_can('view_own', 'staff_external_engagement')) {
        // $CI->app_menu->add_sidebar_menu_item('staff_external_engagement', [
        //     'name'     => _l('staff_external_engagement'),
        //     'href'     => admin_url('staff_external_engagement'),
        //     'position' => 4,
        //     'icon'     => 'fa fa-briefcase',
        // ]);
        
         $CI->app_menu->add_sidebar_children_item('new_declaration', [
            'slug'     => 'staff_external_engagement',
            'name'     => _l('staff_external_engagement'),
            'href'     => admin_url('staff_external_engagement'),
            'position' => 13,
            'badge'    => [],
        ]);
    }
}

// language
register_language_files(STAFF_EXTERNAL_ENGAGEMENT_MODULE_NAME, ['staff_external_engagement']);
