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

/*
Module Name: Staff Declaration (Gift Disclosure)
Description: INCEIF Gift Disclosure Form with file upload and PDF export
Version: 1.0.0
Requires at least: 3.4.*
*/

define('STAFF_DECLARATION_MODULE_NAME', 'staff_declaration');

hooks()->add_action('admin_init', 'staff_declaration_init_menu_items');
hooks()->add_action('admin_init', 'staff_declaration_register_permissions');

register_activation_hook(STAFF_DECLARATION_MODULE_NAME, 'staff_declaration_module_activation_hook');
register_uninstall_hook(STAFF_DECLARATION_MODULE_NAME, 'staff_declaration_module_uninstall_hook');

function staff_declaration_module_activation_hook()
{
    $CI = &get_instance();
    require_once(__DIR__ . '/install.php');
}

function staff_declaration_module_uninstall_hook()
{
    $CI = &get_instance();
    require_once(__DIR__ . '/uninstall.php');
}

function staff_declaration_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'),
        'approve'  => 'Approve (CEO/PCEO)',
    ];

    // Register module permissions group
    register_staff_capabilities('staff_declaration', $capabilities, _l('staff_declaration'));
}

function staff_declaration_init_menu_items()
{
    $CI = &get_instance();
 if (staff_can('create', 'staff_declaration')){
    // Language strings come from module language file
    $CI->app_menu->add_sidebar_menu_item('staff_declaration', [
        'name'     => _l('annual_declaration'),
        //'href'     => admin_url('staff_declaration'),
        'position' => 2,
        'icon'     => 'fa fa-pencil-square',
        'badge'    => [],
    ]);
    $CI->app_menu->add_sidebar_menu_item('new_declaration', [
        'name'     => _l('new_adhoc_declaration'),
        //'href'     => admin_url('staff_declaration'),
        'position' => 2,
        'icon'     => 'fa fa-pencil-square',
        'badge'    => [],
    ]);

    $CI->app_menu->add_sidebar_children_item('new_declaration', [
            'slug'     => 'staff_declaration',
            'name'     => _l('staff_declaration'),
            'href'     => admin_url('staff_declaration'),
            'position' => 3,
            'badge'    => [],
        ]);
}

if(is_admin()){
         $CI->app_menu->add_sidebar_menu_item('notification_setting', [
        
            'name'     => _l('notification_setting'),
            'href'     => admin_url('gift_policy_statement/settings'),
            'position' => 13, 
            'icon'     => 'fa fa-envelope',
        ]);
    }
}
// Load module language file
register_language_files(STAFF_DECLARATION_MODULE_NAME, ['staff_declaration']);
