<?php

function display_dashboard_inventory_filtering_parameters() {
    
    dashboard_set_from_to_months('from_month_id', 'to_month_id');
    
    start_table(TABLESTYLE, "width=25%");
        $dash_purchs_array = get_dashboard_inventory_types_array();
        custom_values_list_row("Type:", 'group_code', $dash_purchs_array, null, false, true);
        months_list_row("From Month:", 'from_month_id', null, false, true);   
        months_list_row("To Month:", 'to_month_id', null, false, true);  

        set_global_dashboard_from_month($_POST['from_month_id']);
        set_global_dashboard_to_month($_POST['to_month_id']);
    end_table(1);

    start_table(TABLESTYLE);
        start_row();
            submit_center_first('DashboardPurch', "Display", '', 'process', ICON_OK);
        end_row();
    end_table(2);
}

function get_dashboard_inventory_types_array() {
    $dash_inventory_array = array();
    
        $dash_inventory_array['MOVEMENT_TYPES'] = "Movement Types";
        $dash_inventory_array['MATERIAL_REQUISITIONS'] = "Material Requisitions";
        $dash_inventory_array['CONSUMPTION_VALUE'] = "Item Consumption (Value)";
        $dash_inventory_array['CONSUMPTION_QUANTITY'] = "Item Consumption (Quantity)";
        $dash_inventory_array['APPROVALS'] = "Approvals";
//        $dash_purchs_array['DATA_ENTRY'] = "Data Entry";
        
        return $dash_inventory_array;
}

function display_dashboard_inventory_view() {
    global $path_to_root, $Ajax;

    $from_month = get_month(get_global_dashboard_from_month());
    $to_month = get_month(get_global_dashboard_to_month());

    $Ajax->activate('uda_ddg');
        div_start('uda_ddg');

            start_table();

                switch ($_POST['group_code']) {
                    case 'MOVEMENT_TYPES':
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_inventory_movement_types_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_inventory_movement_types_db.inc"); 
                        include_once($path_to_root . "/petty_cash/includes/db/employee_petty_cash_outstanding_db.inc"); 
                        include_once($path_to_root . "/includes/db/group_companies_db.inc"); 
                        dashboard_inventory_movement_types($from_month['display_order'], $to_month['display_order']);
                        break;
                    case 'MATERIAL_REQUISITIONS': 
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_inventory_material_requisitions_view_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_inventory_material_requisitions_view_db.inc"); 
                        dashboard_display_material_requisitions_view($from_month['display_order'], $to_month['display_order']);
                        break;
                    case 'MATERIAL_REQUISITIONS': 
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_inventory_material_requisitions_view_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_inventory_material_requisitions_view_db.inc"); 
                        dashboard_display_material_requisitions_view($from_month['display_order'], $to_month['display_order']);
                        break;
                    case 'CONSUMPTION_VALUE':
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_inventory_item_consumption_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_inventory_item_consumption_db.inc"); 
                        dashboard_inventory_item_consuption($from_month['display_order'], $to_month['display_order'], 1);
                        break;
                    case 'CONSUMPTION_QUANTITY':
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_inventory_item_consumption_ui.inc");
                        include_once($path_to_root . "/dashboard/includes/db/dashboard_inventory_item_consumption_db.inc"); 
                        dashboard_inventory_item_consuption($from_month['display_order'], $to_month['display_order'], 2);
                        break;                       
                    case 'APPROVALS':
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_approvals_ui.inc");
                        include_once("$path_to_root/dashboard/includes/db/dashboard_approvals_db.inc"); 
                        include_once("$path_to_root/dashboard/includes/ui/dashboard_inventory_approvals_ui.inc");
                        include_once("$path_to_root/dashboard/includes/db/dashboard_inventory_approvals_db.inc");                         
                        dashboard_inventory_approvals($from_month['display_order'], $to_month['display_order']);
                        
                        break;
                        
                    
                        
                    default:        
                        break;
                }

            end_table(2);
        div_end();
}

?>